diff --git a/Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.sln.DotSettings b/Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.sln.DotSettings index 612fcf57d..5eac504b5 100644 --- a/Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.sln.DotSettings +++ b/Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.sln.DotSettings @@ -13,6 +13,8 @@ True True False + True + True True True True diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonBreadCrumb.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonBreadCrumb.cs index f2d92aaf2..86184a89f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonBreadCrumb.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonBreadCrumb.cs @@ -49,8 +49,8 @@ public BreadCrumbButtonSpecCollection(KryptonBreadCrumb owner) private bool _dropDownNavigaton; private float _cornerRoundingRadius; private readonly ViewDrawDocker _drawDocker; - private readonly ButtonSpecManagerDraw _buttonManager; - private VisualPopupToolTip _visualPopupToolTip; + private readonly ButtonSpecManagerDraw? _buttonManager; + private VisualPopupToolTip? _visualPopupToolTip; private KryptonBreadCrumbItem? _selectedItem; private readonly ViewLayoutCrumbs _layoutCrumbs; private ButtonStyle _buttonStyle; @@ -264,11 +264,11 @@ public override bool AutoSize [DefaultValue(true)] public bool UseMnemonic { - get => _buttonManager.UseMnemonic; + get => _buttonManager?.UseMnemonic?? true; set { - if (_buttonManager.UseMnemonic != value) + if (_buttonManager?.UseMnemonic != value) { _buttonManager.UseMnemonic = value; PerformNeedPaint(true); @@ -533,9 +533,9 @@ public bool DesignerGetHitTest(Point pt) /// Mouse location. [EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)] - public Component DesignerComponentFromPoint(Point pt) => + public Component? DesignerComponentFromPoint(Point pt) => // Ignore call as view builder is already destructed - IsDisposed ? null : ViewManager.ComponentFromPoint(pt); + IsDisposed ? null : ViewManager?.ComponentFromPoint(pt); // Ask the current view for a decision /// @@ -598,7 +598,7 @@ protected override void OnEnabledChanged(EventArgs e) _drawDocker.Enabled = Enabled; // Update state to reflect change in enabled state - _buttonManager.RefreshButtons(); + _buttonManager?.RefreshButtons(); // Change in enabled state requires a layout and repaint PerformNeedPaint(true); @@ -620,7 +620,7 @@ protected override void OnEnabledChanged(EventArgs e) protected override void OnButtonSpecChanged(object sender, EventArgs e) { // Recreate all the button specs with new values - _buttonManager.RecreateButtons(); + _buttonManager?.RecreateButtons(); // Let base class perform standard processing base.OnButtonSpecChanged(sender, e); @@ -709,7 +709,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) bool shadow = true; // Find the button spec associated with the tooltip request - ButtonSpec? buttonSpec = _buttonManager.ButtonSpecFromView(e.Target); + ButtonSpec? buttonSpec = _buttonManager?.ButtonSpecFromView(e.Target); // If the tooltip is for a button spec if (buttonSpec != null) @@ -718,7 +718,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/Controls Toolkit/KryptonButton.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonButton.cs index fdd3be19c..feb5062a9 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonButton.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonButton.cs @@ -826,7 +826,7 @@ protected override void OnPaint(PaintEventArgs e) int internalBorder = BORDER_SIZE; - Rectangle focusRectangle = new Rectangle(internalBorder, internalBorder, + var focusRectangle = new Rectangle(internalBorder, internalBorder, bounds.Width - _dropDownRectangle.Width - internalBorder, bounds.Height - (internalBorder * 2)); PaletteBase? palette = KryptonManager.CurrentGlobalPalette; @@ -1115,13 +1115,17 @@ private void UpdateOSUACShieldIcon(UACShieldIconSize? iconSize = null, Size? cus private static void PaintArrow(Graphics graphics, Rectangle rectangle) { - Point midPoint = new Point(Convert.ToInt32(rectangle.Left + rectangle.Width / 2), + var midPoint = new Point(Convert.ToInt32(rectangle.Left + rectangle.Width / 2), Convert.ToInt32(rectangle.Top + rectangle.Height / 2)); midPoint.X += (rectangle.Width % 2); - Point[] arrow = new Point[] { new Point(midPoint.X - 2, midPoint.Y - 1), - new Point(midPoint.X + 3, midPoint.Y - 1), new Point(midPoint.X, midPoint.Y + 2) }; + var arrow = new Point[] + { + new Point(midPoint.X - 2, midPoint.Y - 1), + new Point(midPoint.X + 3, midPoint.Y - 1), + new Point(midPoint.X, midPoint.Y + 2) + }; graphics.FillPolygon(SystemBrushes.ControlText, arrow); } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCheckButton.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCheckButton.cs index 84b75c543..aaa4c8318 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCheckButton.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCheckButton.cs @@ -121,7 +121,7 @@ public bool Checked if (value != ViewDrawButton.Checked) { // Generate a pre-change event allowing it to be cancelled - CancelEventArgs ce = new CancelEventArgs(); + var ce = new CancelEventArgs(); OnCheckedChanging(ce); // If the change is allowed to occur diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCheckedListBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCheckedListBox.cs index 7485eef8d..b32b7b071 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCheckedListBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCheckedListBox.cs @@ -569,7 +569,7 @@ protected override void OnLayout(LayoutEventArgs levent) base.OnLayout(levent); // Ask the panel to layout given our available size - using ViewLayoutContext context = new ViewLayoutContext(_viewManager, this, _kryptonCheckedListBox, + using var context = new ViewLayoutContext(_viewManager, this, _kryptonCheckedListBox, _kryptonCheckedListBox.Renderer); ViewDrawPanel.Layout(context); } @@ -645,7 +645,7 @@ protected override void WndProc(ref Message m) else { // Find the item under the mouse - Point mousePoint = new Point((int)m.LParam.ToInt64()); + var mousePoint = new Point((int)m.LParam.ToInt64()); var mouseIndex = IndexFromPoint(mousePoint); // If we have an actual item from the point @@ -813,7 +813,7 @@ internal IEnumerator InnerArrayGetEnumerator(int stateMask, bool anyBit) #region Private private void WmPaint(ref Message m) { - PI.PAINTSTRUCT ps = new PI.PAINTSTRUCT(); + var ps = new PI.PAINTSTRUCT(); // Do we need to BeginPaint or just take the given HDC? IntPtr hdc = m.WParam == IntPtr.Zero ? PI.BeginPaint(Handle, ref ps) : m.WParam; @@ -839,14 +839,13 @@ private void WmPaint(ref Message m) using (Graphics g = Graphics.FromHdc(_screenDC)) { // Ask the view element to layout in given space, needs this before a render call - using (ViewLayoutContext context = - new ViewLayoutContext(this, _kryptonCheckedListBox.Renderer)) + using (var context = new ViewLayoutContext(this, _kryptonCheckedListBox.Renderer)) { context.DisplayRectangle = realRect; ViewDrawPanel.Layout(context); } - using (RenderContext context = new RenderContext(this, _kryptonCheckedListBox, g, + using (var context = new RenderContext(this, _kryptonCheckedListBox, g, realRect, _kryptonCheckedListBox.Renderer)) { ViewDrawPanel.Render(context); @@ -860,7 +859,7 @@ private void WmPaint(ref Message m) if (Items.Count == 0) { - using RenderContext context = new RenderContext(this, _kryptonCheckedListBox, g, + using var context = new RenderContext(this, _kryptonCheckedListBox, g, realRect, _kryptonCheckedListBox.Renderer); ViewDrawPanel.Render(context); } @@ -869,12 +868,12 @@ private void WmPaint(ref Message m) // Now blit from the bitmap from the screen to the real dc PI.BitBlt(hdc, 0, 0, realRect.Width, realRect.Height, _screenDC, 0, 0, PI.SRCCOPY); - // When disabled with no items the above code does not draw the backround! Strange but true and + // When disabled with no items the above code does not draw the background! Strange but true and // so we need to draw the background instead directly, without using a bit blitting of bitmap if (Items.Count == 0) { using Graphics g = Graphics.FromHdc(hdc); - using RenderContext context = new RenderContext(this, _kryptonCheckedListBox, g, + using var context = new RenderContext(this, _kryptonCheckedListBox, g, realRect, _kryptonCheckedListBox.Renderer); ViewDrawPanel.Render(context); } @@ -926,7 +925,7 @@ private void LbnSelChange() { CheckState checkedState = _kryptonCheckedListBox.GetItemCheckState(selectedIndex); CheckState newCheckValue = (checkedState != CheckState.Unchecked) ? CheckState.Unchecked : CheckState.Checked; - ItemCheckEventArgs ice = new ItemCheckEventArgs(selectedIndex, newCheckValue, checkedState); + var ice = new ItemCheckEventArgs(selectedIndex, newCheckValue, checkedState); _kryptonCheckedListBox.SetItemCheckState(selectedIndex, ice.NewValue); } _lastSelected = selectedIndex; @@ -1791,7 +1790,7 @@ public void SetItemCheckState(int index, CheckState value) if (value != checkedState) { // Give developers a chance to see and alter the change - ItemCheckEventArgs ice = new ItemCheckEventArgs(index, value, checkedState); + var ice = new ItemCheckEventArgs(index, value, checkedState); OnItemCheck(ice); // If a change is still occurring @@ -2308,7 +2307,7 @@ private void OnListBoxDrawItem(object sender, DrawItemEventArgs e) // Easier to draw using a graphics instance than a DC! using Graphics g = Graphics.FromHdc(_screenDC); // Ask the view element to layout in given space, needs this before a render call - using (ViewLayoutContext context = new ViewLayoutContext(this, Renderer)) + using (var context = new ViewLayoutContext(this, Renderer)) { context.DisplayRectangle = e.Bounds; _listBox.ViewDrawPanel.Layout(context); @@ -2316,7 +2315,7 @@ private void OnListBoxDrawItem(object sender, DrawItemEventArgs e) } // Ask the view element to actually draw - using (RenderContext context = new RenderContext(this, g, e.Bounds, Renderer)) + using (var context = new RenderContext(this, g, e.Bounds, Renderer)) { _listBox.ViewDrawPanel.Render(context); _layoutDocker.Render(context); @@ -2344,7 +2343,7 @@ private void OnListBoxMeasureItem(object sender, MeasureItemEventArgs e) UpdateContentFromItemIndex(e.Index); // Ask the view element to layout in given space, needs this before a render call - using ViewLayoutContext context = new ViewLayoutContext(this, Renderer); + using var context = new ViewLayoutContext(this, Renderer); Size size = _layoutDocker.GetPreferredSize(context); e.ItemWidth = size.Width; e.ItemHeight = size.Height; diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonColorButton.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonColorButton.cs index 23afc2c2d..fed373188 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonColorButton.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonColorButton.cs @@ -1191,7 +1191,7 @@ private bool ShowDropDown() } // Package up the context menu and positioning values we will use later - ContextPositionMenuArgs cpma = new ContextPositionMenuArgs(null, + var cpma = new ContextPositionMenuArgs(null, _kryptonContextMenu, GetPositionH(), GetPositionV()); // Let use examine and later values OnDropDown(cpma); @@ -1480,14 +1480,14 @@ private void DecideOnVisible(KryptonContextMenuItemBase visible, KryptonContextM private void OnClickMoreColors(object sender, EventArgs e) { // Give user a chance to cancel showing the Krypton more colors dialog - CancelEventArgs cea = new CancelEventArgs(); + var cea = new CancelEventArgs(); OnMoreColors(cea); // If not instructed to cancel then... if (!cea.Cancel) { // Use a Krypton color dialog for the selection of custom colors - KryptonColorDialog cd = new KryptonColorDialog + var cd = new KryptonColorDialog { Color = SelectedColor, FullOpen = _allowFullOpen diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonComboBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonComboBox.cs index 0223f6481..a15730e14 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonComboBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonComboBox.cs @@ -290,11 +290,11 @@ protected override void WndProc(ref Message m) rect.bottom -= borderSize.Height; // Create rectangle that represents the drop down button - Rectangle dropRect = new Rectangle(rect.right + 2, rect.top, dropDownWidth - 2, + var dropRect = new Rectangle(rect.right + 2, rect.top, dropDownWidth - 2, rect.bottom - rect.top); // Extract the point in client coordinates - Point clientPoint = new Point((int)m.LParam); + var clientPoint = new Point((int)m.LParam); var mouseTracking = dropRect.Contains(clientPoint); if (mouseTracking != _mouseTracking) { @@ -311,7 +311,7 @@ protected override void WndProc(ref Message m) { PI.SendMessage(Handle, PI.CB_SETCUEBANNER, IntPtr.Zero, _kryptonComboBox.CueHint.CueHintText); } - PI.PAINTSTRUCT ps = new PI.PAINTSTRUCT(); + var ps = new PI.PAINTSTRUCT(); // Do we need to BeginPaint or just take the given HDC? IntPtr hdc = m.WParam == IntPtr.Zero ? PI.BeginPaint(Handle, ref ps) : m.WParam; @@ -347,7 +347,7 @@ protected override void WndProc(ref Message m) PaletteInputControlTripleStates states = _kryptonComboBox.GetComboBoxTripleState(); // Drawn entire client area in the background color - using SolidBrush backBrush = new SolidBrush(states.PaletteBack.GetBackColor1(state)); + using var backBrush = new SolidBrush(states.PaletteBack.GetBackColor1(state)); g.FillRectangle(backBrush, new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top)); // Get the constant used to crack open the display @@ -420,7 +420,7 @@ protected override void WndProc(ref Message m) } // Draw text using font defined by the control - Rectangle rectangle = new Rectangle(rect.left, rect.top, rect.right - rect.left, + var rectangle = new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); rectangle = CommonHelper.ApplyPadding(VisualOrientation.Top, rectangle, states.Content.GetContentPadding(state)); // Find correct text color @@ -455,7 +455,7 @@ protected override void WndProc(ref Message m) if (_kryptonComboBox.KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) @@ -545,8 +545,7 @@ private void DrawDropButton(Graphics? g, Rectangle drawRect) _viewButton.ElementState = state; // Position the button element inside the available drop down button area - using (ViewLayoutContext layoutContext = - new ViewLayoutContext(_kryptonComboBox, _kryptonComboBox.Renderer)) + using (var layoutContext = new ViewLayoutContext(_kryptonComboBox, _kryptonComboBox.Renderer)) { // Define the available area for layout layoutContext.DisplayRectangle = drawRect; @@ -556,14 +555,13 @@ private void DrawDropButton(Graphics? g, Rectangle drawRect) } // Fill background with the solid background color - using (SolidBrush backBrush = new SolidBrush(BackColor)) + using (var backBrush = new SolidBrush(BackColor)) { g.FillRectangle(backBrush, drawRect); } // Ask the element to draw now - using (RenderContext renderContext = - new RenderContext(_kryptonComboBox, g, drawRect, _kryptonComboBox.Renderer)) + using (var renderContext = new RenderContext(_kryptonComboBox, g, drawRect, _kryptonComboBox.Renderer)) { // Ask the button element to draw itself _viewButton.Render(renderContext); @@ -703,7 +701,7 @@ protected override void WndProc(ref Message m) // Mouse is over the control if (!MouseOver) { - PI.TRACKMOUSEEVENTS tme = new PI.TRACKMOUSEEVENTS + var tme = new PI.TRACKMOUSEEVENTS { // This structure needs to know its own size in bytes @@ -730,7 +728,7 @@ protected override void WndProc(ref Message m) if (_kryptonComboBox.KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) @@ -2289,7 +2287,7 @@ protected virtual void OnHoverSelectionChanged(HoveredSelectionChangedEventArgs { HoveredSelectionChanged?.Invoke(this, e); // See if there is a tooltip to display for the new selection. - ToolTipNeededEventArgs args = new ToolTipNeededEventArgs(e.Index, e.Item); + var args = new ToolTipNeededEventArgs(e.Index, e.Item); OnToolTipNeeded(args); if (!args.IsEmpty) { @@ -2820,8 +2818,7 @@ private void OnComboBoxDrawItem(object sender, DrawItemEventArgs e) { _hoverIndex = e.Index; // Raise the Hover event - HoveredSelectionChangedEventArgs ev = - new HoveredSelectionChangedEventArgs(e.Bounds, e.Index, Items[e.Index]); + var ev = new HoveredSelectionChangedEventArgs(e.Bounds, e.Index, Items[e.Index]); OnHoverSelectionChanged(ev); } } @@ -2850,7 +2847,7 @@ private void OnComboBoxDrawItem(object sender, DrawItemEventArgs e) // Easier to draw using a graphics instance than a DC! using Graphics g = Graphics.FromHdc(_screenDC); // Ask the view element to layout in given space, needs this before a render call - using (ViewLayoutContext context = new ViewLayoutContext(this, Renderer)) + using (var context = new ViewLayoutContext(this, Renderer)) { context.DisplayRectangle = drawBounds; _drawPanel.Layout(context); @@ -2858,7 +2855,7 @@ private void OnComboBoxDrawItem(object sender, DrawItemEventArgs e) } // Ask the view element to actually draw - using (RenderContext context = new RenderContext(this, g, drawBounds, Renderer)) + using (var context = new RenderContext(this, g, drawBounds, Renderer)) { _drawPanel.Render(context); _drawButton.Render(context); @@ -2888,7 +2885,7 @@ private void OnComboBoxMeasureItem(object sender, MeasureItemEventArgs e) UpdateContentFromItemIndex(e.Index); // Ask the view element to layout in given space, needs this before a render call - using ViewLayoutContext context = new ViewLayoutContext(this, Renderer); + using var context = new ViewLayoutContext(this, Renderer); Size size = _drawButton.GetPreferredSize(context); e.ItemWidth = size.Width; e.ItemHeight = size.Height; @@ -3070,7 +3067,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) @@ -3129,7 +3126,7 @@ private VisualPopupToolTip GetToolTip() return _toolTip; } - PaletteRedirect redirector = new PaletteRedirect(KryptonManager.CurrentGlobalPalette); + var redirector = new PaletteRedirect(KryptonManager.CurrentGlobalPalette); _toolTip = new VisualPopupToolTip(redirector, new ButtonSpecToContent(redirector, _toolTipSpec), KryptonManager .CurrentGlobalPalette.GetRenderer(), @@ -3145,7 +3142,7 @@ private void ShowToolTip(ToolTipNeededEventArgs e, Point location) VisualPopupToolTip tip = GetToolTip(); // Needed to make Krypton update the tooltip data with the data of the spec. tip.PerformNeedPaint(true); - Point point = new Point(location.X + DropDownWidth, location.Y); + var point = new Point(location.X + DropDownWidth, location.Y); tip.ShowCalculatingSize(PointToScreen(point)); } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonContextMenu.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonContextMenu.cs index 61fcfaea1..8637a90e5 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonContextMenu.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonContextMenu.cs @@ -354,7 +354,7 @@ public bool Show(object caller, Caller = caller; // Give event handler a change to cancel the open request - CancelEventArgs cea = new CancelEventArgs(); + var cea = new CancelEventArgs(); OnOpening(cea); if (!cea.Cancel) @@ -470,7 +470,7 @@ protected virtual VisualContextMenu CreateContextMenu(KryptonContextMenu kcm, #region Internal internal ToolStripDropDownCloseReason CloseReason { get; set; } - internal VisualContextMenu VisualContextMenu { get; private set; } + internal VisualContextMenu? VisualContextMenu { get; private set; } #endregion diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCustomPaletteBase.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCustomPaletteBase.cs index 39b198d37..387fc8db2 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCustomPaletteBase.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCustomPaletteBase.cs @@ -2053,7 +2053,7 @@ public void PopulateFromBase(bool silent) { if (UseKryptonFileDialogs) { - using KryptonOpenFileDialog kofd = new KryptonOpenFileDialog + using var kofd = new KryptonOpenFileDialog { CheckFileExists = true, CheckPathExists = true, @@ -2078,7 +2078,7 @@ public void PopulateFromBase(bool silent) } else { - using OpenFileDialog dialog = new OpenFileDialog + using var dialog = new OpenFileDialog { // Palette files are just XML documents CheckFileExists = true, @@ -2282,7 +2282,7 @@ public void Import(byte[] byteArray, bool silent) { if (UseKryptonFileDialogs) { - using KryptonSaveFileDialog ksfd = new KryptonSaveFileDialog + using var ksfd = new KryptonSaveFileDialog { OverwritePrompt = true, DefaultExt = @"xml", @@ -2299,7 +2299,7 @@ public void Import(byte[] byteArray, bool silent) } else { - using SaveFileDialog dialog = new SaveFileDialog + using var dialog = new SaveFileDialog { // Palette files are just xml documents OverwritePrompt = true, @@ -2950,7 +2950,7 @@ private object ImportFromFile(object parameter) } // Create a new xml document for storing the palette settings - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); // Attempt to load as a valid xml document doc.Load(filename); @@ -2964,10 +2964,10 @@ private object ImportFromFile(object parameter) private object ImportFromStream(object parameter) { // Cast to correct type - Stream stream = (Stream)parameter; + var stream = (Stream)parameter; // Create a new xml document for storing the palette settings - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); // Attempt to load from the provided stream doc.Load(stream); @@ -2984,7 +2984,7 @@ private object ImportFromStream(object parameter) var byteArray = (byte[])parameter; // Create a memory based stream - MemoryStream ms = new MemoryStream(byteArray); + using var ms = new MemoryStream(byteArray); // Perform import from the memory stream ImportFromStream(ms); @@ -3050,7 +3050,7 @@ private void ImportFromXmlDocument(XmlDocument doc) } // Cache the images from the images element - ImageReverseDictionary imageCache = new ImageReverseDictionary(); + var imageCache = new ImageReverseDictionary(); // Use reflection to import the palette hierarchy ImportImagesFromElement(images, imageCache); @@ -3072,7 +3072,7 @@ private object ExportToFile(object parameter) var filename = (string)parameters[0]; var ignoreDefaults = (bool)parameters[1]; - FileInfo info = new FileInfo(filename); + var info = new FileInfo(filename); // Check the target directory actually exists if (info.Directory != null && !info.Directory.Exists) @@ -3116,7 +3116,7 @@ private object ExportToByteArray(object parameter) var ignoreDefaults = (bool)parameters[0]; // Create a memory based stream - MemoryStream ms = new MemoryStream(); + using var ms = new MemoryStream(); // Perform export into the memory stream ExportToStream(new object[] { ms, ignoreDefaults }); @@ -3139,7 +3139,7 @@ private XmlDocument ExportToXmlDocument(bool ignoreDefaults) Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; // Create a new xml document for storing the palette settings - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); // Add the standard xml version number doc.AppendChild(doc.CreateProcessingInstruction("xml", @"version=""1.0""")); @@ -3164,7 +3164,7 @@ private XmlDocument ExportToXmlDocument(bool ignoreDefaults) root.AppendChild(images); // Cache any images that are found during object export - ImageDictionary imageCache = new ImageDictionary(); + var imageCache = new ImageDictionary(); // Use reflection to export the palette hierarchy ExportObjectToElement(doc, props, imageCache, this, ignoreDefaults); @@ -3308,7 +3308,7 @@ private void ImportImagesFromElement(XmlElement element, ImageReverseDictionary var bytes = Convert.FromBase64String(cdata.Value); // Convert the bytes back into an Image - MemoryStream memory = new MemoryStream(bytes); + using var memory = new MemoryStream(bytes); Bitmap resurect; try { @@ -3319,7 +3319,7 @@ private void ImportImagesFromElement(XmlElement element, ImageReverseDictionary // Do the old way // SYSLIB0011: BinaryFormatter serialization is obsolete #pragma warning disable SYSLIB0011 - BinaryFormatter formatter = new BinaryFormatter(); + var formatter = new BinaryFormatter(); var old = (Image)formatter.Deserialize(memory); #pragma warning restore SYSLIB0011 resurect = old is Bitmap bitmap ? bitmap : new Bitmap(old); @@ -3495,7 +3495,7 @@ private void ExportImagesToElement(XmlDocument doc, XmlElement element, ImageDic try { // Convert the Image into base64 so it can be used in xml - using MemoryStream memory = new MemoryStream(); + using var memory = new MemoryStream(); var imageFormat = entry.Key.RawFormat; diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCustomPaletteManager.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCustomPaletteManager.cs index 56ca8838a..30a479a59 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCustomPaletteManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonCustomPaletteManager.cs @@ -53,7 +53,7 @@ public KryptonCustomPaletteManager() public static void LoadExternalPalette(PaletteBase palette) { - KryptonCustomPaletteManager pm = new KryptonCustomPaletteManager(); + var pm = new KryptonCustomPaletteManager(); try { diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridView.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridView.cs index 803e2149b..5f65363b3 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridView.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridView.cs @@ -668,7 +668,7 @@ public virtual PaletteState GetCellTriple(DataGridViewElementStates state, // A data cell cannot become tracking or pressed if ((rowIndex < 0) || (columnIndex < 0)) { - Point cellIndex = new Point(columnIndex, rowIndex); + var cellIndex = new Point(columnIndex, rowIndex); // If the user has pressed down on this cell if (cellIndex.Equals(_cellDown)) @@ -1181,14 +1181,14 @@ protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e) var rtl = RightToLeftInternal; // Use an offscreen bitmap to draw onto before blitting it to the screen - Rectangle tempCellBounds = new Rectangle(0, 0, e.CellBounds.Width, e.CellBounds.Height); - using (Bitmap tempBitmap = new Bitmap(e.CellBounds.Width, e.CellBounds.Height, e.Graphics)) + var tempCellBounds = new Rectangle(0, 0, e.CellBounds.Width, e.CellBounds.Height); + using (var tempBitmap = new Bitmap(e.CellBounds.Width, e.CellBounds.Height, e.Graphics)) { using (Graphics tempG = Graphics.FromImage(tempBitmap)) { - using (RenderContext renderContext = new RenderContext(this, tempG, tempCellBounds, Renderer)) + using (var renderContext = new RenderContext(this, tempG, tempCellBounds, Renderer)) { - // Force the border to have a specificed maximum border edge + // Force the border to have a specified maximum border edge _borderForced.SetInherit(paletteBorder); _borderForced.MaxBorderEdges = GetCellMaxBorderEdges(e.CellBounds, e.ColumnIndex, e.RowIndex); @@ -1238,7 +1238,7 @@ protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e) // Draw icon and update the remainder cell bounds left over var iconWidth = spec.Icon.Width + 5; var width = tempCellBounds.Width - iconWidth; - Rectangle iconBounds = new Rectangle( + var iconBounds = new Rectangle( tempCellBounds.X + (spec.Alignment == IconSpec.IconAlignment.Left ? 5 : width), tempCellBounds.Y + 3, spec.Icon.Width, spec.Icon.Height); @@ -1254,7 +1254,7 @@ protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e) case { RowIndex: >= 0, ColumnIndex: -1 }: { // By default there is no glyph needed for the row - GridRowGlyph glpyh = GridRowGlyph.None; + GridRowGlyph glyph = GridRowGlyph.None; // Find the correct glyph that should be drawn if (CurrentCellAddress.Y == e.RowIndex) @@ -1263,40 +1263,40 @@ protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e) { if (IsCurrentRowDirty && ShowEditingIcon) { - glpyh = GridRowGlyph.Pencil; + glyph = GridRowGlyph.Pencil; } else if (NewRowIndex == e.RowIndex) { - glpyh = GridRowGlyph.ArrowStar; + glyph = GridRowGlyph.ArrowStar; } else { - glpyh = GridRowGlyph.Arrow; + glyph = GridRowGlyph.Arrow; } } else if (IsCurrentCellDirty && ShowEditingIcon) { - glpyh = GridRowGlyph.Pencil; + glyph = GridRowGlyph.Pencil; } else if (NewRowIndex == e.RowIndex) { - glpyh = GridRowGlyph.ArrowStar; + glyph = GridRowGlyph.ArrowStar; } else { - glpyh = GridRowGlyph.Arrow; + glyph = GridRowGlyph.Arrow; } } else if (NewRowIndex == e.RowIndex) { - glpyh = GridRowGlyph.Star; + glyph = GridRowGlyph.Star; } // Do we need to draw an image? - if (glpyh != GridRowGlyph.None) + if (glyph != GridRowGlyph.None) { // Draw the row glyph and update the remainder cell bounds left over - tempCellBounds = Renderer.RenderGlyph.DrawGridRowGlyph(renderContext, glpyh, tempCellBounds, paletteContent, state, rtl); + tempCellBounds = Renderer.RenderGlyph.DrawGridRowGlyph(renderContext, glyph, tempCellBounds, paletteContent, state, rtl); } // Is there an error icon associated with the row that needs showing @@ -1306,8 +1306,8 @@ protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e) Rectangle beforeCellBounds = tempCellBounds; tempCellBounds = Renderer.RenderGlyph.DrawGridErrorGlyph(renderContext, tempCellBounds, state, rtl); - // Calculate the icon rectangle - Rectangle iconBounds = new Rectangle(tempCellBounds.Right + 1, tempCellBounds.Top, + // Calculate the icon rectangle + var iconBounds = new Rectangle(tempCellBounds.Right + 1, tempCellBounds.Top, beforeCellBounds.Width - tempCellBounds.Width, tempCellBounds.Height); // Cache the icon area @@ -1347,7 +1347,7 @@ protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e) // Draw icon and update the remainder cell bounds left over var iconWidth = spec.Icon.Width + 5; var width = tempCellBounds.Width - iconWidth; - Rectangle iconBounds = new Rectangle( + var iconBounds = new Rectangle( tempCellBounds.X + (spec.Alignment == IconSpec.IconAlignment.Left ? 5 : width), tempCellBounds.Y + 3, spec.Icon.Width, spec.Icon.Height); @@ -1386,7 +1386,7 @@ protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e) var sCount = 1; while (sindx >= 0) { - Rectangle hl_rect = new Rectangle + var hl_rect = new Rectangle { Y = e.CellBounds.Y + 2, Height = e.CellBounds.Height - 5 @@ -1420,7 +1420,7 @@ protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e) // hl_rect.Width = s2.Width - 6; //} - SolidBrush hl_brush = + var hl_brush = (e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.None ? new SolidBrush(Color.DarkGoldenrod) @@ -1446,7 +1446,7 @@ protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e) // Use the display value of the header cell _shortTextValue.ShortText = e.FormattedValue.ToString(); - using ViewLayoutContext layoutContext = new ViewLayoutContext(this, Renderer); + using var layoutContext = new ViewLayoutContext(this, Renderer); // If a column header cell... if ((e.RowIndex == -1) && (e.ColumnIndex != -1)) { @@ -1556,7 +1556,7 @@ protected override void PaintBackground(Graphics graphics, PaintTransparentBackground(graphics, clipBounds); // Use the view manager to paint the view panel that fills the entire areas as the background - using RenderContext context = new RenderContext(this, graphics, clipBounds, Renderer); + using var context = new RenderContext(this, graphics, clipBounds, Renderer); ViewManager.Paint(context); } @@ -2494,7 +2494,7 @@ private string TruncateToolTipText(string toolTipText) { if (toolTipText.Length > 0x120) { - StringBuilder builder = new StringBuilder(toolTipText.Substring(0, 0x100), 0x103); + var builder = new StringBuilder(toolTipText.Substring(0, 0x100), 0x103); builder.Append(@"..."); return builder.ToString(); } @@ -2661,7 +2661,7 @@ protected override void WndProc(ref Message m) if (KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewButtonCell.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewButtonCell.cs index 931de25e4..a508744f3 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewButtonCell.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewButtonCell.cs @@ -155,7 +155,7 @@ protected override Size GetPreferredSize(Graphics graphics, } // Position the button element inside the available cell area - using ViewLayoutContext layoutContext = new ViewLayoutContext(kDGV, kDGV.Renderer); + using var layoutContext = new ViewLayoutContext(kDGV, kDGV.Renderer); // Define the available area for layout layoutContext.DisplayRectangle = new Rectangle(0, 0, int.MaxValue, int.MaxValue); @@ -206,7 +206,7 @@ protected override void Paint(Graphics graphics, // Should we draw the content foreground? if ((paintParts & DataGridViewPaintParts.ContentForeground) == DataGridViewPaintParts.ContentForeground) { - using RenderContext renderContext = new RenderContext(kDgv, graphics, cellBounds, kDgv.Renderer); + using var renderContext = new RenderContext(kDgv, graphics, cellBounds, kDgv.Renderer); // Create the view elements and palette structure CreateViewAndPalettes(kDgv); @@ -279,7 +279,7 @@ protected override void Paint(Graphics graphics, cellBounds.Height -= cellStyle.Padding.Vertical; // Position the button element inside the available cell area - using (ViewLayoutContext layoutContext = new ViewLayoutContext(kDgv, kDgv.Renderer)) + using (var layoutContext = new ViewLayoutContext(kDgv, kDgv.Renderer)) { // Define the available area for layout layoutContext.DisplayRectangle = cellBounds; diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewButtonColumn.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewButtonColumn.cs index 50a3c909a..681fdcbc7 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewButtonColumn.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewButtonColumn.cs @@ -34,7 +34,7 @@ public class KryptonDataGridViewButtonColumn : KryptonDataGridViewIconColumn public KryptonDataGridViewButtonColumn() : base(new KryptonDataGridViewButtonCell()) { - DataGridViewCellStyle style = new DataGridViewCellStyle + var style = new DataGridViewCellStyle { Alignment = DataGridViewContentAlignment.MiddleCenter }; @@ -47,7 +47,7 @@ public KryptonDataGridViewButtonColumn() /// A String that represents the current Object. public override string ToString() { - StringBuilder builder = new StringBuilder(0x40); + var builder = new StringBuilder(0x40); builder.Append(@"KryptonDataGridViewButtonColumn { Name="); // ReSharper disable RedundantBaseQualifier builder.Append(base.Name); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewCheckBoxCell.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewCheckBoxCell.cs index 7ec33f193..47def0c90 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewCheckBoxCell.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewCheckBoxCell.cs @@ -91,7 +91,7 @@ protected override Size GetPreferredSize(Graphics graphics, var pressed = currentCell && ((ButtonStateInternal & ButtonState.Pushed) == ButtonState.Pushed); // Find out the requested size of the check box drawing - using ViewLayoutContext viewContent = new ViewLayoutContext(kDGV, kDGV.Renderer); + using var viewContent = new ViewLayoutContext(kDGV, kDGV.Renderer); Size checkBoxSize = kDGV.Renderer.RenderGlyph.GetCheckBoxPreferredSize(viewContent, kDGV.Redirector, kDGV.Enabled, @@ -171,11 +171,11 @@ protected override void Paint(Graphics graphics, var tracking = mouseCell && MouseInContentBoundsInternal; var pressed = currentCell && ((ButtonStateInternal & ButtonState.Pushed) == ButtonState.Pushed); - using RenderContext renderContext = new RenderContext(kDgv, graphics, cellBounds, kDgv.Renderer); + using var renderContext = new RenderContext(kDgv, graphics, cellBounds, kDgv.Renderer); Size checkBoxSize; // Find out the requested size of the check box drawing - using (ViewLayoutContext viewContent = new ViewLayoutContext(kDgv, kDgv.Renderer)) + using (var viewContent = new ViewLayoutContext(kDgv, kDgv.Renderer)) { checkBoxSize = renderContext.Renderer.RenderGlyph.GetCheckBoxPreferredSize(viewContent, kDgv.Redirector, diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewCheckBoxColumn.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewCheckBoxColumn.cs index b1127ad7b..bb1660f62 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewCheckBoxColumn.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewCheckBoxColumn.cs @@ -37,7 +37,7 @@ public KryptonDataGridViewCheckBoxColumn() public KryptonDataGridViewCheckBoxColumn(bool threeState) : base(new KryptonDataGridViewCheckBoxCell(threeState)) { - DataGridViewCellStyle style = new DataGridViewCellStyle + var style = new DataGridViewCellStyle { Alignment = DataGridViewContentAlignment.MiddleCenter }; @@ -59,7 +59,7 @@ public KryptonDataGridViewCheckBoxColumn(bool threeState) /// A String that represents the current Object. public override string ToString() { - StringBuilder builder = new StringBuilder(0x40); + var builder = new StringBuilder(0x40); builder.Append(@"KryptonDataGridViewCheckBoxColumn { Name="); // ReSharper disable RedundantBaseQualifier builder.Append(base.Name); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewComboBoxColumn.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewComboBoxColumn.cs index 18b42583b..b7b5b38ca 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewComboBoxColumn.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewComboBoxColumn.cs @@ -37,7 +37,7 @@ public KryptonDataGridViewComboBoxColumn() /// public override string ToString() { - StringBuilder builder = new StringBuilder(0x40); + var builder = new StringBuilder(0x40); builder.Append(@"KryptonDataGridViewComboBoxColumn { Name="); // ReSharper disable RedundantBaseQualifier builder.Append(base.Name); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewDateTimePickerColumn.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewDateTimePickerColumn.cs index 04da764af..8819ab452 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewDateTimePickerColumn.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewDateTimePickerColumn.cs @@ -43,7 +43,7 @@ public KryptonDataGridViewDateTimePickerColumn() /// public override string ToString() { - StringBuilder builder = new StringBuilder(0x40); + var builder = new StringBuilder(0x40); builder.Append("KryptonDataGridViewDateTimePickerColumn { Name="); // ReSharper disable RedundantBaseQualifier builder.Append(base.Name); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewDomainUpDownColumn.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewDomainUpDownColumn.cs index 2adc29c33..11be5ec0e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewDomainUpDownColumn.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewDomainUpDownColumn.cs @@ -32,7 +32,7 @@ public KryptonDataGridViewDomainUpDownColumn() /// public override string ToString() { - StringBuilder builder = new StringBuilder(0x40); + var builder = new StringBuilder(0x40); builder.Append(@"KryptonDataGridViewDomainUpDownColumn { Name="); // ReSharper disable RedundantBaseQualifier builder.Append(base.Name); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewIconColumn.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewIconColumn.cs index a1e5b0183..feb56820c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewIconColumn.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewIconColumn.cs @@ -39,7 +39,7 @@ public enum IconAlignment /// /// Gets or sets the icon to display. /// - public Image Icon + public Image? Icon { get; set; @@ -62,7 +62,7 @@ public IconAlignment Alignment /// public object Clone() { - IconSpec spec = new IconSpec + var spec = new IconSpec { Icon = Icon?.Clone() as Image, Alignment = Alignment diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewLinkCell.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewLinkCell.cs index 1de314701..bf16b53b8 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewLinkCell.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewLinkCell.cs @@ -144,7 +144,7 @@ protected override Size GetPreferredSize(Graphics graphics, } // Position the button element inside the available cell area - using ViewLayoutContext layoutContext = new ViewLayoutContext(kDGV, kDGV.Renderer); + using var layoutContext = new ViewLayoutContext(kDGV, kDGV.Renderer); // Define the available area for layout layoutContext.DisplayRectangle = new Rectangle(0, 0, int.MaxValue, int.MaxValue); @@ -195,7 +195,7 @@ protected override void Paint(Graphics graphics, // Should we draw the content foreground? if ((paintParts & DataGridViewPaintParts.ContentForeground) == DataGridViewPaintParts.ContentForeground) { - using RenderContext renderContext = new RenderContext(kDgv, graphics, cellBounds, kDgv.Renderer); + using var renderContext = new RenderContext(kDgv, graphics, cellBounds, kDgv.Renderer); // Cache the starting cell bounds Rectangle startBounds = cellBounds; @@ -243,7 +243,7 @@ protected override void Paint(Graphics graphics, cellBounds.Height -= cellStyle.Padding.Vertical; // Position the button element inside the available cell area - using (ViewLayoutContext layoutContext = new ViewLayoutContext(kDgv, kDgv.Renderer)) + using (var layoutContext = new ViewLayoutContext(kDgv, kDgv.Renderer)) { // Define the available area for calculating layout layoutContext.DisplayRectangle = cellBounds; diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewLinkColumn.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewLinkColumn.cs index 1b4938038..985c3a631 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewLinkColumn.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewLinkColumn.cs @@ -44,7 +44,7 @@ public KryptonDataGridViewLinkColumn() /// A String that represents the current Object. public override string ToString() { - StringBuilder builder = new StringBuilder(0x40); + var builder = new StringBuilder(0x40); builder.Append("KryptonDataGridViewLinkColumn { Name="); // ReSharper disable RedundantBaseQualifier builder.Append(base.Name); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewMaskedTextBoxColumn.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewMaskedTextBoxColumn.cs index 7cac0cae0..422dbdb3e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewMaskedTextBoxColumn.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewMaskedTextBoxColumn.cs @@ -34,7 +34,7 @@ public KryptonDataGridViewMaskedTextBoxColumn() /// public override string ToString() { - StringBuilder builder = new StringBuilder(0x40); + var builder = new StringBuilder(0x40); builder.Append("KryptonDataGridViewMaskedTextBoxColumn { Name="); // ReSharper disable RedundantBaseQualifier builder.Append(base.Name); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewNumericUpDownColumn.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewNumericUpDownColumn.cs index f57271edd..d7fae24c7 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewNumericUpDownColumn.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewNumericUpDownColumn.cs @@ -34,7 +34,7 @@ public KryptonDataGridViewNumericUpDownColumn() /// public override string ToString() { - StringBuilder builder = new StringBuilder(0x40); + var builder = new StringBuilder(0x40); builder.Append("KryptonDataGridViewNumericUpDownColumn { Name="); // ReSharper disable RedundantBaseQualifier builder.Append(base.Name); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewTextBoxColumn.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewTextBoxColumn.cs index c3a513c45..4734a795d 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewTextBoxColumn.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDataGridViewTextBoxColumn.cs @@ -36,7 +36,7 @@ public KryptonDataGridViewTextBoxColumn() /// A String that represents the current Object. public override string ToString() { - StringBuilder builder = new StringBuilder(0x40); + var builder = new StringBuilder(0x40); builder.Append("KryptonDataGridViewTextBoxColumn { Name="); // ReSharper disable RedundantBaseQualifier builder.Append(base.Name); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDateTimePicker.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDateTimePicker.cs index 2e200641f..f6c0da04b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDateTimePicker.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDateTimePicker.cs @@ -65,7 +65,7 @@ public DateTimePickerButtonSpecCollection(KryptonDateTimePicker owner) private readonly ViewLayoutCenter _layoutCheckBox; private readonly ButtonSpecManagerDraw _buttonManager; private VisualPopupToolTip _visualPopupToolTip; - private KryptonContextMenuMonthCalendar _kmc; + private KryptonContextMenuMonthCalendar? _kmc; private InputControlStyle _inputControlStyle; private ButtonStyle _upDownButtonStyle; private ButtonStyle _dropButtonStyle; @@ -223,7 +223,7 @@ public KryptonDateTimePicker() // Add a checkbox to the left of the text area Images = new CheckBoxImages(NeedPaintDelegate); - PaletteRedirectCheckBox paletteCheckBoxImages = new PaletteRedirectCheckBox(Redirector, Images); + var paletteCheckBoxImages = new PaletteRedirectCheckBox(Redirector, Images); InternalViewDrawCheckBox = new ViewDrawCheckBox(paletteCheckBoxImages) { CheckState = CheckState.Checked @@ -235,8 +235,7 @@ public KryptonDateTimePicker() _layoutCheckBox.Visible = false; // Need a controller for handling check box mouse input - CheckBoxController controller = - new CheckBoxController(InternalViewDrawCheckBox, InternalViewDrawCheckBox, NeedPaintDelegate); + var controller = new CheckBoxController(InternalViewDrawCheckBox, InternalViewDrawCheckBox, NeedPaintDelegate); controller.Click += OnCheckBoxClick; controller.Enabled = true; InternalViewDrawCheckBox.MouseController = controller; @@ -1731,7 +1730,7 @@ protected override void OnMouseWheel(MouseEventArgs e) if (!IsDisposed && !Disposing && !InRibbonDesignMode) { // We treat positive numbers as moving upwards - KeyEventArgs kpea = new KeyEventArgs((e.Delta < 0) ? Keys.Down : Keys.Up); + var kpea = new KeyEventArgs((e.Delta < 0) ? Keys.Down : Keys.Up); // Simulate the up/down key the correct number of times var detents = Math.Abs(e.Delta) / SystemInformation.MouseWheelScrollDelta; @@ -2093,7 +2092,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) bool shadow = true; // Find the button spec associated with the tooltip request - ButtonSpec buttonSpec = _buttonManager.ButtonSpecFromView(e.Target); + ButtonSpec? buttonSpec = _buttonManager.ButtonSpecFromView(e.Target); // If the tooltip is for a button spec if (buttonSpec != null) @@ -2102,7 +2101,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) @@ -2158,7 +2157,7 @@ private void OnDropDownClick(object sender, EventArgs e) _dropDownMonthChanged = false; // Create a new krypton context menu each time we drop the menu - DTPContextMenu kcm = new DTPContextMenu(RectangleToScreen(_buttonDropDown.ClientRectangle)); + var kcm = new DTPContextMenu(RectangleToScreen(_buttonDropDown.ClientRectangle)); // Add and setup a month calendar element _kmc = new KryptonContextMenuMonthCalendar @@ -2197,7 +2196,7 @@ private void OnDropDownClick(object sender, EventArgs e) } // Give user a change to modify the context menu or even cancel the menu entirely - DateTimePickerDropArgs dtpda = new DateTimePickerDropArgs(kcm, + var dtpda = new DateTimePickerDropArgs(kcm, DropDownAlign == LeftRightAlignment.Left ? KryptonContextMenuPositionH.Left : KryptonContextMenuPositionH.Right, KryptonContextMenuPositionV.Below); @@ -2252,8 +2251,8 @@ private void OnDropDownClick(object sender, EventArgs e) private void OnMonthCalendarDateChanged(object sender, DateRangeEventArgs e) { - // Use the newly selected date but the exising time - DateTime newDt = new DateTime(e.Start.Year, e.Start.Month, e.Start.Day, _dateTime.Hour, _dateTime.Minute, + // Use the newly selected date but the existing time + var newDt = new DateTime(e.Start.Year, e.Start.Month, e.Start.Day, _dateTime.Hour, _dateTime.Minute, _dateTime.Second, _dateTime.Millisecond); // Range check in case the min/max have time portions and not just full days @@ -2288,7 +2287,7 @@ private void OnKryptonContextMenuClosed(object sender, EventArgs e) } // Generate the close up event and provide the menu so handlers can examine state that might have changed - DateTimePickerCloseArgs dtca = new DateTimePickerCloseArgs(kcm); + var dtca = new DateTimePickerCloseArgs(kcm); OnCloseUp(dtca); // Notify that the month calendar changed value whilst the dropped down. diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDomainUpDown.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDomainUpDown.cs index 49e100de7..34b1b022a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDomainUpDown.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDomainUpDown.cs @@ -134,7 +134,7 @@ protected override void WndProc(ref Message m) if (_kryptonDomainUpDown.KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) @@ -311,7 +311,7 @@ protected override void WndProc(ref Message m) // Mouse is over the control if (!MouseOver) { - PI.TRACKMOUSEEVENTS tme = new PI.TRACKMOUSEEVENTS + var tme = new PI.TRACKMOUSEEVENTS { // This structure needs to know its own size in bytes @@ -336,7 +336,7 @@ protected override void WndProc(ref Message m) case PI.WM_.PRINTCLIENT: case PI.WM_.PAINT: { - PI.PAINTSTRUCT ps = new PI.PAINTSTRUCT(); + var ps = new PI.PAINTSTRUCT(); // Do we need to BeginPaint or just take the given HDC? IntPtr hdc = m.WParam == IntPtr.Zero ? PI.BeginPaint(Handle, ref ps) : m.WParam; @@ -354,7 +354,7 @@ protected override void WndProc(ref Message m) PaletteInputControlTripleStates states = DomainUpDown.GetTripleState(); // Drawn entire client area in the background color - using (SolidBrush backBrush = new SolidBrush(states.PaletteBack.GetBackColor1(state))) + using (var backBrush = new SolidBrush(states.PaletteBack.GetBackColor1(state))) { g.FillRectangle(backBrush, new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top)); } @@ -398,7 +398,7 @@ protected override void WndProc(ref Message m) if (DomainUpDown.KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) @@ -534,14 +534,14 @@ protected override void WndProc(ref Message m) case PI.WM_.PRINTCLIENT: case PI.WM_.PAINT: { - PI.PAINTSTRUCT ps = new PI.PAINTSTRUCT(); + var ps = new PI.PAINTSTRUCT(); // Do we need to BeginPaint or just take the given HDC? IntPtr hdc = m.WParam == IntPtr.Zero ? PI.BeginPaint(Handle, ref ps) : m.WParam; // Grab the client area of the control PI.GetClientRect(Handle, out PI.RECT rect); - Rectangle clientRect = new Rectangle(rect.left, rect.top, rect.right - rect.left, + var clientRect = new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); try @@ -561,8 +561,7 @@ protected override void WndProc(ref Message m) // Easier to draw using a graphics instance than a DC! using Graphics g = Graphics.FromHdc(_screenDC); // Drawn entire client area in the background color - using (SolidBrush backBrush = - new SolidBrush(DomainUpDown.DomainUpDown.BackColor)) + using (var backBrush = new SolidBrush(DomainUpDown.DomainUpDown.BackColor)) { g.FillRectangle(backBrush, clientRect); } @@ -623,14 +622,13 @@ private void DrawUpDownButtons(Graphics g, Rectangle clientRect) _palette.SetStyles(DomainUpDown.UpDownButtonStyle); // Find button rectangles - Rectangle upRect = new Rectangle(clientRect.X, clientRect.Y, clientRect.Width, clientRect.Height / 2); - Rectangle downRect = new Rectangle(clientRect.X, upRect.Bottom, clientRect.Width, + var upRect = new Rectangle(clientRect.X, clientRect.Y, clientRect.Width, clientRect.Height / 2); + var downRect = new Rectangle(clientRect.X, upRect.Bottom, clientRect.Width, clientRect.Bottom - upRect.Bottom); // Position and draw the up/down buttons - using ViewLayoutContext layoutContext = new ViewLayoutContext(DomainUpDown, DomainUpDown.Renderer); - using RenderContext renderContext = - new RenderContext(DomainUpDown, g, clientRect, DomainUpDown.Renderer); + using var layoutContext = new ViewLayoutContext(DomainUpDown, DomainUpDown.Renderer); + using var renderContext = new RenderContext(DomainUpDown, g, clientRect, DomainUpDown.Renderer); // Up button layoutContext.DisplayRectangle = upRect; _viewButton.ElementState = ButtonElementState(upRect); @@ -1969,7 +1967,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/Controls Toolkit/KryptonDropButton.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDropButton.cs index 07c385ff6..76cad7eaa 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDropButton.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonDropButton.cs @@ -822,7 +822,7 @@ private bool ShowDropDown() } // Package up the context menu and positioning values we will use later - ContextPositionMenuArgs cpma = new ContextPositionMenuArgs(ContextMenuStrip, + var cpma = new ContextPositionMenuArgs(ContextMenuStrip, KryptonContextMenu, GetPositionH(), GetPositionV()); // Let use examine and later values OnDropDown(cpma); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonFolderBrowserDialog.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonFolderBrowserDialog.cs index 6abcd667c..158e98aca 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonFolderBrowserDialog.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonFolderBrowserDialog.cs @@ -21,7 +21,7 @@ namespace Krypton.Toolkit public class KryptonFolderBrowserDialog : ShellDialogWrapper, IDisposable { #if NET60_OR_GREATER - private readonly FolderBrowserDialog _internalOpenFileDialog = new();// { AutoUpgradeEnabled = true }; + private readonly FolderBrowserDialog _internalOpenFileDialog = new FolderBrowserDialog();// { AutoUpgradeEnabled = true }; #else private readonly ShellBrowserDialogTFM _internalOpenFileDialog = new ShellBrowserDialogTFM(); #endif diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs index 896d94a04..140f3c02d 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs @@ -1068,7 +1068,7 @@ protected override IntPtr WindowChromeHitTest(Point pt, bool composition) return new IntPtr(PI.HT.CLIENT); } - using (ViewLayoutContext context = new ViewLayoutContext(this, Renderer)) + using (var context = new ViewLayoutContext(this, Renderer)) { // Discover if the form icon is being Displayed if (_drawContent.IsImageDisplayed(context)) @@ -1194,12 +1194,12 @@ protected override void WindowChromePaint(Graphics g, Rectangle bounds) /// True if the message was processed; otherwise false. protected override bool OnWM_NCLBUTTONDOWN(ref Message m) { - using ViewLayoutContext context = new ViewLayoutContext(this, Renderer); + using var context = new ViewLayoutContext(this, Renderer); // Discover if the form icon is being Displayed if (_drawContent.IsImageDisplayed(context)) { // Extract the point in screen coordinates - Point screenPoint = new Point((int)m.LParam.ToInt64()); + var screenPoint = new Point((int)m.LParam.ToInt64()); // Convert to window coordinates Point windowPoint = ScreenToWindow(screenPoint); @@ -1440,7 +1440,7 @@ private bool CheckViewLayout() _regionWindowState = WindowState; // Get the path for the border so we can shape the form using it - using RenderContext context = new RenderContext(this, null, Bounds, Renderer); + using var context = new RenderContext(this, null, Bounds, Renderer); using GraphicsPath? path = _drawDocker.GetOuterBorderPath(context); if (!_firstCheckView) { @@ -1495,7 +1495,7 @@ private void UpdateRegionForMaximized() Padding padding = RealWindowBorders; // Reduce the Bounds by the padding on all but the top - Rectangle maximizedRect = new Rectangle(padding.Left, padding.Left, Width - padding.Horizontal, + var maximizedRect = new Rectangle(padding.Left, padding.Left, Width - padding.Horizontal, Height - padding.Left - padding.Bottom); // Use this as the new region @@ -1608,7 +1608,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) @@ -1813,7 +1813,7 @@ public static bool GetHasCurrentInstanceGotAdministrativeRights() { try { - WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); + var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); var hasAdministrativeRights = principal.IsInRole(WindowsBuiltInRole.Administrator); @@ -1843,7 +1843,7 @@ public static bool GetHasCurrentInstanceGotAdministrativeRights() public static void SetIsInAdministratorMode(bool value) { // TODO: @wagnerp: what is this supposed to be doing ? - KryptonForm form = new KryptonForm(); + var form = new KryptonForm(); //form.IsInAdministratorMode = value; } @@ -1853,7 +1853,7 @@ public static void SetIsInAdministratorMode(bool value) public static bool GetIsInAdministratorMode() { // TODO: @wagnerp: what is this supposed to be doing ? - KryptonForm form = new KryptonForm(); + var form = new KryptonForm(); return form.IsInAdministratorMode; } @@ -1899,85 +1899,59 @@ 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; + // TODO: Remove usage of "Magic Numbers" // Add configured buttons to array... - _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; } } /// Returns the integrated tool bar. /// Returns the integrated tool bar. - private ButtonSpecAny[] ReturnIntegratedToolBar() => _integratedToolBarItems; + private ButtonSpecAny[]? ReturnIntegratedToolBar() => _integratedToolBarItems; #endregion } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonHeader.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonHeader.cs index bb7242484..8a740bba2 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonHeader.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonHeader.cs @@ -561,7 +561,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/Controls Toolkit/KryptonHeaderGroup.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonHeaderGroup.cs index eebe8837d..8c8db2d6f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonHeaderGroup.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonHeaderGroup.cs @@ -1137,7 +1137,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/Controls Toolkit/KryptonHelpCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonHelpCommand.cs index 06372727c..ce23977a2 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonHelpCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonHelpCommand.cs @@ -37,6 +37,7 @@ public class KryptonHelpCommand : KryptonCommand /// Gets or sets the help button. /// The help button. [DefaultValue(null), Description(@"Access to the help button spec.")] + [AllowNull] public ButtonSpecAny? HelpButton { get => _helpButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonInputBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonInputBox.cs index a8f3bc303..86091cbe6 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonInputBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonInputBox.cs @@ -24,7 +24,7 @@ public static string Show(string prompt, string caption = @"", string defaultResponse = @"", string cueText = @"", - Color cueColour = new Color(), + Color cueColour = new Color(), // Color.Empty Font? cueTypeface = null, bool usePasswordOption = false) => InternalShow(null, prompt, caption, defaultResponse, cueText, cueColour, cueTypeface, usePasswordOption); @@ -45,7 +45,7 @@ public static string Show(IWin32Window owner, string prompt, string caption = @"", string defaultResponse = @"", string cueText = @"", - Color cueColour = new Color(), + Color cueColour = new Color(), // Color.Empty Font? cueTypeface = null, bool usePasswordOption = false) => InternalShow(owner, prompt, caption, defaultResponse, cueText, cueColour, cueTypeface, usePasswordOption); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarCopyCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarCopyCommand.cs index da281700f..6e4fba2c8 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarCopyCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarCopyCommand.cs @@ -37,6 +37,7 @@ public class KryptonIntegratedToolbarCopyCommand : KryptonCommand /// Gets or sets the copy button. /// The copy button. [DefaultValue(null), Description(@"Access to the copy button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarCopyButton { get => _copyButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarCutCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarCutCommand.cs index f55c2b309..4238eb337 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarCutCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarCutCommand.cs @@ -37,6 +37,7 @@ public class KryptonIntegratedToolbarCutCommand : KryptonCommand /// Gets or sets the cut button. /// The cut button. [DefaultValue(null), Description(@"Access to the cut button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarCutButton { get => _cutButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarNewCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarNewCommand.cs index acd60cd9e..c55127329 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarNewCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarNewCommand.cs @@ -37,6 +37,7 @@ public class KryptonIntegratedToolbarNewCommand : KryptonCommand /// Gets or sets the new button. /// The new button. [DefaultValue(null), Description(@"Access to the new button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarNewButton { get => _newButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarOpenCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarOpenCommand.cs index c1d3a4217..2ee71b116 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarOpenCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarOpenCommand.cs @@ -37,6 +37,7 @@ public class KryptonIntegratedToolbarOpenCommand : KryptonCommand /// Gets or sets the open button. /// The open button. [DefaultValue(null), Description(@"Access to the open button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarOpenButton { get => _openButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPageSetupCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPageSetupCommand.cs index c03a94162..c34748c0e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPageSetupCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPageSetupCommand.cs @@ -37,6 +37,7 @@ public class KryptonIntegratedToolbarPageSetupCommand : KryptonCommand /// Gets or sets the page setup button. /// The page setup button. [DefaultValue(null), Description(@"Access to the page setup button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarPageSetupButton { get => _pageSetupButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPasteCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPasteCommand.cs index 77b63b958..96f9de9b4 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPasteCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPasteCommand.cs @@ -37,6 +37,7 @@ public class KryptonIntegratedToolbarPasteCommand : KryptonCommand /// Gets or sets the paste button. /// The paste button. [DefaultValue(null), Description(@"Access to the paste button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarPasteButton { get => _pasteButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPrintCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPrintCommand.cs index 4797d5bb7..02b8158e9 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPrintCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPrintCommand.cs @@ -43,6 +43,7 @@ public class KryptonIntegratedToolbarPrintCommand : KryptonCommand /// Gets or sets the print button. /// The print button. [DefaultValue(null), Description(@"Access to the print button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarPrintButton { get => _printButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPrintPreviewCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPrintPreviewCommand.cs index 1292d43ff..140f6b68d 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPrintPreviewCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarPrintPreviewCommand.cs @@ -37,6 +37,7 @@ public class KryptonIntegratedToolbarPrintPreviewCommand : KryptonCommand /// Gets or sets the print preview button. /// The print preview button. [DefaultValue(null), Description(@"Access to the print preview button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarPrintPreviewButton { get => _printPreviewButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarQuickPrintCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarQuickPrintCommand.cs index 78733e7c3..a902f2313 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarQuickPrintCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarQuickPrintCommand.cs @@ -37,6 +37,7 @@ public class KryptonIntegratedToolbarQuickPrintCommand : KryptonCommand /// Gets or sets the quick print button. /// The quick print button. [DefaultValue(null), Description(@"Access to the quick print button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarQuickPrintButton { get => _quickPrintButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarRedoCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarRedoCommand.cs index fa957207e..d5226639f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarRedoCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarRedoCommand.cs @@ -37,6 +37,7 @@ public class KryptonIntegratedToolbarRedoCommand : KryptonCommand /// Gets or sets the redo button. /// The redo button. [DefaultValue(null), Description(@"Access to the redo button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarRedoButton { get => _redoButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarSaveAllCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarSaveAllCommand.cs index 39fcbf8c0..b290c2aaf 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarSaveAllCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarSaveAllCommand.cs @@ -45,6 +45,7 @@ public class KryptonIntegratedToolbarSaveAllCommand : KryptonCommand /// Gets or sets the save all button. /// The save all button. [DefaultValue(null), Description(@"Access to the save all button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarSaveAllButton { get => _saveAllButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarSaveAsCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarSaveAsCommand.cs index 1658b45a0..665390397 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarSaveAsCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarSaveAsCommand.cs @@ -37,6 +37,7 @@ public class KryptonIntegratedToolbarSaveAsCommand : KryptonCommand /// Gets or sets the save as button. /// The save as button. [DefaultValue(null), Description(@"Access to the save as button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarSaveAsButton { get => _saveAsButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarSaveCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarSaveCommand.cs index f93303d02..f9403428a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarSaveCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarSaveCommand.cs @@ -37,6 +37,7 @@ public class KryptonIntegratedToolbarSaveCommand : KryptonCommand /// Gets or sets the save button. /// The save button. [DefaultValue(null), Description(@"Access to the save button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarSaveButton { get => _saveButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarUndoCommand.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarUndoCommand.cs index 2f46650f2..0dea82aaf 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarUndoCommand.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonIntegratedToolbarUndoCommand.cs @@ -37,6 +37,7 @@ public class KryptonIntegratedToolbarUndoCommand : KryptonCommand /// Gets or sets the undo button. /// The undo button. [DefaultValue(null), Description(@"Access to the undo button spec.")] + [AllowNull] public ButtonSpecAny? ToolBarUndoButton { get => _undoButtonSpec ?? new ButtonSpecAny(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonLinkWrapLabel.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonLinkWrapLabel.cs index 0561bfc6d..f0f5cbcc3 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonLinkWrapLabel.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonLinkWrapLabel.cs @@ -714,7 +714,7 @@ protected override void WndProc(ref Message m) if (KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonListBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonListBox.cs index efe29410e..4fc3b329d 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonListBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonListBox.cs @@ -166,8 +166,7 @@ protected override void OnLayout(LayoutEventArgs levent) base.OnLayout(levent); // Ask the panel to layout given our available size - using ViewLayoutContext context = - new ViewLayoutContext(_viewManager, this, _kryptonListBox, _kryptonListBox.Renderer); + using var context = new ViewLayoutContext(_viewManager, this, _kryptonListBox, _kryptonListBox.Renderer); ViewDrawPanel.Layout(context); } @@ -211,7 +210,7 @@ protected override void WndProc(ref Message m) else { // Find the item under the mouse - Point mousePoint = new Point((int)m.LParam.ToInt64()); + var mousePoint = new Point((int)m.LParam.ToInt64()); var mouseIndex = IndexFromPoint(mousePoint); // If we have an actual item from the point @@ -256,7 +255,7 @@ protected override void WndProc(ref Message m) #region Private private void WmPaint(ref Message m) { - PI.PAINTSTRUCT ps = new PI.PAINTSTRUCT(); + var ps = new PI.PAINTSTRUCT(); // Do we need to BeginPaint or just take the given HDC? IntPtr hdc = m.WParam == IntPtr.Zero ? PI.BeginPaint(Handle, ref ps) : m.WParam; @@ -282,13 +281,13 @@ private void WmPaint(ref Message m) using (Graphics g = Graphics.FromHdc(_screenDC)) { // Ask the view element to layout in given space, needs this before a render call - using (ViewLayoutContext context = new ViewLayoutContext(this, _kryptonListBox.Renderer)) + using (var context = new ViewLayoutContext(this, _kryptonListBox.Renderer)) { context.DisplayRectangle = realRect; ViewDrawPanel.Layout(context); } - using (RenderContext context = new RenderContext(this, _kryptonListBox, g, realRect, + using (var context = new RenderContext(this, _kryptonListBox, g, realRect, _kryptonListBox.Renderer)) { ViewDrawPanel.Render(context); @@ -302,7 +301,7 @@ private void WmPaint(ref Message m) if (Items.Count == 0) { - using RenderContext context = new RenderContext(this, _kryptonListBox, g, realRect, + using var context = new RenderContext(this, _kryptonListBox, g, realRect, _kryptonListBox.Renderer); ViewDrawPanel.Render(context); } @@ -315,7 +314,7 @@ private void WmPaint(ref Message m) if (Items.Count == 0) { using Graphics g = Graphics.FromHdc(hdc); - using RenderContext context = new RenderContext(this, _kryptonListBox, g, realRect, + using var context = new RenderContext(this, _kryptonListBox, g, realRect, _kryptonListBox.Renderer); ViewDrawPanel.Render(context); } @@ -1642,7 +1641,7 @@ private void OnListBoxDrawItem(object sender, DrawItemEventArgs e) // Easier to draw using a graphics instance than a DC! using Graphics g = Graphics.FromHdc(_screenDC); // Ask the view element to layout in given space, needs this before a render call - using (ViewLayoutContext context = new ViewLayoutContext(this, Renderer)) + using (var context = new ViewLayoutContext(this, Renderer)) { context.DisplayRectangle = e.Bounds; _listBox.ViewDrawPanel.Layout(context); @@ -1650,7 +1649,7 @@ private void OnListBoxDrawItem(object sender, DrawItemEventArgs e) } // Ask the view element to actually draw - using (RenderContext context = new RenderContext(this, g, e.Bounds, Renderer)) + using (var context = new RenderContext(this, g, e.Bounds, Renderer)) { _listBox.ViewDrawPanel.Render(context); _drawButton.Render(context); @@ -1678,7 +1677,7 @@ private void OnListBoxMeasureItem(object sender, MeasureItemEventArgs e) UpdateContentFromItemIndex(e.Index); // Ask the view element to layout in given space, needs this before a render call - using ViewLayoutContext context = new ViewLayoutContext(this, Renderer); + using var context = new ViewLayoutContext(this, Renderer); Size size = _drawButton.GetPreferredSize(context); e.ItemWidth = size.Width; e.ItemHeight = size.Height; diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonListView.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonListView.cs index 729c45f23..47551535c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonListView.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonListView.cs @@ -570,7 +570,7 @@ protected override void OnDrawItem(DrawListViewItemEventArgs e) #pragma warning restore CA2208 // Instantiate argument exceptions correctly }; - using (ViewLayoutContext context = new ViewLayoutContext(this, Renderer)) + using (var context = new ViewLayoutContext(this, Renderer)) { context.DisplayRectangle = e.Bounds; ViewDrawPanel.Layout(context); @@ -591,12 +591,12 @@ protected override void OnDrawItem(DrawListViewItemEventArgs e) // Easier to draw using a graphics instance than a DC! using Graphics g = Graphics.FromHdc(_screenDC); - using (RenderContext context = new RenderContext(this, g, e.Bounds, Renderer)) + using (var context = new RenderContext(this, g, e.Bounds, Renderer)) { ViewDrawPanel.Render(context); } - using (RenderContext context = new RenderContext(this, g, bounds, Renderer)) + using (var context = new RenderContext(this, g, bounds, Renderer)) { layoutDocker.Render(context); } @@ -708,7 +708,7 @@ protected override void WndProc(ref Message m) if (KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMaskedTextBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMaskedTextBox.cs index 8df947ccd..f5c57157e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMaskedTextBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMaskedTextBox.cs @@ -152,7 +152,7 @@ protected override void WndProc(ref Message m) case PI.WM_.PRINTCLIENT: case PI.WM_.PAINT: { - PI.PAINTSTRUCT ps = new PI.PAINTSTRUCT(); + var ps = new PI.PAINTSTRUCT(); // Do we need to BeginPaint or just take the given HDC? IntPtr hdc = m.WParam == IntPtr.Zero ? PI.BeginPaint(Handle, ref ps) : m.WParam; @@ -164,7 +164,7 @@ protected override void WndProc(ref Message m) PI.GetClientRect(Handle, out PI.RECT rect); // Drawn entire client area in the background color - using (SolidBrush backBrush = new SolidBrush(BackColor)) + using (var backBrush = new SolidBrush(BackColor)) { g.FillRectangle(backBrush, new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top)); } @@ -196,7 +196,7 @@ protected override void WndProc(ref Message m) g.TextRenderingHint = CommonHelper.PaletteTextHintToRenderingHint(_kryptonMaskedTextBox.StateDisabled.PaletteContent.GetContentShortTextHint(PaletteState.Disabled)); // Define the string formatting requirements - StringFormat stringFormat = new StringFormat + var stringFormat = new StringFormat { LineAlignment = StringAlignment.Center, FormatFlags = StringFormatFlags.NoWrap, @@ -222,14 +222,14 @@ protected override void WndProc(ref Message m) var drawText = MaskedTextProvider?.ToDisplayString() ?? Text; try { - using SolidBrush foreBrush = new SolidBrush(ForeColor); + using var foreBrush = new SolidBrush(ForeColor); g.DrawString(drawText, Font, foreBrush, new RectangleF(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), stringFormat); } catch (ArgumentException) { - using SolidBrush foreBrush = new SolidBrush(ForeColor); + using var foreBrush = new SolidBrush(ForeColor); g.DrawString(drawText, _kryptonMaskedTextBox.GetTripleState().PaletteContent.GetContentShortTextFont(PaletteState.Disabled), foreBrush, new RectangleF(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), stringFormat); @@ -252,7 +252,7 @@ protected override void WndProc(ref Message m) if (_kryptonMaskedTextBox.KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) @@ -1894,7 +1894,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/Controls Toolkit/KryptonMessageBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMessageBox.cs index aba18f59b..8a984b5c6 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMessageBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMessageBox.cs @@ -54,7 +54,7 @@ public static DialogResult Show(string text, string caption, bool? showCtrlCopy /// Show extraText in title. If null(default) then only when Warning or Error icon is used. /// Specifies the . /// Specifies a if using the type. - /// Specifies the if a has not been defined. + /// Specifies the if a has not been defined. /// Specifies the start of a link if using the type. /// Specifies the end of a link if using the type. /// One of the System.Windows.Forms.DialogResult values. @@ -369,7 +369,7 @@ private static DialogResult ShowCore(IWin32Window? owner, IWin32Window? showOwner = ValidateOptions(owner, options, helpInfo); // Show message box window as a modal dialog and then dispose of it afterwards - using KryptonMessageBoxForm kmb = new KryptonMessageBoxForm(showOwner, text, caption, buttons, icon, + using var kmb = new KryptonMessageBoxForm(showOwner, text, caption, buttons, icon, defaultButton, options, helpInfo, showCtrlCopy, showHelpButton, showActionButton, actionButtonText, actionButtonCommand, applicationImage, applicationPath, contentAreaType, linkLabelCommand, linkLaunchArgument, linkAreaStart, linkAreaEnd); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMonthCalendar.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMonthCalendar.cs index 0ebc29f1c..36d8ca3e2 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMonthCalendar.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMonthCalendar.cs @@ -1710,7 +1710,7 @@ private DateTime EffectiveMinDate(DateTime minDate) private void AdjustSize(ref int width, ref int height) { - using ViewLayoutContext context = new ViewLayoutContext(this, Renderer); + using var context = new ViewLayoutContext(this, Renderer); // Ask back/border the size it requires Size backBorderSize = _drawDocker.GetNonChildSize(context); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonNumericUpDown.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonNumericUpDown.cs index e75e28504..9ad39ac46 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonNumericUpDown.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonNumericUpDown.cs @@ -144,7 +144,7 @@ protected override void WndProc(ref Message m) if (_kryptonNumericUpDown.KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) @@ -320,9 +320,8 @@ protected override void WndProc(ref Message m) // Mouse is over the control if (!MouseOver) { - PI.TRACKMOUSEEVENTS tme = new PI.TRACKMOUSEEVENTS + var tme = new PI.TRACKMOUSEEVENTS { - // This structure needs to know its own size in bytes cbSize = (uint)Marshal.SizeOf(typeof(PI.TRACKMOUSEEVENTS)), dwHoverTime = 100, @@ -345,7 +344,7 @@ protected override void WndProc(ref Message m) case PI.WM_.PRINTCLIENT: case PI.WM_.PAINT: { - PI.PAINTSTRUCT ps = new PI.PAINTSTRUCT(); + var ps = new PI.PAINTSTRUCT(); // Do we need to BeginPaint or just take the given HDC? IntPtr hdc = m.WParam == IntPtr.Zero ? PI.BeginPaint(Handle, ref ps) : m.WParam; @@ -362,7 +361,7 @@ protected override void WndProc(ref Message m) PaletteInputControlTripleStates states = NumericUpDown.GetTripleState(); // Drawn entire client area in the background color - using (SolidBrush backBrush = new SolidBrush(states.PaletteBack.GetBackColor1(state))) + using (var backBrush = new SolidBrush(states.PaletteBack.GetBackColor1(state))) { g.FillRectangle(backBrush, new Rectangle(rect.left, rect.top, rect.right - rect.left, @@ -428,7 +427,7 @@ protected override void WndProc(ref Message m) if (NumericUpDown.KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) @@ -561,14 +560,14 @@ protected override void WndProc(ref Message m) case PI.WM_.PRINTCLIENT: case PI.WM_.PAINT: { - PI.PAINTSTRUCT ps = new PI.PAINTSTRUCT(); + var ps = new PI.PAINTSTRUCT(); // Do we need to BeginPaint or just take the given HDC? IntPtr hdc = m.WParam == IntPtr.Zero ? PI.BeginPaint(Handle, ref ps) : m.WParam; // Grab the client area of the control PI.GetClientRect(Handle, out PI.RECT rect); - Rectangle clientRect = new Rectangle(rect.left, rect.top, rect.right - rect.left, + var clientRect = new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); try @@ -588,8 +587,7 @@ protected override void WndProc(ref Message m) // Easier to draw using a graphics instance than a DC! using Graphics g = Graphics.FromHdc(_screenDC); // Drawn entire client area in the background color - using (SolidBrush backBrush = - new SolidBrush(NumericUpDown.NumericUpDown.BackColor)) + using (var backBrush = new SolidBrush(NumericUpDown.NumericUpDown.BackColor)) { g.FillRectangle(backBrush, clientRect); } @@ -650,14 +648,13 @@ private void DrawUpDownButtons(Graphics g, Rectangle clientRect) _palette.SetStyles(NumericUpDown.UpDownButtonStyle); // Find button rectangles - Rectangle upRect = new Rectangle(clientRect.X, clientRect.Y, clientRect.Width, clientRect.Height / 2); - Rectangle downRect = new Rectangle(clientRect.X, upRect.Bottom, clientRect.Width, + var upRect = new Rectangle(clientRect.X, clientRect.Y, clientRect.Width, clientRect.Height / 2); + var downRect = new Rectangle(clientRect.X, upRect.Bottom, clientRect.Width, clientRect.Bottom - upRect.Bottom); // Position and draw the up/down buttons - using ViewLayoutContext layoutContext = new ViewLayoutContext(NumericUpDown, NumericUpDown.Renderer); - using RenderContext renderContext = - new RenderContext(NumericUpDown, g, clientRect, NumericUpDown.Renderer); + using var layoutContext = new ViewLayoutContext(NumericUpDown, NumericUpDown.Renderer); + using var renderContext = new RenderContext(NumericUpDown, g, clientRect, NumericUpDown.Renderer); // Up button layoutContext.DisplayRectangle = upRect; _viewButton.ElementState = ButtonElementState(upRect); @@ -2097,7 +2094,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/Controls Toolkit/KryptonRichTextBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonRichTextBox.cs index 0c96ecd8b..c3bb9d2a4 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonRichTextBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonRichTextBox.cs @@ -131,7 +131,7 @@ public int Print(int charFrom, int charTo, Graphics gr, Rectangle bounds) fmtRange.rc = rectToPrint; fmtRange.rcPage = rectPage; - IntPtr wparam = new IntPtr(1); + var wparam = new IntPtr(1); //Get the pointer to the FORMATRANGE structure in memory IntPtr lparam = Marshal.AllocCoTaskMem(Marshal.SizeOf(fmtRange)); @@ -199,7 +199,7 @@ protected override void WndProc(ref Message m) if (_kryptonRichTextBox.KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) @@ -220,7 +220,7 @@ protected override void WndProc(ref Message m) && (_kryptonRichTextBox.TextLength == 0) ) { - PI.PAINTSTRUCT ps = new PI.PAINTSTRUCT(); + var ps = new PI.PAINTSTRUCT(); // Do we need to BeginPaint or just take the given HDC? IntPtr hdc = m.WParam == IntPtr.Zero ? PI.BeginPaint(Handle, ref ps) : m.WParam; using (Graphics g = Graphics.FromHdc(hdc)) @@ -236,7 +236,7 @@ protected override void WndProc(ref Message m) var states = _kryptonRichTextBox.GetTripleState(); // Drawn entire client area in the background color - using SolidBrush backBrush = new SolidBrush(states.PaletteBack.GetBackColor1(state)); + using var backBrush = new SolidBrush(states.PaletteBack.GetBackColor1(state)); // Go perform the drawing of the CueHint _kryptonRichTextBox.CueHint.PerformPaint(_kryptonRichTextBox, g, rect, backBrush); } @@ -2240,7 +2240,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/Controls Toolkit/KryptonScrollBar.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonScrollBar.cs index 6d9acbb0d..bfdb3194c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonScrollBar.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonScrollBar.cs @@ -590,7 +590,7 @@ protected override void OnPaint(PaintEventArgs e) } // draw border - using Pen pen = new Pen(Enabled ? ScrollBarKryptonRenderer.borderColours[0] : _disabledBorderColor); + using var pen = new Pen(Enabled ? ScrollBarKryptonRenderer.borderColours[0] : _disabledBorderColor); e.Graphics.DrawRectangle(pen, 0, 0, Width - 1, Height - 1); } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonSeparator.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonSeparator.cs index f992d08b7..ad9f27e7f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonSeparator.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonSeparator.cs @@ -478,7 +478,7 @@ public Rectangle SeparatorMoveBox get { // Fire event to recover the rectangle of allowed separator movement - SplitterMoveRectMenuArgs args = new SplitterMoveRectMenuArgs(Rectangle.Empty); + var args = new SplitterMoveRectMenuArgs(Rectangle.Empty); OnSplitterMoveRect(args); return Orientation == Orientation.Horizontal @@ -497,7 +497,7 @@ public Rectangle SeparatorMoveBox public bool SeparatorMoving(Point mouse, Point splitter) { // Fire the event that indicates the splitter is being moved - SplitterCancelEventArgs e = new SplitterCancelEventArgs(mouse.X, mouse.Y, splitter.X, splitter.Y); + var e = new SplitterCancelEventArgs(mouse.X, mouse.Y, splitter.X, splitter.Y); OnSplitterMoving(e); // Tell caller if the movement should be cancelled or not @@ -513,7 +513,7 @@ public bool SeparatorMoving(Point mouse, Point splitter) public void SeparatorMoved(Point mouse, Point splitter) { // Fire the event that indicates the splitter has finished being moved - SplitterEventArgs e = new SplitterEventArgs(mouse.X, mouse.Y, splitter.X, splitter.Y); + var e = new SplitterEventArgs(mouse.X, mouse.Y, splitter.X, splitter.Y); OnSplitterMoved(e); _redrawTimer?.Start(); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonSplitContainer.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonSplitContainer.cs index 3ec9ec456..64b5bc429 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonSplitContainer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonSplitContainer.cs @@ -890,7 +890,7 @@ public bool SeparatorMoving(Point mouse, Point splitter) } // Fire the event that indicates the splitter is being moved - SplitterCancelEventArgs e = new SplitterCancelEventArgs(mouse.X, mouse.Y, splitter.X, splitter.Y); + var e = new SplitterCancelEventArgs(mouse.X, mouse.Y, splitter.X, splitter.Y); OnSplitterMoving(e); // Tell caller if the movement should be cancelled or not @@ -916,7 +916,7 @@ public void SeparatorMoved(Point mouse, Point splitter) } // Fire the event that indicates the splitter has finished being moved - SplitterEventArgs e = new SplitterEventArgs(mouse.X, mouse.Y, splitter.X, splitter.Y); + var e = new SplitterEventArgs(mouse.X, mouse.Y, splitter.X, splitter.Y); OnSplitterMoved(e); } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTableLayoutPanel.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTableLayoutPanel.cs index 252c964a3..d17322bfc 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTableLayoutPanel.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTableLayoutPanel.cs @@ -312,8 +312,8 @@ protected override void WndProc(ref Message m) // Only interested in overriding the behavior when we have a krypton context menu... if (KryptonContextMenu != null) { - // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + // Extract the screen mouse position (if might not actually be provided) + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTaskDialog.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTaskDialog.cs index de8de5536..033787376 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTaskDialog.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTaskDialog.cs @@ -507,7 +507,7 @@ public static DialogResult Show(string windowTitle, TaskDialogButtons commonButtons) { // Create a temporary task dialog for storing definition whilst showing - using KryptonTaskDialog taskDialog = new KryptonTaskDialog(); + using var taskDialog = new KryptonTaskDialog(); // Store incoming values taskDialog.WindowTitle = windowTitle; taskDialog.MainInstruction = mainInstruction; diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTextBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTextBox.cs index fe5ccf903..4a5dd6f9c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTextBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTextBox.cs @@ -133,7 +133,7 @@ protected override void WndProc(ref Message m) case PI.WM_.PRINTCLIENT: case PI.WM_.PAINT: { - PI.PAINTSTRUCT ps = new PI.PAINTSTRUCT(); + var ps = new PI.PAINTSTRUCT(); // Do we need to BeginPaint or just take the given HDC? IntPtr hdc = m.WParam == IntPtr.Zero ? PI.BeginPaint(Handle, ref ps) : m.WParam; @@ -153,12 +153,12 @@ protected override void WndProc(ref Message m) ) { // Go perform the drawing of the CueHint - using SolidBrush backBrush = new SolidBrush(BackColor); + using var backBrush = new SolidBrush(BackColor); _kryptonTextBox.CueHint.PerformPaint(_kryptonTextBox, g, rect, backBrush); } else { - using (SolidBrush backBrush = new SolidBrush(BackColor)) + using (var backBrush = new SolidBrush(BackColor)) { // Draw entire client area in the background color g.FillRectangle(backBrush, @@ -192,7 +192,7 @@ protected override void WndProc(ref Message m) PaletteState.Disabled)); // Define the string formatting requirements - StringFormat stringFormat = new StringFormat + var stringFormat = new StringFormat { Trimming = StringTrimming.None, LineAlignment = StringAlignment.Near @@ -227,7 +227,7 @@ protected override void WndProc(ref Message m) // Draw using a solid brush try { - using SolidBrush foreBrush = new SolidBrush(ForeColor); + using var foreBrush = new SolidBrush(ForeColor); g.DrawString(drawString, Font, foreBrush, new RectangleF(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), @@ -235,7 +235,7 @@ protected override void WndProc(ref Message m) } catch (ArgumentException) { - using SolidBrush foreBrush = new SolidBrush(ForeColor); + using var foreBrush = new SolidBrush(ForeColor); g.DrawString(drawString, _kryptonTextBox.GetTripleState().PaletteContent? .GetContentShortTextFont(PaletteState.Disabled), foreBrush, @@ -261,7 +261,7 @@ protected override void WndProc(ref Message m) if (_kryptonTextBox.KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) @@ -1971,7 +1971,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e) // Create a helper object to provide tooltip values if (Redirector != null) { - 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/Controls Toolkit/KryptonTreeView.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTreeView.cs index feda92f6f..d2f2406d9 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTreeView.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTreeView.cs @@ -155,8 +155,7 @@ protected override void OnLayout(LayoutEventArgs levent) base.OnLayout(levent); // Ask the panel to layout given our available size - using ViewLayoutContext context = - new ViewLayoutContext(_viewManager, this, _kryptonTreeView, _kryptonTreeView.Renderer); + using var context = new ViewLayoutContext(_viewManager, this, _kryptonTreeView, _kryptonTreeView.Renderer); ViewDrawPanel.Layout(context); } @@ -227,7 +226,7 @@ protected override void WndProc(ref Message m) #region Private private void WmPaint(ref Message m) { - PI.PAINTSTRUCT ps = new PI.PAINTSTRUCT(); + var ps = new PI.PAINTSTRUCT(); // Do we need to BeginPaint or just take the given HDC? IntPtr hdc = m.WParam == IntPtr.Zero ? PI.BeginPaint(Handle, ref ps) : m.WParam; @@ -253,14 +252,13 @@ private void WmPaint(ref Message m) using (Graphics g = Graphics.FromHdc(_screenDC)) { // Ask the view element to layout in given space, needs this before a render call - using (ViewLayoutContext context = - new ViewLayoutContext(this, _kryptonTreeView.Renderer)) + using (var context = new ViewLayoutContext(this, _kryptonTreeView.Renderer)) { context.DisplayRectangle = realRect; ViewDrawPanel.Layout(context); } - using (RenderContext context = new RenderContext(this, _kryptonTreeView, g, realRect, + using (var context = new RenderContext(this, _kryptonTreeView, g, realRect, _kryptonTreeView.Renderer)) { ViewDrawPanel.Render(context); @@ -532,24 +530,22 @@ public KryptonTreeView() // Create the palette storage _redirectImages = new PaletteRedirectTreeView(Redirector, PlusMinusImages, CheckBoxImages); - PaletteBackInheritRedirect backInherit = - new PaletteBackInheritRedirect(Redirector, PaletteBackStyle.InputControlStandalone); - PaletteBorderInheritRedirect borderInherit = - new PaletteBorderInheritRedirect(Redirector, PaletteBorderStyle.InputControlStandalone); - PaletteBackColor1 commonBack = new PaletteBackColor1(backInherit, NeedPaintDelegate); - PaletteBorder commonBorder = new PaletteBorder(borderInherit, NeedPaintDelegate); + var backInherit = new PaletteBackInheritRedirect(Redirector, PaletteBackStyle.InputControlStandalone); + var borderInherit = new PaletteBorderInheritRedirect(Redirector, PaletteBorderStyle.InputControlStandalone); + var commonBack = new PaletteBackColor1(backInherit, NeedPaintDelegate); + var commonBorder = new PaletteBorder(borderInherit, NeedPaintDelegate); StateCommon = new PaletteTreeStateRedirect(Redirector, commonBack, backInherit, commonBorder, borderInherit, NeedPaintDelegate); - PaletteBackColor1 disabledBack = new PaletteBackColor1(StateCommon.PaletteBack, NeedPaintDelegate); - PaletteBorder disabledBorder = new PaletteBorder(StateCommon.PaletteBorder, NeedPaintDelegate); + var disabledBack = new PaletteBackColor1(StateCommon.PaletteBack, NeedPaintDelegate); + var disabledBorder = new PaletteBorder(StateCommon.PaletteBorder, NeedPaintDelegate); StateDisabled = new PaletteTreeState(StateCommon, disabledBack, disabledBorder, NeedPaintDelegate); - PaletteBackColor1 normalBack = new PaletteBackColor1(StateCommon.PaletteBack, NeedPaintDelegate); - PaletteBorder normalBorder = new PaletteBorder(StateCommon.PaletteBorder, NeedPaintDelegate); + var normalBack = new PaletteBackColor1(StateCommon.PaletteBack, NeedPaintDelegate); + var normalBorder = new PaletteBorder(StateCommon.PaletteBorder, NeedPaintDelegate); StateNormal = new PaletteTreeState(StateCommon, normalBack, normalBorder, NeedPaintDelegate); - PaletteBackColor1 activeBack = new PaletteBackColor1(StateCommon.PaletteBack, NeedPaintDelegate); - PaletteBorder activeBorder = new PaletteBorder(StateCommon.PaletteBorder, NeedPaintDelegate); + var activeBack = new PaletteBackColor1(StateCommon.PaletteBack, NeedPaintDelegate); + var activeBorder = new PaletteBorder(StateCommon.PaletteBorder, NeedPaintDelegate); StateActive = new PaletteDouble(StateCommon, activeBack, activeBorder, NeedPaintDelegate); OverrideFocus = new PaletteTreeNodeTripleRedirect(Redirector, PaletteBackStyle.ButtonListItem, PaletteBorderStyle.ButtonListItem, PaletteContentStyle.ButtonListItem, NeedPaintDelegate); @@ -574,7 +570,7 @@ public KryptonTreeView() { _drawCheckBox }; - ViewLayoutSeparator layoutCheckBoxAfter = new ViewLayoutSeparator(3, 0); + var layoutCheckBoxAfter = new ViewLayoutSeparator(3, 0); _layoutCheckBoxStack = new ViewLayoutStack(true) { layoutCheckBox, @@ -583,8 +579,8 @@ public KryptonTreeView() // Stack used to layout the location of the node image _layoutImage = new ViewLayoutSeparator(0, 0); - ViewLayoutSeparator layoutImageAfter = new ViewLayoutSeparator(3, 0); - ViewLayoutCenter layoutImageCenter = new ViewLayoutCenter(_layoutImage); + var layoutImageAfter = new ViewLayoutSeparator(3, 0); + var layoutImageCenter = new ViewLayoutCenter(_layoutImage); _layoutImageStack = new ViewLayoutStack(true) { layoutImageCenter, @@ -650,7 +646,7 @@ public KryptonTreeView() }; // Create inner view for placing inside the drawing docker - ViewLayoutDocker drawDockerInner = new ViewLayoutDocker + var drawDockerInner = new ViewLayoutDocker { { _layoutFill, ViewDockStyle.Fill } }; @@ -1924,7 +1920,7 @@ private void UpdateItemHeight() } } - private void UpdateContentFromNode(TreeNode node) + private void UpdateContentFromNode(TreeNode? node) { _overrideNormalNode.TreeNode = node; @@ -2123,7 +2119,7 @@ private void OnTreeViewDrawNode(object sender, DrawTreeNodeEventArgs e) // Create indent rectangle and adjust bounds for remainder var nodeIndent = NodeIndent(e.Node) + 2; - Rectangle indentBounds = new Rectangle(bounds.X + nodeIndent - indent, bounds.Y, indent, bounds.Height); + var indentBounds = new Rectangle(bounds.X + nodeIndent - indent, bounds.Y, indent, bounds.Height); bounds.X += nodeIndent; bounds.Width -= nodeIndent; @@ -2141,7 +2137,7 @@ private void OnTreeViewDrawNode(object sender, DrawTreeNodeEventArgs e) // Easier to draw using a graphics instance than a DC! using Graphics g = Graphics.FromHdc(_screenDC); - using (ViewLayoutContext context = new ViewLayoutContext(this, Renderer)) + using (var context = new ViewLayoutContext(this, Renderer)) { context.DisplayRectangle = e.Bounds; _treeView.ViewDrawPanel.Layout(context); @@ -2168,7 +2164,7 @@ private void OnTreeViewDrawNode(object sender, DrawTreeNodeEventArgs e) _layoutDocker.Layout(context); } - using (RenderContext context = new RenderContext(this, g, e.Bounds, Renderer)) + using (var context = new RenderContext(this, g, e.Bounds, Renderer)) { _treeView.ViewDrawPanel.Render(context); } @@ -2177,7 +2173,8 @@ private void OnTreeViewDrawNode(object sender, DrawTreeNodeEventArgs e) if (indentBounds.X >= 0) { // Do we draw lines between nodes? - if (ShowLines && (Redirector.GetMetricBool(PaletteState.Normal, PaletteMetricBool.TreeViewLines) != InheritBool.False)) + if (ShowLines + && (Redirector.GetMetricBool(PaletteState.Normal, PaletteMetricBool.TreeViewLines) != InheritBool.False)) { // Find center points var hCenter = indentBounds.X + (indentBounds.Width / 2) - 1; @@ -2203,7 +2200,7 @@ private void OnTreeViewDrawNode(object sender, DrawTreeNodeEventArgs e) // Draw the horizontal and vertical lines Color lineColor = Redirector.GetContentShortTextColor1(PaletteContentStyle.InputControlStandalone, PaletteState.Normal); - using Pen linePen = new Pen(lineColor); + using var linePen = new Pen(lineColor); linePen.DashStyle = DashStyle.Dot; linePen.DashOffset = indent % 2; g.DrawLine(linePen, hCenter, top, hCenter, bottom); @@ -2233,7 +2230,7 @@ private void OnTreeViewDrawNode(object sender, DrawTreeNodeEventArgs e) } } - using (RenderContext context = new RenderContext(this, g, bounds, Renderer)) + using (var context = new RenderContext(this, g, bounds, Renderer)) { _layoutDocker.Render(context); } diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonWebBrowser.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonWebBrowser.cs index 9bcc0e42c..731b34821 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonWebBrowser.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonWebBrowser.cs @@ -149,7 +149,7 @@ protected override void WndProc(ref Message m) if (KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int) (long) m.LParam) == -1) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonWrapLabel.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonWrapLabel.cs index 7225b228c..69ea2df35 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonWrapLabel.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonWrapLabel.cs @@ -716,7 +716,7 @@ protected override void WndProc(ref Message m) if (KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonInputBoxForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonInputBoxForm.cs index f3c92cd5f..dfdd4111c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonInputBoxForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonInputBoxForm.cs @@ -100,11 +100,13 @@ internal static string InternalShow(IWin32Window? owner, IWin32Window? showOwner = owner ?? FromHandle(PI.GetActiveWindow()); // Show input box window as a modal dialog and then dispose of it afterwards - using KryptonInputBoxForm ib = new KryptonInputBoxForm(prompt, caption, defaultResponse, cueText, cueColour, + using var ib = new KryptonInputBoxForm(prompt, caption, defaultResponse, cueText, cueColour, cueTypeface, usePasswordOption); ib.StartPosition = showOwner == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent; - return ib.ShowDialog(showOwner) == DialogResult.OK ? ib.InputResponse : string.Empty; + return ib.ShowDialog(showOwner) == DialogResult.OK + ? ib.InputResponse + : string.Empty; } internal string InputResponse => _textBoxResponse.Text; diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.cs index 9948be65d..9bad35f24 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.cs @@ -610,7 +610,7 @@ private Size UpdateButtonsSizing() // Button1 is always visible Size button1Size = _button1.GetPreferredSize(Size.Empty); - Size maxButtonSize = new Size(button1Size.Width + GAP, button1Size.Height); + var maxButtonSize = new Size(button1Size.Width + GAP, button1Size.Height); // If Button2 is visible if (_button2.Enabled) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMultilineStringEditorForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMultilineStringEditorForm.cs index 2014d725a..b5d4eb221 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMultilineStringEditorForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMultilineStringEditorForm.cs @@ -224,8 +224,7 @@ private void kbtnOk_Click(object sender, EventArgs e) IWin32Window? showOwner = owner ?? FromHandle(PI.GetActiveWindow()); - using KryptonMultilineStringEditorForm kmse = - new KryptonMultilineStringEditorForm(input, null, useRichTextBox, headerText, windowTitle); + using var kmse = new KryptonMultilineStringEditorForm(input, null, useRichTextBox, headerText, windowTitle); kmse.StartPosition = showOwner == null ? FormStartPosition.CenterParent : FormStartPosition.CenterScreen; @@ -240,8 +239,7 @@ private void kbtnOk_Click(object sender, EventArgs e) IWin32Window showOwner = owner ?? FromHandle(PI.GetActiveWindow()); - using KryptonMultilineStringEditorForm kmse = - new KryptonMultilineStringEditorForm(null, input, useRichTextBox, headerText, windowTitle); + using var kmse = new KryptonMultilineStringEditorForm(null, input, useRichTextBox, headerText, windowTitle); kmse.StartPosition = showOwner == null ? FormStartPosition.CenterParent : FormStartPosition.CenterScreen; diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/MultilineStringEditor.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/MultilineStringEditor.cs index 5d2211739..d41f1387f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/MultilineStringEditor.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/MultilineStringEditor.cs @@ -95,7 +95,7 @@ protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); // Paint the sizing grip. - using (Bitmap gripImage = new Bitmap(0x10, 0x10)) + using (var gripImage = new Bitmap(0x10, 0x10)) { using (Graphics g = Graphics.FromImage(gripImage)) { @@ -205,7 +205,7 @@ private bool OnGetMinMaxInfo(ref Message m) private bool OnNcHitTest(ref Message m) { Point clientLocation = PointToClient(Cursor.Position); - GripBounds gripBounds = new GripBounds(ClientRectangle); + var gripBounds = new GripBounds(ClientRectangle); if (gripBounds.BottomRight.Contains(clientLocation)) { m.Result = (IntPtr)PI.HT.BOTTOMRIGHT; diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualBlur.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualBlur.cs index 8edad226d..f284d926a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualBlur.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualBlur.cs @@ -36,7 +36,7 @@ public VisualBlur(BlurValues values) // Update form properties so we do not have a border and do not show // in the task bar. We draw the background in Magenta and set that as // the transparency key so it is a see through window. - CreateParams cp = new CreateParams + var cp = new CreateParams { // Define the screen position/size X = -2, @@ -112,7 +112,7 @@ public void SetTargetRect(Point clientLocation, Rectangle windowBounds) internal static Rectangle GetTargetRectangle(Point clientLocation, Rectangle windowBounds) { - Rectangle rect = new Rectangle(0, 0, windowBounds.Width, windowBounds.Height); + var rect = new Rectangle(0, 0, windowBounds.Width, windowBounds.Height); rect.Offset(clientLocation); return rect; } @@ -147,10 +147,10 @@ internal void UpdateShadowLayer() hOldBitmap = PI.SelectObject(memDc, hBitmap); // Set parameters for layered window update. - PI.SIZE newSize = new PI.SIZE(_blurredForm.Width, _blurredForm.Height); - PI.POINT sourceLocation = new PI.POINT(0, 0); - PI.POINT newLocation = new PI.POINT(TargetRect.Left, TargetRect.Top); - PI.BLENDFUNCTION blend = new PI.BLENDFUNCTION + var newSize = new PI.SIZE(_blurredForm.Width, _blurredForm.Height); + var sourceLocation = new PI.POINT(0, 0); + var newLocation = new PI.POINT(TargetRect.Left, TargetRect.Top); + var blend = new PI.BLENDFUNCTION { BlendOp = PI.AC_SRC_OVER, BlendFlags = 0, diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContainerControlBase.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContainerControlBase.cs index 4784df1e7..5f1c2d78d 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContainerControlBase.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContainerControlBase.cs @@ -1037,7 +1037,7 @@ protected override void WndProc(ref Message m) if (KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContextMenu.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContextMenu.cs index 8351d52a6..f7996c555 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContextMenu.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualContextMenu.cs @@ -387,7 +387,7 @@ protected override void OnLayout(LayoutEventArgs levent) base.OnLayout(levent); // Need a render context for accessing the renderer - using RenderContext context = new RenderContext(this, null, ClientRectangle, Renderer); + using var context = new RenderContext(this, null, ClientRectangle, Renderer); // Grab a path that is the outside edge of the border Rectangle borderRect = ClientRectangle; GraphicsPath borderPath1 = Renderer.RenderStandardBorder.GetOutsideBorderPath(context, borderRect, _provider.ProviderStateCommon.ControlOuter.Border, VisualOrientation.Top, PaletteState.Normal); @@ -422,13 +422,13 @@ private void Construct(KryptonContextMenuCollection items, items.GenerateView(_provider, this, _viewColumns, true, true); // Create the control panel canvas - ViewDrawCanvas mainBackground = new ViewDrawCanvas(_provider.ProviderStateCommon.ControlInner.Back, + var mainBackground = new ViewDrawCanvas(_provider.ProviderStateCommon.ControlInner.Back, _provider.ProviderStateCommon.ControlInner.Border, VisualOrientation.Top) { _viewColumns }; - ViewLayoutDocker layoutDocker = new ViewLayoutDocker(); + var layoutDocker = new ViewLayoutDocker(); Padding outerPadding = _provider.ProviderRedirector.GetMetricPadding(PaletteState.Normal, PaletteMetricPadding.ContextMenuItemOuter); layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Top), ViewDockStyle.Top); layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Bottom), ViewDockStyle.Bottom); @@ -459,7 +459,7 @@ private Size CalculatePreferredSize() try { // Find the preferred size which fits exactly the calculated contents size - using ViewLayoutContext context = new ViewLayoutContext(this, Renderer); + using var context = new ViewLayoutContext(this, Renderer); return ViewManager.Root.GetPreferredSize(context); } finally diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs index 9c83839d4..c694148fc 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs @@ -1129,7 +1129,7 @@ protected override void WndProc(ref Message m) if (KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualForm.cs index 6e5f80c91..92e99559c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualForm.cs @@ -805,7 +805,7 @@ protected void InvalidateNonClient(Rectangle invalidRect, realWindowRectangle.Height); } - using Region invalidRegion = new Region(invalidRect); + using var invalidRegion = new Region(invalidRect); if (excludeClientArea) { invalidRegion.Exclude(ClientRectangle); @@ -830,7 +830,7 @@ protected Rectangle RealWindowRectangle { // 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 @@ -951,7 +951,7 @@ protected override void OnPaintBackground(PaintEventArgs e) // If drawing with custom chrome and composition if (ApplyCustomChrome && ApplyComposition) { - Rectangle compositionRect = new Rectangle(0, 0, Width, _compositionHeight); + var compositionRect = new Rectangle(0, 0, Width, _compositionHeight); // Draw the extended area inside the client in black, this ensures // it is treated as transparent by the desktop window manager @@ -1345,7 +1345,7 @@ protected virtual bool OnWM_NCPAINT(ref Message m) protected virtual bool OnWM_NCHITTEST(ref Message m) { // Extract the point in screen coordinates - Point screenPoint = new Point((int)m.LParam.ToInt64()); + var screenPoint = new Point((int)m.LParam.ToInt64()); // Convert to window coordinates Point windowPoint = ScreenToWindow(screenPoint); @@ -1381,7 +1381,7 @@ protected virtual bool OnCompWM_NCHITTEST(ref Message m) || m.Result == (IntPtr)PI.HT.CLIENT) { // Extract the point in screen coordinates - Point screenPoint = new Point((int)m.LParam.ToInt64()); + var screenPoint = new Point((int)m.LParam.ToInt64()); // Convert to window coordinates Point windowPoint = ScreenToWindow(screenPoint); @@ -1449,7 +1449,7 @@ protected virtual bool OnPaintNonClient(ref Message m) protected virtual bool OnWM_NCMOUSEMOVE(ref Message m) { // Extract the point in screen coordinates - Point screenPoint = new Point((int)m.LParam.ToInt64()); + var screenPoint = new Point((int)m.LParam.ToInt64()); // Convert to window coordinates Point windowPoint = ScreenToWindow(screenPoint); @@ -1466,7 +1466,7 @@ protected virtual bool OnWM_NCMOUSEMOVE(ref Message m) // If we are not tracking when the mouse leaves the non-client window if (!_trackingMouse) { - PI.TRACKMOUSEEVENTS tme = new PI.TRACKMOUSEEVENTS + var tme = new PI.TRACKMOUSEEVENTS { // This structure needs to know its own size in bytes cbSize = (uint)Marshal.SizeOf(typeof(PI.TRACKMOUSEEVENTS)), @@ -1501,7 +1501,7 @@ protected virtual bool OnWM_NCMOUSEMOVE(ref Message m) protected virtual bool OnWM_NCLBUTTONDOWN(ref Message m) { // Extract the point in screen coordinates - Point screenPoint = new Point((int)m.LParam.ToInt64()); + var screenPoint = new Point((int)m.LParam.ToInt64()); // Convert to window coordinates Point windowPoint = ScreenToWindow(screenPoint); @@ -1524,7 +1524,7 @@ protected virtual bool OnWM_NCLBUTTONDOWN(ref Message m) protected virtual bool OnWM_NCLBUTTONUP(ref Message m) { // Extract the point in screen coordinates - Point screenPoint = new Point((int)m.LParam.ToInt64()); + var screenPoint = new Point((int)m.LParam.ToInt64()); // Convert to window coordinates Point windowPoint = ScreenToWindow(screenPoint); @@ -1571,7 +1571,7 @@ protected virtual bool OnWM_NCMOUSELEAVE(ref Message m) protected virtual bool OnWM_MOUSEMOVE(ref Message m) { // Extract the point in client coordinates - Point clientPoint = new Point((int)m.LParam); + var clientPoint = new Point((int)m.LParam); // Convert to screen coordinates Point screenPoint = PointToScreen(clientPoint); @@ -1603,7 +1603,7 @@ protected virtual bool OnWM_LBUTTONUP(ref Message m) _trackingMouse = false; // Extract the point in client coordinates - Point clientPoint = new Point((int)m.LParam); + var clientPoint = new Point((int)m.LParam); // Convert to screen coordinates Point screenPoint = PointToScreen(clientPoint); @@ -1631,7 +1631,7 @@ protected virtual bool OnWM_LBUTTONUP(ref Message m) protected virtual bool OnWM_NCLBUTTONDBLCLK(ref Message m) { // Extract the point in screen coordinates - Point screenPoint = new Point((int)m.LParam.ToInt64()); + var screenPoint = new Point((int)m.LParam.ToInt64()); // Convert to window coordinates Point windowPoint = ScreenToWindow(screenPoint); @@ -1668,7 +1668,7 @@ protected virtual void OnNonClientPaint(IntPtr hWnd) { // Find the rectangle that covers the client area of the form Padding borders = RealWindowBorders; - Rectangle clipClientRect = new Rectangle(borders.Left, borders.Top, + var clipClientRect = new Rectangle(borders.Left, borders.Top, windowBounds.Width - borders.Horizontal, windowBounds.Height - borders.Vertical); var minimized = CommonHelper.IsFormMinimized(this); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPanel.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPanel.cs index b63304c17..94636f230 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPanel.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPanel.cs @@ -493,7 +493,7 @@ protected override void WndProc(ref Message m) if (KryptonContextMenu != null) { // Extract the screen mouse position (if might not actually be provided) - Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); + var mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam)); // If keyboard activated, the menu position is centered if (((int)(long)m.LParam) == -1) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopup.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopup.cs index 7b89b7136..73aca20ff 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopup.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopup.cs @@ -212,7 +212,7 @@ public virtual bool DoesCurrentMouseDownEndAllTracking(Message m, Point pt) { // Get the window handle of the window under this screen point Point screenPt = PointToScreen(pt); - PI.POINT screenPIPt = new PI.POINT + var screenPIPt = new PI.POINT { X = screenPt.X, Y = screenPt.Y @@ -222,7 +222,7 @@ public virtual bool DoesCurrentMouseDownEndAllTracking(Message m, Point pt) // Assuming we got back a valid window handle if (hWnd != IntPtr.Zero) { - StringBuilder className = new StringBuilder(256); + var className = new StringBuilder(256); var length = PI.GetClassName(hWnd, className, className.Capacity); // If we got back a valid name diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopupManager.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopupManager.cs index 471fe91c2..d5c52b232 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopupManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopupManager.cs @@ -417,7 +417,7 @@ public bool PreFilterMessage(ref Message m) // KeyPress events occur for the current popup. if (!CurrentPopup.ContainsFocus) { - PI.MSG msg = new PI.MSG + var msg = new PI.MSG { hwnd = m.HWnd, message = m.Msg, @@ -576,7 +576,7 @@ private bool ProcessClientMouseDown(ref Message m) private bool ProcessNonClientMouseDown(ref Message m) { // Extract the x and y mouse position from message - Point screenPt = new Point(PI.LOWORD((int)m.LParam), PI.HIWORD((int)m.LParam)); + var screenPt = new Point(PI.LOWORD((int)m.LParam), PI.HIWORD((int)m.LParam)); // Ask the popup if this message causes the entire stack to be killed if (CurrentPopup.DoesCurrentMouseDownEndAllTracking(m, ScreenPtToClientPt(screenPt))) @@ -661,7 +661,7 @@ private bool ProcessMouseMoveWithCMS(ref Message m) Point screenPt = CommonHelper.ClientMouseMessageToScreenPt(m); // Convert from a class to a structure - PI.POINT screenPIPt = new PI.POINT + var screenPIPt = new PI.POINT { X = screenPt.X, Y = screenPt.Y @@ -697,7 +697,7 @@ private bool ProcessMouseMoveWithCMS(ref Message m) private Point ScreenPtToClientPt(Point pt, IntPtr handle) { - PI.POINTC clientPt = new PI.POINTC + var clientPt = new PI.POINTC { x = pt.X, y = pt.Y @@ -716,7 +716,7 @@ private Point ScreenPtToClientPt(Point pt, IntPtr handle) } // 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/Controls Visuals/VisualPopupTooltip.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopupTooltip.cs index 79e1e70bc..62098cd8e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopupTooltip.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualPopupTooltip.cs @@ -235,7 +235,7 @@ protected override void OnLayout(LayoutEventArgs lEvent) base.OnLayout(lEvent); // Need a render context for accessing the renderer - using RenderContext context = new RenderContext(this, null, ClientRectangle, Renderer); + using var context = new RenderContext(this, null, ClientRectangle, Renderer); // Grab a path that is the outside edge of the border Rectangle borderRect = ClientRectangle; GraphicsPath borderPath1 = Renderer.RenderStandardBorder.GetOutsideBorderPath(context, borderRect, _palette.Border, VisualOrientation.Top, PaletteState.Normal); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualShadowBase.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualShadowBase.cs index 74cd1f9d8..8e4067d9f 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualShadowBase.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualShadowBase.cs @@ -36,7 +36,7 @@ public VisualShadowBase(ShadowValues shadowValues, VisualOrientation visualOrien // Update form properties so we do not have a border and do not show // in the task bar. We draw the background in Magenta and set that as // the transparency key so it is a see through window. - CreateParams cp = new CreateParams + var cp = new CreateParams { // Define the screen position/size X = -2, @@ -171,10 +171,10 @@ internal void UpdateShadowLayer() hOldBitmap = PI.SelectObject(memDc, hBitmap); // Set parameters for layered window update. - PI.SIZE newSize = new PI.SIZE(_shadowClip.Width, _shadowClip.Height); - PI.POINT sourceLocation = new PI.POINT(0, 0); - PI.POINT newLocation = new PI.POINT(TargetRect.Left, TargetRect.Top); - PI.BLENDFUNCTION blend = new PI.BLENDFUNCTION + var newSize = new PI.SIZE(_shadowClip.Width, _shadowClip.Height); + var sourceLocation = new PI.POINT(0, 0); + var newLocation = new PI.POINT(TargetRect.Left, TargetRect.Top); + var blend = new PI.BLENDFUNCTION { BlendOp = PI.AC_SRC_OVER, BlendFlags = 0, diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualTaskDialog.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualTaskDialog.cs index b078e8e88..0293a4c58 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualTaskDialog.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualTaskDialog.cs @@ -302,7 +302,7 @@ private void UpdateRadioButtons() foreach (KryptonTaskDialogCommand command in _radioButtons) { // Create and add a new radio button instance - KryptonRadioButton button = new KryptonRadioButton + var button = new KryptonRadioButton { LabelStyle = LabelStyle.NormalPanel }; @@ -330,7 +330,7 @@ private void UpdateRadioButtons() maxButtonSize.Width = Math.Min(Math.Max(maxButtonSize.Width, 150), 400); // Position the radio buttons in a vertical stack and size owning panel - Point offset = new Point(BUTTON_GAP - 1, 2); + var offset = new Point(BUTTON_GAP - 1, 2); foreach (KryptonRadioButton button in _panelMainRadio.Controls) { button.Location = offset; @@ -358,7 +358,7 @@ private void UpdateCommandButtons() foreach (KryptonTaskDialogCommand command in _commandButtons) { // Create and add a new button instance - KryptonButton button = new KryptonButton + var button = new KryptonButton { ButtonStyle = ButtonStyle.Command }; @@ -385,7 +385,7 @@ private void UpdateCommandButtons() maxButtonSize.Width = Math.Min(Math.Max(maxButtonSize.Width, 150), 400); // Position the buttons in a vertical stack and size owning panel - Point offset = new Point(BUTTON_GAP - 1, 2); + var offset = new Point(BUTTON_GAP - 1, 2); foreach (KryptonButton button in _panelMainCommands.Controls) { button.Location = offset; @@ -643,7 +643,7 @@ private Size UpdateMainTextSizing() var h = (int)Math.Min(messageContentSize.Height, dispSize.Height * 0.6); var w = (int)Math.Min(messageContentSize.Width, dispSize.Width * 0.6); - Size sz = new Size(w, h); + var sz = new Size(w, h); if (messageContentSize != sz) { messageContentSize = sz; @@ -833,7 +833,7 @@ private Size UpdateButtonsSizing() { _panelButtons.Visible = true; - Size panelButtonSize = new Size((maxButtonSize.Width * numButtons) + (BUTTON_GAP * (numButtons + 1)), + var panelButtonSize = new Size((maxButtonSize.Width * numButtons) + (BUTTON_GAP * (numButtons + 1)), maxButtonSize.Height + (BUTTON_GAP * 2)); if (!checkboxSize.IsEmpty) @@ -986,7 +986,7 @@ private void button_keyDown(object sender, KeyEventArgs e) // Pressing Ctrl+C should copy message text into the clipboard if (e is { Modifiers: Keys.Control, KeyCode: Keys.C }) { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); sb.AppendLine("---------------------------"); sb.AppendLine(_windowTitle); diff --git a/Source/Krypton Components/Krypton.Toolkit/Converters/PaletteDrawBordersConverter.cs b/Source/Krypton Components/Krypton.Toolkit/Converters/PaletteDrawBordersConverter.cs index b190cfd2d..86693a9aa 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Converters/PaletteDrawBordersConverter.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Converters/PaletteDrawBordersConverter.cs @@ -45,7 +45,7 @@ public override object ConvertTo(ITypeDescriptorContext context, if (destinationType == typeof(string)) { // Convert object to expected style - PaletteDrawBorders borders = (PaletteDrawBorders)value; + var borders = (PaletteDrawBorders)value; // If the inherit flag is set that that is the only flag of interest if (borders.HasFlag(PaletteDrawBorders.Inherit)) @@ -55,7 +55,7 @@ public override object ConvertTo(ITypeDescriptorContext context, else { // Append the names of each border we want - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); if (borders.HasFlag(PaletteDrawBorders.Top)) { diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonBorderEdgeActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonBorderEdgeActionList.cs index 3e0aba6a0..efabb0144 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonBorderEdgeActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonBorderEdgeActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonBorderEdgeActionList : DesignerActionList { #region Instance Fields - private readonly KryptonBorderEdge _borderEdge; + private readonly KryptonBorderEdge? _borderEdge; private readonly IComponentChangeService _service; private string _action; #endregion @@ -127,7 +127,7 @@ public PaletteMode PaletteMode public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_borderEdge != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonBreadCrumbActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonBreadCrumbActionList.cs index 4889abf2f..3057ab5b9 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonBreadCrumbActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonBreadCrumbActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonBreadCrumbActionList : DesignerActionList { #region Instance Fields - private readonly KryptonBreadCrumb _breadCrumb; + private readonly KryptonBreadCrumb? _breadCrumb; private readonly IComponentChangeService _service; #endregion @@ -113,7 +113,7 @@ public PaletteMode PaletteMode public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_breadCrumb != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonButtonActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonButtonActionList.cs index 64d6a054c..cd359529a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonButtonActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonButtonActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonButtonActionList : DesignerActionList { #region Instance Fields - private readonly KryptonButton _button; + private readonly KryptonButton? _button; private readonly IComponentChangeService _service; #endregion @@ -251,7 +251,7 @@ public bool UseAsUACElevatedButton public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + DesignerActionItemCollection? actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_button != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckBoxActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckBoxActionList.cs index a3850423e..9433d8478 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckBoxActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckBoxActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonCheckBoxActionList : DesignerActionList { #region Instance Fields - private readonly KryptonCheckBox _checkBox; + private readonly KryptonCheckBox? _checkBox; private readonly IComponentChangeService _service; #endregion @@ -300,7 +300,7 @@ public PaletteTextTrim ShortTextTrim public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_checkBox != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckButtonActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckButtonActionList.cs index 218b4684a..1cfac74bd 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckButtonActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckButtonActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonCheckButtonActionList : KryptonButtonActionList { #region Instance Fields - private readonly KryptonCheckButton _checkButton; + private readonly KryptonCheckButton? _checkButton; private readonly IComponentChangeService _service; private string _action; #endregion @@ -77,7 +77,7 @@ public bool Checked public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_checkButton != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckSetActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckSetActionList.cs index f8e73ae02..f5406012e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckSetActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckSetActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonCheckSetActionList : DesignerActionList { #region Instance Fields - private readonly KryptonCheckSet _set; + private readonly KryptonCheckSet? _set; #endregion #region Identity @@ -76,7 +76,7 @@ public Font StateCommonLongTextFont public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_set != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckedListBoxActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckedListBoxActionList.cs index bf236344b..92c5ee813 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckedListBoxActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCheckedListBoxActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonCheckedListBoxActionList : DesignerActionList { #region Instance Fields - private readonly KryptonCheckedListBox _checkedListBox; + private readonly KryptonCheckedListBox? _checkedListBox; private readonly IComponentChangeService _service; #endregion @@ -233,7 +233,7 @@ public float StateCommonCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_checkedListBox != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonColorButtonActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonColorButtonActionList.cs index 0ba0e9ac7..7525c3428 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonColorButtonActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonColorButtonActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonColorButtonActionList : DesignerActionList { #region Instance Fields - private readonly KryptonColorButton _colorButton; + private readonly KryptonColorButton? _colorButton; private readonly IComponentChangeService _service; #endregion @@ -297,7 +297,7 @@ public Rectangle SelectedRect public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_colorButton != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonComboBoxActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonComboBoxActionList.cs index bcf7dbce3..257d777b7 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonComboBoxActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonComboBoxActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonComboBoxActionList : DesignerActionList { #region Instance Fields - private readonly KryptonComboBox _comboBox; + private readonly KryptonComboBox? _comboBox; private readonly IComponentChangeService _service; #endregion @@ -148,7 +148,7 @@ public float StateCommonCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_comboBox != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCommandActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCommandActionList.cs index a1cd83aa0..833227ea7 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCommandActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonCommandActionList.cs @@ -12,7 +12,7 @@ namespace Krypton.Toolkit internal class KryptonCommandActionList : DesignerActionList { #region Instance Fields - private readonly KryptonCommand _command; + private readonly KryptonCommand? _command; private readonly IComponentChangeService _service; #endregion @@ -105,7 +105,7 @@ public Color ImageTransparentColor public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a component instance at design time if (_command != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonContextMenuActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonContextMenuActionList.cs index 87a4b29d1..87af5b1ef 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonContextMenuActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonContextMenuActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonContextMenuActionList : DesignerActionList { #region Instance Fields - private readonly KryptonContextMenu _contextMenu; + private readonly KryptonContextMenu? _contextMenu; private readonly IComponentChangeService _service; #endregion @@ -43,7 +43,7 @@ public KryptonContextMenuActionList(KryptonContextMenuDesigner owner) public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a component instance at design time if (_contextMenu != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonDateTimePickerActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonDateTimePickerActionList.cs index e5b4a7010..85d3ee663 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonDateTimePickerActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonDateTimePickerActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonDateTimePickerActionList : DesignerActionList { #region Instance Fields - private readonly KryptonDateTimePicker _dateTimePicker; + private readonly KryptonDateTimePicker? _dateTimePicker; private readonly IComponentChangeService _service; #endregion @@ -180,7 +180,7 @@ public float StateCommonCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_dateTimePicker != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonDomainUpDownActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonDomainUpDownActionList.cs index 3c9d5b378..d12d58cf5 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonDomainUpDownActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonDomainUpDownActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonDomainUpDownActionList : DesignerActionList { #region Instance Fields - private readonly KryptonDomainUpDown _domainUpDown; + private readonly KryptonDomainUpDown? _domainUpDown; private readonly IComponentChangeService _service; #endregion @@ -129,7 +129,7 @@ public float StateCommonCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_domainUpDown != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonDropButtonActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonDropButtonActionList.cs index a7c7f42b0..49ce24947 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonDropButtonActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonDropButtonActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonDropButtonActionList : DesignerActionList { #region Instance Fields - private readonly KryptonDropButton _dropButton; + private readonly KryptonDropButton? _dropButton; private readonly IComponentChangeService _service; #endregion @@ -267,7 +267,7 @@ public float StateCommonCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_dropButton != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonGroupActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonGroupActionList.cs index d95c5d1ba..451580234 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonGroupActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonGroupActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonGroupActionList : DesignerActionList { #region Instance Fields - private readonly KryptonGroup _group; + private readonly KryptonGroup? _group; private readonly IComponentChangeService _service; #endregion @@ -96,7 +96,7 @@ public PaletteMode PaletteMode public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_group != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonGroupBoxActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonGroupBoxActionList.cs index 87fe27b8e..8b5554662 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonGroupBoxActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonGroupBoxActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonGroupBoxActionList : DesignerActionList { #region Instance Fields - private readonly KryptonGroupBox _groupBox; + private readonly KryptonGroupBox? _groupBox; private readonly IComponentChangeService _service; #endregion @@ -232,7 +232,7 @@ public Font StateCommonShortTextFont public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_groupBox != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonHeaderActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonHeaderActionList.cs index e6a565030..9101b7f56 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonHeaderActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonHeaderActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonHeaderActionList : DesignerActionList { #region Instance Fields - private readonly KryptonHeader _header; + private readonly KryptonHeader? _header; private readonly IComponentChangeService _service; #endregion @@ -147,7 +147,7 @@ public PaletteMode PaletteMode public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_header != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonHeaderGroupActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonHeaderGroupActionList.cs index c5ed0fbf3..9719d890d 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonHeaderGroupActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonHeaderGroupActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonHeaderGroupActionList : DesignerActionList { #region Instance Fields - private readonly KryptonHeaderGroup _headerGroup; + private readonly KryptonHeaderGroup? _headerGroup; private readonly IComponentChangeService _service; private DesignerVerb _visible1; private DesignerVerb _visible2; @@ -168,7 +168,7 @@ public PaletteMode PaletteMode public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_headerGroup != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLabelActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLabelActionList.cs index e480510f4..b2777b886 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLabelActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLabelActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonLabelActionList : DesignerActionList { #region Instance Fields - private readonly KryptonLabel _label; + private readonly KryptonLabel? _label; private readonly IComponentChangeService _service; #endregion @@ -181,7 +181,7 @@ public Font StateCommonLongTextFont public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_label != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLanguageManagerActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLanguageManagerActionList.cs index 956c5b50e..49fb2844c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLanguageManagerActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLanguageManagerActionList.cs @@ -37,7 +37,7 @@ public KryptonLanguageManagerActionList(KryptonLanguageManagerDesigner manager) public override DesignerActionItemCollection GetSortedActionItems() { - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); if (_languageManager != null) { diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLinkLabelActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLinkLabelActionList.cs index d793c7479..4bcb582a0 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLinkLabelActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLinkLabelActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonLinkLabelActionList : DesignerActionList { #region Instance Fields - private readonly KryptonLinkLabel _linkLabel; + private readonly KryptonLinkLabel? _linkLabel; private readonly IComponentChangeService _service; private string _action; #endregion @@ -223,7 +223,7 @@ public Font StateCommonLongTextFont public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_linkLabel != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLinkWrapLabelActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLinkWrapLabelActionList.cs index 5842772a7..dc6b46dbf 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLinkWrapLabelActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonLinkWrapLabelActionList.cs @@ -12,7 +12,7 @@ namespace Krypton.Toolkit internal class KryptonLinkWrapLabelActionList : DesignerActionList { #region Instance Fields - private readonly KryptonLinkWrapLabel _linkWrapLabel; + private readonly KryptonLinkWrapLabel? _linkWrapLabel; private readonly IComponentChangeService _service; #endregion @@ -93,7 +93,7 @@ public Font Font public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_linkWrapLabel != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonListBoxActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonListBoxActionList.cs index a2484fad8..568cbadf5 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonListBoxActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonListBoxActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonListBoxActionList : DesignerActionList { #region Instance Fields - private readonly KryptonListBox _listBox; + private readonly KryptonListBox? _listBox; private readonly IComponentChangeService _service; #endregion @@ -234,7 +234,7 @@ public float StateCommonItemCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_listBox != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonListViewActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonListViewActionList.cs index b85ae51c2..40a2160c8 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonListViewActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonListViewActionList.cs @@ -17,7 +17,7 @@ namespace Krypton.Toolkit.Designers.Action_Lists internal class KryptonListViewActionList : DesignerActionList { #region Instance Fields - private readonly KryptonListView _listView; + private readonly KryptonListView? _listView; private readonly IComponentChangeService _service; #endregion @@ -169,7 +169,7 @@ public float StateCommonItemCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_listView != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonManagerActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonManagerActionList.cs index 82e0d7f0d..3b8de1340 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonManagerActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonManagerActionList.cs @@ -74,16 +74,13 @@ public KryptonLanguageManager? LanguageManager private void OnAddLanguageManager(object sender, EventArgs e) { - if (_manager != null) + if (_manager is { LanguageManager: null }) { - if (_manager.LanguageManager == null) - { - _manager.LanguageManager = new KryptonLanguageManager(); + _manager.LanguageManager = new KryptonLanguageManager(); - KryptonLanguageManager languageManager = new KryptonLanguageManager(); + var languageManager = new KryptonLanguageManager(); - _service.OnComponentChanged(_manager, null, null, languageManager); - } + _service.OnComponentChanged(_manager, null, null, languageManager); } } @@ -107,7 +104,7 @@ private void OnRemoveLanguageManager(object sender, EventArgs e) public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a component instance at design time if (_manager != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonMaskedTextBoxActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonMaskedTextBoxActionList.cs index 401cbfdfd..13ecc7d93 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonMaskedTextBoxActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonMaskedTextBoxActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonMaskedTextBoxActionList : DesignerActionList { #region Instance Fields - private readonly KryptonMaskedTextBox _maskedTextBox; + private readonly KryptonMaskedTextBox? _maskedTextBox; private readonly IComponentChangeService _service; #endregion @@ -148,7 +148,7 @@ public float StateCommonCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_maskedTextBox != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonMonthCalendarActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonMonthCalendarActionList.cs index d578fc4cc..f8b45c6bf 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonMonthCalendarActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonMonthCalendarActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonMonthCalendarActionList : DesignerActionList { #region Instance Fields - private readonly KryptonMonthCalendar _monthCalendar; + private readonly KryptonMonthCalendar? _monthCalendar; private readonly IComponentChangeService _service; #endregion @@ -199,7 +199,7 @@ public float StateCommonCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_monthCalendar != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonNumericUpDownActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonNumericUpDownActionList.cs index ef014d9b8..7b90beace 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonNumericUpDownActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonNumericUpDownActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonNumericUpDownActionList : DesignerActionList { #region Instance Fields - private readonly KryptonNumericUpDown _numericUpDown; + private readonly KryptonNumericUpDown? _numericUpDown; private readonly IComponentChangeService _service; #endregion @@ -182,7 +182,7 @@ public float StateCommonCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_numericUpDown != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonPaletteActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonPaletteActionList.cs index 443ff1365..0ed54ce57 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonPaletteActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonPaletteActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonPaletteActionList : DesignerActionList { #region Instance Fields - private readonly KryptonCustomPaletteBase _palette; + private readonly KryptonCustomPaletteBase? _palette; private readonly IComponentChangeService _service; #endregion @@ -43,7 +43,7 @@ public KryptonPaletteActionList(KryptonPaletteDesigner owner) public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a component instance at design time if (_palette != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonPanelActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonPanelActionList.cs index 244eab35b..4624d4117 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonPanelActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonPanelActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonPanelActionList : DesignerActionList { #region Instance Fields - private readonly KryptonPanel _panel; + private readonly KryptonPanel? _panel; private readonly IComponentChangeService _service; #endregion @@ -79,7 +79,7 @@ public PaletteMode PaletteMode public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_panel != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonPropertyGridActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonPropertyGridActionList.cs index f66d032a0..ce930e416 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonPropertyGridActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonPropertyGridActionList.cs @@ -16,7 +16,7 @@ internal class KryptonPropertyGridActionList : DesignerActionList { #region Instance Fields - private readonly KryptonPropertyGrid _propertyGrid; + private readonly KryptonPropertyGrid? _propertyGrid; private readonly IComponentChangeService _service; @@ -85,7 +85,7 @@ public PropertySort PropertySort public override DesignerActionItemCollection GetSortedActionItems() { - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); if (_propertyGrid != null) { diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonRadioButtonActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonRadioButtonActionList.cs index d8b4cf78e..829421f4e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonRadioButtonActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonRadioButtonActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonRadioButtonActionList : DesignerActionList { #region Instance Fields - private readonly KryptonRadioButton _radioButton; + private readonly KryptonRadioButton? _radioButton; private readonly IComponentChangeService _service; #endregion @@ -215,7 +215,7 @@ public Font StateCommonLongTextFont public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_radioButton != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonRichTextBoxActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonRichTextBoxActionList.cs index bdceca725..c14abd1ce 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonRichTextBoxActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonRichTextBoxActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonRichTextBoxActionList : DesignerActionList { #region Instance Fields - private readonly KryptonRichTextBox _richTextBox; + private readonly KryptonRichTextBox? _richTextBox; private readonly IComponentChangeService _service; #endregion @@ -165,7 +165,7 @@ public float StateCommonCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_richTextBox != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonScrollBarActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonScrollBarActionList.cs index adbe868f0..00dd6b6be 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonScrollBarActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonScrollBarActionList.cs @@ -16,8 +16,7 @@ internal class KryptonScrollBarActionList : DesignerActionList { #region Instance Fields - private readonly KryptonScrollBar _scrollBar; - + private readonly KryptonScrollBar? _scrollBar; private readonly IComponentChangeService _service; #endregion @@ -104,7 +103,7 @@ public ScrollBarOrientation Orientation /// A DesignerActionItem array that contains the items in this list. public override DesignerActionItemCollection GetSortedActionItems() { - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); if (_scrollBar != null) { diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonSeparatorActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonSeparatorActionList.cs index 3132806da..0facd6e4d 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonSeparatorActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonSeparatorActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonSeparatorActionList : DesignerActionList { #region Instance Fields - private readonly KryptonSeparator _separator; + private readonly KryptonSeparator? _separator; private readonly IComponentChangeService _service; #endregion @@ -96,7 +96,7 @@ public PaletteMode PaletteMode public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_separator != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonSplitContainerActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonSplitContainerActionList.cs index 725ff4f63..2dcd6ff11 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonSplitContainerActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonSplitContainerActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonSplitContainerActionList : DesignerActionList { #region Instance Fields - private readonly KryptonSplitContainer _splitContainer; + private readonly KryptonSplitContainer? _splitContainer; private readonly IComponentChangeService _service; private string _action; #endregion @@ -112,7 +112,7 @@ public PaletteMode PaletteMode public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_splitContainer != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonTextBoxActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonTextBoxActionList.cs index bb3a2f308..86e6d6af6 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonTextBoxActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonTextBoxActionList.cs @@ -182,7 +182,7 @@ public float StateCommonCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_textBox != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonTrackBarActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonTrackBarActionList.cs index a8a3972d4..771aa9720 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonTrackBarActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonTrackBarActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonTrackBarActionList : DesignerActionList { #region Instance Fields - private readonly KryptonTrackBar _trackBar; + private readonly KryptonTrackBar? _trackBar; private readonly IComponentChangeService _service; private string _action; #endregion @@ -180,7 +180,7 @@ public int LargeChange public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_trackBar != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonTreeViewActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonTreeViewActionList.cs index 51b457a6d..af1cc2c16 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonTreeViewActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonTreeViewActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonTreeViewActionList : DesignerActionList { #region Instance Fields - private readonly KryptonTreeView _treeView; + private readonly KryptonTreeView? _treeView; private readonly IComponentChangeService _service; #endregion @@ -217,7 +217,7 @@ public float NodeStateCommonCornerRoundingRadius public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_treeView != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonWrapLabelActionList.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonWrapLabelActionList.cs index 77e7c16f8..7b11f95dd 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonWrapLabelActionList.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Action Lists/KryptonWrapLabelActionList.cs @@ -15,7 +15,7 @@ namespace Krypton.Toolkit internal class KryptonWrapLabelActionList : DesignerActionList { #region Instance Fields - private readonly KryptonWrapLabel _wrapLabel; + private readonly KryptonWrapLabel? _wrapLabel; private readonly IComponentChangeService _service; #endregion @@ -96,7 +96,7 @@ public Font Font public override DesignerActionItemCollection GetSortedActionItems() { // Create a new collection for holding the single item we want to create - DesignerActionItemCollection actions = new DesignerActionItemCollection(); + var actions = new DesignerActionItemCollection(); // This can be null when deleting a control instance at design time if (_wrapLabel != null) diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonBorderEdgeDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonBorderEdgeDesigner.cs index 48abae00e..0b588cd79 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonBorderEdgeDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonBorderEdgeDesigner.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 KryptonBorderEdgeActionList(this) }; diff --git a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonBreadCrumbDesigner.cs b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonBreadCrumbDesigner.cs index e325f5a7b..f394d2291 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonBreadCrumbDesigner.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Designers/Designers/KryptonBreadCrumbDesigner.cs @@ -16,7 +16,7 @@ internal class KryptonBreadCrumbDesigner : ControlDesigner { #region Instance Fields private bool _lastHitTest; - private KryptonBreadCrumb _breadCrumb; + private KryptonBreadCrumb? _breadCrumb; private IDesignerHost _designerHost; private IComponentChangeService _changeService; private ISelectionService _selectionService; @@ -65,7 +65,7 @@ public override ICollection AssociatedComponents { get { - ArrayList compound = new ArrayList(base.AssociatedComponents); + var compound = new ArrayList(base.AssociatedComponents); if (_breadCrumb != null) { @@ -85,9 +85,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 KryptonBreadCrumbActionList(this) }; @@ -164,7 +163,7 @@ private void OnBreadCrumbMouseUp(object sender, MouseEventArgs e) if ((_breadCrumb != null) && (e.Button == MouseButtons.Left)) { // Get any component associated with the current mouse position - Component component = _breadCrumb.DesignerComponentFromPoint(new Point(e.X, e.Y)); + Component? component = _breadCrumb.DesignerComponentFromPoint(new Point(e.X, e.Y)); if (component != null) { @@ -172,7 +171,7 @@ private void OnBreadCrumbMouseUp(object sender, MouseEventArgs e) _breadCrumb.PerformLayout(); // Select the component - ArrayList selectionList = new ArrayList + var selectionList = new ArrayList { component }; @@ -184,7 +183,7 @@ private void OnBreadCrumbMouseUp(object sender, MouseEventArgs e) private void OnBreadCrumbDoubleClick(object sender, Point pt) { // Get any component associated with the current mouse position - Component component = _breadCrumb?.DesignerComponentFromPoint(pt); + Component? component = _breadCrumb?.DesignerComponentFromPoint(pt); if (component != null) { @@ -202,7 +201,7 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) if ((_breadCrumb != null) && (e.Component == _breadCrumb)) { // Need access to host in order to delete a component - IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + IDesignerHost? host = (IDesignerHost)GetService(typeof(IDesignerHost)); // We need to remove all the button spec instances for (var i = _breadCrumb.ButtonSpecs.Count - 1; i >= 0; i--) @@ -217,7 +216,7 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) _breadCrumb.ButtonSpecs.Remove(spec); // Get host to remove it from design time - host.DestroyComponent(spec); + host?.DestroyComponent(spec); // Must wrap button spec removal in change notifications _changeService.OnComponentChanged(_breadCrumb, null, null, null); diff --git a/Source/Krypton Components/Krypton.Toolkit/EventArgs/ContextMenuArgs.cs b/Source/Krypton Components/Krypton.Toolkit/EventArgs/ContextMenuArgs.cs index 164779e45..9d0443e7d 100644 --- a/Source/Krypton Components/Krypton.Toolkit/EventArgs/ContextMenuArgs.cs +++ b/Source/Krypton Components/Krypton.Toolkit/EventArgs/ContextMenuArgs.cs @@ -49,8 +49,8 @@ public ContextMenuArgs(KryptonContextMenu kcm) /// /// Context menu strip that can be customized. /// KryptonContextMenu that can be customized. - public ContextMenuArgs(ContextMenuStrip cms, - KryptonContextMenu kcm) + public ContextMenuArgs(ContextMenuStrip? cms, + KryptonContextMenu? kcm) { ContextMenuStrip = cms; KryptonContextMenu = kcm; diff --git a/Source/Krypton Components/Krypton.Toolkit/EventArgs/ContextPositionMenuArgs.cs b/Source/Krypton Components/Krypton.Toolkit/EventArgs/ContextPositionMenuArgs.cs index 3f9678962..ed87149cd 100644 --- a/Source/Krypton Components/Krypton.Toolkit/EventArgs/ContextPositionMenuArgs.cs +++ b/Source/Krypton Components/Krypton.Toolkit/EventArgs/ContextPositionMenuArgs.cs @@ -55,8 +55,8 @@ public ContextPositionMenuArgs(KryptonContextMenu kcm, /// KryptonContextMenu that can be customized. /// Relative horizontal position of the KryptonContextMenu. /// Relative vertical position of the KryptonContextMenu. - public ContextPositionMenuArgs(ContextMenuStrip cms, - KryptonContextMenu kcm, + public ContextPositionMenuArgs(ContextMenuStrip? cms, + KryptonContextMenu? kcm, KryptonContextMenuPositionH positionH, KryptonContextMenuPositionV positionV) : base(cms, kcm) diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteBackInheritNode.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteBackInheritNode.cs index ed70e1a10..0180b1561 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteBackInheritNode.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteBackInheritNode.cs @@ -40,7 +40,7 @@ public PaletteBackInheritNode([DisallowNull] IPaletteBack inherit) /// /// Set the tree node to use for sourcing values. /// - public TreeNode TreeNode { get; set; } + public TreeNode? TreeNode { get; set; } #endregion diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteContentInheritNode.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteContentInheritNode.cs index 3cb65f599..f22e1eb43 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteContentInheritNode.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteContentInheritNode.cs @@ -37,7 +37,7 @@ public PaletteContentInheritNode(IPaletteContent inherit) => /// /// Set the tree node to use for sourcing values. /// - public TreeNode TreeNode { get; set; } + public TreeNode? TreeNode { get; set; } #endregion diff --git a/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteNodeOverride.cs b/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteNodeOverride.cs index 2b1db97fc..001039ac4 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteNodeOverride.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Palette Controls/PaletteNodeOverride.cs @@ -52,7 +52,7 @@ public PaletteNodeOverride([DisallowNull] IPaletteTriple triple) /// /// Set the tree node to use for sourcing values. /// - public TreeNode TreeNode + public TreeNode? TreeNode { set { @@ -71,12 +71,12 @@ public TreeNode TreeNode /// /// Gets the border palette. /// - public IPaletteBorder? PaletteBorder => _overrideBorder; + public IPaletteBorder PaletteBorder => _overrideBorder; /// /// Gets the border palette. /// - public IPaletteContent? PaletteContent => _overrideContent; + public IPaletteContent PaletteContent => _overrideContent; #endregion }