Example #1
0
        public OptionEditor(IHostingForm parent)
        {
            this.ApplySystemFont();

            this.InitializeComponent();

            // Dynamically added option panels.
            List <Type> types = ConnectionManager.GetOptionDialogTypes();

            foreach (Type type in types)
            {
                OptionPanel panel = null;
                try
                {
                    panel = (OptionPanel)Activator.CreateInstance(type);
                }
                catch (Exception ex)
                {
                    Log.Debug("ERROR ceating option panel! Type name: " + type.Name, ex);
                    continue;
                }

                panel.Location = new System.Drawing.Point(6, 26);
                panel.Tag      = panel.Name;
                panel.Size     = new System.Drawing.Size(512, 328);
                panel.TabIndex = 0;

                TreeNode treeNode11 = new TreeNode(panel.Text);
                treeNode11.Text = panel.Text;
                treeNode11.Tag  = panel.Tag;
                this.OptionsTreeView.Nodes["Connections"].Nodes.Add(treeNode11);

                TabPage page = new TabPage(panel.Text);
                page.AutoScroll = true;
                page.Controls.Add(panel);
                page.Padding  = new System.Windows.Forms.Padding(3);
                page.Dock     = DockStyle.Fill;
                page.AutoSize = true;
                page.TabIndex = 0;
                page.Text     = panel.Text;
                page.UseVisualStyleBackColor = true;

                this.tabCtrlOptionPanels.Controls.Add(page);
            }

            this.MovePanelsFromTabsIntoControls();
            Settings.ConfigurationChanged += this.SettingsConfigFileReloaded;
            this.LoadSettings();

            this.SetFormSize();

            IOptionPanel[] optionPanels = this.FindOptionPanels().ToArray <IOptionPanel>();

            foreach (IOptionPanel optionPanel in optionPanels)
            {
                optionPanel.IHostingForm = parent;
            }

            this.UpdateLookAndFeel();
        }
Example #2
0
        public RasProperties(IHostingForm parentForm, RASConnection rasConnection)
        {
            this.RasConnection = rasConnection;
            this.ParentForm    = parentForm;
            this.InitializeComponent();

            if (parentForm.InvokeRequired)
            {
                parentForm.Invoke(new MethodInvoker(delegate
                {
                    this.timer = new Timer {
                        Interval = 2000
                    };
                    this.timer.Tick += this.timer_Tick;
                    this.timer.Start();
                }));
            }
            else
            {
                this.timer = new Timer {
                    Interval = 2000
                };
                this.timer.Tick += this.timer_Tick;
                this.timer.Start();
            }
        }
