private void BtRestoreDefault_Click(object sender, RoutedEventArgs e) { try { ThemeClass.RestoreColor(_ThemeDefault, _settings); foreach (ThemeElement themeElement in _ThemeDefault) { var control = this.FindName("tb" + themeElement.Name); if (control is TextBlock) { ((TextBlock)control).Background = themeElement.Element; ThemeClass.SetThemeColor(themeElement.Name, null, _settings, themeElement.Element); } else { logger.Warn($"ThemeModifier - Bad control {"tb" + themeElement.Name}: {control.ToString()}"); } } } catch (Exception ex) { Common.LogError(ex, "ThemeModifier", "Error on BtRestoreDefault_Click()"); } }
private void PART_TM_ColorOK_Click(object sender, RoutedEventArgs e) { LinearGradientBrush linearGradientBrush = new LinearGradientBrush(); if (tbControl != null && lControl != null) { if (PART_SelectorColorPicker.IsSimpleColor) { tbControl.Background = PART_SelectorColorPicker.SimpleSolidColorBrush; ThemeClass.SetThemeColor(lControl.Content.ToString(), PART_SelectorColorPicker.SimpleSolidColorBrush, _settings); } else { linearGradientBrush = PART_SelectorColorPicker.linearGradientBrush; tbControl.Background = linearGradientBrush; ThemeClass.SetThemeColor(lControl.Content.ToString(), linearGradientBrush, _settings); } } else { logger.Warn("ThemeModifier - One control is undefined"); } PART_SelectorColor.Visibility = Visibility.Collapsed; PART_ThemeColor.Visibility = Visibility.Visible; }
public ThemeModifier(IPlayniteAPI api) : base(api) { settings = new ThemeModifierSettings(this); // Get plugin's location string pluginFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // Add plugin localization in application ressource. PluginLocalization.SetPluginLanguage(pluginFolder, api.ApplicationSettings.Language); // Add common in application ressource. Common.Load(pluginFolder); Common.SetEvent(PlayniteApi); // Check version if (settings.EnableCheckVersion) { CheckVersion cv = new CheckVersion(); cv.Check("ThemeModifier", pluginFolder, api); } // Init ui interagration themeModifierUI = new ThemeModifierUI(api, this.GetPluginUserDataPath(), settings); // Theme default ThemeDefault = ThemeClass.GetThemeDefault(); ThemeDefaultConstants = ThemeClass.GetThemeDefaultConstants(PlayniteApi); // Theme actual if (ThemeDefaultConstants.Count > 0) { ThemeActualConstants = ThemeClass.GetThemeActualConstants(settings, PlayniteApi); } #if DEBUG logger.Debug($"ThemeModifier [Ignored] - ThemeDefault: {JsonConvert.SerializeObject(ThemeDefault)}"); logger.Debug($"ThemeModifier [Ignored] - ThemeDefaultConstants: {JsonConvert.SerializeObject(ThemeDefaultConstants)}"); logger.Debug($"ThemeModifier [Ignored] - ThemeActualConstants: {JsonConvert.SerializeObject(ThemeActualConstants)}"); #endif // Add modified values if (PlayniteApi.ApplicationInfo.Mode == ApplicationMode.Desktop) { ThemeClass.SetThemeSettings(settings); ThemeClass.SetThemeSettingsConstants(ThemeActualConstants); } // Features integration icoFeatures = new IcoFeatures(pluginFolder); // Add event fullScreen if (api.ApplicationInfo.Mode == ApplicationMode.Fullscreen) { EventManager.RegisterClassHandler(typeof(Button), Button.ClickEvent, new RoutedEventHandler(BtFullScreen_ClickEvent)); } }
public void InitializeLocalValues() { //Navigation Values Canal = 0; Nivel = 0; EmpresaID = -1; GranjaID = -1; NucleoID = -1; GalponID = -1; SiloID = -1; //Get Scripts ServerScript = gameObject.GetComponent <ServerClass>(); GridScript = gameObject.GetComponent <GridClass>(); ThemeScript = gameObject.GetComponent <ThemeClass>(); WinManagerScript = gameObject.GetComponent <WindowManager>(); //Initialize Grids GridName = "Grid"; GridLocation = GameObject.Find("Grid"); GridCanales = GameObject.Find("GridCanales"); GridLocation.SetActive(false); //Channels Buttons GameObject.Find("Temas").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => GoToChannel("temas")); GameObject.Find("Indicadores").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => GoToChannel("indicadores")); GameObject.Find("Resumen").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => GoToChannel("resumen")); GameObject.Find("Temperatura").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => GoToChannel("temperatura")); //Debugging and navigation backBtn = GameObject.Find("back-btn").GetComponent <Button>(); backBtn.onClick.AddListener(() => JumpToComponent("menu")); empresaBtn = GameObject.Find("empresas-btn").GetComponent <Button>(); granjaBtn = GameObject.Find("granjas-btn").GetComponent <Button>(); nucleoBtn = GameObject.Find("nucleos-btn").GetComponent <Button>(); galponBtn = GameObject.Find("galpones-btn").GetComponent <Button>(); empresaImg = GameObject.Find("empresas-btn").GetComponent <Image>(); granjaImg = GameObject.Find("granjas-btn").GetComponent <Image>(); nucleoImg = GameObject.Find("nucleos-btn").GetComponent <Image>(); galponImg = GameObject.Find("galpones-btn").GetComponent <Image>(); enabledColor = AuxFunctions.ConvertColorRGBA(107.0f, 171.0f, 129.0f, 1.0f); disabledColor = AuxFunctions.ConvertColorRGBA(143.0f, 168.0f, 185.0f, 1.0f); empresaImg.color = disabledColor; granjaImg.color = disabledColor; nucleoImg.color = disabledColor; galponImg.color = disabledColor; empresaBtn.onClick.AddListener(() => JumpToComponent("empresa")); granjaBtn.onClick.AddListener(() => JumpToComponent("granja")); nucleoBtn.onClick.AddListener(() => JumpToComponent("nucleo")); }
public ThemeClassViewModel(ThemeClass @class, ThemeFileViewModel parent) { this.@class = @class; Parent = parent; properties.AddRange(@class.Properties.Select(x => new OwnedThemePropertyViewModel(x))); parts = @class.Parts.Select(x => new ThemePartViewModel(x, this)).ToList(); parts.Sort((x, y) => x.Id.CompareTo(y.Id)); children.Add(new NamedItemContainer("Parts", parts)); }
private void BtSetIcons_Click(object sender, RoutedEventArgs e) { _settings.EnableInDescription = (bool)cEnableInDescription.IsChecked; _settings.UseIconCircle = (bool)tbUseIconCircle.IsChecked; _settings.UseIconClock = (bool)tbUseIconClock.IsChecked; _settings.UseIconSquareCorne = (bool)tbUseIconSquareCorne.IsChecked; _settings.UseIconWe4ponx = (bool)tbUseIconWe4ponx.IsChecked; ThemeClass.SetThemeFile(_PlayniteApi, _settings); }
protected void Page_PreRender(object sender, EventArgs e) { //Generate drop down list if (Session["LoggedInUserId"] != null) { themeClass = new ThemeClass(ThemeDropDownList); themeClass.run(); } else { ThemeDropDownList.Visible = false; } }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ThemeClass theme = new ThemeClass(); theme.ToggleAutoThemeSwitcherByLight(); theme.RunThemeByLightSwitcher(); SysTrayIcon.GenerateSystemTrayIcon(theme); }
//If the session has the information about the theme, then use it //otherwise check if from the ThemeClass public void loadTheme() { if (Session["themeId"] != null) { this.Theme = Session["themeId"].ToString(); } else { ThemeClass themeClass = new ThemeClass(); themeClass.findUserTheme(); this.Theme = themeClass.getUserThemeId(); } }
private void PART_EditThemeMenuBtLoad_Click(object sender, RoutedEventArgs e) { string PathFileName = ((FrameworkElement)sender).Tag.ToString(); try { ThemeClass.LoadThemeColors(PathFileName, _settings, this); } catch (Exception ex) { Common.LogError(ex, "ThemeModifier", $"Error on load {PathFileName}"); } }
public void CancelEdit() { // Code executed when user decides to cancel any changes made since BeginEdit was called. // This method should revert any changes made to Option1 and Option2. var savedSettings = plugin.LoadPluginSettings <ThemeModifierSettings>(); var settings = new ThemeModifierSettings(plugin); ThemeClass.RestoreColor(ThemeModifier.ThemeDefault, settings); ThemeClass.RestoreColor(ThemeModifier.ThemeDefault, savedSettings, true); ThemeClass.SetThemeSettingsConstants(ThemeModifier.ThemeDefaultConstants); ThemeClass.SetThemeSettingsConstants(ThemeModifier.ThemeActualConstants); }
private void PART_EditThemeMenuBtRemove_Click(object sender, RoutedEventArgs e) { try { string PathFileName = ((FrameworkElement)sender).Tag.ToString(); if (_PlayniteApi.Dialogs.ShowMessage(resources.GetString("LOCRemoveLabel") + " " + PathFileName, "ThemeModifier", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { ThemeClass.DeleteThemeColors(PathFileName, _PluginUserDataPath); SetMenuItems(); } } catch (Exception ex) { Common.LogError(ex, "ThemeModifier", $"Error on remove {((FrameworkElement)sender).Tag.ToString()}"); } }
private void BtRestore_Click(object sender, RoutedEventArgs e) { try { TextBlock tbControl = ((StackPanel)((FrameworkElement)sender).Parent).Children.OfType <TextBlock>().FirstOrDefault(); Label lControl = ((StackPanel)((FrameworkElement)sender).Parent).Children.OfType <Label>().FirstOrDefault(); ThemeElement finded = _ThemeDefault.Find(x => x.Name == lControl.Content.ToString()); tbControl.Background = finded.Element; ThemeClass.SetThemeColor(lControl.Content.ToString(), null, _settings, finded.Element); } catch (Exception ex) { Common.LogError(ex, "ThemeModifier", "Error on BtRestore_Click()"); } }
private void PART_EditThemeMenuBtSave_Click(object sender, RoutedEventArgs e) { string ThemeName = PART_EditThemeMenuSaveName.Text; if (ThemeClass.SaveThemeColors(this, ThemeName, _PluginUserDataPath)) { _PlayniteApi.Dialogs.ShowMessage(resources.GetString("LOCThemeModifierManageSaveOk"), "ThemeModifier"); SetMenuItems(); } else { _PlayniteApi.Dialogs.ShowMessage(resources.GetString("LOCThemeModifierManageSaveKo"), "ThemeModifier"); } PART_EditThemeMenuSaveName.Text = string.Empty; PART_EditThemeMenuBtSave.IsEnabled = false; }
private void SetMenuItems() { Thread.Sleep(500); var listItems = ThemeClass.GetListThemeColors(_PluginUserDataPath); if (listItems == null) { Thread.Sleep(500); listItems = ThemeClass.GetListThemeColors(_PluginUserDataPath); } listItems.Sort((x, y) => x.Name.CompareTo(y.Name)); PART_EditThemeMenuLoad.ItemsSource = listItems; PART_EditThemeMenuRemove.ItemsSource = listItems; PART_EditThemeMenuExport.ItemsSource = listItems; }
public ThemeModifierSettingsView(IPlayniteAPI PlayniteApi, ThemeModifierSettings settings, List <ThemeElement> ThemeDefault, string PlayniteConfigurationPath, string PluginUserDataPath) { _PlayniteApi = PlayniteApi; _settings = settings; _ThemeDefault = ThemeDefault; _PlayniteConfigurationPath = PlayniteConfigurationPath; _PluginUserDataPath = PluginUserDataPath; SettingsThemeConstants = ThemeClass.GetThemeActualConstants(settings, PlayniteApi); InitializeComponent(); SetMenuItems(); SetThemeConstants(); }
public void EndEdit() { ThemesConstants = ThemeClass.GetThemesConstants(plugin.PlayniteApi, ThemeModifierSettingsView.SettingsThemeConstants, ThemesConstants); ThemeModifier.ThemeActualConstants = ThemeModifierSettingsView.SettingsThemeConstants; ThemeClass.SetThemeSettingsConstants(ThemeModifier.ThemeDefaultConstants); ThemeClass.SetThemeSettingsConstants(ThemeModifier.ThemeActualConstants); // Code executed when user decides to confirm changes made since BeginEdit was called. // This method should save settings made to Option1 and Option2. plugin.SavePluginSettings(this); ThemeModifier.themeModifierUI.RemoveElements(); var TaskIntegrationUI = Task.Run(() => { var dispatcherOp = ThemeModifier.themeModifierUI.AddElements(); dispatcherOp.Completed += (s, e) => { ThemeModifier.themeModifierUI.RefreshElements(ThemeModifier.GameSelected); }; }); }
// public static bool ThemeClassesNotUsed(KnowledgeBase KB, IOutputService output, ThemeClass themeclass) { return Objects.ThemeClassesNotUsed(KB, output, themeclass); }
public void InitializeValues() { NumberCanales = 4; // Control & Navigation Values remoteControlFromBD = ""; storedRemoteControlFromBD = ""; Canal = 0; CanalFromBD = 0; storedCanalFromBD = 0; Nivel = 0; NivelFromBD = 0; storedNivelFromBD = 0; EmpresaID = "-1"; EmpresaIdFromBD = "-1"; storedEmpresaFromBD = "-1"; GranjaID = "-1"; GranjaIdFromBD = "-1"; storedGranjaFromBD = "-1"; NucleoID = "-1"; NucleoIdFromBD = "-1"; storedNucleoFromBD = "-1"; GalponID = "-1"; galponesDataFromBD = "-1"; storedGalponesDataFromBD = "-1"; SiloID = "-1"; storedSiloFromBD = "-1"; activeElem = -1; zoomFromBD = 1; currentPageFromBD = 1; totalPagesFromBD = 0; themeFromBD = 0; flagFromBD = 0; //Initialize Grids gridName = "Grid"; grid = GameObject.Find("Grid"); gridCanales = GameObject.Find("GridCanales"); grid.SetActive(false); // Add Scripts from Namespace if (gameObject.GetComponent <GridClass>() == null) { gameObject.AddComponent <GridClass>(); } if (gameObject.GetComponent <ThemeClass>() == null) { gameObject.AddComponent <ThemeClass>(); } // Get Scripts gridScript = GetComponent <GridClass>(); themeScript = GetComponent <ThemeClass>(); //UI Interface //Channels Buttons GameObject.Find("Temas").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => TemasChannel()); GameObject.Find("Indicadores").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => IndicadoresChannel()); GameObject.Find("Resumen").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => ResumenChannel()); GameObject.Find("Temperatura").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => TemperaturaChannel()); //Debugging an navigation //navigationPath = new List<string>(); backBtn = GameObject.Find("back-btn").GetComponent <Button>(); backBtn.onClick.AddListener(() => JumpToComponent("back")); empresaBtn = GameObject.Find("empresas-btn").GetComponent <Button>(); granjaBtn = GameObject.Find("granjas-btn").GetComponent <Button>(); nucleoBtn = GameObject.Find("nucleos-btn").GetComponent <Button>(); galponBtn = GameObject.Find("galpones-btn").GetComponent <Button>(); empresaImg = GameObject.Find("empresas-btn").GetComponent <Image>(); granjaImg = GameObject.Find("granjas-btn").GetComponent <Image>(); nucleoImg = GameObject.Find("nucleos-btn").GetComponent <Image>(); galponImg = GameObject.Find("galpones-btn").GetComponent <Image>(); enabledColor = AuxFunctions.ConvertColorRGBA(107.0f, 171.0f, 129.0f, 1.0f); disabledColor = AuxFunctions.ConvertColorRGBA(143.0f, 168.0f, 185.0f, 1.0f); empresaImg.color = disabledColor; granjaImg.color = disabledColor; nucleoImg.color = disabledColor; galponImg.color = disabledColor; empresaBtn.onClick.AddListener(() => JumpToComponent("empresa")); granjaBtn.onClick.AddListener(() => JumpToComponent("granja")); nucleoBtn.onClick.AddListener(() => JumpToComponent("nucleo")); }
private void PART_EditThemeMenuSaveName_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { string ThemeName = PART_EditThemeMenuSaveName.Text; PART_EditThemeMenuBtSave.IsEnabled = (ThemeName.Trim().Length > 3 && !ThemeClass.ThemeFileExist(ThemeName, _PluginUserDataPath)); }
private void BtRemoveIcons_Click(object sender, RoutedEventArgs e) { ThemeClass.RestoreThemeFile(_PlayniteApi); }
private void IntegrationUI() { List <ResourcesList> resourcesLists = new List <ResourcesList>(); resourcesLists.Add(new ResourcesList { Key = "TM_Image", Value = null }); resourcesLists.Add(new ResourcesList { Key = "TM_ImageShape", Value = null }); ui.AddResources(resourcesLists); ThemeManifest ThemeInfos = ThemeClass.GetActualTheme(PlayniteApi); string pluginFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string ImageName = string.Empty; if (ThemeInfos != null && settings.EnableIconChanger) { if (settings.UseIconCircle) { ImageName = "circle"; } if (settings.UseIconClock) { ImageName = "clock"; } if (settings.UseIconSquareCorne) { ImageName = "squareCorne"; } if (settings.UseIconWe4ponx) { ImageName = "we4ponx"; } resourcesLists = new List <ResourcesList>(); resourcesLists.Add(new ResourcesList { Key = "TM_Image", Value = new BitmapImage(new Uri($"{pluginFolder}\\Themes\\Images\\{ImageName}.png")) }); resourcesLists.Add(new ResourcesList { Key = "TM_ImageShape", Value = new BitmapImage(new Uri($"{pluginFolder}\\Themes\\Images\\{ImageName}Shape.png")) }); ui.AddResources(resourcesLists); } if (ThemeInfos != null && settings.EnableIconChanger && settings.EnableInDescription && File.Exists(Path.Combine(ThemeInfos.DirectoryPath, "apply"))) { try { var PART_ControlGameView = CommonPluginsShared.IntegrationUI.SearchElementByName("PART_ControlGameView"); var PART_ImageIcon = CommonPluginsShared.IntegrationUI.SearchElementByName("PART_ImageIcon", PART_ControlGameView); var PART_ThemeModifierIcon = CommonPluginsShared.IntegrationUI.SearchElementByName("PART_ThemeModifierIcon", PART_ControlGameView); if (PART_ImageIcon != null || PART_ThemeModifierIcon != null) { double MaxHeight = 10; #if DEBUG logger.Debug($"ThemeModifier [Ignored] - PART_ImageIcon.MaxHeight: {PART_ImageIcon.MaxHeight} - MaxHeight: {MaxHeight}"); #endif if (!double.IsNaN(PART_ImageIcon.MaxHeight) && (MaxHeight < 11 || double.IsInfinity(MaxHeight))) { MaxHeight = PART_ImageIcon.MaxHeight; } #if DEBUG logger.Debug($"ThemeModifier [Ignored] - PART_ImageIcon.Height: {PART_ImageIcon.Height} - MaxHeight: {MaxHeight}"); #endif if (!double.IsNaN(PART_ImageIcon.Height) && (MaxHeight < 11 || double.IsInfinity(MaxHeight))) { logger.Debug("Height"); MaxHeight = PART_ImageIcon.Height; } #if DEBUG logger.Debug($"ThemeModifier [Ignored] - PART_ImageIcon.MaxWidth: {PART_ImageIcon.MaxWidth} - MaxHeight: {MaxHeight}"); #endif if (!double.IsNaN(PART_ImageIcon.MaxWidth) && (MaxHeight < 11 || double.IsInfinity(MaxHeight))) { MaxHeight = PART_ImageIcon.MaxWidth; } #if DEBUG logger.Debug($"ThemeModifier [Ignored] - PART_ImageIcon.Width: {PART_ImageIcon.Width} - MaxHeight: {MaxHeight}"); #endif if (!double.IsNaN(PART_ImageIcon.Width) && (MaxHeight < 11 || double.IsInfinity(MaxHeight))) { MaxHeight = PART_ImageIcon.Width; } #if DEBUG logger.Debug($"ThemeModifier [Ignored] - MaxHeight: {MaxHeight}"); #endif BitmapImage OriginalSource = new BitmapImage(); if (!string.IsNullOrEmpty(GameSelected.Icon)) { OriginalSource = new BitmapImage(new Uri(PlayniteApi.Database.GetFullFilePath(GameSelected.Icon))); } else { OriginalSource = (BitmapImage)resources.GetResource("DefaultGameIcon"); } Grid gNew = ThemeClass.CreateControl(settings, MaxHeight, ((Image)PART_ImageIcon).Source); gNew.Name = "PART_ThemeModifierIcon"; if (gNew != null) { FrameworkElement parent = null; if (PART_ThemeModifierIcon != null) { #if DEBUG logger.Debug("ThemeModifier [Ignored] - Remove PART_ThemeModifierIcon"); #endif ((Image)PART_ImageIcon).Source = OriginalSource; ((Image)PART_ImageIcon).UpdateLayout(); } else if (PART_ImageIcon != null) { #if DEBUG logger.Debug("ThemeModifier [Ignored] - Remove PART_ImageIcon"); logger.Debug($"ThemeModifier [Ignored] - PART_ImageIcon.Parent is {PART_ImageIcon.Parent.ToString()}"); #endif if (PART_ImageIcon.Parent is DockPanel) { parent = (DockPanel)(PART_ImageIcon.Parent); ((DockPanel)parent).Children.Remove(PART_ImageIcon); ((DockPanel)parent).Children.Insert(0, gNew); ((DockPanel)parent).UpdateLayout(); } if (PART_ImageIcon.Parent is StackPanel) { parent = (StackPanel)(PART_ImageIcon.Parent); ((StackPanel)parent).Children.Remove(PART_ImageIcon); ((StackPanel)parent).Children.Insert(0, gNew); ((StackPanel)parent).UpdateLayout(); } if (PART_ImageIcon.Parent is Canvas) { parent = (Canvas)(PART_ImageIcon.Parent); ((Canvas)parent).Children.Remove(PART_ImageIcon); ((Canvas)parent).Children.Insert(0, gNew); ((Canvas)parent).UpdateLayout(); } } } else { logger.Warn("ThemeModifier - ThemeClass.CreateControl() is null"); } } else { logger.Warn("ThemeModifier - PART_ImageIcon not find "); } } catch (Exception ex) { Common.LogError(ex, "ThemeModifier", "Error integration in Details View"); } } }