private Button CreateAIconButton(PackIconKind icon, System.Drawing.Color forecolor, string tooltip = null) { Button button = new Button() { Margin = new Thickness(4, 0, 4, 0), Content = new PackIcon() { Kind = icon, Height = 24, Width = 24, Foreground = new SolidColorBrush(ColorExtension.ConvertToMediaColor(forecolor)) }, ToolTip = tooltip, }; button.SetValue(Button.StyleProperty, this.Resources["MaterialDesignFloatingActionMiniAccentButton"]); return(button); }
private void IndexTextBox_TextChanged(object sender, TextChangedEventArgs e) { DialogFinishButton.IsEnabled = true; SelectedMessage.Text = SelectedParam.Text = null; System.Drawing.Bitmap bitmap; SelectedMessage.Foreground = new SolidColorBrush(ColorExtension.ConvertToMediaColor(System.Drawing.Color.DimGray)); byte index; if (byte.TryParse(IndexTextBox.Text, out index)) { IGH_Param dataType; bitmap = CanvasRenderEngine.GetObjectBitmap(_selectedProxy.CreateObejct(), this._isInput, out dataType, index); if (bitmap != null) { ShowcaseImage.Source = CanvasRenderEngine.BitmapToBitmapImage(bitmap); SelectedParam.Text = $"{dataType.Name} [{dataType.Type.Name}]"; if (this._proxy.TypeFullName != dataType.Type.FullName) { SelectedMessage.Text += LanguagableComponent.GetTransLation(new string[] { "Data Type is not the Same!", "数据类型并不一致!" }); SelectedMessage.Foreground = new SolidColorBrush(ColorExtension.ConvertToMediaColor(System.Drawing.Color.DarkOrange)); } } else { bitmap = CanvasRenderEngine.GetObjectBitmap(_selectedProxy.CreateObejct(), this._isInput, out _); SelectedMessage.Text = LanguagableComponent.GetTransLation(new string[] { "Input data is out of range!", "输入数据超出索引阈值!" }); SelectedMessage.Foreground = new SolidColorBrush(ColorExtension.ConvertToMediaColor(System.Drawing.Color.DarkRed)); DialogFinishButton.IsEnabled = false; } } else { bitmap = CanvasRenderEngine.GetObjectBitmap(_selectedProxy.CreateObejct(), this._isInput, out _); SelectedMessage.Text = LanguagableComponent.GetTransLation(new string[] { "Please input a number between 0 - 255!", "请输入一个0 - 255的数值!" }); SelectedMessage.Foreground = new SolidColorBrush(ColorExtension.ConvertToMediaColor(System.Drawing.Color.DarkRed)); DialogFinishButton.IsEnabled = false; } ShowcaseImage.Source = CanvasRenderEngine.BitmapToBitmapImage(bitmap); this._paramIndex = index; }
internal void WindowSwitchControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (MajorGrid == null || ButtonPanel == null) { return; } MajorGrid.Children.Clear(); ButtonPanel.Children.Clear(); switch (SelectionBox.SelectedIndex) { case 0: #region Add major ColorPicker color = new ColorPicker() { Color = this.WireColor }; MajorGrid.Children.Add(color); #endregion #region Add Button ButtonPanel.Children.Add(CreateARespondIconButton(PackIconKind.Refresh, System.Drawing.Color.DarkRed, (x, y) => { this.SetWireColor(ColorExtension.ConvertToMediaColor(this._wireColor)); this._proxy.Owner.ExpireSolution(true); }, LanguagableComponent.GetTransLation(new string[] { "Reset", "重置" }))); ButtonPanel.Children.Add(CreateARespondIconButton(PackIconKind.Refresh, System.Drawing.Color.DimGray, (x, y) => { this.SetWireColor(color); this._proxy.Owner.ExpireSolution(true); }, LanguagableComponent.GetTransLation(new string[] { "Refresh", "刷新" }))); SelectionBox.SelectionChanged += (x, y) => { this.SetWireColor(color); }; OKButton.Click += (x, y) => { this.SetWireColor(color); }; #endregion break; case 1: #region Add major MajorGrid.Children.Add(CreateDataGrid(true)); #endregion #region Add Button IOControlButton(true); #endregion break; case 2: #region Add major MajorGrid.Children.Add(CreateDataGrid(false)); #endregion #region Add Button IOControlButton(false); #endregion break; default: throw new ArgumentOutOfRangeException("selectedindex", "index is out of range."); } }