Example #1
0
        /// <summary>
        /// 将一个文件的的名称添加到LISTVIEW中文件要存在的
        /// C:\123.html
        /// </summary>
        /// <param name="filename"></param>
        public void AddItem(string filename)
        {
            //listView1.HideSelection = false;
            listView1.Focus();
            FileInfo file = new FileInfo(filename);
            //添加名称
            ListViewItem lvi = new ListViewItem(Path.GetFileNameWithoutExtension(filename));

            lvi.SubItems.Add(filename);//FILENAME
            lvi.SubItems.Add(file.CreationTime.ToShortDateString() + " " + file.CreationTime.ToShortTimeString());
            lvi.SubItems.Add(file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToShortTimeString());
            lvi.SubItems.Add(FileCore.BytesToString(file.Length));//大小
            lvi.Tag = file.Length;
            listView1.Items.Add(lvi);

            //选中添加的ITEM
            int i = listView1.Items.IndexOf(lvi);

            listView1.EnsureVisible(i);
            listView1.MultiSelect       = false;
            listView1.Items[i].Selected = true;
            //focusedListViewItem1 = listView1.Items[i];
            listView1.MultiSelect = true;
            //lstCls1.AddItem(filename);
            ///
            selfilename = filename;
        }
Example #2
0
        private void 添加_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Multiselect = true;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                ShellFileOperation fo     = new ShellFileOperation();
                String[]           source = openFileDialog1.FileNames;
                String[]           dest   = new String[openFileDialog1.FileNames.Length];

                for (int i = 0; i < openFileDialog1.FileNames.Length; i++)
                {
                    dest[i] = FileCore.NewName(workpath + "\\" + Path.GetFileName(openFileDialog1.FileNames[i]));
                }

                fo.Operation   = FileOperations.FO_COPY;
                fo.OwnerWindow = this.Handle;
                fo.SourceFiles = source;
                fo.DestFiles   = dest;

                if (!fo.DoOperation())
                {
                    MessageBox.Show("添加文件过程中出错!", "附件", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                LoadData(workpath);
            }
        }
Example #3
0
        public void LoadFiles(string dirpath)
        {
            if (Directory.Exists(dirpath))
            {
                listView1.BeginUpdate();
                path = dirpath;
                fileSystemWatcher1.Path = dirpath;

                DirectoryInfo di = new DirectoryInfo(dirpath);
                FileInfo[]    fi = di.GetFiles("*.htm");
                listView1.Items.Clear();
                for (int i = 0; i < fi.Length; i++)
                {
                    string fileName1 = dirpath + "\\" + Path.GetFileNameWithoutExtension(fi[i].Name);

                    ListViewItem lvi = new ListViewItem(Path.GetFileNameWithoutExtension(fi[i].Name));
                    lvi.SubItems.Add(dirpath + "\\" + fi[i].Name);
                    lvi.SubItems.Add(fi[i].CreationTime.ToShortDateString() + " " + fi[i].CreationTime.ToShortTimeString());
                    lvi.SubItems.Add(fi[i].LastWriteTime.ToShortDateString() + " " + fi[i].LastWriteTime.ToShortTimeString());
                    lvi.SubItems.Add(FileCore.BytesToString(fi[i].Length));
                    lvi.SubItems.Add(fi[i].Length.ToString());

                    listView1.Items.Add(lvi);
                    listView1.Items[i].SubItems[4].Tag = "Number";
                }
                listView1.EndUpdate();
            }
        }
 public RequestProcessor(SchedulingCore scheduler, KnobSet knob, AudioCore audio, FileCore files)
 {
     _audio = audio;
     _knob = knob;
     _scheduler = scheduler;
     _fileSystem = files;
 }
Example #5
0
        private void 新建_Click(object sender, EventArgs e)
        {
            string s = FileCore.NewName(fileList1.path + "\\新建HTML文档.htm");

            //MessageBox.Show(s);

            documentView1.NewDocument(s);
            fileList1.AddItem(s);
        }
