Пример #1
0
        public override void OnFrameworkInitializationCompleted()
        {
            base.OnFrameworkInitializationCompleted();

            if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
            {
                var mainWindow = new MainWindow();

                var messageDialogService = new MessageDialogService(mainWindow);

                var contentDialogService = new ContentDialogService <CustomContentViewModel>(
                    mainWindow,
                    new CustomContentViewResolver());

                var openFileDialogService = new OpenFileDialogService(mainWindow);
                var saveFileDialogService = new SaveFileDialogService(mainWindow);

                var printDialogService = new PrintDialogService(mainWindow);

                mainWindow.DataContext = new MainWindowViewModel(
                    () => AvaloniaOpenFile(mainWindow),
                    () => AvaloniaSaveFile(mainWindow),
                    messageDialogService,
                    contentDialogService,
                    openFileDialogService,
                    saveFileDialogService,
                    printDialogService);

                desktop.MainWindow = mainWindow;
            }
        }
Пример #2
0
        private MainWindowViewModel ShowProviderWindow(LanguagePair[] languagePairs,
                                                       ITranslationProviderCredentialStore credentialStore, IMtTranslationOptions loadOptions, RegionsProvider regionsProvider)
        {
            SetSavedCredentialsOnUi(credentialStore, loadOptions);

            var dialogService     = new OpenFileDialogService();
            var providerControlVm = new ProviderControlViewModel(loadOptions, regionsProvider);

            var settingsControlVm = new SettingsControlViewModel(loadOptions, dialogService, false);
            var mainWindowVm      = new MainWindowViewModel(loadOptions, providerControlVm, settingsControlVm, credentialStore, languagePairs);

            var mainWindow = new MainWindow
            {
                DataContext = mainWindowVm
            };

            mainWindowVm.CloseEventRaised += () =>
            {
                UpdateProviderCredentials(credentialStore, loadOptions);

                mainWindow.Close();
            };

            mainWindow.ShowDialog();
            return(mainWindowVm);
        }
Пример #3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            MainWindowView view = new MainWindowView();

            //inject dependencies (could use a dependency injection framework for this, but not strictly necessary):
            ICustomerRepository    customerRepository    = new CustomerRepository();
            IProductRepository     productRepository     = new ProductRepository();
            ILocalizationService   localizationService   = new LocalizationService();
            IUpdateService         updateService         = new UpdateService();
            IMessageBoxService     messageBoxService     = new MessageBoxService();
            IDialogService         dialogService         = new DialogService();
            IAppDialogService      appDialogService      = new AppDialogService(dialogService, localizationService, () => new LanguageSelectionView(), () => new AboutView());
            IOpenFileDialogService openFileDialogService = new OpenFileDialogService();
            ISaveFileDialogService saveFileDialogService = new SaveFileDialogService();

            MainWindowViewModel viewModel = new MainWindowViewModel(
                customerRepository,
                productRepository,
                updateService,
                messageBoxService,
                appDialogService,
                openFileDialogService,
                saveFileDialogService,
                localizationService);

            //could also be wired up and handled in MainWindow.xaml.cs code behind (maybe in DataContextChanged override for example)
            //also could have a controller class listening to this event
            viewModel.RequestClose += (s, args) => view.Close();

            view.DataContext = viewModel;
            view.Show();
        }
Пример #4
0
        public void OpenWAV()
        {
            OutputLogs logs = OutputLogs.Instance();

            OpenFileDialogService.Filter      = "Wav Files (.wav)|*.wav|All Files (*.*)|*.*";
            OpenFileDialogService.FilterIndex = 1;
            OpenFileDialogService.Title       = "Open target audio";
            if (OpenFileDialogService.ShowDialog())
            {
                IFileInfo file   = OpenFileDialogService.Files.First();
                WavReader reader = null;
                try
                {
                    reader        = new WavReader(File.Open(file.GetFullName(), FileMode.Open, FileAccess.Read, FileShare.None));
                    Audio         = reader.ReadAudio();
                    AudioFileName = file.Name;
                    string msg = string.Concat("Succesfully loaded file - ", file.GetFullName());
                    logs.AddLog(new Message(MessageType.Info, msg, "WavReader"));
                }
                catch (ApplicationException ex)
                {
                    logs.AddLog(new Message(MessageType.Error, ex.Message, ex.Source));
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Dispose();
                    }
                }
            }
        }
