Beispiel #1
0
        private void DialogHost_DialogOpened(object sender, MaterialDesignThemes.Wpf.DialogOpenedEventArgs eventArgs)
        {
            IndexTextBox.Text       = null;
            ActiveBorder.Visibility = Visibility.Visible;
            this.ComponentName.Text = _selectedProxy.FullName;
            System.Drawing.Bitmap bitmap = CanvasRenderEngine.GetObjectBitmap(_selectedProxy.CreateObejct(), this._isInput, out _);
            ShowcaseImage.Source = CanvasRenderEngine.BitmapToBitmapImage(bitmap);

            this.DialogCancelButton.Content = LanguagableComponent.GetTransLation(new string[] { "CANCEL", "取消" });
            this.DialogFinishButton.Content = LanguagableComponent.GetTransLation(new string[] { "ACCEPT", "接受" });
            HintAssist.SetHint(this.IndexTextBox, _isInput ? LanguagableComponent.GetTransLation(new string[] { "Output Index", "输出端索引" }) :
                               LanguagableComponent.GetTransLation(new string[] { "Input Index", "输入端索引" }));
        }
Beispiel #2
0
        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;
        }