public static void PrintHeader(ICellSurface target, SadConsole.UI.Colors themeColors, Point position, int totalWidth, string text) { totalWidth = totalWidth - text.Length - 3; if (totalWidth < 0) { throw new Exception("Header text too small"); } var lineText = ColoredString.FromGradient( new Gradient( new[] { themeColors.White, themeColors.White, themeColors.Gray, themeColors.Gray, themeColors.GrayDark, themeColors.GrayDark }, new[] { 0f, 0.3f, 0.31f, 0.65f, 0.66f, 1f }), new string((char)196, totalWidth)); target.Print(position.X, position.Y, new ColoredString(new ColoredGlyph(themeColors.White, Color.Transparent, 196)) + new ColoredString(new ColoredGlyph(themeColors.Cyan, Color.Transparent, 254)) + new ColoredString(text, themeColors.Title, Color.Transparent) + new ColoredString(new ColoredGlyph(themeColors.Cyan, Color.Transparent, 254)) ); var targetPosition = Point.FromIndex(position.ToIndex(target.Width) + text.Length + 3, target.Width); target.Print(targetPosition.X, targetPosition.Y, lineText); }
private void ButtonLoad_Click(object sender, EventArgs e) { Windows.SelectEditorFilePopup popup = new Windows.SelectEditorFilePopup(); popup.Closed += (s, e) => { if (popup.DialogResult) { EditingColors = SadConsole.Serializer.Load <Colors>(popup.SelectedFile, false); SettingsPanel.RefreshColors(); RefreshTestingPanel(); } }; popup.Show(true); }
public Container() { EditingColors = SadConsole.UI.Themes.Library.Default.Colors.Clone(); //EditingColors = SadConsole.UI.Colors.CreateSadConsoleBlue(); OptionsPanel = new ControlsConsole(6, 2); Border.AddToSurface(OptionsPanel, ""); OptionsPanel.Position = (2, 1); Button button = new Button(6, 1) { Text = "Load", Position = (0, 0) }; button.Click += ButtonLoad_Click; OptionsPanel.Controls.Add(button); button = new Button(6, 1) { Text = "Save", Position = (0, 1) }; button.Click += ButtonSave_Click; OptionsPanel.Controls.Add(button); SettingsPanel = new SettingsConsole(30, 36); Border.AddToSurface(SettingsPanel, "Settings"); SettingsPanel.Position = (4, 3); TestingPanel = new ControlsTest(); Border.AddToSurface(TestingPanel, "Preview"); TestingPanel.Position = SettingsPanel.Position + (SettingsPanel.Surface.Area.Width, 0) + (4, 0); TestingPanel.Controls.ThemeColors = EditingColors; Children.Add(SettingsPanel); Children.Add(OptionsPanel); Children.Add(TestingPanel); }
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; }
/// <summary> /// Creates a new colors object with the default blue colors theme of SadConsole. /// </summary> /// <returns></returns> public static Colors CreateSadConsoleBlue() { var colors = new Colors(0) { White = Color.White, Black = Color.Black, Gray = new Color(176, 196, 222), GrayDark = new Color(66, 66, 66), Red = new Color(255, 0, 51), Green = new Color(153, 224, 0), Blue = new Color(102, 204, 255), Purple = new Color(132, 0, 214), Yellow = new Color(255, 255, 102), Orange = new Color(255, 153, 0), Cyan = new Color(82, 242, 234), Brown = new Color(100, 59, 15), RedDark = new Color(153, 51, 51), GreenDark = new Color(110, 166, 23), BlueDark = new Color(51, 102, 153), PurpleDark = new Color(70, 0, 114), YellowDark = new Color(255, 207, 15), OrangeDark = new Color(255, 102, 0), CyanDark = new Color(33, 182, 168), BrownDark = new Color(119, 17, 0), Gold = new Color(255, 215, 0), GoldDark = new Color(127, 107, 0), Silver = new Color(192, 192, 192), SilverDark = new Color(169, 169, 169), Bronze = new Color(205, 127, 50), BronzeDark = new Color(144, 89, 35) }; colors.IsLightTheme = true; colors.Title = new AdjustableColor(ColorNames.Orange, "Title", colors); colors.Lines = new AdjustableColor(ColorNames.Gray, "Lines", colors); colors.ControlForegroundNormal = new AdjustableColor(ColorNames.Blue, "Control Foreground Normal", colors); colors.ControlForegroundDisabled = new AdjustableColor(ColorNames.Gray, "Control Foreground Disabled", colors); colors.ControlForegroundMouseOver = new AdjustableColor(ColorNames.Blue, "Control Foreground MouseOver", colors); colors.ControlForegroundMouseDown = new AdjustableColor(ColorNames.BlueDark, "Control Foreground MouseDown", colors); colors.ControlForegroundSelected = new AdjustableColor(ColorNames.Yellow, "Control Foreground Selected", colors); colors.ControlForegroundFocused = new AdjustableColor(ColorNames.Cyan, "Control Foreground Focused", colors); colors.ControlBackgroundNormal = new AdjustableColor(ColorNames.BlueDark, "Control Background Normal", colors); colors.ControlBackgroundDisabled = new AdjustableColor(ColorNames.BlueDark, "Control Background Disabled", colors); colors.ControlBackgroundMouseOver = new AdjustableColor(ColorNames.BlueDark, "Control Background MouseOver", colors) { Brightness = Brightness.Dark }; colors.ControlBackgroundMouseDown = new AdjustableColor(ColorNames.Blue, "Control Background MouseDown", colors); colors.ControlBackgroundSelected = new AdjustableColor(ColorNames.BlueDark, "Control Background Selected", colors); colors.ControlBackgroundFocused = new AdjustableColor(ColorNames.BlueDark, "Control Background Focused", colors) { Brightness = Brightness.Dark }; colors.ControlHostForeground = new AdjustableColor(ColorNames.Blue, "Control Host Foreground", colors); colors.ControlHostBackground = new AdjustableColor(ColorNames.BlueDark, "Control Host Background", colors); // Rebuild the controls colors.RebuildAppearances(); return(colors); }