/// <summary>
        /// 绑定产品和列表
        /// </summary>
        public void BindProductList()
        {
            Task.Run((Action)(() =>
            {
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("condition", "true");
                dic.Add("exchangeId", (string)this.exchangeId);
                Dictionary <string, string> header = new Dictionary <string, string>();
                string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance());
                header.Add("GeneralParam", GeneralParam);
                header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId);
                string result = ApiHelper.SendPostByHeader(InterfacePath.Default.hangqinglist, dic, header, "post");

                Quotation resultmodel = JsonHelper.JsonToObj <Quotation>(result);

                objList = resultmodel.data;
                Dispatcher.Invoke(new Action(() =>
                {
                    if (this.listbox_product.Items.Count == 0)
                    {
                        for (int i = 0; i < resultmodel.data.Count; i++)
                        {
                            ListBoxItem listBoxItem = new ListBoxItem();
                            TextBlock txt = new TextBlock();
                            txt.Text = resultmodel.data[i].productName;
                            txt.MouseLeftButtonDown += SecondToolBar_MouseLeftButtonDown;
                            listBoxItem.Content = txt;
                            if (i == 0)
                            {
                                listBoxItem.IsSelected = true;
                            }
                            this.listbox_product.Items.Add(listBoxItem);
                            if (i == 0)
                            {
                                this.productId = resultmodel.data[i].productId;
                            }
                        }
                        ReloadProduct();
                    }
                    if (objList.Count > 0)
                    {
                        if (objDetailList != null && objDetailList.Count > 0)
                        {
                            QuotationChildren model = objList.Find(x => x.productId == this.productId);
                            if (model != null)
                            {
                                objDetailList = model.contractDtoList;
                            }
                        }
                        else
                        {
                            objDetailList = objList[0].contractDtoList;
                        }
                        this.grid_saffer.ItemsSource = objDetailList;
                        Grid_saffer_SizeChanged(null, null);
                        BindSocket();
                    }
                }));
            }));
        }
        /// <summary>
        /// 添加条件
        /// </summary>
        private void AddCondition()
        {
            try
            {
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("direction", "BUY");//BUY,SELL

                Dictionary <string, string> header = new Dictionary <string, string>();
                header.Add("GeneralParam", JsonHelper.ToJson(SoftwareInformation.Instance()));
                header.Add("Authorization", "Bearer " + Loginer.LoginerUser.Token);
                ResultModel result = JsonHelper.JsonToObj <ResultModel>(ApiHelper.SendPost(InterfacePath.Default.maimai, dic, header, "post"));
                if (result.code == 200)
                {
                    MessageBox.Show("设置成功!");
                }
                else
                {
                    MessageBox.Show("设置失败!");
                }
            }
            catch (Exception ex)
            {
                Log4Helper.Error(this.GetType(), "设置条件单:" + ex);
            }
        }
        public MainPage()
        {
            #region 获取MQTT连接信息
            try
            {
                Dictionary <string, string> dic    = new Dictionary <string, string>();
                Dictionary <string, string> header = new Dictionary <string, string>();
                string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance());
                header.Add("GeneralParam", GeneralParam);
                header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId);

                string result = ApiHelper.SendPostByHeader(InterfacePath.Default.mqttinfo, dic, header, "post");

                ResultModel <MqttEntity> loginsession = JsonHelper.JsonToObj <ResultModel <MqttEntity> >(result);
                MqttEntity._instance          = loginsession.data;
                MqttEntity._instance.clientId = SoftwareInformation.Instance().deviceId;
                #endregion

                #region 连接MQTT
                SubscribeClient subscribeClient = new SubscribeClient(MqttEntity._instance);
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            InitializeComponent();
        }
        /// <summary>
        /// 卖出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SellOut_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("direction", "SELL");                //BUY,SELL
            dic.Add("instrumentId", this.contractId);
            dic.Add("limitPrice", this.limitPrice.Text); //若选择市价,则 priceType=MARKET_PRICE,limitPrice为空, 若选择对手价,最新价,排队价,或者用户手动输入,则priceType=LIMIT_PRICE,limitPrice为对应的价格
            if (this.rdo_kaicang.IsChecked == true)
            {
                dic.Add("offsetFlag", "OPEN");//开仓
            }
            else
            {
                dic.Add("offsetFlag", "CLOSE");//平仓
            }
            dic.Add("priceType", "LIMIT_PRICE");
            dic.Add("volume", this.volume.Text);
            Dictionary <string, string> header = new Dictionary <string, string>();
            string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance());

            header.Add("GeneralParam", GeneralParam);
            header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId);
            string      result      = ApiHelper.SendPostByHeader(InterfacePath.Default.maimai, dic, header, "post");
            ResultModel resultmodel = JsonHelper.JsonToObj <ResultModel>(result);

            if (resultmodel.code == 200)
            {
                MessageBox.Show("提交成功!");
            }
            else if (resultmodel.code == 402)
            {
                ReloadLogin();
            }
        }
