示例#1
0
        private void SetApplicationsParametrs(CAppParams appParams)
        {
            Point newLocation;

            System.Drawing.Size newSize;
            GetSizeAndLocation(appParams.WindowSize, appParams.WindowLocation, out newSize, out newLocation);

            this.Size     = newSize;
            this.Location = newLocation;
            if (appParams.IsMaximized)
            {
                this.WindowState = FormWindowState.Maximized;
            }
            else
            {
                this.WindowState = FormWindowState.Normal;
            }
            currentPictureBackgroundColor = appParams.PictureBackgroundColor;
            lColor1.BackColor             = appParams.Colors[0];
            lColor2.BackColor             = appParams.Colors[1];
            lColor3.BackColor             = appParams.Colors[2];
            lColor4.BackColor             = appParams.Colors[3];
            lColor5.BackColor             = appParams.Colors[4];
            lColor6.BackColor             = appParams.Colors[5];
            lColor7.BackColor             = appParams.Colors[6];
            lColor8.BackColor             = appParams.Colors[7];
            lColor9.BackColor             = appParams.Colors[8];
            lColor10.BackColor            = appParams.Colors[9];

            if (picture != null)
            {
                picture.BackgroundColor = currentPictureBackgroundColor;
            }
        }
示例#2
0
        public bool SaveApplicationParametrsToFile(string path, CAppParams appParams)
        {
            try
            {
                MakeXMLfile(path);
                XmlDocument document = new XmlDocument();
                document.Load(path);

                ResetTreeInfo();
                MakeStackWithSavingParams(appParams);
                string[] children = xmlTree[FIRST_TREE_LEVEL_NUM][0];
                XmlNode  childNode;
                for (int i = 0; i < children.Length; i++)
                {
                    childNode = GetTreeNode(children[i], FIRST_TREE_LEVEL_NUM, document);
                    document.DocumentElement.AppendChild(childNode);
                }

                document.Save(path);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#3
0
        private CAppParams GetLoadedParams()
        {
            if (CAppParams.ParamsAmo != loadedParams.Count)
            {
                return(null);
            }

            CAppParams result = new CAppParams();

            result.WindowLocation         = new Point(Int32.Parse(loadedParams[0]), Int32.Parse(loadedParams[1]));
            result.IsMaximized            = Boolean.Parse(loadedParams[2]);
            result.WindowSize             = new Size(Int32.Parse(loadedParams[4]), Int32.Parse(loadedParams[3]));
            result.PictureBackgroundColor = Color.FromArgb(Int32.Parse(loadedParams[5]));
            result.Colors[0] = Color.FromArgb(Int32.Parse(loadedParams[6]));
            result.Colors[1] = Color.FromArgb(Int32.Parse(loadedParams[7]));
            result.Colors[2] = Color.FromArgb(Int32.Parse(loadedParams[8]));
            result.Colors[3] = Color.FromArgb(Int32.Parse(loadedParams[9]));
            result.Colors[4] = Color.FromArgb(Int32.Parse(loadedParams[10]));
            result.Colors[5] = Color.FromArgb(Int32.Parse(loadedParams[11]));
            result.Colors[6] = Color.FromArgb(Int32.Parse(loadedParams[12]));
            result.Colors[7] = Color.FromArgb(Int32.Parse(loadedParams[13]));
            result.Colors[8] = Color.FromArgb(Int32.Parse(loadedParams[14]));
            result.Colors[9] = Color.FromArgb(Int32.Parse(loadedParams[15]));

            return(result);
        }
示例#4
0
        private void ExportParams(string filename)
        {
            CAppParams currentParams = GetApplicationParametrs();

            if (!paramsXML.SaveApplicationParametrsToFile(filename, currentParams))
            {
                showErrorMessageBox(FAIL_TO_EXPORT_PARAMS);
            }
        }
示例#5
0
        private void ImportParams(string filename)
        {
            CAppParams loadedParams = paramsXML.LoadApplicationParametrsFromFile(filename);

            if (loadedParams != null)
            {
                SetApplicationsParametrs(loadedParams);
            }
            else
            {
                showErrorMessageBox(FAIL_TO_IMPORT_PARAMS);
            }
        }
示例#6
0
 private void MakeStackWithSavingParams(CAppParams appParams)
 {
     for (int i = appParams.Colors.Length; i > 0; i--)
     {
         savingParams.Push(appParams.Colors[i - 1].ToArgb().ToString());
     }
     savingParams.Push(appParams.PictureBackgroundColor.ToArgb().ToString());
     savingParams.Push(appParams.WindowSize.Width.ToString());
     savingParams.Push(appParams.WindowSize.Height.ToString());
     savingParams.Push(appParams.IsMaximized.ToString());
     savingParams.Push(appParams.WindowLocation.Y.ToString());
     savingParams.Push(appParams.WindowLocation.X.ToString());
 }
示例#7
0
        private CAppParams GetApplicationParametrs()
        {
            CAppParams res = new CAppParams();

            res.IsMaximized            = (this.WindowState == FormWindowState.Maximized);
            res.WindowLocation         = new Point(locationX, locationY);
            res.WindowSize             = new Size(windowWidth, windowHeight);
            res.PictureBackgroundColor = currentPictureBackgroundColor;
            res.Colors[0] = lColor1.BackColor;
            res.Colors[1] = lColor2.BackColor;
            res.Colors[2] = lColor3.BackColor;
            res.Colors[3] = lColor4.BackColor;
            res.Colors[4] = lColor5.BackColor;
            res.Colors[5] = lColor6.BackColor;
            res.Colors[6] = lColor7.BackColor;
            res.Colors[7] = lColor8.BackColor;
            res.Colors[8] = lColor9.BackColor;
            res.Colors[9] = lColor10.BackColor;

            return(res);
        }
示例#8
0
 private void frmMain_Shown(object sender, EventArgs e)
 {
     standartParams = GetApplicationParametrs();
     ImportParams(CONFIG_FILE_PATH);
 }