Skip to content

Commit

Permalink
Settings update and minor changes
Browse files Browse the repository at this point in the history
- Added mountain and valley fold settings
- Fixed .net compatibilty bugs
- Added borders on saved svg images
  • Loading branch information
UnclePetros committed Dec 10, 2020
1 parent aaf9782 commit 5cfc31f
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 75 deletions.
16 changes: 10 additions & 6 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,26 @@
along with OriFlagTess. If not, see<http://www.gnu.org/licenses/> -->
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<appSettings>
<add key="maxPleat" value="8" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
<add key="maxPleat" value="8"/>
<add key="mountainFold" value="0"/>
<add key="valleyFold" value="1"/>
<add key="mountainFoldColor" value="#a52a2a"/>
<add key="valleyFoldColor" value="#a52a2a"/>
<add key="ClientSettingsProvider.ServiceUri" value=""/>
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""/>
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400"/>
</providers>
</roleManager>
</system.web>
</configuration>
</configuration>
6 changes: 6 additions & 0 deletions Main.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
Expand All @@ -175,6 +176,11 @@
<Image Source="images/save.png" />
</StackPanel>
</Button>
<Button x:Name="Settings" Grid.Column="4" Width="48" Height="48" HorizontalAlignment="Center" ToolTip="Settings" Click="Settings_Click">
<StackPanel Margin="5,5,5,5">
<Image Source="images/settings.png" />
</StackPanel>
</Button>
</Grid>
</GroupBox>
<GroupBox Grid.Row="0" Grid.RowSpan="7" Grid.Column="3" Header="Log" Margin="10,0,0,0">
Expand Down
177 changes: 111 additions & 66 deletions Main.xaml.cs

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions OriFlagTess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>logo.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Svg, Version=3.0.0.0, Culture=neutral, PublicKeyToken=12a0bac221edeae2, processorArchitecture=MSIL">
<HintPath>packages\Svg.3.0.49\lib\net35\Svg.dll</HintPath>
Expand Down Expand Up @@ -94,7 +97,14 @@
<DependentUpon>Main.xaml</DependentUpon>
</Compile>
<Compile Include="Molecule.cs" />
<Compile Include="Settings.xaml.cs">
<DependentUpon>Settings.xaml</DependentUpon>
</Compile>
<Compile Include="Utils.cs" />
<Page Include="Settings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
Expand Down Expand Up @@ -154,5 +164,8 @@
<ItemGroup>
<Resource Include="images\center.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="logo.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
2 changes: 1 addition & 1 deletion Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions Settings.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Window xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" x:Class="Flagstone_Tessellation___Molecule_construction.Settings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Flagstone_Tessellation___Molecule_construction"
mc:Ignorable="d"
Title="OriFlagTess :: Settings" ResizeMode="NoResize" SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterScreen">
<Grid x:Name="settingsGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="60" />
</Grid.RowDefinitions>
<GroupBox Header="Settings" Grid.Row="0" Grid.Column="0" Margin="10,10,10,0" Padding="10,10,10,10">
<Grid x:Name="parametersGrid" Margin="10,10,10,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<Label Content="MountainFold" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right"/>
<ComboBox x:Name="mountainFoldComboBox" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Height="30" Width="200" FontWeight="Bold" FontSize="16" SelectionChanged="mountainFoldComboBox_SelectionChanged"/>
<Label Content="ValleyFold" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right"/>
<ComboBox x:Name="valleyFoldComboBox" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Height="30" Width="200" FontWeight="Bold" FontSize="16" SelectionChanged="valleyFoldComboBox_SelectionChanged"/>
<xctk:ColorPicker x:Name="mountainFoldColorPicker" Grid.Row="0" Grid.Column="2" Height="30" Margin="10,0,0,0" SelectedColorChanged="mountainFoldColorPicker_SelectedColorChanged"/>
<xctk:ColorPicker x:Name="valleyFoldColorPicker" Grid.Row="1" Grid.Column="2" Height="30" Margin="10,0,0,0" SelectedColorChanged="valleyFoldColorPicker_SelectedColorChanged"/>
</Grid>
</GroupBox>
<Button x:Name="OK" Grid.Row="2" Grid.ColumnSpan="2" Width="75" Height="40" Content="OK" HorizontalAlignment="Center" ToolTip="Close settings" Click="OK_Click"/>
</Grid>
</Window>
79 changes: 79 additions & 0 deletions Settings.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Flagstone_Tessellation___Molecule_construction
{
/// <summary>
/// Interaction logic for Settings.xaml
/// </summary>
public partial class Settings : Window
{
public Settings()
{
InitializeComponent();
this.mountainFoldComboBox.Items.Add(new Line { X1 = 1, X2 = 200, Y1 = 10, Y2 = 10, Stroke = Brushes.Black, StrokeThickness = 1, Height = 25 });
this.mountainFoldComboBox.Items.Add(new Line { X1 = 1, X2 = 200, Y1 = 10, Y2 = 10, Stroke = Brushes.Black, StrokeThickness = 1, Height = 25, StrokeDashArray = Utils.toDashArrayPattern(1) });
this.mountainFoldComboBox.Items.Add(new Line { X1 = 1, X2 = 200, Y1 = 10, Y2 = 10, Stroke = Brushes.Black, StrokeThickness = 1, Height = 25, StrokeDashArray = Utils.toDashArrayPattern(2) });
this.mountainFoldComboBox.Items.Add(new Line { X1 = 1, X2 = 200, Y1 = 10, Y2 = 10, Stroke = Brushes.Black, StrokeThickness = 1, Height = 25, StrokeDashArray = Utils.toDashArrayPattern(3) });
this.valleyFoldComboBox.Items.Add(new Line { X1 = 1, X2 = 200, Y1 = 10, Y2 = 10, Stroke = Brushes.Black, StrokeThickness = 1, Height = 25 });
this.valleyFoldComboBox.Items.Add(new Line { X1 = 1, X2 = 200, Y1 = 10, Y2 = 10, Stroke = Brushes.Black, StrokeThickness = 1, Height = 25, StrokeDashArray = Utils.toDashArrayPattern(1) });
this.valleyFoldComboBox.Items.Add(new Line { X1 = 1, X2 = 200, Y1 = 10, Y2 = 10, Stroke = Brushes.Black, StrokeThickness = 1, Height = 25, StrokeDashArray = Utils.toDashArrayPattern(2) });
this.valleyFoldComboBox.Items.Add(new Line { X1 = 1, X2 = 200, Y1 = 10, Y2 = 10, Stroke = Brushes.Black, StrokeThickness = 1, Height = 25, StrokeDashArray = Utils.toDashArrayPattern(3) });
this.mountainFoldComboBox.SelectedIndex = int.Parse(System.Configuration.ConfigurationManager.AppSettings["mountainFold"]);
this.valleyFoldComboBox.SelectedIndex = int.Parse(System.Configuration.ConfigurationManager.AppSettings["valleyFold"]);
var mountainFoldHtmlColor = System.Configuration.ConfigurationManager.AppSettings["mountainFoldColor"];
this.mountainFoldColorPicker.SelectedColor = ((SolidColorBrush)new BrushConverter().ConvertFromString(mountainFoldHtmlColor)).Color;
var valleyFoldHtmlColor = System.Configuration.ConfigurationManager.AppSettings["valleyFoldColor"];
this.valleyFoldColorPicker.SelectedColor = ((SolidColorBrush)new BrushConverter().ConvertFromString(valleyFoldHtmlColor)).Color;
}

private void OK_Click(object sender, RoutedEventArgs e)
{
this.Close();
}

private void mountainFoldComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["mountainFold"].Value = "" + this.mountainFoldComboBox.SelectedIndex;
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}

private void valleyFoldComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["valleyFold"].Value = "" + this.valleyFoldComboBox.SelectedIndex;
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}

