diff --git a/Source/Krypton Components/Krypton.Navigator/Navigator/KryptonPageDesigner.cs b/Source/Krypton Components/Krypton.Navigator/Navigator/KryptonPageDesigner.cs index 13d333afb..91df54f6c 100644 --- a/Source/Krypton Components/Krypton.Navigator/Navigator/KryptonPageDesigner.cs +++ b/Source/Krypton Components/Krypton.Navigator/Navigator/KryptonPageDesigner.cs @@ -76,7 +76,7 @@ public override bool CanBeParentedTo(IDesigner parentDesigner) => /// /// Gets the collection of components associated with the component managed by the designer. /// - public override ICollection AssociatedComponents => _page != null ? _page.ButtonSpecs : base.AssociatedComponents; + public override ICollection AssociatedComponents => _page?.ButtonSpecs ?? base.AssociatedComponents; /// /// Gets the design-time action lists supported by the component associated with the designer. diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonBreadCrumbItemDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonBreadCrumbItemDesigner.cs index 023a32f82..a36e4f338 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonBreadCrumbItemDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonBreadCrumbItemDesigner.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonBreadCrumbItemDesigner : ComponentDesigner { #region Instance Fields - private KryptonBreadCrumbItem _crumbItem; + private KryptonBreadCrumbItem? _crumbItem; private IComponentChangeService _changeService; #endregion @@ -48,7 +48,7 @@ public override ICollection AssociatedComponents { get { - ArrayList compound = new ArrayList(base.AssociatedComponents); + var compound = new ArrayList(base.AssociatedComponents); if (_crumbItem != null) { diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonButtonDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonButtonDesigner.cs index 9c10d2b2f..9aa303912 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonButtonDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonButtonDesigner.cs @@ -35,9 +35,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the button specific list new KryptonButtonActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckBoxDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckBoxDesigner.cs index 84c8e168f..94aafba50 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckBoxDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckBoxDesigner.cs @@ -35,9 +35,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the checkbox specific list new KryptonCheckBoxActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckButtonDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckButtonDesigner.cs index 2bce328e9..e3dd8c099 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckButtonDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckButtonDesigner.cs @@ -23,9 +23,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the check button specific list new KryptonCheckButtonActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckSetDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckSetDesigner.cs index 14ed3100f..26fc81a62 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckSetDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckSetDesigner.cs @@ -23,9 +23,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the panel specific list new KryptonCheckSetActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckedListBoxDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckedListBoxDesigner.cs index fdf6ada37..1508093fb 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckedListBoxDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCheckedListBoxDesigner.cs @@ -38,9 +38,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonCheckedListBoxActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonColorButtonDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonColorButtonDesigner.cs index c93fd67a6..d5dd3f7ca 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonColorButtonDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonColorButtonDesigner.cs @@ -35,9 +35,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the color button specific list new KryptonColorButtonActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonComboBoxDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonComboBoxDesigner.cs index f6487cb6d..bbb94c532 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonComboBoxDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonComboBoxDesigner.cs @@ -16,7 +16,7 @@ internal class KryptonComboBoxDesigner : ControlDesigner { #region Instance Fields private bool _lastHitTest; - private KryptonComboBox _comboBox; + private KryptonComboBox? _comboBox; private IDesignerHost _designerHost; private IComponentChangeService _changeService; private ISelectionService _selectionService; @@ -62,7 +62,7 @@ public override void Initialize([DisallowNull] IComponent component) /// Gets the collection of components associated with the component managed by the designer. /// public override ICollection AssociatedComponents => - _comboBox != null ? _comboBox.ButtonSpecs : base.AssociatedComponents; + _comboBox?.ButtonSpecs ?? base.AssociatedComponents; /// /// Gets the selection rules that indicate the movement capabilities of a component. @@ -86,9 +86,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonComboBoxActionList(this) }; @@ -144,15 +143,15 @@ private void OnComboBoxMouseUp(object sender, MouseEventArgs e) if (e.Button == MouseButtons.Left) { // Get any component associated with the current mouse position - Component component = _comboBox?.DesignerComponentFromPoint(new Point(e.X, e.Y)); + Component? component = _comboBox?.DesignerComponentFromPoint(new Point(e.X, e.Y)); if (component != null) { // Force the layout to be update for any change in selection - _comboBox.PerformLayout(); + _comboBox!.PerformLayout(); // Select the component - ArrayList selectionList = new ArrayList + var selectionList = new ArrayList { component }; @@ -164,7 +163,7 @@ private void OnComboBoxMouseUp(object sender, MouseEventArgs e) private void OnComboBoxDoubleClick(object sender, Point pt) { // Get any component associated with the current mouse position - Component component = _comboBox?.DesignerComponentFromPoint(pt); + Component? component = _comboBox?.DesignerComponentFromPoint(pt); if (component != null) { diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCommandDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCommandDesigner.cs index b1a3ad981..5ce8d2e22 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCommandDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonCommandDesigner.cs @@ -23,9 +23,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the palette specific list new KryptonCommandActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonContextMenuDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonContextMenuDesigner.cs index 4065fb870..f3c80b40c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonContextMenuDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonContextMenuDesigner.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonContextMenuDesigner : ComponentDesigner { #region Instance Fields - private KryptonContextMenu _contextMenu; + private KryptonContextMenu? _contextMenu; private IComponentChangeService _changeService; #endregion @@ -48,7 +48,7 @@ public override ICollection AssociatedComponents { get { - ArrayList compound = new ArrayList(base.AssociatedComponents); + var compound = new ArrayList(base.AssociatedComponents); if (_contextMenu != null) { @@ -67,7 +67,7 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { // Add the palette specific list new KryptonContextMenuActionList(this) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonContextMenuItemDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonContextMenuItemDesigner.cs index d36a31094..9db10c009 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonContextMenuItemDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonContextMenuItemDesigner.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonContextMenuItemDesigner : ComponentDesigner { #region Instance Fields - private KryptonContextMenuItem _contextMenuItem; + private KryptonContextMenuItem? _contextMenuItem; private IComponentChangeService _changeService; #endregion @@ -48,7 +48,7 @@ public override ICollection AssociatedComponents { get { - ArrayList compound = new ArrayList(base.AssociatedComponents); + var compound = new ArrayList(base.AssociatedComponents); if (_contextMenuItem != null) { diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonContextMenuItemsDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonContextMenuItemsDesigner.cs index c4024b9ba..1b337eb1a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonContextMenuItemsDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonContextMenuItemsDesigner.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonContextMenuItemsDesigner : ComponentDesigner { #region Instance Fields - private KryptonContextMenuItems _contextMenuItems; + private KryptonContextMenuItems? _contextMenuItems; private IComponentChangeService _changeService; #endregion @@ -48,7 +48,7 @@ public override ICollection AssociatedComponents { get { - ArrayList compound = new ArrayList(base.AssociatedComponents); + var compound = new ArrayList(base.AssociatedComponents); if (_contextMenuItems != null) { diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonDateTimePickerDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonDateTimePickerDesigner.cs index 762fea294..5d9e13747 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonDateTimePickerDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonDateTimePickerDesigner.cs @@ -16,7 +16,7 @@ internal class KryptonDateTimePickerDesigner : ControlDesigner { #region Instance Fields private bool _lastHitTest; - private KryptonDateTimePicker _dateTimePicker; + private KryptonDateTimePicker? _dateTimePicker; private IDesignerHost _designerHost; private IComponentChangeService _changeService; private ISelectionService _selectionService; @@ -62,7 +62,7 @@ public override void Initialize([DisallowNull] IComponent component) /// Gets the collection of components associated with the component managed by the designer. /// public override ICollection AssociatedComponents => - _dateTimePicker != null ? _dateTimePicker.ButtonSpecs : base.AssociatedComponents; + _dateTimePicker?.ButtonSpecs ?? base.AssociatedComponents; /// /// Gets the design-time action lists supported by the component associated with the designer. @@ -72,9 +72,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the bread crumb specific list new KryptonDateTimePickerActionList(this) }; @@ -163,7 +162,7 @@ private void OnDateTimePickerMouseUp(object sender, MouseEventArgs e) if ((_dateTimePicker != null) && (e.Button == MouseButtons.Left)) { // Get any component associated with the current mouse position - Component component = _dateTimePicker.DesignerComponentFromPoint(new Point(e.X, e.Y)); + Component? component = _dateTimePicker.DesignerComponentFromPoint(new Point(e.X, e.Y)); if (component != null) { @@ -171,7 +170,7 @@ private void OnDateTimePickerMouseUp(object sender, MouseEventArgs e) _dateTimePicker.PerformLayout(); // Select the component - ArrayList selectionList = new ArrayList + var selectionList = new ArrayList { component }; @@ -183,7 +182,7 @@ private void OnDateTimePickerMouseUp(object sender, MouseEventArgs e) private void OnDateTimePickerDoubleClick(object sender, Point pt) { // Get any component associated with the current mouse position - Component component = _dateTimePicker.DesignerComponentFromPoint(pt); + Component? component = _dateTimePicker.DesignerComponentFromPoint(pt); if (component != null) { @@ -201,7 +200,7 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) if (e.Component == _dateTimePicker) { // Need access to host in order to delete a component - IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + var host = (IDesignerHost)GetService(typeof(IDesignerHost)); // We need to remove all the button spec instances for (var i = _dateTimePicker.ButtonSpecs.Count - 1; i >= 0; i--) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonDomainUpDownDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonDomainUpDownDesigner.cs index 147f880ae..e6f447e86 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonDomainUpDownDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonDomainUpDownDesigner.cs @@ -16,7 +16,7 @@ internal class KryptonDomainUpDownDesigner : ControlDesigner { #region Instance Fields private bool _lastHitTest; - private KryptonDomainUpDown _domainUpDown; + private KryptonDomainUpDown? _domainUpDown; private IDesignerHost _designerHost; private IComponentChangeService _changeService; private ISelectionService _selectionService; @@ -62,7 +62,7 @@ public override void Initialize([DisallowNull] IComponent component) /// Gets the collection of components associated with the component managed by the designer. /// public override ICollection AssociatedComponents => - _domainUpDown != null ? _domainUpDown.ButtonSpecs : base.AssociatedComponents; + _domainUpDown?.ButtonSpecs ?? base.AssociatedComponents; /// /// Gets the selection rules that indicate the movement capabilities of a component. @@ -89,9 +89,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonDomainUpDownActionList(this) }; @@ -147,7 +146,7 @@ private void OnDomainUpDownMouseUp(object sender, MouseEventArgs e) if ((_domainUpDown != null) && (e.Button == MouseButtons.Left)) { // Get any component associated with the current mouse position - Component component = _domainUpDown.DesignerComponentFromPoint(new Point(e.X, e.Y)); + Component? component = _domainUpDown.DesignerComponentFromPoint(new Point(e.X, e.Y)); if (component != null) { @@ -155,7 +154,7 @@ private void OnDomainUpDownMouseUp(object sender, MouseEventArgs e) _domainUpDown.PerformLayout(); // Select the component - ArrayList selectionList = new ArrayList + var selectionList = new ArrayList { component }; @@ -167,7 +166,7 @@ private void OnDomainUpDownMouseUp(object sender, MouseEventArgs e) private void OnDomainUpDownDoubleClick(object sender, Point pt) { // Get any component associated with the current mouse position - Component component = _domainUpDown?.DesignerComponentFromPoint(pt); + Component? component = _domainUpDown?.DesignerComponentFromPoint(pt); if (component != null) { @@ -185,7 +184,7 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) if ((_domainUpDown != null) && (e.Component == _domainUpDown)) { // Need access to host in order to delete a component - IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + var host = (IDesignerHost)GetService(typeof(IDesignerHost)); // We need to remove all the button spec instances for (var i = _domainUpDown.ButtonSpecs.Count - 1; i >= 0; i--) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonDropButtonDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonDropButtonDesigner.cs index 772cfbbf1..c24778dea 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonDropButtonDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonDropButtonDesigner.cs @@ -35,9 +35,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the drop down button specific list new KryptonDropButtonActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonGroupBoxDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonGroupBoxDesigner.cs index 26a0279c5..cf09cb58c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonGroupBoxDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonGroupBoxDesigner.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonGroupBoxDesigner : ParentControlDesigner { #region Instance Fields - private KryptonGroupBox _groupBox; + private KryptonGroupBox? _groupBox; private IDesignerHost _designerHost; #endregion @@ -83,7 +83,7 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { // Add the group box specific list new KryptonGroupBoxActionList(this) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonGroupDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonGroupDesigner.cs index 28f4fe72b..22a01a15e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonGroupDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonGroupDesigner.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonGroupDesigner : ParentControlDesigner { #region Instance Fields - private KryptonGroup _group; + private KryptonGroup? _group; private IDesignerHost _designerHost; #endregion @@ -81,7 +81,7 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + DesignerActionListCollection? actionLists = new DesignerActionListCollection { // Add the group specific list new KryptonGroupActionList(this) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonHeaderDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonHeaderDesigner.cs index 461f9a6f4..cc80b383b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonHeaderDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonHeaderDesigner.cs @@ -16,7 +16,7 @@ internal class KryptonHeaderDesigner : ControlDesigner { #region Instance Fields private bool _lastHitTest; - private KryptonHeader _header; + private KryptonHeader? _header; private IDesignerHost _designerHost; private IComponentChangeService _changeService; private ISelectionService _selectionService; @@ -87,7 +87,7 @@ public override void Initialize([DisallowNull] IComponent component) /// Gets the collection of components associated with the component managed by the designer. /// public override ICollection AssociatedComponents => - _header != null ? _header.ButtonSpecs : base.AssociatedComponents; + _header?.ButtonSpecs ?? base.AssociatedComponents; /// /// Gets the design-time action lists supported by the component associated with the designer. @@ -97,9 +97,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the header specific list new KryptonHeaderActionList(this) }; @@ -157,7 +156,7 @@ private void OnHeaderMouseUp(object sender, MouseEventArgs e) if ((_header != null) && (e.Button == MouseButtons.Left)) { // Get any component associated with the current mouse position - Component component = _header.DesignerComponentFromPoint(new Point(e.X, e.Y)); + Component? component = _header.DesignerComponentFromPoint(new Point(e.X, e.Y)); if (component != null) { @@ -165,7 +164,7 @@ private void OnHeaderMouseUp(object sender, MouseEventArgs e) _header.PerformLayout(); // Select the component - ArrayList selectionList = new ArrayList + var selectionList = new ArrayList { component }; @@ -177,7 +176,7 @@ private void OnHeaderMouseUp(object sender, MouseEventArgs e) private void OnHeaderDoubleClick(object sender, Point pt) { // Get any component associated with the current mouse position - Component component = _header?.DesignerComponentFromPoint(pt); + Component? component = _header?.DesignerComponentFromPoint(pt); if (component != null) { @@ -195,7 +194,7 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) if ((_header != null) && (e.Component == _header)) { // Need access to host in order to delete a component - IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + var host = (IDesignerHost)GetService(typeof(IDesignerHost)); // We need to remove all the button spec instances for (var i = _header.ButtonSpecs.Count - 1; i >= 0; i--) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonHeaderGroupDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonHeaderGroupDesigner.cs index c1ad6f0d2..088d6b72e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonHeaderGroupDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonHeaderGroupDesigner.cs @@ -16,7 +16,7 @@ internal class KryptonHeaderGroupDesigner : ParentControlDesigner { #region Instance Fields private bool _lastHitTest; - private KryptonHeaderGroup _headerGroup; + private KryptonHeaderGroup? _headerGroup; private IDesignerHost _designerHost; private IComponentChangeService _changeService; private ISelectionService _selectionService; @@ -103,7 +103,7 @@ public override ICollection AssociatedComponents else { // Create a new collection for both values - ArrayList compound = new ArrayList(baseComponents); + var compound = new ArrayList(baseComponents); // Add all the button specs to the end compound.AddRange(_headerGroup.ButtonSpecs); @@ -145,9 +145,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the header group specific list new KryptonHeaderGroupActionList(this) }; @@ -205,7 +204,7 @@ private void OnHeaderGroupMouseUp(object sender, MouseEventArgs e) if ((_headerGroup != null) && (e.Button == MouseButtons.Left)) { // Get any component associated with the current mouse position - Component component = _headerGroup.DesignerComponentFromPoint(new Point(e.X, e.Y)); + Component? component = _headerGroup.DesignerComponentFromPoint(new Point(e.X, e.Y)); if (component != null) { @@ -213,7 +212,7 @@ private void OnHeaderGroupMouseUp(object sender, MouseEventArgs e) _headerGroup.PerformLayout(); // Select the component - ArrayList selectionList = new ArrayList + var selectionList = new ArrayList { component }; @@ -225,7 +224,7 @@ private void OnHeaderGroupMouseUp(object sender, MouseEventArgs e) private void OnHeaderGroupDoubleClick(object sender, Point pt) { // Get any component associated with the current mouse position - Component component = _headerGroup.DesignerComponentFromPoint(pt); + Component? component = _headerGroup.DesignerComponentFromPoint(pt); if (component != null) { @@ -243,7 +242,7 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) if (e.Component == _headerGroup) { // Need access to host in order to delete a component - IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + var host = (IDesignerHost)GetService(typeof(IDesignerHost)); // We need to remove all the button spec instances for (var i = _headerGroup.ButtonSpecs.Count - 1; i >= 0; i--) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLabelDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLabelDesigner.cs index 4e2bacc97..34d7b1ca2 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLabelDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLabelDesigner.cs @@ -35,9 +35,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonLabelActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLanguageManagerDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLanguageManagerDesigner.cs index f812483ee..065b68f03 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLanguageManagerDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLanguageManagerDesigner.cs @@ -17,7 +17,7 @@ public override DesignerActionListCollection ActionLists { get { - DesignerActionListCollection actionList = new DesignerActionListCollection + var actionList = new DesignerActionListCollection { new KryptonLanguageManagerActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLinkLabelDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLinkLabelDesigner.cs index 0981d1fad..dc50c4fec 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLinkLabelDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLinkLabelDesigner.cs @@ -35,9 +35,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonLinkLabelActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLinkWrapLabelDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLinkWrapLabelDesigner.cs index e6107de5e..c8723cfef 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLinkWrapLabelDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonLinkWrapLabelDesigner.cs @@ -31,9 +31,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the wrap label specific list new KryptonLinkWrapLabelActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonListBoxDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonListBoxDesigner.cs index 46426fa5c..a0eafc492 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonListBoxDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonListBoxDesigner.cs @@ -40,9 +40,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonListBoxActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonListViewDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonListViewDesigner.cs index 92be89c80..512f0c496 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonListViewDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonListViewDesigner.cs @@ -40,9 +40,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonListViewActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonManagerDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonManagerDesigner.cs index c1c29e507..5c256c527 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonManagerDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonManagerDesigner.cs @@ -23,9 +23,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the manager specific list new KryptonManagerActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonMaskedTextBoxDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonMaskedTextBoxDesigner.cs index b34433900..c9a254a01 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonMaskedTextBoxDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonMaskedTextBoxDesigner.cs @@ -16,7 +16,7 @@ internal class KryptonMaskedTextBoxDesigner : ControlDesigner { #region Instance Fields private bool _lastHitTest; - private KryptonMaskedTextBox _maskedTextBox; + private KryptonMaskedTextBox? _maskedTextBox; private IDesignerHost _designerHost; private IComponentChangeService _changeService; private ISelectionService _selectionService; @@ -62,7 +62,7 @@ public override void Initialize([DisallowNull] IComponent component) /// Gets the collection of components associated with the component managed by the designer. /// public override ICollection AssociatedComponents => - _maskedTextBox != null ? _maskedTextBox.ButtonSpecs : base.AssociatedComponents; + _maskedTextBox?.ButtonSpecs ?? base.AssociatedComponents; /// /// Gets the selection rules that indicate the movement capabilities of a component. @@ -75,7 +75,7 @@ public override SelectionRules SelectionRules SelectionRules rules = base.SelectionRules; // Get access to the actual control instance - KryptonMaskedTextBox maskedTextBox = (KryptonMaskedTextBox)Component; + var maskedTextBox = (KryptonMaskedTextBox)Component; // With multiline and autosize we prevent the user changing the height if (maskedTextBox.AutoSize) @@ -95,9 +95,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonMaskedTextBoxActionList(this) }; @@ -153,7 +152,7 @@ private void OnMaskedTextBoxMouseUp(object sender, MouseEventArgs e) if ((_maskedTextBox != null) && (e.Button == MouseButtons.Left)) { // Get any component associated with the current mouse position - Component component = _maskedTextBox.DesignerComponentFromPoint(new Point(e.X, e.Y)); + Component? component = _maskedTextBox.DesignerComponentFromPoint(new Point(e.X, e.Y)); if (component != null) { @@ -161,7 +160,7 @@ private void OnMaskedTextBoxMouseUp(object sender, MouseEventArgs e) _maskedTextBox.PerformLayout(); // Select the component - ArrayList selectionList = new ArrayList + var selectionList = new ArrayList { component }; @@ -173,7 +172,7 @@ private void OnMaskedTextBoxMouseUp(object sender, MouseEventArgs e) private void OnMaskedTextBoxDoubleClick(object sender, Point pt) { // Get any component associated with the current mouse position - Component component = _maskedTextBox.DesignerComponentFromPoint(pt); + Component? component = _maskedTextBox.DesignerComponentFromPoint(pt); if (component != null) { @@ -191,7 +190,7 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) if (e.Component == _maskedTextBox) { // Need access to host in order to delete a component - IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + var host = (IDesignerHost)GetService(typeof(IDesignerHost)); // We need to remove all the button spec instances for (var i = _maskedTextBox.ButtonSpecs.Count - 1; i >= 0; i--) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonMonthCalendarDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonMonthCalendarDesigner.cs index 7305e4615..d5dbb4c02 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonMonthCalendarDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonMonthCalendarDesigner.cs @@ -16,7 +16,7 @@ internal class KryptonMonthCalendarDesigner : ControlDesigner { #region Instance Fields private bool _lastHitTest; - private KryptonMonthCalendar _monthCalendar; + private KryptonMonthCalendar? _monthCalendar; private IDesignerHost _designerHost; private IComponentChangeService _changeService; private ISelectionService _selectionService; @@ -77,7 +77,7 @@ public override ICollection AssociatedComponents else { // Create a new collection for both values - ArrayList compound = new ArrayList(baseComponents); + var compound = new ArrayList(baseComponents); // Add all the button specs to the end compound.AddRange(_monthCalendar.ButtonSpecs); @@ -95,9 +95,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the bread crumb specific list new KryptonMonthCalendarActionList(this) }; @@ -186,7 +185,7 @@ private void OnCalendarMouseUp(object sender, MouseEventArgs e) if ((_monthCalendar != null) && (e.Button == MouseButtons.Left)) { // Get any component associated with the current mouse position - Component component = _monthCalendar.DesignerComponentFromPoint(new Point(e.X, e.Y)); + Component? component = _monthCalendar.DesignerComponentFromPoint(new Point(e.X, e.Y)); if (component != null) { @@ -194,7 +193,7 @@ private void OnCalendarMouseUp(object sender, MouseEventArgs e) _monthCalendar.PerformLayout(); // Select the component - ArrayList selectionList = new ArrayList + ArrayList? selectionList = new ArrayList { component }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonNumericUpDownDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonNumericUpDownDesigner.cs index 0b0d14be9..746fb3708 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonNumericUpDownDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonNumericUpDownDesigner.cs @@ -16,7 +16,7 @@ internal class KryptonNumericUpDownDesigner : ControlDesigner { #region Instance Fields private bool _lastHitTest; - private KryptonNumericUpDown _numericUpDown; + private KryptonNumericUpDown? _numericUpDown; private IDesignerHost _designerHost; private IComponentChangeService _changeService; private ISelectionService _selectionService; @@ -62,7 +62,7 @@ public override void Initialize([DisallowNull] IComponent component) /// Gets the collection of components associated with the component managed by the designer. /// public override ICollection AssociatedComponents => - _numericUpDown != null ? _numericUpDown.ButtonSpecs : base.AssociatedComponents; + _numericUpDown?.ButtonSpecs ?? base.AssociatedComponents; /// /// Gets the selection rules that indicate the movement capabilities of a component. @@ -89,9 +89,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonNumericUpDownActionList(this) }; @@ -147,7 +146,7 @@ private void OnNumericUpDownMouseUp(object sender, MouseEventArgs e) if ((_numericUpDown != null) && (e.Button == MouseButtons.Left)) { // Get any component associated with the current mouse position - Component component = _numericUpDown.DesignerComponentFromPoint(new Point(e.X, e.Y)); + Component? component = _numericUpDown.DesignerComponentFromPoint(new Point(e.X, e.Y)); if (component != null) { @@ -155,7 +154,7 @@ private void OnNumericUpDownMouseUp(object sender, MouseEventArgs e) _numericUpDown.PerformLayout(); // Select the component - ArrayList selectionList = new ArrayList + ArrayList? selectionList = new ArrayList { component }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonPaletteDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonPaletteDesigner.cs index 1c4e1b45c..266a82f9a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonPaletteDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonPaletteDesigner.cs @@ -23,9 +23,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the palette specific list new KryptonPaletteActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonPanelDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonPanelDesigner.cs index 6d82b645a..6d769409b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonPanelDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonPanelDesigner.cs @@ -35,9 +35,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the panel specific list new KryptonPanelActionList(this) }; @@ -66,7 +65,7 @@ protected override void OnPaintAdornments(PaintEventArgs pe) private void DrawBorder(Graphics graphics) { // Create a pen for drawing - using Pen borderPen = new Pen(SystemColors.ControlDarkDark); + using var borderPen = new Pen(SystemColors.ControlDarkDark); // Always draw the border dashed borderPen.DashStyle = DashStyle.Dash; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonPropertyGridDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonPropertyGridDesigner.cs index 9d4571631..98da6d50a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonPropertyGridDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonPropertyGridDesigner.cs @@ -26,7 +26,7 @@ public override DesignerActionListCollection ActionLists { get { - DesignerActionListCollection actionList = new DesignerActionListCollection + var actionList = new DesignerActionListCollection { new KryptonPropertyGridActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonRadioButtonDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonRadioButtonDesigner.cs index efe80aca3..11c986e8f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonRadioButtonDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonRadioButtonDesigner.cs @@ -35,9 +35,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the checkbox specific list new KryptonRadioButtonActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonRichTextBoxDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonRichTextBoxDesigner.cs index cd1172a3a..687ced2fc 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonRichTextBoxDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonRichTextBoxDesigner.cs @@ -16,7 +16,7 @@ internal class KryptonRichTextBoxDesigner : ControlDesigner { #region Instance Fields private bool _lastHitTest; - private KryptonRichTextBox _richTextBox; + private KryptonRichTextBox? _richTextBox; private IDesignerHost _designerHost; private IComponentChangeService _changeService; private ISelectionService _selectionService; @@ -62,7 +62,7 @@ public override void Initialize([DisallowNull] IComponent component) /// Gets the collection of components associated with the component managed by the designer. /// public override ICollection AssociatedComponents => - _richTextBox != null ? _richTextBox.ButtonSpecs : base.AssociatedComponents; + _richTextBox?.ButtonSpecs ?? base.AssociatedComponents; /// /// Gets the selection rules that indicate the movement capabilities of a component. @@ -75,7 +75,7 @@ public override SelectionRules SelectionRules SelectionRules rules = base.SelectionRules; // Get access to the actual control instance - KryptonRichTextBox richTextBox = (KryptonRichTextBox)Component; + var richTextBox = (KryptonRichTextBox)Component; // With multiline and autosize we prevent the user changing the height if (richTextBox is { Multiline: false, AutoSize: true }) @@ -95,9 +95,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonRichTextBoxActionList(this) }; @@ -153,7 +152,7 @@ private void OnTextBoxMouseUp(object sender, MouseEventArgs e) if ((_richTextBox != null) && (e.Button == MouseButtons.Left)) { // Get any component associated with the current mouse position - Component component = _richTextBox.DesignerComponentFromPoint(new Point(e.X, e.Y)); + Component? component = _richTextBox.DesignerComponentFromPoint(new Point(e.X, e.Y)); if (component != null) { @@ -161,7 +160,7 @@ private void OnTextBoxMouseUp(object sender, MouseEventArgs e) _richTextBox.PerformLayout(); // Select the component - ArrayList selectionList = new ArrayList + var selectionList = new ArrayList { component }; @@ -173,7 +172,7 @@ private void OnTextBoxMouseUp(object sender, MouseEventArgs e) private void OnTextBoxDoubleClick(object sender, Point pt) { // Get any component associated with the current mouse position - Component component = _richTextBox.DesignerComponentFromPoint(pt); + Component? component = _richTextBox?.DesignerComponentFromPoint(pt); if (component != null) { @@ -191,7 +190,7 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) if (e.Component == _richTextBox) { // Need access to host in order to delete a component - IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + var host = (IDesignerHost)GetService(typeof(IDesignerHost)); // We need to remove all the button spec instances for (var i = _richTextBox.ButtonSpecs.Count - 1; i >= 0; i--) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonScrollBarDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonScrollBarDesigner.cs index 493443e9e..413140ea9 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonScrollBarDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonScrollBarDesigner.cs @@ -30,7 +30,7 @@ public override DesignerActionListCollection ActionLists { get { - DesignerActionListCollection actionList = new DesignerActionListCollection + var actionList = new DesignerActionListCollection { new KryptonScrollBarActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonSeparatorDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonSeparatorDesigner.cs index 1a85fe42c..99171dec2 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonSeparatorDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonSeparatorDesigner.cs @@ -35,9 +35,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonSeparatorActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonSplitContainerDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonSplitContainerDesigner.cs index 936d42646..6c1e01202 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonSplitContainerDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonSplitContainerDesigner.cs @@ -126,9 +126,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the orientation list new KryptonSplitContainerActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonSplitterPanelDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonSplitterPanelDesigner.cs index dfdfb9723..5fd23dc8b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonSplitterPanelDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonSplitterPanelDesigner.cs @@ -218,7 +218,7 @@ private void DrawWaterMark(Graphics g) var drawText = Control.Name; // Use a fixed font for the drawing - using Font f = new Font("Arial", 8f); + using var f = new Font("Arial", 8f); try { // Measure the size of the text @@ -234,7 +234,10 @@ private void DrawWaterMark(Graphics g) Color.Black, TextFormatFlags.GlyphOverhangPadding); } - catch { } + catch + { + // TODO: Call krypton logging + } } #endregion } diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonTextBoxDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonTextBoxDesigner.cs index 7b943cf1a..1317df22c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonTextBoxDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonTextBoxDesigner.cs @@ -16,7 +16,7 @@ internal class KryptonTextBoxDesigner : ControlDesigner { #region Instance Fields private bool _lastHitTest; - private KryptonTextBox _textBox; + private KryptonTextBox? _textBox; private IDesignerHost _designerHost; private IComponentChangeService _changeService; private ISelectionService _selectionService; @@ -62,7 +62,7 @@ public override void Initialize([DisallowNull] IComponent component) /// Gets the collection of components associated with the component managed by the designer. /// public override ICollection AssociatedComponents => - _textBox != null ? _textBox.ButtonSpecs : base.AssociatedComponents; + _textBox?.ButtonSpecs ?? base.AssociatedComponents; /// /// Gets the selection rules that indicate the movement capabilities of a component. @@ -75,7 +75,7 @@ public override SelectionRules SelectionRules SelectionRules rules = base.SelectionRules; // Get access to the actual control instance - KryptonTextBox textBox = (KryptonTextBox)Component; + var textBox = (KryptonTextBox)Component; // With multiline or autosize we prevent the user changing the height if (textBox is { Multiline: false, AutoSize: true }) @@ -95,9 +95,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonTextBoxActionList(this) }; @@ -161,7 +160,7 @@ private void OnTextBoxMouseUp(object sender, MouseEventArgs e) _textBox.PerformLayout(); // Select the component - ArrayList selectionList = new ArrayList + var selectionList = new ArrayList { component }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonTrackBarDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonTrackBarDesigner.cs index 4a5ca04d7..379e19ffc 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonTrackBarDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonTrackBarDesigner.cs @@ -66,9 +66,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the button specific list new KryptonTrackBarActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonTreeViewDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonTreeViewDesigner.cs index bb38ed366..885064f76 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonTreeViewDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonTreeViewDesigner.cs @@ -40,9 +40,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the label specific list new KryptonTreeViewActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonWrapLabelDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonWrapLabelDesigner.cs index 277b9c40d..7a81681ca 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonWrapLabelDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonWrapLabelDesigner.cs @@ -35,9 +35,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the wrap label specific list new KryptonWrapLabelActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Editors/KryptonBreadCrumbItemsEditor.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Editors/KryptonBreadCrumbItemsEditor.cs index 23f2b299b..adc65ea37 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Editors/KryptonBreadCrumbItemsEditor.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Editors/KryptonBreadCrumbItemsEditor.cs @@ -800,9 +800,9 @@ private void UpdatePropertyGrid() private DictItemBase CreateItemsDictionary(object[] items) { - DictItemBase dictItems = new DictItemBase(); + var dictItems = new DictItemBase(); - foreach (KryptonBreadCrumbItem item in items) + foreach (KryptonBreadCrumbItem item in items.Cast()) { AddItemsToDictionary(dictItems, item); } @@ -822,10 +822,10 @@ private void AddItemsToDictionary(DictItemBase dictItems, KryptonBreadCrumbItem } } - private void AddMenuTreeNode(KryptonBreadCrumbItem item, MenuTreeNode parent) + private void AddMenuTreeNode(KryptonBreadCrumbItem item, MenuTreeNode? parent) { // Create a node to match the item - MenuTreeNode node = new MenuTreeNode(item); + var node = new MenuTreeNode(item); // Add to either root or parent node if (parent != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Editors/KryptonCheckButtonCollectionEditor.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Editors/KryptonCheckButtonCollectionEditor.cs index a89704426..8dd940c6e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Editors/KryptonCheckButtonCollectionEditor.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Editors/KryptonCheckButtonCollectionEditor.cs @@ -42,7 +42,7 @@ public override object EditValue(ITypeDescriptorContext? context, IServiceProvid KryptonCheckSet checkSet = (KryptonCheckSet)context.Instance; // Create the dialog used to edit the set of KryptonCheckButtons - KryptonCheckButtonCollectionForm dialog = new KryptonCheckButtonCollectionForm(checkSet); + var dialog = new KryptonCheckButtonCollectionForm(checkSet); if (editorService.ShowDialog(dialog) == DialogResult.OK) { diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Editors/PaletteDrawBordersEditor.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Editors/PaletteDrawBordersEditor.cs index 2341c554a..110f66355 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Editors/PaletteDrawBordersEditor.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Editors/PaletteDrawBordersEditor.cs @@ -45,9 +45,8 @@ public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext contex if (service != null) { // Create the custom control used to edit value - PaletteDrawBordersSelector selector = new PaletteDrawBordersSelector + var selector = new PaletteDrawBordersSelector { - // Populate selector with starting value Value = (PaletteDrawBorders)value }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Other/KryptonSplitContainerGlyph.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Other/KryptonSplitContainerGlyph.cs index 97d280c29..c5168fce7 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Other/KryptonSplitContainerGlyph.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Other/KryptonSplitContainerGlyph.cs @@ -69,7 +69,7 @@ public KryptonSplitContainerGlyph([DisallowNull] ISelectionService selectionServ if (bounds.Contains(pt)) { // Convert from adorner coordinates to the control client coordinates - Point splitPt = new Point(pt.X - bounds.X, pt.Y - bounds.Y); + var splitPt = new Point(pt.X - bounds.X, pt.Y - bounds.Y); // Ask the split container for the correct cursor to use return _splitContainer.DesignGetHitTest(splitPt); diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Other/OverrideComboBoxStyleDropDownStyle.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Other/OverrideComboBoxStyleDropDownStyle.cs index 536e2e3ef..f6738c949 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Other/OverrideComboBoxStyleDropDownStyle.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Other/OverrideComboBoxStyleDropDownStyle.cs @@ -27,13 +27,13 @@ public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext contex : base.GetEditStyle(context); - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider? provider, object? value) { - IWindowsFormsEditorService svc = (IWindowsFormsEditorService)provider?.GetService(typeof(IWindowsFormsEditorService)); + IWindowsFormsEditorService? svc = (IWindowsFormsEditorService)provider?.GetService(typeof(IWindowsFormsEditorService)); if (svc != null) { - UserControl ctrl = new UserControl(); - ListBox clb = new ListBox { Dock = DockStyle.Fill }; + var ctrl = new UserControl(); + var clb = new ListBox { Dock = DockStyle.Fill }; clb.Items.Add(ComboBoxStyle.DropDown); clb.Items.Add(ComboBoxStyle.DropDownList); clb.SelectedIndexChanged += delegate diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/UX/KryptonContextMenuCollectionForm.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/UX/KryptonContextMenuCollectionForm.cs index 91188eef3..bd30a38f0 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/UX/KryptonContextMenuCollectionForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/UX/KryptonContextMenuCollectionForm.cs @@ -853,10 +853,10 @@ private void UpdatePropertyGrid() _propertyGrid1.SelectedObject = ((MenuTreeNode)node)?.PropertyObject; } - private void AddMenuTreeNode(KryptonContextMenuItemBase item, MenuTreeNode parent) + private void AddMenuTreeNode(KryptonContextMenuItemBase item, MenuTreeNode? parent) { // Create a node to match the item - MenuTreeNode node = new MenuTreeNode(item); + var node = new MenuTreeNode(item); // Add to either root or parent node if (parent != null) @@ -1018,11 +1018,11 @@ private bool AllowAddItem(KryptonContextMenuItemBase item, if (ItemInsideCollection(item, parent)) { - KryptonContextMenuCollection temp = new KryptonContextMenuCollection(); + var temp = new KryptonContextMenuCollection(); return temp.RestrictTypes.Any(t => t.Equals(addType)); } - KryptonContextMenuItemCollection temp1 = new KryptonContextMenuItemCollection(); + var temp1 = new KryptonContextMenuItemCollection(); if (temp1.RestrictTypes.Any(t => t.Equals(addType))) { return true; @@ -1030,7 +1030,7 @@ private bool AllowAddItem(KryptonContextMenuItemBase item, if (item is KryptonContextMenuItem) { - KryptonContextMenuCollection temp2 = new KryptonContextMenuCollection(); + var temp2 = new KryptonContextMenuCollection(); return temp2.RestrictTypes.Any(t => t.Equals(addType)); } @@ -1040,14 +1040,14 @@ private bool AllowAddItem(KryptonContextMenuItemBase item, private bool ValidInCollection(KryptonContextMenuItemBase item) { Type addType = item.GetType(); - KryptonContextMenuCollection temp = new KryptonContextMenuCollection(); + var temp = new KryptonContextMenuCollection(); return temp.RestrictTypes.Any(t => t.Equals(addType)); } private bool ValidInItemCollection(KryptonContextMenuItemBase item) { Type addType = item.GetType(); - KryptonContextMenuItemCollection temp = new KryptonContextMenuItemCollection(); + var temp = new KryptonContextMenuItemCollection(); return temp.RestrictTypes.Any(t => t.Equals(addType)); } @@ -1059,9 +1059,9 @@ private bool ItemInsideCollection(KryptonContextMenuItemBase item, private DictItemBase CreateItemsDictionary(object[] items) { - DictItemBase dictItems = new DictItemBase(); + var dictItems = new DictItemBase(); - foreach (KryptonContextMenuItemBase item in items) + foreach (KryptonContextMenuItemBase item in items.Cast()) { AddItemsToDictionary(dictItems, item); } @@ -1078,24 +1078,19 @@ private void AddItemsToDictionary(DictItemBase dictItems, KryptonContextMenuItem { // Add children of an items collection case KryptonContextMenuItems items: + foreach (KryptonContextMenuItemBase childItem in items.Items) { - foreach (KryptonContextMenuItemBase childItem in items.Items) - { - AddItemsToDictionary(dictItems, childItem); - } - - break; + AddItemsToDictionary(dictItems, childItem); } + break; + // Add children of an item case KryptonContextMenuItem item: + foreach (KryptonContextMenuItemBase childItem in item.Items) { - foreach (KryptonContextMenuItemBase childItem in item.Items) - { - AddItemsToDictionary(dictItems, childItem); - } - - break; + AddItemsToDictionary(dictItems, childItem); } + break; } } @@ -1117,7 +1112,7 @@ private void SynchronizeCollections(DictItemBase before, context.Container?.Remove(item); } - IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + IComponentChangeService? changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); if (changeService != null) { // Mark components as changed when not added or removed diff --git a/Source/Krypton Components/Krypton.Toolkit/General/BlurManager.cs b/Source/Krypton Components/Krypton.Toolkit/General/BlurManager.cs index c61e566dd..bf0b89fb5 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/BlurManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/BlurManager.cs @@ -99,7 +99,7 @@ public bool IsOverlapped() var visited = new HashSet { hWnd }; try { - Form activeForm = Form.ActiveForm; + Form? activeForm = Form.ActiveForm; if (activeForm != null) { visited.Add(activeForm.Handle); @@ -108,14 +108,14 @@ public bool IsOverlapped() visited.Add(_visualBlur.Handle); - PI.RECT thisRect = new PI.RECT(); + var thisRect = new PI.RECT(); PI.GetWindowRect(hWnd, ref thisRect); while ((hWnd = PI.GetWindow(hWnd, PI.GetWindowType.GW_HWNDPREV)) != IntPtr.Zero && !visited.Contains(hWnd)) { visited.Add(hWnd); - PI.RECT testRect = new PI.RECT(); + var testRect = new PI.RECT(); if (PI.IsWindowVisible(hWnd) && PI.GetWindowRect(hWnd, ref testRect) && PI.IntersectRect(out _, ref thisRect, ref testRect) @@ -222,7 +222,7 @@ internal void TakeSnapshot() private static Bitmap TakeSnapshot(Rectangle targetRectangle) { - Bitmap bmp = new Bitmap(targetRectangle.Width, targetRectangle.Height); + var bmp = new Bitmap(targetRectangle.Width, targetRectangle.Height); Graphics g = Graphics.FromImage(bmp); g.CopyFromScreen(targetRectangle.Left, targetRectangle.Top, 0, 0, bmp.Size); return bmp; diff --git a/Source/Krypton Components/Krypton.Toolkit/General/CommonHelper.cs b/Source/Krypton Components/Krypton.Toolkit/General/CommonHelper.cs index cf7aa22f9..7a92ef82c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/CommonHelper.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/CommonHelper.cs @@ -416,12 +416,12 @@ public static bool ValidKryptonContextMenu(KryptonContextMenu? kcm) => public static object? PerformOperation(Operation op, object parameter) { // Create a modal window for showing feedback - using ModalWaitDialog wait = new ModalWaitDialog(); + using var wait = new ModalWaitDialog(); // Create the object that runs the operation in a separate thread - OperationThread opThread = new OperationThread(op, parameter); + var opThread = new OperationThread(op, parameter); // Create the actual thread and provide thread entry point - Thread thread = new Thread(opThread.Run); + var thread = new Thread(opThread.Run); // Kick off the thread action thread.Start(); @@ -825,7 +825,7 @@ public static PaletteButtonStyle ButtonStyleToPalette(ButtonStyle style) /// GraphicsPath instance. public static GraphicsPath RoundedRectanglePath(Rectangle rect, int rounding) { - GraphicsPath roundedPath = new GraphicsPath(); + var roundedPath = new GraphicsPath(); // Only use a rounding that will fit inside the rect rounding = Math.Min(rounding, Math.Min(rect.Width / 2, rect.Height / 2) - rounding); @@ -839,7 +839,7 @@ public static GraphicsPath RoundedRectanglePath(Rectangle rect, int rounding) else { // We create the path using a floating point rectangle - RectangleF rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); + var rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); // The border is made of up a quarter of a circle arc, in each corner var arcLength = rounding * 2; @@ -1174,7 +1174,7 @@ public static void RemoveControlFromParent([DisallowNull] Control c) /// Border sizing. public static Padding GetWindowBorders(CreateParams cp) { - PI.RECT rect = new PI.RECT + var rect = new PI.RECT { // Start with a zero sized rectangle left = 0, @@ -1227,7 +1227,7 @@ public static Rectangle RealClientRectangle(IntPtr handle) { // Grab the actual current size of the window, this is more accurate than using // the 'this.Size' which is out of date when performing a resize of the window. - PI.RECT windowRect = new PI.RECT(); + var windowRect = new PI.RECT(); PI.GetWindowRect(handle, ref windowRect); // Create rectangle that encloses the entire window @@ -1421,7 +1421,7 @@ public static void DestroyInstance(object instance, IDesignerHost? host) public static void LogOutput(string str) { // TODO: Make this thread aware ! - FileInfo fi = new FileInfo(Application.ExecutablePath); + var fi = new FileInfo(Application.ExecutablePath); using var writer = new StreamWriter($@"{fi.DirectoryName}LogOutput.txt", true, Encoding.ASCII); writer.Write($@"{DateTime.Now.ToLongTimeString()} : "); writer.WriteLine(str); @@ -1525,7 +1525,7 @@ public static bool DesignMode(Component? c) public static Point ClientMouseMessageToScreenPt(Message m) { // Extract the x and y mouse position from message - PI.POINTC clientPt = new PI.POINTC + var clientPt = new PI.POINTC { x = PI.LOWORD((int)m.LParam), y = PI.HIWORD((int)m.LParam) @@ -1544,7 +1544,7 @@ public static Point ClientMouseMessageToScreenPt(Message m) } // Convert a 0,0 point from client to screen to find offsetting - PI.POINTC zeroPIPt = new PI.POINTC + var zeroPIPt = new PI.POINTC { x = 0, y = 0 diff --git a/Source/Krypton Components/Krypton.Toolkit/General/PlatformInvoke.cs b/Source/Krypton Components/Krypton.Toolkit/General/PlatformInvoke.cs index 2c1892803..c26c92954 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/PlatformInvoke.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/PlatformInvoke.cs @@ -3295,7 +3295,7 @@ internal static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, [SuppressMessage("Microsoft.Performance", @"CA1811:AvoidUncalledPrivateCode")] internal static MONITORINFO GetMonitorInfo(IntPtr hMonitor) { - MONITORINFO mi = new MONITORINFO(); + var mi = new MONITORINFO(); if (!_GetMonitorInfo(hMonitor, mi)) { throw new Win32Exception(); diff --git a/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/HScrollSkin.cs b/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/HScrollSkin.cs index 11581a18b..1c8daed19 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/HScrollSkin.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/HScrollSkin.cs @@ -435,9 +435,9 @@ protected override void WndProc(ref Message m) } if (_win.GetType() == typeof(ListView)) { - ListView listView1 = (ListView)_win; + var listView1 = (ListView)_win; - WIN32ScrollBars.ScrollInfo si = new WIN32ScrollBars.ScrollInfo(); + var si = new WIN32ScrollBars.ScrollInfo(); si.cbSize = Marshal.SizeOf(si); si.fMask = (int)PI.SIF_.ALL; if (PI.GetScrollInfo(listView1.Handle, (int)PI.SB_.HORZ, ref si)) diff --git a/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/ScrollBarExtendedRenderer.cs b/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/ScrollBarExtendedRenderer.cs index 864c66c19..afe05589f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/ScrollBarExtendedRenderer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/ScrollBarExtendedRenderer.cs @@ -326,7 +326,7 @@ public static void DrawThumbGrip( Rectangle r = AdjustThumbGrip(rect, orientation, gripImage); // adjust alpha channel of grip image - using ImageAttributes attr = new ImageAttributes(); + using var attr = new ImageAttributes(); attr.SetColorMatrix( new ColorMatrix(new[] { @@ -349,7 +349,7 @@ public static void DrawThumbGrip( /// public static Bitmap GetGripNomalBitmap() { - Bitmap btm = new Bitmap(8, 8); + var btm = new Bitmap(8, 8); btm.SetResolution(72, 72); Graphics g = Graphics.FromImage(btm); @@ -370,7 +370,7 @@ public static Bitmap GetGripNomalBitmap() /// public static Image GetScrollBarArrowDownBitmap() { - Bitmap img = new Bitmap(9, 5, PixelFormat.Format32bppArgb); + var img = new Bitmap(9, 5, PixelFormat.Format32bppArgb); img.SetResolution(72, 72); Graphics g = Graphics.FromImage(img); @@ -431,28 +431,28 @@ public static void DrawArrowButton(Graphics g, Rectangle rect, ScrollBarArrowBut /// The rectangle in which to paint. private static void DrawBackgroundVertical(Graphics g, Rectangle rect) { - using (Pen p = new Pen(backgroundColours[0])) + using (var p = new Pen(backgroundColours[0])) { g.DrawLine(p, rect.Left + 1, rect.Top + 1, rect.Left + 1, rect.Bottom - 1); g.DrawLine(p, rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 1); } - using (Pen p = new Pen(backgroundColours[1])) + using (var p = new Pen(backgroundColours[1])) { g.DrawLine(p, rect.Left + 2, rect.Top + 1, rect.Left + 2, rect.Bottom - 1); } - Rectangle firstRect = new Rectangle(rect.Left + 3, rect.Top, 8, rect.Height); + var firstRect = new Rectangle(rect.Left + 3, rect.Top, 8, rect.Height); - Rectangle secondRect = new Rectangle(firstRect.Right - 1, firstRect.Top, 7, firstRect.Height); + var secondRect = new Rectangle(firstRect.Right - 1, firstRect.Top, 7, firstRect.Height); - using (LinearGradientBrush brush = new LinearGradientBrush(firstRect, backgroundColours[2], + using (var brush = new LinearGradientBrush(firstRect, backgroundColours[2], backgroundColours[3], LinearGradientMode.Horizontal)) { g.FillRectangle(brush, firstRect); } - using (LinearGradientBrush brush = new LinearGradientBrush(secondRect, backgroundColours[3], + using (var brush = new LinearGradientBrush(secondRect, backgroundColours[3], backgroundColours[4], LinearGradientMode.Horizontal)) { g.FillRectangle(brush, secondRect); @@ -466,28 +466,28 @@ private static void DrawBackgroundVertical(Graphics g, Rectangle rect) /// The rectangle in which to paint. private static void DrawBackgroundHorizontal(Graphics g, Rectangle rect) { - using (Pen p = new Pen(backgroundColours[0])) + using (var p = new Pen(backgroundColours[0])) { g.DrawLine(p, rect.Left + 1, rect.Top + 1, rect.Right - 1, rect.Top + 1); g.DrawLine(p, rect.Left + 1, rect.Bottom - 2, rect.Right - 1, rect.Bottom - 2); } - using (Pen p = new Pen(backgroundColours[1])) + using (var p = new Pen(backgroundColours[1])) { g.DrawLine(p, rect.Left + 1, rect.Top + 2, rect.Right - 1, rect.Top + 2); } - Rectangle firstRect = new Rectangle(rect.Left, rect.Top + 3, rect.Width, 8); + var firstRect = new Rectangle(rect.Left, rect.Top + 3, rect.Width, 8); - Rectangle secondRect = new Rectangle(firstRect.Left, firstRect.Bottom - 1, firstRect.Width, 7); + var secondRect = new Rectangle(firstRect.Left, firstRect.Bottom - 1, firstRect.Width, 7); - using (LinearGradientBrush brush = new LinearGradientBrush(firstRect, backgroundColours[2], + using (var brush = new LinearGradientBrush(firstRect, backgroundColours[2], backgroundColours[3], LinearGradientMode.Vertical)) { g.FillRectangle(brush, firstRect); } - using (LinearGradientBrush brush = new LinearGradientBrush(secondRect, backgroundColours[3], + using (var brush = new LinearGradientBrush(secondRect, backgroundColours[3], backgroundColours[4], LinearGradientMode.Vertical)) { g.FillRectangle(brush, secondRect); @@ -501,9 +501,9 @@ private static void DrawBackgroundHorizontal(Graphics g, Rectangle rect) /// The rectangle in which to paint. private static void DrawTrackVertical(Graphics g, Rectangle rect) { - Rectangle innerRect = new Rectangle(rect.Left + 1, rect.Top, 15, rect.Height); + var innerRect = new Rectangle(rect.Left + 1, rect.Top, 15, rect.Height); - using LinearGradientBrush brush = new LinearGradientBrush(innerRect, trackColours[0], trackColours[1], + using var brush = new LinearGradientBrush(innerRect, trackColours[0], trackColours[1], LinearGradientMode.Horizontal); g.FillRectangle(brush, innerRect); } @@ -515,9 +515,9 @@ private static void DrawTrackVertical(Graphics g, Rectangle rect) /// The rectangle in which to paint. private static void DrawTrackHorizontal(Graphics g, Rectangle rect) { - Rectangle innerRect = new Rectangle(rect.Left, rect.Top + 1, rect.Width, 15); + var innerRect = new Rectangle(rect.Left, rect.Top + 1, rect.Width, 15); - using LinearGradientBrush brush = new LinearGradientBrush(innerRect, trackColours[0], trackColours[1], + using var brush = new LinearGradientBrush(innerRect, trackColours[0], trackColours[1], LinearGradientMode.Vertical); g.FillRectangle(brush, innerRect); } @@ -578,7 +578,7 @@ private static void DrawThumbVertical(Graphics g, Rectangle rect, ScrollBarState r.Height++; // draw left gradient - using (LinearGradientBrush brush = new LinearGradientBrush(r, thumbColours[index, 1], + using (var brush = new LinearGradientBrush(r, thumbColours[index, 1], thumbColours[index, 2], LinearGradientMode.Horizontal)) { g.FillRectangle(brush, r); @@ -589,7 +589,7 @@ private static void DrawThumbVertical(Graphics g, Rectangle rect, ScrollBarState // draw right gradient if (index == 0) { - using LinearGradientBrush brush = new LinearGradientBrush(r, thumbColours[index, 4], + using var brush = new LinearGradientBrush(r, thumbColours[index, 4], thumbColours[index, 5], LinearGradientMode.Horizontal); brush.InterpolationColors = new ColorBlend(3) { @@ -606,21 +606,21 @@ private static void DrawThumbVertical(Graphics g, Rectangle rect, ScrollBarState } else { - using (LinearGradientBrush brush = new LinearGradientBrush(r, thumbColours[index, 4], + using (var brush = new LinearGradientBrush(r, thumbColours[index, 4], thumbColours[index, 5], LinearGradientMode.Horizontal)) { g.FillRectangle(brush, r); } // draw left line - using (Pen p = new Pen(thumbColours[index, 7])) + using (var p = new Pen(thumbColours[index, 7])) { g.DrawLine(p, innerRect.X, innerRect.Y, innerRect.X, innerRect.Bottom); } } // draw right line - using (Pen p = new Pen(thumbColours[index, 3])) + using (var p = new Pen(thumbColours[index, 3])) { g.DrawLine(p, innerRect.Right, innerRect.Y, innerRect.Right, innerRect.Bottom); } @@ -628,7 +628,7 @@ private static void DrawThumbVertical(Graphics g, Rectangle rect, ScrollBarState g.SmoothingMode = SmoothingMode.AntiAlias; // draw border - using (Pen p = new Pen(thumbColours[index, 0])) + using (var p = new Pen(thumbColours[index, 0])) { using (GraphicsPath path = CreateRoundPath(rect, 2f, 2f)) { @@ -665,7 +665,7 @@ private static void DrawThumbHorizontal( r.Width++; // draw left gradient - using (LinearGradientBrush brush = new LinearGradientBrush(r, thumbColours[index, 1], + using (var brush = new LinearGradientBrush(r, thumbColours[index, 1], thumbColours[index, 2], LinearGradientMode.Vertical)) { g.FillRectangle(brush, r); @@ -676,7 +676,7 @@ private static void DrawThumbHorizontal( // draw right gradient if (index == 0) { - using LinearGradientBrush brush = new LinearGradientBrush(r, thumbColours[index, 4], + using var brush = new LinearGradientBrush(r, thumbColours[index, 4], thumbColours[index, 5], LinearGradientMode.Vertical); brush.InterpolationColors = new ColorBlend(3) { @@ -693,21 +693,21 @@ private static void DrawThumbHorizontal( } else { - using (LinearGradientBrush brush = new LinearGradientBrush(r, thumbColours[index, 4], + using (var brush = new LinearGradientBrush(r, thumbColours[index, 4], thumbColours[index, 5], LinearGradientMode.Vertical)) { g.FillRectangle(brush, r); } // draw left line - using (Pen p = new Pen(thumbColours[index, 7])) + using (var p = new Pen(thumbColours[index, 7])) { g.DrawLine(p, innerRect.X, innerRect.Y, innerRect.Right, innerRect.Y); } } // draw right line - using (Pen p = new Pen(thumbColours[index, 3])) + using (var p = new Pen(thumbColours[index, 3])) { g.DrawLine(p, innerRect.X, innerRect.Bottom, innerRect.Right, innerRect.Bottom); } @@ -715,7 +715,7 @@ private static void DrawThumbHorizontal( g.SmoothingMode = SmoothingMode.AntiAlias; // draw border - using (Pen p = new Pen(thumbColours[index, 0])) + using (var p = new Pen(thumbColours[index, 0])) { using (GraphicsPath path = CreateRoundPath(rect, 2f, 2f)) { @@ -755,14 +755,7 @@ private static void DrawArrowButtonHorizontal(Graphics g, Rectangle rect, Scroll bool arrowUp) { using Image arrowImage = GetArrowDownButtonImage(state); - if (arrowUp) - { - arrowImage.RotateFlip(RotateFlipType.Rotate90FlipNone); - } - else - { - arrowImage.RotateFlip(RotateFlipType.Rotate270FlipNone); - } + arrowImage.RotateFlip(arrowUp ? RotateFlipType.Rotate90FlipNone : RotateFlipType.Rotate270FlipNone); g.DrawImage(arrowImage, rect); } @@ -774,8 +767,8 @@ private static void DrawArrowButtonHorizontal(Graphics g, Rectangle rect, Scroll /// The arrow down button as . private static Image GetArrowDownButtonImage(ScrollBarArrowButtonState state) { - Rectangle rect = new Rectangle(0, 0, 15, 17); - Bitmap bitmap = new Bitmap(15, 17, PixelFormat.Format32bppArgb); + var rect = new Rectangle(0, 0, 15, 17); + var bitmap = new Bitmap(15, 17, PixelFormat.Format32bppArgb); bitmap.SetResolution(72f, 72f); using Graphics g = Graphics.FromImage(bitmap); @@ -788,27 +781,18 @@ private static Image GetArrowDownButtonImage(ScrollBarArrowButtonState state) { case ScrollBarArrowButtonState.UpHot: case ScrollBarArrowButtonState.DownHot: - { index = 1; - break; - } case ScrollBarArrowButtonState.UpActive: case ScrollBarArrowButtonState.DownActive: - { index = 0; - break; - } case ScrollBarArrowButtonState.UpPressed: case ScrollBarArrowButtonState.DownPressed: - { index = 2; - break; - } } if (index != -1) @@ -822,10 +806,10 @@ private static Image GetArrowDownButtonImage(ScrollBarArrowButtonState state) rect.Inflate(0, -1); - using (LinearGradientBrush brush = new LinearGradientBrush(rect, arrowBorderColours[2], + using (var brush = new LinearGradientBrush(rect, arrowBorderColours[2], arrowBorderColours[1], LinearGradientMode.Vertical)) { - ColorBlend blend = new ColorBlend(3) + var blend = new ColorBlend(3) { Positions = new[] { 0f, .5f, 1f }, Colors = new[] { @@ -836,7 +820,7 @@ private static Image GetArrowDownButtonImage(ScrollBarArrowButtonState state) brush.InterpolationColors = blend; - using (Pen p = new Pen(brush)) + using (var p = new Pen(brush)) { g.DrawLine(p, rect.X, rect.Y, rect.X, rect.Bottom - 1); g.DrawLine(p, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1); @@ -850,7 +834,7 @@ private static Image GetArrowDownButtonImage(ScrollBarArrowButtonState state) upper.Y++; upper.Height = 7; - using (LinearGradientBrush brush = new LinearGradientBrush(upper, arrowColours[index, 2], + using (var brush = new LinearGradientBrush(upper, arrowColours[index, 2], arrowColours[index, 3], LinearGradientMode.Vertical)) { g.FillRectangle(brush, upper); @@ -859,7 +843,7 @@ private static Image GetArrowDownButtonImage(ScrollBarArrowButtonState state) upper.Inflate(-1, 0); upper.Height = 6; - using (LinearGradientBrush brush = new LinearGradientBrush(upper, arrowColours[index, 0], + using (var brush = new LinearGradientBrush(upper, arrowColours[index, 0], arrowColours[index, 1], LinearGradientMode.Vertical)) { g.FillRectangle(brush, upper); @@ -870,7 +854,7 @@ private static Image GetArrowDownButtonImage(ScrollBarArrowButtonState state) lower.Y = 8; lower.Height = 8; - using (LinearGradientBrush brush = new LinearGradientBrush(lower, arrowColours[index, 6], + using (var brush = new LinearGradientBrush(lower, arrowColours[index, 6], arrowColours[index, 7], LinearGradientMode.Vertical)) { g.FillRectangle(brush, lower); @@ -878,14 +862,14 @@ private static Image GetArrowDownButtonImage(ScrollBarArrowButtonState state) lower.Inflate(-1, 0); - using (LinearGradientBrush brush = new LinearGradientBrush(lower, arrowColours[index, 4], + using (var brush = new LinearGradientBrush(lower, arrowColours[index, 4], arrowColours[index, 5], LinearGradientMode.Vertical)) { g.FillRectangle(brush, lower); } } - using Image arrowIcon = (Image)GetScrollBarArrowDownBitmap().Clone(); + using var arrowIcon = (Image)GetScrollBarArrowDownBitmap().Clone(); if (state is ScrollBarArrowButtonState.DownDisabled or ScrollBarArrowButtonState.UpDisabled) { ControlPaint.DrawImageDisabled( @@ -913,10 +897,10 @@ private static Image GetArrowDownButtonImage(ScrollBarArrowButtonState state) private static GraphicsPath CreateRoundPath(Rectangle r, float radiusX, float radiusY) { // create new graphics path object - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); // calculate radius of edges - PointF d = new PointF(Math.Min(radiusX * 2, r.Width), Math.Min(radiusY * 2, r.Height)); + var d = new PointF(Math.Min(radiusX * 2, r.Width), Math.Min(radiusY * 2, r.Height)); // make sure radius is valid d.X = Math.Max(1, d.X); diff --git a/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/ScrollBarKryptonRenderer.cs b/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/ScrollBarKryptonRenderer.cs index b36629f08..6271b6a09 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/ScrollBarKryptonRenderer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/ScrollBarKryptonRenderer.cs @@ -321,12 +321,12 @@ public static void DrawThumbGrip( } // get grip image - using Image gripImage = GetGripNomalBitmap(); + using Image gripImage = GetGripNormalBitmap(); // adjust rectangle and rotate grip image if necessary Rectangle r = AdjustThumbGrip(rect, orientation, gripImage); // adjust alpha channel of grip image - using ImageAttributes attr = new ImageAttributes(); + using var attr = new ImageAttributes(); attr.SetColorMatrix( new ColorMatrix(new[] { @@ -345,14 +345,13 @@ public static void DrawThumbGrip( } /// - /// Draws the GripNomal Bitmap. + /// Draws the GripNormal Bitmap. /// - public static Bitmap GetGripNomalBitmap() + public static Bitmap GetGripNormalBitmap() { - Bitmap btm = new Bitmap(8, 8); + var btm = new Bitmap(8, 8); btm.SetResolution(72, 72); Graphics g = Graphics.FromImage(btm); - Rectangle rect = new Rectangle(0, 0, 8, 8); g.DrawLine(new Pen(gripColours[1]), new Point(0, 0), new Point(8, 0));//dark g.DrawLine(new Pen(gripColours[0]), new Point(1, 1), new Point(7, 1));//light @@ -367,11 +366,11 @@ public static Bitmap GetGripNomalBitmap() } /// - /// Draws the GripNomal Bitmap. + /// Draws the GetScrollBarArrowDownBitmap /// public static Image GetScrollBarArrowDownBitmap() { - Bitmap img = new Bitmap(9, 5, PixelFormat.Format32bppArgb); + var img = new Bitmap(9, 5, PixelFormat.Format32bppArgb); img.SetResolution(72, 72); Graphics g = Graphics.FromImage(img); @@ -384,7 +383,6 @@ public static Image GetScrollBarArrowDownBitmap() g.DrawLine(new Pen(gripColours[0]), new Point(3, 0), new Point(5, 0));//light g.DrawLine(new Pen(gripColours[0]), new Point(4, 0), new Point(4, 1));//light - return img; } @@ -437,28 +435,28 @@ public static void DrawArrowButton( /// The rectangle in which to paint. private static void DrawBackgroundVertical(Graphics g, Rectangle rect) { - using (Pen p = new Pen(backgroundColours[0])) + using (var p = new Pen(backgroundColours[0])) { g.DrawLine(p, rect.Left + 1, rect.Top + 1, rect.Left + 1, rect.Bottom - 1); g.DrawLine(p, rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 1); } - using (Pen p = new Pen(backgroundColours[1])) + using (var p = new Pen(backgroundColours[1])) { g.DrawLine(p, rect.Left + 2, rect.Top + 1, rect.Left + 2, rect.Bottom - 1); } - Rectangle firstRect = new Rectangle(rect.Left + 3, rect.Top, 8, rect.Height); + var firstRect = new Rectangle(rect.Left + 3, rect.Top, 8, rect.Height); - Rectangle secondRect = new Rectangle(firstRect.Right - 1, firstRect.Top, 7, firstRect.Height); + var secondRect = new Rectangle(firstRect.Right - 1, firstRect.Top, 7, firstRect.Height); - using (LinearGradientBrush brush = new LinearGradientBrush(firstRect, backgroundColours[2], + using (var brush = new LinearGradientBrush(firstRect, backgroundColours[2], backgroundColours[3], LinearGradientMode.Horizontal)) { g.FillRectangle(brush, firstRect); } - using (LinearGradientBrush brush = new LinearGradientBrush(secondRect, backgroundColours[3], + using (var brush = new LinearGradientBrush(secondRect, backgroundColours[3], backgroundColours[4], LinearGradientMode.Horizontal)) { g.FillRectangle(brush, secondRect); @@ -472,28 +470,28 @@ private static void DrawBackgroundVertical(Graphics g, Rectangle rect) /// The rectangle in which to paint. private static void DrawBackgroundHorizontal(Graphics g, Rectangle rect) { - using (Pen p = new Pen(backgroundColours[0])) + using (var p = new Pen(backgroundColours[0])) { g.DrawLine(p, rect.Left + 1, rect.Top + 1, rect.Right - 1, rect.Top + 1); g.DrawLine(p, rect.Left + 1, rect.Bottom - 2, rect.Right - 1, rect.Bottom - 2); } - using (Pen p = new Pen(backgroundColours[1])) + using (var p = new Pen(backgroundColours[1])) { g.DrawLine(p, rect.Left + 1, rect.Top + 2, rect.Right - 1, rect.Top + 2); } - Rectangle firstRect = new Rectangle(rect.Left, rect.Top + 3, rect.Width, 8); + var firstRect = new Rectangle(rect.Left, rect.Top + 3, rect.Width, 8); - Rectangle secondRect = new Rectangle(firstRect.Left, firstRect.Bottom - 1, firstRect.Width, 7); + var secondRect = new Rectangle(firstRect.Left, firstRect.Bottom - 1, firstRect.Width, 7); - using (LinearGradientBrush brush = new LinearGradientBrush(firstRect, backgroundColours[2], + using (var brush = new LinearGradientBrush(firstRect, backgroundColours[2], backgroundColours[3], LinearGradientMode.Vertical)) { g.FillRectangle(brush, firstRect); } - using (LinearGradientBrush brush = new LinearGradientBrush(secondRect, backgroundColours[3], + using (var brush = new LinearGradientBrush(secondRect, backgroundColours[3], backgroundColours[4], LinearGradientMode.Vertical)) { g.FillRectangle(brush, secondRect); @@ -507,9 +505,9 @@ private static void DrawBackgroundHorizontal(Graphics g, Rectangle rect) /// The rectangle in which to paint. private static void DrawTrackVertical(Graphics g, Rectangle rect) { - Rectangle innerRect = new Rectangle(rect.Left + 1, rect.Top, 15, rect.Height); + var innerRect = new Rectangle(rect.Left + 1, rect.Top, 15, rect.Height); - using LinearGradientBrush brush = new LinearGradientBrush(innerRect, trackColours[0], trackColours[1], + using var brush = new LinearGradientBrush(innerRect, trackColours[0], trackColours[1], LinearGradientMode.Horizontal); g.FillRectangle(brush, innerRect); } @@ -521,9 +519,9 @@ private static void DrawTrackVertical(Graphics g, Rectangle rect) /// The rectangle in which to paint. private static void DrawTrackHorizontal(Graphics g, Rectangle rect) { - Rectangle innerRect = new Rectangle(rect.Left, rect.Top + 1, rect.Width, 15); + var innerRect = new Rectangle(rect.Left, rect.Top + 1, rect.Width, 15); - using LinearGradientBrush brush = new LinearGradientBrush(innerRect, trackColours[0], trackColours[1], + using var brush = new LinearGradientBrush(innerRect, trackColours[0], trackColours[1], LinearGradientMode.Vertical); g.FillRectangle(brush, innerRect); } @@ -590,7 +588,7 @@ private static void DrawThumbVertical( r.Height++; // draw left gradient - using (LinearGradientBrush brush = new LinearGradientBrush(r, thumbColours[index, 1], + using (var brush = new LinearGradientBrush(r, thumbColours[index, 1], thumbColours[index, 2], LinearGradientMode.Horizontal)) { g.FillRectangle(brush, r); @@ -601,7 +599,7 @@ private static void DrawThumbVertical( // draw right gradient if (index == 0) { - using LinearGradientBrush brush = new LinearGradientBrush(r, thumbColours[index, 4], + using var brush = new LinearGradientBrush(r, thumbColours[index, 4], thumbColours[index, 5], LinearGradientMode.Horizontal); brush.InterpolationColors = new ColorBlend(3) { @@ -618,21 +616,21 @@ private static void DrawThumbVertical( } else { - using (LinearGradientBrush brush = new LinearGradientBrush(r, thumbColours[index, 4], + using (var brush = new LinearGradientBrush(r, thumbColours[index, 4], thumbColours[index, 5], LinearGradientMode.Horizontal)) { g.FillRectangle(brush, r); } // draw left line - using (Pen p = new Pen(thumbColours[index, 7])) + using (var p = new Pen(thumbColours[index, 7])) { g.DrawLine(p, innerRect.X, innerRect.Y, innerRect.X, innerRect.Bottom); } } // draw right line - using (Pen p = new Pen(thumbColours[index, 3])) + using (var p = new Pen(thumbColours[index, 3])) { g.DrawLine(p, innerRect.Right, innerRect.Y, innerRect.Right, innerRect.Bottom); } @@ -640,7 +638,7 @@ private static void DrawThumbVertical( g.SmoothingMode = SmoothingMode.AntiAlias; // draw border - using (Pen p = new Pen(thumbColours[index, 0])) + using (var p = new Pen(thumbColours[index, 0])) { using (GraphicsPath path = CreateRoundPath(rect, 2f, 2f)) { @@ -677,7 +675,7 @@ private static void DrawThumbHorizontal( r.Width++; // draw left gradient - using (LinearGradientBrush brush = new LinearGradientBrush(r, thumbColours[index, 1], + using (var brush = new LinearGradientBrush(r, thumbColours[index, 1], thumbColours[index, 2], LinearGradientMode.Vertical)) { g.FillRectangle(brush, r); @@ -688,7 +686,7 @@ private static void DrawThumbHorizontal( // draw right gradient if (index == 0) { - using LinearGradientBrush brush = new LinearGradientBrush(r, thumbColours[index, 4], + using var brush = new LinearGradientBrush(r, thumbColours[index, 4], thumbColours[index, 5], LinearGradientMode.Vertical); brush.InterpolationColors = new ColorBlend(3) { @@ -705,21 +703,21 @@ private static void DrawThumbHorizontal( } else { - using (LinearGradientBrush brush = new LinearGradientBrush(r, thumbColours[index, 4], + using (var brush = new LinearGradientBrush(r, thumbColours[index, 4], thumbColours[index, 5], LinearGradientMode.Vertical)) { g.FillRectangle(brush, r); } // draw left line - using (Pen p = new Pen(thumbColours[index, 7])) + using (var p = new Pen(thumbColours[index, 7])) { g.DrawLine(p, innerRect.X, innerRect.Y, innerRect.Right, innerRect.Y); } } // draw right line - using (Pen p = new Pen(thumbColours[index, 3])) + using (var p = new Pen(thumbColours[index, 3])) { g.DrawLine(p, innerRect.X, innerRect.Bottom, innerRect.Right, innerRect.Bottom); } @@ -727,7 +725,7 @@ private static void DrawThumbHorizontal( g.SmoothingMode = SmoothingMode.AntiAlias; // draw border - using (Pen p = new Pen(thumbColours[index, 0])) + using (var p = new Pen(thumbColours[index, 0])) { using (GraphicsPath path = CreateRoundPath(rect, 2f, 2f)) { @@ -774,14 +772,7 @@ private static void DrawArrowButtonHorizontal( bool arrowUp) { using Image arrowImage = GetArrowDownButtonImage(state); - if (arrowUp) - { - arrowImage.RotateFlip(RotateFlipType.Rotate90FlipNone); - } - else - { - arrowImage.RotateFlip(RotateFlipType.Rotate270FlipNone); - } + arrowImage.RotateFlip(arrowUp ? RotateFlipType.Rotate90FlipNone : RotateFlipType.Rotate270FlipNone); g.DrawImage(arrowImage, rect); } @@ -794,8 +785,8 @@ private static void DrawArrowButtonHorizontal( private static Image GetArrowDownButtonImage( ScrollBarArrowButtonState state) { - Rectangle rect = new Rectangle(0, 0, 15, 17); - Bitmap bitmap = new Bitmap(15, 17, PixelFormat.Format32bppArgb); + var rect = new Rectangle(0, 0, 15, 17); + var bitmap = new Bitmap(15, 17, PixelFormat.Format32bppArgb); bitmap.SetResolution(72f, 72f); using Graphics g = Graphics.FromImage(bitmap); @@ -808,27 +799,18 @@ private static Image GetArrowDownButtonImage( { case ScrollBarArrowButtonState.UpHot: case ScrollBarArrowButtonState.DownHot: - { index = 1; - break; - } case ScrollBarArrowButtonState.UpActive: case ScrollBarArrowButtonState.DownActive: - { index = 0; - break; - } case ScrollBarArrowButtonState.UpPressed: case ScrollBarArrowButtonState.DownPressed: - { index = 2; - break; - } } if (index != -1) @@ -842,10 +824,10 @@ private static Image GetArrowDownButtonImage( rect.Inflate(0, -1); - using (LinearGradientBrush brush = new LinearGradientBrush(rect, arrowBorderColours[2], + using (var brush = new LinearGradientBrush(rect, arrowBorderColours[2], arrowBorderColours[1], LinearGradientMode.Vertical)) { - ColorBlend blend = new ColorBlend(3) + var blend = new ColorBlend(3) { Positions = new[] { 0f, .5f, 1f }, Colors = new[] { @@ -856,7 +838,7 @@ private static Image GetArrowDownButtonImage( brush.InterpolationColors = blend; - using (Pen p = new Pen(brush)) + using (var p = new Pen(brush)) { g.DrawLine(p, rect.X, rect.Y, rect.X, rect.Bottom - 1); g.DrawLine(p, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1); @@ -870,7 +852,7 @@ private static Image GetArrowDownButtonImage( upper.Y++; upper.Height = 7; - using (LinearGradientBrush brush = new LinearGradientBrush(upper, arrowColours[index, 2], + using (var brush = new LinearGradientBrush(upper, arrowColours[index, 2], arrowColours[index, 3], LinearGradientMode.Vertical)) { g.FillRectangle(brush, upper); @@ -879,7 +861,7 @@ private static Image GetArrowDownButtonImage( upper.Inflate(-1, 0); upper.Height = 6; - using (LinearGradientBrush brush = new LinearGradientBrush(upper, arrowColours[index, 0], + using (var brush = new LinearGradientBrush(upper, arrowColours[index, 0], arrowColours[index, 1], LinearGradientMode.Vertical)) { g.FillRectangle(brush, upper); @@ -890,7 +872,7 @@ private static Image GetArrowDownButtonImage( lower.Y = 8; lower.Height = 8; - using (LinearGradientBrush brush = new LinearGradientBrush(lower, arrowColours[index, 6], + using (var brush = new LinearGradientBrush(lower, arrowColours[index, 6], arrowColours[index, 7], LinearGradientMode.Vertical)) { g.FillRectangle(brush, lower); @@ -898,14 +880,14 @@ private static Image GetArrowDownButtonImage( lower.Inflate(-1, 0); - using (LinearGradientBrush brush = new LinearGradientBrush(lower, arrowColours[index, 4], + using (var brush = new LinearGradientBrush(lower, arrowColours[index, 4], arrowColours[index, 5], LinearGradientMode.Vertical)) { g.FillRectangle(brush, lower); } } - using Image arrowIcon = (Image)GetScrollBarArrowDownBitmap().Clone(); + using var arrowIcon = (Image)GetScrollBarArrowDownBitmap().Clone(); if (state is ScrollBarArrowButtonState.DownDisabled or ScrollBarArrowButtonState.UpDisabled) { ControlPaint.DrawImageDisabled( @@ -936,10 +918,10 @@ private static GraphicsPath CreateRoundPath( float radiusY) { // create new graphics path object - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); // calculate radius of edges - PointF d = new PointF(Math.Min(radiusX * 2, r.Width), Math.Min(radiusY * 2, r.Height)); + var d = new PointF(Math.Min(radiusX * 2, r.Width), Math.Min(radiusY * 2, r.Height)); // make sure radius is valid d.X = Math.Max(1, d.X); diff --git a/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/VScrollSkin.cs b/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/VScrollSkin.cs index b7ce2c7dd..33890bb87 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/VScrollSkin.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/Scroll Bars/VScrollSkin.cs @@ -588,9 +588,9 @@ protected override void WndProc(ref Message m) if (_win.GetType() == typeof(ListView)) { - ListView listView1 = (ListView)_win; + var listView1 = (ListView)_win; - WIN32ScrollBars.ScrollInfo si = new WIN32ScrollBars.ScrollInfo(); + var si = new WIN32ScrollBars.ScrollInfo(); si.cbSize = Marshal.SizeOf(si); si.fMask = (int)PI.SIF_.ALL; if (PI.GetScrollInfo(listView1.Handle, PI.SB_.VERT, ref si)) @@ -615,7 +615,6 @@ protected override void WndProc(ref Message m) HScrollBar1.Update();//.SyncThumbPositionWithLogicalValue(); } } - } base.WndProc(ref m); diff --git a/Source/Krypton Components/Krypton.Toolkit/General/ShadowManager.cs b/Source/Krypton Components/Krypton.Toolkit/General/ShadowManager.cs index ce271fced..01f10a923 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/ShadowManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/ShadowManager.cs @@ -183,7 +183,7 @@ private Bitmap DrawShadowBitmap(Rectangle clientRectangle) var solidW = clientRectangle.Width + blur * 2; var solidH = clientRectangle.Height + blur * 2; var blurOffset = _shadowValues.ExtraWidth - blur; - Bitmap bitmap = new Bitmap(w, h); + var bitmap = new Bitmap(w, h); bitmap.MakeTransparent(); using Graphics g = Graphics.FromImage(bitmap); // fill background @@ -195,7 +195,7 @@ private Bitmap DrawShadowBitmap(Rectangle clientRectangle) // four dir gradient if (blurOffset > 0) { - using (LinearGradientBrush brush = new LinearGradientBrush(new PointF(0, 0), new PointF(blurOffset, 0), + using (var brush = new LinearGradientBrush(new PointF(0, 0), new PointF(blurOffset, 0), Color.Transparent, _shadowValues.Colour)) { // Left @@ -219,11 +219,11 @@ private Bitmap DrawShadowBitmap(Rectangle clientRectangle) // four corner - using (GraphicsPath gp = new GraphicsPath()) - using (Matrix matrix = new Matrix()) + using (var gp = new GraphicsPath()) + using (var matrix = new Matrix()) { gp.AddEllipse(0, 0, blurOffset * 2, blurOffset * 2); - using (PathGradientBrush pgb = new PathGradientBrush(gp) + using (var pgb = new PathGradientBrush(gp) { CenterColor = _shadowValues.Colour, SurroundColors = new[] { Color.Transparent }, @@ -316,7 +316,6 @@ void Mi() { Mi(); } - } } diff --git a/Source/Krypton Components/Krypton.Toolkit/General/WindowStylesHelper.cs b/Source/Krypton Components/Krypton.Toolkit/General/WindowStylesHelper.cs index bef166558..7f5095b9a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/WindowStylesHelper.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/WindowStylesHelper.cs @@ -28,7 +28,7 @@ public WindowStylesHelper(IntPtr style, IntPtr exStyle) public override string ToString() { - StringBuilder str1 = new StringBuilder(); + var str1 = new StringBuilder(); if (Caption) { str1.Append("Caption+"); diff --git a/Source/Krypton Components/Krypton.Toolkit/General/XmlHelper.cs b/Source/Krypton Components/Krypton.Toolkit/General/XmlHelper.cs index 5537ed2a8..e4697d978 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/XmlHelper.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/XmlHelper.cs @@ -99,7 +99,7 @@ public static Bitmap XmlCDataToImage(XmlReader xmlReader) // Do the old image way // SYSLIB0011: BinaryFormatter serialization is obsolete #pragma warning disable SYSLIB0011 - BinaryFormatter formatter = new BinaryFormatter(); + var formatter = new BinaryFormatter(); var img = (Image)formatter.Deserialize(memory); #pragma warning restore SYSLIB0011 return new Bitmap(img); diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteBack/PaletteBack.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteBack/PaletteBack.cs index e42088178..4aa4cc578 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteBack/PaletteBack.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteBack/PaletteBack.cs @@ -66,7 +66,7 @@ public InternalStorage() #endregion #region Instance Fields - private IPaletteBack _inherit; + private IPaletteBack? _inherit; private InternalStorage? _storage; #endregion @@ -85,8 +85,8 @@ public InternalStorage() /// /// Source for inheriting defaulted values. /// Delegate for notifying paint requests. - public PaletteBack(IPaletteBack inherit, - NeedPaintHandler needPaint) + public PaletteBack(IPaletteBack? inherit, + NeedPaintHandler? needPaint) { // Remember inheritance _inherit = inherit; diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteDouble/PaletteDoubleRedirect.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteDouble/PaletteDoubleRedirect.cs index 0da2398ee..04ee8c5b3 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteDouble/PaletteDoubleRedirect.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteDouble/PaletteDoubleRedirect.cs @@ -52,12 +52,12 @@ public PaletteDoubleRedirect(PaletteRedirect? redirect, NeedPaintHandler needPaint) { // Store the inherit instances - PaletteBackInheritRedirect backInherit = new PaletteBackInheritRedirect(redirect, backStyle); - PaletteBorderInheritRedirect borderInherit = new PaletteBorderInheritRedirect(redirect, borderStyle); + var backInherit = new PaletteBackInheritRedirect(redirect, backStyle); + var borderInherit = new PaletteBorderInheritRedirect(redirect, borderStyle); // Create storage that maps onto the inherit instances - PaletteBack back = new PaletteBack(backInherit, needPaint); - PaletteBorder border = new PaletteBorder(borderInherit, needPaint); + var back = new PaletteBack(backInherit, needPaint); + var border = new PaletteBorder(borderInherit, needPaint); Construct(redirect, back, backInherit, border, borderInherit, needPaint); } diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteTools/PaletteTools.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteTools/PaletteTools.cs index ac0f32978..85055de0e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteTools/PaletteTools.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Base/PaletteTools/PaletteTools.cs @@ -27,7 +27,7 @@ public class PaletteTools /// public PaletteMode LinkPaletteType1(string themeName) { - PaletteMode paletteMode = new PaletteMode(); + var paletteMode = new PaletteMode(); switch (themeName) { @@ -107,7 +107,7 @@ public static void ApplyTheme(KryptonManager manager, PaletteMode paletteMode = if (!string.IsNullOrWhiteSpace(customThemePath)) { - KryptonCustomPaletteBase palette = new KryptonCustomPaletteBase(); + var palette = new KryptonCustomPaletteBase(); palette.Import(customThemePath); 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 d77ecfd87..257d47541 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/PaletteBase.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/PaletteBase.cs @@ -1284,7 +1284,7 @@ public static Color MergeColors(Color color1, float percent1, public static Color FadedColor(Color baseColor) { // Convert to HSL space - ColorHSL hsl = new ColorHSL(baseColor) + var hsl = new ColorHSL(baseColor) { // Remove saturation and fix luminance @@ -1307,7 +1307,7 @@ protected virtual Padding InputControlPadding if (!_inputControlPadding.HasValue) { // Find size of a input control with and without a border - TextBox tb = new TextBox + var tb = new TextBox { BorderStyle = BorderStyle.None }; @@ -1316,7 +1316,7 @@ protected virtual Padding InputControlPadding Size ss = tb.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); // Always subtract one from top and bottom edges to account for border placed there later by Krypton - Padding inputControlPadding = new Padding(0); + var inputControlPadding = new Padding(0); var xDiff = Math.Max(0, ss.Width - sn.Width); var yDiff = Math.Max(0, ss.Height - sn.Height - 2); diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteButtonSpecs.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteButtonSpecs.cs index 028fd77b0..caa2d83db 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteButtonSpecs.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteButtonSpecs.cs @@ -61,7 +61,7 @@ public KryptonPaletteButtonSpecs([DisallowNull] PaletteRedirect redirector) RibbonExpand = new KryptonPaletteButtonSpecTyped(redirector); // Create redirector for inheriting from style specific to style common - PaletteRedirectButtonSpec redirectCommon = new PaletteRedirectButtonSpec(redirector, Common); + var redirectCommon = new PaletteRedirectButtonSpec(redirector, Common); // Inform the button spec to use the new redirector Generic.SetRedirector(redirectCommon); diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteCheckButtons.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteCheckButtons.cs index 4b47782d5..bf269c884 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteCheckButtons.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteCheckButtons.cs @@ -51,7 +51,7 @@ public KryptonPaletteCheckButtons([DisallowNull] PaletteRedirect redirector, ButtonCustom3 = new KryptonPaletteCheckButton(redirector, PaletteBackStyle.ButtonCustom3, PaletteBorderStyle.ButtonCustom3, PaletteContentStyle.ButtonCustom3, needPaint); // Create redirectors for inheriting from style specific to style common - PaletteRedirectTriple redirectCommon = new PaletteRedirectTriple(redirector, ButtonCommon.StateDisabled, + var redirectCommon = new PaletteRedirectTriple(redirector, ButtonCommon.StateDisabled, ButtonCommon.StateNormal, ButtonCommon.StatePressed, ButtonCommon.StateTracking, ButtonCommon.StateCheckedNormal, ButtonCommon.StateCheckedPressed, ButtonCommon.StateCheckedTracking, ButtonCommon.OverrideFocus, ButtonCommon.OverrideDefault); diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteControls.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteControls.cs index 15451a432..b369ae1af 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteControls.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteControls.cs @@ -41,7 +41,7 @@ public KryptonPaletteControls([DisallowNull] PaletteRedirect redirector, ControlCustom3 = new KryptonPaletteControl(redirector, PaletteBackStyle.ControlCustom3, PaletteBorderStyle.ControlCustom3, needPaint); // Create redirectors for inheriting from style specific to style common - PaletteRedirectDouble redirectCommon = + var redirectCommon = new PaletteRedirectDouble(redirector, ControlCommon.StateDisabled, ControlCommon.StateNormal); // Inform the button style to use the new redirector diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteForms.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteForms.cs index ad25ccc52..e83242245 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteForms.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteForms.cs @@ -36,7 +36,7 @@ public KryptonPaletteForms([DisallowNull] PaletteRedirect redirector, FormCustom3 = new KryptonPaletteForm(redirector, PaletteBackStyle.FormCustom3, PaletteBorderStyle.FormCustom3, needPaint); // Create redirectors for inheriting from style specific to style common - PaletteRedirectDouble redirectCommon = + var redirectCommon = new PaletteRedirectDouble(redirector, FormCommon.StateInactive, FormCommon.StateActive); // Inform the form style to use the new redirector diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteGrids.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteGrids.cs index 60ff964a0..9f93b5643 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteGrids.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteGrids.cs @@ -36,7 +36,7 @@ public KryptonPaletteGrids([DisallowNull] PaletteRedirect redirector, GridCustom3 = new KryptonPaletteGrid(redirector, GridStyle.Custom3, needPaint); // Create redirectors for inheriting from style specific to style common - PaletteRedirectGrids redirectCommon = new PaletteRedirectGrids(redirector, GridCommon); + var redirectCommon = new PaletteRedirectGrids(redirector, GridCommon); // Ensure the specific styles inherit to the common grid style GridList.SetRedirector(redirectCommon); diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteHeaders.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteHeaders.cs index 36592988e..fa4442eac 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteHeaders.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteHeaders.cs @@ -40,7 +40,7 @@ public KryptonPaletteHeaders([DisallowNull] PaletteRedirect redirector, HeaderCustom3 = new KryptonPaletteHeader(redirector, PaletteBackStyle.HeaderCustom3, PaletteBorderStyle.HeaderCustom3, PaletteContentStyle.HeaderCustom3, needPaint); // Create redirectors for inheriting from style specific to style common - PaletteRedirectTripleMetric redirectCommon = new PaletteRedirectTripleMetric(redirector, + var redirectCommon = new PaletteRedirectTripleMetric(redirector, HeaderCommon.StateDisabled, HeaderCommon.StateDisabled, HeaderCommon.StateNormal, HeaderCommon.StateNormal); diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteInputControls.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteInputControls.cs index 31911b67d..ca7f3c082 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteInputControls.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteInputControls.cs @@ -37,7 +37,7 @@ public KryptonPaletteInputControls([DisallowNull] PaletteRedirect redirector, InputControlCustom3 = new KryptonPaletteInputControl(redirector, PaletteBackStyle.InputControlCustom3, PaletteBorderStyle.InputControlCustom3, PaletteContentStyle.InputControlCustom3, needPaint); // Create redirectors for inheriting from style specific to style common - PaletteRedirectTriple redirectCommon = new PaletteRedirectTriple(redirector, + var redirectCommon = new PaletteRedirectTriple(redirector, InputControlCommon.StateDisabled, InputControlCommon.StateNormal, InputControlCommon.StateActive); // Inform the input control style to use the new redirector diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteLabels.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteLabels.cs index 486e333eb..b04cb6c5b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteLabels.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteLabels.cs @@ -47,7 +47,7 @@ public KryptonPaletteLabels([DisallowNull] PaletteRedirect redirector, LabelCustom3 = new KryptonPaletteLabel(redirector, PaletteContentStyle.LabelCustom3, needPaint); // Create redirectors for inheriting from style specific to style common - PaletteRedirectContent redirectCommon = + var redirectCommon = new PaletteRedirectContent(redirector, LabelCommon.StateDisabled, LabelCommon.StateNormal); // Inform the button style to use the new redirector diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPalettePanels.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPalettePanels.cs index bd78998b1..fb2b89f8e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPalettePanels.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPalettePanels.cs @@ -38,7 +38,7 @@ public KryptonPalettePanels([DisallowNull] PaletteRedirect redirector, PanelCustom3 = new KryptonPalettePanel(redirector, PaletteBackStyle.PanelCustom3, needPaint); // Create redirectors for inheriting from style specific to style common - PaletteRedirectBack redirectCommon = + var redirectCommon = new PaletteRedirectBack(redirector, PanelCommon.StateDisabled, PanelCommon.StateNormal); // Inform the button style to use the new redirector diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteSeparators.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteSeparators.cs index 1d307d9ba..4f88064e7 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteSeparators.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteSeparators.cs @@ -38,7 +38,7 @@ public KryptonPaletteSeparators([DisallowNull] PaletteRedirect redirector, SeparatorCustom3 = new KryptonPaletteSeparator(redirector, PaletteBackStyle.SeparatorCustom3, PaletteBorderStyle.SeparatorCustom3, needPaint); // Create redirectors for inheriting from style specific to style common - PaletteRedirectDouble redirectCommon = new PaletteRedirectDouble(redirector, SeparatorCommon.StateDisabled, + var redirectCommon = new PaletteRedirectDouble(redirector, SeparatorCommon.StateDisabled, SeparatorCommon.StateNormal, SeparatorCommon.StatePressed, SeparatorCommon.StateTracking); // Inform the button style to use the new redirector diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteTabButtons.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteTabButtons.cs index 05eb4f6c2..293c2d15a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteTabButtons.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Component/KryptonPaletteTabButtons.cs @@ -41,7 +41,7 @@ public KryptonPaletteTabButtons([DisallowNull] PaletteRedirect redirector, TabCustom3 = new KryptonPaletteTabButton(redirector, PaletteBackStyle.TabCustom3, PaletteBorderStyle.TabCustom3, PaletteContentStyle.TabCustom3, needPaint); // Create redirectors for inheriting from style specific to style common - PaletteRedirectTriple redirectCommon = new PaletteRedirectTriple(redirector, TabCommon.StateDisabled, + var redirectCommon = new PaletteRedirectTriple(redirector, TabCommon.StateDisabled, TabCommon.StateNormal, TabCommon.StatePressed, TabCommon.StateTracking, TabCommon.StateSelected, TabCommon.OverrideFocus); // Inform the button style to use the new redirector diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteBorderEdge.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteBorderEdge.cs index 0760bcddb..70b62e935 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteBorderEdge.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteBorderEdge.cs @@ -29,7 +29,7 @@ public class PaletteBorderEdge : PaletteBack /// Source for inheriting defaulted values. /// Delegate for notifying paint requests. public PaletteBorderEdge([DisallowNull] PaletteBorderEdgeRedirect inherit, - NeedPaintHandler needPaint) + NeedPaintHandler? needPaint) : base(inherit, needPaint) { Debug.Assert(inherit != null); diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteBorderEdgeRedirect.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteBorderEdgeRedirect.cs index a580b9e17..707105eb2 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteBorderEdgeRedirect.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteBorderEdgeRedirect.cs @@ -127,7 +127,7 @@ public PaletteGraphicsHint GetBackGraphicsHint(PaletteState state) => /// Source for inheriting defaulted values. /// Delegate for notifying paint requests. public PaletteBorderEdgeRedirect(IPaletteBorder inherit, - NeedPaintHandler needPaint) + NeedPaintHandler? needPaint) : base(null, needPaint) { // Remember inheritance diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteCueHintText.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteCueHintText.cs index e8dc73f28..5684bf2a4 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteCueHintText.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteCueHintText.cs @@ -163,9 +163,8 @@ internal void PerformPaint(VisualControlBase textBox, Graphics? g, PI.RECT rect, layoutRectangle.Height -= padding.Top + padding.Bottom; } - using Font font = GetContentShortTextNewFont(PaletteState.Normal); - using SolidBrush foreBrush = new SolidBrush(GetContentShortTextColor1(PaletteState.Normal)); + using var foreBrush = new SolidBrush(GetContentShortTextColor1(PaletteState.Normal)); var drawText = string.IsNullOrEmpty(CueHintText) ? textBox.Text : CueHintText; g.DrawString(drawText, font, foreBrush, layoutRectangle, stringFormat); } diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonMicrosoft365Renderer.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonMicrosoft365Renderer.cs index ca43e9e86..d3bf1b017 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonMicrosoft365Renderer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonMicrosoft365Renderer.cs @@ -60,14 +60,14 @@ public virtual void DrawItem(Graphics? g, Rectangle rect) public virtual void DrawBorder(Graphics? g, Rectangle rect) { // Drawing with anti aliasing to create smoother appearance - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); Rectangle backRectI = rect; backRectI.Inflate(1, 1); // Finally draw the border around the menu item - using LinearGradientBrush borderBrush = new LinearGradientBrush(backRectI, Border1, Border2, 90f); + using var borderBrush = new LinearGradientBrush(backRectI, Border1, Border2, 90f); // Convert the brush to a pen for DrawPath call - using Pen borderPen = new Pen(borderBrush); + using var borderPen = new Pen(borderBrush); // Create border path around the entire item using GraphicsPath borderPath = CreateBorderPath(rect, _cutItemMenu); g?.DrawPath(borderPen, borderPath); @@ -125,9 +125,9 @@ public GradientItemColorsTracking(Color border, public override void DrawBack(Graphics? g, Rectangle rect) { - Rectangle inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); - Rectangle insetB = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3); - Rectangle insetC = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4); + var inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); + var insetB = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3); + var insetC = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4); using LinearGradientBrush insideBrush1 = new LinearGradientBrush(rect, Back1B, Back1, 90f), insideBrush2 = new LinearGradientBrush(insetB, Back2B, Back2, 90f); @@ -137,23 +137,23 @@ public override void DrawBack(Graphics? g, Rectangle rect) g.FillRectangle(insideBrush1, inset); using GraphicsPath borderPath = CreateBorderPath(insetC, _cutInnerItemMenu), clipPath = CreateBorderPath(insetB, _cutInnerItemMenu); - using (Pen insidePen = new Pen(insideBrush2)) + using (var insidePen = new Pen(insideBrush2)) { g.DrawPath(insidePen, borderPath); } g.FillPath(insideBrush2, borderPath); - using (Clipping clipping = new Clipping(g, clipPath)) + using (var clipping = new Clipping(g, clipPath)) { - using (GraphicsPath ellipsePath = new GraphicsPath()) + using (var ellipsePath = new GraphicsPath()) { - RectangleF ellipseRect = new RectangleF(-(rect.Width / 2), rect.Bottom - 9, rect.Width * 2, 18); - PointF ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), + var ellipseRect = new RectangleF(-(rect.Width / 2), rect.Bottom - 9, rect.Width * 2, 18); + var ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), ellipseRect.Top + (ellipseRect.Height / 2)); ellipsePath.AddEllipse(ellipseRect); - using (PathGradientBrush insideLighten = new PathGradientBrush(ellipsePath)) + using (var insideLighten = new PathGradientBrush(ellipsePath)) { insideLighten.CenterPoint = ellipseCenter; insideLighten.CenterColor = Color.White; @@ -187,7 +187,6 @@ public GradientItemColorsDisabled(Color border, Back2B = CommonHelper.ColorToBlackAndWhite(Back2B); } } - private class GradientItemColorsPressed : GradientItemColors { /// @@ -208,10 +207,10 @@ public GradientItemColorsPressed(Color border, public override void DrawBack(Graphics? g, Rectangle rect) { - Rectangle rect2 = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 1); - Rectangle rect3 = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 3); + var rect2 = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 1); + var rect3 = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 3); - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); using GraphicsPath path1 = CreateBorderPath(rect, _cutItemMenu), path2 = CreateBorderPath(rect2, _cutItemMenu), path3 = CreateBorderPath(rect3, _cutItemMenu); @@ -245,20 +244,20 @@ public GradientItemColorsChecked(Color border, public override void DrawBack(Graphics? g, Rectangle rect) { - Rectangle inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); + var inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); - using LinearGradientBrush insideBrush = new LinearGradientBrush(rect, Back2, Back1, 90f); + using var insideBrush = new LinearGradientBrush(rect, Back2, Back1, 90f); insideBrush.SetSigmaBellShape(0.5f); g.FillRectangle(insideBrush, inset); using GraphicsPath borderPath = CreateBorderPath(inset, _cutInnerItemMenu); - using GraphicsPath ellipsePath = new GraphicsPath(); - RectangleF ellipseRect = new RectangleF(rect.Left, rect.Bottom - 8, rect.Width, 8); - PointF ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), + using var ellipsePath = new GraphicsPath(); + var ellipseRect = new RectangleF(rect.Left, rect.Bottom - 8, rect.Width, 8); + var ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), ellipseRect.Top + (ellipseRect.Height / 2)); ellipsePath.AddEllipse(ellipseRect); - using PathGradientBrush insideLighten = new PathGradientBrush(ellipsePath); + using var insideLighten = new PathGradientBrush(ellipsePath); insideLighten.CenterPoint = ellipseCenter; insideLighten.CenterColor = Color.FromArgb(96, Color.White); insideLighten.SurroundColors = new[] { Color.Transparent }; @@ -403,7 +402,7 @@ protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) }; // Draw the actual arrow using a gradient - using LinearGradientBrush arrowBrush = new LinearGradientBrush(boundsF, color1, color2, angle); + using var arrowBrush = new LinearGradientBrush(boundsF, color1, color2, angle); e.Graphics.FillPath(arrowBrush, arrowPath); } } @@ -417,7 +416,7 @@ protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e) { // Cast to correct type - ToolStripButton button = (ToolStripButton)e.Item; + var button = (ToolStripButton)e.Item; if (button.Selected || button.Pressed || button.Checked) { @@ -469,17 +468,17 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) } // Drawing with anti aliasing to create smoother appearance - using AntiAlias aa = new AntiAlias(e.Graphics); + using var aa = new AntiAlias(e.Graphics); // Create border path for the check box using GraphicsPath borderPath = CreateBorderPath(checkBox, _cutItemMenu); // Fill the background in a solid color - using (SolidBrush fillBrush = new SolidBrush(KCT.CheckBackground)) + using (var fillBrush = new SolidBrush(KCT.CheckBackground)) { e.Graphics.FillPath(fillBrush, borderPath); } // Draw the border around the check box - using (Pen borderPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 1.05f, 1.52f, 2.75f))) + using (var borderPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 1.05f, 1.52f, 2.75f))) { e.Graphics.DrawPath(borderPen, borderPath); } @@ -487,7 +486,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) // If there is not an image, then we can draw the tick, square etc... if (e.Item.Image == null) { - CheckState checkState = CheckState.Unchecked; + var checkState = CheckState.Unchecked; // Extract the check state from the item if (e.Item is ToolStripMenuItem toolStripItem) @@ -503,7 +502,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) using (GraphicsPath tickPath = CreateTickPath(checkBox)) { // Draw the tick with a thickish brush - using Pen tickPen = + using var tickPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 3.86f, 3.02f, 1.07f), _contextCheckTickThickness); e.Graphics.DrawPath(tickPen, tickPath); @@ -514,7 +513,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) using (GraphicsPath tickPath = CreateIndeterminatePath(checkBox)) { // Draw the tick with a thickish brush - using (SolidBrush tickBrush = + using (var tickBrush = new SolidBrush(CommonHelper.WhitenColor(KCT.CheckBackground, 3.86f, 3.02f, 1.07f))) { e.Graphics.FillPath(tickBrush, tickPath); @@ -589,7 +588,7 @@ protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) } else { - using GraphicsTextHint clearTypeGridFit = + using var clearTypeGridFit = new GraphicsTextHint(e.Graphics, TextRenderingHint.ClearTypeGridFit); base.OnRenderItemText(e); } @@ -619,7 +618,7 @@ protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e) } else { - using ImageAttributes attribs = new ImageAttributes(); + using var attribs = new ImageAttributes(); attribs.SetColorMatrix(CommonHelper.MatrixDisabled); // Draw using the disabled matrix to make it look disabled @@ -729,7 +728,7 @@ protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventAr if (e.Item.Selected || e.Item.Pressed) { // Cast to correct type - ToolStripSplitButton splitButton = (ToolStripSplitButton)e.Item; + var splitButton = (ToolStripSplitButton)e.Item; // Draw the border and background RenderToolSplitButtonBackground(e.Graphics, splitButton, e.ToolStrip); @@ -802,7 +801,7 @@ protected override void OnRenderToolStripContentPanelBackground(ToolStripContent // Cannot paint a zero sized area if (e.ToolStripContentPanel is { Width: > 0, Height: > 0 }) { - using LinearGradientBrush backBrush = new LinearGradientBrush(e.ToolStripContentPanel.ClientRectangle, + using var backBrush = new LinearGradientBrush(e.ToolStripContentPanel.ClientRectangle, KCT.ToolStripContentPanelGradientEnd, KCT.ToolStripContentPanelGradientBegin, 90f); e.Graphics.FillRectangle(backBrush, e.ToolStripContentPanel.ClientRectangle); } @@ -830,9 +829,9 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) using GraphicsPath borderPath = CreateBorderPath(e.AffectedBounds, _cutContextMenu), clipPath = CreateClipBorderPath(e.AffectedBounds, _cutContextMenu); // Clip all drawing to within the border path - using Clipping clipping = new Clipping(e.Graphics, clipPath); + using var clipping = new Clipping(e.Graphics, clipPath); // Create the background brush - using SolidBrush backBrush = new SolidBrush(KCT.ToolStripDropDownBackground); + using var backBrush = new SolidBrush(KCT.ToolStripDropDownBackground); e.Graphics.FillPath(backBrush, borderPath); break; } @@ -844,21 +843,21 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) e.ToolStrip.Font = KCT.StatusStripFont; } - // We do not paint the top two pixel lines, as they are drawn by the status strip border render method - RectangleF backRect = new RectangleF(0, 1.5f, e.ToolStrip.Width, e.ToolStrip.Height - 2); + // We do not paint the top two pixel lines, as they are drawn by the status strip border render method + var backRect = new RectangleF(0, 1.5f, e.ToolStrip.Width, e.ToolStrip.Height - 2); // Cannot paint a zero sized area if (backRect is { Width: > 0, Height: > 0 }) { - //using (LinearGradientBrush backBrush = new LinearGradientBrush(backRect, - // KCT.StatusStripGradientBegin, - // KCT.StatusStripGradientEnd, - // 90f)) - //{ - // backBrush.Blend = _stripBlend; - // e.Graphics.FillRectangle(backBrush, backRect); - //} - using SolidBrush backBrush = new SolidBrush(KCT.StatusStripGradientEnd); + //using (var backBrush = new LinearGradientBrush(backRect, + // KCT.StatusStripGradientBegin, + // KCT.StatusStripGradientEnd, + // 90f)) + //{ + // backBrush.Blend = _stripBlend; + // e.Graphics.FillRectangle(backBrush, backRect); + //} + using var backBrush = new SolidBrush(KCT.StatusStripGradientEnd); e.Graphics.FillRectangle(backBrush, backRect); } @@ -882,13 +881,13 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) e.ToolStrip.Font = KCT.ToolStripFont; } - // Cannot paint a zero sized area - RectangleF backRect = new RectangleF(0, 0, e.ToolStrip.Width, e.ToolStrip.Height); + // Cannot paint a zero sized area + var backRect = new RectangleF(0, 0, e.ToolStrip.Width, e.ToolStrip.Height); if (backRect is { Width: > 0, Height: > 0 }) { if (e.ToolStrip.Orientation == Orientation.Horizontal) { - using (LinearGradientBrush backBrush = new LinearGradientBrush(backRect, + using (var backBrush = new LinearGradientBrush(backRect, KCT.ToolStripGradientBegin, KCT.ToolStripGradientEnd, 90f)) { backBrush.Blend = _stripBlend; @@ -905,7 +904,7 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) } else { - using (LinearGradientBrush backBrush = new LinearGradientBrush(backRect, + using (var backBrush = new LinearGradientBrush(backRect, KCT.ToolStripGradientBegin, KCT.ToolStripGradientEnd, 0f)) { backBrush.Blend = _stripBlend; @@ -942,7 +941,7 @@ protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) // If there is a connected area to be drawn if (!e.ConnectedArea.IsEmpty) { - using SolidBrush excludeBrush = new SolidBrush(KCT.ToolStripDropDownBackground); + using var excludeBrush = new SolidBrush(KCT.ToolStripDropDownBackground); e.Graphics.FillRectangle(excludeBrush, e.ConnectedArea); } @@ -954,9 +953,9 @@ protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) using Pen borderPen = new Pen(KCT.MenuBorder), insidePen = new Pen(KCT.ToolStripDropDownBackground); // Clip all drawing to within the border path - using Clipping clipping = new Clipping(e.Graphics, clipPath); + using var clipping = new Clipping(e.Graphics, clipPath); // Drawing with anti aliasing to create smoother appearance - using (AntiAlias aa = new AntiAlias(e.Graphics)) + using (var aa = new AntiAlias(e.Graphics)) { // Draw the inside area first e.Graphics.DrawPath(insidePen, insidePath); @@ -1014,7 +1013,7 @@ protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) marginRect.X += _marginInset / 2; } - using Pen marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); + using var marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); if (!rtl) { e.Graphics.DrawLine(marginPen, marginRect.Right, marginRect.Top, marginRect.Right, marginRect.Bottom); @@ -1154,7 +1153,7 @@ private void DrawGradientToolSplitItem(Graphics? g, GradientItemColors colorsSplit) { // Create entire area and just the drop button area rectangles - Rectangle backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); + var backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); Rectangle backRectDrop = splitButton.DropDownButtonBounds; // Cannot paint zero sized areas @@ -1192,12 +1191,12 @@ private void DrawGradientToolSplitItem(Graphics? g, colorsDrop.DrawBack(g, backRectDrop); // Draw the split line between the areas - using (LinearGradientBrush splitBrush = new LinearGradientBrush( + using (var splitBrush = new LinearGradientBrush( new Rectangle(backRect.X + splitOffset, backRect.Top, 1, backRect.Height + 1), colorsSplit.Border1, colorsSplit.Border2, 90f)) { // Convert the brush to a pen for DrawPath call - using (Pen splitPen = new Pen(splitBrush)) + using (var splitPen = new Pen(splitBrush)) { g.DrawLine(splitPen, backRect.X + splitOffset, backRect.Top + 1, backRect.X + splitOffset, backRect.Bottom - 1); } @@ -1211,22 +1210,22 @@ private void DrawGradientToolSplitItem(Graphics? g, private void DrawContextMenuHeader(Graphics? g, ToolStripItem item) { // Get the rectangle that is the items area - Rectangle itemRect = new Rectangle(Point.Empty, item.Bounds.Size); + var itemRect = new Rectangle(Point.Empty, item.Bounds.Size); // Create border and clipping paths using GraphicsPath borderPath = CreateBorderPath(itemRect, _cutHeaderMenu), insidePath = CreateInsideBorderPath(itemRect, _cutHeaderMenu), clipPath = CreateClipBorderPath(itemRect, _cutHeaderMenu); // Clip all drawing to within the border path - using Clipping clipping = new Clipping(g, clipPath); + using var clipping = new Clipping(g, clipPath); // Draw the entire background area first - using (SolidBrush backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) + using (var backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) { g.FillPath(backBrush, borderPath); } // Draw the border - using (Pen borderPen = new Pen(KCT.MenuBorder)) + using (var borderPen = new Pen(KCT.MenuBorder)) { g.DrawPath(borderPen, borderPath); } @@ -1283,7 +1282,7 @@ private void DrawGradientContextMenuItem(Graphics? g, GradientItemColors colors) { // Do we need to draw with separator on the opposite edge? - Rectangle backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); + var backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); // Perform actual drawing into the background colors.DrawItem(g, backRect); @@ -1309,7 +1308,7 @@ private void DrawContextMenuSeparator(Graphics g, var t = rect.Y; var b = rect.Bottom; - using Pen marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); + using var marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); marginPen.DashPattern = new float[] { 2, 2 }; g.DrawLine(marginPen, l, t, l, b); } @@ -1319,7 +1318,7 @@ private void DrawContextMenuSeparator(Graphics g, var l = rect.X + (rtl ? 0 : horizontalInset); var r = rect.Right - (rtl ? horizontalInset : 0); - using Pen marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); + using var marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); marginPen.DashPattern = new float[] { 2, 2 }; g.DrawLine(marginPen, l, y, r, y); } @@ -1333,7 +1332,7 @@ private void DrawToolStripSeparator(Graphics g, int horizontalInset, bool rtl) { - RectangleF boundsF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); + var boundsF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); if (vertical) { @@ -1438,7 +1437,7 @@ private static GraphicsPath CreateBorderPath(Rectangle rect, pts.Add(new PointF(l, y0)); // Create path using a simple set of lines that cut the corner - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); // Add a line between each set of points for (var i = 1; i < pts.Count; i++) @@ -1459,7 +1458,7 @@ private static GraphicsPath CreateBorderPath(Rectangle rect, float cut) rect.Height--; // Create path using a simple set of lines that cut the corner - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(rect.Left + cut, rect.Top, rect.Right - cut, rect.Top); path.AddLine(rect.Right - cut, rect.Top, rect.Right, rect.Top + cut); path.AddLine(rect.Right, rect.Top + cut, rect.Right, rect.Bottom - cut); @@ -1539,7 +1538,7 @@ private GraphicsPath CreateArrowPath(ToolStripItem item, } // Create triangle using a series of lines - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); switch (direction) { @@ -1574,7 +1573,7 @@ private GraphicsPath CreateTickPath(Rectangle rect) var x = rect.X + rect.Width / 2; var y = rect.Y + rect.Height / 2; - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(x - 4, y, x - 2, y + 4); path.AddLine(x - 2, y + 4, x + 3, y - 5); return path; @@ -1586,7 +1585,7 @@ private GraphicsPath CreateIndeterminatePath(Rectangle rect) var x = rect.X + rect.Width / 2; var y = rect.Y + rect.Height / 2; - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(x - 3, y, x, y - 3); path.AddLine(x, y - 3, x + 3, y); path.AddLine(x + 3, y, x, y + 3); diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonOffice2007Renderer.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonOffice2007Renderer.cs index b0b83a122..f23266201 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonOffice2007Renderer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonOffice2007Renderer.cs @@ -283,7 +283,7 @@ protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) }; // Draw the actual arrow using a gradient - using LinearGradientBrush arrowBrush = new LinearGradientBrush(boundsF, color1, color2, angle); + using var arrowBrush = new LinearGradientBrush(boundsF, color1, color2, angle); e.Graphics.FillPath(arrowBrush, arrowPath); } } @@ -297,7 +297,7 @@ protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e) { // Cast to correct type - ToolStripButton button = (ToolStripButton)e.Item; + var button = (ToolStripButton)e.Item; if (button.Selected || button.Pressed || button.Checked) { @@ -349,17 +349,17 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) //} // Drawing with anti aliasing to create smoother appearance - using AntiAlias aa = new AntiAlias(e.Graphics); + using var aa = new AntiAlias(e.Graphics); // Create border path for the check box using GraphicsPath borderPath = CreateBorderPath(checkBox, 0 /*CUT_MENU_ITEM_BACK*/); // Fill the background in a solid color - using (SolidBrush fillBrush = new SolidBrush(KCT.CheckBackground)) + using (var fillBrush = new SolidBrush(KCT.CheckBackground)) { e.Graphics.FillPath(fillBrush, borderPath); } // Draw the border around the check box - using (Pen borderPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 1.05f, 1.52f, 2.75f))) + using (var borderPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 1.05f, 1.52f, 2.75f))) { e.Graphics.DrawPath(borderPen, borderPath); } @@ -367,7 +367,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) // If there is not an image, then we can draw the tick, square etc... if (e.Item.Image == null) { - CheckState checkState = CheckState.Unchecked; + var checkState = CheckState.Unchecked; // Extract the check state from the item if (e.Item is ToolStripMenuItem item) @@ -383,7 +383,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) using (GraphicsPath tickPath = CreateTickPath(checkBox)) { // Draw the tick with a thickish brush - using (Pen tickPen = + using (var tickPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 3.86f, 3.02f, 1.07f), CONTEXT_CHECK_TICK_THICKNESS)) { @@ -396,7 +396,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) using (GraphicsPath tickPath = CreateIndeterminatePath(checkBox)) { // Draw the tick with a thickish brush - using (SolidBrush tickBrush = + using (var tickBrush = new SolidBrush(CommonHelper.WhitenColor(KCT.CheckBackground, 3.86f, 3.02f, 1.07f))) { e.Graphics.FillPath(tickBrush, tickPath); @@ -441,7 +441,7 @@ protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) } else { - using GraphicsTextHint clearTypeGridFit = + using var clearTypeGridFit = new GraphicsTextHint(e.Graphics, TextRenderingHint.ClearTypeGridFit); base.OnRenderItemText(e); } @@ -471,7 +471,7 @@ protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e) } else { - using ImageAttributes attribs = new ImageAttributes(); + using var attribs = new ImageAttributes(); attribs.SetColorMatrix(CommonHelper.MatrixDisabled); // Draw using the disabled matrix to make it look disabled @@ -561,7 +561,7 @@ protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventAr if (e.Item.Selected || e.Item.Pressed) { // Cast to correct type - ToolStripSplitButton splitButton = (ToolStripSplitButton)e.Item; + var splitButton = (ToolStripSplitButton)e.Item; // Draw the border and background RenderToolSplitButtonBackground(e.Graphics, splitButton, e.ToolStrip); @@ -634,7 +634,7 @@ protected override void OnRenderToolStripContentPanelBackground(ToolStripContent // Cannot paint a zero sized area if (e.ToolStripContentPanel is { Width: > 0, Height: > 0 }) { - using LinearGradientBrush backBrush = new LinearGradientBrush(e.ToolStripContentPanel.ClientRectangle, + using var backBrush = new LinearGradientBrush(e.ToolStripContentPanel.ClientRectangle, KCT.ToolStripContentPanelGradientEnd, KCT.ToolStripContentPanelGradientBegin, 90f); e.Graphics.FillRectangle(backBrush, e.ToolStripContentPanel.ClientRectangle); } @@ -698,10 +698,10 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) clipPath = CreateClipBorderPath(e.AffectedBounds, CUT_CONTEXT_MENU)) { // Clip all drawing to within the border path - using (Clipping clipping = new Clipping(e.Graphics, clipPath)) + using (var clipping = new Clipping(e.Graphics, clipPath)) { // Create the background brush - using (SolidBrush backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) + using (var backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) { e.Graphics.FillPath(backBrush, borderPath); } @@ -709,22 +709,23 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) } break; case StatusStrip _: + { // Make sure the font is current e.ToolStrip.Font = KCT.StatusStripFont; // We do not paint the top two pixel lines, so are drawn by the status strip border render method - RectangleF backRect = new RectangleF(0, 1.5f, e.ToolStrip.Width, e.ToolStrip.Height - 2); + var backRect = new RectangleF(0, 1.5f, e.ToolStrip.Width, e.ToolStrip.Height - 2); Form owner = e.ToolStrip.FindForm(); // Check if the status strip is inside a KryptonForm and using the Office 2007 renderer, in // which case we want to extend the drawing down into the border area for an integrated look if (e.ToolStrip.Visible - && e.ToolStrip is { Dock: DockStyle.Bottom, RenderMode: ToolStripRenderMode.ManagerRenderMode } - && (ToolStripManager.Renderer is KryptonOffice2007Renderer) - && owner is KryptonForm kryptonForm + && e.ToolStrip is { Dock: DockStyle.Bottom, RenderMode: ToolStripRenderMode.ManagerRenderMode } + && (ToolStripManager.Renderer is KryptonOffice2007Renderer) + && owner is KryptonForm kryptonForm && (e.ToolStrip.Bottom == owner.ClientSize.Height) - ) + ) { // Get the window borders @@ -739,11 +740,12 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) // Cannot paint a zero sized area if (backRect is { Width: > 0, Height: > 0 }) { - using LinearGradientBrush backBrush = new LinearGradientBrush(backRect, + using var backBrush = new LinearGradientBrush(backRect, KCT.StatusStripGradientBegin, KCT.StatusStripGradientEnd, 90f); backBrush.Blend = _statusStripBlend; e.Graphics.FillRectangle(backBrush, backRect); } + } break; default: if (e.ToolStrip is MenuStrip) @@ -798,7 +800,7 @@ protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) } // Draw the entire margin area in a solid color - using (SolidBrush backBrush = new SolidBrush(KCT.ImageMarginGradientBegin)) + using (var backBrush = new SolidBrush(KCT.ImageMarginGradientBegin)) { e.Graphics.FillRectangle(backBrush, marginRect); } @@ -841,28 +843,31 @@ protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) { case ContextMenuStrip _: case ToolStripDropDownMenu _: + { // If there is a connected area to be drawn if (!e.ConnectedArea.IsEmpty) { - using SolidBrush excludeBrush = new SolidBrush(KCT.ToolStripDropDownBackground); + using var excludeBrush = new SolidBrush(KCT.ToolStripDropDownBackground); e.Graphics.FillRectangle(excludeBrush, e.ConnectedArea); } // Create border and clipping paths - using (GraphicsPath borderPath = CreateBorderPath(e.AffectedBounds, e.ConnectedArea, CUT_CONTEXT_MENU), - insidePath = CreateInsideBorderPath(e.AffectedBounds, e.ConnectedArea, CUT_CONTEXT_MENU), - clipPath = CreateClipBorderPath(e.AffectedBounds, e.ConnectedArea, CUT_CONTEXT_MENU)) + using (GraphicsPath borderPath = + CreateBorderPath(e.AffectedBounds, e.ConnectedArea, CUT_CONTEXT_MENU), + insidePath = CreateInsideBorderPath(e.AffectedBounds, e.ConnectedArea, CUT_CONTEXT_MENU), + clipPath = CreateClipBorderPath(e.AffectedBounds, e.ConnectedArea, CUT_CONTEXT_MENU)) { // Create the different pen colors we need using (Pen borderPen = new Pen(KCT.MenuBorder), - insidePen = new Pen(CommonHelper.WhitenColor(KCT.ToolStripDropDownBackground, 1.02f, 1.02f, - 1.02f))) + insidePen = new Pen(CommonHelper.WhitenColor(KCT.ToolStripDropDownBackground, 1.02f, + 1.02f, + 1.02f))) { // Clip all drawing to within the border path - using (Clipping clipping = new Clipping(e.Graphics, clipPath)) + using (var clipping = new Clipping(e.Graphics, clipPath)) { // Drawing with anti aliasing to create smoother appearance - using (AntiAlias aa = new AntiAlias(e.Graphics)) + using (var aa = new AntiAlias(e.Graphics)) { // Draw the inside area first e.Graphics.DrawPath(insidePen, insidePath); @@ -877,16 +882,17 @@ protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) } } } + } break; case StatusStrip _: + { // Draw two lines at top of the status strip - using (Pen darkBorder = - new Pen(CommonHelper.WhitenColor(KCT.StatusStripGradientEnd, 1.6f, 1.6f, 1.6f)), - lightBorder = new Pen(ControlPaint.LightLight(KCT.StatusStripGradientBegin))) - { - e.Graphics.DrawLine(darkBorder, 0, 0, e.ToolStrip.Width, 0); - e.Graphics.DrawLine(lightBorder, 0, 1, e.ToolStrip.Width, 1); - } + using Pen darkBorder = + new Pen(CommonHelper.WhitenColor(KCT.StatusStripGradientEnd, 1.6f, 1.6f, 1.6f)), + lightBorder = new Pen(ControlPaint.LightLight(KCT.StatusStripGradientBegin)); + e.Graphics.DrawLine(darkBorder, 0, 0, e.ToolStrip.Width, 0); + e.Graphics.DrawLine(lightBorder, 0, 1, e.ToolStrip.Width, 1); + } break; default: base.OnRenderToolStripBorder(e); @@ -1018,7 +1024,7 @@ private void DrawGradientToolSplitItem(Graphics? g, GradientItemColors colorsSplit) { // Create entire area and just the drop button area rectangles - Rectangle backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); + var backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); Rectangle backRectDrop = splitButton.DropDownButtonBounds; // Cannot paint zero sized areas @@ -1056,7 +1062,7 @@ private void DrawGradientToolSplitItem(Graphics? g, DrawGradientBack(g, backRectDrop, colorsDrop); // Draw the split line between the areas - using (LinearGradientBrush splitBrush = new LinearGradientBrush( + using (var splitBrush = new LinearGradientBrush( new Rectangle(backRect.X + splitOffset, backRect.Top, 1, backRect.Height + 1), colorsSplit.Border1, colorsSplit.Border2, 90f)) { @@ -1064,7 +1070,7 @@ private void DrawGradientToolSplitItem(Graphics? g, splitBrush.SetSigmaBellShape(0.5f); // Convert the brush to a pen for DrawPath call - using (Pen splitPen = new Pen(splitBrush)) + using (var splitPen = new Pen(splitBrush)) { g.DrawLine(splitPen, backRect.X + splitOffset, backRect.Top + 1, backRect.X + splitOffset, backRect.Bottom - 1); } @@ -1078,23 +1084,23 @@ private void DrawGradientToolSplitItem(Graphics? g, private void DrawContextMenuHeader(Graphics? g, ToolStripItem item) { // Get the rectangle that is the items area - Rectangle itemRect = new Rectangle(Point.Empty, item.Bounds.Size); + var itemRect = new Rectangle(Point.Empty, item.Bounds.Size); // Create border and clipping paths using GraphicsPath borderPath = CreateBorderPath(itemRect, CUT_TOOL_ITEM_MENU), insidePath = CreateInsideBorderPath(itemRect, CUT_TOOL_ITEM_MENU), clipPath = CreateClipBorderPath(itemRect, CUT_TOOL_ITEM_MENU); // Clip all drawing to within the border path - using Clipping clipping = new Clipping(g, clipPath); + using var clipping = new Clipping(g, clipPath); // Draw the entire background area first - using (SolidBrush backBrush = + using (var backBrush = new SolidBrush(CommonHelper.WhitenColor(KCT.ToolStripDropDownBackground, 1.02f, 1.02f, 1.02f))) { g.FillPath(backBrush, borderPath); } // Draw the border - using (Pen borderPen = new Pen(KCT.MenuBorder)) + using (var borderPen = new Pen(KCT.MenuBorder)) { g.DrawPath(borderPen, borderPath); } @@ -1151,7 +1157,7 @@ private void DrawGradientContextMenuItem(Graphics? g, GradientItemColors colors) { // Do we need to draw with separator on the opposite edge? - Rectangle backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); + var backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); // Perform actual drawing into the background DrawGradientItem(g, backRect, colors); @@ -1180,8 +1186,8 @@ private static void DrawGradientBack(Graphics? g, backRect.Inflate(-1, -1); var y2 = backRect.Height / 2; - Rectangle backRect1 = new Rectangle(backRect.X, backRect.Y, backRect.Width, y2); - Rectangle backRect2 = new Rectangle(backRect.X, backRect.Y + y2, backRect.Width, backRect.Height - y2); + var backRect1 = new Rectangle(backRect.X, backRect.Y, backRect.Width, y2); + var backRect2 = new Rectangle(backRect.X, backRect.Y + y2, backRect.Width, backRect.Height - y2); Rectangle backRect1I = backRect1; Rectangle backRect2I = backRect2; backRect1I.Inflate(1, 1); @@ -1226,18 +1232,18 @@ private static void DrawGradientBorder(Graphics? g, GradientItemColors colors) { // Drawing with anti aliasing to create smoother appearance - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); Rectangle backRectI = backRect; backRectI.Inflate(1, 1); // Finally draw the border around the menu item - using LinearGradientBrush borderBrush = + using var borderBrush = new LinearGradientBrush(backRectI, colors.Border1, colors.Border2, 90f); // Sigma curve, so go from color1 to color2 and back to color1 again borderBrush.SetSigmaBellShape(0.5f); // Convert the brush to a pen for DrawPath call - using Pen borderPen = new Pen(borderBrush); + using var borderPen = new Pen(borderBrush); // Create border path around the entire item using GraphicsPath borderPath = CreateBorderPath(backRect, CUT_MENU_ITEM_BACK); g.DrawPath(borderPen, borderPath); @@ -1356,7 +1362,7 @@ private static GraphicsPath CreateBorderPath(Rectangle rect, pts.Add(new PointF(l, y0)); // Create path using a simple set of lines that cut the corner - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); // Add a line between each set of points for (var i = 1; i < pts.Count; i++) @@ -1377,7 +1383,7 @@ private static GraphicsPath CreateBorderPath(Rectangle rect, float cut) rect.Height--; // Create path using a simple set of lines that cut the corner - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(rect.Left + cut, rect.Top, rect.Right - cut, rect.Top); path.AddLine(rect.Right - cut, rect.Top, rect.Right, rect.Top + cut); path.AddLine(rect.Right, rect.Top + cut, rect.Right, rect.Bottom - cut); @@ -1457,7 +1463,7 @@ private GraphicsPath CreateArrowPath(ToolStripItem item, } // Create triangle using a series of lines - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); switch (direction) { @@ -1492,7 +1498,7 @@ private GraphicsPath CreateTickPath(Rectangle rect) var x = rect.X + (rect.Width / 2); var y = rect.Y + (rect.Height / 2); - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); //path.AddLine(x - 4, y, x - 2, y + 4); //path.AddLine(x - 2, y + 4, x + 3, y - 5); path.AddLine(x - 4, y - 1, x - 2, y - 1 + 4); @@ -1506,7 +1512,7 @@ private GraphicsPath CreateIndeterminatePath(Rectangle rect) var x = rect.X + (rect.Width / 2); var y = rect.Y + (rect.Height / 2); - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(x - 3, y, x, y - 3); path.AddLine(x, y - 3, x + 3, y); path.AddLine(x + 3, y, x, y + 3); diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonOffice2010Renderer.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonOffice2010Renderer.cs index b23e098d6..7cb9a84a3 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonOffice2010Renderer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonOffice2010Renderer.cs @@ -59,14 +59,14 @@ public virtual void DrawItem(Graphics? g, Rectangle rect) public virtual void DrawBorder(Graphics? g, Rectangle rect) { // Drawing with anti aliasing to create smoother appearance - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); Rectangle backRectI = rect; backRectI.Inflate(1, 1); // Finally draw the border around the menu item - using LinearGradientBrush borderBrush = new LinearGradientBrush(backRectI, Border1, Border2, 90f); + using var borderBrush = new LinearGradientBrush(backRectI, Border1, Border2, 90f); // Convert the brush to a pen for DrawPath call - using Pen borderPen = new Pen(borderBrush); + using var borderPen = new Pen(borderBrush); // Create border path around the entire item using GraphicsPath borderPath = CreateBorderPath(rect, CUT_ITEM_MENU); g.DrawPath(borderPen, borderPath); @@ -124,9 +124,9 @@ public GradientItemColorsTracking(Color border, public override void DrawBack(Graphics? g, Rectangle rect) { - Rectangle inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); - Rectangle insetB = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3); - Rectangle insetC = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4); + var inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); + var insetB = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3); + var insetC = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4); using LinearGradientBrush insideBrush1 = new LinearGradientBrush(rect, Back1B, Back1, 90f), insideBrush2 = new LinearGradientBrush(insetB, Back2B, Back2, 90f); @@ -136,23 +136,23 @@ public override void DrawBack(Graphics? g, Rectangle rect) g.FillRectangle(insideBrush1, inset); using GraphicsPath borderPath = CreateBorderPath(insetC, CUT_INNER_ITEM_MENU), clipPath = CreateBorderPath(insetB, CUT_INNER_ITEM_MENU); - using (Pen insidePen = new Pen(insideBrush2)) + using (var insidePen = new Pen(insideBrush2)) { g.DrawPath(insidePen, borderPath); } g.FillPath(insideBrush2, borderPath); - using (Clipping clipping = new Clipping(g, clipPath)) + using (var clipping = new Clipping(g, clipPath)) { - using (GraphicsPath ellipsePath = new GraphicsPath()) + using (var ellipsePath = new GraphicsPath()) { - RectangleF ellipseRect = new RectangleF(-(rect.Width / 2), rect.Bottom - 9, rect.Width * 2, 18); - PointF ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), + var ellipseRect = new RectangleF(-(rect.Width / 2), rect.Bottom - 9, rect.Width * 2, 18); + var ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), ellipseRect.Top + (ellipseRect.Height / 2)); ellipsePath.AddEllipse(ellipseRect); - using (PathGradientBrush insideLighten = new PathGradientBrush(ellipsePath)) + using (var insideLighten = new PathGradientBrush(ellipsePath)) { insideLighten.CenterPoint = ellipseCenter; insideLighten.CenterColor = Color.White; @@ -207,10 +207,10 @@ public GradientItemColorsPressed(Color border, public override void DrawBack(Graphics? g, Rectangle rect) { - Rectangle rect2 = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 1); - Rectangle rect3 = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 3); + var rect2 = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 1); + var rect3 = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 3); - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); using GraphicsPath path1 = CreateBorderPath(rect, CUT_ITEM_MENU), path2 = CreateBorderPath(rect2, CUT_ITEM_MENU), path3 = CreateBorderPath(rect3, CUT_ITEM_MENU); @@ -244,20 +244,20 @@ public GradientItemColorsChecked(Color border, public override void DrawBack(Graphics? g, Rectangle rect) { - Rectangle inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); + var inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); - using LinearGradientBrush insideBrush = new LinearGradientBrush(rect, Back2, Back1, 90f); + using var insideBrush = new LinearGradientBrush(rect, Back2, Back1, 90f); insideBrush.SetSigmaBellShape(0.5f); g.FillRectangle(insideBrush, inset); using GraphicsPath borderPath = CreateBorderPath(inset, CUT_INNER_ITEM_MENU); - using GraphicsPath ellipsePath = new GraphicsPath(); - RectangleF ellipseRect = new RectangleF(rect.Left, rect.Bottom - 8, rect.Width, 8); - PointF ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), + using var ellipsePath = new GraphicsPath(); + var ellipseRect = new RectangleF(rect.Left, rect.Bottom - 8, rect.Width, 8); + var ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), ellipseRect.Top + (ellipseRect.Height / 2)); ellipsePath.AddEllipse(ellipseRect); - using PathGradientBrush insideLighten = new PathGradientBrush(ellipsePath); + using var insideLighten = new PathGradientBrush(ellipsePath); insideLighten.CenterPoint = ellipseCenter; insideLighten.CenterColor = Color.FromArgb(96, Color.White); insideLighten.SurroundColors = new[] { Color.Transparent }; @@ -403,7 +403,7 @@ protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) }; // Draw the actual arrow using a gradient - using LinearGradientBrush arrowBrush = new LinearGradientBrush(boundsF, color1, color2, angle); + using var arrowBrush = new LinearGradientBrush(boundsF, color1, color2, angle); e.Graphics.FillPath(arrowBrush, arrowPath); } } @@ -417,7 +417,7 @@ protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e) { // Cast to correct type - ToolStripButton button = (ToolStripButton)e.Item; + var button = (ToolStripButton)e.Item; if (button.Selected || button.Pressed || button.Checked) { @@ -469,17 +469,17 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) } // Drawing with anti aliasing to create smoother appearance - using AntiAlias aa = new AntiAlias(e.Graphics); + using var aa = new AntiAlias(e.Graphics); // Create border path for the check box using GraphicsPath borderPath = CreateBorderPath(checkBox, CUT_ITEM_MENU); // Fill the background in a solid color - using (SolidBrush fillBrush = new SolidBrush(KCT.CheckBackground)) + using (var fillBrush = new SolidBrush(KCT.CheckBackground)) { e.Graphics.FillPath(fillBrush, borderPath); } // Draw the border around the check box - using (Pen borderPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 1.05f, 1.52f, 2.75f))) + using (var borderPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 1.05f, 1.52f, 2.75f))) { e.Graphics.DrawPath(borderPen, borderPath); } @@ -487,7 +487,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) // If there is not an image, then we can draw the tick, square etc... if (e.Item.Image == null) { - CheckState checkState = CheckState.Unchecked; + var checkState = CheckState.Unchecked; // Extract the check state from the item if (e.Item is ToolStripMenuItem item) @@ -503,7 +503,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) using (GraphicsPath tickPath = CreateTickPath(checkBox)) { // Draw the tick with a thickish brush - using (Pen tickPen = + using (var tickPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 3.86f, 3.02f, 1.07f), CONTEXT_CHECK_TICK_THICKNESS)) { @@ -516,7 +516,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) using (GraphicsPath tickPath = CreateIndeterminatePath(checkBox)) { // Draw the tick with a thickish brush - using (SolidBrush tickBrush = + using (var tickBrush = new SolidBrush(CommonHelper.WhitenColor(KCT.CheckBackground, 3.86f, 3.02f, 1.07f))) { e.Graphics.FillPath(tickBrush, tickPath); @@ -589,7 +589,7 @@ protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) } else { - using GraphicsTextHint clearTypeGridFit = + using var clearTypeGridFit = new GraphicsTextHint(e.Graphics, TextRenderingHint.ClearTypeGridFit); base.OnRenderItemText(e); } @@ -619,7 +619,7 @@ protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e) } else { - using ImageAttributes attribs = new ImageAttributes(); + using var attribs = new ImageAttributes(); attribs.SetColorMatrix(CommonHelper.MatrixDisabled); // Draw using the disabled matrix to make it look disabled @@ -729,7 +729,7 @@ protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventAr if (e.Item.Selected || e.Item.Pressed) { // Cast to correct type - ToolStripSplitButton splitButton = (ToolStripSplitButton)e.Item; + var splitButton = (ToolStripSplitButton)e.Item; // Draw the border and background RenderToolSplitButtonBackground(e.Graphics, splitButton, e.ToolStrip); @@ -802,7 +802,7 @@ protected override void OnRenderToolStripContentPanelBackground(ToolStripContent // Cannot paint a zero sized area if (e.ToolStripContentPanel is { Width: > 0, Height: > 0 }) { - using LinearGradientBrush backBrush = new LinearGradientBrush(e.ToolStripContentPanel.ClientRectangle, + using var backBrush = new LinearGradientBrush(e.ToolStripContentPanel.ClientRectangle, KCT.ToolStripContentPanelGradientEnd, KCT.ToolStripContentPanelGradientBegin, 90f); e.Graphics.FillRectangle(backBrush, e.ToolStripContentPanel.ClientRectangle); } @@ -831,10 +831,10 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) clipPath = CreateClipBorderPath(e.AffectedBounds, CUT_CONTEXT_MENU)) { // Clip all drawing to within the border path - using (Clipping clipping = new Clipping(e.Graphics, clipPath)) + using (var clipping = new Clipping(e.Graphics, clipPath)) { // Create the background brush - using (SolidBrush backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) + using (var backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) { e.Graphics.FillPath(backBrush, borderPath); } @@ -850,12 +850,12 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) } // We do not paint the top two pixel lines, as they are drawn by the status strip border render method - RectangleF backRect = new RectangleF(0, 1.5f, e.ToolStrip.Width, e.ToolStrip.Height - 2); + var backRect = new RectangleF(0, 1.5f, e.ToolStrip.Width, e.ToolStrip.Height - 2); // Cannot paint a zero sized area if (backRect is { Width: > 0, Height: > 0 }) { - using LinearGradientBrush backBrush = new LinearGradientBrush(backRect, + using var backBrush = new LinearGradientBrush(backRect, KCT.StatusStripGradientBegin, KCT.StatusStripGradientEnd, 90f); backBrush.Blend = _stripBlend; e.Graphics.FillRectangle(backBrush, backRect); @@ -878,12 +878,12 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) } // Cannot paint a zero sized area - RectangleF backRect = new RectangleF(0, 0, e.ToolStrip.Width, e.ToolStrip.Height); + var backRect = new RectangleF(0, 0, e.ToolStrip.Width, e.ToolStrip.Height); if (backRect is { Width: > 0, Height: > 0 }) { if (e.ToolStrip.Orientation == Orientation.Horizontal) { - using (LinearGradientBrush backBrush = new LinearGradientBrush(backRect, + using (var backBrush = new LinearGradientBrush(backRect, KCT.ToolStripGradientBegin, KCT.ToolStripGradientEnd, 90f)) { backBrush.Blend = _stripBlend; @@ -900,7 +900,7 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) } else { - using (LinearGradientBrush backBrush = new LinearGradientBrush(backRect, + using (var backBrush = new LinearGradientBrush(backRect, KCT.ToolStripGradientBegin, KCT.ToolStripGradientEnd, 0f)) { backBrush.Blend = _stripBlend; @@ -936,7 +936,7 @@ protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) // If there is a connected area to be drawn if (!e.ConnectedArea.IsEmpty) { - using SolidBrush excludeBrush = new SolidBrush(KCT.ToolStripDropDownBackground); + using var excludeBrush = new SolidBrush(KCT.ToolStripDropDownBackground); e.Graphics.FillRectangle(excludeBrush, e.ConnectedArea); } @@ -950,10 +950,10 @@ protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) insidePen = new Pen(KCT.ToolStripDropDownBackground)) { // Clip all drawing to within the border path - using (Clipping clipping = new Clipping(e.Graphics, clipPath)) + using (var clipping = new Clipping(e.Graphics, clipPath)) { // Drawing with anti aliasing to create smoother appearance - using (AntiAlias aa = new AntiAlias(e.Graphics)) + using (var aa = new AntiAlias(e.Graphics)) { // Draw the inside area first e.Graphics.DrawPath(insidePen, insidePath); @@ -1013,7 +1013,7 @@ protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) marginRect.X += MARGIN_INSET / 2; } - using Pen marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); + using var marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); if (!rtl) { e.Graphics.DrawLine(marginPen, marginRect.Right, marginRect.Top, marginRect.Right, marginRect.Bottom); @@ -1153,7 +1153,7 @@ private void DrawGradientToolSplitItem(Graphics? g, GradientItemColors colorsSplit) { // Create entire area and just the drop button area rectangles - Rectangle backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); + var backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); Rectangle backRectDrop = splitButton.DropDownButtonBounds; // Cannot paint zero sized areas @@ -1191,12 +1191,12 @@ private void DrawGradientToolSplitItem(Graphics? g, colorsDrop.DrawBack(g, backRectDrop); // Draw the split line between the areas - using (LinearGradientBrush splitBrush = new LinearGradientBrush( + using (var splitBrush = new LinearGradientBrush( new Rectangle(backRect.X + splitOffset, backRect.Top, 1, backRect.Height + 1), colorsSplit.Border1, colorsSplit.Border2, 90f)) { // Convert the brush to a pen for DrawPath call - using (Pen splitPen = new Pen(splitBrush)) + using (var splitPen = new Pen(splitBrush)) { g.DrawLine(splitPen, backRect.X + splitOffset, backRect.Top + 1, backRect.X + splitOffset, backRect.Bottom - 1); } @@ -1210,22 +1210,22 @@ private void DrawGradientToolSplitItem(Graphics? g, private void DrawContextMenuHeader(Graphics? g, ToolStripItem item) { // Get the rectangle that is the items area - Rectangle itemRect = new Rectangle(Point.Empty, item.Bounds.Size); + var itemRect = new Rectangle(Point.Empty, item.Bounds.Size); // Create border and clipping paths using GraphicsPath borderPath = CreateBorderPath(itemRect, CUT_HEADER_MENU), insidePath = CreateInsideBorderPath(itemRect, CUT_HEADER_MENU), clipPath = CreateClipBorderPath(itemRect, CUT_HEADER_MENU); // Clip all drawing to within the border path - using Clipping clipping = new Clipping(g, clipPath); + using var clipping = new Clipping(g, clipPath); // Draw the entire background area first - using (SolidBrush backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) + using (var backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) { g.FillPath(backBrush, borderPath); } // Draw the border - using (Pen borderPen = new Pen(KCT.MenuBorder)) + using (var borderPen = new Pen(KCT.MenuBorder)) { g.DrawPath(borderPen, borderPath); } @@ -1282,7 +1282,7 @@ private void DrawGradientContextMenuItem(Graphics? g, GradientItemColors colors) { // Do we need to draw with separator on the opposite edge? - Rectangle backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); + var backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); // Perform actual drawing into the background colors.DrawItem(g, backRect); @@ -1310,7 +1310,7 @@ private void DrawContextMenuSeparator(Graphics g, var t = rect.Y; var b = rect.Bottom; - using Pen marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); + using var marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); marginPen.DashPattern = new float[] { 2, 2 }; g.DrawLine(marginPen, l, t, l, b); } @@ -1320,7 +1320,7 @@ private void DrawContextMenuSeparator(Graphics g, var l = rect.X + (rtl ? 0 : horizontalInset); var r = rect.Right - (rtl ? horizontalInset : 0); - using Pen marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); + using var marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); marginPen.DashPattern = new float[] { 2, 2 }; g.DrawLine(marginPen, l, y, r, y); } @@ -1334,7 +1334,7 @@ private void DrawToolStripSeparator(Graphics g, int horizontalInset, bool rtl) { - RectangleF boundsF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); + var boundsF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); if (vertical) { @@ -1439,7 +1439,7 @@ private static GraphicsPath CreateBorderPath(Rectangle rect, pts.Add(new PointF(l, y0)); // Create path using a simple set of lines that cut the corner - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); // Add a line between each set of points for (var i = 1; i < pts.Count; i++) @@ -1460,7 +1460,7 @@ private static GraphicsPath CreateBorderPath(Rectangle rect, float cut) rect.Height--; // Create path using a simple set of lines that cut the corner - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(rect.Left + cut, rect.Top, rect.Right - cut, rect.Top); path.AddLine(rect.Right - cut, rect.Top, rect.Right, rect.Top + cut); path.AddLine(rect.Right, rect.Top + cut, rect.Right, rect.Bottom - cut); @@ -1540,7 +1540,7 @@ private GraphicsPath CreateArrowPath(ToolStripItem item, } // Create triangle using a series of lines - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); switch (direction) { @@ -1575,7 +1575,7 @@ private GraphicsPath CreateTickPath(Rectangle rect) var x = rect.X + (rect.Width / 2); var y = rect.Y + (rect.Height / 2); - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(x - 4, y, x - 2, y + 4); path.AddLine(x - 2, y + 4, x + 3, y - 5); return path; @@ -1587,7 +1587,7 @@ private GraphicsPath CreateIndeterminatePath(Rectangle rect) var x = rect.X + (rect.Width / 2); var y = rect.Y + (rect.Height / 2); - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(x - 3, y, x, y - 3); path.AddLine(x, y - 3, x + 3, y); path.AddLine(x + 3, y, x, y + 3); diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonOffice2013Renderer.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonOffice2013Renderer.cs index 675c23b88..18d53f076 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonOffice2013Renderer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonOffice2013Renderer.cs @@ -59,14 +59,14 @@ public virtual void DrawItem(Graphics? g, Rectangle rect) public virtual void DrawBorder(Graphics? g, Rectangle rect) { // Drawing with anti aliasing to create smoother appearance - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); Rectangle backRectI = rect; backRectI.Inflate(1, 1); // Finally draw the border around the menu item - using LinearGradientBrush borderBrush = new LinearGradientBrush(backRectI, Border1, Border2, 90f); + using var borderBrush = new LinearGradientBrush(backRectI, Border1, Border2, 90f); // Convert the brush to a pen for DrawPath call - using Pen borderPen = new Pen(borderBrush); + using var borderPen = new Pen(borderBrush); // Create border path around the entire item using GraphicsPath borderPath = CreateBorderPath(rect, _cutItemMenu); g.DrawPath(borderPen, borderPath); @@ -124,9 +124,9 @@ public GradientItemColorsTracking(Color border, public override void DrawBack(Graphics? g, Rectangle rect) { - Rectangle inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); - Rectangle insetB = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3); - Rectangle insetC = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4); + var inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); + var insetB = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3); + var insetC = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4); using LinearGradientBrush insideBrush1 = new LinearGradientBrush(rect, Back1B, Back1, 90f), insideBrush2 = new LinearGradientBrush(insetB, Back2B, Back2, 90f); @@ -136,23 +136,23 @@ public override void DrawBack(Graphics? g, Rectangle rect) g.FillRectangle(insideBrush1, inset); using GraphicsPath borderPath = CreateBorderPath(insetC, _cutInnerItemMenu), clipPath = CreateBorderPath(insetB, _cutInnerItemMenu); - using (Pen insidePen = new Pen(insideBrush2)) + using (var insidePen = new Pen(insideBrush2)) { g.DrawPath(insidePen, borderPath); } g.FillPath(insideBrush2, borderPath); - using (Clipping clipping = new Clipping(g, clipPath)) + using (var clipping = new Clipping(g, clipPath)) { - using (GraphicsPath ellipsePath = new GraphicsPath()) + using (var ellipsePath = new GraphicsPath()) { - RectangleF ellipseRect = new RectangleF(-(rect.Width / 2), rect.Bottom - 9, rect.Width * 2, 18); - PointF ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), + var ellipseRect = new RectangleF(-(rect.Width / 2), rect.Bottom - 9, rect.Width * 2, 18); + var ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), ellipseRect.Top + (ellipseRect.Height / 2)); ellipsePath.AddEllipse(ellipseRect); - using (PathGradientBrush insideLighten = new PathGradientBrush(ellipsePath)) + using (var insideLighten = new PathGradientBrush(ellipsePath)) { insideLighten.CenterPoint = ellipseCenter; insideLighten.CenterColor = Color.White; @@ -207,10 +207,10 @@ public GradientItemColorsPressed(Color border, public override void DrawBack(Graphics? g, Rectangle rect) { - Rectangle rect2 = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 1); - Rectangle rect3 = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 3); + var rect2 = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 1); + var rect3 = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 3); - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); using GraphicsPath path1 = CreateBorderPath(rect, _cutItemMenu), path2 = CreateBorderPath(rect2, _cutItemMenu), path3 = CreateBorderPath(rect3, _cutItemMenu); @@ -244,20 +244,20 @@ public GradientItemColorsChecked(Color border, public override void DrawBack(Graphics? g, Rectangle rect) { - Rectangle inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); + var inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); - using LinearGradientBrush insideBrush = new LinearGradientBrush(rect, Back2, Back1, 90f); + using var insideBrush = new LinearGradientBrush(rect, Back2, Back1, 90f); insideBrush.SetSigmaBellShape(0.5f); g.FillRectangle(insideBrush, inset); using GraphicsPath borderPath = CreateBorderPath(inset, _cutInnerItemMenu); - using GraphicsPath ellipsePath = new GraphicsPath(); - RectangleF ellipseRect = new RectangleF(rect.Left, rect.Bottom - 8, rect.Width, 8); - PointF ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), + using var ellipsePath = new GraphicsPath(); + var ellipseRect = new RectangleF(rect.Left, rect.Bottom - 8, rect.Width, 8); + var ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), ellipseRect.Top + (ellipseRect.Height / 2)); ellipsePath.AddEllipse(ellipseRect); - using PathGradientBrush insideLighten = new PathGradientBrush(ellipsePath); + using var insideLighten = new PathGradientBrush(ellipsePath); insideLighten.CenterPoint = ellipseCenter; insideLighten.CenterColor = Color.FromArgb(96, Color.White); insideLighten.SurroundColors = new[] { Color.Transparent }; @@ -402,7 +402,7 @@ protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) }; // Draw the actual arrow using a gradient - using LinearGradientBrush arrowBrush = new LinearGradientBrush(boundsF, color1, color2, angle); + using var arrowBrush = new LinearGradientBrush(boundsF, color1, color2, angle); e.Graphics.FillPath(arrowBrush, arrowPath); } } @@ -416,7 +416,7 @@ protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e) { // Cast to correct type - ToolStripButton button = (ToolStripButton)e.Item; + var button = (ToolStripButton)e.Item; if (button.Selected || button.Pressed || button.Checked) { @@ -468,17 +468,17 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) } // Drawing with anti aliasing to create smoother appearance - using AntiAlias aa = new AntiAlias(e.Graphics); + using var aa = new AntiAlias(e.Graphics); // Create border path for the check box using GraphicsPath borderPath = CreateBorderPath(checkBox, _cutItemMenu); // Fill the background in a solid color - using (SolidBrush fillBrush = new SolidBrush(KCT.CheckBackground)) + using (var fillBrush = new SolidBrush(KCT.CheckBackground)) { e.Graphics.FillPath(fillBrush, borderPath); } // Draw the border around the check box - using (Pen borderPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 1.05f, 1.52f, 2.75f))) + using (var borderPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 1.05f, 1.52f, 2.75f))) { e.Graphics.DrawPath(borderPen, borderPath); } @@ -486,7 +486,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) // If there is not an image, then we can draw the tick, square etc... if (e.Item.Image == null) { - CheckState checkState = CheckState.Unchecked; + var checkState = CheckState.Unchecked; // Extract the check state from the item if (e.Item is ToolStripMenuItem item) @@ -502,7 +502,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) using (GraphicsPath tickPath = CreateTickPath(checkBox)) { // Draw the tick with a thickish brush - using (Pen tickPen = + using (var tickPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 3.86f, 3.02f, 1.07f), _contextCheckTickThickness)) { @@ -515,7 +515,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) using (GraphicsPath tickPath = CreateIndeterminatePath(checkBox)) { // Draw the tick with a thickish brush - using (SolidBrush tickBrush = + using (var tickBrush = new SolidBrush(CommonHelper.WhitenColor(KCT.CheckBackground, 3.86f, 3.02f, 1.07f))) { e.Graphics.FillPath(tickBrush, tickPath); @@ -590,7 +590,7 @@ protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) } else { - using GraphicsTextHint clearTypeGridFit = + using var clearTypeGridFit = new GraphicsTextHint(e.Graphics, TextRenderingHint.ClearTypeGridFit); base.OnRenderItemText(e); } @@ -620,7 +620,7 @@ protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e) } else { - using ImageAttributes attribs = new ImageAttributes(); + using var attribs = new ImageAttributes(); attribs.SetColorMatrix(CommonHelper.MatrixDisabled); // Draw using the disabled matrix to make it look disabled @@ -730,7 +730,7 @@ protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventAr if (e.Item.Selected || e.Item.Pressed) { // Cast to correct type - ToolStripSplitButton splitButton = (ToolStripSplitButton)e.Item; + var splitButton = (ToolStripSplitButton)e.Item; // Draw the border and background RenderToolSplitButtonBackground(e.Graphics, splitButton, e.ToolStrip); @@ -803,7 +803,7 @@ protected override void OnRenderToolStripContentPanelBackground(ToolStripContent // Cannot paint a zero sized area if (e.ToolStripContentPanel is { Width: > 0, Height: > 0 }) { - using LinearGradientBrush backBrush = new LinearGradientBrush(e.ToolStripContentPanel.ClientRectangle, + using var backBrush = new LinearGradientBrush(e.ToolStripContentPanel.ClientRectangle, KCT.ToolStripContentPanelGradientEnd, KCT.ToolStripContentPanelGradientBegin, 90f); e.Graphics.FillRectangle(backBrush, e.ToolStripContentPanel.ClientRectangle); } @@ -831,9 +831,9 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) using GraphicsPath borderPath = CreateBorderPath(e.AffectedBounds, _cutContextMenu), clipPath = CreateClipBorderPath(e.AffectedBounds, _cutContextMenu); // Clip all drawing to within the border path - using Clipping clipping = new Clipping(e.Graphics, clipPath); + using var clipping = new Clipping(e.Graphics, clipPath); // Create the background brush - using SolidBrush backBrush = new SolidBrush(KCT.ToolStripDropDownBackground); + using var backBrush = new SolidBrush(KCT.ToolStripDropDownBackground); e.Graphics.FillPath(backBrush, borderPath); break; } @@ -846,7 +846,7 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) } // We do not paint the top two pixel lines, as they are drawn by the status strip border render method - RectangleF backRect = new RectangleF(0, 1.5f, e.ToolStrip.Width, e.ToolStrip.Height - 2); + var backRect = new RectangleF(0, 1.5f, e.ToolStrip.Width, e.ToolStrip.Height - 2); // Cannot paint a zero sized area if (backRect is { Width: > 0, Height: > 0 }) @@ -859,7 +859,7 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) // backBrush.Blend = _stripBlend; // e.Graphics.FillRectangle(backBrush, backRect); //} - using SolidBrush backBrush = new SolidBrush(KCT.StatusStripGradientEnd); + using var backBrush = new SolidBrush(KCT.StatusStripGradientEnd); e.Graphics.FillRectangle(backBrush, backRect); } @@ -884,12 +884,12 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) } // Cannot paint a zero sized area - RectangleF backRect = new RectangleF(0, 0, e.ToolStrip.Width, e.ToolStrip.Height); + var backRect = new RectangleF(0, 0, e.ToolStrip.Width, e.ToolStrip.Height); if (backRect is { Width: > 0, Height: > 0 }) { if (e.ToolStrip.Orientation == Orientation.Horizontal) { - using (LinearGradientBrush backBrush = new LinearGradientBrush(backRect, + using (var backBrush = new LinearGradientBrush(backRect, KCT.ToolStripGradientBegin, KCT.ToolStripGradientEnd, 90f)) { backBrush.Blend = _stripBlend; @@ -906,7 +906,7 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) } else { - using (LinearGradientBrush backBrush = new LinearGradientBrush(backRect, + using (var backBrush = new LinearGradientBrush(backRect, KCT.ToolStripGradientBegin, KCT.ToolStripGradientEnd, 0f)) { backBrush.Blend = _stripBlend; @@ -943,7 +943,7 @@ protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) // If there is a connected area to be drawn if (!e.ConnectedArea.IsEmpty) { - using SolidBrush excludeBrush = new SolidBrush(KCT.ToolStripDropDownBackground); + using var excludeBrush = new SolidBrush(KCT.ToolStripDropDownBackground); e.Graphics.FillRectangle(excludeBrush, e.ConnectedArea); } @@ -955,9 +955,9 @@ protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) using Pen borderPen = new Pen(KCT.MenuBorder), insidePen = new Pen(KCT.ToolStripDropDownBackground); // Clip all drawing to within the border path - using Clipping clipping = new Clipping(e.Graphics, clipPath); + using var clipping = new Clipping(e.Graphics, clipPath); // Drawing with anti aliasing to create smoother appearance - using (AntiAlias aa = new AntiAlias(e.Graphics)) + using (var aa = new AntiAlias(e.Graphics)) { // Draw the inside area first e.Graphics.DrawPath(insidePen, insidePath); @@ -1015,7 +1015,7 @@ protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) marginRect.X += _marginInset / 2; } - using Pen marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); + using var marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); if (!rtl) { e.Graphics.DrawLine(marginPen, marginRect.Right, marginRect.Top, marginRect.Right, marginRect.Bottom); @@ -1155,7 +1155,7 @@ private void DrawGradientToolSplitItem(Graphics? g, GradientItemColors colorsSplit) { // Create entire area and just the drop button area rectangles - Rectangle backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); + var backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); Rectangle backRectDrop = splitButton.DropDownButtonBounds; // Cannot paint zero sized areas @@ -1193,12 +1193,12 @@ private void DrawGradientToolSplitItem(Graphics? g, colorsDrop.DrawBack(g, backRectDrop); // Draw the split line between the areas - using (LinearGradientBrush splitBrush = new LinearGradientBrush( + using (var splitBrush = new LinearGradientBrush( new Rectangle(backRect.X + splitOffset, backRect.Top, 1, backRect.Height + 1), colorsSplit.Border1, colorsSplit.Border2, 90f)) { // Convert the brush to a pen for DrawPath call - using (Pen splitPen = new Pen(splitBrush)) + using (var splitPen = new Pen(splitBrush)) { g.DrawLine(splitPen, backRect.X + splitOffset, backRect.Top + 1, backRect.X + splitOffset, backRect.Bottom - 1); } @@ -1212,22 +1212,22 @@ private void DrawGradientToolSplitItem(Graphics? g, private void DrawContextMenuHeader(Graphics? g, ToolStripItem item) { // Get the rectangle that is the items area - Rectangle itemRect = new Rectangle(Point.Empty, item.Bounds.Size); + var itemRect = new Rectangle(Point.Empty, item.Bounds.Size); // Create border and clipping paths using GraphicsPath borderPath = CreateBorderPath(itemRect, _cutHeaderMenu), insidePath = CreateInsideBorderPath(itemRect, _cutHeaderMenu), clipPath = CreateClipBorderPath(itemRect, _cutHeaderMenu); // Clip all drawing to within the border path - using Clipping clipping = new Clipping(g, clipPath); + using var clipping = new Clipping(g, clipPath); // Draw the entire background area first - using (SolidBrush backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) + using (var backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) { g.FillPath(backBrush, borderPath); } // Draw the border - using (Pen borderPen = new Pen(KCT.MenuBorder)) + using (var borderPen = new Pen(KCT.MenuBorder)) { g.DrawPath(borderPen, borderPath); } @@ -1284,7 +1284,7 @@ private void DrawGradientContextMenuItem(Graphics? g, GradientItemColors colors) { // Do we need to draw with separator on the opposite edge? - Rectangle backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); + var backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); // Perform actual drawing into the background colors.DrawItem(g, backRect); @@ -1310,7 +1310,7 @@ private void DrawContextMenuSeparator(Graphics g, var t = rect.Y; var b = rect.Bottom; - using Pen marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); + using var marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); marginPen.DashPattern = new float[] { 2, 2 }; g.DrawLine(marginPen, l, t, l, b); } @@ -1320,7 +1320,7 @@ private void DrawContextMenuSeparator(Graphics g, var l = rect.X + (rtl ? 0 : horizontalInset); var r = rect.Right - (rtl ? horizontalInset : 0); - using Pen marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); + using var marginPen = new Pen(Color.FromArgb(80, KCT.MenuBorder)); marginPen.DashPattern = new float[] { 2, 2 }; g.DrawLine(marginPen, l, y, r, y); } @@ -1334,7 +1334,7 @@ private void DrawToolStripSeparator(Graphics g, int horizontalInset, bool rtl) { - RectangleF boundsF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); + var boundsF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); if (vertical) { @@ -1439,7 +1439,7 @@ private static GraphicsPath CreateBorderPath(Rectangle rect, pts.Add(new PointF(l, y0)); // Create path using a simple set of lines that cut the corner - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); // Add a line between each set of points for (var i = 1; i < pts.Count; i++) @@ -1460,7 +1460,7 @@ private static GraphicsPath CreateBorderPath(Rectangle rect, float cut) rect.Height--; // Create path using a simple set of lines that cut the corner - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(rect.Left + cut, rect.Top, rect.Right - cut, rect.Top); path.AddLine(rect.Right - cut, rect.Top, rect.Right, rect.Top + cut); path.AddLine(rect.Right, rect.Top + cut, rect.Right, rect.Bottom - cut); @@ -1540,7 +1540,7 @@ private GraphicsPath CreateArrowPath(ToolStripItem item, } // Create triangle using a series of lines - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); switch (direction) { @@ -1575,7 +1575,7 @@ private GraphicsPath CreateTickPath(Rectangle rect) var x = rect.X + rect.Width / 2; var y = rect.Y + rect.Height / 2; - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(x - 4, y, x - 2, y + 4); path.AddLine(x - 2, y + 4, x + 3, y - 5); return path; @@ -1587,7 +1587,7 @@ private GraphicsPath CreateIndeterminatePath(Rectangle rect) var x = rect.X + rect.Width / 2; var y = rect.Y + rect.Height / 2; - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(x - 3, y, x, y - 3); path.AddLine(x, y - 3, x + 3, y); path.AddLine(x + 3, y, x, y + 3); diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonProfessionalRenderer.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonProfessionalRenderer.cs index c9bcd7fdf..e7d7ed4fd 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonProfessionalRenderer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonProfessionalRenderer.cs @@ -66,14 +66,14 @@ protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e) if ((fiM != null) && (fiR != null) && (fiC != null)) { #pragma warning disable IDE0019 // Use pattern matching - ToolStripMenuItem? m = fiM.GetValue(mcs) as ToolStripMenuItem; - ToolStripMenuItem? r = fiR.GetValue(mcs) as ToolStripMenuItem; - ToolStripMenuItem? c = fiC.GetValue(mcs) as ToolStripMenuItem; + var m = fiM.GetValue(mcs) as ToolStripMenuItem; + var r = fiR.GetValue(mcs) as ToolStripMenuItem; + var c = fiC.GetValue(mcs) as ToolStripMenuItem; #pragma warning restore IDE0019 // Use pattern matching if ((m != null) && (r != null) && (c != null)) { // Compare the event provided image with the internal cached ones to discover the type of pendant button we are drawing - PaletteButtonSpecStyle specStyle = PaletteButtonSpecStyle.Generic; + var specStyle = PaletteButtonSpecStyle.Generic; if (m.Image == e.Image) { specStyle = PaletteButtonSpecStyle.PendantMin; @@ -97,9 +97,9 @@ protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e) // Finally we actually have an image to draw! if (paletteImage != null) { - using ImageAttributes attribs = new ImageAttributes(); + using var attribs = new ImageAttributes(); // Setup mapping to make required color transparent - ColorMap remap = new ColorMap + var remap = new ColorMap { OldColor = transparentColor, NewColor = Color.Transparent diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonSparkleRenderer.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonSparkleRenderer.cs index 975a7be6d..64e9500a0 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonSparkleRenderer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/KryptonSparkleRenderer.cs @@ -194,7 +194,7 @@ protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) }; // Draw the actual arrow using a gradient - using LinearGradientBrush arrowBrush = new LinearGradientBrush(boundsF, color1, color2, angle); + using var arrowBrush = new LinearGradientBrush(boundsF, color1, color2, angle); e.Graphics.FillPath(arrowBrush, arrowPath); } } @@ -209,7 +209,7 @@ protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e) { // Cast to correct type - ToolStripButton button = (ToolStripButton)e.Item; + var button = (ToolStripButton)e.Item; if (button.Selected || button.Pressed || button.Checked) { @@ -261,7 +261,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) } // Drawing with anti aliasing to create smoother appearance - using AntiAlias aa = new AntiAlias(e.Graphics); + using var aa = new AntiAlias(e.Graphics); // Create border path for the check box using GraphicsPath borderPath = CreateBorderPath(checkBox, CUT_MENU_ITEM_BACK); Color colorFill = KCT.CheckBackground; @@ -273,13 +273,13 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) } // Fill the background in a solid color - using (SolidBrush fillBrush = new SolidBrush(colorFill)) + using (var fillBrush = new SolidBrush(colorFill)) { e.Graphics.FillPath(fillBrush, borderPath); } // Draw the border around the check box - using (Pen borderPen = new Pen(colorBorder)) + using (var borderPen = new Pen(colorBorder)) { e.Graphics.DrawPath(borderPen, borderPath); } @@ -287,7 +287,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) // If there is not an image, then we can draw the tick, square etc... if (e.Item.Image == null) { - CheckState checkState = CheckState.Unchecked; + var checkState = CheckState.Unchecked; // Extract the check state from the item if (e.Item is ToolStripMenuItem item) @@ -308,7 +308,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) // Draw the image centered in the available space var xOffset = e.ImageRectangle.Width - drawImage.Width; var yOffset = e.ImageRectangle.Height - drawImage.Height; - Rectangle drawRect = new Rectangle(e.ImageRectangle.X + xOffset, e.ImageRectangle.Y + yOffset, + var drawRect = new Rectangle(e.ImageRectangle.X + xOffset, e.ImageRectangle.Y + yOffset, drawImage.Width, drawImage.Height); // Do we need to draw disabled? @@ -318,7 +318,7 @@ protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) } else { - using ImageAttributes attribs = new ImageAttributes(); + using var attribs = new ImageAttributes(); attribs.SetColorMatrix(CommonHelper.MatrixDisabled); // Draw using the disabled matrix to make it look disabled @@ -388,7 +388,7 @@ protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) } else { - using GraphicsTextHint clearTypeGridFit = + using var clearTypeGridFit = new GraphicsTextHint(e.Graphics, TextRenderingHint.ClearTypeGridFit); base.OnRenderItemText(e); } @@ -418,7 +418,7 @@ protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e) } else { - using ImageAttributes attribs = new ImageAttributes(); + using var attribs = new ImageAttributes(); attribs.SetColorMatrix(CommonHelper.MatrixDisabled); // Draw using the disabled matrix to make it look disabled @@ -498,7 +498,7 @@ protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventAr if (e.Item.Selected || e.Item.Pressed) { // Cast to correct type - ToolStripSplitButton splitButton = (ToolStripSplitButton)e.Item; + var splitButton = (ToolStripSplitButton)e.Item; // Draw the border and background RenderToolSplitButtonBackground(e.Graphics, splitButton, e.ToolStrip); @@ -571,7 +571,7 @@ protected override void OnRenderToolStripContentPanelBackground(ToolStripContent // Cannot paint a zero sized area if (e.ToolStripContentPanel is { Width: > 0, Height: > 0 }) { - using LinearGradientBrush backBrush = new LinearGradientBrush(e.ToolStripContentPanel.ClientRectangle, + using var backBrush = new LinearGradientBrush(e.ToolStripContentPanel.ClientRectangle, KCT.ToolStripContentPanelGradientEnd, KCT.ToolStripContentPanelGradientBegin, 90f); e.Graphics.FillRectangle(backBrush, e.ToolStripContentPanel.ClientRectangle); } @@ -636,10 +636,10 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) clipPath = CreateClipBorderPath(e.AffectedBounds, CUT_CONTEXT_MENU)) { // Clip all drawing to within the border path - using (Clipping clipping = new Clipping(e.Graphics, clipPath)) + using (var clipping = new Clipping(e.Graphics, clipPath)) { // Create the background brush - using (SolidBrush backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) + using (var backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) { e.Graphics.FillPath(backBrush, borderPath); } @@ -648,7 +648,7 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) break; case StatusStrip _: // Create rectangle that covers the status strip area - RectangleF backRect = new RectangleF(0, 0, e.ToolStrip.Width, e.ToolStrip.Height); + var backRect = new RectangleF(0, 0, e.ToolStrip.Width, e.ToolStrip.Height); Form? owner = e.ToolStrip.FindForm(); @@ -678,15 +678,15 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) if (backRect is { Width: > 0, Height: > 0 }) { // Draw entire background - using (SolidBrush backBrush = new SolidBrush(KCT.MenuStripGradientBegin)) + using (var backBrush = new SolidBrush(KCT.MenuStripGradientBegin)) { e.Graphics.FillRectangle(backBrush, backRect); } // Create path for the rounded bottom edges - using (GraphicsPath innerPath = new GraphicsPath()) + using (var innerPath = new GraphicsPath()) { - RectangleF innerRectF = new RectangleF(backRect.X + 2, backRect.Y, backRect.Width - 4, + var innerRectF = new RectangleF(backRect.X + 2, backRect.Y, backRect.Width - 4, backRect.Height - 2); innerPath.AddLine(innerRectF.Right - 1, innerRectF.Top, innerRectF.Right - 1, innerRectF.Bottom - 7); @@ -698,14 +698,14 @@ protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) innerPath.CloseFigure(); // Fill with a gradient brush - using (LinearGradientBrush innerBrush = new LinearGradientBrush( + using (var innerBrush = new LinearGradientBrush( new Rectangle((int)backRect.X - 1, (int)backRect.Y - 1, (int)backRect.Width + 2, (int)backRect.Height + 1), KCT.StatusStripGradientBegin, KCT.StatusStripGradientEnd, 90f)) { innerBrush.Blend = _statusStripBlend; - using (AntiAlias aa = new AntiAlias(e.Graphics)) + using (var aa = new AntiAlias(e.Graphics)) { e.Graphics.FillPath(innerBrush, innerPath); } @@ -749,7 +749,7 @@ protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) } // Draw the entire margine area in a solid color - using (SolidBrush backBrush = new SolidBrush(KCT.ImageMarginGradientBegin)) + using (var backBrush = new SolidBrush(KCT.ImageMarginGradientBegin)) { e.Graphics.FillRectangle(backBrush, marginRect); } @@ -791,7 +791,7 @@ protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) // If there is a connected area to be drawn if (!e.ConnectedArea.IsEmpty) { - using SolidBrush excludeBrush = new SolidBrush(KCT.ToolStripDropDownBackground); + using var excludeBrush = new SolidBrush(KCT.ToolStripDropDownBackground); e.Graphics.FillRectangle(excludeBrush, e.ConnectedArea); } @@ -803,9 +803,9 @@ protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) using Pen borderPen = new Pen(KCT.MenuBorder), insidePen = new Pen(KCT.ToolStripDropDownBackground); // Clip all drawing to within the border path - using Clipping clipping = new Clipping(e.Graphics, clipPath); + using var clipping = new Clipping(e.Graphics, clipPath); // Drawing with anti aliasing to create smoother appearance - using (AntiAlias aa = new AntiAlias(e.Graphics)) + using (var aa = new AntiAlias(e.Graphics)) { // Draw the inside area first e.Graphics.DrawPath(insidePen, insidePath); @@ -952,7 +952,7 @@ private void DrawGradientToolSplitItem(Graphics? g, GradientItemColors? colorsSplit) { // Create entire area and just the drop button area rectangles - Rectangle backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); + var backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); Rectangle backRectDrop = splitButton.DropDownButtonBounds; // Cannot paint zero sized areas @@ -982,7 +982,7 @@ private void DrawGradientToolSplitItem(Graphics? g, // Draw the split line between the areas if (colorsSplit != null) { - using (Pen splitPen = new Pen(colorsSplit.Border)) + using (var splitPen = new Pen(colorsSplit.Border)) { g?.DrawLine(splitPen, backRect.X + splitOffset, backRect.Top + 1, backRect.X + splitOffset, backRect.Bottom - 1); @@ -997,22 +997,22 @@ private void DrawGradientToolSplitItem(Graphics? g, private void DrawContextMenuHeader(Graphics? g, ToolStripItem item) { // Get the rectangle that is the items area - Rectangle itemRect = new Rectangle(Point.Empty, item.Bounds.Size); + var itemRect = new Rectangle(Point.Empty, item.Bounds.Size); // Create border and clipping paths using GraphicsPath borderPath = CreateBorderPath(itemRect, CUT_TOOL_ITEM_MENU), insidePath = CreateInsideBorderPath(itemRect, CUT_TOOL_ITEM_MENU), clipPath = CreateClipBorderPath(itemRect, CUT_TOOL_ITEM_MENU); // Clip all drawing to within the border path - using Clipping clipping = new Clipping(g, clipPath); + using var clipping = new Clipping(g, clipPath); // Draw the entire background area first - using (SolidBrush backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) + using (var backBrush = new SolidBrush(KCT.ToolStripDropDownBackground)) { g?.FillPath(backBrush, borderPath); } // Draw the border - using (Pen borderPen = new Pen(KCT.MenuBorder)) + using (var borderPen = new Pen(KCT.MenuBorder)) { g?.DrawPath(borderPen, borderPath); } @@ -1069,7 +1069,7 @@ private void DrawLinearContextMenuItem(Graphics? g, LinearItemColors colors) { // Do we need to draw with separator on the opposite edge? - Rectangle backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); + var backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); // Perform actual drawing into the background DrawLinearGradientItem(g, backRect, colors); @@ -1097,7 +1097,7 @@ private static void DrawLinearGradientBack(Graphics? g, // Reduce rect draw drawing inside the border backRect.Inflate(-1, -1); - using LinearGradientBrush backBrush = new LinearGradientBrush(backRect, colors.Fill1, colors.Fill2, 90f); + using var backBrush = new LinearGradientBrush(backRect, colors.Fill1, colors.Fill2, 90f); g?.FillRectangle(backBrush, backRect); } @@ -1106,8 +1106,8 @@ private static void DrawLinearGradientBorder(Graphics? g, LinearItemColors colors) { // Drawing with anti aliasing to create smoother appearance - using AntiAlias aa = new AntiAlias(g); - using Pen borderPen = new Pen(colors.Border); + using var aa = new AntiAlias(g); + using var borderPen = new Pen(colors.Border); using GraphicsPath borderPath = CreateBorderPath(backRect, CUT_MENU_ITEM_BACK); g?.DrawPath(borderPen, borderPath); } @@ -1117,7 +1117,7 @@ private void DrawGradientContextMenuItem(Graphics? g, GradientItemColors? colors) { // Do we need to draw with separator on the opposite edge? - Rectangle backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); + var backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); // Perform actual drawing into the background DrawGradientItem(g, backRect, colors); @@ -1145,7 +1145,7 @@ private static void DrawGradientBack(Graphics? g, backRect.X++; backRect.Width -= 1; - using RenderContext context = new RenderContext(null, g, backRect, null); + using var context = new RenderContext(null, g, backRect, null); using GraphicsPath backPath = CreateBorderPath(backRect, CUT_MENU_ITEM_BACK); backRect.Width -= 1; backRect.Height -= 1; @@ -1163,14 +1163,14 @@ private static void DrawSolidBorder(Graphics? g, GradientItemColors? colors) { // Drawing with anti aliasing to create smoother appearance - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); Rectangle backRectI = backRect; backRectI.Inflate(1, 1); // Use solid color for the border if (colors != null && g != null) { - using Pen borderPen = new Pen(colors.Border); + using var borderPen = new Pen(colors.Border); using GraphicsPath borderPath = CreateBorderPath(backRect, CUT_MENU_ITEM_BACK); g.DrawPath(borderPen, borderPath); } @@ -1289,7 +1289,7 @@ private static GraphicsPath CreateBorderPath(Rectangle rect, pts.Add(new PointF(l, y0)); // Create path using a simple set of lines that cut the corner - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); // Add a line between each set of points for (var i = 1; i < pts.Count; i++) @@ -1310,7 +1310,7 @@ private static GraphicsPath CreateBorderPath(Rectangle rect, float cut) rect.Height--; // Create path using a simple set of lines that cut the corner - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(rect.Left + cut, rect.Top, rect.Right - cut, rect.Top); path.AddLine(rect.Right - cut, rect.Top, rect.Right, rect.Top + cut); path.AddLine(rect.Right, rect.Top + cut, rect.Right, rect.Bottom - cut); @@ -1390,7 +1390,7 @@ private static GraphicsPath CreateArrowPath(ToolStripItem item, } // Create triangle using a series of lines - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); switch (direction) { @@ -1425,7 +1425,7 @@ private static GraphicsPath CreateTickPath(Rectangle rect) var x = rect.X + (rect.Width / 2); var y = rect.Y + (rect.Height / 2); - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(x - 5, y - 1, x - 2, y + 4); path.AddLine(x - 2, y + 4, x + 3, y - 5); return path; @@ -1437,7 +1437,7 @@ private static GraphicsPath CreateIndeterminatePath(Rectangle rect) var x = rect.X + (((float)rect.Width - 6) / 2); var y = rect.Y + (((float)rect.Height - 6) / 2); - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddEllipse(x, y, 6f, 6f); return path; } diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderBase.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderBase.cs index 1d23aa39c..ff0cf6813 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderBase.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderBase.cs @@ -956,7 +956,7 @@ protected static void DrawImageHelper([DisallowNull] ViewContext context, } // Use image attributes class to modify image drawing for effects - ImageAttributes attribs = new ImageAttributes(); + var attribs = new ImageAttributes(); switch (effect) { @@ -1002,7 +1002,7 @@ protected static void DrawImageHelper([DisallowNull] ViewContext context, // Create remapping for the transparent color if (remapTransparent != Color.Empty) { - ColorMap remap = new ColorMap + var remap = new ColorMap { OldColor = remapTransparent, NewColor = Color.Transparent @@ -1013,7 +1013,7 @@ protected static void DrawImageHelper([DisallowNull] ViewContext context, // Create remapping from source to target colors if ((remapColor != Color.Empty) && (remapNew != Color.Empty)) { - ColorMap remap = new ColorMap + var remap = new ColorMap { OldColor = remapColor, NewColor = remapNew diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderExpertHelpers.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderExpertHelpers.cs index cb2e6779b..d1648e9da 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderExpertHelpers.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderExpertHelpers.cs @@ -60,7 +60,7 @@ static RenderExpertHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); MementoDouble? cache; if (memento is MementoDouble mementoDouble) @@ -103,7 +103,7 @@ static RenderExpertHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Cannot draw a zero length rectangle if (rect is { Width: > 0, Height: > 0 }) { @@ -142,7 +142,7 @@ static RenderExpertHelpers() cache.Brush3 = new SolidBrush(backColor1); } - using AntiAlias aa = new AntiAlias(context.Graphics); + using var aa = new AntiAlias(context.Graphics); context.Graphics.FillRectangle(cache.Brush3, rect); context.Graphics.FillPath(cache.Brush1, cache.Path1); context.Graphics.FillPath(cache.Brush2, cache.Path2); @@ -170,7 +170,7 @@ static RenderExpertHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Draw the expert background which is gradient with highlight at bottom return DrawBackExpert(rect, backColor1, backColor2, orientation, context.Graphics, memento, true, false); } @@ -193,7 +193,7 @@ static RenderExpertHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); MementoDouble? cache; if (memento is MementoDouble mementoDouble) @@ -238,7 +238,7 @@ static RenderExpertHelpers() IDisposable? memento, bool light) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Cannot draw a zero length rectangle if (rect is { Width: > 0, Height: > 0 }) { @@ -421,7 +421,7 @@ private static IDisposable DrawBackSolid(RectangleF drawRect, } // Create rectangle that covers the enter area - RectangleF gradientRect = new RectangleF(drawRect.X - 1, drawRect.Y - 1, drawRect.Width + 2, + var gradientRect = new RectangleF(drawRect.X - 1, drawRect.Y - 1, drawRect.Width + 2, drawRect.Height + 2); // Cannot draw a zero length rectangle @@ -474,7 +474,7 @@ private static IDisposable DrawBackSolid(RectangleF drawRect, if (cache.EntireBrush != null) { - using Clipping clip = new Clipping(g, cache.ClipPath); + using var clip = new Clipping(g, cache.ClipPath); g.FillRectangle(cache.EntireBrush, cache.DrawRect); g.FillPath(cache.InsideLighten, cache.EllipsePath); } @@ -490,7 +490,7 @@ private static GraphicsPath CreateBorderPath(Rectangle rect, float cut) rect.Height--; // Create path using a simple set of lines that cut the corner - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLine(rect.Left + cut, rect.Top, rect.Right - cut, rect.Top); path.AddLine(rect.Right - cut, rect.Top, rect.Right, rect.Top + cut); path.AddLine(rect.Right, rect.Top + cut, rect.Right, rect.Bottom - cut); diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderGlassHelpers.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderGlassHelpers.cs index 5691b831d..1a9328f64 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderGlassHelpers.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderGlassHelpers.cs @@ -61,7 +61,7 @@ static RenderGlassHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); MementoDouble? cache; if (memento is MementoDouble mementoDouble) @@ -114,7 +114,7 @@ static RenderGlassHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); MementoDouble? cache; if (memento is MementoDouble mementoDouble) @@ -166,7 +166,7 @@ static RenderGlassHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); MementoDouble? cache; if (memento is MementoDouble mementoDouble) @@ -456,7 +456,7 @@ static RenderGlassHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); var generate = true; MementoBackGlassThreeEdge? cache; @@ -528,7 +528,7 @@ static RenderGlassHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Draw the inside area return DrawBackGlassLinear(rect, rect, backColor1, backColor2, @@ -558,7 +558,7 @@ static RenderGlassHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Draw the inside area as a glass effect return DrawBackGlassRadial(rect, backColor1, backColor2, _glassColorTopL, _glassColorBottomL, @@ -584,7 +584,7 @@ static RenderGlassHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Draw the inside areas as a glass effect return DrawBackGlassRadial(rect, backColor1, backColor2, _glassColorTopL, _glassColorBottomL, @@ -610,7 +610,7 @@ static RenderGlassHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Draw the inside areas as a glass effect return DrawBackGlassRadial(rect, backColor1, backColor2, _glassColorTopD, _glassColorBottomD, @@ -636,7 +636,7 @@ static RenderGlassHelpers() GraphicsPath path, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Draw the inside areas as a glass effect return DrawBackGlassRadial(rect, backColor1, backColor2, _glassColorTopD, _glassColorBottomD, @@ -656,7 +656,7 @@ static RenderGlassHelpers() float glassPercent, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); MementoDouble? cache; if (memento is MementoDouble mementoDouble) @@ -672,7 +672,7 @@ static RenderGlassHelpers() } // Get the drawing rectangle for the path - RectangleF drawRect = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); + var drawRect = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); // Draw the border as a lighter version of the inside cache.First = DrawBackGlassLinear(drawRect, drawRect, @@ -712,7 +712,7 @@ static RenderGlassHelpers() float glassPercent, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); MementoDouble? cache; if (memento is MementoDouble mementoDouble) @@ -728,7 +728,7 @@ static RenderGlassHelpers() } // Get the drawing rectangle for the path - RectangleF drawRect = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); + var drawRect = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); // Draw the border as a lighter version of the inside cache.First = DrawBackGlassLinear(drawRect, drawRect, @@ -767,7 +767,7 @@ static RenderGlassHelpers() float glassPercent, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); MementoDouble? cache; if (memento is MementoDouble mementoDouble) @@ -811,7 +811,7 @@ static RenderGlassHelpers() float glassPercent, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); MementoTriple? cache; if (memento is MementoTriple triple) @@ -861,7 +861,7 @@ static RenderGlassHelpers() float glassPercent, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); MementoTriple? cache; if (memento is MementoTriple triple) @@ -913,7 +913,7 @@ static RenderGlassHelpers() float glassPercent, IDisposable? memento) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); MementoTriple? cache; if (memento is MementoTriple triple) @@ -1321,7 +1321,7 @@ private static IDisposable DrawBackGlassFade(RectangleF drawRect, cache.Dispose(); // Create gradient rect from the drawing rect - RectangleF gradientRect = new RectangleF(drawRect.X - 1, drawRect.Y - 1, drawRect.Width + 2, + var gradientRect = new RectangleF(drawRect.X - 1, drawRect.Y - 1, drawRect.Width + 2, drawRect.Height + 2); // Cannot draw a zero sized rectangle @@ -1371,7 +1371,7 @@ private static IDisposable DrawBackGlassFade(RectangleF drawRect, } // Create gradient rectangles - RectangleF glassGradientRect = new RectangleF(glassRect.X - 1, glassRect.Y - 1, glassRect.Width + 2, + var glassGradientRect = new RectangleF(glassRect.X - 1, glassRect.Y - 1, glassRect.Width + 2, glassRect.Height + 2); // Cannot draw a zero sized rectangle @@ -1479,9 +1479,9 @@ private static IDisposable DrawBackGlassFade(RectangleF drawRect, cache.MainRect = mainRect; // Create gradient rectangles - RectangleF glassGradientRect = new RectangleF(cache.GlassRect.X - 1, cache.GlassRect.Y - 1, + var glassGradientRect = new RectangleF(cache.GlassRect.X - 1, cache.GlassRect.Y - 1, cache.GlassRect.Width + 2, cache.GlassRect.Height + 2); - RectangleF mainGradientRect = new RectangleF(cache.MainRect.X - 1, cache.MainRect.Y - 1, + var mainGradientRect = new RectangleF(cache.MainRect.X - 1, cache.MainRect.Y - 1, cache.MainRect.Width + 2, cache.MainRect.Height + 2); // Cannot draw a zero length rectangle @@ -1575,7 +1575,7 @@ private static RectangleF DrawBackGlassBasic(RectangleF drawRect, }; // Gradient rectangle is always a little bigger to prevent tiling at edges - RectangleF glassGradientRect = new RectangleF(glassRect.X - 1, glassRect.Y - 1, glassRect.Width + 2, + var glassGradientRect = new RectangleF(glassRect.X - 1, glassRect.Y - 1, glassRect.Width + 2, glassRect.Height + 2); // Cannot draw a zero length rectangle @@ -1633,7 +1633,7 @@ private static IDisposable DrawBackLinear(RectangleF drawRect, cache.Dispose(); // Create rectangle that covers the enter area - RectangleF gradientRect = new RectangleF(drawRect.X - 1, drawRect.Y - 1, drawRect.Width + 2, + var gradientRect = new RectangleF(drawRect.X - 1, drawRect.Y - 1, drawRect.Width + 2, drawRect.Height + 2); // Cannot draw a zero length rectangle @@ -1731,7 +1731,7 @@ private static IDisposable DrawBackDarkEdge(RectangleF drawRect, } // Create rectangle that covers the enter area - RectangleF gradientRect = new RectangleF(drawRect.X - 0.5f, drawRect.Y - 0.5f, + var gradientRect = new RectangleF(drawRect.X - 0.5f, drawRect.Y - 0.5f, drawRect.Width + 1, drawRect.Height + 1); // Cannot draw a zero length rectangle diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderMicrosoft365.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderMicrosoft365.cs index 94f8d7915..81f6958a6 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderMicrosoft365.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderMicrosoft365.cs @@ -53,7 +53,7 @@ public override void DrawRibbonClusterEdge(PaletteRibbonShape shape, Color borderColour = paletteBack.GetBackColor1(state), lightColour = CommonHelper.MergeColors(borderColour, BORDER_PERCENT, Color.White, WHITE_PERCENT); // Draw inside of the border edge in a lighter version of the border - using SolidBrush drawBrush = new SolidBrush(lightColour); + using var drawBrush = new SolidBrush(lightColour); context.Graphics.FillRectangle(drawBrush, displayRect); } #endregion @@ -74,7 +74,7 @@ public override ToolStripRenderer RenderToolStrip([DisallowNull] PaletteBase col throw new ArgumentNullException(nameof(colourPalette)); } - KryptoMicrosoft365Renderer renderer = new KryptoMicrosoft365Renderer(colourPalette.ColorTable) + var renderer = new KryptoMicrosoft365Renderer(colourPalette.ColorTable) { RoundedEdges = colourPalette.ColorTable.UseRoundedEdges != InheritBool.False }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderOffice2007.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderOffice2007.cs index f805ab156..4c6a40445 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderOffice2007.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderOffice2007.cs @@ -75,7 +75,7 @@ public override void DrawRibbonClusterEdge(PaletteRibbonShape shape, Color.White, WHITE_PERCENT); // Draw inside of the border edge in a lighter version of the border - using SolidBrush drawBrush = new SolidBrush(lightColor); + using var drawBrush = new SolidBrush(lightColor); context.Graphics.FillRectangle(drawBrush, displayRect); } @@ -99,7 +99,7 @@ public override ToolStripRenderer RenderToolStrip([DisallowNull] PaletteBase col } // Use the professional renderer but pull colors from the palette - KryptonOffice2007Renderer renderer = new KryptonOffice2007Renderer(colorPalette.ColorTable) + var renderer = new KryptonOffice2007Renderer(colorPalette.ColorTable) { // Setup the need to use rounded corners RoundedEdges = colorPalette.ColorTable.UseRoundedEdges != InheritBool.False @@ -147,16 +147,16 @@ protected override IDisposable DrawRibbonTabContext(RenderContext context, // Dispose of existing values cache.Dispose(); - Rectangle borderRect = new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); + var borderRect = new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); cache.FillRect = new Rectangle(rect.X + 1, rect.Y, rect.Width - 2, rect.Height - 1); - LinearGradientBrush borderBrush = new LinearGradientBrush(borderRect, c1, Color.Transparent, 270f) + var borderBrush = new LinearGradientBrush(borderRect, c1, Color.Transparent, 270f) { Blend = _ribbonGroup5Blend }; cache.BorderPen = new Pen(borderBrush); - LinearGradientBrush underlineBrush = + var underlineBrush = new LinearGradientBrush(borderRect, Color.Transparent, Color.FromArgb(200, c2), 0f) { Blend = _ribbonGroup7Blend diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderOffice2010.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderOffice2010.cs index 85cdc1794..9bc520efd 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderOffice2010.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderOffice2010.cs @@ -75,7 +75,7 @@ public override void DrawRibbonClusterEdge(PaletteRibbonShape shape, Color.White, WHITE_PERCENT); // Draw inside of the border edge in a lighter version of the border - using SolidBrush drawBrush = new SolidBrush(lightColor); + using var drawBrush = new SolidBrush(lightColor); context.Graphics.FillRectangle(drawBrush, displayRect); } @@ -99,7 +99,7 @@ public override ToolStripRenderer RenderToolStrip([DisallowNull] PaletteBase col } // Use the professional renderer but pull colors from the palette - KryptonOffice2010Renderer renderer = new KryptonOffice2010Renderer(colorPalette.ColorTable) + var renderer = new KryptonOffice2010Renderer(colorPalette.ColorTable) { // Setup the need to use rounded corners diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderOffice2013.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderOffice2013.cs index f702b3d37..2fd4a4573 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderOffice2013.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderOffice2013.cs @@ -68,7 +68,7 @@ public override void DrawRibbonClusterEdge(PaletteRibbonShape shape, Color.White, WHITE_PERCENT); // Draw inside of the border edge in a lighter version of the border - using SolidBrush drawBrush = new SolidBrush(lightColor); + using var drawBrush = new SolidBrush(lightColor); context.Graphics.FillRectangle(drawBrush, displayRect); } @@ -92,7 +92,7 @@ public override ToolStripRenderer RenderToolStrip([DisallowNull] PaletteBase col } // Use the professional renderer but pull colors from the palette - KryptonOffice2013Renderer renderer = new KryptonOffice2013Renderer(colorPalette.ColorTable) + var renderer = new KryptonOffice2013Renderer(colorPalette.ColorTable) { // Setup the need to use rounded corners diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderSparkle.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderSparkle.cs index a70180e91..aef7edc6a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderSparkle.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderSparkle.cs @@ -198,7 +198,7 @@ public override void DrawInputControlDropDownGlyph([DisallowNull] RenderContext var xStart = cellRect.Left + ((cellRect.Right - cellRect.Left - 4) / 2); var yStart = cellRect.Top + ((cellRect.Bottom - cellRect.Top - 3) / 2); - using Pen darkPen = new Pen(c1); + using var darkPen = new Pen(c1); context.Graphics.DrawLine(darkPen, xStart, yStart, xStart + 4, yStart); context.Graphics.DrawLine(darkPen, xStart + 1, yStart + 1, xStart + 3, yStart + 1); context.Graphics.DrawLine(darkPen, xStart + 2, yStart + 2, xStart + 2, yStart + 1); @@ -237,7 +237,7 @@ public override void DrawInputControlNumericUpGlyph([DisallowNull] RenderContext var xStart = cellRect.Left + ((cellRect.Right - cellRect.Left - 4) / 2); var yStart = cellRect.Top + ((cellRect.Bottom - cellRect.Top - 3) / 2); - using Pen darkPen = new Pen(c1); + using var darkPen = new Pen(c1); context.Graphics.DrawLine(darkPen, xStart, yStart + 3, xStart + 4, yStart + 3); context.Graphics.DrawLine(darkPen, xStart + 1, yStart + 2, xStart + 3, yStart + 2); context.Graphics.DrawLine(darkPen, xStart + 2, yStart + 2, xStart + 2, yStart + 1); @@ -276,7 +276,7 @@ public override void DrawInputControlNumericDownGlyph([DisallowNull] RenderConte var xStart = cellRect.Left + ((cellRect.Right - cellRect.Left - 4) / 2); var yStart = cellRect.Top + ((cellRect.Bottom - cellRect.Top - 3) / 2); - using Pen darkPen = new Pen(c1); + using var darkPen = new Pen(c1); context.Graphics.DrawLine(darkPen, xStart, yStart, xStart + 4, yStart); context.Graphics.DrawLine(darkPen, xStart + 1, yStart + 1, xStart + 3, yStart + 1); context.Graphics.DrawLine(darkPen, xStart + 2, yStart + 2, xStart + 2, yStart + 1); @@ -301,7 +301,7 @@ public override ToolStripRenderer RenderToolStrip([DisallowNull] PaletteBase col } // Use the professional renderer but pull colors from the palette - KryptonSparkleRenderer renderer = new KryptonSparkleRenderer(colorPalette.ColorTable) + var renderer = new KryptonSparkleRenderer(colorPalette.ColorTable) { // Setup the need to use rounded corners @@ -350,16 +350,16 @@ protected override IDisposable DrawRibbonTabContext(RenderContext context, // Dispose of existing values cache.Dispose(); - Rectangle borderRect = new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); + var borderRect = new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); cache.FillRect = new Rectangle(rect.X + 1, rect.Y, rect.Width - 2, rect.Height - 1); - LinearGradientBrush borderBrush = new LinearGradientBrush(borderRect, c1, Color.Transparent, 270f) + var borderBrush = new LinearGradientBrush(borderRect, c1, Color.Transparent, 270f) { Blend = _ribbonGroup5Blend }; cache.BorderPen = new Pen(borderBrush); - LinearGradientBrush underlineBrush = + var underlineBrush = new LinearGradientBrush(borderRect, Color.Transparent, Color.FromArgb(200, c2), 0f) { Blend = _ribbonGroup7Blend diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderStandard.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderStandard.cs index 457c4f51f..237102666 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderStandard.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/RenderStandard.cs @@ -386,7 +386,7 @@ public override ToolStripRenderer RenderToolStrip([DisallowNull] PaletteBase col } // Use the professional renderer but pull colors from the palette - KryptonStandardRenderer renderer = new KryptonStandardRenderer(colorPalette.ColorTable) + var renderer = new KryptonStandardRenderer(colorPalette.ColorTable) { // Setup the need to use rounded corners @@ -733,7 +733,7 @@ public override void DrawBorder([DisallowNull] RenderContext context, SmoothingMode smoothMode = palette.GetBorderRounding(state) > 0 ? SmoothingMode.AntiAlias : SmoothingMode.Default; // We want to draw using anti aliasing for a nice smooth effect - using GraphicsHint hint = new GraphicsHint(context.Graphics, palette.GetBorderGraphicsHint(state)); + using var hint = new GraphicsHint(context.Graphics, palette.GetBorderGraphicsHint(state)); // Cache commonly used values var borderWidth = palette.GetBorderWidth(state); @@ -764,7 +764,7 @@ public override void DrawBorder([DisallowNull] RenderContext context, // Use standard helper routine to create appropriate color brush PaletteColorStyle colorStyle = palette.GetBorderColorStyle(state); - using (Pen borderPen = + using (var borderPen = new Pen( CreateColorBrush(gradientRect, palette.GetBorderColor1(state), palette.GetBorderColor2(state), colorStyle, palette.GetBorderColorAngle(state), @@ -794,7 +794,7 @@ public override void DrawBorder([DisallowNull] RenderContext context, Rectangle imageRect = context.GetAlignedRectangle(palette.GetBorderImageAlign(state), rect); // Use standard helper routine to create appropriate image brush - using Pen borderPen = new Pen(CreateImageBrush(imageRect, borderImage!, borderImageStyle), + using var borderPen = new Pen(CreateImageBrush(imageRect, borderImage!, borderImageStyle), borderWidth); context.Graphics.DrawPath(borderPen, borderPath0); @@ -873,7 +873,7 @@ public override void DrawBorder([DisallowNull] RenderContext context, } // We want to draw using anti aliasing for a nice smooth effect - using GraphicsHint smooth = new GraphicsHint(context.Graphics, palette.GetBackGraphicsHint(state)); + using var smooth = new GraphicsHint(context.Graphics, palette.GetBackGraphicsHint(state)); // Cache commonly used values Image? backImage = palette.GetBackImage(state); PaletteImageStyle backImageStyle = palette.GetBackImageStyle(state); @@ -1067,7 +1067,7 @@ public override Size GetContentPreferredSize([DisallowNull] ViewLayoutContext co // Provide a maximum sized rectangle for placing content into, in // order to work out how much of the space is actually allocated - Rectangle displayRect = new Rectangle(Point.Empty, new Size(int.MaxValue, int.MaxValue)); + var displayRect = new Rectangle(Point.Empty, new Size(int.MaxValue, int.MaxValue)); // Track the allocated space in each grid position var allocation = new Size[3, 3] { { Size.Empty, Size.Empty, Size.Empty }, @@ -1075,7 +1075,7 @@ public override Size GetContentPreferredSize([DisallowNull] ViewLayoutContext co { Size.Empty, Size.Empty, Size.Empty } }; // Create a memento for storing calculations - using StandardContentMemento memento = new StandardContentMemento(); + using var memento = new StandardContentMemento(); // Cache the size of a spacing gap var spacingGap = palette.GetContentAdjacentGap(state); @@ -1205,7 +1205,7 @@ public override IDisposable LayoutContent([DisallowNull] ViewLayoutContext conte { Size.Empty, Size.Empty, Size.Empty } }; // Create a memento to return to caller - StandardContentMemento memento = new StandardContentMemento(); + var memento = new StandardContentMemento(); // Cache the size of a spacing gap var spacingGap = palette.GetContentAdjacentGap(state); @@ -1325,7 +1325,7 @@ public override void DrawContent([DisallowNull] RenderContext context, Debug.Assert(!context.Control.IsDisposed); // Cast the incoming memento to the correct type - StandardContentMemento standard = (StandardContentMemento)memento; + var standard = (StandardContentMemento)memento; if (standard.DrawImage) { @@ -1341,7 +1341,7 @@ public override void DrawContent([DisallowNull] RenderContext context, if (standard.DrawShortText) { - using GraphicsTextHint hint = new GraphicsTextHint(context.Graphics, standard.ShortTextHint); + using var hint = new GraphicsTextHint(context.Graphics, standard.ShortTextHint); // Get the rectangle to use when dealing with gradients Rectangle gradientRect = context.GetAlignedRectangle(palette.GetContentShortTextColorAlign(state), standard.ShortTextRect); @@ -1420,7 +1420,7 @@ public override void DrawContent([DisallowNull] RenderContext context, if (standard.DrawLongText) { - using GraphicsTextHint hint = new GraphicsTextHint(context.Graphics, standard.LongTextHint); + using var hint = new GraphicsTextHint(context.Graphics, standard.LongTextHint); // Get the rectangle to use when dealing with gradients Rectangle gradientRect = context.GetAlignedRectangle(palette.GetContentLongTextColorAlign(state), standard.LongTextRect); @@ -1516,7 +1516,7 @@ public override bool GetContentImageDisplayed(IDisposable memento) { if (memento != null) { - StandardContentMemento standard = (StandardContentMemento)memento; + var standard = (StandardContentMemento)memento; return standard.DrawImage; } else @@ -1534,7 +1534,7 @@ public override Rectangle GetContentImageRectangle(IDisposable memento) { if (memento != null) { - StandardContentMemento standard = (StandardContentMemento)memento; + var standard = (StandardContentMemento)memento; return standard.ImageRect; } else @@ -1552,7 +1552,7 @@ public override bool GetContentShortTextDisplayed(IDisposable memento) { if (memento != null) { - StandardContentMemento standard = (StandardContentMemento)memento; + var standard = (StandardContentMemento)memento; return standard.DrawShortText; } else @@ -1570,7 +1570,7 @@ public override Rectangle GetContentShortTextRectangle(IDisposable memento) { if (memento != null) { - StandardContentMemento standard = (StandardContentMemento)memento; + var standard = (StandardContentMemento)memento; return standard.ShortTextRect; } else @@ -1588,7 +1588,7 @@ public override bool GetContentLongTextDisplayed(IDisposable memento) { if (memento != null) { - StandardContentMemento standard = (StandardContentMemento)memento; + var standard = (StandardContentMemento)memento; return standard.DrawLongText; } else @@ -1606,7 +1606,7 @@ public override Rectangle GetContentLongTextRectangle(IDisposable memento) { if (memento != null) { - StandardContentMemento standard = (StandardContentMemento)memento; + var standard = (StandardContentMemento)memento; return standard.LongTextRect; } else @@ -1712,7 +1712,7 @@ public override Padding GetTabBorderDisplayPadding(ViewLayoutContext context, // Cache the right to left setting var rtl = context.Control.RightToLeft == RightToLeft.Yes; - Padding ret = Padding.Empty; + var ret = Padding.Empty; switch (tabBorderStyle) { @@ -1974,7 +1974,7 @@ public override void DrawTabBorder([DisallowNull] RenderContext context, if (rect is { Width: > 0, Height: > 0 }) { // Decide if we need to use anti aliasing for a smoother looking visual - using GraphicsHint hint = new GraphicsHint(context.Graphics, palette.GetBorderGraphicsHint(state)); + using var hint = new GraphicsHint(context.Graphics, palette.GetBorderGraphicsHint(state)); // Cache commonly used values var borderWidth = palette.GetBorderWidth(state); @@ -1996,7 +1996,7 @@ public override void DrawTabBorder([DisallowNull] RenderContext context, palette.GetBorderColorAngle(state), orientation)) { - using (Pen borderPen = new Pen(borderBrush, borderWidth)) + using (var borderPen = new Pen(borderBrush, borderWidth)) { context.Graphics.DrawPath(borderPen, borderPath); } @@ -2014,7 +2014,7 @@ public override void DrawTabBorder([DisallowNull] RenderContext context, PaletteImageStyle borderImageStyle = palette.GetBorderImageStyle(state); // Use standard helper routine to create appropriate image brush - using Pen borderPen = new Pen(CreateImageBrush(imageRect, borderImage, borderImageStyle), + using var borderPen = new Pen(CreateImageBrush(imageRect, borderImage, borderImageStyle), borderWidth); context.Graphics.DrawPath(borderPen, borderPath); } @@ -2058,7 +2058,7 @@ public override void DrawTabBorder([DisallowNull] RenderContext context, // Do nothing break; case PaletteRibbonColorStyle.Solid: - using (SolidBrush backBrush = new SolidBrush(palette.GetRibbonBackColor1(state))) + using (var backBrush = new SolidBrush(palette.GetRibbonBackColor1(state))) { context.Graphics.FillRectangle(backBrush, rect); } @@ -2232,7 +2232,7 @@ public override void DrawRibbonClusterEdge(PaletteRibbonShape shape, Debug.Assert(paletteBack != null); // Draw inside of the border edge in a lighter version of the border - using SolidBrush drawBrush = new SolidBrush(paletteBack.GetBackColor1(state)); + using var drawBrush = new SolidBrush(paletteBack.GetBackColor1(state)); context.Graphics.FillRectangle(drawBrush, displayRect); } #endregion @@ -2528,7 +2528,7 @@ public override Size GetDropDownButtonPreferredSize(ViewLayoutContext context, Image? drawImage = palette.GetDropDownButtonImage(state); // Get the image defined size - Size imageSize = Size.Empty; + var imageSize = Size.Empty; if (drawImage != null) { imageSize = drawImage.Size; @@ -2763,12 +2763,12 @@ public override void DrawRibbonDialogBoxLauncher(PaletteRibbonShape shape, } break; case PaletteRibbonShape.Office2010: - LinearGradientBrush dialogBrush = new LinearGradientBrush( + var dialogBrush = new LinearGradientBrush( new RectangleF(displayRect.X - 1, displayRect.Y - 1, displayRect.Width + 2, displayRect.Height + 2), paletteGeneral.GetRibbonGroupDialogLight(state), paletteGeneral.GetRibbonGroupDialogDark(state), 45f); - using (Pen dialogPen = new Pen(dialogBrush)) + using (var dialogPen = new Pen(dialogBrush)) { context.Graphics.DrawLine(dialogPen, displayRect.Left, displayRect.Top + 5, displayRect.Left, displayRect.Top); context.Graphics.DrawLine(dialogPen, displayRect.Left, displayRect.Top, displayRect.Left + 5, displayRect.Top); @@ -2832,7 +2832,7 @@ public override void DrawRibbonDropArrow(PaletteRibbonShape shape, } break; case PaletteRibbonShape.Office2010: - using (LinearGradientBrush fillBrush = new LinearGradientBrush( + using (var fillBrush = new LinearGradientBrush( new RectangleF(displayRect.X - 1, displayRect.Y - 1, displayRect.Width + 2, displayRect.Height + 2), lightColor, darkColor, 45f)) { @@ -3021,7 +3021,7 @@ public override void DrawRibbonGroupSeparator(PaletteRibbonShape shape, darkBrush.SetSigmaBellShape(0.5f); lightBrush.SetSigmaBellShape(0.5f); - using (Pen darkPen = new Pen(darkBrush)) + using (var darkPen = new Pen(darkBrush)) { context.Graphics.FillRectangle(lightBrush, x, displayRect.Top, 3, displayRect.Height); context.Graphics.DrawLine(darkPen, x + 1, displayRect.Top, x + 1, displayRect.Bottom - 1); @@ -3065,9 +3065,9 @@ public override Rectangle DrawGridSortGlyph([DisallowNull] RenderContext context Color imageColor = paletteContent.GetContentShortTextColor1(state); // Draw the image with remapping the image color to the foreground color - using (ImageAttributes attribs = new ImageAttributes()) + using (var attribs = new ImageAttributes()) { - ColorMap cm = new ColorMap + var cm = new ColorMap { OldColor = Color.Black, NewColor = CommonHelper.MergeColors(imageColor, 0.75f, Color.Transparent, 0.25f) @@ -3145,9 +3145,9 @@ public override Rectangle DrawGridRowGlyph([DisallowNull] RenderContext context, Color imageColor = paletteContent.GetContentShortTextColor1(state); // Draw the image with remapping the image color to the foreground color - using (ImageAttributes attribs = new ImageAttributes()) + using (var attribs = new ImageAttributes()) { - ColorMap cm = new ColorMap + var cm = new ColorMap { OldColor = Color.Black, NewColor = CommonHelper.MergeColors(imageColor, 0.75f, Color.Transparent, 0.25f) @@ -3233,12 +3233,12 @@ public override void DrawDragDropSolidGlyph([DisallowNull] RenderContext context Debug.Assert(context != null); Debug.Assert(dragDropPalette != null); - using (SolidBrush backBrush = new SolidBrush(dragDropPalette.GetDragDropSolidBack())) + using (var backBrush = new SolidBrush(dragDropPalette.GetDragDropSolidBack())) { context.Graphics.FillRectangle(backBrush, drawRect); } - using (Pen borderPen = new Pen(dragDropPalette.GetDragDropSolidBorder())) + using (var borderPen = new Pen(dragDropPalette.GetDragDropSolidBorder())) { context.Graphics.DrawRectangle(borderPen, drawRect); } @@ -3418,7 +3418,7 @@ public override void DrawTrackTicksGlyph(RenderContext context, } float range = maximum - minimum; - using Pen tickPen = new Pen(elementPalette.GetElementColor1(state)); + using var tickPen = new Pen(elementPalette.GetElementColor1(state)); if (orientation == Orientation.Horizontal) { // Reduce area by half the position indicator on each side @@ -3522,7 +3522,7 @@ public override void DrawTrackGlyph(RenderContext context, using Pen border1Pen = new Pen(elementPalette.GetElementColor1(state)), border2Pen = new Pen(elementPalette.GetElementColor2(state)); - using SolidBrush insideBrush = new SolidBrush(elementPalette.GetElementColor3(state)); + using var insideBrush = new SolidBrush(elementPalette.GetElementColor3(state)); if (!volumeControl) { context.Graphics.FillRectangle(insideBrush, drawRect.X + 1, drawRect.Y + 1, drawRect.Width - 2, drawRect.Height - 2); @@ -3539,7 +3539,7 @@ public override void DrawTrackGlyph(RenderContext context, { if (orientation == Orientation.Horizontal) { - using AntiAlias aa = new AntiAlias(context.Graphics); + using var aa = new AntiAlias(context.Graphics); context.Graphics.FillPolygon(insideBrush, new Point[]{ new Point(drawRect.X, drawRect.Bottom - 2), new Point(drawRect.Right - 1, drawRect.Y), new Point(drawRect.Right - 1, drawRect.Bottom - 1), new Point(drawRect.X, drawRect.Bottom - 1), @@ -3552,7 +3552,7 @@ public override void DrawTrackGlyph(RenderContext context, } else { - using AntiAlias aa = new AntiAlias(context.Graphics); + using var aa = new AntiAlias(context.Graphics); context.Graphics.FillPolygon(insideBrush, new Point[]{ new Point(drawRect.X + 1, drawRect.Bottom - 1), new Point(drawRect.Right - 1, drawRect.Y + 1), new Point(drawRect.X, drawRect.Y + 1), new Point(drawRect.X, drawRect.Bottom - 1), @@ -3624,21 +3624,21 @@ public override void DrawTrackPositionGlyph(RenderContext context, && (inside != null) ) { - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { using (Pen outsidePen = new Pen(elementPalette.GetElementColor1(state)), borderPen = new Pen(elementPalette.GetElementColor2(state))) { context.Graphics.DrawPath(outsidePen, outside); - using (SolidBrush insideBrush = new SolidBrush(elementPalette.GetElementColor3(state))) + using (var insideBrush = new SolidBrush(elementPalette.GetElementColor3(state))) { context.Graphics.FillPath(insideBrush, border); } context.Graphics.DrawPath(borderPen, border); - using (LinearGradientBrush innerBrush = new LinearGradientBrush(inside.GetBounds(), + using (var innerBrush = new LinearGradientBrush(inside.GetBounds(), elementPalette.GetElementColor4(state), elementPalette.GetElementColor5(state), 90f)) { context.Graphics.FillPath(innerBrush, inside); @@ -3667,7 +3667,7 @@ private void CreatePositionPathsBoth(Rectangle drawRect, private GraphicsPath CreatePositionPathsBoth(Rectangle drawRect) { - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLines(new PointF[]{ new PointF(drawRect.X + 0.75f, drawRect.Y), new PointF(drawRect.Right - 1.75f, drawRect.Y), new PointF(drawRect.Right - 1.0f, drawRect.Y + 0.75f), @@ -3697,7 +3697,7 @@ private GraphicsPath CreatePositionPathsBottom(Rectangle drawRect) { var half = ((float)drawRect.Width / 2) - 0.5f; - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLines(new PointF[]{ new PointF(drawRect.X + half, drawRect.Y), new PointF(drawRect.Right - 1.0f, drawRect.Y + +half), new PointF(drawRect.Right - 1.0f, drawRect.Bottom - 2.0f), @@ -3724,7 +3724,7 @@ private GraphicsPath CreatePositionPathsTop(Rectangle drawRect) { var half = ((float)drawRect.Width / 2) - 0.5f; - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLines(new PointF[]{ new PointF(drawRect.X + 0.75f, drawRect.Y), new PointF(drawRect.Right - 1.75f, drawRect.Y), new PointF(drawRect.Right - 1.0f, drawRect.Y + 0.75f), @@ -3752,7 +3752,7 @@ private GraphicsPath CreatePositionPathsRight(Rectangle drawRect) { var half = ((float)drawRect.Height / 2) - 0.5f; - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLines(new PointF[]{ new PointF(drawRect.X + 0.75f, drawRect.Y), new PointF(drawRect.Right - half - 1.0f, drawRect.Y), new PointF(drawRect.Right - 1.0f, drawRect.Y + half), @@ -3780,7 +3780,7 @@ private GraphicsPath CreatePositionPathsLeft(Rectangle drawRect) { var half = ((float)drawRect.Height / 2) - 0.5f; - GraphicsPath path = new GraphicsPath(); + var path = new GraphicsPath(); path.AddLines(new PointF[]{ new PointF(drawRect.Right - 1.75f, drawRect.Y), new PointF(drawRect.Right - 1.0f, drawRect.Y + 0.75f), new PointF(drawRect.Right - 1.0f, drawRect.Bottom - 2.0f), @@ -3803,7 +3803,7 @@ private static GraphicsPath CreateBorderBackPath(bool forBorder, bool smoothing, int variant) { - GraphicsPath borderPath = new GraphicsPath(); + var borderPath = new GraphicsPath(); // A zero size rectangle cannot be drawn, so return a null path if (rect is { Width: > 0, Height: > 0 }) @@ -3929,7 +3929,7 @@ private static void CreateAllBorderBackPath(bool middle, else { // We create the path using a floating point rectangle - RectangleF rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); + var rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); // If trying to get the outside edge then perform some offsetting so that // when converted to a region it draws nicely inside the path outline @@ -4051,7 +4051,7 @@ private static void CreateBorderBackPathOnly(bool middle, rect.Height -= 1; // We create the path using a floating point rectangle - RectangleF rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); + var rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); // If trying to get the outside edge then perform some offsetting so that // when converted to a region it draws nicely inside the path outline @@ -4161,7 +4161,7 @@ private static void CreateBorderBackPathOnlyClosed(bool middle, rect.Height--; // We create the path using a floating point rectangle - RectangleF rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); + var rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); // If trying to get the outside edge then perform some offsetting so that // when converted to a region it draws nicely inside the path outline @@ -4247,7 +4247,7 @@ private static void CreateBorderBackPathComplete(bool middle, float arcLength) { // We create the path using a floating point rectangle - RectangleF rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); + var rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); // If trying to get the outside edge then perform some offsetting so that // when converted to a region it draws nicely inside the path outline @@ -4356,7 +4356,7 @@ private static GraphicsPath CreateTabBorderBackPath(RightToLeft rtl, VisualOrientation orientation, bool smoothing) { - GraphicsPath borderPath = new GraphicsPath(); + var borderPath = new GraphicsPath(); // A zero size rectangle cannot be drawn, so return a null path if (rect is { Width: > 0, Height: > 0 }) @@ -5147,7 +5147,7 @@ private static Brush CreateColorBrush(Rectangle rect, } // Otherwise we always create a linear brush using provided colors and angle - LinearGradientBrush brush = new LinearGradientBrush(rect, color1, color2, angle); + var brush = new LinearGradientBrush(rect, color1, color2, angle); switch (gradientStyle) { @@ -5213,7 +5213,7 @@ private static Brush CreateImageBrush(Rectangle rect, PaletteImageStyle imageStyle) { // Create brush based on the provided image - TextureBrush brush = new TextureBrush(image); + var brush = new TextureBrush(image); // Create appropriate wrapping mode from image style switch (imageStyle) @@ -5291,7 +5291,7 @@ private void DrawBackSolidInside(RenderContext context, GraphicsPath path) { // Clip to prevent drawing outside the path - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Get the rectangle that encloses the path RectangleF rectF = path.GetBounds(); @@ -5350,7 +5350,7 @@ private void DrawBackOneNote(RenderContext context, } // Make a copy of the original path, so we can change it - GraphicsPath insetPath = (GraphicsPath)path.Clone(); + var insetPath = (GraphicsPath)path.Clone(); // Offset by 1.5 pixels so the background shows around two of // the edges of the background we are about to draw @@ -5368,7 +5368,7 @@ private void DrawBackOneNote(RenderContext context, break; } - using (Clipping clip = new Clipping(context.Graphics, path)) + using (var clip = new Clipping(context.Graphics, path)) { // Draw the second color as the offset background using (Brush backBrush = CreateColorBrush(gradientRect, @@ -5393,9 +5393,9 @@ private void DrawBackSolidLine(RenderContext context, PaletteColorStyle style, GraphicsPath path) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Draw entire background in second color - using (SolidBrush brushColor2 = new SolidBrush(backColor2)) + using (var brushColor2 = new SolidBrush(backColor2)) { context.Graphics.FillRectangle(brushColor2, rect); } @@ -5426,7 +5426,7 @@ private void DrawBackSolidLine(RenderContext context, } // Draw the second color as a solid block - using (SolidBrush brushColor2 = new SolidBrush(backColor1)) + using (var brushColor2 = new SolidBrush(backColor1)) { context.Graphics.FillRectangle(brushColor2, rect); } @@ -5442,7 +5442,7 @@ private void DrawBackRoundedTopLeftWhite(RenderContext context, VisualOrientation orientation, GraphicsPath path) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Draw entire background in white context.Graphics.FillRectangle(Brushes.White, rect); @@ -5474,9 +5474,9 @@ private void DrawBackRoundedTopLight(RenderContext context, VisualOrientation orientation, GraphicsPath path) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Draw entire background in white - using (SolidBrush lightBrush = new SolidBrush(ControlPaint.LightLight(backColor1))) + using (var lightBrush = new SolidBrush(ControlPaint.LightLight(backColor1))) { context.Graphics.FillRectangle(lightBrush, rect); } @@ -5522,7 +5522,7 @@ private void DrawBackRounded4(RenderContext context, VisualOrientation orientation, GraphicsPath path) { - using Clipping clip = new Clipping(context.Graphics, path); + using var clip = new Clipping(context.Graphics, path); // Use standard helper routine to create appropriate color brush using (Brush backBrush = CreateColorBrush(gradientRect, backColor1, backColor2, backColorStyle, backColorAngle, orientation)) @@ -5530,7 +5530,7 @@ private void DrawBackRounded4(RenderContext context, context.Graphics.FillPath(backBrush, path); } - using (Pen linePen = new Pen(backColor1)) + using (var linePen = new Pen(backColor1)) { // Adjust angle for the orientation switch (orientation) @@ -5565,7 +5565,7 @@ private void DrawBackRounding5(RenderContext context, rect.Inflate(-1, -1); // Prevent drawing over that ourside edge - using Clipping clip = new Clipping(context.Graphics, rect); + using var clip = new Clipping(context.Graphics, rect); // Use standard helper routine to create appropriate color brush using Brush backBrush = CreateColorBrush(gradientRect, backColor1, backColor2, PaletteColorStyle.Rounding5, backColorAngle, @@ -5584,7 +5584,7 @@ private void DrawBackLinearShadow(RenderContext context, GraphicsPath path) { // Prevent drawing over that ourside edge - using Clipping clip = new Clipping(context.Graphics, rect); + using var clip = new Clipping(context.Graphics, rect); // Use standard helper routine to create appropriate color brush using (Brush backBrush = CreateColorBrush(gradientRect, backColor1, backColor2, PaletteColorStyle.Linear, backColorAngle, @@ -5594,7 +5594,7 @@ private void DrawBackLinearShadow(RenderContext context, } // Use path gradient to give the outside of the area a shadow effect - using (PathGradientBrush borderBrush = new PathGradientBrush(path)) + using (var borderBrush = new PathGradientBrush(path)) { borderBrush.Blend = _linearShadowBlend; borderBrush.CenterColor = backColor1; @@ -6146,7 +6146,7 @@ private static void PositionAlignContent([DisallowNull] StandardContentMemento m int spacingGap) { // Create client rectangle covering cell size - Rectangle cellRect = new Rectangle(cellX, cellY, cellWidth, cellHeight); + var cellRect = new Rectangle(cellX, cellY, cellWidth, cellHeight); PaletteRelativeAlign drawHImage = paletteContent.GetContentImageH(state); PaletteRelativeAlign drawVImage = paletteContent.GetContentImageV(state); @@ -6226,7 +6226,7 @@ private static Point PositionCellContent(RightToLeft rtl, int spacingGap, ref Rectangle cellRect) { - Point location = Point.Empty; + var location = Point.Empty; // If drawing from right to left... if (rtl == RightToLeft.Yes) @@ -6491,31 +6491,31 @@ private void DrawDragDockingRoundedMiddle(RenderContext context, { Color borderColor = dragData.ActiveMiddle ? active : border; Color insideColor = dragData.ActiveMiddle ? active : inside; - using AntiAlias aa = new AntiAlias(context.Graphics); + using var aa = new AntiAlias(context.Graphics); using GraphicsPath borderPath = new GraphicsPath(), insidePath = new GraphicsPath(); // Generate the graphics paths for the border and the inside area which is just inside the border Rectangle rect = dragData.RectMiddle; - Rectangle rectInside = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4); + var rectInside = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4); DrawDragDockingMiddleLines(borderPath, dragData.RectMiddle, 13); DrawDragDockingMiddleLines(insidePath, rectInside, 9); // Fill the entire border area - using (SolidBrush borderBrush = new SolidBrush(Color.FromArgb(196, Color.White))) + using (var borderBrush = new SolidBrush(Color.FromArgb(196, Color.White))) { context.Graphics.FillPath(borderBrush, borderPath); } // Fill with gradient the area inside the border - RectangleF rectBoundsF = new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); - using (LinearGradientBrush insideBrush = + var rectBoundsF = new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); + using (var insideBrush = new LinearGradientBrush(rectBoundsF, Color.FromArgb(196, Color.White), insideColor, 90)) { insideBrush.Blend = _dragRoundedInsideBlend; context.Graphics.FillPath(insideBrush, insidePath); } - using (Pen borderPen = new Pen(borderColor)) + using (var borderPen = new Pen(borderColor)) { // Finally draw the actual border context.Graphics.DrawPath(borderPen, borderPath); @@ -6544,26 +6544,26 @@ private void DrawDragDockingRoundedRect(RenderContext context, Rectangle drawRect, int rounding) { - using AntiAlias aa = new AntiAlias(context.Graphics); - RectangleF rectBoundsF = + using var aa = new AntiAlias(context.Graphics); + var rectBoundsF = new RectangleF(drawRect.X - 1, drawRect.Y - 1, drawRect.Width + 2, drawRect.Height + 1); - Rectangle rectInside = + var rectInside = new Rectangle(drawRect.X + 2, drawRect.Y + 2, drawRect.Width - 4, drawRect.Height - 4); using GraphicsPath borderPath = CreateBorderBackPath(true, true, drawRect, PaletteDrawBorders.All, 1, rounding, true, 0), insidePath = CreateBorderBackPath(true, true, rectInside, PaletteDrawBorders.All, 1, rounding - 1, true, 0); - using (SolidBrush borderBrush = new SolidBrush(Color.FromArgb(196, Color.White))) + using (var borderBrush = new SolidBrush(Color.FromArgb(196, Color.White))) { context.Graphics.FillPath(borderBrush, borderPath); } - using (LinearGradientBrush insideBrush = + using (var insideBrush = new LinearGradientBrush(rectBoundsF, Color.FromArgb(196, Color.White), inside, 90)) { insideBrush.Blend = _dragRoundedInsideBlend; context.Graphics.FillPath(insideBrush, insidePath); } - using (Pen borderPen = new Pen(border)) + using (var borderPen = new Pen(border)) { context.Graphics.DrawPath(borderPen, borderPath); } @@ -6574,7 +6574,7 @@ private void DrawDragDockingArrow(RenderContext context, Rectangle rect, VisualOrientation orientation) { - using GraphicsPath innerPath = new GraphicsPath(); + using var innerPath = new GraphicsPath(); var angle = 0f; switch (orientation) { @@ -6620,13 +6620,13 @@ private void DrawDragDockingArrow(RenderContext context, } // Draw background in white top highlight the arrow - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { context.Graphics.FillPath(Brushes.White, innerPath); } // Draw the actual arrow itself - using (LinearGradientBrush innerBrush = + using (var innerBrush = new LinearGradientBrush(rect, ControlPaint.Dark(active), ControlPaint.Light(active), angle)) { context.Graphics.FillPath(innerBrush, innerPath); @@ -6685,8 +6685,8 @@ private void DrawDragDockingSquaresBackground(Graphics? g, } Color start = Color.FromArgb(190, 190, 190); - using Pen borderPen = new Pen(border); - using SolidBrush insideBrush = new SolidBrush(inside); + using var borderPen = new Pen(border); + using var insideBrush = new SolidBrush(inside); using LinearGradientBrush gradientLL = new LinearGradientBrush(new Rectangle(-1, -1, 5, 5), start, inside, 0f), gradientTL = new LinearGradientBrush(new Rectangle(-1, 23, 5, 5), start, inside, 90f), @@ -7111,7 +7111,7 @@ private void DrawDragDockingSquaresMiddle(Graphics? g, g.FillRectangle(SystemBrushes.Window, 49, 51, 5, 3); // Fill the inner indicator area - using (SolidBrush innerBrush = new SolidBrush(Color.FromArgb(64, inactiveColor))) + using (var innerBrush = new SolidBrush(Color.FromArgb(64, inactiveColor))) { g.FillRectangle(innerBrush, 34, 36, 19, 13); g.FillRectangle(innerBrush, 34, 49, 7, 3); @@ -7196,10 +7196,10 @@ protected virtual IDisposable DrawRibbonGroupAreaBorder1And2(RenderContext conte // Dispose of existing values cache.Dispose(); - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePathN = new GraphicsPath(); - GraphicsPath insidePathL = new GraphicsPath(); - GraphicsPath shadowPath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePathN = new GraphicsPath(); + var insidePathL = new GraphicsPath(); + var shadowPath = new GraphicsPath(); // Create path for the entire border outsidePath.AddLine(rect.Left + 2, rect.Top, rect.Right - 3, rect.Top); @@ -7225,12 +7225,12 @@ protected virtual IDisposable DrawRibbonGroupAreaBorder1And2(RenderContext conte shadowPath.AddLine(rect.Right - 4, rect.Bottom, rect.Right, rect.Bottom - 3); shadowPath.AddLine(rect.Right, rect.Bottom - 3, rect.Right, rect.Top + 3); - LinearGradientBrush insideBrush = new LinearGradientBrush(rect, Color.Transparent, c2, 95f); + var insideBrush = new LinearGradientBrush(rect, Color.Transparent, c2, 95f); cache.InsidePen = new Pen(insideBrush); - Rectangle rectGradient = new Rectangle(rect.Left - 1, rect.Top, rect.Width + 2, rect.Height + 1); - LinearGradientBrush shadowBrushN = new LinearGradientBrush(rectGradient, _darken8, _darken38, 90f); - LinearGradientBrush shadowBrushL = new LinearGradientBrush(rectGradient, _darken8, _darken18, 90f); + var rectGradient = new Rectangle(rect.Left - 1, rect.Top, rect.Width + 2, rect.Height + 1); + var shadowBrushN = new LinearGradientBrush(rectGradient, _darken8, _darken38, 90f); + var shadowBrushL = new LinearGradientBrush(rectGradient, _darken8, _darken18, 90f); cache.ShadowPenN = new Pen(shadowBrushN); cache.ShadowPenL = new Pen(shadowBrushL); @@ -7253,12 +7253,12 @@ protected virtual IDisposable DrawRibbonGroupAreaBorder1And2(RenderContext conte context.Graphics.FillPath(cache.FillBrush, cache.OutsidePath); // Clip drawing to the outside border - using (Clipping clip = new Clipping(context.Graphics, cache.OutsidePath)) + using (var clip = new Clipping(context.Graphics, cache.OutsidePath)) { context.Graphics.FillPath(cache.FillTopBrush, cache.OutsidePath); } - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { // Draw the outside of the entire border line context.Graphics.DrawPath(cache.OutsidePen, cache.OutsidePath); @@ -7400,9 +7400,9 @@ protected virtual IDisposable DrawRibbonGroupAreaBorderContext(RenderContext con // Dispose of existing values cache.Dispose(); - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); - GraphicsPath shadowPath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); + var shadowPath = new GraphicsPath(); // Create path for the entire border outsidePath.AddLine(rect.Left + 2, rect.Top, rect.Right - 3, rect.Top); @@ -7427,11 +7427,11 @@ protected virtual IDisposable DrawRibbonGroupAreaBorderContext(RenderContext con shadowPath.AddLine(rect.Right - 4, rect.Bottom, rect.Right, rect.Bottom - 3); shadowPath.AddLine(rect.Right, rect.Bottom - 3, rect.Right, rect.Top + 3); - LinearGradientBrush insideBrush = new LinearGradientBrush(rect, Color.Transparent, c2, 95f); + var insideBrush = new LinearGradientBrush(rect, Color.Transparent, c2, 95f); cache.InsidePen = new Pen(insideBrush); - Rectangle rectGradient = new Rectangle(rect.Left - 1, rect.Top, rect.Width + 2, rect.Height + 1); - LinearGradientBrush shadowBrush = new LinearGradientBrush(rectGradient, _darken8, _darken38, 90f); + var rectGradient = new Rectangle(rect.Left - 1, rect.Top, rect.Width + 2, rect.Height + 1); + var shadowBrush = new LinearGradientBrush(rectGradient, _darken8, _darken38, 90f); cache.ShadowPen = new Pen(shadowBrush); cache.FillBrush = new LinearGradientBrush(rect, Color.White, _242, 90f) @@ -7452,12 +7452,12 @@ protected virtual IDisposable DrawRibbonGroupAreaBorderContext(RenderContext con context.Graphics.FillPath(cache.FillBrush, cache.OutsidePath); // Clip drawing to the outside border - using (Clipping clip = new Clipping(context.Graphics, cache.OutsidePath)) + using (var clip = new Clipping(context.Graphics, cache.OutsidePath)) { context.Graphics.FillPath(cache.FillTopBrush, cache.OutsidePath); } - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { // Draw the outside of the entire border line context.Graphics.DrawPath(cache.OutsidePen, cache.OutsidePath); @@ -7552,7 +7552,7 @@ protected virtual IDisposable DrawRibbonTabTracking2007(PaletteRibbonShape shape } // Draw the actual border - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { context.Graphics.DrawPath(cache.OutsidePen, cache.OutsidePath); } @@ -7587,7 +7587,7 @@ protected virtual void DrawRibbonTabTrackingTop2007(Rectangle rect, MementoRibbonTabTracking2007 cache) { // Create path for a curved border around the tab - GraphicsPath outsidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); outsidePath.AddLine(rect.Left + 1, rect.Bottom - 2, rect.Left + 1, rect.Top + 1.5f); outsidePath.AddLine(rect.Left + 1, rect.Top + 1.5f, rect.Left + 3, rect.Top); outsidePath.AddLine(rect.Left + 3, rect.Top, rect.Right - 4, rect.Top); @@ -7595,7 +7595,7 @@ protected virtual void DrawRibbonTabTrackingTop2007(Rectangle rect, outsidePath.AddLine(rect.Right - 2, rect.Top + 1.5f, rect.Right - 2, rect.Bottom - 2); // Create path for the top hightlight line - GraphicsPath topPath = new GraphicsPath(); + var topPath = new GraphicsPath(); topPath.AddLine(rect.Left + 3, rect.Top + 2, rect.Left + 4, rect.Top + 1); topPath.AddLine(rect.Left + 4, rect.Top + 1, rect.Right - 5, rect.Top + 1); topPath.AddLine(rect.Right - 5, rect.Top + 1, rect.Right - 4, rect.Top + 2); @@ -7606,8 +7606,8 @@ protected virtual void DrawRibbonTabTrackingTop2007(Rectangle rect, var half2 = full - half1; cache.Half1Rect = new Rectangle(rect.Left + 3, rect.Top + 2, rect.Width - 6, half1); cache.Half2Rect = new Rectangle(rect.Left + 3, rect.Top + 2 + half1, rect.Width - 6, half2); - Rectangle fullRect = new Rectangle(rect.Left + 3, rect.Top + 2, rect.Width - 6, half1 + half2); - RectangleF half1RectF = new RectangleF(cache.Half1Rect.Left - 1, cache.Half1Rect.Top - 0.5f, + var fullRect = new Rectangle(rect.Left + 3, rect.Top + 2, rect.Width - 6, half1 + half2); + var half1RectF = new RectangleF(cache.Half1Rect.Left - 1, cache.Half1Rect.Top - 0.5f, cache.Half1Rect.Width + 2, cache.Half1Rect.Height + 1); cache.Half2RectF = new RectangleF(cache.Half2Rect.Left - 1, cache.Half2Rect.Top - 0.5f, cache.Half2Rect.Width + 2, cache.Half2Rect.Height + 1); @@ -7626,7 +7626,7 @@ protected virtual void DrawRibbonTabTrackingTop2007(Rectangle rect, cache.EllipseRect = new RectangleF(fullRect.Left - (fullRect.Width / 8), fullRect.Top, fullRect.Width * 1.25f, fullRect.Height); // Cannot draw a path that contains a zero sized element - GraphicsPath ellipsePath = new GraphicsPath(); + var ellipsePath = new GraphicsPath(); if (cache.EllipseRect is { Width: > 0, Height: > 0 }) { ellipsePath.AddEllipse(cache.EllipseRect); @@ -7634,14 +7634,14 @@ protected virtual void DrawRibbonTabTrackingTop2007(Rectangle rect, { CenterColor = Color.FromArgb(92, Color.White) }; - PointF centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), + var centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), cache.EllipseRect.Top + (cache.EllipseRect.Height / 2)); cache.EllipseBrush.CenterPoint = centerPoint; cache.EllipseBrush.SurroundColors = new[] { Color.Transparent }; } - RectangleF vertRectF = new RectangleF(rect.Left - 1, rect.Top + 2, rect.Width + 2, rect.Height - 2); - RectangleF horzRectF = new RectangleF(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height); + var vertRectF = new RectangleF(rect.Left - 1, rect.Top + 2, rect.Width + 2, rect.Height - 2); + var horzRectF = new RectangleF(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height); cache.OutsideBrush = new LinearGradientBrush(vertRectF, Color.Transparent, _whiten128, 90f) { Blend = _ribbonOutBlend @@ -7683,7 +7683,7 @@ protected virtual void DrawRibbonTabTrackingLeft2007(Rectangle rect, MementoRibbonTabTracking2007 cache) { // Create path for a curved border around the tab - GraphicsPath outsidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); outsidePath.AddLine(rect.Right - 2, rect.Bottom - 2, rect.Left + 1.5f, rect.Bottom - 2); outsidePath.AddLine(rect.Left + 1.5f, rect.Bottom - 2, rect.Left, rect.Bottom - 4); outsidePath.AddLine(rect.Left, rect.Bottom - 4, rect.Left, rect.Top + 3); @@ -7691,7 +7691,7 @@ protected virtual void DrawRibbonTabTrackingLeft2007(Rectangle rect, outsidePath.AddLine(rect.Left + 1.5f, rect.Top + 1, rect.Right - 2, rect.Top + 1); // Create path for the top hightlight line - GraphicsPath topPath = new GraphicsPath(); + var topPath = new GraphicsPath(); topPath.AddLine(rect.Left + 2, rect.Bottom - 4, rect.Left + 1, rect.Bottom - 5); topPath.AddLine(rect.Left + 1, rect.Bottom - 5, rect.Left + 1, rect.Top + 4); topPath.AddLine(rect.Left + 1, rect.Top + 4, rect.Left + 2, rect.Top + 3); @@ -7702,8 +7702,8 @@ protected virtual void DrawRibbonTabTrackingLeft2007(Rectangle rect, var half2 = full - half1; cache.Half1Rect = new Rectangle(rect.Left + 2, rect.Top + 3, half1, rect.Height - 6); cache.Half2Rect = new Rectangle(rect.Left + 2 + half1, rect.Top + 3, half2, rect.Height - 6); - Rectangle fullRect = new Rectangle(rect.Left + 2, rect.Top + 3, half1 + half2, rect.Height - 6); - RectangleF half1RectF = new RectangleF(cache.Half1Rect.Left - 0.5f, cache.Half1Rect.Top - 1f, + var fullRect = new Rectangle(rect.Left + 2, rect.Top + 3, half1 + half2, rect.Height - 6); + var half1RectF = new RectangleF(cache.Half1Rect.Left - 0.5f, cache.Half1Rect.Top - 1f, cache.Half1Rect.Width + 1, cache.Half1Rect.Height + 2); cache.Half2RectF = new RectangleF(cache.Half2Rect.Left - 0.5f, cache.Half2Rect.Top - 1f, cache.Half2Rect.Width + 1, cache.Half2Rect.Height + 2); @@ -7721,7 +7721,7 @@ protected virtual void DrawRibbonTabTrackingLeft2007(Rectangle rect, // Create ellipse information for lightening the bottom hald cache.EllipseRect = new RectangleF(fullRect.Left, fullRect.Top - (fullRect.Width / 8), fullRect.Width, fullRect.Height * 1.25f); - GraphicsPath ellipsePath = new GraphicsPath(); + var ellipsePath = new GraphicsPath(); // Cannot draw a path that contains a zero sized element if (cache.EllipseRect is { Width: > 0, Height: > 0 }) { @@ -7730,14 +7730,14 @@ protected virtual void DrawRibbonTabTrackingLeft2007(Rectangle rect, { CenterColor = Color.FromArgb(48, Color.White) }; - PointF centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), + var centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), cache.EllipseRect.Top + (cache.EllipseRect.Height / 2)); cache.EllipseBrush.CenterPoint = centerPoint; cache.EllipseBrush.SurroundColors = new[] { Color.Transparent }; } - RectangleF vertRectF = new RectangleF(rect.Left + 2, rect.Top - 1, rect.Width - 2, rect.Height + 2); - RectangleF horzRectF = new RectangleF(rect.Left, rect.Top + 1, rect.Width, rect.Height - 2); + var vertRectF = new RectangleF(rect.Left + 2, rect.Top - 1, rect.Width - 2, rect.Height + 2); + var horzRectF = new RectangleF(rect.Left, rect.Top + 1, rect.Width, rect.Height - 2); cache.OutsideBrush = new LinearGradientBrush(vertRectF, Color.Transparent, _whiten128, 180f) { Blend = _ribbonOutBlend @@ -7779,7 +7779,7 @@ protected virtual void DrawRibbonTabTrackingRight2007(Rectangle rect, MementoRibbonTabTracking2007 cache) { // Create path for a curved border around the tab - GraphicsPath outsidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); outsidePath.AddLine(rect.Left + 1, rect.Bottom - 2, rect.Right - 2.5f, rect.Bottom - 2); outsidePath.AddLine(rect.Right - 2.5f, rect.Bottom - 2, rect.Right - 1, rect.Bottom - 4); outsidePath.AddLine(rect.Right - 1, rect.Bottom - 4, rect.Right - 1, rect.Top + 3); @@ -7787,7 +7787,7 @@ protected virtual void DrawRibbonTabTrackingRight2007(Rectangle rect, outsidePath.AddLine(rect.Right - 2.5f, rect.Top + 1, rect.Left + 1, rect.Top + 1); // Create path for the top hightlight line - GraphicsPath topPath = new GraphicsPath(); + var topPath = new GraphicsPath(); topPath.AddLine(rect.Right - 3, rect.Bottom - 4, rect.Right - 2, rect.Bottom - 5); topPath.AddLine(rect.Right - 2, rect.Bottom - 5, rect.Right - 2, rect.Top + 4); topPath.AddLine(rect.Right - 2, rect.Top + 4, rect.Right - 3, rect.Top + 3); @@ -7798,9 +7798,9 @@ protected virtual void DrawRibbonTabTrackingRight2007(Rectangle rect, var half2 = full - half1; cache.Half1Rect = new Rectangle(rect.Right - 2 - half1, rect.Top + 3, half1, rect.Height - 6); cache.Half2Rect = new Rectangle(rect.Right - 2 - half1 - half2, rect.Top + 3, half2, rect.Height - 6); - Rectangle fullRect = new Rectangle(rect.Right - 2 - half1 - half2, rect.Top + 3, half1 + half2, + var fullRect = new Rectangle(rect.Right - 2 - half1 - half2, rect.Top + 3, half1 + half2, rect.Height - 6); - RectangleF half1RectF = new RectangleF(cache.Half1Rect.Left - 0.5f, cache.Half1Rect.Top - 1f, + var half1RectF = new RectangleF(cache.Half1Rect.Left - 0.5f, cache.Half1Rect.Top - 1f, cache.Half1Rect.Width + 1, cache.Half1Rect.Height + 2); cache.Half2RectF = new RectangleF(cache.Half2Rect.Left - 0.5f, cache.Half2Rect.Top - 1f, cache.Half2Rect.Width + 1, cache.Half2Rect.Height + 2); @@ -7818,7 +7818,7 @@ protected virtual void DrawRibbonTabTrackingRight2007(Rectangle rect, // Create ellipse information for lightening the bottom hald cache.EllipseRect = new RectangleF(fullRect.Left, fullRect.Top - (fullRect.Width / 8), fullRect.Width, fullRect.Height * 1.25f); - GraphicsPath ellipsePath = new GraphicsPath(); + var ellipsePath = new GraphicsPath(); // Cannot draw a path that contains a zero sized element if (cache.EllipseRect is { Width: > 0, Height: > 0 }) { @@ -7827,14 +7827,14 @@ protected virtual void DrawRibbonTabTrackingRight2007(Rectangle rect, { CenterColor = Color.FromArgb(48, Color.White) }; - PointF centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), + var centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), cache.EllipseRect.Top + (cache.EllipseRect.Height / 2)); cache.EllipseBrush.CenterPoint = centerPoint; cache.EllipseBrush.SurroundColors = new[] { Color.Transparent }; } - RectangleF vertRectF = new RectangleF(rect.Left, rect.Top - 1, rect.Width - 2, rect.Height + 2); - RectangleF horzRectF = new RectangleF(rect.Left, rect.Top + 1, rect.Width, rect.Height - 2); + var vertRectF = new RectangleF(rect.Left, rect.Top - 1, rect.Width - 2, rect.Height + 2); + var horzRectF = new RectangleF(rect.Left, rect.Top + 1, rect.Width, rect.Height - 2); cache.OutsideBrush = new LinearGradientBrush(vertRectF, Color.Transparent, _whiten128, 0f) { Blend = _ribbonOutBlend @@ -7876,7 +7876,7 @@ protected virtual void DrawRibbonTabTrackingBottom2007(Rectangle rect, MementoRibbonTabTracking2007 cache) { // Create path for a curved border around the tab - GraphicsPath outsidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); outsidePath.AddLine(rect.Left + 1, rect.Top + 1, rect.Left + 1, rect.Bottom - 2.5f); outsidePath.AddLine(rect.Left + 1, rect.Bottom - 2.5f, rect.Left + 3, rect.Bottom - 1); outsidePath.AddLine(rect.Left + 3, rect.Bottom - 1, rect.Right - 4, rect.Bottom - 1); @@ -7884,7 +7884,7 @@ protected virtual void DrawRibbonTabTrackingBottom2007(Rectangle rect, outsidePath.AddLine(rect.Right - 2, rect.Bottom - 2.5f, rect.Right - 2, rect.Top + 1); // Create path for the bottom hightlight line - GraphicsPath topPath = new GraphicsPath(); + var topPath = new GraphicsPath(); topPath.AddLine(rect.Left + 3, rect.Bottom - 3, rect.Left + 4, rect.Bottom - 2); topPath.AddLine(rect.Left + 4, rect.Bottom - 2, rect.Right - 5, rect.Bottom - 2); topPath.AddLine(rect.Right - 5, rect.Bottom - 2, rect.Right - 4, rect.Bottom - 3); @@ -7895,9 +7895,9 @@ protected virtual void DrawRibbonTabTrackingBottom2007(Rectangle rect, var half2 = full - half1; cache.Half1Rect = new Rectangle(rect.Left + 3, rect.Bottom - 2 - half1, rect.Width - 6, half1); cache.Half2Rect = new Rectangle(rect.Left + 3, rect.Bottom - 2 - half1 - half2, rect.Width - 6, half2); - Rectangle fullRect = new Rectangle(rect.Left + 3, rect.Bottom - 2 - half1 - half2, rect.Width - 6, + var fullRect = new Rectangle(rect.Left + 3, rect.Bottom - 2 - half1 - half2, rect.Width - 6, half1 + half2); - RectangleF half1RectF = new RectangleF(cache.Half1Rect.Left - 1, cache.Half1Rect.Top - 0.5f, + var half1RectF = new RectangleF(cache.Half1Rect.Left - 1, cache.Half1Rect.Top - 0.5f, cache.Half1Rect.Width + 2, cache.Half1Rect.Height + 1); cache.Half2RectF = new RectangleF(cache.Half2Rect.Left - 1, cache.Half2Rect.Top - 0.5f, cache.Half2Rect.Width + 2, cache.Half2Rect.Height + 1); @@ -7915,7 +7915,7 @@ protected virtual void DrawRibbonTabTrackingBottom2007(Rectangle rect, // Create ellipse information for lightening the bottom hald cache.EllipseRect = new RectangleF(fullRect.Left - (fullRect.Width / 8), fullRect.Top, fullRect.Width * 1.25f, fullRect.Height); - GraphicsPath ellipsePath = new GraphicsPath(); + var ellipsePath = new GraphicsPath(); // Cannot draw a path that contains a zero sized element if (cache.EllipseRect is { Width: > 0, Height: > 0 }) { @@ -7924,14 +7924,14 @@ protected virtual void DrawRibbonTabTrackingBottom2007(Rectangle rect, { CenterColor = Color.FromArgb(92, Color.White) }; - PointF centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), + var centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), cache.EllipseRect.Bottom - (cache.EllipseRect.Height / 2)); cache.EllipseBrush.CenterPoint = centerPoint; cache.EllipseBrush.SurroundColors = new[] { Color.Transparent }; } - RectangleF vertRectF = new RectangleF(rect.Left - 1, rect.Top, rect.Width + 2, rect.Height - 2); - RectangleF horzRectF = new RectangleF(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height); + var vertRectF = new RectangleF(rect.Left - 1, rect.Top, rect.Width + 2, rect.Height - 2); + var horzRectF = new RectangleF(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height); cache.OutsideBrush = new LinearGradientBrush(vertRectF, Color.Transparent, _whiten128, 270f) { Blend = _ribbonOutBlend @@ -8045,7 +8045,7 @@ protected virtual IDisposable DrawRibbonTabTracking2010(PaletteRibbonShape shape context.Graphics.FillPath(cache.OutsideBrush, cache.OutsidePath); // Draw the border - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { context.Graphics.DrawPath(cache.OutsidePen, cache.BorderPath); } @@ -8064,9 +8064,9 @@ protected virtual void DrawRibbonTabTrackingTop2010(Rectangle rect, Color c3, Color c4, MementoRibbonTabTracking2010 cache) { - GraphicsPath borderPath = new GraphicsPath(); - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var borderPath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create path for a border pen borderPath.AddLine(rect.Left, rect.Bottom - 2, rect.Left, rect.Top + 1.75f); @@ -8111,9 +8111,9 @@ protected virtual void DrawRibbonTabTrackingBottom2010(Rectangle rect, Color c3, Color c4, MementoRibbonTabTracking2010 cache) { - GraphicsPath borderPath = new GraphicsPath(); - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var borderPath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create path for a border pen borderPath.AddLine(rect.Left, rect.Top, rect.Left, rect.Bottom - 2.75f); @@ -8157,9 +8157,9 @@ protected virtual void DrawRibbonTabTrackingLeft2010(Rectangle rect, Color c3, Color c4, MementoRibbonTabTracking2010 cache) { - GraphicsPath borderPath = new GraphicsPath(); - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var borderPath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create path for a border pen borderPath.AddLine(rect.Right - 1, rect.Top, rect.Left + 1.75f, rect.Top); @@ -8204,9 +8204,9 @@ protected virtual void DrawRibbonTabTrackingRight2010(Rectangle rect, Color c3, Color c4, MementoRibbonTabTracking2010 cache) { - GraphicsPath borderPath = new GraphicsPath(); - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var borderPath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create path for a border pen borderPath.AddLine(rect.Left, rect.Top, rect.Right - 2.75f, rect.Top); @@ -8317,7 +8317,7 @@ protected virtual IDisposable DrawRibbonTabFocus2010(PaletteRibbonShape shape, context.Graphics.FillPath(cache.OutsideBrush, cache.OutsidePath); // Draw the border - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { context.Graphics.DrawPath(cache.OutsidePen, cache.BorderPath); } @@ -8336,9 +8336,9 @@ protected virtual void DrawRibbonTabFocusTop2010(Rectangle rect, Color c3, Color c4, MementoRibbonTabTracking2010 cache) { - GraphicsPath borderPath = new GraphicsPath(); - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var borderPath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create path for a border pen borderPath.AddLine(rect.Left, rect.Bottom - 1, rect.Left + 1, rect.Bottom - 2); @@ -8389,9 +8389,9 @@ protected virtual void DrawRibbonTabFocusBottom2010(Rectangle rect, Color c3, Color c4, MementoRibbonTabTracking2010 cache) { - GraphicsPath borderPath = new GraphicsPath(); - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var borderPath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create path for a border pen borderPath.AddLine(rect.Left, rect.Top, rect.Left + 1, rect.Top + 1); @@ -8441,9 +8441,9 @@ protected virtual void DrawRibbonTabFocusLeft2010(Rectangle rect, Color c3, Color c4, MementoRibbonTabTracking2010 cache) { - GraphicsPath borderPath = new GraphicsPath(); - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var borderPath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create path for a border pen borderPath.AddLine(rect.Right - 1, rect.Top - 1, rect.Right - 2, rect.Top); @@ -8492,9 +8492,9 @@ protected virtual void DrawRibbonTabFocusRight2010(Rectangle rect, Color c3, Color c4, MementoRibbonTabTracking2010 cache) { - GraphicsPath borderPath = new GraphicsPath(); - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var borderPath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create path for a border pen borderPath.AddLine(rect.Left, rect.Top - 1, rect.Left + 1, rect.Top); @@ -8608,7 +8608,7 @@ protected virtual IDisposable DrawRibbonTabGlowing(PaletteRibbonShape shape, } // Draw the border over the edge of the inside color - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { context.Graphics.DrawPath(cache.OutsidePen, cache.OutsidePath); } @@ -8633,9 +8633,9 @@ protected virtual void DrawRibbonTabGlowingTop(Rectangle rect, Color c1, Color c2, Color insideColor, MementoRibbonTabGlowing cache) { - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath topPath = new GraphicsPath(); - GraphicsPath ellipsePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var topPath = new GraphicsPath(); + var ellipsePath = new GraphicsPath(); // Create path for a curved border around the tab outsidePath.AddLine(rect.Left, rect.Bottom - 2, rect.Left, rect.Top + 1.5f); @@ -8654,7 +8654,7 @@ protected virtual void DrawRibbonTabGlowingTop(Rectangle rect, topPath.AddLine(rect.Right - 2, rect.Top + 2 + q4, rect.Right - 2, rect.Top + 2); topPath.AddLine(rect.Right - 2, rect.Top + 2, rect.Right - 3, rect.Top + 1); - RectangleF topRectF = new RectangleF(rect.Left, rect.Top, rect.Width, q4 + 5); + var topRectF = new RectangleF(rect.Left, rect.Top, rect.Width, q4 + 5); cache.TopBrush = new LinearGradientBrush(topRectF, c1, Color.Transparent, 90f); var ellipseWidth = (int)(rect.Width * 1.2f); @@ -8670,7 +8670,7 @@ protected virtual void DrawRibbonTabGlowingTop(Rectangle rect, { CenterColor = c2 }; - PointF centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), + var centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), cache.EllipseRect.Top + (cache.EllipseRect.Height / 2)); cache.EllipseBrush.CenterPoint = centerPoint; cache.EllipseBrush.SurroundColors = new[] { Color.Transparent }; @@ -8691,9 +8691,9 @@ protected virtual void DrawRibbonTabGlowingLeft(Rectangle rect, Color c1, Color c2, Color insideColor, MementoRibbonTabGlowing cache) { - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath topPath = new GraphicsPath(); - GraphicsPath ellipsePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var topPath = new GraphicsPath(); + var ellipsePath = new GraphicsPath(); // Create path for a curved border around the tab outsidePath.AddLine(rect.Right - 2, rect.Bottom - 1, rect.Left + 1.5f, rect.Bottom - 1); @@ -8712,7 +8712,7 @@ protected virtual void DrawRibbonTabGlowingLeft(Rectangle rect, topPath.AddLine(rect.Left + 2 + q4, rect.Top + 1, rect.Left + 2, rect.Top + 2); topPath.AddLine(rect.Left + 2, rect.Top + 2, rect.Left + 1, rect.Top + 2); - RectangleF topRectF = new RectangleF(rect.Left, rect.Top, q4 + 5, rect.Height); + var topRectF = new RectangleF(rect.Left, rect.Top, q4 + 5, rect.Height); cache.TopBrush = new LinearGradientBrush(topRectF, c1, Color.Transparent, 0f); var ellipseWidth = (int)(rect.Width * 0.4f); @@ -8728,7 +8728,7 @@ protected virtual void DrawRibbonTabGlowingLeft(Rectangle rect, { CenterColor = c2 }; - PointF centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), + var centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), cache.EllipseRect.Top + (cache.EllipseRect.Height / 2)); cache.EllipseBrush.CenterPoint = centerPoint; cache.EllipseBrush.SurroundColors = new[] { Color.Transparent }; @@ -8749,9 +8749,9 @@ protected virtual void DrawRibbonTabGlowingRight(Rectangle rect, Color c1, Color c2, Color insideColor, MementoRibbonTabGlowing cache) { - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath topPath = new GraphicsPath(); - GraphicsPath ellipsePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var topPath = new GraphicsPath(); + var ellipsePath = new GraphicsPath(); // Create path for a curved border around the tab outsidePath.AddLine(rect.Left + 1, rect.Bottom - 1, rect.Right - 2.5f, rect.Bottom - 1); @@ -8770,7 +8770,7 @@ protected virtual void DrawRibbonTabGlowingRight(Rectangle rect, topPath.AddLine(rect.Right - 2 - q4, rect.Top + 1, rect.Right - 2, rect.Top + 2); topPath.AddLine(rect.Right - 2, rect.Top + 2, rect.Right - 1, rect.Top + 2); - RectangleF topRectF = new RectangleF(rect.Right - q4 - 5, rect.Top, q4 + 5, rect.Height); + var topRectF = new RectangleF(rect.Right - q4 - 5, rect.Top, q4 + 5, rect.Height); cache.TopBrush = new LinearGradientBrush(topRectF, c1, Color.Transparent, 180f); var ellipseWidth = (int)(rect.Width * 0.4f); @@ -8786,7 +8786,7 @@ protected virtual void DrawRibbonTabGlowingRight(Rectangle rect, { CenterColor = c2 }; - PointF centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), + var centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), cache.EllipseRect.Top + (cache.EllipseRect.Height / 2)); cache.EllipseBrush.CenterPoint = centerPoint; cache.EllipseBrush.SurroundColors = new[] { Color.Transparent }; @@ -8807,9 +8807,9 @@ protected virtual void DrawRibbonTabGlowingBottom(Rectangle rect, Color c1, Color c2, Color insideColor, MementoRibbonTabGlowing cache) { - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath topPath = new GraphicsPath(); - GraphicsPath ellipsePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var topPath = new GraphicsPath(); + var ellipsePath = new GraphicsPath(); // Create path for a curved border around the tab outsidePath.AddLine(rect.Left, rect.Top + 1, rect.Left, rect.Bottom - 2.5f); @@ -8828,7 +8828,7 @@ protected virtual void DrawRibbonTabGlowingBottom(Rectangle rect, topPath.AddLine(rect.Right - 2, rect.Bottom - 2 - q4, rect.Right - 2, rect.Bottom - 2); topPath.AddLine(rect.Right - 2, rect.Bottom - 2, rect.Right - 3, rect.Bottom - 1); - RectangleF topRectF = new RectangleF(rect.Left, rect.Bottom - 6 - q4, rect.Width, q4 + 5); + var topRectF = new RectangleF(rect.Left, rect.Bottom - 6 - q4, rect.Width, q4 + 5); cache.TopBrush = new LinearGradientBrush(topRectF, c1, Color.Transparent, 270f); var ellipseWidth = (int)(rect.Width * 1.2f); @@ -8844,7 +8844,7 @@ protected virtual void DrawRibbonTabGlowingBottom(Rectangle rect, { CenterColor = c2 }; - PointF centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), + var centerPoint = new PointF(cache.EllipseRect.Left + (cache.EllipseRect.Width / 2), cache.EllipseRect.Bottom - 1 - (cache.EllipseRect.Height / 2)); cache.EllipseBrush.CenterPoint = centerPoint; cache.EllipseBrush.SurroundColors = new[] { Color.Transparent }; @@ -8926,7 +8926,7 @@ protected virtual IDisposable DrawRibbonTabSelected2007(RenderContext context, context.Graphics.FillPath(cache.InsideBrush, cache.OutsidePath); // Draw the actual border - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { context.Graphics.DrawPath(cache.OutsidePen, cache.OutsidePath); } @@ -8961,7 +8961,7 @@ protected virtual void DrawRibbonTabSelectedTop2007(Rectangle rect, Color c4, Color c5, MementoRibbonTabSelected2007 cache) { - GraphicsPath outsidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Left, rect.Bottom - 2, rect.Left + 1, rect.Bottom - 3); @@ -8973,7 +8973,7 @@ protected virtual void DrawRibbonTabSelectedTop2007(Rectangle rect, outsidePath.AddLine(rect.Right - 2, rect.Bottom - 3, rect.Right - 1, rect.Bottom - 2); cache.CenterRect = new Rectangle(rect.Left + 4, rect.Top + 4, rect.Width - 8, rect.Height - 4); - RectangleF centerRectF = new RectangleF(cache.CenterRect.Left - 1, cache.CenterRect.Top - 1, + var centerRectF = new RectangleF(cache.CenterRect.Left - 1, cache.CenterRect.Top - 1, cache.CenterRect.Width + 2, cache.CenterRect.Height + 2); cache.CenterBrush = new LinearGradientBrush(centerRectF, c4, c5, 90f); cache.OutsidePath = outsidePath; @@ -8991,7 +8991,7 @@ protected virtual void DrawRibbonTabSelectedTopDraw2007(Rectangle rect, g.DrawLine(cache.InsidePen, rect.Left + 2, rect.Bottom - 2, rect.Right - 3, rect.Bottom - 2); g.DrawLine(cache.CenterPen, rect.Left + 3, rect.Bottom - 1, rect.Right - 4, rect.Bottom - 1); - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); // Draw a line on the inside of the left and right border edges g.DrawLine(cache.MiddlePen, rect.Left + 0.5f, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 3); g.DrawLine(cache.MiddlePen, rect.Left + 2, rect.Bottom - 3, rect.Left + 2, rect.Top + 2); @@ -9012,7 +9012,7 @@ protected virtual void DrawRibbonTabSelectedLeft2007(Rectangle rect, Color c4, Color c5, MementoRibbonTabSelected2007 cache) { - GraphicsPath outsidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Right - 2, rect.Bottom - 1, rect.Right - 3, rect.Bottom - 2); @@ -9024,7 +9024,7 @@ protected virtual void DrawRibbonTabSelectedLeft2007(Rectangle rect, outsidePath.AddLine(rect.Right - 3, rect.Top + 1, rect.Right - 1, rect.Top); cache.CenterRect = new Rectangle(rect.Left + 4, rect.Top + 4, rect.Width - 4, rect.Height - 8); - RectangleF centerRectF = new RectangleF(cache.CenterRect.Left - 1, cache.CenterRect.Top - 1, + var centerRectF = new RectangleF(cache.CenterRect.Left - 1, cache.CenterRect.Top - 1, cache.CenterRect.Width + 2, cache.CenterRect.Height + 2); cache.CenterBrush = new LinearGradientBrush(centerRectF, c4, c5, 0f); cache.OutsidePath = outsidePath; @@ -9042,7 +9042,7 @@ protected virtual void DrawRibbonTabSelectedLeftDraw2007(Rectangle rect, g.DrawLine(cache.InsidePen, rect.Right - 2, rect.Bottom - 3, rect.Right - 2, rect.Top + 2); g.DrawLine(cache.CenterPen, rect.Right - 1, rect.Bottom - 4, rect.Right - 1, rect.Top + 3); - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); // Draw a line on the inside of the left and right border edges g.DrawLine(cache.MiddlePen, rect.Right - 1, rect.Bottom - 1.5f, rect.Right - 3, rect.Bottom - 3); g.DrawLine(cache.MiddlePen, rect.Right - 3, rect.Bottom - 3, rect.Left + 2, rect.Bottom - 3); @@ -9063,7 +9063,7 @@ protected virtual void DrawRibbonTabSelectedRight2007(Rectangle rect, Color c4, Color c5, MementoRibbonTabSelected2007 cache) { - GraphicsPath outsidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Left + 1, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 2); @@ -9075,7 +9075,7 @@ protected virtual void DrawRibbonTabSelectedRight2007(Rectangle rect, outsidePath.AddLine(rect.Left + 2, rect.Top + 1, rect.Left, rect.Top); cache.CenterRect = new Rectangle(rect.Left, rect.Top + 4, rect.Width - 4, rect.Height - 8); - RectangleF centerRectF = new RectangleF(cache.CenterRect.Left - 1, cache.CenterRect.Top - 1, + var centerRectF = new RectangleF(cache.CenterRect.Left - 1, cache.CenterRect.Top - 1, cache.CenterRect.Width + 2, cache.CenterRect.Height + 2); cache.CenterBrush = new LinearGradientBrush(centerRectF, c4, c5, 180f); cache.OutsidePath = outsidePath; @@ -9093,7 +9093,7 @@ protected virtual void DrawRibbonTabSelectedRightDraw2007(Rectangle rect, g.DrawLine(cache.InsidePen, rect.Left + 1, rect.Bottom - 3, rect.Left + 1, rect.Top + 2); g.DrawLine(cache.CenterPen, rect.Left, rect.Bottom - 4, rect.Left, rect.Top + 3); - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); // Draw a line on the inside of the left and right border edges g.DrawLine(cache.MiddlePen, rect.Left, rect.Bottom - 1.5f, rect.Left + 2, rect.Bottom - 3); g.DrawLine(cache.MiddlePen, rect.Left + 2, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 3); @@ -9114,7 +9114,7 @@ protected virtual void DrawRibbonTabSelectedBottom2007(Rectangle rect, Color c4, Color c5, MementoRibbonTabSelected2007 cache) { - GraphicsPath outsidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Left, rect.Top + 1, rect.Left + 1, rect.Top + 2); @@ -9126,7 +9126,7 @@ protected virtual void DrawRibbonTabSelectedBottom2007(Rectangle rect, outsidePath.AddLine(rect.Right - 2, rect.Top + 2, rect.Right - 1, rect.Top + 1); cache.CenterRect = new Rectangle(rect.Left + 4, rect.Top, rect.Width - 8, rect.Height - 4); - RectangleF centerRectF = new RectangleF(cache.CenterRect.Left - 1, cache.CenterRect.Top - 1, + var centerRectF = new RectangleF(cache.CenterRect.Left - 1, cache.CenterRect.Top - 1, cache.CenterRect.Width + 2, cache.CenterRect.Height + 2); cache.CenterBrush = new LinearGradientBrush(centerRectF, c4, c5, 270f); cache.OutsidePath = outsidePath; @@ -9144,7 +9144,7 @@ protected virtual void DrawRibbonTabSelectedBottomDraw2007(Rectangle rect, g.DrawLine(cache.InsidePen, rect.Left + 2, rect.Top + 1, rect.Right - 3, rect.Top + 1); g.DrawLine(cache.CenterPen, rect.Left + 3, rect.Top, rect.Right - 4, rect.Top); - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); // Draw a line on the inside of the left and right border edges g.DrawLine(cache.MiddlePen, rect.Left + 0.5f, rect.Top, rect.Left + 2, rect.Top + 2); g.DrawLine(cache.MiddlePen, rect.Left + 2, rect.Top + 2, rect.Left + 2, rect.Bottom - 3); @@ -9238,7 +9238,7 @@ protected virtual IDisposable DrawRibbonTabSelected2010(RenderContext context, context.Graphics.FillPath(cache.InsideBrush, cache.InsidePath); } - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { context.Graphics.DrawPath(cache.OutsidePen, cache.OutsidePath); } @@ -9270,8 +9270,8 @@ protected virtual void DrawRibbonTabSelectedTop2010(Rectangle rect, Color c2, Color c3, Color c5, MementoRibbonTabSelected2010 cache) { - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Left, rect.Bottom - 2, rect.Left + 1, rect.Bottom - 3); @@ -9282,7 +9282,7 @@ protected virtual void DrawRibbonTabSelectedTop2010(Rectangle rect, outsidePath.AddLine(rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 3); outsidePath.AddLine(rect.Right - 2, rect.Bottom - 3, rect.Right - 1, rect.Bottom - 2); - RectangleF centerRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); + var centerRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); cache.CenterBrush = new LinearGradientBrush(centerRectF, c2, c3, 90f) { Blend = _ribbonTabSelected1Blend @@ -9304,7 +9304,7 @@ protected virtual void DrawRibbonTabSelectedTop2010(Rectangle rect, insidePath.AddLine(rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 3); insidePath.AddLine(rect.Right - 2, rect.Bottom - 3, rect.Right - 1, rect.Bottom - 2); - RectangleF insideRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); + var insideRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); cache.InsideBrush = new LinearGradientBrush(insideRectF, Color.FromArgb(32, c5), Color.Transparent, 90f) { Blend = _ribbonTabSelected2Blend @@ -9323,7 +9323,7 @@ protected virtual void DrawRibbonTabSelectedTopDraw2010(Rectangle rect, g.DrawLine(cache.CenterPen, rect.Left + 2, rect.Bottom - 2, rect.Right - 3, rect.Bottom - 2); g.DrawLine(cache.CenterPen, rect.Left + 1, rect.Bottom - 1, rect.Right - 2, rect.Bottom - 1); - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); // Draw shadow lines on the outside of the left and right edges g.DrawLine(_mediumShadowPen, rect.Left, rect.Bottom - 3, rect.Left, rect.Top + 2); g.DrawLine(_mediumShadowPen, rect.Right - 1, rect.Bottom - 3, rect.Right - 1, rect.Top + 2); @@ -9336,8 +9336,8 @@ protected virtual void DrawRibbonTabSelectedLeft2010(Rectangle rect, Color c2, Color c3, Color c5, MementoRibbonTabSelected2010 cache) { - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Right - 2, rect.Bottom - 1, rect.Right - 2, rect.Bottom - 2); @@ -9348,7 +9348,7 @@ protected virtual void DrawRibbonTabSelectedLeft2010(Rectangle rect, outsidePath.AddLine(rect.Left + 1, rect.Top + 1, rect.Right - 2, rect.Top + 1); outsidePath.AddLine(rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Top); - RectangleF centerRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); + var centerRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); cache.CenterBrush = new LinearGradientBrush(centerRectF, c2, c3, 0f) { Blend = _ribbonTabSelected1Blend @@ -9370,7 +9370,7 @@ protected virtual void DrawRibbonTabSelectedLeft2010(Rectangle rect, insidePath.AddLine(rect.Left + 1, rect.Top + 1, rect.Right - 2, rect.Top + 1); insidePath.AddLine(rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Top); - RectangleF insideRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); + var insideRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); cache.InsideBrush = new LinearGradientBrush(insideRectF, Color.FromArgb(32, c5), Color.Transparent, 0f) { Blend = _ribbonTabSelected2Blend @@ -9389,7 +9389,7 @@ protected virtual void DrawRibbonTabSelectedLeftDraw2010(Rectangle rect, g.DrawLine(cache.CenterPen, rect.Right - 2, rect.Bottom - 3, rect.Right - 2, rect.Top + 2); g.DrawLine(cache.CenterPen, rect.Right - 1, rect.Bottom - 2, rect.Right - 1, rect.Top + 1); - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); // Draw shadow lines on the outside of the top and bottom edges g.DrawLine(_mediumShadowPen, rect.Right - 3, rect.Bottom - 1, rect.Left + 3, rect.Bottom - 1); g.DrawLine(_mediumShadowPen, rect.Right - 3, rect.Top, rect.Left + 3, rect.Top); @@ -9402,8 +9402,8 @@ protected virtual void DrawRibbonTabSelectedRight2010(Rectangle rect, Color c2, Color c3, Color c5, MementoRibbonTabSelected2010 cache) { - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Left + 1, rect.Bottom - 1, rect.Left + 1, rect.Bottom - 2); @@ -9414,7 +9414,7 @@ protected virtual void DrawRibbonTabSelectedRight2010(Rectangle rect, outsidePath.AddLine(rect.Right - 2, rect.Top + 1, rect.Left + 1, rect.Top + 1); outsidePath.AddLine(rect.Left + 1, rect.Top + 1, rect.Left + 1, rect.Top); - RectangleF centerRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); + var centerRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); cache.CenterBrush = new LinearGradientBrush(centerRectF, c2, c3, 180f) { Blend = _ribbonTabSelected1Blend @@ -9435,7 +9435,7 @@ protected virtual void DrawRibbonTabSelectedRight2010(Rectangle rect, insidePath.AddLine(rect.Right - 2, rect.Top + 1, rect.Left + 1, rect.Top + 1); insidePath.AddLine(rect.Left + 1, rect.Top + 1, rect.Left + 1, rect.Top); - RectangleF insideRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); + var insideRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); cache.InsideBrush = new LinearGradientBrush(insideRectF, Color.FromArgb(32, c5), Color.Transparent, 180f) { Blend = _ribbonTabSelected2Blend @@ -9455,7 +9455,7 @@ protected virtual void DrawRibbonTabSelectedRightDraw2010(Rectangle rect, g.DrawLine(cache.CenterPen, rect.Left + 1, rect.Bottom - 3, rect.Left + 1, rect.Top + 2); g.DrawLine(cache.CenterPen, rect.Left, rect.Bottom - 2, rect.Left, rect.Top + 1); - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); // Draw shadow lines on the outside of the top and bottom edges g.DrawLine(_mediumShadowPen, rect.Left + 2, rect.Bottom - 1, rect.Right - 4, rect.Bottom - 1); g.DrawLine(_mediumShadowPen, rect.Left + 2, rect.Top, rect.Right - 4, rect.Top); @@ -9468,8 +9468,8 @@ protected virtual void DrawRibbonTabSelectedBottom2010(Rectangle rect, Color c2, Color c3, Color c5, MementoRibbonTabSelected2010 cache) { - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Left, rect.Top + 1, rect.Left + 1, rect.Top + 1); @@ -9480,7 +9480,7 @@ protected virtual void DrawRibbonTabSelectedBottom2010(Rectangle rect, outsidePath.AddLine(rect.Right - 2, rect.Bottom - 3, rect.Right - 2, rect.Top + 1); outsidePath.AddLine(rect.Right - 2, rect.Top + 1, rect.Right - 1, rect.Top + 1); - RectangleF centerRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); + var centerRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); cache.CenterBrush = new LinearGradientBrush(centerRectF, c2, c3, 270f) { Blend = _ribbonTabSelected1Blend @@ -9501,7 +9501,7 @@ protected virtual void DrawRibbonTabSelectedBottom2010(Rectangle rect, insidePath.AddLine(rect.Right - 2, rect.Bottom - 3, rect.Right - 2, rect.Top + 1); insidePath.AddLine(rect.Right - 2, rect.Top + 1, rect.Right - 1, rect.Top + 1); - RectangleF insideRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); + var insideRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); cache.InsideBrush = new LinearGradientBrush(insideRectF, Color.FromArgb(32, c5), Color.Transparent, 270f) { Blend = _ribbonTabSelected2Blend @@ -9520,7 +9520,7 @@ protected virtual void DrawRibbonTabSelectedBottomDraw2010(Rectangle rect, g.DrawLine(cache.CenterPen, rect.Left + 2, rect.Top + 1, rect.Right - 3, rect.Top + 1); g.DrawLine(cache.CenterPen, rect.Left + 1, rect.Top, rect.Right - 2, rect.Top); - using AntiAlias aa = new AntiAlias(g); + using var aa = new AntiAlias(g); // Draw shadow lines on the outside of the left and right edges g.DrawLine(_mediumShadowPen, rect.Left, rect.Top + 2, rect.Left, rect.Bottom - 4); g.DrawLine(_mediumShadowPen, rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 4); @@ -9594,7 +9594,7 @@ protected virtual IDisposable DrawRibbonTabContextSelected(PaletteRibbonShape sh context.Graphics.FillRectangle(cache.InsideBrush, cache.InteriorRect); // Draw the actual border - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { context.Graphics.DrawPath(cache.OutsidePen, cache.OutsidePath); } @@ -9626,7 +9626,7 @@ protected virtual void DrawRibbonTabContextSelectedTop(Rectangle rect, Color c2, MementoRibbonTabContextSelected cache) { - GraphicsPath outsidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Left, rect.Bottom - 2, rect.Left + 1, rect.Bottom - 3); @@ -9637,9 +9637,9 @@ protected virtual void DrawRibbonTabContextSelectedTop(Rectangle rect, outsidePath.AddLine(rect.Right - 2, rect.Top + 1.5f, rect.Right - 2, rect.Bottom - 3); outsidePath.AddLine(rect.Right - 2, rect.Bottom - 3, rect.Right - 1, rect.Bottom - 2); - LinearGradientBrush leftBrush = + var leftBrush = new LinearGradientBrush(rect, Color.FromArgb(125, c2), Color.FromArgb(67, c2), 90f); - LinearGradientBrush rightBrush = + var rightBrush = new LinearGradientBrush(rect, Color.FromArgb(16, c2), Color.FromArgb(67, c2), 90f); cache.LeftPen = new Pen(leftBrush); cache.RightPen = new Pen(rightBrush); @@ -9683,7 +9683,7 @@ protected virtual void DrawRibbonTabContextSelectedLeft(Rectangle rect, Color c2, MementoRibbonTabContextSelected cache) { - GraphicsPath outsidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Right - 2, rect.Bottom - 1, rect.Right - 3, rect.Bottom - 2); @@ -9694,9 +9694,9 @@ protected virtual void DrawRibbonTabContextSelectedLeft(Rectangle rect, outsidePath.AddLine(rect.Left + 1.5f, rect.Top + 1, rect.Right - 3, rect.Top + 1); outsidePath.AddLine(rect.Right - 3, rect.Top + 1, rect.Right - 2, rect.Top); - LinearGradientBrush leftBrush = + var leftBrush = new LinearGradientBrush(rect, Color.FromArgb(125, c2), Color.FromArgb(67, c2), 0f); - LinearGradientBrush rightBrush = + var rightBrush = new LinearGradientBrush(rect, Color.FromArgb(16, c2), Color.FromArgb(67, c2), 0f); cache.LeftPen = new Pen(leftBrush); cache.RightPen = new Pen(rightBrush); @@ -9740,7 +9740,7 @@ protected virtual void DrawRibbonTabContextSelectedRight(Rectangle rect, Color c2, MementoRibbonTabContextSelected cache) { - GraphicsPath outsidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Left + 1, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 2); @@ -9751,9 +9751,9 @@ protected virtual void DrawRibbonTabContextSelectedRight(Rectangle rect, outsidePath.AddLine(rect.Right - 2.5f, rect.Top + 1, rect.Left + 2, rect.Top + 1); outsidePath.AddLine(rect.Left + 2, rect.Top + 1, rect.Left + 1, rect.Top); - LinearGradientBrush leftBrush = + var leftBrush = new LinearGradientBrush(rect, Color.FromArgb(125, c2), Color.FromArgb(67, c2), 180f); - LinearGradientBrush rightBrush = + var rightBrush = new LinearGradientBrush(rect, Color.FromArgb(16, c2), Color.FromArgb(67, c2), 180f); cache.LeftPen = new Pen(leftBrush); cache.RightPen = new Pen(rightBrush); @@ -9797,7 +9797,7 @@ protected virtual void DrawRibbonTabContextSelectedBottom(Rectangle rect, Color c2, MementoRibbonTabContextSelected cache) { - GraphicsPath outsidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Left, rect.Top + 1, rect.Left + 1, rect.Top + 2); @@ -9808,9 +9808,9 @@ protected virtual void DrawRibbonTabContextSelectedBottom(Rectangle rect, outsidePath.AddLine(rect.Right - 2, rect.Bottom - 2.5f, rect.Right - 2, rect.Top + 2); outsidePath.AddLine(rect.Right - 2, rect.Top + 2, rect.Right - 1, rect.Top + 1); - LinearGradientBrush leftBrush = + var leftBrush = new LinearGradientBrush(rect, Color.FromArgb(125, c2), Color.FromArgb(67, c2), 270f); - LinearGradientBrush rightBrush = + var rightBrush = new LinearGradientBrush(rect, Color.FromArgb(16, c2), Color.FromArgb(67, c2), 270f); cache.LeftPen = new Pen(leftBrush); cache.RightPen = new Pen(rightBrush); @@ -9941,8 +9941,8 @@ protected virtual void DrawRibbonTabHighlightTop(Rectangle rect, Color c4, Color c5, MementoRibbonTabHighlight cache) { - RectangleF hF = new RectangleF(rect.Left - 2, rect.Top - 1, rect.Width + 4, 6); - RectangleF vF = new RectangleF(rect.Left - 2, rect.Top + 1, rect.Width + 4, rect.Height - 1); + var hF = new RectangleF(rect.Left - 2, rect.Top - 1, rect.Width + 4, 6); + var vF = new RectangleF(rect.Left - 2, rect.Top + 1, rect.Width + 4, rect.Height - 1); cache.TopBorderBrush = new LinearGradientBrush(hF, Color.FromArgb(48, c5), Color.FromArgb(64, c5), 90f); cache.BorderVertBrush = new LinearGradientBrush(vF, c5, c4, 90f); cache.OutsideVertBrush = new LinearGradientBrush(vF, Color.FromArgb(48, c5), c5, 90f); @@ -9990,8 +9990,8 @@ protected virtual void DrawRibbonTabHighlightLeft(Rectangle rect, Color c4, Color c5, MementoRibbonTabHighlight cache) { - RectangleF hF = new RectangleF(rect.Left - 1, rect.Top - 2, 6, rect.Height - 4); - RectangleF vF = new RectangleF(rect.Left + 1, rect.Top - 2, rect.Width - 1, rect.Height - 4); + var hF = new RectangleF(rect.Left - 1, rect.Top - 2, 6, rect.Height - 4); + var vF = new RectangleF(rect.Left + 1, rect.Top - 2, rect.Width - 1, rect.Height - 4); cache.TopBorderBrush = new LinearGradientBrush(hF, Color.FromArgb(48, c5), Color.FromArgb(64, c5), 0f); cache.BorderVertBrush = new LinearGradientBrush(vF, c5, c4, 0f); cache.OutsideVertBrush = new LinearGradientBrush(vF, Color.FromArgb(48, c5), c5, 0f); @@ -10039,8 +10039,8 @@ protected virtual void DrawRibbonTabHighlightRight(Rectangle rect, Color c4, Color c5, MementoRibbonTabHighlight cache) { - RectangleF hF = new RectangleF(rect.Right - 6, rect.Top - 2, 6, rect.Height - 4); - RectangleF vF = new RectangleF(rect.Left, rect.Top - 2, rect.Width - 1, rect.Height - 4); + var hF = new RectangleF(rect.Right - 6, rect.Top - 2, 6, rect.Height - 4); + var vF = new RectangleF(rect.Left, rect.Top - 2, rect.Width - 1, rect.Height - 4); cache.TopBorderBrush = new LinearGradientBrush(hF, Color.FromArgb(48, c5), Color.FromArgb(64, c5), 180f); cache.BorderVertBrush = new LinearGradientBrush(vF, c5, c4, 180f); cache.OutsideVertBrush = new LinearGradientBrush(vF, Color.FromArgb(48, c5), c5, 180f); @@ -10088,8 +10088,8 @@ protected virtual void DrawRibbonTabHighlightBottom(Rectangle rect, Color c4, Color c5, MementoRibbonTabHighlight cache) { - RectangleF hF = new RectangleF(rect.Left - 2, rect.Bottom - 6, rect.Width + 4, 6); - RectangleF vF = new RectangleF(rect.Left - 2, rect.Top, rect.Width + 4, rect.Height - 1); + var hF = new RectangleF(rect.Left - 2, rect.Bottom - 6, rect.Width + 4, 6); + var vF = new RectangleF(rect.Left - 2, rect.Top, rect.Width + 4, rect.Height - 1); cache.TopBorderBrush = new LinearGradientBrush(hF, Color.FromArgb(48, c5), Color.FromArgb(64, c5), 270f); cache.BorderVertBrush = new LinearGradientBrush(vF, c5, c4, 270f); cache.OutsideVertBrush = new LinearGradientBrush(vF, Color.FromArgb(48, c5), c5, 270f); @@ -10167,16 +10167,16 @@ protected virtual IDisposable DrawRibbonTabContext(RenderContext context, // Dispose of existing values cache.Dispose(); - Rectangle borderRect = new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); + var borderRect = new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); cache.FillRect = new Rectangle(rect.X + 1, rect.Y, rect.Width - 2, rect.Height - 1); - LinearGradientBrush borderBrush = new LinearGradientBrush(borderRect, c1, Color.Transparent, 270f) + var borderBrush = new LinearGradientBrush(borderRect, c1, Color.Transparent, 270f) { Blend = _ribbonGroup5Blend }; cache.BorderPen = new Pen(borderBrush); - LinearGradientBrush underlineBrush = + var underlineBrush = new LinearGradientBrush(borderRect, Color.Transparent, Color.FromArgb(200, c2), 0f) { Blend = _ribbonGroup7Blend @@ -10273,7 +10273,7 @@ protected virtual IDisposable DrawRibbonAppButton(PaletteRibbonShape shape, cache.BrushLower = new LinearGradientBrush(cache.RectLower, Color.Transparent, Color.Transparent, LinearGradientMode.Horizontal); } - using AntiAlias aa = new AntiAlias(context.Graphics); + using var aa = new AntiAlias(context.Graphics); DrawRibbonAppButtonBorder1(context.Graphics, cache); DrawRibbonAppButtonUpperHalf(context.Graphics, cache, state, topDark, bottomDark, topLight, topMedium, trackBorderAsPressed); DrawRibbonAppButtonLowerHalf(context.Graphics, cache, state, bottomDark, bottomLight, bottomMedium); @@ -10322,7 +10322,7 @@ protected virtual void DrawRibbonAppButtonUpperHalf(Graphics? g, Color[] colorsUpperHalf = { topDark, topMedium, topLight, topLight, topMedium, topDark }; float[] posUpperHalf = { 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f }; - ColorBlend blendUpperHalf = new ColorBlend + var blendUpperHalf = new ColorBlend { Colors = colorsUpperHalf, Positions = posUpperHalf @@ -10347,7 +10347,7 @@ protected virtual void DrawRibbonAppButtonUpperHalf(Graphics? g, c2 = topDark; } - using LinearGradientBrush brushUpper2 = + using var brushUpper2 = new LinearGradientBrush(memento.Rect, c1, c2, LinearGradientMode.Vertical); g.FillPie(brushUpper2, memento.Rect.X, memento.Rect.Y, memento.Rect.Width, memento.Rect.Height, 180, 180); } @@ -10368,7 +10368,7 @@ protected virtual void DrawRibbonAppButtonLowerHalf(Graphics? g, ? new[] { 0.0f, 0.3f, 0.5f, 0.5f, 0.7f, 1.0f } : new[] { 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f }; - ColorBlend blendLowerHalf = new ColorBlend + var blendLowerHalf = new ColorBlend { Colors = colorsLowerHalf, Positions = posLowerHalf @@ -10387,7 +10387,7 @@ protected virtual void DrawRibbonAppButtonGlowCenter(Graphics? g, Color topLight, Color bottomLight) { - using LinearGradientBrush brushBottomGlow = new LinearGradientBrush(memento.RectBottomGlow, + using var brushBottomGlow = new LinearGradientBrush(memento.RectBottomGlow, Color.FromArgb(50, Color.White), Color.FromArgb(30, Color.White), LinearGradientMode.Vertical); RectangleF rectBottomGlow = memento.RectBottomGlow; rectBottomGlow.X = memento.Rect.X + ((memento.Rect.Width - rectBottomGlow.Width) / 2); @@ -10405,9 +10405,9 @@ protected virtual void DrawRibbonAppButtonGlowCenter(Graphics? g, rectBottomGlow.X = memento.Rect.X + ((memento.Rect.Width - rectBottomGlow.Width) / 2); rectBottomGlow.Y = memento.Rect.Y + (memento.Rect.Height - rectBottomGlow.Height); - using GraphicsPath path = new GraphicsPath(); + using var path = new GraphicsPath(); path.AddEllipse(rectBottomGlow); - using PathGradientBrush pathGradient = new PathGradientBrush(path); + using var pathGradient = new PathGradientBrush(path); pathGradient.CenterColor = topLight; pathGradient.SurroundColors = new[] { Color.FromArgb(100, bottomLight) }; g.FillEllipse(pathGradient, rectBottomGlow); @@ -10433,7 +10433,7 @@ protected virtual void DrawRibbonAppButtonGlowUpperBottom(Graphics? g, mediumTransparency = 200; } - using LinearGradientBrush brushUpperGlow = new LinearGradientBrush(memento.RectUpperGlow, Color.Transparent, + using var brushUpperGlow = new LinearGradientBrush(memento.RectUpperGlow, Color.Transparent, Color.Transparent, LinearGradientMode.Horizontal); Color[] colorsUpperGlow = { Color.FromArgb(180, bottomDark), Color.FromArgb(mediumTransparency, bottomMedium), @@ -10444,7 +10444,7 @@ protected virtual void DrawRibbonAppButtonGlowUpperBottom(Graphics? g, float[] posUpperGlow = { 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f }; - ColorBlend blendUpperGlow = new ColorBlend + var blendUpperGlow = new ColorBlend { Colors = colorsUpperGlow, Positions = posUpperGlow @@ -10487,12 +10487,12 @@ protected virtual void DrawRibbonAppButtonBorder2(Graphics? g, borderGlowColor = _whiten120; } - using (Pen p = new Pen(borderGlowColor)) + using (var p = new Pen(borderGlowColor)) { g.DrawEllipse(p, memento.BorderMain1); } - using (Pen p = new Pen(Color.FromArgb(100, 52, 59, 64))) + using (var p = new Pen(Color.FromArgb(100, 52, 59, 64))) { g.DrawEllipse(p, memento.Rect); } @@ -10500,12 +10500,12 @@ protected virtual void DrawRibbonAppButtonBorder2(Graphics? g, if (pressed) { borderGlowColor = _whiten60; - using Pen p = new Pen(borderGlowColor); + using var p = new Pen(borderGlowColor); g.DrawEllipse(p, memento.BorderMain3); } borderGlowColor = pressed ? _whiten50 : _whiten80; - using (Pen p = new Pen(borderGlowColor)) + using (var p = new Pen(borderGlowColor)) { g.DrawArc(p, memento.BorderMain2, 180, 180); } @@ -10513,13 +10513,13 @@ protected virtual void DrawRibbonAppButtonBorder2(Graphics? g, if (!pressed) { borderGlowColor = _whiten30; - using Pen p = new Pen(borderGlowColor); + using var p = new Pen(borderGlowColor); g.DrawArc(p, memento.BorderMain4, 180, 180); } if (tracking && !pressed) { - using Pen p = new Pen(Color.FromArgb(100, borderGlowColor)); + using var p = new Pen(Color.FromArgb(100, borderGlowColor)); g.DrawEllipse(p, memento.Rect); } } @@ -10614,7 +10614,7 @@ protected virtual IDisposable DrawRibbonAppTab(PaletteRibbonShape shape, context.Graphics.FillPath(cache.BorderBrush, cache.BorderFillPath); // Draw the outside border - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { context.Graphics.DrawPath(cache.BorderPen, cache.BorderPath); } @@ -10623,7 +10623,7 @@ protected virtual IDisposable DrawRibbonAppTab(PaletteRibbonShape shape, context.Graphics.FillPath(cache.InsideFillBrush, cache.InsideFillPath); // Draw highlight over bottom half - using (Clipping clip = new Clipping(context.Graphics, cache.InsideFillPath)) + using (var clip = new Clipping(context.Graphics, cache.InsideFillPath)) { context.Graphics.FillPath(cache.HighlightBrush, cache.HighlightPath); } @@ -10676,7 +10676,7 @@ protected virtual IDisposable DrawRibbonGroupNormal(bool showingInPopup, // Dispose of existing values cache.Dispose(); - GraphicsPath trackingPath = new GraphicsPath(); + var trackingPath = new GraphicsPath(); trackingPath.AddEllipse(new Rectangle(rect.X, rect.Y + (rect.Height / 2), rect.Width - 3, rect.Height)); cache.TrackHighlightBrush = new PathGradientBrush(trackingPath) { @@ -10757,10 +10757,10 @@ protected virtual IDisposable DrawRibbonGroupNormal(bool showingInPopup, // Dispose of existing values cache.Dispose(); - GraphicsPath solidPath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); - GraphicsPath outsidePath = new GraphicsPath(); - GraphicsPath lightPath = new GraphicsPath(); + var solidPath = new GraphicsPath(); + var insidePath = new GraphicsPath(); + var outsidePath = new GraphicsPath(); + var lightPath = new GraphicsPath(); // Create the rounded complete border solidPath.AddLine(rect.Left + 2, rect.Top, rect.Right - 4, rect.Top); @@ -10792,8 +10792,8 @@ protected virtual IDisposable DrawRibbonGroupNormal(bool showingInPopup, lightPath.AddLine(rect.Left + 1, rect.Bottom - 4, rect.Left + 1, rect.Top + 2); lightPath.AddLine(rect.Left + 1, rect.Top + 2, rect.Left + 2, rect.Top + 1); - RectangleF solidRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); - LinearGradientBrush solidBrush = new LinearGradientBrush(solidRectF, c1, c2, 90f); + var solidRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); + var solidBrush = new LinearGradientBrush(solidRectF, c1, c2, 90f); cache.SolidPen = new Pen(solidBrush); cache.BackRect = new Rectangle(rect.Left + 2, rect.Top + 1, rect.Width - 4, rect.Height - 4); @@ -10809,7 +10809,7 @@ protected virtual IDisposable DrawRibbonGroupNormal(bool showingInPopup, context.Graphics.FillRectangle(lightInside ? _whitenLightLBrush : _whitenLightBrush, cache.BackRect); } - using (AntiAlias aa = new AntiAlias(context.Graphics)) + using (var aa = new AntiAlias(context.Graphics)) { // Draw the solid border context.Graphics.DrawPath(cache.SolidPen, cache.SolidPath); @@ -10877,7 +10877,7 @@ protected virtual IDisposable DrawRibbonGroupNormalBorderSep(bool showingInPopup // Dispose of existing values cache.Dispose(); - RectangleF rectF = new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); + var rectF = new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); cache.TotalBrush = new LinearGradientBrush(rectF, c2, c1, 90f); cache.InnerBrush = new LinearGradientBrush(rectF, c4, c3, 90f); @@ -10956,7 +10956,7 @@ protected virtual IDisposable DrawRibbonGroupNormalTitle(RenderContext context, // Dispose of existing values cache.Dispose(); - GraphicsPath titlePath = new GraphicsPath(); + var titlePath = new GraphicsPath(); // Create the rounded bottom edge to fit inside a group border titlePath.AddLine(rect.Left, rect.Top, rect.Right - 1, rect.Top); @@ -10966,7 +10966,7 @@ protected virtual IDisposable DrawRibbonGroupNormalTitle(RenderContext context, titlePath.AddLine(rect.Left + 2, rect.Bottom - 1, rect.Left, rect.Bottom - 3); titlePath.AddLine(rect.Left, rect.Bottom - 3, rect.Left, rect.Top); - RectangleF rectF = new RectangleF(rect.Left - 0.5f, rect.Top - 0.5f, rect.Width + 1, + var rectF = new RectangleF(rect.Left - 0.5f, rect.Top - 0.5f, rect.Width + 1, rect.Height + 1); cache.TitleBrush = new LinearGradientBrush(rectF, c1, c2, 90f); cache.TitlePath = titlePath; @@ -11019,8 +11019,8 @@ protected virtual IDisposable DrawRibbonGroupCollapsedBorder(RenderContext conte // Dispose of existing values cache.Dispose(); - GraphicsPath solidPath = new GraphicsPath(); - GraphicsPath insidePath = new GraphicsPath(); + var solidPath = new GraphicsPath(); + var insidePath = new GraphicsPath(); // Create the rounded complete border solidPath.AddLine(rect.Left + 1.25f, rect.Top, rect.Right - 2, rect.Top); @@ -11042,11 +11042,11 @@ protected virtual IDisposable DrawRibbonGroupCollapsedBorder(RenderContext conte insidePath.AddLine(rect.Left + 1, rect.Bottom - 3, rect.Left + 1, rect.Top + 2); insidePath.AddLine(rect.Left + 1, rect.Top + 2, rect.Left + 2, rect.Top + 1); - RectangleF solidRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); - RectangleF insideRectF = new RectangleF(rect.Left, rect.Top, rect.Width, rect.Height); + var solidRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); + var insideRectF = new RectangleF(rect.Left, rect.Top, rect.Width, rect.Height); - LinearGradientBrush solidBrush = new LinearGradientBrush(solidRectF, c1, c2, 90f); - LinearGradientBrush insideBrush = new LinearGradientBrush(insideRectF, c3, c4, 90f); + var solidBrush = new LinearGradientBrush(solidRectF, c1, c2, 90f); + var insideBrush = new LinearGradientBrush(insideRectF, c3, c4, 90f); cache.SolidPath = solidPath; cache.InsidePath = insidePath; @@ -11055,7 +11055,7 @@ protected virtual IDisposable DrawRibbonGroupCollapsedBorder(RenderContext conte } // Perform actual drawing using the cache values - using AntiAlias aa = new AntiAlias(context.Graphics); + using var aa = new AntiAlias(context.Graphics); context.Graphics.DrawPath(cache.SolidPen, cache.SolidPath); context.Graphics.DrawPath(cache.InsidePen, cache.InsidePath); } @@ -11100,7 +11100,7 @@ protected virtual IDisposable DrawRibbonGroupCollapsedFrameBorder(RenderContext // Dispose of existing values cache.Dispose(); - GraphicsPath solidPath = new GraphicsPath(); + var solidPath = new GraphicsPath(); // Create the rounded complete border solidPath.AddLine(rect.Left + 2, rect.Top, rect.Right - 3, rect.Top); @@ -11118,11 +11118,11 @@ protected virtual IDisposable DrawRibbonGroupCollapsedFrameBorder(RenderContext } // Perform actual drawing using the cache values - Rectangle titleRect = new Rectangle(rect.Left + 1, rect.Bottom - GROUP_FRAME_TITLE_HEIGHT, + var titleRect = new Rectangle(rect.Left + 1, rect.Bottom - GROUP_FRAME_TITLE_HEIGHT, rect.Width - 2, GROUP_FRAME_TITLE_HEIGHT - 1); context.Graphics.FillRectangle(cache.TitleBrush, titleRect); - using AntiAlias aa = new AntiAlias(context.Graphics); + using var aa = new AntiAlias(context.Graphics); context.Graphics.DrawPath(cache.SolidPen, cache.SolidPath); } @@ -11166,7 +11166,7 @@ protected virtual IDisposable DrawRibbonGroupGradientOne(RenderContext context, // Dispose of existing values cache.Dispose(); - RectangleF rectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); + var rectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); cache.Brush = new LinearGradientBrush(rectF, c1, c2, 90f) { Blend = _ribbonGroup8Blend @@ -11221,11 +11221,11 @@ protected virtual IDisposable DrawRibbonGroupGradientTwo(RenderContext context, cache.Dispose(); var topHeight = (int)(rect.Height * percent); - Rectangle topRect = new Rectangle(rect.Left, rect.Top, rect.Width, topHeight); - Rectangle bottomRect = new Rectangle(rect.Left, topRect.Bottom, rect.Width, rect.Height - topHeight); - RectangleF topRectF = new RectangleF(topRect.Left - 1, topRect.Top - 1, topRect.Width + 2, + var topRect = new Rectangle(rect.Left, rect.Top, rect.Width, topHeight); + var bottomRect = new Rectangle(rect.Left, topRect.Bottom, rect.Width, rect.Height - topHeight); + var topRectF = new RectangleF(topRect.Left - 1, topRect.Top - 1, topRect.Width + 2, topRect.Height + 2); - RectangleF bottomRectF = new RectangleF(bottomRect.Left - 1, bottomRect.Top - 1, + var bottomRectF = new RectangleF(bottomRect.Left - 1, bottomRect.Top - 1, bottomRect.Width + 2, bottomRect.Height + 2); cache.TopBrush = new LinearGradientBrush(topRectF, c1, c2, 90f); @@ -11283,9 +11283,9 @@ protected virtual IDisposable DrawRibbonQATMinibarSingle(RenderContext context, // Dispose of existing values cache.Dispose(); - GraphicsPath borderPath = new GraphicsPath(); - GraphicsPath topRight1 = new GraphicsPath(); - GraphicsPath bottomLeft1 = new GraphicsPath(); + var borderPath = new GraphicsPath(); + var topRight1 = new GraphicsPath(); + var bottomLeft1 = new GraphicsPath(); // Find values needed for drawing the main border var left = rect.X + 1; @@ -11341,7 +11341,7 @@ protected virtual IDisposable DrawRibbonQATMinibarSingle(RenderContext context, cache.WhitenPen = new Pen(c5); } - using AntiAlias aa = new AntiAlias(context.Graphics); + using var aa = new AntiAlias(context.Graphics); if (!composition) { // Draw the light borders @@ -11409,9 +11409,9 @@ protected virtual IDisposable DrawRibbonQATMinibarDouble(RenderContext context, // Dispose of existing values cache.Dispose(); - GraphicsPath borderPath = new GraphicsPath(); - GraphicsPath topRight1 = new GraphicsPath(); - GraphicsPath bottomLeft1 = new GraphicsPath(); + var borderPath = new GraphicsPath(); + var topRight1 = new GraphicsPath(); + var bottomLeft1 = new GraphicsPath(); // Find values needed for drawing the main border var left = rect.X + 1; @@ -11468,7 +11468,7 @@ protected virtual IDisposable DrawRibbonQATMinibarDouble(RenderContext context, cache.WhitenPen = new Pen(c5); } - using AntiAlias aa = new AntiAlias(context.Graphics); + using var aa = new AntiAlias(context.Graphics); if (!composition) { // Draw the light borders @@ -11577,7 +11577,7 @@ protected virtual IDisposable DrawRibbonLinearBorder(RenderContext context, cache.LinearPen = new Pen(cache.LinearBrush); // Create the rounded complete border - GraphicsPath borderPath = new GraphicsPath(); + var borderPath = new GraphicsPath(); borderPath.AddLine(rect.Left + 2, rect.Top, rect.Right - 3, rect.Top); borderPath.AddLine(rect.Right - 3, rect.Top, rect.Right - 1, rect.Top + 2); borderPath.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 3); @@ -11753,9 +11753,9 @@ protected virtual IDisposable DrawRibbonQATFullbarRound(RenderContext context, cache.InnerBrush = new LinearGradientBrush(rect, c1, c2, 90f); cache.DarkPen = new Pen(c3); - GraphicsPath darkPath = new GraphicsPath(); - GraphicsPath lightPath1 = new GraphicsPath(); - GraphicsPath lightPath2 = new GraphicsPath(); + var darkPath = new GraphicsPath(); + var lightPath1 = new GraphicsPath(); + var lightPath2 = new GraphicsPath(); // Create the dark border darkPath.AddLine(rect.Left, rect.Top + 0.75f, rect.Left + 1, rect.Top); @@ -11784,7 +11784,7 @@ protected virtual IDisposable DrawRibbonQATFullbarRound(RenderContext context, context.Graphics.FillRectangle(cache.InnerBrush, cache.InnerRect); // Draw the dark/light lines - using AntiAlias aa = new AntiAlias(context.Graphics); + using var aa = new AntiAlias(context.Graphics); context.Graphics.DrawPath(cache.DarkPen, cache.DarkPath); context.Graphics.DrawPath(_light1Pen, cache.LightPath1); context.Graphics.DrawPath(_light2Pen, cache.LightPath2); @@ -11895,7 +11895,7 @@ protected virtual IDisposable DrawRibbonQATOverflow(PaletteRibbonShape shape, // Draw a gradient for the inside of the area context.Graphics.FillRectangle(cache.BackBrush, rect); - using AntiAlias aa = new AntiAlias(context.Graphics); + using var aa = new AntiAlias(context.Graphics); if (shape == PaletteRibbonShape.Office2010) { context.Graphics.DrawPolygon(cache.BorderPen, new Point[]{ diff --git a/Source/Krypton Components/Krypton.Toolkit/Rendering/ThemeManager.cs b/Source/Krypton Components/Krypton.Toolkit/Rendering/ThemeManager.cs index b76077d07..91bb7246b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Rendering/ThemeManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Rendering/ThemeManager.cs @@ -206,7 +206,7 @@ public static void LoadCustomTheme(KryptonCustomPaletteBase palette, KryptonMana /// public static string? ReturnPaletteModeAsString(PaletteMode paletteMode) { - PaletteModeConverter modeConverter = new PaletteModeConverter(); + var modeConverter = new PaletteModeConverter(); return modeConverter.ConvertToString(paletteMode); } diff --git a/Source/Krypton Components/Krypton.Toolkit/Tooling/ExceptionHandler.cs b/Source/Krypton Components/Krypton.Toolkit/Tooling/ExceptionHandler.cs index bc2ce87c1..227b5af90 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Tooling/ExceptionHandler.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Tooling/ExceptionHandler.cs @@ -65,7 +65,7 @@ public static void PrintStackTrace(Exception exception, string fileName) File.Create(fileName); } - StreamWriter writer = new StreamWriter(fileName); + var writer = new StreamWriter(fileName); writer.Write(exception.ToString()); @@ -91,7 +91,7 @@ public static void PrintExceptionStackTrace(Exception exception, string fileName File.Create(fileName); } - StreamWriter writer = new StreamWriter(fileName); + var writer = new StreamWriter(fileName); writer.Write(exception.StackTrace); diff --git a/Source/Krypton Components/Krypton.Toolkit/Translations/Converters/PaletteModeStrings.cs b/Source/Krypton Components/Krypton.Toolkit/Translations/Converters/PaletteModeStrings.cs index b1cd35b4d..1325f8435 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Translations/Converters/PaletteModeStrings.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Translations/Converters/PaletteModeStrings.cs @@ -623,7 +623,7 @@ public static string[] ThemeArray { get { - PaletteModeStrings strings = new PaletteModeStrings(); + var strings = new PaletteModeStrings(); return strings._themeArray; } diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/PaletteImageScaler.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/PaletteImageScaler.cs index a5c93fdd9..9cf45159a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/PaletteImageScaler.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/PaletteImageScaler.cs @@ -159,7 +159,7 @@ private static void ScaleButtonSpecImageType(KryptonPaletteButtonSpecTyped bst, { return img; } - using Bitmap tmpBmp = new Bitmap(img); + using var tmpBmp = new Bitmap(img); tmpBmp.MakeTransparent(Color.Magenta); return CommonHelper.ScaleImageForSizedDisplay(tmpBmp, img.Width * scaleFactor.Width, img.Height * scaleFactor.Height); } diff --git a/Source/Krypton Components/Krypton.Toolkit/Values/ColorButtonValues.cs b/Source/Krypton Components/Krypton.Toolkit/Values/ColorButtonValues.cs index e5dbebb09..69b906228 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Values/ColorButtonValues.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Values/ColorButtonValues.cs @@ -28,7 +28,7 @@ public class ColorButtonValues : Storage, #region Instance Fields private Image _image; private Image _sourceImage; - private Image _compositeImage; + private Image? _compositeImage; private Color _transparent; private string? _text; private string _extraText; @@ -364,7 +364,7 @@ public void ResetRoundedCorners() // Create a copy of the source image Size selectedRectSize = _selectedRect.Size; Size imageSize = image.Size; - Bitmap copyBitmap = new Bitmap(image, Math.Max(selectedRectSize.Width, imageSize.Width), + var copyBitmap = new Bitmap(image, Math.Max(selectedRectSize.Width, imageSize.Width), Math.Max(selectedRectSize.Height, imageSize.Height)); // Paint over the image with a color indicator @@ -377,13 +377,13 @@ public void ResetRoundedCorners() // Indicate the absence of a color by drawing a border around // the selected color area, thus indicating the area inside the // block is blank/empty. - using Pen borderPen = new Pen(_emptyBorderColor); + using var borderPen = new Pen(_emptyBorderColor); DrawRoundedRectangle(g, borderPen, _selectedRect, _roundedCorners); } else { // We have a valid selected color so draw a solid block of color - using SolidBrush colorBrush = new SolidBrush(_selectedColor); + using var colorBrush = new SolidBrush(_selectedColor); FillRoundedRectangle(g, colorBrush, _selectedRect, _roundedCorners); } } diff --git a/Source/Krypton Components/Krypton.Toolkit/Values/IntegratedToolBarValues.cs b/Source/Krypton Components/Krypton.Toolkit/Values/IntegratedToolBarValues.cs index 77c765289..b69acd9da 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Values/IntegratedToolBarValues.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Values/IntegratedToolBarValues.cs @@ -68,78 +68,52 @@ 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(); + var newButtonSpec = new ButtonSpecAny(); + var openButtonSpecAny = new ButtonSpecAny(); + var saveButtonSpecAny = new ButtonSpecAny(); + var saveAsButtonSpecAny = new ButtonSpecAny(); + var saveAllButtonSpecAny = new ButtonSpecAny(); + var cutButtonSpecAny = new ButtonSpecAny(); + var copyButtonSpecAny = new ButtonSpecAny(); + var pasteButtonSpecAny = new ButtonSpecAny(); + var undoButtonSpecAny = new ButtonSpecAny(); + var redoButtonSpecAny = new ButtonSpecAny(); + var pageSetupButtonSpecAny = new ButtonSpecAny(); + var printPreviewButtonSpecAny = new ButtonSpecAny(); + var printButtonSpecAny = new ButtonSpecAny(); + var quickPrintButtonSpecAny = new ButtonSpecAny(); // Set up buttons newButtonSpec.Type = PaletteButtonSpecStyle.New; - openButtonSpecAny.Type = PaletteButtonSpecStyle.Open; - saveAllButtonSpecAny.Type = PaletteButtonSpecStyle.SaveAll; - saveAsButtonSpecAny.Type = PaletteButtonSpecStyle.SaveAs; - saveButtonSpecAny.Type = PaletteButtonSpecStyle.Save; - cutButtonSpecAny.Type = PaletteButtonSpecStyle.Cut; - copyButtonSpecAny.Type = PaletteButtonSpecStyle.Copy; - pasteButtonSpecAny.Type = PaletteButtonSpecStyle.Paste; - undoButtonSpecAny.Type = PaletteButtonSpecStyle.Undo; - redoButtonSpecAny.Type = PaletteButtonSpecStyle.Redo; - pageSetupButtonSpecAny.Type = PaletteButtonSpecStyle.PageSetup; - printPreviewButtonSpecAny.Type = PaletteButtonSpecStyle.PrintPreview; - printButtonSpecAny.Type = PaletteButtonSpecStyle.Print; - quickPrintButtonSpecAny.Type = PaletteButtonSpecStyle.QuickPrint; // Add configured buttons to array... - + // TODO: These should not be magic numbers (How about using the `PaletteButtonSpecStyle`?) _integratedToolBarItems[0] = newButtonSpec; - _integratedToolBarItems[1] = openButtonSpecAny; - _integratedToolBarItems[2] = saveButtonSpecAny; - _integratedToolBarItems[3] = saveAsButtonSpecAny; - _integratedToolBarItems[4] = saveAllButtonSpecAny; - _integratedToolBarItems[5] = cutButtonSpecAny; - _integratedToolBarItems[6] = copyButtonSpecAny; - _integratedToolBarItems[7] = pasteButtonSpecAny; - _integratedToolBarItems[8] = undoButtonSpecAny; - _integratedToolBarItems[9] = redoButtonSpecAny; - _integratedToolBarItems[10] = pageSetupButtonSpecAny; - _integratedToolBarItems[11] = printPreviewButtonSpecAny; - _integratedToolBarItems[12] = printPreviewButtonSpecAny; - _integratedToolBarItems[13] = quickPrintButtonSpecAny; } } diff --git a/Source/Krypton Components/Krypton.Toolkit/View Base/ViewContextMenuManager.cs b/Source/Krypton Components/Krypton.Toolkit/View Base/ViewContextMenuManager.cs index ba053296f..f8378e3ed 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Base/ViewContextMenuManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Base/ViewContextMenuManager.cs @@ -24,7 +24,7 @@ private class TargetList : List { } #region Instance Fields private IContextMenuTarget _target; private IContextMenuTarget? _targetSubMenu; - private System.Windows.Forms.Timer _itemDelayTimer; + private System.Windows.Forms.Timer? _itemDelayTimer; #endregion #region Identity @@ -426,14 +426,14 @@ public bool DoesStackedClientMouseDownBecomeCurrent(Message m, Point pt) => #region Implementation private TargetList ConstructKeyboardTargets(ViewBase root) { - TargetList targets = new TargetList(); + var targets = new TargetList(); FindKeyboardTargets(root, targets); return targets; } private void FindKeyboardTargets(ViewBase parent, TargetList targets) { - IContextMenuTarget target = null; + IContextMenuTarget? target = null; // Any target interface will be implemented on a controller instance if (parent.KeyController != null) @@ -458,10 +458,10 @@ private void FindKeyboardTargets(ViewBase parent, TargetList targets) } } - private IContextMenuTarget FindTopLeftTarget(TargetList targets) + private IContextMenuTarget? FindTopLeftTarget(TargetList targets) { // Best match found so far - IContextMenuTarget topLeftTarget = null; + IContextMenuTarget? topLeftTarget = null; Rectangle topLeftRect = Rectangle.Empty; // Search all targets, looking for a better match than the current best @@ -492,10 +492,10 @@ private IContextMenuTarget FindTopLeftTarget(TargetList targets) return topLeftTarget; } - private IContextMenuTarget FindTopRightTarget(TargetList targets) + private IContextMenuTarget? FindTopRightTarget(TargetList targets) { // Best match found so far - IContextMenuTarget topRightTarget = null; + IContextMenuTarget? topRightTarget = null; Rectangle topRightRect = Rectangle.Empty; // Search all targets, looking for a better match than the current best @@ -526,10 +526,10 @@ private IContextMenuTarget FindTopRightTarget(TargetList targets) return topRightTarget; } - private IContextMenuTarget FindBottomLeftTarget(TargetList targets) + private IContextMenuTarget? FindBottomLeftTarget(TargetList targets) { // Best match found so far - IContextMenuTarget bottomLeftTarget = null; + IContextMenuTarget? bottomLeftTarget = null; Rectangle bottomLeftRect = Rectangle.Empty; // Search all targets, looking for a better match than the current best @@ -560,10 +560,10 @@ private IContextMenuTarget FindBottomLeftTarget(TargetList targets) return bottomLeftTarget; } - private IContextMenuTarget FindDownTarget(TargetList targets, IContextMenuTarget current) + private IContextMenuTarget? FindDownTarget(TargetList targets, IContextMenuTarget current) { // Find the next item below the current one - IContextMenuTarget newTarget = FindDownTarget(targets, current.ClientRectangle); + IContextMenuTarget? newTarget = FindDownTarget(targets, current.ClientRectangle); // If nothing found, then we must be at the bottom of the display if (newTarget == null) @@ -580,14 +580,14 @@ private IContextMenuTarget FindDownTarget(TargetList targets, IContextMenuTarget return newTarget; } - private IContextMenuTarget FindDownTarget(TargetList targets, Rectangle currentRect) + private IContextMenuTarget? FindDownTarget(TargetList targets, Rectangle currentRect) { // We compare from the bottom edge always currentRect.Y = currentRect.Bottom; currentRect.Height = 0; // Best match found so far - IContextMenuTarget nextTarget = null; + IContextMenuTarget? nextTarget = null; Rectangle nextRect = Rectangle.Empty; // Search all targets, looking for a better match than the current best @@ -623,10 +623,10 @@ private IContextMenuTarget FindDownTarget(TargetList targets, Rectangle currentR return nextTarget; } - private IContextMenuTarget FindUpTarget(TargetList targets, IContextMenuTarget current) + private IContextMenuTarget? FindUpTarget(TargetList targets, IContextMenuTarget current) { // Find the next item above the current one - IContextMenuTarget newTarget = FindUpTarget(targets, current.ClientRectangle); + IContextMenuTarget? newTarget = FindUpTarget(targets, current.ClientRectangle); // If nothing found, then we must be at the top of the display if (newTarget == null) @@ -643,13 +643,13 @@ private IContextMenuTarget FindUpTarget(TargetList targets, IContextMenuTarget c return newTarget; } - private IContextMenuTarget FindUpTarget(TargetList targets, Rectangle currentRect) + private IContextMenuTarget? FindUpTarget(TargetList targets, Rectangle currentRect) { // We compare from the top edge always currentRect.Height = 0; // Best match found so far - IContextMenuTarget nextTarget = null; + IContextMenuTarget? nextTarget = null; Rectangle nextRect = Rectangle.Empty; // Search all targets, looking for a better match than the current best @@ -685,10 +685,10 @@ private IContextMenuTarget FindUpTarget(TargetList targets, Rectangle currentRec return nextTarget; } - private IContextMenuTarget FindRightTarget(TargetList targets, IContextMenuTarget current) + private IContextMenuTarget? FindRightTarget(TargetList targets, IContextMenuTarget current) { // Find the next item after the current one - IContextMenuTarget newTarget = FindRightTarget(targets, current.ClientRectangle); + IContextMenuTarget? newTarget = FindRightTarget(targets, current.ClientRectangle); // If nothing found, then we must be at the right side of the display if (newTarget == null) @@ -705,14 +705,14 @@ private IContextMenuTarget FindRightTarget(TargetList targets, IContextMenuTarge return newTarget; } - private IContextMenuTarget FindRightTarget(TargetList targets, Rectangle currentRect) + private IContextMenuTarget? FindRightTarget(TargetList targets, Rectangle currentRect) { // We compare from the right edge always currentRect.X = currentRect.Right; currentRect.Width = 0; // Best match found so far - IContextMenuTarget nextTarget = null; + IContextMenuTarget? nextTarget = null; Rectangle nextRect = Rectangle.Empty; // Search all targets, looking for a better match than the current best @@ -748,13 +748,13 @@ private IContextMenuTarget FindRightTarget(TargetList targets, Rectangle current return nextTarget; } - private IContextMenuTarget FindLeftTarget(TargetList targets, + private IContextMenuTarget? FindLeftTarget(TargetList targets, IContextMenuTarget current, bool wrap, ref bool hitEdge) { // Find the item left of the current one - IContextMenuTarget newTarget = FindLeftTarget(targets, current.ClientRectangle); + IContextMenuTarget? newTarget = FindLeftTarget(targets, current.ClientRectangle); // If nothing found, then we must be at the left edge of the display if (newTarget == null) @@ -778,13 +778,13 @@ private IContextMenuTarget FindLeftTarget(TargetList targets, return newTarget; } - private IContextMenuTarget FindLeftTarget(TargetList targets, Rectangle currentRect) + private IContextMenuTarget? FindLeftTarget(TargetList targets, Rectangle currentRect) { // We compare from the left edge always currentRect.Width = 0; // Best match found so far - IContextMenuTarget nextTarget = null; + IContextMenuTarget? nextTarget = null; Rectangle nextRect = Rectangle.Empty; // Search all targets, looking for a better match than the current best diff --git a/Source/Krypton Components/Krypton.Toolkit/View Base/ViewControl.cs b/Source/Krypton Components/Krypton.Toolkit/View Base/ViewControl.cs index 93e5569f9..b3cafc0a8 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Base/ViewControl.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Base/ViewControl.cs @@ -157,7 +157,7 @@ protected override void OnPaint(PaintEventArgs e) PaintBackground?.Invoke(this, e); // Create a render context for drawing the view - using RenderContext context = new RenderContext(GetViewManager(), this, RootInstance, e.Graphics, + using var context = new RenderContext(GetViewManager(), this, RootInstance, e.Graphics, e.ClipRectangle, Renderer); // Ask the view to paint itself ViewLayoutControl.ChildView.Render(context); @@ -192,13 +192,14 @@ protected override void OnMouseMove(MouseEventArgs e) if (!IsDisposed && !Disposing && !RootInstance.IsDisposed) { // Do we have a manager for processing mouse messages? - if (GetViewManager() != null) + ViewManager? viewManager = GetViewManager(); + if (viewManager != null) { // Convert from control to parent control coordinates Point rootPoint = RootInstance.PointToClient(PointToScreen(new Point(e.X, e.Y))); // Use the root controls view manager to process the event - GetViewManager().MouseMove(new MouseEventArgs(e.Button, + viewManager.MouseMove(new MouseEventArgs(e.Button, e.Clicks, rootPoint.X, rootPoint.Y, @@ -221,13 +222,14 @@ protected override void OnMouseDown(MouseEventArgs e) if (!IsDisposed && !Disposing && !RootInstance.IsDisposed) { // Do we have a manager for processing mouse messages? - if (GetViewManager() != null) + ViewManager? viewManager = GetViewManager(); + if (viewManager != null) { // Convert from control to parent control coordinates Point rootPoint = RootInstance.PointToClient(PointToScreen(new Point(e.X, e.Y))); // Use the root controls view manager to process the event - GetViewManager().MouseDown(new MouseEventArgs(e.Button, + viewManager.MouseDown(new MouseEventArgs(e.Button, e.Clicks, rootPoint.X, rootPoint.Y, @@ -260,13 +262,14 @@ protected override void OnMouseUp(MouseEventArgs e) if (!IsDisposed && !Disposing && !RootInstance.IsDisposed) { // Do we have a manager for processing mouse messages? - if (GetViewManager() != null) + ViewManager? viewManager = GetViewManager(); + if (viewManager != null) { // Convert from control to parent control coordinates Point rootPoint = RootInstance.PointToClient(PointToScreen(new Point(e.X, e.Y))); // Use the root controls view manager to process the event - GetViewManager().MouseUp(new MouseEventArgs(e.Button, + viewManager.MouseUp(new MouseEventArgs(e.Button, e.Clicks, rootPoint.X, rootPoint.Y, @@ -388,10 +391,10 @@ protected override void WndProc(ref Message m) if (m.Msg == PI.WM_.NCHITTEST) { // Extract the screen point for the hit test - Point screenPoint = new Point((int)m.LParam.ToInt64()); + var screenPoint = new Point((int)m.LParam.ToInt64()); // Generate event so message can be processed - ViewControlHitTestArgs args = new ViewControlHitTestArgs(PointToClient(screenPoint)); + var args = new ViewControlHitTestArgs(PointToClient(screenPoint)); OnWndProcHitTest(args); if (!args.Cancel) @@ -473,7 +476,7 @@ private IRenderer? Renderer private void PaintTransparentBackground(PaintEventArgs e) { // Get the parent control for transparent drawing purposes - Control parent = Parent; + Control? parent = Parent; // Do we have a parent control and we need to paint background? if (parent != null) @@ -491,7 +494,7 @@ private void PaintTransparentBackground(PaintEventArgs e) try { - _miPTB.Invoke(this, new object[] { e, ClientRectangle, null }); + _ = _miPTB.Invoke(this, new object[] { e, ClientRectangle, null }); } catch { diff --git a/Source/Krypton Components/Krypton.Toolkit/View Base/ViewManager.cs b/Source/Krypton Components/Krypton.Toolkit/View Base/ViewManager.cs index e3e24072b..b3a38a3ca 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Base/ViewManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Base/ViewManager.cs @@ -170,13 +170,13 @@ public virtual Size GetPreferredSize(IRenderer? renderer, return Size.Empty; } - Size retSize = Size.Empty; + var retSize = Size.Empty; // Short circuit for a disposed control if (!Control.IsDisposed) { // Create a layout context for calculating size and positioning - using ViewLayoutContext context = new ViewLayoutContext(this, + using var context = new ViewLayoutContext(this, Control, AlignControl, renderer, proposedSize); retSize = Root.GetPreferredSize(context); } @@ -214,7 +214,7 @@ public bool EvalTransparentPaint([DisallowNull] IRenderer renderer) } // Create a layout context for calculating size and positioning - using ViewContext context = new ViewContext(this, Control, AlignControl, renderer); + using var context = new ViewContext(this, Control, AlignControl, renderer); // Ask the view to perform operation return Root.EvalTransparentPaint(context); } @@ -293,7 +293,7 @@ public virtual void Layout([DisallowNull] IRenderer renderer) if (!Control.IsDisposed) { // Create a layout context for calculating size and positioning - using ViewLayoutContext context = new ViewLayoutContext(this, Control, AlignControl, renderer); + using var context = new ViewLayoutContext(this, Control, AlignControl, renderer); Layout(context); } } @@ -380,7 +380,7 @@ public virtual void Paint([DisallowNull] IRenderer renderer, PaintEventArgs e) if (!Control.IsDisposed) { // Create a render context for drawing the view - using RenderContext context = new RenderContext(this, + using var context = new RenderContext(this, Control, AlignControl, e.Graphics, e.ClipRectangle, renderer); Paint(context); } @@ -449,7 +449,7 @@ public virtual void MouseMove([DisallowNull] MouseEventArgs e, Point rawPt) throw new ArgumentNullException(nameof(e)); } - Point pt = new Point(e.X, e.Y); + var pt = new Point(e.X, e.Y); // Set the correct active view from the point UpdateViewFromPoint(Control, pt); @@ -474,7 +474,7 @@ public virtual void MouseDown([DisallowNull] MouseEventArgs e, Point rawPt) throw new ArgumentNullException(nameof(e)); } - Point pt = new Point(e.X, e.Y); + var pt = new Point(e.X, e.Y); // Set the correct active view from the point UpdateViewFromPoint(Control, pt); @@ -505,7 +505,7 @@ public virtual void MouseUp([DisallowNull] MouseEventArgs e, Point rawPt) throw new ArgumentNullException(nameof(e)); } - Point pt = new Point(e.X, e.Y); + var pt = new Point(e.X, e.Y); // Set the correct active view from the point UpdateViewFromPoint(Control, pt); diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawDateTimeText.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawDateTimeText.cs index a4e1f4b32..ceb980592 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawDateTimeText.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawDateTimeText.cs @@ -56,7 +56,7 @@ public FormatHandler(KryptonDateTimePicker dateTimePicker, /// User readable name of the instance. public override string ToString() { - StringBuilder ret = new StringBuilder(); + var ret = new StringBuilder(); foreach (FormatFragment fmt in _fragments) { ret.Append(fmt.GetDisplay(DateTime)); @@ -405,8 +405,8 @@ public void InputDigit(char digit) // Rotate around the end of the fragments if (!HasActiveFragment) { - // Use evnet to show that we are overflowing - CancelEventArgs cea = new CancelEventArgs(); + // Use event to show that we are overflowing + var cea = new CancelEventArgs(); _timeText.OnAutoShiftOverflow(cea); // Event might be cancelled so check we want to overflow @@ -451,8 +451,8 @@ public void InputDigit(char digit) // Rotate around the end of the fragments if (!HasActiveFragment) { - // Use evnet to show that we are overflowing - CancelEventArgs cea = new CancelEventArgs(); + // Use event to show that we are overflowing + var cea = new CancelEventArgs(); _timeText.OnAutoShiftOverflow(cea); // Event might be cancelled so check we want to overflow @@ -549,7 +549,7 @@ public void Render(RenderContext context, Font font, Rectangle rect, totalWidth = rect.Width; } - Rectangle drawText = new Rectangle(rect.X + lastTotalWidth, rect.Y, + var drawText = new Rectangle(rect.X + lastTotalWidth, rect.Y, totalWidth - lastTotalWidth, rect.Height); if (drawText.Width > 0) { @@ -567,7 +567,7 @@ public void Render(RenderContext context, Font font, Rectangle rect, } else { - using (SolidBrush fillBrush = new SolidBrush(foreColor)) + using (var fillBrush = new SolidBrush(foreColor)) { context.Graphics.FillRectangle(fillBrush, drawText); } @@ -648,7 +648,7 @@ private void MeasureFragments(Graphics? g, Font font, DateTime dt) } // Update format with details of the ranges to measure - StringFormat measureFormat = new StringFormat(StringFormatFlags.FitBlackBox); + var measureFormat = new StringFormat(StringFormatFlags.FitBlackBox); measureFormat.SetMeasurableCharacterRanges(charRanges); // Perform measuring using the output of the last fragment (last frag must be the whole output string) @@ -663,7 +663,7 @@ private void MeasureFragments(Graphics? g, Font font, DateTime dt) private FormatFragmentList ParseFormatToFragments(string format) { - FormatFragmentList fragList = new FormatFragmentList(); + var fragList = new FormatFragmentList(); // Grab the string used for formatting var length = format.Length; @@ -1645,7 +1645,7 @@ public override void Render(RenderContext context) _formatHandler.DateTime = _dateTimePicker.Value; // Ask the format handler to perform actual rendering of the text - using Clipping clipped = new Clipping(context.Graphics, ClientRectangle); + using var clipped = new Clipping(context.Graphics, ClientRectangle); _formatHandler.Render(context, GetFont(), ClientRectangle, GetTextColor(), GetBackColor(), _dateTimePicker.Checked); diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawDebug.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawDebug.cs index c110afd25..ed0515a7b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawDebug.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawDebug.cs @@ -89,7 +89,7 @@ public override void RenderBefore([DisallowNull] RenderContext context) } // Ignore renderer, we just draw using solid color for debugging purposes - using SolidBrush brush = new SolidBrush(_color); + using var brush = new SolidBrush(_color); context.Graphics.FillRectangle(brush, ClientRectangle); } #endregion diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuCheckBox.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuCheckBox.cs index fdc5a0dd4..6162b1513 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuCheckBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuCheckBox.cs @@ -86,7 +86,7 @@ public ViewDrawMenuCheckBox(IContextMenuProvider provider, }; // Use context menu specific version of the check box controller - MenuCheckBoxController mcbc = new MenuCheckBoxController(provider.ProviderViewManager, _innerDocker, this, + var mcbc = new MenuCheckBoxController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate); mcbc.Click += OnClick; _innerDocker.MouseController = mcbc; diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuCheckButton.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuCheckButton.cs index 6691d3268..d76eb1c18 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuCheckButton.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuCheckButton.cs @@ -83,7 +83,7 @@ public ViewDrawMenuCheckButton(IContextMenuProvider provider, }; // Use context menu specific version of the check box controller - MenuCheckButtonController mcbc = new MenuCheckButtonController(provider.ProviderViewManager, _innerDocker, + var mcbc = new MenuCheckButtonController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate); mcbc.Click += OnClick; _innerDocker.MouseController = mcbc; diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuColorBlock.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuColorBlock.cs index 7494fd9d9..c73a6bce4 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuColorBlock.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuColorBlock.cs @@ -51,7 +51,7 @@ public ViewDrawMenuColorBlock(IContextMenuProvider provider, _blockSize = colorColumns.BlockSize; // Use context menu specific version of the radio button controller - MenuColorBlockController mcbc = new MenuColorBlockController(provider.ProviderViewManager, this, this, + var mcbc = new MenuColorBlockController(provider.ProviderViewManager, this, this, provider.ProviderNeedPaintDelegate); mcbc.Click += OnClick; MouseController = mcbc; @@ -191,7 +191,7 @@ public override void RenderBefore([DisallowNull] RenderContext context) } // Draw ourself in the designated color - using SolidBrush brush = new SolidBrush(Color); + using var brush = new SolidBrush(Color); context.Graphics.FillRectangle(brush, drawRect); } diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuColorColumn.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuColorColumn.cs index ed9452381..a53e2d923 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuColorColumn.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuColorColumn.cs @@ -34,7 +34,7 @@ public ViewDrawMenuColorColumn(IContextMenuProvider provider, int end, bool enabled) { - ViewLayoutColorStack vertical = new ViewLayoutColorStack(); + var vertical = new ViewLayoutColorStack(); for (var i = start; i < end; i++) { @@ -92,7 +92,7 @@ public override void RenderBefore([DisallowNull] RenderContext context) throw new ArgumentNullException(nameof(context)); } - using SolidBrush brush = new SolidBrush(Color.FromArgb(197, 197, 197)); + using var brush = new SolidBrush(Color.FromArgb(197, 197, 197)); context.Graphics.FillRectangle(brush, ClientRectangle); } #endregion diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuColorColumns.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuColorColumns.cs index 0fb22dea3..1e7661c0e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuColorColumns.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuColorColumns.cs @@ -48,7 +48,7 @@ public ViewDrawMenuColorColumns(IContextMenuProvider provider, var enabled = provider.ProviderEnabled; // Always assume there is a first row of colors - ViewLayoutStack fillStack = new ViewLayoutStack(false) + var fillStack = new ViewLayoutStack(false) { CreateColumns(provider, colorColumns, colors, 0, 1, enabled) }; @@ -137,7 +137,7 @@ private ViewLayoutStack CreateColumns(IContextMenuProvider provider, bool enabled) { // Create a horizontal stack of columns - ViewLayoutStack columns = new ViewLayoutStack(true) + var columns = new ViewLayoutStack(true) { FillLastChild = false }; @@ -152,7 +152,7 @@ private ViewLayoutStack CreateColumns(IContextMenuProvider provider, } // Add container for the column, this draws the background - ViewDrawMenuColorColumn colorColumn = + var colorColumn = new ViewDrawMenuColorColumn(provider, colorColumns, colors[i], start, end, enabled); columns.Add(colorColumn); } diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuImageSelectItem.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuImageSelectItem.cs index 06c4ec664..774a5c91b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuImageSelectItem.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuImageSelectItem.cs @@ -188,7 +188,7 @@ private void OnItemClick(object sender, MouseEventArgs e) if (_layout.CanCloseMenu) { // Ask the original context menu definition, if we can close - CancelEventArgs cea = new CancelEventArgs(); + var cea = new CancelEventArgs(); _layout.Closing(cea); if (!cea.Cancel) diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuItem.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuItem.cs index 690801d3d..a62a88bfd 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuItem.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuItem.cs @@ -66,14 +66,14 @@ public ViewDrawMenuItem(IContextMenuProvider provider, KryptonContextMenuItem.SetPaletteRedirect(provider); // Create a stack of horizontal items inside the item - ViewLayoutDocker docker = new ViewLayoutDocker(); + var docker = new ViewLayoutDocker(); // Decide on the enabled state of the display ItemEnabled = provider.ProviderEnabled && ResolveEnabled; PaletteContextMenuItemState menuItemState = ItemEnabled ? KryptonContextMenuItem.StateNormal : KryptonContextMenuItem.StateDisabled; // Calculate the image to show inside in the image column - Image itemColumnImage = ResolveImage; + Image? itemColumnImage = ResolveImage; Color itemImageTransparent = ResolveImageTransparentColor; // If no image found then... @@ -149,8 +149,7 @@ public ViewDrawMenuItem(IContextMenuProvider provider, Add(docker); // Add a controller for handing mouse and keyboard events - MenuItemController mic = - new MenuItemController(provider.ProviderViewManager, this, provider.ProviderNeedPaintDelegate); + var mic = new MenuItemController(provider.ProviderViewManager, this, provider.ProviderNeedPaintDelegate); MouseController = mic; KeyController = mic; diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuLinkLabel.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuLinkLabel.cs index e6662271b..17888ad72 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuLinkLabel.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuLinkLabel.cs @@ -73,7 +73,7 @@ public ViewDrawMenuLinkLabel(IContextMenuProvider provider, }; // Use context menu specific version of the link label controller - MenuLinkLabelController mllc = new MenuLinkLabelController(provider.ProviderViewManager, _drawContent, this, + var mllc = new MenuLinkLabelController(provider.ProviderViewManager, _drawContent, this, provider.ProviderNeedPaintDelegate); mllc.Click += OnClick; _drawContent.MouseController = mllc; diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuRadioButton.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuRadioButton.cs index a52fc386e..e86b5c2ba 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuRadioButton.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMenuRadioButton.cs @@ -85,7 +85,7 @@ public ViewDrawMenuRadioButton(IContextMenuProvider provider, }; // Use context menu specific version of the radio button controller - MenuRadioButtonController mrbc = new MenuRadioButtonController(provider.ProviderViewManager, _innerDocker, + var mrbc = new MenuRadioButtonController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate); mrbc.Click += OnClick; _innerDocker.MouseController = mrbc; diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMonth.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMonth.cs index 8dcc06e80..80fe7407e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMonth.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMonth.cs @@ -104,9 +104,9 @@ public ViewDrawMonth(IKryptonMonthCalendar calendar, _calendar.GetToolStripDelegate, needPaintDelegate); // Create stacks for holding display items - ViewLayoutStack namesStack = new ViewLayoutStack(true); - ViewLayoutStack weeksStack = new ViewLayoutStack(true); - ViewLayoutStack daysStack = new ViewLayoutStack(false); + var namesStack = new ViewLayoutStack(true); + var weeksStack = new ViewLayoutStack(true); + var daysStack = new ViewLayoutStack(false); _numberStack = new ViewLayoutStack(false); weeksStack.Add(_numberStack); weeksStack.Add(daysStack); @@ -124,7 +124,7 @@ public ViewDrawMonth(IKryptonMonthCalendar calendar, _borderEdge = new PaletteBorderEdge(_borderEdgeRedirect, null); _drawBorderEdge = new ViewDrawBorderEdge(_borderEdge, Orientation.Vertical); _drawWeekNumbers = new ViewDrawWeekNumbers(_calendar, _months); - ViewLayoutDocker borderLeftDock = new ViewLayoutDocker + var borderLeftDock = new ViewLayoutDocker { { _drawWeekNumbers, ViewDockStyle.Left }, { new ViewLayoutSeparator(0, 4), ViewDockStyle.Top }, @@ -134,11 +134,10 @@ public ViewDrawMonth(IKryptonMonthCalendar calendar, _numberStack.Add(borderLeftDock); // Add border between day names and individual days - PaletteBorderEdgeRedirect borderEdgeRedirect = - new PaletteBorderEdgeRedirect(_calendar.StateNormal.Header.Border, null); - PaletteBorderEdge borderEdge = new PaletteBorderEdge(borderEdgeRedirect, null); - ViewDrawBorderEdge drawBorderEdge = new ViewDrawBorderEdge(borderEdge, Orientation.Horizontal); - ViewLayoutDocker borderTopDock = new ViewLayoutDocker + var borderEdgeRedirect = new PaletteBorderEdgeRedirect(_calendar.StateNormal.Header.Border, null); + var borderEdge = new PaletteBorderEdge(borderEdgeRedirect, null); + var drawBorderEdge = new ViewDrawBorderEdge(borderEdge, Orientation.Horizontal); + var borderTopDock = new ViewLayoutDocker { { new ViewLayoutSeparator(4, 1), ViewDockStyle.Left }, { drawBorderEdge, ViewDockStyle.Fill }, diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMonthDayNames.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMonthDayNames.cs index 81e2f930f..3503d2bee 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMonthDayNames.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMonthDayNames.cs @@ -103,7 +103,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) PaletteState state = Enabled ? PaletteState.Normal : PaletteState.Disabled; // Layout the 7 day names - Rectangle layoutRect = new Rectangle(ClientLocation, _months.SizeDays); + var layoutRect = new Rectangle(ClientLocation, _months.SizeDays); for (int i = 0, day=(int)_months.DisplayDayOfWeek; i < 7; i++, day++) { // Define text to be drawn @@ -136,7 +136,7 @@ public override void RenderBefore([DisallowNull] RenderContext context) PaletteState state = Enabled ? PaletteState.Normal : PaletteState.Disabled; // Draw the 7 day names - Rectangle drawRect = new Rectangle(ClientLocation, _months.SizeDays); + var drawRect = new Rectangle(ClientLocation, _months.SizeDays); for(int i=0, day=(int)_months.DisplayDayOfWeek; i<7; i++, day++) { // Draw using memento cached from the layout call diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMonthDays.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMonthDays.cs index 717f71ff9..60091f80b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMonthDays.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawMonthDays.cs @@ -236,9 +236,9 @@ public override void Layout([DisallowNull] ViewLayoutContext context) var layoutXCell = ClientLocation.X; var layoutXDay = ClientLocation.X + ((_months.SizeDays.Width - _months.SizeDay.Width) / 2); - Rectangle layoutRectCell = new Rectangle(layoutXCell, ClientLocation.Y, _months.SizeDays.Width, + var layoutRectCell = new Rectangle(layoutXCell, ClientLocation.Y, _months.SizeDays.Width, _months.SizeDays.Height); - Rectangle layoutRectDay = new Rectangle(layoutXDay, ClientLocation.Y, _months.SizeDay.Width, + var layoutRectDay = new Rectangle(layoutXDay, ClientLocation.Y, _months.SizeDay.Width, _months.SizeDays.Height); // Layout each week as a row @@ -371,9 +371,9 @@ public override void RenderBefore([DisallowNull] RenderContext context) var layoutXCell = ClientLocation.X; var layoutXDay = ClientLocation.X + ((_months.SizeDays.Width - _months.SizeDay.Width) / 2); - Rectangle drawRectCell = new Rectangle(layoutXCell, ClientLocation.Y, _months.SizeDays.Width, + var drawRectCell = new Rectangle(layoutXCell, ClientLocation.Y, _months.SizeDays.Width, _months.SizeDays.Height); - Rectangle drawRectDay = new Rectangle(layoutXDay, ClientLocation.Y, _months.SizeDay.Width, + var drawRectDay = new Rectangle(layoutXDay, ClientLocation.Y, _months.SizeDay.Width, _months.SizeDays.Height); // Draw each week as a row diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawNull.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawNull.cs index 703c72168..9ed8f8477 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawNull.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawNull.cs @@ -45,7 +45,7 @@ public override string ToString() => /// Rendering context. public override void RenderBefore(RenderContext context) { - using SolidBrush fillBrush = new SolidBrush(_fillColor); + using var fillBrush = new SolidBrush(_fillColor); context.Graphics.FillRectangle(fillBrush, ClientRectangle); } #endregion diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawPanel.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawPanel.cs index f480b4077..255c7dcd4 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawPanel.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawPanel.cs @@ -171,7 +171,7 @@ public override void RenderBefore([DisallowNull] RenderContext context) if (_paletteBack.GetBackDraw(State) == InheritBool.True) { // Render the background - using GraphicsPath panelPath = new GraphicsPath(); + using var panelPath = new GraphicsPath(); var rectF = ClientRectangleF; // Now workaround https://github.com/Krypton-Suite/Standard-Toolkit/issues/308 rectF.Offset(-0.25f, -0.25f); diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawSplitCanvas.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawSplitCanvas.cs index 6ccc6d45e..234629b8b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawSplitCanvas.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawSplitCanvas.cs @@ -514,7 +514,7 @@ public override void RenderBefore([DisallowNull] RenderContext context) Orientation, State); // Create a new region the same as the existing clipping region - Region combineRegion = new Region(borderPath); + var combineRegion = new Region(borderPath); // Reduce clipping region down by our border path combineRegion.Intersect(_clipRegion); @@ -571,58 +571,66 @@ private void RenderBackground(RenderContext context, Rectangle rect) switch (State) { case PaletteState.Tracking: - using (Clipping clipToSplitter = new Clipping(context.Graphics, NonSplitRectangle)) + { + using (var clipToSplitter = new Clipping(context.Graphics, NonSplitRectangle)) { if (SplitWithFading) { - DrawBackground(context, rect, mouseInSplit ? _paletteBackLight : PaletteBack, PaletteBorder, PaletteState.Tracking); + DrawBackground(context, rect, mouseInSplit ? _paletteBackLight : PaletteBack, + PaletteBorder, PaletteState.Tracking); } else { - DrawBackground(context, rect, mouseInSplit ? _paletteBackDraw : PaletteBack, PaletteBorder, mouseInSplit ? PaletteState.Normal : PaletteState.Tracking); + DrawBackground(context, rect, mouseInSplit ? _paletteBackDraw : PaletteBack, + PaletteBorder, mouseInSplit ? PaletteState.Normal : PaletteState.Tracking); } } - using (Clipping clipToSplitter = new Clipping(context.Graphics, _splitRectangle)) + using (var clipToSplitter = new Clipping(context.Graphics, _splitRectangle)) { if (SplitWithFading) { - DrawBackground(context, rect, mouseInSplit ? PaletteBack : _paletteBackLight, PaletteBorder, PaletteState.Tracking); + DrawBackground(context, rect, mouseInSplit ? PaletteBack : _paletteBackLight, + PaletteBorder, PaletteState.Tracking); } else { - DrawBackground(context, rect, mouseInSplit ? PaletteBack : _paletteBackDraw, PaletteBorder, mouseInSplit ? PaletteState.Tracking : PaletteState.Normal); + DrawBackground(context, rect, mouseInSplit ? PaletteBack : _paletteBackDraw, + PaletteBorder, mouseInSplit ? PaletteState.Tracking : PaletteState.Normal); } } + } break; case PaletteState.Pressed: - using (Clipping clipToSplitter = new Clipping(context.Graphics, _splitRectangle)) + { + using (var clipToSplitter = new Clipping(context.Graphics, _splitRectangle)) { if (SplitWithFading) { DrawBackground(context, rect, mouseInSplit ? PaletteBack : _paletteBackLight, - PaletteBorder, mouseInSplit ? PaletteState.Pressed : PaletteState.Tracking); + PaletteBorder, mouseInSplit ? PaletteState.Pressed : PaletteState.Tracking); } else { DrawBackground(context, rect, mouseInSplit ? PaletteBack : _paletteBackDraw, - PaletteBorder, mouseInSplit ? PaletteState.Pressed : PaletteState.Normal); + PaletteBorder, mouseInSplit ? PaletteState.Pressed : PaletteState.Normal); } } - using (Clipping clipToSplitter = new Clipping(context.Graphics, NonSplitRectangle)) + using (var clipToSplitter = new Clipping(context.Graphics, NonSplitRectangle)) { if (SplitWithFading) { DrawBackground(context, rect, mouseInSplit ? _paletteBackLight : PaletteBack, - PaletteBorder, mouseInSplit ? PaletteState.Tracking : PaletteState.Pressed); + PaletteBorder, mouseInSplit ? PaletteState.Tracking : PaletteState.Pressed); } else { DrawBackground(context, rect, mouseInSplit ? _paletteBackDraw : PaletteBack, - PaletteBorder, mouseInSplit ? PaletteState.Normal : PaletteState.Pressed); + PaletteBorder, mouseInSplit ? PaletteState.Normal : PaletteState.Pressed); } } + } break; default: DrawBackground(context, rect, PaletteBack, PaletteBorder, State); @@ -652,14 +660,15 @@ private void RenderBorder([DisallowNull] RenderContext context, Rectangle rect) DrawBorder(context, rect, PaletteBorder, PaletteState.Tracking); break; case PaletteState.Pressed: + { DrawBorder(context, rect, PaletteBorder, PaletteState.Tracking); - using (Clipping clipToSplitter = new Clipping(context.Graphics, + using (var clipToSplitter = new Clipping(context.Graphics, mouseInSplit ? _splitRectangle : NonSplitRectangle)) { DrawBorder(context, rect, PaletteBorder, PaletteState.Pressed); } - + } break; default: DrawBorder(context, rect, PaletteBorder, State); diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawToday.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawToday.cs index 87f3cc58f..8b8841e94 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawToday.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawToday.cs @@ -55,7 +55,7 @@ public ViewDrawToday(IKryptonMonthCalendar calendar, ButtonValues = this; // Define a controller so the button can be clicked - ButtonController controller = new ButtonController(this, needPaintHandler); + var controller = new ButtonController(this, needPaintHandler); controller.Click += OnClick; MouseController = controller; SourceController = controller; diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawTrackTP.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawTrackTP.cs index 2a9fdef20..c24934c56 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawTrackTP.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawTrackTP.cs @@ -39,13 +39,13 @@ public ViewDrawTP(ViewDrawTrackBar drawTrackBar) Add(ViewDrawTrackPosition); // Use controller for the entire track area - TrackBarController tbController = new TrackBarController(this); + var tbController = new TrackBarController(this); drawTrackBar.MouseController = tbController; drawTrackBar.KeyController = tbController; drawTrackBar.SourceController = tbController; // Use controller for dragging the position indicator - TrackPositionController tpController = new TrackPositionController(this); + var tpController = new TrackPositionController(this); ViewDrawTrackPosition.MouseController = tpController; } diff --git a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawWeekNumbers.cs b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawWeekNumbers.cs index 2bd1fc7d2..7261c18f6 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawWeekNumbers.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Draw/ViewDrawWeekNumbers.cs @@ -117,7 +117,7 @@ public DateTime Month } // Find the first day of the year - DateTime yearDay = new DateTime(value.Year, 1, 1); + var yearDay = new DateTime(value.Year, 1, 1); _weekDay = _firstDay; // Move forewards until we hit the starting day of the year @@ -156,7 +156,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) _calendar.SetBoldedOverride(false); // Layout each week number - Rectangle layoutRectWeek = new Rectangle(ClientLocation.X, ClientLocation.Y, _months.SizeDay.Width, + var layoutRectWeek = new Rectangle(ClientLocation.X, ClientLocation.Y, _months.SizeDay.Width, _months.SizeDays.Height); DateTime weekDate = _weekDay; DateTime displayDate = _firstDay; @@ -207,7 +207,7 @@ public override void RenderBefore([DisallowNull] RenderContext context) _calendar.SetBoldedOverride(false); // Layout each week number - Rectangle drawRectWeek = new Rectangle(ClientLocation.X, ClientLocation.Y, _months.SizeDay.Width, + var drawRectWeek = new Rectangle(ClientLocation.X, ClientLocation.Y, _months.SizeDay.Width, _months.SizeDays.Height); DateTime weekDate = _weekDay; DateTime displayDate = _firstDay; diff --git a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutControl.cs b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutControl.cs index 7607e0d02..13d70e7b8 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutControl.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutControl.cs @@ -224,7 +224,7 @@ public override Size GetPreferredSize([DisallowNull] ViewLayoutContext context) UpdateParent(context.Control); // Ensure context has the correct control - using CorrectContextControl ccc = new CorrectContextControl(context, ChildControl); + using var ccc = new CorrectContextControl(context, ChildControl); // Ask the view for its preferred size if (ChildView != null) { @@ -253,7 +253,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) if (ChildControl != null) { // Ensure context has the correct control - using CorrectContextControl ccc = new CorrectContextControl(context, ChildControl); + using var ccc = new CorrectContextControl(context, ChildControl); // We take on all the available display area ClientRectangle = context.DisplayRectangle; diff --git a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutCrumbs.cs b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutCrumbs.cs index 5ef3bdedf..4aac7d144 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutCrumbs.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutCrumbs.cs @@ -136,7 +136,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) SyncBreadCrumbs(); // Positioning rectangle is our client rectangle reduced by control padding - Rectangle layoutRect = new Rectangle(ClientLocation.X + _kryptonBreadCrumb.Padding.Left, + var layoutRect = new Rectangle(ClientLocation.X + _kryptonBreadCrumb.Padding.Left, ClientLocation.Y + _kryptonBreadCrumb.Padding.Top, ClientWidth - _kryptonBreadCrumb.Padding.Horizontal, ClientHeight - _kryptonBreadCrumb.Padding.Vertical); @@ -328,7 +328,7 @@ private void CreateOverflowButton() }; // Create controller for operating the button - ButtonController crumbButtonController = new ButtonController(_overflowButton, _needPaintDelegate) + var crumbButtonController = new ButtonController(_overflowButton, _needPaintDelegate) { Tag = this, BecomesFixed = true @@ -364,7 +364,7 @@ private void SyncBreadCrumbs() }; // Create controller for operating the button - ButtonController crumbButtonController = new ButtonController(crumbButton, _needPaintDelegate) + var crumbButtonController = new ButtonController(crumbButton, _needPaintDelegate) { Tag = item, BecomesFixed = true @@ -405,7 +405,7 @@ private void OnButtonClick(object sender, MouseEventArgs e) if (viewButton.DropDown && viewButton.SplitRectangle.Contains(e.Location)) { // Create a context menu with a items collection - KryptonContextMenu kcm = new KryptonContextMenu + var kcm = new KryptonContextMenu { // Use same palette settings for context menu as the main control @@ -417,7 +417,7 @@ private void OnButtonClick(object sender, MouseEventArgs e) } // Add an items collection as the root item of the context menu - KryptonContextMenuItems items = new KryptonContextMenuItems(); + var items = new KryptonContextMenuItems(); kcm.Items.Add(items); // Store lookup between each menu item and the crumb it represents. Prevents @@ -428,7 +428,7 @@ private void OnButtonClick(object sender, MouseEventArgs e) // Create a new menu item to represent each child crumb foreach (KryptonBreadCrumbItem childCrumb in breadCrumb.Items) { - KryptonContextMenuItem childMenu = new KryptonContextMenuItem(); + var childMenu = new KryptonContextMenuItem(); // Store 1-to-1 association _menuItemToCrumb.Add(childMenu, childCrumb); @@ -444,7 +444,7 @@ private void OnButtonClick(object sender, MouseEventArgs e) } // Allow the user a chance to alter the menu contents or cancel it entirely - BreadCrumbMenuArgs bcma = new BreadCrumbMenuArgs(breadCrumb, kcm, KryptonContextMenuPositionH.Left, + var bcma = new BreadCrumbMenuArgs(breadCrumb, kcm, KryptonContextMenuPositionH.Left, KryptonContextMenuPositionV.Below); _kryptonBreadCrumb.OnCrumbDropDown(bcma); @@ -488,7 +488,7 @@ private void OnButtonClick(object sender, MouseEventArgs e) private void OnKryptonContextMenuClosed(object sender, EventArgs e) { // Cast to correct type - KryptonContextMenu kcm = (KryptonContextMenu)sender; + var kcm = (KryptonContextMenu)sender; // Unhook from context menu and dispose of it, we only use each menu instance once kcm.Closed -= OnKryptonContextMenuClosed; @@ -515,13 +515,12 @@ private void OnOverflowButtonClick(object sender, MouseEventArgs e) if (!_showingContextMenu) { // Get access to the controller, view and crumb item - ViewDrawButton viewButton = sender as ViewDrawButton; - ButtonController controller = viewButton.MouseController as ButtonController; + var viewButton = sender as ViewDrawButton; + var controller = viewButton.MouseController as ButtonController; // Create a context menu with a items collection - KryptonContextMenu kcm = new KryptonContextMenu + var kcm = new KryptonContextMenu { - // Use same palette settings for context menu as the main control Palette = _kryptonBreadCrumb.Palette }; @@ -531,7 +530,7 @@ private void OnOverflowButtonClick(object sender, MouseEventArgs e) } // Add an items collection as the root item of the context menu - KryptonContextMenuItems items = new KryptonContextMenuItems(); + var items = new KryptonContextMenuItems(); kcm.Items.Add(items); // Store lookup between each menu item and the crumb it represents. Prevents @@ -546,7 +545,7 @@ private void OnOverflowButtonClick(object sender, MouseEventArgs e) if (!this[i].Visible) { KryptonBreadCrumbItem childCrumb = _buttonToCrumb[(ViewDrawButton)this[i]]; - KryptonContextMenuItem childMenu = new KryptonContextMenuItem(); + var childMenu = new KryptonContextMenuItem(); // Store 1-to-1 association _menuItemToCrumb.Add(childMenu, childCrumb); @@ -578,7 +577,7 @@ private void OnOverflowButtonClick(object sender, MouseEventArgs e) firstRoot = false; } - KryptonContextMenuItem childMenu = new KryptonContextMenuItem(); + var childMenu = new KryptonContextMenuItem(); // Store 1-to-1 association _menuItemToCrumb.Add(childMenu, childCrumb); @@ -594,7 +593,7 @@ private void OnOverflowButtonClick(object sender, MouseEventArgs e) } // Allow the user a chance to alter the menu contents or cancel it entirely - ContextPositionMenuArgs cpma = new ContextPositionMenuArgs(kcm, KryptonContextMenuPositionH.Left, + var cpma = new ContextPositionMenuArgs(kcm, KryptonContextMenuPositionH.Left, KryptonContextMenuPositionV.Below); _kryptonBreadCrumb.OnOverflowDropDown(cpma); diff --git a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutDocker.cs b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutDocker.cs index 6bdb1d692..0a34a8bba 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutDocker.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutDocker.cs @@ -185,23 +185,23 @@ public override Size GetPreferredSize([DisallowNull] ViewLayoutContext context) Debug.Assert(context != null); // Create new lookup that only contains entries for current child items - ViewDockStyleLookup newChildDocking = new ViewDockStyleLookup(); + var newChildDocking = new ViewDockStyleLookup(); // Remember the original display rectangle provided Rectangle originalRect = context.DisplayRectangle; Rectangle displayRect = context.DisplayRectangle; // Accumulate the size that must be provided by docking edges and then filler - Size preferredSize = Size.Empty; + var preferredSize = Size.Empty; // Track the minimize size needed to satisfy the docking edges only - Size minimumSize = Size.Empty; + var minimumSize = Size.Empty; - PaletteDrawBorders leftEdges = PaletteDrawBorders.All; - PaletteDrawBorders rightEdges = PaletteDrawBorders.All; - PaletteDrawBorders topEdges = PaletteDrawBorders.All; - PaletteDrawBorders bottomEdges = PaletteDrawBorders.All; - PaletteDrawBorders fillEdges = PaletteDrawBorders.All; + var leftEdges = PaletteDrawBorders.All; + var rightEdges = PaletteDrawBorders.All; + var topEdges = PaletteDrawBorders.All; + var bottomEdges = PaletteDrawBorders.All; + var fillEdges = PaletteDrawBorders.All; // Check for edge docking children foreach (ViewBase child in Reverse()) @@ -235,8 +235,8 @@ public override Size GetPreferredSize([DisallowNull] ViewLayoutContext context) { minimumSize.Width = childSize.Width; } - break; + case ViewDockStyle.Bottom: preferredSize.Height += childSize.Height; displayRect.Height -= childSize.Height; @@ -245,8 +245,8 @@ public override Size GetPreferredSize([DisallowNull] ViewLayoutContext context) { minimumSize.Width = childSize.Width; } - break; + case ViewDockStyle.Left: preferredSize.Width += childSize.Width; displayRect.X += childSize.Width; @@ -256,8 +256,8 @@ public override Size GetPreferredSize([DisallowNull] ViewLayoutContext context) { minimumSize.Height = childSize.Height; } - break; + case ViewDockStyle.Right: preferredSize.Width += childSize.Width; displayRect.Width -= childSize.Width; @@ -266,7 +266,6 @@ public override Size GetPreferredSize([DisallowNull] ViewLayoutContext context) { minimumSize.Height = childSize.Height; } - break; } } @@ -314,6 +313,7 @@ public override Size GetPreferredSize([DisallowNull] ViewLayoutContext context) preferredSize.Width += Padding.Horizontal; preferredSize.Height += Padding.Vertical; break; + case VisualOrientation.Left: case VisualOrientation.Right: preferredSize.Width += Padding.Vertical; @@ -348,18 +348,21 @@ public override void Layout([DisallowNull] ViewLayoutContext context) fillerRect.Width -= Padding.Horizontal; fillerRect.Height -= Padding.Vertical; break; + case VisualOrientation.Bottom: fillerRect.X += Padding.Right; fillerRect.Y += Padding.Bottom; fillerRect.Width -= Padding.Horizontal; fillerRect.Height -= Padding.Vertical; break; + case VisualOrientation.Left: fillerRect.X += Padding.Top; fillerRect.Y += Padding.Right; fillerRect.Width -= Padding.Vertical; fillerRect.Height -= Padding.Horizontal; break; + case VisualOrientation.Right: fillerRect.X += Padding.Bottom; fillerRect.Y += Padding.Left; @@ -369,11 +372,11 @@ public override void Layout([DisallowNull] ViewLayoutContext context) } // By default all the children need to draw all their borders - PaletteDrawBorders leftEdges = PaletteDrawBorders.All; - PaletteDrawBorders rightEdges = PaletteDrawBorders.All; - PaletteDrawBorders topEdges = PaletteDrawBorders.All; - PaletteDrawBorders bottomEdges = PaletteDrawBorders.All; - PaletteDrawBorders fillEdges = PaletteDrawBorders.All; + var leftEdges = PaletteDrawBorders.All; + var rightEdges = PaletteDrawBorders.All; + var topEdges = PaletteDrawBorders.All; + var bottomEdges = PaletteDrawBorders.All; + var fillEdges = PaletteDrawBorders.All; // Position all except the filler foreach (ViewBase child in Reverse() @@ -397,15 +400,18 @@ public override void Layout([DisallowNull] ViewLayoutContext context) fillerRect.Height -= childSize.Height; fillerRect.Y += childSize.Height; break; + case ViewDockStyle.Bottom: context.DisplayRectangle = new Rectangle(fillerRect.X, fillerRect.Bottom - childSize.Height, fillerRect.Width, childSize.Height); fillerRect.Height -= childSize.Height; break; + case ViewDockStyle.Left: context.DisplayRectangle = new Rectangle(fillerRect.X, fillerRect.Y, childSize.Width, fillerRect.Height); fillerRect.Width -= childSize.Width; fillerRect.X += childSize.Width; break; + case ViewDockStyle.Right: context.DisplayRectangle = new Rectangle(fillerRect.Right - childSize.Width, fillerRect.Y, childSize.Width, fillerRect.Height); fillerRect.Width -= childSize.Width; diff --git a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutMenuItemsPile.cs b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutMenuItemsPile.cs index 28ad55123..5593693c6 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutMenuItemsPile.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutMenuItemsPile.cs @@ -45,7 +45,7 @@ public ViewLayoutMenuItemsPile(IContextMenuProvider provider, // Create and place an image column inside a docker so it appears on the left side _imageColumn = new ViewDrawMenuImageColumn(items, provider.ProviderStateCommon.ItemImageColumn); - ViewLayoutDocker imageDocker = new ViewLayoutDocker + var imageDocker = new ViewLayoutDocker { { _imageColumn, ViewDockStyle.Left } }; @@ -60,7 +60,7 @@ public ViewLayoutMenuItemsPile(IContextMenuProvider provider, }; // Use a docker with the item stack as the fill - ViewLayoutDocker stackDocker = new ViewLayoutDocker + var stackDocker = new ViewLayoutDocker { { ItemStack, ViewDockStyle.Fill } }; diff --git a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutMonths.cs b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutMonths.cs index 6365c2f13..f0fba3f4b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutMonths.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutMonths.cs @@ -26,13 +26,13 @@ public class ViewLayoutMonths : ViewComposite, private readonly ViewDrawDocker _drawHeader; private readonly PaletteBorderInheritForced _borderForced; - private VisualPopupToolTip _visualPopupToolTip; + private VisualPopupToolTip? _visualPopupToolTip; private readonly ViewDrawToday _drawToday; private readonly ButtonSpecRemapByContentView? _remapPalette; private readonly ViewDrawEmptyContent _emptyContent; private readonly PaletteTripleRedirect _palette; private readonly ToolTipManager _toolTipManager; - private CultureInfo _lastCultureInfo; + private CultureInfo? _lastCultureInfo; private DateTime _displayMonth; private string _dayOfWeekMeasure; private string _dayMeasure; @@ -81,7 +81,7 @@ public ViewLayoutMonths(IContextMenuProvider provider, AllowButtonSpecToolTips = false; // Use a controller that can work against all the displayed months - MonthCalendarController controller = + var controller = new MonthCalendarController(monthCalendar, viewManager, this, _needPaintDelegate); MouseController = controller; SourceController = controller; @@ -626,7 +626,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) internal DayOfWeek DisplayDayOfWeek { get; private set; } - internal string[] DayNames { get; private set; } + internal string[]? DayNames { get; private set; } #endregion @@ -649,7 +649,7 @@ private void OnTodayClick(object sender, EventArgs e) if (CloseOnTodayClick && Provider is { ProviderCanCloseMenu: true }) { // Ask the original context menu definition, if we can close - CancelEventArgs cea = new CancelEventArgs(); + var cea = new CancelEventArgs(); Provider.OnClosing(cea); if (!cea.Cancel) @@ -754,7 +754,7 @@ private void SyncMonths() // Bring the selection into the display range DateTime endMonth = _displayMonth.AddMonths(months - 1); DateTime oldSelEndDate = _oldSelectionEnd.Date; - DateTime oldSelEndMonth = new DateTime(oldSelEndDate.Year, oldSelEndDate.Month, 1); + var oldSelEndMonth = new DateTime(oldSelEndDate.Year, oldSelEndDate.Month, 1); if (oldSelEndMonth >= endMonth) { _displayMonth = oldSelEndMonth.AddMonths(-(months - 1)); @@ -772,7 +772,7 @@ private void SyncMonths() // Inform each view which month it should be drawing for (var i = 1; i < Count; i++) { - ViewDrawMonth viewMonth = (ViewDrawMonth)this[i]; + var viewMonth = (ViewDrawMonth)this[i]; viewMonth.Enabled = Enabled; viewMonth.Month = currentMonth; viewMonth.FirstMonth = i == 1; @@ -789,7 +789,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) if (!IsDisposed) { // Do not show tooltips when the form we are in does not have focus - Form topForm = Calendar.CalendarControl.FindForm(); + Form? topForm = Calendar.CalendarControl.FindForm(); if (topForm is { ContainsFocus: false }) { return; @@ -799,7 +799,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) if (!Calendar.InDesignMode) { IContentValues? sourceContent = null; - LabelStyle toolTipStyle = LabelStyle.ToolTip; + var toolTipStyle = LabelStyle.ToolTip; bool shadow = true; @@ -813,7 +813,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) if (AllowButtonSpecToolTips) { // Create a helper object to provide tooltip values - ButtonSpecToContent buttonSpecMapping = new ButtonSpecToContent(_redirector, buttonSpec); + var buttonSpecMapping = new ButtonSpecToContent(_redirector, buttonSpec); // Is there actually anything to show for the tooltip if (buttonSpecMapping.HasContent) diff --git a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutViewport.cs b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutViewport.cs index 6c9c17006..6935d0f44 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutViewport.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutViewport.cs @@ -27,7 +27,7 @@ public class ViewLayoutViewport : ViewComposite #region Instance Fields private readonly System.Windows.Forms.Timer _animationTimer; - private IPaletteMetric _paletteMetrics; + private IPaletteMetric? _paletteMetrics; private PaletteMetricPadding _metricPadding; private PaletteMetricInt _metricOvers; private RightToLeft _rightToLeft; @@ -542,7 +542,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) childOffsetY = CalculateAlignedOffset(AlignmentRTL, positionRectangle.Y, positionRectangle.Height, _offset.Y, _extent.Height, _limit.Y); } - Point childOffset = new Point(childOffsetX, childOffsetY); + var childOffset = new Point(childOffsetX, childOffsetY); // Ask each child to layout in turn foreach (ViewBase child in this) @@ -554,7 +554,7 @@ public override void Layout([DisallowNull] ViewLayoutContext context) context.DisplayRectangle = positionRectangle; // Ask the child how much space they would like - Size childSize = child.GetPreferredSize(context); + var childSize = child.GetPreferredSize(context); // Do we need to fill any remainder space? if (FillSpace) @@ -605,7 +605,7 @@ public override void Render(RenderContext context) } // New clipping region is at most our own client size - using Region combineRegion = new Region(clipRectangle); + using var combineRegion = new Region(clipRectangle); // Remember the current clipping region Region clipRegion = context.Graphics.Clip.Clone(); diff --git a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutWeekCorner.cs b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutWeekCorner.cs index d85fe9024..7044a3e82 100644 --- a/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutWeekCorner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/View Layout/ViewLayoutWeekCorner.cs @@ -59,7 +59,7 @@ public override Size GetPreferredSize([DisallowNull] ViewLayoutContext context) Debug.Assert(context != null); // Start with size needed to draw a week number - Size retSize = new Size(_months.SizeDay.Width, _months.SizeDays.Height); + var retSize = new Size(_months.SizeDay.Width, _months.SizeDays.Height); // Add the width of the vertical border retSize.Width += _palette.GetBorderWidth(State); diff --git a/Source/Krypton Components/Krypton.Workspace/Controls Workspace/KryptonWorkspace.cs b/Source/Krypton Components/Krypton.Workspace/Controls Workspace/KryptonWorkspace.cs index 374aebbec..ee0a6f39f 100644 --- a/Source/Krypton Components/Krypton.Workspace/Controls Workspace/KryptonWorkspace.cs +++ b/Source/Krypton Components/Krypton.Workspace/Controls Workspace/KryptonWorkspace.cs @@ -1339,7 +1339,7 @@ public void ApplySingleCell(bool createCellIfNoPages) if (createCellIfNoPages || (pages.Count > 0)) { // Create a new cell with entire list of pages as the only workspace item - KryptonWorkspaceCell cell = new KryptonWorkspaceCell(); + var cell = new KryptonWorkspaceCell(); cell.Pages.AddRange(pages.ToArray()); Root.Children.Add(cell); @@ -1459,7 +1459,7 @@ public void ApplyGridCells(bool createCellIfEmpty, while (cells.Count > 0) { // Add a maximum of sequenceItems to the sequence - KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(sequenceDirection); + var sequence = new KryptonWorkspaceSequence(sequenceDirection); for (var j = 0; j < sequenceItems; j++) { // If no cells then do we need to create a cell? @@ -1597,13 +1597,13 @@ public void ApplyGridPages(bool createCellIfNoPages, while (pages.Count > 0) { // Add a maximum of sequenceItems to the sequence - KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(sequenceDirection); + var sequence = new KryptonWorkspaceSequence(sequenceDirection); for (var j = 0; j < sequenceItems; j++) { // If no pages then do we need to create a cell? if (createCellIfNoPages || (pages.Count > 0)) { - KryptonWorkspaceCell cell = new KryptonWorkspaceCell(); + var cell = new KryptonWorkspaceCell(); // Add the first cell in the list to the cell if (pages.Count > 0) @@ -1686,7 +1686,7 @@ public void ClearAllPages() /// List of drag targets. public virtual DragTargetList GenerateDragTargets(PageDragEndData? dragEndData, KryptonPageFlags allowFlags) { - DragTargetList targets = new DragTargetList(); + var targets = new DragTargetList(); var visibleCells = 0; var numPages = 0; @@ -1763,7 +1763,7 @@ public virtual DragTargetList GenerateDragTargets(PageDragEndData? dragEndData, public byte[] SaveLayoutToArray(Encoding encoding) { // Save into the file stream - MemoryStream ms = new MemoryStream(); + var ms = new MemoryStream(); SaveLayoutToStream(ms, encoding); ms.Close(); @@ -1862,7 +1862,7 @@ public void SaveLayoutToXml(XmlWriter xmlWriter) /// Array of source bytes. public void LoadLayoutFromArray(byte[] buffer) { - MemoryStream ms = new MemoryStream(buffer); + var ms = new MemoryStream(buffer); LoadLayoutFromStream(ms); ms.Close(); } @@ -1945,7 +1945,7 @@ public void LoadLayoutFromXml(XmlReader xmlReader, KryptonPageCollection availab throw new ArgumentException(@"Can only load Version 1 and upwards of KryptonWorkspace persisted data."); } - ScreenObscurer obscurer = new ScreenObscurer(); + var obscurer = new ScreenObscurer(); try { @@ -2201,7 +2201,7 @@ public virtual void WritePageElement(XmlWriter xmlWriter, KryptonPage page) else { // Use event to try and get a newly created page for use - RecreateLoadingPageEventArgs args = new RecreateLoadingPageEventArgs(uniqueName); + var args = new RecreateLoadingPageEventArgs(uniqueName); OnRecreateLoadingPage(args); if (!args.Cancel) { @@ -2555,11 +2555,11 @@ protected override void OnLayout(LayoutEventArgs levent) } // Lists for the layout processing to populate with instances still needed - SeparatorList separators = new SeparatorList(); - ControlList controls = new ControlList(); + var separators = new SeparatorList(); + var controls = new ControlList(); // Layout child controls according to the need for a maximized cell or not - using (ViewLayoutContext layoutContext = new ViewLayoutContext(this, Renderer)) + using (var layoutContext = new ViewLayoutContext(this, Renderer)) { if (MaximizedCell != null) { @@ -3297,7 +3297,7 @@ private void LayoutSequenceNonMaximized(KryptonWorkspaceSequence seq, }; // Need a controller that operates the movement - SeparatorController separatorController = new SeparatorController(viewSeparator, viewSeparator, + var separatorController = new SeparatorController(viewSeparator, viewSeparator, true, true, _separatorNeedPaint); viewSeparator.Source = viewSeparator; viewSeparator.MouseController = separatorController; @@ -3628,7 +3628,7 @@ private static void SeparatorToMovement(ViewDrawWorkspaceSeparator separator, private CellList CopyToCellList() { // Make a list of all the pages in workspace without removing any - CellList cells = new CellList(); + var cells = new CellList(); KryptonWorkspaceCell? cell = FirstCell(); while (cell != null) { @@ -3653,7 +3653,7 @@ private CellList ClearToCellList() private PageList CopyToPageList() { // Make list of all pages inside all cells - PageList pages = new PageList(); + var pages = new PageList(); KryptonWorkspaceCell? cell = FirstCell(); while (cell != null) { @@ -3667,7 +3667,7 @@ private PageList CopyToPageList() private KryptonPageCollection CopyToPageCollection() { // Make list of all pages inside all cells - KryptonPageCollection pages = new KryptonPageCollection(); + var pages = new KryptonPageCollection(); KryptonWorkspaceCell? cell = FirstCell(); while (cell != null) { @@ -3685,7 +3685,7 @@ private KryptonPageCollection CopyToPageCollection() private PageList ClearToPageList() { // Remove all pages from all cells add then to a list - PageList pages = new PageList(); + var pages = new PageList(); KryptonWorkspaceCell? cell = FirstCell(); while (cell != null) { @@ -4035,7 +4035,7 @@ private void PageSplitDirection(KryptonWorkspaceCell cell, var index = parentSequence.Children.IndexOf(cell); // Create a new cell and move the context page into it - KryptonWorkspaceCell newCell = new KryptonWorkspaceCell(); + var newCell = new KryptonWorkspaceCell(); cell.Pages.Remove(page); newCell.Pages.Add(page); @@ -4051,9 +4051,8 @@ private void PageSplitDirection(KryptonWorkspaceCell cell, else { // Split is in opposite direction so create a new sequence to replace the existing cell - KryptonWorkspaceSequence newSequence = new KryptonWorkspaceSequence(orientation) + var newSequence = new KryptonWorkspaceSequence(orientation) { - // Put the same size into the sequence as was in the original cell StarSize = cell.StarSize }; @@ -4129,7 +4128,7 @@ private void ResumeActivePageChangedEvent() private static UniqueNameToPage BuildUniqueNameDictionary(KryptonPageCollection pages) { - UniqueNameToPage dict = new UniqueNameToPage(); + var dict = new UniqueNameToPage(); // Add each page that has a non-null unique name but only add the same unique name once foreach (KryptonPage page in pages) diff --git a/Source/Krypton Components/Krypton.Workspace/Controls Workspace/KryptonWorkspaceCell.cs b/Source/Krypton Components/Krypton.Workspace/Controls Workspace/KryptonWorkspaceCell.cs index b64e97419..0cb2e63a5 100644 --- a/Source/Krypton Components/Krypton.Workspace/Controls Workspace/KryptonWorkspaceCell.cs +++ b/Source/Krypton Components/Krypton.Workspace/Controls Workspace/KryptonWorkspaceCell.cs @@ -477,7 +477,7 @@ public void LoadFromXml(KryptonWorkspace workspace, var finished = xmlReader.IsEmptyElement; // Generate event so custom data can be loaded and/or the page to be added can be modified - PageLoadingEventArgs plea = new PageLoadingEventArgs(workspace, page, xmlReader); + var plea = new PageLoadingEventArgs(workspace, page, xmlReader); workspace.OnPageLoading(plea); page = plea.Page; diff --git a/Source/Krypton Components/Krypton.Workspace/Controls Workspace/KryptonWorkspaceSequence.cs b/Source/Krypton Components/Krypton.Workspace/Controls Workspace/KryptonWorkspaceSequence.cs index 68752c784..9581d6d41 100644 --- a/Source/Krypton Components/Krypton.Workspace/Controls Workspace/KryptonWorkspaceSequence.cs +++ b/Source/Krypton Components/Krypton.Workspace/Controls Workspace/KryptonWorkspaceSequence.cs @@ -362,7 +362,7 @@ public Size WorkspaceMaxSize { get { - Size maxSize = new Size(int.MaxValue, int.MaxValue); + var maxSize = new Size(int.MaxValue, int.MaxValue); // Search all children for the smallest defined maximum if (Children != null) @@ -373,7 +373,7 @@ public Size WorkspaceMaxSize if ((component is IWorkspaceItem { WorkspaceVisible: true } item)) { // Sequence maximum is the smallest min value of the children - Size itemMax = item.WorkspaceMaxSize; + var itemMax = item.WorkspaceMaxSize; if (itemMax.Width > 0) { maxSize.Width = Math.Min(maxSize.Width, itemMax.Width); @@ -553,14 +553,19 @@ public void LoadFromXml(KryptonWorkspace workspace, switch (xmlReader.Name) { case "WS": - KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(); + { + var sequence = new KryptonWorkspaceSequence(); sequence.LoadFromXml(workspace, xmlReader, existingPages); Children?.Add(sequence); + } break; + case "WC": - KryptonWorkspaceCell cell = new KryptonWorkspaceCell(); + { + var cell = new KryptonWorkspaceCell(); cell.LoadFromXml(workspace, xmlReader, existingPages); Children?.Add(cell); + } break; default: throw new ArgumentException("Unknown element was encountered."); diff --git a/Source/Krypton Components/Krypton.Workspace/Dragging/DragTargetWorkspace.cs b/Source/Krypton Components/Krypton.Workspace/Dragging/DragTargetWorkspace.cs index f12fad8e6..55fba83a2 100644 --- a/Source/Krypton Components/Krypton.Workspace/Dragging/DragTargetWorkspace.cs +++ b/Source/Krypton Components/Krypton.Workspace/Dragging/DragTargetWorkspace.cs @@ -81,7 +81,7 @@ protected override void Dispose(bool disposing) { // Use event to allow decision on if the page should be dropped // (or even swap the page for a different page to be dropped) - PageDropEventArgs e = new PageDropEventArgs(page); + var e = new PageDropEventArgs(page); workspace.OnPageDrop(e); if (e is { Cancel: false, Page: { } }) diff --git a/Source/Krypton Components/Krypton.Workspace/Dragging/DragTargetWorkspaceCellEdge.cs b/Source/Krypton Components/Krypton.Workspace/Dragging/DragTargetWorkspaceCellEdge.cs index 58080b625..5abb8e552 100644 --- a/Source/Krypton Components/Krypton.Workspace/Dragging/DragTargetWorkspaceCellEdge.cs +++ b/Source/Krypton Components/Krypton.Workspace/Dragging/DragTargetWorkspaceCellEdge.cs @@ -79,10 +79,10 @@ public override bool IsMatch(Point screenPt, PageDragEndData? dragEndData) if (_visibleNotDraggedPages == -1) { // If pages are being dragged from this cell - if (dragEndData.Navigator == Cell) + if (dragEndData?.Navigator == Cell) { // Create list of all the visible pages in the cell - KryptonPageCollection visiblePages = new KryptonPageCollection(); + var visiblePages = new KryptonPageCollection(); foreach (KryptonPage page in Cell.Pages) { if (page.LastVisibleSet) @@ -130,7 +130,7 @@ public override bool PerformDrop(Point screenPt, PageDragEndData? data) if (Cell.WorkspaceParent is KryptonWorkspaceSequence parent) { // Transfer the dragged pages into a new cell - KryptonWorkspaceCell cell = new KryptonWorkspaceCell(); + var cell = new KryptonWorkspaceCell(); KryptonPage? page = ProcessDragEndData(Workspace, cell, data); // If no pages are transferred then we do nothing and no longer need cell instance @@ -151,7 +151,7 @@ public override bool PerformDrop(Point screenPt, PageDragEndData? data) : Orientation.Horizontal; // Create a new sequence and transfer the target cell into it - KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(sequenceOrientation); + var sequence = new KryptonWorkspaceSequence(sequenceOrientation); var index = parent.Children.IndexOf(Cell); parent.Children.RemoveAt(index); sequence.Children.Add(Cell); diff --git a/Source/Krypton Components/Krypton.Workspace/Dragging/DragTargetWorkspaceEdge.cs b/Source/Krypton Components/Krypton.Workspace/Dragging/DragTargetWorkspaceEdge.cs index 955de6a94..006a97136 100644 --- a/Source/Krypton Components/Krypton.Workspace/Dragging/DragTargetWorkspaceEdge.cs +++ b/Source/Krypton Components/Krypton.Workspace/Dragging/DragTargetWorkspaceEdge.cs @@ -73,7 +73,7 @@ public DragTargetWorkspaceEdge(Rectangle screenRect, public override bool PerformDrop(Point screenPt, PageDragEndData? data) { // Transfer the dragged pages into a new cell - KryptonWorkspaceCell cell = new KryptonWorkspaceCell(); + var cell = new KryptonWorkspaceCell(); KryptonPage? page = ProcessDragEndData(Workspace, cell, data); // If no pages are transferred then we do nothing and no longer need cell instance @@ -89,7 +89,7 @@ public override bool PerformDrop(Point screenPt, PageDragEndData? data) (!dropHorizontal && (Workspace.Root.Orientation == Orientation.Horizontal))) { // Create a new sequence and place all existing root items into it - KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(Workspace.Root.Orientation); + var sequence = new KryptonWorkspaceSequence(Workspace.Root.Orientation); for (var i = Workspace.Root.Children.Count - 1; i >= 0; i--) { Component child = Workspace.Root.Children[i]; diff --git a/Source/Krypton Components/Krypton.Workspace/General/StarNumber.cs b/Source/Krypton Components/Krypton.Workspace/General/StarNumber.cs index 37d51ecb7..9410f2833 100644 --- a/Source/Krypton Components/Krypton.Workspace/General/StarNumber.cs +++ b/Source/Krypton Components/Krypton.Workspace/General/StarNumber.cs @@ -105,7 +105,7 @@ internal string PersistString { get { - StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); builder.Append(UsingStar ? "T," : "F,"); builder.Append($"{FixedSize},"); builder.Append(CommonHelper.DoubleToString(StarSize)); diff --git a/Source/Krypton Components/Krypton.Workspace/General/StarSize.cs b/Source/Krypton Components/Krypton.Workspace/General/StarSize.cs index 93e208d8b..d9844a6e7 100644 --- a/Source/Krypton Components/Krypton.Workspace/General/StarSize.cs +++ b/Source/Krypton Components/Krypton.Workspace/General/StarSize.cs @@ -71,8 +71,8 @@ public string Value } // Parse both halfs, exceptions are thrown if a problem occurs - StarNumber width = new StarNumber(parts[0]); - StarNumber height = new StarNumber(parts[1]); + var width = new StarNumber(parts[0]); + var height = new StarNumber(parts[1]); // No errors, so use the values StarWidth.Value = width.Value; diff --git a/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceActionList.cs b/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceActionList.cs index 57c1ef3d0..039d0c361 100644 --- a/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceActionList.cs +++ b/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Workspace internal class KryptonWorkspaceActionList : DesignerActionList { #region Instance Fields - private readonly KryptonWorkspace _workspace; + private readonly KryptonWorkspace? _workspace; private readonly IComponentChangeService _service; #endregion @@ -129,7 +129,7 @@ public PaletteMode PaletteMode /// A DesignerActionItem array that contains the items in this list. public override DesignerActionItemCollection GetSortedActionItems() { - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_workspace != null) diff --git a/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceCollectionEditor.cs b/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceCollectionEditor.cs index a79aa1838..e8722785f 100644 --- a/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceCollectionEditor.cs +++ b/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceCollectionEditor.cs @@ -695,12 +695,12 @@ public MenuTreeNode(Component item) /// /// Gets access to the associated workspace cell item. /// - public KryptonPage PageItem { get; } + public KryptonPage? PageItem { get; } /// /// Gets access to the associated workspace cell item. /// - public KryptonWorkspaceCell CellItem { get; } + public KryptonWorkspaceCell? CellItem { get; } /// /// Gets access to the associated workspace sequence item. @@ -1695,7 +1695,7 @@ private static void SeparatorToItems(ViewDrawWorkspaceSeparator separator, private void UpdateButtons() { - MenuTreeNode node = (MenuTreeNode)_treeView.SelectedNode; + var node = (MenuTreeNode)_treeView.SelectedNode; var isNone = (node == null); var isPage = node?.PageItem != null; var isCell = node?.CellItem != null; @@ -1718,7 +1718,7 @@ private void UpdatePropertyGrid() } else { - MenuTreeNode menuNode = (MenuTreeNode)node; + var menuNode = (MenuTreeNode)node; if (menuNode.PageItem != null) { @@ -1737,7 +1737,7 @@ private void UpdatePropertyGrid() private DictItemBase CreateItemsDictionary(object[] items) { - DictItemBase dictItems = new DictItemBase(); + var dictItems = new DictItemBase(); foreach (Component item in items) { @@ -1756,31 +1756,27 @@ private void AddItemsToDictionary(DictItemBase dictItems, Component baseItem) { // Add pages from a cell case KryptonWorkspaceCell cell: - { foreach (Component item in cell.Pages) { AddItemsToDictionary(dictItems, item); } break; - } // Add children from a sequence case KryptonWorkspaceSequence sequence: - { foreach (Component item in sequence.Children) { AddItemsToDictionary(dictItems, item); } break; - } } } - private void AddMenuTreeNode(Component item, MenuTreeNode parent) + private void AddMenuTreeNode(Component item, MenuTreeNode? parent) { // Create a node to match the item - MenuTreeNode node = new MenuTreeNode(item); + var node = new MenuTreeNode(item); // Add to either root or parent node if (parent != null) @@ -1796,24 +1792,20 @@ private void AddMenuTreeNode(Component item, MenuTreeNode parent) { // Add pages from a cell case KryptonWorkspaceCell cell: - { foreach (Component page in cell.Pages) { AddMenuTreeNode(page, node); } break; - } // Add children from a sequence case KryptonWorkspaceSequence sequence: - { foreach (Component child in sequence.Children) { AddMenuTreeNode(child, node); } break; - } } } @@ -1841,7 +1833,7 @@ private void SynchronizeCollections(DictItemBase before, } } - IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + IComponentChangeService? changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); if (changeService != null) { // Mark components as changed when not added or removed diff --git a/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceDesigner.cs b/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceDesigner.cs index c5244c154..fe7582072 100644 --- a/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceDesigner.cs +++ b/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceDesigner.cs @@ -15,7 +15,7 @@ namespace Krypton.Workspace internal class KryptonWorkspaceDesigner : ParentControlDesigner { #region Instance Fields - private KryptonWorkspace _workspace; + private KryptonWorkspace? _workspace; private IComponentChangeService _changeService; #endregion @@ -53,7 +53,7 @@ public override ICollection AssociatedComponents { get { - ArrayList compound = new ArrayList(); + var compound = new ArrayList(); if (_workspace != null) { @@ -72,9 +72,8 @@ public override DesignerActionListCollection ActionLists get { // Create a collection of action lists - DesignerActionListCollection actionLists = new DesignerActionListCollection + var actionLists = new DesignerActionListCollection { - // Add the navigator specific list new KryptonWorkspaceActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceSequenceDesigner.cs b/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceSequenceDesigner.cs index 95c4e1988..f09e4f7a0 100644 --- a/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceSequenceDesigner.cs +++ b/Source/Krypton Components/Krypton.Workspace/Workspace/KryptonWorkspaceSequenceDesigner.cs @@ -15,8 +15,8 @@ namespace Krypton.Workspace internal class KryptonWorkspaceSequenceDesigner : ComponentDesigner { #region Instance Fields - private KryptonWorkspaceSequence _sequence; - private IComponentChangeService _changeService; + private KryptonWorkspaceSequence? _sequence; + private IComponentChangeService? _changeService; #endregion #region Identity @@ -58,7 +58,7 @@ public override ICollection AssociatedComponents get { // Create a new compound array - ArrayList compound = new ArrayList(); + var compound = new ArrayList(); // Add the list of collection items compound.AddRange(_sequence.Children);