private void ComboBox_DropDownClosed(object sender, EventArgs e) { var thisCombo = sender as ComboBox; try { switch (thisCombo.SelectionBoxItem.ToString()) { case "中文": LocalizedHelper.ChangeLanguage(Data.ID.Chinense); SettingsHelper.ModifySettings(Data.ID.ST_Language, Data.ID.Chinense); break; case "English": LocalizedHelper.ChangeLanguage(Data.ID.English); SettingsHelper.ModifySettings(Data.ID.ST_Language, Data.ID.English); break; default: return; } } catch { Failed(); return; } Succeed(); }
private bool PathCheck(string Path) { if (!FileHelper.PathAvailableOrNot(Path)) { MainWindow.Snackbar.MessageQueue.Enqueue(LocalizedHelper.GetLocalizedString("Path_Does_Not_Exist", Data.ID.StrRes_Settings)); return(false); } return(true); }
/// <summary> /// 初始化设置 /// </summary> private void InitSettings() { if (!SettingsHelper.ReadSettings()) { MainSnackbar.MessageQueue.Enqueue(LocalizedHelper.GetLocalizedString("Failed_To_Get_Settings", Data.ID.StrRes_Main)); } if (!ThemeHelper.ApplyTheme()) { MainSnackbar.MessageQueue.Enqueue(LocalizedHelper.GetLocalizedString("Failed_To_Apply_Theme", Data.ID.StrRes_Main)); } LocalizedHelper.ChangeLanguage(Data.SettingsData.Laguage); }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { if (string.IsNullOrWhiteSpace((value ?? "").ToString())) { return(new ValidationResult(false, LocalizedHelper.GetLocalizedString("Validation_Required", Data.ID.StrRes_Common))); } if (FileHelper.PathAvailableOrNot(Data.SettingsData.StoragePath + Data.ID.Dir_Core + "\\" + value.ToString())) { return(new ValidationResult(false, LocalizedHelper.GetLocalizedString("Validation_Repeat", Data.ID.StrRes_Common))); } return(ValidationResult.ValidResult); }
/// <summary> /// 开始欢迎 /// </summary> private SnackbarMessageQueue Welcome() { Task.Factory.StartNew(() => { Thread.Sleep(1000); }).ContinueWith(t => { //note you can use the message queue from any thread, but just for the demo here we //need to get the message queue from the snackbar, so need to be on the dispatcher MainSnackbar.MessageQueue.Enqueue(LocalizedHelper.GetLocalizedString("WelcomMSG", Data.ID.StrRes_Main)); }, TaskScheduler.FromCurrentSynchronizationContext()); return(MainSnackbar.MessageQueue); }
/// <summary> /// 创建右键菜单 /// </summary> /// <param name="Router"></param> /// <returns></returns> private ContextMenu CreateRootChangeMenu(string Router) { ContextMenu menu = new ContextMenu(); MenuItem menuItem = new MenuItem() { Header = LocalizedHelper.GetLocalizedString("Intro_SetRoot", ID.StrRes_Core), Tag = Router }; menuItem.Click += new RoutedEventHandler(SetRootMenu_Click); menu.Items.Add(menuItem); return(menu); }
/// <summary> /// 判断目录是否可用 /// </summary> /// <param name="Path"></param> private void ShowCoreAvailability(string Path) { List <string> ENBFiles = new List <string>() { "d3d9.dll", "d3d11.dll" }; if (FileHelper.FileExistOrNot(ENBFiles, Path)) { CoreAvailability.Text = LocalizedHelper.GetLocalizedString("Intro_CoreAvailable", ID.StrRes_Core); CoreAvailability.Foreground = new SolidColorBrush(Colors.Green); return; } CoreAvailability.Text = LocalizedHelper.GetLocalizedString("Intro_CoreUnavailable", ID.StrRes_Core); CoreAvailability.Foreground = new SolidColorBrush(Colors.Red); }
/// <summary> /// 预设不可用警示文本 /// </summary> /// <param name="ErroMSG"></param> /// <returns></returns> private void ShowExpectionText(string ErroMSG, Style style = null) { if (style == null) { style = (Style)FindResource("MaterialDesignDisplay3TextBlock"); } TextBlock textBlock = new TextBlock() { Text = LocalizedHelper.GetLocalizedString("No_Preset_Managed", ID.StrRes_Preset), Style = (Style)this.FindResource("MaterialDesignDisplay3TextBlock"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Foreground = (Brush)this.FindResource("AccentColorBrush2"), TextWrapping = TextWrapping.Wrap }; AddToView(textBlock, ID.Preset_ExpText); }
private bool TESVCheck(string Path) { List <string> TESV = new List <string> { Data.ID.Exe_Skyrim, Data.ID.Exe_SkyrimSE, "SkyrimSELauncher.exe", "SkyrimLauncher.exe", "TSEV.exe" }; if (!FileHelper.FileExistOrNot(TESV, Path, 0)) { MainWindow.Snackbar.MessageQueue.Enqueue(LocalizedHelper.GetLocalizedString("Not_TESV_Folder", Data.ID.StrRes_Settings)); return(false); } return(true); }
private void StorageTextBox_LostFocus(object sender, RoutedEventArgs e) { var thisTexBox = sender as TextBox; string Path = thisTexBox.Text; if (Path == null) { thisTexBox.Text = Data.SettingsData.StoragePath; return; } if (!PathCheck(Path)) { if (!(FileHelper.CreateFolder(Path))) { thisTexBox.Text = Data.SettingsData.StoragePath; MainWindow.Snackbar.MessageQueue.Enqueue(LocalizedHelper.GetLocalizedString("Failed_To_Create_New_Folder", "SettingsStr")); return; } MainWindow.Snackbar.MessageQueue.Enqueue(LocalizedHelper.GetLocalizedString("Folder_Created", "SettingsStr")); } try { FileHelper.MV_Folder(Data.SettingsData.StoragePath + Data.ID.Dir_Storage, Path + Data.ID.Dir_Storage); } catch { StoragePath.Text = Data.SettingsData.StoragePath; Failed(); return; } if (!SettingsHelper.ModifySettings(thisTexBox.Name, thisTexBox.Text)) { thisTexBox.Text = Data.SettingsData.StoragePath; Failed(); return; } Succeed(); }
/// <summary> /// 判断目录是否可用 /// </summary> /// <param name="Path"></param> private void ShowPresetAvailability(string Path) { List <string> ENBFiles = new List <string>() { "enblens.fx", "enbeffect.fx", "enbbloom.fx", "enblocal.ini", "enbseries.ini" }; if (FileHelper.FileExistOrNot(ENBFiles, Path)) { PresetAvailability.Text = LocalizedHelper.GetLocalizedString("Intro_Preset_Available", Data.ID.StrRes_Preset); PresetAvailability.Foreground = new SolidColorBrush(Colors.Green); return; } PresetAvailability.Text = LocalizedHelper.GetLocalizedString("Intro_Preset_Unavailable", Data.ID.StrRes_Preset); PresetAvailability.Foreground = new SolidColorBrush(Colors.Red); }
private void StoragePath_Click(object sender, RoutedEventArgs e) { string Path = FileHelper.OpenFolderDialog(); if (Path == null) { return; } if (!PathCheck(Path)) { if (!(FileHelper.CreateFolder(Path))) { MainWindow.Snackbar.MessageQueue.Enqueue(LocalizedHelper.GetLocalizedString("Failed_To_Create_New_Folder", "SettingsStr")); return; } MainWindow.Snackbar.MessageQueue.Enqueue(LocalizedHelper.GetLocalizedString("Folder_Created", "SettingsStr")); } try { FileHelper.MV_Folder(Data.SettingsData.StoragePath + Data.ID.Dir_Storage, Path + Data.ID.Dir_Storage); } catch { StoragePath.Text = Data.SettingsData.StoragePath; Failed(); return; } if (!SettingsHelper.ModifySettings("StoragePath", Path)) { return; } StoragePath.Text = Path; Succeed(); }
public override string FormatErrorMessage(string name) { return(string.Format(LocalizedHelper.L(ErrorMessage), name)); }
/// <summary> /// 创建Flipper的前展示区 /// </summary> /// <param name="preset"></param> /// <returns></returns> private UIElement CreateFrontContent(PresetData preset, string UUID) { ColorZone TitlecolorZone = new ColorZone() { Mode = ColorZoneMode.PrimaryLight, Height = 30 }; TextBlock StateText = new TextBlock() { Text = LocalizedHelper.GetLocalizedString("State_Available", ID.StrRes_Preset), Foreground = (Brush)this.FindResource("AccentColorBrush3"), Margin = new Thickness(10) }; TextBlock NamText = new TextBlock() { Text = preset.PresetName, Margin = new Thickness(10), Style = (Style)this.FindResource("MaterialDesignTitleTextBlock"), HorizontalAlignment = HorizontalAlignment.Center }; TextBlock CoreText = new TextBlock() { Text = preset.Core, Margin = new Thickness(10), Style = (Style)this.FindResource("MaterialDesignBody1TextBlock"), HorizontalAlignment = HorizontalAlignment.Center }; TextBlock InstallTime = new TextBlock() { Text = preset.InstallTime.Date.ToString(), Margin = new Thickness(10, 10, 10, 10), Style = (Style)this.FindResource("MaterialDesignBody1TextBlock"), HorizontalAlignment = HorizontalAlignment.Center }; Button DetailBtn = new Button() { Style = (Style)this.FindResource("MaterialDesignFlatButton"), Content = LocalizedHelper.GetLocalizedString("Btn_Detail", ID.StrRes_Preset), Margin = new Thickness(10), Tag = UUID }; DetailBtn.Click += new RoutedEventHandler(DetailBtn_Click); Button ChangeStateBtn = new Button() { Style = (Style)this.FindResource("MaterialDesignFloatingActionMiniAccentButton"), Content = new PackIcon() { Kind = PackIconKind.Play }, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(0, 0, 16, -25), Tag = UUID }; if (preset.isRunning) { TitlecolorZone.Mode = ColorZoneMode.PrimaryDark; StateText.Foreground = (Brush)this.FindResource("AccentColorBrush"); StateText.Text = LocalizedHelper.GetLocalizedString("State_Running", ID.StrRes_Preset); ChangeStateBtn.Content = new PackIcon() { Kind = PackIconKind.Stop }; ChangeStateBtn.Click += new RoutedEventHandler(UnApplyPresetBtn_Click); } else { ChangeStateBtn.Click += new RoutedEventHandler(ApplyPresetBtn_Click); } Grid TitleGrid = new Grid() { RowDefinitions = { new RowDefinition(), new RowDefinition() } }; TitleGrid.Children.Add(TitlecolorZone); TitleGrid.Children.Add(ChangeStateBtn); TitleGrid.Children.Add(NamText); Grid.SetRow(TitlecolorZone, 0); Grid.SetRow(ChangeStateBtn, 0); Grid.SetRow(NamText, 1); Grid InfoGrid = new Grid() { ColumnDefinitions = { new ColumnDefinition(), new ColumnDefinition() }, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(10) }; InfoGrid.Children.Add(CoreText); InfoGrid.Children.Add(StateText); Grid.SetColumn(CoreText, 0); Grid.SetColumn(StateText, 1); StackPanel stackPanel = new StackPanel(); stackPanel.Children.Add(TitleGrid); stackPanel.Children.Add(InfoGrid); stackPanel.Children.Add(InstallTime); stackPanel.Children.Add(DetailBtn); return(stackPanel); }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { return(string.IsNullOrWhiteSpace((value ?? "").ToString()) ? new ValidationResult(false, LocalizedHelper.GetLocalizedString("Validation_Required", Data.ID.StrRes_Common)) : ValidationResult.ValidResult); }
/// <summary> /// 创建Flipper的后展示区 /// </summary> /// <param name="preset"></param> /// <returns></returns> private UIElement CreateBackContent(PresetData preset, string UUID) { ColorZone TitlecolorZone = new ColorZone() { Mode = ColorZoneMode.PrimaryLight, Height = 30 }; TreeView FileTree = new TreeView() { Height = 200, Margin = new Thickness(10) }; FileTree.Items.Clear(); FileTree.Items.Add(TreeHelper.GetTreeViewItem(SettingsData.StoragePath + ID.Dir_Preset + "\\" + preset.PresetName, preset.PresetName)); Button DeleteBtn = new Button() { Style = (Style)this.FindResource("MaterialDesignFloatingActionMiniAccentButton"), Content = new PackIcon() { Kind = PackIconKind.Delete }, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(0, 0, 16, -25), Tag = UUID }; DeleteBtn.Click += new RoutedEventHandler(DeleteBtn_Click); Button ReturnBtn = new Button() { Style = (Style)this.FindResource("MaterialDesignFlatButton"), Content = LocalizedHelper.GetLocalizedString("Btn_Return", ID.StrRes_Preset), Margin = new Thickness(10), Command = Flipper.FlipCommand, Tag = UUID }; if (preset.isRunning) { TitlecolorZone.Mode = ColorZoneMode.PrimaryDark; } Grid TitleGrid = new Grid(); TitleGrid.Children.Add(TitlecolorZone); TitleGrid.Children.Add(DeleteBtn); StackPanel stackPanel = new StackPanel() { Children = { TitleGrid, FileTree, ReturnBtn } }; return(stackPanel); }
private void Failed() { MainWindow.Snackbar.MessageQueue.Enqueue(LocalizedHelper.GetLocalizedString("Failed_To_Save", Data.ID.StrRes_Settings)); }
private void Succeed() { MainWindow.Snackbar.MessageQueue.Enqueue(LocalizedHelper.GetLocalizedString("Settins_Saved", Data.ID.StrRes_Settings)); }
/// <summary> /// SnakeBar 消息 /// </summary> /// <param name="MSG"></param> private void SB_Message(string MSG) { MainWindow.Snackbar.MessageQueue.Enqueue(LocalizedHelper.GetLocalizedString(MSG, ID.StrRes_Core)); }
private Card CreateCard(CoreData coreData) { string UUID = Guid.NewGuid().ToString("N"); while (!Char.IsLetter(UUID[0])) { UUID = UUID.Substring(1); } TextBlock CoreVersion = new TextBlock() { Text = coreData.CoreVersion, Style = (Style)this.FindResource("MaterialDesignTitleTextBlock"), HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(10) }; TextBlock InstallTime = new TextBlock() { Text = coreData.InstallTime.ToString(), Style = (Style)this.FindResource("MaterialDesignBody1TextBlock"), HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(10) }; TreeView FileTree = new TreeView() { Margin = new Thickness(10), MaxHeight = 200, HorizontalAlignment = HorizontalAlignment.Center }; FileTree.Items.Clear(); FileTree.Items.Add(TreeHelper.GetTreeViewItem(SettingsData.StoragePath + ID.Dir_Core + "\\" + coreData.CoreVersion, coreData.CoreVersion)); Button DeleteBtn = new Button() { Style = (Style)this.FindResource("MaterialDesignFlatButton"), Content = LocalizedHelper.GetLocalizedString("Btn_Delete", ID.StrRes_Core), Margin = new Thickness(10), HorizontalAlignment = HorizontalAlignment.Stretch, Tag = UUID }; DeleteBtn.Click += new RoutedEventHandler(DeleteBtn_Click); var Container = new StackPanel(); Container.Children.Add(CoreVersion); Container.Children.Add(InstallTime); Container.Children.Add(FileTree); Container.Children.Add(DeleteBtn); Card card = new Card() { Background = (Brush)FindResource("PrimaryHueDarkBrush"), Foreground = (Brush)FindResource("PrimaryHueDarkForegroundBrush"), Padding = new Thickness(10), Margin = new Thickness(10, 0, 10, 0), Content = Container, Tag = coreData.CoreVersion, Name = UUID, Width = 250, Height = 360, VerticalAlignment = VerticalAlignment.Center }; return(card); }