Example #3
0
        /// <summary>
        ///     Creates a new connection by spawning a new thread.
        /// </summary>
        /// <param name="favorite"> </param>
        /// <param name="TerminalTabPage"> </param>
        /// <param name="parentForm"> </param>
        /// <remarks>
        ///     This method calls the <see cref="ConnectionBase.Connect" /> method and requires it to be thread safe.
        /// </remarks>
        public static void CreateConnection(FavoriteConfigurationElement favorite, IHostingForm parentForm, bool waitforEnd, TerminalTabControlItem terminalTabPage, ConnectionBase conn = null)
        {
            // This might happen if the user is not allowed to
            // use all available connections e.g.
            // if the user has a freeware version.
            if (Limit.Contains(favorite.Protocol.ToUpper()) || terminalTabPage == null)
            {
                MessageBox.Show("You are not allowed to use that kind of connection!", AssemblyInfo.Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!waitforEnd)
            {
                Thread t = new Thread((ThreadStart) delegate
                {
                    Code(terminalTabPage, parentForm, favorite, conn);
                });

                t.SetApartmentState(ApartmentState.STA);
                t.Start();
            }
            else
            {
                Code(terminalTabPage, parentForm, favorite, conn);
            }
        }
Example #4
0
        public static PopupTerminal CreateConnectionInPopup(IHostingForm parentForm, FavoriteConfigurationElement favorite)
        {
            TerminalTabControlItem item = CreateTerminalTabPageByFavoriteName(favorite);

            CreateConnection(favorite, parentForm, false, item);
            PopupTerminal popup = new PopupTerminal();

            popup.AddTerminal(item);
            return(popup);
        }
Example #5
0
        public static PopupTerminal CreateConnectionInPopup(IHostingForm parentForm, string protocol, string name, string url = null, string server = null)
        {
            if (url == null && server == null)
            {
                throw new Exception("Either the url or the server must be set.");
            }

            return(CreateConnectionInPopup(parentForm, new FavoriteConfigurationElement
            {
                Protocol = protocol,
                Url = url,
                ServerName = server,
                Name = name
            }));
        }
Example #6
0
        public RasProperties(IHostingForm parentForm, RASConnection rasConnection)
        {
            this.RasConnection = rasConnection;
            this.ParentForm = parentForm;
            this.InitializeComponent();

            if (parentForm.InvokeRequired)
                parentForm.Invoke(new MethodInvoker(delegate
                {
                    this.timer = new Timer { Interval = 2000 };
                    this.timer.Tick += this.timer_Tick;
                    this.timer.Start();
                }));
            else
            {
                this.timer = new Timer { Interval = 2000 };
                this.timer.Tick += this.timer_Tick;
                this.timer.Start();
            }
        }
Example #7
0
 public TerminalTabsSelectionControler(IHostingForm mainForm, TabControl tabControl)
 {
     this.mainTabControl = tabControl;
     this.mainForm       = mainForm;
     FavoritesDataDispatcher.Instance.FavoritesChanged += this.OnFavoritesChanged;
 }
        private static void Code(TerminalTabControlItem terminalTabPage, IHostingForm parentForm, FavoriteConfigurationElement favorite, ConnectionBase conn = null)
        {
            if (conn == null)
            {
                conn = CreateConnection(favorite);
                conn.TerminalTabPage = terminalTabPage;
                terminalTabPage.TabColor = FavoriteConfigurationElement.TranslateColor(favorite.TabColor);
                terminalTabPage.Connection = conn;
            }

            conn.Favorite = favorite;
            conn.ParentForm = parentForm;

            if (conn.Connect())
            {
                if (conn.InvokeRequired)
                    conn.Invoke(new MethodInvoker(delegate
                    {
                        conn.BringToFront();
                        conn.Update();
                    }));
                else
                {
                    conn.BringToFront();
                    conn.Update();
                }
                
                if (parentForm.InvokeRequired)
                    parentForm.Invoke(new MethodInvoker(delegate
                    {
                        parentForm.UpdateControls();

                        if (favorite.DesktopSize == DesktopSize.FullScreen)
                            parentForm.FullScreen = true;
                    }));
                else
                {
                    parentForm.UpdateControls();

                    if (favorite.DesktopSize == DesktopSize.FullScreen)
                        parentForm.FullScreen = true;
                }

                conn.AfterConnectPlugins();
            }
            else
            {
            	string message = "Sorry, " + AssemblyInfo.Title + " was unable to create the connection. Try again or check the log for more information.";

                Log.Error(message);
                MessageBox.Show(message, AssemblyInfo.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);

                if (parentForm.InvokeRequired)
                    parentForm.Invoke(new MethodInvoker(delegate { parentForm.RemoveAndUnSelect(terminalTabPage); }));
                else
                    parentForm.RemoveAndUnSelect(terminalTabPage);
            }

            if (conn.Connected && favorite.NewWindow)
            {
                if (parentForm.InvokeRequired)
                    parentForm.Invoke(new MethodInvoker(delegate { parentForm.DetachTabToNewWindow(terminalTabPage); }));
                else
                    parentForm.DetachTabToNewWindow(terminalTabPage);
            }
        }
        /// <summary>
        ///     Creates a new connection by spawning a new thread.
        /// </summary>
        /// <param name="favorite"> </param>
        /// <param name="TerminalTabPage"> </param>
        /// <param name="parentForm"> </param>
        /// <remarks>
        ///     This method calls the <see cref="ConnectionBase.Connect" /> method and requires it to be thread safe.
        /// </remarks>
        public static void CreateConnection(FavoriteConfigurationElement favorite, IHostingForm parentForm, bool waitforEnd, TerminalTabControlItem terminalTabPage, ConnectionBase conn = null)
        {
            // This might happen if the user is not allowed to
            // use all available connections e.g. 
            // if the user has a freeware version.
            if (Limit.Contains(favorite.Protocol.ToUpper()) || terminalTabPage == null)
            {
                MessageBox.Show("You are not allowed to use that kind of connection! Please upgrade your license.", AssemblyInfo.Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            
            if (!waitforEnd)
            {
               Thread t = new Thread((ThreadStart)delegate
                                                    {
                                                        Code(terminalTabPage, parentForm, favorite, conn);
                                                    });

                t.SetApartmentState(ApartmentState.STA);
                t.Start();
            }
            else
            {
                Code(terminalTabPage, parentForm, favorite, conn);
            }
        }
Example #10
0
 public static PopupTerminal CreateConnectionInPopup(IHostingForm parentForm, FavoriteConfigurationElement favorite)
 {
     TerminalTabControlItem item = CreateTerminalTabPageByFavoriteName(favorite);
     CreateConnection(favorite, parentForm, false, item);
     PopupTerminal popup = new PopupTerminal();
     popup.AddTerminal(item);
     return popup;
 }
Example #11
0
        public static PopupTerminal CreateConnectionInPopup(IHostingForm parentForm, string protocol, string name, string url = null, string server = null)
        {
            if (url == null && server == null)
                throw new Exception("Either the url or the server must be set.");

            return CreateConnectionInPopup(parentForm, new FavoriteConfigurationElement
                                                           {
                                                               Protocol = protocol,
                                                               Url = url,
                                                               ServerName = server,
                                                               Name = name
                                                           });
        }
Example #12
0
        private static void Code(TerminalTabControlItem terminalTabPage, IHostingForm parentForm, FavoriteConfigurationElement favorite, ConnectionBase conn = null)
        {
            if (conn == null)
            {
                conn = CreateConnection(favorite);
                conn.TerminalTabPage       = terminalTabPage;
                terminalTabPage.TabColor   = FavoriteConfigurationElement.TranslateColor(favorite.TabColor);
                terminalTabPage.Connection = conn;
            }

            conn.Favorite   = favorite;
            conn.ParentForm = parentForm;

            if (conn.Connect())
            {
                if (conn.InvokeRequired)
                {
                    conn.Invoke(new MethodInvoker(delegate
                    {
                        conn.BringToFront();
                        conn.Update();
                    }));
                }
                else
                {
                    conn.BringToFront();
                    conn.Update();
                }

                if (parentForm.InvokeRequired)
                {
                    parentForm.Invoke(new MethodInvoker(delegate
                    {
                        parentForm.UpdateControls();

                        if (favorite.DesktopSize == DesktopSize.FullScreen)
                        {
                            parentForm.FullScreen = true;
                        }
                    }));
                }
                else
                {
                    parentForm.UpdateControls();

                    if (favorite.DesktopSize == DesktopSize.FullScreen)
                    {
                        parentForm.FullScreen = true;
                    }
                }

                conn.AfterConnectPlugins();
            }
            else
            {
                string message = "Sorry, " + AssemblyInfo.Title + " was unable to create the connection. Try again or check the log for more information.";

                Log.Error(message);
                MessageBox.Show(message, AssemblyInfo.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);

                if (parentForm.InvokeRequired)
                {
                    parentForm.Invoke(new MethodInvoker(delegate { parentForm.RemoveAndUnSelect(terminalTabPage); }));
                }
                else
                {
                    parentForm.RemoveAndUnSelect(terminalTabPage);
                }
            }

            if (conn.Connected && favorite.NewWindow)
            {
                if (parentForm.InvokeRequired)
                {
                    parentForm.Invoke(new MethodInvoker(delegate { parentForm.DetachTabToNewWindow(terminalTabPage); }));
                }
                else
                {
                    parentForm.DetachTabToNewWindow(terminalTabPage);
                }
            }
        }
Example #13
0
        public OptionEditor(IHostingForm parent)
        {
            this.ApplySystemFont();

            this.InitializeComponent();

            // Dynamically added option panels.
            List<Type> types = ConnectionManager.GetOptionDialogTypes();

            foreach (Type type in types)
            {
                OptionPanel panel = null;
                try
                {
                    panel = (OptionPanel)Activator.CreateInstance(type);
                }
                catch (Exception ex)
                {
                    Log.Debug("ERROR ceating option panel! Type name: " + type.Name, ex);
                    continue;
                }

                panel.Location = new System.Drawing.Point(6, 26);
                panel.Tag = panel.Name;
                panel.Size = new System.Drawing.Size(512, 328);
                panel.TabIndex = 0;

                TreeNode treeNode11 = new TreeNode(panel.Text);
                treeNode11.Text = panel.Text;
                treeNode11.Tag = panel.Tag;
                this.OptionsTreeView.Nodes["Connections"].Nodes.Add(treeNode11);

                TabPage page = new TabPage(panel.Text);
                page.AutoScroll = true;
                page.Controls.Add(panel);
                page.Padding = new System.Windows.Forms.Padding(3);
                page.Dock = DockStyle.Fill;
                page.AutoSize = true;
                page.TabIndex = 0;
                page.Text = panel.Text;
                page.UseVisualStyleBackColor = true;

                this.tabCtrlOptionPanels.Controls.Add(page);
            }
            
            this.MovePanelsFromTabsIntoControls();
            Settings.ConfigurationChanged += this.SettingsConfigFileReloaded;
            this.LoadSettings();

            this.SetFormSize();

            IOptionPanel[] optionPanels = this.FindOptionPanels().ToArray<IOptionPanel>();

            foreach (IOptionPanel optionPanel in optionPanels)
            {
                optionPanel.IHostingForm = parent;
            }

            this.UpdateLookAndFeel();

            
        }
 public TerminalTabsSelectionControler(IHostingForm mainForm, TabControl tabControl)
 {
     this.mainTabControl = tabControl;
     this.mainForm = mainForm;
     FavoritesDataDispatcher.Instance.FavoritesChanged += this.OnFavoritesChanged;
 }