Skip to content

Commit

Permalink
save/reload theme after exit
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisniu committed Mar 3, 2016
1 parent e82c538 commit 1e9cc9e
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 85 deletions.
1 change: 1 addition & 0 deletions Niv.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="prop\app.config" />
<None Include="prop\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
Binary file modified exe/Niv.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions prop/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
ResourceDictionaryLocation.SourceAssembly
)]

[assembly: AssemblyVersion("0.3.1.0")]
[assembly: AssemblyFileVersion("0.3.1.0")]
[assembly: AssemblyVersion("0.3.2.0")]
[assembly: AssemblyFileVersion("0.3.2.0")]
26 changes: 25 additions & 1 deletion prop/Settings.Designer.cs

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

15 changes: 10 additions & 5 deletions prop/Settings.settings
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Niv.prop" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="theme" Type="System.String" Scope="User">
<Value Profile="(Default)">light</Value>
</Setting>
<Setting Name="fullscreen" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
18 changes: 18 additions & 0 deletions prop/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Niv.prop.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<Niv.prop.Settings>
<setting name="theme" serializeAs="String">
<value>light</value>
</setting>
<setting name="fullscreen" serializeAs="String">
<value>False</value>
</setting>
</Niv.prop.Settings>
</userSettings>
</configuration>
2 changes: 1 addition & 1 deletion src/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Controller
// but the distance is within this threshold. Then we also think it's a valid click.
private static int CLICK_MOVE_THRESHOLD = 16;

private static int DOUBLE_CLICK_TIME_THRESHOLD = 750;
private static int DOUBLE_CLICK_TIME_THRESHOLD = 400;

// The mouse moved distance during the click.
private double movedDistanceOfClick = 0;
Expand Down
66 changes: 45 additions & 21 deletions src/com.jarvisniu/AnimationJar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ public AnimatorJar()
boardHeight.Children.Add(heightAnimation);
}

/// --------------------------------------------------------------------
/// All transition animation effects -----------------------------------
/// --------------------------------------------------------------------

/// Fade & Margin ------------------------------------------------------

public AnimatorJar fadeIn(FrameworkElement target)
{
Expand All @@ -126,25 +130,7 @@ public AnimatorJar marginTo(FrameworkElement target, Thickness m)
return this;
}

public AnimatorJar marginTopTo(FrameworkElement target, double des)
{
Thickness m = target.Margin;
translateAnimation.To = new Thickness(m.Left, des, m.Right, m.Bottom);
Storyboard.SetTarget(translateAnimation, target);
boardTranslate.Begin();

return this;
}

public AnimatorJar marginBottomTo(FrameworkElement target, double des)
{
Thickness m = target.Margin;
translateAnimation.To = new Thickness(m.Left, m.Top, m.Right, des);
Storyboard.SetTarget(translateAnimation, target);
boardTranslate.Begin();

return this;
}
/// Translate ----------------------------------------------------------

public AnimatorJar translateTopTo(FrameworkElement target, double desTop)
{
Expand Down Expand Up @@ -222,18 +208,56 @@ public AnimatorJar translateLeftByI(FrameworkElement target, double delta)
return this;
}

public AnimatorJar translateBottomTo(FrameworkElement target, double des)
{
Thickness m = target.Margin;
translateAnimation.To = new Thickness(m.Left, m.Top, m.Right, des);
Storyboard.SetTarget(translateAnimation, target);
boardTranslate.Begin();

return this;
}

public AnimatorJar translateBottomToI(FrameworkElement target, double des)
{
translateAnimation.Duration = DURITION_ZERO;
translateBottomTo(target, des);
translateAnimation.Duration = DURITION_DOT2;

return this;
}

public AnimatorJar translateLeftBottomTo(FrameworkElement target, double desLeft, double desBottom)
{
Thickness m = target.Margin;
translateAnimation.To = new Thickness(desLeft, m.Top, m.Right, desBottom);
Storyboard.SetTarget(translateAnimation, target);
boardTranslate.Begin();

return this;
}

public AnimatorJar translateLeftBottomToI(FrameworkElement target, double desLeft, double desBottom)
{
translateAnimation.Duration = DURITION_ZERO;
translateLeftBottomTo(target, desLeft, desBottom);
translateAnimation.Duration = DURITION_DOT2;

return this;
}

/// Rotate -------------------------------------------------------------

public AnimatorJar rotateTo(FrameworkElement target, double angle)
{
if (!(target.RenderTransform is RotateTransform))
target.RenderTransform = new RotateTransform(0);
double currDegree = (double)target.RenderTransform.GetValue(RotateTransform.AngleProperty);
Console.WriteLine(currDegree + " => " + angle);
while (Math.Abs(angle - currDegree) > 180)
{
if (angle > currDegree) angle -= 360;
else angle += 360;
}
Console.WriteLine(currDegree + " -> " + angle);
rotateAnimation.To = angle;
Storyboard.SetTarget(rotateAnimation, target);
boardRotate.Begin();
Expand Down
2 changes: 1 addition & 1 deletion xaml/NivWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<Border x:Name="btnExit" BorderBrush="#7F404040" BorderThickness="2,0,0,2" Height="50" VerticalAlignment="Top" HorizontalAlignment="Right" Width="50" Margin="0" CornerRadius="0,0,0,8">
<Image x:Name="imageExit" Margin="15" Source="/Niv;component/res/theme-dark/icon-close.png"/>
</Border>
<Border x:Name="page" BorderBrush="Gray" BorderThickness="2" Margin="0,0,10,218" CornerRadius="0" Background="#FF404040" HorizontalAlignment="Right" Width="50" Height="32" VerticalAlignment="Bottom" IsHitTestVisible="False">
<Border x:Name="page" BorderBrush="Gray" BorderThickness="2" Margin="0,0,211,57" CornerRadius="0" Background="#FF404040" HorizontalAlignment="Right" Width="50" Height="32" VerticalAlignment="Bottom" IsHitTestVisible="False">
<Label x:Name="iPage" Content="0/0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="15" Foreground="#FFDEDEDE"/>
</Border>
<Border x:Name="menu" BorderBrush="#BF404040" BorderThickness="2,2,2,0" Margin="0,0,10,57" HorizontalAlignment="Right" Width="196" Height="180" VerticalAlignment="Bottom" Background="Black">
Expand Down
Loading

0 comments on commit 1e9cc9e

Please sign in to comment.