GetVirtualDirectoryFiles() public static method

public static GetVirtualDirectoryFiles ( string storageCategory ) : string[]
storageCategory string
return string[]
コード例 #1
0
        public CreateProjectWizard()
        {
            InitializeComponent();

            string[] filelist = StorageManager.GetVirtualDirectoryFiles("Templates", "*.nkar", System.IO.SearchOption.AllDirectories);

            this.templateList.LargeImageList            = new ImageList();
            this.templateList.LargeImageList.ColorDepth = ColorDepth.Depth32Bit;
            this.templateList.LargeImageList.ImageSize  = new Size(48, 48);
            this.templateList.SmallImageList            = new ImageList();
            this.templateList.SmallImageList.ColorDepth = ColorDepth.Depth32Bit;
            this.templateList.SmallImageList.ImageSize  = new Size(16, 16);
            this.templateList.Columns.Add("名称");
            this.templateList.Columns.Add("版本");
            this.templateList.Columns.Add("语言");
            this.templateList.Columns.Add("备注");
            this.templateList.View          = View.Details;
            this.templateList.MultiSelect   = false;
            this.templateList.FullRowSelect = true;
            this.templateList.HideSelection = false;
            this.templateList.Sorting       = SortOrder.Ascending;

            foreach (string filename in filelist)
            {
                try
                {
                    ArchiveFile file   = new ArchiveFile(filename);
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.LoadXml(file.Manifest);

                    XmlNode root = xmldoc["NekoKunProjectTemplate"];
                    if (new Version(root.Attributes["Version"].Value) > new Version(((System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyFileVersionAttribute), false)[0] as System.Reflection.AssemblyFileVersionAttribute).Version)))
                    {
                        throw new ArgumentException("The project template file was created in a newer version of NekoKun which is not supported by this version of NekoKun.");
                    }

                    ListViewItem lvi = new ListViewItem();
                    lvi.Tag  = file;
                    lvi.Text = root["Title"].InnerText;
                    lvi.SubItems.Add(root["Version"] != null ? root["Version"].InnerText : "");
                    lvi.SubItems.Add(root["Language"] != null ? root["Language"].InnerText : "");
                    lvi.SubItems.Add(root["Description"] != null ? root["Description"].InnerText : "");
                    lvi.ToolTipText = root["Description"] != null ? root["Description"].InnerText : "";
                    if (root["Icon"] != null)
                    {
                        Image image = NekoKun.Core.DrawingHelper.DecodeBase64Image(root["Icon"].InnerText);

                        this.templateList.LargeImageList.Images.Add(filename, image);
                        this.templateList.SmallImageList.Images.Add(filename, image);
                        lvi.ImageKey = filename;
                    }

                    this.templateList.Items.Add(lvi);
                }
                catch { }
            }

            if (this.templateList.Items.Count >= 1)
            {
                this.templateList.Items[0].Selected = true;
            }

            this.templateList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

            FillFields();
            this.fieldName.TextChanged    += new EventHandler(fieldName_TextChanged);
            this.browseFolderButton.Click += new EventHandler(browseFolderButton_Click);
            UpdateAccept();

            this.templateList.ItemSelectionChanged += delegate { UpdateAccept(); };
            this.fieldLocation.TextChanged         += delegate { UpdateAccept(); };
            this.fieldName.TextChanged             += delegate { UpdateAccept(); };

            this.accpetButton.Click += new EventHandler(accpetButton_Click);
        }