소스 검색

1

样式分支
fyf 2 년 전
부모
커밋
0d28158de5
1개의 변경된 파일0개의 추가작업 그리고 141개의 파일을 삭제
  1. +0
    -141
      BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs

+ 0
- 141
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 左侧控件栏移动
/// <summary>
/// 当前拖动子控件流
/// </summary>
private UIElement ChildElement;
/// <summary>
/// 是否已经按下
/// </summary>
private bool isDown = false;
/// <summary>
/// 当前拖动的Pop窗体
/// </summary>
private Popup DropPopup = null;
/// <summary>
/// 移动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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)
{

}
}
/// <summary>
/// 鼠标抬起事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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)
{

}
}
/// <summary>
/// 移动到右侧
/// </summary>
/// <param name="sender"></param>
@@ -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)
{

}
}
}
/// <summary>
/// 创建浮动窗口
/// </summary>
/// <param name="dragElement"></param>
/// <param name="e"></param>
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;
}
/// <summary>
/// 显示代码
/// </summary>
/// <param name="sender"></param>


불러오는 중...
취소
저장