aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/GraphicObject.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-15 14:58:36 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-15 14:58:36 +0100
commitc1b29a565bdbf37fd88d268588710ce8f4f84d5b (patch)
tree37ec254f01bb8d2bad971c137fa787ca76a194d1 /src/GraphicObjects/GraphicObject.cs
parent0efa7446134489edd303b349ae1220f1c4228e9a (diff)
CrowIDE WIP, context commands, tooltips, PointIsIn(ref point), configuration no longer static.
also: - remove default null value for datasource - dschange sender changed in group and privateContainer - try closing menuItem, should debug - Contains search also template in TemplatedContainer - change in nodeAddress: expresion starting with '/' means current node - MouseEventArgs CTOR with one source button - RemoveWidget trigger check HoverWidget - Orientation binding in Menu template
Diffstat (limited to 'src/GraphicObjects/GraphicObject.cs')
-rw-r--r--src/GraphicObjects/GraphicObject.cs77
1 files changed, 57 insertions, 20 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index ad02a544..ad9392b0 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -190,7 +190,8 @@ namespace Crow
bool isDragged;
bool allowDrag;
bool allowDrop;
-
+ string tooltip;
+ IList<Command> contextCommands;
#endregion
#region public fields
@@ -764,7 +765,7 @@ namespace Crow
/// Seek first logical tree upward if logicalParent is set, or seek graphic tree for
/// a not null dataSource that will be active for all descendants having dataSource=null
/// </summary>
- [XmlAttributeAttribute][DefaultValue(null)]
+ [XmlAttributeAttribute]//[DefaultValue(null)]
public virtual object DataSource {
set {
if (DataSource == value)
@@ -774,6 +775,10 @@ namespace Crow
dataSource = value;
dse.NewDataSource = DataSource;
+ //prevent setting null causing stack overflow in specific case
+ if (dse.NewDataSource == dse.OldDataSource)
+ return;
+
OnDataSourceChanged (this, dse);
NotifyValueChanged ("DataSource", DataSource);
@@ -813,7 +818,6 @@ namespace Crow
NotifyValueChanged ("Style", style);
}
}
- string tooltip;
[XmlAttributeAttribute]
public virtual string Tooltip {
get { return tooltip; }
@@ -824,6 +828,16 @@ namespace Crow
NotifyValueChanged("Tooltip", tooltip);
}
}
+ [XmlAttributeAttribute]
+ public IList<Command> ContextCommands {
+ get { return contextCommands; }
+ set {
+ if (contextCommands == value)
+ return;
+ contextCommands = value;
+ NotifyValueChanged("ContextCommands", contextCommands);
+ }
+ }
#endregion
#region Default and Style Values loading
@@ -1499,24 +1513,45 @@ namespace Crow
#endregion
#region Mouse handling
+ public virtual bool PointIsIn(ref Point m)
+ {
+ if (!(Visible & isEnabled)||IsDragged)
+ return false;
+ ILayoutable tmp = Parent;
+ //while (tmp != null){
+ if (!parent.PointIsIn(ref m))
+ return false;
+ m -= (parent.getSlot().Position + parent.ClientRectangle.Position) ;
+
+ return Slot.ContainsOrIsEqual (m);
+ }
public virtual bool MouseIsIn(Point m)
{
- try {
- if (!(Visible & isEnabled)||IsDragged)
- return false;
- if (ScreenCoordinates (Slot).ContainsOrIsEqual (m)) {
- Scroller scr = Parent as Scroller;
- if (scr == null) {
- if (Parent is GraphicObject)
- return (Parent as GraphicObject).MouseIsIn (m);
- else return true;
- }
- return scr.MouseIsIn (scr.savedMousePos);
- }
- } catch (Exception ex) {
- return false;
- }
- return false;
+ Point p = m;
+ return PointIsIn (ref m);
+// try {
+// if (!(Visible & isEnabled)||IsDragged)
+// return false;
+// ILayoutable tmp = Parent;
+// //while (tmp != null){
+// if (!parent.MouseIsIn(m))
+// return false;
+// m -= (parent.getSlot().Position + parent.ClientRectangle.Position) ;
+//
+// return slot.ContainsOrIsEqual (m);
+//// Scroller scr = tmp as Scroller;
+//// if (scr != null) {
+//// m.Y += scr.ScrollY;
+//// m.X += scr.ScrollX;
+//// }
+//// tmp = tmp.Parent;
+// //}
+//
+// //}
+// } catch (Exception ex) {
+// return false;
+// }
+ //return false;
}
public virtual void checkHoverWidget(MouseMoveEventArgs e)
{
@@ -1525,7 +1560,7 @@ namespace Crow
onMouseEnter (this, e);
}
- this.onMouseMove (this, e);//without this, window border doesn't work, should be removed
+ //this.onMouseMove (this, e);//without this, window border doesn't work, should be removed
}
public virtual void onMouseMove(object sender, MouseMoveEventArgs e)
{
@@ -1553,6 +1588,8 @@ namespace Crow
if (be.Focused == null) {
be.Focused = this;
CurrentInterface.FocusedWidget = this;
+ if (e.Button == MouseButton.Right && this.ContextCommands != null)
+ CurrentInterface.ShowContextMenu (this);
}
}
//bubble event to the top