Пример #1
0
 /*Gлучаем заголовок, содержимое и тип вызываемой формы*/
 public DialogForm(String header, String text, Global.DialogTypes dialog)
 {
     InitializeComponent();
     this.Size          = new Size(260, 150);
     this.Text          = header;
     message            = new DBLabel(text);
     editText           = text;
     this.dialogType    = dialog;
     this.Width         = 260;
     this.Height        = 150;
     this.StartPosition = FormStartPosition.CenterScreen;
 }
Пример #2
0
        /*Загрузка формы*/
        private void WaitConnectionForm_Load(object sender, EventArgs e)
        {
            int marginCoef = 10;

            this.Height = 200;
            /*Генерируем случайный пароль*/
            Global.securityCode = GetRandomCode(8);
            /*Инициализируем экранную переменную*/
            Global.screenActions = new ScreenActions();
            /*Инициализируем медиа-переменную*/
            Global.mediaData = new MediaData();
            #region Контролы
            /*Label'ы*/
            DBLabel nameLabel = new DBLabel("Имя пользователя:");
            DBLabel ipLabel   = new DBLabel("Текущий адрес:");
            DBLabel passLabel = new DBLabel("Пароль:");
            username           = new DBCopyTextBox(Global.username.ToString());
            address            = new DBCopyTextBox(String.Format(Global.externalIP + ":{0}", Global.receivePort));
            pass               = new DBCopyTextBox(Global.securityCode);
            nameLabel.Location = new Point(marginCoef, marginCoef * 2);
            ipLabel.Location   = new Point(marginCoef, nameLabel.Location.Y + nameLabel.Height + marginCoef);
            passLabel.Location = new Point(marginCoef, ipLabel.Location.Y + ipLabel.Height + marginCoef);
            username.Location  = new Point(nameLabel.Width + marginCoef, nameLabel.Location.Y);
            address.Location   = new Point(ipLabel.Width + marginCoef, ipLabel.Location.Y);
            pass.Location      = new Point(passLabel.Width + marginCoef, passLabel.Location.Y);
            WorkingArea.Controls.Add(nameLabel);
            WorkingArea.Controls.Add(ipLabel);
            WorkingArea.Controls.Add(passLabel);
            WorkingArea.Controls.Add(username);
            WorkingArea.Controls.Add(address);
            WorkingArea.Controls.Add(pass);
            /*Кнопки редактирования*/
            changeUsernameButton          = new DBIconButton(Properties.Resources.edit_icon);
            changeUsernameButton.Location = new Point(username.Location.X + username.Width, username.Location.Y);
            changePortButton           = new DBIconButton(Properties.Resources.edit_icon);
            changePortButton.Location  = new Point(address.Location.X + address.Width, address.Location.Y);
            refreshPassButton          = new DBIconButton(Properties.Resources.refresh_icon);
            refreshPassButton.Location = new Point(pass.Location.X + pass.Width, pass.Location.Y);
            /*По нажатию на кнопку вызываем диалог изменения свойства*/
            changeUsernameButton.Click += ((o, ev) =>
            {
                DialogResult result = new DialogResult();
                string editField = DialogForm.Show("Имя пользователя", Global.username, Global.DialogTypes.edit, out result);
                if (result == DialogResult.OK)
                {
                    Global.username = editField;
                }
                username.Text = Global.username;
                changeUsernameButton.Location = new Point(username.Location.X + username.Width, username.Location.Y);
            });
            changePortButton.Click += ((o, ev) =>
            {
                DialogResult result = new DialogResult();
                string editField = DialogForm.Show("Порт", Global.username, Global.DialogTypes.edit, out result);
                if (result == DialogResult.OK)
                {
                    Global.receivePort = Convert.ToInt32(editField);
                    address.Text = String.Format(Global.externalIP + ":{0}", Global.receivePort);
                    changePortButton.Location = new Point(address.Location.X + address.Width, address.Location.Y);
                    Global.connection = new RemoteConnection();
                }
            });
            /*По нажатию на кнопку обновляем пароль*/
            refreshPassButton.MouseClick += RefreshPassButton_MouseClick;
            WorkingArea.Controls.Add(changeUsernameButton);
            WorkingArea.Controls.Add(changePortButton);
            WorkingArea.Controls.Add(refreshPassButton);
            #endregion
            server            = new MainServerForm();
            server.properties = this;
            /*Инициализируем сетевую переменную*/
            Global.connection = new RemoteConnection();
            /*Заводим таймер на отслеживание подключения*/
            Timer connectionMonitor = new Timer();
            connectionMonitor.Interval = 100;
            connectionMonitor.Tick    += ((o, ev) =>
            {
                if (Global.connection.Connected)
                {
                    server.Show();
                    connectionMonitor.Stop();
                }
                else
                {
                    server.Hide();
                }
            });
            connectionMonitor.Start();
        }
Пример #3
0
 /*Настраиваем label*/
 private void SetMessageBounds(DBLabel mess)
 {
     mess.Location = new Point(10, WorkingArea.Height / 2 - mess.Height);
 }