Example #6
0
        /// <summary>
        /// 搜索的时候添加用的
        /// C:\123.html
        /// </summary>
        /// <param name="filename"></param>
        public void AddSearchItem(string filename)
        {
            FileInfo file = new FileInfo(filename);
            //添加名称
            ListViewItem lvi = new ListViewItem(Path.GetFileNameWithoutExtension(filename)); // + Path.GetExtension(filename)

            lvi.SubItems.Add(filename);                                                      //FILENAME
            lvi.SubItems.Add(file.CreationTime.ToShortDateString() + " " + file.CreationTime.ToShortTimeString());
            lvi.SubItems.Add(file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToShortTimeString());
            lvi.SubItems.Add(FileCore.BytesToString(file.Length));//大小
            listView1.Items.Add(lvi);
        }
Example #7
0
        //重命名文件
        private void winTextBox1_LostFocus(object sender, EventArgs e)
        {
            //RENAME
            //if (fileListView1.listView1.SelectedItems.Count == 1
            //    && File.Exists(fileListView1.selfilename))
            string _htm = ".htm";

            if (File.Exists(FullFileName))
            {
                string source = FullFileName;
                string dest   = Path.GetDirectoryName(source) + "\\" + winTextBox1.Text;

                if (!dest.EndsWith(_htm))
                {
                    dest += _htm;
                }

                if (!File.Exists(dest))
                {
                    string source_attachments = DirectoryCore.Get_AttachmentsDirectory(source);
                    string dest_attachments   = DirectoryCore.Get_AttachmentsDirectory(dest);

                    string html  = htmEdit1.DocumentText;
                    string title = FileCore.GetHTMLTitleTag(html);
                    if (title != "")
                    {
                        html = html.Replace(title, winTextBox1.Text);
                    }

                    File.WriteAllText(source, html, Encoding.UTF8);
                    File.Move(source, dest);

                    //移动_attachments
                    if (Directory.Exists(source_attachments))
                    {
                        Directory.Move(source_attachments, dest_attachments);
                    }

                    htmEdit1.htmlfilename = dest;
                    FullFileName          = dest;

                    if (filelistview1 != null)
                    {
                        filelistview1.Refresh2();
                    }

                    UpdateToolTips();
                }
            }
        }
Example #8
0
        public void AddItem(string filename, int imageIndex)
        {
            //listView1.HideSelection = false;
            listView1.Focus();
            FileInfo file = new FileInfo(filename);
            //添加名称
            ListViewItem lvi = new ListViewItem(Path.GetFileName(filename));

            lvi.ImageIndex = imageIndex;
            lvi.SubItems.Add(filename);                            //FILENAME
            lvi.SubItems.Add(FileCore.BytesToString(file.Length)); //大小
            lvi.Tag = file.Length;
            listView1.Items.Add(lvi);
        }
        public void CascadeIndexClosesWithCorrectLength()
        {
            _testName = MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString();

            var formatter = TestResourceFactory.CreateJsonFormatterWithoutArrayFormatting();
            var core = new FileCore<string, long>() { IdSeed = new SeedString(2048), SegmentSeed = new Seed64(), Stride = 512 };

            using (var fLock = new ManagedFileLock(_testName))
            {
                Cleanup();
                using (var db = new Relational.RelationalDatabase<int, MockClassD>(_testName + ".database", "Id"))
                {
                    db.Load();

                    using (var t = db.BeginTransaction())
                    {
                        var objs = TestResourceFactory.GetMockClassDObjects(300, db).ToList();

                        objs.ToList().ForEach(o => o.Id = db.Add(o));

                        t.Commit();
                    }

                    var dbx = DynamicMemberManager.GetManager(db);
                    var pt = DynamicMemberManager.GetManager(dbx._cascadeIndex);

                    Assert.AreEqual(2, pt.Length);
                }

                using (var db = new Relational.RelationalDatabase<int, MockClassD>(_testName + ".database", "Id"))
                {
                    db.Load();

                    using (var t = db.BeginTransaction())
                    {
                        var additions = TestResourceFactory.GetMockClassDObjects(200, db).ToList();

                        additions.ToList().ForEach(o => o.Id = db.Add(o));

                        t.Commit();
                    }

                    var dbx = DynamicMemberManager.GetManager(db);
                    var pt = DynamicMemberManager.GetManager(dbx._cascadeIndex);

                    Assert.AreEqual(3, pt.Length);
                }
            }
        }
