Esempio n. 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);
        }
Esempio n. 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;
        }
Esempio n. 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();
        }
Esempio n. 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);
        }
Esempio n. 5
0
        private bool ReadSettings()
        {
            RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software");

            if (softwareKey == null)
            {
                return(false);
            }

            RegistryKey wroxKey = softwareKey.OpenSubKey("WroxPress");

            if (wroxKey == null)
            {
                return(false);
            }

            RegistryKey selfPlacingWindowKey = wroxKey.OpenSubKey("SelfPlacingWindow");

            if (selfPlacingWindowKey == null)
            {
                return(false);
            }

            listBoxMessages.Items.Add(string.Format("Successfully opened key {0}", selfPlacingWindowKey));

            var redComponent   = (int)selfPlacingWindowKey.GetValue("Red");
            var greenComponent = (int)selfPlacingWindowKey.GetValue("Green");
            var blueComponent  = (int)selfPlacingWindowKey.GetValue("Blue");

            BackColor = Color.FromArgb(redComponent, greenComponent, blueComponent);
            listBoxMessages.Items.Add(string.Format("Background color: {0}", BackColor.Name));
            var x = (int)selfPlacingWindowKey.GetValue("X");
            var y = (int)selfPlacingWindowKey.GetValue("Y");

            DesktopLocation = new Point(x, y);
            listBoxMessages.Items.Add(string.Format("Desktop location: {0}", DesktopLocation));
            Height = (int)selfPlacingWindowKey.GetValue("Height");
            Width  = (int)selfPlacingWindowKey.GetValue("Width");
            listBoxMessages.Items.Add(string.Format("Size: {0}", new Size(Width, Height)));
            var initialWindowState = (string)selfPlacingWindowKey.GetValue("WindowState");

            listBoxMessages.Items.Add(string.Format("Window State: {0}", initialWindowState));
            WindowState = (FormWindowState)Enum.Parse(WindowState.GetType(), initialWindowState);

            return(true);
        }
Esempio n. 6
0
        private bool ReadSettings()
        {
            var storageFile = IsolatedStorageFile.GetUserStoreForDomain();
            var userFiles   = storageFile.GetFileNames(SelfplacingwindowXml);

            foreach (var userFile in userFiles.Where(file => file == SelfplacingwindowXml))
            {
                listBoxMessages.Items.Add(string.Format("Successfully opened file {0}", userFile));
                var storageStream = new StreamReader(
                    new IsolatedStorageFileStream(SelfplacingwindowXml, FileMode.Open, storageFile));
                var reader         = new XmlTextReader(storageStream);
                int redComponent   = 0;
                int greenComponent = 0;
                int blueComponent  = 0;
                int x = 0;
                int y = 0;
                while (reader.Read())
                {
                    switch (reader.Name)
                    {
                    case "Red":
                        redComponent = int.Parse(reader.ReadString());
                        break;

                    case "Green":
                        greenComponent = int.Parse(reader.ReadString());
                        break;

                    case "Blue":
                        blueComponent = int.Parse(reader.ReadString());
                        break;

                    case "X":
                        x = int.Parse(reader.ReadString());
                        break;

                    case "Y":
                        y = int.Parse(reader.ReadString());
                        break;

                    case "Width":
                        Width = int.Parse(reader.ReadString());
                        break;

                    case "Height":
                        Height = int.Parse(reader.ReadString());
                        break;

                    case "WindowState":
                        WindowState = (FormWindowState)Enum.Parse(WindowState.GetType(), reader.ReadString());
                        break;
                    }
                }

                BackColor       = Color.FromArgb(redComponent, greenComponent, blueComponent);
                DesktopLocation = new Point(x, y);
                listBoxMessages.Items.Add(string.Format("Background color: {0}", BackColor.Name));
                listBoxMessages.Items.Add(string.Format("Desktop location: {0}", DesktopLocation));
                listBoxMessages.Items.Add(string.Format("Size: {0}", new Size(Width, Height).ToString()));
                listBoxMessages.Items.Add(string.Format("Window State: {0}", WindowState));

                storageStream.Close();
                storageFile.Close();
            }

            return(true);
        }
Esempio n. 7
0
 private void Window_Closed(object sender, EventArgs e)
 {
     StaticEntity.AppConfigurationSettings.Save(_Width, this.Width.ToString());
     StaticEntity.AppConfigurationSettings.Save(_Height, this.Height.ToString());
     StaticEntity.AppConfigurationSettings.Save(WindowState.GetType().ToString(), this.WindowState.ToString());
 }
Esempio n. 8
0
        public MainWindow()
        {
            try
            {
                StaticEntity.AppConfigurationSettings = new AppConfiguration("WinDeployQT-GUI.Settings");
                this.Width       = Convert.ToDouble(StaticEntity.AppConfigurationSettings.LoadSettings(_Width));
                this.Height      = Convert.ToDouble(StaticEntity.AppConfigurationSettings.LoadSettings(_Height));
                this.WindowState = (WindowState)Enum.Parse(typeof(WindowState), StaticEntity.AppConfigurationSettings.LoadSettings(WindowState.GetType().ToString()));
            }
            catch { }
            InitializeComponent();
            ViewModel viewModel = new ViewModel();

            DataContext = viewModel;
        }
Esempio n. 9
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);
        }