Ejemplo n.º 1
0
        private void ConnectBtn_Click(object sender, EventArgs e)
        {
            ConsoleTabPage tab = ConsoleTabPage.Clone(RCON, IPTextBox.Text);

            Tabs.TabPages.Add(tab);
            Tabs.SelectedIndex = Tabs.TabCount - 1;
            tab.Output.AppendText(AnsiOutput.cls());
            int x = Int32.Parse(PortTextBox.Text);

            if (!tab.RCONClient.setupStream(IPTextBox.Text, x, PasswordTextBox.Text, OtherRCON.RCONColorMode.ANSI))
            {
                tab.Output.AppendText(AnsiOutput.red("Error connecting.") + " IP settings incorrect?\n");
                return;
            }
            string answer = tab.RCONClient.sendMessage(OtherRCON.RCONMessageType.Command, "echo RCON Connection Established");

            if (String.IsNullOrEmpty(answer))
            {
                tab.Output.AppendText(AnsiOutput.red("Error connecting.") + " Password incorrect?\n");
                return;
            }
            string answer2 = tab.RCONClient.sendMessage(OtherRCON.RCONMessageType.Command, "list");

            tab.Output.AppendText(answer);
            tab.Output.AppendText(answer2);
            Properties.Settings.Default.HasConnected = true;
            Properties.Settings.Default.FirstTime    = false;
            Properties.Settings.Default.IP           = IPTextBox.Text;
            Properties.Settings.Default.Port         = PortTextBox.Text;
            Properties.Settings.Default.Password     = PasswordTextBox.Text;
            Properties.Settings.Default.Save();
        }
Ejemplo n.º 2
0
        private void Tabs_SelectedIndexChanged(object sender, EventArgs e)
        {
            ConsoleTabPage tab = Tabs.SelectedTab as ConsoleTabPage;

            if (null != tab)
            {
                tab.CMDInput.Focus();
            }
        }
Ejemplo n.º 3
0
        public static ConsoleTabPage Clone(TabPage rCON, string name)
        {
            ConsoleTabPage tab = (ConsoleTabPage)ControlFactory.CloneCtrl(rCON);

            tab.Text              = name + "        ";
            tab.SendBTN.Click    += new System.EventHandler(tab.SendBTN_Click);
            tab.CMDInput.KeyDown += new KeyEventHandler(tab.CMDInput_KeyDown);
            return(tab);
        }
Ejemplo n.º 4
0
        public static Control CreateControl(string ctrlName, string partialName)
        {
            try
            {
                Control ctrl;
                switch (ctrlName)
                {
                case "Label":
                    ctrl = new Label();
                    break;

                case "TextBox":
                    ctrl = new TextBox();
                    break;

                case "PictureBox":
                    ctrl = new PictureBox();
                    break;

                case "ListView":
                    ctrl = new ListView();
                    break;

                case "ComboBox":
                    ctrl = new ComboBox();
                    break;

                case "Button":
                    ctrl = new Button();
                    break;

                case "CheckBox":
                    ctrl = new CheckBox();
                    break;

                case "MonthCalender":
                    ctrl = new MonthCalendar();
                    break;

                case "DateTimePicker":
                    ctrl = new DateTimePicker();
                    break;

                case "TabPage":
                    ctrl = new ConsoleTabPage();
                    break;

                case "AnsiTextBox":
                    ctrl = new ChimitAnsi.AnsiTextBox();
                    break;

                default:
                    Assembly controlAsm  = Assembly.LoadWithPartialName(partialName);
                    Type     controlType = controlAsm.GetType(partialName + "." + ctrlName);
                    ctrl = (Control)Activator.CreateInstance(controlType);
                    break;
                }
                return(ctrl);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("create control failed:" + ex.Message);
                return(new Control());
            }
        }