private bool ConfirmOverwrite(IFileChooser fcd, string file)
        {
            string primary   = Translations.GetString("A file named \"{0}\" already exists. Do you want to replace it?");
            string secondary = Translations.GetString("The file already exists in \"{1}\". Replacing it will overwrite its contents.");
            string message   = string.Format(markup, primary, secondary);

            using var md = new MessageDialog(PintaCore.Chrome.MainWindow, DialogFlags.Modal | DialogFlags.DestroyWithParent,
                                             MessageType.Question, ButtonsType.None,
                                             true, message, System.IO.Path.GetFileName(file), fcd.CurrentFolder);

            // Use the standard button order for each OS.
            if (PintaCore.System.OperatingSystem == OS.Windows)
            {
                md.AddButton(Translations.GetString("Replace"), ResponseType.Ok);
                md.AddButton(Stock.Cancel, ResponseType.Cancel);
            }
            else
            {
                md.AddButton(Stock.Cancel, ResponseType.Cancel);
                md.AddButton(Translations.GetString("Replace"), ResponseType.Ok);
            }

            md.DefaultResponse = ResponseType.Cancel;

            int response = md.Run();

            return(response == (int)ResponseType.Ok);
        }
 ///<summary>
 /// Constructs the <see cref="FileChooserManager"/>
 ///</summary>
 ///<param name="controlFactory"></param>
 ///<param name="fileChooser"></param>
 public FileChooserManager(IControlFactory controlFactory, IFileChooser fileChooser)
 {
     _controlFactory = controlFactory;
     _fileChooser = fileChooser;
     FlowLayoutManager manager = new FlowLayoutManager(_fileChooser, _controlFactory);
     _fileTextBox = _controlFactory.CreateTextBox();
     _selectFileButton = _controlFactory.CreateButton("Select...", null);
     manager.AddControl(_fileTextBox);
     manager.AddControl(_selectFileButton);
 }
Example #3
0
        public MainViewModel(IImageProcessingStrategy imageProcessingStrategy, IFileChooser fileChooser, ITaskExecutor <Bitmap> imageLoadingExecutor,
                             ITaskExecutor <ImageProcessingOutput> imageProcessingExecutor)
        {
            imageProcessor               = imageProcessingStrategy;
            this.fileChooser             = fileChooser;
            this.imageLoadingExecutor    = imageLoadingExecutor;
            this.imageProcessingExecutor = imageProcessingExecutor;

            SetupImageLoadingExecutor();
            SetupImageProcessingExecutor();
        }
        ///<summary>
        /// Constructs the <see cref="FileChooserManager"/>
        ///</summary>
        ///<param name="controlFactory"></param>
        ///<param name="fileChooser"></param>
        public FileChooserManager(IControlFactory controlFactory, IFileChooser fileChooser)
        {
            _controlFactory = controlFactory;
            _fileChooser    = fileChooser;
            FlowLayoutManager manager = new FlowLayoutManager(_fileChooser, _controlFactory);

            _fileTextBox      = _controlFactory.CreateTextBox();
            _selectFileButton = _controlFactory.CreateButton("Select...", null);
            manager.AddControl(_fileTextBox);
            manager.AddControl(_selectFileButton);
        }
        public void TestSelectedFilePath()
        {
            //---------------Set up test pack-------------------
            IFileChooser fileChooser = GetControlFactory().CreateFileChooser();

            //--------------Assert PreConditions----------------
            Assert.AreEqual("", fileChooser.SelectedFilePath);
            //---------------Execute Test ----------------------
            fileChooser.SelectedFilePath = TEST_PATH;
            //---------------Test Result -----------------------
            Assert.AreEqual(TEST_PATH, fileChooser.SelectedFilePath);
            //---------------Tear Down -------------------------
        }
Example #6
0
        private void ProcessSelectDirectoryNameCommand(object o, Action <string> func)
        {
            IFileChooser chooser = o as IFileChooser;

            if (o == null)
            {
                return;
            }

            string file = chooser.SelectDirectory();

            if (!string.IsNullOrWhiteSpace(file))
            {
                func(file);
            }
        }
Example #7
0
        public ApplicationViewModel(
            IFileChooser fileChooser,
            IModalNotifier modalNotifier,
            ServerMap model)
        {
            _fileChooser = fileChooser;
            _modalNotifier = modalNotifier;
            _model = model;

            RegisterCommand(ApplicationCommands.New, New, (e) => { e.CanExecute = true; });
            RegisterCommand(ApplicationCommands.Save, Save, (e) => { e.CanExecute = _model.CurrentFilename != null && _model.Current.IsDirty; });
            RegisterCommand(ApplicationCommands.SaveAs, SaveAs, (e) => { e.CanExecute = CurrentServiceDefinition != null; });
            RegisterCommand(ApplicationCommands.Open, Open, (e) => { e.CanExecute = true; });
            AboutCommand = new RelayCommand((e)=>_modalNotifier.Notify(GenerateAboutMessage(), "About ServerMap", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK));
            RunDataOperationCommand = new RelayCommand(RunDataOperation, () => CurrentServiceDefinition != null);
        }
        public void TestCreateControl()
        {
            //---------------Set up test pack-------------------

            //--------------Assert PreConditions----------------

            //---------------Execute Test ----------------------
            IFileChooser fileChooser = GetControlFactory().CreateFileChooser();

            //---------------Test Result -----------------------
            Assert.IsNotNull(fileChooser, "A File Chooser should have been created");
            Assert.AreEqual(2, fileChooser.Controls.Count);
            Assert.IsInstanceOf(typeof(ITextBox), fileChooser.Controls[0]);
            Assert.IsInstanceOf(typeof(IButton), fileChooser.Controls[1]);
            IButton button = (IButton)fileChooser.Controls[1];

            Assert.AreEqual(button.Text, "Select...");
            //---------------Tear Down -------------------------
        }
Example #9
0
 private DBusSystemDialog(IFileChooser fileChooser)
 {
     _fileChooser = fileChooser;
 }
Example #10
0
 public static Task <uint> GetVersionAsync(this IFileChooser o) => o.GetAsync <uint>("version");