コード例 #1
0
        private void themePartSettingColorSet_Click(object sender, EventArgs e)
        {
            AdjustableColor setting = _themeParts[_themePartSelectedIndex];

            if (setting.IsCustomColor)
            {
                ColorPickerPopup window = new ColorPickerPopup();
                window.Center();
                window.SelectedColor = _themeParts[_themePartSelectedIndex].BaseColor;
                window.Closed       += (s, e) =>
                {
                    if (window.DialogResult)
                    {
                        _themeParts[_themePartSelectedIndex].SetColor(window.SelectedColor, Container.EditingColors, Colors.Brightness.Normal);
                        DrawThemeParts();
                    }
                };
                window.Show(true);
            }
            else
            {
                SelectPaletteColor window = new SelectPaletteColor(setting.UIColor);
                window.Center();
                window.Closed += (s, e) =>
                {
                    if (window.DialogResult)
                    {
                        _themeParts[_themePartSelectedIndex].SetUIColor(window.SelectedColor, Container.EditingColors, Colors.Brightness.Normal);
                        DrawThemeParts();
                    }
                };
                window.Show(true);
            }
        }
コード例 #2
0
        private void GenerateShaderInputControl(ShaderModelConstantRegister register)
        {
            string toolTipText = String.IsNullOrEmpty(register.Description) ? null : register.Description;

            TextBlock textBlock = new TextBlock
            {
                Foreground = Brushes.White,
                Margin     = new Thickness(5),
                Inlines    =
                {
                    new Run {
                        Foreground = (Brush)Application.Current.FindResource("HighlightBrush"), Text = register.RegisterName
                    },
                    new Run {
                        Text = String.Format(" : {0}", register.RegisterType.Name)
                    },
                },
                ToolTip = toolTipText
            };

            inputControlPanel.Children.Add(textBlock);

            Control control = null;

            if (register.RegisterType == typeof(Brush))
            {
                control = new TexturePicker(register);
            }
            else if (register.RegisterType == typeof(double) || register.RegisterType == typeof(float))
            {
                double minValue = Convert.ToDouble(register.MinValue);
                double maxValue = Convert.ToDouble(register.MaxValue);
                //double defaultValue = Double.Parse(register.DefaultValue.ToString(), NumberStyles.Any, null);
                double defaultValue = Convert.ToDouble(register.DefaultValue);
                control = new AdjustableSlider
                {
                    Minimum = Math.Min(minValue, defaultValue),
                    Maximum = Math.Max(maxValue, defaultValue),
                    Value   = defaultValue
                };
            }
            else if (register.RegisterType == typeof(Point) || register.RegisterType == typeof(Vector) || register.RegisterType == typeof(Size))
            {
                Point minValue     = (Point)RegisterValueConverter.ConvertToUsualType(register.MinValue);
                Point maxValue     = (Point)RegisterValueConverter.ConvertToUsualType(register.MaxValue);
                Point defaultValue = (Point)RegisterValueConverter.ConvertToUsualType(register.DefaultValue);
                control = new AdjustableSliderPair
                {
                    Minimum = new Point(Math.Min(minValue.X, defaultValue.X), Math.Min(minValue.Y, defaultValue.Y)),
                    Maximum = new Point(Math.Max(maxValue.X, defaultValue.X), Math.Max(maxValue.Y, defaultValue.Y)),
                    Value   = defaultValue
                };
            }
            else if (register.RegisterType == typeof(Point3D) || register.RegisterType == typeof(Vector3D))
            {
                Point3D minValue     = (Point3D)RegisterValueConverter.ConvertToUsualType(register.MinValue);
                Point3D maxValue     = (Point3D)RegisterValueConverter.ConvertToUsualType(register.MaxValue);
                Point3D defaultValue = (Point3D)RegisterValueConverter.ConvertToUsualType(register.DefaultValue);
                control = new AdjustableSliderTriplet
                {
                    Minimum = new Point3D(Math.Min(minValue.X, defaultValue.X), Math.Min(minValue.Y, defaultValue.Y), Math.Min(minValue.Z, defaultValue.Z)),
                    Maximum = new Point3D(Math.Max(maxValue.X, defaultValue.X), Math.Max(maxValue.Y, defaultValue.Y), Math.Max(maxValue.Z, defaultValue.Z)),
                    Value   = defaultValue
                };
            }
            else if (register.RegisterType == typeof(Color))
            {
                Color defaultValue = (Color)register.DefaultValue;
                //control = new Telerik.Windows.Controls.RadColorEditor
                //{

                //  HorizontalAlignment = HorizontalAlignment.Left,
                //  SelectedColor = defaultValue
                //};

                control = new AdjustableColor
                {
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Value = defaultValue
                };
                //  ((control) as AdjustableColor).;
                //control = new TextBox
                //{
                //  Background = Brushes.LightYellow,
                //  Width = 150,
                //  HorizontalAlignment = HorizontalAlignment.Left,
                //  Text = defaultValue.ToString()
                //};
            }
            else if (register.RegisterType == typeof(Point4D))
            {
                Point4D minValue     = (Point4D)register.MinValue;
                Point4D maxValue     = (Point4D)register.MaxValue;
                Point4D defaultValue = (Point4D)register.DefaultValue;
                control = new AdjustableSliderQuadruplet
                {
                    Minimum = new Point4D(Math.Min(minValue.X, defaultValue.X), Math.Min(minValue.Y, defaultValue.Y), Math.Min(minValue.Z, defaultValue.Z), Math.Min(minValue.W, defaultValue.W)),
                    Maximum = new Point4D(Math.Max(maxValue.X, defaultValue.X), Math.Max(maxValue.Y, defaultValue.Y), Math.Max(maxValue.Z, defaultValue.Z), Math.Max(maxValue.W, defaultValue.W)),
                    Value   = defaultValue
                };
            }

            if (control != null)
            {
                control.Margin  = new Thickness(15, 2, 25, 5);
                control.ToolTip = toolTipText;
                this.inputControlPanel.Children.Add(control);
                register.AffiliatedControl = control;
            }
        }