private void mountainFoldColorPicker_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs<Color?> e)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["mountainFoldColor"].Value = "" + this.mountainFoldColorPicker.SelectedColor.ToString();
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}

private void valleyFoldColorPicker_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs<Color?> e)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["valleyFoldColor"].Value = "" + this.valleyFoldColorPicker.SelectedColor.ToString();
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}
}
}
27 changes: 25 additions & 2 deletions Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,46 @@ public static double Atan2(double value1, double value2)
return RadToDeg(Math.Atan2(value1, value2));
}

public static Line line(double x1, double y1, double x2, double y2, Brush brush)
public static Line line(double x1, double y1, double x2, double y2, Brush brush, int lineStyle = 0)
{
Line line = new Line();
line.X1 = x1;
line.X2 = x2;
line.Y1 = y1;
line.Y2 = y2;

if(lineStyle != 0)
line.StrokeDashArray = toDashArrayPattern(lineStyle);

line.StrokeThickness = 1;
line.Stroke = brush;

Canvas.SetZIndex(line, 100);

return line;
}
public static DoubleCollection toDashArrayPattern(int lineStyle)
{
DoubleCollection pattern = new DoubleCollection();
switch (lineStyle)
{
case 1:
pattern.Add(8); pattern.Add(2); pattern.Add(1); pattern.Add(2);
break;
case 2:
pattern.Add(8); pattern.Add(3);
break;
case 3:
pattern.Add(4); pattern.Add(2);
break;
default:
break;
}

return pattern;
}

public static Line lineDash(double x1, double y1, double x2, double y2, Brush brush)
public static Line lineDash(double x1, double y1, double x2, double y2, Brush brush)
{
Line line = new Line();
line.X1 = x1;
Expand Down
Binary file added images/logo.ico
Binary file not shown.
Binary file added images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo.ico
Binary file not shown.

0 comments on commit 5cfc31f

Please sign in to comment.