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); }
private void FormSetting_Load(object sender, EventArgs e) { RegSetting.GetSettingsFromRegistry(); //// Version Text label_Version.Text = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion.ToString(); //// Advanced - LogLevel comboBox_LogLevel.DataSource = Enum.GetValues(typeof(FConstants.FreyaLogLevel)); comboBox_LogLevel.SelectedItem = RegSetting.LogLevel; checkBox_SMTPLogWriterEnable.Checked = RegSetting.SMTPLogWriterEnable; //// Mail - Email Addres textBox_Email.Text = RegSetting.EMail; if (textBox_Email.Text.Length == 0) { Options_OK.Enabled = false; } //// Mail - Password textBox_Password.Text = RegSetting.getPassword(); if (textBox_Password.Text.Length == 0) { Options_OK.Enabled = false; } //// Mail - IMAP Server textBox_IMAPServer.Text = RegSetting.IMAPServerIP; if (textBox_IMAPServer.Text.Length == 0) { Options_OK.Enabled = false; } //// Mail - SMTP Server textBox_SMTPServer.Text = RegSetting.SMTPServerIP; if (textBox_SMTPServer.Text.Length == 0) { Options_OK.Enabled = false; } //// Mail - WebService textBox_WebService.Text = RegSetting.WebServiceIP; if (textBox_WebService.Text.Length == 0) { Options_OK.Enabled = false; } //// Mail - SMTPLogLevel string[] SMTPLogLevels = { "None", "Critical", "Error", "Warning", "Information", "Verbose", "Raw" }; comboBox_SMTPLogLevel.Items.AddRange(SMTPLogLevels); string SMTPLogLevel = RegSetting.SMTPLogLevel; comboBox_SMTPLogLevel.SelectedItem = (SMTPLogLevel == null) ? SMTPLogLevels[0] : SMTPLogLevel; //// DMS - Enable/Disable checkBox_DMSEnable.Checked = RegSetting.DMS_Enable; setDMSControlsStatus(); textBox_DMS_UserID.Text = RegSetting.DMS_Setting.UserID; textBox_DMS_Password.Text = RegSetting.DMS_Setting.getPassword(); textBox_DMS_Action.Text = RegSetting.DMS_Setting.Action; textBox_DMS_Target.Text = RegSetting.DMS_Setting.Target; textBox_DMS_Event.Text = RegSetting.DMS_Setting.Event; dateTimePicker_DMS_From.Value = RegSetting.DMS_Setting.From; dateTimePicker_DMS_To.Value = RegSetting.DMS_Setting.To; dateTimePicker_DMS_TriggerAt.Value = RegSetting.DMS_TriggerAt; numericUpDown_DMS_Items.Value = (RegSetting.DMS_Setting.Items >= numericUpDown_DMS_Items.Minimum && RegSetting.DMS_Setting.Items <= numericUpDown_DMS_Items.Maximum) ? RegSetting.DMS_Setting.Items : numericUpDown_DMS_Items.Minimum; label_DMS_hours.Text = string.Format("Total hours : {0}", dateTimePicker_DMS_To.Value.TimeOfDay.Subtract(dateTimePicker_DMS_From.Value.TimeOfDay).TotalHours.ToString()); Dictionary <string, string> ComboboxItem = new Dictionary <string, string>(); ComboboxItem.Add(RegSetting.DMS_Setting.project, RegSetting.DMS_Setting.projectname); comboBox_DMS_Projects.DisplayMember = "Value"; comboBox_DMS_Projects.ValueMember = "Key"; comboBox_DMS_Projects.DataSource = new BindingSource(ComboboxItem, null); comboBox_DMS_Projects.SelectedIndex = 0; /// -------------------------------------------------------------- /// Encryotion /// -------------------------------------------------------------- /// string[] EncryptionMethods = { "StringCipher", "CeasarCipher" }; comboBox_EncryptionMethod.Items.AddRange(EncryptionMethods); comboBox_EncryptionMethod.SelectedItem = EncryptionMethods[1]; // 把每個tabpage都跑一次,讓每個控制項都initialize for (int i = 0; i < tabControl1.TabCount; i++) { tabControl1.SelectedIndex = i; } tabControl1.SelectedIndex = 0; //// 確認哪些UI要顯示 if (RegSetting.hasRight(FConstants.FeatureByte.Hide)) { UI_Adjust(0); //Hide mode } else if (RegSetting.hasRight(FConstants.FeatureByte.Odin)) { UI_Adjust(3); //Odie mode } else { UI_Adjust(1); //Normal mode } //reset switchs sw_needIMAPAuthCheck = false; restartProxy = false; }