コード例 #3
0
        private void DrawThemeParts()
        {
            SadConsole.UI.Colors colors = Controls.GetThemeColors();
            Surface.Clear(_themePartsArea);
            int y      = _themePartsArea.Y;
            int themeY = 0;

            UpdateColors();

            AdjustableColor selectedSetting = _themeParts[_themePartSelectedIndex];

            for (int i = 0; i < _themeParts.Length; i++)
            {
                int row = y + i;
                if (i == _themePartSelectedIndex)
                {
                    themeY = row;
                    Surface.Print(3, row, ColoredString.Parse(GetThemePartString(selectedSetting.ComputedColor, selectedSetting.Name.Replace("Control ", ""))));
                    Surface.SetGlyph(2, row, ICellSurface.ConnectedLineThin[0], colors.Lines);
                    Surface.DrawLine(new Point(2, row + 1), (_themePartsArea.MaxExtentX, row + 1), ICellSurface.ConnectedLineThin[0], colors.Lines);
                    Surface.DrawLine(new Point(_themePartsArea.MaxExtentX, row + 1), new Point(_themePartsArea.MaxExtentX, row + _themePartSelectedAreaSize), ICellSurface.ConnectedLineThin[0], colors.Lines);
                    Surface.DrawLine(new Point(_themePartsArea.MaxExtentX, row + _themePartSelectedAreaSize + 1), new Point(2, row + _themePartSelectedAreaSize + 1), ICellSurface.ConnectedLineThin[0], colors.Lines);

                    y += _themePartSelectedAreaSize + 1;
                }
                else
                {
                    Surface.Print(3, row, ColoredString.Parse(GetThemePartString(_themeParts[i].ComputedColor, _themeParts[i].Name.Replace("Control ", ""))));
                    Surface.SetGlyph(2, row, ICellSurface.ConnectedLineThin[0], colors.Lines);
                }
            }

            // Connect all the lines for the selected theme area
            Surface.ConnectLines(ICellSurface.ConnectedLineThin, _themePartsArea);

            // Draw the shade selection area
            _themePartsShadeBoxes = new TextField(new Point(_themePartsArea.MaxExtentX - 10, themeY + 3), 10, Surface);
            var colorPreviewText     = new TextField(_themePartsShadeBoxes.Position.WithY(themeY + 2), 5, Surface);
            var colorPreviewBarsText = new TextField(new Point(colorPreviewText.Position.X + colorPreviewText.Width, themeY + 2), 5, Surface);
            var shadePreviewBarsText = new TextField(_themePartsShadeBoxes.Position.WithY(themeY + 4), 5, Surface);
            var shadePreviewText     = new TextField(new Point(shadePreviewBarsText.Position.X + shadePreviewBarsText.Width, themeY + 4), 5, Surface);
            var intoColorPreviewText = new TextField(new Point(colorPreviewText.Position.X - 3, colorPreviewText.Position.Y), 3, Surface);

            var intoColorPreviewString = new ColoredString(3);

            intoColorPreviewString.SetForeground(colors.Lines);
            intoColorPreviewString.SetGlyph(ICellSurface.ConnectedLineThin[(int)ICellSurface.ConnectedLineIndex.Top]);

            var colorPreviewString = new ColoredString(5);

            colorPreviewString.SetForeground(selectedSetting.BaseColor);
            colorPreviewString[0].Glyph = 301;
            colorPreviewString[1].Glyph = 303;
            colorPreviewString[2].Glyph = 303;
            colorPreviewString[3].Glyph = 303;
            colorPreviewString[4].Glyph = 302;

            var colorPreviewBarsString = new ColoredString(5);

            colorPreviewBarsString.SetForeground(colors.Lines);
            colorPreviewBarsString.SetGlyph(ICellSurface.ConnectedLineThin[(int)ICellSurface.ConnectedLineIndex.Top]);
            colorPreviewBarsString[4].Glyph = ICellSurface.ConnectedLineThin[(int)ICellSurface.ConnectedLineIndex.TopRight];

            var shadeBarsString = new ColoredString(10);

            shadeBarsString[0].Glyph = 299; shadeBarsString[0].Foreground = selectedSetting.BaseColor.GetBrightest();
            shadeBarsString[1].Glyph = 300; shadeBarsString[1].Foreground = selectedSetting.BaseColor.GetBrightest();
            shadeBarsString[2].Glyph = 299; shadeBarsString[2].Foreground = selectedSetting.BaseColor.GetBright();
            shadeBarsString[3].Glyph = 300; shadeBarsString[3].Foreground = selectedSetting.BaseColor.GetBright();
            shadeBarsString[4].Glyph = 299; shadeBarsString[4].Foreground = selectedSetting.BaseColor;
            shadeBarsString[5].Glyph = 300; shadeBarsString[5].Foreground = selectedSetting.BaseColor;
            shadeBarsString[6].Glyph = 299; shadeBarsString[6].Foreground = selectedSetting.BaseColor.GetDark();
            shadeBarsString[7].Glyph = 300; shadeBarsString[7].Foreground = selectedSetting.BaseColor.GetDark();
            shadeBarsString[8].Glyph = 299; shadeBarsString[8].Foreground = selectedSetting.BaseColor.GetDarkest();
            shadeBarsString[9].Glyph = 300; shadeBarsString[9].Foreground = selectedSetting.BaseColor.GetDarkest();

            var shadePreviewBarsString = new ColoredString(5);

            shadePreviewBarsString.SetForeground(colors.Lines);
            shadePreviewBarsString.SetGlyph(ICellSurface.ConnectedLineThin[(int)ICellSurface.ConnectedLineIndex.Top]);
            shadePreviewBarsString[0].Glyph = ICellSurface.ConnectedLineThin[(int)ICellSurface.ConnectedLineIndex.BottomLeft];

            var shadePreviewString = new ColoredString(5);

            shadePreviewString.SetForeground(selectedSetting.ComputedColor);
            shadePreviewString[0].Glyph = 301;
            shadePreviewString[1].Glyph = 303;
            shadePreviewString[2].Glyph = 303;
            shadePreviewString[3].Glyph = 303;
            shadePreviewString[4].Glyph = 302;

            intoColorPreviewText.Print(intoColorPreviewString);
            colorPreviewText.Print(colorPreviewString);
            colorPreviewBarsText.Print(colorPreviewBarsString);
            shadePreviewBarsText.Print(shadePreviewBarsString);
            shadePreviewText.Print(shadePreviewString);

            // Position the controls
            _themePartSettingColorSet.Position           = (3, themeY + 2);
            _themePartSettingIsPredefinedColor.Position  = (3, themeY + 3);
            _themePartSettingIsCustomColor.Position      = (3, themeY + 4);
            _themePartSettingColorSet.IsVisible          = true;
            _themePartSettingIsCustomColor.IsVisible     = true;
            _themePartSettingIsPredefinedColor.IsVisible = true;

            // Configure controls/shade
            _themePartSettingIsCustomColor.IsSelected     = selectedSetting.IsCustomColor;
            _themePartSettingIsPredefinedColor.IsSelected = !selectedSetting.IsCustomColor;

            switch (selectedSetting.Brightness)
            {
            case Colors.Brightness.Brightest:
                shadeBarsString[0].Glyph = 301;
                shadeBarsString[1].Glyph = 302;
                break;

            case Colors.Brightness.Bright:
                shadeBarsString[2].Glyph = 301;
                shadeBarsString[3].Glyph = 302;
                break;

            case Colors.Brightness.Normal:
                shadeBarsString[4].Glyph = 301;
                shadeBarsString[5].Glyph = 302;
                break;

            case Colors.Brightness.Dark:
                shadeBarsString[6].Glyph = 301;
                shadeBarsString[7].Glyph = 302;
                break;

            case Colors.Brightness.Darkest:
                shadeBarsString[8].Glyph = 301;
                shadeBarsString[9].Glyph = 302;
                break;

            default:
                break;
            }
            _themePartsShadeBoxes.Print(shadeBarsString);


            Controls.IsDirty = true;
        }