private void miAdd_Click(object sender, RoutedEventArgs e) { var mi = sender as MenuItem; JSC.JSValue decl; if (!IsReadonly && mi != null && (decl = mi.Tag as JSC.JSValue) != null) { if ((bool)decl["willful"]) { bool o_hc = _items.Any(); var ni = new InManifest(decl, this); _items.Insert(0, ni); _collFunc(ni, true); if (!o_hc) { PropertyChangedReise("HasChildren"); } if (!IsExpanded) { IsExpanded = true; base.PropertyChangedReise("IsExpanded"); } } else { string fName = mi.Header as string; _data.SetField(IsGroupHeader ? fName : _path + "." + fName, decl["default"]); } } }
public override void SetLocation(Vector loc, bool save) { int topCell = (int)(loc.Y / CELL_SIZE + 0.5); if (topCell < 0) { topCell = 0; } int leftCell = (int)(loc.X / CELL_SIZE); if (leftCell < 0) { leftCell = 0; } if (save) { var lo = JsLib.GetField(model.Manifest, "Logram"); int xo, yo; xo = JsLib.OfInt(JsLib.GetField(lo, "left"), 0); yo = JsLib.OfInt(JsLib.GetField(lo, "top"), 0); if (xo == leftCell && yo == topCell) // refresh wires { this.Dispatcher.BeginInvoke(new Action <int>(this.Render), System.Windows.Threading.DispatcherPriority.DataBind, 3); } else { lo = JsLib.SetField(lo, "top", topCell); lo = JsLib.SetField(lo, "left", leftCell); model.SetField("Logram", lo); } } else { this.Offset = new Vector(leftCell * CELL_SIZE, (topCell - 0.5) * CELL_SIZE); foreach (var p in _pins) { p.Render(2); } } }
protected override void OnMouseUp(MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Right && e.RightButton == MouseButtonState.Released) { DTopic cur; if (selected != null && (cur = selected.GetModel()) != null) { var cm = (this as Canvas).ContextMenu; cm.ItemsSource = MenuItems(cur, selected); cm.IsOpen = true; } e.Handled = true; return; } else if (e.ChangedButton == MouseButton.Left && e.LeftButton == MouseButtonState.Released) { if (_mSelected != null && _mSelected.Length > 0) { var cp = e.GetPosition(this); double r = 0, d = 0; foreach (var el in _mSelected) { if (move) { el.SetLocation(new Vector(el.OriginalLocation.X + (cp.X - ScreenStartPoint.X), el.OriginalLocation.Y + (cp.Y - ScreenStartPoint.Y)), true); d = Math.Max(d, el.Offset.Y + el.ContentBounds.Bottom); r = Math.Max(r, el.Offset.X + el.ContentBounds.Right); } el.Select(false); } _mSelected = null; if (move) { if (d + CELL_SIZE > this.Height) { _model.SetField("Logram.height", (int)(d + CELL_SIZE)); } if (r + CELL_SIZE > this.Width) { _model.SetField("Logram.width", (int)(r + CELL_SIZE)); } } } if (IsMouseCaptured) { Cursor = Cursors.Arrow; ReleaseMouseCapture(); } else if (selected != null) { loElement el; loBinding w; var cp = e.GetPosition(this); if ((el = selected as loElement) != null && move) { el.SetLocation(new Vector(el.OriginalLocation.X + (cp.X - ScreenStartPoint.X), el.OriginalLocation.Y + (cp.Y - ScreenStartPoint.Y)), true); if (selected.Offset.Y + selected.ContentBounds.Bottom + CELL_SIZE > this.Height) { _model.SetField("Logram.height", (int)(selected.Offset.Y + selected.ContentBounds.Bottom + CELL_SIZE)); } if (selected.Offset.X + selected.ContentBounds.Right + CELL_SIZE > this.Width) { _model.SetField("Logram.width", (int)(selected.Offset.X + selected.ContentBounds.Right + CELL_SIZE)); } } else if ((w = selected as loBinding) != null && (w.Output == null || w.Input == null)) { loPin finish = GetVisual(cp.X, cp.Y) as loPin; if (finish != null && ((w.Output == null && finish.GetModel() != w.Input.GetModel() && finish.IsFreeInput) || (w.Input == null && finish.GetModel() != w.Output.GetModel() && !finish.IsInput))) //-V3080 //-V3027 { w.SetFinish(finish); } else { this.DeleteVisual(w); } } } else if (_multipleSelection) { var cp = e.GetPosition(this); _multipleSelection = false; base.RemoveVisualChild(_mSelectVisual); var objs = new List <loElement>(); GeometryHitTestParameters parameters; { double l, t, w, h; if (cp.X - ScreenStartPoint.X < 0) { l = cp.X; w = ScreenStartPoint.X - cp.X; } else { l = ScreenStartPoint.X; w = cp.X - ScreenStartPoint.X; } if (cp.Y - ScreenStartPoint.Y < 0) { t = cp.Y; h = ScreenStartPoint.Y - cp.Y; } else { t = ScreenStartPoint.Y; h = cp.Y - ScreenStartPoint.Y; } parameters = new GeometryHitTestParameters(new RectangleGeometry(new Rect(l, t, w, h))); } VisualTreeHelper.HitTest(this, null, new HitTestResultCallback((hr) => { var rez = (GeometryHitTestResult)hr; var vis = hr.VisualHit as loElement; if (vis != null && rez.IntersectionDetail == IntersectionDetail.FullyInside) { objs.Add(vis); } return(HitTestResultBehavior.Continue); }), parameters); if (objs.Count > 0) { if (objs.Count == 1) { selected = objs[0]; } else { _mSelected = objs.ToArray(); foreach (var el in _mSelected) { el.Select(true); } } } } else { base.OnMouseUp(e); } move = false; } else { base.OnMouseUp(e); } }