Пример #5
0
        public void DefaultValues()
        {
            OpenFileDialogService service = new OpenFileDialogService();

            Assert.AreEqual(true, service.AddExtension);
            Assert.AreEqual(true, service.AutoUpgradeEnabled);
            Assert.AreEqual(true, service.CheckFileExists);
            Assert.AreEqual(true, service.CheckPathExists);
            Assert.AreEqual(true, service.DereferenceLinks);
            Assert.AreEqual(false, service.RestoreDirectory);
            Assert.AreEqual(false, service.ShowHelp);
            Assert.AreEqual(false, service.ShowReadOnly);
            Assert.AreEqual(false, service.SupportMultiDottedExtensions);
            Assert.AreEqual(string.Empty, service.Title);
            Assert.AreEqual(true, service.ValidateNames);
            Assert.AreEqual(string.Empty, service.Filter);
            Assert.AreEqual(1, service.FilterIndex);
            Assert.AreEqual(string.Empty, service.InitialDirectory);
            Assert.AreEqual(string.Empty, service.DefaultFileName);
            Assert.AreEqual(false, service.Multiselect);

            IOpenFileDialogService iService = service;

            Assert.IsNull(iService.File);
            Assert.AreEqual(0, iService.Files.Count());
        }
Пример #6
0
 public void BrowseToServiceConfiguration()
 {
     IOpenFileDialogService service = new OpenFileDialogService();
     RoleConfiguration.ConfigurationPath = service.OpenFileDialog(RoleConfiguration.ConfigurationPath,
         "Choose service configuration",
         "Service Configuration Files (.cscfg)|*.cscfg");
 }
Пример #7
0
        public MainWindowViewModel(
            Func <Task> avaloniaOpenFile,
            Func <Task> avaloniaSaveFile,
            MessageDialogService messageDialogService,
            ContentDialogService <CustomContentViewModel> contentDialogService,
            OpenFileDialogService openFileDialogService,
            SaveFileDialogService saveFileDialogService,
            PrintDialogService printDialogService)
        {
            _messageDialogService = messageDialogService;
            _contentDialogService = contentDialogService;

            _openFileDialogService = openFileDialogService;
            _saveFileDialogService = saveFileDialogService;

            _printDialogService = printDialogService;

            ShowMessageCommand       = ReactiveCommand.Create(ShowMessageAsync);
            ShowCustomContentCommand = ReactiveCommand.Create(ShowCustomContentAsync);

            OpenFileCommand = ReactiveCommand.Create(OpenFileAsync);
            SaveFileCommand = ReactiveCommand.Create(SaveFileAsync);

            PrintCommand = ReactiveCommand.Create(PrintAsync);

            AvaloniaOpenFileCommand = ReactiveCommand.Create(avaloniaOpenFile);
            AvaloniaSaveFileCommand = ReactiveCommand.Create(avaloniaSaveFile);
        }
Пример #8
0
 public void BrowseToAssembly()
 {
     IOpenFileDialogService service = new OpenFileDialogService();
     RoleConfiguration.Assembly = service.OpenFileDialog(RoleConfiguration.Assembly, 
         "Choose service assembly",
         "Assembly Files (.dll)|*.dll");
     OnPropertyChanged("RoleConfiguration");
 }
Пример #9
0
        public void BrowseToServiceConfiguration()
        {
            IOpenFileDialogService service = new OpenFileDialogService();

            RoleConfiguration.ConfigurationPath = service.OpenFileDialog(RoleConfiguration.ConfigurationPath,
                                                                         "Choose service configuration",
                                                                         "Service Configuration Files (.cscfg)|*.cscfg");
        }
Пример #10
0
        public void BrowseToAssembly()
        {
            IOpenFileDialogService service = new OpenFileDialogService();

            RoleConfiguration.Assembly = service.OpenFileDialog(RoleConfiguration.Assembly,
                                                                "Choose service assembly",
                                                                "Assembly Files (.dll)|*.dll");
            OnPropertyChanged("RoleConfiguration");
        }
Пример #11
0
        protected void Open()
        {
            var filename = OpenFileDialogService.ShowDialog();

            if (filename != null)
            {
                InputFile.Value = filename;
            }
        }
