Ejemplo n.º 1
0
 private void CheckPath()
 {
     if (TbtargetPath.Text.Trim().Contains(TbOriginalPath.Text.Trim()))
     {
         PUMessageBox.ShowConfirm("路径存在包含关系,无法复制", "温馨提示", buttons: Buttons.OK);
     }
 }
Ejemplo n.º 2
0
        public void Delete(ItemCollection sender, RoutedPropertyChangedEventArgs <PUComboBoxItem> e)
        {
            var item = e.NewValue as PUComboBoxItem;

            if (PUMessageBox.ShowConfirm("确定要删除该选项吗?") == true)
            {
                sender.Remove(item);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 使用数字作为参数不是一个好方法,这里为了方便
        /// </summary>
        /// <param name="category"></param>
        public void Display(int category)
        {
            switch (category)
            {
            case 1:
                var window1 = new Views.Control.Examples.MultiNavWindow();
                window1.ShowDialog();
                if (!window1.Result.Equals(0))
                {
                    PUMessageBox.ShowDialog("最后点击的按钮(缩放和关闭按钮不算)是第" + window1.Result + "个");
                }
                break;

            case 2:
                var window2 = new Views.Control.Examples.LoginWindow();
                window2.Owner = (Parent as ShellWindowViewModel).GetCurrentWindow();
                window2.ShowDialog();
                break;

            case 3:
                var window4 = new Views.Control.Examples.ChatWindow();
                window4.ShowDialog();
                break;

            case 4:
                SetAwait(true);
                Task.Run(() =>
                {
                    Thread.Sleep(2000);
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        SetAwait(false);
                    });
                });
                break;

            case 5:
                PUMessageBox.ShowDialog("Hello World");
                break;

            case 6:
                PUMessageBox.ShowConfirm("Hello World");
                break;

            case 7:
                PUMessageBox.ShowAwait("正在执行......", delegate
                {
                    PUMessageBox.CloseAwait(delegate
                    {
                        PUMessageBox.ShowDialog("已取消。");
                    });
                });
                break;
            }
        }
