BlueSky.SyntaxEditorWindow.LoadRegisteredGraphicsCommands C# (CSharp) Метод

LoadRegisteredGraphicsCommands() приватный Метод

private LoadRegisteredGraphicsCommands ( string grpListPath ) : void
grpListPath string
Результат void
        private void LoadRegisteredGraphicsCommands(string grpListPath)//07Sep2012
        {
            //string grpListPath = @".\Config\GraphicCommandList.txt";
            registeredGraphicsList.Clear();//clearing just as precaution. Not actually needed
            string line;
            string[] lineparts;

            char[] separators = new char[] { ',' };//{',', ' ', ';'};
            string keyGraphicCommand;
            int grphwidth=-1, grphheight=-1; // -1 means use defauls from the options setting.
            StreamReader f = null;
            try
            {
                f = new StreamReader(grpListPath);
                while ((line = f.ReadLine()) != null)
                {
                    grphwidth=-1; grphheight=-1;
                    if (line.Trim().Length > 0)//do not add blank lines
                    {
                        if (line.Trim().StartsWith("#"))//commented line in GraphicCommandList.txt. Only single line comment is supported.
                            continue;
                        lineparts = (line.Trim()).Split(separators);
                        keyGraphicCommand = lineparts[0].Trim();
                        if(lineparts.Length>1 && lineparts[1]!=null && lineparts[1].Trim().Length>0 )//get width from file(line)
                        {
                            Int32.TryParse(lineparts[1], out grphwidth);//try setting width from file.
                        }
                        if (lineparts.Length > 2 && lineparts[2] != null && lineparts[2].Trim().Length > 0)//get height from file(line)
                        {
                            if(!Int32.TryParse(lineparts[2], out grphheight))//if conversion fails
                            {
                                if(grphwidth>0)
                                    grphheight = grphwidth; // make height same as width, if height is not provided
                            }
                        }
                        
                        //now add three values to dictionary
                        if(!registeredGraphicsList.ContainsKey(keyGraphicCommand)) // if the key is not already present. Unique keys are entertained.
                            registeredGraphicsList.Add(keyGraphicCommand, new ImageDimensions(){ imagewidth = grphwidth, imageheight = grphheight} );
                    }
                }
                f.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(this, "Error opening registered graphic command list.\n" + e.Message);
                logService.WriteToLogLevel("Registered Graphics List not found!", LogLevelEnum.Error);
            }
        }
SyntaxEditorWindow