private void OnActorChanged(Actor actor) { if (this.Appearance != null) { this.Appearance.PropertyChanged -= this.OnViewModelPropertyChanged; this.Appearance.Dispose(); } Application.Current.Dispatcher.Invoke(() => this.IsEnabled = false); this.Appearance = null; this.Hair = null; if (actor == null || !actor.IsCustomizable()) { return; } this.Appearance = new AppearanceViewModel(actor); this.Appearance.PropertyChanged += this.OnViewModelPropertyChanged; Application.Current.Dispatcher.Invoke(() => { this.IsEnabled = true; if (this.Appearance.Race == 0) { this.Appearance.Race = AnAppearance.Races.Hyur; } this.UpdateRaceAndTribe(); }); }
public Appearance() { InitializeComponent(); // create and assign the appearance view model DataContext = new AppearanceViewModel(); }
public MainWindow() { InitializeComponent(); var settings = new AppearanceViewModel(); settings.SetThemeAndColor(Settings.Default.SelectedThemeDisplayName, Settings.Default.SelectedThemeSource, Settings.Default.SelectedAccentColor, Settings.Default.SelectedFontSize); }
private void ComboBox_DropDownClosed(object sender, EventArgs e) { var selectedTheme = new AppearanceViewModel().GetSelectedTheme(); selectedTheme = ((FirstFloor.ModernUI.Presentation.Displayable)(selectedTheme)).DisplayName; if (selectedTheme.ToString() == "light") { var cb = (ComboBox)sender; cb.Foreground = Brushes.Black; } else { var cb = (ComboBox)sender; cb.Foreground = Brushes.WhiteSmoke; } }
public ConfigForm(HotkeyManager hotkeyManager, KneeboardManager kneeboardManager, AltCodeData altCodeData) { InitializeComponent(); _HotkeyManager = hotkeyManager; _KneeboardManager = kneeboardManager; _AltCodeData = altCodeData; _PlacementViewModel = new PlacementViewModel(); // Tab pages tabPageEntryBindingSource.DataSource = new List <TabPageEntry>() { new TabPageEntry(R.keyboard, R.Hotkeys), new TabPageEntry(R.star, R.Favorites), new TabPageEntry(R.palette, R.Appearance), new TabPageEntry(R.placement, R.Dimensions) }; // Hotkeys hotkeyListPanel.Controls.Clear(); foreach (var kvp in _HotkeyManager.GetHooks()) { var item = new HotkeyListItem(kvp.Key, kvp.Value); item.KeyComboEditingChanged += (sender, args) => _HotkeyManager.Enabled = !item.KeyComboEditing && Settings.Default.HotkeysEnabled; hotkeyListPanel.Controls.Add(item); } // Favorites _Favorites = new List <Favorite>(); foreach (var code in _AltCodeData.AltCodes.AltCodes) { var f = new Favorite(code); f.PropertyChanged += Favorite_PropertyChanged; _Favorites.Add(f); } gridFavorites.RowCount = _Favorites.Count; // Favorites: Visible Groups var groups = new List <GroupVisible>(); var hiddenGroups = Settings.Default.HiddenGroups ?? new int[0]; foreach (var group in _AltCodeData.Groups.Groups) { var gv = new GroupVisible(group, !hiddenGroups.Contains(group.ID)); gv.PropertyChanged += GroupVisible_PropertyChanged; groups.Add(gv); } groupVisibleBindingSource.DataSource = groups; cmbStyleSort.DataSource = FormUtils.GetEnumList(typeof(SortMode)); cmbStyleSort.DataBindings.Add(nameof(ComboBox.SelectedValue), Settings.Default, nameof(Settings.SortMode), false, DataSourceUpdateMode.OnPropertyChanged); // Appearance // TODO Allow theme selection from XML/other serialization _AppearanceViewModel = new AppearanceViewModel(); propertyGridTheme.SelectedObject = _KneeboardManager.Theme; propertyGridTheme.DataBindings.Add(nameof(PropertyGrid.PropertySort), _AppearanceViewModel, nameof(AppearanceViewModel.SortMode), false, DataSourceUpdateMode.OnPropertyChanged); toolStripButtonAppearanceThemeSortAlpha.DataBindings.Add(nameof(ToolStripButton.Checked), _AppearanceViewModel, nameof(AppearanceViewModel.SortAlpha), false, DataSourceUpdateMode.OnPropertyChanged); toolStripButtonAppearanceThemeSortByCategory.DataBindings.Add(nameof(ToolStripButton.Checked), _AppearanceViewModel, nameof(AppearanceViewModel.SortCategory), false, DataSourceUpdateMode.OnPropertyChanged); appearancePreview = new AppearancePreviewControl(new KneeboardLayout(_AltCodeData, Settings.Default.Favorites, Settings.Default.HiddenGroups), _KneeboardManager.Theme); appearancePreview.BackgroundImage = R.TransparencyBackground; appearancePreview.BackgroundImageLayout = ImageLayout.Tile; appearancePreview.Dock = DockStyle.Fill; tableLayoutPanelAppearance.Controls.Add(appearancePreview, 1, 0); tableLayoutPanelAppearance.SetRowSpan(appearancePreview, 2); // Placement numPlacementX.DataBindings.Add(nameof(NumericUpDown.Value), _PlacementViewModel, nameof(PlacementViewModel.X), false, DataSourceUpdateMode.OnPropertyChanged); numPlacementY.DataBindings.Add(nameof(NumericUpDown.Value), _PlacementViewModel, nameof(PlacementViewModel.Y), false, DataSourceUpdateMode.OnPropertyChanged); numPlacementWidth.DataBindings.Add(nameof(NumericUpDown.Value), _PlacementViewModel, nameof(PlacementViewModel.Width), false, DataSourceUpdateMode.OnPropertyChanged); numPlacementHeight.DataBindings.Add(nameof(NumericUpDown.Value), _PlacementViewModel, nameof(PlacementViewModel.Height), false, DataSourceUpdateMode.OnPropertyChanged); }
private void OnActorChanged(Actor actor) { if (this.Appearance != null) { this.Appearance.PropertyChanged -= this.OnViewModelPropertyChanged; this.Appearance.Dispose(); } this.skinColorMem?.Dispose(); this.skinGlowMem?.Dispose(); this.leftEyeColorMem?.Dispose(); this.rightEyeColorMem?.Dispose(); this.limbalRingColorMem?.Dispose(); this.hairTintColorMem?.Dispose(); this.hairGlowColorMem?.Dispose(); this.highlightTintColorMem?.Dispose(); if (this.lipTintMem != null) { this.lipTintMem?.Dispose(); this.lipTintMem.ValueChanged -= this.OnLipTintMemChanged; } if (this.lipGlossMem != null) { this.lipGlossMem?.Dispose(); this.lipGlossMem.ValueChanged -= this.OnLipTintMemChanged; } Application.Current.Dispatcher.Invoke(() => this.IsEnabled = false); this.Appearance = null; this.Hair = null; if (actor == null || (actor.Type != ActorTypes.Player && actor.Type != ActorTypes.EventNpc)) { return; } this.skinColorMem = actor.BaseAddress.GetMemory(Offsets.Main.SkinColor); this.skinColorMem.Bind(this, nameof(AppearanceEditor.SkinTint)); this.skinColorMem.Name = "Skin Color"; this.skinGlowMem = actor.BaseAddress.GetMemory(Offsets.Main.SkinGloss); this.skinGlowMem.Bind(this, nameof(AppearanceEditor.SkinGlow)); this.skinGlowMem.Name = "Skin Glow"; this.leftEyeColorMem = actor.BaseAddress.GetMemory(Offsets.Main.LeftEyeColor); this.leftEyeColorMem.Bind(this, nameof(AppearanceEditor.LeftEyeColor)); this.leftEyeColorMem.Name = "Left Eye Color"; this.rightEyeColorMem = actor.BaseAddress.GetMemory(Offsets.Main.RightEyeColor); this.rightEyeColorMem.Bind(this, nameof(AppearanceEditor.RightEyeColor)); this.rightEyeColorMem.Name = "Right Eye Color"; this.limbalRingColorMem = actor.BaseAddress.GetMemory(Offsets.Main.LimbalColor); this.limbalRingColorMem.Bind(this, nameof(AppearanceEditor.LimbalRingColor)); this.limbalRingColorMem.Name = "Limbal Ring Color"; this.hairTintColorMem = actor.BaseAddress.GetMemory(Offsets.Main.HairColor); this.hairTintColorMem.Bind(this, nameof(AppearanceEditor.HairTint)); this.hairTintColorMem.Name = "Hair Color"; this.hairGlowColorMem = actor.BaseAddress.GetMemory(Offsets.Main.HairGloss); this.hairGlowColorMem.Bind(this, nameof(AppearanceEditor.HairGlow)); this.hairGlowColorMem.Name = "Gair Glow"; this.highlightTintColorMem = actor.BaseAddress.GetMemory(Offsets.Main.HairHiglight); this.highlightTintColorMem.Bind(this, nameof(AppearanceEditor.HighlightTint)); this.highlightTintColorMem.Name = "Hair Highlight Color"; this.lipTintMem = actor.BaseAddress.GetMemory(Offsets.Main.MouthColor); this.lipTintMem.ValueChanged += this.OnLipTintMemChanged; this.lipTintMem.Name = "Lips Color"; this.lipGlossMem = actor.BaseAddress.GetMemory(Offsets.Main.MouthGloss); this.lipGlossMem.ValueChanged += this.OnLipTintMemChanged; this.lipGlossMem.Name = "Lips Gloss"; this.OnLipTintMemChanged(null, null); this.Appearance = new AppearanceViewModel(actor); this.Appearance.PropertyChanged += this.OnViewModelPropertyChanged; Application.Current.Dispatcher.Invoke(() => { this.IsEnabled = true; if (this.Appearance.Race == 0) { this.Appearance.Race = ConceptMatrix.Appearance.Races.Hyur; } this.Race = this.gameDataService.Races.Get((byte)this.Appearance.Race); this.TribeComboBox.ItemsSource = this.Race.Tribes; this.Tribe = this.gameDataService.Tribes.Get((byte)this.Appearance.Tribe); this.OnViewModelPropertyChanged(null, null); }); }
public MainWindow() { InitializeComponent(); AppearanceViewModel appearance = App.CurrentAppearanceViewModel; }
public Appearance() { InitializeComponent(); DataContext = new AppearanceViewModel(); }
/// <summary> /// This is the first bit of code being executed when the application is invoked (main entry point). /// /// Use the <paramref name="e"/> parameter to evaluate command line options. /// Invoking a program with an associated file type extension (eg.: *.txt) in Explorer /// results, for example, in executing this function with the path and filename being /// supplied in <paramref name="e"/>. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Application_Startup(object sender, StartupEventArgs e) { try { // Set shutdown mode here (and reset further below) to enable showing custom dialogs (messageboxes) // durring start-up without shutting down application when the custom dialogs (messagebox) closes ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown; } catch { } var settings = GetService <ISettingsManager>(); // add the default themes try // Program message box service for Modern UI (Metro Light and Dark) { var msgBox = GetService <IMessageBoxService>(); msgBox.Style = MsgBoxStyle.WPFThemed; // Add theming models settings.Themes.AddThemeInfo("dark", new Uri("/LocultMetro;component/Themes/ModernUIDark.xaml", UriKind.RelativeOrAbsolute)); // AppearanceManager.DarkThemeSource ); settings.Themes.AddThemeInfo("light", new Uri("/LocultMetro;component/Themes/ModernUILight.xaml", UriKind.RelativeOrAbsolute)); // AppearanceManager.LightThemeSource } catch { } // Create a general settings model to make sure the app is at least governed by defaults // if there are no customized settings on first ever start-up of application var options = settings.Options; SettingDefaults.CreateGeneralSettings(settings); MetroSettingsDefaults.CreateAppearanceSettings(options, settings); settings.Options.SetUndirty(); AppLifeCycleViewModel lifeCycle = null; AppViewModel app = null; try { lifeCycle = new AppLifeCycleViewModel(); lifeCycle.LoadConfigOnAppStartup(); var selectedLanguage = settings.Options.GetOptionValue <string>("Options", "LanguageSelected"); Thread.CurrentThread.CurrentCulture = new CultureInfo(selectedLanguage); Thread.CurrentThread.CurrentUICulture = new CultureInfo(selectedLanguage); app = new AppViewModel(lifeCycle); if (settings.Options.GetOptionValue <string>("Appearance", "ThemeDisplayName") == "dark") { AppearanceManager.Current.DarkThemeCommand.Execute(null); } else { settings.Options.SetOptionValue("Appearance", "ThemeDisplayName", "light"); AppearanceManager.Current.LightThemeCommand.Execute(null); } } catch (Exception exp) { Logger.Error(exp); } // Create the optional appearance viewmodel and apply // current settings to start-up with correct colors etc... var appearSettings = new AppearanceViewModel(settings.Themes); try { appearSettings.ApplyOptionsFromModel(settings.Options); } catch (Exception exp) { Logger.Error(exp); } try { // Register this settings page viewmodel and view var reslocService = GetService <IResourceLocator>(); app.PageManager.AddSettingsPageViewModel(reslocService.GetNewPageTemplateModel( Assembly.GetAssembly(typeof(SettingsAppearance)).GetName().Name, "Views/DataTemplates.xaml", "AppAppearanceSettingsTemplate", appearSettings, "Appearance", 1000)); } catch (Exception exp) { Logger.Error(exp); } try { Application.Current.MainWindow = mMainWin = new MainWindow(); ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose; AppCore.CreateAppDataFolder(); if (mMainWin != null && app != null) { mMainWin.Loaded += mMainWin_Loaded; mMainWin.Closing += OnClosing; // When the ViewModel asks to be closed, close the window. // Source: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx mMainWin.Closed += delegate { // Save session data and close application OnClosed(Workspace, mMainWin); var dispose = Workspace as IDisposable; if (dispose != null) { dispose.Dispose(); Workspace = null; } }; ConstructMainWindowSession(app, mMainWin); mMainWin.Show(); } double fontSize = (double)settings.Options.GetOptionValue <int>("Appearance", "DefaultFontSize"); double keyFixedFontSize = (double)settings.Options.GetOptionValue <int>("Appearance", "FixedFontSize"); Application.Current.Resources[AppearanceManager.KeyDefaultFontSize] = fontSize; Application.Current.Resources[AppearanceManager.KeyFixedFontSize] = keyFixedFontSize; } catch (Exception exp) { Logger.Error(exp); } }
/// <summary> /// This is the first bit of code being executed when the application is invoked (main entry point). /// /// Use the <paramref name="e"/> parameter to evaluate command line options. /// Invoking a program with an associated file type extension (eg.: *.txt) in Explorer /// results, for example, in executing this function with the path and filename being /// supplied in <paramref name="e"/>. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Application_Startup(object sender, StartupEventArgs e) { try { // Set shutdown mode here (and reset further below) to enable showing custom dialogs (messageboxes) // durring start-up without shutting down application when the custom dialogs (messagebox) closes ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown; } catch { } var settings = GetService <ISettingsManager>(); // add the default themes try { // Customize services specific items for this application // Program message box service for Modern UI (Metro Light and Dark) var msgBox = GetService <IMessageBoxService>(); msgBox.Style = MsgBoxStyle.WPFThemed; // Add theming models settings.Themes.AddThemeInfo("dark", new Uri("/SettingsModelWPFDemo;component/Themes/DarkTheme.xaml", UriKind.RelativeOrAbsolute)); // AppearanceManager.DarkThemeSource ); settings.Themes.AddThemeInfo("light", new Uri("/SettingsModelWPFDemo;component/Themes/LightTheme.xaml", UriKind.RelativeOrAbsolute)); // AppearanceManager.LightThemeSource // Create a general settings model to make sure the app is at least governed by defaults // if there are no customized settings on first ever start-up of application var options = settings.Options; SettingDefaults.CreateGeneralSettings(options); SettingDefaults.CreateAppearanceSettings(options, settings); settings.Options.SetUndirty(); } catch { } AppLifeCycleViewModel lifeCycle = null; AppViewModel app = null; try { lifeCycle = new AppLifeCycleViewModel(); lifeCycle.LoadConfigOnAppStartup(); var selectedLanguage = settings.Options.GetOptionValue <string>("Options", "LanguageSelected"); try { Thread.CurrentThread.CurrentCulture = new CultureInfo(selectedLanguage); Thread.CurrentThread.CurrentUICulture = new CultureInfo(selectedLanguage); } catch { } app = new AppViewModel(lifeCycle, settings.Options.GetOptionValue <bool>("Options", "ReloadOpenFilesFromLastSession"), settings.SessionData.LastActiveSolution); if (settings.Options.GetOptionValue <string>("Appearance", "ThemeDisplayName") == "Dark") { AppearanceManager.Current.DarkThemeCommand.Execute(null); } else { AppearanceManager.Current.LightThemeCommand.Execute(null); } // Create the optional appearance viewmodel and apply // current settings to start-up with correct colors etc... var appearSettings = new AppearanceViewModel(settings.Themes); appearSettings.ApplyOptionsFromModel(settings.Options); } catch (Exception exp) { Logger.Error(exp); } try { Application.Current.MainWindow = mMainWin = new MainWindow(); ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose; AppCore.CreateAppDataFolder(); if (mMainWin != null && app != null) { mMainWin.Closing += OnClosing; // When the ViewModel asks to be closed, close the window. // Source: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx mMainWin.Closed += delegate { // Save session data and close application OnClosed(Workspace, mMainWin); var dispose = Workspace as IDisposable; if (dispose != null) { dispose.Dispose(); Workspace = null; } }; ConstructMainWindowSession(app, mMainWin); mMainWin.Show(); } } catch (Exception exp) { Logger.Error(exp); } }
public AppearanceView(AppearanceViewModel VM) { view_model = VM; DataContext = VM; InitializeComponent(); }