Beispiel #1
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);
        }
Beispiel #2
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);
     }
 }
Beispiel #3
0
        private void AddBulletPoints(StringBuilder output, string input, string bulletsRoot)
        {
            int lineNumber = 1;

            using (TextReader reader = new StringReader(input))
            {
                for (; ;)
                {
                    string line = reader.ReadLine();
                    if (line == null)
                    {
                        break;
                    }
                    line = line.Trim();
                    line = line.Replace("\"", "{inch}");
                    while (line.Contains("  "))
                    {
                        line = line.Replace("  ", " ");
                    }
                    line = SingleSign.NormalizeText(line);
                    if (!string.IsNullOrEmpty(line))
                    {
                        System.Security.SecurityElement.Escape(line);
                        output.AppendLine("  <data id=\"" + bulletsRoot + lineNumber.ToString() + "\">" + line + "</data>");
                        lineNumber++;
                    }
                }
            }
        }
Beispiel #4
0
 private void docSign_PrintPage(object sender, PrintPageEventArgs e)
 {
     try
     {
         _SignIterator.Print(e);
     }
     catch (Exception ex)
     {
         SingleSign.ShowException(ex);
     }
 }
Beispiel #5
0
        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);
        }
Beispiel #6
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);
            }
        }