Example #5
0
 private void Application_Exit(object sender, ExitEventArgs e)
 {
     if (!string.IsNullOrEmpty(BussinesLoginer.bussinesLoginer.sessionId))
     {
         Dictionary <string, string> dic    = new Dictionary <string, string>();
         Dictionary <string, string> header = new Dictionary <string, string>();
         string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance());
         header.Add("GeneralParam", GeneralParam);
         string result = ApiHelper.SendPostByHeader(InterfacePath.Default.bussineloginout, dic, header, "post");
     }
 }
Example #6
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public ResultModel <UserInfoModel> GetUserInfo(string strUrl, string token)
        {
            //string strUrl = "http://front.future.alibaba.com/user/info";
            Dictionary <string, string> param = new Dictionary <string, string>();

            Dictionary <string, string> header = new Dictionary <string, string>();

            header.Add("GeneralParam", JsonHelper.ToJson(SoftwareInformation.Instance()));
            header.Add("Authorization", "Bearer " + token);

            return(JsonHelper.JsonToObj <ResultModel <UserInfoModel> >(ApiHelper.SendPost(strUrl, param, header, "post")));
        }
Example #7
0
        /// <summary>
        /// 短信验证码登录/注册
        /// </summary>
        /// <param name="mobile">手机号</param>
        /// <param name="checkCode">验证码</param>
        /// <returns></returns>
        public ResultModel <Token> LoginOrRegisterByCode(string strUrl, string mobile, string checkCode)
        {
            //string strUrl = "http://front.future.alibaba.com/user/auth/login/sms";
            Dictionary <string, string> param = new Dictionary <string, string>();

            param.Add("mobile", mobile);
            param.Add("checkCode", checkCode);

            Dictionary <string, string> header = new Dictionary <string, string>();

            header.Add("GeneralParam", JsonHelper.ToJson(SoftwareInformation.Instance()));

            return(JsonHelper.JsonToObj <ResultModel <Token> >(ApiHelper.SendPost(strUrl, param, header, "post")));
        }
Example #8
0
        public ResultModel CheckMessageCode(string strUrl, string checkCode, string checkCodeType, string mobile)
        {
            //string strUrl = "http://front.future.alibaba.com/user/auth/checkCode/verify";
            Dictionary <string, string> param = new Dictionary <string, string>();

            param.Add("checkCode", checkCode);
            param.Add("checkCodeType", checkCodeType);
            param.Add("mobile", mobile);

            Dictionary <string, string> header = new Dictionary <string, string>();

            header.Add("GeneralParam", JsonHelper.ToJson(SoftwareInformation.Instance()));

            return(JsonHelper.JsonToObj <ResultModel>(ApiHelper.SendPost(strUrl, param, header, "post")));
        }