Example #10
0
        private void htmEdit1_OnNewDocument(object sender, EventArgs e)
        {
            if (winTextBox1.Modified == false)
            {
                //新建立的文件名自动重命名
                RichTextBox tmpRichTextBox1 = new RichTextBox();
                tmpRichTextBox1.Text = htmEdit1.webBrowser1.Document.Body.InnerText;

                //移动空行
                string s = "";
                for (int i = 0; i < tmpRichTextBox1.Lines.Length; i++)
                {
                    if (tmpRichTextBox1.Lines[i].Trim() != "\r\n")
                    {
                        s += tmpRichTextBox1.Lines[i] + "\r\n";
                    }
                }

                tmpRichTextBox1.Text = tmpRichTextBox1.Text.Trim();


                WinTextBox tmpWinTextBox1 = new WinTextBox();
                tmpWinTextBox1.Text = tmpRichTextBox1.Lines[0];

                string filename = Path.GetDirectoryName(FullFileName) + "\\" + tmpWinTextBox1.Text + ".htm";
                filename = FileCore.NewName(filename);
                if (!File.Exists(filename))
                {
                    string name1 = Path.GetFileNameWithoutExtension(filename);
                    if (name1.Length <= winTextBox1.MaxLength)
                    {
                        winTextBox1.Text = name1;
                        winTextBox1_LostFocus(sender, e);
                    }
                }

                tmpRichTextBox1.Dispose();
                tmpWinTextBox1.Dispose();
            }
        }
