示例#1
0
        private void textBox_Leave(object sender, EventArgs e)
        {
            PrintItem printItem = (PrintItem)listBox.SelectedItem;

            printItem.Name = textBox.Text;

            textBox.Hide();
            listBox.Refresh();
        }
示例#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);
                    }
                }
            }
        }
示例#3
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);
        }
示例#4
0
        private void button2_Click(object sender, EventArgs e)
        {
            XmlNode node    = xml.CreateNode("element", "item", "");
            XmlNode subItem = currentNode.AppendChild(node);

            subItem.AppendChild(xml.CreateNode("element", "Name", ""));
            subItem.AppendChild(xml.CreateNode("element", "Description", ""));
            subItem.AppendChild(xml.CreateNode("element", "Location", ""));
            subItem.AppendChild(xml.CreateNode("element", "PrintFont", ""));

            PrintItem item = new PrintItem();

            item.Tag         = subItem;
            item.Name        = "新建名";
            item.Description = "新建名描述";
            item.Location    = Point.Empty;
            item.PrintFont   = new Font("宋体", 9);

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