Beispiel #1
0
        bool ReadSettings()
        {
            // Загрузка настроек по парам [ключ]-[значение].
            NameValueCollection allAppSettings = ConfigurationManager.AppSettings;

            if (allAppSettings.Count < 1)
            {
                return(false);
            }

            // Восстановление состояния:
            //1. Цвет фона.
            int red   = Convert.ToInt32(allAppSettings["BackGroundColor.R"]);
            int green = Convert.ToInt32(allAppSettings["BackGroundColor.G"]);
            int blue  = Convert.ToInt32(allAppSettings["BackGroundColor.B"]);

            this.BackColor = Color.FromArgb(red, green, blue);
            listBox1.Items.Add("Цвет фона: " + BackColor.Name);


            this.Height = Convert.ToInt32(allAppSettings["Window.Height"]);
            this.Width  = Convert.ToInt32(allAppSettings["Window.Width"]);
            this.Text   = new Size(Width, Height).ToString();



            //4. Состояние окна.
            string winState = allAppSettings["Window.State"];

            listBox1.Items.Add("Состояние окна: " + winState);
            this.WindowState = (FormWindowState)FormWindowState.Parse(WindowState.GetType(), winState);
            return(true);
        }
Beispiel #2
0
        //*************************************************************************************************************
        private void OnLoad(object sender, EventArgs e)
        {
            config.Load();

            string[] args = Environment.GetCommandLineArgs();
            foreach (string arg in args)
            {
                if (arg == "-crash")
                {
                    throw new Exception("Exception Test");
                }
            }

            if (config.GetValue("UI_CLOSE_TO_TRAY").ToBoolOrDefault(false) ||
                config.GetValue("UI_MINIMIZE_TO_TRAY").ToBoolOrDefault(false))
            {
                appTrayIcon.Visible = true;
            }

            Toolbar_Updates.Image = null;

            myImageList.ColorDepth = ColorDepth.Depth32Bit;
            myImageList.Images.Add("folder", Resources.folder);
            myImageList.Images.Add("rdp", Resources.rdp);
            myImageList.Images.Add("vnc", Resources.vnc);
            myImageList.Images.Add("ftp", Resources.ftp);
            myImageList.Images.Add("ssh", Resources.ssh);
            myImageList.Images.Add("ie", Resources.IE);
            myImageList.Images.Add("sql", Resources.database);
            myImageList.Images.Add("sftp", Resources.sftp);
            myImageList.Images.Add("s3", Resources.s3);
            myImageList.Images.Add("azure", Resources.azure);
            ServerTabs.ImageList = myImageList;

            Visible     = false;
            WindowState = (FormWindowState)FormWindowState.Parse(WindowState.GetType(),
                                                                 config.GetValue("MainFormState", "Normal"));
            int       X        = config.GetValue("MainFormLocationX").ToIntOrDefault(50);
            int       Y        = config.GetValue("MainFormLocationY").ToIntOrDefault(50);
            int       W        = config.GetValue("MainFormLocationW").ToIntOrDefault(700);
            int       H        = config.GetValue("MainFormLocationH").ToIntOrDefault(600);
            Rectangle position = new Rectangle(X, Y, W, H);
            Rectangle screen   = SystemInformation.VirtualScreen;

            screen.Inflate(20, 20);
            if (screen.Contains(position))
            {
                Location = position.Location;
                Size     = position.Size;
            }
            Visible = true;

            timerClose.Interval    = 100;
            timerClose.Tick       += new System.EventHandler(this.timerClose_Tick);
            timerCloseTab.Interval = 100;
            timerCloseTab.Tick    += new System.EventHandler(this.timerCloseTab_Tick);

            LoadFavorites();
            resized = false;
        }
Beispiel #3
0
        //*************************************************************************************************************
        private void resetPositionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WindowState = (FormWindowState)FormWindowState.Parse(WindowState.GetType(),
                                                                 config.GetValue("MainFormState", "Normal"));
            Rectangle screen = SystemInformation.VirtualScreen;

            screen.Inflate(-200, -100);
            Location = screen.Location;
            Size     = screen.Size;
            Show();
        }
