Пример #1
0
        public override void OnClick()
        {
            if (_hook.ResultsTree == null)
            {
                return;
            }
            TreeNode selectNode = _hook.ResultsTree.SelectedNode;

            if (selectNode != null)
            {
                if (MessageBox.Show("确定要删除该级目录?此操作将导致该目录无法恢复", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    ModStringpro.DeleteFolder((selectNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim());
                    _hook.ResultsTree.Nodes.Remove(selectNode);
                }
            }
        }
Пример #2
0
        private void NewResultsTreeName(TreeNode rootNode)
        {
            if (rootNode == null)
            {
                return;
            }
            if (!Directory.Exists((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim()))
            {
                return;
            }
            frmResultsTreeName pfrmResultsTreeName = new frmResultsTreeName();

            pfrmResultsTreeName.femText = "创建目录";
            pfrmResultsTreeName.LabText = "创建名称:";
            if (pfrmResultsTreeName.ShowDialog() == DialogResult.OK)
            {
                string strNewName = pfrmResultsTreeName.ResultsTreeName;
                if (strNewName == "")
                {
                    return;
                }
                string strPath = (rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim() + "\\" + strNewName;
                if (!ModStringpro.IsSameTreeNode(rootNode, strNewName, strPath))
                {
                    TreeNode fileNode = new TreeNode(Path.GetFileName(strPath));  //创建文件夹类型新节点
                    Dictionary <string, string> pDicTag = new Dictionary <string, string>();
                    pDicTag.Add("Path", strPath);
                    pDicTag.Add("Type", "Folder");
                    fileNode.Tag              = pDicTag;
                    fileNode.ImageKey         = "关闭";
                    fileNode.SelectedImageKey = "关闭";
                    rootNode.Nodes.Add(fileNode);
                    fileNode.Expand();
                    Directory.CreateDirectory(strPath);
                }
            }
        }
Пример #3
0
        private void ModifyResultsTreeName(TreeNode rootNode)
        {
            if (rootNode == null)
            {
                return;
            }
            if (!Directory.Exists((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim()))
            {
                return;
            }
            frmResultsTreeName pfrmResultsTreeName = new frmResultsTreeName();

            pfrmResultsTreeName.femText = "修改目录名称";
            pfrmResultsTreeName.LabText = "修改名称:";
            if (pfrmResultsTreeName.ShowDialog() == DialogResult.OK)
            {
                string strNewName = pfrmResultsTreeName.ResultsTreeName;
                if (strNewName == "")
                {
                    return;
                }
                string strPath = Path.GetDirectoryName((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim()) + "\\" + strNewName;
                if (!ModStringpro.IsSameTreeNode(rootNode.Parent, strNewName, strPath))
                {
                    try
                    {
                        Directory.Move((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim(), strPath);
                        rootNode.Text = strNewName;
                        Dictionary <string, string> pDicTag = new Dictionary <string, string>();
                        pDicTag.Add("Path", strPath);
                        pDicTag.Add("Type", "Folder");
                        rootNode.Tag = pDicTag;
                    }
                    catch { MessageBox.Show("修改失败!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Information); }
                }
            }
        }
Пример #4
0
        private void UploadingResults(TreeNode rootNode)
        {
            if (rootNode == null)
            {
                return;
            }
            if (!Directory.Exists((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim()))
            {
                return;
            }
            System.Windows.Forms.FolderBrowserDialog sOpenFileD = new System.Windows.Forms.FolderBrowserDialog();
            sOpenFileD.RootFolder = Environment.SpecialFolder.Desktop;
            if (sOpenFileD.ShowDialog() == DialogResult.OK)
            {
                if (!sOpenFileD.SelectedPath.ToLower().EndsWith("gdb"))
                {
                    MessageBox.Show("请选择gdb数据库文件夹", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                string strPathName               = sOpenFileD.SelectedPath;
                string strDirtoryName            = strPathName.Substring(strPathName.LastIndexOf("\\") + 1);
                Dictionary <string, string> pDic = new Dictionary <string, string>();
                if (Directory.Exists(strPathName.ToString()))
                {
                    string strPath = (rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim() + "\\" + strDirtoryName;
                    if (!ModStringpro.IsSameTreeNode(rootNode, strDirtoryName, strPath))
                    {
                        SysCommon.CProgress vProgress = new SysCommon.CProgress();
                        vProgress.ShowDescription    = true;
                        vProgress.ShowProgressNumber = true;
                        vProgress.TopMost            = true;
                        vProgress.EnableCancel       = true;
                        vProgress.EnableUserCancel(true);
                        vProgress.ShowProgress();
                        Application.DoEvents();
                        vProgress.SetProgress("正在上传GDB数据.....");
                        try
                        {
                            ModStringpro.CopyDirectory(strPathName, (rootNode.Tag as Dictionary <string, string>)["Path"].ToString(), vProgress);
                            vProgress.Close();
                        }
                        catch
                        {
                            pDic.Add(strDirtoryName, "文件上传失败");
                            vProgress.Close();
                            return;
                        }
                        DirectoryInfo fi = new DirectoryInfo(strPath);
                        if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                        {
                            fi.Attributes = FileAttributes.Normal;
                        }
                        TreeNode ResultsNode = new TreeNode(strDirtoryName);  //创建文件类型新节点
                        Dictionary <string, string> pDicTag = new Dictionary <string, string>();
                        pDicTag.Add("Path", strPath);
                        pDicTag.Add("Type", "GDB");
                        ResultsNode.Tag              = pDicTag;
                        ResultsNode.ImageKey         = "PDB";
                        ResultsNode.SelectedImageKey = "PDB";

                        rootNode.Nodes.Add(ResultsNode);
                        rootNode.Expand();
                        pDic.Add(strDirtoryName, "数据上传成功");
                    }
                    else
                    {
                        pDic.Add(strDirtoryName, "目录中已经存在");
                    }
                }

                frmUploadingList pfrmUploadingList = new frmUploadingList(pDic);
                pfrmUploadingList.ShowDialog();
            }
        }
Пример #5
0
        /// <summary>
        /// 清空指定的文件夹,但不删除文件夹
        /// </summary>
        /// <param name="dir"></param>
        private bool CopyResults(string dir, string strCopyPath, string strTpye)
        {
            switch (strTpye)
            {
            case "File":
                if (File.Exists(dir))
                {
                    FileInfo fi = new FileInfo(dir);
                    if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                    {
                        fi.Attributes = FileAttributes.Normal;
                    }
                    try
                    {
                        fi.CopyTo(strCopyPath + "\\" + fi.Name, true);
                    }
                    catch { return(false); }
                }
                else
                {
                    return(false);
                }
                break;

            case "Folder":
                if (Directory.Exists(dir))
                {
                    SysCommon.CProgress vProgress = new SysCommon.CProgress();
                    vProgress.ShowDescription    = true;
                    vProgress.ShowProgressNumber = true;
                    vProgress.TopMost            = true;
                    vProgress.EnableCancel       = true;
                    vProgress.EnableUserCancel(true);
                    vProgress.ShowProgress();
                    Application.DoEvents();
                    vProgress.SetProgress("正在导出目录.....");
                    string flag = ModStringpro.CopyFolder(dir, strCopyPath, vProgress);
                    vProgress.Close();
                    if (flag != "success")
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
                break;

            case "GDB":
                if (Directory.Exists(dir))
                {
                    SysCommon.CProgress vProgress = new SysCommon.CProgress();
                    vProgress.ShowDescription    = true;
                    vProgress.ShowProgressNumber = true;
                    vProgress.TopMost            = true;
                    vProgress.EnableCancel       = true;
                    vProgress.EnableUserCancel(true);
                    vProgress.ShowProgress();
                    Application.DoEvents();
                    vProgress.SetProgress("正在导出GDB数据.....");
                    try
                    {
                        ModStringpro.CopyDirectory(dir, strCopyPath, vProgress);
                        vProgress.Close();
                    }
                    catch
                    {
                        vProgress.Close();
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
                break;
            }
            return(true);
        }
Пример #6
0
        private void UploadingResults(TreeNode rootNode)
        {
            if (rootNode == null)
            {
                return;
            }
            if (!Directory.Exists((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim()))
            {
                return;
            }
            System.Windows.Forms.OpenFileDialog sOpenFileD = new System.Windows.Forms.OpenFileDialog();
            sOpenFileD.CheckFileExists = true;
            sOpenFileD.CheckPathExists = true;
            sOpenFileD.Multiselect     = true;
            sOpenFileD.Title           = "选择文件";
            sOpenFileD.Filter          = "制图文件(*.mxd)|*.mxd|Excel工作薄 (*.xls;*.xlsx)|*.xls;*.xlsx|Word(*.doc;*.docx)|*.doc;*.docx|Text 文档(*.txt)|*.txt|PDF 文档(*.pdf)|*.pdf|图片文件 (*.jpg;*.png;*.bmp)|*.jpg;*.png;*.bmp";
            if (sOpenFileD.ShowDialog() == DialogResult.OK)
            {
                Dictionary <string, string> pDic = new Dictionary <string, string>();
                string[]            strFileName  = sOpenFileD.FileNames;
                SysCommon.CProgress vProgress    = new SysCommon.CProgress();
                vProgress.ShowDescription    = true;
                vProgress.ShowProgressNumber = true;
                vProgress.TopMost            = true;
                vProgress.EnableCancel       = true;
                vProgress.EnableUserCancel(true);
                vProgress.MaxValue       = strFileName.Length;
                vProgress.ProgresssValue = 0;
                vProgress.Step           = 1;
                vProgress.ShowProgress();
                vProgress.SetProgress("正在上传.....");
                for (int j = 0; j < strFileName.Length; j++)
                {
                    vProgress.SetProgress("正在上传:" + Path.GetFileName(strFileName[j].ToString()) + "成果......");
                    vProgress.ProgresssValue = vProgress.ProgresssValue + 1;
                    if (vProgress.UserAskCancel)
                    {
                        vProgress.Close();
                        break;
                    }
                    if (File.Exists(strFileName[j].ToString()))
                    {
                        string strPath = (rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim() + "\\" + Path.GetFileName(strFileName[j].ToString());
                        if (!ModStringpro.IsSameTreeNode(rootNode, Path.GetFileName(strPath), strPath))
                        {
                            if (!ModStringpro.copyDirectory(strFileName[j].ToString(), strPath))
                            {
                                pDic.Add(Path.GetFileName(strFileName[j].ToString()), "文件上传失败");
                                continue;
                            }
                            FileInfo fi = new FileInfo(strPath);
                            if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                            {
                                fi.Attributes = FileAttributes.Normal;
                            }
                            TreeNode ResultsNode = new TreeNode(Path.GetFileName(strPath));   //创建文件类型新节点
                            Dictionary <string, string> pDicTag = new Dictionary <string, string>();
                            pDicTag.Add("Path", strPath);
                            pDicTag.Add("Type", "File");
                            ResultsNode.Tag = pDicTag;
                            switch (Path.GetExtension(strPath).ToLower())
                            {
                            case ".mxd":
                                ResultsNode.ImageKey         = "ArcMap";
                                ResultsNode.SelectedImageKey = "ArcMap";
                                break;

                            case ".doc":
                            case ".docx":
                                ResultsNode.ImageKey         = "word";
                                ResultsNode.SelectedImageKey = "word";
                                break;

                            case ".xls":
                            case ".xlsx":
                                ResultsNode.ImageKey         = "excel";
                                ResultsNode.SelectedImageKey = "excel";
                                break;

                            case ".jpg":
                            case ".bmp":
                            case ".png":
                            case ".img":
                            case ".jpeg":
                            case ".gif":
                                ResultsNode.ImageKey         = "images";
                                ResultsNode.SelectedImageKey = "images";
                                break;

                            case ".txt":
                                ResultsNode.ImageKey         = "text";
                                ResultsNode.SelectedImageKey = "text";
                                break;

                            case ".pdf":
                                ResultsNode.ImageKey         = "pdf";
                                ResultsNode.SelectedImageKey = "pdf";
                                break;
                            }

                            rootNode.Nodes.Add(ResultsNode);
                            rootNode.Expand();
                            pDic.Add(Path.GetFileName(strFileName[j].ToString()), "文件上传成功");
                        }
                        else
                        {
                            pDic.Add(Path.GetFileName(strFileName[j].ToString()), "目录中已经存在");
                        }
                    }
                }
                vProgress.Close();
                Application.DoEvents();
                frmUploadingList pfrmUploadingList = new frmUploadingList(pDic);
                pfrmUploadingList.ShowDialog();
            }
        }
        private void RefreshResultsTree(TreeNode rootNode)
        {
            if (rootNode == null)
            {
                return;
            }
            if (!Directory.Exists((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim()))
            {
                return;
            }
            foreach (string d in Directory.GetFileSystemEntries((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim()))
            {
                Dictionary <string, string> pDicTag = new Dictionary <string, string>();
                if (File.Exists(d))
                {
                    if (!ModStringpro.IsSameTreeNode(rootNode, Path.GetFileName(d), d))
                    {
                        FileInfo fi = new FileInfo(d);
                        if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                        {
                            fi.Attributes = FileAttributes.Normal;
                        }
                        TreeNode ResultsNode = new TreeNode(Path.GetFileName(d));  //创建文件类型新节点
                        pDicTag.Add("Path", d);
                        pDicTag.Add("Type", "File");
                        ResultsNode.Tag = pDicTag;
                        switch (Path.GetExtension(d).ToLower())
                        {
                        case ".mxd":
                            ResultsNode.ImageKey         = "ArcMap";
                            ResultsNode.SelectedImageKey = "ArcMap";
                            break;

                        case ".doc":
                        case ".docx":
                            ResultsNode.ImageKey         = "word";
                            ResultsNode.SelectedImageKey = "word";
                            break;

                        case ".xls":
                        case ".xlsx":
                            ResultsNode.ImageKey         = "excel";
                            ResultsNode.SelectedImageKey = "excel";
                            break;

                        case ".jpg":
                        case ".bmp":
                        case ".png":
                        case ".jpeg":
                        case ".gif":
                            ResultsNode.ImageKey         = "images";
                            ResultsNode.SelectedImageKey = "images";
                            break;

                        case ".txt":
                            ResultsNode.ImageKey         = "text";
                            ResultsNode.SelectedImageKey = "text";
                            break;

                        case ".pdf":
                            ResultsNode.ImageKey         = "pdf";
                            ResultsNode.SelectedImageKey = "pdf";
                            break;

                        default:
                            ResultsNode.ImageKey         = "warning";
                            ResultsNode.SelectedImageKey = "warning";
                            break;
                        }
                        rootNode.Nodes.Add(ResultsNode);
                    }
                }
                else if (Directory.Exists(d) && d.ToLower().EndsWith("gdb"))
                {
                    if (!ModStringpro.IsSameTreeNode(rootNode, Path.GetFileName(d), d))
                    {
                        TreeNode GdbNode = new TreeNode(d.Substring(d.LastIndexOf("\\") + 1));  //创建文件类型新节点
                        pDicTag.Add("Path", d);
                        pDicTag.Add("Type", "GDB");
                        GdbNode.Tag              = pDicTag;
                        GdbNode.ImageKey         = "PDB";
                        GdbNode.SelectedImageKey = "PDB";
                        rootNode.Nodes.Add(GdbNode);
                    }
                }
                else
                {
                    if (!ModStringpro.IsSameTreeNode(rootNode, Path.GetFileName(d), d))
                    {
                        TreeNode fileNode = new TreeNode(Path.GetFileName(d));  //创建文件夹类型新节点
                        pDicTag.Add("Path", d);
                        pDicTag.Add("Type", "Folder");
                        fileNode.Tag              = pDicTag;
                        fileNode.ImageKey         = "关闭";
                        fileNode.SelectedImageKey = "关闭";
                        rootNode.Nodes.Add(fileNode);
                        fileNode.Expand();
                        DirectoryInfo d1 = new DirectoryInfo(d);
                        if (d1.GetFileSystemInfos().Length != 0)
                        {
                            RefreshResultsTree(fileNode);
                            //DeleteFolder(d1.FullName);////递归创建节点
                        }
                    }
                }
            }
        }