예제 #1
0
        private void tsmSave_Click(object sender, System.EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter           = Properties.Resources.Controlfile_FilterText;
            sfd.InitialDirectory = Application.StartupPath;
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                _controlInformation.Save(sfd.FileName);
            }
        }
        /// <summary>
        /// Saves the parser definition to a file.
        /// </summary>
        /// <param name="fileName">The file to save the parser definition to.</param>
        public void Save(string fileName)
        {
            Assertions.AssertNotEmpty(fileName, "fileName");

            ControlInformation ci = new ControlInformation();
            ci.FaxName = this.ParserName;

            foreach (SectionDefinitionViewModel svm in this.Sections)
            {
                SectionDefinition sd = new SectionDefinition();
                sd.SectionString = new GenericParserString(svm.Name);

                foreach (SectionParserDefinitionViewModel spvm in svm.Aspects)
                {
                    SectionParserDefinition spd = new SectionParserDefinition();
                    spd.Type = spvm.Type;
                    spvm.Parser.OnSave(spd.Options);

                    sd.Parsers.Add(spd);
                }

                foreach (AreaDefinitionViewModel avm in svm.Areas)
                {
                    AreaDefinition ad = new AreaDefinition();
                    ad.AreaString = new GenericParserString(avm.Name);
                    ad.MapToPropertyExpression = avm.MapToPropertyExpression;

                    sd.Areas.Add(ad);
                }

                ci.Sections.Add(sd);
            }

            ci.Save(fileName);
        }