Пример #1
0
        private bool InitializeFreyaEnvironment()
        {
            ///
            ///[確認Service存在並啟動]
            string serviceStatus = GetServiceStatus();

            if (serviceStatus.Equals("NotExist"))
            {
                if (FFunc.Heimdallr("install") == false)
                {
                    ExitFreya();
                    return(false);
                }
            }
            else
            {
                string FreyaDirectory = (string)FFunc.GetRegKey("FreyaDirectory");
                if (FreyaDirectory == null || !FreyaDirectory.Equals(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase))
                {
                    if (FFunc.Heimdallr("reinstall") == false)
                    {
                        ExitFreya();
                        return(false);
                    }
                }
            }
            //StartService();

            RegSetting.GetSettingsFromRegistry();
            ///
            /// [Registry]
            /// 確認 Email/WebService/SMTPServer有值,若無,則跳出Option視窗要求填寫
            while (RegSetting.EMail == null || RegSetting.Password == null || RegSetting.SMTPServerIP == null || RegSetting.WebServiceIP == null)
            {
                if (!RegSetting.hasRight(FConstants.FeatureByte.Hide))
                {
                    FormSetting f = new FormSetting();
                    f.radioClient = radioClient;
                    f.TopMost     = true;
                    f.TopLevel    = true;
                    f.ShowDialog(this);

                    //如果按下Cancel,直接結束程式
                    if (f.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                    {
                        this.Close();
                        ExitFreya();
                        return(false);
                    }
                    else if (f.DialogResult == System.Windows.Forms.DialogResult.OK)
                    {
                        radioClient.Send(JsonConvert.SerializeObject(new FMsg {
                            Type = "CMD", Data = "StartProxy"
                        }));
                        logger.WriteLine("[FreyaUI] Send options to service.");
                        RegSetting.GetSettingsFromRegistry();
                    }
                }
                else
                {
                    break;
                }
            }
            RegSetting.GetSettingsFromRegistry();
            getStatus();
            alwaysActiveToolStripMenuItem.Checked = RegSetting.hasRight(FConstants.FeatureByte.AlwaysRun) ? true : false;
            return(true);
        }
Пример #2
0
        private void textBox_FeatureByte_TextChanged(object sender, EventArgs e)
        {
            switch (textBox_FeatureByte.Text)
            {
            case "Hide":
                if (RegSetting.hasRight(FConstants.FeatureByte.Hide))
                {
                    RegSetting.delRight(FConstants.FeatureByte.Hide);      //刪除
                    RegSetting.delRight(FConstants.FeatureByte.AlwaysRun); //刪除
                    UI_Adjust(1);                                          //Normal mode
                }
                else
                {
                    RegSetting.addRight(FConstants.FeatureByte.Hide);      //增加
                    RegSetting.addRight(FConstants.FeatureByte.AlwaysRun); //增加
                    UI_Adjust(0);                                          //Hide mode
                    Options_OK.Enabled = true;
                }
                textBox_FeatureByte.Text = "";
                break;

            case "Odin":
                if (RegSetting.hasRight(FConstants.FeatureByte.Odin))
                {
                    RegSetting.delRight(FConstants.FeatureByte.Odin); //刪除
                    UI_Adjust(1);                                     //Normal mode
                }
                else
                {
                    RegSetting.addRight(FConstants.FeatureByte.Odin); //增加
                    UI_Adjust(3);                                     //Odin mode, full UI, full log
                    Options_OK.Enabled = true;
                }
                textBox_FeatureByte.Text = "";
                break;

            case "Reset":
                RegSetting.FeatureByte = FConstants.FeatureByte.Base;
                UI_Adjust(1);     //Normal mode
                textBox_FeatureByte.Text = "";
                break;

            case "Uninstall":
                FFunc.Heimdallr("uninstall");
                textBox_FeatureByte.Text = "";
                this.DialogResult        = DialogResult.Cancel;
                break;

            case "Update":
                FFunc.Heimdallr("update");
                textBox_FeatureByte.Text = "";
                this.DialogResult        = DialogResult.Cancel;
                break;

            case "ForceUpdate":
                FFunc.Heimdallr("forceupdate");
                textBox_FeatureByte.Text = "";
                this.DialogResult        = DialogResult.Cancel;
                break;

            case "ReInstall":
                FFunc.Heimdallr("reinstall");
                textBox_FeatureByte.Text = "";
                this.DialogResult        = DialogResult.Cancel;
                break;

            default:
                break;
            }
        }