Exemplo n.º 1
0
        /// <summary>
        /// Opens an <see cref="OptionsWindow"/> instance when the user clicks on the "Options" menu item from a <see cref="ConnectionWindow"/>.
        /// </summary>
        public void OpenOptions()
        {
            TitleBarTab tab = Tabs.FirstOrDefault(t => t.Content is OptionsWindow);

            // Focus on the options tab if a window is already open
            if (tab != null)
            {
                SelectedTab = tab;
                return;
            }

            _previousEncryptionType = Options.EncryptionType ?? EncryptionType.Rijndael;

            // Create the options window and then add entries for each protocol type to the window
            OptionsWindow       optionsWindow       = new OptionsWindow(this);
            GlobalOptionsWindow globalOptionsWindow = new GlobalOptionsWindow();

            globalOptionsWindow.Closed += globalOptionsWindow_Closed;
            optionsWindow.OptionsForms.Add(globalOptionsWindow);

            foreach (IProtocol protocol in ConnectionFactory.GetProtocols())
            {
                Form optionsForm = protocol.GetOptionsFormInDefaultsMode();

                optionsForm.Closed += (sender, args) => ConnectionFactory.SetDefaults(((IOptionsForm)optionsForm).Connection);
                optionsWindow.OptionsForms.Add(optionsForm);
            }

            ShowInEmptyTab(optionsWindow);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Opens an <see cref="OptionsWindow"/> instance when the user clicks on the "Options" menu item from a <see cref="ConnectionWindow"/>.
        /// </summary>
        public void OpenOptions()
        {
            TitleBarTab tab = Tabs.FirstOrDefault(t => t.Content is OptionsWindow);

            // Focus on the options tab if a window is already open
            if (tab != null)
            {
                SelectedTab = tab;
                return;
            }

            _previousEncryptionType = Options.EncryptionType ?? EncryptionType.Rijndael;

            // Create the options window and then add entries for each protocol type to the window
            OptionsWindow optionsWindow = new OptionsWindow(this);
            GlobalOptionsWindow globalOptionsWindow = new GlobalOptionsWindow();

            globalOptionsWindow.Closed += globalOptionsWindow_Closed;
            optionsWindow.OptionsForms.Add(globalOptionsWindow);

            foreach (IProtocol protocol in ConnectionFactory.GetProtocols())
            {
                Form optionsForm = protocol.GetOptionsFormInDefaultsMode();

                optionsForm.Closed += (sender, args) => ConnectionFactory.SetDefaults(((IOptionsForm) optionsForm).Connection);
                optionsWindow.OptionsForms.Add(optionsForm);
            }

            ShowInEmptyTab(optionsWindow);
        }