コード例 #1
0
ファイル: Plugin.cs プロジェクト: ChuckFork/Arena-Helper
        protected void InitializeMainWindow()
        {
            if (arenawindow == null)
            {
                arenawindow = new ArenaWindow();

                // Load config
                LoadConfig();
                AddElements();
                ApplyConfig();
                arenawindow.Closed += (sender, args) =>
                {
                    plugins.CloseArena(arenadata, state);

                    SaveConfig();
                    RemoveElements();
                    arenawindow = null;
                    configinit = false;
                };

                // Init
                InitConfigureHero();

                arenawindow.onbuttonnewarenaclick = new ArenaWindow.OnEvent(OnButtonNewArenaClick);
                arenawindow.onbuttonsaveclick = new ArenaWindow.OnEvent(OnButtonSaveClick);
                arenawindow.onwindowlocation = new ArenaWindow.OnEvent(OnWindowLocation);

                arenawindow.onheroclick = new ArenaWindow.OnOverrideClick(OnHeroClick);
                arenawindow.oncardclick = new ArenaWindow.OnOverrideClick(OnCardClick);
                arenawindow.onconfigurehero = new ArenaWindow.OnEvent(OnConfigureHero);
                arenawindow.oncheroclick = new ArenaWindow.OnOverrideClick(OnCHeroClick);

                arenawindow.oncheckboxoverlay = new ArenaWindow.OnCheckbox(OnCheckboxOverlay);
                arenawindow.oncheckboxmanual = new ArenaWindow.OnCheckbox(OnCheckboxManual);
                arenawindow.oncheckboxautosave = new ArenaWindow.OnCheckbox(OnCheckboxAutoSave);
                arenawindow.oncheckboxdebug = new ArenaWindow.OnCheckbox(OnCheckboxDebug);

                // Get the latest arena data
                string newestfilename = "";
                if (Directory.Exists(DeckDataDir))
                {
                    var newest = Directory.GetFiles(DeckDataDir).Select(x => new FileInfo(x)).OrderByDescending(x => x.CreationTime).FirstOrDefault();
                    if (newest != null)
                    {
                        newestfilename = newest.FullName;
                    }
                }
                LoadArenaData(newestfilename);
            }
        }
コード例 #2
0
ファイル: Plugin.cs プロジェクト: ChuckFork/Arena-Helper
        public void OnUnload()
        {
            //RemoveElements();

            if (arenawindow != null)
            {
                if (arenawindow.IsVisible)
                {
                    arenawindow.Close();
                }
                arenawindow = null;
            }

        }
コード例 #3
0
ファイル: Plugin.cs プロジェクト: SuperGouge/Arena-Helper
        protected async Task InitializeMainWindow()
        {
            if (arenawindow == null)
            {
                arenawindow = new ArenaWindow();

                // Load config
                LoadConfig();
                AddElements();
                ApplyConfig();
                arenawindow.Closed += async (sender, args) =>
                {
                    await plugins.CloseArena(arenadata, state);

                    // Save window location
                    if (arenawindow.WindowState != System.Windows.WindowState.Minimized)
                    {
                        // Set window location
                        configdata.windowx = (int)arenawindow.Left;
                        configdata.windowy = (int)arenawindow.Top;
                    }

                    SaveConfig();
                    RemoveElements();
                    arenawindow = null;
                    configinit = false;
                };

                // Init
                InitConfigureHero();

                arenawindow.onbuttonnewarenaclick = new ArenaWindow.OnEvent(OnButtonNewArenaClick);
                arenawindow.onbuttonsaveclick = new ArenaWindow.OnEvent(OnButtonSaveClick);
                arenawindow.onaboutclick = new ArenaWindow.OnEvent(OnAboutClick);

                arenawindow.onheroclick = new ArenaWindow.OnOverrideClick(OnHeroClick);
                arenawindow.oncardclick = new ArenaWindow.OnOverrideClick(OnCardClick);
                arenawindow.onconfigurehero = new ArenaWindow.OnEvent(OnConfigureHero);
                arenawindow.oncheroclick = new ArenaWindow.OnOverrideClick(OnCHeroClick);

                arenawindow.oncheckboxoverlay = new ArenaWindow.OnCheckbox(OnCheckboxOverlay);
                arenawindow.oncheckboxmanual = new ArenaWindow.OnCheckbox(OnCheckboxManual);
                arenawindow.oncheckboxautosave = new ArenaWindow.OnCheckbox(OnCheckboxAutoSave);
                arenawindow.oncheckboxdebug = new ArenaWindow.OnCheckbox(OnCheckboxDebug);

                // Get the latest arena data
                string newestfilename = "";
                if (Directory.Exists(DeckDataDir))
                {
                    var newest = Directory.GetFiles(DeckDataDir).Select(x => new FileInfo(x)).OrderByDescending(x => x.CreationTime).FirstOrDefault();
                    if (newest != null)
                    {
                        newestfilename = newest.FullName;
                    }
                }
                await LoadArenaData(newestfilename);
            }
        }