Пример #12
0
        public override void Execute()
        {
            var currentProject = SdlTradosStudio.Application.GetController <ProjectsController>().CurrentProject;

            if (currentProject == null)
            {
                MessageBox.Show(@"No project is set as active");
            }
            else
            {
                var settings = currentProject.GetTranslationProviderConfiguration();
                if (!settings.Entries.Any(entry => entry.MainTranslationProvider.Uri.OriginalString.Contains("mtenhancedprovider")))
                {
                    MessageBox.Show(
                        @"MT Enhanced Provider is not set on this project\nPlease set it in project settings before using TellMe to access it");
                }
                else
                {
                    var translationProvider = settings.Entries.FirstOrDefault(entry =>
                                                                              entry.MainTranslationProvider.Uri.OriginalString.Contains("mtenhancedprovider"));

                    if (translationProvider != null)
                    {
                        var mtTranslationOptions =
                            new MtTranslationOptions(translationProvider.MainTranslationProvider.Uri);

                        var dialogService = new OpenFileDialogService();

                        var settingsControlVm = new SettingsControlViewModel(mtTranslationOptions, dialogService, true);
                        var mainWindowVm      = new MainWindowViewModel(mtTranslationOptions, settingsControlVm, true);

                        var mainWindow = new MainWindow
                        {
                            DataContext = mainWindowVm
                        };

                        mainWindowVm.CloseEventRaised += () =>
                        {
                            settings.Entries.Find(entry =>
                                                  entry.MainTranslationProvider.Uri.ToString().Contains("mtenhancedprovider"))
                            .MainTranslationProvider
                            .Uri = mtTranslationOptions.Uri;

                            currentProject.UpdateTranslationProviderConfiguration(settings);
                            mainWindow.Close();
                        };

                        mainWindow.ShowDialog();
                    }
                }
            }
        }
Пример #13
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            log4net.Config.XmlConfigurator.Configure();
            IOpenFileDialogService    openFileDialogService = new OpenFileDialogService();
            IMessageBoxService        messageBoxService     = new MessageBoxService();
            IConfigurationManager     configManager         = new AccountTransactionUploadApp.Implementation.ConfigurationManager();
            FileDataUploaderViewModel viewModel             = new FileDataUploaderViewModel(openFileDialogService, messageBoxService, configManager);
            FileDataUploader          fileDataUploader      = new FileDataUploader();

            fileDataUploader.DataContext = viewModel;
            fileDataUploader.Show();
        }
Пример #14
0
        public MainWindow()
        {
            InitializeComponent();
            var                        productionState         = new ProductionState();
            var                        scenarioLoader          = new ProductionStateLoader(LoadScenarionPaths("InputFiles"), "InputFiles/ProcessingTimeMatrix.csv");
            var                        naiveController         = new NaiveController(productionState);
            BaseController             asyncController         = new NaiveAsyncControllerWithHalfCycleDelay(productionState);
            GreedyWarehouseReorganizer reorganizer             = new GreedyWarehouseReorganizer();
            RealProductionSimulator    realProductionSimulator = new RealProductionSimulator(naiveController, null);
            //ViewModel = new MainWindowViewModel(naiveController, scenarioLoader);
            var openFileDialog = new OpenFileDialogService();
            IOpenFileService openFolderDialog = new OpenFolderDialogService();

            ViewModel   = new MainWindowViewModel(naiveController, asyncController, reorganizer, realProductionSimulator, scenarioLoader, openFileDialog, openFolderDialog, DialogCoordinator.Instance);
            DataContext = ViewModel;
        }
 public virtual void AttachFiles(DragEventArgs e)
 {
     string[] filesName = new string[] { };
     if (e != null && e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         filesName = (string[])(e.Data.GetData(DataFormats.FileDrop));
     }
     else
     {
         bool dialogResult = OpenFileDialogService.ShowDialog();
         if (dialogResult)
         {
             filesName = OpenFileDialogService.Files.Select(x => Path.Combine(x.DirectoryName, x.Name)).ToArray();
         }
     }
     AttachedFilesCore(filesName);
 }
