/// <summary> /// 初始化 /// </summary> public ConnectLine(Model.BackGrid grid) { SubBrush = new SolidColorBrush(Colors.Black); Selected = false; this.StrokeThickness = _defaultWidth; this.Cursor = Cursors.Hand; this.MouseEnter += new MouseEventHandler(_linePath_MouseEnter); this.MouseLeave += new MouseEventHandler(_linePath_MouseLeave); //_lineGeometry.Figures.Add(_linePoints); this.Data = lineGeometry; backGrid = grid; //添加移除菜单 menu = new ContextMenu(); var deleteMenu = new MenuItem(); deleteMenu.Header = "移除"; menu.Items.Add(deleteMenu); deleteMenu.Click += (m, arg) => { this.Hide(); }; grid.BackCanvas.MouseMove += new MouseEventHandler(BackCanvas_MouseMove); grid.BackCanvas.MouseLeftButtonUp += new MouseButtonEventHandler(BackCanvas_MouseLeftButtonUp); }
/// <summary> /// 重新定位 /// </summary> public virtual void ResetPosition(Model.BackGrid grid = null) { if (grid == null) { grid = CanvasGrid; } else { CanvasGrid = grid; } this.Height = Helper.Config.GridSize.Height - Helper.Config.ElementMargin.Top - Helper.Config.ElementMargin.Bottom; this.Width = Helper.Config.GridSize.Width - Helper.Config.ElementMargin.Left - Helper.Config.ElementMargin.Right; Canvas.SetZIndex(this, Helper.ShapZIndex.Shap.GetHashCode()); var x = this.Position.X * Helper.Config.GridSize.Width + Helper.Config.ElementMargin.Left + grid.GridRect.Left; var y = this.Position.Y * Helper.Config.GridSize.Height + Helper.Config.ElementMargin.Top + grid.GridRect.Top; Canvas.SetLeft(this, x); Canvas.SetTop(this, y); CreateInOutPosition(); MoveCallback(); }
public override void ResetPosition(Model.BackGrid grid = null) { base.ResetPosition(grid); var ml = (Helper.Config.GridSize.Width - this.ActualWidth) / 2; var mh = (Helper.Config.GridSize.Height - this.ActualHeight) / 2; this.GridMargin = new Thickness(ml, mh, ml, mh); }
public EditorCanvas() { InitializeComponent(); //实例化表格 grid = new Model.BackGrid(this.canvasArea); //this.canvasArea.Width = 200; //this.canvasArea.Height = 120; this.Loaded += new RoutedEventHandler(EditorCanvas_Loaded); //this.canvasArea.MouseEnter += new MouseEventHandler(canvasArea_MouseEnter); //this.canvasArea.MouseLeftButtonUp += new MouseButtonEventHandler(canvasArea_MouseLeftButtonUp); }
/// <summary> /// 重新定位 /// </summary> /// <param name="grid"></param> public override void ResetPosition(Model.BackGrid grid = null) { if (this.Model.Part.IsStart) { this.Position = new Point(0, 0); } else if (this.Model.Part.Id == "1") { this.Position = new Point(Helper.Config.ColumnCount - 1, 0); } base.ResetPosition(grid); //Canvas.SetZIndex(this, Helper.ShapZIndex.Shap.GetHashCode()); //var x = this.Position.X * Helper.Config.GridSize.Width + Helper.Config.ElementMargin.Left + grid.GridRect.Left; //var y = this.Position.Y * Helper.Config.GridSize.Height + Helper.Config.ElementMargin.Top + grid.GridRect.Top; //Canvas.SetLeft(this, x); //Canvas.SetTop(this, y); //CreateInOutPosition(); this.Height = CanvasGrid.GridRect.Height - CanvasGrid.GridRect.Top * 2; var ml = (Helper.Config.GridSize.Width - centerRect.ActualWidth) / 2; var mh = (Helper.Config.GridSize.Height - centerRect.ActualHeight) / 2; this.GridMargin = new Thickness(ml, mh, ml, mh); var x = Canvas.GetLeft(this); var y = Canvas.GetTop(this); this.InPoint = new Point(x + (this.Width - centerRect.ActualWidth) / 2, y + (this.Height) / 2); this.OutPoint = new Point(x + (this.Width + centerRect.ActualWidth) / 2, y + (this.Height) / 2); }