Exemplo n.º 1
0
        //选择目录
        private void btnDir_Click(object sender, EventArgs e)
        {
            if (pc == null)
            {
                pc = new PathConfig();
            }

            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                pc.DirectoryPath = fbd.SelectedPath;
                Message          = "目录选择完成!" + pc.DirectoryPath;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 设置配置页面
 /// </summary>
 private void ResetConfig()
 {
     if (!configExand)
     {
         this.Width  = 494;
         pc          = new PathConfig();
         configExand = !configExand;
         btnSet.Text = "取消配置";
     }
     else
     {
         pc          = null;
         this.Width  = 242;
         configExand = !configExand;
         btnSet.Text = "添加配置";
         Reset();
     }
 }
Exemplo n.º 3
0
        public CopyItem(PathConfig pconfig)
        {
            InitializeComponent();
            if (pconfig != null)
            {
                this.pathconfig = pconfig;
                this.O          = new FileEx(pconfig);
                O.FileMoved    += new FileEx.Moved(O_FileMoved);
                O.MessageFg    += new FileEx.FgMessage(O_MessageFg);

                this.labDir.Text  = O.DirectoryPath;
                this.labFile.Text = O.FilePathSource;
                labTitle.Text     = O.Title;
            }
            else
            {
                throw new Exception("PathConfig对象不能为空");
            }
        }
Exemplo n.º 4
0
        //重置设置
        private void ClearConfig(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否要清空配置", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    cmlConfig.Reset();
                    AutoButton();
                    pc = null;

                    Message = "清空配置成功!";
                    (sender as Control).Enabled = false;
                }
                catch (Exception ex)
                {
                    Message = "重置设置错误!" + ex.Message;
                }
            }
        }
Exemplo n.º 5
0
        //添加到集合
        private void AddPathConfig(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(pc.FilePathSource))
                {
                    throw new Exception("尚未选择复制文件");
                }
                if (string.IsNullOrEmpty(pc.DirectoryPath))
                {
                    throw new Exception("尚未选择目标文件夹");
                }

                pc.Title = "复制:" + GetName(pc.FilePathSource);

                cmlConfig.AddSave(pc);
                pc = null;

                AutoButton();

                //手气配置页面
                ResetConfig();
                //显示信息
                Message = "添加配置成功!";

                Reset();

                //防止重复按重新配置
                if (labClearConfig.Enabled == false)
                {
                    labClearConfig.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                Message = "添加配置错误!" + ex.Message;
                MessageBox.Show("添加配置错误!" + ex.Message);
            }
        }
Exemplo n.º 6
0
        //选择文件
        private void btnFile_Click(object sender, EventArgs e)
        {
            if (pc == null)
            {
                pc = new PathConfig();
            }

            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                //判断文件是否过大
                if (!ValidateFile(ofd.FileName))
                {
                    return;
                }

                pc.FilePathSource = ofd.FileName;

                Message = "文件选择完成" + pc.FilePathSource;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 进行更新对象
        /// </summary>
        /// <param name="apc">原有对象</param>
        /// <param name="title">更新标题</param>
        /// <param name="filePath">更新文件路径</param>
        /// <param name="dirPath">更新目标路径</param>
        public void Update(PathConfig apc, string title, string filePath, string dirPath)
        {
            PathConfig tmp = this.EasyFilecg.Find(delegate(PathConfig p)
            {
                if (p.Title == apc.Title && p.DirectoryPath == apc.DirectoryPath && p.FilePathSource == apc.DirectoryPath)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });

            if (tmp != null)
            {
                tmp.DirectoryPath  = dirPath;
                tmp.FilePathSource = filePath;
                tmp.Title          = title;
            }
            Save();
        }
Exemplo n.º 8
0
        //拖放文件
        private void btnFile_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                string[] str = (string[])e.Data.GetData(DataFormats.FileDrop, true);//获取拖放文件的路径 输出的数组[0]是文件路径

                if (str.Length > 0)
                {
                    if (File.Exists(str[0]))
                    {
                        //判断文件是否过大
                        if (!ValidateFile(str[0]))
                        {
                            return;
                        }

                        if (pc == null)
                        {
                            pc = new PathConfig();
                        }
                        pc.FilePathSource = str[0];

                        Message = "文件选择完成!" + pc.FilePathSource;

                        btnFile.Text = GetName(pc.FilePathSource);
                    }
                    else
                    {
                        throw new Exception("文件不存在!");
                    }
                }
            }
            catch (Exception ex)
            {
                Message = "文件选择失败!" + ex.Message;
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// 添加并保持
 /// </summary>
 /// <param name="model">添加的实体</param>
 public void AddSave(PathConfig model)
 {
     EasyFilecg.Add(model);
     Save();
 }
Exemplo n.º 10
0
 /// <summary>
 /// 删除对象
 /// </summary>
 /// <param name="apc"></param>
 public void Delete(PathConfig apc)
 {
     this.EasyFilecg.Remove(apc);
     Save();
 }