Ejemplo n.º 4
0
 public void DeleteSubject()
 {
     if (PUMessageBox.ShowConfirm("此操作会将所关联的题目删除,是否确定执行", "提示", Buttons.OKOrCancel, true, AnimationStyles.Gradual) != true)
     {
         return;
     }
     _quetionBankBusiness.DeleteSubject(SelectedValue);
     SubjectName = "";
     PUMessageBox.ShowDialog("删除成功");
     Init();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 导入数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string[] paths          = null;
            var      openFileDialog = new Microsoft.Win32.OpenFileDialog()
            {
                Filter = "Excel Files (*.csv)|*.csv", Multiselect = true
            };
            var result = openFileDialog.ShowDialog();

            if (result == true)
            {
                paths = openFileDialog.FileNames;
            }
            else
            {
                return;
            }

            for (int i = 0; i < paths.Length; i++)
            {
                DataTable csv = FileHelper.OpenCSV(paths[i], new string[] { "时间", "车牌", "x 坐标", "y 坐标" }, 0);
                if (csv == null)
                {
                    return;
                }
                //DataHelper.CreateXClass("BikePoint", GeomType.Pnt, "Templates", new string[] { "FieldID", "BikeID", "time" });
                bool done = DataHelper.ImportSFCLSData(csv, "BikePnts");
                csv.Dispose();
                csv = null;
                if (done)
                {
                    PUMessageBox.ShowDialog("导入文件 " + paths[i] + " 完成", "我好了");
                }
                else
                {
                    if (PUMessageBox.ShowConfirm("导入文件 " + paths[i] + " 失败,要继续吗?") == true)
                    {
                        continue;
                    }
                    else
                    {
                        return;
                    }
                }
            }

            WuhanMapControl.Dock      = DockStyle.Fill;
            WuhanMapControl.BackColor = System.Drawing.Color.White;

            //ShowMaps();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 复制目录文件的核心方法
        /// </summary>
        /// <param name="sourcePath">源路径</param>
        /// <param name="targetPath">目标路径</param>
        /// <param name="overWrite">是否重写</param>
        /// <returns></returns>
        private bool CopyDirectoty(string sourcePath, string targetPath, bool overWrite)
        {
            bool result;

            try
            {
                sourcePath = sourcePath.EndsWith(@"\") ? sourcePath : sourcePath + @"\";
                targetPath = targetPath.EndsWith(@"\") ? targetPath : targetPath + @"\";
                if (!Directory.Exists(targetPath))
                {
                    Directory.CreateDirectory(targetPath);
                }
                var orginalDirectories = Directory.GetDirectories(sourcePath);
                foreach (var directory in orginalDirectories)
                {
                    var driInfo = new DirectoryInfo(directory);
                    if (!CopyDirectoty(directory, targetPath + driInfo.Name, overWrite))
                    {
                        return(false);
                    }
                }
                var originalFiles = Directory.GetFiles(sourcePath);

                //ProgressBar.IsPercentShow = true;
                //ProgressBar.
                ProgressBar.Maximum = originalFiles.Length;
                ShowProgressBar(true);
                UpdateProgressBarDelegate updateProgressBaDelegate = ProgressBar.SetValue;
                var count = 0.0;
                foreach (var file in originalFiles)
                {
                    var flinfo = new FileInfo(file);
                    flinfo.CopyTo(targetPath + flinfo.Name, overWrite);
                    count++;
                    Dispatcher.Invoke(updateProgressBaDelegate, DispatcherPriority.Background, RangeBase.ValueProperty, count);
                    LbPercent.Content = $"{Math.Round(count * 100 / originalFiles.Length, 2)}%";
                }
                ShowProgressBar(false);
                result = true;
            }
            catch (Exception e)
            {
                PUMessageBox.ShowConfirm(e.Message, buttons: Buttons.OK, animateStyle: AnimationStyles.Fade);
                ShowProgressBar(false);
                result = false;
            }
            return(result);
        }
Ejemplo n.º 7
0
        public void DeleteItem(RoutedPropertyChangedEventArgs <PUComboBoxItem> e)
        {
            if (DeleteMode == DeleteModes.Delete)
            {
                return;
            }
            var comboBoxItem = e.NewValue;

            //移除绑定值的Model即可,切记不能直接操作ComboBox的Items属性,否则会出现混乱
            var model = ComboBoxItems.FirstOrDefault(x => x.Uid == comboBoxItem.Uid);

            if (model != null && PUMessageBox.ShowConfirm("确认要删除该选项吗?") == true)
            {
                ComboBoxItems.Remove(model);
            }
        }
Ejemplo n.º 8
0
 private void BtnStart_Click(object sender, RoutedEventArgs e)
 {
     if (TbtargetPath.Text.Trim().Contains(TbOriginalPath.Text.Trim()))
     {
         PUMessageBox.ShowConfirm("路径有问题,不能复制文件", "温馨提示", Buttons.Sure, animateStyle: AnimationStyles.Fade);
         return;
     }
     if (!CopyDirectoty(TbOriginalPath.Text, TbtargetPath.Text, true))
     {
         PUMessageBox.ShowConfirm("复制失败", "温馨提示", Buttons.Sure, animateStyle: AnimationStyles.Fade);
     }
     else
     {
         PUMessageBox.ShowConfirm("复制成功", "温馨提示", Buttons.Sure, animateStyle: AnimationStyles.Fade);//.Show("复制成功", "温馨提示");
         //Close();
     }
 }
Ejemplo n.º 9
0
        public void UpdateActivePage()
        {
            if (ChoosedValue != "Login" && !_login_ViewModel.IsLogin)
            {
                return;
            }
            switch (ChoosedValue)
            {
            case "Login":
                ActivateItem(_login_ViewModel);
                break;

            case "LoginSucceed":
                ActivateItem(new LoginSucceedViewModel(CurrentUser));
                break;

            case "AddUser":
                if (_roleRights.FirstOrDefault(c => c.RightName.Equals("UserManager")) == null)
                {
                    PUMessageBox.ShowDialog("你没有访问权限,请联系管理员");
                    return;
                }
                ActivateItem(new AddUserViewModel(_windowManager));
                break;

            case "UserManager":
                if (_roleRights.FirstOrDefault(c => c.RightName.Equals("UserManager")) == null)
                {
                    PUMessageBox.ShowDialog("你没有访问权限,请联系管理员");
                    return;
                }
                ActivateItem(new UserManagerViewModel(_windowManager));
                break;

            case "AddQuestions":
                ActivateItem(new AddQuestionBankViewModel(_windowManager));
                break;

            case "QuestionsManager":
                if (_roleRights.FirstOrDefault(c => c.RightName.Equals("QuestionBankManager")) == null)
                {
                    return;
                }
                ActivateItem(new QuestionBankManagerViewModel(_windowManager));
                break;

            case "ExaminationPaperManager":
                if (_roleRights.FirstOrDefault(c => c.RightName.Equals("ExaminationPaperManager")) == null)
                {
                    PUMessageBox.ShowDialog("你没有访问权限,请联系管理员");
                    return;
                }
                ActivateItem(new ExaminationPaperManagerViewModel(_windowManager));
                break;

            case "KnowledgePoint":
                ActivateItem(new KnowledgePointManagerViewModel(_windowManager));
                break;

            case "QuestionTypes":
                ActivateItem(new QuestionTypeManagerViewModel(_windowManager));
                break;

            case "Subject":
                ActivateItem(new SubjectManagerViewModel(_windowManager));
                break;

            case "AddExaminationPaper":
                ActivateItem(new AddExaminationPaperViewModel(_windowManager));
                break;

            case "AutogenerationExaminationPaper":

                ActivateItem(new AutoAddExaminationPaperViewModel(_windowManager));
                break;

            case "ExportExaminationPaper":

                ActivateItem(new ExaminationPaperGenerateViewModel(_windowManager));
                break;

            case "AuthorityManagement":
                if (_roleRights.FirstOrDefault(c => c.RightName.Equals("UserManager")) == null && CurrentUser.Id != 1)
                {
                    PUMessageBox.ShowDialog("你没有访问权限,请联系管理员");
                    return;
                }
                ActivateItem(new RightManagerViewModel(_windowManager));
                break;

            case "PersonalSettings":
                ActivateItem(new UpdateUserViewModel(_windowManager, CurrentUser));
                break;

            case "Logout":
                if (PUMessageBox.ShowConfirm("是否注销", "提示", Buttons.OKOrCancel, true, AnimationStyles.Gradual) != true)
                {
                    return;
                }
                CurrentUser      = new User();
                _login_ViewModel = new Login_ViewModel(_windowManager);
                ActivateItem(_login_ViewModel);
                break;
            }
        }