コード例 #1
0
        public override void onSaveButtonClic(object sender, RoutedEventArgs e)
        {
            String message = "Saving Tree";

            action = new BusyAction(false)
            {
                DoWork = () =>
                {
                    action.ReportProgress(0, message);
                    System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
                    {
                        action.ReportProgress(10, message);
                        base.onSaveButtonClic(sender, e);
                    }
                                                                                  ));
                    action.ReportProgress(99, message);

                    action.ReportProgress(100, message);
                    return(Kernel.Application.OperationState.CONTINUE);
                },

                EndWork = () =>
                {
                    return(Kernel.Application.OperationState.CONTINUE);
                },
            };
            action.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(GetTransformationTreeEditorController().ApplicationManager.MainWindow.OnBusyPropertyChanged);
            action.Run();
        }
コード例 #2
0
        /// <summary>
        /// Supprime les objets sélectionnés
        /// </summary>
        /// <returns></returns>
        public override OperationState Delete()
        {
            System.Collections.IList items = GetBrowser().Form.Grid.SelectedItems;
            if (items == null || items.Count == 0)
            {
                return(OperationState.STOP);
            }
            int    count   = items.Count;
            string message = "You are about to delete " + count + " items.\nDo you want to continue?";

            if (count == 1)
            {
                object item = GetBrowser().Form.Grid.SelectedItem;
                if (item != null)
                {
                    message = "You are about to delete " + item.ToString() + " .\nDo you want to continue?";
                }
            }
            MessageBoxResult result = Kernel.Util.MessageDisplayer.DisplayYesNoQuestion("Delete", message);

            if (result == MessageBoxResult.Yes)
            {
                action = new BusyAction(false)
                {
                    DoWork = () =>
                    {
                        try
                        {
                            action.ReportProgress(0, message);
                            if (!Service.Delete(items))
                            {
                                Kernel.Util.MessageDisplayer.DisplayError("Delete", "Delete fail!");
                            }
                            else
                            {
                                System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => Search()));
                            }
                            action.ReportProgress(100, message);
                        }
                        catch (BcephalException e)
                        {
                            MessageDisplayer.DisplayError("Error", e.Message);
                            action = null;
                            return(OperationState.STOP);
                        }
                        return(OperationState.CONTINUE);
                    }
                };
                action.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ApplicationManager.MainWindow.OnBusyPropertyChanged);
                action.Run();
            }
            return(OperationState.CONTINUE);
        }
コード例 #3
0
        public void OnBusyPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            BusyAction action = (BusyAction)sender;

            switch (e.PropertyName)
            {
            case "IsBusy":
                if (action.IsBusy)
                {
                    BusyBorder.Visibility = System.Windows.Visibility.Visible;
                    if (action.IsDeterministic)
                    {
                        LoadingProgressBar.Visibility = System.Windows.Visibility.Visible;
                        LoadingLabel.Visibility       = System.Windows.Visibility.Visible;
                        LoadingImage.Visibility       = System.Windows.Visibility.Hidden;
                    }
                    else
                    {
                        LoadingProgressBar.Visibility = System.Windows.Visibility.Hidden;
                        LoadingLabel.Visibility       = System.Windows.Visibility.Hidden;
                        LoadingImage.Visibility       = System.Windows.Visibility.Visible;
                        //LoadingImage.StartAnimate();
                    }
                }
                else
                {
                    //LoadingImage.StopAnimate();
                    BusyBorder.Visibility = System.Windows.Visibility.Hidden;
                    action.EndWork();
                }

                break;

            case "LoadingPercentage":
                LoadingProgressBar.Maximum = action.MaxLoadingPercentage;
                LoadingProgressBar.Value   = action.LoadingPercentage;
                LoadingLabel.Content       = action.LoadingStep;
                break;
            }
        }
