Пример #1
0
        /// <summary>
        /// 新建文件夹
        /// </summary>
        void NewResourcesFolder()
        {
            SdsiteXmlDocument doc             = Service.Sdsite.CurrentDocument;
            FolderXmlElement  parentFolderEle = filePaths[pathNum] as FolderXmlElement;
            FolderXmlElement  newFolderEle    = doc.CreateFolder(parentFolderEle, XmlUtilService.CreateIncreaseFolderTitle(parentFolderEle));

            Directory.CreateDirectory(newFolderEle.AbsoluteFilePath);

            MyFolderItem mylvi = new MyFolderItem(newFolderEle);

            listView.Items.Add(mylvi);

            KeyValuePair <string, Image> keyImg = GetImageAndKey(mylvi.Element.AbsoluteFilePath);

            if (!listView.SmallImageList.Images.ContainsKey(keyImg.Key))
            {
                listView.SmallImageList.Images.Add(keyImg.Key, keyImg.Value);
            }
            mylvi.ImageKey = keyImg.Key;

            mylvi.Selected = true;
            mylvi.BeginEdit();
        }
Пример #2
0
        /// <summary>
        /// 加载项目
        /// </summary>
        /// <param name="initPath"></param>
        void InitListView(SimpleExIndexXmlElement folderEle)
        {
            listView.Items.Clear();
            SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument;

            //加载子文件夹
            foreach (XmlNode node in folderEle.ChildNodes)
            {
                if (node is FolderXmlElement)
                {
                    FolderXmlElement folder = (FolderXmlElement)node;
                    if (folder.IsDeleted)
                    {
                        continue;
                    }

                    MyFolderItem mylvi      = new MyFolderItem(folder);
                    string       folderPath = folder.AbsoluteFilePath.Substring(0, folder.AbsoluteFilePath.Length - 1);
                    mylvi.Text = Path.GetFileName(folderPath);
                    mylvi.Text = folder.Title;
                    listView.Items.Add(mylvi);
                }
            }
            //加载子文件
            foreach (XmlNode node in folderEle.ChildNodes)
            {
                if (node is FileSimpleExXmlElement)
                {
                    FileSimpleExXmlElement fileEle    = (FileSimpleExXmlElement)node;
                    MyFileItem             myFileItem = new MyFileItem(fileEle);
                    if (fileEle.IsDeleted)
                    {
                        continue;
                    }

                    myFileItem.Element = fileEle;
                    myFileItem.Text    = Path.GetFileName(fileEle.AbsoluteFilePath);
                    myFileItem.Text    = fileEle.Title;

                    string exfile = Path.GetExtension(fileEle.AbsoluteFilePath).ToLower();
                    switch (FileType)
                    {
                    case MediaFileType.Pic:
                    {
                        if (exfile == ".jpg" || exfile == ".jpeg" /*|| exfile == ".png"*/ || exfile == ".gif")
                        {
                            myFileItem.ItemMediaType = MediaFileType.Pic;
                            string valuestr = "";
                            if (!picFilter.TryGetValue(FilterComboBox.Text, out valuestr) || valuestr == "all")
                            {
                                listView.Items.Add(myFileItem);
                            }
                            else
                            {
                                if (exfile == valuestr)
                                {
                                    listView.Items.Add(myFileItem);
                                }
                            }
                        }
                        break;
                    }

                    case MediaFileType.Flash:
                    {
                        if (exfile == ".swf")
                        {
                            myFileItem.ItemMediaType = MediaFileType.Flash;
                            listView.Items.Add(myFileItem);
                        }
                        break;
                    }

                    case MediaFileType.Audio:
                    {
                        if (exfile == ".mp3" || exfile == ".mdi" || exfile == ".wma" || exfile == "*.wav")
                        {
                            myFileItem.ItemMediaType = MediaFileType.Audio;
                            string valuestr = "";
                            if (!audioFilter.TryGetValue(FilterComboBox.Text, out valuestr) || valuestr == "all")
                            {
                                listView.Items.Add(myFileItem);
                            }
                            else
                            {
                                if (exfile == valuestr)
                                {
                                    listView.Items.Add(myFileItem);
                                }
                            }
                        }
                        break;
                    }

                    case MediaFileType.Video:
                    {
                        if (exfile == ".rmvb" || exfile == ".rm" || exfile == ".avi" || exfile == ".wmv")
                        {
                            myFileItem.ItemMediaType = MediaFileType.Video;
                            string valuestr = "";
                            if (!mediaFilter.TryGetValue(FilterComboBox.Text, out valuestr) || valuestr == "all")
                            {
                                listView.Items.Add(myFileItem);
                            }
                            else
                            {
                                if (exfile == valuestr)
                                {
                                    listView.Items.Add(myFileItem);
                                }
                            }
                        }
                        break;
                    }
                    }
                }
            }

            //加载图标
            foreach (MyItem lvitem in listView.Items)
            {
                string fullPath = lvitem.Element.AbsoluteFilePath;
                KeyValuePair <string, Image> keyImg = GetImageAndKey(fullPath);
                if (!listView.SmallImageList.Images.ContainsKey(keyImg.Key))
                {
                    listView.SmallImageList.Images.Add(keyImg.Key, keyImg.Value);
                }
                lvitem.ImageKey = keyImg.Key;
            }
        }