/// <summary> /// 加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainLayout_Loaded(object sender, RoutedEventArgs e) { mainIb = new LineItemBox() { BoxType = ItemBoxEnum.MAIN, Name = "任务入口" }; mainIb.AddOutput(new ParatItem() { Name = "输出", PIEnum = ParaItemEnum.OUTPUT, Color = Colors.AntiqueWhite, UIMain = contentsCanvas }); ContentX = center.X; ContentY = center.Y; dataTree.CreateCallback += DataTree_CreateCallback; dataTreePop.AllowsTransparency = true; dataTreePop.PopupAnimation = PopupAnimation.Fade; dataTreePop.StaysOpen = false; dataTreePop.Placement = PlacementMode.Mouse; ///设置弹出框内容 dataTreePop.Child = dataTree; this.Add(mainIb); mainIb.ContentX = -center.X; mainIb.ContentY = -center.Y; this.contentsCanvas.Children.Add(rectangle); HidenRect(); }
/// <summary> /// 移动当前选中的框 /// </summary> /// <param name="pos">移动的差值</param> protected void moveSelectedBox(Point pos) { foreach (var item in selectedBoxs) { LineItemBox ibox = item.Ibox as LineItemBox; ibox.ContentX += pos.X; ibox.ContentY += pos.Y; item.MoveChange(); } }
/// <summary> /// 添加一个函数框 /// </summary> /// <param name="itbox"></param> public override void Add(IItemBox item) { LineItemBox itbox = item as LineItemBox; FunctionBox fb = new FunctionBox(); itbox.ContentX = currentPosition.X; itbox.ContentY = currentPosition.Y; fb.UIMain = contentsCanvas; fb.DataContext = itbox; itbox.Thickness = 6; Itemboxs.Add(itbox); fb.InitFunction(); Add(fb); }
/// <summary> /// 添加一个函数框 /// </summary> /// <param name="itbox"></param> public void Add(IItemBox item, bool isaddposition) { LineItemBox itbox = item as LineItemBox; FunctionBox fb = new FunctionBox(); if (isaddposition == true) { itbox.ContentX = currentPosition.X; itbox.ContentY = currentPosition.Y; } fb.UIMain = contentsCanvas; fb.DataContext = itbox; itbox.Thickness = 6; Itemboxs.Add(itbox); fb.InitFunction(); Add(fb); }