コード例 #4
0
        /// <summary>
        /// Supprime les objets sélectionnés
        /// </summary>
        /// <returns></returns>
        public override OperationState Delete()
        {
            System.Collections.IList items = GetBrowser().Form.Grid.SelectedItems;
            if (items == null || items.Count == 0)
            {
                return(OperationState.STOP);
            }
            int    count   = items.Count;
            string message = "You are about to delete " + count + " trees.\nDo you want to continue?";

            if (count == 1)
            {
                object item = GetBrowser().Form.Grid.SelectedItem;
                if (item != null)
                {
                    message = "You are about to delete " + item.ToString() + " .\nDo you want to continue?";
                }
            }
            MessageBoxResult result = Kernel.Util.MessageDisplayer.DisplayYesNoQuestion("Delete", message);

            if (result == MessageBoxResult.Yes)
            {
                action = new BusyAction(false)
                {
                    DoWork = () =>
                    {
                        try
                        {
                            action.ReportProgress(0, message);
                            bool canDelete = true; // getTransformationTreeService().usedByCombinedTree(items);
                            if (!canDelete)
                            {
                                String warning = count == 1 ? "Unable to delete " + items[0].ToString() + " because it's used by a combined tree.\nDelete the combined tree and try again."
                                    : "Unable to delete one or more tree in the selection because there're used by a combined tree.\nDelete the combined tree and try again.";
                                MessageDisplayer.DisplayWarning("Delete", warning);
                            }
                            else
                            {
                                if (!Service.Delete(items))
                                {
                                    Kernel.Util.MessageDisplayer.DisplayError("Delete", "Delete fail!");
                                }
                                else
                                {
                                    System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => Search()));
                                }
                            }
                            action.ReportProgress(100, message);
                        }
                        catch (BcephalException e)
                        {
                            MessageDisplayer.DisplayError("Error", e.Message);
                            action = null;
                            return(OperationState.STOP);
                        }
                        return(OperationState.CONTINUE);
                    }
                };
                action.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ApplicationManager.MainWindow.OnBusyPropertyChanged);
                action.Run();
            }
            return(OperationState.CONTINUE);
        }
