コード例 #1
0
        private List <PrintItem> GetPrintItems()
        {
            bool             findOut           = false;
            List <PrintItem> ItemParameterList = null;

            XmlNode root = xml.FirstChild["Defines"];

            foreach (XmlNode node in root.ChildNodes)
            {
                findOut = node.Attributes[0].InnerText.ToUpper() == printTitleName.ToUpper();
                if (findOut)
                {
                    root = node;
                    break;
                }
            }

            if (findOut)
            {
                ItemParameterList = new List <PrintItem>();
                //currentNode = root;
                foreach (XmlNode node in root.ChildNodes)
                {
                    PrintItem item = new PrintItem();
                    item.Name        = node["Name"].InnerText;
                    item.Description = node["Description"].InnerText;
                    try
                    {
                        item.Location  = node["Location"].InnerText == "" ? Point.Empty : new Point(int.Parse(node["Location"].InnerText.Substring(1, node["Location"].InnerText.Length - 2).Split(',')[0].Split('=')[1]), int.Parse(node["Location"].InnerText.Substring(1, node["Location"].InnerText.Length - 2).Split(',')[1].Split('=')[1]));
                        item.PrintFont = node["PrintFont"].InnerText == "" ? null : item.SetFontName(node["PrintFont"].InnerText);
                    }
                    catch
                    {
                        item.Location  = Point.Empty;
                        item.PrintFont = null;
                    }

                    ItemParameterList.Add(item);
                }
            }

            return(ItemParameterList);
        }
コード例 #2
0
        private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox.SelectedItem != null)
            {
                bool       findOut = false;
                PrintTitle title   = (PrintTitle)comboBox.SelectedItem;
                propertyGrid.SelectedObject = title;

                XmlNode root = xml.FirstChild["Defines"];

                foreach (XmlNode node in root.ChildNodes)
                {
                    findOut = node.Attributes[0].InnerText.ToUpper() == title.Name.ToUpper();
                    if (findOut)
                    {
                        root = node;
                        break;
                    }
                }

                if (findOut)
                {
                    listBox.Items.Clear();
                    currentNode = root;
                    foreach (XmlNode node in root.ChildNodes)
                    {
                        PrintItem item = new PrintItem();
                        item.Name        = node["Name"].InnerText;
                        item.Description = node["Description"].InnerText;
                        try
                        {
                            item.Location  = node["Location"].InnerText == "" ? Point.Empty : new Point(int.Parse(node["Location"].InnerText.Substring(1, node["Location"].InnerText.Length - 2).Split(',')[0].Split('=')[1]), int.Parse(node["Location"].InnerText.Substring(1, node["Location"].InnerText.Length - 2).Split(',')[1].Split('=')[1]));
                            item.PrintFont = node["PrintFont"].InnerText == "" ? null : item.SetFontName(node["PrintFont"].InnerText);
                        }
                        catch
                        {
                            item.Location  = Point.Empty;
                            item.PrintFont = null;
                        }

                        item.Tag = node;

                        listBox.Items.Add(item);
                    }
                }
            }
        }