Exemplo n.º 1
0
        private void OK_Click(object sender, RoutedEventArgs e)
        {
            bool?  isCopy = IsCopyRadio.IsChecked;
            string tem;

            if (isCopy.Value)
            {
                tem = "复制";
            }
            else
            {
                tem = "更名或者移动";
            }
            int successCount          = 0;
            int falseCount            = 0;
            var fileReplaceNameModels = filePagerPage.GetAllList <FileReplaceNameModel>();

            if (fileReplaceNameModels.Count > 0)
            {
                if (MessageBoxCustom.MessageBoxShow("你将" + tem + fileReplaceNameModels.Count + " 个文件"))
                {
                    foreach (FileReplaceNameModel model in fileReplaceNameModels)
                    {
                        WaitFormCustom.ShowCustom();
                        string path     = model.FilePath;
                        string saveName = model.NewFileName;
                        string saveDir  = Path.GetDirectoryName(saveName);
                        if (saveDir == "")
                        {
                            model.Success = false;
                            continue;
                        }
                        if (!Utils.CheckDirExists(saveDir))
                        {
                            Directory.CreateDirectory(saveDir);
                        }
                        if (Utils.CheckFileExists(path))
                        {
                            if (isCopy.Value)
                            {
                                File.Copy(path, saveName, true);
                            }
                            else
                            {
                                File.Move(path, saveName);
                            }
                            successCount++;
                            model.Success = true;
                        }
                        else
                        {
                            model.Success = false;
                            falseCount++;
                        }
                    }
                    WaitFormCustom.CloseWaitForm("成功:" + successCount + " 个文件,失败:" + falseCount + " 个文件");
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 本地打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LocalPrint_Click(object sender, RoutedEventArgs e)
        {
            IList <PrintFileModel> files = addFilePagerPage.GetChekedAll();

            if (files.Count > 0 && MessageBoxCustom.MessageBoxShow("确要打印:" + files.Count + " 个文件吗?", false, Visibility.Visible))
            {
                IList <MyAction> actions = new List <MyAction>();
                foreach (PrintFileModel model in files)
                {
                    MyAction myAction = new MyAction(new Action(() =>
                    {
                        for (int a = 0; a < model.PrintCount; a++)
                        {
                            PrintUtils.RelativePrint(model.FilePath);
                            model.IsPrintOver = true;
                        }
                    }), model.Name + model.Extension);
                    actions.Add(myAction);
                }
                SingleTaskForm singleTaskForm = new SingleTaskForm(actions);
            }
        }