private async Task LoadScriptAsync(string scriptFilename)
        {
            IItemFilterScriptViewModel loadedViewModel;

            Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
            try
            {
                loadedViewModel = await _itemFilterScriptRepository.LoadScriptFromFileAsync(scriptFilename);
            }
            catch (IOException e)
            {
                Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
                if (_logger.IsErrorEnabled)
                {
                    _logger.Error(e);
                }
                _messageBoxService.Show("Script Load Error", "Error loading filter script - " + e.Message,
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                return;
            }

            Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
            _avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
        }
        public async Task SaveAsync()
        {
            if (IsMasterTheme)
            {
                return;
            }

            if (_filenameIsFake)
            {
                await SaveAsAsync();

                return;
            }

            try
            {
                await _themeProvider.SaveThemeAsync(this, FilePath);

                //RemoveDirtyFlag();
            }
            catch (Exception e)
            {
                if (Logger.IsErrorEnabled)
                {
                    Logger.Error(e);
                }

                _messageBoxService.Show("Save Error", "Error saving filter theme - " + e.Message, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 3
0
        private void OnOpenScriptCommand()
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter           = "Filter Files (*.filter)|*.filter|All Files (*.*)|*.*",
                InitialDirectory = _itemFilterScriptRepository.GetItemFilterScriptDirectory()
            };

            if (openFileDialog.ShowDialog() != true)
            {
                return;
            }

            IItemFilterScriptViewModel loadedViewModel;

            try
            {
                loadedViewModel = _itemFilterScriptRepository.LoadScriptFromFile(openFileDialog.FileName);
            }
            catch (IOException e)
            {
                if (_logger.IsErrorEnabled)
                {
                    _logger.Error(e);
                }
                _messageBoxService.Show("Script Load Error", "Error loading filter script - " + e.Message,
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                return;
            }

            _avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
        }
Esempio n. 4
0
        private void OnAppDispatcherUnhandledException(
            object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            IMessageBoxService messageBoxService = ServiceLocator.Current.GetInstance <IMessageBoxService>();

            FaultException <ValidationException> validationException = e.Exception as FaultException <ValidationException>;

            if (validationException != null)
            {
                // Mostramos el error
                string validationMessage = string.Empty;
                foreach (var error in validationException.Detail.ValidationErrors)
                {
                    validationMessage = validationMessage + error + Environment.NewLine;
                }

                // Mostramos el mensaje.
                messageBoxService.Show(
                    validationMessage,
                    System.Windows.Application.Current.MainWindow.Title,
                    System.Windows.MessageBoxButton.OK,
                    System.Windows.MessageBoxImage.Error);

                e.Handled = true;
                return;
            }

            FaultException <InternalException> faultObject = e.Exception as FaultException <InternalException>;

            if (faultObject != null)
            {
                // Mostramos el mensaje.
                messageBoxService.Show(
                    faultObject.Detail.Reason,
                    System.Windows.Application.Current.MainWindow.Title,
                    System.Windows.MessageBoxButton.OK,
                    System.Windows.MessageBoxImage.Error);

                e.Handled = true;
                return;
            }

            string message = "UNHANDLED EXCEPTION: " +
                             Environment.NewLine +
                             Environment.NewLine +
                             e.Exception.GetType().Name +
                             Environment.NewLine +
                             Environment.NewLine +
                             e.Exception.Message;

            // Mostramos el mensaje.
            messageBoxService.Show(
                message,
                System.Windows.Application.Current.MainWindow.Title,
                System.Windows.MessageBoxButton.OK,
                System.Windows.MessageBoxImage.Error);
            e.Handled = true;

            //Application.Current.Shutdown(-1);
        }
Esempio n. 5
0
        private async void UseCurrentLocation()
        {
            if (!_settingsModel.AllowLocationAccess)
            {
                if (_messageBoxService.Show("Allow The Other Side to get your current location?\n\nYour location information will only be used to retrieve information and will not be saved or shared with anyone.", "Location Service", System.Windows.MessageBoxButton.OKCancel) != System.Windows.MessageBoxResult.OK)
                {
                    return;
                }

                _settingsModel.AllowLocationAccess = true;
                _settingsModel.Save();
            }

            _systemTrayService.Show("Getting your current location...");

            try
            {
                var position = await _locationService.GetPositionAsync(LocationServiceAccuracy.High, TimeSpan.FromMinutes(30), TimeSpan.FromSeconds(20));

                _systemTrayService.Hide();

                Position  = new Coordinate(position.Latitude, position.Longitude);
                Center    = Position;
                ZoomLevel = 14;
            }
            catch (Exception)
            {
                _systemTrayService.Hide();

                _messageBoxService.Show("An error occurred while trying to get your current location!", "Error");
            }
        }
Esempio n. 6
0
        public void Login()
        {
            try
            {
                Control = apiClient.GetUserLoginModelByEmail(Model.Email);
                var encrypter = new Encrypter();
                if (encrypter.MD5EncryptPassword(Model.Password) != Control.Password)
                {
                    messageBoxService.Show("Wrong combination of e-mail and password!", "Error", MessageBoxButton.OK);
                    Model = new UserLoginModelInner();
                }
                else
                {
                    IDHolder.IDUser = Control.Id ?? default(int);
                    var userModel = apiClient.GetUserById(IDHolder.IDUser);
                    IDHolder.NameUser = userModel.Name;

                    mediator.Send(new UserProfileCloseMessage());
                    mediator.Send(new UserListCloseMessage());
                    mediator.Send(new TeamUpdatedMessage());
                    Model = null;
                }
            }
            catch
            {
                messageBoxService.Show("Wrong combination of e-mail and password!", "Error", MessageBoxButton.OK);
                Model = new UserLoginModelInner();
            }
        }
Esempio n. 7
0
        private async void Delete()
        {
            if (_messageBoxService.Show($"Delete tag '{Repository}:{Tag}'?", "Delete tag", MessageBoxButton.YesNo) ==
                MessageBoxResult.Yes)
            {
                var ex = await Executor.ExecuteAsync(async() =>
                {
                    //We need to get the digest of the manifest
                    var manifest = await _registryClient.Manifest.GetManifestAsync(Repository, Tag);

                    string digest = manifest.DockerContentDigest;

                    if (string.IsNullOrWhiteSpace(digest))
                    {
                        _messageBoxService.Show("Unable to find digest.");
                    }
                    else
                    {
                        await _registryClient.Manifest.DeleteManifestAsync(Repository, digest);
                    }
                });

                if (ex == null)
                {
                    //Refresh
                    _parent.Refresh();
                }
            }
        }
Esempio n. 8
0
        public int SaveImage(Image img, string fileName)
        {
            sourcePath = fileName;
            string targetPath = AppConfiguration.DirectoryPath + "\\" + fileName;

            img.Save(sourcePath);


            try
            {
                _log.LogDebug("Saving image at: {targetPath}", targetPath);
                if (!File.Exists(sourcePath))
                {
                    _messageBoxService.Show("Error: No image to save");
                    return(-1);
                }

                // Ensure that the target does not exist.
                if (File.Exists(targetPath))
                {
                    _messageBoxService.Show("Image saved already");
                    return(0);
                }

                // Move the file.
                File.Move(sourcePath, targetPath);
                _log.LogDebug("Image saved ✅");
                return(0);
            }
            catch (Exception e)
            {
                _messageBoxService.Show($"The process failed: {e}");
                return(-1);
            }
        }
        public static MessageBoxResult Show(this IMessageBoxService service, string messageBoxText, string caption, MessageBoxButton button)
        {
#if !SILVERLIGHT
            return(service.Show(messageBoxText, caption, button, MessageBoxImage.None));
#else
            return(service.Show(messageBoxText, caption, button, MessageBoxResult.None));
#endif
        }
 private void Edit(StateMachineReferenceViewModel stateMachineViewModel)
 {
     try
     {
         stateMachineViewModel.Edit();
     }
     catch (Exception e)
     {
         _messageBoxService.Show(e);
     }
 }
 /// <summary>
 /// Deletes the student.
 /// </summary>
 public async Task DeleteStudentAsync()
 {
     if (SelectedStudent != null)
     {
         await _dataService.DeleteStudentAsync(SelectedStudent);
         await LoadDataAsync();
     }
     else
     {
         _messageBoxService.Show("Select one student.");
     }
 }
Esempio n. 12
0
        public NewObjectViewModel(ICttObjectTrackingService cttObjectTrackingService, INavigationService navigationService, ISystemTrayService systemTrayService, IMessageBoxService messageBoxService)
        {
            _cttObjectTrackingService = cttObjectTrackingService;
            _navigationService        = navigationService;
            _systemTrayService        = systemTrayService;
            _messageBoxService        = messageBoxService;

            AddObjectCommand = new RelayCommand(() =>
            {
                if (string.IsNullOrWhiteSpace(ObjectId))
                {
                    _messageBoxService.Show("Por favor indique o número do objecto", "Erro");

                    return;
                }

                _systemTrayService.SetProgressIndicator(string.Format("A adicionar: {0}...", ObjectId));

                _cttObjectTrackingService.GetCttObjectTrackingStatus(ObjectId, result =>
                {
                    _systemTrayService.HideProgressIndicator();

                    if (result.Error != null)
                    {
                        _messageBoxService.Show(string.Format("Não foi possível adicionar o objecto \"{0}\"", ObjectId), "Erro");

                        ScanBarcodeCommand.RaiseCanExecuteChanged();
                        AddObjectCommand.RaiseCanExecuteChanged();
                    }
                    else
                    {
                        MessengerInstance.Send <AddObjectMessage>(new AddObjectMessage(_description, result.ETag, result.Data));

                        _navigationService.GoBack();

                        ObjectId = null;
                    }
                }, null);

                ScanBarcodeCommand.RaiseCanExecuteChanged();
                AddObjectCommand.RaiseCanExecuteChanged();
            }, () => !IsBusy);

            ScanBarcodeCommand = new RelayCommand(() =>
            {
                _navigationService.NavigateTo(new Uri("/View/ScanBarcodePage.xaml", UriKind.Relative));
            }, () => !IsBusy);

            MessengerInstance.Register <ScannedBarcodeMessage>(this, message =>
            {
                ObjectId = message.ObjectId;
            });
        }
Esempio n. 13
0
 /// <summary>
 /// Deletes the university.
 /// </summary>
 private async Task DeleteUniversity()
 {
     if (SelectedUniversity != null)
     {
         await _dataService.DeleteUniversityAsync(SelectedUniversity);
         await LoadData();
     }
     else
     {
         _messageBoxService.Show("Select one university.");
     }
 }
Esempio n. 14
0
        public IList <SaveDataInfo> GetSaveInfo()
        {
            IMessageBoxService messageBoxService = ServicesContainer.GetService <IMessageBoxService>();

            IList <SaveDataInfo> saveDataInfoItems = FileSystemUtils.EnumerateSaveDataInfo().ToList();

            if (saveDataInfoItems.Count > 0)
            {
                return(saveDataInfoItems);
            }

            var options = new MessageBoxServiceOptions
            {
                Title          = "Save data not found",
                MessageBoxText = "Could not automatically find location of save data.\nPlease select it manually.",
                Buttons        = MessageBoxButton.OK,
                Icon           = MessageBoxImage.Warning
            };

            messageBoxService.Show(options);

            var dialog = new OpenFileDialog
            {
                AddExtension    = false,
                CheckFileExists = true,
                CheckPathExists = true,
                FileName        = FileSystemUtils.GameSaveDataFilename,
                Filter          = $"Save data|{FileSystemUtils.GameSaveDataFilename}|All files (*.*)|*.*",
                Multiselect     = false,
                ShowReadOnly    = true,
                Title           = "Select Monster Hunter: World save data file"
            };

            if (dialog.ShowDialog() != true)
            {
                options = new MessageBoxServiceOptions
                {
                    Title          = "Operation cancelled",
                    MessageBoxText = "Operation cancelled.",
                    Buttons        = MessageBoxButton.OK,
                    Icon           = MessageBoxImage.Warning
                };

                messageBoxService.Show(options);

                return(null);
            }

            saveDataInfoItems.Add(new SaveDataInfo("<unknown>", dialog.FileName));

            return(saveDataInfoItems);
        }
Esempio n. 15
0
        public void NullService1()
        {
            IMessageBoxService service = null;

            Assert.Throws <ArgumentNullException>(() => { service.Show(""); });
            Assert.Throws <ArgumentNullException>(() => { service.Show("", ""); });
            Assert.Throws <ArgumentNullException>(() => { service.ShowMessage("", "", MessageButton.OKCancel); });
            Assert.Throws <ArgumentNullException>(() => { service.ShowMessage("", "", MessageButton.OKCancel, MessageIcon.Warning); });
            Assert.Throws <ArgumentNullException>(() => { service.ShowMessage(""); });
            Assert.Throws <ArgumentNullException>(() => { service.ShowMessage("", ""); });
            Assert.Throws <ArgumentNullException>(() => { service.ShowMessage("", "", MessageButton.OKCancel); });
            Assert.Throws <ArgumentNullException>(() => { service.ShowMessage("", "", MessageButton.OKCancel, MessageIcon.Warning); });
        }
        private void Edit()
        {
            try
            {
                var viewModel = new TransitionEditorViewModel(_model, _parent, Reload, _messageBoxService);

                _viewService.ShowDialog(viewModel);
            }
            catch (Exception ex)
            {
                _messageBoxService.Show(ex);
            }
        }
Esempio n. 17
0
        private void Edit()
        {
            try
            {
                var viewModel = new StateDialogViewModel(Parent, GetModel(), Reload, _messageBoxService);

                _viewService.ShowDialog(viewModel);
            }
            catch (Exception ex)
            {
                _messageBoxService.Show(ex);
            }
        }
        private void Generate(string projectPath, DebugMode debugMode)
        {
            try
            {
                //Create the generator
                var generator = new EmbeddedCodeGenerator();

                //Get the project model
                var project = GetModel();

                project.GenerationOptions.DebugMode = debugMode;

                string documentationFullPath = string.Empty;

                if (!string.IsNullOrWhiteSpace(GenerationOptions.DocumentationFolder))
                {
                    var directory = Path.Combine(projectPath, GenerationOptions.DocumentationFolder ?? string.Empty);

                    Directory.CreateDirectory(directory);

                    documentationFullPath = Path.Combine(directory, DocumentationFileName);

                    new MarkdownGenerator().Generate(project.StateMachines.ToList(), documentationFullPath);
                }

                //Massage it real nice like
                project.Massage();

                try
                {
                    //Generate. Do it now.
                    generator.Generate(project, projectPath);
                }
                catch (Exception ex)
                {
                    string errorMessage = "\nException during code generation: " + ex.Message;

                    if (!string.IsNullOrWhiteSpace(documentationFullPath))
                    {
                        AppendTextToFile(documentationFullPath, errorMessage);
                    }

                    MessageBox.Show(errorMessage);
                }
            }
            catch (Exception ex)
            {
                _messageBoxService.Show(ex);
            }
        }
Esempio n. 19
0
        public void OnSelectGitPath()
        {
            string newPath  = ShowOpenFileDialog(".exe", "Select Git.exe");
            string fileName = Path.GetFileName(newPath);

            if (File.Exists(newPath) && fileName.ToLower() == "git.exe")
            {
                GitPath = newPath;
            }
            else
            {
                MSG_BOX_SERVICE.Show($"Unable to set Git Path to {newPath}", "Error selecting directory", System.Windows.MessageBoxButton.OK);
            }
        }
        bool ShowConfirmation()
        {
            if (!EnableConfirmationMessage)
            {
                return(true);
            }
            IMessageBoxService service = GetActualService();

#if !SILVERLIGHT
            MessageBoxResult res = service.Show(MessageText, MessageTitle, MessageButton, MessageIcon, MessageDefaultResult);
#else
            MessageBoxResult res = service.Show(MessageText, MessageTitle, MessageButton, MessageDefaultResult);
#endif
            return(res == MessageBoxResult.OK || res == MessageBoxResult.Yes);
        }
Esempio n. 21
0
        public void Save()
        {
            if (!CanSave)
            {
                return;
            }

            var ctx = CreateDecompileContext();

            if (ctx == null)
            {
                return;
            }

            tab.AsyncExec(cs => {
                ctx.DecompileNodeContext.DecompilationContext.CancellationToken = cs.Token;
                documentViewer.ShowCancelButton(dnSpy_Resources.SavingCode, () => cs.Cancel());
            }, () => {
                documentTreeNodeDecompiler.Decompile(ctx.DecompileNodeContext, nodes);
            }, result => {
                ctx.Dispose();
                documentViewer.HideCancelButton();
                if (result.Exception != null)
                {
                    messageBoxService.Show(result.Exception);
                }
            });
        }
Esempio n. 22
0
        public bool CanCloseDialog()
        {
            if (closeRequested)
            {
                return(true);
            }
            if (!isDirty)
            {
                return(true);
            }

            var interactionResult = MessageBoxService.Show("IG Outlook", ResourceStrings.SaveChangesMessage_Text, MessageBoxButtons.YesNoCancel);

            if (interactionResult == InteractionResult.Cancel)
            {
                return(false);
            }
            else if (interactionResult == InteractionResult.No)
            {
                DataErrorInfo dataErrorInfo;
                DataManager.CancelEdit(Activity, out dataErrorInfo);
                return(true);
            }
            else
            {
                SaveChanges();
                return(true);
            }
        }
Esempio n. 23
0
            public override void OnExecute(object sender, ExecutedRoutedEventArgs e)
            {
                // Save changes before closing current document?
                if (this.mViewModel.QuerySaveChanges() == false)
                {
                    return;
                }

                // Create and configure OpenFileDialog.
                FileDialog dlg = new OpenFileDialog()
                {
                    Filter          = MiniUML.Framework.Local.Strings.STR_FILETYPE_FILTER,
                    DefaultExt      = "xml",
                    AddExtension    = true,
                    ValidateNames   = true,
                    CheckFileExists = true
                };

                // Show dialog; return if canceled.
                if (!dlg.ShowDialog(Application.Current.MainWindow).GetValueOrDefault())
                {
                    return;
                }

                try
                {
                    // Open the document.
                    this.mViewModel.LoadFile(dlg.FileName);
                }
                catch (Exception ex)
                {
                    _MsgBox.Show(ex, string.Format(MiniUML.Framework.Local.Strings.STR_OpenFILE_MSG, dlg.FileName),
                                 MiniUML.Framework.Local.Strings.STR_OpenFILE_MSG_CAPTION);
                }
            }
Esempio n. 24
0
            public bool Execute()
            {
                // Create and configure SaveFileDialog.
                FileDialog dlg = new SaveFileDialog()
                {
                    Filter        = MiniUML.Framework.Local.Strings.STR_FILETYPE_FILTER_SAVE,
                    AddExtension  = true,
                    ValidateNames = true
                };

                // Show dialog; return if canceled.
                if (!dlg.ShowDialog(Application.Current.MainWindow).GetValueOrDefault())
                {
                    return(false);
                }

                try
                {
                    // Save document.
                    this.mViewModel._DataModel.Save(dlg.FileName);
                    this.mViewModel.prop_DocumentFilePath = dlg.FileName;

                    return(true);
                }
                catch (Exception ex)
                {
                    _MsgBox.Show(ex, string.Format(MiniUML.Framework.Local.Strings.STR_SaveFILE_MSG, dlg.FileName),
                                 MiniUML.Framework.Local.Strings.STR_SaveFILE_MSG_CAPTION);
                }

                return(false);
            }
Esempio n. 25
0
        public void Delete(object obj)
        {
            if (Model.Id != null)
            {
                try
                {
                    apiClient.DeleteUser(Model.Id ?? default(int));
                }
                catch
                {
                    messageBoxService.Show($"Deleting of {Model?.Name} filed", "Deleting failed", MessageBoxButton.OK);
                }
            }

            Model = null;
        }
Esempio n. 26
0
            public bool Execute()
            {
                string file = this.mViewModel.prop_DocumentFilePath;

                try
                {
                    if (File.Exists(file))
                    {
                        // Save document to the existing file.
                        this.mViewModel._DataModel.Save(file);
                        return(true);
                    }
                    else
                    {
                        // Execute SaveAs command.
                        return(((SaveAsCommandModel)this.mViewModel.cmd_SaveAs).Execute());
                    }
                }
                catch (Exception ex)
                {
                    _MsgBox.Show(ex, string.Format(MiniUML.Framework.Local.Strings.STR_SaveFILE_MSG, file),
                                 MiniUML.Framework.Local.Strings.STR_SaveFILE_MSG_CAPTION);
                }

                return(false);
            }
Esempio n. 27
0
        public void Save()
        {
            if (!CanSave)
            {
                return;
            }

            var ctx = CreateDecompileContext();

            if (ctx is null)
            {
                return;
            }

            tab.AsyncExec(cs => {
                ctx.Token = cs.Token;
                documentViewer.ShowCancelButton(dnSpy_BamlDecompiler_Resources.Saving, cs.Cancel);
            }, () => {
                bamlNode.Decompile(ctx.Output, ctx.Token);
            }, result => {
                ctx.Dispose();
                documentViewer.HideCancelButton();
                if (result.Exception is not null)
                {
                    messageBoxService.Show(result.Exception);
                }
            });
        }
        private void Refresh()
        {
            Tickets.Clear();

            if (!String.IsNullOrEmpty(SearchId))
            {
                try
                {
                    Ticket ticket = _context.Tickets.Find(Convert.ToInt32(SearchId));

                    if (ticket != null)
                    {
                        Tickets.Add(ticket);
                    }
                }
                catch (FormatException)
                {
                    MessageBoxService.Show("Bad id format", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                var tickets = _context.Tickets.ToList();

                foreach (var ticket in tickets)
                {
                    Tickets.Add(ticket);
                }
            }
        }
Esempio n. 29
0
        internal async void HandleException(Exception exception, bool startedByUser = false)
        {
            var errorMessage = ExceptionHandlerService.Instance.Handle(exception);


#if DEBUG
            MessageBoxService.Show(exception.ToString());
            return;
#endif

            if (startedByUser)
            {
                try
                {
                    await MessageBoxService.ShowAsync(errorMessage, AppResources.App_Error);
                }
                catch (Exception)
                {
                }
            }
            else
            {
                ShowErrorMessage(errorMessage);
            }
        }
Esempio n. 30
0
        public override void Save(Bookmark[] bookmarks)
        {
            if (bookmarks == null)
            {
                throw new ArgumentNullException(nameof(bookmarks));
            }
            if (bookmarks.Length == 0)
            {
                return;
            }
            var filename = pickSaveFilename.GetFilename(null, "xml", PickFilenameConstants.XmlFilenameFilter);

            if (filename == null)
            {
                return;
            }
            var settingsService = settingsServiceFactory.Value.Create();

            new BookmarksSerializer(settingsService, bookmarkLocationSerializerService.Value).Save(bookmarks);
            try {
                settingsService.Save(filename);
            }
            catch (Exception ex) {
                messageBoxService.Show(ex);
            }
        }
Esempio n. 31
0
		public static void OpenWebPage(string url, IMessageBoxService messageBoxService) {
			try {
				Process.Start(url);
			}
			catch {
				messageBoxService.Show(dnSpy_Resources.CouldNotStartBrowser);
			}
		}
        public MainWindowViewModel(IBookingService bookingService, IMessageBoxService mboxService, IConfigService configService)
        {
            _context = SynchronizationContext.Current;//We will always execute this on UI dispatcher.
            _bookingService = bookingService;
            _mboxService = mboxService;
            _configService = configService;

            AddNewCommand = new ActionCommand(AddNewClicked);

            _bookingService.GetBookingsAsync(DateTime.Now, HandleBookings,
                e => _mboxService.Show("Error Getting Bookings. " + e, "Error", MessageBoxButton.OK, MessageBoxImage.Error));
        }
        public MainViewModel(IMessageBoxService messageBoxService)
        {
            _messageBoxService = messageBoxService;

            AddItemCommand = new RelayCommand(() =>
            {
                Items.Add(DateTime.Now.ToString());

                EnableSelectionCommand.RaiseCanExecuteChanged();
            });

            EnableSelectionCommand = new RelayCommand(() =>
            {
                IsSelectionEnabled = true;
            }, () => Items.Count > 0);

            DeleteItemsCommand = new RelayCommand<System.Collections.IList>(items =>
            {
                var itemsToRemove = items
                    .Cast<string>()
                    .ToArray();

                foreach (var itemToRemove in itemsToRemove)
                {
                    Items.Remove(itemToRemove);
                }

                EnableSelectionCommand.RaiseCanExecuteChanged();

                IsSelectionEnabled = false;
            });

            BackKeyPressCommand = new RelayCommand<CancelEventArgs>(e =>
            {
                if (IsSelectionEnabled)
                {
                    IsSelectionEnabled = false;

                    e.Cancel = true;
                }
            });

            AboutCommand = new RelayCommand(() =>
            {
                _messageBoxService.Show("Cimbalino Windows Phone Toolkit Bindable Application Bar Sample", "About");
            });

            Items = new ObservableCollection<string>();
        }
Esempio n. 34
0
        public static void CheckAndPromptForSagaUpdate(IComponent handlerComponent, IMessageBoxService messageBoxService, IDialogWindowFactory windowFactory)
        {
            if (handlerComponent.ProcessesMultipleMessages)
            {
                var sagaRecommendationMessage =
                    handlerComponent.IsSaga
                        ? String.Format(Resources.Saga_UpdateQuery)
                        : String.Format(CultureInfo.CurrentCulture, Resources.Saga_ConvertQuery, handlerComponent.CodeIdentifier);

                var result = messageBoxService.Show(sagaRecommendationMessage, Resources.Saga_QueryTitle, MessageBoxButton.YesNo);
                if (result == MessageBoxResult.Yes)
                {
                    new ShowComponentSagaStarterPicker { WindowFactory = windowFactory, CurrentElement = handlerComponent }.Execute();
                }
            }
        }
Esempio n. 35
0
 public MainViewModel(IMessageBoxService messageBoxService)
 {
     if (messageBoxService == null) throw new ArgumentNullException(nameof(messageBoxService));
     _messageBoxService = messageBoxService;
     _items = new OrderedListViewModel<ItemViewModel>(
         //() => new ItemViewModel(),
         () => null,
         addedAction: item => Console.WriteLine($"Item '{item?.Text}' added"),
         deleted: item => _messageBoxService.Show($"Delete '{item.Text}'", button:MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         new ItemViewModel() {Value = 1, Text = "One"},
         new ItemViewModel() {Value = 2, Text = "Two"},
         new ItemViewModel() {Value = 3, Text = "Three"},
         new ItemViewModel() {Value = 4, Text = "Four"},
         new ItemViewModel() {Value = 5, Text = "Five"}
     };
 }
        public MainViewModel(ILocationService locationService, IMessageBoxService messageBoxService)
        {
            _locationService = locationService;
            _messageBoxService = messageBoxService;

            _locationService.PositionChanged += LocationService_PositionChanged;
            _locationService.StatusChanged += LocationService_StatusChanged;

            GetCurrentLocationCommand = new RelayCommand(() =>
            {
                _locationService.GetPosition(LocationServiceAccuracy.High, TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(10), (location, ex) =>
                {
                    if (ex != null)
                    {
                        _messageBoxService.Show(ex.ToString(), "Error");
                    }
                    else
                    {
                        CurrentLocation = location.ToString();
                    }
                });
            });

            StartMonitoringLocationCommand = new RelayCommand(() =>
            {
                _locationService.Start(LocationServiceAccuracy.High);

                Status = "Starting";
            });

            StopMonitoringLocationCommand = new RelayCommand(() =>
            {
                _locationService.Stop();

                Status = "Stopped";
            });

            CurrentLocation = "(Unknown)";
            Status = "Stopped";
        }
Esempio n. 37
0
        public ExplorerViewModel(IMainModel mainModel, IGoogleDriveService googleDriveService, INavigationService navigationService, IMessageBoxService messageBoxService, ISystemTrayService systemTrayService, IPhotoChooserService photoChooserService)
        {
            _mainModel = mainModel;
            _googleDriveService = googleDriveService;
            _navigationService = navigationService;
            _messageBoxService = messageBoxService;
            _systemTrayService = systemTrayService;
            _photoChooserService = photoChooserService;

            Files = new ObservableCollection<GoogleFileViewModel>();
            PictureFiles = new ObservableCollection<GoogleFileViewModel>();

            OpenFileCommand = new RelayCommand<GoogleFileViewModel>(file =>
            {
                if (IsSelectionEnabled)
                {
                    return;
                }

                OpenFile(file);
            });

            ChangeStaredStatusCommand = new RelayCommand<GoogleFileViewModel>(file =>
            {
                if (IsSelectionEnabled)
                {
                    return;
                }

                ChangeStaredStatus(file);
            });

            AddFileCommand = new RelayCommand(UploadFile);

            EnableSelectionCommand = new RelayCommand(() =>
            {
                if (IsBusy)
                {
                    return;
                }

                IsSelectionEnabled = true;
            });

            RefreshFilesCommand = new RelayCommand(RefreshFiles);

            DeleteFilesCommand = new RelayCommand<IList>(files =>
            {
                _messageBoxService.Show("You are about to delete the selected files. Do you wish to proceed?", "Delete files?", new[] { "delete", "cancel" }, button =>
                {
                    if (button != 0)
                        return;

                    var filesArray = files
                        .Cast<GoogleFileViewModel>()
                        .ToArray();

                    IsSelectionEnabled = false;

                    DeleteFiles(filesArray);
                });
            });

            CreateNewFolderCommand = new RelayCommand(CreateNewFolder);

            RenameFileCommand = new RelayCommand<GoogleFileViewModel>(RenameFile);

            DeleteFileCommand = new RelayCommand<GoogleFileViewModel>(file =>
            {
                _messageBoxService.Show(string.Format("You are about to delete '{0}'. Do you wish to proceed?", file.Title), "Delete file?", new[] { "delete", "cancel" }, button =>
                {
                    if (button != 0)
                        return;

                    DeleteFile(file);
                });
            });

            ShowAboutCommand = new RelayCommand(() =>
            {
                _navigationService.NavigateTo("/View/AboutPage.xaml");
            });

            PageLoadedCommand = new RelayCommand(ExecuteInitialLoad);

            BackKeyPressCommand = new RelayCommand<CancelEventArgs>(e =>
            {
                GoogleDriveFile item;

                if (PivotSelectedIndex == 1)
                {
                    PivotSelectedIndex = 0;

                    e.Cancel = true;
                }
                else if (IsSelectionEnabled)
                {
                    IsSelectionEnabled = false;

                    e.Cancel = true;
                }
                else if (_mainModel.TryPop(out item))
                {
                    AbortCurrentCall();

                    RaisePropertyChanged(() => CurrentPath);

                    RefreshFiles();

                    e.Cancel = true;
                }
                else
                {
                    AbortCurrentCall(true);

                    Files.Clear();
                    PictureFiles.Clear();
                }
            });

            MessengerInstance.Register<RefreshFilesMessage>(this, message =>
            {
                DispatcherHelper.RunAsync(RefreshFiles);
            });
        }
Esempio n. 38
0
        public MainViewModel(IMainModel mainModel, INavigationService navigationService, IMessageBoxService messageBoxService, IApplicationSettingsService applicationSettingsService, IShellTileService shellTileService)
        {
            _mainModel = mainModel;
            _navigationService = navigationService;
            _messageBoxService = messageBoxService;
            _applicationSettingsService = applicationSettingsService;
            _shellTileService = shellTileService;

            NewAccountCommand = new RelayCommand(() =>
            {
                _navigationService.NavigateTo("/View/AuthorizationPage.xaml");
            });

            RemoveAccountCommand = new RelayCommand<AccountViewModel>(account =>
            {
                _mainModel.AvailableAccounts.Remove(account.Model);
                _mainModel.Save();

                RefreshAccountsList();
            });

            OpenAccountCommand = new RelayCommand<AccountViewModel>(account =>
            {
                _mainModel.CurrentAccount = account.Model;
                _mainModel.ExecuteInitialLoad = true;

                _navigationService.NavigateTo("/View/ExplorerPage.xaml");
            });

            ShowAboutCommand = new RelayCommand(() =>
            {
                _navigationService.NavigateTo("/View/AboutPage.xaml");
            });

            PageLoadedCommand = new RelayCommand(() =>
            {
                _mainModel.CurrentAccount = null;

                if (!_applicationSettingsService.Get<bool>("AcceptedDisclaimer", false))
                {
                    _applicationSettingsService.Set("AcceptedDisclaimer", true);
                    _applicationSettingsService.Save();

                    _messageBoxService.Show("You are advised to read the GDrive disclaimer before you continue.\n\nWould you like to read it now?\n\nYou can always find it later in the About page.", "Welcome to GDrive", new[] { "now", "later" }, buttonIndex =>
                    {
                        if (buttonIndex == 0)
                        {
                            _navigationService.NavigateTo("/View/AboutPage.xaml?disclaimer=true");
                        }
                    });
                }
            });

            MessengerInstance.Register<AvailableAccountsChangedMessage>(this, message =>
            {
                RefreshAccountsList();
            });

#if !WP8
            DispatcherHelper.RunAsync(UpdateTiles);
#endif
        }