Ejemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 public BeerXmlData()
 {
     Equipment = new EquipmentList();
     Fermentables = new FermentableList();
     Hops = new HopList();
     Miscs = new MiscList();
     Recipes = new RecipeList();
     Styles = new StyleList();
     Waters = new WaterList();
     Yeasts = new YeastList();
 }
Ejemplo n.º 2
0
        public static void CreateXMLDocument(string XMLDocumentName, string NodeName, string NodeText)
        {
            XmlDocument xmldoc;
            XmlNode     xmlnode;
            XmlElement  xmlelem;
            XmlElement  MiscList;

            XmlText xmltext;

            if (System.IO.File.Exists(Application.StartupPath + "\\" + XMLDocumentName + ".xml"))
            {
                xmldoc = new XmlDocument();
                xmldoc.Load(Application.StartupPath + "\\" + XMLDocumentName + ".xml");
                MiscList = xmldoc.CreateElement(NodeName);
                MiscList = xmldoc.CreateElement("", NodeName, "");
                xmltext  = xmldoc.CreateTextNode(NodeText);
                MiscList.AppendChild(xmltext);
                xmldoc.ChildNodes.Item(1).AppendChild(MiscList);
            }
            else
            {
                xmldoc = new XmlDocument();
                //加入XML的声明段落
                xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
                xmldoc.AppendChild(xmlnode);
                //加入一个根元素
                xmlelem = xmldoc.CreateElement("", "NodeList", "");
                //  xmltext = xmldoc.CreateTextNode("heyu5220");
                //  xmlelem.AppendChild(xmltext);
                xmldoc.AppendChild(xmlelem);
                //加入另外一个元素
                MiscList = xmldoc.CreateElement(NodeName);
                MiscList = xmldoc.CreateElement("", NodeName, "");
                xmltext  = xmldoc.CreateTextNode(NodeText);
                MiscList.AppendChild(xmltext);
                xmldoc.ChildNodes.Item(1).AppendChild(MiscList);
            }
            //保存创建好的XML文档
            try
            {
                xmldoc.Save(Application.StartupPath + "\\" + XMLDocumentName + ".xml");
            }
            catch (Exception e)
            {
                //显示错误信息
                Console.WriteLine(e.Message);
            }
            Console.ReadLine();
        }
        public MainWindow()
        {
            InitializeComponent();
            MaximizeBox = false;

            BloatList.BeginUpdate();
            BloatList.View                  = View.List;
            BloatList.ShowGroups            = false;
            BloatList.CheckBoxes            = true;
            BloatList.ItemChecked          += ItemChecked;
            BloatList.ItemSelectionChanged += ItemSelectionChanged;

            ColumnHeader program = BloatList.Columns.Add("Program");

            program.Width = 107;

            foreach (WSBloatware v in WSBloatware.All)
            {
                bool canrun = v.IsInstalled();
                BloatList.Items.Add(new ListViewItem($"{v.Name}{(canrun ? "" : " - N/A")}")
                {
                    Tag = canrun ? v : null,
                });
            }

            BloatList.EndUpdate();

            MiscList.BeginUpdate();
            MiscList.View                  = View.Details;
            MiscList.CheckBoxes            = true;
            MiscList.HeaderStyle           = ColumnHeaderStyle.None;
            MiscList.ItemChecked          += ItemChecked;
            MiscList.ItemSelectionChanged += ItemSelectionChanged;

            ColumnHeader info = MiscList.Columns.Add("Info");

            info.Width = 325;

            foreach (ICustom v in Method.GetCustom())
            {
                bool canrun = v.CanRun();

                MiscList.Items.Add(new ListViewItem($"{v.GetName()} - {(canrun ? v.GetInfo() : "Method unavailable on this computer")}")
                {
                    Tag     = canrun ? v : null,
                    Checked = true
                });
            }

            foreach (IRegEdit v in Method.GetRegEdits())
            {
                bool canrun = false;

                foreach (RegEdit reg in v.GetRegEdits())
                {
                    if (reg.CanRun())
                    {
                        canrun = true;
                        break;
                    }
                }

                MiscList.Items.Add(new ListViewItem($"{v.GetName()} - {(canrun ? v.GetInfo() : "Method unavailable on this computer")}")
                {
                    Tag     = canrun ? v : null,
                    Checked = canrun
                });
            }

            MiscList.EndUpdate();
        }