Exemplo n.º 1
0
        public static SidebarState RestoreFromIni(string section)
        {
            ISettingStore ini   = Core.SettingStore;
            int           count = ini.ReadInt(section, "PaneCount", 0);

            if (count == 0)
            {
                return(null);
            }

            int[] paneHeights = new int[count];
            for (int i = 0; i < count; i++)
            {
                paneHeights[i] = ini.ReadInt(section, "Pane" + i + "Height", 0);
            }

            int activePaneIndex = ini.ReadInt(section, "ActivePaneIndex", 0);

            if (activePaneIndex >= paneHeights.Length)
            {
                activePaneIndex = 0;
            }

            IResource selResource = null;
            int       resId       = ini.ReadInt(section, "SelectedResource", -1);

            if (resId >= 0)
            {
                selResource = Core.ResourceStore.TryLoadResource(resId);
            }

            return(new SidebarState(paneHeights, activePaneIndex, selResource));
        }
Exemplo n.º 2
0
        /**
         * Saves the setting store used by the form and restores its settings
         * from the INI file.
         */

        public void RestoreSettings()
        {
            AdjustContolProperties(Controls);
            KeyPreview = true;

            _ini = Core.SettingStore;
            string section   = GetFormSettingsSection();
            bool   maximized = _ini.ReadBool(section, "Maximized", false);

            if (maximized)
            {
                WindowState = FormWindowState.Maximized;
            }
            else
            {
                int x      = _ini.ReadInt(section, "X", -1);
                int y      = _ini.ReadInt(section, "Y", -1);
                int width  = _ini.ReadInt(section, "Width", -1);
                int height = _ini.ReadInt(section, "Height", -1);

                if (x != -1 && y != -1)
                {
                    Screen scr = Screen.FromPoint(new Point(x, y));

                    //  First correct horizontal location (since it is that
                    //  what changes most of the time when screens configuration
                    //  is changed). If new point is suitable, do not change vertical
                    //  location.
                    //  NB: pay attention to cases when Screen.WorkingArea is (0, 0, 0, 0)!!!
                    if (!scr.Bounds.Contains(x, y))
                    {
                        x = scr.WorkingArea.X;
                        if (scr.WorkingArea.Width != 0)
                        {
                            x += Math.Abs(x) % scr.WorkingArea.Width;
                        }
                    }

                    if (!scr.Bounds.Contains(x, y))
                    {
                        y = scr.WorkingArea.Y;
                        if (scr.WorkingArea.Height != 0)
                        {
                            y += Math.Abs(y) % scr.WorkingArea.Height;
                        }
                    }
                    StartPosition = FormStartPosition.Manual;
                    Location      = new Point(x, y);
                }
                if (width > 0 && height > 0)
                {
                    ClientSize = new Size(width, height);
                }
            }
        }
Exemplo n.º 3
0
        public override void ShowPane()
        {
            _ini = ICore.Instance.SettingStore;
            _chkGreetingInReplies.Checked = _ini.ReadBool("MailFormat", "GreetingInReplies", true);
            _chkPrefixInitials.Checked    = _ini.ReadBool("MailFormat", "PrefixInitials", false);
            _boxPrefix.Text = _ini.ReadString("MailFormat", "GreetingString", "Hello");

            /**
             * signatures
             */
            _chkUseSignature.Checked = _ini.ReadBool("MailFormat", "UseSignature", false);
            _signatureBox.Enabled    = _chkUseSignature.Checked;
            if (_signatureBox.Enabled)
            {
                _signatureBox.Text = _ini.ReadString("MailFormat", "Signature");
            }

            switch (_ini.ReadInt("MailFormat", "SignatureInReplies", 1))
            {
            case 0: _radReplySignatureNone.Checked = true; break;

            case 1: _radSignatureBeforeQuoting.Checked = true; break;

            case 2: _radSignatureAfterQuoting.Checked = true; break;
            }
        }
