protected override void DrawCell(Graphics g) { Rectangle rect = Bounds; rect.Inflate(-2, -2); GraphicsToolkit.Draw3DButton(g, rect, isPressed); }
internal override void DrawFocus(Graphics g) { if (EnableDropWindow) { GraphicsToolkit.DrawDropdownButton(g, dropdownButtonBound, IsDropdown); } base.DrawFocus(g); }
public virtual int GetColorIndexByPoint(Point p) { int i = -1; for (int x = 8; x < 160; x += 20) { for (int y = 8; y < 100; y += 20) { i++; if (GraphicsToolkit.PointInRect(new Rectangle(x - 2, y - 2, 19, 19), p)) { return(i); } } } i++; // no color : 40 if (GraphicsToolkit.PointInRect(new Rectangle(8, 112, 88, 20), p)) { return(i); } i++; // more : 41 if (GraphicsToolkit.PointInRect(new Rectangle(96, 112, 70, 20), p)) { return(i); } // recent : 42 ~ 50 for (int x = 8; x < 160; x += 20) { i++; if (GraphicsToolkit.PointInRect(new Rectangle(x - 2, 142, 19, 19), p)) { return(i); } } return(-1); }
public override void OnPaint(CellDrawingContext dc) { var g = dc.Graphics; RGFloat hh = Bounds.Height / 2 - 1; Rectangle rect = Bounds; Rectangle upRect = new Rectangle(rect.Right - ButtonSize, rect.Top, ButtonSize, hh); GraphicsToolkit.Draw3DButton(g.PlatformGraphics, (System.Drawing.Rectangle)upRect, isUpPressed); GraphicsToolkit.FillTriangle(g.PlatformGraphics, ArrowSize, new Point(upRect.Left + ButtonSize / 2 - ArrowSize / 2, upRect.Top + hh / 2 + (isUpPressed ? 2 : 1)), GraphicsToolkit.TriangleDirection.Up); Rectangle downRect = new Rectangle(rect.Right - ButtonSize, rect.Top + hh + 1, ButtonSize, hh); GraphicsToolkit.Draw3DButton(g.PlatformGraphics, (System.Drawing.Rectangle)downRect, isDownPressed); GraphicsToolkit.FillTriangle(g.PlatformGraphics, ArrowSize, new Point(downRect.Left + ButtonSize / 2 - ArrowSize / 2, downRect.Top + hh / 2 - (isDownPressed ? 1 : 2)), GraphicsToolkit.TriangleDirection.Down); }
public FontSettingsControl() { InitializeComponent(); ShowColorPicker = true; sizeList.Items.AddRange(FontUIToolkit.FontSizeList.Select(f => (object)f).ToArray()); //---------------------------------------------- fontList.SelectedIndexChanged += (s, e) => { if (!updateUI) { updateUI = true; FontFamilyInfo fontFamily = (FontFamilyInfo)fontList.SelectedItem; selectedFont.FontFamilyInfo = fontFamily; UpdateFontStyle(); txtFont.Text = fontFamily.CultureName; labSample.Invalidate(); updateUI = false; RaiseFontNameChanged(); } }; styleList.SelectedIndexChanged += (s, e) => { if (!updateUI) { string style = styleList.SelectedItem as string; if (!string.IsNullOrEmpty(style)) { updateUI = true; selectedFont.Style = FontUIToolkit.GetFontStyleByName(style, "italic", "bold"); if (chkUnderline.Checked) { selectedFont.Style |= FontStyle.Underline; } if (chkStrikeout.Checked) { selectedFont.Style |= FontStyle.Strikeout; } labSample.Invalidate(); updateUI = false; RaiseFontStyleChanged(); } } }; sizeList.SelectedIndexChanged += (s, e) => { if (!updateUI) { updateUI = true; float size = sizeList.SelectedIndex == -1 ? 0 : ((float)sizeList.SelectedItem); txtSize.Text = size == 0 ? string.Empty : size.ToString(); selectedFont.Size = size; labSample.Invalidate(); updateUI = false; RaiseFontSizeChanged(); } }; //---------------------------------------------- txtFont.TextChanged += (s, e) => { string fontName = txtFont.Text; if (!string.IsNullOrEmpty(fontName)) { SetFontNameByString(fontName); } }; txtFont.KeyDown += (s, e) => { switch (e.KeyCode) { case Keys.Up: if (fontList.SelectedIndex > 0) { fontList.SelectedIndex--; } e.Handled = true; break; case Keys.Down: if (fontList.SelectedIndex < fontList.Items.Count - 1) { fontList.SelectedIndex++; } e.Handled = true; break; } }; txtStyle.TextChanged += (s, e) => { if (!updateUI) { updateUI = true; string styleString = txtStyle.Text.Trim(); if (styleString.Length > 0) { foreach (string style in styleList.Items) { if (style.StartsWith(styleString, StringComparison.InvariantCultureIgnoreCase)) { styleList.SelectedItem = style; RaiseFontStyleChanged(); break; } } } updateUI = false; } }; txtStyle.KeyDown += (s, e) => { switch (e.KeyCode) { case Keys.Up: if (styleList.SelectedIndex > 0) { styleList.SelectedIndex--; } e.Handled = true; break; case Keys.Down: if (styleList.SelectedIndex < styleList.Items.Count - 1) { styleList.SelectedIndex++; } e.Handled = true; break; } }; txtSize.TextChanged += (s, e) => { if (!updateUI && txtSize.Text.Trim().Length > 0) { string sizeStr = txtSize.Text; if (sizeStr.StartsWith(" ") || sizeStr.EndsWith(" ")) { sizeStr = sizeStr.Trim(); } float inputSize = SystemFonts.DefaultFont.Size; float.TryParse(txtSize.Text, out inputSize); for (int i = 0; i < sizeList.Items.Count; i++) { if ((float)sizeList.Items[i] == inputSize) { sizeList.SelectedIndex = i; RaiseFontSizeChanged(); break; } } selectedFont.Size = inputSize; labSample.Invalidate(); } }; txtSize.KeyDown += (s, e) => { switch (e.KeyCode) { case Keys.Up: if (sizeList.SelectedIndex > 0) { sizeList.SelectedIndex--; } e.Handled = true; break; case Keys.Down: if (sizeList.SelectedIndex < sizeList.Items.Count - 1) { sizeList.SelectedIndex++; } e.Handled = true; break; } }; labSample.Paint += (s, e) => { Graphics g = e.Graphics; g.Clear(Color.White); if (labSample.ForeColor.A < 255) { GraphicsToolkit.DrawTransparentBlock(g, labSample.ClientRectangle); } using (StringFormat sf = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center, FormatFlags = StringFormatFlags.NoWrap, }) { using (Brush b = new SolidBrush(labSample.ForeColor)) { if (selectedFont != null && !string.IsNullOrEmpty(selectedFont.Name) && selectedFont.Size > 0) { try { using (Font font = new Font(SelectedFont.Name, SelectedFont.Size, SelectedFont.Style)) { g.DrawString(labSample.Text, font, b, labSample.ClientRectangle, sf); } } catch { } } } } }; chkUnderline.CheckedChanged += (s, e) => { if (chkUnderline.Checked) { selectedFont.Style |= FontStyle.Underline; } else { selectedFont.Style &= ~FontStyle.Underline; } labSample.Invalidate(); RaiseFontStyleChanged(); }; chkStrikeout.CheckedChanged += (s, e) => { if (chkStrikeout.Checked) { selectedFont.Style |= FontStyle.Strikeout; } else { selectedFont.Style &= ~FontStyle.Strikeout; } labSample.Invalidate(); RaiseFontStyleChanged(); }; fontColor.ColorSelected += (s, e) => { labSample.ForeColor = fontColor.SolidColor; if (SelectedFontColorChanged != null) { SelectedFontColorChanged(this, null); } }; }
/// <summary> /// Override OnPaint method /// </summary> /// <param name="e">paint event argument</param> protected override void OnPaint(PaintEventArgs e) { System.Drawing.Graphics g = e.Graphics; int hh = (int)Math.Round(Height / 2f); GraphicsToolkit.FillTriangle(g, 8, new Point(10, hh), GraphicsToolkit.TriangleDirection.Left, viewScroll > 0 ? SystemPens.WindowText : SystemPens.GrayText); int max = this.maxWidth - this.ClientRectangle.Width + rightPadding + 10; GraphicsToolkit.FillTriangle(g, 8, new Point(20, hh), GraphicsToolkit.TriangleDirection.Right, viewScroll < max ? SystemPens.WindowText : SystemPens.GrayText); var controlStyle = this.grid.ControlStyle; var borderPen = this.resourceManager.GetPen(controlStyle[ControlAppearanceColors.SheetTabBorder]); var defaultTextBrush = this.resourceManager.GetBrush(this.ForeColor); Rectangle rect = new Rectangle(leftPadding, 0, ClientRectangle.Width - 4, ClientRectangle.Height - 2); #region Border if (this.BorderStyle != SheetTabBorderStyle.NoBorder) { switch (this.Position) { default: case SheetTabControlPosition.Top: g.DrawLine(borderPen, 0, rect.Bottom - 1, ClientRectangle.Right, rect.Bottom - 1); break; case SheetTabControlPosition.Bottom: g.DrawLine(borderPen, 0, rect.Top, ClientRectangle.Right, rect.Top); break; } } #endregion g.SetClip(new Rectangle(ClientRectangle.Left + leftPadding, ClientRectangle.Top, ClientRectangle.Width - leftPadding - rightPadding, ClientRectangle.Height)); g.TranslateTransform(-this.viewScroll, 0); using (var sf = new StringFormat(StringFormat.GenericTypographic) { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center, }) { int textTopPadding = (this.ClientRectangle.Height - this.Font.Height) / 2; #region Unselected items for (int i = 0; i < tabs.Count; i++) { var tab = this.tabs[i]; rect = tab.Bounds; if (i != selectedIndex) { if (!tab.BackgroundColor.IsEmpty && tab.BackgroundColor.A > 0) { using (var bb = new SolidBrush(tab.BackgroundColor)) { g.FillRectangle(bb, rect); } } if (!tab.ForegroundColor.IsEmpty && tab.ForegroundColor.A > 0) { using (var fb = new SolidBrush(tab.ForegroundColor)) { g.DrawString(tab.Title, this.Font, fb, rect, sf); } } else { g.DrawString(tab.Title, this.Font, defaultTextBrush, rect, sf); } if (i > 0) { g.DrawLine(SystemPens.ControlDark, rect.Left, rect.Top + 4, rect.Left, rect.Bottom - 4); } } if (rect.Left > maxWidth) { break; } } #endregion #region Selected item if (this.selectedIndex >= 0 && this.selectedIndex < this.tabs.Count) { var tab = this.tabs[this.selectedIndex]; rect = tab.Bounds; if (rect.Right > this.viewScroll || rect.Left < this.maxWidth - this.viewScroll) { int x = rect.Left, x2 = rect.Right, y = 0, y2 = 0; if (this.BorderStyle != SheetTabBorderStyle.NoBorder) { if (this.BorderStyle == SheetTabBorderStyle.SplitRouned) { x++; x2--; } switch (this.Position) { default: case SheetTabControlPosition.Top: y = rect.Top; y2 = rect.Bottom; if (this.BorderStyle == SheetTabBorderStyle.SplitRouned) { y++; y2--; } break; case SheetTabControlPosition.Bottom: y = rect.Bottom - 1; y2 = rect.Top; if (this.BorderStyle == SheetTabBorderStyle.SplitRouned) { y--; y2++; } break; } // left and right g.DrawLine(borderPen, rect.Left, y, rect.Left, y2); g.DrawLine(borderPen, rect.Right, y, rect.Right, y2); } Brush selectedBackBrush = this.resourceManager.GetBrush(controlStyle[ControlAppearanceColors.SheetTabSelected]); Brush selectedTextBrush = this.resourceManager.GetBrush(controlStyle[ControlAppearanceColors.SheetTabText]); // top or bottom switch (this.Position) { default: case SheetTabControlPosition.Top: var bgrectTop = new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 1, rect.Height - 1); if (!tab.BackgroundColor.IsEmpty && tab.BackgroundColor.A > 0) { using (var bb = new SolidBrush(tab.BackgroundColor)) { g.FillRectangle(bb, bgrectTop); } } else { g.FillRectangle(selectedBackBrush, bgrectTop); } if (this.BorderStyle != SheetTabBorderStyle.NoBorder) { g.DrawLine(borderPen, x, rect.Top, x2, rect.Top); } break; case SheetTabControlPosition.Bottom: var bgrectBottom = new Rectangle(rect.Left + 1, rect.Top, rect.Width - 1, rect.Height - 1); if (!tab.BackgroundColor.IsEmpty && tab.BackgroundColor.A > 0) { using (var bb = new SolidBrush(tab.BackgroundColor)) { g.FillRectangle(bb, bgrectBottom); } } else { g.FillRectangle(selectedBackBrush, bgrectBottom); } if (this.BorderStyle != SheetTabBorderStyle.NoBorder) { g.DrawLine(borderPen, x, rect.Bottom - 1, x2, rect.Bottom - 1); } break; } if (this.BorderStyle != SheetTabBorderStyle.NoBorder && Shadow) { g.DrawLine(borderPen, rect.Right + 1, rect.Top + 2, rect.Right + 1, rect.Bottom - 1); } if (!tab.ForegroundColor.IsEmpty && tab.ForegroundColor.A > 0) { using (var fb = new SolidBrush(tab.ForegroundColor)) { g.DrawString(tab.Title, this.Font, fb, rect, sf); } } else { g.DrawString(tab.Title, this.Font, selectedTextBrush, rect, sf); } } } #endregion // Selected item } g.ResetClip(); g.ResetTransform(); if (this.NewButtonVisible) { g.DrawImage(addButtonHover ? newButtonImage : newButtonDisableImage, new Rectangle(this.ClientRectangle.Width - 28, (this.ClientRectangle.Height - 16) / 2, 16, 16)); } for (int i = 4; i < this.ClientRectangle.Height - 4; i += 4) { g.FillRectangle(SystemBrushes.ControlDark, new Rectangle(this.ClientRectangle.Right - 5, i, 2, 2)); } if (this.movingHoverIndex >= 0 && this.movingHoverIndex <= this.tabs.Count && this.movingHoverIndex != this.movingStartIndex) { Rectangle itemRect = GetItemBounds(this.movingHoverIndex >= this.tabs.Count ? this.tabs.Count - 1 : this.movingHoverIndex); GraphicsToolkit.FillTriangle(g, 8, new Point( (this.movingHoverIndex >= this.tabs.Count ? itemRect.Right : itemRect.Left) - this.viewScroll, itemRect.Top + 4), GraphicsToolkit.TriangleDirection.Up); } base.OnPaint(e); }
protected override void OnPaint(PaintEventArgs e) { GraphicsToolkit.FillTriangle(e.Graphics, 7, new Point(ClientRectangle.Right - 10, ClientRectangle.Top + ClientRectangle.Height / 2 - 1)); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; Rectangle rect = new Rectangle(0, 0, Size.Width - 1, Size.Height - 1); // background Rectangle bgRect = rect; bgRect.Offset(1, 1); //g.FillRectangle(isPressed ? Brushes.Black : Brushes.White, bgRect); // outter frame g.DrawLine(SystemPens.ButtonShadow, rect.X + 1, rect.Y, rect.Right - 1, rect.Y); g.DrawLine(SystemPens.ButtonShadow, rect.X + 1, rect.Bottom, rect.Right - 1, rect.Bottom); g.DrawLine(SystemPens.ButtonShadow, rect.X, rect.Y + 1, rect.X, rect.Bottom - 1); g.DrawLine(SystemPens.ButtonShadow, rect.Right, rect.Y + 1, rect.Right, rect.Bottom - 1); // content Rectangle bodyRect = rect; bodyRect.Inflate(-1, -1); bodyRect.Offset(1, 1); //g.FillRectangle(Brushes.Gainsboro, bodyRect); // shadow if (showShadow) { g.DrawLines(isPressed ? SystemPens.ControlLightLight : SystemPens.ControlDarkDark, new Point[] { new Point(rect.Left + 1, rect.Bottom - 1), new Point(rect.Right - 1, rect.Bottom - 1), new Point(rect.Right - 1, rect.Top + 1), }); } // draw allow if (isPressed) { rect.Offset(1, 1); } try { g.FillPolygon(Brushes.Black, new Point[] { new Point(rect.Right - 13, rect.Top + 8), new Point(rect.Right - 4, rect.Top + 8), new Point(rect.Right - 9, rect.Top + 17), }); } catch { } g.DrawLine(SystemPens.ControlDarkDark, rect.Right - 16, rect.Top + 3, rect.Right - 16, rect.Bottom - 4); g.DrawLine(SystemPens.ControlLightLight, rect.Right - 15, rect.Top + 4, rect.Right - 15, rect.Bottom - 4); // draw color Rectangle colorRect = new Rectangle(4, 4, 14, 14); if (isPressed) { colorRect.Offset(1, 1); } if (currentColor == null || currentColor.IsEmpty) { g.DrawRectangle(Pens.Black, colorRect); g.DrawLine(Pens.Black, colorRect.Left, colorRect.Bottom, colorRect.Right, colorRect.Top); } else if (currentColor is SolidColor) { //g.FillRectangle(ResourcePoolManager.Instance.GetBrush(((SolidColor)currentColor).Color), colorRect); Color c = currentColor.CompliantSolidColor; if (c.A < 255) { GraphicsToolkit.DrawTransparentBlock(g, colorRect); } using (SolidBrush b = new SolidBrush(currentColor.CompliantSolidColor)) { g.FillRectangle(b, colorRect); } } else if (currentColor is LinearGradientColor) { LinearGradientColor lgc = (LinearGradientColor)currentColor; using (LinearGradientBrush b = lgc.CreateGradientBrush(colorRect)) { g.PixelOffsetMode = PixelOffsetMode.Half; g.FillRectangle(b, colorRect); g.PixelOffsetMode = PixelOffsetMode.Default; } } else if (currentColor is HatchPatternColor) { using (HatchBrush b = ((HatchPatternColor)currentColor).CreateHatchBrush()) { g.FillRectangle(b, colorRect); } } }
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; int index = -1; using (SolidBrush b = new SolidBrush(Color.White)) { for (int x = 8, i = 0; x < 160 && i < fixedColor.Length; i++, x += 20) { for (int y = 8, p = 0; y < 100; p++, y += 20) { index++; if (index == hoverColorIndex) { b.Color = SystemColors.Highlight; g.FillRectangle(b, x - 2, y - 2, 18, 18); g.DrawRectangle(SystemPens.WindowFrame, x - 2, y - 2, 18, 18); } if (index == selectedColorIndex) { g.DrawRectangle(SystemPens.Highlight, x - 2, y - 2, 18, 18); } b.Color = fixedColor[i, p]; g.DrawRectangle(Pens.Black, x, y, 14, 14); g.FillRectangle(b, x + 1, y + 1, 13, 13); } } g.DrawLine(SystemPens.ControlDark, 4, 110, ClientRectangle.Width - 4, 110); // no color index++; if (index == hoverColorIndex) { b.Color = SystemColors.Highlight; g.FillRectangle(b, 6, 113, 80, 21); g.DrawRectangle(SystemPens.WindowFrame, 6, 113, 80, 21); } if (index == selectedColorIndex) { g.DrawRectangle(SystemPens.Highlight, 6, 113, 80, 21); } g.DrawRectangle(Pens.Black, 8, 116, 14, 14); g.DrawLine(Pens.Black, 8, 130, 22, 116); g.DrawString(ReoGrid.Editor.LangRes.LangResource.NoColor, Font, index == hoverColorIndex ? SystemBrushes.HighlightText : SystemBrushes.WindowText, new Rectangle(26, 116, 60, 20)); // more index++; if (index == hoverColorIndex) { b.Color = SystemColors.Highlight; g.FillRectangle(b, 95, 113, 68, 21); g.DrawRectangle(SystemPens.WindowFrame, 95, 113, 68, 21); } if (index == selectedColorIndex) { g.DrawRectangle(SystemPens.Highlight, 95, 113, 68, 21); } g.DrawLine(SystemPens.ControlDark, 90, 115, 90, 132); b.Color = currentColor; g.FillRectangle(b, 100, 116, 14, 14); g.DrawRectangle(Pens.Black, 100, 116, 14, 14); g.DrawString(ReoGrid.Editor.LangRes.LangResource.Menu_More, Font, index == hoverColorIndex ? SystemBrushes.HighlightText : SystemBrushes.WindowText, new Rectangle(118, 116, 60, 20)); g.DrawLine(SystemPens.ControlDark, 4, 138, ClientRectangle.Width - 4, 138); // recent colors for (int x = 8, k = 0; x < 160; k++, x += 20) { index++; if (index == hoverColorIndex) { b.Color = SystemColors.Highlight; g.FillRectangle(b, x - 2, 142, 18, 18); g.DrawRectangle(SystemPens.WindowFrame, x - 2, 142, 18, 18); } if (index == selectedColorIndex) { g.DrawRectangle(SystemPens.Highlight, x - 2, 142, 18, 18); } b.Color = recentColor[k]; using (SolidBrush sb = new SolidBrush(b.Color)) { g.FillRectangle(sb, x, 144, 14, 14); g.DrawRectangle(Pens.Black, x, 144, 14, 14); } } // transparent GraphicsToolkit.DrawTransparentBlock(g, transparentRect); using (Brush lineBrush = new LinearGradientBrush(transparentRect, Color.FromArgb(0, Color.White), Color.FromArgb(255, Color.White), LinearGradientMode.Horizontal)) g.FillRectangle(lineBrush, transparentRect); g.DrawRectangle(Pens.DimGray, transparentRect); GraphicsToolkit.FillTriangle(g, 10, new Point(transparentRect.Left + (int)(currentColor.A * transparentRect.Width / 255), transparentRect.Bottom + 6), GraphicsToolkit.TriangleDirection.Up); } }
public SettingForm() { InitializeComponent(); InitCulture(); int r = 0; foreach (ShortcutAction action in ShortcutActionManager.Instance.Actions.Values) { if (action.HideInList) { continue; } ShortcutControlInfo sci = new ShortcutControlInfo { Action = action, }; sci.CheckBox = new CheckBox() { Text = action.Name, Dock = DockStyle.Fill, Tag = sci }; sci.CheckBox.CheckedChanged += new EventHandler(CheckBox_CheckedChanged); unvell.JustCapture.XML.ActionInfo ai = (ConfigurationManager.Instance.GetCurrentUserConfiguration().GetAction(action.Id)); if (ai != null) { sci.CheckBox.Checked = ai.activated; } sci.KeyField = new ShortcutTextbox() { ShortcutKeys = ai == null? Keys.None :ShortcutKeyToolkit.StringToKeys(ai.shortcutKeys), Dock = DockStyle.Fill, Tag = sci }; table.Controls.Add(sci.CheckBox, 0, r); table.Controls.Add(sci.KeyField, 1, r); scis.Add(sci); r++; } if (RegistryToolkit.PermissionToWriteSystemStartup()) { chkStartup.Enabled = true; } else { chkStartup.Enabled = false; imgNoPermission.Visible = true; labNoPermission.Visible = true; } chkStartup.Checked = RegistryToolkit.IsStartupProcessExists(ProductInfo.ProductName); chkStartup.CheckedChanged += (s, e) => { if (chkStartup.Checked) { RegistryToolkit.SetStartupProcess(ProductInfo.ProductName, Application.ExecutablePath); } else { // try delete value of registry if (!RegistryToolkit.RemoveStartupProcess(ProductInfo.ProductName)) { // if deleting is failed, try write a non-existed value to start up registry if (!RegistryToolkit.SetStartupProcess(ProductInfo.ProductName, string.Empty)) { // if value cannot be replaced with an invalid application path, // check on and tell user the startup item cannot be removed imgNoPermission.Visible = labNoPermission.Visible = true; chkStartup.Checked = true; } } } }; // show toolbar chkShowToolboxInCapturer.Checked = ConfigurationManager.Instance.IsCurrentUserSetting( UserConfigKey.CF_Toolstrip, true); // restore last selected region chkRestorePreviousRegion.Checked = ConfigurationManager.Instance.IsCurrentUserSetting( UserConfigKey.User_RestoreLastSelectRegion, true); // check for updates chkCheckForUpdates.Checked = ConfigurationManager.Instance.IsCurrentUserSetting( UserConfigKey.User_EnableCheckForUpdates, true); outerLineColorComboBox.CurrentColor = FileToolkit.DecodeColor(ConfigurationManager.Instance.GetCurrentUserSetting( UserConfigKey.CF_Selection_OuterColor, Color.Black.Name)); innerLineColorComboBox.CurrentColor = FileToolkit.DecodeColor(ConfigurationManager.Instance.GetCurrentUserSetting( UserConfigKey.CF_Selection_InnerColor, Color.Gold.Name)); thumbColorComboBox.CurrentColor = FileToolkit.DecodeColor(ConfigurationManager.Instance.GetCurrentUserSetting( UserConfigKey.CF_Selection_ThumbColor, Color.SkyBlue.Name)); // show coordinate info chkShowCoordinateInfo.Checked = ConfigurationManager.Instance.IsCurrentUserSetting(UserConfigKey.CF_Show_Coordinate_Info, true); // magnifier scale string magnifierScaleStr = ConfigurationManager.Instance.GetCurrentUserSetting(UserConfigKey.CF_Magnifier_Scale, "2"); int magnifierScale = 2; int.TryParse(magnifierScaleStr, out magnifierScale); trkMagnifierScale.ValueChanged += (s, e) => UpdateMagnifierValue(); trkMagnifierScale.Value = magnifierScale; regionSelectionSamplePanel.Paint += (s, e) => { Graphics g = e.Graphics; Rectangle rect = regionSelectionSamplePanel.ClientRectangle; rect.Inflate(-10, -10); RangeHandlerEdit.UpdateRangeHandlers(rect, thumbs); rect.Inflate(3, 3); GraphicsToolkit.DrawDoubleLineRectangle(g, rect, outerLineColorComboBox.CurrentColor, innerLineColorComboBox.CurrentColor); RangeHandlerEdit.DrawRangeHandlerPos(g, thumbs, thumbColorComboBox.CurrentColor); }; outerLineColorComboBox.ColorSelected += (s, e) => regionSelectionSamplePanel.Invalidate(); innerLineColorComboBox.ColorSelected += (s, e) => regionSelectionSamplePanel.Invalidate(); thumbColorComboBox.ColorSelected += (s, e) => regionSelectionSamplePanel.Invalidate(); languageCombo.SelectedValueChanged += (s, e) => { CultureInfo selectedCulture = MainForm.SupportedCultures[languageCombo.SelectedIndex]; if (LangResource.Culture != selectedCulture) { LangResource.Culture = selectedCulture; InitCulture(); } }; ReloadSupportedLanguageList(); chkShowCoordinateInfo.Checked = ConfigurationManager.Instance.IsCurrentUserSetting( UserConfigKey.CF_Show_Coordinate_Info, true); }
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; if (CheckOnClick) { using (HatchBrush hb = new HatchBrush(HatchStyle.SmallConfetti, SystemColors.Window, SystemColors.ControlLight)) { g.FillRectangle(Checked ? hb : SystemBrushes.Window, buttonBounds); } } else { g.FillRectangle(SystemBrushes.Window, buttonBounds); } // left button g.DrawLine(SystemPens.ControlLight, buttonBounds.X + 1, buttonBounds.Y, buttonBounds.Right, buttonBounds.Y); // top g.DrawLine(SystemPens.ControlLight, buttonBounds.X + 1, buttonBounds.Bottom, buttonBounds.Right, buttonBounds.Bottom); // bottom g.DrawLine(SystemPens.ControlLight, buttonBounds.X, buttonBounds.Y + 1, buttonBounds.X, buttonBounds.Bottom - 1); // left g.DrawLine(SystemPens.ControlLight, buttonBounds.Right, buttonBounds.Y + 1, buttonBounds.Right, buttonBounds.Bottom - 1); // right if (isButtonPressed || Checked) { g.DrawLine(SystemPens.ControlDark, buttonBounds.X + 1, buttonBounds.Y + 1, buttonBounds.Right, buttonBounds.Y + 1); g.DrawLine(SystemPens.ControlDark, buttonBounds.X + 1, buttonBounds.Y + 2, buttonBounds.X + 1, buttonBounds.Bottom - 1); // left } Rectangle arrowRect = arrowBounds; if (isPickerPressed) { g.DrawLine(SystemPens.ButtonShadow, arrowRect.X, arrowRect.Y + 1, arrowRect.Right - 1, arrowRect.Y + 1); // top g.DrawLine(SystemPens.ControlDark, arrowRect.X, buttonBounds.Y + 2, arrowRect.X, buttonBounds.Bottom - 1); // right } // right button g.DrawLine(SystemPens.ControlLight, arrowRect.X, arrowRect.Y, arrowRect.Right - 1, arrowRect.Y); // top g.DrawLine(SystemPens.ControlLight, arrowRect.X, arrowRect.Bottom, arrowRect.Right - 1, arrowRect.Bottom); // bottom g.DrawLine(SystemPens.ControlLight, arrowRect.Right, arrowRect.Y + 1, arrowRect.Right, arrowRect.Bottom - 1); // right int arrowoffset = isPickerPressed ? 1: 0; // arrow GraphicsToolkit.FillTriangle(g, arrowSize, new Point( arrowBounds.X + (arrowBounds.Width) / 2 + arrowoffset, arrowBounds.Y + (arrowBounds.Height) / 2 - 1 + arrowoffset)); // color Rectangle buttonRect = new Rectangle(3, 3, 16, 16); if (isButtonPressed || Checked) { buttonRect.Offset(1, 1); } if (Image != null) { g.DrawImage(Image, buttonRect); } else { Rectangle drawRect = new Rectangle(buttonRect.X + (buttonRect.Width - 14) / 2, buttonRect.Y + (buttonRect.Height - 14) / 2, 14, 14); if (currentColor.IsEmpty) { g.DrawRectangle(Pens.Black, drawRect); g.DrawLine(Pens.Black, drawRect.Left, drawRect.Bottom, drawRect.Right, drawRect.Top); } else { using (Pen p = new Pen(currentColor, 2)) { using (Pen ep = new Pen(currentColor)) { using (Brush b = new SolidBrush(currentColor)) { switch (mode) { case ShapeMode.RoundedRect: g.DrawLine(p, drawRect.X + 1, drawRect.Y, drawRect.Right - 1, drawRect.Top); g.DrawLine(p, drawRect.X + 1, drawRect.Bottom, drawRect.Right - 1, drawRect.Bottom); g.DrawLine(p, drawRect.X, drawRect.Y + 1, drawRect.X, drawRect.Bottom - 1); g.DrawLine(p, drawRect.Right, drawRect.Y + 1, drawRect.Right, drawRect.Bottom - 1); break; default: case ShapeMode.Rectangle: g.DrawRectangle(p, drawRect); break; case ShapeMode.Ellipse: g.SmoothingMode = SmoothingMode.AntiAlias; g.DrawEllipse(ep, drawRect); g.SmoothingMode = SmoothingMode.Default; break; case ShapeMode.Line: g.DrawLine(p, drawRect.X, drawRect.Bottom, drawRect.Right, drawRect.Top); break; case ShapeMode.Arrow: int y = drawRect.Top + drawRect.Height / 2; using (Pen arrow = new Pen(currentColor)) { arrow.CustomEndCap = new AdjustableArrowCap(4, 4); g.DrawLine(arrow, drawRect.X, y, drawRect.Right, y); } break; case ShapeMode.Number: g.SmoothingMode = SmoothingMode.AntiAlias; g.DrawEllipse(ep, drawRect); g.SmoothingMode = SmoothingMode.Default; using (StringFormat sf = new StringFormat(StringFormat.GenericTypographic)) { sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; string str = currentNumber.ToString(); SizeF s = g.MeasureString(str, numberFont, drawRect.Width, sf); g.DrawString(str, numberFont, b, drawRect, sf); } break; case ShapeMode.Text: using (StringFormat sf = new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center, }) { g.DrawString("A", SystemFonts.DialogFont, b, drawRect, sf); } break; } } } } } } }