diff --git a/src/App.xaml.cs b/src/App.xaml.cs index 07b4a038..1e12f2b4 100644 --- a/src/App.xaml.cs +++ b/src/App.xaml.cs @@ -1,11 +1,5 @@ using System; -using System.Diagnostics; using System.IO; -using System.Net; -using System.Reflection; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; using System.Windows; namespace SourceGit { @@ -14,7 +8,6 @@ namespace SourceGit { /// 程序入口. /// public partial class App : Application { - private static bool restart = false; /// /// 读取本地化字串 @@ -28,15 +21,6 @@ namespace SourceGit { return string.Format(data, args); } - /// - /// 重启程序 - /// - public static void Restart() { - restart = true; - Process.Start(Process.GetCurrentProcess().MainModule.FileName); - Current.Shutdown(); - } - /// /// 启动. /// @@ -48,31 +32,11 @@ namespace SourceGit { Directory.CreateDirectory(Views.Controls.Avatar.CACHE_PATH); } - // 控制主题 - if (Models.Preference.Instance.General.UseDarkTheme) { - foreach (var rs in Current.Resources.MergedDictionaries) { - if (rs.Source != null && rs.Source.OriginalString.StartsWith("pack://application:,,,/Resources/Themes/", StringComparison.Ordinal)) { - rs.Source = new Uri("pack://application:,,,/Resources/Themes/Dark.xaml", UriKind.Absolute); - break; - } - } - } - - // 控制显示语言 - var lang = Models.Preference.Instance.General.Locale; - if (lang != "en_US") { - foreach (var rs in Current.Resources.MergedDictionaries) { - if (rs.Source != null && rs.Source.OriginalString.StartsWith("pack://application:,,,/Resources/Locales/", StringComparison.Ordinal)) { - rs.Source = new Uri($"pack://application:,,,/Resources/Locales/{lang}.xaml", UriKind.Absolute); - break; - } - } - } - - // 主界面显示 - MainWindow = new Views.Launcher(); + Models.Theme.Change(); + Models.Locale.Change(); // 如果启动命令中指定了路径,打开指定目录的仓库 + var launcher = new Views.Launcher(); if (e.Args.Length > 0) { var repo = Models.Preference.Instance.FindRepository(e.Args[0]); if (repo == null) { @@ -99,33 +63,15 @@ namespace SourceGit { } } + // 主界面显示 + MainWindow = launcher; MainWindow.Show(); - // 检测更新 - if (Models.Preference.Instance.General.CheckForUpdate) { - var curDayOfYear = DateTime.Now.DayOfYear; - var lastDayOfYear = Models.Preference.Instance.General.LastCheckDay; - if (lastDayOfYear != curDayOfYear) { - Models.Preference.Instance.General.LastCheckDay = curDayOfYear; - Task.Run(() => { - try { - var web = new WebClient() { Encoding = Encoding.UTF8 }; - var raw = web.DownloadString("https://gitee.com/api/v5/repos/sourcegit/sourcegit/releases/latest"); - var ver = Models.Version.Load(raw); - var cur = Assembly.GetExecutingAssembly().GetName().Version; - - var matches = Regex.Match(ver.TagName, @"^v(\d+)\.(\d+).*"); - if (!matches.Success) return; - - var major = int.Parse(matches.Groups[1].Value); - var minor = int.Parse(matches.Groups[2].Value); - if (major > cur.Major || (major == cur.Major && minor > cur.Minor)) { - Dispatcher.Invoke(() => Views.Upgrade.Open(MainWindow, ver)); - } - } catch {} - }); - } - } + // 检测版本更新 + Models.Version.Check(ver => Dispatcher.Invoke(() => { + var dialog = new Views.Upgrade(ver) { Owner = MainWindow }; + dialog.ShowDialog(); + })); } /// @@ -135,7 +81,7 @@ namespace SourceGit { /// private void OnAppDeactivated(object sender, EventArgs e) { GC.Collect(); - if (!restart) Models.Preference.Save(); + Models.Preference.Save(); } } } diff --git a/src/Models/Locale.cs b/src/Models/Locale.cs index 4a94fbc3..d3abb25c 100644 --- a/src/Models/Locale.cs +++ b/src/Models/Locale.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; namespace SourceGit.Models { @@ -18,5 +19,15 @@ namespace SourceGit.Models { Name = name; Resource = res; } + + public static void Change() { + var lang = Preference.Instance.General.Locale; + foreach (var rs in App.Current.Resources.MergedDictionaries) { + if (rs.Source != null && rs.Source.OriginalString.StartsWith("pack://application:,,,/Resources/Locales/", StringComparison.Ordinal)) { + rs.Source = new Uri($"pack://application:,,,/Resources/Locales/{lang}.xaml", UriKind.Absolute); + break; + } + } + } } } diff --git a/src/Models/Theme.cs b/src/Models/Theme.cs new file mode 100644 index 00000000..7eafb22d --- /dev/null +++ b/src/Models/Theme.cs @@ -0,0 +1,38 @@ +using System; +using System.Windows; + +namespace SourceGit.Models { + /// + /// 主题 + /// + public static class Theme { + /// + /// 主题切换事件 + /// + public static event Action Changed; + + /// + /// 启用主题变化监听 + /// + /// + public static void AddListener(FrameworkElement elem, Action callback) { + elem.Loaded += (_, __) => Changed += callback; + elem.Unloaded += (_, __) => Changed -= callback; + } + + /// + /// 切换主题 + /// + public static void Change() { + var theme = Preference.Instance.General.UseDarkTheme ? "Dark" : "Light"; + foreach (var rs in App.Current.Resources.MergedDictionaries) { + if (rs.Source != null && rs.Source.OriginalString.StartsWith("pack://application:,,,/Resources/Themes/", StringComparison.Ordinal)) { + rs.Source = new Uri($"pack://application:,,,/Resources/Themes/{theme}.xaml", UriKind.Absolute); + break; + } + } + + Changed?.Invoke(); + } + } +} diff --git a/src/Models/Version.cs b/src/Models/Version.cs index adc9ada5..0567c85b 100644 --- a/src/Models/Version.cs +++ b/src/Models/Version.cs @@ -1,4 +1,9 @@ using System; +using System.Net; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; #if NET48 using Newtonsoft.Json; @@ -52,12 +57,36 @@ namespace SourceGit.Models { get { return PreRelease ? "YES" : "NO"; } } - public static Version Load(string data) { + public static void Check(Action onUpgradable) { + if (!Preference.Instance.General.CheckForUpdate) return; + + var curDayOfYear = DateTime.Now.DayOfYear; + var lastDayOfYear = Preference.Instance.General.LastCheckDay; + if (lastDayOfYear != curDayOfYear) { + Preference.Instance.General.LastCheckDay = curDayOfYear; + Task.Run(() => { + try { + var web = new WebClient() { Encoding = Encoding.UTF8 }; + var raw = web.DownloadString("https://gitee.com/api/v5/repos/sourcegit/sourcegit/releases/latest"); #if NET48 - return JsonConvert.DeserializeObject(data); + var ver = JsonConvert.DeserializeObject(raw); #else - return JsonSerializer.Deserialize(data); + var ver = JsonSerializer.Deserialize(raw); #endif + var cur = Assembly.GetExecutingAssembly().GetName().Version; + + var matches = Regex.Match(ver.TagName, @"^v(\d+)\.(\d+).*"); + if (!matches.Success) return; + + var major = int.Parse(matches.Groups[1].Value); + var minor = int.Parse(matches.Groups[2].Value); + if (major > cur.Major || (major == cur.Major && minor > cur.Minor)) { + onUpgradable?.Invoke(ver); + } + } catch { + } + }); + } } } } diff --git a/src/Resources/Controls.xaml b/src/Resources/Controls.xaml index 45515ddb..a4ff0461 100644 --- a/src/Resources/Controls.xaml +++ b/src/Resources/Controls.xaml @@ -19,5 +19,6 @@ + \ No newline at end of file diff --git a/src/Resources/Icons.xaml b/src/Resources/Icons.xaml index 05f51072..1eac2676 100644 --- a/src/Resources/Icons.xaml +++ b/src/Resources/Icons.xaml @@ -28,6 +28,9 @@ M1017 598c0-25-25-50-50-50c-30 0-50 25-50 50c0 35-10 136-55 186c-25 25-55 35-95 35c-70 0-121-191-161-326c-50-196-100-377-231-377c-186 0-271 286-326 472c-10 40-20 75-30 95c-10 25 5 55 30 65c25 10 55-5 65-30c10-25 20-60 35-105c35-136 116-397 226-397c55 0 105 181 141 301c55 196 110 402 256 402c65 0 121-20 161-65c90-95 85-251 85-256z M341 475 147 675 65 593l271-284 281 265 254-295 89 77-336 387z + + M512 768c-38 0-74-9-107-23C493 704 555 615 555 512c0-103-61-192-149-233C438 265 474 256 512 256a256 256 0 01256 256a256 256 0 01-256 256m341-397V171h-200L512 29 371 171H171v200L29 512 171 653V853h200L512 995 653 853H853v-200L995 512 853 371z + M853 653l141-141-141-141 0-200-200 0-141-141-141 141-200 0 0 200-141 141 141 141 0 200 200 0 141 141 141-141 200 0 0-200zM512 768c-141 0-256-115-256-256s115-256 256-256s256 115 256 256s-115 256-256 256z M509 546l271-271 91 91-348 349-1-1-13 13-363-361 91-91z M256 224l0 115L512 544l256-205 0-115-256 205L256 224zM512 685l-256-205L256 595 512 800 768 595l0-115L512 685z diff --git a/src/Resources/Locales/en_US.xaml b/src/Resources/Locales/en_US.xaml index c073e9b1..eee9110c 100644 --- a/src/Resources/Locales/en_US.xaml +++ b/src/Resources/Locales/en_US.xaml @@ -16,12 +16,13 @@ Optional. ‡Directory|*.this.directory SELECT FOLDER + DARK/LIGHT THEME URL : Git Repository URL Parent Folder : Relative foler to store this module. Optional. - + ABOUT SourceGit - OPEN SOURCE GIT CLIENT @@ -361,10 +362,8 @@ Preference GENERAL SETTING - RESTART REQUIRED Language : Avatar Server : - Use dark theme Check for update Fetch remotes automatically Restore windows diff --git a/src/Resources/Locales/zh_CN.xaml b/src/Resources/Locales/zh_CN.xaml index d826eefa..b0da1246 100644 --- a/src/Resources/Locales/zh_CN.xaml +++ b/src/Resources/Locales/zh_CN.xaml @@ -15,6 +15,7 @@ 选填 ‡路径|*.this.directory 选择文件夹 + 切换主题 仓库地址 : 远程仓库地址 @@ -360,10 +361,8 @@ 偏好设置 通用配置 - 需要重启软件 显示语言 : 头像服务 : - 启用—暗色主题 启用检测更新 启用定时自动拉取远程更新 启动时恢复上次打开的仓库 diff --git a/src/Resources/Styles/ToggleButton.xaml b/src/Resources/Styles/ToggleButton.xaml index f786b798..d7339bbb 100644 --- a/src/Resources/Styles/ToggleButton.xaml +++ b/src/Resources/Styles/ToggleButton.xaml @@ -143,6 +143,35 @@ + + + \ No newline at end of file diff --git a/src/Views/About.xaml b/src/Views/About.xaml index 4d3366f1..1c567773 100644 --- a/src/Views/About.xaml +++ b/src/Views/About.xaml @@ -7,7 +7,7 @@ xmlns:controls="clr-namespace:SourceGit.Views.Controls" mc:Ignorable="d" WindowStartupLocation="CenterOwner" - Title="{StaticResource Text.About}" + Title="{DynamicResource Text.About}" Height="280" Width="400" ResizeMode="NoResize"> @@ -18,7 +18,7 @@ - + @@ -30,7 +30,7 @@ - + + Fill="{DynamicResource Brush.Border0}"/> @@ -57,12 +57,12 @@ Margin="0,16,0,0" Width="64" Height="64" Data="{StaticResource Icon.Git}" - Fill="{StaticResource Brush.Logo}"/> + Fill="{DynamicResource Brush.Logo}"/> diff --git a/src/Views/Blame.xaml b/src/Views/Blame.xaml index 85c4cdea..6fd0cd2d 100644 --- a/src/Views/Blame.xaml +++ b/src/Views/Blame.xaml @@ -7,7 +7,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:controls="clr-namespace:SourceGit.Views.Controls" mc:Ignorable="d" - Title="{StaticResource Text.Blame}" + Title="{DynamicResource Text.Blame}" WindowStartupLocation="CenterOwner" Height="600" Width="800"> @@ -19,7 +19,7 @@ - + @@ -31,7 +31,7 @@ - + @@ -46,7 +46,7 @@ Grid.Row="1" Height="1" HorizontalAlignment="Stretch" - Fill="{StaticResource Brush.Border0}"/> + Fill="{DynamicResource Brush.Border0}"/> @@ -56,8 +56,8 @@ - - + + @@ -66,8 +66,8 @@ Grid.Row="3" x:Name="blame" GridLinesVisibility="Vertical" - VerticalGridLinesBrush="{StaticResource Brush.Border2}" - BorderBrush="{StaticResource Brush.Border2}" + VerticalGridLinesBrush="{DynamicResource Brush.Border2}" + BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="1" FrozenColumnCount="1" RowHeight="16" @@ -90,7 +90,7 @@ - + @@ -103,10 +103,10 @@ Grid.Row="3" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" - Background="{StaticResource Brush.Window}" + Background="{DynamicResource Brush.Window}" Visibility="Collapsed"> - - + + @@ -114,7 +114,7 @@ - + @@ -127,11 +127,11 @@ - + diff --git a/src/Views/Controls/Badge.cs b/src/Views/Controls/Badge.cs index 102d25fe..0c72e23e 100644 --- a/src/Views/Controls/Badge.cs +++ b/src/Views/Controls/Badge.cs @@ -26,9 +26,10 @@ namespace SourceGit.Views.Controls { Height = 18; CornerRadius = new CornerRadius(9); VerticalAlignment = VerticalAlignment.Center; - Background = FindResource("Brush.Badge") as Brush; Visibility = Visibility.Collapsed; + SetResourceReference(BackgroundProperty, "Brush.Badge"); + label = new TextBlock(); label.FontSize = 10; label.HorizontalAlignment = HorizontalAlignment.Center; diff --git a/src/Views/Controls/Bookmark.cs b/src/Views/Controls/Bookmark.cs index 8f53834e..28ede88c 100644 --- a/src/Views/Controls/Bookmark.cs +++ b/src/Views/Controls/Bookmark.cs @@ -69,14 +69,14 @@ namespace SourceGit.Views.Controls { if (!mark.IsNewPage) { if (mark.Color == 0) { - mark.icon.Fill = mark.FindResource("Brush.FG1") as Brush; + mark.icon.SetResourceReference(Path.FillProperty, "Brush.FG1"); mark.icon.Data = mark.FindResource("Icon.Git") as Geometry; } else { mark.icon.Fill = COLORS[mark.Color % COLORS.Length]; mark.icon.Data = mark.FindResource("Icon.Bookmark") as Geometry; } } else { - mark.icon.Fill = mark.FindResource("Brush.FG1") as Brush; + mark.icon.SetResourceReference(Path.FillProperty, "Brush.FG1"); mark.icon.Data = mark.FindResource("Icon.WelcomePage") as Geometry; } diff --git a/src/Views/Controls/ChangeDisplaySwitcher.cs b/src/Views/Controls/ChangeDisplaySwitcher.cs index 011e7e40..6dfcad0c 100644 --- a/src/Views/Controls/ChangeDisplaySwitcher.cs +++ b/src/Views/Controls/ChangeDisplaySwitcher.cs @@ -36,8 +36,8 @@ namespace SourceGit.Views.Controls { public ChangeDisplaySwitcher() { icon = new Path(); - icon.Fill = FindResource("Brush.FG2") as Brush; icon.Data = FindResource("Icon.Tree") as Geometry; + icon.SetResourceReference(Path.FillProperty, "Brush.FG2"); Content = icon; Style = FindResource("Style.Button") as Style; @@ -73,8 +73,8 @@ namespace SourceGit.Views.Controls { var iconMode = new Path(); iconMode.Width = 12; iconMode.Height = 12; - iconMode.Fill = FindResource("Brush.FG2") as Brush; iconMode.Data = FindResource(icon) as Geometry; + iconMode.SetResourceReference(Path.FillProperty, "Brush.FG2"); var item = new MenuItem(); item.Icon = iconMode; diff --git a/src/Views/Controls/CommitGraph.cs b/src/Views/Controls/CommitGraph.cs index 6ef9053a..b400ead9 100644 --- a/src/Views/Controls/CommitGraph.cs +++ b/src/Views/Controls/CommitGraph.cs @@ -109,6 +109,7 @@ namespace SourceGit.Views.Controls { private double startY = 0; public CommitGraph() { + Models.Theme.AddListener(this, InvalidateVisual); IsHitTestVisible = false; ClipToBounds = true; } diff --git a/src/Views/Controls/Window.cs b/src/Views/Controls/Window.cs index 24888763..d161a4db 100644 --- a/src/Views/Controls/Window.cs +++ b/src/Views/Controls/Window.cs @@ -1,6 +1,4 @@ using System.Windows; -using System.Windows.Media; -using System.Windows.Shell; namespace SourceGit.Views.Controls { /// @@ -20,32 +18,16 @@ namespace SourceGit.Views.Controls { } public Window() { - Background = FindResource("Brush.Window") as Brush; - BorderBrush = FindResource("Brush.WindowBorder") as Brush; - BorderThickness = new Thickness(1); - - SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display); - SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.ClearType); - SetValue(TextOptions.TextHintingModeProperty, TextHintingMode.Animated); - UseLayoutRounding = true; - - var chrome = new WindowChrome(); - chrome.ResizeBorderThickness = new Thickness(4); - chrome.UseAeroCaptionButtons = false; - chrome.CornerRadius = new CornerRadius(0); - chrome.CaptionHeight = 28; - WindowChrome.SetWindowChrome(this, chrome); + Style = FindResource("Style.Window") as Style; StateChanged += (_, __) => { var content = Content as FrameworkElement; if (WindowState == WindowState.Maximized) { if (!IsMaximized) IsMaximized = true; - BorderThickness = new Thickness(0); content.Margin = new Thickness((SystemParameters.MaximizedPrimaryScreenWidth - SystemParameters.WorkArea.Width) / 2); } else { if (IsMaximized) IsMaximized = false; - BorderThickness = new Thickness(1); content.Margin = new Thickness(0); } }; diff --git a/src/Views/Histories.xaml b/src/Views/Histories.xaml index 56e7fe34..c65ff9da 100644 --- a/src/Views/Histories.xaml +++ b/src/Views/Histories.xaml @@ -9,7 +9,7 @@ xmlns:models="clr-namespace:SourceGit.Models" xmlns:widgets="clr-namespace:SourceGit.Views.Widgets" mc:Ignorable="d" - Title="{StaticResource Text.FileHistory}" + Title="{DynamicResource Text.FileHistory}" WindowStartupLocation="CenterOwner" MinHeight="600" MinWidth="800"> @@ -20,7 +20,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -46,7 +46,7 @@ Grid.Row="1" Height="1" HorizontalAlignment="Stretch" - Fill="{StaticResource Brush.Border0}"/> + Fill="{DynamicResource Brush.Border0}"/> @@ -60,8 +60,8 @@ - + @@ -107,7 +107,7 @@ Grid.Column="1" Text="{Binding Author.Time}" FontSize="9pt" FontFamily="Consolas" - Foreground="{StaticResource Brush.FG2}" + Foreground="{DynamicResource Brush.FG2}" Margin="4,0,0,0" HorizontalAlignment="Right"/> diff --git a/src/Views/Hotkeys.xaml b/src/Views/Hotkeys.xaml index b93c21d1..21032768 100644 --- a/src/Views/Hotkeys.xaml +++ b/src/Views/Hotkeys.xaml @@ -7,7 +7,7 @@ xmlns:controls="clr-namespace:SourceGit.Views.Controls" mc:Ignorable="d" SizeToContent="Height" Width="400" - Title="{StaticResource Text.Hotkeys}" + Title="{DynamicResource Text.Hotkeys}" WindowStartupLocation="CenterOwner" ResizeMode="NoResize"> @@ -18,7 +18,7 @@ - + @@ -30,7 +30,7 @@ - + + Fill="{DynamicResource Brush.Border0}"/> + BorderBrush="{DynamicResource Brush.Border0}"> - - + + diff --git a/src/Views/Launcher.xaml b/src/Views/Launcher.xaml index 8f25151a..ce6500e1 100644 --- a/src/Views/Launcher.xaml +++ b/src/Views/Launcher.xaml @@ -11,7 +11,7 @@ mc:Ignorable="d" WindowStartupLocation="CenterScreen" MinWidth="1280" MinHeight="720" - Title="{StaticResource Text.About.Title}" + Title="{DynamicResource Text.About.Title}" Width="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Width, Mode=TwoWay}" Height="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Height, Mode=TwoWay}" Closing="OnClosing"> @@ -22,14 +22,14 @@ - + - + - + - - - + + + + diff --git a/src/Views/Launcher.xaml.cs b/src/Views/Launcher.xaml.cs index d3d5a4f0..e7652e11 100644 --- a/src/Views/Launcher.xaml.cs +++ b/src/Views/Launcher.xaml.cs @@ -69,6 +69,10 @@ namespace SourceGit.Views { #endregion #region RIGHT_COMMANDS + private void ChangeTheme(object sender, RoutedEventArgs e) { + Models.Theme.Change(); + } + private void OpenPreference(object sender, RoutedEventArgs e) { var dialog = new Preference() { Owner = this }; dialog.ShowDialog(); diff --git a/src/Views/Popups/AddSubTree.xaml b/src/Views/Popups/AddSubTree.xaml index e416860d..b4fea84c 100644 --- a/src/Views/Popups/AddSubTree.xaml +++ b/src/Views/Popups/AddSubTree.xaml @@ -25,7 +25,7 @@ + Content="{DynamicResource Text.AddSubTree.Squash}"/> diff --git a/src/Views/Popups/AddSubmodule.xaml b/src/Views/Popups/AddSubmodule.xaml index 1b8233e7..e80e0968 100644 --- a/src/Views/Popups/AddSubmodule.xaml +++ b/src/Views/Popups/AddSubmodule.xaml @@ -24,13 +24,13 @@ + Placeholder="{DynamicResource Text.RepositoryURL}"> @@ -43,13 +43,13 @@ + Placeholder="{DynamicResource Text.ParentFolder.Placeholder}"> @@ -64,6 +64,6 @@ Margin="0,4,0,0" x:Name="chkNested" IsChecked="True" - Content="{StaticResource Text.Submodule.FetchNested}"/> + Content="{DynamicResource Text.Submodule.FetchNested}"/> diff --git a/src/Views/Popups/Apply.xaml b/src/Views/Popups/Apply.xaml index 77bc37ad..22cf973e 100644 --- a/src/Views/Popups/Apply.xaml +++ b/src/Views/Popups/Apply.xaml @@ -30,7 +30,7 @@ @@ -43,7 +43,7 @@ Grid.Column="0" x:Name="txtPath" Height="24" - Placeholder="{StaticResource Text.Apply.File.Placeholder}"> + Placeholder="{DynamicResource Text.Apply.File.Placeholder}"> @@ -64,7 +64,7 @@ - + @@ -89,6 +89,6 @@ Margin="0,4,0,0" x:Name="chkIngoreWS" IsChecked="True" - Content="{StaticResource Text.Apply.IgnoreWS}"/> + Content="{DynamicResource Text.Apply.IgnoreWS}"/> diff --git a/src/Views/Popups/Archive.xaml b/src/Views/Popups/Archive.xaml index 4671e33f..40912bb2 100644 --- a/src/Views/Popups/Archive.xaml +++ b/src/Views/Popups/Archive.xaml @@ -23,7 +23,7 @@ @@ -48,7 +48,7 @@ Grid.Column="0" x:Name="txtSaveTo" Height="24" - Placeholder="{StaticResource Text.Archive.File.Placeholder}"> + Placeholder="{DynamicResource Text.Archive.File.Placeholder}"> diff --git a/src/Views/Popups/CherryPick.xaml b/src/Views/Popups/CherryPick.xaml index 4d3e59ea..361ab8ca 100644 --- a/src/Views/Popups/CherryPick.xaml +++ b/src/Views/Popups/CherryPick.xaml @@ -21,7 +21,7 @@ + Content="{DynamicResource Text.CherryPick.CommitChanges}"/> diff --git a/src/Views/Popups/Clone.xaml b/src/Views/Popups/Clone.xaml index 58b9fa26..3f425d74 100644 --- a/src/Views/Popups/Clone.xaml +++ b/src/Views/Popups/Clone.xaml @@ -24,14 +24,14 @@ + Placeholder="{DynamicResource Text.Clone.RemoteURL.Placeholder}"> @@ -43,7 +43,7 @@ @@ -56,7 +56,7 @@ Grid.Column="0" x:Name="txtFolder" Height="24" - Placeholder="{StaticResource Text.Clone.Folder.Placeholder}"> + Placeholder="{DynamicResource Text.Clone.Folder.Placeholder}"> @@ -71,21 +71,21 @@ Click="OnFolderSelectorClick" Width="24" Height="24" Margin="2,0,0,0" Padding="4" - BorderBrush="{StaticResource Brush.Border1}" + BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1" Icon="{StaticResource Icon.Folder.Open}"/> + Placeholder="{DynamicResource Text.Clone.LocalName.Placeholder}"> @@ -97,14 +97,14 @@ + Placeholder="{DynamicResource Text.Clone.RemoteName.Placeholder}"> @@ -116,13 +116,13 @@ diff --git a/src/Views/Popups/Configure.xaml b/src/Views/Popups/Configure.xaml index bb5c18fe..f3ce320d 100644 --- a/src/Views/Popups/Configure.xaml +++ b/src/Views/Popups/Configure.xaml @@ -23,34 +23,34 @@ + Placeholder="{DynamicResource Text.Configure.User.Placeholder}"/> + Placeholder="{DynamicResource Text.Configure.Email.Placeholder}"/> + Placeholder="{DynamicResource Text.Configure.Proxy.Placeholder}"/> diff --git a/src/Views/Popups/CreateBranch.xaml b/src/Views/Popups/CreateBranch.xaml index d4f6a165..2ec5b4ac 100644 --- a/src/Views/Popups/CreateBranch.xaml +++ b/src/Views/Popups/CreateBranch.xaml @@ -30,7 +30,7 @@ + Placeholder="{DynamicResource Text.CreateBranch.Name.Placeholder}"> @@ -62,17 +62,17 @@ - - + + + Content="{DynamicResource Text.CreateBranch.Checkout}"/> diff --git a/src/Views/Popups/CreateTag.xaml b/src/Views/Popups/CreateTag.xaml index 42e6def3..ddcc6390 100644 --- a/src/Views/Popups/CreateTag.xaml +++ b/src/Views/Popups/CreateTag.xaml @@ -24,7 +24,7 @@ + Placeholder="{DynamicResource Text.CreateTag.Name.Placeholder}"> @@ -56,14 +56,14 @@ diff --git a/src/Views/Popups/DeleteBranch.xaml b/src/Views/Popups/DeleteBranch.xaml index 895011e0..9acdda19 100644 --- a/src/Views/Popups/DeleteBranch.xaml +++ b/src/Views/Popups/DeleteBranch.xaml @@ -20,7 +20,7 @@ + Content="{DynamicResource Text.DeleteTag.WithRemote}"/> diff --git a/src/Views/Popups/Discard.xaml b/src/Views/Popups/Discard.xaml index 9e9f6416..001c5468 100644 --- a/src/Views/Popups/Discard.xaml +++ b/src/Views/Popups/Discard.xaml @@ -21,7 +21,7 @@ + Text="{DynamicResource Text.Discard.Warning}" + Foreground="{DynamicResource Brush.FG2}"/> diff --git a/src/Views/Popups/EditSubTree.xaml b/src/Views/Popups/EditSubTree.xaml index 5a5c034f..b08aef60 100644 --- a/src/Views/Popups/EditSubTree.xaml +++ b/src/Views/Popups/EditSubTree.xaml @@ -23,7 +23,7 @@ + Content="{DynamicResource Text.Fetch.AllRemotes}"/> + Content="{DynamicResource Text.Fetch.Prune}"/> diff --git a/src/Views/Popups/GitFlowFinish.xaml b/src/Views/Popups/GitFlowFinish.xaml index 9edd0b49..848024de 100644 --- a/src/Views/Popups/GitFlowFinish.xaml +++ b/src/Views/Popups/GitFlowFinish.xaml @@ -36,6 +36,6 @@ Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" x:Name="chkKeep" IsChecked="False" - Content="{StaticResource Text.GitFlow.KeepBranchAfterFinish}"/> + Content="{DynamicResource Text.GitFlow.KeepBranchAfterFinish}"/> diff --git a/src/Views/Popups/GitFlowStart.xaml b/src/Views/Popups/GitFlowStart.xaml index 3c6077f2..ec023911 100644 --- a/src/Views/Popups/GitFlowStart.xaml +++ b/src/Views/Popups/GitFlowStart.xaml @@ -28,7 +28,7 @@ Grid.Row="0" Grid.Column="1" x:Name="txtBranchName" Height="24" - Placeholder="{StaticResource Text.GitFlow.StartPlaceholder}"> + Placeholder="{DynamicResource Text.GitFlow.StartPlaceholder}"> diff --git a/src/Views/Popups/Init.xaml b/src/Views/Popups/Init.xaml index e261ccba..d9e487a3 100644 --- a/src/Views/Popups/Init.xaml +++ b/src/Views/Popups/Init.xaml @@ -21,7 +21,7 @@ + Text="{DynamicResource Text.Init.Tip}" + Foreground="{DynamicResource Brush.FG2}"/> diff --git a/src/Views/Popups/InitGitFlow.xaml b/src/Views/Popups/InitGitFlow.xaml index bc5ef9f3..adf09916 100644 --- a/src/Views/Popups/InitGitFlow.xaml +++ b/src/Views/Popups/InitGitFlow.xaml @@ -26,7 +26,7 @@ + Fill="{DynamicResource Brush.Border2}"/> + Placeholder="{DynamicResource Text.Optional}"/> diff --git a/src/Views/Popups/Merge.xaml b/src/Views/Popups/Merge.xaml index bd013311..420b9199 100644 --- a/src/Views/Popups/Merge.xaml +++ b/src/Views/Popups/Merge.xaml @@ -23,7 +23,7 @@ - + diff --git a/src/Views/Popups/Pull.xaml b/src/Views/Popups/Pull.xaml index ce942d6f..062a8821 100644 --- a/src/Views/Popups/Pull.xaml +++ b/src/Views/Popups/Pull.xaml @@ -28,7 +28,7 @@ + Content="{DynamicResource Text.Pull.UseRebase}"/> + Content="{DynamicResource Text.Pull.AutoStash}"/> diff --git a/src/Views/Popups/Push.xaml b/src/Views/Popups/Push.xaml index 52ddfc4f..a8cff331 100644 --- a/src/Views/Popups/Push.xaml +++ b/src/Views/Popups/Push.xaml @@ -27,7 +27,7 @@ + Content="{DynamicResource Text.Push.WithAllTags}"/> + Content="{DynamicResource Text.Push.Force}"/> diff --git a/src/Views/Popups/PushTag.xaml b/src/Views/Popups/PushTag.xaml index 5829509c..7674adba 100644 --- a/src/Views/Popups/PushTag.xaml +++ b/src/Views/Popups/PushTag.xaml @@ -21,7 +21,7 @@ + Content="{DynamicResource Text.Rebase.AutoStash}"/> diff --git a/src/Views/Popups/Remote.xaml b/src/Views/Popups/Remote.xaml index ce2216c0..6ab14c53 100644 --- a/src/Views/Popups/Remote.xaml +++ b/src/Views/Popups/Remote.xaml @@ -23,13 +23,13 @@ + Placeholder="{DynamicResource Text.Remote.Name.Placeholder}"> @@ -42,13 +42,13 @@ + Placeholder="{DynamicResource Text.Remote.URL.Placeholder}"> diff --git a/src/Views/Popups/RenameBranch.xaml b/src/Views/Popups/RenameBranch.xaml index 4270a31b..c998d86a 100644 --- a/src/Views/Popups/RenameBranch.xaml +++ b/src/Views/Popups/RenameBranch.xaml @@ -23,7 +23,7 @@ + Placeholder="{DynamicResource Text.RenameBranch.Name.Placeholder}"> diff --git a/src/Views/Popups/Reset.xaml b/src/Views/Popups/Reset.xaml index 3ac02faf..b55954ab 100644 --- a/src/Views/Popups/Reset.xaml +++ b/src/Views/Popups/Reset.xaml @@ -23,7 +23,7 @@ - + diff --git a/src/Views/Popups/Revert.xaml b/src/Views/Popups/Revert.xaml index 50b5ca6f..b7675ebd 100644 --- a/src/Views/Popups/Revert.xaml +++ b/src/Views/Popups/Revert.xaml @@ -21,7 +21,7 @@ + Content="{DynamicResource Text.Revert.CommitChanges}"/> diff --git a/src/Views/Popups/Stash.xaml b/src/Views/Popups/Stash.xaml index 48a2f661..6f696139 100644 --- a/src/Views/Popups/Stash.xaml +++ b/src/Views/Popups/Stash.xaml @@ -21,18 +21,18 @@ + Placeholder="{DynamicResource Text.Stash.Message.Placeholder}"/> + Content="{DynamicResource Text.Stash.IncludeUntracked}"/> diff --git a/src/Views/Popups/SubTreePull.xaml b/src/Views/Popups/SubTreePull.xaml index 18446afa..279adf41 100644 --- a/src/Views/Popups/SubTreePull.xaml +++ b/src/Views/Popups/SubTreePull.xaml @@ -25,7 +25,7 @@ + Content="{DynamicResource Text.SubTreePullOrPush.Squash}"/> diff --git a/src/Views/Popups/SubTreePush.xaml b/src/Views/Popups/SubTreePush.xaml index f7036261..3fbcb735 100644 --- a/src/Views/Popups/SubTreePush.xaml +++ b/src/Views/Popups/SubTreePush.xaml @@ -24,7 +24,7 @@ diff --git a/src/Views/Preference.xaml b/src/Views/Preference.xaml index 8abc25d6..5c84c280 100644 --- a/src/Views/Preference.xaml +++ b/src/Views/Preference.xaml @@ -10,7 +10,7 @@ mc:Ignorable="d" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" - Title="{StaticResource Text.Preference}" + Title="{DynamicResource Text.Preference}" Width="500" SizeToContent="Height"> @@ -20,7 +20,7 @@ - + @@ -32,7 +32,7 @@ - + + Fill="{DynamicResource Brush.Border0}"/> @@ -58,7 +58,6 @@ - @@ -80,21 +79,16 @@ - - - - + + SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=General.Locale, Mode=TwoWay}" + SelectionChanged="LocaleChanged"/> - - - - + + Foreground="{DynamicResource Brush.FG2}"/> - + @@ -167,23 +156,23 @@ x:Name="editGitPath" Height="24" Text="{Binding Source={x:Static models:Preference.Instance}, Path=Git.Path, Mode=TwoWay}" - Placeholder="{StaticResource Text.Preference.Git.Path.Placeholder}"/> + Placeholder="{DynamicResource Text.Preference.Git.Path.Placeholder}"/> - + @@ -193,49 +182,49 @@ Grid.Column="0" x:Name="txtGitCloneDir" Height="24" - Placeholder="{StaticResource Text.Preference.Git.Dir.Placeholder}" + Placeholder="{DynamicResource Text.Preference.Git.Dir.Placeholder}" Text="{Binding Source={x:Static models:Preference.Instance}, Path=Git.DefaultCloneDir, Mode=TwoWay}"/> + + + + - - - - + Placeholder="{DynamicResource Text.Preference.Git.Email.Placeholder}"/> - + @@ -252,19 +241,19 @@ + Foreground="{DynamicResource Brush.FG2}"/> - + @@ -288,28 +277,28 @@ Grid.Column="0" Height="24" x:Name="txtMergeExec" - Placeholder="{StaticResource Text.Preference.Merger.Path.Placeholder}" + Placeholder="{DynamicResource Text.Preference.Merger.Path.Placeholder}" Text="{Binding Source={x:Static models:Preference.Instance}, Path=MergeTool.Path, Mode=TwoWay}"/> + Foreground="{DynamicResource Brush.FG2}"/> diff --git a/src/Views/Preference.xaml.cs b/src/Views/Preference.xaml.cs index 7d44fc5d..30ef3da3 100644 --- a/src/Views/Preference.xaml.cs +++ b/src/Views/Preference.xaml.cs @@ -15,12 +15,6 @@ namespace SourceGit.Views { public string CRLF { get; set; } public string MergeCmd { get; set; } - private string locale; - private string avatarServer; - private bool useDarkTheme; - private bool checkUpdate; - private bool autoFetch; - public Preference() { if (Models.Preference.Instance.IsReady) { User = new Commands.Config().Get("user.name"); @@ -36,16 +30,15 @@ namespace SourceGit.Views { var merger = Models.MergeTool.Supported.Find(x => x.Type == Models.Preference.Instance.MergeTool.Type); if (merger != null) MergeCmd = merger.Cmd; - locale = Models.Preference.Instance.General.Locale; - avatarServer = Models.Preference.Instance.General.AvatarServer; - useDarkTheme = Models.Preference.Instance.General.UseDarkTheme; - checkUpdate = Models.Preference.Instance.General.CheckForUpdate; - autoFetch = Models.Preference.Instance.General.AutoFetchRemotes; - InitializeComponent(); } #region EVENTS + private void LocaleChanged(object sender, SelectionChangedEventArgs e) { + Models.Locale.Change(); + e.Handled = true; + } + private void SelectGitPath(object sender, RoutedEventArgs e) { var dialog = new OpenFileDialog(); dialog.Filter = "Git Executable|git.exe"; @@ -116,28 +109,7 @@ namespace SourceGit.Views { } Models.Preference.Save(); - - var general = Models.Preference.Instance.General; - if (locale != general.Locale || - avatarServer != general.AvatarServer || - useDarkTheme != general.UseDarkTheme || - checkUpdate != general.CheckForUpdate || - autoFetch != general.AutoFetchRemotes) { - var result = MessageBox.Show( - this, - App.Text("Restart.Content"), - App.Text("Restart.Title"), - MessageBoxButton.OKCancel, - MessageBoxImage.Question, - MessageBoxResult.Cancel); - if (result == MessageBoxResult.OK) { - App.Restart(); - } else { - Close(); - } - } else { - Close(); - } + Close(); } #endregion } diff --git a/src/Views/Upgrade.xaml b/src/Views/Upgrade.xaml index 003f4252..9e47985e 100644 --- a/src/Views/Upgrade.xaml +++ b/src/Views/Upgrade.xaml @@ -7,7 +7,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:controls="clr-namespace:SourceGit.Views.Controls" mc:Ignorable="d" - Title="{StaticResource Text.UpdateAvailable}" + Title="{DynamicResource Text.UpdateAvailable}" WindowStartupLocation="CenterOwner" Height="400" Width="500" ResizeMode="NoResize"> @@ -21,7 +21,7 @@ - + @@ -33,7 +33,7 @@ - + - + - + @@ -68,26 +68,26 @@ - + - + - + - + @@ -97,16 +97,16 @@ - @@ -42,46 +42,46 @@ - - @@ -118,12 +118,12 @@ - + - + @@ -134,7 +134,7 @@ - + @@ -146,7 +146,7 @@ - + @@ -160,9 +160,9 @@ - - - + + + @@ -237,8 +237,8 @@ - - + + @@ -319,9 +319,9 @@ - - - + + + @@ -376,10 +376,10 @@ - - - - @@ -426,9 +426,9 @@ - - - + + + + Background="{DynamicResource Brush.Border0}"/> @@ -475,7 +475,7 @@ - + @@ -488,33 +488,33 @@ x:Name="txtConflictTip" Margin="4,0" FontWeight="DemiBold" - Foreground="{StaticResource Brush.FG3}"/> + Foreground="{DynamicResource Brush.FG3}"/> - + @@ -69,15 +69,15 @@ + Foreground="{DynamicResource Brush.FG2}"/> + Foreground="{DynamicResource Brush.FG2}"/> @@ -86,7 +86,7 @@ Grid.Row="1" x:Name="dropArea" Margin="0,2" - Stroke="{StaticResource Brush.Border1}" + Stroke="{DynamicResource Brush.Border1}" StrokeThickness="2" StrokeDashArray="4,4" SnapsToDevicePixels="True" @@ -129,7 +129,7 @@ - + - + @@ -51,8 +51,8 @@ + ToolTip="{DynamicResource Text.WorkingCopy.Unstaged.Stage}"/> + ToolTip="{DynamicResource Text.WorkingCopy.Unstaged.StageAll}"/> - + - + @@ -105,8 +105,8 @@ + ToolTip="{DynamicResource Text.WorkingCopy.Staged.Unstage}"/> + ToolTip="{DynamicResource Text.WorkingCopy.Staged.UnstageAll}"/> - + - + @@ -150,22 +150,22 @@ - + + Fill="{DynamicResource Brush.FG2}"/> -