diff --git a/Documents/Help/Changelog.md b/Documents/Help/Changelog.md index 6255c7f83..8632579fe 100644 --- a/Documents/Help/Changelog.md +++ b/Documents/Help/Changelog.md @@ -7,8 +7,9 @@ * Implemented [#1223](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1223), Move `UseKryptonFileDialogs` to a better designer location * Implemented [#1222](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1222), Remove `CustomPalette` (Should be part of the palette definition) * Implemented [#1204](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1204), Build on `KryptonCommandLinkButtons` - - [#1216](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1216), Add support for fonts + - [#1218](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1218), Default 'arrow' images, depending on OS version - [#1217](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1217), Add support for text alignment + - [#1216](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1216), Add support for fonts * Resolved [#996](https://github.com/Krypton-Suite/Standard-Toolkit/issues/996), DataGridView ComboBox Adding list over and over * Resolved [#1207](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1207), Microsoft 365 - Black (Dark Mode) Drop button is not visible * Resolved [#1206](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1206), Remove the Font Size (as it is already covered by the actual font !) diff --git a/README.md b/README.md index aa575ac6f..23df1764e 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ * [Support for .NET 7](#support-for-net-7) * [`KryptonButton` Properties](#kryptonbutton-properties) * [API Changes](#api-changes) + * [`KryptonInputBox`](#kryptoninputbox) * [V80.## (2023-11-14 - Build 2311 - November 2023)](#v80-2023-11-14---build-2311---november-2023) * [Support for .NET Core 3.1 and .NET 5](#support-for-net-core-31-and-net-5) * [KryptonMessageBoxButtons](#kryptonmessageboxbuttons) @@ -193,6 +194,9 @@ Some properties previously found in the root such as, `ShowSplitOption`, `UseAsA ### API Changes If using `KryptonAboutToolkit`, please note that this has been superceeded by `KryptonAboutBox`. Or if you use `KryptonThemeBrowserForm`, it has now been moved to `KryptonThemeBrowser` as the public facing API. +### `KryptonInputBox` +The `KryptonInputBox` now uses the new `KryptonInputBoxData` API, to handle data. + ## V80.## (2023-11-14 - Build 2311 - November 2023) There are list of changes that have occurred during the development of the V80.## version diff --git a/Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.sln b/Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.sln index ccbb273b7..9cd61a0ba 100644 --- a/Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.sln +++ b/Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.sln @@ -30,6 +30,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Configuration", "Configurat ..\.editorconfig = ..\.editorconfig ..\..\.gitattributes = ..\..\.gitattributes ..\..\.gitignore = ..\..\.gitignore + Krypton Toolkit Suite 2022 - VS2022.sln.DotSettings = Krypton Toolkit Suite 2022 - VS2022.sln.DotSettings EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{950EE50E-C0E8-4A28-96D3-4735F5313610}" diff --git a/Source/Krypton Components/Krypton.Navigator/Controls Navigator/KryptonNavigator.cs b/Source/Krypton Components/Krypton.Navigator/Controls Navigator/KryptonNavigator.cs index a0175e7f8..a4983f203 100644 --- a/Source/Krypton Components/Krypton.Navigator/Controls Navigator/KryptonNavigator.cs +++ b/Source/Krypton Components/Krypton.Navigator/Controls Navigator/KryptonNavigator.cs @@ -860,7 +860,7 @@ public bool AllowTabSelect /// [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ToolTipManager ToolTipManager { get; private set; } + public ToolTipManager? ToolTipManager { get; private set; } #endregion @@ -1834,7 +1834,7 @@ protected virtual void OnNeedPagePaint(object sender, NeedLayoutEventArgs e) internal void InternalForceViewLayout() => ForceViewLayout(); - internal ToolTipManager HoverManager { get; private set; } + internal ToolTipManager? HoverManager { get; private set; } internal bool InternalDesignMode => DesignMode; diff --git a/Source/Krypton Components/Krypton.Ribbon/Controls Ribbon/KryptonGallery.cs b/Source/Krypton Components/Krypton.Ribbon/Controls Ribbon/KryptonGallery.cs index 8e963adaf..92504d7c0 100644 --- a/Source/Krypton Components/Krypton.Ribbon/Controls Ribbon/KryptonGallery.cs +++ b/Source/Krypton Components/Krypton.Ribbon/Controls Ribbon/KryptonGallery.cs @@ -110,7 +110,7 @@ public KryptonGallery() DropButtonRanges = []; // Create the palette storage - StateCommon = new PaletteGalleryRedirect(Redirector!, NeedPaintDelegate); + StateCommon = new PaletteGalleryRedirect(Redirector, NeedPaintDelegate); StateNormal = new PaletteGalleryState(StateCommon, NeedPaintDelegate); StateDisabled = new PaletteGalleryState(StateCommon, NeedPaintDelegate); StateActive = new PaletteGalleryState(StateCommon, NeedPaintDelegate); @@ -129,7 +129,7 @@ public KryptonGallery() // The draw layout that contains the actual selection images _backBorder = new PaletteGalleryBackBorder(StateNormal); _drawDocker = new ViewDrawDocker(_backBorder, _backBorder); - _drawItems = new ViewLayoutRibbonGalleryItems(Redirector!, this, NeedPaintDelegate, _buttonUp, _buttonDown, _buttonContext); + _drawItems = new ViewLayoutRibbonGalleryItems(Redirector, this, NeedPaintDelegate, _buttonUp, _buttonDown, _buttonContext); _drawDocker.Add(_drawItems, ViewDockStyle.Fill); // Top level layout view diff --git a/Source/Krypton Components/Krypton.Ribbon/Controls Ribbon/KryptonRibbon.cs b/Source/Krypton Components/Krypton.Ribbon/Controls Ribbon/KryptonRibbon.cs index da9af5eaa..230d7858d 100644 --- a/Source/Krypton Components/Krypton.Ribbon/Controls Ribbon/KryptonRibbon.cs +++ b/Source/Krypton Components/Krypton.Ribbon/Controls Ribbon/KryptonRibbon.cs @@ -1160,7 +1160,7 @@ public bool DesignerGetHitTest(Point pt) } // Get the view the mouse is currently over - ViewBase? mouseView = ViewManager?.Root?.ViewFromPoint(pt); + ViewBase? mouseView = ViewManager?.Root.ViewFromPoint(pt); // Do we match of the views we always allow? var matchView = (mouseView?.Parent != null) @@ -1210,7 +1210,7 @@ public Point ViewRectangleToPoint(ViewBase? view) } // Get the view the mouse is currently over - ViewBase? mouseView = ViewManager?.Root?.ViewFromPoint(pt); + ViewBase? mouseView = ViewManager?.Root.ViewFromPoint(pt); if (mouseView is ViewDrawRibbonGroupDateTimePicker picker) { @@ -1270,7 +1270,7 @@ protected override void OnLayout(LayoutEventArgs levent) // Cannot process a message for a disposed control if (!IsDisposed && !Disposing) { - TabsArea?.AppButtonVisibleChanged(); + TabsArea.AppButtonVisibleChanged(); CaptionArea?.AppButtonVisibleChanged(); } @@ -2524,7 +2524,7 @@ internal Point ViewPointToScreen(Point pt) => VisualPopupManager.Singleton.Curre internal Rectangle ViewRectangleToScreen(ViewBase view) => view.OwningControl!.RectangleToScreen(view.ClientRectangle); - internal Rectangle KeyTipToScreen(ViewBase view) => view.OwningControl!.RectangleToScreen(view.ClientRectangle); + internal Rectangle KeyTipToScreen(ViewBase? view) => view!.OwningControl!.RectangleToScreen(view.ClientRectangle); internal ViewBase? FocusView { @@ -2674,7 +2674,7 @@ private void CreateStorageObjects() RibbonStrings = new RibbonStrings(); RibbonAppButton = new RibbonAppButton(this); RibbonStyles = new PaletteRibbonStyles(this, NeedPaintPaletteDelegate); - StateCommon = new PaletteRibbonRedirect(Redirector!, PaletteBackStyle.PanelClient, NeedPaintPaletteDelegate); + StateCommon = new PaletteRibbonRedirect(Redirector, PaletteBackStyle.PanelClient, NeedPaintPaletteDelegate); StateDisabled = new PaletteRibbonDisabled(StateCommon, NeedPaintPaletteDelegate); StateNormal = new PaletteRibbonNormal(StateCommon, NeedPaintPaletteDelegate); StateTracking = new PaletteRibbonAppGroupTab(StateCommon, NeedPaintPaletteDelegate); @@ -2685,7 +2685,7 @@ private void CreateStorageObjects() StateContextTracking = new PaletteRibbonGroupTab(StateCommon, NeedPaintPaletteDelegate); StateContextCheckedNormal = new PaletteRibbonGroupAreaTab(StateCommon, NeedPaintPaletteDelegate); StateContextCheckedTracking = new PaletteRibbonJustTab(StateCommon, NeedPaintPaletteDelegate); - OverrideFocus = new PaletteRibbonFocus(Redirector!, NeedPaintPaletteDelegate); + OverrideFocus = new PaletteRibbonFocus(Redirector, NeedPaintPaletteDelegate); } private void CreateViewManager() @@ -2713,14 +2713,14 @@ private void CreateViewManager() }; // Create caption area which is used if custom chrome cannot perform task - CaptionArea = new ViewDrawRibbonCaptionArea(this, Redirector!, _compositionArea, NeedPaintDelegate); + CaptionArea = new ViewDrawRibbonCaptionArea(this, Redirector, _compositionArea, NeedPaintDelegate); // Create tabs area containing the tabs, pendant buttons etc... - TabsArea = new ViewLayoutRibbonTabsArea(this, Redirector!, CaptionArea, CaptionArea.ContextTitles!, NeedPaintDelegate); + TabsArea = new ViewLayoutRibbonTabsArea(this, Redirector, CaptionArea, CaptionArea.ContextTitles!, NeedPaintDelegate); TabsArea.PaintBackground += OnTabsAreaPaintBackground; // Create groups area containing the groups of the selected tab - GroupsArea = new ViewLayoutRibbonGroupsArea(this, Redirector!, _needPaintGroups); + GroupsArea = new ViewLayoutRibbonGroupsArea(this, Redirector, _needPaintGroups); // Create the quick access toolbar for when below the ribbon _qatBelowContents = new ViewLayoutRibbonQATFromRibbon(this, NeedPaintDelegate, true); @@ -3101,9 +3101,10 @@ private void OnTabPropertyChanged(object sender, PropertyChangedEventArgs e) private void OnRibbonQATButtonsClearing(object sender, EventArgs e) { // Stop tracking changes in button properties - foreach (IQuickAccessToolbarButton qatButton in QATButtons) + // TODO: Use typed 'where' clause + foreach (IQuickAccessToolbarButton component in QATButtons) { - qatButton.PropertyChanged -= OnQATButtonPropertyChanged; + component.PropertyChanged -= OnQATButtonPropertyChanged; } } @@ -3211,7 +3212,7 @@ private void ShowMinimizedPopup() // Create a popup control with the minimized panel as the view var popupManager = new ViewRibbonMinimizedManager(this, GroupsArea.ViewGroups, _drawMinimizedPanel, true, _needPaintGroups); - _minimizedPopup = new VisualPopupMinimized(this, popupManager, CaptionArea!, Renderer!); + _minimizedPopup = new VisualPopupMinimized(this, popupManager, CaptionArea!, Renderer); _minimizedPopup.Disposed += OnMinimizedPopupDisposed; popupManager.Attach(_minimizedPopup, _drawMinimizedPanel); diff --git a/Source/Krypton Components/Krypton.Ribbon/General/Definitions.cs b/Source/Krypton Components/Krypton.Ribbon/General/Definitions.cs index a91b4dd14..33c65cdec 100644 --- a/Source/Krypton Components/Krypton.Ribbon/General/Definitions.cs +++ b/Source/Krypton Components/Krypton.Ribbon/General/Definitions.cs @@ -313,7 +313,7 @@ internal interface IRibbonViewGroupSize /// Update the group with the provided sizing solution. /// /// Array of values for the group containers. - void SetSolutionSize(ItemSizeWidth[] size); + void SetSolutionSize(ItemSizeWidth[]? size); } #endregion diff --git a/Source/Krypton Components/Krypton.Ribbon/General/ItemGroupSizeWidth.cs b/Source/Krypton Components/Krypton.Ribbon/General/ItemGroupSizeWidth.cs index 3f68a8859..41d180447 100644 --- a/Source/Krypton Components/Krypton.Ribbon/General/ItemGroupSizeWidth.cs +++ b/Source/Krypton Components/Krypton.Ribbon/General/ItemGroupSizeWidth.cs @@ -70,7 +70,7 @@ internal class GroupSizeWidth /// /// Width available for sizing a group. /// Sizing information for applying to group. - public GroupSizeWidth(int width, ItemSizeWidth[] sizing) + public GroupSizeWidth(int width, ItemSizeWidth[]? sizing) { Width = width; Sizing = sizing; @@ -86,7 +86,7 @@ public GroupSizeWidth(int width, ItemSizeWidth[] sizing) /// /// Gets and sets the array of sizing information for group. /// - public ItemSizeWidth[] Sizing { get; set; } + public ItemSizeWidth[]? Sizing { get; set; } #endregion } diff --git a/Source/Krypton Components/Krypton.Ribbon/Group Contents/KryptonRibbonGroupCluster.cs b/Source/Krypton Components/Krypton.Ribbon/Group Contents/KryptonRibbonGroupCluster.cs index 9df9cda78..1ca43da70 100644 --- a/Source/Krypton Components/Krypton.Ribbon/Group Contents/KryptonRibbonGroupCluster.cs +++ b/Source/Krypton Components/Krypton.Ribbon/Group Contents/KryptonRibbonGroupCluster.cs @@ -315,7 +315,7 @@ public override Component[] GetChildComponents() [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)] - public ViewBase ClusterView { get; set; } + public ViewBase? ClusterView { get; set; } #endregion diff --git a/Source/Krypton Components/Krypton.Ribbon/Group Contents/KryptonRibbonGroupNumericUpDown.cs b/Source/Krypton Components/Krypton.Ribbon/Group Contents/KryptonRibbonGroupNumericUpDown.cs index 80c337b86..32cbd1705 100644 --- a/Source/Krypton Components/Krypton.Ribbon/Group Contents/KryptonRibbonGroupNumericUpDown.cs +++ b/Source/Krypton Components/Krypton.Ribbon/Group Contents/KryptonRibbonGroupNumericUpDown.cs @@ -575,7 +575,7 @@ public override ViewBase CreateView(KryptonRibbon ribbon, [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)] - public IKryptonDesignObject NumericUpDownDesigner { get; set; } + public IKryptonDesignObject? NumericUpDownDesigner { get; set; } /// /// Internal design time properties. @@ -583,7 +583,7 @@ public override ViewBase CreateView(KryptonRibbon ribbon, [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)] - public ViewBase NumericUpDownView { get; set; } + public ViewBase? NumericUpDownView { get; set; } #endregion @@ -638,7 +638,7 @@ public override ViewBase CreateView(KryptonRibbon ribbon, #endregion #region Internal - internal Control LastParentControl { get; set; } + internal Control? LastParentControl { get; set; } internal KryptonNumericUpDown? LastNumericUpDown { get; set; } diff --git a/Source/Krypton Components/Krypton.Ribbon/Palette/RibbonAppButton.cs b/Source/Krypton Components/Krypton.Ribbon/Palette/RibbonAppButton.cs index 7fa518bb7..c0f28c6f8 100644 --- a/Source/Krypton Components/Krypton.Ribbon/Palette/RibbonAppButton.cs +++ b/Source/Krypton Components/Krypton.Ribbon/Palette/RibbonAppButton.cs @@ -18,7 +18,7 @@ namespace Krypton.Ribbon public class RibbonAppButton : Storage { #region Static Fields - private static readonly Image _defaultAppImage = GenericImageResources.AppButtonDefault; + private static readonly Image? _defaultAppImage = GenericImageResources.AppButtonDefault; private const string DEFAULT_APP_TEXT = @"File"; private static readonly Color _defaultAppBaseColorDark = Color.FromArgb(31, 72, 161); private static readonly Color _defaultAppBaseColorLight = Color.FromArgb(84, 158, 243); @@ -45,7 +45,7 @@ public AppMenuButtonSpecCollection(KryptonRibbon owner) #region Instance Fields private readonly KryptonRibbon _ribbon; - private Image _appButtonImage; + private Image? _appButtonImage; private readonly KryptonContextMenuItems _appButtonMenuItems; private bool _appButtonVisible; private Color _appButtonBaseColorDark; @@ -62,7 +62,7 @@ public AppMenuButtonSpecCollection(KryptonRibbon owner) public RibbonAppButton([DisallowNull] KryptonRibbon ribbon) { Debug.Assert(ribbon != null); - _ribbon = ribbon; + _ribbon = ribbon!; // Default values _appButtonMenuItems = new KryptonContextMenuItems @@ -70,7 +70,7 @@ public RibbonAppButton([DisallowNull] KryptonRibbon ribbon) ImageColumn = false }; _appButtonImage = _defaultAppImage; - AppButtonSpecs = new AppMenuButtonSpecCollection(ribbon); + AppButtonSpecs = new AppMenuButtonSpecCollection(ribbon!); AppButtonRecentDocs = []; AppButtonToolTipTitle = string.Empty; AppButtonToolTipBody = string.Empty; @@ -121,7 +121,7 @@ public RibbonAppButton([DisallowNull] KryptonRibbon ribbon) [Category(@"Values")] [Description(@"Application button image.")] [RefreshProperties(RefreshProperties.All)] - public Image AppButtonImage + public Image? AppButtonImage { get => _appButtonImage; diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppButton.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppButton.cs index 711cd5b2e..977598a46 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppButton.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppButton.cs @@ -109,7 +109,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) Debug.Assert(context != null); // We take on all the available display area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; _clipRect = ClientRectangle; // Update to reflect full size of actual button @@ -164,7 +164,7 @@ public override void RenderBefore(RenderContext context) } // Draw the background - _mementos[memento] = context.Renderer.RenderRibbon.DrawRibbonApplicationButton(_ribbon.RibbonShape, context, ClientRectangle, State, palette, _mementos[memento]); + _mementos[memento] = context.Renderer.RenderRibbon.DrawRibbonApplicationButton(_ribbon.RibbonShape, context, ClientRectangle, State, palette, _mementos[memento]!); // If there is an application button to be drawn if (_ribbon.RibbonAppButton.AppButtonImage != null) diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuDocs.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuDocs.cs index deae02caf..15ab3794c 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuDocs.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuDocs.cs @@ -21,7 +21,7 @@ internal class ViewDrawRibbonAppMenuDocs : ViewLayoutDocker { #region Instance Fields private readonly KryptonRibbon _ribbon; - private IDisposable _memento; + private IDisposable? _memento; #endregion #region Identity diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuInner.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuInner.cs index 40aa3d2f8..1026ff748 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuInner.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuInner.cs @@ -21,7 +21,7 @@ internal class ViewDrawRibbonAppMenuInner : ViewLayoutDocker { #region Instance Fields private readonly KryptonRibbon _ribbon; - private IDisposable _memento; + private IDisposable? _memento; #endregion #region Identity diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuOuter.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuOuter.cs index b014db9e7..907c23575 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuOuter.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuOuter.cs @@ -21,7 +21,7 @@ internal class ViewDrawRibbonAppMenuOuter : ViewLayoutDocker { #region Instance Fields private readonly KryptonRibbon _ribbon; - private IDisposable _memento; + private IDisposable? _memento; #endregion #region Identity diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuRecentDoc.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuRecentDoc.cs index e94b512ff..270c5e480 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuRecentDoc.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonAppMenuRecentDoc.cs @@ -40,7 +40,7 @@ public ViewDrawRibbonAppMenuRecentDec(KryptonRibbon ribbon, int maxWidth, NeedPaintHandler needPaintDelegate, int index) - : base(provider.ProviderStateNormal.ItemHighlight.Back, + : base(provider.ProviderStateNormal.ItemHighlight!.Back, provider.ProviderStateNormal.ItemHighlight.Border, provider.ProviderStateNormal.ItemHighlight, PaletteMetricPadding.ContextMenuItemHighlight, diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroup.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroup.cs index 73e96c499..fd902f2fb 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroup.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroup.cs @@ -465,7 +465,7 @@ public GroupSizeWidth[] GetPossibleSizes(ViewLayoutContext context) /// Update the group with the provided sizing solution. /// /// Solution size. - public void SetSolutionSize(ItemSizeWidth[] size) + public void SetSolutionSize(ItemSizeWidth[]? size) { // Should we become collapsed? Collapsed = size == null; diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupCheckBox.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupCheckBox.cs index fc298c46b..6bb260b94 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupCheckBox.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupCheckBox.cs @@ -58,8 +58,8 @@ public ViewDrawRibbonGroupCheckBox([DisallowNull] KryptonRibbon ribbon, Debug.Assert(needPaint != null); // Remember incoming references - _ribbon = ribbon; - GroupCheckBox = ribbonCheckBox; + _ribbon = ribbon!; + GroupCheckBox = ribbonCheckBox!; _needPaint = needPaint; _currentSize = GroupCheckBox.ItemSizeCurrent; @@ -224,7 +224,7 @@ public void GetGroupKeyTips(KeyTipInfoList keyTipList, int lineHint) } keyTipList.Add(new KeyTipInfo(GroupCheckBox.Enabled, GroupCheckBox.KeyTip, - screenPt, this[0].ClientRectangle, controller)); + screenPt, this[0]!.ClientRectangle, controller)); } } #endregion @@ -271,7 +271,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) UpdateItemSizeState(); // We take on all the available display area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; // Let child elements layout in given space base.Layout(context); @@ -330,7 +330,7 @@ private void CreateLargeCheckBoxView() _viewLarge.Add(new ViewLayoutRibbonSeparator(1, false), ViewDockStyle.Bottom); // Create controller for handling mouse, keyboard and focus - _viewLargeController = new GroupCheckBoxController(_ribbon, _viewLarge, _viewLargeImage, _needPaint); + _viewLargeController = new GroupCheckBoxController(_ribbon, _viewLarge, _viewLargeImage, _needPaint!); _viewLargeController.Click += OnLargeCheckBoxClick; _viewLargeController.ContextClick += OnContextClick; _viewLarge.MouseController = _viewLargeController; @@ -338,7 +338,7 @@ private void CreateLargeCheckBoxView() _viewLarge.KeyController = _viewLargeController; // Create controller for intercepting events to determine tool tip handling - _viewLarge.MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager.ToolTipManager, + _viewLarge.MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager!.ToolTipManager!, _viewLarge, _viewLarge.MouseController); } @@ -368,7 +368,7 @@ private void CreateMediumSmallCheckBoxView() _viewMediumSmall.Add(_viewMediumSmallCenter, ViewDockStyle.Fill); // Create controller for handling mouse, keyboard and focus - _viewMediumSmallController = new GroupCheckBoxController(_ribbon, _viewMediumSmall, _viewMediumSmallImage, _needPaint); + _viewMediumSmallController = new GroupCheckBoxController(_ribbon, _viewMediumSmall, _viewMediumSmallImage, _needPaint!); _viewMediumSmallController.Click += OnMediumSmallCheckBoxClick; _viewMediumSmallController.ContextClick += OnContextClick; _viewMediumSmall.MouseController = _viewMediumSmallController; @@ -376,7 +376,7 @@ private void CreateMediumSmallCheckBoxView() _viewMediumSmall.KeyController = _viewMediumSmallController; // Create controller for intercepting events to determine tool tip handling - _viewMediumSmall.MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager.ToolTipManager, + _viewMediumSmall.MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager!.ToolTipManager!, _viewMediumSmall, _viewMediumSmall.MouseController); } diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupCheckBoxImage.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupCheckBoxImage.cs index 3843dc413..283bd5240 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupCheckBoxImage.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupCheckBoxImage.cs @@ -41,7 +41,7 @@ public ViewDrawRibbonGroupCheckBoxImage(KryptonRibbon ribbon, Debug.Assert(ribbonCheckBox != null); // Remember incoming parameters - _ribbonCheckBox = ribbonCheckBox; + _ribbonCheckBox = ribbonCheckBox!; _large = large; // Use redirector to get the check box images and redirect to parent palette diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupCheckBoxText.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupCheckBoxText.cs index 5062f1866..9d66934f3 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupCheckBoxText.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupCheckBoxText.cs @@ -24,7 +24,7 @@ internal class ViewDrawRibbonGroupCheckBoxText : ViewLeaf, private readonly KryptonRibbon _ribbon; private readonly KryptonRibbonGroupCheckBox _ribbonCheckBox; private readonly RibbonGroupNormalDisabledTextToContent _contentProvider; - private IDisposable _memento; + private IDisposable? _memento; private readonly bool _firstText; private int _heightExtra; private Size _preferredSize; @@ -48,12 +48,12 @@ public ViewDrawRibbonGroupCheckBoxText([DisallowNull] KryptonRibbon ribbon, Debug.Assert(ribbon != null); Debug.Assert(ribbonCheckBox != null); - _ribbon = ribbon; - _ribbonCheckBox = ribbonCheckBox; + _ribbon = ribbon!; + _ribbonCheckBox = ribbonCheckBox!; _firstText = firstText; // Use a class to convert from ribbon group to content interface - _contentProvider = new RibbonGroupNormalDisabledTextToContent(ribbon.StateCommon.RibbonGeneral, + _contentProvider = new RibbonGroupNormalDisabledTextToContent(ribbon!.StateCommon.RibbonGeneral, ribbon.StateNormal.RibbonGroupCheckBoxText, ribbon.StateDisabled.RibbonGroupCheckBoxText); } @@ -152,7 +152,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) Debug.Assert(context != null); // We take on all the available display area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; // A change in state always causes a size and layout calculation if (_cacheState != State) diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupNumericUpDown.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupNumericUpDown.cs index 3f9873b68..d9ac5c4dd 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupNumericUpDown.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGroupNumericUpDown.cs @@ -23,9 +23,9 @@ internal class ViewDrawRibbonGroupNumericUpDown : ViewComposite, #region Instance Fields private readonly int NULL_CONTROL_WIDTH; // = 50; private readonly KryptonRibbon _ribbon; - private ViewDrawRibbonGroup _activeGroup; + private ViewDrawRibbonGroup? _activeGroup; private readonly NumericUpDownController? _controller; - private readonly NeedPaintHandler _needPaint; + private readonly NeedPaintHandler? _needPaint; private GroupItemSize _currentSize; #endregion @@ -45,9 +45,9 @@ public ViewDrawRibbonGroupNumericUpDown([DisallowNull] KryptonRibbon ribbon, Debug.Assert(needPaint != null); // Remember incoming references - _ribbon = ribbon; - GroupNumericUpDown = ribbonNumericUpDown; - _needPaint = needPaint; + _ribbon = ribbon!; + GroupNumericUpDown = ribbonNumericUpDown!; + _needPaint = needPaint!; _currentSize = GroupNumericUpDown.ItemSizeCurrent; // Hook into the numeric up-down events @@ -71,7 +71,7 @@ public ViewDrawRibbonGroupNumericUpDown([DisallowNull] KryptonRibbon ribbon, KeyController = _controller; // We need to rest visibility of the numeric up-down for each layout cycle - _ribbon.ViewRibbonManager.LayoutBefore += OnLayoutAction; + _ribbon.ViewRibbonManager!.LayoutBefore += OnLayoutAction; _ribbon.ViewRibbonManager.LayoutAfter += OnLayoutAction; // Define back reference to view for the numeric up-down definition @@ -108,7 +108,7 @@ protected override void Dispose(bool disposing) GroupNumericUpDown.MouseLeaveControl -= OnMouseLeaveControl; GroupNumericUpDown.ViewPaintDelegate = null; GroupNumericUpDown.PropertyChanged -= OnNumericUpDownPropertyChanged; - _ribbon.ViewRibbonManager.LayoutAfter -= OnLayoutAction; + _ribbon.ViewRibbonManager!.LayoutAfter -= OnLayoutAction; _ribbon.ViewRibbonManager.LayoutBefore -= OnLayoutAction; // Remove association with definition @@ -125,7 +125,7 @@ protected override void Dispose(bool disposing) /// /// Gets access to the owning group numeric up-down instance. /// - public KryptonRibbonGroupNumericUpDown GroupNumericUpDown { get; private set; } + public KryptonRibbonGroupNumericUpDown? GroupNumericUpDown { get; private set; } #endregion @@ -137,7 +137,7 @@ protected override void Dispose(bool disposing) public override void LostFocus(Control c) { // Ask ribbon to shift focus to the hidden control - _ribbon.HideFocus(GroupNumericUpDown.NumericUpDown); + _ribbon.HideFocus(GroupNumericUpDown?.NumericUpDown); base.LostFocus(c); } #endregion @@ -217,7 +217,7 @@ public override void LostFocus(Control c) public void GetGroupKeyTips(KeyTipInfoList keyTipList, int lineHint) { // Only provide a key tip if we are visible and the target control can accept focus - if (Visible && LastNumericUpDown.CanFocus) + if (Visible && LastNumericUpDown!.CanFocus) { // Get the screen location of the button Rectangle viewRect = _ribbon.KeyTipToScreen(this); @@ -225,7 +225,7 @@ public void GetGroupKeyTips(KeyTipInfoList keyTipList, int lineHint) // Determine the screen position of the key tip var screenPt = Point.Empty; - // Determine the screen position of the key tip dependant on item location/size + // Determine the screen position of the key tip dependent on item location/size switch (_currentSize) { case GroupItemSize.Large: @@ -237,7 +237,7 @@ public void GetGroupKeyTips(KeyTipInfoList keyTipList, int lineHint) break; } - keyTipList.Add(new KeyTipInfo(GroupNumericUpDown.Enabled, + keyTipList.Add(new KeyTipInfo(GroupNumericUpDown!.Enabled, GroupNumericUpDown.KeyTip, screenPt, ClientRectangle, @@ -256,7 +256,7 @@ public void GetGroupKeyTips(KeyTipInfoList keyTipList, int lineHint) /// /// Reset the group item size to the item definition. /// - public void ResetGroupItemSize() => _currentSize = GroupNumericUpDown.ItemSizeCurrent; + public void ResetGroupItemSize() => _currentSize = GroupNumericUpDown!.ItemSizeCurrent; /// /// Discover the preferred size of the element. @@ -301,10 +301,10 @@ public override void Layout([DisallowNull] ViewLayoutContext context) Debug.Assert(context != null); // We take on all the available display area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; // Are we allowed to change the layout of controls? - if (!context.ViewManager.DoNotLayoutControls) + if (!context.ViewManager!.DoNotLayoutControls) { // If we have an actual control, position it with a pixel padding all around LastNumericUpDown?.SetBounds(ClientLocation.X + 1, @@ -328,7 +328,7 @@ public override void Render([DisallowNull] RenderContext context) Debug.Assert(context != null); // If we do not have a numeric up-down - if (GroupNumericUpDown.NumericUpDown == null) + if (GroupNumericUpDown?.NumericUpDown == null) { // And we are in design time if (_ribbon.InDesignMode) @@ -339,8 +339,8 @@ public override void Render([DisallowNull] RenderContext context) drawRect.Height--; // Draw an indication of where the numeric up-down will be - context.Graphics.FillRectangle(Brushes.Goldenrod, drawRect); - context.Graphics.DrawRectangle(Pens.Gold, drawRect); + context?.Graphics.FillRectangle(Brushes.Goldenrod, drawRect); + context?.Graphics.DrawRectangle(Pens.Gold, drawRect); } } } @@ -373,7 +373,7 @@ protected virtual void OnNeedPaint(bool needLayout, Rectangle invalidRect) #endregion #region Implementation - private void OnContextClick(object sender, MouseEventArgs e) => GroupNumericUpDown.OnDesignTimeContextMenu(e); + private void OnContextClick(object sender, MouseEventArgs e) => GroupNumericUpDown?.OnDesignTimeContextMenu(e); private void OnNumericUpDownPropertyChanged(object sender, PropertyChangedEventArgs e) { @@ -383,10 +383,10 @@ private void OnNumericUpDownPropertyChanged(object sender, PropertyChangedEventA switch (e.PropertyName) { case nameof(Enabled): - UpdateEnabled(LastNumericUpDown); + UpdateEnabled(LastNumericUpDown!); break; case nameof(Visible): - UpdateVisible(LastNumericUpDown); + UpdateVisible(LastNumericUpDown!); updateLayout = true; break; case "CustomControl": @@ -397,7 +397,7 @@ private void OnNumericUpDownPropertyChanged(object sender, PropertyChangedEventA if (updateLayout) { // If we are on the currently selected tab then... - if ((GroupNumericUpDown.RibbonTab != null) && + if ((GroupNumericUpDown?.RibbonTab != null) && (_ribbon.SelectedTab == GroupNumericUpDown.RibbonTab)) { // ...layout so the visible change is made @@ -423,16 +423,16 @@ private void OnNumericUpDownPropertyChanged(object sender, PropertyChangedEventA #pragma warning restore 162 } - private Control LastParentControl + private Control? LastParentControl { - get => GroupNumericUpDown.LastParentControl; - set => GroupNumericUpDown.LastParentControl = value; + get => GroupNumericUpDown!.LastParentControl; + set => GroupNumericUpDown!.LastParentControl = value; } private KryptonNumericUpDown? LastNumericUpDown { - get => GroupNumericUpDown.LastNumericUpDown; - set => GroupNumericUpDown.LastNumericUpDown = value; + get => GroupNumericUpDown!.LastNumericUpDown; + set => GroupNumericUpDown!.LastNumericUpDown = value; } private void UpdateParent(Control parentControl) @@ -440,13 +440,13 @@ private void UpdateParent(Control parentControl) // Is there a change in the numeric up-down or a change in // the parent control that is hosting the control... if ((parentControl != LastParentControl) || - (LastNumericUpDown != GroupNumericUpDown.NumericUpDown)) + (LastNumericUpDown != GroupNumericUpDown!.NumericUpDown)) { // We only modify the parent and visible state if processing for correct container - if ((GroupNumericUpDown.RibbonContainer.RibbonGroup.ShowingAsPopup && (parentControl is VisualPopupGroup)) || + if ((GroupNumericUpDown!.RibbonContainer!.RibbonGroup!.ShowingAsPopup && (parentControl is VisualPopupGroup)) || (!GroupNumericUpDown.RibbonContainer.RibbonGroup.ShowingAsPopup && parentControl is not VisualPopupGroup)) { - // If we have added the custrom control to a parent before + // If we have added the custom control to a parent before if ((LastNumericUpDown != null) && (LastParentControl != null)) { // If that control is still a child of the old parent @@ -477,12 +477,12 @@ private void UpdateParent(Control parentControl) } } - private void UpdateEnabled(Control c) + private void UpdateEnabled(Control? c) { if (c != null) { // Start with the enabled state of the group element - var enabled = GroupNumericUpDown.Enabled; + var enabled = GroupNumericUpDown!.Enabled; // If we have an associated designer setup... if (!_ribbon.InDesignHelperMode && (GroupNumericUpDown.NumericUpDownDesigner != null)) @@ -495,12 +495,12 @@ private void UpdateEnabled(Control c) } } - private bool ActualVisible(Control c) + private bool ActualVisible(Control? c) { if (c != null) { // Start with the visible state of the group element - var visible = GroupNumericUpDown.Visible; + var visible = GroupNumericUpDown!.Visible; // If we have an associated designer setup... if (!_ribbon.InDesignHelperMode && (GroupNumericUpDown.NumericUpDownDesigner != null)) @@ -515,12 +515,12 @@ private bool ActualVisible(Control c) return false; } - private void UpdateVisible(Control c) + private void UpdateVisible(Control? c) { if (c != null) { // Start with the visible state of the group element - var visible = GroupNumericUpDown.Visible; + var visible = GroupNumericUpDown!.Visible; // If we have an associated designer setup... if (!_ribbon.InDesignHelperMode && (GroupNumericUpDown.NumericUpDownDesigner != null)) @@ -549,7 +549,7 @@ private void UpdateVisible(Control c) else { // Check that the group is not collapsed - if (GroupNumericUpDown.RibbonContainer.RibbonGroup.IsCollapsed && + if (GroupNumericUpDown!.RibbonContainer!.RibbonGroup!.IsCollapsed && ((_ribbon.GetControllerControl(GroupNumericUpDown.NumericUpDown) is KryptonRibbon) || (_ribbon.GetControllerControl(GroupNumericUpDown.NumericUpDown) is VisualPopupMinimized)) ) @@ -572,7 +572,7 @@ private void UpdateVisible(Control c) } // Move up a level - container = container.RibbonContainer; + container = container.RibbonContainer!; } } } @@ -599,7 +599,7 @@ private void OnMouseEnterControl(object sender, EventArgs e) _activeGroup = null; // Find the parent group instance - ViewBase parent = Parent; + ViewBase? parent = Parent; // Keep going till we get to the top or find a group while (parent != null) @@ -618,7 +618,7 @@ private void OnMouseEnterControl(object sender, EventArgs e) if (_activeGroup != null) { _activeGroup.Tracking = true; - _needPaint(this, new NeedLayoutEventArgs(false, _activeGroup.ClientRectangle)); + _needPaint!(this, new NeedLayoutEventArgs(false, _activeGroup.ClientRectangle)); } } @@ -628,7 +628,7 @@ private void OnMouseLeaveControl(object sender, EventArgs e) if (_activeGroup != null) { _activeGroup.Tracking = false; - _needPaint(this, new NeedLayoutEventArgs(false, _activeGroup.ClientRectangle)); + _needPaint!(this, new NeedLayoutEventArgs(false, _activeGroup.ClientRectangle)); _activeGroup = null; } } diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonTab.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonTab.cs index e23111df3..09bc9683f 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonTab.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonTab.cs @@ -401,7 +401,7 @@ public override void RenderBefore(RenderContext context) CheckPaletteState(context); // Grab the context tab set that relates to this tab - ContextTabSet? cts = ViewLayoutRibbonTabs.ContextTabSets[RibbonTab?.ContextName]; + ContextTabSet? cts = ViewLayoutRibbonTabs.ContextTabSets[RibbonTab!.ContextName]; switch (Ribbon.RibbonShape) { @@ -424,7 +424,7 @@ public override void RenderBefore(RenderContext context) } //_paletteContextCurrent.LightBackground = _ribbon.CaptionArea.DrawCaptionOnComposition; - _paletteContextCurrent.LightBackground = Ribbon.CaptionArea.DrawCaptionOnComposition + _paletteContextCurrent.LightBackground = Ribbon.CaptionArea!.DrawCaptionOnComposition && KryptonManager.CurrentGlobalPaletteMode.ToString() .StartsWith(PaletteMode.Office2010Black.ToString()); break; @@ -442,7 +442,7 @@ public override void RenderBefore(RenderContext context) public override void RenderAfter(RenderContext context) { // Grab the context tab set that relates to this tab - ContextTabSet cts = ViewLayoutRibbonTabs.ContextTabSets[RibbonTab.ContextName]; + ContextTabSet? cts = ViewLayoutRibbonTabs.ContextTabSets[RibbonTab!.ContextName]; // Is this tab part of a context? if (cts != null) @@ -506,7 +506,7 @@ private void RenderBefore2007ContextTab(RenderContext context, ContextTabSet cts // Grab the color we draw the context separator in Color sepColor = _paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal); - Rectangle parentRect = Parent.ClientRectangle; + Rectangle parentRect = Parent!.ClientRectangle; var contextRect = parentRect with { X = ClientRectangle.X - 1, Width = ClientRectangle.Width + 2 }; var gradientRect = new Rectangle(ClientRectangle.X - 1, parentRect.Y - 1, ClientRectangle.Width + 2, parentRect.Height + 2); @@ -613,7 +613,7 @@ private void CheckPaletteState(ViewContext context) // Better check we have a child! if (Count > 0) { - this[0].Enabled = enabled; + this[0]!.Enabled = enabled; } // If disabled... @@ -631,7 +631,7 @@ private void CheckPaletteState(ViewContext context) Checked = Ribbon.SelectedTab == RibbonTab; // Is this tab a context tab? - var contextTab = !string.IsNullOrEmpty(RibbonTab.ContextName); + var contextTab = !string.IsNullOrEmpty(RibbonTab!.ContextName); // Apply the checked state if not fixed if (!IsFixed) @@ -706,7 +706,7 @@ private void CheckPaletteState(ViewContext context) // Better check we have a child! if (Count > 0) { - this[0].ElementState = buttonState; + this[0]!.ElementState = buttonState; } // Update the actual source palette @@ -734,12 +734,12 @@ private void OnTabContextClicked(object sender, MouseEventArgs e) { if (Ribbon.InDesignMode) { - _ribbonTab.OnDesignTimeContextMenu(new MouseEventArgs(MouseButtons.Right, 1, e.X, e.Y, 0)); + _ribbonTab?.OnDesignTimeContextMenu(new MouseEventArgs(MouseButtons.Right, 1, e.X, e.Y, 0)); } else { // Convert the mouse point to screen coords from the containing control - Point screenPt = Ribbon.TabsArea.TabsContainerControl.ChildControl.PointToScreen(new Point(e.X, e.Y)); + Point screenPt = Ribbon.TabsArea.TabsContainerControl.ChildControl!.PointToScreen(new Point(e.X, e.Y)); // Convert back to ribbon client coords, needed for the show context menu call Point clientPt = Ribbon.PointToClient(screenPt); diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonTabSep.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonTabSep.cs index 65b9c78d6..2a3afa833 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonTabSep.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonTabSep.cs @@ -49,7 +49,7 @@ public ViewDrawRibbonTabSep([DisallowNull] IPaletteRibbonGeneral palette) : base(SEP_WIDTH, true) { Debug.Assert(palette != null); - _palette = palette; + _palette = palette!; } /// diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonAppButton.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonAppButton.cs index c6911fd87..7ca30bb9d 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonAppButton.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonAppButton.cs @@ -42,9 +42,9 @@ public ViewLayoutRibbonAppButton([DisallowNull] KryptonRibbon ribbon, bool bottomHalf) { Debug.Assert(ribbon != null); - _ribbon = ribbon; + _ribbon = ribbon!; - AppButton = new ViewDrawRibbonAppButton(ribbon, bottomHalf); + AppButton = new ViewDrawRibbonAppButton(ribbon!, bottomHalf); _separator = new ViewLayoutRibbonSeparator(APPBUTTON_GAP, true); // Dock it against the appropriate edge diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonAppTab.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonAppTab.cs index a7ce453ab..d3861a210 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonAppTab.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonAppTab.cs @@ -32,9 +32,9 @@ internal class ViewLayoutRibbonAppTab : ViewLayoutDocker public ViewLayoutRibbonAppTab([DisallowNull] KryptonRibbon ribbon) { Debug.Assert(ribbon != null); - _ribbon = ribbon; + _ribbon = ribbon!; - AppTab = new ViewDrawRibbonAppTab(ribbon); + AppTab = new ViewDrawRibbonAppTab(ribbon!); // Dock it against the appropriate edge Add(AppTab, ViewDockStyle.Bottom); diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonContextTitles.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonContextTitles.cs index 98c59aa5e..f74e9a6db 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonContextTitles.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonContextTitles.cs @@ -44,8 +44,8 @@ public ViewLayoutRibbonContextTitles([DisallowNull] KryptonRibbon ribbon, { Debug.Assert(captionArea != null); Debug.Assert(ribbon != null); - _ribbon = ribbon; - _captionArea = captionArea; + _ribbon = ribbon!; + _captionArea = captionArea!; // Create cache of draw elements _contextTitlesCache = []; @@ -102,10 +102,10 @@ public override void Layout([DisallowNull] ViewLayoutContext context) SyncChildrenToContexts(); // We take on all the available display area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; // Find any filler child - ViewBase filler = this.FirstOrDefault(child => GetDock(child) == ViewDockStyle.Fill); + ViewBase? filler = this.FirstOrDefault(child => GetDock(child) == ViewDockStyle.Fill); var xLeftMost = ClientRectangle.Right; var xRightMost = ClientRectangle.Left; @@ -214,9 +214,9 @@ private void SyncChildrenToContexts() for (var i = 0; i < ViewLayoutRibbonTabs.ContextTabSets.Count; i++) { ViewDrawRibbonContextTitle viewContext = _contextTitlesCache[i]; - var viewController = (ContextTitleController)viewContext.MouseController; + var viewController = viewContext.MouseController as ContextTitleController; viewContext.ContextTabSet = ViewLayoutRibbonTabs.ContextTabSets[i]; - viewController.ContextTabSet = viewContext.ContextTabSet; + viewController!.ContextTabSet = viewContext.ContextTabSet; Add(viewContext); } diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGalleryItems.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGalleryItems.cs index 79862cb3a..63dc1b19c 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGalleryItems.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGalleryItems.cs @@ -70,11 +70,11 @@ public ViewLayoutRibbonGalleryItems([DisallowNull] PaletteBase palette, Debug.Assert(buttonDown != null); Debug.Assert(buttonContext != null); - _gallery = gallery; - _needPaint = needPaint; - _buttonUp = buttonUp; - _buttonDown = buttonDown; - _buttonContext = buttonContext; + _gallery = gallery!; + _needPaint = needPaint!; + _buttonUp = buttonUp!; + _buttonDown = buttonDown!; + _buttonContext = buttonContext!; _bringIntoView = -1; ScrollIntoView = true; @@ -370,8 +370,8 @@ public override Size GetPreferredSize([DisallowNull] ViewLayoutContext context) // Find size of the first item, if there is one if (Count > 0) { - // Ask child for it's own preferred size - preferredSize = this[0].GetPreferredSize(context); + // Ask child for its own preferred size + preferredSize = this[0]!.GetPreferredSize(context!); // Find preferred size from the preferred item size preferredSize.Width *= _gallery.PreferredItemSize.Width; @@ -412,7 +412,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) Rectangle displayRect = CommonHelper.ApplyPadding(Orientation.Horizontal, ClientRectangle, _gallery.Padding); // Get size of the first child, assume all others are same size - _itemSize = this[0].GetPreferredSize(context); + _itemSize = this[0]!.GetPreferredSize(context); // Number of items that can be placed on a single line _lineItems = Math.Max(1, displayRect.Width / _itemSize.Width); @@ -426,7 +426,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) // Index of last line that can be the top line _endLine = _layoutLines - _displayLines; - // Update topline and offset to reflect any outstanding bring into view request + // Update top-line and offset to reflect any outstanding bring into view request ProcessBringIntoView(); // Limit check the top line is within the valid range @@ -489,16 +489,16 @@ public override void Layout([DisallowNull] ViewLayoutContext context) // Position all children on single line from left to right for (var i = 0; i < Count; i++) { - ViewBase childItem = this[i]; + ViewBase? childItem = this[i]; // Should this item be visible if ((i < start) || (i >= end)) { - childItem.Visible = false; + childItem!.Visible = false; } else { - childItem.Visible = true; + childItem!.Visible = true; // Find rectangle for the child context.DisplayRectangle = new Rectangle(nextPoint, _itemSize); @@ -537,12 +537,12 @@ public void SyncChildren() { var required = 0; var selectedIndex = _gallery.SelectedIndex; - ImageList imageList = _gallery.ImageList; + ImageList? imageList = _gallery.ImageList; // Find out how many children we need if (imageList != null) { - required = _gallery.ImageList.Images.Count; + required = _gallery.ImageList!.Images.Count; } // If we do not have enough already @@ -568,8 +568,8 @@ public void SyncChildren() // Tell each item the image it should be displaying for (var i = 0; i < required; i++) { - var item = (ViewDrawRibbonGalleryItem)this[i]; - item.ImageList = imageList; + var item = this[i] as ViewDrawRibbonGalleryItem; + item!.ImageList = imageList; item.ImageIndex = i; item.Checked = selectedIndex == i; } diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupCluster.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupCluster.cs index 93e15bdba..0b4fa5bfd 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupCluster.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupCluster.cs @@ -61,8 +61,8 @@ public ViewLayoutRibbonGroupCluster([DisallowNull] KryptonRibbon ribbon, Debug.Assert(needPaint != null); // Cache references - _ribbon = ribbon; - _ribbonCluster = ribbonCluster; + _ribbon = ribbon!; + _ribbonCluster = ribbonCluster!; _needPaint = needPaint; _currentSize = GroupItemSize.Medium; @@ -93,7 +93,7 @@ public ViewLayoutRibbonGroupCluster([DisallowNull] KryptonRibbon ribbon, // At design time we want to track the mouse and show feedback if (_ribbon.InDesignMode) { - var controller = new ViewHightlightController(this, needPaint); + var controller = new ViewHightlightController(this, needPaint!); controller.ContextClick += OnContextClick; MouseController = controller; } @@ -336,8 +336,8 @@ public void ResetGroupItemSize() } // Our current size is based on the parent one - var viewLines = (ViewLayoutRibbonGroupLines)Parent; - _currentSize = viewLines.CurrentSize == GroupItemSize.Small ? GroupItemSize.Small : GroupItemSize.Medium; + var viewLines = Parent as ViewLayoutRibbonGroupLines; + _currentSize = viewLines?.CurrentSize == GroupItemSize.Small ? GroupItemSize.Small : GroupItemSize.Medium; } /// @@ -360,10 +360,10 @@ public override Size GetPreferredSize(ViewLayoutContext context) // Find total width and maximum height across all child elements for (var i = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; // Only interested in visible items - if (child.Visible) + if (child!.Visible) { // Cache preferred size of the child Size childSize = child.GetPreferredSize(context); @@ -397,7 +397,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) Debug.Assert(context != null); // Store the provided client area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; // Define visible state of the separators _startSep.Visible = _startSepVisible && (_lastShape == PaletteRibbonShape.Office2010); @@ -422,10 +422,10 @@ public override void Layout([DisallowNull] ViewLayoutContext context) // Position each item from left/top to right/bottom for (var i = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; // We only position visible items - if (child.Visible) + if (child!.Visible) { // Cache preferred size of the child Size childSize = viewToSize[child]; @@ -434,7 +434,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) context.DisplayRectangle = new Rectangle(x, y, childSize.Width, ClientHeight); // Position the element - this[i].Layout(context); + this[i]?.Layout(context); // Move across to next position x += childSize.Width; @@ -528,7 +528,7 @@ private void SyncChildrenToRibbonGroupItems() else { // Ask the item definition to return an appropriate view - itemView = item.CreateView(_ribbon, _needPaint); + itemView = item.CreateView(_ribbon, _needPaint!); // Create a border edge to go with the item view itemEdge = new ViewDrawRibbonGroupClusterEdge(_ribbon, _paletteBorderEdge); @@ -621,12 +621,12 @@ private void SyncChildrenToRibbonGroupItems() view.Dispose(); } - foreach (ViewBase view in _viewToEdge.Values) + foreach (var view in _viewToEdge.Values) { view.Dispose(); } - // Always add the end separator as the last view element (excluding any desing time additions) + // Always add the end separator as the last view element (excluding any design time additions) Add(_endSep); // Define visible state of the separators @@ -639,7 +639,7 @@ private void SyncChildrenToRibbonGroupItems() // Create the design time 'Item' first time it is needed _viewAddItem ??= new ViewDrawRibbonDesignCluster(_ribbon, _ribbonCluster, - _needPaint); + _needPaint!); // Always add at end of the list of items Add(_viewAddItem); diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupContent.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupContent.cs index e47e5b0b7..8f260e469 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupContent.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupContent.cs @@ -37,7 +37,7 @@ private class ContainerToView : Dictionary { } private readonly NeedPaintHandler _needPaint; private ContainerToView _containerToView; private List _listWidths; - private int[] _containerWidths; + private int[]? _containerWidths; #endregion #region Identity @@ -56,9 +56,9 @@ public ViewLayoutRibbonGroupContent([DisallowNull] KryptonRibbon ribbon, Debug.Assert(needPaint != null); // Cache references - _ribbon = ribbon; - _ribbonGroup = ribbonGroup; - _needPaint = needPaint; + _ribbon = ribbon!; + _ribbonGroup = ribbonGroup!; + _needPaint = needPaint!; // Use hashtable to store relationships _containerToView = new ContainerToView(); @@ -362,7 +362,7 @@ public GroupSizeWidth[] GetPossibleSizes(ViewLayoutContext context) var maxEntries = 0; for (var i = 0; i < Count; i++) { - if (this[i].Visible + if (this[i]!.Visible && (this[i] is IRibbonViewGroupContainerView container) ) { @@ -526,7 +526,7 @@ public GroupSizeWidth[] GetPossibleSizes(ViewLayoutContext context) /// Update the group with the provided sizing solution. /// /// Solution size. - public void SetSolutionSize(ItemSizeWidth[] size) + public void SetSolutionSize(ItemSizeWidth[]? size) { // Do we need to restore each container to its default size? if ((size == null) || (size.Length == 0)) @@ -534,7 +534,7 @@ public void SetSolutionSize(ItemSizeWidth[] size) // Look for visible child containers for (var i = 0; i < Count; i++) { - if (this[i].Visible + if (this[i]!.Visible && (this[i] is IRibbonViewGroupContainerView container) ) { @@ -552,7 +552,7 @@ public void SetSolutionSize(ItemSizeWidth[] size) // Look for visible child containers for (int i = 0, j = 0; i < Count; i++) { - if (this[i].Visible + if (this[i]!.Visible && (this[i] is IRibbonViewGroupContainerView container) ) { @@ -580,10 +580,10 @@ public override Size GetPreferredSize(ViewLayoutContext context) // Find total width and maximum height across all child elements for (int i = 0, j = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; // Only interested in visible items - if (child.Visible) + if (child!.Visible) { Size childSize; @@ -628,7 +628,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) Debug.Assert(context != null); // We take on all the available display area and then remove our constant padding - ClientRectangle = CommonHelper.ApplyPadding(Orientation.Horizontal, context.DisplayRectangle, _padding); + ClientRectangle = CommonHelper.ApplyPadding(Orientation.Horizontal, context!.DisplayRectangle, _padding); var x = ClientLocation.X; @@ -641,10 +641,10 @@ public override void Layout([DisallowNull] ViewLayoutContext context) // Position each item from left to right taking up entire height for (int i = 0, j = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; // We only position visible items - if (child.Visible) + if (child!.Visible) { Size childSize; @@ -664,7 +664,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) context.DisplayRectangle = new Rectangle(x, y, childSize.Width, height); // Position the element - this[i].Layout(context); + this[i]!.Layout(context); // Move across to next position (add 1 extra as the spacing gap) x += childSize.Width + 1; diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupLines.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupLines.cs index bda7999c1..011587952 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupLines.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupLines.cs @@ -38,7 +38,7 @@ private class ViewList : List { } private readonly KryptonRibbon _ribbon; private readonly KryptonRibbonGroupLines _ribbonLines; private ViewDrawRibbonDesignGroupLines? _viewAddItem; - private readonly NeedPaintHandler _needPaint; + private readonly NeedPaintHandler? _needPaint; private GroupItemSize _currentSize; private ItemToView _itemToView; private ViewToItem _viewToItem; @@ -76,9 +76,9 @@ public ViewLayoutRibbonGroupLines([DisallowNull] KryptonRibbon ribbon, Debug.Assert(needPaint != null); // Cache references - _ribbon = ribbon; - _ribbonLines = ribbonLines; - _needPaint = needPaint; + _ribbon = ribbon!; + _ribbonLines = ribbonLines!; + _needPaint = needPaint!; // Associate the component with this view element for design time selection Component = _ribbonLines; @@ -97,7 +97,7 @@ public ViewLayoutRibbonGroupLines([DisallowNull] KryptonRibbon ribbon, _viewToSmallGap = new ViewToGap(); // Get the initial size used for sizing and positioning - ApplySize(ribbonLines.ItemSizeCurrent); + ApplySize(ribbonLines!.ItemSizeCurrent); // Hook into changes in the ribbon triple definition _ribbonLines.PropertyChanged += OnLinesPropertyChanged; @@ -106,7 +106,7 @@ public ViewLayoutRibbonGroupLines([DisallowNull] KryptonRibbon ribbon, // At design time we want to track the mouse and show feedback if (_ribbon.InDesignMode) { - var controller = new ViewHightlightController(this, needPaint); + var controller = new ViewHightlightController(this, needPaint!); controller.ContextClick += OnContextClick; MouseController = controller; } @@ -529,10 +529,10 @@ public override Size GetPreferredSize(ViewLayoutContext context) // Find the size of each individual visible child item for (var i = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; // Only interested in visible items - if (child.Visible) + if (child!.Visible) { // Inform cluster if it is immediately after another cluster (and so potentially needs a separator) // Are we positioning a cluster? @@ -601,7 +601,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) Debug.Assert(context != null); // Store the provided client area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; // Are there any children to layout? if (Count > 0) @@ -730,7 +730,7 @@ private void SyncChildrenToRibbonGroupItems() var regenViewToItem = new ViewToItem(); // Add a view element for each group item - foreach (IRibbonGroupItem item in _ribbonLines.Items) + foreach (IRibbonGroupItem item in _ribbonLines.Items!) { ViewBase? itemView; @@ -745,7 +745,7 @@ private void SyncChildrenToRibbonGroupItems() else { // Ask the item definition to return an appropriate view - itemView = item.CreateView(_ribbon, _needPaint); + itemView = item.CreateView(_ribbon, _needPaint!); } // Update the visible state of the item @@ -765,14 +765,14 @@ private void SyncChildrenToRibbonGroupItems() _viewAddItem ??= new ViewDrawRibbonDesignGroupLines(_ribbon, _ribbonLines, _currentSize, - _needPaint); + _needPaint!); // Always add at end of the list of items Add(_viewAddItem); } // Dispose of all the items no longer needed - foreach (ViewBase view in _itemToView.Values) + foreach (var view in _itemToView.Values) { view.Dispose(); } @@ -976,10 +976,10 @@ private void LargeMediumLayout(ViewLayoutContext context, ref int split1) // Position the visible items in turn for (int i = 0, visibleIndex = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; // We only position visible items - if (child.Visible) + if (child!.Visible) { // Are we positioning a cluster? if (child is ViewLayoutRibbonGroupCluster clusterChild1) @@ -1012,7 +1012,7 @@ private void LargeMediumLayout(ViewLayoutContext context, ref int split1) context.DisplayRectangle = new Rectangle(x, y, childSize.Width, childSize.Height); // Position the element - this[i].Layout(context); + this[i]?.Layout(context); // Do we need to split after this item if (split1 == visibleIndex) @@ -1063,10 +1063,10 @@ private void SmallLayout(ViewLayoutContext context) // Position the visible items in turn for (int i = 0, visibleIndex = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; // We only position visible items - if (child.Visible) + if (child!.Visible) { // Are we positioning a cluster? if (child is ViewLayoutRibbonGroupCluster clusterChild1) @@ -1099,7 +1099,7 @@ private void SmallLayout(ViewLayoutContext context) context.DisplayRectangle = new Rectangle(x, y, childSize.Width, childSize.Height); // Position the element - this[i].Layout(context); + this[i]?.Layout(context); // Do we need to split after this item if ((_split1Small == visibleIndex) || (_split2Small == visibleIndex)) diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupTriple.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupTriple.cs index 7954cff61..e5cf4a10b 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupTriple.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupTriple.cs @@ -28,7 +28,7 @@ private class ViewToSize : Dictionary { } #region Instance Fields private readonly KryptonRibbon _ribbon; private readonly KryptonRibbonGroupTriple _ribbonTriple; - private ViewDrawRibbonDesignGroupTriple _viewAddItem; + private ViewDrawRibbonDesignGroupTriple? _viewAddItem; private readonly NeedPaintHandler _needPaint; private GroupItemSize _currentSize; private ItemToView _itemToView; @@ -55,9 +55,9 @@ public ViewLayoutRibbonGroupTriple([DisallowNull] KryptonRibbon ribbon, Debug.Assert(needPaint != null); // Cache references - _ribbon = ribbon; - _ribbonTriple = ribbonTriple; - _needPaint = needPaint; + _ribbon = ribbon!; + _ribbonTriple = ribbonTriple!; + _needPaint = needPaint!; // Associate the component with this view element for design time selection Component = _ribbonTriple; @@ -69,7 +69,7 @@ public ViewLayoutRibbonGroupTriple([DisallowNull] KryptonRibbon ribbon, _largeCache = new ViewToSize(); // Get the initial size used for sizing and positioning - SetCurrentSize(ribbonTriple.ItemSizeCurrent); + SetCurrentSize(ribbonTriple!.ItemSizeCurrent); // Hook into changes in the ribbon triple definition _ribbonTriple.PropertyChanged += OnTriplePropertyChanged; @@ -78,7 +78,7 @@ public ViewLayoutRibbonGroupTriple([DisallowNull] KryptonRibbon ribbon, // At design time we want to track the mouse and show feedback if (_ribbon.InDesignMode) { - var controller = new ViewHightlightController(this, needPaint); + var controller = new ViewHightlightController(this, needPaint!); controller.ContextClick += OnContextClick; MouseController = controller; } @@ -400,10 +400,10 @@ public override Size GetPreferredSize(ViewLayoutContext context) // Find total width and maximum height across all child elements for (var i = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; // Only interested in visible items - if (child.Visible) + if (child!.Visible) { // Cache preferred size of the child Size childSize = child.GetPreferredSize(context); @@ -468,7 +468,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) Debug.Assert(context != null); // Store the provided client area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; // Are we sizing horizontal or vertical? var horizontal = _currentSize == GroupItemSize.Large; @@ -489,10 +489,10 @@ public override void Layout([DisallowNull] ViewLayoutContext context) // Position each item from left/top to right/bottom for (var i = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; // We only position visible items - if (child.Visible) + if (child!.Visible) { // Get the cached size of this view var childSize = Size.Empty; @@ -515,7 +515,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) context.DisplayRectangle = new Rectangle(x, y, childSize.Width, ClientHeight); // Position the element - this[i].Layout(context); + this[i]?.Layout(context); // Move across to next position (add 1 extra as the spacing gap) x += childSize.Width + 1; @@ -537,7 +537,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) } // Position the element - this[i].Layout(context); + this[i]?.Layout(context); // Move down to next position y += childSize.Height; @@ -633,7 +633,7 @@ private void SyncChildrenToRibbonGroupItems() var regenerate = new ItemToView(); // Add a view element for each group item - foreach (IRibbonGroupItem item in _ribbonTriple.Items) + foreach (IRibbonGroupItem item in _ribbonTriple.Items!) { ViewBase itemView; @@ -723,4 +723,4 @@ private void OnContextClick(object sender, MouseEventArgs e) } #endregion } -} +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroups.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroups.cs index a735e4140..1b0e8b74c 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroups.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroups.cs @@ -58,8 +58,8 @@ public ViewLayoutRibbonGroups([DisallowNull] KryptonRibbon ribbon, // Cache references _ribbon = ribbon; - _ribbonTab = ribbonTab; - _needPaint = needPaint; + _ribbonTab = ribbonTab!; + _needPaint = needPaint!; // Create initial lookup table _groupToView = new GroupToView(); @@ -123,10 +123,10 @@ public NeedPaintHandler NeedPaintDelegate public ViewDrawRibbonGroup? ViewGroupFromPoint(Point pt) { // Parent element should be a view layout - var layoutControl = (ViewLayoutControl)Parent; + var layoutControl = Parent as ViewLayoutControl; // Get the location of the child control it contains - Point layoutLocation = layoutControl.ChildControl.Location; + Point layoutLocation = layoutControl!.ChildControl!.Location; // Adjust the incoming point for the location of the child control pt.X -= layoutLocation.X; @@ -296,7 +296,7 @@ public override Size GetPreferredSize(ViewLayoutContext context) SyncChildrenToRibbonGroups(); // Find best size for groups to fill available space - return new Size(AdjustGroupStateToMatchSpace(context), _ribbon.CalculatedValues.GroupHeight); + return new Size(AdjustGroupStateToMatchSpace(context), _ribbon!.CalculatedValues.GroupHeight); } /// @@ -308,7 +308,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) Debug.Assert(context != null); // We take on all the available display area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; var x = ClientLocation.X; @@ -321,17 +321,17 @@ public override void Layout([DisallowNull] ViewLayoutContext context) // Position each item from left to right taking up entire height for (int i = 0, j = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; // We only position visible items - if (child.Visible) + if (child!.Visible) { // Cache preferred size of the child // If a group then pull in the cached value Size childSize = child is ViewDrawRibbonGroup - ? new Size(_groupWidths[j++], _ribbon.CalculatedValues.GroupHeight) - : this[i].GetPreferredSize(context); + ? new Size(_groupWidths[j++], _ribbon!.CalculatedValues.GroupHeight) + : this[i]!.GetPreferredSize(context); // Only interested in items with some width if (childSize.Width > 0) @@ -340,7 +340,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) context.DisplayRectangle = new Rectangle(x, y, childSize.Width, height); // Position the element - this[i].Layout(context); + this[i]?.Layout(context); // Move across to next position x += childSize.Width; @@ -397,7 +397,7 @@ private void SyncChildrenToRibbonGroups() } // If a new group, create a view for it now - view ??= new ViewDrawRibbonGroup(_ribbon, ribGroup, _needPaint); + view ??= new ViewDrawRibbonGroup(_ribbon!, ribGroup, _needPaint); // Add to the lookup for future reference regenerate.Add(ribGroup, view); @@ -427,7 +427,7 @@ private void SyncChildrenToRibbonGroups() KryptonRibbonGroup ribbonGroup = _ribbonTab.Groups[i]; // Only make the separator visible if the group is and not the first sep - var groupVisible = _ribbon.InDesignHelperMode || ribbonGroup.Visible; + var groupVisible = _ribbon!.InDesignHelperMode || ribbonGroup.Visible; _groupSepCache[i].Visible = groupVisible && !ignoreSep; regenerate[ribbonGroup].Visible = groupVisible; @@ -553,7 +553,7 @@ private int AdjustGroupStateToMatchSpace(ViewLayoutContext context) _groupWidths = new int[listGroups.Count]; for (var i = 0; i < listGroups.Count; i++) { - _groupWidths[i] = listWidths[i][bestIndexes[i]].Width; + _groupWidths[i] = listWidths[i][bestIndexes![i]].Width; listGroups[i].SetSolutionSize(listWidths[i][bestIndexes[i]].Sizing); } } diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupsArea.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupsArea.cs index 00ffe8ca5..37516e894 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupsArea.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupsArea.cs @@ -47,14 +47,14 @@ public ViewLayoutRibbonGroupsArea([DisallowNull] KryptonRibbon ribbon, Debug.Assert(needPaintDelegate != null); // Remember the incoming reference - _ribbon = ribbon; + _ribbon = ribbon!; // Create access to the redirector and use as our palette source _backInherit = new PaletteBackInheritRedirect(redirect, PaletteBackStyle.PanelClient); SetPalettes(_backInherit); // Create and add the only child we need, the groups area border element - ViewGroups = new ViewDrawRibbonGroupsBorderSynch(ribbon, needPaintDelegate); + ViewGroups = new ViewDrawRibbonGroupsBorderSynch(ribbon!, needPaintDelegate!); Add(ViewGroups); } @@ -119,7 +119,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) Debug.Assert(context != null); // We take on all the available display area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; // Find the correct padding to use Padding padding = _ribbon.RealMinimizedMode ? _layoutMinimizedPadding : _layoutNormalPadding; diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonQATContents.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonQATContents.cs index b66bd82fd..0c0bf6dde 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonQATContents.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonQATContents.cs @@ -45,8 +45,8 @@ public ViewLayoutRibbonQATContents([DisallowNull] KryptonRibbon ribbon, Debug.Assert(ribbon != null); Debug.Assert(needPaint != null); - Ribbon = ribbon; - _needPaint = needPaint; + Ribbon = ribbon!; + _needPaint = needPaint!; // Create initial lookup table _qatButtonToView = new QATButtonToView(); @@ -54,7 +54,7 @@ public ViewLayoutRibbonQATContents([DisallowNull] KryptonRibbon ribbon, // Create the extra button for customization/overflow if (showExtraButton) { - _extraButton = new ViewDrawRibbonQATExtraButton(ribbon, needPaint); + _extraButton = new ViewDrawRibbonQATExtraButton(ribbon!, needPaint!); _extraButton.ClickAndFinish += OnExtraButtonClick; } } @@ -203,19 +203,19 @@ public override Size GetPreferredSize(ViewLayoutContext context) // Find total width and maximum height across all child elements for (var i = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; // Only interested in visible items that are not the extra button if (child != _extraButton) { // Cast child to correct type - var view = (ViewDrawRibbonQATButton)child; + var view = child as ViewDrawRibbonQATButton; // If the quick access toolbar button wants to be visible - if (view.QATButton.GetVisible() || Ribbon.InDesignHelperMode) + if (view!.QATButton.GetVisible() || Ribbon.InDesignHelperMode) { // Cache preferred size of the child - Size childSize = child.GetPreferredSize(context); + Size childSize = child!.GetPreferredSize(context); // Only need extra processing for children that have some width if (childSize.Width > 0) @@ -261,7 +261,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) SyncChildren(true); // We take on all the available display area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; var x = ClientLocation.X; var right = ClientRectangle.Right; @@ -286,15 +286,15 @@ public override void Layout([DisallowNull] ViewLayoutContext context) // Position each item from left to right taking up entire height for (var i = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; - // We only position visible items and we always ignore the extra button + // We only position visible items, and we always ignore the extra button if (child != _extraButton) { - if (child.Visible) + if (child!.Visible) { // Cache preferred size of the child - Size childSize = this[i].GetPreferredSize(context); + Size childSize = this[i]!.GetPreferredSize(context); // Is there enough width for this item to be displayed if ((childSize.Width + x) <= right) @@ -303,7 +303,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) context.DisplayRectangle = new Rectangle(x, y, childSize.Width, height); // Position the element - this[i].Layout(context); + this[i]!.Layout(context); // Move across to next position x += childSize.Width; @@ -529,7 +529,7 @@ private void SyncChildren(bool layout) foreach (IQuickAccessToolbarButton qatButton in qatButtons) { // Get the currently cached view for the button - if (!_qatButtonToView.TryGetValue(qatButton, out ViewDrawRibbonQATButton view)) + if (!_qatButtonToView.TryGetValue(qatButton, out var view)) { // If a new button, create a view for it now view = new ViewDrawRibbonQATButton(Ribbon, qatButton, _needPaint); diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonScrollPort.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonScrollPort.cs index c81279275..5422ea0c5 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonScrollPort.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonScrollPort.cs @@ -36,7 +36,7 @@ public RibbonViewControl([DisallowNull] KryptonRibbon ribbon) : base(ribbon) { Debug.Assert(ribbon != null); - _ribbon = ribbon; + _ribbon = ribbon!; // Create and add a hidden button to act as the focus target _hiddenFocusTarget = new Button @@ -65,7 +65,7 @@ public RibbonViewControl([DisallowNull] KryptonRibbon ribbon) protected override bool ProcessDialogKey(Keys keyData) { // Grab the controlling control that is a parent - Control c = _ribbon.GetControllerControl(this); + Control? c = _ribbon.GetControllerControl(this); // Grab the view manager handling the focus view ViewBase? focusView = null; @@ -73,14 +73,14 @@ protected override bool ProcessDialogKey(Keys keyData) { case VisualPopupGroup popGroup: { - var manager = (ViewRibbonPopupGroupManager)popGroup.GetViewManager(); - focusView = manager.FocusView; + var manager = popGroup.GetViewManager() as ViewRibbonPopupGroupManager; + focusView = manager?.FocusView; break; } case VisualPopupMinimized minimized: { - var manager = (ViewRibbonMinimizedManager)minimized.GetViewManager(); - focusView = manager.FocusView; + var manager = minimized.GetViewManager() as ViewRibbonMinimizedManager; + focusView = manager?.FocusView; break; } } @@ -124,7 +124,7 @@ protected override bool ProcessDialogKey(Keys keyData) private readonly ViewBase _viewFiller; private readonly ViewLayoutRibbonScroller _nearScroller; private readonly ViewLayoutRibbonScroller _farScroller; - private readonly ViewLayoutRibbonTabs _ribbonTabs; + private readonly ViewLayoutRibbonTabs? _ribbonTabs; private readonly RibbonViewControl _viewControlContent; private Rectangle _viewClipRect; private int _scrollOffset; @@ -160,23 +160,23 @@ public ViewLayoutRibbonScrollPort([DisallowNull] KryptonRibbon ribbon, Debug.Assert(needPaintDelegate != null); // Remember initial settings - _ribbon = ribbon; + _ribbon = ribbon!; _orientation = orientation; - _viewFiller = viewFiller; - _needPaintDelegate = needPaintDelegate; + _viewFiller = viewFiller!; + _needPaintDelegate = needPaintDelegate!; _scrollSpeed = scrollSpeed; _ribbonTabs = viewFiller as ViewLayoutRibbonTabs; // Default to left hand scroll position _scrollOffset = 0; - // Place the child view inside a actual control, so that the contents of the + // Place the child view inside an actual control, so that the contents of the // filler are clipped to the control size. This is needed if the child view // contains controls and need clipping inside this area and so prevent them // from drawing over the end scrollers. - _viewControlContent = new RibbonViewControl(ribbon); + _viewControlContent = new RibbonViewControl(ribbon!); _viewControlContent.PaintBackground += OnViewControlPaintBackground; - ViewLayoutControl = new ViewLayoutControl(_viewControlContent, ribbon, _viewFiller); + ViewLayoutControl = new ViewLayoutControl(_viewControlContent, ribbon!, _viewFiller); // Removed because of this // https://github.com/Krypton-Suite/Standard-Toolkit/issues/372 @@ -189,8 +189,8 @@ public ViewLayoutRibbonScrollPort([DisallowNull] KryptonRibbon ribbon, //} // Create the two scrollers used when not enough space for filler - _nearScroller = new ViewLayoutRibbonScroller(ribbon, NearOrientation, insetForTabs, needPaintDelegate); - _farScroller = new ViewLayoutRibbonScroller(ribbon, FarOrientation, insetForTabs, needPaintDelegate); + _nearScroller = new ViewLayoutRibbonScroller(ribbon!, NearOrientation, insetForTabs, needPaintDelegate!); + _farScroller = new ViewLayoutRibbonScroller(ribbon!, FarOrientation, insetForTabs, needPaintDelegate!); // Hook into scroller events _nearScroller.Click += OnNearClick; @@ -459,18 +459,18 @@ public override void Layout([DisallowNull] ViewLayoutContext context) Enabled = _ribbon.Enabled; // We take on all the available display area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; Rectangle layoutRect = ClientRectangle; var controlRect = new Rectangle(Point.Empty, ClientSize); - // Reset the the view control layout offset to be zero again + // Reset the view control layout offset to be zero again ViewLayoutControl.LayoutOffset = Point.Empty; // Ask the view control the size it would like to be, this is the requested filler // size of the control. If it wants more than we can give then scroll buttons are // needed, otherwise we can give it the requested size and any extra available. - _ribbon.GetViewManager().DoNotLayoutControls = true; + _ribbon.GetViewManager()!.DoNotLayoutControls = true; ViewLayoutControl.GetPreferredSize(context); // Ensure context has the correct control @@ -480,7 +480,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) _viewFiller.Layout(context); } - _ribbon.GetViewManager().DoNotLayoutControls = false; + _ribbon.GetViewManager()!.DoNotLayoutControls = false; Size fillerSize = _viewFiller.ClientSize; // Limit check the scroll offset @@ -611,10 +611,10 @@ public override void Layout([DisallowNull] ViewLayoutContext context) if (_ribbon.SelectedTab != null) { // Cast to correct type - ViewBase viewTab = layoutTabs.GetViewForRibbonTab(_ribbon.SelectedTab); + ViewBase? viewTab = layoutTabs.GetViewForRibbonTab(_ribbon.SelectedTab); // If a scroll change is required to bring it into view - if (ScrollIntoView(viewTab.ClientRectangle, false)) + if (ScrollIntoView(viewTab!.ClientRectangle, false)) { // Call ourself again to take change into account Layout(context); @@ -645,13 +645,13 @@ public override void Render([DisallowNull] RenderContext context) // New clipping region is at most our own client size using var combineRegion = new Region(_viewClipRect); // Remember the current clipping region - Region clipRegion = context.Graphics.Clip.Clone(); + Region clipRegion = context?.Graphics.Clip.Clone()!; // Reduce clipping region down by the existing clipping region combineRegion.Intersect(clipRegion); // Use new region that restricts drawing to our client size only - context.Graphics.Clip = combineRegion; + context!.Graphics.Clip = combineRegion; child.Render(context); @@ -660,7 +660,7 @@ public override void Render([DisallowNull] RenderContext context) } else { - child.Render(context); + child.Render(context!); } } } diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonTabs.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonTabs.cs index 8f902cabf..7855b8143 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonTabs.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonTabs.cs @@ -62,8 +62,8 @@ public ViewLayoutRibbonTabs([DisallowNull] KryptonRibbon ribbon, Debug.Assert(needPaint != null); // Cache references - _ribbon = ribbon; - _needPaint = needPaint; + _ribbon = ribbon!; + _needPaint = needPaint!; // Create cache of draw elements _tabCache = []; @@ -120,7 +120,7 @@ public NeedPaintHandler NeedPaintDelegate /// /// Gets and sets the parent control. /// - public Control ParentControl { get; set; } + public Control? ParentControl { get; set; } #endregion @@ -254,13 +254,13 @@ public KeyTipInfo[] GetTabKeyTips() { // Get the screen location of the view tab - Rectangle tabRect = viewTab.OwningControl.RectangleToScreen(viewTab.ClientRectangle); + Rectangle tabRect = viewTab.OwningControl!.RectangleToScreen(viewTab.ClientRectangle); // The keytip should be centered on the bottom center of the view var screenPt = new Point(tabRect.Left + (tabRect.Width / 2), tabRect.Bottom + 2); // Create new key tip that invokes the tab controller when selected - keyTipList.Add(new KeyTipInfo(true, viewTab.RibbonTab.KeyTip, + keyTipList.Add(new KeyTipInfo(true, viewTab.RibbonTab!.KeyTip, screenPt, viewTab.ClientRectangle, viewTab.KeyTipTarget)); } @@ -357,10 +357,10 @@ public override Size GetPreferredSize(ViewLayoutContext context) // Find total width and maximum height across all child elements for (var i = 0; i < Count; i++) { - ViewBase child = this[i]; + ViewBase? child = this[i]; // Only interested in visible items - if (child.Visible) + if (child!.Visible) { // Cache preferred size of the child _cachedSizes[i] = child.GetPreferredSize(context); @@ -443,7 +443,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) SyncChildrenToRibbonTabs(); // We take on all the available display area - ClientRectangle = context.DisplayRectangle; + ClientRectangle = context!.DisplayRectangle; var x = ClientLocation.X; @@ -484,7 +484,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) } // Position the element - this[i].Layout(context); + this[i]?.Layout(context); // Move across to next position x += layoutSizes[i].Width; @@ -511,12 +511,12 @@ public override void Layout([DisallowNull] ViewLayoutContext context) } // We have an owning form we need to update the custom area it treats as a caption - if (_ribbon.CaptionArea.KryptonForm != null) + if (_ribbon.CaptionArea?.KryptonForm != null) { if (!customCaptionRect.IsEmpty) { // Convert the rectangle to the owning form coordinates - customCaptionRect = ParentControl.RectangleToScreen(customCaptionRect); + customCaptionRect = ParentControl!.RectangleToScreen(customCaptionRect); customCaptionRect = _ribbon.CaptionArea.KryptonForm.RectangleToClient(customCaptionRect); } @@ -627,7 +627,7 @@ private void AddTabsWithContextName(string contextName) // Create tab set when first needed, otherwise this tab must be the last one if (cts == null) { - cts = new ContextTabSet(drawTab, _ribbon.RibbonContexts[ribbonTab.ContextName]); + cts = new ContextTabSet(drawTab, _ribbon.RibbonContexts[ribbonTab.ContextName]!); } else { @@ -784,7 +784,7 @@ private void UpdateContextNameCache() // In design mode if (_ribbon.InDesignHelperMode) { - // All all the defined ribbon contexts + // All the defined ribbon contexts foreach (KryptonRibbonContext context in _ribbon.RibbonContexts) { _cachedSelectedContext.Add(context.ContextName); diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonTabsArea.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonTabsArea.cs index cea834b2d..cb3be1f28 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonTabsArea.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonTabsArea.cs @@ -181,8 +181,8 @@ public override string ToString() => /// public void HookToolTipHandling() { - LayoutAppButton.MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager.ToolTipManager, LayoutAppButton, _appButtonController); - LayoutAppTab.MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager.ToolTipManager, LayoutAppTab, _appTabController); + LayoutAppButton.MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager?.ToolTipManager!, LayoutAppButton, _appButtonController); + LayoutAppTab.MouseController = new ToolTipController(_ribbon.TabsArea?.ButtonSpecManager!.ToolTipManager!, LayoutAppTab, _appTabController); } #endregion @@ -232,7 +232,7 @@ public void CheckRibbonSize() // If using custom chrome if (_captionArea.UsingCustomChrome) { - _paintCount = _captionArea.KryptonForm.PaintCount; + _paintCount = _captionArea.KryptonForm!.PaintCount; _invalidateTimer.Start(); } } @@ -533,7 +533,7 @@ private void CreateViewElements(PaletteRedirect redirect) new IPaletteMetric[] { _ribbon.StateCommon }, new[] { PaletteMetricInt.HeaderButtonEdgeInsetPrimary }, new[] { PaletteMetricPadding.RibbonButtonPadding }, - _ribbon.CreateToolStripRenderer, + _ribbon.CreateToolStripRenderer!, NeedPaintDelegate); // Create the manager for handling tooltips @@ -584,13 +584,13 @@ private void OnRibbonParentChanged(object sender, EventArgs e) private void OnRibbonFormActivated(object sender, EventArgs e) { - _ribbon.ViewRibbonManager.Active(); + _ribbon.ViewRibbonManager?.Active(); _ribbon.UpdateBackStyle(); } private void OnRibbonFormDeactivate(object sender, EventArgs e) { - _ribbon.ViewRibbonManager.Inactive(); + _ribbon.ViewRibbonManager?.Inactive(); _ribbon.UpdateBackStyle(); } @@ -624,7 +624,7 @@ private void OnRibbonMdiChildActivate(object sender, EventArgs e) // We never want the mdi child window to have a system menu, we provide the // pendant buttons as part of the ribbon and so replace the need for it. - PI.SetMenu(new HandleRef(_ribbon, topForm.Handle), NullHandleRef); + PI.SetMenu(new HandleRef(_ribbon, topForm!.Handle), NullHandleRef); if (_activeMdiChild != null) { @@ -720,12 +720,12 @@ private void OnAppButtonClicked(object sender, EventArgs e) _ribbon.LocalCustomPalette, _ribbon.PaletteMode, _ribbon.GetRedirector(), appRectTop, appRectBottom, - _appButtonController.Keyboard); + _appButtonController!.Keyboard); // Need to know when the visual control is removed _appMenu.Disposed += OnAppMenuDisposed; - // Adjust the screen rect of the app button/tab, so we show half way down the button + // Adjust the screen rect of the app button/tab, so we show half-way down the button appRectShow.X -= 3; appRectShow.Height = 0; @@ -854,7 +854,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) if (_ribbon.AllowButtonSpecToolTips) { // Create a helper object to provide tooltip values - var buttonSpecMapping = new ButtonSpecToContent(_ribbon.GetRedirector(), buttonSpec); + var buttonSpecMapping = new ButtonSpecToContent(_ribbon.GetRedirector()!, buttonSpec); // Is there actually anything to show for the tooltip if (buttonSpecMapping.HasContent) @@ -901,7 +901,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) _visualPopupToolTip?.Dispose(); // Create the actual tooltip popup object - _visualPopupToolTip = new VisualPopupToolTip(_ribbon.GetRedirector(), + _visualPopupToolTip = new VisualPopupToolTip(_ribbon.GetRedirector()!, sourceContent, _ribbon.Renderer, PaletteBackStyle.ControlToolTip, diff --git a/Source/Krypton Components/Krypton.Toolkit/AccurateText/AccurateText.cs b/Source/Krypton Components/Krypton.Toolkit/AccurateText/AccurateText.cs index 10a26a6bc..b2fe0670b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/AccurateText/AccurateText.cs +++ b/Source/Krypton Components/Krypton.Toolkit/AccurateText/AccurateText.cs @@ -397,7 +397,7 @@ public static void DrawCompositionGlowingText(Graphics? g, } // Select the font for use when drawing - var hFont = font.ToHfont(); + var hFont = font!.ToHfont(); PI.SelectObject(mDC, hFont); // Get renderer for the correct state @@ -503,7 +503,7 @@ public static void DrawCompositionText(Graphics? g, } // Select the font for use when drawing - var hFont = font.ToHfont(); + var hFont = font!.ToHfont(); PI.SelectObject(mDC, hFont); // Get renderer for the correct state diff --git a/Source/Krypton Components/Krypton.Toolkit/AccurateText/AccurateTextMemento.cs b/Source/Krypton Components/Krypton.Toolkit/AccurateText/AccurateTextMemento.cs index 84b05c884..d91d278db 100644 --- a/Source/Krypton Components/Krypton.Toolkit/AccurateText/AccurateTextMemento.cs +++ b/Source/Krypton Components/Krypton.Toolkit/AccurateText/AccurateTextMemento.cs @@ -57,7 +57,7 @@ public void Dispose() { if (_disposeFont) { - Font.Dispose(); + Font?.Dispose(); } GC.SuppressFinalize(this); } diff --git a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecCollection.cs b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecCollection.cs index 109ef8e82..0185cff2b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecCollection.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecCollection.cs @@ -391,16 +391,16 @@ public bool Remove([DisallowNull] T item) Debug.Assert(item != null, nameof(item) + " != null"); // Cache the index of the button spec - var index = IndexOf(item); + var index = IndexOf(item!); // Generate before event - OnRemoving(new ButtonSpecEventArgs(item, index)); + OnRemoving(new ButtonSpecEventArgs(item!, index)); // Remove from the internal list - var ret = _specs.Remove(item); + var ret = _specs.Remove(item!); // Generate after event - OnRemoved(new ButtonSpecEventArgs(item, index)); + OnRemoved(new ButtonSpecEventArgs(item!, index)); return ret; } diff --git a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecManagerDraw.cs b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecManagerDraw.cs index 88d0bf302..e6388d408 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecManagerDraw.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecManagerDraw.cs @@ -81,7 +81,7 @@ public ButtonSpecManagerDraw(Control control, viewMetricPaddings, getRenderer, needPaint) { Debug.Assert(viewDockers != null); - Debug.Assert(viewDockers.Length == viewMetrics.Length); + Debug.Assert(viewDockers!.Length == viewMetrics.Length); Debug.Assert(viewDockers.Length == viewMetricPaddings.Length); // Remember references diff --git a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecToContent.cs b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecToContent.cs index f1b4d8679..6c690d78f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecToContent.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecToContent.cs @@ -33,8 +33,8 @@ public ButtonSpecToContent([DisallowNull] PaletteBase palette, { Debug.Assert(palette != null); Debug.Assert(buttonSpec != null); - _palette = palette; - _buttonSpec = buttonSpec; + _palette = palette!; + _buttonSpec = buttonSpec!; } #endregion diff --git a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecView.cs b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecView.cs index 8f9e8a6a1..667c0a22f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecView.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecView.cs @@ -55,7 +55,7 @@ public ButtonSpecView([DisallowNull] PaletteRedirect redirector, // Intercept calls from the button for color remapping and instead use // the button spec defined map and the container foreground color - RemapPalette = Manager.CreateButtonSpecRemap(redirector, ButtonSpec); + RemapPalette = Manager.CreateButtonSpecRemap(redirector!, ButtonSpec); // Use a redirector to get button values directly from palette _palette = new PaletteTripleRedirect(RemapPalette, @@ -71,7 +71,7 @@ public ButtonSpecView([DisallowNull] PaletteRedirect redirector, var images = new DropDownButtonImages(needPaint); // Image need an extra redirector to check the local images first - var paletteDropDownButtonImages = new PaletteRedirectDropDownButton(redirector, images); + var paletteDropDownButtonImages = new PaletteRedirectDropDownButton(redirector!, images); ViewButton.DropDownPalette = paletteDropDownButtonImages; // Associate the view with the source component (for design time support) diff --git a/Source/Krypton Components/Krypton.Toolkit/ContextMenu/KryptonContextMenuItemBase.cs b/Source/Krypton Components/Krypton.Toolkit/ContextMenu/KryptonContextMenuItemBase.cs index 2f3d92610..e60761121 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ContextMenu/KryptonContextMenuItemBase.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ContextMenu/KryptonContextMenuItemBase.cs @@ -181,7 +181,7 @@ public ToolTipValues ToolTipValues /// [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - internal ToolTipManager ToolTipManager { get; } + internal ToolTipManager? ToolTipManager { get; } internal void OnShowToolTip(object sender, ToolTipEventArgs e) { @@ -219,8 +219,8 @@ internal void OnShowToolTip(object sender, ToolTipEventArgs e) _toolTipValues.Image = args.Icon; // Create the actual tooltip popup object - var renderer = _provider.ProviderRedirector?.Target?.GetRenderer(); - _visualPopupToolTip = new VisualPopupToolTip(_provider.ProviderRedirector!, + var renderer = _provider.ProviderRedirector.Target.GetRenderer(); + _visualPopupToolTip = new VisualPopupToolTip(_provider.ProviderRedirector, _toolTipValues, renderer, PaletteBackStyle.ControlToolTip, diff --git a/Source/Krypton Components/Krypton.Toolkit/Controller/TooltipController.cs b/Source/Krypton Components/Krypton.Toolkit/Controller/TooltipController.cs index 5c6737849..152e41cf5 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controller/TooltipController.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controller/TooltipController.cs @@ -19,7 +19,7 @@ public class ToolTipController : GlobalId, IMouseController { #region Instance Fields - private readonly ToolTipManager _manager; + private readonly ToolTipManager? _manager; private readonly ViewBase _targetElement; private readonly IMouseController? _targetController; #endregion @@ -52,7 +52,7 @@ public ToolTipController([DisallowNull] ToolTipManager manager, /// Reference to the source control instance. public void MouseEnter(Control c) { - _manager.MouseEnter(_targetElement, c); + _manager?.MouseEnter(_targetElement, c); _targetController?.MouseEnter(c); } @@ -64,7 +64,7 @@ public void MouseEnter(Control c) /// Mouse position relative to control. public void MouseMove(Control c, Point pt) { - _manager.MouseMove(_targetElement, c, pt); + _manager?.MouseMove(_targetElement, c, pt); _targetController?.MouseMove(c, pt); } @@ -78,7 +78,7 @@ public void MouseMove(Control c, Point pt) /// True if capturing input; otherwise false. public bool MouseDown(Control c, Point pt, MouseButtons button) { - _manager.MouseDown(_targetElement, c, pt, button); + _manager?.MouseDown(_targetElement, c, pt, button); return _targetController != null && _targetController.MouseDown(c, pt, button); } @@ -91,7 +91,7 @@ public bool MouseDown(Control c, Point pt, MouseButtons button) /// Mouse button released. public void MouseUp(Control c, Point pt, MouseButtons button) { - _manager.MouseUp(_targetElement, c, pt, button); + _manager?.MouseUp(_targetElement, c, pt, button); _targetController?.MouseUp(c, pt, button); } @@ -103,7 +103,7 @@ public void MouseUp(Control c, Point pt, MouseButtons button) /// Reference to view that is next to have the mouse. public void MouseLeave(Control c, ViewBase? next) { - _manager.MouseLeave(_targetElement, c, next); + _manager?.MouseLeave(_targetElement, c, next); _targetController?.MouseLeave(c, next); } @@ -114,7 +114,7 @@ public void MouseLeave(Control c, ViewBase? next) /// Mouse position relative to control. public void DoubleClick(Point pt) { - _manager.DoubleClick(_targetElement, pt); + _manager?.DoubleClick(_targetElement, pt); _targetController?.DoubleClick(pt); } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonAboutBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonAboutBox.cs index 36ebd28ed..d76758453 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonAboutBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonAboutBox.cs @@ -14,7 +14,7 @@ namespace Krypton.Toolkit [DesignerCategory(@"code")] public static class KryptonAboutBox { - #region Implementation + #region Public /// Shows a new . /// The data to pass through. diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCheckSet.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCheckSet.cs index 237653108..e30bc8d64 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCheckSet.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCheckSet.cs @@ -81,7 +81,7 @@ public int Add([DisallowNull] KryptonCheckButton checkButton) /// /// The KryptonCheckButton to locate in the collection. /// True if found in collection; otherwise false. - public bool Contains(KryptonCheckButton checkButton) => + public bool Contains(KryptonCheckButton? checkButton) => // ReSharper disable RedundantBaseQualifier base.List.Contains(checkButton); // ReSharper restore RedundantBaseQualifier @@ -91,7 +91,7 @@ public bool Contains(KryptonCheckButton checkButton) => /// /// The KryptonCheckButton to locate. /// Index of reference; otherwise -1. - public int IndexOf(KryptonCheckButton checkButton) => + public int IndexOf(KryptonCheckButton? checkButton) => // ReSharper disable RedundantBaseQualifier base.List.IndexOf(checkButton); // ReSharper restore RedundantBaseQualifier @@ -157,7 +157,7 @@ public void Remove([DisallowNull] KryptonCheckButton checkButton) /// /// Index of entry to return. /// Reference of KryptonCheckButton instance. - public KryptonCheckButton this[int index] + public KryptonCheckButton? this[int index] { get { @@ -167,7 +167,7 @@ public KryptonCheckButton this[int index] } // ReSharper disable RedundantBaseQualifier - return (KryptonCheckButton)base.List[index]; + return base.List[index] as KryptonCheckButton; // ReSharper restore RedundantBaseQualifier } } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonColorButton.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonColorButton.cs index b41c1f800..108ae57cd 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonColorButton.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonColorButton.cs @@ -955,7 +955,7 @@ protected override void OnLostFocus(EventArgs e) protected override void OnClick(EventArgs e) { // Find the form this color button is on - Form owner = FindForm(); + Form? owner = FindForm(); // If we find a valid owner if (owner != null) @@ -1099,10 +1099,10 @@ protected virtual void OnCommandPropertyChanged(object sender, PropertyChangedEv switch (e.PropertyName) { case nameof(Enabled): - Enabled = KryptonCommand.Enabled; + Enabled = KryptonCommand!.Enabled; break; case @"ImageSmall": - Values.Image = KryptonCommand.ImageSmall; + Values.Image = KryptonCommand!.ImageSmall; PerformNeedPaint(true); break; case nameof(Text): @@ -1233,7 +1233,7 @@ private bool ShowDropDown() DecideOnVisible(_separatorMoreColors, _itemsMoreColors); // Monitor relevant events inside the context menu - HookContextMenuEvents(_kryptonContextMenu.Items, true); + HookContextMenuEvents(_kryptonContextMenu!.Items, true); // Show relative to the screen rectangle cpma.KryptonContextMenu.Closed += OnKryptonContextMenuClosed; @@ -1271,7 +1271,7 @@ private void OnKryptonContextMenuClosed(object sender, EventArgs e) ContextMenuClosed(); // Unhook from item events - HookContextMenuEvents(_kryptonContextMenu.Items, false); + HookContextMenuEvents(_kryptonContextMenu!.Items, false); } private void OnButtonSelect(object sender, MouseEventArgs e) @@ -1337,9 +1337,9 @@ private void UpdateRecentColors(Color color) if (AutoRecentColors) { // We do not add to recent colors if it is inside another color columns - foreach (KryptonContextMenuItemBase item in _kryptonContextMenu.Items) + foreach (KryptonContextMenuItemBase item in _kryptonContextMenu!.Items) { - // Only interested in the non-recent colors color columns + // Only interested in the non-recent colors, color columns if ((item != _colorsRecent) && (item is KryptonContextMenuColorColumns colors)) { // Cast to correct type @@ -1439,7 +1439,7 @@ private void DecideOnVisible(KryptonContextMenuItemBase visible, KryptonContextM if (target.Visible) { // Check all items before the target - foreach (KryptonContextMenuItemBase item in _kryptonContextMenu.Items) + foreach (KryptonContextMenuItemBase item in _kryptonContextMenu!.Items) { // Finish when we reach the target if (item == target) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCommandLinkButton.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCommandLinkButton.cs index e84599891..29cd6b04d 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCommandLinkButton.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCommandLinkButton.cs @@ -81,7 +81,7 @@ public KryptonCommandLinkButton() // Create the palette storage StateCommon = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonCommand, PaletteBorderStyle.ButtonCommand, PaletteContentStyle.ButtonCommand, NeedPaintDelegate); PaletteContentText contentShortText = StateCommon.Content.ShortText; - contentShortText.Font = new Font(@"Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + contentShortText.Font = KryptonManager.CurrentGlobalPalette.BaseFont; //new Font(@"Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); contentShortText.TextH = PaletteRelativeAlign.Near; contentShortText.TextV = PaletteRelativeAlign.Center; StateCommon.Content.LongText.TextH = PaletteRelativeAlign.Near; @@ -110,7 +110,7 @@ public KryptonCommandLinkButton() _overrideNormal, _overrideTracking, _overridePressed, - new PaletteMetricRedirect(Redirector!), + new PaletteMetricRedirect(Redirector), CommandLinkImageValues, CommandLinkTextValues, Orientation, UseMnemonic) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonInputBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonInputBox.cs index 4340dee92..ca9134fc8 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonInputBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonInputBox.cs @@ -12,58 +12,17 @@ public static class KryptonInputBox /// /// Displays an input box with provided prompt and caption and defaulted response string. /// - /// The text to display as an input prompt. - /// The text to display in the title bar of the input box. - /// Default response text.. - /// The cue text. - /// The colour of the cue. - /// The cue font. - /// Enables the password option. + /// The data to feed through to . /// Input string. - public static string Show(string prompt, - string caption = @"", - string defaultResponse = @"", - string cueText = @"", - Color cueColour = new Color(), // Color.Empty - Font? cueTypeface = null, - bool usePasswordOption = false) - => InternalShow(null, prompt, caption, defaultResponse, cueText, cueColour, cueTypeface, usePasswordOption); - - /// - /// DDisplays an input box in front of the specified object and with the provided prompt and caption and defaulted response string. - /// - /// Owner of the modal dialog box. - /// The text to display as an input prompt. - /// The text to display in the title bar of the input box. - /// Default response text.. - /// The cue text. - /// The colour of the cue. - /// The cue font. - /// Enables the password option. - /// Input string. - public static string Show(IWin32Window owner, string prompt, - string caption = @"", - string defaultResponse = @"", - string cueText = @"", - Color cueColour = new Color(), // Color.Empty - Font? cueTypeface = null, - bool usePasswordOption = false) - => InternalShow(owner, prompt, caption, defaultResponse, cueText, cueColour, cueTypeface, usePasswordOption); + public static string Show(KryptonInputBoxData inputBoxData) + => InternalShow(inputBoxData); #endregion #region Implementation - private static string InternalShow(IWin32Window? owner, - string prompt, - string caption, - string defaultResponse, - string cueText, - Color cueColour, - Font? cueTypeface, - bool usePasswordOption) => - VisualInputBoxForm.InternalShow(owner, prompt, caption, defaultResponse, cueText, cueColour, - cueTypeface, usePasswordOption); + private static string InternalShow(KryptonInputBoxData inputBoxData) => + VisualInputBoxForm.InternalShow(inputBoxData); #endregion } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonInputBoxManager.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonInputBoxManager.cs index aaa2547fc..db19c8946 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonInputBoxManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonInputBoxManager.cs @@ -17,97 +17,39 @@ namespace Krypton.Toolkit public class KryptonInputBoxManager : Component { #region Variables - private bool _usePasswordOption; - private Color _cueColour; + private KryptonInputBoxData _inputBoxData; - private Font _cueTypeface; - - private string _caption, _cueText, _defaultResponse, _prompt; - - private IWin32Window? _owner; #endregion #region Properties - /// Gets or sets a value indicating whether [use password option]. - /// true if [use password option]; otherwise, false. - [DefaultValue(false), Description(@"Triggers the password feature of the response textbox.")] - public bool UsePasswordOption { get => _usePasswordOption; set => _usePasswordOption = value; } - - /// Gets or sets the cue colour. - /// The cue colour. - [DefaultValue(typeof(Color), "Color.Gray"), Description(@"Modifies the cue text colour.")] - public Color CueColour { get => _cueColour; set => _cueColour = value; } - - /// Gets or sets the cue typeface. - /// The cue typeface. - [DefaultValue(typeof(Font), "Segoe UI, 9pt"), Description(@"The cue text typeface.")] - public Font CueTypeface { get => _cueTypeface; set => _cueTypeface = value; } - /// Gets or sets the caption. - /// The caption. - [DefaultValue(""), Description(@"The krypton input box caption.")] - public string Caption { get => _caption; set => _caption = value; } + public KryptonInputBoxData InputBoxData { get => _inputBoxData; set => _inputBoxData = value; } - /// Gets or sets the cue text. - /// The cue text. - [DefaultValue(""), Description(@"The krypton input box cue text.")] - public string CueText { get => _cueText; set => _cueText = value; } - - /// Gets or sets the default response. - /// The default response. - [DefaultValue(""), Description(@"The krypton input box default response.")] - public string DefaultResponse { get => _defaultResponse; set => _defaultResponse = value; } - - /// Gets or sets the prompt. - /// The prompt. - [DefaultValue(""), Description(@"The krypton input box prompt text.")] - public string Prompt { get => _prompt; set => _prompt = value; } #endregion #region Constructor /// Initializes a new instance of the class. public KryptonInputBoxManager() { - _usePasswordOption = false; - - _cueColour = Color.Gray; - - _cueTypeface = new Font("Segoe UI", 9f); - - _caption = string.Empty; - - _cueText = string.Empty; - - _defaultResponse = string.Empty; - - _prompt = string.Empty; + _inputBoxData = new KryptonInputBoxData(); } #endregion #region Setters and Getters /// Sets the Owner to the value of value. /// The desired value of Owner. - public void SetOwner(IWin32Window value) => _owner = value; + public void SetOwner(IWin32Window value) => _inputBoxData.Owner = value; /// Returns the value of the Owner. /// The value of the Owner. - public IWin32Window? GetOwner() => _owner; + public IWin32Window? GetOwner() => _inputBoxData.Owner; #endregion #region Methods /// Displays the krypton input box. - public void DisplayKryptonInputBox() - { - if (GetOwner() != null) - { - KryptonInputBox.Show(_owner!, _prompt, _caption, _defaultResponse, _cueText, _cueColour, _cueTypeface, _usePasswordOption); - } - else - { - KryptonInputBox.Show(_prompt, _caption, _defaultResponse, _cueText, _cueColour, _cueTypeface, _usePasswordOption); - } - } + public void DisplayKryptonInputBox() => KryptonInputBox.Show(_inputBoxData); + #endregion } } \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonToast.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonToast.cs new file mode 100644 index 000000000..822eec455 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonToast.cs @@ -0,0 +1,55 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2023 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + /// The public interface to the class. + [ToolboxItem(false)] + [DesignerCategory(@"code")] + public static class KryptonToast + { + #region Public + + public static void Show(KryptonToastData toastData) => ShowCore(toastData); + + #endregion + + #region Implementation + + private static void ShowCore(KryptonToastData toastData) + { + using var kt = new VisualToastForm(toastData.ShowCloseButton, toastData.ShowProgressBar, + toastData.ShowCountdownPercentage, + toastData.ShowActionButton, toastData.ShowUserResponse, + toastData.UserResponsePromptColor, + toastData.LabelContentTextAlignment, + toastData.TitleTextAlignment, toastData.UserResponsePromptFont, + toastData.UserInputControlStyle, + toastData.UserResponsePromptAlignmentHorizontal, + toastData.UserResponsePromptAlignmentVertical, + toastData.UserResponseTextAlignmentHorizontal, + toastData.NotificationContentRichTextBoxAlignment, + toastData.NotificationContentTextBoxAlignment, + toastData.ActionButton, toastData.ActionType, + toastData.ToastNotificationContentAreaType, toastData.NotificationIcon, + toastData.ToastNotificationInputAreaType, toastData.CountDownSeconds, + toastData.CountDownTimerInterval, + toastData.NumericUpDownInputMaximum, toastData.ProgressBarMaximum, toastData.CustomImage, + toastData.SoundStream, toastData.RightToLeft, toastData.Title, + toastData.NotificationContentText, + toastData.SoundPath, toastData.UserResponsePromptText, + toastData.NotificationContentLinkArea, + toastData.NotificationContentLinkDestination, toastData.ActionButtonCommand); + + kt.Show(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContainerControlBase.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContainerControlBase.cs index d36ecfff5..3ebae2a16 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContainerControlBase.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContainerControlBase.cs @@ -30,8 +30,8 @@ public abstract class VisualContainerControlBase : ContainerControl, private bool _refreshAll; private bool _paintTransparent; private bool _evalTransparent; - private PaletteBase _localPalette; - private PaletteBase _palette; + private PaletteBase? _localPalette; + private PaletteBase? _palette; private PaletteMode _paletteMode; private readonly SimpleCall _refreshCall; private readonly SimpleCall _layoutCall; @@ -152,9 +152,9 @@ protected override void Dispose(bool disposing) ViewManager?.Dispose(); _palette = null; - Renderer = null; + Renderer = null!; _localPalette = null; - Redirector.Target = null; + Redirector!.Target = null!; } base.Dispose(disposing); @@ -315,7 +315,7 @@ public PaletteMode PaletteMode [Category(@"Visuals")] [Description(@"Custom palette applied to drawing.")] [DefaultValue(null)] - public PaletteBase Palette + public PaletteBase? Palette { [DebuggerStepThrough] get => _localPalette; @@ -326,7 +326,7 @@ public PaletteBase Palette if (_localPalette != value) { // Remember the starting palette - PaletteBase old = _localPalette; + PaletteBase? old = _localPalette; // Use the provided palette value SetPalette(value); @@ -384,7 +384,7 @@ public IRenderer Renderer /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] - public ToolStripRenderer? CreateToolStripRenderer() => Renderer?.RenderToolStrip(GetResolvedPalette()); + public ToolStripRenderer? CreateToolStripRenderer() => Renderer.RenderToolStrip(GetResolvedPalette()); /// /// Gets or sets the background image displayed in the control. @@ -420,7 +420,7 @@ public override ImageLayout BackgroundImageLayout /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public PaletteBase GetResolvedPalette() => _palette; + public PaletteBase GetResolvedPalette() => _palette!; /// /// Gets and sets the dirty palette counter. @@ -500,7 +500,7 @@ protected bool ForceViewLayout() if (ViewManager != null) { // Ask the view to perform a layout - ViewManager?.Layout(Renderer!); + ViewManager?.Layout(Renderer); return true; } @@ -555,7 +555,7 @@ protected bool NeedTransparentPaint /// Graphics reference for drawing. /// Brush to use when painting. /// Client area to paint. - protected virtual void PaintBackground(Graphics g, Brush backBrush, Rectangle backRect) => g?.FillRectangle(backBrush, backRect); + protected virtual void PaintBackground(Graphics g, Brush backBrush, Rectangle backRect) => g.FillRectangle(backBrush, backRect); /// /// Gets a value indicating is processing of mnemonics should be allowed. @@ -575,7 +575,7 @@ protected bool CanProcessMnemonic() } // Move up one level - c = c.Parent; + c = c.Parent!; } // Evert control in chain is visible and enabled, so allow mnemonics @@ -591,7 +591,7 @@ protected bool CanProcessMnemonic() /// True if paint required; otherwise false. protected virtual bool EvalTransparentPaint() => // Do we have a manager to use for asking about painting? - ViewManager != null && ViewManager.EvalTransparentPaint(Renderer!); + ViewManager != null && ViewManager.EvalTransparentPaint(Renderer); /// /// Work out if this control needs to use Invoke to force a repaint. @@ -629,7 +629,7 @@ protected virtual void OnPaletteChanged(EventArgs e) // Update the redirector with latest palette if (Redirector != null) { - Redirector.Target = _palette; + Redirector.Target = _palette!; } // Need to recalculate anything relying on the palette @@ -659,7 +659,7 @@ protected virtual void OnPaletteNeedPaint(object sender, NeedLayoutEventArgs e) /// Source of notification. /// An NeedLayoutEventArgs containing event data. /// - protected virtual void OnNeedPaint(object sender, [DisallowNull] NeedLayoutEventArgs e) + protected virtual void OnNeedPaint(object? sender, [DisallowNull] NeedLayoutEventArgs e) { Debug.Assert(e != null); @@ -710,7 +710,7 @@ protected virtual void OnNeedPaint(object sender, [DisallowNull] NeedLayoutEvent /// Create the redirector instance. /// /// PaletteRedirect derived class. - protected virtual PaletteRedirect CreateRedirector() => new PaletteRedirect(_palette); + protected virtual PaletteRedirect CreateRedirector() => new PaletteRedirect(_palette!); // ReSharper restore VirtualMemberNeverOverridden.Global #endregion @@ -751,7 +751,7 @@ protected override void OnLayout(LayoutEventArgs levent) _layoutDirty = false; // Ask the view to perform a layout - ViewManager?.Layout(Renderer!); + ViewManager?.Layout(Renderer); } while (_layoutDirty && (max-- > 0)); } @@ -798,7 +798,7 @@ protected override void OnPaint(PaintEventArgs? e) // Ask the view to repaint the visual structure if (!IsDisposed && !Disposing) { - ViewManager?.Paint(Renderer!, e); + ViewManager?.Paint(Renderer, e); } // Request for a refresh has been serviced @@ -991,7 +991,7 @@ protected virtual void OnGlobalPaletteChanged(object sender, EventArgs e) // Update ourself with the new global palette _localPalette = null; SetPalette(KryptonManager.CurrentGlobalPalette); - Redirector!.Target = _palette; + Redirector.Target = _palette!; // Need to recalculate anything relying on the palette DirtyPaletteCounter++; @@ -1075,7 +1075,7 @@ protected virtual void ContextMenuClosed() #endregion #region Implementation - private void SetPalette(PaletteBase palette) + private void SetPalette(PaletteBase? palette) { if (palette != _palette) { @@ -1092,7 +1092,7 @@ private void SetPalette(PaletteBase palette) _palette = palette; // Get the renderer associated with the palette - Renderer = _palette?.GetRenderer(); + Renderer = _palette?.GetRenderer()!; // Hook to new palette events if (_palette != null) @@ -1107,7 +1107,7 @@ private void SetPalette(PaletteBase palette) private void OnBaseChanged(object sender, EventArgs e) => // Change in base renderer or base palette require we fetch the latest renderer - Renderer = _palette?.GetRenderer(); + Renderer = _palette?.GetRenderer()!; private void PaintTransparentBackground(PaintEventArgs? e) { @@ -1128,7 +1128,7 @@ private void PaintTransparentBackground(PaintEventArgs? e) null)!; } - _miPTB?.Invoke(this, new object[] { e!, ClientRectangle, null! }); + _miPTB.Invoke(this, new object[] { e!, ClientRectangle, null! }); } else { @@ -1175,10 +1175,10 @@ private void OnPerformLayout() private void OnContextMenuStripOpening(object sender, CancelEventArgs e) { // Get the actual strip instance - ContextMenuStrip cms = base.ContextMenuStrip; + ContextMenuStrip? cms = base.ContextMenuStrip; // Make sure it has the correct renderer - cms.Renderer = CreateToolStripRenderer(); + cms!.Renderer = CreateToolStripRenderer(); } private void OnKryptonContextMenuDisposed(object sender, EventArgs e) => diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContextMenu.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContextMenu.cs index 55b990eca..d479bd5d0 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContextMenu.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContextMenu.cs @@ -93,7 +93,7 @@ public VisualContextMenu(KryptonContextMenu contextMenu, // Create provider instance _provider = new ContextMenuProvider(contextMenu, (ViewContextMenuManager)ViewManager, _viewColumns, - palette, paletteMode, redirector, redirectorImages, + palette!, paletteMode, redirector, redirectorImages, NeedPaintDelegate, enabled); _provider.Closing += OnProviderClosing; @@ -488,7 +488,7 @@ private void SetPalette(PaletteBase palette) Redirector!.Target = _palette; // Get the renderer associated with the palette - Renderer = _palette?.GetRenderer(); + Renderer = _palette.GetRenderer(); // Hook to new palette events if (_palette != null) @@ -502,7 +502,7 @@ private void SetPalette(PaletteBase palette) private void OnBaseChanged(object sender, EventArgs e) => // Change in base renderer or base palette require we fetch the latest renderer - Renderer = _palette?.GetRenderer(); + Renderer = _palette.GetRenderer(); private void OnProviderClosing(object sender, CancelEventArgs e) => _contextMenu?.OnClosing(e); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs index 8df57cc62..ac9b29755 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs @@ -31,8 +31,8 @@ public abstract class VisualControlBase : Control, private bool _paintTransparent; private bool _evalTransparent; private bool _globalEvents; - private KryptonCustomPaletteBase _localCustomPalette; - private PaletteBase _palette; + private KryptonCustomPaletteBase? _localCustomPalette; + private PaletteBase? _palette; private PaletteMode _paletteMode; private readonly SimpleCall _refreshCall; private readonly SimpleCall _layoutCall; @@ -160,7 +160,7 @@ protected override void Dispose(bool disposing) _palette = null; Renderer = null!; _localCustomPalette = null; - Redirector!.Target = null; + Redirector.Target = null; } base.Dispose(disposing); @@ -321,7 +321,7 @@ public PaletteMode PaletteMode public KryptonCustomPaletteBase LocalCustomPalette { [DebuggerStepThrough] - get => _localCustomPalette; + get => _localCustomPalette!; set { @@ -329,7 +329,7 @@ public KryptonCustomPaletteBase LocalCustomPalette if (_localCustomPalette != value) { // Remember the starting palette - PaletteBase old = _localCustomPalette; + PaletteBase? old = _localCustomPalette; // Use the provided palette value SetPalette(value); @@ -387,7 +387,7 @@ public IRenderer Renderer /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] - public ToolStripRenderer? CreateToolStripRenderer() => Renderer?.RenderToolStrip(GetResolvedPalette()); + public ToolStripRenderer CreateToolStripRenderer() => Renderer.RenderToolStrip(GetResolvedPalette()); /// /// Gets or sets the background image displayed in the control. @@ -423,7 +423,7 @@ public override ImageLayout BackgroundImageLayout /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public PaletteBase GetResolvedPalette() => _palette; + public PaletteBase GetResolvedPalette() => _palette!; /// /// Gets and sets the dirty palette counter. @@ -625,7 +625,7 @@ protected bool CanProcessMnemonic() } // Move up one level - c = c.Parent; + c = c.Parent!; } // Every control in chain is visible and enabled, so allow mnemonics @@ -706,7 +706,7 @@ protected virtual void OnPaletteNeedPaint(object sender, NeedLayoutEventArgs e) /// Source of notification. /// An NeedLayoutEventArgs containing event data. /// - protected virtual void OnNeedPaint(object sender, [DisallowNull] NeedLayoutEventArgs e) + protected virtual void OnNeedPaint(object? sender, [DisallowNull] NeedLayoutEventArgs e) { Debug.Assert(e != null); @@ -1189,7 +1189,7 @@ private void SetPalette(PaletteBase palette) private void OnBaseChanged(object sender, EventArgs e) => // Change in base renderer or base palette require we fetch the latest renderer - Renderer = _palette?.GetRenderer(); + Renderer = _palette?.GetRenderer()!; private void PaintTransparentBackground(PaintEventArgs? e) { @@ -1257,10 +1257,10 @@ private void OnPerformLayout() private void OnContextMenuStripOpening(object sender, CancelEventArgs e) { // Get the actual strip instance - ContextMenuStrip cms = base.ContextMenuStrip; + ContextMenuStrip? cms = base.ContextMenuStrip; // Make sure it has the correct renderer - cms.Renderer = CreateToolStripRenderer()!; + cms!.Renderer = CreateToolStripRenderer()!; } private void OnKryptonContextMenuDisposed(object sender, EventArgs e) => diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualForm.cs index 36bc74b9e..55e1749fa 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualForm.cs @@ -43,7 +43,7 @@ public abstract class VisualForm : Form, private int _compositionHeight; private int _ignoreCount; private ViewBase? _capturedElement; - private KryptonCustomPaletteBase _localCustomPalette; + private KryptonCustomPaletteBase? _localCustomPalette; private PaletteBase _palette; private PaletteMode _paletteMode; private readonly IntPtr _screenDC; @@ -454,7 +454,7 @@ public BlurValues BlurValues [Category(@"Visuals")] [Description(@"Custom palette applied to drawing.")] [DefaultValue(null)] - public KryptonCustomPaletteBase LocalCustomPalette + public KryptonCustomPaletteBase? LocalCustomPalette { [DebuggerStepThrough] get => _localCustomPalette; @@ -465,7 +465,7 @@ public KryptonCustomPaletteBase LocalCustomPalette if (_localCustomPalette != value) { // Remember the starting palette - PaletteBase old = _localCustomPalette; + PaletteBase? old = _localCustomPalette; // Use the provided palette value SetPalette(value); @@ -1022,7 +1022,7 @@ protected virtual void OnPaletteChanged(EventArgs e) Redirector!.Target = _palette; // A new palette source means we need to layout and redraw - OnNeedPaint(LocalCustomPalette, new NeedLayoutEventArgs(true)); + OnNeedPaint(LocalCustomPalette!, new NeedLayoutEventArgs(true)); PaletteChanged?.Invoke(this, e); } @@ -1234,7 +1234,7 @@ protected override void WndProc(ref Message m) /// A Windows-based message. protected virtual void OnWM_GETMINMAXINFO(ref Message m) { - PI.MINMAXINFO mmi = (PI.MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(PI.MINMAXINFO)); + PI.MINMAXINFO mmi = (PI.MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(PI.MINMAXINFO))!; // Adjust the maximized size and position to fit the work area of the correct monitor const int MONITOR_DEFAULT_TO_NEAREST = 0x00000002; @@ -1283,7 +1283,7 @@ protected virtual bool OnWM_NCCALCSIZE(ref Message m) Padding borders = FormBorderStyle == FormBorderStyle.None ? Padding.Empty : RealWindowBorders; // Extract the Win32 NCCALCSIZE_PARAMS structure from LPARAM - PI.NCCALCSIZE_PARAMS calcsize = (PI.NCCALCSIZE_PARAMS)m.GetLParam(typeof(PI.NCCALCSIZE_PARAMS)); + PI.NCCALCSIZE_PARAMS calcsize = (PI.NCCALCSIZE_PARAMS)m.GetLParam(typeof(PI.NCCALCSIZE_PARAMS))!; // If using composition in the custom chrome if (ApplyComposition) @@ -1884,7 +1884,7 @@ private void OnGlobalPaletteChanged(object sender, EventArgs e) Redirector!.Target = _palette; // A new palette source means we need to layout and redraw - OnNeedPaint(LocalCustomPalette, new NeedLayoutEventArgs(true)); + OnNeedPaint(LocalCustomPalette!, new NeedLayoutEventArgs(true)); GlobalPaletteChanged?.Invoke(sender, e); } @@ -1908,7 +1908,7 @@ private void OnUserPreferenceChanged(object sender, UserPreferenceChangedEventAr } } - private void SetPalette(PaletteBase palette) + private void SetPalette(PaletteBase? palette) { if (palette != _palette) { @@ -1923,10 +1923,10 @@ private void SetPalette(PaletteBase palette) } // Remember the new palette - _palette = palette; + _palette = palette!; // Get the renderer associated with the palette - Renderer = _palette?.GetRenderer(); + Renderer = _palette.GetRenderer(); // Hook to new palette events if (_palette != null) @@ -1943,7 +1943,7 @@ private void SetPalette(PaletteBase palette) private void OnBaseChanged(object sender, EventArgs e) => // Change in base renderer or base palette require we fetch the latest renderer - Renderer = _palette?.GetRenderer();// PaletteImageScaler.ScalePalette(FactorDpiX, FactorDpiY, _palette); + Renderer = _palette.GetRenderer();// PaletteImageScaler.ScalePalette(FactorDpiX, FactorDpiY, _palette); #if !NET462 private void OnDpiChanged(object sender, DpiChangedEventArgs e) => UpdateDpiFactors(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualInputBoxForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualInputBoxForm.cs index 37df36da1..7a226e0fa 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualInputBoxForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualInputBoxForm.cs @@ -18,13 +18,9 @@ namespace Krypton.Toolkit public partial class VisualInputBoxForm : KryptonForm { #region Instance Fields - private bool _usePasswordOption; - private Color _cueColour; - private string _prompt; - private string _caption; - private string _defaultResponse; - private string _cueText; - private Font? _cueTypeface; + + private KryptonInputBoxData _inputBoxData; + #endregion #region Identity @@ -38,24 +34,12 @@ public VisualInputBoxForm() } /// Initializes a new instance of the class. - /// The prompt. - /// The caption. - /// The default response. - /// The cue text. - /// The cue colour. - /// The cue typeface. - /// if set to true [use password option]. - public VisualInputBoxForm(string prompt, - string caption, - string defaultResponse, - string cueText, - Color cueColour, - Font? cueTypeface, - bool usePasswordOption) + /// The input box data. + public VisualInputBoxForm(KryptonInputBoxData inputBoxData) { InitializeComponent(); - StoreValues(prompt, caption, defaultResponse, cueText, cueColour, cueTypeface, usePasswordOption); + _inputBoxData = inputBoxData; // Update contents to match requirements UpdateText(); @@ -69,39 +53,13 @@ public VisualInputBoxForm(string prompt, #region Implementation - private void StoreValues(string prompt, string caption, string defaultResponse, string cueText, Color cueColour, - Font? cueTypeface, bool usePasswordOption) - { - _prompt = prompt; - - _caption = caption; - - _defaultResponse = defaultResponse; - - _cueText = cueText; - - _cueColour = cueColour; - - _cueTypeface = cueTypeface; - - _usePasswordOption = usePasswordOption; - } - - internal static string InternalShow(IWin32Window? owner, - string prompt, - string caption, - string defaultResponse, - string cueText, - Color cueColour, - Font? cueTypeface, - bool usePasswordOption) + internal static string InternalShow(KryptonInputBoxData inputBoxData) { // If do not have an owner passed in then get the active window and use that instead - IWin32Window? showOwner = owner ?? FromHandle(PI.GetActiveWindow()); + IWin32Window? showOwner = inputBoxData.Owner ?? FromHandle(PI.GetActiveWindow()); // Show input box window as a modal dialog and then dispose of it afterwards - using var ib = new VisualInputBoxForm(prompt, caption, defaultResponse, cueText, cueColour, - cueTypeface, usePasswordOption); + using var ib = new VisualInputBoxForm(inputBoxData); ib.StartPosition = showOwner == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent; return ib.ShowDialog(showOwner) == DialogResult.OK @@ -113,24 +71,24 @@ internal static string InternalShow(IWin32Window? owner, private void UpdateText() { - Text = _caption; - _labelPrompt.Text = _prompt; - _textBoxResponse.Text = _defaultResponse; - _textBoxResponse.UseSystemPasswordChar = _usePasswordOption; + Text = _inputBoxData.Caption; + _labelPrompt.Text = _inputBoxData.Prompt; + _textBoxResponse.Text = _inputBoxData.DefaultResponse; + _textBoxResponse.UseSystemPasswordChar = _inputBoxData.UsePasswordOption ?? false; } private void UpdateCue() { - _textBoxResponse.CueHint.CueHintText = _cueText; + _textBoxResponse.CueHint.CueHintText = _inputBoxData.CueText; - if (!_cueColour.IsEmpty) + if (_inputBoxData.CueColor != null || _inputBoxData.CueColor != Color.Transparent || _inputBoxData.CueColor != Color.Empty) { - _textBoxResponse.CueHint.Color1 = _cueColour; + _textBoxResponse.CueHint.Color1 = _inputBoxData.CueColor ?? Color.Gray; } - if (_cueTypeface != null) + if (_inputBoxData.CueTypeface != null) { - _textBoxResponse.CueHint.Font = _cueTypeface; + _textBoxResponse.CueHint.Font = _inputBoxData.CueTypeface ?? KryptonManager.CurrentGlobalPalette!.BaseFont; } } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMessageBoxForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMessageBoxForm.cs index 5f43a0608..e4a4a3396 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMessageBoxForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMessageBoxForm.cs @@ -18,11 +18,6 @@ namespace Krypton.Toolkit { internal partial class VisualMessageBoxForm : KryptonForm { - #region Static Fields - private const int GAP = 10; - private static readonly int OS_MAJOR_VERSION; - #endregion - #region Instance Fields private readonly bool _showHelpButton; @@ -57,7 +52,6 @@ internal partial class VisualMessageBoxForm : KryptonForm #endregion #region Identity - static VisualMessageBoxForm() => OS_MAJOR_VERSION = Environment.OSVersion.Version.Major; public VisualMessageBoxForm() { @@ -242,7 +236,7 @@ private void UpdateIcon(KryptonMessageBoxIcon icon) { case KryptonMessageBoxIcon.None: // Windows XP and before will Beep, Vista and above do not! - if (OS_MAJOR_VERSION < 6) + if (GlobalStaticValues.OS_MAJOR_VERSION < 6) { SystemSounds.Beep.Play(); } @@ -314,7 +308,7 @@ private void UpdateIcon(KryptonMessageBoxIcon icon) { case KryptonMessageBoxIcon.None: // Windows XP and before will Beep, Vista and above do not! - if (OS_MAJOR_VERSION < 6) + if (GlobalStaticValues.OS_MAJOR_VERSION < 6) { SystemSounds.Beep.Play(); } @@ -440,7 +434,7 @@ private void UpdateIcon() { case KryptonMessageBoxIcon.None: // Windows XP and before will Beep, Vista and above do not! - if (OS_MAJOR_VERSION < 6) + if (GlobalStaticValues.OS_MAJOR_VERSION < 6) { SystemSounds.Beep.Play(); } @@ -512,7 +506,7 @@ private void UpdateIcon() { case KryptonMessageBoxIcon.None: // Windows XP and before will Beep, Vista and above do not! - if (OS_MAJOR_VERSION < 6) + if (GlobalStaticValues.OS_MAJOR_VERSION < 6) { SystemSounds.Beep.Play(); } @@ -967,9 +961,9 @@ private void LaunchHelp(IWin32Window? owner) { if (owner != null) { - Control control = FromHandle(owner.Handle); + Control? control = FromHandle(owner.Handle); - MethodInfo? mInfoMethod = control.GetType().GetMethod(nameof(OnHelpRequested), BindingFlags.Instance | BindingFlags.NonPublic, + var mInfoMethod = control!.GetType().GetMethod(nameof(OnHelpRequested), BindingFlags.Instance | BindingFlags.NonPublic, Type.DefaultBinder, new[] { typeof(HelpEventArgs) }, null)!; mInfoMethod.Invoke(control, new object[] { new HelpEventArgs(MousePosition) }); if (_helpInfo != null) @@ -1008,9 +1002,9 @@ private void LaunchHelp() { if (_showOwner != null) { - Control control = FromHandle(_showOwner.Handle); + Control? control = FromHandle(_showOwner.Handle); - MethodInfo? mInfoMethod = control.GetType().GetMethod(nameof(OnHelpRequested), BindingFlags.Instance | BindingFlags.NonPublic, + var mInfoMethod = control!.GetType().GetMethod(nameof(OnHelpRequested), BindingFlags.Instance | BindingFlags.NonPublic, Type.DefaultBinder, new[] { typeof(HelpEventArgs) }, null)!; mInfoMethod.Invoke(control, new object[] { new HelpEventArgs(MousePosition) }); if (_helpInfo != null) @@ -1056,7 +1050,7 @@ private Size UpdateMessageSizing(IWin32Window? showOwner) { // Find size of the label, with a max of 2/3 screen width Screen? screen = showOwner != null ? Screen.FromHandle(showOwner.Handle) : Screen.PrimaryScreen; - SizeF scaledMonitorSize = screen.Bounds.Size; + SizeF scaledMonitorSize = screen!.Bounds.Size; scaledMonitorSize.Width *= 2 / 3.0f; scaledMonitorSize.Height *= 0.95f; _messageText.UpdateFont(); @@ -1088,14 +1082,14 @@ private Size UpdateButtonsSizing() // Button1 is always visible Size button1Size = _button1.GetPreferredSize(Size.Empty); - var maxButtonSize = button1Size with { Width = button1Size.Width + GAP }; + var maxButtonSize = button1Size with { Width = button1Size.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING }; // If Button2 is visible if (_button2.Enabled) { numButtons++; Size button2Size = _button2.GetPreferredSize(Size.Empty); - maxButtonSize.Width = Math.Max(maxButtonSize.Width, button2Size.Width + GAP); + maxButtonSize.Width = Math.Max(maxButtonSize.Width, button2Size.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING); maxButtonSize.Height = Math.Max(maxButtonSize.Height, button2Size.Height); } @@ -1104,7 +1098,7 @@ private Size UpdateButtonsSizing() { numButtons++; Size button3Size = _button3.GetPreferredSize(Size.Empty); - maxButtonSize.Width = Math.Max(maxButtonSize.Width, button3Size.Width + GAP); + maxButtonSize.Width = Math.Max(maxButtonSize.Width, button3Size.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING); maxButtonSize.Height = Math.Max(maxButtonSize.Height, button3Size.Height); } // If Button4 is visible @@ -1112,7 +1106,7 @@ private Size UpdateButtonsSizing() { numButtons++; Size button4Size = _button4.GetPreferredSize(Size.Empty); - maxButtonSize.Width = Math.Max(maxButtonSize.Width, button4Size.Width + GAP); + maxButtonSize.Width = Math.Max(maxButtonSize.Width, button4Size.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING); maxButtonSize.Height = Math.Max(maxButtonSize.Height, button4Size.Height); } @@ -1121,56 +1115,56 @@ private Size UpdateButtonsSizing() { numButtons++; Size actionButtonSize = _button5.GetPreferredSize(Size.Empty); - maxButtonSize.Width = Math.Max(maxButtonSize.Width, actionButtonSize.Width + GAP); + maxButtonSize.Width = Math.Max(maxButtonSize.Width, actionButtonSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING); maxButtonSize.Height = Math.Max(maxButtonSize.Height, actionButtonSize.Height); } // Start positioning buttons 10 pixels from right edge - var right = _panelButtons.Right - GAP; + var right = _panelButtons.Right - GlobalStaticValues.GLOBAL_BUTTON_PADDING; - var left = _panelButtons.Left - GAP; + var left = _panelButtons.Left - GlobalStaticValues.GLOBAL_BUTTON_PADDING; // If Action button is visible if (_button5.Enabled) { - _button5.Location = new Point(left - maxButtonSize.Width, GAP); + _button5.Location = new Point(left - maxButtonSize.Width, GlobalStaticValues.GLOBAL_BUTTON_PADDING); _button5.Size = maxButtonSize; - left -= maxButtonSize.Width + GAP; + left -= maxButtonSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING; } // If Button4 is visible if (_button4.Enabled) { - _button4.Location = new Point(right - maxButtonSize.Width, GAP); + _button4.Location = new Point(right - maxButtonSize.Width, GlobalStaticValues.GLOBAL_BUTTON_PADDING); _button4.Size = maxButtonSize; - right -= maxButtonSize.Width + GAP; + right -= maxButtonSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING; } // If Button3 is visible if (_button3.Enabled) { - _button3.Location = new Point(right - maxButtonSize.Width, GAP); + _button3.Location = new Point(right - maxButtonSize.Width, GlobalStaticValues.GLOBAL_BUTTON_PADDING); _button3.Size = maxButtonSize; - right -= maxButtonSize.Width + GAP; + right -= maxButtonSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING; } // If Button2 is visible if (_button2.Enabled) { - _button2.Location = new Point(right - maxButtonSize.Width, GAP); + _button2.Location = new Point(right - maxButtonSize.Width, GlobalStaticValues.GLOBAL_BUTTON_PADDING); _button2.Size = maxButtonSize; - right -= maxButtonSize.Width + GAP; + right -= maxButtonSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING; } // Button1 is always visible - _button1.Location = new Point(right - maxButtonSize.Width, GAP); + _button1.Location = new Point(right - maxButtonSize.Width, GlobalStaticValues.GLOBAL_BUTTON_PADDING); _button1.Size = maxButtonSize; // Size the panel for the buttons - _panelButtons.Size = new Size((maxButtonSize.Width * numButtons) + (GAP * (numButtons + 1)), maxButtonSize.Height + (GAP * 2)); + _panelButtons.Size = new Size((maxButtonSize.Width * numButtons) + (GlobalStaticValues.GLOBAL_BUTTON_PADDING * (numButtons + 1)), maxButtonSize.Height + (GlobalStaticValues.GLOBAL_BUTTON_PADDING * 2)); // Button area is the number of buttons with gaps between them and 10 pixels around all edges - return new Size((maxButtonSize.Width * numButtons) + (GAP * (numButtons + 1)), maxButtonSize.Height + (GAP * 2)); + return new Size((maxButtonSize.Width * numButtons) + (GlobalStaticValues.GLOBAL_BUTTON_PADDING * (numButtons + 1)), maxButtonSize.Height + (GlobalStaticValues.GLOBAL_BUTTON_PADDING * 2)); } private void AnyKeyDown(object sender, KeyEventArgs e) @@ -1280,6 +1274,13 @@ private void UpdateContentAreaType(MessageBoxContentAreaType? contentAreaType) _messageText.Visible = false; break; + case null: + _linkLabelMessageText.Visible = false; + + _messageText.Visible = true; + break; + default: + throw new ArgumentOutOfRangeException(nameof(contentAreaType), contentAreaType, null); } } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMultilineStringEditor.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMultilineStringEditor.cs index d41f1387f..edaa77106 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMultilineStringEditor.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMultilineStringEditor.cs @@ -179,7 +179,7 @@ private void OnKeyDownTextBox(object sender, KeyEventArgs e) /// private bool OnGetMinMaxInfo(ref Message m) { - PI.MINMAXINFO minMax = (PI.MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(PI.MINMAXINFO)); + var minMax = (PI.MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(PI.MINMAXINFO))!; if (!MaximumSize.IsEmpty) { minMax.ptMaxTrackSize.X = MaximumSize.Width; diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMultilineStringEditorForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMultilineStringEditorForm.cs index 4e1d91cba..a96fb648c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMultilineStringEditorForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMultilineStringEditorForm.cs @@ -226,7 +226,7 @@ private void kbtnOk_Click(object sender, EventArgs e) { StringCollection? collection; - IWin32Window showOwner = owner ?? FromHandle(PI.GetActiveWindow()); + IWin32Window? showOwner = owner ?? FromHandle(PI.GetActiveWindow()); using var kmse = new VisualMultilineStringEditorForm(null, input, useRichTextBox, headerText, windowTitle); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPanel.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPanel.cs index 67ee98dfa..37bf70ec6 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPanel.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPanel.cs @@ -34,8 +34,8 @@ public abstract class VisualPanel : Panel, private bool _evalTransparent; private bool _globalEvents; private Size _lastLayoutSize; - private PaletteBase _localPalette; - private PaletteBase _palette; + private PaletteBase? _localPalette; + private PaletteBase? _palette; private PaletteMode _paletteMode; private readonly SimpleCall _refreshCall; private KryptonContextMenu? _kryptonContextMenu; @@ -353,7 +353,7 @@ public PaletteMode PaletteMode [Category(@"Visuals")] [Description(@"Custom palette applied to drawing.")] [DefaultValue(null)] - public PaletteBase Palette + public PaletteBase? Palette { [DebuggerStepThrough] get => _localPalette; @@ -364,7 +364,7 @@ public PaletteBase Palette if (_localPalette != value) { // Remember the starting palette - PaletteBase old = _localPalette; + PaletteBase? old = _localPalette; // Use the provided palette value SetPalette(value); @@ -410,7 +410,7 @@ public PaletteBase Palette [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public IRenderer Renderer + public IRenderer? Renderer { [DebuggerStepThrough] get; @@ -636,7 +636,7 @@ protected NeedPaintHandler NeedPaintDelegate /// Source of notification. /// An NeedLayoutEventArgs containing event data. /// - protected void OnNeedPaint(object sender, [DisallowNull] NeedLayoutEventArgs e) + protected void OnNeedPaint(object? sender, [DisallowNull] NeedLayoutEventArgs e) { Debug.Assert(e != null); @@ -704,7 +704,7 @@ protected bool NeedTransparentPaint /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public PaletteBase GetResolvedPalette() => _palette; + public PaletteBase GetResolvedPalette() => _palette!; #endregion @@ -726,7 +726,7 @@ protected virtual void OnPaletteChanged(EventArgs e) Redirector!.Target = _palette; // A new palette source means we need to layout and redraw - OnNeedPaint(Palette, new NeedLayoutEventArgs(true)); + OnNeedPaint(Palette!, new NeedLayoutEventArgs(true)); PaletteChanged?.Invoke(this, e); } @@ -1060,7 +1060,7 @@ protected override void OnLostFocus(EventArgs e) #endregion #region Implementation - private void SetPalette(PaletteBase palette) + private void SetPalette(PaletteBase? palette) { if (palette != _palette) { diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopup.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopup.cs index 7f37a4dc3..38529cb55 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopup.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopup.cs @@ -55,7 +55,7 @@ public VisualPopup(IRenderer renderer, /// Drawing renderer. /// Does the popup need a shadow effect. public VisualPopup(ViewManager viewManager, - IRenderer renderer, + IRenderer? renderer, bool shadow) { #region Default ControlStyle Values @@ -90,7 +90,7 @@ public VisualPopup(ViewManager viewManager, SetStyle(ControlStyles.Selectable, false); // Cache incoming references - Renderer = renderer; + Renderer = renderer!; ViewManager = viewManager; // Setup the need paint delegate @@ -285,14 +285,14 @@ public virtual bool AllowMouseMove(Message m, Point pt) => /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] - public ToolStripRenderer? CreateToolStripRenderer() => Renderer?.RenderToolStrip(GetResolvedPalette()); + public ToolStripRenderer? CreateToolStripRenderer() => Renderer.RenderToolStrip(GetResolvedPalette()!); /// /// Gets the resolved palette to actually use when drawing. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public virtual PaletteBase GetResolvedPalette() => null; + public virtual PaletteBase? GetResolvedPalette() => null; /// /// Gets access to the current renderer. diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualTaskDialog.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualTaskDialog.cs index 555a550ac..a588ca8cf 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualTaskDialog.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualTaskDialog.cs @@ -66,12 +66,6 @@ protected override void WndProc(ref Message m) } #endregion - #region Static Fields - - private const int BUTTON_GAP = 10; - - #endregion - #region Instance Fields private KryptonTaskDialog? _taskDialog; private readonly string _windowTitle; @@ -332,7 +326,7 @@ private void UpdateRadioButtons() maxButtonSize.Width = Math.Min(Math.Max(maxButtonSize.Width, 150), 400); // Position the radio buttons in a vertical stack and size owning panel - var offset = new Point(BUTTON_GAP - 1, 2); + var offset = new Point(GlobalStaticValues.GLOBAL_BUTTON_PADDING - 1, 2); foreach (KryptonRadioButton button in _panelMainRadio.Controls) { button.Location = offset; @@ -387,7 +381,7 @@ private void UpdateCommandButtons() maxButtonSize.Width = Math.Min(Math.Max(maxButtonSize.Width, 150), 400); // Position the buttons in a vertical stack and size owning panel - var offset = new Point(BUTTON_GAP - 1, 2); + var offset = new Point(GlobalStaticValues.GLOBAL_BUTTON_PADDING - 1, 2); foreach (KryptonButton button in _panelMainCommands.Controls) { button.Location = offset; @@ -766,7 +760,7 @@ private Size UpdateMainTextSizing() // Resize panel containing the main text Padding panelMessagePadding = _panelMainText.Padding; _panelMainText.Width = Math.Max(_messageText.Size.Width, messageContentSize.Width) + panelMessagePadding.Horizontal; - _panelMainText.Height = _messageText.Size.Height + messageContentSize.Height + panelMessagePadding.Vertical + BUTTON_GAP; + _panelMainText.Height = _messageText.Size.Height + messageContentSize.Height + panelMessagePadding.Vertical + GlobalStaticValues.GLOBAL_BUTTON_PADDING; // Position the content label below the main label _messageContent.Location = new Point(_messageText.Left + 2, _messageText.Bottom); @@ -786,7 +780,7 @@ private Size UpdateRadioSizing() return Size.Empty; } - return _panelMainRadio.Size with { Width = _panelMainRadio.Size.Width + BUTTON_GAP + 2 }; + return _panelMainRadio.Size with { Width = _panelMainRadio.Size.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING + 2 }; } private Size UpdateCommandSizing() @@ -799,7 +793,7 @@ private Size UpdateCommandSizing() return Size.Empty; } - return _panelMainCommands.Size with { Width = _panelMainCommands.Size.Width + BUTTON_GAP + 2 }; + return _panelMainCommands.Size with { Width = _panelMainCommands.Size.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING + 2 }; } private Size UpdateSpacerSizing() @@ -818,7 +812,7 @@ private Size UpdateButtonsSizing() { numButtons++; Size buttonCancelSize = _buttonClose.GetPreferredSize(Size.Empty); - maxButtonSize.Width = Math.Max(maxButtonSize.Width, buttonCancelSize.Width + BUTTON_GAP); + maxButtonSize.Width = Math.Max(maxButtonSize.Width, buttonCancelSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING); maxButtonSize.Height = Math.Max(maxButtonSize.Height, buttonCancelSize.Height); } @@ -826,7 +820,7 @@ private Size UpdateButtonsSizing() { numButtons++; Size buttonRetrySize = _buttonRetry.GetPreferredSize(Size.Empty); - maxButtonSize.Width = Math.Max(maxButtonSize.Width, buttonRetrySize.Width + BUTTON_GAP); + maxButtonSize.Width = Math.Max(maxButtonSize.Width, buttonRetrySize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING); maxButtonSize.Height = Math.Max(maxButtonSize.Height, buttonRetrySize.Height); } @@ -834,7 +828,7 @@ private Size UpdateButtonsSizing() { numButtons++; Size buttonCancelSize = _buttonCancel.GetPreferredSize(Size.Empty); - maxButtonSize.Width = Math.Max(maxButtonSize.Width, buttonCancelSize.Width + BUTTON_GAP); + maxButtonSize.Width = Math.Max(maxButtonSize.Width, buttonCancelSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING); maxButtonSize.Height = Math.Max(maxButtonSize.Height, buttonCancelSize.Height); } @@ -842,7 +836,7 @@ private Size UpdateButtonsSizing() { numButtons++; Size buttonNoSize = _buttonNo.GetPreferredSize(Size.Empty); - maxButtonSize.Width = Math.Max(maxButtonSize.Width, buttonNoSize.Width + BUTTON_GAP); + maxButtonSize.Width = Math.Max(maxButtonSize.Width, buttonNoSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING); maxButtonSize.Height = Math.Max(maxButtonSize.Height, buttonNoSize.Height); } @@ -850,7 +844,7 @@ private Size UpdateButtonsSizing() { numButtons++; Size buttonYesSize = _buttonYes.GetPreferredSize(Size.Empty); - maxButtonSize.Width = Math.Max(maxButtonSize.Width, buttonYesSize.Width + BUTTON_GAP); + maxButtonSize.Width = Math.Max(maxButtonSize.Width, buttonYesSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING); maxButtonSize.Height = Math.Max(maxButtonSize.Height, buttonYesSize.Height); } @@ -858,54 +852,54 @@ private Size UpdateButtonsSizing() { numButtons++; Size buttonOKSize = _buttonOK.GetPreferredSize(Size.Empty); - maxButtonSize.Width = Math.Max(maxButtonSize.Width, buttonOKSize.Width + BUTTON_GAP); + maxButtonSize.Width = Math.Max(maxButtonSize.Width, buttonOKSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING); maxButtonSize.Height = Math.Max(maxButtonSize.Height, buttonOKSize.Height); } // Start positioning buttons from right edge - var right = _panelButtons.Right - BUTTON_GAP; + var right = _panelButtons.Right - GlobalStaticValues.GLOBAL_BUTTON_PADDING; if ((_commonButtons & TaskDialogButtons.Close) == TaskDialogButtons.Close) { - _buttonClose.Location = new Point(right - maxButtonSize.Width, BUTTON_GAP); + _buttonClose.Location = new Point(right - maxButtonSize.Width, GlobalStaticValues.GLOBAL_BUTTON_PADDING); _buttonClose.Size = maxButtonSize; - right -= maxButtonSize.Width + BUTTON_GAP; + right -= maxButtonSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING; } if ((_commonButtons & TaskDialogButtons.Retry) == TaskDialogButtons.Retry) { - _buttonRetry.Location = new Point(right - maxButtonSize.Width, BUTTON_GAP); + _buttonRetry.Location = new Point(right - maxButtonSize.Width, GlobalStaticValues.GLOBAL_BUTTON_PADDING); _buttonRetry.Size = maxButtonSize; - right -= maxButtonSize.Width + BUTTON_GAP; + right -= maxButtonSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING; } if ((_commonButtons & TaskDialogButtons.Cancel) == TaskDialogButtons.Cancel) { - _buttonCancel.Location = new Point(right - maxButtonSize.Width, BUTTON_GAP); + _buttonCancel.Location = new Point(right - maxButtonSize.Width, GlobalStaticValues.GLOBAL_BUTTON_PADDING); _buttonCancel.Size = maxButtonSize; - right -= maxButtonSize.Width + BUTTON_GAP; + right -= maxButtonSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING; } if ((_commonButtons & TaskDialogButtons.No) == TaskDialogButtons.No) { - _buttonNo.Location = new Point(right - maxButtonSize.Width, BUTTON_GAP); + _buttonNo.Location = new Point(right - maxButtonSize.Width, GlobalStaticValues.GLOBAL_BUTTON_PADDING); _buttonNo.Size = maxButtonSize; - right -= maxButtonSize.Width + BUTTON_GAP; + right -= maxButtonSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING; } if ((_commonButtons & TaskDialogButtons.Yes) == TaskDialogButtons.Yes) { - _buttonYes.Location = new Point(right - maxButtonSize.Width, BUTTON_GAP); + _buttonYes.Location = new Point(right - maxButtonSize.Width, GlobalStaticValues.GLOBAL_BUTTON_PADDING); _buttonYes.Size = maxButtonSize; - right -= maxButtonSize.Width + BUTTON_GAP; + right -= maxButtonSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING; } if ((_commonButtons & TaskDialogButtons.OK) == TaskDialogButtons.OK) { - _buttonOK.Location = new Point(right - maxButtonSize.Width, BUTTON_GAP); + _buttonOK.Location = new Point(right - maxButtonSize.Width, GlobalStaticValues.GLOBAL_BUTTON_PADDING); _buttonOK.Size = maxButtonSize; - right -= maxButtonSize.Width + BUTTON_GAP; + right -= maxButtonSize.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING; } var checkboxSize = Size.Empty; @@ -924,22 +918,22 @@ private Size UpdateButtonsSizing() else { _panelButtons.Visible = true; - _checkBox.Location = new Point(BUTTON_GAP, BUTTON_GAP); - return new Size(checkboxSize.Width + (BUTTON_GAP * 2), checkboxSize.Height + (BUTTON_GAP * 2)); + _checkBox.Location = new Point(GlobalStaticValues.GLOBAL_BUTTON_PADDING, GlobalStaticValues.GLOBAL_BUTTON_PADDING); + return new Size(checkboxSize.Width + (GlobalStaticValues.GLOBAL_BUTTON_PADDING * 2), checkboxSize.Height + (GlobalStaticValues.GLOBAL_BUTTON_PADDING * 2)); } } else { _panelButtons.Visible = true; - var panelButtonSize = new Size((maxButtonSize.Width * numButtons) + (BUTTON_GAP * (numButtons + 1)), - maxButtonSize.Height + (BUTTON_GAP * 2)); + var panelButtonSize = new Size((maxButtonSize.Width * numButtons) + (GlobalStaticValues.GLOBAL_BUTTON_PADDING * (numButtons + 1)), + maxButtonSize.Height + (GlobalStaticValues.GLOBAL_BUTTON_PADDING * 2)); if (!checkboxSize.IsEmpty) { panelButtonSize.Width += checkboxSize.Width; - panelButtonSize.Height = Math.Max(panelButtonSize.Height, checkboxSize.Height + (BUTTON_GAP * 2)); - _checkBox.Location = new Point(BUTTON_GAP, (panelButtonSize.Height - checkboxSize.Height) / 2); + panelButtonSize.Height = Math.Max(panelButtonSize.Height, checkboxSize.Height + (GlobalStaticValues.GLOBAL_BUTTON_PADDING * 2)); + _checkBox.Location = new Point(GlobalStaticValues.GLOBAL_BUTTON_PADDING, (panelButtonSize.Height - checkboxSize.Height) / 2); } return panelButtonSize; @@ -979,14 +973,14 @@ private Size UpdateFooterSizing() if ((_footerIcon != KryptonMessageBoxIcon.None) || (_customFooterIcon != null)) { - requiredSize.Width += _iconFooter.Width + BUTTON_GAP; + requiredSize.Width += _iconFooter.Width + GlobalStaticValues.GLOBAL_BUTTON_PADDING; requiredSize.Height = Math.Max(requiredSize.Height, _iconFooter.Size.Height); } if (requiredSize.Width > 0) { - requiredSize.Width += BUTTON_GAP * 2; - requiredSize.Height += BUTTON_GAP * 2; + requiredSize.Width += GlobalStaticValues.GLOBAL_BUTTON_PADDING * 2; + requiredSize.Height += GlobalStaticValues.GLOBAL_BUTTON_PADDING * 2; } // Do we have anything to show? @@ -996,12 +990,12 @@ private Size UpdateFooterSizing() if (requiredSize.Width > 0) { _panelFooter.Size = requiredSize; - var offset = BUTTON_GAP; + var offset = GlobalStaticValues.GLOBAL_BUTTON_PADDING; if ((_footerIcon != KryptonMessageBoxIcon.None) || (_customFooterIcon != null)) { _iconFooter.Location = new Point(offset, (requiredSize.Height - _iconFooter.Height) / 2); - offset += _iconFooter.Width + (BUTTON_GAP / 2); + offset += _iconFooter.Width + (GlobalStaticValues.GLOBAL_BUTTON_PADDING / 2); } if (!string.IsNullOrEmpty(_footerText)) @@ -1038,12 +1032,12 @@ private void OnCommandClicked(object sender, EventArgs e) Close(); // Update the result code from the command button - var button = (KryptonButton)sender; - DialogResult = button.DialogResult; + var button = sender as KryptonButton; + DialogResult = button!.DialogResult; // Invoke any event handlers from the command button - var command = (KryptonTaskDialogCommand)button.Tag; - command.PerformExecute(); + var command = button.Tag as KryptonTaskDialogCommand; + command?.PerformExecute(); } private void OnTaskDialogFormClosing(object sender, FormClosingEventArgs e) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualTaskDialogForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualTaskDialogForm.cs index c05fb28e5..67ce6e434 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualTaskDialogForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualTaskDialogForm.cs @@ -945,12 +945,12 @@ private void OnCommandClicked(object sender, EventArgs e) Close(); // Update the result code from the command button - var button = (KryptonButton)sender; - DialogResult = button.DialogResult; + var button = sender as KryptonButton; + DialogResult = button!.DialogResult; // Invoke any event handlers from the command button - var command = (KryptonTaskDialogCommand)button.Tag; - command.PerformExecute(); + var command = button.Tag as KryptonTaskDialogCommand; + command?.PerformExecute(); } private void OnTaskDialogFormClosing(object sender, FormClosingEventArgs e) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualToastForm.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualToastForm.Designer.cs new file mode 100644 index 000000000..b0b9235ff --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualToastForm.Designer.cs @@ -0,0 +1,395 @@ +namespace Krypton.Toolkit +{ + partial class VisualToastForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.kryptonPanel1 = new Krypton.Toolkit.KryptonPanel(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.itbtnButton1 = new Krypton.Toolkit.InternalToastButton(); + this.itbtnButton2 = new Krypton.Toolkit.InternalToastButton(); + this.itbtnButton3 = new Krypton.Toolkit.InternalToastButton(); + this.kryptonBorderEdge1 = new Krypton.Toolkit.KryptonBorderEdge(); + this.kryptonPanel2 = new Krypton.Toolkit.KryptonPanel(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.pbxImage = new System.Windows.Forms.PictureBox(); + this.kryptonProgressBar1 = new Krypton.Toolkit.KryptonProgressBar(); + this.tlpContent = new System.Windows.Forms.TableLayoutPanel(); + this.kwlblToastTitle = new Krypton.Toolkit.KryptonWrapLabel(); + this.kpnlContentArea = new Krypton.Toolkit.KryptonPanel(); + this.ktxtNotificationContent = new Krypton.Toolkit.KryptonTextBox(); + this.krtxtNotificationContent = new Krypton.Toolkit.KryptonRichTextBox(); + this.klwlblNotificationContent = new Krypton.Toolkit.KryptonLinkWrapLabel(); + this.kwlblNotificationContent = new Krypton.Toolkit.KryptonWrapLabel(); + this.kpnlUserPromptArea = new Krypton.Toolkit.KryptonPanel(); + this.kdudUserInput = new Krypton.Toolkit.KryptonDomainUpDown(); + this.knudUserInput = new Krypton.Toolkit.KryptonNumericUpDown(); + this.ktxtUserInput = new Krypton.Toolkit.KryptonTextBox(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).BeginInit(); + this.kryptonPanel1.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel2)).BeginInit(); + this.kryptonPanel2.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pbxImage)).BeginInit(); + this.tlpContent.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kpnlContentArea)).BeginInit(); + this.kpnlContentArea.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kpnlUserPromptArea)).BeginInit(); + this.kpnlUserPromptArea.SuspendLayout(); + this.SuspendLayout(); + // + // kryptonPanel1 + // + this.kryptonPanel1.Controls.Add(this.tableLayoutPanel1); + this.kryptonPanel1.Controls.Add(this.kryptonBorderEdge1); + this.kryptonPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.kryptonPanel1.Location = new System.Drawing.Point(0, 400); + this.kryptonPanel1.Name = "kryptonPanel1"; + this.kryptonPanel1.PanelBackStyle = Krypton.Toolkit.PaletteBackStyle.PanelAlternate; + this.kryptonPanel1.Size = new System.Drawing.Size(800, 50); + this.kryptonPanel1.TabIndex = 0; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.BackColor = System.Drawing.Color.Transparent; + this.tableLayoutPanel1.ColumnCount = 3; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.Controls.Add(this.itbtnButton1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.itbtnButton2, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.itbtnButton3, 2, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 1); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 1; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(800, 49); + this.tableLayoutPanel1.TabIndex = 1; + // + // itbtnButton1 + // + this.itbtnButton1.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.itbtnButton1.IsActionButton = false; + this.itbtnButton1.IsDismissButton = false; + this.itbtnButton1.Location = new System.Drawing.Point(10, 12); + this.itbtnButton1.Margin = new System.Windows.Forms.Padding(10); + this.itbtnButton1.Name = "itbtnButton1"; + this.itbtnButton1.Owner = this; + this.itbtnButton1.Size = new System.Drawing.Size(90, 25); + this.itbtnButton1.TabIndex = 0; + this.itbtnButton1.Values.Text = "internalToastButton1"; + // + // itbtnButton2 + // + this.itbtnButton2.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.itbtnButton2.IsActionButton = false; + this.itbtnButton2.IsDismissButton = false; + this.itbtnButton2.Location = new System.Drawing.Point(590, 12); + this.itbtnButton2.Margin = new System.Windows.Forms.Padding(10); + this.itbtnButton2.Name = "itbtnButton2"; + this.itbtnButton2.Owner = null; + this.itbtnButton2.Size = new System.Drawing.Size(90, 25); + this.itbtnButton2.TabIndex = 1; + this.itbtnButton2.Values.Text = "internalToastButton2"; + // + // itbtnButton3 + // + this.itbtnButton3.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.itbtnButton3.IsActionButton = false; + this.itbtnButton3.IsDismissButton = false; + this.itbtnButton3.Location = new System.Drawing.Point(700, 12); + this.itbtnButton3.Margin = new System.Windows.Forms.Padding(10); + this.itbtnButton3.Name = "itbtnButton3"; + this.itbtnButton3.Owner = null; + this.itbtnButton3.Size = new System.Drawing.Size(90, 25); + this.itbtnButton3.TabIndex = 2; + this.itbtnButton3.Values.Text = "internalToastButton3"; + // + // kryptonBorderEdge1 + // + this.kryptonBorderEdge1.BorderStyle = Krypton.Toolkit.PaletteBorderStyle.HeaderSecondary; + this.kryptonBorderEdge1.Dock = System.Windows.Forms.DockStyle.Top; + this.kryptonBorderEdge1.Location = new System.Drawing.Point(0, 0); + this.kryptonBorderEdge1.Name = "kryptonBorderEdge1"; + this.kryptonBorderEdge1.Size = new System.Drawing.Size(800, 1); + this.kryptonBorderEdge1.Text = "kryptonBorderEdge1"; + // + // kryptonPanel2 + // + this.kryptonPanel2.Controls.Add(this.tableLayoutPanel2); + this.kryptonPanel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.kryptonPanel2.Location = new System.Drawing.Point(0, 0); + this.kryptonPanel2.Name = "kryptonPanel2"; + this.kryptonPanel2.Size = new System.Drawing.Size(800, 400); + this.kryptonPanel2.TabIndex = 1; + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.BackColor = System.Drawing.Color.Transparent; + this.tableLayoutPanel2.ColumnCount = 2; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel2.Controls.Add(this.pbxImage, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.kryptonProgressBar1, 0, 1); + this.tableLayoutPanel2.Controls.Add(this.tlpContent, 1, 0); + this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 2; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel2.Size = new System.Drawing.Size(800, 400); + this.tableLayoutPanel2.TabIndex = 0; + // + // pbxImage + // + this.pbxImage.Dock = System.Windows.Forms.DockStyle.Fill; + this.pbxImage.Location = new System.Drawing.Point(5, 5); + this.pbxImage.Margin = new System.Windows.Forms.Padding(5); + this.pbxImage.Name = "pbxImage"; + this.pbxImage.Size = new System.Drawing.Size(64, 358); + this.pbxImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.pbxImage.TabIndex = 0; + this.pbxImage.TabStop = false; + // + // kryptonProgressBar1 + // + this.tableLayoutPanel2.SetColumnSpan(this.kryptonProgressBar1, 2); + this.kryptonProgressBar1.Dock = System.Windows.Forms.DockStyle.Fill; + this.kryptonProgressBar1.Location = new System.Drawing.Point(3, 371); + this.kryptonProgressBar1.Name = "kryptonProgressBar1"; + this.kryptonProgressBar1.Size = new System.Drawing.Size(794, 26); + this.kryptonProgressBar1.StateCommon.Back.Color1 = System.Drawing.Color.Green; + this.kryptonProgressBar1.StateDisabled.Back.ColorStyle = Krypton.Toolkit.PaletteColorStyle.OneNote; + this.kryptonProgressBar1.StateNormal.Back.ColorStyle = Krypton.Toolkit.PaletteColorStyle.OneNote; + this.kryptonProgressBar1.TabIndex = 1; + this.kryptonProgressBar1.Text = "kryptonProgressBar1"; + this.kryptonProgressBar1.Values.Text = "kryptonProgressBar1"; + // + // tlpContent + // + this.tlpContent.ColumnCount = 1; + this.tlpContent.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tlpContent.Controls.Add(this.kwlblToastTitle, 0, 0); + this.tlpContent.Controls.Add(this.kpnlContentArea, 0, 1); + this.tlpContent.Controls.Add(this.kpnlUserPromptArea, 0, 2); + this.tlpContent.Dock = System.Windows.Forms.DockStyle.Fill; + this.tlpContent.Location = new System.Drawing.Point(77, 3); + this.tlpContent.Name = "tlpContent"; + this.tlpContent.RowCount = 3; + this.tlpContent.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tlpContent.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tlpContent.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F)); + this.tlpContent.Size = new System.Drawing.Size(720, 362); + this.tlpContent.TabIndex = 2; + // + // kwlblToastTitle + // + this.kwlblToastTitle.Dock = System.Windows.Forms.DockStyle.Fill; + this.kwlblToastTitle.Font = new System.Drawing.Font("Segoe UI", 13.5F, System.Drawing.FontStyle.Bold); + this.kwlblToastTitle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(57)))), ((int)(((byte)(91))))); + this.kwlblToastTitle.LabelStyle = Krypton.Toolkit.LabelStyle.TitleControl; + this.kwlblToastTitle.Location = new System.Drawing.Point(3, 0); + this.kwlblToastTitle.Name = "kwlblToastTitle"; + this.kwlblToastTitle.Size = new System.Drawing.Size(714, 25); + this.kwlblToastTitle.Text = "kwlblToastTitle"; + // + // kpnlContentArea + // + this.kpnlContentArea.Controls.Add(this.ktxtNotificationContent); + this.kpnlContentArea.Controls.Add(this.krtxtNotificationContent); + this.kpnlContentArea.Controls.Add(this.klwlblNotificationContent); + this.kpnlContentArea.Controls.Add(this.kwlblNotificationContent); + this.kpnlContentArea.Dock = System.Windows.Forms.DockStyle.Fill; + this.kpnlContentArea.Location = new System.Drawing.Point(3, 28); + this.kpnlContentArea.Name = "kpnlContentArea"; + this.kpnlContentArea.Size = new System.Drawing.Size(714, 304); + this.kpnlContentArea.TabIndex = 1; + // + // ktxtNotificationContent + // + this.ktxtNotificationContent.Dock = System.Windows.Forms.DockStyle.Fill; + this.ktxtNotificationContent.Location = new System.Drawing.Point(0, 0); + this.ktxtNotificationContent.Multiline = true; + this.ktxtNotificationContent.Name = "ktxtNotificationContent"; + this.ktxtNotificationContent.ReadOnly = true; + this.ktxtNotificationContent.Size = new System.Drawing.Size(714, 304); + this.ktxtNotificationContent.TabIndex = 5; + // + // krtxtNotificationContent + // + this.krtxtNotificationContent.Dock = System.Windows.Forms.DockStyle.Fill; + this.krtxtNotificationContent.Location = new System.Drawing.Point(0, 0); + this.krtxtNotificationContent.Name = "krtxtNotificationContent"; + this.krtxtNotificationContent.ReadOnly = true; + this.krtxtNotificationContent.Size = new System.Drawing.Size(714, 304); + this.krtxtNotificationContent.TabIndex = 2; + this.krtxtNotificationContent.Text = "krtxtNotificationContent"; + // + // klwlblNotificationContent + // + this.klwlblNotificationContent.AutoSize = false; + this.klwlblNotificationContent.Dock = System.Windows.Forms.DockStyle.Fill; + this.klwlblNotificationContent.Font = new System.Drawing.Font("Segoe UI", 9F); + this.klwlblNotificationContent.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(57)))), ((int)(((byte)(91))))); + this.klwlblNotificationContent.LabelStyle = Krypton.Toolkit.LabelStyle.AlternateControl; + this.klwlblNotificationContent.Location = new System.Drawing.Point(0, 0); + this.klwlblNotificationContent.Name = "klwlblNotificationContent"; + this.klwlblNotificationContent.Size = new System.Drawing.Size(714, 304); + this.klwlblNotificationContent.Text = "klwlblNotificationContent"; + this.klwlblNotificationContent.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // kwlblNotificationContent + // + this.kwlblNotificationContent.AutoSize = false; + this.kwlblNotificationContent.Dock = System.Windows.Forms.DockStyle.Fill; + this.kwlblNotificationContent.Font = new System.Drawing.Font("Segoe UI", 9F); + this.kwlblNotificationContent.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(57)))), ((int)(((byte)(91))))); + this.kwlblNotificationContent.LabelStyle = Krypton.Toolkit.LabelStyle.AlternateControl; + this.kwlblNotificationContent.Location = new System.Drawing.Point(0, 0); + this.kwlblNotificationContent.Name = "kwlblNotificationContent"; + this.kwlblNotificationContent.Size = new System.Drawing.Size(714, 304); + this.kwlblNotificationContent.Text = "kwlblNotificationContent"; + this.kwlblNotificationContent.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // kpnlUserPromptArea + // + this.kpnlUserPromptArea.Controls.Add(this.kdudUserInput); + this.kpnlUserPromptArea.Controls.Add(this.knudUserInput); + this.kpnlUserPromptArea.Controls.Add(this.ktxtUserInput); + this.kpnlUserPromptArea.Dock = System.Windows.Forms.DockStyle.Fill; + this.kpnlUserPromptArea.Location = new System.Drawing.Point(3, 338); + this.kpnlUserPromptArea.Name = "kpnlUserPromptArea"; + this.kpnlUserPromptArea.Size = new System.Drawing.Size(714, 21); + this.kpnlUserPromptArea.TabIndex = 2; + // + // kdudUserInput + // + this.kdudUserInput.Dock = System.Windows.Forms.DockStyle.Fill; + this.kdudUserInput.Location = new System.Drawing.Point(0, 0); + this.kdudUserInput.Name = "kdudUserInput"; + this.kdudUserInput.Size = new System.Drawing.Size(714, 21); + this.kdudUserInput.TabIndex = 2; + this.kdudUserInput.Text = null; + // + // knudUserInput + // + this.knudUserInput.Dock = System.Windows.Forms.DockStyle.Fill; + this.knudUserInput.Increment = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.knudUserInput.Location = new System.Drawing.Point(0, 0); + this.knudUserInput.Maximum = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.knudUserInput.Minimum = new decimal(new int[] { + 0, + 0, + 0, + 0}); + this.knudUserInput.Name = "knudUserInput"; + this.knudUserInput.Size = new System.Drawing.Size(714, 21); + this.knudUserInput.TabIndex = 1; + this.knudUserInput.Value = new decimal(new int[] { + 0, + 0, + 0, + 0}); + // + // ktxtUserInput + // + this.ktxtUserInput.Dock = System.Windows.Forms.DockStyle.Fill; + this.ktxtUserInput.Location = new System.Drawing.Point(0, 0); + this.ktxtUserInput.Name = "ktxtUserInput"; + this.ktxtUserInput.Size = new System.Drawing.Size(714, 23); + this.ktxtUserInput.TabIndex = 0; + this.ktxtUserInput.Text = null; + // + // VisualToastForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.kryptonPanel2); + this.Controls.Add(this.kryptonPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "VisualToastForm"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).EndInit(); + this.kryptonPanel1.ResumeLayout(false); + this.kryptonPanel1.PerformLayout(); + this.tableLayoutPanel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel2)).EndInit(); + this.kryptonPanel2.ResumeLayout(false); + this.tableLayoutPanel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pbxImage)).EndInit(); + this.tlpContent.ResumeLayout(false); + this.tlpContent.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kpnlContentArea)).EndInit(); + this.kpnlContentArea.ResumeLayout(false); + this.kpnlContentArea.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kpnlUserPromptArea)).EndInit(); + this.kpnlUserPromptArea.ResumeLayout(false); + this.kpnlUserPromptArea.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private KryptonPanel kryptonPanel1; + private KryptonPanel kryptonPanel2; + private KryptonBorderEdge kryptonBorderEdge1; + private TableLayoutPanel tableLayoutPanel1; + private TableLayoutPanel tableLayoutPanel2; + private InternalToastButton itbtnButton1; + private InternalToastButton itbtnButton2; + private InternalToastButton itbtnButton3; + private PictureBox pbxImage; + private KryptonProgressBar kryptonProgressBar1; + private TableLayoutPanel tlpContent; + private KryptonWrapLabel kwlblToastTitle; + private KryptonPanel kpnlContentArea; + private KryptonWrapLabel kwlblNotificationContent; + private KryptonPanel kpnlUserPromptArea; + private KryptonTextBox ktxtUserInput; + private KryptonNumericUpDown knudUserInput; + private KryptonDomainUpDown kdudUserInput; + private KryptonLinkWrapLabel klwlblNotificationContent; + private KryptonRichTextBox krtxtNotificationContent; + private KryptonTextBox ktxtNotificationContent; + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualToastForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualToastForm.cs new file mode 100644 index 000000000..1d07abde6 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualToastForm.cs @@ -0,0 +1,458 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2023 - 2023. All rights reserved. + * + */ +#endregion + +using ContentAlignment = System.Drawing.ContentAlignment; +using Timer = System.Windows.Forms.Timer; + +namespace Krypton.Toolkit +{ + internal partial class VisualToastForm : KryptonForm + { + #region Instance Fields + + private readonly bool _showCloseButton; + + private readonly bool _showCountDownProgressBar; + + private readonly bool _showCountDownProgressBarText; + + private readonly bool _showActionButton; + + private readonly bool _showUserResponse; + + private readonly Color? _userResponsePromptColor; + + private readonly ContentAlignment? _labelContentTextAlignment; + + private readonly ContentAlignment? _labelTitleTextAlignment; + + private readonly Font? _userResponsePromptFont; + + private readonly InputControlStyle? _userInputControlStyle; + + private readonly PaletteRelativeAlign? _userResponsePromptAlignHorizontal; + + private readonly PaletteRelativeAlign? _userResponsePromptAlignVertical; + + private readonly PaletteRelativeAlign? _userResponseTextAlignmentHorizontal; + + private readonly PaletteRelativeAlign? _notificationContentRichTextBoxAlignment; + + private readonly HorizontalAlignment? _notificationContentTextBoxAlignment; + + private readonly KryptonToastNotificationActionButton? _actionButton; + + private readonly KryptonToastNotificationActionType? _actionType; + + private readonly KryptonToastNotificationContentAreaType? _toastNotificationContentAreaType; + + private readonly KryptonToastNotificationIcon? _toastNotificationIcon; + + private readonly KryptonToastNotificationInputAreaType? _toastNotificationInputAreaType; + + private readonly int? _countDownSeconds; + + private readonly int? _countDownTimerInterval; + + private int? _time; + + private readonly int? _progressBarMaximum; + + private readonly int? _numericUpDownMaximum; + + private readonly object? _contentLinkDestination; + + private Timer _timer; + + private readonly Image? _customImage; + + private SoundPlayer? _soundPlayer; + + private readonly Stream? _soundStream; + + private readonly RightToLeft? _rightToLeft; + + private readonly string _notificationTitle; + + private readonly string _notificationContentText; + + private readonly string? _soundPath; + + private readonly string _userResponsePromptText; + + private readonly LinkArea? _notificationContentLinkArea; + + private readonly KryptonCommand? _actionButtonCommand; + + #endregion + + #region Internals + + internal KryptonToastNotificationActionType? ActionType => + _actionType ?? KryptonToastNotificationActionType.Default; + + internal object? ContentLinkDestination => _contentLinkDestination ?? string.Empty; + + internal KryptonCommand? ActionButtonCommand => _actionButtonCommand ?? null; + + #endregion + + #region Identity + + /// Initializes a new instance of the class. + /// The show close button. + /// The show count down progress bar. + /// The show count down progress bar text. + /// The show action button. + /// The show user response. + /// Color of the user response prompt. + /// The label content text alignment. + /// The label title text alignment. + /// The user response prompt font. + /// The user input control style. + /// The user response prompt align horizontal. + /// The user response prompt align vertical. + /// The user response text alignment horizontal. + /// The notification content rich text box alignment. + /// The notification content text box alignment. + /// The action button. + /// Type of the action. + /// Type of the content area. + /// The toast notification icon. + /// Type of the input area. + /// The count down seconds. + /// The count down timer interval. + /// The numeric up down maximum. + /// The progress bar maximum. + /// The custom image. + /// The sound stream. + /// The right to left. + /// The notification title. + /// The notification content text. + /// The sound path. + /// The user response prompt text. + /// The notification content link area. + /// The content link destination. + /// The action button command. + public VisualToastForm(bool? showCloseButton, bool? showCountDownProgressBar, bool? showCountDownProgressBarText, + bool? showActionButton, bool? showUserResponse, Color? userResponsePromptColor, + ContentAlignment? labelContentTextAlignment, ContentAlignment? labelTitleTextAlignment, + Font? userResponsePromptFont, InputControlStyle? userInputControlStyle, + PaletteRelativeAlign? userResponsePromptAlignHorizontal, + PaletteRelativeAlign? userResponsePromptAlignVertical, + PaletteRelativeAlign? userResponseTextAlignmentHorizontal, + PaletteRelativeAlign? notificationContentRichTextBoxAlignment, + HorizontalAlignment? notificationContentTextBoxAlignment, + KryptonToastNotificationActionButton? actionButton, + KryptonToastNotificationActionType? actionType, KryptonToastNotificationContentAreaType? contentAreaType, + KryptonToastNotificationIcon? toastNotificationIcon, KryptonToastNotificationInputAreaType? inputAreaType, + int? countDownSeconds, int? countDownTimerInterval, int? numericUpDownMaximum, int? progressBarMaximum, + Image? customImage, Stream? soundStream, RightToLeft? rightToLeft, string? notificationTitle, + string notificationContentText, string? soundPath, string? userResponsePromptText, LinkArea? notificationContentLinkArea, + object? contentLinkDestination, KryptonCommand? actionButtonCommand) + { + // Assign values + _showCloseButton = showCloseButton ?? false; + _showCountDownProgressBar = showCountDownProgressBar ?? false; + _showCountDownProgressBarText = showCountDownProgressBarText ?? false; + _showActionButton = showActionButton ?? false; + _showUserResponse = showUserResponse ?? false; + _userResponsePromptColor = userResponsePromptColor ?? Color.Gray; + _labelContentTextAlignment = labelContentTextAlignment ?? ContentAlignment.MiddleCenter; + _labelTitleTextAlignment = labelTitleTextAlignment ?? ContentAlignment.MiddleCenter; + _userResponsePromptFont = userResponsePromptFont ?? KryptonManager.CurrentGlobalPalette?.BaseFont; + _userInputControlStyle = userInputControlStyle ?? InputControlStyle.Standalone; + _userResponsePromptAlignHorizontal = userResponsePromptAlignHorizontal ?? PaletteRelativeAlign.Inherit; + _userResponsePromptAlignVertical = userResponsePromptAlignVertical ?? PaletteRelativeAlign.Inherit; + _userResponseTextAlignmentHorizontal = userResponseTextAlignmentHorizontal ?? PaletteRelativeAlign.Inherit; + _notificationContentRichTextBoxAlignment = notificationContentRichTextBoxAlignment ?? PaletteRelativeAlign.Near; + _notificationContentTextBoxAlignment = notificationContentTextBoxAlignment ?? HorizontalAlignment.Left; + _actionButton = actionButton ?? KryptonToastNotificationActionButton.Button1; + _actionType = actionType ?? KryptonToastNotificationActionType.Default; + _toastNotificationContentAreaType = contentAreaType ?? KryptonToastNotificationContentAreaType.WrapLabel; + _toastNotificationIcon = toastNotificationIcon ?? KryptonToastNotificationIcon.None; + _toastNotificationInputAreaType = inputAreaType ?? KryptonToastNotificationInputAreaType.None; + _countDownSeconds = countDownSeconds ?? 60; + _countDownTimerInterval = countDownTimerInterval ?? 1000; + _numericUpDownMaximum = numericUpDownMaximum ?? 100; + _progressBarMaximum = progressBarMaximum ?? 100; + _customImage = customImage ?? null; + _soundStream = soundStream ?? Stream.Null; + _rightToLeft = rightToLeft ?? RightToLeft.Inherit; + _notificationTitle = notificationTitle ?? string.Empty; + _notificationContentText = notificationContentText; + _soundPath = soundPath ?? string.Empty; + _userResponsePromptText = userResponsePromptText ?? string.Empty; + _notificationContentLinkArea = notificationContentLinkArea ?? new LinkArea(0, klwlblNotificationContent.Text.Length); + _contentLinkDestination = contentLinkDestination ?? string.Empty; + _actionButtonCommand = actionButtonCommand ?? null; + + InitializeComponent(); + } + + #endregion + + #region Implementation + + private void SetupBaseElements() + { + switch (_toastNotificationContentAreaType) + { + case KryptonToastNotificationContentAreaType.RichTextBox: + klwlblNotificationContent.Visible = false; + kwlblNotificationContent.Visible = false; + krtxtNotificationContent.Visible = true; + ktxtNotificationContent.Visible = false; + krtxtNotificationContent.Text = _notificationContentText; + ktxtNotificationContent.StateCommon.Content.TextH = _notificationContentRichTextBoxAlignment ?? PaletteRelativeAlign.Near; + break; + case KryptonToastNotificationContentAreaType.MultiLineTextBox: + klwlblNotificationContent.Visible = false; + kwlblNotificationContent.Visible = false; + krtxtNotificationContent.Visible = false; + ktxtNotificationContent.Visible = true; + ktxtNotificationContent.Text = _notificationContentText; + ktxtNotificationContent.TextAlign = _notificationContentTextBoxAlignment ?? HorizontalAlignment.Left; + break; + case KryptonToastNotificationContentAreaType.WrapLinkLabel: + klwlblNotificationContent.Visible = true; + kwlblNotificationContent.Visible = false; + krtxtNotificationContent.Visible = true; + ktxtNotificationContent.Visible = false; + klwlblNotificationContent.Text = _notificationContentText; + klwlblNotificationContent.TextAlign = _labelContentTextAlignment ?? ContentAlignment.MiddleCenter; + SetupLinkArea(_notificationContentLinkArea); + break; + case KryptonToastNotificationContentAreaType.WrapLabel: + klwlblNotificationContent.Visible = false; + kwlblNotificationContent.Visible = false; + krtxtNotificationContent.Visible = true; + ktxtNotificationContent.Visible = false; + klwlblNotificationContent.Text = _notificationContentText; + klwlblNotificationContent.TextAlign = _labelContentTextAlignment ?? ContentAlignment.MiddleCenter; + break; + case null: + klwlblNotificationContent.Visible = false; + kwlblNotificationContent.Visible = false; + krtxtNotificationContent.Visible = true; + ktxtNotificationContent.Visible = false; + klwlblNotificationContent.Text = _notificationContentText; + klwlblNotificationContent.TextAlign = _labelContentTextAlignment ?? ContentAlignment.MiddleCenter; + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + + private void SetupLinkArea(LinkArea? linkArea) => klwlblNotificationContent.LinkArea = linkArea ?? new LinkArea(0, klwlblNotificationContent.Text.Length); + + private void SetStartupLocation() => + //Once loaded, position the form to the bottom left of the screen with added padding + Location = new Point(Screen.PrimaryScreen!.WorkingArea.Width - Width - 5, + Screen.PrimaryScreen.WorkingArea.Height - Height - 5); + + private void SetupUserResponseArea() + { + if (!_showUserResponse) + { + TableLayoutRowStyleCollection rowStyleCollection = tlpContent.RowStyles; + + } + else + { + switch (_toastNotificationInputAreaType) + { + case KryptonToastNotificationInputAreaType.None: + kpnlUserPromptArea.Visible = false; + break; + case KryptonToastNotificationInputAreaType.DomainDropDown: + break; + case KryptonToastNotificationInputAreaType.NumericDropDown: + break; + case KryptonToastNotificationInputAreaType.MaskedTextBox: + break; + case KryptonToastNotificationInputAreaType.TextBox: + break; + case null: + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + } + + private void SetIcon() + { + if (OSUtilities.IsWindowsEleven) + { + + } + else if (OSUtilities.IsWindowsTen) + { + + } + else + { + + } + } + + public new void Show() + { + Opacity = 0; + + DoubleBuffered = true; + + SetupBaseElements(); + + SetupUserResponseArea(); + + if (_countDownSeconds != null || _countDownSeconds != 0) + { + switch (_rightToLeft) + { + case RightToLeft.No: + itbtnButton1.Text = + $@"{KryptonManager.Strings.CustomStrings.Dismiss} ({_countDownSeconds - _time})"; + + itbtnButton1.IsDismissButton = true; + + itbtnButton2.IsDismissButton = false; + + itbtnButton3.IsDismissButton = false; + break; + case RightToLeft.Yes: + itbtnButton3.Text = + $@"{KryptonManager.Strings.CustomStrings.Dismiss} ({_countDownSeconds - _time})"; + + itbtnButton1.IsDismissButton = false; + + itbtnButton2.IsDismissButton = false; + + itbtnButton3.IsDismissButton = true; + break; + case RightToLeft.Inherit: + itbtnButton2.Text = + $@"{KryptonManager.Strings.CustomStrings.Dismiss} ({_countDownSeconds - _time})"; + + itbtnButton1.IsDismissButton = false; + + itbtnButton2.IsDismissButton = true; + + itbtnButton3.IsDismissButton = false; + break; + case null: + itbtnButton2.Text = + $@"{KryptonManager.Strings.CustomStrings.Dismiss} ({_countDownSeconds - _time})"; + + itbtnButton1.IsDismissButton = false; + + itbtnButton2.IsDismissButton = true; + + itbtnButton3.IsDismissButton = false; + break; + default: + throw new ArgumentOutOfRangeException(); + } + + _timer = new Timer(); + + _timer.Interval = _countDownTimerInterval ?? 1000; + + _timer.Tick += (sender, e) => + { + _time++; + + switch (_rightToLeft) + { + case RightToLeft.No: + itbtnButton1.Text = + $@"{KryptonManager.Strings.CustomStrings.Dismiss} ({_countDownSeconds - _time})"; + + itbtnButton1.IsDismissButton = true; + + itbtnButton2.IsDismissButton = false; + + itbtnButton3.IsDismissButton = false; + break; + case RightToLeft.Yes: + itbtnButton3.Text = + $@"{KryptonManager.Strings.CustomStrings.Dismiss} ({_countDownSeconds - _time})"; + + itbtnButton1.IsDismissButton = false; + + itbtnButton2.IsDismissButton = false; + + itbtnButton3.IsDismissButton = true; + break; + case RightToLeft.Inherit: + itbtnButton2.Text = + $@"{KryptonManager.Strings.CustomStrings.Dismiss} ({_countDownSeconds - _time})"; + + itbtnButton1.IsDismissButton = false; + + itbtnButton2.IsDismissButton = true; + + itbtnButton3.IsDismissButton = false; + break; + case null: + itbtnButton2.Text = + $@"{KryptonManager.Strings.CustomStrings.Dismiss} ({_countDownSeconds - _time})"; + + itbtnButton1.IsDismissButton = false; + + itbtnButton2.IsDismissButton = true; + + itbtnButton3.IsDismissButton = false; + break; + default: + throw new ArgumentOutOfRangeException(); + } + + if (_time == _countDownSeconds) + { + _timer.Stop(); + + Hide(); + } + }; + } + + if (_actionButtonCommand != null) + { + _actionButtonCommand.Execute += (sender, e) => + { + switch (_actionType) + { + case KryptonToastNotificationActionType.Default: + break; + case KryptonToastNotificationActionType.Dismiss: + break; + case KryptonToastNotificationActionType.LaunchProcess: + break; + case KryptonToastNotificationActionType.Open: + break; + case null: + break; + default: + throw new ArgumentOutOfRangeException(); + } + }; + } + + _soundPlayer = _soundPath != null ? new SoundPlayer(_soundPath) : null; + + _soundPlayer = _soundStream != null ? new SoundPlayer(_soundStream) : null; + + base.Show(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualToastForm.resx b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualToastForm.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualToastForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Converters/DateTimeNullableConverter.cs b/Source/Krypton Components/Krypton.Toolkit/Converters/DateTimeNullableConverter.cs index 42d961b0e..b8d0e5f7d 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Converters/DateTimeNullableConverter.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Converters/DateTimeNullableConverter.cs @@ -41,7 +41,7 @@ public DateTimeNullableConverter() // We allow an empty string or a string with DBNull/null/Nothing to be converted to a DBNull value. if (value is string) { - var stringValue = value.ToString().ToLower(); + var stringValue = value.ToString()!.ToLower(); if (stringValue is "dbnull" or "null" or "nothing") { return DBNull.Value; diff --git a/Source/Krypton Components/Krypton.Toolkit/Converters/KryptonMessageBoxIconConverter.cs b/Source/Krypton Components/Krypton.Toolkit/Converters/KryptonMessageBoxIconConverter.cs new file mode 100644 index 000000000..2c9383e0f --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Converters/KryptonMessageBoxIconConverter.cs @@ -0,0 +1,57 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2023 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + /// Custom type converter so that values appear as neat text at design time. + internal class KryptonMessageBoxIconConverter : StringLookupConverter + { + #region Static Fields + + [Localizable(true)] + private static readonly BiDictionary _iconPairs = + new BiDictionary(new Dictionary + { + { KryptonMessageBoxIcon.None, DesignTimeUtilities.DEFAULT_ICON_NONE }, + { KryptonMessageBoxIcon.Hand, DesignTimeUtilities.DEFAULT_ICON_HAND }, + { KryptonMessageBoxIcon.SystemHand, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_HAND }, + { KryptonMessageBoxIcon.Question, DesignTimeUtilities.DEFAULT_ICON_QUESTION }, + { KryptonMessageBoxIcon.SystemQuestion, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_QUESTION }, + { KryptonMessageBoxIcon.Exclamation, DesignTimeUtilities.DEFAULT_ICON_EXCLAMATION }, + { KryptonMessageBoxIcon.SystemExclamation, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_EXCLAMATION }, + { KryptonMessageBoxIcon.Asterisk, DesignTimeUtilities.DEFAULT_ICON_ASTERISK }, + { KryptonMessageBoxIcon.SystemAsterisk, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_ASTERISK }, + { KryptonMessageBoxIcon.Stop, DesignTimeUtilities.DEFAULT_ICON_STOP }, + { KryptonMessageBoxIcon.SystemStop, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_STOP }, + { KryptonMessageBoxIcon.Error, DesignTimeUtilities.DEFAULT_ICON_ERROR }, + { KryptonMessageBoxIcon.SystemError, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_ERROR }, + { KryptonMessageBoxIcon.Warning, DesignTimeUtilities.DEFAULT_ICON_WARNING }, + { KryptonMessageBoxIcon.SystemWarning, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_WARNING }, + { KryptonMessageBoxIcon.Information, DesignTimeUtilities.DEFAULT_ICON_INFORMATION }, + { KryptonMessageBoxIcon.SystemInformation, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_INFORMATION }, + { KryptonMessageBoxIcon.Shield, DesignTimeUtilities.DEFAULT_ICON_SHIELD }, + { KryptonMessageBoxIcon.WindowsLogo, DesignTimeUtilities.DEFAULT_ICON_WINDOWS_LOGO }, + { KryptonMessageBoxIcon.Application, DesignTimeUtilities.DEFAULT_ICON_APPLICATION }, + { KryptonMessageBoxIcon.SystemApplication, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_APPLICATION } + }); + + #endregion + + #region Protected + + /// Gets an array of lookup pairs. + protected override IReadOnlyDictionary PairsStringToEnum => _iconPairs.SecondToFirst; + + /// Gets the pairs enum to string. + /// The pairs enum to string. + protected override IReadOnlyDictionary PairsEnumToString => _iconPairs.FirstToSecond; + + #endregion + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Converters/KryptonToastNotificationIconConverter.cs b/Source/Krypton Components/Krypton.Toolkit/Converters/KryptonToastNotificationIconConverter.cs new file mode 100644 index 000000000..8f3add13c --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Converters/KryptonToastNotificationIconConverter.cs @@ -0,0 +1,59 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2023 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + /// Custom type converter so that values appear as neat text at design time. + internal class KryptonToastNotificationIconConverter : StringLookupConverter + { + #region Static Fields + + [Localizable(true)] + private static readonly BiDictionary _iconPairs = + new BiDictionary(new Dictionary + { + { KryptonToastNotificationIcon.None, DesignTimeUtilities.DEFAULT_ICON_NONE }, + { KryptonToastNotificationIcon.Hand, DesignTimeUtilities.DEFAULT_ICON_HAND }, + { KryptonToastNotificationIcon.SystemHand, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_HAND }, + { KryptonToastNotificationIcon.Question, DesignTimeUtilities.DEFAULT_ICON_QUESTION }, + { KryptonToastNotificationIcon.SystemQuestion, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_QUESTION }, + { KryptonToastNotificationIcon.Exclamation, DesignTimeUtilities.DEFAULT_ICON_EXCLAMATION }, + { KryptonToastNotificationIcon.SystemExclamation, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_EXCLAMATION }, + { KryptonToastNotificationIcon.Asterisk, DesignTimeUtilities.DEFAULT_ICON_ASTERISK }, + { KryptonToastNotificationIcon.SystemAsterisk, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_ASTERISK }, + { KryptonToastNotificationIcon.Stop, DesignTimeUtilities.DEFAULT_ICON_STOP }, + { KryptonToastNotificationIcon.SystemStop, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_STOP }, + { KryptonToastNotificationIcon.Error, DesignTimeUtilities.DEFAULT_ICON_ERROR }, + { KryptonToastNotificationIcon.SystemError, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_ERROR }, + { KryptonToastNotificationIcon.Warning, DesignTimeUtilities.DEFAULT_ICON_WARNING }, + { KryptonToastNotificationIcon.SystemWarning, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_WARNING }, + { KryptonToastNotificationIcon.Information, DesignTimeUtilities.DEFAULT_ICON_INFORMATION }, + { KryptonToastNotificationIcon.SystemInformation, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_INFORMATION }, + { KryptonToastNotificationIcon.Shield, DesignTimeUtilities.DEFAULT_ICON_SHIELD }, + { KryptonToastNotificationIcon.WindowsLogo, DesignTimeUtilities.DEFAULT_ICON_WINDOWS_LOGO }, + { KryptonToastNotificationIcon.Application, DesignTimeUtilities.DEFAULT_ICON_APPLICATION }, + { KryptonToastNotificationIcon.SystemApplication, DesignTimeUtilities.DEFAULT_ICON_SYSTEM_APPLICATION }, + { KryptonToastNotificationIcon.Ok, DesignTimeUtilities.DEFAULT_ICON_OK }, + { KryptonToastNotificationIcon.Custom, DesignTimeUtilities.DEFAULT_ICON_CUSTOM } + }); + + #endregion + + #region Protected + + /// Gets an array of lookup pairs. + protected override IReadOnlyDictionary PairsStringToEnum => _iconPairs.SecondToFirst; + + /// Gets the pairs enum to string. + /// The pairs enum to string. + protected override IReadOnlyDictionary PairsEnumToString => _iconPairs.FirstToSecond; + + #endregion + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/General/Definitions.cs b/Source/Krypton Components/Krypton.Toolkit/General/Definitions.cs index ba10dba37..445d584b3 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/Definitions.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/Definitions.cs @@ -1873,6 +1873,283 @@ public enum MessageBoxContentAreaType #endregion + #region Enum KryptonMessageBoxIcon + + /// Specifies the icon type for . + [TypeConverter(typeof(KryptonMessageBoxIconConverter))] + public enum KryptonMessageBoxIcon + { + /// Specify no icon. + None = 0, + + /// Specify a hand icon. + Hand = 1, + + /// Specify the system hand icon. + SystemHand = MessageBoxIcon.Hand, + + /// Specify a question icon. + Question = 2, + + /// Specify the system question icon. + SystemQuestion = MessageBoxIcon.Question, + + /// Specify an exclamation icon. + Exclamation = 3, + + /// Specify the system exclamation icon. + SystemExclamation = MessageBoxIcon.Exclamation, + + /// Specify an asterisk icon. + Asterisk = 4, + + /// Specify the system asterisk icon. + SystemAsterisk = MessageBoxIcon.Asterisk, + + /// Specify a stop icon. + Stop = 5, + + /// Specify the system stop icon. + SystemStop = MessageBoxIcon.Stop, + + /// Specify a error icon. + Error = 6, + + /// Specify the system error icon. + SystemError = MessageBoxIcon.Error, + + /// Specify a warning icon. + Warning = 7, + + /// Specify the system warning icon. + SystemWarning = MessageBoxIcon.Warning, + + /// Specify an information icon. + Information = 8, + + /// Specify the system information icon. + SystemInformation = MessageBoxIcon.Information, + + /// Specify a UAC shield icon. + Shield = 9, + + /// Specify a Windows logo icon. + WindowsLogo = 10, + + /// Specify your application icon. + Application = 11, + + /// Specify the default system application icon. See . + SystemApplication = 12 + } + + #endregion + + #region Enum KryptonMessageBoxButtons + + /// Specifies constants defining which buttons to display on a . + public enum KryptonMessageBoxButtons + { + /// + /// Specifies that the message box contains an OK button. + /// + OK = MessageBoxButtons.OK, + + /// + /// Specifies that the message box contains OK and Cancel buttons. + /// + OKCancel = MessageBoxButtons.OKCancel, + + /// + /// Specifies that the message box contains Abort, Retry, and Ignore buttons. + /// + AbortRetryIgnore = MessageBoxButtons.AbortRetryIgnore, + + /// + /// Specifies that the message box contains Yes, No, and Cancel buttons. + /// + YesNoCancel = MessageBoxButtons.YesNoCancel, + + /// + /// Specifies that the message box contains Yes and No buttons. + /// + YesNo = MessageBoxButtons.YesNo, + + /// + /// Specifies that the message box contains Retry and Cancel buttons. + /// + RetryCancel = MessageBoxButtons.RetryCancel, + + /// + /// Specifies that the message box contains Cancel, Try Again, and Continue buttons. + /// +#if NET60_OR_GREATER + CancelTryContinue = MessageBoxButtons.CancelTryContinue +#else + CancelTryContinue = 0x00000006 +#endif + } + + #endregion + + #region Enum KryptonMessageBoxDefaultButton + + /// Specifies constants defining the default button on a . + public enum KryptonMessageBoxDefaultButton + { + /// The first button on the message box is the default button. + Button1 = 0, + + /// The second button on the message box is the default button. + Button2 = 256, + + /// The third button on the message box is the default button. + Button3 = 512, + + /// Specifies that the Help button on the message box should be the default button. + Button4 = 768, + + /// The accelerator button. + Button5 = 1024 + } + + #endregion + + #region Enum KryptonToastNotificationIcon + + [TypeConverter(typeof(KryptonToastNotificationIconConverter))] + public enum KryptonToastNotificationIcon + { + /// Specify no icon. + None = 0, + + /// Specify a hand icon. + Hand = 1, + + /// Specify the system hand icon. + SystemHand = MessageBoxIcon.Hand, + + /// Specify a question icon. + Question = 2, + + /// Specify the system question icon. + SystemQuestion = MessageBoxIcon.Question, + + /// Specify an exclamation icon. + Exclamation = 3, + + /// Specify the system exclamation icon. + SystemExclamation = MessageBoxIcon.Exclamation, + + /// Specify an asterisk icon. + Asterisk = 4, + + /// Specify the system asterisk icon. + SystemAsterisk = MessageBoxIcon.Asterisk, + + /// Specify a stop icon. + Stop = 5, + + /// Specify the system stop icon. + SystemStop = MessageBoxIcon.Stop, + + /// Specify a error icon. + Error = 6, + + /// Specify the system error icon. + SystemError = MessageBoxIcon.Error, + + /// Specify a warning icon. + Warning = 7, + + /// Specify the system warning icon. + SystemWarning = MessageBoxIcon.Warning, + + /// Specify an information icon. + Information = 8, + + /// Specify the system information icon. + SystemInformation = MessageBoxIcon.Information, + + /// Specify a UAC shield icon. + Shield = 9, + + /// Specify a Windows logo icon. + WindowsLogo = 10, + + /// Specify your application icon. + Application = 11, + + /// Specify the default system application icon. See . + SystemApplication = 12, + + /// Specify an ok icon. + Ok = 13, + + /// Specify a custom icon. + Custom = 14, + } + + #endregion + + #region Enum KryptonToastNotificationContentAreaType + + public enum KryptonToastNotificationContentAreaType + { + RichTextBox = 0, + MultiLineTextBox = 1, + WrapLinkLabel = 2, + WrapLabel = 3 + } + + #endregion + + #region Enum KryptonToastNotificationInputAreaType + + public enum KryptonToastNotificationInputAreaType + { + None = 0, + DomainDropDown = 1, + NumericDropDown = 2, + MaskedTextBox = 3, + TextBox = 4 + } + + #endregion + + #region Enum KryptonToastNotificationActionButton + + public enum KryptonToastNotificationActionButton + { + Button1 = 0, + Button2 = 1, + //Button3 = 2 + } + + #endregion + + #region Enum KryptonToastNotificationActionType + + public enum KryptonToastNotificationActionType + { + Default = 0, + Dismiss = 1, + LaunchProcess = 2, + Open = 3 + } + + #endregion + + #region Enum KryptonToastNotificationDismissButtonLocation + + public enum KryptonToastNotificationDismissButtonLocation + { + Left = 0, + Right = 1, + } + + #endregion + #region Enum ToolkitType public enum ToolkitType diff --git a/Source/Krypton Components/Krypton.Toolkit/General/DesignTimeUtilities.cs b/Source/Krypton Components/Krypton.Toolkit/General/DesignTimeUtilities.cs index 8d65f8641..088c1ec68 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/DesignTimeUtilities.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/DesignTimeUtilities.cs @@ -7,6 +7,7 @@ */ #endregion +// ReSharper disable InconsistentNaming namespace Krypton.Toolkit { internal class DesignTimeUtilities @@ -640,6 +641,34 @@ internal class DesignTimeUtilities #endregion + #region ToastNotificationIcon + + internal static string DEFAULT_ICON_NONE = @"None"; + internal static string DEFAULT_ICON_HAND = @"Hand"; + internal static string DEFAULT_ICON_SYSTEM_HAND = @"Hand (System)"; + internal static string DEFAULT_ICON_QUESTION = @"Question"; + internal static string DEFAULT_ICON_SYSTEM_QUESTION = @"Question (System)"; + internal static string DEFAULT_ICON_EXCLAMATION = @"Exclamation"; + internal static string DEFAULT_ICON_SYSTEM_EXCLAMATION = @"Exclamation (System)"; + internal static string DEFAULT_ICON_ASTERISK = @"Asterisk"; + internal static string DEFAULT_ICON_SYSTEM_ASTERISK = @"Asterisk (System)"; + internal static string DEFAULT_ICON_STOP = @"Stop"; + internal static string DEFAULT_ICON_SYSTEM_STOP = @"Stop (System)"; + internal static string DEFAULT_ICON_ERROR = @"Error"; + internal static string DEFAULT_ICON_SYSTEM_ERROR = @"Error (System)"; + internal static string DEFAULT_ICON_WARNING = @"Warning"; + internal static string DEFAULT_ICON_SYSTEM_WARNING = "Warning (System)"; + internal static string DEFAULT_ICON_INFORMATION = @"Information"; + internal static string DEFAULT_ICON_SYSTEM_INFORMATION = @"Information (System)"; + internal static string DEFAULT_ICON_SHIELD = @"User Account Control Shield"; + internal static string DEFAULT_ICON_WINDOWS_LOGO = @"Windows Logo"; + internal static string DEFAULT_ICON_APPLICATION = @"Application"; + internal static string DEFAULT_ICON_SYSTEM_APPLICATION = @"Application (System)"; + internal static string DEFAULT_ICON_OK = @"OK"; + internal static string DEFAULT_ICON_CUSTOM = @"Custom"; + + #endregion + #endregion } } \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/General/GlobalStaticValues.cs b/Source/Krypton Components/Krypton.Toolkit/General/GlobalStaticValues.cs index a9febe708..6a6d5c95e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/GlobalStaticValues.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/GlobalStaticValues.cs @@ -39,11 +39,15 @@ public class GlobalStaticValues public static Size DEFAULT_UAC_SHIELD_ICON_CUSTOM_SIZE = new Size(16, 16); + internal const int GLOBAL_BUTTON_PADDING = 10; + // Used for version reporting internal static string DEFAULT_DOCKING_FILE = @"Krypton.Docking.dll"; internal static string DEFAULT_NAVIGATOR_FILE = @"Krypton.Navigator.dll"; internal static string DEFAULT_RIBBON_FILE = @"Krypton.Ribbon.dll"; internal static string DEFAULT_TOOLKIT_FILE = @"Krypton.Toolkit.dll"; internal static string DEFAULT_WORKSPACE_FILE = @"Krypton.Workspace.dll"; + + internal static readonly int OS_MAJOR_VERSION = Environment.OSVersion.Version.Major; } } \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/General/HResult.cs b/Source/Krypton Components/Krypton.Toolkit/General/HResult.cs index caf4a7505..ba3922f54 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/HResult.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/HResult.cs @@ -97,7 +97,7 @@ public static string AsString(this PI.HRESULT hr) ? $"HRESULT {hr} [0x{(int)hr:X} ({(int)hr:D})]" : $"HRESULT [0x{(int)hr:X} ({(int)hr:D})]"; - public static Exception GetExceptionForHR(this PI.HRESULT errorCode) => Marshal.GetExceptionForHR((int)errorCode); + public static Exception GetExceptionForHR(this PI.HRESULT errorCode) => Marshal.GetExceptionForHR((int)errorCode)!; public static void ThrowExceptionIfFailed(this PI.HRESULT hr) { diff --git a/Source/Krypton Components/Krypton.Toolkit/General/KryptonAboutBoxUtilities.cs b/Source/Krypton Components/Krypton.Toolkit/General/KryptonAboutBoxUtilities.cs index 40bf357e0..b3ffcd4b0 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/KryptonAboutBoxUtilities.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/KryptonAboutBoxUtilities.cs @@ -40,32 +40,39 @@ public static DateTime AssemblyLastWriteTime(Assembly assembly) } } - public static DateTime AssemblyBuildDate(Assembly assembly, bool forceFileDate) + public static DateTime AssemblyBuildDate(Assembly? assembly, bool forceFileDate) { - Version assemblyVersion = assembly.GetName().Version; - - DateTime dateTime; - - if (forceFileDate) - { - dateTime = AssemblyLastWriteTime(assembly); - } - else + if (assembly != null) { - dateTime = DateTime.Parse(@"01/01/1970").AddDays(assemblyVersion.Build).AddSeconds(assemblyVersion.Revision * 2); + Version assemblyVersion = assembly.GetName().Version; - if (TimeZone.IsDaylightSavingTime(dateTime, TimeZone.CurrentTimeZone.GetDaylightChanges(dateTime.Year))) - { - dateTime = dateTime.AddHours(1); - } + DateTime dateTime; - if (dateTime > DateTime.Now || assemblyVersion.Build < 730 || assemblyVersion.Revision == 0) + if (forceFileDate) { dateTime = AssemblyLastWriteTime(assembly); } - } + else + { + dateTime = DateTime.Parse(@"01/01/1970").AddDays(assemblyVersion.Build).AddSeconds(assemblyVersion.Revision * 2); + + if (TimeZone.IsDaylightSavingTime(dateTime, TimeZone.CurrentTimeZone.GetDaylightChanges(dateTime.Year))) + { + dateTime = dateTime.AddHours(1); + } - return dateTime; + if (dateTime > DateTime.Now || assemblyVersion.Build < 730 || assemblyVersion.Revision == 0) + { + dateTime = AssemblyLastWriteTime(assembly); + } + } + + return dateTime; + } + else + { + return DateTime.Now; + } } public static NameValueCollection AssemblyAttribs(Assembly assembly) @@ -239,11 +246,11 @@ public static void PopulateBasicApplicationInformation(KryptonDataGridView dataS { AppDomain domain = AppDomain.CurrentDomain; - string _entryAssemblyName = Assembly.GetEntryAssembly()!.GetName().Name; + string entryAssemblyName = Assembly.GetEntryAssembly()!.GetName().Name; - string _executingAssemblyName = Assembly.GetExecutingAssembly().GetName().Name; + string executingAssemblyName = Assembly.GetExecutingAssembly().GetName().Name; - string _callingAssemblyName = Assembly.GetCallingAssembly().GetName().Name; + string callingAssemblyName = Assembly.GetCallingAssembly().GetName().Name; Populate(dataStore, KryptonManager.Strings.KryptonAboutBoxBasicApplicationInformationStrings.ApplicationName, Assembly.GetEntryAssembly()!.GetName().Name); @@ -266,11 +273,11 @@ public static void PopulateBasicApplicationInformation(KryptonDataGridView dataS Populate(dataStore, string.Empty, string.Empty); - Populate(dataStore, KryptonManager.Strings.KryptonAboutBoxBasicApplicationInformationStrings.EntryAssembly, _entryAssemblyName); + Populate(dataStore, KryptonManager.Strings.KryptonAboutBoxBasicApplicationInformationStrings.EntryAssembly, entryAssemblyName); - Populate(dataStore, KryptonManager.Strings.KryptonAboutBoxBasicApplicationInformationStrings.ExecutingAssembly, _executingAssemblyName); + Populate(dataStore, KryptonManager.Strings.KryptonAboutBoxBasicApplicationInformationStrings.ExecutingAssembly, executingAssemblyName); - Populate(dataStore, KryptonManager.Strings.KryptonAboutBoxBasicApplicationInformationStrings.CallingAssembly, _callingAssemblyName); + Populate(dataStore, KryptonManager.Strings.KryptonAboutBoxBasicApplicationInformationStrings.CallingAssembly, callingAssemblyName); } public static void PopulateAssemblies(KryptonComboBox assemblyList, KryptonDataGridView dataStore) diff --git a/Source/Krypton Components/Krypton.Toolkit/General/KryptonAboutToolkitData.cs b/Source/Krypton Components/Krypton.Toolkit/General/KryptonAboutToolkitData.cs index 15160cec3..43b5b04a2 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/KryptonAboutToolkitData.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/KryptonAboutToolkitData.cs @@ -9,7 +9,7 @@ namespace Krypton.Toolkit { - /// Contains the information used for creating a new . + /// Contains the toolkit information used for creating a new . public struct KryptonAboutToolkitData { #region Static Fields diff --git a/Source/Krypton Components/Krypton.Toolkit/General/KryptonGlobalToolkitStrings.cs b/Source/Krypton Components/Krypton.Toolkit/General/KryptonGlobalToolkitStrings.cs index 9c8caab2e..8dbf6ca25 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/KryptonGlobalToolkitStrings.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/KryptonGlobalToolkitStrings.cs @@ -304,10 +304,24 @@ public class KryptonGlobalToolkitStrings : GlobalId public TabStyleStrings TabStyleStrings => TabStyles; private bool ShouldSerializeTabStyleStrings() => !TabStyles.IsDefault; - + /// Resets the tab style strings. public void ResetTabStyleStrings() => TabStyles.Reset(); + /// Gets the toast notification icon strings. + /// The toast notification icon strings. + [Category(@"Visuals")] + [Description(@"Collection of toast notification icon strings.")] + [MergableProperty(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + [Localizable(true)] + public ToastNotificationIconStrings ToastNotificationIconStrings => ToastNotificationIcon; + + private bool ShouldSerializeToastNotificationIconStrings() => !ToastNotificationIcon.IsDefault; + + /// Resets the toast notification icon strings. + public void ResetToastNotificationIconStrings() => ToastNotificationIcon.Reset(); + /// Gets the krypton about box basic application information strings. /// The krypton about box basic application information strings. [Category(@"Visuals")] @@ -545,6 +559,10 @@ public static GeneralToolkitStrings GeneralToolkitStrings /// The tab styles. public static TabStyleStrings TabStyles { get; } = new TabStyleStrings(); + /// Gets the toast notification icon. + /// The toast notification icon. + public static ToastNotificationIconStrings ToastNotificationIcon { get; } = new ToastNotificationIconStrings(); + /// Gets the basic application information strings. /// The basic application information strings. public static KryptonAboutBoxBasicApplicationInformationStrings BasicApplicationInformationStrings { get; } = new KryptonAboutBoxBasicApplicationInformationStrings(); @@ -605,6 +623,7 @@ public KryptonGlobalToolkitStrings() ShouldSerializeSeparatorStyleStrings() || ShouldSerializeTabBorderStyleStrings() || ShouldSerializeTabStyleStrings() || + ShouldSerializeToastNotificationIconStrings() || ShouldSerializeKryptonAboutBoxBasicApplicationInformationStrings() || ShouldSerializeKryptonAboutBoxStrings() || ShouldSerializeKryptonMiscellaneousThemeStrings() || @@ -663,6 +682,8 @@ public void Reset() ResetTabStyleStrings(); + ResetToastNotificationIconStrings(); + ResetKryptonKryptonAboutBoxBasicApplicationInformationStrings(); ResetKryptonAboutBoxStrings(); diff --git a/Source/Krypton Components/Krypton.Toolkit/General/KryptonInputBoxData.cs b/Source/Krypton Components/Krypton.Toolkit/General/KryptonInputBoxData.cs new file mode 100644 index 000000000..415b87656 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/General/KryptonInputBoxData.cs @@ -0,0 +1,51 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2023 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + /// A structure that contains basic information for . + public struct KryptonInputBoxData + { + #region Public + + /// Gets or sets the owner of the . + /// The owner of the . + public IWin32Window? Owner { get; set; } + + /// Gets or sets the prompt text. + /// The prompt text. + public string Prompt { get; set; } + + /// Gets or sets the caption. + /// The caption. + public string Caption { get; set; } + + /// Gets or sets the default response. + /// The default response. + public string DefaultResponse { get; set; } + + /// Gets or sets the cue text. + /// The cue text. + public string CueText { get; set; } + + /// Gets or sets the color of the cue text. + /// The color of the cue text. + public Color? CueColor { get; set; } + + /// Gets or sets the cue typeface. + /// The cue typeface. + public Font? CueTypeface { get; set; } + + /// Gets or sets the use password option. + /// The use password option. + public bool? UsePasswordOption { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/General/KryptonToastData.cs b/Source/Krypton Components/Krypton.Toolkit/General/KryptonToastData.cs new file mode 100644 index 000000000..9317eadbb --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/General/KryptonToastData.cs @@ -0,0 +1,169 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2023 - 2023. All rights reserved. + * + */ +#endregion + +using ContentAlignment = System.Drawing.ContentAlignment; + +namespace Krypton.Toolkit +{ + /// A structure that contains basic information for . + public struct KryptonToastData + { + #region Public + + /// Gets or sets a value indicating whether [show close button]. + /// true if [show close button]; otherwise, false. + public bool ShowCloseButton { get; set; } + + /// Gets or sets a value indicating whether [show countdown percentage]. + /// true if [show countdown percentage]; otherwise, false. + public bool ShowCountdownPercentage { get; set; } + + /// Gets or sets a value indicating whether [show title]. + /// true if [show title]; otherwise, false. + public bool ShowTitle { get; set; } + + /// Gets or sets a value indicating whether [show action button]. + /// true if [show action button]; otherwise, false. + public bool ShowActionButton { get; set; } + + /// Gets or sets a value indicating whether [show progress bar]. + /// true if [show progress bar]; otherwise, false. + public bool ShowProgressBar { get; set; } + + /// Gets or sets the color of the user response prompt. + /// The color of the user response prompt. + public Color? UserResponsePromptColor { get; set; } + + /// Gets or sets the label content text alignment. + /// The label content text alignment. + public ContentAlignment? LabelContentTextAlignment { get; set; } + + /// Gets or sets the title text alignment. + /// The title text alignment. + public ContentAlignment? TitleTextAlignment { get; set; } + + /// Gets or sets the user response prompt font. + /// The user response prompt font. + public Font? UserResponsePromptFont { get; set; } + + /// Gets or sets the user input control style. + /// The user input control style. + public InputControlStyle? UserInputControlStyle { get; set; } + + /// Gets or sets the user response prompt horizontal alignment. + /// The user response prompt horizontal alignment. + public PaletteRelativeAlign? UserResponsePromptAlignmentHorizontal { get; set; } + + /// Gets or sets the user response prompt vertical alignment. + /// The user response prompt vertical alignment. + public PaletteRelativeAlign? UserResponsePromptAlignmentVertical { get; set; } + + /// Gets or sets the text box content text horizontal alignment. + /// The text box content text horizontal alignment. + public PaletteRelativeAlign? TextBoxContentTextAlignmentHorizontal { get; set; } + + /// Gets or sets the action button. + /// The action button. + public KryptonToastNotificationActionButton? ActionButton { get; set; } + + /// Gets or sets the type of the action. + /// The type of the action. + public KryptonToastNotificationActionType? ActionType { get; set; } + + /// Gets or sets the type of the toast notification content area. + /// The type of the toast notification content area. + public KryptonToastNotificationContentAreaType? ToastNotificationContentAreaType { get; set; } + + /// Gets or sets the type of the toast notification input area. + /// The type of the toast notification input area. + public KryptonToastNotificationInputAreaType? ToastNotificationInputAreaType { get; set; } + + /// Gets or sets the notification icon. + /// The notification icon. + public KryptonToastNotificationIcon NotificationIcon { get; set; } + + /// Gets or sets the count-down seconds. + /// The count-down seconds. + public int? CountDownSeconds { get; set; } + + /// Gets or sets the time. + /// The time. + public int? Time { get; set; } + + /// Gets or sets the progress bar maximum value. + /// The progress bar maximum value. + public int? ProgressBarMaximum { get; set; } + + /// Gets or sets the custom image. + /// The custom image. + public Image CustomImage { get; set; } + + /// Gets or sets the sound stream. + /// The sound stream. + public Stream SoundStream { get; set; } + + /// Gets or sets the right to left. + /// The right to left. + public RightToLeft? RightToLeft { get; set; } + + /// Gets or sets the title. + /// The title. + public string Title { get; set; } + + /// Gets or sets the notification content text. + /// The notification content text. + public string NotificationContentText { get; set; } + + /// Gets or sets the sound path. + /// The sound path. + public string SoundPath { get; set; } + + /// Gets or sets the user response prompt text. + /// The user response prompt text. + public string UserResponsePromptText { get; set; } + + /// Gets or sets the notification content link area. + /// The notification content link area. + public LinkArea? NotificationContentLinkArea { get; set; } + + /// Gets or sets the action button command. + /// The action button command. + public KryptonCommand? ActionButtonCommand { get; set; } + + /// Gets or sets the show user response UI. + /// The show user response UI. + public bool? ShowUserResponse { get; set; } + + /// Gets or sets the user response text alignment horizontal. + /// The user response text alignment horizontal. + public PaletteRelativeAlign? UserResponseTextAlignmentHorizontal { get; set; } + + /// Gets or sets the notification content rich text box alignment. + /// The notification content rich text box alignment. + public PaletteRelativeAlign? NotificationContentRichTextBoxAlignment { get; set; } + + /// Gets or sets the notification content text box alignment. + /// The notification content text box alignment. + public HorizontalAlignment? NotificationContentTextBoxAlignment { get; set; } + + /// Gets or sets the numeric up down input maximum value. + /// The numeric up down input maximum value. + public int? NumericUpDownInputMaximum { get; set; } + + /// Gets or sets the notification content link destination. + /// The notification content link destination. + public object? NotificationContentLinkDestination { get; set; } + + /// Gets or sets the count-down timer interval. + /// The count-down timer interval. + public int? CountDownTimerInterval { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/General/ShadowManager.cs b/Source/Krypton Components/Krypton.Toolkit/General/ShadowManager.cs index 446540e80..a4c3a3fb9 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/ShadowManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/ShadowManager.cs @@ -420,7 +420,7 @@ private static IntPtr ShellProc(int code, IntPtr wParam, IntPtr lParam) { try { - if (_forms.TryGetValue(wParam, out Form f)) + if (_forms.TryGetValue(wParam, out var f)) { FlashEvent(f, (int)lParam == 1); } diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteRedirect/PaletteRedirect.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteRedirect/PaletteRedirect.cs index a9d80fe54..5843acc51 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteRedirect/PaletteRedirect.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteRedirect/PaletteRedirect.cs @@ -18,7 +18,7 @@ namespace Krypton.Toolkit public class PaletteRedirect : PaletteBase, IGlobalId { #region Instance Fields - private PaletteBase _target; + private PaletteBase? _target; #endregion #region Identity @@ -34,11 +34,11 @@ public PaletteRedirect() /// Initialize a new instance of the PaletteRedirect class. /// /// Initial palette target for redirection. - public PaletteRedirect(PaletteBase target) + public PaletteRedirect(PaletteBase? target) { Id = CommonHelper.NextId; // Remember incoming target - _target = target; + _target = target!; } #endregion @@ -47,7 +47,7 @@ public PaletteRedirect(PaletteBase target) /// /// Gets and sets the redirection target. /// - public virtual PaletteBase Target + public virtual PaletteBase? Target { get => _target; set => _target = value; @@ -68,7 +68,7 @@ public virtual PaletteBase Target /// Gets the renderer to use for this palette. /// /// Renderer to use for drawing palette settings. - public override IRenderer GetRenderer() => _target?.GetRenderer(); + public override IRenderer GetRenderer() => _target!.GetRenderer(); #endregion @@ -87,7 +87,7 @@ public virtual PaletteBase Target /// Border style. /// Palette value should be applicable to this state. /// PaletteGraphicsHint value. - public override PaletteGraphicsHint GetBackGraphicsHint(PaletteBackStyle style, PaletteState state) => _target.GetBackGraphicsHint(style, state); + public override PaletteGraphicsHint GetBackGraphicsHint(PaletteBackStyle style, PaletteState state) => _target!.GetBackGraphicsHint(style, state); /// /// Gets the first background color. @@ -95,7 +95,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetBackColor1(PaletteBackStyle style, PaletteState state) => _target.GetBackColor1(style, state); + public override Color GetBackColor1(PaletteBackStyle style, PaletteState state) => _target!.GetBackColor1(style, state); /// /// Gets the second back color. @@ -103,7 +103,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetBackColor2(PaletteBackStyle style, PaletteState state) => _target.GetBackColor2(style, state); + public override Color GetBackColor2(PaletteBackStyle style, PaletteState state) => _target!.GetBackColor2(style, state); /// /// Gets the color background drawing style. @@ -111,7 +111,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// Color drawing style. - public override PaletteColorStyle GetBackColorStyle(PaletteBackStyle style, PaletteState state) => _target.GetBackColorStyle(style, state); + public override PaletteColorStyle GetBackColorStyle(PaletteBackStyle style, PaletteState state) => _target!.GetBackColorStyle(style, state); /// /// Gets the color alignment. @@ -119,7 +119,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// Color alignment style. - public override PaletteRectangleAlign GetBackColorAlign(PaletteBackStyle style, PaletteState state) => _target.GetBackColorAlign(style, state); + public override PaletteRectangleAlign GetBackColorAlign(PaletteBackStyle style, PaletteState state) => _target!.GetBackColorAlign(style, state); /// /// Gets the color background angle. @@ -127,7 +127,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// Angle used for color drawing. - public override float GetBackColorAngle(PaletteBackStyle style, PaletteState state) => _target.GetBackColorAngle(style, state); + public override float GetBackColorAngle(PaletteBackStyle style, PaletteState state) => _target!.GetBackColorAngle(style, state); /// /// Gets a background image. @@ -143,7 +143,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// Image style value. - public override PaletteImageStyle GetBackImageStyle(PaletteBackStyle style, PaletteState state) => _target.GetBackImageStyle(style, state); + public override PaletteImageStyle GetBackImageStyle(PaletteBackStyle style, PaletteState state) => _target!.GetBackImageStyle(style, state); /// /// Gets the image alignment. @@ -151,7 +151,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// Image alignment style. - public override PaletteRectangleAlign GetBackImageAlign(PaletteBackStyle style, PaletteState state) => _target.GetBackImageAlign(style, state); + public override PaletteRectangleAlign GetBackImageAlign(PaletteBackStyle style, PaletteState state) => _target!.GetBackImageAlign(style, state); #endregion @@ -170,7 +170,7 @@ public virtual PaletteBase Target /// Border style. /// Palette value should be applicable to this state. /// PaletteDrawBorders value. - public override PaletteDrawBorders GetBorderDrawBorders(PaletteBorderStyle style, PaletteState state) => _target.GetBorderDrawBorders(style, state); + public override PaletteDrawBorders GetBorderDrawBorders(PaletteBorderStyle style, PaletteState state) => _target!.GetBorderDrawBorders(style, state); /// /// Gets the graphics drawing hint for the border. @@ -178,7 +178,7 @@ public virtual PaletteBase Target /// Border style. /// Palette value should be applicable to this state. /// PaletteGraphicsHint value. - public override PaletteGraphicsHint GetBorderGraphicsHint(PaletteBorderStyle style, PaletteState state) => _target.GetBorderGraphicsHint(style, state); + public override PaletteGraphicsHint GetBorderGraphicsHint(PaletteBorderStyle style, PaletteState state) => _target!.GetBorderGraphicsHint(style, state); /// /// Gets the first border color. @@ -186,7 +186,7 @@ public virtual PaletteBase Target /// Border style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetBorderColor1(PaletteBorderStyle style, PaletteState state) => _target.GetBorderColor1(style, state); + public override Color GetBorderColor1(PaletteBorderStyle style, PaletteState state) => _target!.GetBorderColor1(style, state); /// /// Gets the second border color. @@ -194,7 +194,7 @@ public virtual PaletteBase Target /// Border style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetBorderColor2(PaletteBorderStyle style, PaletteState state) => _target.GetBorderColor2(style, state); + public override Color GetBorderColor2(PaletteBorderStyle style, PaletteState state) => _target!.GetBorderColor2(style, state); /// /// Gets the color border drawing style. @@ -202,7 +202,7 @@ public virtual PaletteBase Target /// Border style. /// Palette value should be applicable to this state. /// Color drawing style. - public override PaletteColorStyle GetBorderColorStyle(PaletteBorderStyle style, PaletteState state) => _target.GetBorderColorStyle(style, state); + public override PaletteColorStyle GetBorderColorStyle(PaletteBorderStyle style, PaletteState state) => _target!.GetBorderColorStyle(style, state); /// /// Gets the color border alignment. @@ -210,7 +210,7 @@ public virtual PaletteBase Target /// Border style. /// Palette value should be applicable to this state. /// Color alignment style. - public override PaletteRectangleAlign GetBorderColorAlign(PaletteBorderStyle style, PaletteState state) => _target.GetBorderColorAlign(style, state); + public override PaletteRectangleAlign GetBorderColorAlign(PaletteBorderStyle style, PaletteState state) => _target!.GetBorderColorAlign(style, state); /// /// Gets the color border angle. @@ -218,7 +218,7 @@ public virtual PaletteBase Target /// Border style. /// Palette value should be applicable to this state. /// Angle used for color drawing. - public override float GetBorderColorAngle(PaletteBorderStyle style, PaletteState state) => _target.GetBorderColorAngle(style, state); + public override float GetBorderColorAngle(PaletteBorderStyle style, PaletteState state) => _target!.GetBorderColorAngle(style, state); /// /// Gets the border width. @@ -226,7 +226,7 @@ public virtual PaletteBase Target /// Border style. /// Palette value should be applicable to this state. /// Integer width. - public override int GetBorderWidth(PaletteBorderStyle style, PaletteState state) => _target.GetBorderWidth(style, state); + public override int GetBorderWidth(PaletteBorderStyle style, PaletteState state) => _target!.GetBorderWidth(style, state); /// /// Gets the border corner rounding. @@ -234,7 +234,7 @@ public virtual PaletteBase Target /// Border style. /// Palette value should be applicable to this state. /// Float rounding. - public override float GetBorderRounding(PaletteBorderStyle style, PaletteState state) => _target.GetBorderRounding(style, state); + public override float GetBorderRounding(PaletteBorderStyle style, PaletteState state) => _target!.GetBorderRounding(style, state); /// /// Gets a border image. @@ -250,7 +250,7 @@ public virtual PaletteBase Target /// Border style. /// Palette value should be applicable to this state. /// Image style value. - public override PaletteImageStyle GetBorderImageStyle(PaletteBorderStyle style, PaletteState state) => _target.GetBorderImageStyle(style, state); + public override PaletteImageStyle GetBorderImageStyle(PaletteBorderStyle style, PaletteState state) => _target!.GetBorderImageStyle(style, state); /// /// Gets the image border alignment. @@ -258,7 +258,7 @@ public virtual PaletteBase Target /// Border style. /// Palette value should be applicable to this state. /// Image alignment style. - public override PaletteRectangleAlign GetBorderImageAlign(PaletteBorderStyle style, PaletteState state) => _target.GetBorderImageAlign(style, state); + public override PaletteRectangleAlign GetBorderImageAlign(PaletteBorderStyle style, PaletteState state) => _target!.GetBorderImageAlign(style, state); #endregion #region Content @@ -276,7 +276,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// InheritBool value. - public override InheritBool GetContentDrawFocus(PaletteContentStyle style, PaletteState state) => _target.GetContentDrawFocus(style, state); + public override InheritBool GetContentDrawFocus(PaletteContentStyle style, PaletteState state) => _target!.GetContentDrawFocus(style, state); /// /// Gets the horizontal relative alignment of the image. @@ -284,7 +284,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// RelativeAlignment value. - public override PaletteRelativeAlign GetContentImageH(PaletteContentStyle style, PaletteState state) => _target.GetContentImageH(style, state); + public override PaletteRelativeAlign GetContentImageH(PaletteContentStyle style, PaletteState state) => _target!.GetContentImageH(style, state); /// /// Gets the vertical relative alignment of the image. @@ -292,7 +292,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// RelativeAlignment value. - public override PaletteRelativeAlign GetContentImageV(PaletteContentStyle style, PaletteState state) => _target.GetContentImageV(style, state); + public override PaletteRelativeAlign GetContentImageV(PaletteContentStyle style, PaletteState state) => _target!.GetContentImageV(style, state); /// /// Gets the effect applied to drawing of the image. @@ -300,7 +300,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// PaletteImageEffect value. - public override PaletteImageEffect GetContentImageEffect(PaletteContentStyle style, PaletteState state) => _target.GetContentImageEffect(style, state); + public override PaletteImageEffect GetContentImageEffect(PaletteContentStyle style, PaletteState state) => _target!.GetContentImageEffect(style, state); /// /// Gets the image color to remap into another color. @@ -308,7 +308,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetContentImageColorMap(PaletteContentStyle style, PaletteState state) => _target.GetContentImageColorMap(style, state); + public override Color GetContentImageColorMap(PaletteContentStyle style, PaletteState state) => _target!.GetContentImageColorMap(style, state); /// /// Gets the color to use in place of the image map color. @@ -316,10 +316,10 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetContentImageColorTo(PaletteContentStyle style, PaletteState state) => _target.GetContentImageColorTo(style, state); + public override Color GetContentImageColorTo(PaletteContentStyle style, PaletteState state) => _target!.GetContentImageColorTo(style, state); /// - public override Color GetContentImageColorTransparent(PaletteContentStyle style, PaletteState state) => _target.GetContentImageColorTransparent(style, state); + public override Color GetContentImageColorTransparent(PaletteContentStyle style, PaletteState state) => _target!.GetContentImageColorTransparent(style, state); /// /// Gets the font for the short text. @@ -327,7 +327,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Font value. - public override Font? GetContentShortTextFont(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextFont(style, state); + public override Font? GetContentShortTextFont(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextFont(style, state); /// /// Gets the font for the short text by generating a new font instance. @@ -335,7 +335,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Font value. - public override Font? GetContentShortTextNewFont(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextNewFont(style, state); + public override Font? GetContentShortTextNewFont(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextNewFont(style, state); /// /// Gets the rendering hint for the short text. @@ -343,7 +343,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// PaletteTextHint value. - public override PaletteTextHint GetContentShortTextHint(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextHint(style, state); + public override PaletteTextHint GetContentShortTextHint(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextHint(style, state); /// /// Gets the prefix drawing setting for short text. @@ -351,7 +351,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// PaletteTextPrefix value. - public override PaletteTextHotkeyPrefix GetContentShortTextPrefix(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextPrefix(style, state); + public override PaletteTextHotkeyPrefix GetContentShortTextPrefix(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextPrefix(style, state); /// /// Gets the flag indicating if multiline text is allowed for short text. @@ -367,7 +367,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// PaletteTextTrim value. - public override PaletteTextTrim GetContentShortTextTrim(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextTrim(style, state); + public override PaletteTextTrim GetContentShortTextTrim(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextTrim(style, state); /// /// Gets the horizontal relative alignment of the short text. @@ -375,7 +375,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// RelativeAlignment value. - public override PaletteRelativeAlign GetContentShortTextH(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextH(style, state); + public override PaletteRelativeAlign GetContentShortTextH(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextH(style, state); /// /// Gets the vertical relative alignment of the short text. @@ -383,7 +383,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// RelativeAlignment value. - public override PaletteRelativeAlign GetContentShortTextV(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextV(style, state); + public override PaletteRelativeAlign GetContentShortTextV(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextV(style, state); /// /// Gets the horizontal relative alignment of multiline short text. @@ -391,7 +391,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// RelativeAlignment value. - public override PaletteRelativeAlign GetContentShortTextMultiLineH(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextMultiLineH(style, state); + public override PaletteRelativeAlign GetContentShortTextMultiLineH(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextMultiLineH(style, state); /// /// Gets the first back color for the short text. @@ -399,7 +399,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetContentShortTextColor1(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextColor1(style, state); + public override Color GetContentShortTextColor1(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextColor1(style, state); /// /// Gets the second back color for the short text. @@ -407,7 +407,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetContentShortTextColor2(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextColor2(style, state); + public override Color GetContentShortTextColor2(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextColor2(style, state); /// /// Gets the color drawing style for the short text. @@ -415,7 +415,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Color drawing style. - public override PaletteColorStyle GetContentShortTextColorStyle(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextColorStyle(style, state); + public override PaletteColorStyle GetContentShortTextColorStyle(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextColorStyle(style, state); /// /// Gets the color alignment for the short text. @@ -423,7 +423,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Color alignment style. - public override PaletteRectangleAlign GetContentShortTextColorAlign(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextColorAlign(style, state); + public override PaletteRectangleAlign GetContentShortTextColorAlign(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextColorAlign(style, state); /// /// Gets the color background angle for the short text. @@ -431,7 +431,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Angle used for color drawing. - public override float GetContentShortTextColorAngle(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextColorAngle(style, state); + public override float GetContentShortTextColorAngle(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextColorAngle(style, state); /// /// Gets a background image for the short text. @@ -447,7 +447,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Image style value. - public override PaletteImageStyle GetContentShortTextImageStyle(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextImageStyle(style, state); + public override PaletteImageStyle GetContentShortTextImageStyle(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextImageStyle(style, state); /// /// Gets the image alignment for the short text. @@ -455,7 +455,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Image alignment style. - public override PaletteRectangleAlign GetContentShortTextImageAlign(PaletteContentStyle style, PaletteState state) => _target.GetContentShortTextImageAlign(style, state); + public override PaletteRectangleAlign GetContentShortTextImageAlign(PaletteContentStyle style, PaletteState state) => _target!.GetContentShortTextImageAlign(style, state); /// /// Gets the font for the long text. @@ -463,7 +463,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Font value. - public override Font? GetContentLongTextFont(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextFont(style, state); + public override Font? GetContentLongTextFont(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextFont(style, state); /// /// Gets the font for the long text by generating a new font instance. @@ -471,7 +471,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Font value. - public override Font? GetContentLongTextNewFont(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextNewFont(style, state); + public override Font? GetContentLongTextNewFont(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextNewFont(style, state); /// /// Gets the rendering hint for the long text. @@ -479,7 +479,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// PaletteTextHint value. - public override PaletteTextHint GetContentLongTextHint(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextHint(style, state); + public override PaletteTextHint GetContentLongTextHint(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextHint(style, state); /// /// Gets the flag indicating if multiline text is allowed for long text. @@ -495,7 +495,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// PaletteTextTrim value. - public override PaletteTextTrim GetContentLongTextTrim(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextTrim(style, state); + public override PaletteTextTrim GetContentLongTextTrim(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextTrim(style, state); /// /// Gets the prefix drawing setting for long text. @@ -503,7 +503,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// PaletteTextPrefix value. - public override PaletteTextHotkeyPrefix GetContentLongTextPrefix(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextPrefix(style, state); + public override PaletteTextHotkeyPrefix GetContentLongTextPrefix(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextPrefix(style, state); /// /// Gets the horizontal relative alignment of the long text. @@ -511,7 +511,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// RelativeAlignment value. - public override PaletteRelativeAlign GetContentLongTextH(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextH(style, state); + public override PaletteRelativeAlign GetContentLongTextH(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextH(style, state); /// /// Gets the vertical relative alignment of the long text. @@ -519,7 +519,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// RelativeAlignment value. - public override PaletteRelativeAlign GetContentLongTextV(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextV(style, state); + public override PaletteRelativeAlign GetContentLongTextV(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextV(style, state); /// /// Gets the horizontal relative alignment of multiline long text. @@ -527,7 +527,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// RelativeAlignment value. - public override PaletteRelativeAlign GetContentLongTextMultiLineH(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextMultiLineH(style, state); + public override PaletteRelativeAlign GetContentLongTextMultiLineH(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextMultiLineH(style, state); /// /// Gets the first back color for the long text. @@ -535,7 +535,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetContentLongTextColor1(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextColor1(style, state); + public override Color GetContentLongTextColor1(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextColor1(style, state); /// /// Gets the second back color for the long text. @@ -543,7 +543,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetContentLongTextColor2(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextColor2(style, state); + public override Color GetContentLongTextColor2(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextColor2(style, state); /// /// Gets the color drawing style for the long text. @@ -551,7 +551,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Color drawing style. - public override PaletteColorStyle GetContentLongTextColorStyle(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextColorStyle(style, state); + public override PaletteColorStyle GetContentLongTextColorStyle(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextColorStyle(style, state); /// /// Gets the color alignment for the long text. @@ -559,7 +559,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Color alignment style. - public override PaletteRectangleAlign GetContentLongTextColorAlign(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextColorAlign(style, state); + public override PaletteRectangleAlign GetContentLongTextColorAlign(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextColorAlign(style, state); /// /// Gets the color background angle for the long text. @@ -567,7 +567,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Angle used for color drawing. - public override float GetContentLongTextColorAngle(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextColorAngle(style, state); + public override float GetContentLongTextColorAngle(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextColorAngle(style, state); /// /// Gets a background image for the long text. @@ -583,7 +583,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Image style value. - public override PaletteImageStyle GetContentLongTextImageStyle(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextImageStyle(style, state); + public override PaletteImageStyle GetContentLongTextImageStyle(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextImageStyle(style, state); /// /// Gets the image alignment for the long text. @@ -591,7 +591,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Image alignment style. - public override PaletteRectangleAlign GetContentLongTextImageAlign(PaletteContentStyle style, PaletteState state) => _target.GetContentLongTextImageAlign(style, state); + public override PaletteRectangleAlign GetContentLongTextImageAlign(PaletteContentStyle style, PaletteState state) => _target!.GetContentLongTextImageAlign(style, state); /// /// Gets the padding between the border and content drawing. @@ -599,7 +599,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Padding value. - public override Padding GetContentPadding(PaletteContentStyle style, PaletteState state) => _target.GetContentPadding(style, state); + public override Padding GetContentPadding(PaletteContentStyle style, PaletteState state) => _target!.GetContentPadding(style, state); /// /// Gets the padding between adjacent content items. @@ -607,7 +607,7 @@ public virtual PaletteBase Target /// Content style. /// Palette value should be applicable to this state. /// Integer value. - public override int GetContentAdjacentGap(PaletteContentStyle style, PaletteState state) => _target.GetContentAdjacentGap(style, state); + public override int GetContentAdjacentGap(PaletteContentStyle style, PaletteState state) => _target!.GetContentAdjacentGap(style, state); #endregion @@ -618,7 +618,7 @@ public virtual PaletteBase Target /// Palette value should be applicable to this state. /// Requested metric. /// Integer value. - public override int GetMetricInt(PaletteState state, PaletteMetricInt metric) => _target.GetMetricInt(state, metric); + public override int GetMetricInt(PaletteState state, PaletteMetricInt metric) => _target!.GetMetricInt(state, metric); /// /// Gets a boolean metric value. @@ -634,7 +634,7 @@ public virtual PaletteBase Target /// Palette value should be applicable to this state. /// Requested metric. /// Padding value. - public override Padding GetMetricPadding(PaletteState state, PaletteMetricPadding metric) => _target.GetMetricPadding(state, metric); + public override Padding GetMetricPadding(PaletteState state, PaletteMetricPadding metric) => _target!.GetMetricPadding(state, metric); #endregion @@ -688,7 +688,7 @@ public virtual PaletteBase Target /// Gets an image indicating a sub-menu on a context menu item. /// /// Appropriate image for drawing; otherwise null. - public override Image? GetContextMenuSubMenuImage() => _target.GetContextMenuSubMenuImage(); + public override Image? GetContextMenuSubMenuImage() => _target!.GetContextMenuSubMenuImage(); /// /// Gets a check box image appropriate for the provided state. @@ -721,7 +721,7 @@ public virtual PaletteBase Target /// /// Style of button spec. /// Color value. - public override Color GetButtonSpecImageTransparentColor(PaletteButtonSpecStyle style) => _target.GetButtonSpecImageTransparentColor(style); + public override Color GetButtonSpecImageTransparentColor(PaletteButtonSpecStyle style) => _target!.GetButtonSpecImageTransparentColor(style); /// /// Gets the short text to display for the button. @@ -742,45 +742,45 @@ public virtual PaletteBase Target /// /// Style of button spec. /// String value. - public override string? GetButtonSpecToolTipTitle(PaletteButtonSpecStyle style) => _target.GetButtonSpecToolTipTitle(style); + public override string? GetButtonSpecToolTipTitle(PaletteButtonSpecStyle style) => _target!.GetButtonSpecToolTipTitle(style); /// /// Gets the color to remap from the image to the container foreground. /// /// Style of button spec. /// Color value. - public override Color GetButtonSpecColorMap(PaletteButtonSpecStyle style) => _target.GetButtonSpecColorMap(style); + public override Color GetButtonSpecColorMap(PaletteButtonSpecStyle style) => _target!.GetButtonSpecColorMap(style); /// - public override Color GetButtonSpecColorTransparent(PaletteButtonSpecStyle style) => _target.GetButtonSpecColorTransparent(style); + public override Color GetButtonSpecColorTransparent(PaletteButtonSpecStyle style) => _target!.GetButtonSpecColorTransparent(style); /// /// Gets the button style used for drawing the button. /// /// Style of button spec. /// ButtonStyle value. - public override PaletteButtonStyle GetButtonSpecStyle(PaletteButtonSpecStyle style) => _target.GetButtonSpecStyle(style); + public override PaletteButtonStyle GetButtonSpecStyle(PaletteButtonSpecStyle style) => _target!.GetButtonSpecStyle(style); /// /// Get the location for the button. /// /// Style of button spec. /// HeaderLocation value. - public override HeaderLocation GetButtonSpecLocation(PaletteButtonSpecStyle style) => _target.GetButtonSpecLocation(style); + public override HeaderLocation GetButtonSpecLocation(PaletteButtonSpecStyle style) => _target!.GetButtonSpecLocation(style); /// /// Gets the edge to position the button against. /// /// Style of button spec. /// PaletteRelativeEdgeAlign value. - public override PaletteRelativeEdgeAlign GetButtonSpecEdge(PaletteButtonSpecStyle style) => _target.GetButtonSpecEdge(style); + public override PaletteRelativeEdgeAlign GetButtonSpecEdge(PaletteButtonSpecStyle style) => _target!.GetButtonSpecEdge(style); /// /// Gets the button orientation. /// /// Style of button spec. /// PaletteButtonOrientation value. - public override PaletteButtonOrientation GetButtonSpecOrientation(PaletteButtonSpecStyle style) => _target.GetButtonSpecOrientation(style); + public override PaletteButtonOrientation GetButtonSpecOrientation(PaletteButtonSpecStyle style) => _target!.GetButtonSpecOrientation(style); #endregion @@ -789,140 +789,140 @@ public virtual PaletteBase Target /// Gets the ribbon shape that should be used. /// /// Ribbon shape value. - public override PaletteRibbonShape GetRibbonShape() => _target.GetRibbonShape(); + public override PaletteRibbonShape GetRibbonShape() => _target!.GetRibbonShape(); /// /// Gets the text alignment for the ribbon context text. /// /// Palette value should be applicable to this state. /// Font value. - public override PaletteRelativeAlign GetRibbonContextTextAlign(PaletteState state) => _target.GetRibbonContextTextAlign(state); + public override PaletteRelativeAlign GetRibbonContextTextAlign(PaletteState state) => _target!.GetRibbonContextTextAlign(state); /// /// Gets the font for the ribbon context text. /// /// Palette value should be applicable to this state. /// Font value. - public override Font GetRibbonContextTextFont(PaletteState state) => _target.GetRibbonContextTextFont(state); + public override Font GetRibbonContextTextFont(PaletteState state) => _target!.GetRibbonContextTextFont(state); /// /// Gets the color for the ribbon context text. /// /// Palette value should be applicable to this state. /// Font value. - public override Color GetRibbonContextTextColor(PaletteState state) => _target.GetRibbonContextTextColor(state); + public override Color GetRibbonContextTextColor(PaletteState state) => _target!.GetRibbonContextTextColor(state); /// /// Gets the dark disabled color used for ribbon glyphs. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonDisabledDark(PaletteState state) => _target.GetRibbonDisabledDark(state); + public override Color GetRibbonDisabledDark(PaletteState state) => _target!.GetRibbonDisabledDark(state); /// /// Gets the light disabled color used for ribbon glyphs. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonDisabledLight(PaletteState state) => _target.GetRibbonDisabledLight(state); + public override Color GetRibbonDisabledLight(PaletteState state) => _target!.GetRibbonDisabledLight(state); /// /// Gets the color for the drop arrow light. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonDropArrowLight(PaletteState state) => _target.GetRibbonDropArrowLight(state); + public override Color GetRibbonDropArrowLight(PaletteState state) => _target!.GetRibbonDropArrowLight(state); /// /// Gets the color for the drop arrow dark. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonDropArrowDark(PaletteState state) => _target.GetRibbonDropArrowDark(state); + public override Color GetRibbonDropArrowDark(PaletteState state) => _target!.GetRibbonDropArrowDark(state); /// /// Gets the color for the dialog launcher dark. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonGroupDialogDark(PaletteState state) => _target.GetRibbonGroupDialogDark(state); + public override Color GetRibbonGroupDialogDark(PaletteState state) => _target!.GetRibbonGroupDialogDark(state); /// /// Gets the color for the dialog launcher light. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonGroupDialogLight(PaletteState state) => _target.GetRibbonGroupDialogLight(state); + public override Color GetRibbonGroupDialogLight(PaletteState state) => _target!.GetRibbonGroupDialogLight(state); /// /// Gets the color for the group separator dark. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonGroupSeparatorDark(PaletteState state) => _target.GetRibbonGroupSeparatorDark(state); + public override Color GetRibbonGroupSeparatorDark(PaletteState state) => _target!.GetRibbonGroupSeparatorDark(state); /// /// Gets the color for the group separator light. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonGroupSeparatorLight(PaletteState state) => _target.GetRibbonGroupSeparatorLight(state); + public override Color GetRibbonGroupSeparatorLight(PaletteState state) => _target!.GetRibbonGroupSeparatorLight(state); /// /// Gets the color for the minimize bar dark. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonMinimizeBarDark(PaletteState state) => _target.GetRibbonMinimizeBarDark(state); + public override Color GetRibbonMinimizeBarDark(PaletteState state) => _target!.GetRibbonMinimizeBarDark(state); /// /// Gets the color for the minimize bar light. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonMinimizeBarLight(PaletteState state) => _target.GetRibbonMinimizeBarLight(state); + public override Color GetRibbonMinimizeBarLight(PaletteState state) => _target!.GetRibbonMinimizeBarLight(state); /// /// Gets the color for the tab separator. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonTabSeparatorColor(PaletteState state) => _target.GetRibbonTabSeparatorColor(state); + public override Color GetRibbonTabSeparatorColor(PaletteState state) => _target!.GetRibbonTabSeparatorColor(state); /// /// Gets the color for the tab context separators. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonTabSeparatorContextColor(PaletteState state) => _target.GetRibbonTabSeparatorContextColor(state); + public override Color GetRibbonTabSeparatorContextColor(PaletteState state) => _target!.GetRibbonTabSeparatorContextColor(state); /// /// Gets the font for the ribbon text. /// /// Palette value should be applicable to this state. /// Font value. - public override Font GetRibbonTextFont(PaletteState state) => _target.GetRibbonTextFont(state); + public override Font GetRibbonTextFont(PaletteState state) => _target!.GetRibbonTextFont(state); /// /// Gets the rendering hint for the ribbon font. /// /// Palette value should be applicable to this state. /// PaletteTextHint value. - public override PaletteTextHint GetRibbonTextHint(PaletteState state) => _target.GetRibbonTextHint(state); + public override PaletteTextHint GetRibbonTextHint(PaletteState state) => _target!.GetRibbonTextHint(state); /// /// Gets the color for the extra QAT button dark content color. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonQATButtonDark(PaletteState state) => _target.GetRibbonQATButtonDark(state); + public override Color GetRibbonQATButtonDark(PaletteState state) => _target!.GetRibbonQATButtonDark(state); /// /// Gets the color for the extra QAT button light content color. /// /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonQATButtonLight(PaletteState state) => _target.GetRibbonQATButtonLight(state); + public override Color GetRibbonQATButtonLight(PaletteState state) => _target!.GetRibbonQATButtonLight(state); #endregion @@ -933,7 +933,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// PaletteRibbonBackStyle value. - public override PaletteRibbonColorStyle GetRibbonBackColorStyle(PaletteRibbonBackStyle style, PaletteState state) => _target.GetRibbonBackColorStyle(style, state); + public override PaletteRibbonColorStyle GetRibbonBackColorStyle(PaletteRibbonBackStyle style, PaletteState state) => _target!.GetRibbonBackColorStyle(style, state); /// /// Gets the first background color for the ribbon item. @@ -941,7 +941,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonBackColor1(PaletteRibbonBackStyle style, PaletteState state) => _target.GetRibbonBackColor1(style, state); + public override Color GetRibbonBackColor1(PaletteRibbonBackStyle style, PaletteState state) => _target!.GetRibbonBackColor1(style, state); /// /// Gets the second background color for the ribbon item. @@ -949,7 +949,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonBackColor2(PaletteRibbonBackStyle style, PaletteState state) => _target.GetRibbonBackColor2(style, state); + public override Color GetRibbonBackColor2(PaletteRibbonBackStyle style, PaletteState state) => _target!.GetRibbonBackColor2(style, state); /// /// Gets the third background color for the ribbon item. @@ -957,7 +957,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonBackColor3(PaletteRibbonBackStyle style, PaletteState state) => _target.GetRibbonBackColor3(style, state); + public override Color GetRibbonBackColor3(PaletteRibbonBackStyle style, PaletteState state) => _target!.GetRibbonBackColor3(style, state); /// /// Gets the fourth background color for the ribbon item. @@ -965,7 +965,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonBackColor4(PaletteRibbonBackStyle style, PaletteState state) => _target.GetRibbonBackColor4(style, state); + public override Color GetRibbonBackColor4(PaletteRibbonBackStyle style, PaletteState state) => _target!.GetRibbonBackColor4(style, state); /// /// Gets the fifth background color for the ribbon item. @@ -973,7 +973,7 @@ public virtual PaletteBase Target /// Background style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonBackColor5(PaletteRibbonBackStyle style, PaletteState state) => _target.GetRibbonBackColor5(style, state); + public override Color GetRibbonBackColor5(PaletteRibbonBackStyle style, PaletteState state) => _target!.GetRibbonBackColor5(style, state); #endregion @@ -984,7 +984,7 @@ public virtual PaletteBase Target /// Text style. /// Palette value should be applicable to this state. /// Color value. - public override Color GetRibbonTextColor(PaletteRibbonTextStyle style, PaletteState state) => _target.GetRibbonTextColor(style, state); + public override Color GetRibbonTextColor(PaletteRibbonTextStyle style, PaletteState state) => _target!.GetRibbonTextColor(style, state); #endregion @@ -995,7 +995,7 @@ public virtual PaletteBase Target /// Element for which color is required. /// Palette value should be applicable to this state. /// Color value. - public override Color GetElementColor1(PaletteElement element, PaletteState state) => _target.GetElementColor1(element, state); + public override Color GetElementColor1(PaletteElement element, PaletteState state) => _target!.GetElementColor1(element, state); /// /// Gets the second element color. @@ -1003,7 +1003,7 @@ public virtual PaletteBase Target /// Element for which color is required. /// Palette value should be applicable to this state. /// Color value. - public override Color GetElementColor2(PaletteElement element, PaletteState state) => _target.GetElementColor2(element, state); + public override Color GetElementColor2(PaletteElement element, PaletteState state) => _target!.GetElementColor2(element, state); /// /// Gets the third element color. @@ -1011,7 +1011,7 @@ public virtual PaletteBase Target /// Element for which color is required. /// Palette value should be applicable to this state. /// Color value. - public override Color GetElementColor3(PaletteElement element, PaletteState state) => _target.GetElementColor3(element, state); + public override Color GetElementColor3(PaletteElement element, PaletteState state) => _target!.GetElementColor3(element, state); /// /// Gets the fourth element color. @@ -1019,7 +1019,7 @@ public virtual PaletteBase Target /// Element for which color is required. /// Palette value should be applicable to this state. /// Color value. - public override Color GetElementColor4(PaletteElement element, PaletteState state) => _target.GetElementColor4(element, state); + public override Color GetElementColor4(PaletteElement element, PaletteState state) => _target!.GetElementColor4(element, state); /// /// Gets the fifth element color. @@ -1027,7 +1027,7 @@ public virtual PaletteBase Target /// Element for which color is required. /// Palette value should be applicable to this state. /// Color value. - public override Color GetElementColor5(PaletteElement element, PaletteState state) => _target.GetElementColor5(element, state); + public override Color GetElementColor5(PaletteElement element, PaletteState state) => _target!.GetElementColor5(element, state); #endregion @@ -1036,49 +1036,49 @@ public virtual PaletteBase Target /// Gets the feedback drawing method used. /// /// Feedback enumeration value. - public override PaletteDragFeedback GetDragDropFeedback() => _target.GetDragDropFeedback(); + public override PaletteDragFeedback GetDragDropFeedback() => _target!.GetDragDropFeedback(); /// /// Gets the background color for a solid drag drop area. /// /// Color value. - public override Color GetDragDropSolidBack() => _target.GetDragDropSolidBack(); + public override Color GetDragDropSolidBack() => _target!.GetDragDropSolidBack(); /// /// Gets the border color for a solid drag drop area. /// /// Color value. - public override Color GetDragDropSolidBorder() => _target.GetDragDropSolidBack(); + public override Color GetDragDropSolidBorder() => _target!.GetDragDropSolidBack(); /// /// Gets the opacity of the solid area. /// /// Opacity ranging from 0 to 1. - public override float GetDragDropSolidOpacity() => _target.GetDragDropSolidOpacity(); + public override float GetDragDropSolidOpacity() => _target!.GetDragDropSolidOpacity(); /// /// Gets the background color for the docking indicators area. /// /// Color value. - public override Color GetDragDropDockBack() => _target.GetDragDropDockBack(); + public override Color GetDragDropDockBack() => _target!.GetDragDropDockBack(); /// /// Gets the border color for the docking indicators area. /// /// Color value. - public override Color GetDragDropDockBorder() => _target.GetDragDropDockBorder(); + public override Color GetDragDropDockBorder() => _target!.GetDragDropDockBorder(); /// /// Gets the active color for docking indicators. /// /// Color value. - public override Color GetDragDropDockActive() => _target.GetDragDropDockActive(); + public override Color GetDragDropDockActive() => _target!.GetDragDropDockActive(); /// /// Gets the inactive color for docking indicators. /// /// Color value. - public override Color GetDragDropDockInactive() => _target.GetDragDropDockInactive(); + public override Color GetDragDropDockInactive() => _target!.GetDragDropDockInactive(); #endregion @@ -1087,7 +1087,7 @@ public virtual PaletteBase Target /// /// Gets access to the color table instance. /// - public override KryptonColorTable ColorTable => _target.ColorTable; + public override KryptonColorTable ColorTable => _target!.ColorTable; #endregion diff --git a/Source/Krypton Components/Krypton.Toolkit/Translations/Converters/ToastNotificationIconStrings.cs b/Source/Krypton Components/Krypton.Toolkit/Translations/Converters/ToastNotificationIconStrings.cs new file mode 100644 index 000000000..64e680b7f --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Translations/Converters/ToastNotificationIconStrings.cs @@ -0,0 +1,88 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2023 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + /// Exposes the set of strings used within Krypton and that are localizable. + [TypeConverter(typeof(ExpandableObjectConverter))] + public class ToastNotificationIconStrings : GlobalId + { + #region Identity + + /// Initializes a new instance of the class. + public ToastNotificationIconStrings() + { + Reset(); + } + + #endregion + + #region Public + + [Browsable(false)] + public bool IsDefault => true; + + public string Application { get; set; } + + public string Asterisk { get; set; } + + public string Custom { get; set; } + + public string Error { get; set; } + + public string Exclamation { get; set; } + + public string Hand { get; set; } + + public string Information { get; set; } + + public string None { get; set; } + + public string Ok { get; set; } + + public string Question { get; set; } + + public string Shield { get; set; } + + public string Stop { get; set; } + + public string SystemApplication { get; set; } + + public string SystemAsterisk { get; set; } + + public string SystemError { get; set; } + + public string SystemExclamation { get; set; } + + public string SystemHand { get; set; } + + public string SystemInformation { get; set; } + + public string SystemQuestion { get; set; } + + public string SystemStop { get; set; } + + public string SystemWarning { get; set; } + + public string Warning { get; set; } + + public string WindowsLogo { get; set; } + + #endregion + + #region Implementation + + public void Reset() + { + + } + + #endregion + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Translations/General/CustomToolkitStrings.cs b/Source/Krypton Components/Krypton.Toolkit/Translations/General/CustomToolkitStrings.cs index 05895f819..3310b349f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Translations/General/CustomToolkitStrings.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Translations/General/CustomToolkitStrings.cs @@ -35,6 +35,7 @@ public class CustomToolkitStrings : GlobalId private const string DEFAULT_RESET = @"&Reset"; // Accelerator key - R private const string DEFAULT_SYSTEM_INFORMATION = "S&ystem Information"; private const string DEFAULT_CURRENT_THEME = @"Current Theme"; + private const string DEFAULT_DISMISS = @"D&ismiss"; // Note: The following may not be needed... /*private const string DEFAULT_MORE_DETAILS = "M&ore Details..."; @@ -82,7 +83,8 @@ public CustomToolkitStrings() OkToAll.Equals(DEFAULT_OK_TO_ALL) && Reset.Equals(DEFAULT_RESET) && SystemInformation.Equals(DEFAULT_SYSTEM_INFORMATION) && - CurrentTheme.Equals(DEFAULT_CURRENT_THEME); + CurrentTheme.Equals(DEFAULT_CURRENT_THEME) && + Dismiss.Equals(DEFAULT_DISMISS); /// Resets the values. public void ResetValues() @@ -107,6 +109,7 @@ public void ResetValues() Reset = DEFAULT_RESET; SystemInformation = DEFAULT_SYSTEM_INFORMATION; CurrentTheme = DEFAULT_CURRENT_THEME; + Dismiss = DEFAULT_DISMISS; } /// Gets or sets the collapse string used in expandable footers. @@ -270,6 +273,13 @@ public void ResetValues() [DefaultValue(DEFAULT_CURRENT_THEME)] public string CurrentTheme { get; set; } + /// Gets or sets the dismiss string used for custom situations. + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"Dismiss string used for custom situations.")] + [DefaultValue(DEFAULT_DISMISS)] + public string Dismiss { get; set; } + #endregion } } \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs index 3698814f4..75feedc89 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs @@ -118,20 +118,36 @@ public static Icon LoadIcon(IconType type, Size size) /// The height. public static Bitmap? ScaleImage(Image? image, int width, int height) => ScaleImage(image, new Size(width, height)); - // TODO: Remove, as this is redundant - //public enum IconType - //{ - // Warning = 101, - // Help = 102, - // Error = 103, - // Info = 104, - // Shield = 106 - //} - /// Sets the icon. /// The image. /// The size. public static Image SetIcon(Image image, Size size) => new Bitmap(image, size); + + /// Extracts an icon from a DLL. Code from https://stackoverflow.com/questions/6872957/how-can-i-use-the-images-within-shell32-dll-in-my-c-sharp-project. + /// The file path to ingest. + /// Index of the image. + /// if set to true [large icon]. + /// A specified icon from a chosen DLL file. + public static Icon? ExtractIcon(string filePath, int imageIndex, bool largeIcon = true) + { + if (string.IsNullOrEmpty(filePath)) + { + throw new ArgumentNullException(nameof(filePath)); + } + + IntPtr hIcon; + + if (largeIcon) + { + ImageNativeMethods.ExtractIconEx(filePath, imageIndex, out hIcon, IntPtr.Zero, 1); + } + else + { + ImageNativeMethods.ExtractIconEx(filePath, imageIndex, IntPtr.Zero, out hIcon, 1); + } + + return hIcon != IntPtr.Zero ? Icon.FromHandle(hIcon) : null; + } } #endregion diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/ImageNativeMethods.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/ImageNativeMethods.cs index 02816ce9a..c7a66b709 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/ImageNativeMethods.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/ImageNativeMethods.cs @@ -13,6 +13,8 @@ internal class ImageNativeMethods { private const string USER32 = Libraries.User32; + private const string SHELL32 = Libraries.Shell32; + [DllImport(USER32, SetLastError = true)] [DefaultDllImportSearchPaths(DllImportSearchPath.System32)] public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); @@ -20,5 +22,14 @@ internal class ImageNativeMethods [DllImport(USER32, EntryPoint = "LoadImageW", CharSet = CharSet.Unicode, SetLastError = true)] [DefaultDllImportSearchPaths(DllImportSearchPath.System32)] public static extern IntPtr LoadImage(IntPtr hInt, string lpszName, uint uType, int cxDesired, int cyDesired, uint fuLoad); + + [DllImport(SHELL32, CharSet = CharSet.Unicode)] + [DefaultDllImportSearchPaths(DllImportSearchPath.System32)] + public static extern int ExtractIconEx(string lpszFile, int nIconIndex, out IntPtr phiconLarge, IntPtr phiconSmall, int nIcons); + + + [DllImport(SHELL32, CharSet = CharSet.Unicode)] + [DefaultDllImportSearchPaths(DllImportSearchPath.System32)] + public static extern int ExtractIconEx(string lpszFile, int nIconIndex, IntPtr phiconLarge, out IntPtr phiconSmall, int nIcons); } } \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxButtons.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxButtons.cs deleted file mode 100644 index 7626ab35a..000000000 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxButtons.cs +++ /dev/null @@ -1,54 +0,0 @@ -#region BSD License -/* - * - * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) - * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. - * - */ -#endregion - -namespace Krypton.Toolkit -{ - /// Specifies constants defining which buttons to display on a . - public enum KryptonMessageBoxButtons - { - /// - /// Specifies that the message box contains an OK button. - /// - OK = MessageBoxButtons.OK, - - /// - /// Specifies that the message box contains OK and Cancel buttons. - /// - OKCancel = MessageBoxButtons.OKCancel, - - /// - /// Specifies that the message box contains Abort, Retry, and Ignore buttons. - /// - AbortRetryIgnore = MessageBoxButtons.AbortRetryIgnore, - - /// - /// Specifies that the message box contains Yes, No, and Cancel buttons. - /// - YesNoCancel = MessageBoxButtons.YesNoCancel, - - /// - /// Specifies that the message box contains Yes and No buttons. - /// - YesNo = MessageBoxButtons.YesNo, - - /// - /// Specifies that the message box contains Retry and Cancel buttons. - /// - RetryCancel = MessageBoxButtons.RetryCancel, - - /// - /// Specifies that the message box contains Cancel, Try Again, and Continue buttons. - /// -#if NET60_OR_GREATER - CancelTryContinue = MessageBoxButtons.CancelTryContinue -#else - CancelTryContinue = 0x00000006 -#endif - } -} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxDefaultButton.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxDefaultButton.cs deleted file mode 100644 index dcd4a3726..000000000 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxDefaultButton.cs +++ /dev/null @@ -1,30 +0,0 @@ -#region BSD License -/* - * - * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) - * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. - * - */ -#endregion - -namespace Krypton.Toolkit -{ - /// Specifies constants defining the default button on a . - public enum KryptonMessageBoxDefaultButton - { - /// The first button on the message box is the default button. - Button1 = 0, - - /// The second button on the message box is the default button. - Button2 = 256, - - /// The third button on the message box is the default button. - Button3 = 512, - - /// Specifies that the Help button on the message box should be the default button. - Button4 = 768, - - /// The accelerator button. - Button5 = 1024 - } -} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxIcon.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxIcon.cs deleted file mode 100644 index f9fd49e18..000000000 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxIcon.cs +++ /dev/null @@ -1,78 +0,0 @@ -#region BSD License -/* - * - * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) - * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. - * - */ -#endregion - -namespace Krypton.Toolkit -{ - /// Specifies the icon type for . - public enum KryptonMessageBoxIcon - { - /// Specify no icon. - None = 0, - - /// Specify a hand icon. - Hand = 1, - - /// Specify the system hand icon. - SystemHand = MessageBoxIcon.Hand, - - /// Specify a question icon. - Question = 2, - - /// Specify the system question icon. - SystemQuestion = MessageBoxIcon.Question, - - /// Specify a exclamation icon. - Exclamation = 3, - - /// Specify the system exclamation icon. - SystemExclamation = MessageBoxIcon.Exclamation, - - /// Specify a asterisk icon. - Asterisk = 4, - - /// Specify the system asterisk icon. - SystemAsterisk = MessageBoxIcon.Asterisk, - - /// Specify a stop icon. - Stop = 5, - - /// Specify the system stop icon. - SystemStop = MessageBoxIcon.Stop, - - /// Specify a error icon. - Error = 6, - - /// Specify the system error icon. - SystemError = MessageBoxIcon.Error, - - /// Specify a warning icon. - Warning = 7, - - /// Specify the system warning icon. - SystemWarning = MessageBoxIcon.Warning, - - /// Specify a information icon. - Information = 8, - - /// Specify the system information icon. - SystemInformation = MessageBoxIcon.Information, - - /// Specify a UAC shield icon. - Shield = 9, - - /// Specify a Windows logo icon. - WindowsLogo = 10, - - /// Specify your application icon. - Application = 11, - - /// Specify the default system application icon. See . - SystemApplication = 12 - } -} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkImageValues.cs b/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkImageValues.cs index 1be1cefcb..c08d6ae4e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkImageValues.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkImageValues.cs @@ -7,13 +7,14 @@ */ #endregion +// ReSharper disable InconsistentNaming namespace Krypton.Toolkit { public class CommandLinkImageValues : Storage, IContentValues { #region Static Fields - private static readonly Image DEFAULT_IMAGE = MessageBoxImageResources.GenericQuestion; + private static readonly Image? DEFAULT_IMAGE = /*MessageBoxImageResources.GenericQuestion*/ GraphicsExtensions.ScaleImage(GraphicsExtensions.ExtractIcon(Libraries.Shell32, 16805, true)?.ToBitmap(), 32, 32); private static readonly Image DEFAULT_WINDOWS_11_IMAGE = CommandLinkImageResources.Windows_11_CommandLink_Arrow; @@ -106,7 +107,7 @@ public Color ImageTransparentColor [Category("Visuals")] [Description("The image.")] [RefreshProperties(RefreshProperties.All)] - //[DefaultValue()] + [DefaultValue(typeof(Image), @"DEFAULT_IMAGE")] public Image? Image { get => _image; @@ -121,28 +122,13 @@ public Image? Image } - private bool ShouldSerializeImage() => Image != DEFAULT_WINDOWS_11_IMAGE; + private bool ShouldSerializeImage() => Image != DEFAULT_IMAGE; public void ResetImage() { - //if (OSUtilities.IsWindowsEleven) - //{ - // Image = DEFAULT_WINDOWS_11_IMAGE; - //} - //else if (OSUtilities.IsWindowsTen) - //{ - // Image = DEFAULT_WINDOWS_10_IMAGE; - //} - //else if (OSUtilities.IsWindowsEightPointOne || OSUtilities.IsWindowsEight || OSUtilities.IsWindowsSeven) - //{ - - //} - //else - //{ - // Image = DEFAULT_IMAGE; - //} + Image = DEFAULT_IMAGE; - Image = DEFAULT_WINDOWS_11_IMAGE; + // Image = DEFAULT_WINDOWS_11_IMAGE; } [DefaultValue(UACShieldIconSize.Small), Description(@"")] diff --git a/Source/Krypton Components/Krypton.Toolkit/Values/KryptonInputBoxValues.cs b/Source/Krypton Components/Krypton.Toolkit/Values/KryptonInputBoxValues.cs new file mode 100644 index 000000000..f13fbd2dc --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Values/KryptonInputBoxValues.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Krypton.Toolkit +{ + /// Access Krypton input box settings. + [Category(@"Code")] + [Description(@"Access Krypton input box settings.")] + [TypeConverter(typeof(ExpandableObjectConverter))] + public class KryptonInputBoxValues : Storage + { + public override bool IsDefault => throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/View Base/InternalToastButton.cs b/Source/Krypton Components/Krypton.Toolkit/View Base/InternalToastButton.cs new file mode 100644 index 000000000..3ebfa3241 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/View Base/InternalToastButton.cs @@ -0,0 +1,115 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2023 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + internal class InternalToastButton : KryptonButton + { + #region Instance Fields + + private bool _isActionButton; + + private bool _isDismissButton; + + private VisualToastForm? _owner; + + #endregion + + #region Public + + public bool IsActionButton + { + get => _isActionButton; + + set + { + _isActionButton = value; + + Invalidate(); + } + } + + public bool IsDismissButton + { + get => _isDismissButton; + + set + { + _isDismissButton = value; + + Invalidate(); + } + } + + public VisualToastForm? Owner + { + get => _owner; + + set => _owner = value; + } + + #endregion + + #region Identity + + /// Initializes a new instance of the class. + public InternalToastButton() + { + _isActionButton = false; + + _isDismissButton = false; + + _owner = null; + } + + #endregion + + #region Protected + + protected override void OnPaint(PaintEventArgs? e) + { + if (_isDismissButton) + { + _isActionButton = false; + + if (_owner != null) + { + _owner.AcceptButton = this; + } + } + + base.OnPaint(e); + } + + protected override void OnClick(EventArgs e) + { + if (_isActionButton && _owner != null && _owner.ActionButtonCommand != null) + { + _owner.ActionButtonCommand.PerformExecute(); + } + + if (_isDismissButton) + { + _owner?.Close(); + } + + base.OnClick(e); + } + + #endregion + + #region Public Overrides + + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public override IKryptonCommand? KryptonCommand { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/Source/Krypton Components/TestForm/Form1.Designer.cs b/Source/Krypton Components/TestForm/Form1.Designer.cs index a9e51b39d..64c23a718 100644 --- a/Source/Krypton Components/TestForm/Form1.Designer.cs +++ b/Source/Krypton Components/TestForm/Form1.Designer.cs @@ -31,6 +31,7 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.kryptonPanel1 = new Krypton.Toolkit.KryptonPanel(); + this.kryptonButton10 = new Krypton.Toolkit.KryptonButton(); this.kryptonColorButton1 = new Krypton.Toolkit.KryptonColorButton(); this.kryptonButton9 = new Krypton.Toolkit.KryptonButton(); this.kryptonButton5 = new Krypton.Toolkit.KryptonButton(); @@ -79,6 +80,7 @@ private void InitializeComponent() this.kryptonManager1 = new Krypton.Toolkit.KryptonManager(this.components); this.kryptonCheckSet1 = new Krypton.Toolkit.KryptonCheckSet(this.components); this.kryptonTaskDialog1 = new Krypton.Toolkit.KryptonTaskDialog(); + this.kryptonInputBoxManager1 = new Krypton.Toolkit.KryptonInputBoxManager(); ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).BeginInit(); this.kryptonPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.kryptonThemeComboBox1)).BeginInit(); @@ -87,6 +89,7 @@ private void InitializeComponent() // // kryptonPanel1 // + this.kryptonPanel1.Controls.Add(this.kryptonButton10); this.kryptonPanel1.Controls.Add(this.kryptonColorButton1); this.kryptonPanel1.Controls.Add(this.kryptonButton9); this.kryptonPanel1.Controls.Add(this.kryptonButton5); @@ -122,6 +125,15 @@ private void InitializeComponent() this.kryptonPanel1.Size = new System.Drawing.Size(1483, 926); this.kryptonPanel1.TabIndex = 0; // + // kryptonButton10 + // + this.kryptonButton10.Location = new System.Drawing.Point(15, 446); + this.kryptonButton10.Name = "kryptonButton10"; + this.kryptonButton10.Size = new System.Drawing.Size(183, 25); + this.kryptonButton10.TabIndex = 36; + this.kryptonButton10.Values.Text = "Toast"; + this.kryptonButton10.Click += new System.EventHandler(this.kryptonButton10_Click); + // // kryptonColorButton1 // this.kryptonColorButton1.Location = new System.Drawing.Point(272, 162); @@ -535,7 +547,6 @@ private void InitializeComponent() this.ButtonSpecs.Add(this.buttonSpecAny10); this.ClientSize = new System.Drawing.Size(1483, 926); this.Controls.Add(this.kryptonPanel1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.FormTitleAlign = Krypton.Toolkit.PaletteRelativeAlign.Inherit; this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "Form1"; @@ -601,5 +612,7 @@ private void InitializeComponent() private Krypton.Toolkit.KryptonTaskDialog kryptonTaskDialog1; private Krypton.Toolkit.KryptonButton kryptonButton9; private Krypton.Toolkit.KryptonColorButton kryptonColorButton1; + private Krypton.Toolkit.KryptonButton kryptonButton10; + private Krypton.Toolkit.KryptonInputBoxManager kryptonInputBoxManager1; } } \ No newline at end of file diff --git a/Source/Krypton Components/TestForm/Form1.cs b/Source/Krypton Components/TestForm/Form1.cs index 958dd5357..874059932 100644 --- a/Source/Krypton Components/TestForm/Form1.cs +++ b/Source/Krypton Components/TestForm/Form1.cs @@ -324,5 +324,22 @@ private void kryptonColorButton1_SelectedColorChanged(object sender, ColorEventA { kryptonButton1.Values.DropDownArrowColor = e.Color; } + + private void kryptonButton10_Click(object sender, EventArgs e) + { + KryptonToastData toastData = new KryptonToastData(); + + toastData.CountDownSeconds = 60; + + toastData.NotificationContentText = @"Hello world"; + + toastData.Title = @"Test"; + + toastData.ToastNotificationInputAreaType = KryptonToastNotificationInputAreaType.None; + + //toastData. + + KryptonToast.Show(toastData); + } } } \ No newline at end of file diff --git a/Source/Krypton Components/TestForm/Form1.resx b/Source/Krypton Components/TestForm/Form1.resx index d05c541a9..326ca82ec 100644 --- a/Source/Krypton Components/TestForm/Form1.resx +++ b/Source/Krypton Components/TestForm/Form1.resx @@ -164,4 +164,7 @@ 167, 54 + + 324, 54 + \ No newline at end of file