Example #9
0
        /// <summary>
        /// 发送短信验证码
        /// </summary>
        /// <param name="mobile">手机号</param>
        /// <param name="checkCodeType"></param>
        public ResultModel SendMessage(string strUrl, string mobile, string checkCodeType)
        {
            Log4Helper.Info(this.GetType(), $"手机号;{mobile}发送短信一次!");
            //string strUrl = "http://front.future.alibaba.com/user/auth/checkCode/send";
            Dictionary <string, string> param = new Dictionary <string, string>();

            param.Add("checkCodeType", checkCodeType);
            param.Add("mobile", mobile);

            Dictionary <string, string> header = new Dictionary <string, string>();

            header.Add("GeneralParam", JsonHelper.ToJson(SoftwareInformation.Instance()));

            return(JsonHelper.JsonToObj <ResultModel>(ApiHelper.SendPost(strUrl, param, header, "post")));
        }
Example #10
0
        private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int selectindex = this.tab_bussines.SelectedIndex;
            Dictionary <string, string> dic    = new Dictionary <string, string>();
            Dictionary <string, string> header = new Dictionary <string, string>();
            string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance());

            header.Add("GeneralParam", GeneralParam);
            header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId);

            if (selectindex == 0)//持仓
            {
                string result = ApiHelper.SendPostByHeader(InterfacePath.Default.chicang, dic, header, "post");
                //ResultModel<HoldModel> resultmodel = JsonHelper.JsonToObj<ResultModel<HoldModel>>(result);
                //if (resultmodel.code == 402)
                //{
                //    ReloadLogin();
                //}
                //if (resultmodel.data != null)
                //{
                //    this.grid_hold.Dispatcher.Invoke(new Action(() => { this.grid_hold.ItemsSource = resultmodel.data.list; }));
                //}
            }
            if (selectindex == 2)//委托
            {
                //string result = ApiHelper.SendPostByHeader(InterfacePath.Default.weituo, dic, header, "post");
                //ResultModel<EntrustModel_List> resultmodel = JsonHelper.JsonToObj<ResultModel<EntrustModel_List>>(result);
                //if (resultmodel.code == 402)
                //{
                //    ReloadLogin();
                //}
                ResultModel <EntrustModel_List> resultmodel = new ResultModel <EntrustModel_List>();
                LoadList(resultmodel, 2);
                this.grid_entrust.Dispatcher.Invoke(new Action(() => { this.grid_entrust.ItemsSource = resultmodel.data.list; }));
            }
            if (selectindex == 3)//成交记录
            {
                //string result = ApiHelper.SendPostByHeader(InterfacePath.Default.chengjiaojilu, dic, header, "post");
                //ResultModel<RecordModel> resultmodel = JsonHelper.JsonToObj<ResultModel<RecordModel>>(result);
                //if (resultmodel.code == 402)
                //{
                //    ReloadLogin();
                //}
                ResultModel <RecordModel> resultmodel = new ResultModel <RecordModel>();
                LoadList(resultmodel, 3);
                this.grid_record.Dispatcher.Invoke(new Action(() => { this.grid_record.ItemsSource = resultmodel.data.list; }));
            }
        }
