Ejemplo n.º 1
0
        //============================================================================*
        // Export() - XML Document
        //============================================================================*

        public void Export(cRWXMLDocument XMLDocument, XmlElement XMLParentElement)
        {
            XmlElement XMLThisElement = XMLDocument.CreateElement("Charge");

            XMLParentElement.AppendChild(XMLThisElement);

            // PowderWeight

            XmlElement XMLElement     = XMLDocument.CreateElement("PowderWeight");
            XmlText    XMLTextElement = XMLDocument.CreateTextNode(String.Format("{0}", m_dPowderWeight));

            XMLElement.AppendChild(XMLTextElement);

            XMLThisElement.AppendChild(XMLElement);

            // Fill Ratio

            XMLElement     = XMLDocument.CreateElement("FillRatio");
            XMLTextElement = XMLDocument.CreateTextNode(String.Format("{0}", m_dFillRatio));
            XMLElement.AppendChild(XMLTextElement);

            XMLThisElement.AppendChild(XMLElement);

            // Favorite

            XMLElement     = XMLDocument.CreateElement("Favorite");
            XMLTextElement = XMLDocument.CreateTextNode(m_fFavorite ? "Yes" : "-");
            XMLElement.AppendChild(XMLTextElement);

            XMLThisElement.AppendChild(XMLElement);

            // Reject

            XMLElement     = XMLDocument.CreateElement("Reject");
            XMLTextElement = XMLDocument.CreateTextNode(m_fReject ? "Yes" : "-");
            XMLElement.AppendChild(XMLTextElement);

            XMLThisElement.AppendChild(XMLElement);

            TestList.Export(XMLDocument, XMLThisElement);
        }
Ejemplo n.º 2
0
        //============================================================================*
        // CreateShareFile()
        //============================================================================*

        private void CreateShareFile()
        {
            //----------------------------------------------------------------------------*
            // Gather all the needed info to store the loads to be shared
            //----------------------------------------------------------------------------*

            cManufacturerList ShareManufacturerList = new cManufacturerList();
            cCaliberList      ShareCaliberList      = new cCaliberList();
            cBulletList       ShareBulletList       = new cBulletList();
            cCaseList         ShareCaseList         = new cCaseList();
            cPowderList       SharePowderList       = new cPowderList();
            cPrimerList       SharePrimerList       = new cPrimerList();

            cLoadList ShareLoadList = new cLoadList();

            foreach (ListViewItem Item in m_LoadDataListView.CheckedItems)
            {
                cLoad Load = (cLoad)Item.Tag;

                if (Load != null && Load.Bullet != null && Load.Case != null && Load.Powder != null && Load.Primer != null)
                {
                    foreach (cBulletCaliber BulletCaliber in Load.Bullet.BulletCaliberList)
                    {
                        ShareCaliberList.AddCaliber(BulletCaliber.Caliber);
                    }

                    ShareManufacturerList.AddManufacturer(Load.Bullet.Manufacturer);
                    ShareBulletList.AddBullet(Load.Bullet);

                    ShareManufacturerList.AddManufacturer(Load.Case.Manufacturer);
                    ShareCaseList.AddCase(Load.Case);

                    ShareManufacturerList.AddManufacturer(Load.Powder.Manufacturer);
                    SharePowderList.AddPowder(Load.Powder);

                    ShareManufacturerList.AddManufacturer(Load.Primer.Manufacturer);
                    SharePrimerList.AddPrimer(Load.Primer);

                    ShareLoadList.Add(Load);
                }
            }

            //----------------------------------------------------------------------------*
            // Now create a cRWXMLDocument and export the load data to it
            //----------------------------------------------------------------------------*

            cRWXMLDocument XMLDocument = new cRWXMLDocument(m_DataFiles);

            XmlElement MainElement = XMLDocument.CreateElement("Body");

            XMLDocument.AppendChild(MainElement);

            XmlText XMLTextElement = XMLDocument.CreateTextNode(String.Format("{0} Load Data Share File Export", Application.ProductName));

            MainElement.AppendChild(XMLTextElement);

            ShareManufacturerList.Export(XMLDocument, MainElement);
            ShareBulletList.Export(XMLDocument, MainElement, false);
            ShareCaliberList.Export(XMLDocument, MainElement);
            ShareCaseList.Export(XMLDocument, MainElement, false);
            SharePowderList.Export(XMLDocument, MainElement, false);
            SharePrimerList.Export(XMLDocument, MainElement, false);

            ShareLoadList.Export(XMLDocument, MainElement);

            //----------------------------------------------------------------------------*
            // Save the Exported XML Share File
            //----------------------------------------------------------------------------*

            SaveFileDialog SaveDialog = new SaveFileDialog();

            SaveDialog.AddExtension     = true;
            SaveDialog.CheckPathExists  = true;
            SaveDialog.DefaultExt       = "xml";
            SaveDialog.FileName         = String.Format("{0} Load Data Share File - {1}{2}{3}", Application.ProductName, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            SaveDialog.Filter           = "XML Files {*.xml)|*.xml";
            SaveDialog.InitialDirectory = Path.Combine(m_DataFiles.GetDataPath(), "Share");
            SaveDialog.OverwritePrompt  = true;
            SaveDialog.Title            = String.Format("Export Load Data");
            SaveDialog.ValidateNames    = true;

            if (SaveDialog.ShowDialog() == DialogResult.OK)
            {
                XMLDocument.Save(SaveDialog.OpenFile());
            }
        }