Skip to content

Commit

Permalink
Merge pull request #46 from andyld97/dev
Browse files Browse the repository at this point in the history
feat: Next update
  • Loading branch information
andyld97 authored Aug 27, 2022
2 parents 91f93c6 + 6a9fac8 commit df5c7cd
Show file tree
Hide file tree
Showing 47 changed files with 1,882 additions and 163 deletions.
4 changes: 2 additions & 2 deletions Helper Applications/PDF2J/PDF2J.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="11.3.0" />
<PackageReference Include="Magick.NET.Core" Version="11.3.0" />
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="12.1.0" />
<PackageReference Include="Magick.NET.Core" Version="12.1.0" />
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions Shared Libraries/SimpleJournal.Common/Data/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,18 @@ public Color(byte r, byte g, byte b) : this(255, r, g, b)
// Black
public Color() : this(255, 0, 0, 0)
{ }

public static bool operator ==(Color c1, Color c2)
{
return c1.A == c2.A &&
c1.R == c2.R &&
c1.G == c2.G &&
c2.B == c2.B;
}

public static bool operator !=(Color c1, Color c2)
{
return c1 != c2;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.336902">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.0-preview.6.22324.4" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.0-preview.7.22375.6" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions Shared Libraries/SimpleJournal.Common/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ namespace SimpleJournal.Common
{
public static class Strings
{
public const string Version = "0.5.6.0";
public const string StoreVersion = "1.560.0.0";
public const string Version = "0.5.7.0";
public const string StoreVersion = "1.570.0.0";
public const string Copyright = "Copyright © 2018-2022";

#if RELEASE
public static readonly DateTime ReleaseDate = new DateTime(2022, 7, 24, 14, 38, 0);
public static readonly DateTime ReleaseDate = new DateTime(2022, 8, 27, 15, 0, 0);
#else
public static readonly DateTime ReleaseDate = DateTime.Now;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="11.3.0" />
<PackageReference Include="Magick.NET.Core" Version="11.3.0" />
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="12.1.0" />
<PackageReference Include="Magick.NET.Core" Version="12.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public static bool Change
#endregion

#region Pubic Properties

public bool IsEmpty => Strokes.Count == 0 && Children.Count == 0;

public ActionManager Manager { get; } = null;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using SimpleJournal.Common;
using SimpleJournal.Documents.UI.Controls.Paper;
using System.Windows;
using System.Windows.Controls;
using Orientation = SimpleJournal.Common.Orientation;
Expand All @@ -18,6 +19,9 @@ public PageSplitter()
InitializeComponent();
}

public delegate bool onCheckPages(Func<IPaper, bool> evalute);
public event onCheckPages OnCheckPages;

private void ButtonChequered_Click(object sender, RoutedEventArgs e)
{
ShowContextMenu(sender, e, PaperType.Chequered);
Expand All @@ -40,6 +44,18 @@ private void ButtonDotted_Click(object sender, RoutedEventArgs e)

private void ShowContextMenu(object sender, RoutedEventArgs e, PaperType type)
{
if (Settings.Instance.SkipOrientationMenu)
{
bool result = (bool)(OnCheckPages?.Invoke(new Func<IPaper, bool>((IPaper paper) => paper.Orientation == Orientation.Portrait)));

if (result)
{
// Hide menu and add the page in portrait format
OnPageAdded?.Invoke(this, type, Orientation.Portrait);
return;
}
}

var btn = sender as TransparentImageButton;
ContextMenu contextMenu = btn.ContextMenu;
contextMenu.PlacementTarget = btn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Windows.Controls;
using SimpleJournal.Documents.UI.Helper;
using Orientation = SimpleJournal.Common.Orientation;
using SimpleJournal.Documents.Pattern;

namespace SimpleJournal.Documents.UI.Controls.Paper
{
Expand Down Expand Up @@ -57,5 +58,10 @@ public void Dispose()
Canvas.Strokes.Clear();
Canvas.Children.Clear();
}

public void ApplyPattern(IPattern pattern)
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
using System.Windows.Media;
using SimpleJournal.Documents.UI.Helper;
using Orientation = SimpleJournal.Common.Orientation;
using System.Windows;
using System.Reflection;
using SimpleJournal.Documents.UI.Extensions;
using SimpleJournal.Documents.Pattern;

namespace SimpleJournal.Documents.UI.Controls.Paper
{
Expand All @@ -11,6 +15,8 @@ namespace SimpleJournal.Documents.UI.Controls.Paper
/// </summary>
public partial class Chequered : UserControl, IPaper
{
private IPattern pattern;

public Chequered(Orientation orientation)
{
InitializeComponent();
Expand All @@ -35,6 +41,54 @@ public Chequered(Orientation orientation)
}
}

#region ApplyBackgroundBrushSettings

public void ApplyPattern(IPattern pattern)
{
this.pattern = pattern;
if (pattern is ChequeredPattern chequeredPattern)
{
DrawingBrush brush = (DrawingBrush)FindResource(Settings.Instance.UseOldChequeredPattern ? "OldChequeredBrush" : "CurrentChequeredBrush");

ApplyIntensity(brush, chequeredPattern.ViewPort);
ApplyOffset(brush, chequeredPattern.ViewOffset);
ApplyLineColor(brush, chequeredPattern.Color);
ApplyStrokeThickness(brush, chequeredPattern.StrokeWidth);
}
}

private void ApplyStrokeThickness(DrawingBrush brush, double value)
{
var g = brush.Drawing as GeometryDrawing;
g.Pen.Thickness = value;
}

private void ApplyIntensity(DrawingBrush brush, double value)
{
brush.Viewport = new Rect(0, 0, value, value);
}

private void ApplyOffset(DrawingBrush brush, double value)
{
var g = brush.Drawing as GeometryDrawing;
var grp = g.Geometry as GeometryGroup;

var lg1 = (grp.Children[0] as LineGeometry);
lg1.StartPoint = new Point(0, value);
lg1.EndPoint = new Point(value, value);

var lg2 = (grp.Children[1] as LineGeometry);
lg2.StartPoint = new Point(0, 0);
lg2.EndPoint = new Point(0, value);
}

private void ApplyLineColor(DrawingBrush brush, SimpleJournal.Common.Data.Color color)
{
(brush.Drawing as GeometryDrawing).Pen.Brush = new SolidColorBrush(color.ToColor());
}

#endregion

public Orientation Orientation { get; set; }

public Format Format => Format.A4;
Expand All @@ -55,6 +109,8 @@ public IPaper ClonePage(bool isReadonly)
foreach (var child in Canvas.Children)
chq.Canvas.Children.Add(UIHelper.CloneElement(child));

chq.ApplyPattern(pattern);

return chq;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Windows.Media;
using SimpleJournal.Documents.UI.Helper;
using Orientation = SimpleJournal.Common.Orientation;
using SimpleJournal.Documents.Pattern;

namespace SimpleJournal.Documents.UI.Controls.Paper
{
Expand Down Expand Up @@ -74,5 +75,10 @@ public void Dispose()
Canvas.Strokes.Clear();
Canvas.Children.Clear();
}

public void ApplyPattern(IPattern pattern)
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
using System.Windows.Controls;
using SimpleJournal.Documents.UI.Helper;
using Orientation = SimpleJournal.Common.Orientation;
using SimpleJournal.Documents.Pattern;
using System.Windows.Media;
using SimpleJournal.Documents.UI.Extensions;

namespace SimpleJournal.Documents.UI.Controls.Paper
{
Expand All @@ -10,6 +13,8 @@ namespace SimpleJournal.Documents.UI.Controls.Paper
/// </summary>
public partial class Dotted : UserControl, IPaper
{
private IPattern pattern;

public Dotted(Orientation orientation)
{
InitializeComponent();
Expand Down Expand Up @@ -42,6 +47,8 @@ public IPaper ClonePage(bool isReadonly)
foreach (var child in Canvas.Children)
dotted.Canvas.Children.Add(UIHelper.CloneElement(child));

dotted.ApplyPattern(pattern);

return dotted;
}

Expand All @@ -57,5 +64,23 @@ public void Dispose()
Canvas.Strokes.Clear();
Canvas.Children.Clear();
}

public void ApplyPattern(IPattern pattern)
{
this.pattern = pattern;
if (pattern is DottedPattern dp)
{
var brush = FindResource("DottetBrush") as DrawingBrush;

brush.Viewport = new System.Windows.Rect(0, 0, dp.ViewPort, dp.ViewPort);
var gd = (brush.Drawing as GeometryDrawing);
var gg = gd.Geometry as GeometryGroup;
var eg = (gg.Children[0] as EllipseGeometry);
eg.RadiusX = eg.RadiusY = dp.Radius;

gd.Pen.Thickness = dp.StrokeWidth;
gd.Pen.Brush = new SolidColorBrush(dp.Color.ToColor());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using SimpleJournal.Common;
using SimpleJournal.Documents.Pattern;

namespace SimpleJournal.Documents.UI.Controls.Paper
{
Expand All @@ -10,6 +11,8 @@ public interface IPaper : IDisposable

DrawingCanvas Canvas { get; }

void ApplyPattern(IPattern pattern);

Orientation Orientation { get; set; }

PageSplitter Border { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,27 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:controls="clr-namespace:SimpleJournal.Documents.UI.Controls"
Background="White" Height="29.7cm" Width="21cm"
mc:Ignorable="d">
<UserControl.Resources>
<DrawingBrush x:Key="RuledBrush" Stretch="None" TileMode="Tile" Viewport="0,0 50,50" ViewportUnits="Absolute">
<DrawingBrush.Drawing>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<GeometryGroup>
<LineGeometry StartPoint="0,0" EndPoint="50,0"/>
</GeometryGroup>
</GeometryDrawing.Geometry>
<GeometryDrawing.Pen>
<Pen Thickness="0.1" Brush="Black"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
</UserControl.Resources>
<!--
For more infos see this url
https://stackoverflow.com/questions/20748651/wpf-drawing-colored-grid-lines-on-a-canvas-panel-background
-->
<Grid>
<Border>
<controls:DrawingCanvas x:Name="canvas">
<controls:DrawingCanvas.Background>
<DrawingBrush Stretch="None" TileMode="Tile"
Viewport="0,0 50,50" ViewportUnits="Absolute">
<DrawingBrush.Drawing>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<GeometryGroup>
<LineGeometry StartPoint="0,0" EndPoint="50,0"/>
</GeometryGroup>
</GeometryDrawing.Geometry>
<GeometryDrawing.Pen>
<Pen Thickness="0.1" Brush="Black"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
</controls:DrawingCanvas.Background>
</controls:DrawingCanvas>
</Border>
<controls:DrawingCanvas x:Name="canvas" Background="{StaticResource RuledBrush}" />
</Grid>
</UserControl>
Loading

0 comments on commit df5c7cd

Please sign in to comment.