Exemplo n.º 4
0
        public override void ShowPane()
        {
            ISettingStore ini = Core.SettingStore;

            _address.Text = ini.ReadString("HttpProxy", "Address");
            int port = ini.ReadInt("HttpProxy", "Port", 3128);

            if (port < (int)_port.Minimum)
            {
                port = (int)_port.Minimum;
            }
            else if (port > (int)_port.Maximum)
            {
                port = (int)_port.Maximum;
            }
            _port.Value          = port;
            _user.Text           = ini.ReadString("HttpProxy", "User");
            _password.Text       = ini.ReadString("HttpProxy", "Password");
            _bypassLocal.Checked = ini.ReadBool("HttpProxy", "BypassLocal", true);
            _bypassList.Text     = ini.ReadString("HttpProxy", "BypassList");

            if (_address.Text.Length > 0)
            {
                _configureProxyButton.Checked = true;
            }
            else
            {
                _defaultProxyButton.Checked = true;
            }

            if (IsDefaultProxyAutoconfigured())
            {
                _lblDefaultSetting.Text = "Autoconfigure script not supported, please specify proxy settings manually";
            }
            else if (WebProxy.GetDefaultProxy().Address != null)
            {
                _lblDefaultSetting.Text = "Default proxy setting: " + WebProxy.GetDefaultProxy().Address;
            }
            else
            {
                _lblDefaultSetting.Text = "Default proxy setting: No proxy specified";
            }
        }
Exemplo n.º 5
0
        public override void ShowPane()
        {
            ISettingStore ini        = Core.SettingStore;
            int           markReadMS = ini.ReadInt("Resources", "MarkAsReadTimeOut", 2000);

            if (markReadMS == 0)
            {
                _chkMarkAsRead.Checked       = false;
                _udMarkAsReadSeconds.Enabled = false;
            }
            else
            {
                _chkMarkAsRead.Checked     = true;
                _udMarkAsReadSeconds.Value = markReadMS / 1000;
            }
            _chkShowContext.Checked        = ini.ReadBool("Resources", "ShowSearchContext", true);
            _chkUseShortDateFormat.Checked = ini.ReadBool("Resources", "UseShortDateFormat", false);
            _chkSwitchToTab.Checked        = ini.ReadBool("Search", "AutoSwitchToResults", true);
            _chkMinimizeToTray.Checked     = ini.ReadBool("Resources", "MinimizeToTray", false);
            _chkTrayIconMode.Checked       = Core.TrayIconManager.IsOutlookMode;
            _chkIdleTextIndex.Checked      = Core.TextIndexManager.IdleIndexingMode;

            if (ini.ReadBool("Resources", "LinksInNewWindow", false))
            {
                _radBrowserWindow.Checked = true;
            }
            else if (ini.ReadBool("Resources", "LinksInPreviewPane", false))
            {
                _radPreviewPane.Checked = true;
            }
            else
            {
                _radOmeaWindow.Checked = true;
            }

            _udPeriod.Value = Core.SettingStore.ReadInt("General", "BalloonTimeout", ciDefaultVisibilityInterval);

            ReadBackColor();
            ReadFontCharacteristics();
            ReadPrefixes();
        }
