copy from WPFProject/UI/WorkControl.xaml.cs
copy to Plugin.TestBuilder/TestBuilder.xaml.cs
| File was copied from WPFProject/UI/WorkControl.xaml.cs |
| | |
| | | using System; |
| | | using HMI.Base; |
| | | using Plugin.TestBuilder.Entity; |
| | | using Plugin.TestBuilder.UI; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Windows; |
| | | using System.Windows.Controls; |
| | | using HMI.Base; |
| | | using log4net; |
| | | using WPFProject.Controls; |
| | | using WPFProject.Models; |
| | | using WPFProject.Utils; |
| | | using System.Windows.Media; |
| | | |
| | | namespace WPFProject.UI |
| | | namespace Plugin.TestBuilder |
| | | { |
| | | /// <summary> |
| | | /// WorkControl.xaml 的交互逻辑 |
| | | /// </summary> |
| | | public partial class WorkControl : PluginControl |
| | | public partial class TestBuilder : PluginControl |
| | | { |
| | | private ILog log; |
| | | public WorkControl() |
| | | public TestBuilder() |
| | | { |
| | | InitializeComponent(); |
| | | Loaded += UserControl_Loaded; |
| | |
| | | |
| | | private void UserControl_Loaded(object sender, RoutedEventArgs e) |
| | | { |
| | | //List<CanvasPosition> pos = InitGridSize(); |
| | | //ProgramList programList = new ProgramList(); |
| | | //InnerWindow p = new InnerWindow(pos[0]) |
| | | //{ |
| | | // Title = "程序列表", |
| | | // Content = programList |
| | | //}; |
| | | //HandleInnerWindow(p); |
| | | List<CanvasPosition> pos = InitGridSize(); |
| | | ProgramList programList = new ProgramList(); |
| | | InnerWindow p = new InnerWindow(pos[0]) |
| | | { |
| | | Title = "程序列表", |
| | | Content = programList |
| | | }; |
| | | HandleInnerWindow(p); |
| | | |
| | | //InnerWindow p1 = new InnerWindow(pos[1]) |
| | | //{ |
| | | // Title = "图片", |
| | | //}; |
| | | //HandleInnerWindow(p1); |
| | | InnerWindow p1 = new InnerWindow(pos[1]) |
| | | { |
| | | Title = "图片" |
| | | }; |
| | | HandleInnerWindow(p1); |
| | | |
| | | //SequnceList sequnceList = new SequnceList(); |
| | | //programList.ProgramChanged += sequnceList.Selected_Program_Changed; |
| | | SequnceList sequnceList = new SequnceList(); |
| | | programList.ProgramChanged += sequnceList.Selected_Program_Changed; |
| | | |
| | | //InnerWindow p2 = new InnerWindow(pos[2]) |
| | | //{ |
| | | // Title = "序列", |
| | | // Content = sequnceList |
| | | //}; |
| | | //HandleInnerWindow(p2); |
| | | InnerWindow p2 = new InnerWindow(pos[2]) |
| | | { |
| | | Title = "序列", |
| | | Content = sequnceList |
| | | }; |
| | | HandleInnerWindow(p2); |
| | | |
| | | //FunctionSetting functionSetting = new FunctionSetting(); |
| | | //InnerWindow p3 = new InnerWindow(pos[3]) |
| | | //{ |
| | | // Title = "函数", |
| | | // Content = functionSetting |
| | | //}; |
| | | //HandleInnerWindow(p3); |
| | | FunctionSetting functionSetting = new FunctionSetting(); |
| | | InnerWindow p3 = new InnerWindow(pos[3]) |
| | | { |
| | | Title = "函数", |
| | | Content = functionSetting |
| | | }; |
| | | HandleInnerWindow(p3); |
| | | |
| | | //StepSetting stepSetting = new StepSetting(); |
| | | //InnerWindow p4 = new InnerWindow(pos[4]) |
| | | //{ |
| | | // Title = "单步设置", |
| | | // Content = stepSetting |
| | | //}; |
| | | //HandleInnerWindow(p4); |
| | | StepSetting stepSetting = new StepSetting(); |
| | | InnerWindow p4 = new InnerWindow(pos[4]) |
| | | { |
| | | Title = "单步设置", |
| | | Content = stepSetting |
| | | }; |
| | | HandleInnerWindow(p4); |
| | | |
| | | |
| | | //SizeChanged += WorkControl_SizeChanged; |
| | | SizeChanged += WorkControl_SizeChanged; |
| | | Loaded -= UserControl_Loaded; |
| | | |
| | | } |
| | |
| | | /// <param name="e"></param> |
| | | private void WorkControl_SizeChanged(object sender, SizeChangedEventArgs e) |
| | | { |
| | | //Size newSize = e.NewSize; |
| | | //Size previousSize = e.PreviousSize; |
| | | Size newSize = e.NewSize; |
| | | Size previousSize = e.PreviousSize; |
| | | |
| | | //double xRate = newSize.Width / previousSize.Width; |
| | | //double yRate = newSize.Height / previousSize.Height; |
| | | //for (int i = 0; i < VisualTreeHelper.GetChildrenCount(WorkArea); i++) |
| | | //{ |
| | | // UIElement child = VisualTreeHelper.GetChild(WorkArea, i) as UIElement; |
| | | // Canvas.SetLeft(child, Canvas.GetLeft(child) * xRate); |
| | | // Canvas.SetTop(child, Canvas.GetTop(child) * yRate); |
| | | //} |
| | | double xRate = newSize.Width / previousSize.Width; |
| | | double yRate = newSize.Height / previousSize.Height; |
| | | for (int i = 0; i < VisualTreeHelper.GetChildrenCount(WorkArea); i++) |
| | | { |
| | | UIElement child = VisualTreeHelper.GetChild(WorkArea, i) as UIElement; |
| | | Canvas.SetLeft(child, Canvas.GetLeft(child) * xRate); |
| | | Canvas.SetTop(child, Canvas.GetTop(child) * yRate); |
| | | } |
| | | |
| | | //for (int i = 0; i < VisualTreeHelper.GetChildrenCount(WorkArea); i++) |
| | | //{ |
| | | // UIElement child = VisualTreeHelper.GetChild(WorkArea, i) as UIElement; |
| | | // if (Canvas.GetLeft(child) >= newSize.Width) |
| | | // { |
| | | // Canvas.SetLeft(child, Canvas.GetLeft(child) + newSize.Width - previousSize.Width); |
| | | // } |
| | | // if (Canvas.GetTop(child) >= newSize.Height) |
| | | // { |
| | | // Canvas.SetTop(child, Canvas.GetTop(child) + newSize.Height - previousSize.Height); |
| | | // } |
| | | //} |
| | | for (int i = 0; i < VisualTreeHelper.GetChildrenCount(WorkArea); i++) |
| | | { |
| | | UIElement child = VisualTreeHelper.GetChild(WorkArea, i) as UIElement; |
| | | if (Canvas.GetLeft(child) >= newSize.Width) |
| | | { |
| | | Canvas.SetLeft(child, Canvas.GetLeft(child) + newSize.Width - previousSize.Width); |
| | | } |
| | | if (Canvas.GetTop(child) >= newSize.Height) |
| | | { |
| | | Canvas.SetTop(child, Canvas.GetTop(child) + newSize.Height - previousSize.Height); |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | |
| | | } |
| | | #endregion |
| | | |
| | | public void OnTabChange(object sender, SelectionChangedEventArgs args) |
| | | { |
| | | if (args.AddedItems.Count > 0) |
| | | { |
| | | IconTabItem newTab = args.AddedItems[0] as IconTabItem; |
| | | if (newTab != null && newTab.Content == this) |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
| | | if (args.RemovedItems.Count > 0) |
| | | { |
| | | IconTabItem oldTab = args.RemovedItems[0] as IconTabItem; |
| | | if (oldTab != null && oldTab.Content == this) |
| | | { |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | public object Active() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | public object DeActive() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | public void OnTabChange(object sender, object args) |
| | | { |
| | | |
| | | } |
| | | |
| | | public object Init() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | public void SetLogger(ILog logger) |
| | | { |
| | | log = logger; |
| | | } |
| | | } |
| | | } |