Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
trim_trailing_whitespace = false
insert_final_newline = true

[*.cs]
indent_style = space
indent_size = 4
max_line_length = 120

csharpier_print_width = 120
dotnet_diagnostic.IDE1006.severity = none # naming conventions
68 changes: 49 additions & 19 deletions Examples/SDUI.AnimationEngineTest/MenuCloseButton.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using SDUI.AnimationEngine;
using System.Drawing.Drawing2D;
using System.Drawing.Drawing2D;
using SDUI.AnimationEngine;

namespace SDUI.AnimationEngineTest
{
public class MenuCloseButton
: Control
public class MenuCloseButton : Control
{
public MenuCloseButton()
: base()
Expand All @@ -15,24 +14,38 @@ public MenuCloseButton()
//Every Point is between (-1|-1) and (1|1)
this.NormalState = new PointF[]
{
new PointF(-1, .8f), new PointF(1, .8f), //Topmost line
new PointF(-1, 0), new PointF(1, 0), //Middle line
new PointF(-1, -.8f), new PointF(1, -.8f) //Lowest line
new PointF(-1, .8f),
new PointF(1, .8f), //Topmost line
new PointF(-1, 0),
new PointF(1, 0), //Middle line
new PointF(-1, -.8f),
new PointF(1, -.8f), //Lowest line
};

this.ExtendedState = new PointF[]
{
new PointF(1, -1), new PointF(-1, 1), //Bottom right to top left
new PointF(1, 0), new PointF(-1, 0), //Collapsed
new PointF(1, 1), new PointF(-1, -1) //Top right to bottom left
new PointF(1, -1),
new PointF(-1, 1), //Bottom right to top left
new PointF(1, 0),
new PointF(-1, 0), //Collapsed
new PointF(1, 1),
new PointF(-1, -1), //Top right to bottom left
};

this.PointProvider = new ValueProvider<PointF[]>(this.NormalState, ValueFactoryCreator.CreateArrayFactory<PointF>(ValueFactories.PointFFactory), EasingMethods.ExponentialEaseOut);
this.MiddleLineOpacityProvider = new ValueProvider<byte>(255, ValueFactories.ByteFactory, EasingMethods.ExponentialEaseInOut);
this.PointProvider = new ValueProvider<PointF[]>(
this.NormalState,
ValueFactoryCreator.CreateArrayFactory<PointF>(ValueFactories.PointFFactory),
EasingMethods.ExponentialEaseOut
);
this.MiddleLineOpacityProvider = new ValueProvider<byte>(
255,
ValueFactories.ByteFactory,
EasingMethods.ExponentialEaseInOut
);

this.DoubleBuffered = true;
//For updates.
new System.Windows.Forms.Timer() { Enabled = true, Interval = 1000/60 }.Tick += (s, e) =>
new System.Windows.Forms.Timer() { Enabled = true, Interval = 1000 / 60 }.Tick += (s, e) =>
{
this.Invalidate();
};
Expand All @@ -41,7 +54,6 @@ public MenuCloseButton()
protected PointF[] NormalState;
protected PointF[] ExtendedState;


protected double durationFactor = 1;
private bool extended = false;
public bool Extended
Expand All @@ -51,8 +63,14 @@ public bool Extended
{
if (value != this.extended)
{
this.PointProvider.StartTransition(value ? this.ExtendedState : this.NormalState, TimeSpan.FromSeconds(1 * durationFactor));
this.MiddleLineOpacityProvider.StartTransition(value ? (byte)0 : (byte)255, TimeSpan.FromSeconds(.25 * durationFactor));
this.PointProvider.StartTransition(
value ? this.ExtendedState : this.NormalState,
TimeSpan.FromSeconds(1 * durationFactor)
);
this.MiddleLineOpacityProvider.StartTransition(
value ? (byte)0 : (byte)255,
TimeSpan.FromSeconds(.25 * durationFactor)
);
this.extended = value;
}
}
Expand All @@ -70,9 +88,18 @@ protected override void OnPaint(PaintEventArgs pevent)
pevent.Graphics.DrawLine(linePen, this.Project(currentState[0]), this.Project(currentState[1]));
pevent.Graphics.DrawLine(linePen, this.Project(currentState[4]), this.Project(currentState[5]));

using (Pen middleLinePen = new Pen(Color.FromArgb(this.MiddleLineOpacityProvider.CurrentValue, this.ForeColor), linePen.Width))
using (
Pen middleLinePen = new Pen(
Color.FromArgb(this.MiddleLineOpacityProvider.CurrentValue, this.ForeColor),
linePen.Width
)
)
{
pevent.Graphics.DrawLine(middleLinePen, this.Project(currentState[2]), this.Project(currentState[3]));
pevent.Graphics.DrawLine(
middleLinePen,
this.Project(currentState[2]),
this.Project(currentState[3])
);
}
}

Expand All @@ -82,7 +109,10 @@ protected override void OnPaint(PaintEventArgs pevent)
protected PointF Project(PointF relativePoint, float spacing = .1f)
{
PointF center = new PointF(this.Width / 2f, this.Height / 2f);
return new PointF(center.X + (center.X * relativePoint.X) - ((center.X * spacing) * relativePoint.X), center.Y + (center.Y * relativePoint.Y) - ((center.Y * spacing) * relativePoint.Y));
return new PointF(
center.X + (center.X * relativePoint.X) - ((center.X * spacing) * relativePoint.X),
center.Y + (center.Y * relativePoint.Y) - ((center.Y * spacing) * relativePoint.Y)
);
}

protected override void OnClick(EventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion Examples/SDUI.AnimationEngineTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ static void Main()
Application.Run(new Main());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
Expand All @@ -11,5 +10,4 @@
<ItemGroup>
<ProjectReference Include="..\..\SDUI\SDUI.csproj" />
</ItemGroup>

</Project>
</Project>
2 changes: 1 addition & 1 deletion Examples/SDUI.Examples.Mac/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ public MainWindow()
AddMousePressMove(panel1);
}
}
}
}
2 changes: 1 addition & 1 deletion Examples/SDUI.Examples.Mac/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ static void Main()
Application.Run(new MainWindow());
}
}
}
}
4 changes: 1 addition & 3 deletions Examples/SDUI.Examples.Mac/SDUI.Examples.Mac.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
Expand All @@ -11,5 +10,4 @@
<ItemGroup>
<ProjectReference Include="..\..\SDUI\SDUI.csproj" />
</ItemGroup>

