public override void OnLeftMouseButtonDown(OverlayShapeVM item, Point p, TEMouseArgs e) { if (!EnsureParseTreeExists()) { return; } overlay.BeginUpdate(); overlay.SetCorrectRaster(overlay.CurEditing, true); //Point p = new Point(e.GetPosition(canvas1).X, Height - e.GetPosition(canvas1).Y); p = overlay.Rasterizer.RasterizePixelToTikz(p); if (ContinueWithBigImage(p) == false) { return; } // find next tikzpicture and add Parser.Tikz_Picture tpict = overlay.ParseTree.GetTikzPicture(); if (tpict != null) { Parser.Tikz_Node tn = new Parser.Tikz_Node(); tn.label = ""; tn.coord = new Parser.Tikz_Coord(); if (!String.IsNullOrEmpty(overlay.NodeStyle)) { tn.options = "[" + overlay.NodeStyle + "]"; } Parser.Tikz_Path tp = new Parser.Tikz_Path(); tp.starttag = @"\node "; tp.endtag = ";"; tp.AddChild(tn); if (overlay.CurEditing != null) { overlay.CurEditing.tikzitem.AddChild(tp); overlay.CurEditing.tikzitem.AddChild(new Parser.Tikz_Something("\r\n")); } else { tpict.AddChild(tp); tpict.AddChild(new Parser.Tikz_Something("\r\n")); } // do it here since the coordinate calculation needs the parents' coord. transform tn.SetAbsPos(new Point(p.X, p.Y)); //hack //tn.UpdateText(); tp.UpdateText(); //tpict.UpdateText(); //RedrawObjects(); // overlay.AddToDisplayTree(tp); } overlay.EndUpdate(); }
public override void OnRightMouseButtonDown(OverlayShapeVM item, Point p, TEMouseArgs e) { //base.OnRightMouseButtonDown(item, p, e); // if a node is selected, unselect it if (curSel != null) { curSel = null; e.Handled = true; // we don't want anything else to happen (contextmenu opening etc) } }
void OnButtonPress(object sender, ButtonPressEventArgs eee) { var e = eee.Event; // base.OnMouseDown(e); // this.Focus(); // todo GlobalUI.UI.AddStatusLine(this, " Press " + e.Button); if (e.Button == MouseButtonConsts.Left) { // call left down-method in the current tool var mousep = e.Location(); var oo = ObjectAtCursor; TEMouseArgs ee = e.ToTEMouseArgs(); TheOverlayModel.CurrentTool.OnLeftMouseButtonDown(oo, new System.Windows.Point(mousep.X, Height - mousep.Y), ee); //e.Handled = ee.Handled; } else if (e.Button == MouseButtonConsts.Right) { // call right down-method in the current tool var mousep = e.Location(); var oo = ObjectAtCursor; TEMouseArgs ee = e.ToTEMouseArgs(); TheOverlayModel.CurrentTool.OnRightMouseButtonDown(oo, new System.Windows.Point(mousep.X, Height - mousep.Y), ee); //e.Handled = ee.Handled; // if the tool didn't use the click-> proceed with standard handling if (!ee.Handled) { if (Tool == OverlayToolType.move) { //canvas1.ContextMenu.IsEnabled = true; if (TheOverlayModel.CurEditing != null) { TheOverlayModel.CurEditing = null; //PreventContextMenuOpening = true; } else { // right click not consumed yet -> open context menu // TheContextMenu.Popup(this, null, (x,y, out xx, out xxx)=> {e.Location}, 0,2000); // todo } } else { Tool = OverlayToolType.move; //PreventContextMenuOpening = true; } } } //return base.OnButtonPressEvent(e); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); var mousep = e.Location.ToPoint(); // convert to bottom left coordinates var p = new System.Windows.Point(mousep.X, Height - mousep.Y); TEMouseArgs ee = e.ToTEMouseArgs(); TheOverlayModel.CurrentTool.OnMouseMove(p, ee); //GlobalUI.UI.AddStatusLine(this, "mm " + mousep+" " + CursorPosition); //e.Handled = ee.Handled; }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); this.Focus(); if (e.Button.HasFlag(MouseButtons.Left)) { // call left down-method in the current tool var mousep = e.Location.ToPoint(); var oo = ObjectAtCursor; TEMouseArgs ee = e.ToTEMouseArgs(); TheOverlayModel.CurrentTool.OnLeftMouseButtonDown(oo, new System.Windows.Point(mousep.X, Height - mousep.Y), ee); //e.Handled = ee.Handled; } else if (e.Button.HasFlag(MouseButtons.Right)) { // call right down-method in the current tool var mousep = e.Location.ToPoint(); var oo = ObjectAtCursor; TEMouseArgs ee = e.ToTEMouseArgs(); TheOverlayModel.CurrentTool.OnRightMouseButtonDown(oo, new System.Windows.Point(mousep.X, Height - mousep.Y), ee); //e.Handled = ee.Handled; // if the tool didn't use the click-> proceed with standard handling if (!ee.Handled) { if (Tool == OverlayToolType.move) { //canvas1.ContextMenu.IsEnabled = true; if (TheOverlayModel.CurEditing != null) { TheOverlayModel.CurEditing = null; //PreventContextMenuOpening = true; } else { // right click not consumed yet -> open context menu TheContextMenu.Show(this, e.Location); } } else { Tool = OverlayToolType.move; //PreventContextMenuOpening = true; } } } }
void OnMotionNotify(object sender, MotionNotifyEventArgs eee) { // base.OnMouseMove(e); var e = eee.Event; var mousep = e.Location(); // convert to bottom left coordinates var p = new System.Windows.Point(mousep.X, Height - mousep.Y); TEMouseArgs ee = e.ToTEMouseArgs(); TheOverlayModel.CurrentTool.OnMouseMove(p, ee); //GlobalUI.UI.AddStatusLine(this, "mm " + mousep+" " + CursorPosition); //e.Handled = ee.Handled; //return true; }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (e.Button.HasFlag(MouseButtons.Left)) { if (MouseCaptured) { MouseCaptured = false; // release mouse capture here to make sure the tools cannot forget } var mousep = e.Location.ToPoint(); TEMouseArgs ee = e.ToTEMouseArgs(); TheOverlayModel.CurrentTool.OnLeftMouseButtonUp(new System.Windows.Point(mousep.X, Height - mousep.Y), ee); //e.Handled = ee.Handled; } else if (e.Button.HasFlag(MouseButtons.Right)) { } }
void OnButtonRelease(object sender, ButtonReleaseEventArgs eee) { var e = eee.Event; // base.OnMouseUp(e); if (e.Button == MouseButtonConsts.Left) { if (MouseCaptured) { MouseCaptured = false; // release mouse capture here to make sure the tools cannot forget } var mousep = e.Location(); TEMouseArgs ee = e.ToTEMouseArgs(); TheOverlayModel.CurrentTool.OnLeftMouseButtonUp(new System.Windows.Point(mousep.X, Height - mousep.Y), ee); //e.Handled = ee.Handled; } else if (e.Button == MouseButtonConsts.Right) { } //return true; }
public override void OnLeftMouseButtonDown(OverlayShapeVM item, Point p, TEMouseArgs e) { if (!EnsureParseTreeExists()) return; p = overlay.Rasterizer.RasterizePixelToTikz(p); if (ContinueWithBigImage(p) == false) return; overlay.BeginUpdate(); //overlay.SetCorrectRaster(overlay.CurEditing, true); UpdateRaster(); //Point p = new Point(e.GetPosition(canvas1).X, Height - e.GetPosition(canvas1).Y); // find next tikzpicture and add bool lcreated; if (EnsureCurAddToExists(out lcreated)) { // on double click -> close path if (e.ClickCount == 2) { if (!lcreated) { //if (!Keyboard.Modifiers.HasFlag(ModifierKeys.Control)) curAddTo.AddChild(new Parser.Tikz_Something(" -- cycle")); //else // curAddTo.AddChild(new Parser.Tikz_Something(" cycle")); } } else { if (!lcreated) { if (!overlay.KeyboardModifiers.HasFlag(TEModifierKeys.Control)) // add an edge curAddTo.AddChild(new Parser.Tikz_Something(" -- ")); else curAddTo.AddChild(new Parser.Tikz_Something(" ")); } // create new coordinate. If some node was clicked, set a reference to that node. Otherwise, just make new coordinates Tikz_Coord tc = new Tikz_Coord(); if (item is OverlayNode && IsReferenceable(item)) { Tikz_Node tn = MakeReferenceableNode((item as OverlayNode).tikzitem); tc.type = Tikz_CoordType.Named; tc.nameref = tn.name; curAddTo.AddChild(tc); } else { // do it here since the coordinate calculation needs the parents' coord. transform tc.type = overlay.UsePolarCoordinates ? Tikz_CoordType.Polar : Tikz_CoordType.Cartesian; if (!lcreated) tc.deco = overlay.NewNodeModifier; // first node should always be in absolute coordinates curAddTo.AddChild(tc); tc.SetAbsPos(new Point(p.X, p.Y)); //hack // if a nonempty node style is selected, also add a node with that style if (!String.IsNullOrWhiteSpace(overlay.NodeStyle)) { Tikz_Node tn = new Tikz_Node() { options = "[" + overlay.NodeStyle + "]", coord = null, text = "" }; curAddTo.AddChild(new Tikz_Something(" ")); curAddTo.AddChild(tn); } } //tn.UpdateText(); curAddTo.UpdateText(); //tpict.UpdateText(); // draw the added object in the overlay // overlay.AddToDisplayTree(tc); } } overlay.EndUpdate(); UpdateRaster(); // doubleclick also stops path drawing if (e.ClickCount == 2) overlay.ActivateDefaultTool(); }
public override void OnLeftMouseButtonDown(OverlayShapeVM item, Point p, TEMouseArgs e) { if (!(item is OverlayNode)) { curSel = null; return; } OverlayNode n = item as OverlayNode; // make sure a referenceable item is selected... otherwise we cannot add an edge if (!IsReferenceable(item)) { GlobalUI.UI.AddStatusLine(this, "Only items that are referenceable (=can be given names) can be connected with the edge tool."); return; } if (curSel == null) { curSel = n; return; } // make sure both nodes involved are nodes /* if (!(curSel.tikzitem is Tikz_Node) || !(n.tikzitem is Tikz_Node)) { String which = ""; String verb = "is"; if (!(curSel.tikzitem is Tikz_Node) && !(n.tikzitem is Tikz_Node)) { which = "Both"; verb = "are"; } else if (!(curSel.tikzitem is Tikz_Node)) which = "The first"; else if (!(n.tikzitem is Tikz_Node)) which = "The second"; MainWindow.AddStatusLine(which + " of the selected coordinates " + verb + " not a node (i.e. not defined with \\node but rather with \\draw or \\path)", true); curSel = null; return; // hack } */ //the return from above must not interfere with BeginModify() overlay.BeginUpdate(); // add an edge curSel to n //bool lcreated; //if (EnsureCurAddToExists(out lcreated)) //always create new \draw command. otherwise it can happen that the \draw-command //is above the \node-definition which causes an error while compiling the latex code. if (AddNewCurAddTo()) { // make sure both nodes involved have names Parser.Tikz_Node t1 = MakeReferenceableNode(curSel.tikzitem), t2 = MakeReferenceableNode(n.tikzitem); Parser.Tikz_Coord tc1 = new Parser.Tikz_Coord(); tc1.type = Parser.Tikz_CoordType.Named; Parser.Tikz_Coord tc2 = new Parser.Tikz_Coord(); tc2.type = Parser.Tikz_CoordType.Named; curAddTo.AddChild(new Parser.Tikz_Something(" ")); curAddTo.AddChild(tc1); if (t1 == t2) curAddTo.AddChild(new Parser.Tikz_Something(" edge[loop, looseness=20] ")); else curAddTo.AddChild(new Parser.Tikz_Something(" edge ")); curAddTo.AddChild(tc2); //tpict.AddChild(tp); // make sure both nodes have names /* Tikz_Picture tpict = overlay.ParseTree.GetTikzPicture(); if (t1.name == "") { t1.SetName(tpict.GetUniqueName()); t1.UpdateText(); } if (t2.name == "") { t2.SetName(tpict.GetUniqueName()); t2.UpdateText(); } */ tc1.nameref = t1.name; tc2.nameref = t2.name; //tc1.UpdateText(); curAddTo.UpdateText(); //tpict.UpdateText(); // txtCode_TextChanged //RedrawObjects(); //if (OnModified != null) // OnModified.Invoke(); //edge was drawn. release currently selected node. curSel = null; //will neither want to path tool to start from this last select nodes. curAddTo = null; } //forgetting to call EndModify causes weird "No undo group should be open at this point"-message. overlay.EndUpdate(); }
public override void OnLeftMouseButtonDown(OverlayShapeVM item, Point p, TEMouseArgs e) { if (!EnsureParseTreeExists()) return; overlay.BeginUpdate(); overlay.SetCorrectRaster(overlay.CurEditing, true); //Point p = new Point(e.GetPosition(canvas1).X, Height - e.GetPosition(canvas1).Y); p = overlay.Rasterizer.RasterizePixelToTikz(p); if (ContinueWithBigImage(p) == false) return; // find next tikzpicture and add Parser.Tikz_Picture tpict = overlay.ParseTree.GetTikzPicture(); if (tpict != null) { Parser.Tikz_Node tn = new Parser.Tikz_Node(); tn.label = ""; tn.coord = new Parser.Tikz_Coord(); if (!String.IsNullOrEmpty(overlay.NodeStyle)) tn.options = "[" + overlay.NodeStyle + "]"; Parser.Tikz_Path tp = new Parser.Tikz_Path(); tp.starttag = @"\node "; tp.endtag = ";"; tp.AddChild(tn); if (overlay.CurEditing != null) { overlay.CurEditing.tikzitem.AddChild(tp); overlay.CurEditing.tikzitem.AddChild(new Parser.Tikz_Something("\r\n")); } else { tpict.AddChild(tp); tpict.AddChild(new Parser.Tikz_Something("\r\n")); } // do it here since the coordinate calculation needs the parents' coord. transform tn.SetAbsPos(new Point(p.X, p.Y)); //hack //tn.UpdateText(); tp.UpdateText(); //tpict.UpdateText(); //RedrawObjects(); // overlay.AddToDisplayTree(tp); } overlay.EndUpdate(); }
public override void OnLeftMouseButtonDown(OverlayShapeVM item, Point p, TEMouseArgs e) { if (!(item is OverlayNode)) { curSel = null; return; } OverlayNode n = item as OverlayNode; // make sure a referenceable item is selected... otherwise we cannot add an edge if (!IsReferenceable(item)) { GlobalUI.UI.AddStatusLine(this, "Only items that are referenceable (=can be given names) can be connected with the edge tool."); return; } if (curSel == null) { curSel = n; return; } // make sure both nodes involved are nodes /* if (!(curSel.tikzitem is Tikz_Node) || !(n.tikzitem is Tikz_Node)) * { * String which = ""; String verb = "is"; * if (!(curSel.tikzitem is Tikz_Node) && !(n.tikzitem is Tikz_Node)) * { which = "Both"; verb = "are"; } * else if (!(curSel.tikzitem is Tikz_Node)) * which = "The first"; * else if (!(n.tikzitem is Tikz_Node)) * which = "The second"; * MainWindow.AddStatusLine(which + " of the selected coordinates " + verb + " not a node (i.e. not defined with \\node but rather with \\draw or \\path)", true); * curSel = null; * return; // hack * } */ //the return from above must not interfere with BeginModify() overlay.BeginUpdate(); // add an edge curSel to n //bool lcreated; //if (EnsureCurAddToExists(out lcreated)) //always create new \draw command. otherwise it can happen that the \draw-command //is above the \node-definition which causes an error while compiling the latex code. if (AddNewCurAddTo()) { // make sure both nodes involved have names Parser.Tikz_Node t1 = MakeReferenceableNode(curSel.tikzitem), t2 = MakeReferenceableNode(n.tikzitem); Parser.Tikz_Coord tc1 = new Parser.Tikz_Coord(); tc1.type = Parser.Tikz_CoordType.Named; Parser.Tikz_Coord tc2 = new Parser.Tikz_Coord(); tc2.type = Parser.Tikz_CoordType.Named; curAddTo.AddChild(new Parser.Tikz_Something(" ")); curAddTo.AddChild(tc1); if (t1 == t2) { curAddTo.AddChild(new Parser.Tikz_Something(" edge[loop, looseness=20] ")); } else { curAddTo.AddChild(new Parser.Tikz_Something(" edge ")); } curAddTo.AddChild(tc2); //tpict.AddChild(tp); // make sure both nodes have names /* Tikz_Picture tpict = overlay.ParseTree.GetTikzPicture(); * if (t1.name == "") * { * t1.SetName(tpict.GetUniqueName()); * t1.UpdateText(); * } * if (t2.name == "") * { * t2.SetName(tpict.GetUniqueName()); * t2.UpdateText(); * } */ tc1.nameref = t1.name; tc2.nameref = t2.name; //tc1.UpdateText(); curAddTo.UpdateText(); //tpict.UpdateText(); // txtCode_TextChanged //RedrawObjects(); //if (OnModified != null) // OnModified.Invoke(); //edge was drawn. release currently selected node. curSel = null; //will neither want to path tool to start from this last select nodes. curAddTo = null; } //forgetting to call EndModify causes weird "No undo group should be open at this point"-message. overlay.EndUpdate(); }
public override void OnLeftMouseButtonDown(OverlayShapeVM item, Point p, TEMouseArgs e) { if (!EnsureParseTreeExists()) { return; } p = overlay.Rasterizer.RasterizePixelToTikz(p); if (ContinueWithBigImage(p) == false) { return; } overlay.BeginUpdate(); //overlay.SetCorrectRaster(overlay.CurEditing, true); UpdateRaster(); //Point p = new Point(e.GetPosition(canvas1).X, Height - e.GetPosition(canvas1).Y); // find next tikzpicture and add bool lcreated; if (EnsureCurAddToExists(out lcreated)) { // on double click -> close path if (e.ClickCount == 2) { if (!lcreated) { //if (!Keyboard.Modifiers.HasFlag(ModifierKeys.Control)) curAddTo.AddChild(new Parser.Tikz_Something(" -- cycle")); //else // curAddTo.AddChild(new Parser.Tikz_Something(" cycle")); } } else { if (!lcreated) { if (!overlay.KeyboardModifiers.HasFlag(TEModifierKeys.Control)) { // add an edge curAddTo.AddChild(new Parser.Tikz_Something(" -- ")); } else { curAddTo.AddChild(new Parser.Tikz_Something(" ")); } } // create new coordinate. If some node was clicked, set a reference to that node. Otherwise, just make new coordinates Tikz_Coord tc = new Tikz_Coord(); if (item is OverlayNode && IsReferenceable(item)) { Tikz_Node tn = MakeReferenceableNode((item as OverlayNode).tikzitem); tc.type = Tikz_CoordType.Named; tc.nameref = tn.name; curAddTo.AddChild(tc); } else { // do it here since the coordinate calculation needs the parents' coord. transform tc.type = overlay.UsePolarCoordinates ? Tikz_CoordType.Polar : Tikz_CoordType.Cartesian; if (!lcreated) { tc.deco = overlay.NewNodeModifier; // first node should always be in absolute coordinates } curAddTo.AddChild(tc); tc.SetAbsPos(new Point(p.X, p.Y)); //hack // if a nonempty node style is selected, also add a node with that style if (!String.IsNullOrWhiteSpace(overlay.NodeStyle)) { Tikz_Node tn = new Tikz_Node() { options = "[" + overlay.NodeStyle + "]", coord = null, text = "" }; curAddTo.AddChild(new Tikz_Something(" ")); curAddTo.AddChild(tn); } } //tn.UpdateText(); curAddTo.UpdateText(); //tpict.UpdateText(); // draw the added object in the overlay // overlay.AddToDisplayTree(tc); } } overlay.EndUpdate(); UpdateRaster(); // doubleclick also stops path drawing if (e.ClickCount == 2) { overlay.ActivateDefaultTool(); } }