Пример #16
0
        public static void DeSerializeSerializationData(ref ObservableCollection <Employee> Employees, ref ObservableCollection <Client> Clients, Client ObjClient, Employee ObjEmployee)
        {
            IOpenFileDialogService OpenFileDialogService = new OpenFileDialogService
            {
                Filter      = "Text Files (.xml)|*.xml|All Files (*.*)|*.*",
                FilterIndex = 1,
                Title       = "Test Dialog",
                Multiselect = true,
            };

            var DialogResult = OpenFileDialogService.ShowDialog();

            if (!DialogResult)
            {
            }
            else
            {
                try
                {
                    XmlSerializer formatterClient   = new XmlSerializer(typeof(ObservableCollection <Client>));
                    XmlSerializer formatterEmployee = new XmlSerializer(typeof(ObservableCollection <Employee>));
                    foreach (IFileInfo file in OpenFileDialogService.Files)
                    {
                        if (file.Name.Contains(ObjClient.GetType().Name))
                        {
                            using (FileStream fs = new FileStream(file.Name, FileMode.OpenOrCreate))
                            {
                                Clients = (ObservableCollection <Client>)formatterClient.Deserialize(fs);
                            }
                        }
                        if (file.Name.Contains(ObjEmployee.GetType().Name))
                        {
                            using (FileStream fs = new FileStream(file.Name, FileMode.OpenOrCreate))
                            {
                                Employees = (ObservableCollection <Employee>)formatterEmployee.Deserialize(fs);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Пример #17
0
        private void OpenFile()
        {
            var dialog = new OpenFileDialogService(".txt", "Text documents (.txt)|*.txt");

            FilePath = dialog.OpenFile();
            if (!string.IsNullOrEmpty(FilePath))
            {
                IsOpenFileButtonEnabled   = false;
                IsProjectMainPanelEnabled = true;
            }
            var text  = TextFile.ReadFile(FilePath);
            var words = TextWords.GetUniqueWordList(TextWords.FindWords(text));

            foreach (var word in words)
            {
                ProjectTextWords.Add(word);
            }
            OnPropertyChanged("ProjectTextWords");
        }
Пример #18
0
 public void SetSourcePath()
 {
     if (UseExcelFileSource)
     {
         OpenFileDialogService.Filter = ExcelFilter;
         if (OpenFileDialogService.ShowDialog() == true)
         {
             FilePath = OpenFileDialogService.GetFullFileName();
         }
     }
     else
     {
         OpenFolderDialogService.Title = Properties.Resources.Import;
         if (OpenFolderDialogService.ShowDialog() == true)
         {
             FolderPath = OpenFolderDialogService.Folder.Path;
         }
     }
 }
Пример #19
0
        public async Task Import(ProgressDialogController progress)
        {
            await Task.Run(() =>
            {
                // open file
                var result = new OpenFileDialogService().Show(fileName =>
                {
                    // initialize LocalDB
                    Delete();
                    Create();

                    // import bacpac
                    _dacService.ProgressChanged += (sender, args) => progress.SetMessage($"{args.Status} : {args.Message}");
                    _dacService.ImportBacpac(BacPackage.Load(fileName), _databaseName);
                });
                progress.SetMessage(result ? "Success" : "Fail");
            });

            await progress.CloseAsync();
        }
Пример #20
0
        private string FindFile()
        {
            IOpenFileDialogService OpenFileDialogService = new OpenFileDialogService
            {
                Filter      = "Text Files (.csv)|*.csv|All Files (*.*)|*.*",
                FilterIndex = 1,
                Title       = "Test Dialog",
            };


            var DialogResult = OpenFileDialogService.ShowDialog();

            if (!DialogResult)
            {
                return(string.Empty);
            }
            else
            {
                IFileInfo file = OpenFileDialogService.Files.First();
                return(file.GetFullName());
            }
        }
        public void RestoreDatabase()
        {
            OpenFileDialogService openFileDialogService = new OpenFileDialogService();
            string path = openFileDialogService.Open();
            if (!String.IsNullOrWhiteSpace(path))
            {
                try
                {
                    Ctx.RestoreDatabase(path);
                    var message = new MessageBoxService();
                    var result = message.AskForConfirmation("Restore van backup van databank is geslaagd. Om effect te hebben moet u de applicatie herstarten! \nWilt u de applicatie nu herstarten?","Strijkdienst Conny Restore Database", System.Windows.MessageBoxButton.YesNo);
                    if (result == MessageBoxResult.Yes)
                    {
                        System.Windows.Forms.Application.Restart();
                        Process.GetCurrentProcess().Kill();
                    }

                }
                catch
                {
                    //TODO
                }
            }
        }
 public OpenFileDialogServiceImpl(OpenFileDialogService parent)
 {
     _parent = parent;
     _dialog = new Lazy <OpenFileDialog>(() => new OpenFileDialog());
 }