Esempio n. 1
0
        // ListView Population Functions
        private void populateRegularFolder(RegularFolder folder)
        {
            listView1.Columns.Clear();
            listView1.Items.Clear();
            ImageList il = new ImageList();

            listView1.SmallImageList = il;

            listView1.Columns.Add("Name", 300);
            listView1.Columns.Add("Type", 300);

            foreach (AmjObject obj in folder.contents)
            {
                ListViewItem item;
                if (obj is AmjFolder)
                {
                    AmjFolder f = (AmjFolder)obj;
                    il.Images.Add(f.name, IconReader.GetFolderIcon(IconReader.IconSize.Small, IconReader.FolderType.Open));
                    item           = new ListViewItem(f.name);
                    item.ForeColor = Color.Green;
                    item.ImageKey  = f.name;
                    //item.UseItemStyleForSubItems = false;
                    ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem(item, "Amj Folder");
                    //subItem.ForeColor = Color.Green;
                    item.SubItems.Add(subItem);
                }
                else if (obj is RegularFolder)
                {
                    RegularFolder f = (RegularFolder)obj;
                    il.Images.Add(f.name, IconReader.GetFolderIcon(IconReader.IconSize.Small, IconReader.FolderType.Open));
                    item          = new ListViewItem(f.name);
                    item.ImageKey = f.name;
                    item.SubItems.Add("Folder");
                }

                else if (obj is RegularFile)
                {
                    RegularFile f = (RegularFile)obj;
                    //il.Images.Add(f.name, Icon.ExtractAssociatedIcon(f.path));
                    il.Images.Add(f.name, IconReader.GetFileIcon(f.path, IconReader.IconSize.Small, true));
                    item          = new ListViewItem(f.name);
                    item.ImageKey = f.name;
                    item.SubItems.Add("File");
                }
                else
                {
                    continue;
                }
                item.Tag = obj;
                this.listView1.Items.Add(item);
            }
        }
Esempio n. 2
0
        private void doOpen()
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }

            AmjObject obj = (AmjObject)listView1.SelectedItems[0].Tag;

            if (obj is AmjFolder)
            {
                AmjFolder f = (AmjFolder)obj;
                curFolder = f;
                f.loadContents();
                populateAmjFolder(f, 0);
                selectedDirs.Add(curFolder.name);
            }
            else if (obj is RegularFolder)
            {
                RegularFolder f = (RegularFolder)obj;
                curFolder = f;
                f.loadContents();
                populateRegularFolder(f);
                selectedDirs.Add(curFolder.name);
            }
            else if (obj is RegularFile)
            {
                RegularFile f = (RegularFile)obj;
                f.open();
            }
            else if (obj is AmjAttribute)
            {
                AmjAttribute a = (AmjAttribute)obj;
                selectedAttributes.Add(a.value == "Unknown"?"":a.value);
                populateAmjFolder((AmjFolder)curFolder, selectedAttributes.Count);
                selectedDirs.Add("[" + a.value + "]");
            }
            this.txtPath.Text = "";
            foreach (String dir in selectedDirs)
            {
                this.txtPath.Text += dir.Contains("\\") ? dir : dir + "\\";
            }

            if (obj is RegularFolder)
            {
                File.WriteAllText(Program.SettingsFile, "RecentPath=" + this.txtPath.Text.Substring(0, this.txtPath.Text.Length - 1));
            }
        }