Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override OperationState Rename()
        {
            try
            {
                string filePath = openFileDialogForFolders("Rename", 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);

                Misp.Kernel.Domain.File file = this.GetFileInfoService().Rename(fileDir, fileName);
                if (file == null)
                {
                    return(OperationState.STOP);
                }
                ApplicationManager.MainWindow.Title = fileNameWithoutExtension + " - B-Cephal";
                UserPreferencesUtil.RenameLastOpened(filePath);

                ApplicationManager.MainWindow.MenuBar.GetFileMenu().BuildRecentOpenedFiles();
                return(OperationState.CONTINUE);
            }
            catch (BcephalException e)
            {
                MessageDisplayer.DisplayError("Error", e.Message);
                return(OperationState.STOP);
            }
        }
Beispiel #2
0
 public Step1()
 {
     InitializeComponent();
     InitializeExcelFilesGrid();
     InitializeHandlers();
     setSelectionTypeVisibility();
     loadDefaultRepository(UserPreferencesUtil.GetMultipleFileUploadRepository());
 }
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            string current = UserPreferencesUtil.GetMultipleFileUploadRepository();

            if (!UserPreferencesUtil.SetMultipleFileUploadRepository(this.folderField.Text))
            {
                MessageDisplayer.DisplayWarning("Upload Multiple File Repository", "Attempt to save an empty repository!");
                setFolderName(UserPreferencesUtil.GetMultipleFileUploadRepository());
            }
            else
            {
                this.Close();
            }
        }
Beispiel #4
0
        /// <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);
        }
 public PropertiesDialog()
 {
     InitializeComponent();
     setFolderName(UserPreferencesUtil.GetMultipleFileUploadRepository());
 }