示例#1
0
        private static ListViewItem CreateItem(CANAPETemplate template)
        {
            ListViewItem item = new ListViewItem(template.Name);
            item.SubItems.Add(template.Description);
            item.Tag = template;

            return item;
        }
示例#2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            ListView listView = _tabs[tabControl.SelectedTab.Text];

            if (listView.SelectedItems.Count > 0)
            {
                Template = (CANAPETemplate)listView.SelectedItems[0].Tag;
                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                MessageBox.Show(this, CANAPE.Properties.Resources.SelectTemplateForm_SpecifyTemplate,
                    CANAPE.Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
        private static List <CANAPETemplate> GetTemplatesFromFile(string indexPath, string basePath, string typeName)
        {
            List <CANAPETemplate> templates = new List <CANAPETemplate>();

            try
            {
                if (File.Exists(indexPath))
                {
                    XmlDocument doc = new XmlDocument();

                    doc.Load(indexPath);

                    XmlNodeList nodes = doc.SelectNodes("/templates/template");

                    foreach (XmlNode node in nodes)
                    {
                        XmlElement element = node as XmlElement;

                        if (element != null)
                        {
                            CANAPETemplate template = CANAPETemplate.ReadFromXml(element, basePath, typeName);
                            if (template != null)
                            {
                                templates.Add(template);
                            }
                        }
                    }
                }
            }
            catch (FileNotFoundException)
            {
            }
            catch (DirectoryNotFoundException)
            {
            }
            catch (XmlException)
            {
            }
            catch (UnauthorizedAccessException)
            {
            }

            return(templates);
        }
示例#4
0
        internal static CANAPETemplate ReadFromXml(XmlElement elem, string baseDir, string typeName)
        {
            string name        = elem.GetAttribute("name");
            string description = elem.GetAttribute("description");
            string filename    = elem.GetAttribute("filename");
            string id          = elem.GetAttribute("id");

            CANAPETemplate template = null;

            if (!String.IsNullOrWhiteSpace(name) && !String.IsNullOrWhiteSpace(filename))
            {
                string fullPath = Path.Combine(baseDir, filename);

                if (File.Exists(fullPath))
                {
                    template = new CANAPETemplate(name, description == null ? String.Empty : description,
                                                  typeName, fullPath, id, null);
                }
            }

            return(template);
        }
示例#5
0
        internal static CANAPETemplate ReadFromXml(XmlElement elem, string baseDir, string typeName)
        {
            string name = elem.GetAttribute("name");
            string description = elem.GetAttribute("description");
            string filename = elem.GetAttribute("filename");
            string id = elem.GetAttribute("id");

            CANAPETemplate template = null;

            if (!String.IsNullOrWhiteSpace(name) && !String.IsNullOrWhiteSpace(filename))
            {
                string fullPath = Path.Combine(baseDir, filename);

                if (File.Exists(fullPath))
                {
                    template = new CANAPETemplate(name, description == null ? String.Empty : description,
                        typeName, fullPath, id, null);
                }
            }

            return template;
        }
示例#6
0
 private void listViewNodes_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     ListViewExtension listView = (ListViewExtension)sender;
     if (listView.SelectedItems.Count > 0)
     {
         Template = (CANAPETemplate)listView.SelectedItems[0].Tag;
         DialogResult = DialogResult.OK;
         Close();
     }
 }