Skip to content

Commit

Permalink
Implement themes and color schemes for material style, .UseStyle(styl…
Browse files Browse the repository at this point in the history
…e) refactoring (#8)
  • Loading branch information
bubuntoid authored Dec 18, 2020
1 parent 412c239 commit 1d53155
Show file tree
Hide file tree
Showing 22 changed files with 688 additions and 25 deletions.
3 changes: 3 additions & 0 deletions src/EasyDialog.Tests/EasyDialog.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MaterialSkin, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialSkin.0.2.1\lib\MaterialSkin.dll</HintPath>
</Reference>
<Reference Include="MetroFramework, Version=1.2.0.3, Culture=neutral, PublicKeyToken=5f91a84759bf584a, processorArchitecture=MSIL">
<HintPath>..\packages\MetroFramework.RunTime.1.2.0.3\lib\net40-Client\MetroFramework.dll</HintPath>
</Reference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class AuthentificationDialog : DialogContext

protected override void OnConfiguring(DialogContextOptionsBuilder builder)
{
builder.UseStyle(DialogStyle.Material)
builder.UseMaterialStyle(MaterialTheme.Light, MaterialColorScheme.Cyan)
.WithTitle("Authentification")
.WithButton("Sign in");

Expand Down
4 changes: 1 addition & 3 deletions src/EasyDialog.Tests/Implementation/ClientDialog.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using bubuntoid.EasyDialog.Enums;
using bubuntoid.EasyDialog.Tests.Implementation.CustomDialogItems;
using bubuntoid.EasyDialog.Tests.Models;

Expand Down Expand Up @@ -34,8 +33,7 @@ protected override void OnConfiguring(DialogContextOptionsBuilder builder)
var title = client == null ? "Create a new client" : $"Edit client #{client.Id}";
var button = client == null ? "Add" : "Save";

builder.UseStyle(DialogStyle.Metro)
.UseMetroTheme(theme)
builder.UseMetroStyle(theme)
.WithTitle(title)
.WithButton(button);

Expand Down
6 changes: 2 additions & 4 deletions src/EasyDialog.Tests/Implementation/UploadFileDialog.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using bubuntoid.EasyDialog.Tests.Implementation.CustomDialogItems;
using bubuntoid.EasyDialog.Tests.Implementation.CustomDialogItems;

namespace bubuntoid.EasyDialog.Tests.Implementation
{
Expand All @@ -11,7 +9,7 @@ public class UploadFileDialog : DialogContext

protected override void OnConfiguring(DialogContextOptionsBuilder builder)
{
builder.UseStyle(DialogStyle.Default)
builder.UseDefaultStyle()
.WithTitle("Uploading...")
.WithButton("Upload");

Expand Down
4 changes: 2 additions & 2 deletions src/EasyDialog.Tests/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Windows.Forms;
using System.Threading.Tasks;
using bubuntoid.EasyDialog.Enums;
using bubuntoid.EasyDialog.Tests.Implementation;
using bubuntoid.EasyDialog.Tests.Models;
using MaterialSkin.Controls;

namespace bubuntoid.EasyDialog.Tests
{
Expand All @@ -19,7 +19,7 @@ static void Main()
var taskB = Task.Factory.StartNew(() => new ClientDialog(Client.Get()).Show());
var taskC = Task.Factory.StartNew(() => new UploadFileDialog().Show());
var taskD = Task.Factory.StartNew(() => new ClientDialog(null, MetroTheme.Green).Show());

Task.WaitAll(new[] { taskA, taskB, taskC, taskD });
}
}
Expand Down
1 change: 1 addition & 0 deletions src/EasyDialog.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MaterialSkin" version="0.2.1" targetFramework="net472" />
<package id="MetroFramework.RunTime" version="1.2.0.3" targetFramework="net472" />
</packages>
44 changes: 39 additions & 5 deletions src/EasyDialog/DialogContextOptionsBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;

using bubuntoid.EasyDialog.Enums;

namespace bubuntoid.EasyDialog
{
public class DialogContextOptionsBuilder
Expand All @@ -11,6 +9,8 @@ public class DialogContextOptionsBuilder

internal DialogStyle Style { get; set; } = DialogStyle.Default;
internal MetroTheme MetroTheme { get; set; } = MetroTheme.Default;
internal MaterialTheme MaterialTheme { get; set; } = MaterialTheme.Light;
internal MaterialColorScheme MaterialColorScheme { get; set; } = MaterialColorScheme.Default;
internal string Title { get; set; } = "Dialog";
internal string ButtonText { get; set; } = "Ok";

Expand All @@ -19,17 +19,51 @@ internal DialogContextOptionsBuilder(IEnumerable<BaseDialogItem> items)
this.items = items;
}

public DialogContextOptionsBuilder UseStyle(DialogStyle style)
/// <summary>
/// Material skin using some statics inside, so you may use only one dialog with that style at once.
/// </summary>
/// <param name="theme"></param>
/// <returns></returns>
public DialogContextOptionsBuilder UseMaterialStyle(MaterialTheme theme)
{
Style = style;
Style = DialogStyle.Material;

MaterialTheme = theme;
return this;
}
/// <summary>
/// Material skin using some statics inside, so you may use only one dialog with that style at once.
/// Uses Light theme by default.
/// </summary>
/// <param name="theme"></param>
/// <returns></returns>
public DialogContextOptionsBuilder UseMaterialStyle() => UseMaterialStyle(MaterialTheme.Light);

/// <summary>
/// Material skin using some statics inside, so you may use only one dialog with that style at once.
/// Default values are: Light, BlueGrey800, BlueGrey900, BlueGrey500, LightBlue200, White
/// </summary>
/// <param name="theme"></param>
/// <returns></returns>
public DialogContextOptionsBuilder UseMaterialStyle(MaterialTheme theme, MaterialColorScheme colorScheme)
{
MaterialColorScheme = colorScheme;
return UseMaterialStyle(theme);
}

public DialogContextOptionsBuilder UseMetroTheme(MetroTheme theme)
public DialogContextOptionsBuilder UseMetroStyle(MetroTheme theme)
{
Style = DialogStyle.Metro;
MetroTheme = theme;
return this;
}
public DialogContextOptionsBuilder UseMetroStyle() => UseMetroStyle(MetroTheme.Default);

public DialogContextOptionsBuilder UseDefaultStyle()
{
Style = DialogStyle.Default;
return this;
}

public DialogContextOptionsBuilder WithTitle(string title)
{
Expand Down
5 changes: 5 additions & 0 deletions src/EasyDialog/EasyDialog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@
<Compile Include="DialogContext.cs" />
<Compile Include="DialogContextOptionsBuilder.cs" />
<Compile Include="DialogItemsOptionsBuilder.cs" />
<Compile Include="Enums\MaterialTheme.cs" />
<Compile Include="Enums\MaterialThemeAccent.cs" />
<Compile Include="Enums\MaterialThemePrimaryColor.cs" />
<Compile Include="Enums\MetroTheme.cs" />
<Compile Include="Internal\Forms\EasyDialogForm.cs" />
<Compile Include="Internal\Forms\Interfaces\IFormProvider.cs" />
<Compile Include="Internal\Forms\Templates\ButtonTemplate.cs" />
<Compile Include="Models\MaterialColorScheme.cs" />
<Compile Include="Items\ComboBoxItemOptionsBuilder.cs" />
<Compile Include="Items\DateTimePickerItemOptionsBuilder.cs" />
<Compile Include="Items\Implementations\ComboBoxItem.cs" />
Expand All @@ -89,6 +93,7 @@
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Compile Include="Enums\MaterialThemeTextShade.cs" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/EasyDialog/Enums/DialogStyle.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace bubuntoid.EasyDialog
{
public enum DialogStyle
internal enum DialogStyle
{
Default,
Metro,
Expand Down
8 changes: 8 additions & 0 deletions src/EasyDialog/Enums/MaterialTheme.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace bubuntoid.EasyDialog
{
public enum MaterialTheme
{
Light,
Dark,
}
}
70 changes: 70 additions & 0 deletions src/EasyDialog/Enums/MaterialThemeAccent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
namespace bubuntoid.EasyDialog
{
public enum MaterialThemeAccent
{
LightBlue700 = 37354,
LightBlue400 = 45311,
Cyan700 = 47316,
Teal700 = 49061,
Green700 = 51283,
Cyan400 = 58879,
Green400 = 58998,
Cyan200 = 1638399,
Teal400 = 1960374,
Blue700 = 2712319,
Blue400 = 2718207,
Indigo700 = 3166206,
Indigo400 = 4020990,
LightBlue200 = 4244735,
Blue200 = 4492031,
Indigo200 = 5467646,
DeepPurple700 = 6422762,
LightGreen700 = 6610199,
Teal200 = 6619098,
DeepPurple400 = 6627327,
Green200 = 6942894,
LightGreen400 = 7798531,
DeepPurple200 = 8146431,
LightBlue100 = 8444159,
Blue100 = 8565247,
Cyan100 = 8716287,
Indigo100 = 9215743,
Teal100 = 11010027,
Purple700 = 11141375,
Lime700 = 11463168,
LightGreen200 = 11730777,
DeepPurple100 = 11766015,
Green100 = 12187338,
Pink700 = 12915042,
Lime400 = 13041408,
LightGreen100 = 13434768,
Red700 = 13959168,
Purple400 = 13959417,
DeepOrange700 = 14494720,
Purple200 = 14696699,
Purple100 = 15368444,
Lime200 = 15662913,
Lime100 = 16056193,
Pink400 = 16056407,
Red400 = 16717636,
DeepOrange400 = 16727296,
Pink200 = 16728193,
Red200 = 16732754,
Orange700 = 16739584,
DeepOrange200 = 16739904,
Pink100 = 16744619,
Red100 = 16747136,
Orange400 = 16748800,
DeepOrange100 = 16752256,
Amber700 = 16755456,
Orange200 = 16755520,
Amber400 = 16761856,
Orange100 = 16765312,
Yellow700 = 16766464,
Amber200 = 16766784,
Amber100 = 16770431,
Yellow400 = 16771584,
Yellow200 = 16776960,
Yellow100 = 16777101
}
}
Loading

0 comments on commit 1d53155

Please sign in to comment.