Example #11
0
        /// <summary>
        /// 账户注册
        /// </summary>
        /// <param name="checkCode">验证码</param>
        /// <param name="mobile">手机号</param>
        /// <param name="nickname">昵称</param>
        /// <param name="password">密码</param>
        /// <param name="profilePhoto">头像</param>
        /// <param name="qq">qq</param>
        /// <returns></returns>
        public ResultModel <Token> Register(string strUrl, string checkCode, string mobile, string nickname, string password, string profilePhoto, string qq)
        {
            //string strUrl = "http://front.future.alibaba.com/user/auth/register";
            Dictionary <string, string> param = new Dictionary <string, string>();

            param.Add("mobile", mobile);
            param.Add("checkCode", checkCode);
            param.Add("nickname", nickname);
            param.Add("password", password);
            param.Add("profilePhoto", profilePhoto);
            param.Add("qq", qq);

            Dictionary <string, string> header = new Dictionary <string, string>();

            header.Add("GeneralParam", JsonHelper.ToJson(SoftwareInformation.Instance()));

            return(JsonHelper.JsonToObj <ResultModel <Token> >(ApiHelper.SendPost(strUrl, param, header, "post")));
        }
        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSure_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("instrumentId", ""); //合约编号
            dic.Add("stopPrice", "");    //输入价格
            dic.Add("volume", "");       //数量
            //if (this.rdo_kaicang.IsChecked == true)//开平
            //{
            //    dic.Add("offsetFlag", "OPEN");//开仓
            //}
            //else
            //{
            //    dic.Add("offsetFlag", "CLOSE");//平仓
            //}
            dic.Add("direction", "");//方向 BUY,SELL

            //价格->可选择市价,或者是手动输入价格。 若选择市价则  priceType=MARKET_PRICE, limitPrice为空 ,若不选择市价手动输入价格,则  priceType=LIMIT_PRICE,limitPrice=输入值
            dic.Add("priceType", "MARKET_PRICE");

            //dic.Add("priceType", "LIMIT_PRICE");
            //dic.Add("limitPrice", this.limitPrice.Text);

            dic.Add("contingentCondition ", "");
            //dic.Add("volume", this.volume.Text);
            Dictionary <string, string> header = new Dictionary <string, string>();
            string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance());

            header.Add("GeneralParam", GeneralParam);
            header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId);
            string      result      = ApiHelper.SendPostByHeader(InterfacePath.Default.maimai, dic, header, "post");
            ResultModel resultmodel = JsonHelper.JsonToObj <ResultModel>(result);

            if (resultmodel.code == 200)
            {
                //刷新条件列表
            }
            else if (resultmodel.code == 402)
            {
                MessageBox.Show("提交失败!");
            }
        }
Example #13
0
        private void BussinesLogin_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("user", "1297005");
            dic.Add("password", "1297005");
            Dictionary <string, string> header = new Dictionary <string, string>();
            string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance());

            header.Add("GeneralParam", GeneralParam);
            string result = ApiHelper.SendPostByHeader(InterfacePath.Default.bussinelogin, dic, header, "post");

            ResultModel <BussinesLoginer> loginsession = JsonHelper.JsonToObj <ResultModel <BussinesLoginer> >(result);

            BussinesLoginer.bussinesLoginer.sessionId = loginsession.data.sessionId;
            MainPage mainPage = new MainPage();

            mainPage.Show();
            this.Close();
        }
Example #14
0
        public void TiaoJianDanList()
        {
            int selectindex = this.tab_bussines.SelectedIndex;
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("condition", "true");
            Dictionary <string, string> header = new Dictionary <string, string>();
            string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance());

            header.Add("GeneralParam", GeneralParam);
            header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId);

            string result = ApiHelper.SendPostByHeader(InterfacePath.Default.weituo, dic, header, "post");
            ResultModel <EntrustModel_List> resultmodel = JsonHelper.JsonToObj <ResultModel <EntrustModel_List> >(result);

            if (resultmodel.code == 402)
            {
                ReloadLogin();
            }
            this.grid_condition.Dispatcher.Invoke(new Action(() => { this.grid_condition.ItemsSource = resultmodel.data.list; }));
        }
