コード例 #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
        public void Print(PrintPageEventArgs e)
        {
            string dataPath = _DataPaths[_SignIndex];

            _SignIndex++;
            try
            {
                string      dataFile   = Path.GetFileName(dataPath);
                string      dataFolder = Path.GetDirectoryName(dataPath);
                MacroValues macros     = new MacroValues();
                SingleSign.AddStandardMacroValues(macros);
                AddUserMacros(macros);
                XmlDocument dataDoc = SingleSign.CreateEmptySignDataDoc();
                dataDoc.Load(Path.Combine(dataFolder, dataFile));
                SingleSign.AddDataFileMacros(macros, dataFolder, dataDoc);
                string     templateFile   = Path.GetFileName(_TemplatePath);
                string     templateFolder = Path.GetDirectoryName(_TemplatePath);
                SingleSign singleSign     = new SingleSign();
                singleSign.Print(templateFile, templateFolder, macros, dataFolder, e);
            }
            catch (Exception ex)
            {
                throw new Exception("Error in sign data file " + dataPath, ex);
            }
            e.HasMorePages = (_SignIndex < _SignCount);
        }
コード例 #3
0
        private void lstPlantFiles_DoubleClick(object sender, EventArgs e)
        {
            if (DeclineToDiscardChanges())
            {
                return;
            }
            Clear();
            string      plantFile = (string)lstPlantFiles.SelectedItem;
            XmlDocument plantDoc  = SingleSign.CreateEmptySignDataDoc();
            string      plantPath = Path.Combine(_PlantFolder, plantFile);
            string      plantXML  = File.ReadAllText(plantPath);

            txtPlantFileContents.Text = plantXML;
            _PlantHasChanged          = false;
            try
            {
                plantDoc.Load(plantPath);
                txtPlantFileName.Text = plantFile;

                XmlNode node;

                node = plantDoc.DocumentElement.SelectSingleNode("data[@id='variety']");
                if (node != null)
                {
                    txtVarietyName.Text = node.InnerText;
                }

                node = plantDoc.DocumentElement.SelectSingleNode("data[@id='variety2']");
                if (node != null)
                {
                    txtVarietyName2.Text = node.InnerText;
                }

                node = plantDoc.DocumentElement.SelectSingleNode("data[@id='pic']");
                if (node != null)
                {
                    txtEncodedImageName.Text = node.InnerText;
                }

                cboExtraFactFile.SelectedIndex = -1;
                cboExtraFactFile.Text          = string.Empty;
                foreach (XmlNode includeNode in plantDoc.DocumentElement.SelectNodes("include"))
                {
                    string includeFile = includeNode.InnerText;
                    if (includeFile.ToLower() != "facts.sgninc")
                    {
                        int factFileIndex = 0;
                        foreach (string factFile in cboExtraFactFile.Items)
                        {
                            if (factFile == includeFile)
                            {
                                cboExtraFactFile.SelectedIndex = factFileIndex;
                                break;
                            }
                            factFileIndex++;
                        }
                    }
                }

                plantFacts.LoadXML(plantDoc);

                _PlantIsNew      = false;
                _PlantHasChanged = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception reading sign data file: " + ex.Message);
            }
        }