private void SettingsLoad(object sender, EventArgs e) { if (!Helper.HasFeature(Enums.Features.Settings)) { using (var cp = new CheckPassword()) { cp.ShowDialog(this); } } if (!Helper.HasFeature(Enums.Features.Settings)) { MessageBox.Show(this, LocRm.GetString("AccessDenied")); Close(); return; } UISync.Init(this); tcTabs.SelectedIndex = InitialTab; chkErrorReporting.Checked = MainForm.Conf.Enable_Error_Reporting; chkCheckForUpdates.Checked = MainForm.Conf.Enable_Update_Check; chkShowGettingStarted.Checked = MainForm.Conf.Enabled_ShowGettingStarted; _rkApp = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", false); chkStartup.Checked = (_rkApp != null && _rkApp.GetValue("iSpy") != null); mediaDirectoryEditor1.Init(MainForm.Conf.MediaDirectories); btnDetectColor.BackColor = MainForm.Conf.ActivityColor.ToColor(); btnNoDetectColor.BackColor = MainForm.Conf.NoActivityColor.ToColor(); btnColorTracking.BackColor = MainForm.Conf.TrackingColor.ToColor(); btnColorVolume.BackColor = MainForm.Conf.VolumeLevelColor.ToColor(); btnColorMain.BackColor = MainForm.Conf.MainColor.ToColor(); btnColorArea.BackColor = MainForm.Conf.AreaColor.ToColor(); btnColorBack.BackColor = MainForm.Conf.BackColor.ToColor(); btnBorderHighlight.BackColor = MainForm.Conf.BorderHighlightColor.ToColor(); btnBorderDefault.BackColor = MainForm.Conf.BorderDefaultColor.ToColor(); chkAutoSchedule.Checked = MainForm.Conf.AutoSchedule; numMaxCPU.Value = MainForm.Conf.CPUMax; numMaxRecordingThreads.Value = MainForm.Conf.MaxRecordingThreads; numRedraw.Value = MainForm.Conf.MaxRedrawRate; numMediaPanelItems.Value = MainForm.Conf.PreviewItems; txtTrayIcon.Text = MainForm.Conf.TrayIconText; chkMinimise.Checked = MainForm.Conf.MinimiseOnClose; chkSpeechRecognition.Checked = MainForm.Conf.SpeechRecognition; chkMinimiseToTray.Checked = MainForm.Conf.TrayOnMinimise; if (chkMonitor.Checked && !MainForm.Conf.Monitor) { Process.Start(Program.AppPath + "iSpyMonitor.exe"); } chkMonitor.Checked = MainForm.Conf.Monitor; tbOpacity.Value = MainForm.Conf.Opacity; SetColors(); chkBalloon.Checked = MainForm.Conf.BalloonTips; txtIPCameraTimeout.Value = MainForm.Conf.IPCameraTimeout; txtServerReceiveTimeout.Value = MainForm.Conf.ServerReceiveTimeout; txtServerName.Text = MainForm.Conf.ServerName; rtbAccessList.Text = MainForm.Conf.AllowedIPList; int i = 0, selind = 0; foreach (TranslationsTranslationSet set in LocRm.TranslationSets.OrderBy(p => p.Name)) { ddlLanguage.Items.Add(new ListItem(set.Name, new[] {set.CultureCode})); if (set.CultureCode == MainForm.Conf.Language) selind = i; i++; } ddlLanguage.SelectedIndex = selind; chkAlertWindows.Checked = MainForm.Conf.CreateAlertWindows; chkOverlay.Checked = MainForm.Conf.ShowOverlayControls; chkInterrupt.Checked = MainForm.Conf.ScreensaverWakeup; chkEnableIPv6.Checked = !MainForm.Conf.IPv6Disabled; chkRecycle.Checked = MainForm.Conf.DeleteToRecycleBin; txtAppendLinkText.Text = MainForm.Conf.AppendLinkText; numMJPEGStreamInterval.Value = MainForm.Conf.MJPEGStreamInterval; txtAlertOnDisconnect.Text = MainForm.Conf.AlertOnDisconnect; txtAlertOnReconnect.Text = MainForm.Conf.AlertOnReconnect; txtArchive.Text = MainForm.Conf.Archive; SetSSLText(); txtAlertSubject.Text = MainForm.Conf.MailAlertSubject; txtAlertBody.Text = MainForm.Conf.MailAlertBody; txtSMSBody.Text = MainForm.Conf.SMSAlert; foreach (string s in StartupModes) { ddlStartupMode.Items.Add(LocRm.GetString(s)); } foreach (string s in Priorities) { ddlPriority.Items.Add(LocRm.GetString(s)); } ddlStartupMode.SelectedIndex = MainForm.Conf.StartupMode; foreach(var grid in MainForm.Conf.GridViews) { ddlStartUpForm.Items.Add(grid.name); } ddlPriority.SelectedIndex = MainForm.Conf.Priority - 1; ddlStartUpForm.SelectedItem = MainForm.Conf.StartupForm; if (ddlStartUpForm.SelectedItem==null) ddlStartUpForm.SelectedIndex = 0; ddlPlayback.Items.AddRange(PlaybackModes); if (MainForm.Conf.PlaybackMode < 0) MainForm.Conf.PlaybackMode = 0; if (MainForm.Conf.PlaybackMode<ddlPlayback.Items.Count) ddlPlayback.SelectedIndex = MainForm.Conf.PlaybackMode; try { numJPEGQuality.Value = MainForm.Conf.JPEGQuality; } catch (Exception) { } chkBigButtons.Checked = MainForm.Conf.BigButtons; selind = -1; i = 1; try { ddlTalkMic.Items.Add(LocRm.GetString("None")); for (int n = 0; n < WaveIn.DeviceCount; n++) { ddlTalkMic.Items.Add(WaveIn.GetCapabilities(n).ProductName); if (WaveIn.GetCapabilities(n).ProductName == MainForm.Conf.TalkMic) selind = i; i++; } ddlTalkMic.Enabled = true; if (selind > -1) ddlTalkMic.SelectedIndex = selind; else { if (ddlTalkMic.Items.Count == 1) { ddlTalkMic.Items.Add(_noDevices); ddlTalkMic.Enabled = false; ddlTalkMic.SelectedIndex = 1; } else ddlTalkMic.SelectedIndex = 0; } } catch (ApplicationException ex) { MainForm.LogExceptionToFile(ex); ddlTalkMic.Items.Add(_noDevices); ddlTalkMic.Enabled = false; } ddlJoystick.Items.Add(LocRm.GetString("None")); _jst = new JoystickDevice(); var ij = 0; _sticks = _jst.FindJoysticks(); i = 1; foreach(string js in _sticks) { var nameid = js.Split('|'); ddlJoystick.Items.Add(nameid[0]); if (nameid[1] == MainForm.Conf.Joystick.id) ij = i; i++; } ddlJoystick.SelectedIndex = ij; jaxis1.ID = MainForm.Conf.Joystick.XAxis; jaxis1.SupportDPad = true; jaxis1.Invert = MainForm.Conf.Joystick.InvertXAxis; jaxis2.ID = MainForm.Conf.Joystick.YAxis; jaxis2.Invert = MainForm.Conf.Joystick.InvertYAxis; jaxis3.ID = MainForm.Conf.Joystick.ZAxis; jaxis3.Invert = MainForm.Conf.Joystick.InvertZAxis; jbutton1.ID = MainForm.Conf.Joystick.Record; jbutton2.ID = MainForm.Conf.Joystick.Snapshot; jbutton3.ID = MainForm.Conf.Joystick.Talk; jbutton4.ID = MainForm.Conf.Joystick.Listen; jbutton5.ID = MainForm.Conf.Joystick.Play; jbutton6.ID = MainForm.Conf.Joystick.Next; jbutton7.ID = MainForm.Conf.Joystick.Previous; jbutton8.ID = MainForm.Conf.Joystick.Stop; jbutton9.ID = MainForm.Conf.Joystick.MaxMin; jbutton1.GetInput += JbuttonGetInput; jbutton2.GetInput += JbuttonGetInput; jbutton3.GetInput += JbuttonGetInput; jbutton4.GetInput += JbuttonGetInput; jbutton5.GetInput += JbuttonGetInput; jbutton6.GetInput += JbuttonGetInput; jbutton7.GetInput += JbuttonGetInput; jbutton8.GetInput += JbuttonGetInput; jbutton9.GetInput += JbuttonGetInput; jaxis1.GetInput += JaxisGetInput; jaxis2.GetInput += JaxisGetInput; jaxis3.GetInput += JaxisGetInput; chkGZip.Checked = MainForm.Conf.EnableGZip; numDisconnectNotification.Value = MainForm.Conf.DisconnectNotificationDelay; mediaDirectoryEditor1.Enabled = Helper.HasFeature(Enums.Features.Storage); HideTab(tabPage11, Helper.HasFeature(Enums.Features.Plugins)); //important leave here: chkPasswordProtect.Checked = MainForm.Conf.Enable_Password_Protect; if (Helper.HasFeature(Enums.Features.Plugins)) ListPlugins(); chkUseiSpy.Checked = !MainForm.Conf.UseSMTP; txtSMTPFromAddress.Text = MainForm.Conf.SMTPFromAddress; txtSMTPUsername.Text = MainForm.Conf.SMTPUsername; txtSMTPPassword.Text = MainForm.Conf.SMTPPassword; txtSMTPServer.Text = MainForm.Conf.SMTPServer; chkSMTPUseSSL.Checked = MainForm.Conf.SMTPSSL; numSMTPPort.Value = MainForm.Conf.SMTPPort; ftpEditor1.Init(MainForm.Conf.FTPServers); chkOpenGrabs.Checked = MainForm.Conf.OpenGrabs; numFileCache.Value = MainForm.Conf.VLCFileCache; rtbReferrers.Text = MainForm.Conf.Referers; chkPasswordProtectOnStart.Checked = MainForm.Conf.Password_Protect_Startup; chkEnableLogging.Checked = MainForm.Conf.Logging.Enabled; numMaxLogSize.Value = MainForm.Conf.Logging.FileSize; numKeepLogs.Value = MainForm.Conf.Logging.KeepDays; _loaded = true; }
public MainForm(bool silent, string command) { if (Conf.StartupForm != "iSpy") { SilentStartup = true; } SilentStartup = SilentStartup || silent || Conf.Enable_Password_Protect || Conf.StartupMode == 1; //need to wrap initialize component if (SilentStartup) { ShowInTaskbar = false; ShowIcon = false; WindowState = FormWindowState.Minimized; } else { switch (Conf.StartupMode) { case 0: _mWindowState = new PersistWindowState {Parent = this, RegistryPath = @"Software\ispy\startup"}; break; case 2: WindowState = FormWindowState.Maximized; break; case 3: WindowState = FormWindowState.Maximized; FormBorderStyle = FormBorderStyle.None; break; } } InitializeComponent(); if (!SilentStartup) { if (Conf.StartupMode == 0) _mWindowState = new PersistWindowState {Parent = this, RegistryPath = @"Software\ispy\startup"}; } RenderResources(); _startCommand = command; Windows7Renderer r = Windows7Renderer.Instance; toolStripMenu.Renderer = r; statusStrip1.Renderer = r; _pnlCameras.BackColor = Conf.MainColor.ToColor(); RemoteManager = new McRemoteControlManager.RemoteControlDevice(); RemoteManager.ButtonPressed += RemoteManagerButtonPressed; SetPriority(); Arrange(false); _jst = new JoystickDevice(); bool jsactive = false; string[] sticks = _jst.FindJoysticks(); foreach (string js in sticks) { string[] nameid = js.Split('|'); if (nameid[1] == Conf.Joystick.id) { Guid g = Guid.Parse(nameid[1]); jsactive = _jst.AcquireJoystick(g); } } if (!jsactive) { _jst.ReleaseJoystick(); _jst = null; } else { _tmrJoystick = new Timer(100); _tmrJoystick.Elapsed += TmrJoystickElapsed; _tmrJoystick.Start(); } try { INetworkListManager mNlm = new NetworkListManager(); var icpc = (IConnectionPointContainer) mNlm; //similar event subscription can be used for INetworkEvents and INetworkConnectionEvents Guid tempGuid = typeof (INetworkListManagerEvents).GUID; icpc.FindConnectionPoint(ref tempGuid, out _mIcp); if (_mIcp != null) { _mIcp.Advise(this, out _mCookie); } } catch (Exception) { _mIcp = null; } InstanceReference = this; }