mirror of
https://github.com/colhountech/DarkUI.Net5.git
synced 2025-07-02 23:29:28 +03:00
Minor refactoring and cleaning
Removed unnecessary comments. Added string interpolation from C# 6.0. Removed unneeded library references.
This commit is contained in:
parent
a29c055545
commit
baaab81736
@ -40,20 +40,12 @@ namespace DarkUI
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Release managed resources
|
||||
}
|
||||
|
||||
// Release unmanaged resources.
|
||||
// Set large fields to null.
|
||||
if (ItemsAdded != null)
|
||||
ItemsAdded = null;
|
||||
|
||||
if (ItemsRemoved != null)
|
||||
ItemsRemoved = null;
|
||||
|
||||
// Set disposed flag
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ namespace DarkUI
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public new bool Enabled
|
||||
{
|
||||
get { return base.Enabled; }
|
||||
|
@ -208,7 +208,7 @@ namespace DarkUI
|
||||
public void SelectItem(int index)
|
||||
{
|
||||
if (index < 0 || index > Items.Count - 1)
|
||||
throw new IndexOutOfRangeException(string.Format("Value '{0}' is outside of valid range.", index));
|
||||
throw new IndexOutOfRangeException($"Value '{index}' is outside of valid range.");
|
||||
|
||||
_selectedIndices.Clear();
|
||||
_selectedIndices.Add(index);
|
||||
@ -228,7 +228,7 @@ namespace DarkUI
|
||||
foreach (var index in list)
|
||||
{
|
||||
if (index < 0 || index > Items.Count - 1)
|
||||
throw new IndexOutOfRangeException(string.Format("Value '{0}' is outside of valid range.", index));
|
||||
throw new IndexOutOfRangeException($"Value '{index}' is outside of valid range.");
|
||||
|
||||
_selectedIndices.Add(index);
|
||||
}
|
||||
@ -428,7 +428,6 @@ namespace DarkUI
|
||||
var top = range.Min();
|
||||
var bottom = range.Max();
|
||||
|
||||
// Draw items
|
||||
for (var i = top; i <= bottom; i++)
|
||||
{
|
||||
var width = Math.Max(ContentSize.Width, Viewport.Width);
|
||||
@ -446,7 +445,7 @@ namespace DarkUI
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
|
||||
// Border
|
||||
// DEBUG: Border
|
||||
/*using (var p = new Pen(Colors.DarkBorder))
|
||||
{
|
||||
g.DrawLine(p, new Point(rect.Left, rect.Bottom - 1), new Point(rect.Right, rect.Bottom - 1));
|
||||
|
@ -205,7 +205,7 @@ namespace DarkUI
|
||||
|
||||
if (_trackArea.Contains(e.Location) && e.Button == MouseButtons.Left)
|
||||
{
|
||||
// Check if our input is at least aligned with the thumb
|
||||
// Step 1. Check if our input is at least aligned with the thumb
|
||||
if (_scrollOrientation == DarkOrientation.Vertical)
|
||||
{
|
||||
var modRect = new Rectangle(_thumbArea.Left, _trackArea.Top, _thumbArea.Width, _trackArea.Height);
|
||||
@ -219,7 +219,7 @@ namespace DarkUI
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 1. Scroll to the area initially clicked.
|
||||
// Step 2. Scroll to the area initially clicked.
|
||||
if (_scrollOrientation == DarkOrientation.Vertical)
|
||||
{
|
||||
var loc = e.Location.Y;
|
||||
@ -235,7 +235,7 @@ namespace DarkUI
|
||||
ScrollToPhysical(loc);
|
||||
}
|
||||
|
||||
// Step 2. Initiate a thumb drag.
|
||||
// Step 3. Initiate a thumb drag.
|
||||
_isScrolling = true;
|
||||
_initialContact = e.Location;
|
||||
_thumbHot = true;
|
||||
@ -246,7 +246,6 @@ namespace DarkUI
|
||||
_initialValue = _thumbArea.Left;
|
||||
|
||||
Invalidate();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -163,13 +163,6 @@ namespace DarkUI
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Release managed resources
|
||||
}
|
||||
|
||||
// Release unmanaged resources.
|
||||
// Set large fields to null.
|
||||
DisposeIcons();
|
||||
|
||||
if (SelectedNodesChanged != null)
|
||||
@ -187,11 +180,9 @@ namespace DarkUI
|
||||
if (_selectedNodes != null)
|
||||
_selectedNodes.CollectionChanged -= SelectedNodes_CollectionChanged;
|
||||
|
||||
// Set disposed flag
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
// Call Dispose on your base class.
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
@ -1159,7 +1150,7 @@ namespace DarkUI
|
||||
if (node == dropNode)
|
||||
{
|
||||
if (isMoving)
|
||||
DarkMessageBox.ShowError(String.Format(@"Cannot move {0}. The destination folder is the same as the source folder.", node.Text), Application.ProductName);
|
||||
DarkMessageBox.ShowError($"Cannot move {node.Text}. The destination folder is the same as the source folder.", Application.ProductName);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1167,7 +1158,7 @@ namespace DarkUI
|
||||
if (node.ParentNode != null && node.ParentNode == dropNode)
|
||||
{
|
||||
if (isMoving)
|
||||
DarkMessageBox.ShowError(String.Format(@"Cannot move {0}. The destination folder is the same as the source folder.", node.Text), Application.ProductName);
|
||||
DarkMessageBox.ShowError($"Cannot move {node.Text}. The destination folder is the same as the source folder.", Application.ProductName);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1178,7 +1169,7 @@ namespace DarkUI
|
||||
if (node == parentNode)
|
||||
{
|
||||
if (isMoving)
|
||||
DarkMessageBox.ShowError(String.Format(@"Cannot move {0}. The destination folder is a subfolder of the source folder.", node.Text), Application.ProductName);
|
||||
DarkMessageBox.ShowError($"Cannot move {node.Text}. The destination folder is a subfolder of the source folder.", Application.ProductName);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -7,8 +7,11 @@ namespace DarkUI
|
||||
#region Property Region
|
||||
|
||||
public string Text { get; set; }
|
||||
|
||||
public Rectangle Area { get; set; }
|
||||
|
||||
public Color TextColor { get; set; }
|
||||
|
||||
public FontStyle FontStyle { get; set; }
|
||||
|
||||
#endregion
|
||||
|
@ -46,13 +46,17 @@ namespace DarkUI
|
||||
}
|
||||
|
||||
public Rectangle ExpandArea { get; set; }
|
||||
|
||||
public Rectangle IconArea { get; set; }
|
||||
|
||||
public Rectangle TextArea { get; set; }
|
||||
|
||||
public Rectangle FullArea { get; set; }
|
||||
|
||||
public bool ExpandAreaHot { get; set; }
|
||||
|
||||
public Bitmap Icon { get; set; }
|
||||
|
||||
public Bitmap ExpandedIcon { get; set; }
|
||||
|
||||
public bool Expanded
|
||||
|
@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DarkUI
|
||||
{
|
||||
@ -12,7 +10,7 @@ namespace DarkUI
|
||||
var last = items.LastOrDefault();
|
||||
if (last == null)
|
||||
return false;
|
||||
return item.Equals(last); // OR Object.ReferenceEquals(last, item)
|
||||
return item.Equals(last);
|
||||
}
|
||||
|
||||
internal static bool IsFirst<T>(this IEnumerable<T> items, T item)
|
||||
|
@ -14,9 +14,8 @@ namespace DarkUI
|
||||
var hControlUnderMouse = Native.WindowFromPoint(new Point((int)m.LParam));
|
||||
|
||||
if (hControlUnderMouse == m.HWnd)
|
||||
return false; // Already headed for the right control.
|
||||
return false;
|
||||
|
||||
// Redirect the message to the control under the mouse.
|
||||
Native.SendMessage(hControlUnderMouse, (uint)m.Msg, m.WParam, m.LParam);
|
||||
return true;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace Example
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
lblVersion.Text = string.Format("Version: {0}", Application.ProductVersion.ToString());
|
||||
lblVersion.Text = $"Version: {Application.ProductVersion.ToString()}";
|
||||
btnOk.Text = "Close";
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ namespace Example
|
||||
// Build dummy list data
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var item = new DarkListItem(string.Format("List item #{0}", i));
|
||||
var item = new DarkListItem($"List item #{i}");
|
||||
lstTest.Items.Add(item);
|
||||
}
|
||||
|
||||
@ -19,13 +19,13 @@ namespace Example
|
||||
var childCount = 0;
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
var node = new DarkTreeNode(string.Format("Root node #{0}", i));
|
||||
var node = new DarkTreeNode($"Root node #{i}");
|
||||
node.ExpandedIcon = Icons.folder_open;
|
||||
node.Icon = Icons.folder_closed;
|
||||
|
||||
for (var x = 0; x < 10; x++)
|
||||
{
|
||||
var childNode = new DarkTreeNode(string.Format("Child node #{0}", childCount));
|
||||
var childNode = new DarkTreeNode($"Child node #{childCount}");
|
||||
childNode.Icon = Icons.files;
|
||||
childCount++;
|
||||
node.Nodes.Add(childNode);
|
||||
|
@ -13,7 +13,7 @@ namespace Example
|
||||
// Build dummy list data
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var item = new DarkListItem(string.Format("List item #{0}", i));
|
||||
var item = new DarkListItem($"List item #{i}");
|
||||
lstConsole.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace Example
|
||||
// Build dummy list data
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var item = new DarkListItem(string.Format("List item #{0}", i));
|
||||
var item = new DarkListItem($"List item #{i}");
|
||||
lstHistory.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace Example
|
||||
// Build dummy list data
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var item = new DarkListItem(string.Format("List item #{0}", i));
|
||||
var item = new DarkListItem($"List item #{i}");
|
||||
lstLayers.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ namespace Example
|
||||
var childCount = 0;
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
var node = new DarkTreeNode(string.Format("Root node #{0}", i));
|
||||
var node = new DarkTreeNode($"Root node #{i}");
|
||||
node.ExpandedIcon = Icons.folder_open;
|
||||
node.Icon = Icons.folder_closed;
|
||||
|
||||
for (var x = 0; x < 10; x++)
|
||||
{
|
||||
var childNode = new DarkTreeNode(string.Format("Child node #{0}", childCount));
|
||||
var childNode = new DarkTreeNode($"Child node #{childCount}");
|
||||
childNode.Icon = Icons.files;
|
||||
childCount++;
|
||||
node.Nodes.Add(childNode);
|
||||
|
@ -43,7 +43,7 @@ namespace Example
|
||||
DockPanel.AddContent(_dockLayers);
|
||||
DockPanel.AddContent(_dockHistory);
|
||||
|
||||
// Add 3 dummy documents to the main document area of the dock panel
|
||||
// Add dummy documents to the main document area of the dock panel
|
||||
DockPanel.AddContent(new DockDocument { DockText = "Document 1" });
|
||||
DockPanel.AddContent(new DockDocument { DockText = "Document 2" });
|
||||
DockPanel.AddContent(new DockDocument { DockText = "Document 3" });
|
||||
|
@ -5,9 +5,6 @@ namespace Example
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user