Esempio n. 1
0
        public override void AddBtActionBar()
        {
            if (PART_BtActionBar != null)
            {
#if DEBUG
                logger.Debug($"GameActivity [Ignored] - PART_BtActionBar allready insert");
#endif
                return;
            }

            FrameworkElement BtActionBar;

            if (PluginDatabase.PluginSettings.EnableIntegrationInDescriptionWithToggle)
            {
                if (PluginDatabase.PluginSettings.EnableIntegrationButtonDetails)
                {
                    BtActionBar = new GameActivityToggleButtonDetails();
                }
                else
                {
                    BtActionBar = new GameActivityToggleButton();
                }

                ((ToggleButton)BtActionBar).Click += OnBtActionBarToggleButtonClick;
            }
            else
            {
                if (PluginDatabase.PluginSettings.EnableIntegrationButtonDetails)
                {
                    BtActionBar = new GameActivityButtonDetails();
                }
                else
                {
                    BtActionBar = new GameActivityButton();
                }

                ((Button)BtActionBar).Click += OnBtActionBarClick;
            }

            if (!PluginDatabase.PluginSettings.EnableIntegrationInDescriptionOnlyIcon)
            {
                BtActionBar.MinWidth = 150;
            }

            BtActionBar.Name = BtActionBarName;

            try
            {
                ui.AddButtonInGameSelectedActionBarButtonOrToggleButton(BtActionBar);
                PART_BtActionBar = IntegrationUI.SearchElementByName(BtActionBarName);
            }
            catch (Exception ex)
            {
                Common.LogError(ex, "GameActivity");
            }
        }
Esempio n. 2
0
        private void Integration()
        {
            try
            {
                // Refresh database
                if (GameActivity.isFirstLoad)
                {
                    GameActivityDatabases = new GameActivityCollection();
                    GameActivityDatabases.InitializeCollection(this.GetPluginUserDataPath());
                    GameActivity.isFirstLoad = false;
                }


                GameActivityClass SelectedGameGameActivity = GameActivityDatabases.Get(GameSelected.Id);


                // Search game description
                if (PART_ElemDescription == null)
                {
                    foreach (StackPanel sp in Tools.FindVisualChildren <StackPanel>(Application.Current.MainWindow))
                    {
                        if (sp.Name == "PART_ElemDescription")
                        {
                            PART_ElemDescription = sp;
                            break;
                        }
                    }
                }


                // Delete
                logger.Info("GameActivity - Delete");
                ui.RemoveButtonInGameSelectedActionBarButtonOrToggleButton("PART_GaButton");
                ui.RemoveButtonInGameSelectedActionBarButtonOrToggleButton("PART_GaToggleButton");
                ui.RemoveElementInGameSelectedDescription("PART_GameActivity");
                ui.ClearElementInCustomTheme("PART_GameActivty_Graphic");
                ui.ClearElementInCustomTheme("PART_GameActivty_GraphicLog");


                // Reset resources
                //List<ResourcesList> resourcesLists = new List<ResourcesList>();
                //ui.AddResources(resourcesLists);


                // No game activity
                if (SelectedGameGameActivity == null)
                {
                    logger.Info("GameActivity - No activity for " + GameSelected.Name);
                    return;
                }


                // Add resources
                //ui.AddResources(resourcesLists);


                // Auto integration
                if (settings.EnableIntegrationInDescription || settings.EnableIntegrationInDescriptionWithToggle)
                {
                    if (settings.EnableIntegrationInDescriptionWithToggle)
                    {
                        ToggleButton tb = new ToggleButton();
                        if (settings.IntegrationToggleDetails)
                        {
                            tb = new GameActivityToggleButtonDetails(SelectedGameGameActivity.GetLastSessionActivity().ElapsedSeconds);
                        }
                        else
                        {
                            tb         = new GameActivityToggleButton();
                            tb.Content = resources.GetString("LOCGameActivityTitle");
                        }

                        tb.IsChecked           = false;
                        tb.Name                = "PART_GaToggleButton";
                        tb.Width               = 150;
                        tb.HorizontalAlignment = HorizontalAlignment.Right;
                        tb.VerticalAlignment   = VerticalAlignment.Stretch;
                        tb.Margin              = new Thickness(10, 0, 0, 0);
                        tb.Click              += OnGameSelectedToggleButtonClick;

                        ui.AddButtonInGameSelectedActionBarButtonOrToggleButton(tb);
                    }


                    // Add game activity elements
                    StackPanel GaSp = CreateGa(SelectedGameGameActivity, settings.IntegrationShowTitle, settings.IntegrationShowGraphic, settings.IntegrationShowGraphicLog, false);

                    if (settings.EnableIntegrationInDescriptionWithToggle)
                    {
                        GaSp.Visibility = Visibility.Collapsed;
                    }

                    ui.AddElementInGameSelectedDescription(GaSp, settings.IntegrationTopGameDetails);
                }


                // Auto adding button
                if (settings.EnableIntegrationButton || settings.EnableIntegrationButtonDetails)
                {
                    Button bt = new Button();
                    if (settings.EnableIntegrationButton)
                    {
                        bt.Content = resources.GetString("LOCGameActivityTitle");
                    }

                    if (settings.EnableIntegrationButtonDetails)
                    {
                        bt = new GameActivityButtonDetails(SelectedGameGameActivity.GetLastSessionActivity().ElapsedSeconds);
                    }

                    bt.Name  = "PART_GaButton";
                    bt.Width = 150;
                    bt.HorizontalAlignment = HorizontalAlignment.Right;
                    bt.VerticalAlignment   = VerticalAlignment.Stretch;
                    bt.Margin = new Thickness(10, 0, 0, 0);
                    bt.Click += OnBtGameSelectedActionBarClick;

                    ui.AddButtonInGameSelectedActionBarButtonOrToggleButton(bt);
                }


                // Custom theme
                if (settings.EnableIntegrationInCustomTheme)
                {
                    // Create
                    StackPanel spGaG = CreateGa(SelectedGameGameActivity, false, true, false, true);
                    ui.AddElementInCustomTheme(spGaG, "PART_GameActivty_Graphic");

                    StackPanel spGaGL = CreateGa(SelectedGameGameActivity, false, false, true, true);
                    ui.AddElementInCustomTheme(spGaGL, "PART_GameActivty_GraphicLog");
                }
            }
            catch (Exception ex)
            {
                Common.LogError(ex, "GameActivity", $"Impossible integration");
            }
        }