コード例 #1
0
 private void docSign_PrintPage(object sender, PrintPageEventArgs e)
 {
     try
     {
         string           dataFolder     = _PlantFolder;
         string           templateFile   = Path.GetFileName(_TemplatePath);
         string           templateFolder = Path.GetDirectoryName(_TemplatePath);
         MacroDefinitions macroDefs      = new MacroDefinitions();
         SingleSign.LoadMacroDefinitions(templateFile, templateFolder, macroDefs);
         MacroValues macros = new MacroValues();
         SingleSign.AddStandardMacroValues(macros);
         foreach (MacroDefinition macroDef in macroDefs)
         {
             macros[macroDef.Name] = macroDef.Value;
         }
         XmlDocument dataDoc = SingleSign.CreateEmptySignDataDoc();
         dataDoc.LoadXml(txtPlantFileContents.Text);
         SingleSign.AddDataFileMacros(macros, dataFolder, dataDoc);
         SingleSign singleSign = new SingleSign();
         singleSign.Print(templateFile, templateFolder, macros, dataFolder, e);
         e.HasMorePages = false;
     }
     catch (Exception ex)
     {
         SingleSign.ShowException(ex);
     }
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: timyaukey/SignPrinter
 private void DisplayMacroDef(MacroDefinitions macroDefs, int index, TextBox macroNameControl, TextBox macroValueControl)
 {
     macroNameControl.Text  = string.Empty;
     macroValueControl.Text = string.Empty;
     if (index < macroDefs.Count)
     {
         macroNameControl.Text  = macroDefs[index].Name;
         macroValueControl.Text = macroDefs[index].Value;
     }
 }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: timyaukey/SignPrinter
        private void LoadMacroDefs()
        {
            string           templateFolder = Path.GetDirectoryName(_TemplatePath);
            string           templateFile   = Path.GetFileName(_TemplatePath);
            MacroDefinitions macroDefs      = new MacroDefinitions();

            SingleSign.LoadMacroDefinitions(templateFile, templateFolder, macroDefs);
            DisplayMacroDef(macroDefs, 0, txtMacro1Name, txtMacro1Value);
            DisplayMacroDef(macroDefs, 1, txtMacro2Name, txtMacro2Value);
            DisplayMacroDef(macroDefs, 2, txtMacro3Name, txtMacro3Value);
        }
コード例 #4
0
ファイル: SingleSign.cs プロジェクト: timyaukey/SignPrinter
        public static void LoadMacroDefinitions(string templateFile, string templateFolder, MacroDefinitions macroDefs)
        {
            string      templatePath = Path.Combine(templateFolder, templateFile);
            XmlDocument templateDoc  = new XmlDocument();

            templateDoc.Load(templatePath);
            foreach (XmlNode templateNode in templateDoc.DocumentElement.ChildNodes)
            {
                XmlElement cmdElm = templateNode as XmlElement;
                if (cmdElm != null)
                {
                    string cmdName = cmdElm.Name.ToLowerInvariant();
                    switch (cmdName)
                    {
                    case "macrodef":
                        string macroName;
                        if (!TryGetAttrib(cmdElm, "name", out macroName))
                        {
                            throw CreateTemplateAttributeException(cmdElm, "name", "Missing [name] attribute");
                        }
                        string macroValue;
                        if (!TryGetAttrib(cmdElm, "value", out macroValue))
                        {
                            throw CreateTemplateAttributeException(cmdElm, "value", "Missing [value] attribute");
                        }
                        macroDefs.Add(new MacroDefinition(macroName, macroValue));
                        break;

                    case "include":
                        string includePath = cmdElm.InnerText;
                        if (string.IsNullOrEmpty(includePath))
                        {
                            throw CreateTemplateException(cmdElm, "Missing include file name");
                        }
                        LoadMacroDefinitions(Path.GetFileName(includePath), templateFolder, macroDefs);
                        break;
                    }
                }
            }
        }
コード例 #5
0
 public ProjectInformation(Project project) : base(project)
 {
     globals   = new Globals(project);
     macroDefs = new MacroDefinitions(project);
 }