Ejemplo n.º 1
0
        private void miCopyTagFullPathEx_Click(object sender, RoutedEventArgs e)
        {
            UpdateCurrentTagByContextMenu();
            string dir = CfgPath.GetDirByTag(SelectedTag.Title, true);//拷贝目录名,需要保证路径存在

            dir = System.IO.Path.Combine(dir, DateTime.Now.ToString("yyyyMMdd") + "-");
            ClipBoardSafe.SetText(dir);
        }
Ejemplo n.º 2
0
        private string[] CopyToHouse(string[] list, string tag)
        {
            List <string> ret     = new List <string>();
            List <string> scrList = new List <string>();
            List <string> dstList = new List <string>();

            foreach (string f in list)
            {
                if (PathHelper.IsValidWebLink(f))
                {
                    ret.Add(f);
                }
                else if (!PathHelper.IsValidFS(f))
                {
                    Logger.E("Copy To House: File not Exist " + f);
                    ret.Add(f);
                }
                else
                {
                    System.Diagnostics.Debug.Assert(PathHelper.IsValidFS(f));
                    FileInfo fi      = new FileInfo(f);
                    string   dstDir  = CfgPath.GetDirByTag(tag, true);//新建文件,保证目录存在
                    string   dstFile = System.IO.Path.Combine(dstDir, fi.Name);
                    if (dstFile == f)
                    {
                        ret.Add(f);
                    }
                    else
                    {
                        ret.Add(dstFile);
                        if (!System.IO.File.Exists(dstFile) && !System.IO.Directory.Exists(dstFile))
                        {
                            scrList.Add(f);
                            dstList.Add(dstFile);
                        }
                    }
                }
            }

            FileShell.SHCopyFile(scrList.ToArray(), dstList.ToArray());
            return(ret.ToArray());

            /*
             * if(dstFile==f)
             * {
             *  return f;
             * }
             * if (!System.IO.File.Exists(dstFile) && !System.IO.Directory.Exists(dstFile))//TODO 已经存在的需要提示覆盖、放弃、重命名
             * {
             *  if(FileShell.CopyFile(f, dstFile))
             *  {
             *      return dstFile;
             *  }
             * }
             * return null;*/
        }
Ejemplo n.º 3
0
        public void TestFS_FilesRelocationTest()
        {
            string testFile = @"B:\hello";

            File.Create(testFile).Close();
            FilesRelocationTest(new string[] { CfgPath.GetDirByTag("test", true) + "\\hello" },
                                new string[] { testFile },
                                "test");
            File.Delete(testFile);
        }
Ejemplo n.º 4
0
        public void KeepVDir(string tag)
        {
            //检查功能开关是否关闭,关闭直接返回
            if (!StaticCfg.Ins.Opt.KeepVDir)
            {
                return;
            }

            //一个新的tag,添加在头部
            if (!TagHistory.Contains(tag))
            {
                while (TagHistory.Count >= StaticCfg.Ins.MAX_TAG_VDIR)
                {
                    TagHistory.RemoveAt(0);
                }
                TagHistory.Add(tag);
            }
            //一个已有的tag,换一下位置
            else
            {
                TagHistory.Remove(tag);
                TagHistory.Add(tag);
            }

            //新建虚拟目录
            foreach (string t in TagHistory)
            {
                string tagVDir = CfgPath.GetVDirByTag(t);
                string tagDir  = CfgPath.GetDirByTag(t);//目前这个功能已经废除了,但不需要在这儿新建目录
                if (Directory.Exists(tagDir))
                {
                    PathHelper.LinkDir(tagVDir, tagDir);
                }
            }

            //如果溢出的话,淘汰老的目录
            DirectoryInfo vroot = new DirectoryInfo(CfgPath.VDir);

            DirectoryInfo[] vdirs     = vroot.GetDirectories();
            int             vDirCount = vdirs.Length;

            foreach (DirectoryInfo v in vdirs)
            {
                if (!TagHistory.Contains(v.Name) && vDirCount > StaticCfg.Ins.MAX_TAG_VDIR)
                {
                    v.Delete();
                    vDirCount--;
                }
            }
        }
Ejemplo n.º 5
0
        //private void scrollViewer_SizeChanged(object sender, SizeChangedEventArgs e)
        //{
        //    double h = e.NewSize.Height;


        //    //canvasMinHeight = this.ActualHeight - 60;
        //    //SetHeight();

        //    System.Diagnostics.Debug.WriteLine(e.NewSize.Height+" "+e.NewSize.Width + " "+rootTag + " "+currentTag);
        //    RedrawGraph();
        //}

        private void miNewFile_Click(object sender, RoutedEventArgs e)
        {
            UpdateCurrentTagByContextMenu();
            string         initDir = CfgPath.GetDirByTag(SelectedTag.Title, true);//新建文件,保证目录存在
            SaveFileDialog sf      = new SaveFileDialog();

            sf.InitialDirectory = initDir;

            sf.Filter = TemplateHelper.GetTemplateFileFilter();//"One文件(*.one)|*.one|Mind文件(*.xmind)|*.xmind";
            if (sf.ShowDialog() == true)
            {
                if (File.Exists(sf.FileName))
                {
                    MessageBox.Show("该文件已经存在" + sf.FileName, "文件名冲突", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                else
                {
                    FileInfo fi          = new FileInfo(sf.FileName);
                    string   tmplateFile = TemplateHelper.GetTemplateByExtension(fi.Extension);
                    if (tmplateFile != null && File.Exists(tmplateFile))
                    {
                        File.Copy(tmplateFile, sf.FileName);
                        AddUri(new List <string>()
                        {
                            sf.FileName
                        });
                        FileShell.OpenFile(sf.FileName);
                    }
                    else
                    {
                        File.Create(sf.FileName).Close();
                    }
                }
            }
        }
Ejemplo n.º 6
0
 private void miCopyTagFullPath_Click(object sender, RoutedEventArgs e)
 {
     UpdateCurrentTagByContextMenu();
     ClipBoardSafe.SetText(CfgPath.GetDirByTag(SelectedTag.Title, true)); //拷贝完整路径名,需要保证目录存在
 }