Example #15
0
        /// <summary>
        /// 撤单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CheDan_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("exchangeId", "");
            dic.Add("instrumentId", this.contractId);
            dic.Add("orderSysId", "");
            Dictionary <string, string> header = new Dictionary <string, string>();
            string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance());

            header.Add("GeneralParam", GeneralParam);
            header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId);
            string      result      = ApiHelper.SendPostByHeader(InterfacePath.Default.chedan, dic, header, "post");
            ResultModel resultmodel = JsonHelper.JsonToObj <ResultModel>(result);

            if (resultmodel.code == 200)
            {
                MessageBox.Show("提交成功!");
            }
            else if (resultmodel.code == 402)
            {
                ReloadLogin();
            }
        }
        private static SoftwareInformation GetSoftwareInformation()
        {
            var result = new SoftwareInformation();

            try
            {
                string[] antivirusPrograms;
                using (
                    var searcher =
                        new ManagementObjectSearcher(CoreHelper.RunningOnVistaOrGreater ? "root\\SecurityCenter2" : "root\\SecurityCenter",
                                                     "SELECT * FROM AntivirusProduct"))
                {
                    antivirusPrograms =
                        searcher.Get()
                        .OfType <ManagementObject>()
                        .Select(mObject => mObject["displayName"].ToString())
                        .ToArray();
                }

                result.AntiVirusPrograms = antivirusPrograms.Length > 0
                    ? string.Join(", ", antivirusPrograms.ToArray())
                    : "N/A";
            }
            catch
            {
                result.AntiVirusPrograms = "Unknown";
            }

            try
            {
                string[] firewalls;
                using (
                    var searcher =
                        new ManagementObjectSearcher(CoreHelper.RunningOnVistaOrGreater ? "root\\SecurityCenter2" : "root\\SecurityCenter",
                                                     "SELECT * FROM FirewallProduct"))
                {
                    firewalls =
                        searcher.Get()
                        .OfType <ManagementObject>()
                        .Select(mObject => mObject["displayName"].ToString())
                        .ToArray();
                }

                result.Firewalls = firewalls.Length > 0 ? string.Join(", ", firewalls) : "N/A";
            }
            catch
            {
                result.Firewalls = "Unknown";
            }

            try
            {
                using (
                    var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
                    result.InstalledPrograms = key?.GetSubKeyNames().Length ?? -1;
            }
            catch (Exception)
            {
                result.InstalledPrograms = -1;
            }


            return(result);
        }
Example #17
0
        public T LoadList <T>(T t, int selectindex)
        {
            Dictionary <string, string> dic    = new Dictionary <string, string>();
            Dictionary <string, string> header = new Dictionary <string, string>();
            string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance());

            header.Add("GeneralParam", GeneralParam);
            header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId);
            if (selectindex == 0)//持仓
            {
                string result = ApiHelper.SendPostByHeader(InterfacePath.Default.chicang, dic, header, "post");
                //ResultModel<HoldModel> resultmodel = JsonHelper.JsonToObj<ResultModel<HoldModel>>(result);
                //if (resultmodel.code == 402)
                //{
                //    ReloadLogin();
                //}
                //if (resultmodel.data != null)
                //{
                //    this.grid_hold.Dispatcher.Invoke(new Action(() => { this.grid_hold.ItemsSource = resultmodel.data.list; }));
                //}
            }
            if (selectindex == 2)//委托
            {
                string result = ApiHelper.SendPostByHeader(InterfacePath.Default.weituo, dic, header, "post");
                ResultModel <EntrustModel_List> resultmodel = JsonHelper.JsonToObj <ResultModel <EntrustModel_List> >(result);
                if (resultmodel.code == 402)
                {
                    ReloadLogin();
                }
                if ((t as ResultModel <EntrustModel_List>).data == null)
                {
                    (t as ResultModel <EntrustModel_List>).data = resultmodel.data;
                    return(t);
                }
                foreach (EntrustModel item in resultmodel.data.list)
                {
                    (t as ResultModel <EntrustModel_List>).data.list.Add(item);
                }
                return(t);
            }
            if (selectindex == 3)//成交记录
            {
                string result = ApiHelper.SendPostByHeader(InterfacePath.Default.chengjiaojilu, dic, header, "post");
                ResultModel <RecordModel> resultmodel = JsonHelper.JsonToObj <ResultModel <RecordModel> >(result);
                if (resultmodel.code == 402)
                {
                    ReloadLogin();
                }

                if ((t as ResultModel <RecordModel>).data == null)
                {
                    (t as ResultModel <RecordModel>).data = resultmodel.data;
                    return(t);
                }
                foreach (RecordModel_List item in resultmodel.data.list)
                {
                    (t as ResultModel <RecordModel>).data.list.Add(item);
                }
                return(t);
            }
            return(t);
        }
Example #18
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, "起動処理が完了しました。");
        }