Exemplo n.º 6
0
        private static WebProxy LoadDefaultProxy()
        {
            WebProxy      proxy;
            ISettingStore ini       = Core.SettingStore;
            string        address   = ini.ReadString("HttpProxy", "Address");
            bool          haveProxy = false;

            if (address.Length == 0)
            {
                proxy             = WebProxy.GetDefaultProxy();
                proxy.Credentials = CredentialCache.DefaultCredentials;
                if (proxy.Address != null)
                {
                    Trace.WriteLine("Using proxy settings from IE: address " + proxy.Address +
                                    ", bypass on local addresses " + proxy.BypassProxyOnLocal);
                    haveProxy = true;
                }
                else
                {
                    Trace.WriteLine("No proxy configured in IE");
                }
            }
            else
            {
                do
                {
                    int port = ini.ReadInt("HttpProxy", "Port", 3128);
                    try
                    {
                        proxy = new WebProxy(address, port);
                    }
                    catch
                    {
                        proxy = WebProxy.GetDefaultProxy();
                    }
                    string user = ini.ReadString("HttpProxy", "User");
                    if (user.Length == 0)
                    {
                        proxy.Credentials = CredentialCache.DefaultCredentials;
                    }
                    else
                    {
                        string   password  = ini.ReadString("HttpProxy", "Password");
                        string[] userParts = user.Split('\\', '/');
                        if (userParts.Length == 2)
                        {
                            proxy.Credentials = new NetworkCredential(userParts[1], password, userParts[0]);
                        }
                        else
                        {
                            proxy.Credentials = new NetworkCredential(user, password);
                        }
                    }
                    proxy.BypassProxyOnLocal = ini.ReadBool("HttpProxy", "BypassLocal", true);

                    string bypassList = ini.ReadString("HttpProxy", "BypassList");
                    if (bypassList.Trim().Length > 0)
                    {
                        try
                        {
                            proxy.BypassList = bypassList.Split(';');
                        }
                        catch {}
                    }

                    if (proxy.Address != null)
                    {
                        Trace.WriteLine("Using proxy settings specified by user: address " + proxy.Address +
                                        ", bypass on local addresses " + proxy.BypassProxyOnLocal);
                        haveProxy = true;
                    }
                    else
                    {
                        Trace.WriteLine("No proxy configured by user");
                    }
                } while(false);
            }

            if (haveProxy)
            {
                ServicePointManager.DefaultConnectionLimit = 5;
            }

            return(proxy);
        }