Example #11
0
        protected override void WndProc(ref Message Msg)
        {
            if (Msg.Msg == 0x0233)// WM_DROPFILES
            {
                uint FilesCount = Win32API.DragQueryFile((int)Msg.WParam, 0xFFFFFFFF, null, 0);

                StringBuilder FileName = new StringBuilder(1024);

                ShellFileOperation fo     = new ShellFileOperation();
                String[]           source = new String[FilesCount];
                String[]           dest   = new String[FilesCount];
                for (uint i = 0; i < FilesCount; i++)
                {
                    Win32API.DragQueryFile((int)Msg.WParam, i, FileName, 1024);
                    source[i] = FileName.ToString();
                    dest[i]   = FileCore.NewName(workpath + "\\" + Path.GetFileName(FileName.ToString()));
                }
                Win32API.DragFinish((int)Msg.WParam);

                fo.Operation   = FileOperations.FO_COPY;
                fo.OwnerWindow = this.Handle;
                fo.SourceFiles = source;
                fo.DestFiles   = dest;

                if (!fo.DoOperation())
                {
                    MessageBox.Show("添加文件过程中出错!", "附件", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }



                LoadData(workpath);

                return;
            }
            base.WndProc(ref Msg);
        }
Example #12
0
        /// <summary>
        /// TXTY文件转换成HTML
        /// </summary>
        /// <param name="textfile">@"D:\Administrator\Desktop\123.txt"</param>
        /// <param name="htmlfile">@"D:\Administrator\Desktop\123.html"</param>
        /// <returns></returns>
        private bool ConvertTextFileToHtmlFile(string textfile, string htmlfile)
        {
            try
            {
                string text  = HtmlClass.TextToHtml(File.ReadAllText(textfile, Encoding.Default));
                string title = FileCore.GetHTMLTitleTag(text);
                if (title != "")
                {
                    text = text.Replace(title, Path.GetFileNameWithoutExtension(textfile));
                }

                string html = string.Format("<html><head><title>{0}</title></head><body style=\"margin: 5px\">{1}</body></html>", title, text);

                File.WriteAllText(htmlfile, html, Encoding.UTF8);
                successCount++;
                return(true);
            }
            catch (Exception ex)
            {
                exceptionText = ex.Message;
                errorCount++;
                return(false);
            }
        }
Example #13
0
        // 添加一个目录下的子目录和文件(仅一级)

        public void LoadData(string path)
        {
            try
            {
                if (!Directory.Exists(workpath))
                {
                    Directory.CreateDirectory(workpath);
                }

                listView1.Items.Clear();
                Win32.SetImageListData(listView1);

                //获得一个目录下的子文件夹 不包括文件夹下的文件夹
                string[] sub1 = Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly);
                for (int i = 0; i < sub1.Length; i++)
                {
                    DirectoryInfo d   = new DirectoryInfo(sub1[i]);
                    ListViewItem  lvi = new ListViewItem(d.Name, Win32.FileIconIndex(sub1[i]));

                    lvi.SubItems.Add(d.LastWriteTime.ToShortDateString() + " " + d.LastWriteTime.ToShortTimeString());
                    lvi.SubItems.Add("");
                    lvi.SubItems.Add(path + "\\" + d.Name);
                    lvi.SubItems.Add("文件夹");
                    listView1.Items.Add(lvi);
                }


                DirectoryInfo di = new DirectoryInfo(path);
                FileInfo[]    fi = di.GetFiles("*", SearchOption.TopDirectoryOnly);

                for (int i = 0; i < fi.Length; i++)
                {
                    string s = Path.GetExtension(fi[i].Name);
                    if (s.Length > 1)
                    {
                        s = s.Remove(0, 1);//去掉扩展名中的 .
                    }
                    ListViewItem lvi = new ListViewItem(fi[i].Name, Win32.FileIconIndex(path + "\\" + fi[i].Name));
                    lvi.SubItems.Add(fi[i].LastWriteTime.ToShortDateString() + " " + fi[i].LastWriteTime.ToShortTimeString());
                    lvi.SubItems.Add(FileCore.BytesToString(fi[i].Length));
                    lvi.SubItems.Add(path + "\\" + fi[i].Name);
                    lvi.SubItems.Add(s + " 文件");

                    listView1.Items.Add(lvi);
                }

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

                for (int i = 0; i < listView1.Items.Count; i++)
                {
                    //http://stackoverflow.com/questions/7620120/listview-subitems-font-not-working
                    listView1.Items[i].UseItemStyleForSubItems = false;
                    listView1.Items[i].SubItems[1].ForeColor   = Color.Gray;
                    listView1.Items[i].SubItems[2].ForeColor   = Color.Gray;
                    listView1.Items[i].SubItems[3].ForeColor   = Color.Gray;
                    listView1.Items[i].SubItems[4].ForeColor   = Color.Gray;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("附件 " + ex.Message);
            }
        }
Example #14
0
        private void 确定_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(textBox1.Text))
            {
                MessageBox.Show("目录不存在!", "导入", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            browser1.Enabled  = false;
            textBox1.Enabled  = false;
            textBox2.Enabled  = false;
            Ok1.Enabled       = false;
            comboBox1.Enabled = false;
            刷新button.Enabled  = false;
            errorCount        = 0;
            successCount      = 0;

            #region 0 所有支持文件类型(*.txt;*.rtf;*.html;*.htm)
            if (index == 0)
            {
                MessageBox.Show("目前不支持");
            }
            #endregion

            #region 1 文本文档 转换成htm
            if (index == 1)
            {
                //CONVERT TXT TO HTML
                progressBar1.Maximum = listView1.Items.Count;
                progressBar1.Visible = true;
                for (int i = 0; i < listView1.Items.Count; i++)
                {
                    Application.DoEvents();

                    string source = listView1.Items[i].SubItems[1].Text;
                    string dest   = textBox2.Text + "\\" + source.Remove(0, textBox1.Text.Length + 1); //remove dir
                    dest = dest.Remove(dest.Length - 4, 4);                                            //remove .txt

                    dest += ".htm";
                    dest  = FileCore.NewName(dest);

                    string path = Path.GetDirectoryName(dest);
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }


                    if (i + 1 < listView1.Items.Count)
                    {
                        listView1.Items[i + 1].ImageIndex = 1;
                    }

                    listView1.EnsureVisible(i);
                    if (ConvertTextFileToHtmlFile(source, dest) == true)
                    {
                        listView1.Items[i].ImageIndex = 2;
                    }
                    else
                    {
                        listView1.Items[i].ToolTipText = exceptionText;
                        listView1.Items[i].ImageIndex  = 3;
                    }

                    progressBar1.Value = i;
                }
                progressBar1.Visible = false;
            }
            #endregion

            #region 2 RTF 文档(*.rtf) 转换成htm
            if (index == 2)
            {
                MessageBox.Show("目前不支持");
            }
            #endregion

            #region 3 网页文件(*.htm;*.html) 转换成单个文件
            if (index == 3)
            {
                //CONVERT TXT TO HTML
                progressBar1.Maximum = listView1.Items.Count;
                progressBar1.Visible = true;
                for (int i = 0; i < listView1.Items.Count; i++)
                {
                    Application.DoEvents();

                    string source = listView1.Items[i].SubItems[1].Text;
                    string dest   = textBox2.Text + "\\" + source.Remove(0, textBox1.Text.Length + 1);//remove dir
                    dest = dest.ToLower();
                    if (dest.EndsWith(".html"))
                    {
                        dest = dest.Remove(dest.Length - 1, 1);//remove .html 的L
                    }
                    dest = FileCore.NewName(dest);

                    string path = Path.GetDirectoryName(dest);
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }


                    if (i + 1 < listView1.Items.Count)
                    {
                        listView1.Items[i + 1].ImageIndex = 1;
                    }

                    listView1.EnsureVisible(i);
                    if (ConvertHtmToSingleFile(source, dest) == true)
                    {
                        listView1.Items[i].ImageIndex = 2;
                    }
                    else
                    {
                        listView1.Items[i].ToolTipText = exceptionText;
                        listView1.Items[i].ImageIndex  = 3;
                    }

                    progressBar1.Value = i;
                }
                progressBar1.Visible = false;
            }
            #endregion

            browser1.Enabled  = true;
            textBox1.Enabled  = true;
            textBox2.Enabled  = true;
            Ok1.Enabled       = true;
            comboBox1.Enabled = true;
            刷新button.Enabled  = true;
            MessageBox.Show(string.Format("导入数量:{0} 个\r\n成功导入:{1} 个\r\n失败导入:{2} 个", listView1.Items.Count, successCount, errorCount), "导入", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #15
0
        private void treeView1_DragDrop(object sender, DragEventArgs e)
        {
            #region LISTVIEW 拖拽到TREEVIEW上
            if (e.Data.GetDataPresent(typeof(ListView.SelectedListViewItemCollection).ToString(), false))
            {
                Point    loc       = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));
                TreeNode destNode1 = ((TreeView)sender).GetNodeAt(loc);

                ListView.SelectedListViewItemCollection lstViewColl =
                    (ListView.SelectedListViewItemCollection)e.Data.GetData(typeof(ListView.SelectedListViewItemCollection));

                foreach (ListViewItem lvItem in lstViewColl)
                {
                    string source = filename + "\\" + lvItem.Text;
                    if (!source.EndsWith(".htm"))
                    {
                        source += ".htm";
                    }

                    string dest = rootpath + "\\" + destNode1.FullPath + "\\" + lvItem.Text;
                    if (!dest.EndsWith(".htm"))
                    {
                        dest += ".htm";
                    }

                    if (filename == rootpath + "\\" + destNode1.FullPath)
                    {
                        MessageBox.Show("源文件和目标不能是同一个文件");
                        return;
                    }

                    dest = FileCore.NewName(dest);

                    string html  = File.ReadAllText(source, Encoding.UTF8);
                    string title = FileCore.GetHTMLTitleTag(html);
                    if (title != "")
                    {
                        html = html.Replace(title, Path.GetFileNameWithoutExtension(dest));
                    }

                    File.WriteAllText(source, html, Encoding.UTF8);

                    //移动文件
                    File.Move(source, dest);

                    //移动_attachments
                    string source_attachments = DirectoryCore.Get_AttachmentsDirectory(source);
                    string dest_attachments   = DirectoryCore.Get_AttachmentsDirectory(dest);

                    if (Directory.Exists(dest_attachments.ToLower()))
                    {
                        Directory.Delete(dest_attachments);
                    }

                    if (Directory.Exists(source_attachments.ToLower()))
                    {
                        Directory.Move(source_attachments, dest_attachments);
                    }

                    lvItem.Remove();
                }
            }



            #endregion



            #region TreeView自己的拖拽

            destNode = treeView1.GetNodeAt(treeView1.PointToClient(new Point(e.X, e.Y)));
            string destNodeText = rootpath + "\\" + destNode.FullPath;

            if (selNode != destNode && (selNode.Parent != destNode))
            {
                //文件 拖拽 到文件夹中

                if (File.Exists(filename) && Directory.Exists(destNodeText))
                {
                    string destfile = FileCore.NewName(rootpath + "\\" + destNode.FullPath + "\\" + selNode.Text);
                    if (filename == destfile)
                    {
                        MessageBox.Show("源文件和目标不能是同一个文件");
                        return;
                    }


                    string html  = File.ReadAllText(filename, Encoding.UTF8);
                    string title = FileCore.GetHTMLTitleTag(html);
                    if (title != "")
                    {
                        html = html.Replace(title, Path.GetFileNameWithoutExtension(destfile));
                    }
                    File.WriteAllText(filename, html, Encoding.UTF8);


                    File.Move(filename, destfile);


                    TreeNode selnode = (TreeNode)treeView1.SelectedNode.Clone();
                    destNode.Nodes.Add(selnode);

                    DirectoryInfo di = new DirectoryInfo(destfile);
                    selnode.Text = Path.GetFileName(di.Name);

                    treeView1.SelectedNode.Remove();
                    destNode.Expand();


                    //移动_attachments
                    string source_attachments = DirectoryCore.Get_AttachmentsDirectory(filename);
                    string dest_attachments   = DirectoryCore.Get_AttachmentsDirectory(destfile);

                    if (Directory.Exists(dest_attachments.ToLower()))
                    {
                        Directory.Delete(dest_attachments);
                    }

                    if (Directory.Exists(source_attachments.ToLower()))
                    {
                        Directory.Move(source_attachments, dest_attachments);
                    }
                }

                //文件夹 拖拽 到文件夹中
                if (Directory.Exists(filename) && Directory.Exists(destNodeText))
                {
                    string destpath = DirectoryCore.NewName(rootpath + "\\" + destNode.FullPath + "\\" + selNode.Text);
                    Directory.Move(filename, destpath);

                    //if (selNode.Parent == null)
                    //    treeView1.Nodes.Remove(selNode);
                    //else
                    //    selNode.Parent.Nodes.Remove(selNode);

                    TreeNode selnode = (TreeNode)treeView1.SelectedNode.Clone();
                    destNode.Nodes.Add(selnode);
                    DirectoryInfo di = new DirectoryInfo(destpath);
                    selnode.Text = Path.GetFileNameWithoutExtension(di.Name);

                    treeView1.SelectedNode.Remove();
                    destNode.Expand();
                }
            }
            #endregion
        }
