Ejemplo n.º 1
0
        public MainForm()
        {
            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(Properties.Settings.Default.Language);
            System.Threading.Thread.CurrentThread.CurrentCulture   = System.Globalization.CultureInfo.GetCultureInfo(Properties.Settings.Default.Language);

            InitializeComponent();

            dataGeneral.DataSource                = null;
            dataWordReplacement.DataSource        = null;
            dataWordDefinition.DataSource         = null;
            dataFunctionDefinition.DataSource     = null;
            dataMiscFunctionDefinition.DataSource = null;
            dataOthers.DataSource = null;

            isNewFile             = false;
            openedFile            = false;
            searchTexts           = new string[6];
            search.TextBoxText    = "";
            search.Enabled        = false;
            closeFile.Enabled     = false;
            saveFile.Enabled      = false;
            saveFileSmall.Enabled = false;
            saveAsFile.Enabled    = false;

            try
            {
                LoadCommands loadCommands = new LoadCommands(File.ReadAllLines(@"commands.txt", System.Text.Encoding.Default));
                if (loadCommands.Result == true)
                {
                    commands = loadCommands.Commands;

                    commands.SectionGeneral.Sort((n1, n2) => n1.Name.CompareTo(n2.Name));
                    commands.SectionWordReplacement.Sort((n1, n2) => n1.Name.CompareTo(n2.Name));
                    commands.SectionWordDefinition.Sort((n1, n2) => n1.Name.CompareTo(n2.Name));
                    commands.SectionFunctionDefinition.Sort((n1, n2) => n1.Name.CompareTo(n2.Name));
                    commands.SectionMiscFunctionDefinition.Sort((n1, n2) => n1.Name.CompareTo(n2.Name));
                    commands.SectionOthers.Sort((n1, n2) => n1.Name.CompareTo(n2.Name));
                }
                else
                {
                    MessageBox.Show(Resources.Res.cmdIncorrectFileInfo, Resources.Res.infoHeader, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Environment.Exit(-1);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, Resources.Res.errorHeader, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(-1);
            }
        }
Ejemplo n.º 2
0
        public LoadCommands(string[] commandTexts)
        {
            Commands = new CommandsOfSections();
            Result   = true;

            ReadCommands(commandTexts, "// Section General");
            if (Result == false)
            {
                return;
            }

            ReadCommands(commandTexts, "// Section Word Replacement");
            if (Result == false)
            {
                return;
            }

            ReadCommands(commandTexts, "// Section Word Definition");
            if (Result == false)
            {
                return;
            }

            ReadCommands(commandTexts, "// Section Function Definition");
            if (Result == false)
            {
                return;
            }

            ReadCommands(commandTexts, "// Section Misc Function Definition");
            if (Result == false)
            {
                return;
            }

            ReadCommands(commandTexts, "// Section Others");

            return;
        }