</Project>
</Project>
8 changes: 4 additions & 4 deletions Examples/SDUI.Test/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
4 changes: 2 additions & 2 deletions Examples/SDUI.Test/ConfigPage.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using SDUI.Controls;
using System;
using System;
using System.ComponentModel;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using SDUI.Controls;

namespace SDUI.Test
{
Expand Down
7 changes: 3 additions & 4 deletions Examples/SDUI.Test/GeneralPage.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using SDUI.Controls;
using System;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Threading.Tasks;
using System.Windows.Forms;
using SDUI.Controls;

namespace SDUI.Test
{
Expand Down Expand Up @@ -78,7 +78,6 @@ private void textBox1_KeyDown(object sender, KeyEventArgs e)
MessageBox.Show(textBox1.Text);
}


private void buttonOpenInputDialog_Click(object sender, EventArgs e)
{
var dialog = new InputDialog("The input dialog", "This is a input dialog", "Please set the value!");
Expand All @@ -100,7 +99,7 @@ private void buttonRandomColor_Click(object sender, EventArgs e)
return;

var parent = form as UIWindow;
if(parent != null)
if (parent != null)
{
ColorScheme.BackColor = Color.FromArgb(r, g, b);
parent.BackColor = ColorScheme.BackColor;
Expand Down
16 changes: 12 additions & 4 deletions Examples/SDUI.Test/ListViewPage.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using SDUI.Controls;
using System.ComponentModel;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using SDUI.Controls;

namespace SDUI.Test
{
Expand All @@ -22,7 +22,10 @@ public ListViewPage()
for (int i = 0; i <= 5; i++)
{
var title = "Item " + i.ToString();
var listItem = new ListViewItem(new[] { i.ToString(), title + " Column 2", title + " Column 3", title + " Column 4" }, group1);
var listItem = new ListViewItem(
new[] { i.ToString(), title + " Column 2", title + " Column 3", title + " Column 4" },
group1
);
if (i == 0)
{
listItem.BackColor = ControlPaint.Light(ColorScheme.BackColor, .15f);
Expand All @@ -34,7 +37,12 @@ public ListViewPage()
for (int i = 6; i <= 1000; i++)
{
string sItem = "Item " + i.ToString();
listView1.Items.Add(new ListViewItem(new[] { i.ToString(), sItem + " Column 2", sItem + " Column 3", sItem + " Column 4" }, group2));
listView1.Items.Add(
new ListViewItem(
new[] { i.ToString(), sItem + " Column 2", sItem + " Column 3", sItem + " Column 4" },
group2
)
);
}

//listView1.SetGroupInfo(listView1.Handle, 1, NativeMethods.LVGS_COLLAPSIBLE);
Expand Down
21 changes: 12 additions & 9 deletions Examples/SDUI.Test/MainWindow.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using SDUI.Controls;
using System;
using SDUI.Controls;

namespace SDUI.Test;

public partial class MainWindow : UIWindow
{
public MainWindow()
{
InitializeComponent();
InitializeComponent();
}

protected override void OnBackColorChanged(EventArgs e)
Expand All @@ -19,11 +19,14 @@ protected override void OnBackColorChanged(EventArgs e)

private void MainWindow_Load(object sender, EventArgs e)
{
windowPageControl.Controls.AddRange(new System.Windows.Forms.Control[] {
new GeneralPage(),
new ListViewPage(),
new ConfigPage(),
new MultiPageControlTestPage()
});
windowPageControl.Controls.AddRange(
new System.Windows.Forms.Control[]
{
new GeneralPage(),
new ListViewPage(),
new ConfigPage(),
new MultiPageControlTestPage(),
}
);
}
}
}
5 changes: 3 additions & 2 deletions Examples/SDUI.Test/MultiPageControlTestPage.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using SDUI.Controls;
using System;
using System;
using System.ComponentModel;
using System.Windows.Forms;
using SDUI.Controls;

namespace SDUI.Test
{
[ToolboxItem(false)]
public partial class MultiPageControlTestPage : DoubleBufferedControl
{
private Type[] _types = { typeof(GeneralPage), typeof(ListViewPage), typeof(ConfigPage) };

public MultiPageControlTestPage()
{
InitializeComponent();
Expand Down
2 changes: 0 additions & 2 deletions Examples/SDUI.Test/SDUI.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
Expand All @@ -11,5 +10,4 @@
<ItemGroup>
<ProjectReference Include="..\..\SDUI\SDUI.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion SDUI/AnimationEngine/AnimationDirection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public enum AnimationDirection
InOutIn,
InOutOut,
InOutRepeatingIn,
InOutRepeatingOut
InOutRepeatingOut,
}
}
Loading