private void CreateOnOffStopIndependentOperationInfo(Grid grid, FALibrary.Part.FAPart part, string name, Action<object> OnAction, Action<object> OffAction, Action<object> StopAction, Func<bool> IsOn, Func<bool> IsOff, string onName, string offName) { GeneralOperationInfo obj = new GeneralOperationInfo(); RowDefinition rd = new RowDefinition(); rd.Height = new GridLength(100, GridUnitType.Auto); rd.MinHeight = 100; grid.RowDefinitions.Add(rd); SetOperationGridColor(grid, grid.RowDefinitions.Count - 1); obj.Name = name; obj.FullName = part.FullName; obj.On = OnAction; obj.Off = OffAction; obj.Stop = StopAction; obj.StatusOnName = onName; obj.StatusOffName = offName; obj.IsOn = IsOn; obj.IsOff = IsOff; Label labelName = new Label(); labelName.Height = Double.NaN; labelName.Width = Double.NaN; labelName.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; labelName.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch; labelName.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; labelName.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; labelName.Margin = new Thickness(2); Binding bd = new Binding("Name"); bd.Source = obj; bd.Mode = BindingMode.OneWay; labelName.SetBinding(Label.ContentProperty, bd); Label labelStatus = new Label(); labelStatus.Height = Double.NaN; labelStatus.Width = Double.NaN; labelStatus.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; labelStatus.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch; labelStatus.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; labelStatus.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; labelStatus.Margin = new Thickness(2); bd = new Binding("Status"); bd.Source = obj; bd.Mode = BindingMode.OneWay; labelStatus.SetBinding(Label.ContentProperty, bd); Grid gridInputIOList = CreatePartInputIOList(part); Grid gridOutputIOList = CreatePartOutputIOList(part); Button buttonOn, buttonOff, buttonStop; Grid gridButton = CreateOnOffStopButtonGrid(out buttonOn, out buttonOff, out buttonStop); buttonOn.Content = onName; buttonOff.Content = offName; buttonStop.Content = "STOP"; buttonOn.Click += delegate(object sender, RoutedEventArgs e) { obj.ExecuteOn(); }; buttonOff.Click += delegate(object sender, RoutedEventArgs e) { obj.ExecuteOff(); }; buttonStop.Click += delegate(object sender, RoutedEventArgs e) { obj.ExecuteStop(); }; TextBox textBoxRepeat = new TextBox(); textBoxRepeat.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; textBoxRepeat.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; textBoxRepeat.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; textBoxRepeat.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; textBoxRepeat.Height = Double.NaN; textBoxRepeat.Width = Double.NaN; textBoxRepeat.Margin = new Thickness(2); bd = new Binding("RepeatTime"); bd.Source = obj; bd.Mode = BindingMode.TwoWay; textBoxRepeat.SetBinding(TextBox.TextProperty, bd); CheckBox checkBoxRepeatUse = new CheckBox(); checkBoxRepeatUse.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; checkBoxRepeatUse.VerticalAlignment = System.Windows.VerticalAlignment.Center; checkBoxRepeatUse.LayoutTransform = new ScaleTransform(CHECKBOX_SIZE, CHECKBOX_SIZE); bd = new Binding("RepeatUse"); bd.Source = obj; bd.Mode = BindingMode.TwoWay; checkBoxRepeatUse.SetBinding(CheckBox.IsCheckedProperty, bd); int rowCount = grid.RowDefinitions.Count - 1; grid.Children.Add(labelName); Grid.SetColumn(labelName, 0); Grid.SetRow(labelName, rowCount); grid.Children.Add(labelStatus); Grid.SetColumn(labelStatus, 1); Grid.SetRow(labelStatus, rowCount); grid.Children.Add(gridInputIOList); Grid.SetColumn(gridInputIOList, 2); Grid.SetRow(gridInputIOList, rowCount); grid.Children.Add(gridOutputIOList); Grid.SetColumn(gridOutputIOList, 3); Grid.SetRow(gridOutputIOList, rowCount); grid.Children.Add(gridButton); Grid.SetColumn(gridButton, 4); Grid.SetRow(gridButton, rowCount); grid.Children.Add(textBoxRepeat); Grid.SetColumn(textBoxRepeat, 5); Grid.SetRow(textBoxRepeat, rowCount); grid.Children.Add(checkBoxRepeatUse); Grid.SetColumn(checkBoxRepeatUse, 6); Grid.SetRow(checkBoxRepeatUse, rowCount); _ioOperationList.Add(obj); bd = new Binding("IsEnabledOutputIODirectControl"); bd.Source = this; bd.Mode = BindingMode.OneWay; gridOutputIOList.SetBinding(ListView.IsEnabledProperty, bd); }
private void CreateOnOffStopOperationInfo(Grid grid, FALibrary.Part.FAPart part, string name, Action<object> OnAction, Action<object> OffAction, Action<object> StopAction, Func<bool> IsOn, Func<bool> IsOff, string onName, string offName) { GeneralOperationInfo obj = new GeneralOperationInfo(); RowDefinition rd = new RowDefinition(); rd.Height = new GridLength(150, GridUnitType.Auto); rd.MinHeight = 100; grid.RowDefinitions.Add(rd); SetOperationGridColor(grid, grid.RowDefinitions.Count - 1); obj.Name = name; obj.FullName = part.FullName; obj.On = OnAction; obj.Off = OffAction; obj.Stop = StopAction; obj.StatusOnName = onName; obj.StatusOffName = offName; obj.IsOn = IsOn; obj.IsOff = IsOff; Label labelName = new Label(); labelName.Height = Double.NaN; labelName.Width = Double.NaN; labelName.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; labelName.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; labelName.Margin = new Thickness(2); Binding bd = new Binding("Name"); bd.Source = obj; bd.Mode = BindingMode.OneWay; TextBlock textBlockName = new TextBlock(); textBlockName.TextWrapping = TextWrapping.Wrap; textBlockName.TextAlignment = TextAlignment.Center; textBlockName.SetBinding(TextBlock.TextProperty, bd); labelName.Content = textBlockName; Label labelStatus = new Label(); labelStatus.Height = Double.NaN; labelStatus.Width = Double.NaN; labelStatus.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; labelStatus.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; labelStatus.Margin = new Thickness(2); bd = new Binding("Status"); bd.Source = obj; bd.Mode = BindingMode.OneWay; TextBlock textBlockStatus = new TextBlock(); textBlockStatus.TextWrapping = TextWrapping.Wrap; textBlockStatus.TextAlignment = TextAlignment.Center; textBlockStatus.SetBinding(TextBlock.TextProperty, bd); labelStatus.Content = textBlockStatus; Grid gridInputIOList = CreatePartInputIOList(part); Grid gridOutputIOList = CreatePartOutputIOList(part); Button buttonOnOff = new Button(); buttonOnOff.Height = Double.NaN; buttonOnOff.Width = Double.NaN; buttonOnOff.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; buttonOnOff.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; buttonOnOff.Margin = new Thickness(2); bd = new Binding("ButtonCaption"); bd.Source = obj; bd.Mode = BindingMode.OneWay; buttonOnOff.SetBinding(Button.ContentProperty, bd); buttonOnOff.Click += delegate(object sender, RoutedEventArgs e) { if (obj.IsOn()) obj.ExecuteOff(); else { if (obj.IsOff()) { obj.ExecuteOn(); } else if (StopAction != null) { obj.ExecuteStop(); } else obj.ExecuteOn(); } }; TextBox textBoxRepeat = new TextBox(); textBoxRepeat.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; textBoxRepeat.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; textBoxRepeat.Height = Double.NaN; textBoxRepeat.Width = Double.NaN; textBoxRepeat.Margin = new Thickness(2); bd = new Binding("RepeatTime"); bd.Source = obj; bd.Mode = BindingMode.TwoWay; FAFramework.Utility.BindingUtility.SetBindingObject(textBoxRepeat, BindingMode.TwoWay, obj, TextBox.TextProperty, "RepeatTime"); CheckBox checkBoxRepeatUse = new CheckBox(); checkBoxRepeatUse.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; checkBoxRepeatUse.VerticalAlignment = System.Windows.VerticalAlignment.Center; checkBoxRepeatUse.LayoutTransform = new ScaleTransform(CHECKBOX_SIZE, CHECKBOX_SIZE); bd = new Binding("RepeatUse"); bd.Source = obj; bd.Mode = BindingMode.TwoWay; checkBoxRepeatUse.SetBinding(CheckBox.IsCheckedProperty, bd); int rowCount = grid.RowDefinitions.Count - 1; grid.Children.Add(labelName); Grid.SetColumn(labelName, 0); Grid.SetRow(labelName, rowCount); grid.Children.Add(labelStatus); Grid.SetColumn(labelStatus, 1); Grid.SetRow(labelStatus, rowCount); grid.Children.Add(gridInputIOList); Grid.SetColumn(gridInputIOList, 2); Grid.SetRow(gridInputIOList, rowCount); grid.Children.Add(gridOutputIOList); Grid.SetColumn(gridOutputIOList, 3); Grid.SetRow(gridOutputIOList, rowCount); grid.Children.Add(buttonOnOff); Grid.SetColumn(buttonOnOff, 4); Grid.SetRow(buttonOnOff, rowCount); grid.Children.Add(textBoxRepeat); Grid.SetColumn(textBoxRepeat, 5); Grid.SetRow(textBoxRepeat, rowCount); grid.Children.Add(checkBoxRepeatUse); Grid.SetColumn(checkBoxRepeatUse, 6); Grid.SetRow(checkBoxRepeatUse, rowCount); _ioOperationList.Add(obj); bd = new Binding("IsEnabledOutputIODirectControl"); bd.Source = this; bd.Mode = BindingMode.OneWay; gridOutputIOList.SetBinding(ListView.IsEnabledProperty, bd); }
private void CreateDuplexCaptureOperationInfo(Grid grid, FALibrary.Part.FAPart part, string name, Action<object> OnAction, Action<object> OffAction, Action<object> StopAction, Func<bool> IsOn, Func<bool> IsOff, string onName, string offName) { GeneralOperationInfo obj = new GeneralOperationInfo(); RowDefinition rd = new RowDefinition(); rd.Height = new GridLength(100, GridUnitType.Auto); rd.MinHeight = 100; SetOperationGridColor(grid, grid.RowDefinitions.Count - 1); grid.RowDefinitions.Add(rd); obj.Name = name; obj.FullName = part.FullName; obj.On = OnAction; obj.Off = OffAction; obj.Stop = StopAction; obj.StatusOnName = onName; obj.StatusOffName = offName; obj.IsOn = IsOn; obj.IsOff = IsOff; Label labelName = new Label(); labelName.Height = Double.NaN; labelName.Width = Double.NaN; labelName.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; labelName.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch; labelName.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; labelName.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; labelName.Margin = new Thickness(2); Binding bd = new Binding("Name"); bd.Source = obj; bd.Mode = BindingMode.OneWay; labelName.SetBinding(Label.ContentProperty, bd); Label labelStatus = new Label(); labelStatus.Height = Double.NaN; labelStatus.Width = Double.NaN; labelStatus.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; labelStatus.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch; labelStatus.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; labelStatus.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; labelStatus.Margin = new Thickness(2); bd = new Binding("Status"); bd.Source = obj; bd.Mode = BindingMode.OneWay; labelStatus.SetBinding(Label.ContentProperty, bd); Grid gridInputIOList = CreatePartInputIOList(part); Grid gridOutputIOList = CreatePartOutputIOList(part); Button buttonOn = new Button(); buttonOn.Height = Double.NaN; buttonOn.Width = Double.NaN; buttonOn.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; buttonOn.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch; buttonOn.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; buttonOn.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; buttonOn.Content = onName; buttonOn.Margin = new Thickness(2); buttonOn.PreviewMouseDown += delegate(object sender, MouseButtonEventArgs e) { obj.ExecuteOn(); }; buttonOn.PreviewMouseUp += delegate(object sender, MouseButtonEventArgs e) { obj.ExecuteStop(); }; Button buttonOff = new Button(); buttonOff.Height = Double.NaN; buttonOff.Width = Double.NaN; buttonOff.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; buttonOff.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch; buttonOff.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; buttonOff.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; buttonOff.Content = offName; buttonOff.Margin = new Thickness(2); buttonOff.PreviewMouseDown += delegate(object sender, MouseButtonEventArgs e) { obj.ExecuteOff(); }; buttonOff.PreviewMouseUp += delegate(object sender, MouseButtonEventArgs e) { obj.ExecuteStop(); }; ColumnDefinition col1 = new ColumnDefinition(); col1.Width = new GridLength(100, GridUnitType.Star); ColumnDefinition col2 = new ColumnDefinition(); col2.Width = new GridLength(100, GridUnitType.Star); Grid buttonGrid = new Grid(); buttonGrid.Width = double.NaN; buttonGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; buttonGrid.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; buttonGrid.Height = double.NaN; buttonGrid.Margin = new Thickness(0); buttonGrid.ColumnDefinitions.Add(col1); buttonGrid.ColumnDefinitions.Add(col2); buttonGrid.Children.Add(buttonOn); buttonGrid.Children.Add(buttonOff); Grid.SetColumn(buttonOn, 0); Grid.SetColumn(buttonOff, 1); TextBox textBoxRepeat = new TextBox(); textBoxRepeat.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; textBoxRepeat.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; textBoxRepeat.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; textBoxRepeat.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; textBoxRepeat.Height = Double.NaN; textBoxRepeat.Width = Double.NaN; textBoxRepeat.Margin = new Thickness(2); bd = new Binding("RepeatTime"); bd.Source = obj; bd.Mode = BindingMode.TwoWay; textBoxRepeat.SetBinding(TextBox.TextProperty, bd); CheckBox checkBoxRepeatUse = new CheckBox(); checkBoxRepeatUse.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; checkBoxRepeatUse.VerticalAlignment = System.Windows.VerticalAlignment.Center; bd = new Binding("RepeatUse"); bd.Source = obj; bd.Mode = BindingMode.TwoWay; checkBoxRepeatUse.SetBinding(CheckBox.IsCheckedProperty, bd); int rowCount = grid.RowDefinitions.Count - 1; grid.Children.Add(labelName); Grid.SetColumn(labelName, 0); Grid.SetRow(labelName, rowCount); grid.Children.Add(labelStatus); Grid.SetColumn(labelStatus, 1); Grid.SetRow(labelStatus, rowCount); grid.Children.Add(buttonGrid); Grid.SetColumn(buttonGrid, 2); Grid.SetRow(buttonGrid, rowCount); grid.Children.Add(gridInputIOList); Grid.SetColumn(gridInputIOList, 3); Grid.SetRow(gridInputIOList, rowCount); grid.Children.Add(gridOutputIOList); Grid.SetColumn(gridOutputIOList, 4); Grid.SetRow(gridOutputIOList, rowCount); grid.Children.Add(textBoxRepeat); Grid.SetColumn(textBoxRepeat, 5); Grid.SetRow(textBoxRepeat, rowCount); grid.Children.Add(checkBoxRepeatUse); Grid.SetColumn(checkBoxRepeatUse, 6); Grid.SetRow(checkBoxRepeatUse, rowCount); _ioOperationList.Add(obj); bd = new Binding("IsEnabledOutputIODirectControl"); bd.Source = this; bd.Mode = BindingMode.OneWay; gridOutputIOList.SetBinding(ListView.IsEnabledProperty, bd); }