diff --git a/Documents/Help/Changelog.md b/Documents/Help/Changelog.md index e8cdad19b..2280495f6 100644 --- a/Documents/Help/Changelog.md +++ b/Documents/Help/Changelog.md @@ -6,6 +6,7 @@ * New `KryptonLanguageManager.Strings` is now `KryptonLanguageManager.GeneralToolkitStrings` * New `ShowSplitOption` for `KryptonButton`, allows a krypton/context menu to be shown * Implemented [#1023](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1023), Please remove "sealed" from `KryptonWrapLabel` and `KryptonLinkWrapLabel` +* Resolved [#1020](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1020), Cannot add a `KryptonPage` to a `KryptonNavigator` * Added ability to embed links into the `KryptonMessageBox` content. The new options are:- - `ContentAreaType` - Defines content area type of a `KryptonMessageBox`, default is normal - `LinkLabelCommand` - Specifies a `KryptonCommand` if using the `MessageBoxContentAreaType.LinkLabel` type. diff --git a/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonAutoHiddenGroup.cs b/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonAutoHiddenGroup.cs index a50945822..9c73658ee 100644 --- a/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonAutoHiddenGroup.cs +++ b/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonAutoHiddenGroup.cs @@ -84,7 +84,7 @@ public void StoreAllPages() // Create a list of pages that have not yet store placeholders // ReSharper disable once LoopCanBeConvertedToQuery - foreach(KryptonPage page in Pages) + foreach (KryptonPage page in Pages) { if (page is not KryptonStorePage) { @@ -132,12 +132,15 @@ public void RestorePages(KryptonPage[] pages) foreach (KryptonPage page in pages) { // If a matching page exists and it is not a store placeholder already - KryptonPage? storePage = Pages[page.UniqueName]; - if (storePage is KryptonStorePage) + if (page.UniqueName != null) { - // Replace the existing placeholder with the actual page - Pages.Insert(Pages.IndexOf(storePage), page); - Pages.Remove(storePage); + KryptonPage? storePage = Pages[page.UniqueName]; + if (storePage is KryptonStorePage) + { + // Replace the existing placeholder with the actual page + Pages.Insert(Pages.IndexOf(storePage), page); + Pages.Remove(storePage); + } } } } diff --git a/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonAutoHiddenProxyPage.cs b/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonAutoHiddenProxyPage.cs index 22defe149..581f76353 100644 --- a/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonAutoHiddenProxyPage.cs +++ b/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonAutoHiddenProxyPage.cs @@ -318,7 +318,7 @@ public override bool LastVisibleSet } /// Occurs when an appearance specific page property has changed. - public override event PropertyChangedEventHandler AppearancePropertyChanged + public override event PropertyChangedEventHandler? AppearancePropertyChanged { add { diff --git a/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonAutoHiddenSlidePanel.cs b/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonAutoHiddenSlidePanel.cs index ad39b565f..08339dd7c 100644 --- a/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonAutoHiddenSlidePanel.cs +++ b/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonAutoHiddenSlidePanel.cs @@ -339,7 +339,10 @@ public void SlideOut(KryptonPage? page, KryptonAutoHiddenGroup group, bool selec if (cell == null) { cell = new(); - DockspaceControl.Root.Children.Add(cell); + if (DockspaceControl.Root.Children != null) + { + DockspaceControl.Root.Children.Add(cell); + } } // Replace any existing page with the new one diff --git a/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonDockableWorkspace.cs b/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonDockableWorkspace.cs index 8079f3820..16cd0cf40 100644 --- a/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonDockableWorkspace.cs +++ b/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonDockableWorkspace.cs @@ -103,7 +103,10 @@ private void OnCellCloseAction(object sender, CloseActionEventArgs e) { if (e.Item != null) { - OnPageCloseClicked(new(e.Item.UniqueName)); + if (e.Item.UniqueName != null) + { + OnPageCloseClicked(new(e.Item.UniqueName)); + } } } #endregion diff --git a/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonFloatingWindow.cs b/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonFloatingWindow.cs index 5764a02f0..6e99f437e 100644 --- a/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonFloatingWindow.cs +++ b/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonFloatingWindow.cs @@ -58,11 +58,14 @@ public KryptonFloatingWindow(Form owner, KryptonFloatspace? floatspace, bool use // Hook into floatspace events and add as the content of the floating window FloatspaceControl = floatspace; - FloatspaceControl.CellCountChanged += OnFloatspaceCellCountChanged!; - FloatspaceControl.CellVisibleCountChanged += OnFloatspaceCellVisibleCountChanged!; - FloatspaceControl.WorkspaceCellAdding += OnFloatspaceCellAdding!; - FloatspaceControl.WorkspaceCellRemoved += OnFloatspaceCellRemoved!; - Controls.Add(FloatspaceControl); + if (FloatspaceControl != null) + { + FloatspaceControl.CellCountChanged += OnFloatspaceCellCountChanged!; + FloatspaceControl.CellVisibleCountChanged += OnFloatspaceCellVisibleCountChanged!; + FloatspaceControl.WorkspaceCellAdding += OnFloatspaceCellAdding!; + FloatspaceControl.WorkspaceCellRemoved += OnFloatspaceCellRemoved!; + Controls.Add(FloatspaceControl); + } } #endregion @@ -215,7 +218,7 @@ protected override void OnDeactivate(EventArgs e) private void OnFloatspaceCellCountChanged(object sender, EventArgs e) { // When all the cells (and so pages) have been removed we kill ourself - if (FloatspaceControl.CellCount == 0) + if (FloatspaceControl != null && FloatspaceControl.CellCount == 0) { FloatspaceControl.Dispose(); } @@ -247,49 +250,61 @@ private void OnFloatspaceCellRemoved(object sender, WorkspaceCellEventArgs e) private void OnLayoutWorkspace(object sender, EventArgs e) { - FloatspaceControl.PerformNeedPaint(true); + if (FloatspaceControl != null) + { + FloatspaceControl.PerformNeedPaint(true); + } } private void UpdateCellSettings() { - KryptonWorkspaceCell? cell = FloatspaceControl.FirstVisibleCell(); - if (cell != null) + if (FloatspaceControl != null) { - // If there is only a single cell inside the floating window - if (FloatspaceControl.CellVisibleCount <= 1) + KryptonWorkspaceCell? cell = FloatspaceControl.FirstVisibleCell(); + if (cell != null) { - // Cell display mode depends on the number of tabs in the cell - cell.NavigatorMode = cell.Pages.VisibleCount == 1 ? NavigatorMode.HeaderGroup : NavigatorMode.HeaderGroupTab; - } - else - { - do + // If there is only a single cell inside the floating window + if (FloatspaceControl.CellVisibleCount <= 1) + { + // Cell display mode depends on the number of tabs in the cell + cell.NavigatorMode = cell.Pages.VisibleCount == 1 ? NavigatorMode.HeaderGroup : NavigatorMode.HeaderGroupTab; + } + else { - // With multiple cells we always need the tabs showing - cell.NavigatorMode = NavigatorMode.HeaderGroupTab; - cell = FloatspaceControl.NextVisibleCell(cell); + do + { + // With multiple cells we always need the tabs showing + cell.NavigatorMode = NavigatorMode.HeaderGroupTab; + cell = FloatspaceControl.NextVisibleCell(cell); + } + while (cell != null); } - while (cell != null); } } // Only show the floating window if there is a visible cell - Visible = (FloatspaceControl.CellVisibleCount > 0); + if (FloatspaceControl != null) + { + Visible = (FloatspaceControl.CellVisibleCount > 0); + } } private IReadOnlyList VisibleCloseableUniqueNames() { var uniqueNames = new List(); - KryptonWorkspaceCell? cell = FloatspaceControl.FirstVisibleCell(); - while (cell != null) + if (FloatspaceControl != null) { - // Create a list of all the visible page names in the floatspace that are allowed to be closed - uniqueNames.AddRange(from page in cell.Pages - where page.LastVisibleSet - && page.AreFlagsSet(KryptonPageFlags.DockingAllowClose) - select page.UniqueName); + KryptonWorkspaceCell? cell = FloatspaceControl.FirstVisibleCell(); + while (cell != null) + { + // Create a list of all the visible page names in the floatspace that are allowed to be closed + uniqueNames.AddRange(from page in cell.Pages + where page.LastVisibleSet + && page.AreFlagsSet(KryptonPageFlags.DockingAllowClose) + select page.UniqueName); - cell = FloatspaceControl.NextVisibleCell(cell); + cell = FloatspaceControl.NextVisibleCell(cell); + } } return uniqueNames; diff --git a/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonSpace.cs b/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonSpace.cs index 9abe4907d..b99cbc1ea 100644 --- a/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonSpace.cs +++ b/Source/Krypton Components/Krypton.Docking/Control Docking/KryptonSpace.cs @@ -296,7 +296,8 @@ public override void WritePageElement(XmlWriter xmlWriter, KryptonPage page) page = args.Page; // Add recreated page to the looking dictionary - if ((page != null) + if (page.UniqueName != null + && (page != null) && !existingPages.ContainsKey(page.UniqueName)) { existingPages.Add(page.UniqueName, page); diff --git a/Source/Krypton Components/Krypton.Docking/Elements Impl/KryptonDockingAutoHiddenGroup.cs b/Source/Krypton Components/Krypton.Docking/Elements Impl/KryptonDockingAutoHiddenGroup.cs index 9efcc6043..d7ba6afc3 100644 --- a/Source/Krypton Components/Krypton.Docking/Elements Impl/KryptonDockingAutoHiddenGroup.cs +++ b/Source/Krypton Components/Krypton.Docking/Elements Impl/KryptonDockingAutoHiddenGroup.cs @@ -544,8 +544,8 @@ protected override void LoadChildDockingElement(XmlReader xmlReader, // Get the unique name of the page string uniqueName = xmlReader.GetAttribute(@"UN") ?? string.Empty; - string boolStore = xmlReader.GetAttribute(@"S") ?? string.Empty; - string boolVisible = xmlReader.GetAttribute(@"V") ?? string.Empty; + string? boolStore = xmlReader.GetAttribute(@"S") ?? string.Empty; + string? boolVisible = xmlReader.GetAttribute(@"V") ?? string.Empty; KryptonPage? page; diff --git a/Source/Krypton Components/Krypton.Navigator/Controls Navigator/KryptonNavigator.cs b/Source/Krypton Components/Krypton.Navigator/Controls Navigator/KryptonNavigator.cs index 59691c3cd..f3332f960 100644 --- a/Source/Krypton Components/Krypton.Navigator/Controls Navigator/KryptonNavigator.cs +++ b/Source/Krypton Components/Krypton.Navigator/Controls Navigator/KryptonNavigator.cs @@ -66,198 +66,198 @@ public class KryptonNavigator : VisualSimple, /// [Category(@"Navigator Selection")] [Description(@"Occurs when the SelectedPage property is changed.")] - public event EventHandler SelectedPageChanged; + public event EventHandler? SelectedPageChanged; /// /// Occurs before a page is selected. /// [Category(@"Navigator Selection")] [Description(@"Occurs before a page is selected.")] - public event EventHandler Selecting; + public event EventHandler? Selecting; /// /// Occurs after a page is selected. /// [Category(@"Navigator Selection")] [Description(@"Occurs after a page is selected.")] - public event EventHandler Selected; + public event EventHandler? Selected; /// /// Occurs before a page is deselected. /// [Category(@"Navigator Selection")] [Description(@"Occurs before a page is deselected.")] - public event EventHandler Deselecting; + public event EventHandler? Deselecting; /// /// Occurs after a page is deselected. /// [Category(@"Navigator Selection")] [Description(@"Occurs after a page is deselected.")] - public event EventHandler Deselected; + public event EventHandler? Deselected; /// /// Occurs when the previous action occurs. /// [Category(@"Navigator Actions")] [Description(@"Occurs when the previous action occurs.")] - public event EventHandler PreviousAction; + public event EventHandler? PreviousAction; /// /// Occurs when the next action occurs. /// [Category(@"Navigator Actions")] [Description(@"Occurs when the next action occurs.")] - public event EventHandler NextAction; + public event EventHandler? NextAction; /// /// Occurs when the context action occurs. /// [Category(@"Navigator Actions")] [Description(@"Occurs when the context action occurs.")] - public event EventHandler ContextAction; + public event EventHandler? ContextAction; /// /// Occurs when the close action occurs. /// [Category(@"Navigator Actions")] [Description(@"Occurs when the close action occurs.")] - public event EventHandler CloseAction; + public event EventHandler? CloseAction; /// /// Occurs when the context action occurs. /// [Category(@"Navigator")] [Description(@"Occurs when the drop down button is clicked in Outlook mode.")] - public event EventHandler OutlookDropDown; + public event EventHandler? OutlookDropDown; /// /// Occurs when a page is about to be shown as a popup. /// [Category(@"Navigator")] [Description(@"Occurs when a page is about to be shown as a popup.")] - public event EventHandler DisplayPopupPage; + public event EventHandler? DisplayPopupPage; /// /// Occurs when a page is about to be shown as a popup. /// [Category(@"Navigator")] [Description(@"Occurs when you right click a page header and requests a context menu for display.")] - public event EventHandler ShowContextMenu; + public event EventHandler? ShowContextMenu; /// /// Occurs after the number of pages has changed. /// [Category(@"Navigator")] [Description(@"Occurs after the number of pages has changed.")] - public event EventHandler TabCountChanged; + public event EventHandler? TabCountChanged; /// /// Occurs after the number of visible pages has changed. /// [Category(@"Navigator")] [Description(@"Occurs after the number of visible pages has changed.")] - public event EventHandler TabVisibleCountChanged; + public event EventHandler? TabVisibleCountChanged; /// /// Occurs when the mouse clicks a page tab. /// [Category(@"Navigator")] [Description(@"Occurs when the mouse clicks a page tab.")] - public event EventHandler TabClicked; + public event EventHandler? TabClicked; /// /// Occurs when the mouse double clicks a page tab. /// [Category(@"Navigator")] [Description(@"Occurs when the mouse double clicks a page tab.")] - public event EventHandler TabDoubleClicked; + public event EventHandler? TabDoubleClicked; /// /// Occurs when the left mouse clicks the primary header. /// [Category(@"Navigator")] [Description(@"Occurs when the left mouse clicks the primary header.")] - public event EventHandler PrimaryHeaderLeftClicked; + public event EventHandler? PrimaryHeaderLeftClicked; /// /// Occurs when the right mouse clicks the primary header. /// [Category(@"Navigator")] [Description(@"Occurs when the right mouse clicks the primary header.")] - public event EventHandler PrimaryHeaderRightClicked; + public event EventHandler? PrimaryHeaderRightClicked; /// /// Occurs when the mouse double clicks the primary header. /// [Category(@"Navigator")] [Description(@"Occurs when the mouse double clicks the primary header.")] - public event EventHandler PrimaryHeaderDoubleClicked; + public event EventHandler? PrimaryHeaderDoubleClicked; /// /// Occurs just before a page is reordered. /// [Category(@"Navigator")] [Description(@"Occurs just before a page is reordered.")] - public event EventHandler BeforePageReorder; + public event EventHandler? BeforePageReorder; /// /// Occurs just before a page drag operation is started. /// [Category(@"Navigator")] [Description(@"Occurs just before a page drag operation is started.")] - public event EventHandler BeforePageDrag; + public event EventHandler? BeforePageDrag; /// /// Occurs after a page drag operation has finished/aborted. /// [Category(@"Navigator")] [Description(@"Occurs after a page drag operation has finished/aborted.")] - public event EventHandler AfterPageDrag; + public event EventHandler? AfterPageDrag; /// /// Occurs when a page is being dropped. /// [Category(@"Navigator")] [Description(@"Occurs when a page is being dropped.")] - public event EventHandler PageDrop; + public event EventHandler? PageDrop; /// /// Occurs when control tabbing is starting. /// [Category(@"Navigator")] [Description(@"Occurs when control tabbing is starting.")] - public event EventHandler CtrlTabStart; + public event EventHandler? CtrlTabStart; /// /// Occurs when control tabbing is about to wrap around pages. /// [Category(@"Navigator")] [Description(@"Occurs when control tabbing is about to wrap around pages.")] - public event EventHandler CtrlTabWrap; + public event EventHandler? CtrlTabWrap; /// /// Occurs when the mouse starts hovering over a tab. /// [Category(@"Navigator")] [Description(@"Occurs when the mouse starts hovering over a tab.")] - public event EventHandler TabMouseHoverStart; + public event EventHandler? TabMouseHoverStart; /// /// Occurs when mouse hovering over a tab ends. /// [Category(@"Navigator")] [Description(@"Occurs when mouse hovering over a tab ends.")] - public event EventHandler TabMouseHoverEnd; + public event EventHandler? TabMouseHoverEnd; /// /// Occurs when the user moves a tab to a new indexed position. /// [Category(@"Navigator")] [Description(@"Occurs when the user moves a tab to a new indexed position.")] - public event EventHandler TabMoved; + public event EventHandler? TabMoved; - internal event PropertyChangedEventHandler ViewBuilderPropertyChanged; + internal event PropertyChangedEventHandler? ViewBuilderPropertyChanged; #endregion #region Identity @@ -1423,52 +1423,96 @@ protected override void UpdateGlobalEvents(bool attach) /// /// A KryptonPageCancelEventArgs containing event details. protected virtual void OnDeselecting(KryptonPageCancelEventArgs e) - => Deselecting(this, e); + { + if (Deselecting != null) + { + Deselecting(this, e); + } + } /// /// Raises the Selecting event. /// /// A KryptonPageCancelEventArgs containing event details. protected virtual void OnSelecting(KryptonPageCancelEventArgs e) - => Selecting(this, e); + { + if (Selecting != null) + { + Selecting(this, e); + } + } /// /// Raises the Deselected event. /// /// A KryptonPageEventArgs containing event details. protected virtual void OnDeselected(KryptonPageEventArgs e) - => Deselected(this, e); + { + if (Deselected != null) + { + Deselected(this, e); + } + } /// /// Raises the Selected event. /// /// A KryptonPageEventArgs containing event details. protected virtual void OnSelected(KryptonPageEventArgs e) - => Selected(this, e); + { + if (Selected != null) + { + Selected(this, e); + } + } /// /// Raises the BeforePageReorder event. /// /// A PageDragCancelEventArgs containing event details. - protected internal virtual void OnBeforePageReorder(PageReorderEventArgs de) => BeforePageReorder(this, de); + protected internal virtual void OnBeforePageReorder(PageReorderEventArgs de) + { + if (BeforePageReorder != null) + { + BeforePageReorder(this, de); + } + } /// /// Raises the BeforePageDrag event. /// /// A PageDragCancelEventArgs containing event details. - protected virtual void OnBeforePageDrag(PageDragCancelEventArgs de) => BeforePageDrag(this, de); + protected virtual void OnBeforePageDrag(PageDragCancelEventArgs de) + { + if (BeforePageDrag != null) + { + BeforePageDrag(this, de); + } + } /// /// Raises the AfterPageDrag event. /// /// A EventArgs containing event details. - protected virtual void OnAfterPageDrag(PageDragEndEventArgs e) => AfterPageDrag(this, e); + protected virtual void OnAfterPageDrag(PageDragEndEventArgs e) + { + if (AfterPageDrag != null) + { + AfterPageDrag(this, e); + } + } /// /// Raises the PageDrop event. /// /// A v containing event details. - protected internal virtual void OnPageDrop(PageDropEventArgs e) => PageDrop(this, e); + protected internal virtual void OnPageDrop(PageDropEventArgs e) + { + if (PageDrop != null) + { + PageDrop(this, e); + } + } /// /// Raises the SelectedPageChanged event. @@ -1514,7 +1558,10 @@ protected virtual void OnSelectedPageChanged(EventArgs e) PerformLayout(); } - SelectedPageChanged(this, e); + if (SelectedPageChanged != null) + { + SelectedPageChanged(this, e); + } } } @@ -1536,7 +1583,10 @@ protected virtual DirectionButtonAction OnPreviousAction() SelectedIndex, Button.PreviousButtonAction); - PreviousAction(this, e); + if (PreviousAction != null) + { + PreviousAction(this, e); + } // Return the actual action performed dba = e.Action; @@ -1570,7 +1620,10 @@ protected virtual DirectionButtonAction OnNextAction() SelectedIndex, Button.NextButtonAction); - NextAction(this, e); + if (NextAction != null) + { + NextAction(this, e); + } // Return the actual action performed dba = e.Action; @@ -1589,9 +1642,13 @@ protected virtual DirectionButtonAction OnNextAction() /// /// Raises and processes the ContextAction event. /// - protected virtual void OnContextAction() + protected virtual void OnContextAction(/*ContextActionEventArgs e*/) { // Ask the context button spec to fire and perform default action + //if (ContextAction != null) + //{ + // ContextAction(this, e); + //} } /// @@ -1599,7 +1656,12 @@ protected virtual void OnContextAction() /// /// An CloseActionEventArgs containing the event args. protected virtual void OnCloseAction(CloseActionEventArgs e) - => CloseAction(this, e); + { + if (CloseAction != null) + { + CloseAction(this, e); + } + } /// /// Should the OnInitialized call perform layout. @@ -1630,7 +1692,10 @@ protected virtual CloseButtonAction OnCloseAction(KryptonPage? page) Pages.IndexOf(page), Button.CloseButtonAction); - CloseAction(this, e); + if (CloseAction != null) + { + CloseAction(this, e); + } // Return the action we processed cba = e.Action; @@ -1688,97 +1753,193 @@ protected virtual CloseButtonAction OnCloseAction(KryptonPage? page) /// Raises the TabCountChanged event. /// /// An EventArgs containing the event args. - protected virtual void OnTabCountChanged(EventArgs e) => TabCountChanged(this, e); + protected virtual void OnTabCountChanged(EventArgs e) + { + if (TabCountChanged != null) + { + TabCountChanged(this, e); + } + } /// /// Raises the TabVisibleCountChanged event. /// /// An EventArgs containing the event args. - protected internal virtual void OnTabVisibleCountChanged(EventArgs e) => TabVisibleCountChanged(this, e); + protected internal virtual void OnTabVisibleCountChanged(EventArgs e) + { + if (TabVisibleCountChanged != null) + { + TabVisibleCountChanged(this, e); + } + } /// /// Raises the TabClicked event. /// /// An KryptonPageEventArgs containing the event args. - protected internal virtual void OnTabClicked(KryptonPageEventArgs e) => TabClicked(this, e); + protected internal virtual void OnTabClicked(KryptonPageEventArgs e) + { + if (TabClicked != null) + { + TabClicked(this, e); + } + } /// /// Raises the TabDoubleClicked event. /// /// An KryptonPageEventArgs containing the event args. - protected internal virtual void OnTabDoubleClicked(KryptonPageEventArgs e) => TabDoubleClicked(this, e); + protected internal virtual void OnTabDoubleClicked(KryptonPageEventArgs e) + { + if (TabDoubleClicked != null) + { + TabDoubleClicked(this, e); + } + } /// /// Raises the PrimaryHeaderLeftClicked event. /// /// An EventArgs containing the event args. - protected internal virtual void OnPrimaryHeaderLeftClicked(EventArgs e) => PrimaryHeaderLeftClicked(this, e); + protected internal virtual void OnPrimaryHeaderLeftClicked(EventArgs e) + { + if (PrimaryHeaderLeftClicked != null) + { + PrimaryHeaderLeftClicked(this, e); + } + } /// /// Raises the PrimaryHeaderRightClicked event. /// /// An EventArgs containing the event args. - protected internal virtual void OnPrimaryHeaderRightClicked(EventArgs e) => PrimaryHeaderRightClicked(this, e); + protected internal virtual void OnPrimaryHeaderRightClicked(EventArgs e) + { + if (PrimaryHeaderRightClicked != null) + { + PrimaryHeaderRightClicked(this, e); + } + } /// /// Raises the PrimaryHeaderDoubleClicked event. /// /// An EventArgs containing the event args. - protected internal virtual void OnPrimaryHeaderDoubleClicked(EventArgs e) => PrimaryHeaderDoubleClicked(this, e); + protected internal virtual void OnPrimaryHeaderDoubleClicked(EventArgs e) + { + if (PrimaryHeaderDoubleClicked != null) + { + PrimaryHeaderDoubleClicked(this, e); + } + } /// /// Raises the OutlookDropDown event. /// /// Context menu about to be Displayed. - protected internal virtual void OnOutlookDropDown(KryptonContextMenu kcm) => OutlookDropDown(this, new KryptonContextMenuEventArgs(SelectedPage, SelectedIndex, kcm)); + protected internal virtual void OnOutlookDropDown(KryptonContextMenu kcm) + { + if (OutlookDropDown != null) + { + OutlookDropDown(this, new KryptonContextMenuEventArgs(SelectedPage, SelectedIndex, kcm)); + } + } /// /// Raises the DisplayPopupPage event. /// /// A PopupPageEventArgs containing event data. - protected internal virtual void OnDisplayPopupPage(PopupPageEventArgs e) => DisplayPopupPage(this, e); + protected internal virtual void OnDisplayPopupPage(PopupPageEventArgs e) + { + if (DisplayPopupPage != null) + { + DisplayPopupPage(this, e); + } + } /// /// Raises the ShowContextMenu event. /// /// A ShowContextMenuArgs containing event data. - protected internal virtual void OnShowContextMenu(ShowContextMenuArgs e) => ShowContextMenu(this, e); + protected internal virtual void OnShowContextMenu(ShowContextMenuArgs e) + { + if (ShowContextMenu != null) + { + ShowContextMenu(this, e); + } + } /// /// Raises the CtrlTabStart event. /// /// An CtrlTabCancelEventArgs containing event details. - protected internal virtual void OnCtrlTabStart(CtrlTabCancelEventArgs e) => CtrlTabStart(this, e); + protected internal virtual void OnCtrlTabStart(CtrlTabCancelEventArgs e) + { + if (CtrlTabStart != null) + { + CtrlTabStart(this, e); + } + } /// /// Raises the CtrlTabWrap event. /// /// An CtrlTabCancelEventArgs containing event details. - protected internal virtual void OnCtrlTabWrap(CtrlTabCancelEventArgs e) => CtrlTabWrap(this, e); + protected internal virtual void OnCtrlTabWrap(CtrlTabCancelEventArgs e) + { + if (CtrlTabWrap != null) + { + CtrlTabWrap(this, e); + } + } /// /// Raises the TabMouseHoverStart event. /// /// An KryptonPageEventArgs containing event details. - protected virtual void OnTabMouseHoverStart(KryptonPageEventArgs e) => TabMouseHoverStart(this, e); + protected virtual void OnTabMouseHoverStart(KryptonPageEventArgs e) + { + if (TabMouseHoverStart != null) + { + TabMouseHoverStart(this, e); + } + } /// /// Raises the TabMouseHoverEnd event. /// /// An EventArgs containing event details. - protected virtual void OnTabMouseHoverEnd(EventArgs e) => TabMouseHoverEnd(this, e); + protected virtual void OnTabMouseHoverEnd(EventArgs e) + { + if (TabMouseHoverEnd != null) + { + TabMouseHoverEnd(this, e); + } + } /// /// Raises the TabMoved event. /// /// An TabMovedEventArgs containing event details. - protected internal virtual void OnTabMoved(TabMovedEventArgs e) => TabMoved(this, e); + protected internal virtual void OnTabMoved(TabMovedEventArgs e) + { + if (TabMoved != null) + { + TabMoved(this, e); + } + } /// /// Raises the ViewBuilderPropertyChanged event. /// /// Name of the property that has changed. - protected internal virtual void OnViewBuilderPropertyChanged(string propertyName) => ViewBuilderPropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + protected internal virtual void OnViewBuilderPropertyChanged(string propertyName) + { + if (ViewBuilderPropertyChanged != null) + { + ViewBuilderPropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } #endregion @@ -1928,12 +2089,12 @@ internal bool NextActionValid return null; } - internal KryptonPage? PreviousActionPage([DisallowNull] KryptonPage page) + internal KryptonPage? PreviousActionPage(KryptonPage page) { Debug.Assert(page != null); // Get the index of the page - var pos = Pages.IndexOf(page!); + var pos = Pages.IndexOf(page); // Search backwards towards start of pages collection for (var i = pos - 1; i >= 0; i--) @@ -1948,12 +2109,12 @@ internal bool NextActionValid return null; } - internal KryptonPage? NextActionPage([DisallowNull] KryptonPage page) + internal KryptonPage? NextActionPage(KryptonPage page) { Debug.Assert(page != null); // Get the index of the page - var pos = Pages.IndexOf(page!); + var pos = Pages.IndexOf(page); // Search towards end of pages collection for (var i = pos + 1; i < Pages.Count; i++) @@ -1980,9 +2141,9 @@ internal bool NextActionValid return position; } - internal void ShowPopupPage([DisallowNull] KryptonPage? page, - [DisallowNull] ViewBase? relative, - EventHandler finishDelegate) + internal void ShowPopupPage(KryptonPage? page, + ViewBase? relative, + EventHandler? finishDelegate) { Debug.Assert(page != null); Debug.Assert(relative != null); @@ -2025,7 +2186,10 @@ internal void ShowPopupPage([DisallowNull] KryptonPage? page, if (!delayDelegate) { - finishDelegate(this, EventArgs.Empty); + if (finishDelegate != null) + { + finishDelegate(this, EventArgs.Empty); + } } } @@ -2847,7 +3011,10 @@ private void OnOpeningContextMenu(object sender, CancelEventArgs e) Button.ContextButtonAction, contextMenu); - ContextAction(this, cae); + if (ContextAction != null) + { + ContextAction(this, cae); + } // Process the requested action switch (cae.Action) diff --git a/Source/Krypton Components/Krypton.Navigator/Navigator/KryptonNavigatorDesigner.cs b/Source/Krypton Components/Krypton.Navigator/Navigator/KryptonNavigatorDesigner.cs index 830927822..364ab4ce3 100644 --- a/Source/Krypton Components/Krypton.Navigator/Navigator/KryptonNavigatorDesigner.cs +++ b/Source/Krypton Components/Krypton.Navigator/Navigator/KryptonNavigatorDesigner.cs @@ -465,10 +465,10 @@ private void OnRemovePage(object sender, EventArgs e) private void OnClearPages(object sender, EventArgs e) { - if (MessageBox.Show(@"Are you sure that all pages should be removed?", + if (KryptonMessageBox.Show(@"Are you sure that all pages should be removed?", @"Clear Pages", - MessageBoxButtons.YesNo, - MessageBoxIcon.Warning) == DialogResult.Yes) + KryptonMessageBoxButtons.YesNo, + KryptonMessageBoxIcon.Warning) == DialogResult.Yes) { // Use a transaction to support undo/redo actions DesignerTransaction transaction = _designerHost.CreateTransaction(@"KryptonNavigator RemovePage"); diff --git a/Source/Krypton Components/Krypton.Navigator/Page/KryptonPage.cs b/Source/Krypton Components/Krypton.Navigator/Page/KryptonPage.cs index b6ab13d45..48f72264e 100644 --- a/Source/Krypton Components/Krypton.Navigator/Page/KryptonPage.cs +++ b/Source/Krypton Components/Krypton.Navigator/Page/KryptonPage.cs @@ -68,7 +68,7 @@ public class KryptonPage : VisualPanel /// [Category(@"Page")] [Description(@"Occurs when the control is loaded.")] - public event EventHandler Load; + public event EventHandler? Load; /// /// Occurs when an appearance specific page property has changed. @@ -76,7 +76,7 @@ public class KryptonPage : VisualPanel [Category(@"Page")] [Description(@"Occurs when an appearance specific page property has changed.")] #pragma warning disable CA1070 // Do not declare event fields as virtual - public virtual event PropertyChangedEventHandler AppearancePropertyChanged; + public virtual event PropertyChangedEventHandler? AppearancePropertyChanged; #pragma warning restore CA1070 // Do not declare event fields as virtual /// @@ -84,14 +84,14 @@ public class KryptonPage : VisualPanel /// [Category(@"Page")] [Description(@"Occurs when the flags have changed.")] - public event KryptonPageFlagsEventHandler FlagsChanged; + public event KryptonPageFlagsEventHandler? FlagsChanged; /// /// Occurs when the AutoHiddenSlideSize property has changed. /// [Category(@"Page")] [Description(@"Occurs when the auto hidden slide size have changed.")] - public event EventHandler AutoHiddenSlideSizeChanged; + public event EventHandler? AutoHiddenSlideSizeChanged; /// /// Occurs when the value of the Dock property changes. @@ -99,7 +99,7 @@ public class KryptonPage : VisualPanel [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public new event EventHandler DockChanged; + public new event EventHandler? DockChanged; /// /// Occurs when the value of the Location property changes. @@ -107,7 +107,7 @@ public class KryptonPage : VisualPanel [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public new event EventHandler LocationChanged; + public new event EventHandler? LocationChanged; /// /// Occurs when the value of the TabIndex property changes. @@ -115,7 +115,7 @@ public class KryptonPage : VisualPanel [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public new event EventHandler TabIndexChanged; + public new event EventHandler? TabIndexChanged; /// /// Occurs when the value of the TabStop property changes. @@ -123,7 +123,7 @@ public class KryptonPage : VisualPanel [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public new event EventHandler TabStopChanged; + public new event EventHandler? TabStopChanged; #endregion #region Identity @@ -1432,7 +1432,10 @@ protected override void OnEnabledChanged(EventArgs e) /// An EventArgs containing the event data. protected override void OnDockChanged(EventArgs e) { - DockChanged.Invoke(this, e); + if (DockChanged != null) + { + DockChanged.Invoke(this, e); + } } /// @@ -1441,7 +1444,10 @@ protected override void OnDockChanged(EventArgs e) /// An EventArgs containing the event data. protected override void OnLocationChanged(EventArgs e) { - LocationChanged.Invoke(this, e); + if (LocationChanged != null) + { + LocationChanged.Invoke(this, e); + } } /// @@ -1450,7 +1456,10 @@ protected override void OnLocationChanged(EventArgs e) /// An EventArgs containing the event data. protected override void OnTabIndexChanged(EventArgs e) { - TabIndexChanged.Invoke(this, e); + if (TabIndexChanged != null) + { + TabIndexChanged.Invoke(this, e); + } } /// diff --git a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGalleryItem.cs b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGalleryItem.cs index 22e5c7433..8902e2dce 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGalleryItem.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Draw/ViewDrawRibbonGalleryItem.cs @@ -40,7 +40,7 @@ public ViewDrawRibbonGalleryItem(KryptonGallery gallery, IPaletteTriple palette, ViewLayoutRibbonGalleryItems layout, NeedPaintHandler needPaint) - : base(palette, palette, palette, palette, + : base(palette, palette, palette, palette, null, null, VisualOrientation.Top, false) { _gallery = gallery; @@ -115,7 +115,7 @@ public void Untrack() /// public ImageList? ImageList { - set + set { if (_imageList != value) { @@ -137,7 +137,7 @@ public ImageList? ImageList /// public int ImageIndex { - set + set { if (_imageIndex != value) { @@ -166,7 +166,7 @@ public override void Render([DisallowNull] RenderContext context) PaletteState tempState = ElementState; if (_gallery.TrackingIndex == _imageIndex) { - switch(tempState) + switch (tempState) { case PaletteState.Normal: ElementState = PaletteState.Tracking; @@ -191,11 +191,11 @@ public override void Render([DisallowNull] RenderContext context) /// Image value. public virtual Image? GetImage(PaletteState state) { - // Cache image so we do not copy it every time it is requested - if ((_image == null) && (_imageList != null) && (_imageIndex >= 0)) - { - _image = _imageList.Images[_imageIndex]; - } + // Cache image so we do not copy it every time it is requested + if ((_image == null) && (_imageList != null) && (_imageIndex >= 0)) + { + _image = _imageList.Images[_imageIndex]; + } return _image; } diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupCluster.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupCluster.cs index 1ff9dff5e..c7ac4801e 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupCluster.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupCluster.cs @@ -30,17 +30,17 @@ private class ViewToSize : Dictionary { } #region Instance Fields private readonly KryptonRibbon _ribbon; private readonly KryptonRibbonGroupCluster _ribbonCluster; - private ViewDrawRibbonDesignCluster _viewAddItem; + private ViewDrawRibbonDesignCluster? _viewAddItem; private readonly ViewDrawRibbonGroupClusterSeparator _startSep; private readonly ViewDrawRibbonGroupClusterSeparator _endSep; private readonly PaletteBorderEdge _paletteBorderEdge; - private PaletteRibbonShape _lastShape; - private readonly NeedPaintHandler _needPaint; + private PaletteRibbonShape? _lastShape; + private readonly NeedPaintHandler? _needPaint; private ItemToView _itemToView; private ViewToEdge _viewToEdge; private readonly ViewToSize _viewToSizeMedium; private readonly ViewToSize _viewToSizeSmall; - private GroupItemSize _currentSize; + private GroupItemSize? _currentSize; private bool _startSepVisible; private bool _endSepVisible; #endregion @@ -93,7 +93,7 @@ public ViewLayoutRibbonGroupCluster([DisallowNull] KryptonRibbon ribbon, // At design time we want to track the mouse and show feedback if (_ribbon.InDesignMode) { - ViewHightlightController controller = new(this, needPaint); + ViewHightlightController? controller = new(this, needPaint); controller.ContextClick += OnContextClick; MouseController = controller; } @@ -131,7 +131,7 @@ protected override void Dispose(bool disposing) /// ViewBase of item; otherwise false. public ViewBase? GetFirstFocusItem() { - ViewBase view = null; + ViewBase? view = null; // Scan all the children, which must be items foreach (ViewBase child in this) @@ -164,7 +164,7 @@ protected override void Dispose(bool disposing) /// ViewBase of item; otherwise false. public ViewBase? GetLastFocusItem() { - ViewBase view = null; + ViewBase? view = null; // Scan all the children, which must be items foreach (ViewBase child in Reverse()) @@ -199,7 +199,7 @@ protected override void Dispose(bool disposing) /// ViewBase of item; otherwise false. public ViewBase? GetNextFocusItem(ViewBase current, ref bool matched) { - ViewBase view = null; + ViewBase? view = null; // Scan all the children, which must be containers foreach (ViewBase child in this) @@ -235,7 +235,7 @@ protected override void Dispose(bool disposing) /// ViewBase of item; otherwise false. public ViewBase? GetPreviousFocusItem(ViewBase current, ref bool matched) { - ViewBase view = null; + ViewBase? view = null; // Scan all the children, which must be containers foreach (ViewBase child in Reverse()) @@ -317,7 +317,7 @@ public void SetGroupItemSize(GroupItemSize size) foreach (KryptonRibbonGroupItem item in _ribbonCluster.Items) { - IRibbonViewGroupItemView viewItemSize = _itemToView[item] as IRibbonViewGroupItemView; + IRibbonViewGroupItemView? viewItemSize = _itemToView[item] as IRibbonViewGroupItemView; viewItemSize?.SetGroupItemSize(size); } @@ -331,12 +331,12 @@ public void ResetGroupItemSize() { foreach (KryptonRibbonGroupItem item in _ribbonCluster.Items) { - IRibbonViewGroupItemView viewItemSize = _itemToView[item] as IRibbonViewGroupItemView; + IRibbonViewGroupItemView? viewItemSize = _itemToView[item] as IRibbonViewGroupItemView; viewItemSize?.ResetGroupItemSize(); } // Our current size is based on the parent one - ViewLayoutRibbonGroupLines viewLines = (ViewLayoutRibbonGroupLines)Parent; + ViewLayoutRibbonGroupLines? viewLines = (ViewLayoutRibbonGroupLines)Parent; _currentSize = viewLines.CurrentSize == GroupItemSize.Small ? GroupItemSize.Small : GroupItemSize.Medium; } @@ -349,12 +349,12 @@ public override Size GetPreferredSize(ViewLayoutContext context) // Sync child elements to the current group items SyncChildrenToRibbonGroupItems(); - ViewToSize viewToSize; + ViewToSize? viewToSize; viewToSize = _currentSize == GroupItemSize.Small ? _viewToSizeSmall : _viewToSizeMedium; viewToSize.Clear(); - + Size preferredSize = Size.Empty; // Find total width and maximum height across all child elements @@ -406,7 +406,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) // Are there any children to layout? if (Count > 0) { - ViewToSize viewToSize; + ViewToSize? viewToSize; viewToSize = _currentSize == GroupItemSize.Small ? _viewToSizeSmall : _viewToSizeMedium; @@ -506,14 +506,14 @@ private void SyncChildrenToRibbonGroupItems() ViewToEdge regenEdge = new(); // Cache the first and last visible children - ViewBase viewFirst = null; - ViewBase viewLast = null; + ViewBase? viewFirst = null; + ViewBase? viewLast = null; // Add a view element for each group item foreach (IRibbonGroupItem item in _ribbonCluster.Items) { - ViewBase itemView; - ViewDrawRibbonGroupClusterEdge itemEdge; + ViewBase? itemView; + ViewDrawRibbonGroupClusterEdge? itemEdge; // Do we already have a view for this item definition if (_itemToView.ContainsKey(item)) diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupLines.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupLines.cs index 7fd0fc81c..ce4738fea 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupLines.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroupLines.cs @@ -37,7 +37,7 @@ private class ViewList : List { } #region Instance Fields private readonly KryptonRibbon _ribbon; private readonly KryptonRibbonGroupLines _ribbonLines; - private ViewDrawRibbonDesignGroupLines _viewAddItem; + private ViewDrawRibbonDesignGroupLines? _viewAddItem; private readonly NeedPaintHandler _needPaint; private GroupItemSize _currentSize; private ItemToView _itemToView; @@ -163,7 +163,7 @@ public GroupItemSize CurrentSize /// ViewBase of item; otherwise false. public ViewBase? GetFirstFocusItem() { - ViewBase view = null; + ViewBase? view = null; // Scan all the children, which must be containers foreach (ViewBase child in this) @@ -207,7 +207,7 @@ public GroupItemSize CurrentSize /// ViewBase of item; otherwise false. public ViewBase? GetLastFocusItem() { - ViewBase view = null; + ViewBase? view = null; // Scan all the children, which must be containers foreach (ViewBase child in Reverse()) @@ -253,7 +253,7 @@ public GroupItemSize CurrentSize /// ViewBase of item; otherwise false. public ViewBase? GetNextFocusItem(ViewBase current, ref bool matched) { - ViewBase view = null; + ViewBase? view = null; // Scan all the children, which must be containers foreach (ViewBase child in this) @@ -303,7 +303,7 @@ public GroupItemSize CurrentSize /// ViewBase of item; otherwise false. public ViewBase? GetPreviousFocusItem(ViewBase current, ref bool matched) { - ViewBase view = null; + ViewBase? view = null; // Scan all the children, which must be containers foreach (ViewBase child in Reverse()) @@ -483,7 +483,7 @@ public ItemSizeWidth[] GetPossibleSizes(ViewLayoutContext context) // Ensure original value is put back ResetSize(); - + return results.ToArray(); } @@ -524,7 +524,7 @@ public override Size GetPreferredSize(ViewLayoutContext context) _viewToGap.Clear(); var totalWidth = 0; - ViewBase previousChild = null; + ViewBase? previousChild = null; // Find the size of each individual visible child item for (var i = 0; i < Count; i++) @@ -534,7 +534,7 @@ public override Size GetPreferredSize(ViewLayoutContext context) // Only interested in visible items if (child.Visible) { - // Inform cluster if it is immediatley after another cluster (and so potentially needs a separator) + // Inform cluster if it is immediately after another cluster (and so potentially needs a separator) // Are we positioning a cluster? if (child is ViewLayoutRibbonGroupCluster clusterChild) { @@ -543,7 +543,7 @@ public override Size GetPreferredSize(ViewLayoutContext context) } // Can we calculate the spacing gap between the previous and this item - if (previousChild != null) + if (previousChild != null) { if (_viewToItem.ContainsKey(child) && _viewToItem.ContainsKey(previousChild)) @@ -733,7 +733,7 @@ private void SyncChildrenToRibbonGroupItems() // Add a view element for each group item foreach (IRibbonGroupItem item in _ribbonLines.Items) { - ViewBase itemView; + ViewBase? itemView; // Do we already have a view for this item definition if (_itemToView.ContainsKey(item)) @@ -933,9 +933,9 @@ private Size SmallPreferredSize(int totalWidth) } // Add the spacing gaps before relevant items - if ((_split1Small >= 0) - && (_split1Small < _sizeList.Count) - && (_split2Small >= 0) + if ((_split1Small >= 0) + && (_split1Small < _sizeList.Count) + && (_split2Small >= 0) && (_split2Small < _sizeList.Count) ) { @@ -948,7 +948,7 @@ private Size SmallPreferredSize(int totalWidth) } break; } - + // Our height is always the same as a triple, the entire content height preferredSize.Height = _ribbon.CalculatedValues.GroupTripleHeight; @@ -972,7 +972,7 @@ private void LargeMediumLayout(ViewLayoutContext context, ref int split1) x += DesignTimeDraw.FlapWidth; } - ViewBase previousChild = null; + ViewBase? previousChild = null; // Position the visible items in turn for (int i = 0, visibleIndex = 0; i < Count; i++) @@ -985,7 +985,7 @@ private void LargeMediumLayout(ViewLayoutContext context, ref int split1) // Are we positioning a cluster? if (child is ViewLayoutRibbonGroupCluster clusterChild1) { - // Inform cluster if it is immediatley after another cluster (and so potentially needs a separator) + // Inform cluster if it is immediately after another cluster (and so potentially needs a separator) clusterChild1.StartSeparator = (previousChild != null) && previousChild is not ViewLayoutRibbonGroupCluster; clusterChild1.EndSeparator = false; } @@ -1059,7 +1059,7 @@ private void SmallLayout(ViewLayoutContext context) x += DesignTimeDraw.FlapWidth; } - ViewBase previousChild = null; + ViewBase? previousChild = null; // Position the visible items in turn for (int i = 0, visibleIndex = 0; i < Count; i++) @@ -1072,7 +1072,7 @@ private void SmallLayout(ViewLayoutContext context) // Are we positioning a cluster? if (child is ViewLayoutRibbonGroupCluster clusterChild1) { - // Inform cluster if it is immediatley after another item and so needs a start separator + // Inform cluster if it is immediately after another item and so needs a start separator clusterChild1.StartSeparator = (previousChild != null) && previousChild is not ViewLayoutRibbonGroupCluster; clusterChild1.EndSeparator = false; } diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroups.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroups.cs index 1d3f9dbac..49db7e8c2 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroups.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonGroups.cs @@ -20,7 +20,7 @@ namespace Krypton.Ribbon internal class ViewLayoutRibbonGroups : ViewComposite { #region Classes - private class GroupToView : Dictionary {} + private class GroupToView : Dictionary { } private class ViewDrawRibbonGroupSepList : List { } #endregion @@ -32,7 +32,7 @@ private class ViewDrawRibbonGroupSepList : List { } #endregion #region Instance Fields - private readonly KryptonRibbon _ribbon; + private readonly KryptonRibbon? _ribbon; private readonly KryptonRibbonTab _ribbonTab; private NeedPaintHandler _needPaint; private ViewDrawRibbonDesignGroup _viewAddGroup; @@ -184,7 +184,7 @@ public KeyTipInfo[] GetGroupKeyTips() /// ViewBase of item; otherwise false. public ViewBase? GetFirstFocusItem() { - ViewBase view = null; + ViewBase? view = null; // Search each group until one of them returns a focus item foreach (ViewDrawRibbonGroup group in _groupToView.Values) @@ -207,7 +207,7 @@ public KeyTipInfo[] GetGroupKeyTips() /// ViewBase of item; otherwise false. public ViewBase? GetLastFocusItem() { - ViewBase view = null; + ViewBase? view = null; var groups = new ViewDrawRibbonGroup[_groupToView.Count]; _groupToView.Values.CopyTo(groups, 0); @@ -234,7 +234,7 @@ public KeyTipInfo[] GetGroupKeyTips() /// ViewBase of item; otherwise false. public ViewBase? GetNextFocusItem(ViewBase current) { - ViewBase view = null; + ViewBase? view = null; var matched = false; // Search each group until one of them returns a focus item @@ -262,7 +262,7 @@ public KeyTipInfo[] GetGroupKeyTips() /// ViewBase of item; otherwise false. public ViewBase? GetPreviousFocusItem(ViewBase current) { - ViewBase view = null; + ViewBase? view = null; var matched = false; var groups = new ViewDrawRibbonGroup[_groupToView.Count]; @@ -384,9 +384,9 @@ private void SyncChildrenToRibbonGroups() // Create a new lookup that reflects any changes in groups GroupToView regenerate = new(); - + // Make sure we have a view element to match each group - foreach(KryptonRibbonGroup ribGroup in _ribbonTab.Groups) + foreach (KryptonRibbonGroup ribGroup in _ribbonTab.Groups) { ViewDrawRibbonGroup view = null; @@ -439,7 +439,7 @@ private void SyncChildrenToRibbonGroups() Add(_groupSepCache[i]); Add(regenerate[ribbonGroup]); - + // Remove entries we still are using if (_groupToView.ContainsKey(ribbonGroup)) { @@ -448,7 +448,7 @@ private void SyncChildrenToRibbonGroups() } // When in design time help mode - if (_ribbon.InDesignHelperMode) + if (_ribbon != null && _ribbon.InDesignHelperMode) { // Create the design time 'Add Group' first time it is needed _viewAddGroup ??= new ViewDrawRibbonDesignGroup(_ribbon, _needPaint); @@ -458,7 +458,7 @@ private void SyncChildrenToRibbonGroups() } // Dispose of views no longer required - foreach(ViewDrawRibbonGroup ribGroup in _groupToView.Values) + foreach (ViewDrawRibbonGroup ribGroup in _groupToView.Values) { ribGroup.Dispose(); } @@ -502,7 +502,7 @@ private int AdjustGroupStateToMatchSpace(ViewLayoutContext context) var bestWidth = 0; var availableWidth = context.DisplayRectangle.Width; - int[] bestIndexes = null; + int[]? bestIndexes = null; var permIndexes = new List(); // Scan each horizontal slice of the 2D array of values diff --git a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonTabsArea.cs b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonTabsArea.cs index 337319c2b..c7c5120b6 100644 --- a/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonTabsArea.cs +++ b/Source/Krypton Components/Krypton.Ribbon/View Layout/ViewLayoutRibbonTabsArea.cs @@ -488,19 +488,25 @@ private void CreateViewElements(PaletteRedirect? redirect) LayoutAppTab = new ViewLayoutRibbonAppTab(_ribbon); // Connect up the application button controller to the app button element - _appButtonController.Target3 = LayoutAppButton.AppButton; - _appButtonController.Click += OnAppButtonClicked; - _appButtonController.MouseReleased += OnAppButtonReleased; - LayoutAppButton.MouseController = _appButtonController; - LayoutAppButton.SourceController = _appButtonController; - LayoutAppButton.KeyController = _appButtonController; - - _appTabController.Target1 = LayoutAppTab.AppTab; - _appTabController.Click += OnAppButtonClicked; - _appTabController.MouseReleased += OnAppButtonReleased; - LayoutAppTab.MouseController = _appTabController; - LayoutAppTab.SourceController = _appTabController; - LayoutAppTab.KeyController = _appTabController; + if (_appButtonController != null) + { + _appButtonController.Target3 = LayoutAppButton.AppButton; + _appButtonController.Click += OnAppButtonClicked; + _appButtonController.MouseReleased += OnAppButtonReleased; + LayoutAppButton.MouseController = _appButtonController; + LayoutAppButton.SourceController = _appButtonController; + LayoutAppButton.KeyController = _appButtonController; + } + + if (_appTabController != null) + { + _appTabController.Target1 = LayoutAppTab.AppTab; + _appTabController.Click += OnAppButtonClicked; + _appTabController.MouseReleased += OnAppButtonReleased; + LayoutAppTab.MouseController = _appTabController; + LayoutAppTab.SourceController = _appTabController; + LayoutAppTab.KeyController = _appTabController; + } // When the app button is not visible we need separator instead before start of first tab _layoutAppButtonSep = new ViewLayoutSeparator(5, 0) @@ -739,8 +745,15 @@ private void OnAppMenuDisposed(object sender, EventArgs e) _ribbon.KillKeyboardMode(); // Remove the fixed 'pressed' state from the application button - _appButtonController.RemoveFixed(); - _appTabController.RemoveFixed(); + if (_appButtonController != null) + { + _appButtonController.RemoveFixed(); + } + + if (_appTabController != null) + { + _appTabController.RemoveFixed(); + } // Should still be caching a reference to actual display control if (_appMenu != null) @@ -806,7 +819,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) // Grab the style from the app button settings toolTipStyle = _ribbon.RibbonAppButton.AppButtonToolTipStyle; shadow = _ribbon.RibbonAppButton.ToolTipShadow; - + // Display below the mouse cursor screenRect.Height += SystemInformation.CursorSize.Height / 3 * 2; } @@ -863,7 +876,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) { // Cast to correct type if (e.Target.Parent is { Component: IRibbonGroupItem { ToolTipValues.EnableToolTips: true } groupItem }) - // Is there actually anything to show for the tooltip + // Is there actually anything to show for the tooltip { sourceContent = groupItem.ToolTipValues; diff --git a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecToContent.cs b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecToContent.cs index f1b4d8679..34eb0f087 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecToContent.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecToContent.cs @@ -19,7 +19,7 @@ public class ButtonSpecToContent : IContentValues { #region Instance Fields private readonly ButtonSpec _buttonSpec; - private readonly PaletteBase _palette; + private readonly PaletteBase? _palette; #endregion #region Identity @@ -28,7 +28,7 @@ public class ButtonSpecToContent : IContentValues /// /// Palette for sourcing information. /// Source button spec instance. - public ButtonSpecToContent([DisallowNull] PaletteBase palette, + public ButtonSpecToContent([DisallowNull] PaletteBase? palette, [DisallowNull] ButtonSpec buttonSpec) { Debug.Assert(palette != null); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonButton.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonButton.cs index 48b23a8d3..c5e0afac7 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonButton.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonButton.cs @@ -707,8 +707,11 @@ protected override void OnClick(EventArgs e) if (owner is KryptonMessageBoxForm) { // need to gain access to `dialogResult` and set it forcefully - FieldInfo fi = typeof(Form).GetField("dialogResult", BindingFlags.NonPublic | BindingFlags.Instance); - fi.SetValue(owner, DialogResult); + FieldInfo? fi = typeof(Form).GetField("dialogResult", BindingFlags.NonPublic | BindingFlags.Instance); + if (fi != null) + { + fi.SetValue(owner, DialogResult); + } } else { @@ -1136,7 +1139,7 @@ private void ShowContextMenuStrip() if (KryptonContextMenu != null) { - KryptonContextMenu.Show(FindForm().PointToScreen(Location) + new Size(0, Height)); + KryptonContextMenu.Show(FindForm()!.PointToScreen(Location) + new Size(0, Height)); KryptonContextMenu.Closed += KryptonContextMenu_Closed; } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewTextBoxCell.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewTextBoxCell.cs index d15a17584..bd4c2d0db 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewTextBoxCell.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewTextBoxCell.cs @@ -294,8 +294,8 @@ private void OnCommonChange() } private bool OwnsEditingTextBox(int rowIndex) => - rowIndex != -1 - && DataGridView is { EditingControl: KryptonDataGridViewTextBoxEditingControl control } + rowIndex != -1 + && DataGridView is { EditingControl: KryptonDataGridViewTextBoxEditingControl control } && (rowIndex == ((IDataGridViewEditingControl)control).EditingControlRowIndex); private static bool PartPainted(DataGridViewPaintParts paintParts, DataGridViewPaintParts paintPart) => paintParts.HasFlag(paintPart); @@ -328,6 +328,6 @@ internal void SetMultilineStringEditor(int rowIndex, bool value) [Category(@"Data")] [Description(@"Set of extra icons to appear with control.")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] - public List IconSpecs { get; } = new List(); + public List IconSpecs { get; } = new(); } } \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs index a7d70b767..11f4e3609 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs @@ -1900,20 +1900,20 @@ private void SetupIntegratedToolBarButtons() { if (_integratedToolBarItems != null) { - ButtonSpecAny newButtonSpec = new ButtonSpecAny(), - openButtonSpecAny = new ButtonSpecAny(), - saveButtonSpecAny = new ButtonSpecAny(), - saveAsButtonSpecAny = new ButtonSpecAny(), - saveAllButtonSpecAny = new ButtonSpecAny(), - cutButtonSpecAny = new ButtonSpecAny(), - copyButtonSpecAny = new ButtonSpecAny(), - pasteButtonSpecAny = new ButtonSpecAny(), - undoButtonSpecAny = new ButtonSpecAny(), - redoButtonSpecAny = new ButtonSpecAny(), - pageSetupButtonSpecAny = new ButtonSpecAny(), - printPreviewButtonSpecAny = new ButtonSpecAny(), - printButtonSpecAny = new ButtonSpecAny(), - quickPrintButtonSpecAny = new ButtonSpecAny(); + ButtonSpecAny newButtonSpec = new(), + openButtonSpecAny = new(), + saveButtonSpecAny = new(), + saveAsButtonSpecAny = new(), + saveAllButtonSpecAny = new(), + cutButtonSpecAny = new(), + copyButtonSpecAny = new(), + pasteButtonSpecAny = new(), + undoButtonSpecAny = new(), + redoButtonSpecAny = new(), + pageSetupButtonSpecAny = new(), + printPreviewButtonSpecAny = new(), + printButtonSpecAny = new(), + quickPrintButtonSpecAny = new(); // Set up buttons newButtonSpec.Type = PaletteButtonSpecStyle.New; diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonLanguageManager.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonLanguageManager.cs index 3183d3cd1..d23ab3cc7 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonLanguageManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonLanguageManager.cs @@ -52,19 +52,33 @@ public class KryptonLanguageManager : Component /// Resets the button spec style strings. public void ResetButtonSpecStyleStrings() => ButtonStyles.Reset(); - /// Gets the general strings. - /// The general strings. + /// Gets the custom toolkit strings. + /// The custom toolkit strings. [Category(@"Visuals")] - [Description(@"Collection of general strings.")] + [Description(@"Collection of custom toolkit strings.")] [MergableProperty(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [Localizable(true)] - public GeneralStrings GeneralStrings => GeneralToolkitStrings; + public CustomToolkitStrings CustomStrings => CustomToolkitStrings; + + private bool ShouldSerializeCustomStrings() => !CustomToolkitStrings.IsDefault; + + /// Resets the custom strings. + public void ResetCustomStrings() => CustomToolkitStrings.ResetValues(); + + /// Gets the general toolkit strings. + /// The general toolkit strings. + [Category(@"Visuals")] + [Description(@"Collection of general toolkit strings.")] + [MergableProperty(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + [Localizable(true)] + public GeneralToolkitStrings GeneralStrings => GeneralToolkitStrings; private bool ShouldSerializeGeneralStrings() => !GeneralToolkitStrings.IsDefault; /// Resets the general strings. - public void ResetGeneralStrings() => GeneralToolkitStrings.ResetValues(); + public void ResetGeneralStrings() => GeneralToolkitStrings.Reset(); /// Gets the data grid view style strings. /// The data grid view style strings. @@ -399,9 +413,12 @@ public class KryptonLanguageManager : Component /// The spec style strings. public static ButtonStyleStrings ButtonStyles { get; } = new(); + public static CustomToolkitStrings CustomToolkitStrings { get; } = new(); + /// Gets the strings. /// The strings. - public static GeneralStrings GeneralToolkitStrings { get; } = new(); + public static GeneralToolkitStrings GeneralToolkitStrings + { get; } = new(); /// Gets the grid view style strings. /// The grid view style strings. @@ -514,7 +531,8 @@ public KryptonLanguageManager() /// true if this instance is default; otherwise, false. [EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsDefault => !(ShouldSerializeGeneralStrings() || + public bool IsDefault => !(ShouldSerializeCustomStrings() || + ShouldSerializeGeneralStrings() || ShouldSerializeColorStrings() || ShouldSerializePaletteModeStrings() || ShouldSerializeButtonSpecStyleStrings() || @@ -547,6 +565,8 @@ public void Reset() ResetButtonSpecStyleStrings(); + ResetCustomStrings(); + ResetGeneralStrings(); ResetPaletteModeStrings(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTextBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTextBox.cs index b79c346eb..7befa3a96 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTextBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTextBox.cs @@ -38,12 +38,12 @@ private class InternalTextBox : TextBox /// /// Occurs when the mouse enters the InternalTextBox. /// - public event EventHandler TrackMouseEnter; + public event EventHandler? TrackMouseEnter; /// /// Occurs when the mouse leaves the InternalTextBox. /// - public event EventHandler TrackMouseLeave; + public event EventHandler? TrackMouseLeave; #endregion #region Identity @@ -287,13 +287,25 @@ protected override void WndProc(ref Message m) /// Raises the TrackMouseEnter event. /// /// An EventArgs containing the event data. - protected virtual void OnTrackMouseEnter(EventArgs e) => TrackMouseEnter.Invoke(this, e); + protected virtual void OnTrackMouseEnter(EventArgs e) + { + if (TrackMouseEnter != null) + { + TrackMouseEnter.Invoke(this, e); + } + } /// /// Raises the TrackMouseLeave event. /// /// An EventArgs containing the event data. - protected virtual void OnTrackMouseLeave(EventArgs e) => TrackMouseLeave.Invoke(this, e); + protected virtual void OnTrackMouseLeave(EventArgs e) + { + if (TrackMouseLeave != null) + { + TrackMouseLeave.Invoke(this, e); + } + } #endregion } @@ -320,7 +332,7 @@ public TextBoxButtonSpecCollection(KryptonTextBox owner) #region Instance Fields - private VisualPopupToolTip _visualPopupToolTip; + private VisualPopupToolTip? _visualPopupToolTip; private readonly ButtonSpecManagerLayout? _buttonManager; private readonly ViewLayoutDocker _drawDockerInner; private readonly ViewDrawDocker _drawDockerOuter; @@ -335,6 +347,7 @@ public TextBoxButtonSpecCollection(KryptonTextBox owner) private bool _trackingMouseEnter; private int _cachedHeight; private bool _multilineStringEditor; + private bool _showEllipsisButton; private bool _isInAlphaNumericMode; private readonly ButtonSpecAny _editorButton; private float _cornerRoundingRadius; @@ -347,42 +360,42 @@ public TextBoxButtonSpecCollection(KryptonTextBox owner) /// [Description(@"Occurs when the value of the AcceptsTab property changes.")] [Category(@"Property Changed")] - public event EventHandler AcceptsTabChanged; + public event EventHandler? AcceptsTabChanged; /// /// Occurs when the value of the HideSelection property changes. /// [Description(@"Occurs when the value of the HideSelection property changes.")] [Category(@"Property Changed")] - public event EventHandler HideSelectionChanged; + public event EventHandler? HideSelectionChanged; /// /// Occurs when the value of the TextAlign property changes. /// [Description(@"Occurs when the value of the TextAlign property changes.")] [Category(@"Property Changed")] - public event EventHandler TextAlignChanged; + public event EventHandler? TextAlignChanged; /// /// Occurs when the value of the Modified property changes. /// [Description(@"Occurs when the value of the Modified property changes.")] [Category(@"Property Changed")] - public event EventHandler ModifiedChanged; + public event EventHandler? ModifiedChanged; /// /// Occurs when the value of the Multiline property changes. /// [Description(@"Occurs when the value of the Multiline property changes.")] [Category(@"Property Changed")] - public event EventHandler MultilineChanged; + public event EventHandler? MultilineChanged; /// /// Occurs when the value of the ReadOnly property changes. /// [Description(@"Occurs when the value of the ReadOnly property changes.")] [Category(@"Property Changed")] - public event EventHandler ReadOnlyChanged; + public event EventHandler? ReadOnlyChanged; /// /// Occurs when the mouse enters the control. @@ -390,7 +403,7 @@ public TextBoxButtonSpecCollection(KryptonTextBox owner) [Description(@"Raises the TrackMouseEnter event in the wrapped control.")] [Category(@"Mouse")] [EditorBrowsable(EditorBrowsableState.Advanced)] - public event EventHandler TrackMouseEnter; + public event EventHandler? TrackMouseEnter; /// /// Occurs when the mouse leaves the control. @@ -398,35 +411,35 @@ public TextBoxButtonSpecCollection(KryptonTextBox owner) [Description(@"Raises the TrackMouseLeave event in the wrapped control.")] [Category(@"Mouse")] [EditorBrowsable(EditorBrowsableState.Advanced)] - public event EventHandler TrackMouseLeave; + public event EventHandler? TrackMouseLeave; /// /// Occurs when the value of the BackColor property changes. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public new event EventHandler BackColorChanged; + public new event EventHandler? BackColorChanged; /// /// Occurs when the value of the BackgroundImage property changes. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public new event EventHandler BackgroundImageChanged; + public new event EventHandler? BackgroundImageChanged; /// /// Occurs when the value of the BackgroundImageLayout property changes. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public new event EventHandler BackgroundImageLayoutChanged; + public new event EventHandler? BackgroundImageLayoutChanged; /// /// Occurs when the value of the ForeColor property changes. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public new event EventHandler ForeColorChanged; + public new event EventHandler? ForeColorChanged; #endregion #region Identity @@ -533,6 +546,8 @@ public KryptonTextBox() _cornerRoundingRadius = GlobalStaticValues.PRIMARY_CORNER_ROUNDING_VALUE; _isInAlphaNumericMode = false; + + _showEllipsisButton = false; } /// @@ -637,6 +652,14 @@ public bool MultilineStringEditor } } } + + /// Gets or sets a value indicating whether [show ellipsis button]. + /// true if [show ellipsis button]; otherwise, false. + [Category(@"Visuals")] + [Description(@"Shows a ellipsis (...) button in the textbox.")] + [DefaultValue(false)] + public bool ShowEllipsisButton { get => _showEllipsisButton; set { _showEllipsisButton = value; ToggleEllipsisButtonVisibility(value); } } + /// /// Gets access to the contained TextBox instance. /// @@ -1450,51 +1473,99 @@ protected void SetMultilineStringEditor(bool value) /// Raises the AcceptsTabChanged event. /// /// An EventArgs containing the event data. - protected virtual void OnAcceptsTabChanged(EventArgs e) => AcceptsTabChanged.Invoke(this, e); + protected virtual void OnAcceptsTabChanged(EventArgs e) + { + if (AcceptsTabChanged != null) + { + AcceptsTabChanged.Invoke(this, e); + } + } /// /// Raises the TextAlignChanged event. /// /// An EventArgs containing the event data. - protected virtual void OnTextAlignChanged(EventArgs e) => TextAlignChanged.Invoke(this, e); + protected virtual void OnTextAlignChanged(EventArgs e) + { + if (TextAlignChanged != null) + { + TextAlignChanged.Invoke(this, e); + } + } /// /// Raises the HideSelectionChanged event. /// /// An EventArgs that contains the event data. - protected virtual void OnHideSelectionChanged(EventArgs e) => HideSelectionChanged.Invoke(this, e); + protected virtual void OnHideSelectionChanged(EventArgs e) + { + if (HideSelectionChanged != null) + { + HideSelectionChanged.Invoke(this, e); + } + } /// /// Raises the ModifiedChanged event. /// /// An EventArgs that contains the event data. - protected virtual void OnModifiedChanged(EventArgs e) => ModifiedChanged.Invoke(this, e); + protected virtual void OnModifiedChanged(EventArgs e) + { + if (ModifiedChanged != null) + { + ModifiedChanged.Invoke(this, e); + } + } /// /// Raises the MultilineChanged event. /// /// An EventArgs that contains the event data. - protected virtual void OnMultilineChanged(EventArgs e) => MultilineChanged.Invoke(this, e); + protected virtual void OnMultilineChanged(EventArgs e) + { + if (MultilineChanged != null) + { + MultilineChanged.Invoke(this, e); + } + } /// /// Raises the ReadOnlyChanged event. /// /// An EventArgs that contains the event data. - protected virtual void OnReadOnlyChanged(EventArgs e) => ReadOnlyChanged.Invoke(this, e); + protected virtual void OnReadOnlyChanged(EventArgs e) + { + if (ReadOnlyChanged != null) + { + ReadOnlyChanged.Invoke(this, e); + } + } /// /// Raises the TrackMouseEnter event. /// /// An EventArgs containing the event data. [Description(@"Raises the TrackMouseEnter event.")] - protected virtual void OnTrackMouseEnter(EventArgs e) => TrackMouseEnter.Invoke(this, e); + protected virtual void OnTrackMouseEnter(EventArgs e) + { + if (TrackMouseEnter != null) + { + TrackMouseEnter.Invoke(this, e); + } + } /// /// Raises the TrackMouseLeave event. /// /// An EventArgs containing the event data. [Description(@"Raises the TrackMouseLeave event.")] - protected virtual void OnTrackMouseLeave(EventArgs e) => TrackMouseLeave.Invoke(this, e); + protected virtual void OnTrackMouseLeave(EventArgs e) + { + if (TrackMouseLeave != null) + { + TrackMouseLeave.Invoke(this, e); + } + } // ReSharper restore VirtualMemberNeverOverridden.Global #endregion @@ -1561,25 +1632,45 @@ protected override void OnGotFocus(EventArgs e) /// Raises the BackColorChanged event. /// /// An EventArgs that contains the event data. - protected override void OnBackColorChanged(EventArgs e) => BackColorChanged.Invoke(this, e); + protected override void OnBackColorChanged(EventArgs e) + { + if (BackColorChanged != null) + { + BackColorChanged.Invoke(this, e); + } + } /// /// Raises the BackgroundImageChanged event. /// /// An EventArgs that contains the event data. - protected override void OnBackgroundImageChanged(EventArgs e) => BackgroundImageChanged.Invoke(this, e); + protected override void OnBackgroundImageChanged(EventArgs e) + { + if (BackgroundImageChanged != null) + { + BackgroundImageChanged.Invoke(this, e); + } + } /// /// Raises the BackgroundImageLayoutChanged event. /// /// An EventArgs that contains the event data. - protected override void OnBackgroundImageLayoutChanged(EventArgs e) => BackgroundImageLayoutChanged.Invoke(this, e); + protected override void OnBackgroundImageLayoutChanged(EventArgs e) + { + if (BackgroundImageLayoutChanged != null) + BackgroundImageLayoutChanged.Invoke(this, e); + } /// /// Raises the ForeColorChanged event. /// /// An EventArgs that contains the event data. - protected override void OnForeColorChanged(EventArgs e) => ForeColorChanged.Invoke(this, e); + protected override void OnForeColorChanged(EventArgs e) + { + if (ForeColorChanged != null) + ForeColorChanged.Invoke(this, e); + } /// /// Raises the Resize event. @@ -1907,23 +1998,29 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) bool shadow = true; // Find the button spec associated with the tooltip request - ButtonSpec? buttonSpec = _buttonManager.ButtonSpecFromView(e.Target); - - // If the tooltip is for a button spec - if (buttonSpec != null) + if (_buttonManager != null) { - // Are we allowed to show page related tooltips - if (AllowButtonSpecToolTips) - { - // Create a helper object to provide tooltip values - ButtonSpecToContent buttonSpecMapping = new(Redirector, buttonSpec); + ButtonSpec? buttonSpec = _buttonManager.ButtonSpecFromView(e.Target); - // Is there actually anything to show for the tooltip - if (buttonSpecMapping.HasContent) + // If the tooltip is for a button spec + if (buttonSpec != null) + { + // Are we allowed to show page related tooltips + if (AllowButtonSpecToolTips) { - sourceContent = buttonSpecMapping; - toolTipStyle = buttonSpec.ToolTipStyle; - shadow = buttonSpec.ToolTipShadow; + // Create a helper object to provide tooltip values + if (Redirector != null) + { + ButtonSpecToContent buttonSpecMapping = new(Redirector, buttonSpec); + + // Is there actually anything to show for the tooltip + if (buttonSpecMapping.HasContent) + { + sourceContent = buttonSpecMapping; + toolTipStyle = buttonSpec.ToolTipStyle; + shadow = buttonSpec.ToolTipShadow; + } + } } } } @@ -1931,11 +2028,14 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) if (sourceContent != null) { // Remove any currently showing tooltip - _visualPopupToolTip.Dispose(); - - if (AllowButtonSpecToolTipPriority) + if (_visualPopupToolTip != null) { - visualBasePopupToolTip.Dispose(); + _visualPopupToolTip.Dispose(); + + if (AllowButtonSpecToolTipPriority) + { + visualBasePopupToolTip.Dispose(); + } } // Create the actual tooltip popup object @@ -1955,7 +2055,13 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) } // Remove any currently showing tooltip - private void OnCancelToolTip(object sender, EventArgs e) => _visualPopupToolTip.Dispose(); + private void OnCancelToolTip(object sender, EventArgs e) + { + if (_visualPopupToolTip != null) + { + _visualPopupToolTip.Dispose(); + } + } private void OnVisualPopupToolTipDisposed(object sender, EventArgs e) { @@ -2011,6 +2117,27 @@ private void SetIsInAlphaNumericMode(KryptonTextBox owner) // TODO: Return to this... } + private void ToggleEllipsisButtonVisibility(bool visible) + { + // Setup button + ButtonSpecAny bsaEllipsisButton = new ButtonSpecAny(); + + bsaEllipsisButton.Text = @"&..."; + + if (visible) + { + ButtonSpecs.Add(bsaEllipsisButton); + + bsaEllipsisButton.Visible = true; + } + else + { + bsaEllipsisButton.Visible = false; + + ButtonSpecs.Remove(bsaEllipsisButton); + } + } + #endregion } } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonThemeComboBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonThemeComboBox.cs index ca13519b3..7d1077c2f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonThemeComboBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonThemeComboBox.cs @@ -29,13 +29,9 @@ public class KryptonThemeComboBox : KryptonComboBox /// Helper, to return a new list of names /// [EditorBrowsable(EditorBrowsableState.Never)] - public List SupportedThemesList - { - get => _supportedThemesNames.ToList(); - - //private set { _supportedThemesNames = value.ToArray(); } - } + public List SupportedThemesList => _supportedThemesNames.ToList(); + //private set { _supportedThemesNames = value.ToArray(); } /// /// Gets and sets the ThemeSelectedIndex. /// diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMultilineStringEditorForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMultilineStringEditorForm.cs index 988454575..c536796e6 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMultilineStringEditorForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMultilineStringEditorForm.cs @@ -79,21 +79,21 @@ private void SetupControlsText() kbtnOk.Text = KryptonLanguageManager.GeneralToolkitStrings.OK; - kcRichTextBoxCopy.Text = KryptonLanguageManager.GeneralToolkitStrings.Copy; + kcRichTextBoxCopy.Text = KryptonLanguageManager.CustomToolkitStrings.Copy; - kcRichTextBoxCut.Text = KryptonLanguageManager.GeneralToolkitStrings.Cut; + kcRichTextBoxCut.Text = KryptonLanguageManager.CustomToolkitStrings.Cut; - kcRichTextBoxPaste.Text = KryptonLanguageManager.GeneralToolkitStrings.Paste; + kcRichTextBoxPaste.Text = KryptonLanguageManager.CustomToolkitStrings.Paste; - kcRichTextBoxSelectAll.Text = KryptonLanguageManager.GeneralToolkitStrings.SelectAll; + kcRichTextBoxSelectAll.Text = KryptonLanguageManager.CustomToolkitStrings.SelectAll; - kcTextBoxCopy.Text = KryptonLanguageManager.GeneralToolkitStrings.Copy; + kcTextBoxCopy.Text = KryptonLanguageManager.CustomToolkitStrings.Copy; - kcTextBoxCut.Text = KryptonLanguageManager.GeneralToolkitStrings.Cut; + kcTextBoxCut.Text = KryptonLanguageManager.CustomToolkitStrings.Cut; - kcTextBoxPaste.Text = KryptonLanguageManager.GeneralToolkitStrings.Paste; + kcTextBoxPaste.Text = KryptonLanguageManager.CustomToolkitStrings.Paste; - kcTextBoxSelectAll.Text = KryptonLanguageManager.GeneralToolkitStrings.SelectAll; + kcTextBoxSelectAll.Text = KryptonLanguageManager.CustomToolkitStrings.SelectAll; } private void SetupVariables(string[]? contents, StringCollection? collection, bool? useRichTextBox, string? headerText, string? windowTitle) diff --git a/Source/Krypton Components/Krypton.Toolkit/General/CommonHelper.cs b/Source/Krypton Components/Krypton.Toolkit/General/CommonHelper.cs index 25f71874d..c3c27cb51 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/CommonHelper.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/CommonHelper.cs @@ -30,7 +30,7 @@ namespace Krypton.Toolkit /// public delegate ToolStripRenderer GetToolStripRenderer(); #endregion - + /// /// Set of common helper routines for the Toolkit /// @@ -40,7 +40,7 @@ public static class CommonHelper private const int VK_SHIFT = 0x10; private const int VK_CONTROL = 0x11; private const int VK_MENU = 0x12; - + private static readonly char[] _singleDateFormat = { 'd', 'f', 'F', 'g', 'h', 'H', 'K', 'm', 'M', 's', 't', 'y', 'z' }; //private static readonly int[] _daysInMonth = new int[12] { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; @@ -132,8 +132,8 @@ public static Padding InheritPadding /// Windows message that generated check. /// Keyboard shortcut to check. /// True if shortcut processed; otherwise false. - public static bool CheckContextMenuForShortcut(ContextMenuStrip? cms, - ref Message msg, + public static bool CheckContextMenuForShortcut(ContextMenuStrip? cms, + ref Message msg, Keys keyData) { if (cms != null) @@ -219,7 +219,7 @@ public static Size ApplyPadding(Orientation orientation, Size size, Padding padd /// Padding to be applied. /// Updated size. public static Size ApplyPadding(VisualOrientation orientation, - Size size, + Size size, Padding padding) { // Ignore an empty padding value @@ -257,7 +257,7 @@ public static Size ApplyPadding(VisualOrientation orientation, /// Padding to be applied. /// Updated rectangle. public static Rectangle ApplyPadding(Orientation orientation, - Rectangle rect, + Rectangle rect, Padding padding) { // Ignore an empty padding value @@ -297,7 +297,7 @@ public static Rectangle ApplyPadding(Orientation orientation, /// Padding to be applied. /// Updated rectangle. public static Rectangle ApplyPadding(VisualOrientation orientation, - Rectangle rect, + Rectangle rect, Padding padding) { // Ignore an empty padding value @@ -882,7 +882,7 @@ public static Color ColorToBlackAndWhite(Color color) /// Percentage of green to keep. /// Percentage of blue to keep. /// Modified color. - public static Color WhitenColor(Color color1, + public static Color WhitenColor(Color color1, float percentR, float percentG, float percentB) @@ -1101,7 +1101,7 @@ public static bool IsAltKeyPressed public static Control? GetControlWithFocus(Control control) { // Does the provided control have the focus? - if (control.Focused + if (control.Focused && control is not IContainedInputControl ) { @@ -1110,9 +1110,9 @@ public static bool IsAltKeyPressed else { // Check each child hierarchy in turn - return (from Control child in control.Controls - where child.ContainsFocus - select GetControlWithFocus(child) + return (from Control child in control.Controls + where child.ContainsFocus + select GetControlWithFocus(child) ).FirstOrDefault(); } } @@ -1505,7 +1505,7 @@ public static bool DesignMode(Component? c) /// /// String to convert. /// Boolean value. - public static bool StringToBool(string s) => (bool)_bc.ConvertFromInvariantString(s); + public static bool StringToBool(string? s) => (bool)_bc.ConvertFromInvariantString(s); /// /// Convert a Color to a culture invariant string value. @@ -1562,7 +1562,7 @@ public static Point ClientMouseMessageToScreenPt(Message m) // Return as a managed point type return new Point(clientPt.x, clientPt.y); } - + /// /// Gets a reference to the currently active floating window. /// @@ -1574,7 +1574,7 @@ public static Point ClientMouseMessageToScreenPt(Message m) /// Cursor Hotspot public static Point CaptureCursor() { - Cursor cur = Cursor.Current?? Cursors.Default; + Cursor cur = Cursor.Current ?? Cursors.Default; return cur.HotSpot; } @@ -1588,8 +1588,8 @@ public static void Deflate(this Rectangle rect, Padding margins) { rect.X += margins.Left; rect.Y += margins.Top; - rect.Width -= margins.Left+margins.Right; - rect.Height -= margins.Top+margins.Bottom; + rect.Width -= margins.Left + margins.Right; + rect.Height -= margins.Top + margins.Bottom; } /// @@ -1615,7 +1615,7 @@ public static Bitmap ScaleImageForSizedDisplay(Image src, float trgtWidth, float //srcRect.Offset(-trgtWidth%1, -trgtHeight%1); //gr.DrawImage(src, destRect, srcRect, GraphicsUnit.Pixel); gr.DrawImage(src, 0, 0, (int)trgtWidth, (int)trgtHeight); - + return newImage; } } diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/PaletteBase.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/PaletteBase.cs index 69bd3da36..3a42e6044 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/PaletteBase.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/PaletteBase.cs @@ -1356,7 +1356,8 @@ protected virtual Padding InputControlPadding #endregion #region OnUserPreferenceChanged - public void UserPreferenceChanged() => OnUserPreferenceChanged(this, new UserPreferenceChangedEventArgs(UserPreferenceCategory.General)); + public void UserPreferenceChanged() => + OnUserPreferenceChanged(this, new UserPreferenceChangedEventArgs(UserPreferenceCategory.General)); /// /// Handle a change in the user preferences. @@ -1454,4 +1455,4 @@ protected virtual void OnButtonSpecChanged(object sender, EventArgs e) #endregion } -} +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Translations/General/GeneralStrings.cs b/Source/Krypton Components/Krypton.Toolkit/Translations/General/CustomToolkitStrings.cs similarity index 54% rename from Source/Krypton Components/Krypton.Toolkit/Translations/General/GeneralStrings.cs rename to Source/Krypton Components/Krypton.Toolkit/Translations/General/CustomToolkitStrings.cs index 27e41b76e..306922a0d 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Translations/General/GeneralStrings.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Translations/General/CustomToolkitStrings.cs @@ -7,31 +7,15 @@ */ #endregion -// ReSharper disable InconsistentNaming namespace Krypton.Toolkit { - /// Exposes a general set of strings that are used within the Krypton Toolkit, and are localisable. + /// Exposes a custom set of strings that are used within the Krypton Toolkit, and are localisable. /// [TypeConverter(typeof(ExpandableObjectConverter))] - public class GeneralStrings : GlobalId + public class CustomToolkitStrings : GlobalId { - #region Static Fields - private const string DEFAULT_OK = @"O&K"; // Accelerator key - K - private const string DEFAULT_CANCEL = @"Cance&l"; // Accelerator key - L - private const string DEFAULT_YES = @"&Yes"; // Accelerator key - Y - private const string DEFAULT_NO = @"N&o"; // Accelerator key - O - private const string DEFAULT_ABORT = @"A&bort"; // Accelerator key - B - private const string DEFAULT_RETRY = @"Ret&ry"; // Accelerator key - R - private const string DEFAULT_IGNORE = @"I&gnore"; // Accelerator key - G - private const string DEFAULT_CLOSE = @"Clo&se"; // Accelerator key - S - private const string DEFAULT_TODAY = @"&Today"; // Accelerator key - T - private const string DEFAULT_HELP = @"H&elp"; // Accelerator key - E + #region Static Strings - // NET 6 & newer - private const string DEFAULT_CONTINUE = @"Co&ntinue"; // Accelerator key - N - private const string DEFAULT_TRY_AGAIN = @"Try Aga&in"; // Accelerator key - I - - // Custom private const string DEFAULT_APPLY = @"A&pply"; // Accelerator key - P private const string DEFAULT_BACK = @"Bac&k"; // Accelerator key - K private const string DEFAULT_COLLAPSE = @"C&ollapse"; // Accelerator key - O @@ -58,16 +42,14 @@ public class GeneralStrings : GlobalId #region Identity - /// Initializes a new instance of the class. - public GeneralStrings() + /// Initializes a new instance of the class. + public CustomToolkitStrings() { ResetValues(); } - /// - /// Returns a string that represents the current defaulted state. - /// - /// A string that represents the current defaulted state. + /// Converts to string. + /// A that represents this instance. public override string ToString() => !IsDefault ? "Modified" : string.Empty; #endregion @@ -79,19 +61,7 @@ public GeneralStrings() /// /// True if all values are defaulted; otherwise false. [Browsable(false)] - public bool IsDefault => OK.Equals(DEFAULT_OK) && - Cancel.Equals(DEFAULT_CANCEL) && - Yes.Equals(DEFAULT_YES) && - No.Equals(DEFAULT_NO) && - Abort.Equals(DEFAULT_ABORT) && - Retry.Equals(DEFAULT_RETRY) && - Ignore.Equals(DEFAULT_IGNORE) && - Close.Equals(DEFAULT_CLOSE) && - Today.Equals(DEFAULT_TODAY) && - Help.Equals(DEFAULT_HELP) && - Continue.Equals(DEFAULT_CONTINUE) && - TryAgain.Equals(DEFAULT_TRY_AGAIN) && - Apply.Equals(DEFAULT_APPLY) && + public bool IsDefault => Apply.Equals(DEFAULT_APPLY) && Collapse.Equals(DEFAULT_COLLAPSE) && Expand.Equals(DEFAULT_EXPAND) && Apply.Equals(DEFAULT_APPLY) && @@ -109,31 +79,9 @@ public GeneralStrings() NoToAll.Equals(DEFAULT_NO_TO_ALL) && OkToAll.Equals(DEFAULT_OK_TO_ALL) && Reset.Equals(DEFAULT_RESET); - // Note: The following may not be needed... - /*MoreDetails.Equals(DEFAULT_MORE_DETAILS) && - LessDetails.Equals(DEFAULT_LESS_DETAILS);*/ - /// - /// Reset all strings to default values. - /// public void ResetValues() { - OK = DEFAULT_OK; - Cancel = DEFAULT_CANCEL; - Yes = DEFAULT_YES; - No = DEFAULT_NO; - Abort = DEFAULT_ABORT; - Retry = DEFAULT_RETRY; - Ignore = DEFAULT_IGNORE; - Close = DEFAULT_CLOSE; - Today = DEFAULT_TODAY; - Help = DEFAULT_HELP; - - // NET 6 & newer - Continue = DEFAULT_CONTINUE; - TryAgain = DEFAULT_TRY_AGAIN; - - // Custom Apply = DEFAULT_APPLY; Collapse = DEFAULT_COLLAPSE; Expand = DEFAULT_EXPAND; @@ -152,131 +100,8 @@ public void ResetValues() NoToAll = DEFAULT_NO_TO_ALL; OkToAll = DEFAULT_OK_TO_ALL; Reset = DEFAULT_RESET; - - // Note: The following may not be needed... - /*MoreDetails = DEFAULT_MORE_DETAILS; - LessDetails = DEFAULT_LESS_DETAILS;*/ } - /// - /// Gets and sets the OK string used in message box buttons. - /// - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"OK string used for message box buttons.")] - [DefaultValue(DEFAULT_OK)] - [RefreshProperties(RefreshProperties.All)] - public string OK { get; set; } - - /// - /// Gets and sets the Cancel string used in message box buttons. - /// - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"Cancel string used for message box buttons.")] - [DefaultValue(DEFAULT_CANCEL)] - [RefreshProperties(RefreshProperties.All)] - public string Cancel { get; set; } - - /// - /// Gets and sets the Yes string used in message box buttons. - /// - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"Yes string used for message box buttons.")] - [DefaultValue(DEFAULT_YES)] - [RefreshProperties(RefreshProperties.All)] - public string Yes { get; set; } - - /// - /// Gets and sets the No string used in message box buttons. - /// - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"No string used for message box buttons.")] - [DefaultValue(DEFAULT_NO)] - [RefreshProperties(RefreshProperties.All)] - public string No { get; set; } - - /// - /// Gets and sets the Abort string used in message box buttons. - /// - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"Abort string used for message box buttons.")] - [DefaultValue(DEFAULT_ABORT)] - [RefreshProperties(RefreshProperties.All)] - public string Abort { get; set; } - - /// - /// Gets and sets the Retry string used in message box buttons. - /// - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"Retry string used for message box buttons.")] - [DefaultValue(DEFAULT_RETRY)] - [RefreshProperties(RefreshProperties.All)] - public string Retry { get; set; } - - /// - /// Gets and sets the Ignore string used in message box buttons. - /// - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"Ignore string used for message box buttons.")] - [DefaultValue(DEFAULT_IGNORE)] - [RefreshProperties(RefreshProperties.All)] - public string Ignore { get; set; } - - /// - /// Gets and sets the Close string used in message box buttons. - /// - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"Close string used for message box buttons.")] - [DefaultValue(DEFAULT_CLOSE)] - - [RefreshProperties(RefreshProperties.All)] - public string Close { get; set; } - - /// - /// Gets and sets the Close string used in calendars. - /// - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"Today string used for calendars.")] - [DefaultValue(DEFAULT_TODAY)] - [RefreshProperties(RefreshProperties.All)] - public string Today { get; set; } - - /// - /// Gets and sets the Help string used in message box buttons. - /// - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"Help string used for Message Box Buttons.")] - [DefaultValue(DEFAULT_HELP)] - [RefreshProperties(RefreshProperties.All)] - public string Help { get; set; } - - /// - /// Gets and sets the Continue string used in message box buttons. - /// - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"Continue string used for Message Box Buttons.")] - [DefaultValue(DEFAULT_CONTINUE)] - public string Continue { get; set; } - - /// - /// Gets and sets the Try Again string used in message box buttons. - /// - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"Try Again string used for Message Box Buttons.")] - [DefaultValue(DEFAULT_TRY_AGAIN)] - public string TryAgain { get; set; } - /// Gets or sets the collapse string used in expandable footers. [Localizable(true)] [Category(@"Visuals")] @@ -424,19 +249,7 @@ public void ResetValues() [DefaultValue(DEFAULT_RESET)] public string Reset { get; set; } - // Note: The following may not be needed... - /*/// Gets or sets the more details string used in expandable footers. - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"More details string used in expandable footers.")] - public string MoreDetails { get; set; } - - /// Gets or sets the less details string used in expandable footers. - [Localizable(true)] - [Category(@"Visuals")] - [Description(@"Less details string used in expandable footers.")] - public string LessDetails { get; set; }*/ #endregion } } \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Translations/General/GeneralToolkitStrings.cs b/Source/Krypton Components/Krypton.Toolkit/Translations/General/GeneralToolkitStrings.cs new file mode 100644 index 000000000..03e4f7b99 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Translations/General/GeneralToolkitStrings.cs @@ -0,0 +1,235 @@ +#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 + +// ReSharper disable InconsistentNaming +namespace Krypton.Toolkit +{ + /// Exposes a general set of strings that are used within the Krypton Toolkit, and are localisable. + /// + [TypeConverter(typeof(ExpandableObjectConverter))] + public class GeneralToolkitStrings : GlobalId + { + #region Static Fields + private const string DEFAULT_OK = @"O&K"; // Accelerator key - K + private const string DEFAULT_CANCEL = @"Cance&l"; // Accelerator key - L + private const string DEFAULT_YES = @"&Yes"; // Accelerator key - Y + private const string DEFAULT_NO = @"N&o"; // Accelerator key - O + private const string DEFAULT_ABORT = @"A&bort"; // Accelerator key - B + private const string DEFAULT_RETRY = @"Ret&ry"; // Accelerator key - R + private const string DEFAULT_IGNORE = @"I&gnore"; // Accelerator key - G + private const string DEFAULT_CLOSE = @"Clo&se"; // Accelerator key - S + private const string DEFAULT_TODAY = @"&Today"; // Accelerator key - T + private const string DEFAULT_HELP = @"H&elp"; // Accelerator key - E + + // NET 6 & newer + private const string DEFAULT_CONTINUE = @"Co&ntinue"; // Accelerator key - N + private const string DEFAULT_TRY_AGAIN = @"Try Aga&in"; // Accelerator key - I + + #endregion + + #region Identity + + /// Initializes a new instance of the class. + public GeneralToolkitStrings() + { + Reset(); + } + + /// + /// Returns a string that represents the current defaulted state. + /// + /// A string that represents the current defaulted state. + public override string ToString() => !IsDefault ? "Modified" : string.Empty; + + #endregion + + #region Public + + /// + /// Gets a value indicating if all the strings are default values. + /// + /// True if all values are defaulted; otherwise false. + [Browsable(false)] + public bool IsDefault => OK.Equals(DEFAULT_OK) && + Cancel.Equals(DEFAULT_CANCEL) && + Yes.Equals(DEFAULT_YES) && + No.Equals(DEFAULT_NO) && + Abort.Equals(DEFAULT_ABORT) && + Retry.Equals(DEFAULT_RETRY) && + Ignore.Equals(DEFAULT_IGNORE) && + Close.Equals(DEFAULT_CLOSE) && + Today.Equals(DEFAULT_TODAY) && + Help.Equals(DEFAULT_HELP) && + Continue.Equals(DEFAULT_CONTINUE) && + TryAgain.Equals(DEFAULT_TRY_AGAIN); + + // Note: The following may not be needed... + /*MoreDetails.Equals(DEFAULT_MORE_DETAILS) && + LessDetails.Equals(DEFAULT_LESS_DETAILS);*/ + + /// + /// Reset all strings to default values. + /// + public void Reset() + { + OK = DEFAULT_OK; + Cancel = DEFAULT_CANCEL; + Yes = DEFAULT_YES; + No = DEFAULT_NO; + Abort = DEFAULT_ABORT; + Retry = DEFAULT_RETRY; + Ignore = DEFAULT_IGNORE; + Close = DEFAULT_CLOSE; + Today = DEFAULT_TODAY; + Help = DEFAULT_HELP; + + // NET 6 & newer + Continue = DEFAULT_CONTINUE; + TryAgain = DEFAULT_TRY_AGAIN; + + // Note: The following may not be needed... + /*MoreDetails = DEFAULT_MORE_DETAILS; + LessDetails = DEFAULT_LESS_DETAILS;*/ + } + + /// + /// Gets and sets the OK string used in message box buttons. + /// + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"OK string used for message box buttons.")] + [DefaultValue(DEFAULT_OK)] + [RefreshProperties(RefreshProperties.All)] + public string OK { get; set; } + + /// + /// Gets and sets the Cancel string used in message box buttons. + /// + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"Cancel string used for message box buttons.")] + [DefaultValue(DEFAULT_CANCEL)] + [RefreshProperties(RefreshProperties.All)] + public string Cancel { get; set; } + + /// + /// Gets and sets the Yes string used in message box buttons. + /// + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"Yes string used for message box buttons.")] + [DefaultValue(DEFAULT_YES)] + [RefreshProperties(RefreshProperties.All)] + public string Yes { get; set; } + + /// + /// Gets and sets the No string used in message box buttons. + /// + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"No string used for message box buttons.")] + [DefaultValue(DEFAULT_NO)] + [RefreshProperties(RefreshProperties.All)] + public string No { get; set; } + + /// + /// Gets and sets the Abort string used in message box buttons. + /// + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"Abort string used for message box buttons.")] + [DefaultValue(DEFAULT_ABORT)] + [RefreshProperties(RefreshProperties.All)] + public string Abort { get; set; } + + /// + /// Gets and sets the Retry string used in message box buttons. + /// + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"Retry string used for message box buttons.")] + [DefaultValue(DEFAULT_RETRY)] + [RefreshProperties(RefreshProperties.All)] + public string Retry { get; set; } + + /// + /// Gets and sets the Ignore string used in message box buttons. + /// + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"Ignore string used for message box buttons.")] + [DefaultValue(DEFAULT_IGNORE)] + [RefreshProperties(RefreshProperties.All)] + public string Ignore { get; set; } + + /// + /// Gets and sets the Close string used in message box buttons. + /// + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"Close string used for message box buttons.")] + [DefaultValue(DEFAULT_CLOSE)] + + [RefreshProperties(RefreshProperties.All)] + public string Close { get; set; } + + /// + /// Gets and sets the Close string used in calendars. + /// + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"Today string used for calendars.")] + [DefaultValue(DEFAULT_TODAY)] + [RefreshProperties(RefreshProperties.All)] + public string Today { get; set; } + + /// + /// Gets and sets the Help string used in message box buttons. + /// + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"Help string used for Message Box Buttons.")] + [DefaultValue(DEFAULT_HELP)] + [RefreshProperties(RefreshProperties.All)] + public string Help { get; set; } + + /// + /// Gets and sets the Continue string used in message box buttons. + /// + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"Continue string used for Message Box Buttons.")] + [DefaultValue(DEFAULT_CONTINUE)] + public string Continue { get; set; } + + /// + /// Gets and sets the Try Again string used in message box buttons. + /// + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"Try Again string used for Message Box Buttons.")] + [DefaultValue(DEFAULT_TRY_AGAIN)] + public string TryAgain { get; set; } + + // Note: The following may not be needed... + + /*/// Gets or sets the more details string used in expandable footers. + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"More details string used in expandable footers.")] + public string MoreDetails { get; set; } + + /// Gets or sets the less details string used in expandable footers. + [Localizable(true)] + [Category(@"Visuals")] + [Description(@"Less details string used in expandable footers.")] + public string LessDetails { get; set; }*/ + #endregion + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Values/IntegratedToolBarValues.cs b/Source/Krypton Components/Krypton.Toolkit/Values/IntegratedToolBarValues.cs index 77c765289..d31edc2f1 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Values/IntegratedToolBarValues.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Values/IntegratedToolBarValues.cs @@ -68,20 +68,20 @@ private void SetupIntegratedToolBarButtons() { if (_integratedToolBarItems != null) { - ButtonSpecAny newButtonSpec = new ButtonSpecAny(), - openButtonSpecAny = new ButtonSpecAny(), - saveButtonSpecAny = new ButtonSpecAny(), - saveAsButtonSpecAny = new ButtonSpecAny(), - saveAllButtonSpecAny = new ButtonSpecAny(), - cutButtonSpecAny = new ButtonSpecAny(), - copyButtonSpecAny = new ButtonSpecAny(), - pasteButtonSpecAny = new ButtonSpecAny(), - undoButtonSpecAny = new ButtonSpecAny(), - redoButtonSpecAny = new ButtonSpecAny(), - pageSetupButtonSpecAny = new ButtonSpecAny(), - printPreviewButtonSpecAny = new ButtonSpecAny(), - printButtonSpecAny = new ButtonSpecAny(), - quickPrintButtonSpecAny = new ButtonSpecAny(); + ButtonSpecAny newButtonSpec = new(), + openButtonSpecAny = new(), + saveButtonSpecAny = new(), + saveAsButtonSpecAny = new(), + saveAllButtonSpecAny = new(), + cutButtonSpecAny = new(), + copyButtonSpecAny = new(), + pasteButtonSpecAny = new(), + undoButtonSpecAny = new(), + redoButtonSpecAny = new(), + pageSetupButtonSpecAny = new(), + printPreviewButtonSpecAny = new(), + printButtonSpecAny = new(), + quickPrintButtonSpecAny = new(); // Set up buttons newButtonSpec.Type = PaletteButtonSpecStyle.New; diff --git a/Source/Krypton Components/Krypton.Toolkit/View Base/ViewContextMenuManager.cs b/Source/Krypton Components/Krypton.Toolkit/View Base/ViewContextMenuManager.cs index 168747f61..8bb2df108 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Base/ViewContextMenuManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Base/ViewContextMenuManager.cs @@ -23,7 +23,7 @@ private class TargetList : List { } #region Instance Fields private IContextMenuTarget _target; - private IContextMenuTarget _targetSubMenu; + private IContextMenuTarget? _targetSubMenu; private System.Windows.Forms.Timer _itemDelayTimer; #endregion @@ -311,7 +311,7 @@ public void KeyTab(bool shift) { // Find the currently selected target TargetList targets = ConstructKeyboardTargets(Root); - for(var i=0; i /// Occurs just before the layout cycle. /// - public event EventHandler LayoutBefore; + public event EventHandler? LayoutBefore; /// /// Occurs just after the layout cycle. /// - public event EventHandler LayoutAfter; + public event EventHandler? LayoutAfter; /// /// Occurs when the mouse down event is processed. /// - public event MouseEventHandler MouseDownProcessed; + public event MouseEventHandler? MouseDownProcessed; /// /// Occurs when the mouse up event is processed. /// - public event MouseEventHandler MouseUpProcessed; + public event MouseEventHandler? MouseUpProcessed; /// /// Occurs when the mouse up event is processed. /// - public event PointHandler DoubleClickProcessed; + public event PointHandler? DoubleClickProcessed; #endregion #region Identity @@ -100,7 +100,7 @@ public void Attach(Control control, ViewBase root) /// /// Gets and sets the view root. /// - [DisallowNull] + [DisallowNull] public ViewBase? Root { [DebuggerStepThrough] @@ -713,4 +713,4 @@ protected virtual void UpdateViewFromPoint(Control control, Point pt) } #endregion } -} +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuItem.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuItem.cs index ec75902ce..6748d78cd 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuItem.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuItem.cs @@ -116,7 +116,7 @@ public ViewDrawMenuItem(IContextMenuProvider provider, _textContent = new ViewDrawMenuItemContent(menuItemStyle, _fixedTextExtraText, 1); docker.Add(_textContent, ViewDockStyle.Fill); _textContent.Enabled = ItemEnabled; - + // Shortcut if (KryptonContextMenuItem.ShowShortcutKeys) { @@ -145,7 +145,7 @@ public ViewDrawMenuItem(IContextMenuProvider provider, _subMenuContent = new ViewDrawMenuItemContent(menuItemState.ItemImage.Content, new FixedContentValue(null, null, !HasSubMenu ? _empty16x16 : provider.ProviderImages.GetContextMenuSubMenuImage(), KryptonContextMenuItem.Items.Count == 0 ? Color.Magenta : Color.Empty), 3); docker.Add(new ViewLayoutCenter(_subMenuContent), ViewDockStyle.Right); _subMenuContent.Enabled = ItemEnabled; - + Add(docker); // Add a controller for handing mouse and keyboard events @@ -155,7 +155,7 @@ public ViewDrawMenuItem(IContextMenuProvider provider, // Want to know when a property changes whilst displayed KryptonContextMenuItem.PropertyChanged += OnPropertyChanged; - + // We need to know if a property of the command changes if (KryptonContextMenuItem.KryptonCommand != null) { @@ -191,7 +191,7 @@ protected override void Dispose(bool disposing) } base.Dispose(disposing); - } + } #endregion #region KryptonContextMenuItem @@ -608,10 +608,10 @@ private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) break; } } - + private void OnCommandPropertyChanged(object sender, PropertyChangedEventArgs e) { - switch(e.PropertyName) + switch (e.PropertyName) { case @"Text": case @"ExtraText": diff --git a/Source/Krypton Components/TestForm/Form4.Designer.cs b/Source/Krypton Components/TestForm/Form4.Designer.cs index d123c292b..4ac37f9a7 100644 --- a/Source/Krypton Components/TestForm/Form4.Designer.cs +++ b/Source/Krypton Components/TestForm/Form4.Designer.cs @@ -31,8 +31,9 @@ private void InitializeComponent() this.kryptonNavigator1 = new Krypton.Navigator.KryptonNavigator(); this.kryptonCommand1 = new Krypton.Toolkit.KryptonCommand(); this.kryptonGroupBox1 = new Krypton.Toolkit.KryptonGroupBox(); - this.kryptonCheckBox1 = new Krypton.Toolkit.KryptonCheckBox(); this.kryptonComboBox1 = new Krypton.Toolkit.KryptonComboBox(); + this.kryptonCheckBox1 = new Krypton.Toolkit.KryptonCheckBox(); + this.kryptonPage6 = new Krypton.Navigator.KryptonPage(); ((System.ComponentModel.ISupportInitialize)(this.kryptonNavigator1)).BeginInit(); this.kryptonNavigator1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox1)).BeginInit(); @@ -40,13 +41,13 @@ private void InitializeComponent() this.kryptonGroupBox1.Panel.SuspendLayout(); this.kryptonGroupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.kryptonComboBox1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonPage6)).BeginInit(); this.SuspendLayout(); // // kryptonNavigator1 // this.kryptonNavigator1.ControlKryptonFormFeatures = false; - this.kryptonNavigator1.Location = new System.Drawing.Point(634, 41); - this.kryptonNavigator1.Margin = new System.Windows.Forms.Padding(4); + this.kryptonNavigator1.Location = new System.Drawing.Point(476, 33); this.kryptonNavigator1.Name = "kryptonNavigator1"; this.kryptonNavigator1.NavigatorMode = Krypton.Navigator.NavigatorMode.BarTabGroup; this.kryptonNavigator1.Owner = null; @@ -61,43 +62,57 @@ private void InitializeComponent() // // kryptonGroupBox1 // - this.kryptonGroupBox1.Location = new System.Drawing.Point(65, 66); + this.kryptonGroupBox1.Location = new System.Drawing.Point(49, 54); + this.kryptonGroupBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.kryptonGroupBox1.Name = "kryptonGroupBox1"; // // kryptonGroupBox1.Panel // this.kryptonGroupBox1.Panel.Controls.Add(this.kryptonComboBox1); this.kryptonGroupBox1.Panel.Controls.Add(this.kryptonCheckBox1); - this.kryptonGroupBox1.Size = new System.Drawing.Size(278, 255); + this.kryptonGroupBox1.Size = new System.Drawing.Size(208, 207); this.kryptonGroupBox1.TabIndex = 1; // - // kryptonCheckBox1 - // - this.kryptonCheckBox1.Location = new System.Drawing.Point(46, 23); - this.kryptonCheckBox1.Name = "kryptonCheckBox1"; - this.kryptonCheckBox1.Size = new System.Drawing.Size(152, 24); - this.kryptonCheckBox1.TabIndex = 0; - this.kryptonCheckBox1.Values.Text = "kryptonCheckBox1"; - // // kryptonComboBox1 // this.kryptonComboBox1.DropDownWidth = 121; this.kryptonComboBox1.IntegralHeight = false; - this.kryptonComboBox1.Location = new System.Drawing.Point(28, 99); + this.kryptonComboBox1.Location = new System.Drawing.Point(21, 80); + this.kryptonComboBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.kryptonComboBox1.Name = "kryptonComboBox1"; - this.kryptonComboBox1.Size = new System.Drawing.Size(121, 25); + this.kryptonComboBox1.Size = new System.Drawing.Size(91, 21); this.kryptonComboBox1.StateCommon.ComboBox.Content.TextH = Krypton.Toolkit.PaletteRelativeAlign.Near; this.kryptonComboBox1.TabIndex = 1; this.kryptonComboBox1.Text = "kryptonComboBox1"; // + // kryptonCheckBox1 + // + this.kryptonCheckBox1.Location = new System.Drawing.Point(34, 19); + this.kryptonCheckBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.kryptonCheckBox1.Name = "kryptonCheckBox1"; + this.kryptonCheckBox1.Size = new System.Drawing.Size(125, 20); + this.kryptonCheckBox1.TabIndex = 0; + this.kryptonCheckBox1.Values.Text = "kryptonCheckBox1"; + // + // kryptonPage6 + // + this.kryptonPage6.AutoHiddenSlideSize = new System.Drawing.Size(200, 200); + this.kryptonPage6.Flags = 65534; + this.kryptonPage6.LastVisibleSet = true; + this.kryptonPage6.MinimumSize = new System.Drawing.Size(150, 50); + this.kryptonPage6.Name = "kryptonPage6"; + this.kryptonPage6.Size = new System.Drawing.Size(150, 100); + this.kryptonPage6.Text = "kryptonPage6"; + this.kryptonPage6.ToolTipTitle = "Page ToolTip"; + this.kryptonPage6.UniqueName = "4efe7db16ebe4584a708f5d09fc41c1e"; + // // Form4 // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1067, 554); + this.ClientSize = new System.Drawing.Size(800, 450); this.Controls.Add(this.kryptonGroupBox1); this.Controls.Add(this.kryptonNavigator1); - this.Margin = new System.Windows.Forms.Padding(4); this.Name = "Form4"; this.Text = "Form4"; ((System.ComponentModel.ISupportInitialize)(this.kryptonNavigator1)).EndInit(); @@ -108,6 +123,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox1)).EndInit(); this.kryptonGroupBox1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.kryptonComboBox1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonPage6)).EndInit(); this.ResumeLayout(false); } @@ -121,5 +137,6 @@ private void InitializeComponent() private Krypton.Toolkit.KryptonGroupBox kryptonGroupBox1; private Krypton.Toolkit.KryptonComboBox kryptonComboBox1; private Krypton.Toolkit.KryptonCheckBox kryptonCheckBox1; + private Krypton.Navigator.KryptonPage kryptonPage6; } } \ No newline at end of file