コード例 #5
0
ファイル: FileController.cs プロジェクト: schifflee/bcephal2
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePath">Chemin absolue vers le fichier à ouvrir ou à créer</param>
        /// <param name="create">Est ce la creation</param>
        /// <returns></returns>
        //public OperationState OpenOrCreate(string filePath, bool create)
        //{
        //    action = new BusyAction(false)
        //    {
        //        DoWork = () =>
        //        {
        //            try
        //            {
        //                bool isMonouser = ApplicationManager.ApplcationConfiguration.IsMonouser();
        //                String message = create ? "File creation..." : "File loading...";
        //                action.ReportProgress(0, message);
        //                if (isMonouser && !System.IO.File.Exists(filePath) && !create && ApplicationManager.useZip())
        //                {
        //                    MessageDisplayer.DisplayError("Error", "File not found: " + filePath);
        //                    return OperationState.STOP;
        //                }
        //                if (isMonouser && !System.IO.Directory.Exists(filePath) && !create && !ApplicationManager.useZip())
        //                {
        //                    MessageDisplayer.DisplayError("Error", "Directory not found: " + filePath);
        //                    return OperationState.STOP;
        //                }

        //                string fileDir = System.IO.Path.GetDirectoryName(filePath);
        //                string fileName = System.IO.Path.GetFileName(filePath);
        //                //string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(filePath);

        //                action.ReportProgress(10, message);

        //                Misp.Kernel.Domain.File file = create ?
        //                    this.GetFileInfoService().CreateFile(fileDir, fileName) :
        //                    this.GetFileInfoService().OpenFile(fileDir, fileName);

        //                message = create ? "File created!" : "File loaded!";
        //                action.ReportProgress(99, message);

        //                if (file == null) return OperationState.STOP;
        //                this.ApplicationManager.File = file;
        //                this.ApplicationManager.AllocationCount = this.GetFileInfoService().GetAllocationCount();

        //                Util.UserPreferencesUtil.AddRecentFile(filePath);
        //                Util.UserPreferencesUtil.SetFileOpeningRepository(filePath);
        //               action.ReportProgress(100, message);
        //            }
        //            catch (BcephalException e)
        //            {
        //                MessageDisplayer.DisplayError(create ? "Create file" : "Open file", e.Message);
        //                action = null;
        //                return OperationState.STOP;
        //            }
        //            return OperationState.CONTINUE;
        //        },


        //        EndWork = () =>
        //        {
        //            try
        //            {
        //                string fileNameWithoutExtension = "";
        //                if (filePath.EndsWith(FILE_EXTENSION)) fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(filePath);
        //                else fileNameWithoutExtension = System.IO.Path.GetFileName(filePath);
        //                ApplicationManager.MainWindow.Title = fileNameWithoutExtension + " - B-Cephal";
        //                ApplicationManager.MainWindow.MenuBar.customizeForFileOpened();
        //                this.ToolBar.DisplayAllControls();
        //                ApplicationManager.MainWindow.MenuBar.GetFileMenu().lastFilePath = filePath;
        //                ApplicationManager.MainWindow.MenuBar.GetFileMenu().BuildSaveAsMenu();
        //                ApplicationManager.MainWindow.MenuBar.GetFileMenu().BuildRecentOpenedFiles();
        //                ApplicationManager.MainWindow.MenuBar.GetFileMenu().BackupSimpleMenu.IsEnabled = true;
        //                ApplicationManager.MainWindow.MenuBar.GetFileMenu().BackupAutomaticMenu.IsEnabled = true;
        //                RefreshDashboard();
        //            }
        //            catch (Exception e)
        //            {
        //                MessageDisplayer.DisplayError("Error", e.Message);
        //                return OperationState.STOP;
        //            }
        //            finally
        //            {
        //                action = null;
        //            }

        //            return OperationState.CONTINUE;
        //        }

        //    };

        //    action.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ApplicationManager.MainWindow.OnBusyPropertyChanged);
        //    action.Run();
        //    return OperationState.CONTINUE;

        //}

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override OperationState SaveAs()
        {
            action = new BusyAction(false)
            {
                DoWork = () =>
                {
                    try
                    {
                        String message = "Saving File ";
                        action.ReportProgress(0, message);
                        string filePath = "";
                        System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
                        {
                            filePath = openFileDialogForFolders("Save as", null);
                        }
                                                                                      ));

                        if (filePath == null || string.IsNullOrWhiteSpace(filePath))
                        {
                            return(OperationState.STOP);
                        }

                        string fileDir  = System.IO.Path.GetDirectoryName(filePath);
                        string fileName = System.IO.Path.GetFileName(filePath);
                        string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(filePath);

                        message = "Saving File as " + fileName;
                        action.ReportProgress(10, message);

                        Misp.Kernel.Domain.File file = this.GetFileInfoService().SaveAs(fileDir, fileName);
                        if (file == null)
                        {
                            return(OperationState.STOP);
                        }
                        this.ApplicationManager.File            = file;
                        this.ApplicationManager.AllocationCount = this.GetFileInfoService().GetAllocationCount();
                        System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
                        {
                            ApplicationManager.MainWindow.Title = fileNameWithoutExtension + " - B-Cephal";
                        }
                                                                                      ));

                        message = "File saved as " + fileNameWithoutExtension;
                        action.ReportProgress(99, message);
                        UserPreferencesUtil.AddRecentFile(filePath);
                        System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
                        {
                            ApplicationManager.MainWindow.MenuBar.GetFileMenu().BuildRecentOpenedFiles();
                            RefreshDashboard();
                        }
                                                                                      ));

                        message = "File " + fileNameWithoutExtension + " opened";
                        action.ReportProgress(100, message);
                    }
                    catch (BcephalException e)
                    {
                        MessageDisplayer.DisplayError("Saving file as ", e.Message);
                        action = null;
                        return(OperationState.STOP);
                    }
                    return(OperationState.CONTINUE);
                },

                EndWork = () =>
                {
                    return(OperationState.CONTINUE);
                },
            };
            action.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ApplicationManager.MainWindow.OnBusyPropertyChanged);
            action.Run();
            return(OperationState.CONTINUE);
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Edit(TransformationTreeItem item)
        {
            if (item == null)
            {
                return;
            }
            TransformationTreeItem parent = item.parent;

            item = item.oid != null?this.TransformationTreeService.getItemByOid(item.oid) : item;

            item.parent = parent;
            item.tree   = EditedObject;
            if (item.IsLoop)
            {
                if (this.LoopDialog == null)
                {
                    this.LoopDialog = new LoopDialog();
                    this.LoopDialog.TransformationTreeService = this.TransformationTreeService;
                    if (!this.IsReadOnly)
                    {
                        this.LoopDialog.initializeSideBar();
                    }
                    if (!this.IsReadOnly)
                    {
                        this.LoopDialog.SaveButton.Click += OnLoopDialogSave;
                    }
                    this.LoopDialog.CancelButton.Click += OnLoopDialogCancel;
                    this.LoopDialog.Closing            += OnLoopDialogClosing;
                    this.LoopDialog.Owner = ApplicationManager.Instance.MainWindow;
                }

                this.LoopDialog.Loop = item;
                this.LoopDialog.SetReadOnly(this.IsReadOnly);
                this.LoopDialog.DisplayItem();
                if (!this.LoopDialog.IsVisible)
                {
                    this.LoopDialog.ShowDialog();
                }
            }
            else
            {
                if (this.ActionDialog == null)
                {
                    this.ActionDialog = new TreeActionDialog();
                    this.ActionDialog.TransformationTreeService = this.TransformationTreeService;
                    if (!this.IsReadOnly)
                    {
                        this.ActionDialog.initializeSideBarHandlers();
                    }
                    if (!this.IsReadOnly)
                    {
                        this.ActionDialog.SaveButton.Click += OnActionDialogSave;
                    }
                    this.ActionDialog.CancelButton.Click += OnActionDialogCancel;
                    this.ActionDialog.Closing            += OnActionDialogClosing;
                    this.ActionDialog.OnCloseSlideDialog += OnCloseSlideView;
                    this.ActionDialog.OnCloseTransformationTableDialog += OnCloseTransformationTableView;
                    this.ActionDialog.SaveEndedEventHandler            += OnSaveActionReportEnded;
                    this.ActionDialog.Owner = ApplicationManager.Instance.MainWindow;
                }
                this.ActionDialog.IsReadOnly = this.IsReadOnly;
                if (this.ActionDialog.ReportEditorController == null)
                {
                    this.ActionDialog.initializeReport();
                }
                action = new BusyAction(false)
                {
                    DoWork = () =>
                    {
                        try
                        {
                            System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => {
                                List <TransformationTreeItem> loops = this.EditedObject.GetAllLoops().ToList();
                                this.ActionDialog.initializeSideBarData(new ObservableCollection <TransformationTreeItem>(loops));
                                this.ActionDialog.Action = item;
                                this.ActionDialog.loops = loops;
                                this.ActionDialog.DisplayItem();
                                //this.ActionDialog.initializeSideBarData(new ObservableCollection<TransformationTreeItem>(loops));
                            }));
                        }
                        catch (Kernel.Service.ServiceExecption) { action = null; }
                        return(OperationState.CONTINUE);
                    },

                    EndWork = () =>
                    {
                        try{ } catch (Exception) { }
                        finally{ action = null; }
                        return(OperationState.CONTINUE);
                    }
                };

                action.PropertyChanged      += new System.ComponentModel.PropertyChangedEventHandler(this.ActionDialog.OnBusyPropertyChanged);
                this.ActionDialog.IsReadOnly = this.IsReadOnly;
                action.Run();
                this.ActionDialog.SetReadOnly(this.IsReadOnly);
                if (!this.ActionDialog.IsVisible)
                {
                    this.ActionDialog.ShowDialog();
                }
            }
        }