Example #1
0
        private void cmdPrint_Click(object sender, EventArgs e)
        {
            prgProgress.Value   = 0;
            prgProgress.Maximum = treCharacters.Nodes.Count;

            // Write the Character information to a MemoryStream so we don't need to create any files.
            MemoryStream  objStream = new MemoryStream();
            XmlTextWriter objWriter = new XmlTextWriter(objStream, Encoding.UTF8);

            // Being the document.
            objWriter.WriteStartDocument();
            // <characters>
            objWriter.WriteStartElement("characters");

            // Fire the PrintToStream method for all of the characters in the list.
            foreach (TreeNode objNode in treCharacters.Nodes)
            {
                Character objCharacter = new Character();
                objCharacter.FileName = objNode.Tag.ToString();
                objCharacter.Load();

#if DEBUG
                objCharacter.PrintToStream(objStream, objWriter);
#else
                objCharacter.PrintToStream(objWriter);
#endif
                prgProgress.Value++;
                Application.DoEvents();
            }

            // Finish the document and flush the Writer and Stream.
            // </characters>
            objWriter.WriteEndElement();
            objWriter.WriteEndDocument();
            objWriter.Flush();
            objStream.Flush();

            // Read the stream.
            StreamReader objReader = new StreamReader(objStream);
            objStream.Position = 0;
            XmlDocument objCharacterXML = new XmlDocument();

            // Put the stream into an XmlDocument and send it off to the Viewer.
            string strXML = objReader.ReadToEnd();
            objCharacterXML.LoadXml(strXML);

            objWriter.Close();

            // Set the ProgressBar back to 0.
            prgProgress.Value = 0;

            frmViewer frmViewCharacter = new frmViewer();
            frmViewCharacter.CharacterXML  = objCharacterXML;
            frmViewCharacter.SelectedSheet = "Game Master Summary";
            frmViewCharacter.ShowDialog();
        }
Example #2
0
        private void cmdPrint_Click(object sender, EventArgs e)
        {
            prgProgress.Value = 0;
            prgProgress.Maximum = treCharacters.Nodes.Count;

            // Write the Character information to a MemoryStream so we don't need to create any files.
            MemoryStream objStream = new MemoryStream();
            XmlTextWriter objWriter = new XmlTextWriter(objStream, Encoding.UTF8);

            // Being the document.
            objWriter.WriteStartDocument();
            // <characters>
            objWriter.WriteStartElement("characters");

            // Fire the PrintToStream method for all of the characters in the list.
            foreach (TreeNode objNode in treCharacters.Nodes)
            {
                Character objCharacter = new Character();
                objCharacter.FileName = objNode.Tag.ToString();
                objCharacter.Load();

                objCharacter.PrintToStream(objStream, objWriter);
                prgProgress.Value++;
                Application.DoEvents();
            }

            // Finish the document and flush the Writer and Stream.
            // </characters>
            objWriter.WriteEndElement();
            objWriter.WriteEndDocument();
            objWriter.Flush();
            objStream.Flush();

            // Read the stream.
            StreamReader objReader = new StreamReader(objStream);
            objStream.Position = 0;
            XmlDocument objCharacterXML = new XmlDocument();

            // Put the stream into an XmlDocument and send it off to the Viewer.
            string strXML = objReader.ReadToEnd();
            objCharacterXML.LoadXml(strXML);

            objWriter.Close();

            // Set the ProgressBar back to 0.
            prgProgress.Value = 0;

            frmViewer frmViewCharacter = new frmViewer();
            frmViewCharacter.CharacterXML = objCharacterXML;
            frmViewCharacter.SelectedSheet = "Game Master Summary";
            frmViewCharacter.ShowDialog();
        }
Example #3
0
        private void FinishPrint(object sender, EventArgs e)
        {
            cmdPrint.Enabled = true;
            // Set the ProgressBar back to 0.
            prgProgress.Value = 0;

            if (_frmPrintView == null)
            {
                frmViewer _frmPrintView = new frmViewer();
                _frmPrintView.Characters    = _lstCharacters;
                _frmPrintView.SelectedSheet = "Game Master Summary";
                _frmPrintView.Show();
            }
            else
            {
                _frmPrintView.Activate();
            }
            _frmPrintView.RefreshView();
        }
Example #4
0
        private void FinishPrint(object sender, RunWorkerCompletedEventArgs e)
        {
            cmdPrint.Enabled = true;
            // Set the ProgressBar back to 0.
            prgProgress.Value = 0;

            if (!e.Cancelled)
            {
                if (_frmPrintView == null)
                {
                    _frmPrintView = new frmViewer();
                    _frmPrintView.SetSelectedSheet("Game Master Summary");
                    _frmPrintView.SetCharacters(_lstCharacters.ToArray());
                    _frmPrintView.Show();
                }
                else
                {
                    _frmPrintView.Activate();
                }
                _frmPrintView.RefreshCharacters();
            }
        }
Example #5
0
        /// <summary>
        /// Print this character and open the View Character window.
        /// </summary>
        /// <param name="blnDialog">Whether or not the window should be shown as a dialogue window.</param>
        public void Print(bool blnDialog = true)
        {
            // Write the Character information to a MemoryStream so we don't need to create any files.
            MemoryStream objStream = new MemoryStream();
            XmlTextWriter objWriter = new XmlTextWriter(objStream, Encoding.UTF8);

            // Being the document.
            objWriter.WriteStartDocument();

            // </characters>
            objWriter.WriteStartElement("characters");

            PrintToStream(objStream, objWriter);

            // </characters>
            objWriter.WriteEndElement();

            // Finish the document and flush the Writer and Stream.
            objWriter.WriteEndDocument();
            objWriter.Flush();
            objStream.Flush();

            // Read the stream.
            StreamReader objReader = new StreamReader(objStream);
            objStream.Position = 0;
            XmlDocument objCharacterXML = new XmlDocument();

            // Put the stream into an XmlDocument and send it off to the Viewer.
            string strXML = objReader.ReadToEnd();
            objCharacterXML.LoadXml(strXML);

            objWriter.Close();
            objStream.Close();

            // If a reference to the Viewer window does not yet exist for this character, open a new Viewer window and set the reference to it.
            // If a Viewer window already exists for this character, use it instead.
            if (_frmPrintView == null)
            {
                List<Character> lstCharacters = new List<Character>();
                lstCharacters.Add(this);
                frmViewer frmViewCharacter = new frmViewer();
                frmViewCharacter.Characters = lstCharacters;
                frmViewCharacter.CharacterXML = objCharacterXML;
                _frmPrintView = frmViewCharacter;
                if (blnDialog)
                    frmViewCharacter.ShowDialog();
                else
                    frmViewCharacter.Show();
            }
            else
            {
                _frmPrintView.Activate();
                _frmPrintView.RefreshView();
            }
        }