コード例 #1
0
        /// <summary>
        /// 更新ListView中的项
        /// </summary>
        private void UpdateFileListView(out ListViewItem[] items, ref ScoreDoc[] scoreDocs, ref int indexRecord, int times)
        {
            //GetSystemIcon getIcon = new GetSystemIcon();//获取图标
            string extenName = null; //扩展名
            string name      = null; //文件名
            string length    = null;
            int    k;

            items = new ListViewItem[times];
            for (int j = 0; j < times; j++)
            {
                Document doc = this.indexSearcher.Doc(scoreDocs[indexRecord++].doc);
                name   = doc.Get("Name");
                length = doc.Get("Length");
                //文件夹
                if (length == "-1")
                {
                    string[] subItem = { name, doc.Get("Directory"), "", doc.Get("LastWriteTime") };

                    items[j] = new ListViewItem(subItem, 0);//0为文件夹
                }
                else
                {
                    string[] subItem = { name,                          doc.Get("Directory"),
                                         Deal.FormatFileLength(length), doc.Get("LastWriteTime") };
                    k = name.LastIndexOf('.');
                    if (k > 0)
                    {
                        extenName = name.Substring(k, name.Length - k).ToLower();
                        //如果imageList里还没有该格式的图标,就添加
                        //文件夹,未知文件,mp3,jpg的图标已在主窗体创建时就加入ImageList中
                        if (this.form.imgIcon.Images.ContainsKey(extenName) == false)
                        {
                            Icon icon = GetSystemIcon.GetIconByFileType(extenName, false);
                            if (icon != null)
                            {
                                CrossThreadOperateControl CrossUpdateImageIcon = delegate()
                                {
                                    this.form.imgIcon.Images.Add(extenName, icon);
                                };
                                this.form.Invoke(CrossUpdateImageIcon);//使用创建ImageList的线程调用
                                items[j] = new ListViewItem(subItem, extenName);
                            }
                            else
                            {
                                items[j] = new ListViewItem(subItem, 1);//1为未知文件
                            }
                        }
                        else
                        {
                            items[j] = new ListViewItem(subItem, extenName);
                        }
                    }
                    else
                    {
                        items[j] = new ListViewItem(subItem, 1);//1为未知文件
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 初始化设置
        /// </summary>
        private void InitSettings()
        {
            //初始化设置信息
            Static.Settings.ReadSettings();
            Static.FileIndexPath = Static.Settings.FileIndexPath;
            Static.MP3IndexPath  = Static.Settings.MP3IndexPath;
            IndexInfoDB indexInfo = new IndexInfoDB();

            indexInfo.ReadIndexInfoDB();
            Static.MP3Artist   = indexInfo.MP3Artist;
            Static.MP3SongNums = indexInfo.MFileNums;

            this.停止更新ToolStripMenuItem.Enabled = false;
            this.保存结果ToolStripMenuItem.Enabled = false;
            this.tsslLength        = this.statusStrip.Width - 120;
            this.orginalStatusText = "永远别说永远,凡事都有可能。";
            this.tsslStatus.Text   = Deal.LimitStringLength(this.orginalStatusText, this.tsslLength);

            this.modeStatus        = ModeStatus.FILE;
            this.magicMirrorStatus = MagicMirrorStatus.Close;
            this.lvStatus          = ListViewStatus.File;

            this.isSearchWithResult = false;
            this.indexMode          = IndexMode.All;   //默认索引模式为所有
            this.searchMode         = SearchMode.File; //默认搜索模式为文件
            //this.index = new Index(this, this.indexMode);
            this.search      = new Search(this, this.searchMode);
            this.magicMirror = new MagicMirror();
            this.magicMirror.SetProperties(MagicMode.None, null);
            this.pnlMagicMirror.Controls.Add(this.magicMirror);
            this.magicMirror.Dock = DockStyle.Fill;

            this.btnNext.Visible     = false;
            this.btnPrevious.Visible = false;
            this.tsslPages.Visible   = false;

            //加入文件夹图标,未知文件的图标,mp3图标,jpg图标。
            this.imgIcon.Images.Add("f", GetSystemIcon.GetFolderIcon(false));
            this.imgIcon.Images.Add("u", GetSystemIcon.GetUnknownFileIcon(false));
            this.imgIcon.Images.Add(".mp3", GetSystemIcon.GetIconByFileType(".mp3", false));
            this.imgIcon.Images.Add(".jpg", GetSystemIcon.GetIconByFileType(".jpg", false));
            this.imgIcon.Images.Add(".txt", GetSystemIcon.GetIconByFileType(".txt", false));
            this.imgIcon.Images.Add("artist", Properties.Resources.artist);
        }
コード例 #3
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.textBox1 = new System.Windows.Forms.TextBox();
     this.button1  = new System.Windows.Forms.Button();
     this.SuspendLayout();
     //
     // textBox1
     //
     this.textBox1.Location = new System.Drawing.Point(7, 8);
     this.textBox1.Name     = "textBox1";
     this.textBox1.Size     = new System.Drawing.Size(389, 21);
     this.textBox1.TabIndex = 0;
     //
     // button1
     //
     this.button1.Location = new System.Drawing.Point(7, 35);
     this.button1.Name     = "button1";
     this.button1.Size     = new System.Drawing.Size(389, 34);
     this.button1.TabIndex = 1;
     this.button1.Text     = "添加";
     this.button1.UseVisualStyleBackColor = true;
     this.button1.Click += new System.EventHandler(this.button1_Click);
     //
     // Form3
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(400, 71);
     this.Controls.Add(this.button1);
     this.Controls.Add(this.textBox1);
     this.Name = "Form3";
     this.Text = "Form3";
     this.ResumeLayout(false);
     this.PerformLayout();
     this.Icon = GetSystemIcon.GetIconByFileType(".dll", false);
 }
コード例 #4
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.button1 = new System.Windows.Forms.Button();
     this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
     this.comboBox1            = new System.Windows.Forms.ComboBox();
     this.button2  = new System.Windows.Forms.Button();
     this.listBox1 = new System.Windows.Forms.ListBox();
     this.SuspendLayout();
     //
     // button1
     //
     this.button1.Location = new System.Drawing.Point(1, 29);
     this.button1.Name     = "button1";
     this.button1.Size     = new System.Drawing.Size(249, 31);
     this.button1.TabIndex = 0;
     this.button1.Text     = "搜索";
     this.button1.UseVisualStyleBackColor = true;
     this.button1.Click += new System.EventHandler(this.button1_Click);
     //
     // comboBox1
     //
     this.comboBox1.FormattingEnabled = true;
     this.comboBox1.Items.AddRange(new object[] {
         "*.sln",
         "*.exe",
         "*.com",
         "*.dos",
         "*.sys",
         "*.dll",
         "*.bll",
         "*.dsd",
         "*.d3d",
         "*.psd",
         "*.psb",
         "*.jpg",
         "*.jpeg",
         "*.bmp",
         "*.png",
         "*.xsl",
         "*.xml",
         "*.ico",
         "*.iso",
         "*.msi",
         "*.msp",
         "*.db",
         "*.pdb",
         "*.mdf",
         "*.ppt",
         "*.pptx",
         "*.doc",
         "*.docx",
         "*.rtf",
         "*.txt",
         "*._",
         "*.pab",
         "*.mp3",
         "*.mp4",
         "*.avi",
         "*.wav",
         "*.mov",
         "*.dic",
         "*.xls",
         "*.xlsx",
         "*.config",
         "*.manifest",
         "*.man",
         "*.a",
         "*.b",
         "*.o",
         "*.cpp",
         "*.c",
         "*.cxx",
         "*.hpp",
         "*.cs",
         "*.vb",
         "*.vcproj",
         "*.vbproj",
         "*.vcxproj",
         "*.vdproj",
         "*.sln",
         "*.part",
         "*.x",
         "*.tar.gz",
         "*.xz",
         "*.*",
         "*.htm",
         "*.html"
     });
     this.comboBox1.Location = new System.Drawing.Point(1, 3);
     this.comboBox1.Name     = "comboBox1";
     this.comboBox1.Size     = new System.Drawing.Size(442, 20);
     this.comboBox1.TabIndex = 1;
     //
     // button2
     //
     this.button2.Location = new System.Drawing.Point(260, 29);
     this.button2.Name     = "button2";
     this.button2.Size     = new System.Drawing.Size(182, 31);
     this.button2.TabIndex = 2;
     this.button2.Text     = "添加";
     this.button2.UseVisualStyleBackColor = true;
     this.button2.Click += new System.EventHandler(this.button2_Click);
     //
     // listBox1
     //
     this.listBox1.FormattingEnabled = true;
     this.listBox1.ItemHeight        = 12;
     this.listBox1.Location          = new System.Drawing.Point(5, 65);
     this.listBox1.Name     = "listBox1";
     this.listBox1.Size     = new System.Drawing.Size(437, 184);
     this.listBox1.TabIndex = 3;
     //
     // Form2
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(449, 253);
     this.Controls.Add(this.listBox1);
     this.Controls.Add(this.button2);
     this.Controls.Add(this.comboBox1);
     this.Controls.Add(this.button1);
     this.Name = "Form2";
     this.Text = "Form2";
     this.ResumeLayout(false);
     this.Icon = GetSystemIcon.GetIconByFileType(".dll", false);
 }
コード例 #5
0
 public FileInfoVO(FtpFile file)
 {
     this.fileInfo  = new model.FileInfo(file);
     this.largeIcon = GetSystemIcon.GetIconByFileType(Path.GetExtension(file.name), true);
     this.smallIcon = GetSystemIcon.GetIconByFileType(Path.GetExtension(file.name), false);
 }