예제 #1
0
 private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (PrintControlFromTool != null)
     {
         ContentControlBase control = CommonRule.LoadClassInstance <ContentControlBase>(this.GetType().Namespace, PrintControlFromTool.GetType().Name);
         Canvas.SetTop(control, PrintControlFromToolOfPosition.Y);
         Canvas.SetLeft(control, PrintControlFromToolOfPosition.X);
         AddPrinControlEventHandle(control);
         canvasSpace.Children.Add(control);
         //更新放置坐标到控件相应属性
         PropertyModel pX = GetPropertyItemByName(control.Propertys, "pX");
         if (pX != null)
         {
             pX.Value = Math.Floor(PrintControlFromToolOfPosition.X);
         }
         PropertyModel pY = GetPropertyItemByName(control.Propertys, "pY");
         if (pY != null)
         {
             pY.Value = Math.Floor(PrintControlFromToolOfPosition.Y);
         }
         CurrentControlBase   = control;
         PrintControlFromTool = null;
         this.Cursor          = null;
     }
 }
예제 #2
0
 /// <summary>
 /// 拖动添加打印控件
 /// </summary>
 public void AddPrinControlByDrag()
 {
     if (IsMouseEnter && PrintControlFromTool != null)
     {
         ContentControlBase control = CommonRule.LoadClassInstance <ContentControlBase>(this.GetType().Namespace, PrintControlFromTool.GetType().Name);
         Canvas.SetTop(control, PrintControlFromToolOfPosition.Y);
         Canvas.SetLeft(control, PrintControlFromToolOfPosition.X);
         AddPrinControlEventHandle(control);
         canvasSpace.Children.Add(control);
         //更新放置坐标到控件相应属性
         PropertyModel pX = GetPropertyItemByName(control.Propertys, "pX");
         if (pX != null)
         {
             pX.Value = Math.Floor(PrintControlFromToolOfPosition.X);
         }
         PropertyModel pY = GetPropertyItemByName(control.Propertys, "pY");
         if (pY != null)
         {
             pY.Value = Math.Floor(PrintControlFromToolOfPosition.Y);
         }
         CurrentControlBase   = control;
         PrintControlFromTool = null;
         this.Cursor          = null;
     }
 }