Beispiel #4
0
        bool ReadSettings()
        {
            RegistryKey softwareKey =
                Registry.LocalMachine.OpenSubKey("Software");
            RegistryKey wroxKey = softwareKey.OpenSubKey("WroxPress");

            if (wroxKey == null)
            {
                return(false);
            }
            RegistryKey selfPlacingWindowKey =
                wroxKey.OpenSubKey("SelfPlacingWindow");

            if (selfPlacingWindowKey == null)
            {
                return(false);
            }
            else
            {
                listBoxMessages.Items.Add("Successfully opened key " +
                                          selfPlacingWindowKey.ToString());
            }
            int redComponent   = (int)selfPlacingWindowKey.GetValue("Red");
            int greenComponent = (int)selfPlacingWindowKey.GetValue("Green");
            int blueComponent  = (int)selfPlacingWindowKey.GetValue("Blue");

            this.BackColor = Color.FromArgb(redComponent, greenComponent,
                                            blueComponent);
            listBoxMessages.Items.Add("Background color: " + BackColor.Name);
            int X = (int)selfPlacingWindowKey.GetValue("X");
            int Y = (int)selfPlacingWindowKey.GetValue("Y");

            this.DesktopLocation = new Point(X, Y);
            listBoxMessages.Items.Add("Desktop location: " +
                                      DesktopLocation.ToString());
            this.Height = (int)selfPlacingWindowKey.GetValue("Height");
            this.Width  = (int)selfPlacingWindowKey.GetValue("Width");
            listBoxMessages.Items.Add("Size: " + new
                                      Size(Width, Height).ToString());
            string initialWindowState =
                (string)selfPlacingWindowKey.GetValue("WindowState");

            listBoxMessages.Items.Add("Window State: " + initialWindowState);
            this.WindowState = (FormWindowState)FormWindowState.Parse
                                   (WindowState.GetType(), initialWindowState);
            return(true);
        }
Beispiel #5
0
        bool ReadSettings()
        {
            // Загрузка настроек по парам [ключ]-[значение].
            NameValueCollection allAppSettings = ConfigurationManager.AppSettings;

            if (allAppSettings.Count < 1)
            {
                return(false);
            }

            // Восстановление состояния:
            //1. Цвет фона.
            int red   = Convert.ToInt32(allAppSettings["BackGroundColor.R"]);
            int green = Convert.ToInt32(allAppSettings["BackGroundColor.G"]);
            int blue  = Convert.ToInt32(allAppSettings["BackGroundColor.B"]);

            //2. Цвет текста
            int redText   = Convert.ToInt32(allAppSettings["TextColor.R"]);
            int greedText = Convert.ToInt32(allAppSettings["TextColor.G"]);
            int blueText  = Convert.ToInt32(allAppSettings["TextColor.B"]);

            string    fontName  = Convert.ToString(allAppSettings["TextStyleFont.Name"]);
            float     textSize  = Convert.ToSingle(allAppSettings["TextStyleFont.Size"]);
            FontStyle fontstyle = GetStyleType();

            // определение стиля
            FontStyle GetStyleType()
            {
                if (allAppSettings["TextStyleFont.Style"] == "Bold")
                {
                    return(FontStyle.Bold);
                }
                else if (allAppSettings["TextStyleFont.Style"] == "Italic")
                {
                    return(FontStyle.Italic);
                }
                else if (allAppSettings["TextStyleFont.Style"] == "Regular")
                {
                    return(FontStyle.Regular);
                }
                else if (allAppSettings["TextStyleFont.Style"] == "Strikeout")
                {
                    return(FontStyle.Strikeout);
                }
                else
                {
                    return(FontStyle.Regular);
                }
            }

            // установка
            this.BackColor   = Color.FromArgb(red, green, blue);
            label1.ForeColor = Color.FromArgb(redText, greedText, blueText);
            label1.Font      = new Font(fontName, textSize, fontstyle);



            //4. Состояние окна.
            string winState = allAppSettings["Window.State"];

            this.WindowState = (FormWindowState)FormWindowState.Parse(WindowState.GetType(), winState);
            return(true);
        }