From 0d28158de5dcc8f10d24352cfb6df057888583d8 Mon Sep 17 00:00:00 2001 From: fyf Date: Thu, 13 Oct 2022 09:28:55 +0800 Subject: [PATCH] 1 --- .../Controls/CanvasPanelNew.xaml.cs | 141 ------------------ 1 file changed, 141 deletions(-) diff --git a/BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs b/BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs index b017ee41..0cc0bac0 100644 --- a/BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs +++ b/BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs @@ -50,8 +50,6 @@ namespace BeDesignerSCADA.Controls CtlList.ItemsSource = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o => o.Name)?.ToList(); //读取文件 FileRead(_Path); - //this.MouseLeftButtonUp += CanvasPanelNew_MouseLeftButtonUp; - //this.MouseMove += CanvasPanelNew_MouseMove; } #region 位置调整 @@ -344,84 +342,6 @@ namespace BeDesignerSCADA.Controls #region 左侧控件栏移动 /// - /// 当前拖动子控件流 - /// - private UIElement ChildElement; - /// - /// 是否已经按下 - /// - private bool isDown = false; - /// - /// 当前拖动的Pop窗体 - /// - private Popup DropPopup = null; - /// - /// 移动 - /// - /// - /// - private void CanvasPanelNew_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) - { - try - { - if (isDown == false) return; - - Point ptLeftUp = new Point(0, 0); - Point ptRightDown = new Point(this.ActualWidth, this.ActualHeight); - - ptLeftUp = this.PointToScreen(ptLeftUp); - ptRightDown = this.PointToScreen(ptRightDown); - - double y = e.GetPosition(CtlList).Y; - double x = e.GetPosition(CtlList).X; - - - if (DropPopup != null) - { - //下面两句是设置Popup控件的位置除以2是想让鼠标在它的中心 - DropPopup.HorizontalOffset = ptLeftUp.X + x - ((FrameworkElement)ChildElement).ActualWidth / 2; - DropPopup.VerticalOffset = ptLeftUp.Y + y - ((FrameworkElement)ChildElement).ActualHeight / 2; - } - - } - catch (Exception ex) - { - - } - } - /// - /// 鼠标抬起事件 - /// - /// - /// - private void CanvasPanelNew_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) - { - try - { - //鼠标未按下返回 - if (!isDown) return; - - isDown = false; - - //关闭Pop窗体 - if (this.DropPopup != null) - { - this.DropPopup.IsOpen = false; - this.DropPopup.Child = null; - this.DropPopup = null; - } - - //蒙层关闭 - - ChildElement.ReleaseMouseCapture();//当控件具有鼠标捕获的话,则释放该捕获。 - - } - catch (Exception ex) - { - - } - } - /// /// 移动到右侧 /// /// @@ -432,70 +352,9 @@ namespace BeDesignerSCADA.Controls { DragDrop.DoDragDrop(CtlList, CtlList.SelectedItem, System.Windows.DragDropEffects.Copy); codeEditor.Text = cav.Save(); - - try - { - //var control = Activator.CreateInstance(CtlList.SelectedItem as Type) as FrameworkElement; - //string str = XamlWriter.Save(control); - //ChildElement = (UIElement)XamlReader.Parse(str); - //ChildElement.CaptureMouse();//设置了鼠标捕获,这样它可以不受到其它控件的影响。 - - ////加蒙层,表明已经开始拖动 - ////暂时未加 - - //CreatePopup(ChildElement, null); - - //isDown = true; - - } - catch (Exception ex) - { - - } } } /// - /// 创建浮动窗口 - /// - /// - /// - private void CreatePopup(Visual dragElement, MouseButtonEventArgs e) - { - //使用PointToScreen函数可以将点转换为屏幕坐标 - //首先获取当前窗体的左上角和右下角两点的坐标 - Point ptLeftUp = new Point(0, 0); - //转换获取到这个窗口相对于屏幕两个坐标 - ptLeftUp = this.PointToScreen(ptLeftUp); - - //获取myGrid的实际宽高 - double y = 0;//e.GetPosition(CtlList).Y; - double x = 0;// e.GetPosition(CtlList).X; - - - this.DropPopup = new Popup(); - Border border = new Border(); - border.Margin = new Thickness(0, 0, 8, 8); - DropShadowEffect effect = new DropShadowEffect(); - effect.Opacity = 1; - effect.ShadowDepth = -14; - effect.BlurRadius = 9; - effect.Color = Color.FromArgb(100, 0, 0, 0); - border.Effect = effect; - - - Rectangle r = new Rectangle(); - r.Width = ((FrameworkElement)dragElement).ActualWidth; - r.Height = ((FrameworkElement)dragElement).ActualHeight; - r.Fill = new VisualBrush(dragElement); - border.Child = r; - this.DropPopup.Child = border; - DropPopup.AllowsTransparency = true; - DropPopup.HorizontalOffset = ptLeftUp.X + x - ((FrameworkElement)dragElement).ActualWidth / 2; - DropPopup.VerticalOffset = ptLeftUp.Y + y - ((FrameworkElement)dragElement).ActualHeight / 2; - - this.DropPopup.IsOpen = true; - } - /// /// 显示代码 /// ///