Exemple #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Data.Initializer();

            overlayForm.Show();
            networkWorker = new Network(this);

            label_AboutTitle.Text = string.Format("DFA {0}", Global.VERSION);

            FindFFXIVProcess();

            if (!Settings.ShowOverlay)
            {
                overlayForm.Hide();
                checkBox_Overlay.Checked = false;
            }

            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    Updater.CheckNewVersion(this);
                    Thread.Sleep(30 * 60 * 1000);
                }
            });

            checkBox_StartupShow.Checked     = Settings.StartupShowMainForm;
            checkBox_AutoOverlayHide.Checked = Settings.AutoOverlayHide;
            checkBox_FlashWindow.Checked     = Settings.FlashWindow;
            SetCheatRoulleteCheckBox(Settings.CheatRoulette);

            checkBox_Twitter.Checked = Settings.TwitterEnabled;
            textBox_Twitter.Enabled  = Settings.TwitterEnabled;
            textBox_Twitter.Text     = Settings.TwitterAccount;

            foreach (var zone in Data.Areas)
            {
                if (!zone.Value.isDuty && zone.Value.FATEList.Count > 0)
                {
                    triStateTreeView_FATEs.Nodes.Add(zone.Key.ToString(), zone.Value.Name);
                }
            }

            foreach (var fate in Data.GetFATEs())
            {
                var node = triStateTreeView_FATEs.Nodes[fate.Value.Zone.ToString()].Nodes.Add(fate.Key.ToString(), fate.Value.Name);
                node.Checked = Settings.FATEs.Contains(fate.Key);
                nodes.Add(node);
            }

            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    Thread.Sleep(30 * 1000);

                    if ((FFXIVProcess == null) || FFXIVProcess.HasExited)
                    {
                        FFXIVProcess = null;

                        overlayForm.SetStatus(false);
                        this.Invoke(() => FindFFXIVProcess());
                    }
                    else
                    {
                        // FFXIVProcess is alive

                        if (networkWorker.IsRunning)
                        {
                            networkWorker.UpdateGameConnections(FFXIVProcess);
                        }
                        else
                        {
                            networkWorker.StartCapture(FFXIVProcess);
                        }
                    }
                }
            });

            if (Settings.Updated)
            {
                Settings.Updated = false;
                Settings.Save();
                ShowNotification("버전 {0} 업데이트됨", Global.VERSION);
            }

            Sentry.ReportAsync("App started");
        }