Пример #1
0
        private async void FormMain_Load(object sender, EventArgs e)
        {
            Utility.Configuration.Instance.Load();


            Utility.Logger.Instance.LogAdded += new Utility.LogAddedEventHandler((Utility.Logger.LogData data) => {
                if (InvokeRequired)
                {
                    // Invokeはメッセージキューにジョブを投げて待つので、別のBeginInvokeされたジョブが既にキューにあると、
                    // それを実行してしまい、BeginInvokeされたジョブの順番が保てなくなる
                    // GUIスレッドによる処理は、順番が重要なことがあるので、GUIスレッドからInvokeを呼び出してはいけない
                    Invoke(new Utility.LogAddedEventHandler(Logger_LogAdded), data);
                }
                else
                {
                    Logger_LogAdded(data);
                }
            });
            Utility.Configuration.Instance.ConfigurationChanged += ConfigurationChanged;

            Utility.Logger.Add(2, SoftwareInformation.SoftwareNameJapanese + " を起動しています…");


            this.Text = SoftwareInformation.VersionJapanese;

            ResourceManager.Instance.Load();
            RecordManager.Instance.Load();
            KCDatabase.Instance.Load();
            NotifierManager.Instance.Initialize(this);


            Icon = ResourceManager.Instance.AppIcon;

            APIObserver.Instance.Start(Utility.Configuration.Config.Connection.Port, this);


            MainDockPanel.Extender.FloatWindowFactory = new CustomFloatWindowFactory();


            SubForms = new List <DockContent>();

            //form init
            //注:一度全てshowしないとイベントを受け取れないので注意
            fFleet = new FormFleet[4];
            for (int i = 0; i < fFleet.Length; i++)
            {
                SubForms.Add(fFleet[i] = new FormFleet(this, i + 1));
            }

            SubForms.Add(fDock          = new FormDock(this));
            SubForms.Add(fArsenal       = new FormArsenal(this));
            SubForms.Add(fHeadquarters  = new FormHeadquarters(this));
            SubForms.Add(fInformation   = new FormInformation(this));
            SubForms.Add(fCompass       = new FormCompass(this));
            SubForms.Add(fLog           = new FormLog(this));
            SubForms.Add(fQuest         = new FormQuest(this));
            SubForms.Add(fBattle        = new FormBattle(this));
            SubForms.Add(fFleetOverview = new FormFleetOverview(this));
            SubForms.Add(fShipGroup     = new FormShipGroup(this));
            SubForms.Add(fBrowser       = new FormBrowserHost(this));
            SubForms.Add(fWindowCapture = new FormWindowCapture(this));

            LoadLayout(Configuration.Config.Life.LayoutFilePath);

            ConfigurationChanged();                     //設定から初期化

            SoftwareInformation.CheckUpdate();

            // デバッグ: 開始時にAPIリストを読み込む
            if (Configuration.Config.Debug.LoadAPIListOnLoad)
            {
                try {
                    await Task.Factory.StartNew(() => LoadAPIList( Configuration.Config.Debug.APIListPath ));
                } catch (Exception ex) {
                    Utility.Logger.Add(3, "API読み込みに失敗しました。" + ex.Message);
                }
            }

            // 完了通知(ログインページを開く)
            fBrowser.InitializeApiCompleted();

            UIUpdateTimer.Start();

            Utility.Logger.Add(2, "起動処理が完了しました。");
        }
        private async void FormMain_Load(object sender, EventArgs e)
        {
            if (!Directory.Exists("Settings"))
            {
                Directory.CreateDirectory("Settings");
            }


            Utility.Configuration.Instance.Load(this);


            Utility.Logger.Instance.LogAdded += new Utility.LogAddedEventHandler((Utility.Logger.LogData data) => {
                if (InvokeRequired)
                {
                    // Invokeはメッセージキューにジョブを投げて待つので、別のBeginInvokeされたジョブが既にキューにあると、
                    // それを実行してしまい、BeginInvokeされたジョブの順番が保てなくなる
                    // GUIスレッドによる処理は、順番が重要なことがあるので、GUIスレッドからInvokeを呼び出してはいけない
                    Invoke(new Utility.LogAddedEventHandler(Logger_LogAdded), data);
                }
                else
                {
                    Logger_LogAdded(data);
                }
            });
            Utility.Configuration.Instance.ConfigurationChanged += ConfigurationChanged;

            Utility.Logger.Add(2, SoftwareInformation.SoftwareNameJapanese + " を起動しています…");


            this.Text = SoftwareInformation.VersionJapanese;

            ResourceManager.Instance.Load();
            RecordManager.Instance.Load();
            KCDatabase.Instance.Load();
            NotifierManager.Instance.Initialize(this);
            SyncBGMPlayer.Instance.ConfigurationChanged();

            #region Icon settings
            Icon = ResourceManager.Instance.AppIcon;

            StripMenu_File_Configuration.Image = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormConfiguration];

            StripMenu_View_Fleet.Image         = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormFleet];
            StripMenu_View_FleetOverview.Image = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormFleet];
            StripMenu_View_ShipGroup.Image     = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormShipGroup];
            StripMenu_View_Dock.Image          = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormDock];
            StripMenu_View_Arsenal.Image       = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormArsenal];
            StripMenu_View_Headquarters.Image  = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormHeadQuarters];
            StripMenu_View_Quest.Image         = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormQuest];
            StripMenu_View_Information.Image   = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormInformation];
            StripMenu_View_Compass.Image       = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormCompass];
            StripMenu_View_Battle.Image        = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormBattle];
            StripMenu_View_Browser.Image       = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormBrowser];
            StripMenu_View_Log.Image           = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormLog];
            StripMenu_WindowCapture.Image      = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormWindowCapture];
            StripMenu_View_BaseAirCorps.Image  = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormBaseAirCorps];
            StripMenu_View_Json.Image          = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormJson];

            StripMenu_Tool_EquipmentList.Image        = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormEquipmentList];
            StripMenu_Tool_DropRecord.Image           = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormDropRecord];
            StripMenu_Tool_DevelopmentRecord.Image    = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormDevelopmentRecord];
            StripMenu_Tool_ConstructionRecord.Image   = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormConstructionRecord];
            StripMenu_Tool_ResourceChart.Image        = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormResourceChart];
            StripMenu_Tool_AlbumMasterShip.Image      = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormAlbumShip];
            StripMenu_Tool_AlbumMasterEquipment.Image = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormAlbumEquipment];

            StripMenu_Help_Version.Image = ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.AppIcon];
            #endregion


            APIObserver.Instance.Start(Utility.Configuration.Config.Connection.Port, this);


            MainDockPanel.Extender.FloatWindowFactory = new CustomFloatWindowFactory();


            SubForms = new List <DockContent>();

            //form init
            //注:一度全てshowしないとイベントを受け取れないので注意
            fFleet = new FormFleet[4];
            for (int i = 0; i < fFleet.Length; i++)
            {
                SubForms.Add(fFleet[i] = new FormFleet(this, i + 1));
            }

            SubForms.Add(fDock          = new FormDock(this));
            SubForms.Add(fArsenal       = new FormArsenal(this));
            SubForms.Add(fHeadquarters  = new FormHeadquarters(this));
            SubForms.Add(fInformation   = new FormInformation(this));
            SubForms.Add(fCompass       = new FormCompass(this));
            SubForms.Add(fLog           = new FormLog(this));
            SubForms.Add(fQuest         = new FormQuest(this));
            SubForms.Add(fBattle        = new FormBattle(this));
            SubForms.Add(fFleetOverview = new FormFleetOverview(this));
            SubForms.Add(fShipGroup     = new FormShipGroup(this));
            SubForms.Add(fBrowser       = new FormBrowserHost(this));
            SubForms.Add(fWindowCapture = new FormWindowCapture(this));
            SubForms.Add(fBaseAirCorps  = new FormBaseAirCorps(this));
            SubForms.Add(fJson          = new FormJson(this));

            ConfigurationChanged();                     //設定から初期化

            LoadLayout(Configuration.Config.Life.LayoutFilePath);



            SoftwareInformation.CheckUpdate();

            // デバッグ: 開始時にAPIリストを読み込む
            if (Configuration.Config.Debug.LoadAPIListOnLoad)
            {
                try {
                    await Task.Factory.StartNew(() => LoadAPIList( Configuration.Config.Debug.APIListPath ));
                } catch (Exception ex) {
                    Utility.Logger.Add(3, "API読み込みに失敗しました。" + ex.Message);
                }
            }

            APIObserver.Instance.ResponseReceived += (a, b) => UpdatePlayTime();


            // 🎃
            if (DateTime.Now.Month == 10 && DateTime.Now.Day == 31)
            {
                APIObserver.Instance.APIList["api_port/port"].ResponseReceived += CallPumpkinHead;
            }

            // 完了通知(ログインページを開く)
            fBrowser.InitializeApiCompleted();

            UIUpdateTimer.Start();


            Utility.Logger.Add(3, "起動処理が完了しました。");
        }