コード例 #1
0
ファイル: Settings.cs プロジェクト: Sirendium/IQ-VMS
        private void Button1Click(object sender, EventArgs e)
        {
            string err = "";



            if (err != "")
            {
                MessageBox.Show(err, LocRm.GetString("Error"));
                return;
            }



            SaveSMTPSettings();

            if (!string.IsNullOrEmpty(MainForm.Conf.ArchiveNew))
            {
                if (!MainForm.Conf.ArchiveNew.EndsWith(@"\"))
                {
                    MainForm.Conf.ArchiveNew += @"\";
                }
            }

            MainForm.Iconfont = new Font(FontFamily.GenericSansSerif, MainForm.Conf.BigButtons ? 22 : 15, FontStyle.Bold, GraphicsUnit.Pixel);

            MainForm.Conf.TalkMic = "";



            MainForm.SetPriority();



            LocalServer.ReloadAllowedIPs();



            LocalServer.ReloadAllowedReferrers();



            //SetStorageOptions();

            MainForm.ReloadColors();



            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #2
0
        private void Button1Click(object sender, EventArgs e)
        {
            string err = "";

            foreach (var s in mediaDirectoryEditor1.Directories)
            {
                if (!Directory.Exists(s.Entry))
                {
                    err += LocRm.GetString("Validate_MediaDirectory") + " ("+s.Entry+")\n";
                    break;
                }
            }
            
            if (err != "")
            {
                MessageBox.Show(err, LocRm.GetString("Error"));
                return;
            }

            if (numJPEGQuality.Value != MainForm.Conf.JPEGQuality)
            {
                MainForm.EncoderParams.Param[0] = new EncoderParameter(Encoder.Quality, (int) numJPEGQuality.Value);
            }
            MainForm.Conf.Enable_Error_Reporting = chkErrorReporting.Checked;
            MainForm.Conf.Enable_Update_Check = chkCheckForUpdates.Checked;
            MainForm.Conf.Enable_Password_Protect = chkPasswordProtect.Checked;

            MainForm.Conf.NoActivityColor = btnNoDetectColor.BackColor.ToRGBString();
            MainForm.Conf.ActivityColor = btnDetectColor.BackColor.ToRGBString();
            MainForm.Conf.TrackingColor = btnColorTracking.BackColor.ToRGBString();
            MainForm.Conf.VolumeLevelColor = btnColorVolume.BackColor.ToRGBString();
            MainForm.Conf.MainColor = btnColorMain.BackColor.ToRGBString();
            MainForm.Conf.AreaColor = btnColorArea.BackColor.ToRGBString();
            MainForm.Conf.BackColor = btnColorBack.BackColor.ToRGBString();
            MainForm.Conf.BorderHighlightColor = btnBorderHighlight.BackColor.ToRGBString();
            MainForm.Conf.BorderDefaultColor = btnBorderDefault.BackColor.ToRGBString();

            MainForm.Conf.Enabled_ShowGettingStarted = chkShowGettingStarted.Checked;
            MainForm.Conf.Opacity = tbOpacity.Value;
            MainForm.Conf.OpenGrabs = chkOpenGrabs.Checked;
            MainForm.Conf.BalloonTips = chkBalloon.Checked;
            MainForm.Conf.TrayIconText = txtTrayIcon.Text;
            MainForm.Conf.IPCameraTimeout = Convert.ToInt32(txtIPCameraTimeout.Value);
            MainForm.Conf.ServerReceiveTimeout = Convert.ToInt32(txtServerReceiveTimeout.Value);
            MainForm.Conf.ServerName = txtServerName.Text;
            MainForm.Conf.AutoSchedule = chkAutoSchedule.Checked;
            MainForm.Conf.CPUMax = Convert.ToInt32(numMaxCPU.Value);
            MainForm.Conf.MaxRecordingThreads = (int)numMaxRecordingThreads.Value;
            MainForm.Conf.CreateAlertWindows = chkAlertWindows.Checked;
            MainForm.Conf.MaxRedrawRate = (int)numRedraw.Value;
            MainForm.Conf.Priority = ddlPriority.SelectedIndex + 1;
            MainForm.Conf.Monitor = chkMonitor.Checked;
            MainForm.Conf.ScreensaverWakeup = chkInterrupt.Checked;
            MainForm.Conf.PlaybackMode = ddlPlayback.SelectedIndex;
            MainForm.Conf.PreviewItems = (int)numMediaPanelItems.Value;
            MainForm.Conf.BigButtons = chkBigButtons.Checked;
            MainForm.Conf.DeleteToRecycleBin = chkRecycle.Checked;
            MainForm.Conf.SpeechRecognition = chkSpeechRecognition.Checked;
            MainForm.Conf.AppendLinkText = txtAppendLinkText.Text;
            MainForm.Conf.StartupForm = ddlStartUpForm.SelectedItem.ToString();
            MainForm.Conf.TrayOnMinimise = chkMinimiseToTray.Checked;
            MainForm.Conf.MJPEGStreamInterval = (int)numMJPEGStreamInterval.Value;
            MainForm.Conf.AlertOnDisconnect = txtAlertOnDisconnect.Text;
            MainForm.Conf.AlertOnReconnect = txtAlertOnReconnect.Text;
            MainForm.Conf.StartupMode = ddlStartupMode.SelectedIndex;
            MainForm.Conf.EnableGZip = chkGZip.Checked;
            MainForm.Conf.DisconnectNotificationDelay = (int)numDisconnectNotification.Value;
            var l = mediaDirectoryEditor1.Directories.ToList();
            MainForm.Conf.MediaDirectories = l.ToArray();
            var l2 = ftpEditor1.Servers.ToList();
            MainForm.Conf.FTPServers = l2.ToArray();
            MainForm.Conf.MailAlertSubject = txtAlertSubject.Text;
            MainForm.Conf.MailAlertBody = txtAlertBody.Text;
            MainForm.Conf.SMSAlert = txtSMSBody.Text;
            MainForm.Conf.VLCFileCache = (int)numFileCache.Value;
            MainForm.Conf.Password_Protect_Startup = chkPasswordProtectOnStart.Checked;
            SaveSMTPSettings();

            MainForm.Conf.ArchiveNew = txtArchive.Text.Trim();
            if (!string.IsNullOrEmpty(MainForm.Conf.ArchiveNew))
            {
                if (!MainForm.Conf.ArchiveNew.EndsWith(@"\"))
                    MainForm.Conf.ArchiveNew += @"\";
            }

            MainForm.Iconfont = new Font(FontFamily.GenericSansSerif, MainForm.Conf.BigButtons ? 22 : 15, FontStyle.Bold, GraphicsUnit.Pixel);
            
            MainForm.Conf.TalkMic = "";
            if (ddlTalkMic.Enabled)
            {
                if (ddlTalkMic.SelectedIndex>0)
                    MainForm.Conf.TalkMic = ddlTalkMic.SelectedItem.ToString();
            }

            MainForm.Conf.MinimiseOnClose = chkMinimise.Checked;
            MainForm.Conf.JPEGQuality = (int) numJPEGQuality.Value;
            MainForm.Conf.IPv6Disabled = !chkEnableIPv6.Checked;

            MainForm.SetPriority();

            var ips = rtbAccessList.Text.Trim().Split(',');
            var t = ips.Select(ip => ip.Trim()).Where(ip2 => ip2 != "").Aggregate("", (current, ip2) => current + (ip2 + ","));
            MainForm.Conf.AllowedIPList = t.Trim(',');
            LocalServer.ReloadAllowedIPs();

            var refs = rtbReferrers.Text.Trim().Split(',');
            var t2 = refs.Select(ip => ip.Trim()).Where(ip2 => ip2 != "").Aggregate("", (current, ip2) => current + (ip2 + ","));
            MainForm.Conf.Referers = t2.Trim(',');
            LocalServer.ReloadAllowedReferrers();

            
            MainForm.Conf.ShowOverlayControls = chkOverlay.Checked;

            string lang = ((ListItem) ddlLanguage.SelectedItem).Value[0];
            if (lang != MainForm.Conf.Language)
            {
                ReloadResources = true;
                LocRm.Reset();
            }
            MainForm.Conf.Language = lang;
            if (chkStartup.Checked)
            {
                try
                {
                    _rkApp = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
                    _rkApp?.SetValue("iSpy", "\"" + Application.ExecutablePath + "\" -silent", RegistryValueKind.String);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    Logger.LogException(ex);
                }
            }
            else
            {
                try
                {
                    _rkApp = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
                    _rkApp?.DeleteValue("iSpy", false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    Logger.LogException(ex);
                }
            }

            //SetStorageOptions();

            MainForm.ReloadColors();

            if (ddlJoystick.SelectedIndex > 0)
            {
                string nameid = _sticks[ddlJoystick.SelectedIndex - 1];
                MainForm.Conf.Joystick.id = nameid.Split('|')[1];

                MainForm.Conf.Joystick.XAxis = jaxis1.ID;

                MainForm.Conf.Joystick.InvertXAxis = jaxis1.Invert;

                MainForm.Conf.Joystick.YAxis = jaxis2.ID;
                MainForm.Conf.Joystick.InvertYAxis = jaxis2.Invert;

                MainForm.Conf.Joystick.ZAxis = jaxis3.ID;
                MainForm.Conf.Joystick.InvertZAxis = jaxis3.Invert;

                MainForm.Conf.Joystick.Record = jbutton1.ID;
                MainForm.Conf.Joystick.Snapshot = jbutton2.ID;
                MainForm.Conf.Joystick.Talk = jbutton3.ID;
                MainForm.Conf.Joystick.Listen = jbutton4.ID;
                MainForm.Conf.Joystick.Play = jbutton5.ID;
                MainForm.Conf.Joystick.Next = jbutton6.ID;
                MainForm.Conf.Joystick.Previous = jbutton7.ID;
                MainForm.Conf.Joystick.Stop = jbutton8.ID;
                MainForm.Conf.Joystick.MaxMin = jbutton9.ID;
            }
            else
                MainForm.Conf.Joystick.id = "";

            MainForm.Conf.Logging.Enabled = chkEnableLogging.Checked;
            MainForm.Conf.Logging.FileSize = (int)numMaxLogSize.Value;
            MainForm.Conf.Logging.KeepDays = (int)numKeepLogs.Value;
          
            DialogResult = DialogResult.OK;
            Close();
        }