Exemplo n.º 7
0
        public AnnotationForm()
        {
            Settings = Core.SettingStore;
            InitializeComponent();

            //-----------------------------------------------------------------
            int xPos   = Settings.ReadInt("Annotations", "LocationX", -1),
                yPos   = Settings.ReadInt("Annotations", "LocationY", -1);
            int width  = Settings.ReadInt("Annotations", "Width", -1),
                height = Settings.ReadInt("Annotations", "Height", -1);

            if (xPos != -1 && yPos != -1)
            {
                Location         = new Point(xPos, yPos);
                _defaultPosition = false;
            }
            else
            {
                _defaultPosition = true;
            }
            if (width != -1 && height != -1)
            {
                this.Size = new Size(width, height);
            }

            if (IsOutsideScreen(Location))
            {
                this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Right / 2,
                                          Screen.PrimaryScreen.WorkingArea.Bottom / 2);
            }

            //-----------------------------------------------------------------
            int opacity = Settings.ReadInt("Annotations", "Opacity", -1);

            if (opacity != -1)
            {
                SavedOpacity = Opacity;
                try
                {
                    Opacity = ((double)opacity) / 100.0;
                }
                catch (Exception)
                {
                    // ignore
                }
            }

            string color = Settings.ReadString("Annotations", "BackColor");

            if (!String.IsNullOrEmpty(color))
            {
                if (IsValidColor(color))
                {
                    richText.BackColor = Color.FromName(color);
                }
                else
                {
                    MessageBox.Show(this, "Color name for the Annotation background is illegal", "Illegal Color Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Settings.WriteString("Annotations", "BackColor", "Info");
                }
            }
            color = Settings.ReadString("Annotations", "ForeColor");
            if (!String.IsNullOrEmpty(color))
            {
                if (IsValidColor(color))
                {
                    richText.ForeColor = Color.FromName(color);
                }
                else
                {
                    MessageBox.Show(this, "Color name for the Annotation foreground is illegal", "Illegal Color Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Settings.WriteString("Annotations", "ForeColor", "Black");
                }
            }

            Hide();
        }
Exemplo n.º 8
0
        private void ShowExceptionDialog()
        {
            if (_exceptionDialogVisible)
            {
                return;
            }

            _exceptionDialogVisible = true;
            bool exceptionFatal = false;

            try
            {
                while (true)
                {
                    QueuedException qex = null;
                    lock ( _exceptionQueue )
                    {
                        if (_exceptionQueue.Count > 0)
                        {
                            qex = (QueuedException)_exceptionQueue.Dequeue();
                        }
                    }
                    if (qex == null)
                    {
                        break;
                    }

                    if ((qex.Flags & ExceptionReportFlags.Fatal) != 0)
                    {
                        exceptionFatal = true;
                    }

                    Exception ex = qex.Exception;
                    if (ex is AsyncProcessorException)
                    {
                        ex = ex.InnerException;
                    }
                    if (ex is TargetInvocationException)
                    {
                        ex = ex.InnerException;
                    }

                    ISettingStore ini = Core.SettingStore;
                    using (ExceptionReportForm dlg = new ExceptionReportForm())
                    {
                        ProxySettings proxySettings = new ProxySettings();
                        try
                        {
                            string address = ini.ReadString("HttpProxy", "Address");
                            proxySettings.CustomProxy = address.Length > 0;
                            if (proxySettings.CustomProxy)
                            {
                                proxySettings.Host     = address;
                                proxySettings.Port     = ini.ReadInt("HttpProxy", "Port", 3128);
                                proxySettings.Login    = ini.ReadString("HttpProxy", "User");
                                proxySettings.Password = ini.ReadString("HttpProxy", "Password");
                            }
                            dlg.SetProxy(proxySettings);
                        }
                        catch (Exception pex)
                        {
                            Trace.WriteLine("Failed to set exception reporter proxy: " + pex.ToString());
                        }
                        // Setup our submitter
                        dlg.Submitter  = new RPCExceptionSubmitter();
                        dlg.ProjectKey = "OM";
                        dlg.DisplaySubmissionResult = true;
                        string userName = ini.ReadString("ErrorReport", "UserName");
                        string password = ini.ReadString("ErrorReport", "Password");
                        if (userName.Length > 0 && password.Length > 0)
                        {
                            dlg.SetITNLogin(userName, password);
                        }
                        else
                        {
                            dlg.SetDefaultLogin("om_anonymous", "guest");
                        }

                        if ((qex.Flags & ExceptionReportFlags.AttachLog) != 0)
                        {
                            dlg.AttachLog = true;
                        }

                        dlg.SetBuildNumber(Assembly.GetExecutingAssembly().GetName().Version.Build);

                        IWin32Window ownerWindow = (_ownerControl == null || _ownerControl.IsDisposed) ? null : _ownerControl;

                        if (dlg.ReportException(ownerWindow, ex, GetExceptionDescription()) == DialogResult.OK)
                        {
                            if (dlg.ITNUserName != "om_anonymous")
                            {
                                ini.WriteString("ErrorReport", "UserName", dlg.ITNUserName);
                                ini.WriteString("ErrorReport", "Password", dlg.ITNPassword);
                            }

                            if (dlg.AttachLog)
                            {
                                LogManager.SubmitErrorLog();
                            }
                            proxySettings = dlg.ProxySettings;
                            if (!proxySettings.CustomProxy)
                            {
                                ini.WriteString("HttpProxy", "Address", string.Empty);
                            }
                            else
                            {
                                ini.WriteString("HttpProxy", "Address", proxySettings.Host);
                                ini.WriteInt("HttpProxy", "Port", proxySettings.Port);
                                ini.WriteString("HttpProxy", "User", proxySettings.Login);
                                ini.WriteString("HttpProxy", "Password", proxySettings.Password);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(null, "An exception has occured in the application, and the exception reporter failed to present it.\n\n" + ex.Message + "\n\nThe application will now be terminated.", "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                exceptionFatal = true;
            }
            _exceptionDialogVisible = false;

            if (exceptionFatal)
            {
                (Core.MainWindow as MainFrame).ForceClose();
            }
        }