Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
seto77 committed Jul 25, 2024
1 parent 82cfa78 commit 2a4508c
Show file tree
Hide file tree
Showing 13 changed files with 6,514 additions and 6,859 deletions.
30 changes: 22 additions & 8 deletions Crystallography.Controls/ColorControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,51 +53,65 @@ public FlowDirection FlowDirection
public Padding FooterMargin { set => labelFooter.Margin = value; get => labelFooter.Margin; }

[Category("Color")]
public Color Color { set => pictureBox.BackColor = value; get => pictureBox.BackColor; }
public bool Inversion { set; get; } = false;

[Category("Color")]
public int Argb { set => pictureBox.BackColor = Color.FromArgb(value); get => pictureBox.BackColor.ToArgb(); }
public Color Color
{
set => pictureBox.BackColor = value;
get {
var color = pictureBox.BackColor;
return Inversion ? Color.FromArgb(color.A, 255 - color.R, 255 - color.G, 255 - color.B): color;
}
}

[Category("Color")]
public int Argb
{
set => pictureBox.BackColor = Color.FromArgb(value);
get => Color.ToArgb();
}

[Category("Color")]
public int Red
{
set { if (value >= 0 && value < 256) pictureBox.BackColor = Color.FromArgb(value, pictureBox.BackColor.G, pictureBox.BackColor.B); }
get { return pictureBox.BackColor.R; }
get => Inversion ? 255 - pictureBox.BackColor.R: pictureBox.BackColor.R;
}

[Category("Color")]
public int Green
{
set { if (value >= 0 && value < 256) pictureBox.BackColor = Color.FromArgb(pictureBox.BackColor.R, value, pictureBox.BackColor.B); }
get { return pictureBox.BackColor.G; }
get => Inversion ? 255 - pictureBox.BackColor.G: pictureBox.BackColor.G;
}

[Category("Color")]
public int Blue
{
set { if (value >= 0 && value < 256) pictureBox.BackColor = Color.FromArgb(pictureBox.BackColor.R, pictureBox.BackColor.G, value); }
get { return pictureBox.BackColor.B; }
get => Inversion ? 255 - pictureBox.BackColor.B: pictureBox.BackColor.B;
}

[Category("Color")]
public float RedF
{
set { if (value >= 0 && value <= 1) pictureBox.BackColor = Color.FromArgb((int)(value * 255), pictureBox.BackColor.G, pictureBox.BackColor.B); }
get { return pictureBox.BackColor.R / 255f; }
get => Inversion ? 1 - pictureBox.BackColor.R / 255f : pictureBox.BackColor.R / 255f;
}

[Category("Color")]
public float GreenF
{
set { if (value >= 0 && value < 256) pictureBox.BackColor = Color.FromArgb(pictureBox.BackColor.R, (int)(value * 255), pictureBox.BackColor.B); }
get { return pictureBox.BackColor.G / 255f; }
get => Inversion ? 1 - pictureBox.BackColor.G / 255f: pictureBox.BackColor.G / 255f;
}

[Category("Color")]
public float BlueF
{
set { if (value >= 0 && value < 256) pictureBox.BackColor = Color.FromArgb(pictureBox.BackColor.R, pictureBox.BackColor.G, (int)(value * 255)); }
get { return pictureBox.BackColor.B / 255f; }
get => Inversion ? 1 - pictureBox.BackColor.B / 255f: pictureBox.BackColor.B / 255f;
}

public ColorControl()
Expand Down
4 changes: 2 additions & 2 deletions Crystallography.Controls/Crystallography.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2024.6.20.0815</AssemblyVersion>
<FileVersion>2024.6.20.0815</FileVersion>
<AssemblyVersion>2024.7.25.0643</AssemblyVersion>
<FileVersion>2024.7.25.0643</FileVersion>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
<ApplicationUseCompatibleTextRendering>true</ApplicationUseCompatibleTextRendering>
<ApplicationVisualStyles>true</ApplicationVisualStyles>
Expand Down
4 changes: 2 additions & 2 deletions Crystallography.OpenGL/Crystallography.OpenGL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2024.6.20.0815</AssemblyVersion>
<FileVersion>2024.6.20.0815</FileVersion>
<AssemblyVersion>2024.7.25.0016</AssemblyVersion>
<FileVersion>2024.7.25.0016</FileVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions Crystallography/Crystallography.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2024.6.20.0815</AssemblyVersion>
<FileVersion>2024.6.20.0815</FileVersion>
<AssemblyVersion>2024.7.25.0016</AssemblyVersion>
<FileVersion>2024.7.25.0016</FileVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
</PropertyGroup>

Expand All @@ -28,7 +28,7 @@
<PackageReference Include="MemoryPack" Version="1.21.1" />
<PackageReference Include="OpenTK" Version="3.3.3" />
<PackageReference Include="SimdLinq" Version="1.3.2" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.3" />
</ItemGroup>

<ItemGroup>
Expand Down
27 changes: 27 additions & 0 deletions Crystallography/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Drawing;
using System.Linq;
using System.Numerics;
using Windows.Media.Audio;
using DMat = MathNet.Numerics.LinearAlgebra.Complex.DenseMatrix;
using MC = Crystallography.MathematicalConstants;

Expand Down Expand Up @@ -373,6 +374,32 @@ public static void DrawCircle(this Graphics graphics, in Color c, in PointD pt,
if (Math.Abs(pt.X) < 1E6 && Math.Abs(pt.Y) < 1E6)
graphics.DrawEllipse(new Pen(c, 0.0001f), (float)(pt.X - radius), (float)(pt.Y - radius), (float)(2 * radius), (float)(2 * radius));
}

/// <summary>
/// 拡張メソッド
/// </summary>
/// <param name="graphics"></param>
/// <param name="s"></param>
/// <param name="font"></param>
/// <param name="color"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="resetTransform"></param>
public static void DrawString(this Graphics graphics, string s, Font font, Color color, double x, double y, bool resetTransform=false)
{
var transform = graphics.Transform;
if (resetTransform)
graphics.Transform = new System.Drawing.Drawing2D.Matrix(1, 0, 0, 1, 1, 1);

graphics.DrawString(s, font, new SolidBrush(color), (float)x, (float)y);

if (resetTransform)
graphics.Transform = transform;
}

public static void DrawString(this Graphics graphics, string s, Font font, Color color, PointD pt, bool resetTransform = false)
=>DrawString(graphics,s,font,color, pt.X, pt.Y, resetTransform);

#endregion


Expand Down
Loading

0 comments on commit 2a4508c

Please sign in to comment.