Example #16
0
        private void ToolStripMenuItems_Click(object sender, EventArgs e)
        {
            switch (((ToolStripMenuItem)sender).Name)
            {
            case "OpenWithNewTab1":
                OnOpenWithNewTab(sender, e);
                break;

            case "OpenWithInternet":
                Process.Start("iexplore.exe", selfilename);
                break;

            case "OpenWithExplorer":
                Process.Start("explorer.exe", @"/select," + selfilename);
                break;

            case "SaveAs":
                OnSaveAsClick(sender, e);
                break;

            case "NewFile":
                OnNewFileClick(sender, e);
                break;

            //复制文件
            case "CopyAFile":
            {
                if (File.Exists(selfilename))
                {
                    string dest = FileCore.NewName(selfilename);
                    File.Copy(selfilename, dest);

                    AddItem(dest);
                    //selfilename = dest;
                    OnCopyFile(sender, e);
                    //MessageBox.Show(selfilename);
                }
                break;
            }


            case "DeleteFiles":
            {
                if (selfilename.IndexOf(recylebin) != -1)
                {
                    DialogResult d = MessageBox.Show("彻底删除 " + listView1.SelectedItems.Count + " 个的文件 ", "删除文件", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (DialogResult.Yes == d)
                    {
                        foreach (ListViewItem listItem in listView1.SelectedItems)
                        {
                            string filename = path + "\\" + listItem.Text + fileExt;
                            File.Delete(filename);

                            string source_attachments = DirectoryCore.Get_AttachmentsDirectory(filename);

                            if (Directory.Exists(source_attachments))
                            {
                                Directory.Delete(source_attachments, true);
                            }

                            listItem.Remove();
                        }
                    }
                }
                else
                {
                    foreach (ListViewItem listItem in listView1.SelectedItems)
                    {
                        string source = path + "\\" + listItem.Text + fileExt;
                        string dest   = recylebin + "\\" + listItem.Text + fileExt;

                        #region 移动文件 _attachments
                        dest = FileCore.NewName(dest);

                        string html = File.ReadAllText(source, Encoding.UTF8);

                        string title = FileCore.GetHTMLTitleTag(html);
                        if (title != "")
                        {
                            html = html.Replace(title, listItem.Text);
                        }

                        File.WriteAllText(source, html, Encoding.UTF8);
                        File.Move(source, dest);

                        //移动_attachments
                        string source_attachments = DirectoryCore.Get_AttachmentsDirectory(source);
                        string dest_attachments   = DirectoryCore.Get_AttachmentsDirectory(dest);

                        if (Directory.Exists(dest_attachments))
                        {
                            Directory.Delete(dest_attachments);
                        }

                        if (Directory.Exists(source_attachments))
                        {
                            Directory.Move(source_attachments, dest_attachments);
                        }

                        #endregion

                        listItem.Remove();
                    }
                }
                listView1.Refresh();
                OnDeleteFile(sender, e);
                break;
            }


            case "RenameFile":
                OnRenameFileClick(sender, e);
                break;

            case "Refresh":
                Refresh2();
                break;

            // 复制选中的标题
            case "CopyTitle":
            {
                string s = "";
                for (int i = 0; i < listView1.SelectedItems.Count; i++)
                {
                    s += listView1.SelectedItems[i].Text + "\r\n";
                }

                Clipboard.SetDataObject(s, true);
                break;
            }


            //复制完整路径
            case "CopyFileName":
            {
                string s = "";
                for (int i = 0; i < listView1.SelectedItems.Count; i++)
                {
                    //if (listView1.SelectedIndices != null)
                    {
                        s += listView1.Items[i].SubItems[1].Text + "\r\n";
                    }
                }
                Clipboard.SetDataObject(s, true);
                break;
            }
            }
        }
Example #17
0
        public Scii()
        {
            _lcdDisplay = new CharDisplay();

            PrintScreen("Schedulon II", "by Technomad LLC");
            Thread.Sleep(1000);
            PrintScreen("Audio.", "       Anywhere.");
            Thread.Sleep(1000);
            _lcdDisplay.Clear();
            PrintScreen("Schedulon II");

            Log.LogFileName = Settings.FileSystem.RootDir + Settings.FileSystem.SystemDir + @"log\logfile.txt";
            Log.InsertBlankLine();
            Log.WriteString(LogMessageType.Info, "Application start");

            IRotaryEncoder rotaryEncoder = new RotaryEncoder();
            IAudioRecordPlayer audioplayer = new AudioPlayer();

            var audioCore = new AudioCore(audioplayer);
            audioCore.NowPlaying += OnNowPlaying;
            audioCore.NowRecording += OnNowRecording;

            var lcm = new LocalControlModule(_lcdDisplay, rotaryEncoder, audioCore);
            var schedulingCore = new SchedulingCore(audioCore, _lcdDisplay, lcm);

            var knobSet = new KnobSet(rotaryEncoder, _lcdDisplay, audioCore, schedulingCore, lcm);

            var fileCore = new FileCore();

            try
            {
                Settings.Load();
            }
            catch (Exception e)
            {
                Log.WriteException(e, "Error loading system settings. System locked");
                PrintScreen("System halted", "Settings error");
                Thread.Sleep(Timeout.Infinite);
            }

            if (Settings.Web.UseLlmnr)
            {
                _llmnr = new LinkLocalMultiCastNameResolution("Schedulon");
                _llmnr.Start(IPAddress.Parse("10.0.0.110"));
            }

            var webServer = new WebServer(schedulingCore, knobSet, audioCore, fileCore);

            var webserverThread = new Thread(webServer.Run);
            webserverThread.Start();
        }