private void OpenCopyInKitExplorer(DataTreeNodeViewModel kitNode)
        {
            var kit       = Module.ExportKit(kitNode.KitNumber !.Value);
            var viewModel = new KitExplorerViewModel(ViewServices, Logger, DeviceViewModel, kit);

            ViewServices.ShowKitExplorer(viewModel);
        }
Example #2
0
        private void NotifyToast(NotificationViewModel vm)
        {
            vm.Dispatcher        = Dispatcher;
            vm.MessengerInstance = MessengerInstance;

            ViewServices.OpenNotificationFlyout(vm);
        }
Example #3
0
        /// <summary>
        /// Displays the Progress dialog.
        /// </summary>
        private void OnWorkStarting(object sender, EventArgs e)
        {
            var mainWindowViewModel     = (MainWindowViewModel)this.DataContext;
            var progressDialogViewModel = mainWindowViewModel.ProgressDialogViewModel;

            ViewServices.ShowProgressDialog(Application.Current.MainWindow, progressDialogViewModel);
        }
Example #4
0
        private async void ExecuteDeleteProjectCommand(ProjectViewModel arg)
        {
            ConfirmationServiceArgs args = new ConfirmationServiceArgs(Strings.Confirm, string.Format(Strings.DoYouReallyWantToDeleteProjectXXX, arg.Model.Name), Strings.Yes, Strings.No);

            if (!await ViewServices.Execute <IConfirmationService, bool>(args))
            {
                return;
            }

            arg.CurrentChanged -= Proj_CurrentChanged;

            Projects.Remove(arg);
            ProjectRepo.Delete(arg.Model);

            if (!Projects.Contains(CurrentProject))
            {
                CurrentProject = Projects.FirstOrDefault();
                if (CurrentProject != null)
                {
                    CurrentProject.IsCurrent = true;
                }
            }

            MessengerInstance.Send(new NotificationMessage(Strings.ProjectDeleted));
        }
        private void ImportKitFromFile(DataTreeNodeViewModel kitNode)
        {
            string?file = ViewServices.ShowOpenFileDialog(FileFilters.KitFiles);

            if (file is null)
            {
                return;
            }
            object loaded;

            try
            {
                loaded = ProtoIo.LoadModel(file, Logger);
            }
            catch (Exception ex)
            {
                Logger.LogError($"Error loading {file}", ex);
                return;
            }
            if (!(loaded is Kit kit))
            {
                Logger.LogError("Loaded file was not a kit");
                return;
            }

            if (!kit.Schema.Identifier.Equals(Module.Schema.Identifier))
            {
                Logger.LogError($"Kit was from {kit.Schema.Identifier.Name}; this module is {Module.Schema.Identifier.Name}");
                return;
            }
            Module.ImportKit(kit, kitNode.KitNumber !.Value);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        ViewServices.RegisterCommonTransformations();
        ViewServices.RegisterMimeType();

        // Force NET mumbojumbo scripts to appear - needed for UpdateManager.js
        this.Page.ClientScript.GetPostBackEventReference(this, string.Empty);
    }
Example #7
0
        private async void ExecuteBrowseFolderCommand()
        {
            var path = await ViewServices.Execute <IBrowseFileService, string>(System.IO.Path.GetDirectoryName(Path));

            if (!string.IsNullOrWhiteSpace(path))
            {
                Path = path;
            }
        }
Example #8
0
        public EnqueteController()
        {
            this.unitOfWork      = UnitOfWork.GetInstanceLazyLoad(base.contexto);
            this.pollRepositorio = base.unitOfWork.PollRepositorio;
            this.viewRepositorio = base.unitOfWork.ViewRepositorio;

            this.pollServices = new PollServices(this.pollRepositorio, this.viewRepositorio);
            this.viewServices = new ViewServices(this.viewRepositorio);
        }
        private void CopyKit(DataTreeNodeViewModel kitNode)
        {
            var kit                  = Module.ExportKit(kitNode.KitNumber !.Value);
            var viewModel            = new CopyKitViewModel(Module, kit);
            var destinationKitNumber = ViewServices.ChooseCopyKitTarget(viewModel);

            if (destinationKitNumber is int destination)
            {
                Module.ImportKit(kit, destination);
            }
        }
Example #10
0
        private async void ExecuteDeleteEntryCommand()
        {
            ConfirmationServiceArgs args = new ConfirmationServiceArgs(Strings.Confirm, Strings.DoYouReallyWantToDeleteThisEntry, Strings.Yes, Strings.No);

            if (!await ViewServices.Execute <IConfirmationService, bool>(args))
            {
                return;
            }

            DeleteRequested?.Invoke(this, EventArgs.Empty);
        }
Example #11
0
        private async void ExecuteDeleteScheduleCommand()
        {
            var csa = new ConfirmServiceArgs(Strings.ConfirmDeleteSchedule);

            if (!await ViewServices.Confirm(csa))
            {
                return;
            }

            Scheduler.DeleteJob(Job);
        }
        private void ExportKit(DataTreeNodeViewModel kitNode)
        {
            var kit  = Module.ExportKit(kitNode.KitNumber !.Value);;
            var file = ViewServices.ShowSaveFileDialog(FileFilters.KitFiles);

            if (file is null)
            {
                return;
            }
            using (var stream = File.Create(file))
            {
                kit.Save(stream);
            }
        }
Example #13
0
        private async void ExecuteDeleteTagCommand(TagViewModel arg)
        {
            ConfirmationServiceArgs args = new ConfirmationServiceArgs(Strings.Confirm,
                                                                       string.Format(Strings.DoYouReallyWantToDeleteTagXXX, arg.Model.Name),
                                                                       Strings.Yes, Strings.No);

            if (!await ViewServices.Execute <IConfirmationService, bool>(args))
            {
                return;
            }

            TagRepo.Delete(arg.Model);
            Tags.Remove(arg);

            MessengerInstance.Send(new TagRemovedMessage(arg.Model));
            MessengerInstance.Send(new NotificationMessage(Strings.TagDeleted));
            ReadTagNames();
        }
Example #14
0
        private void DisplayPopup(string message, int closeTime, string display = null, Corner?displayCorner = null)
        {
            display       = display ?? Config.Notifications.PopupDisplay;
            displayCorner = displayCorner ?? Config.Notifications.PopupDisplayCorner;

            var displayPosition = DisplayHelper.GetDisplayPosition(display);

            var       size   = new Size(300, 200);
            const int margin = 10;

            var position = new Rect(size);

            switch (displayCorner)
            {
            case Corner.TopLeft:
                position.X = displayPosition.Left + margin;
                position.Y = displayPosition.Top + margin;
                break;

            case Corner.BottomLeft:
                position.X = displayPosition.Left + margin;
                position.Y = displayPosition.Bottom - margin - size.Height;
                break;

            case Corner.BottomRight:
                position.X = displayPosition.Right - margin - size.Width;
                position.Y = displayPosition.Bottom - margin - size.Height;
                break;

            case Corner.TopRight:
                position.X = displayPosition.Right - margin - size.Width;
                position.Y = displayPosition.Top + margin;
                break;
            }

            var context = new NotificationViewModel(message, NotificationType.Information, position, ProcStarter)
            {
                CloseDelay        = TimeSpan.FromSeconds(closeTime),
                Dispatcher        = Dispatcher,
                MessengerInstance = MessengerInstance
            };

            ViewServices.OpenNotificationPopup(context);
        }
Example #15
0
        private static async void ExecuteOpenProfileCommand(object args)
        {
            if (args == null)
            {
                return;
            }

            string screenName = args.ToString();
            ulong  userid;

            if (ulong.TryParse(screenName, out userid))
            {
                await ViewServices.ViewProfile(userid);
            }
            else
            {
                await ViewServices.ViewProfile(screenName);
            }
        }
Example #16
0
        private async void ExecuteMoveDatabaseCommand()
        {
            var result = await ViewServices.Execute <IMoveDatabaseService, MoveDatabaseResult>();

            if (string.IsNullOrWhiteSpace(result.Path))
            {
                return;
            }

            if (result.OverwriteExisting || !File.Exists(result.Path))
            {
                await ViewServices.Execute <IProgressService>(new ProgressServiceArgs( report =>
                {
                    SQLiteBackupCallback callback =
                        (source, sourceName, destination, destinationName, pages, remainingPages, totalPages, retry) =>
                    {
                        report.SetProgress(totalPages - remainingPages, totalPages);
                        return(true);
                    };

                    SQLiteConnectionStringBuilder sb = new SQLiteConnectionStringBuilder
                    {
                        DataSource = result.Path
                    };

                    using (SQLiteConnection destConnection = new SQLiteConnection(sb.ToString()))
                    {
                        destConnection.Open();

                        var connection = App.Session.Connection as SQLiteConnection;
                        Debug.Assert(connection != null, "connection != null");
                        connection.BackupDatabase(destConnection, "main", "main", -1, callback, 100);
                    }
                } ));
            }

            Settings.Set(SettingKeys.DatabasePath, result.Path);
            Application.Current.Shutdown();
            Process.Start(Assembly.GetExecutingAssembly().Location);
        }
Example #17
0
        public MainViewModel(IObservable <LogEvent> logEvents, ICollection <DeployerItem> deployersItems,
                             ICollection <DriverPackageImporterItem> driverPackageImporterItems, ViewServices viewServices,
                             Func <Task <Phone> > getPhoneFunc)
        {
            DualBootViewModel = new DualBootViewModel(viewServices.DialogCoordinator);

            DeployersItems = deployersItems;

            this.driverPackageImporterItems = driverPackageImporterItems;
            this.viewServices = viewServices;
            this.getPhoneFunc = getPhoneFunc;

            ShowWarningCommand = ReactiveCommand.CreateFromTask(() =>
                                                                viewServices.DialogCoordinator.ShowMessageAsync(this, Resources.TermsOfUseTitle,
                                                                                                                Resources.WarningNotice));

            SetupPickWimCommand();

            var isDeployerSelected =
                this.WhenAnyValue(model => model.SelectedDeployerItem, (DeployerItem x) => x != null);
            var isSelectedWim = this.WhenAnyObservable(x => x.WimMetadata.SelectedImageObs)
                                .Select(metadata => metadata != null);

            var canDeploy =
                isSelectedWim.CombineLatest(isDeployerSelected, (hasWim, hasDeployer) => hasWim && hasDeployer);

            FullInstallWrapper = new CommandWrapper <Unit, Unit>(this,
                                                                 ReactiveCommand.CreateFromTask(DeployUefiAndWindows, canDeploy), viewServices.DialogCoordinator);
            WindowsInstallWrapper = new CommandWrapper <Unit, Unit>(this,
                                                                    ReactiveCommand.CreateFromTask(DeployWindows, canDeploy), viewServices.DialogCoordinator);
            InjectDriversWrapper = new CommandWrapper <Unit, Unit>(this,
                                                                   ReactiveCommand.CreateFromTask(InjectPostOobeDrivers, isDeployerSelected),
                                                                   viewServices.DialogCoordinator);

            ImportDriverPackageWrapper = new CommandWrapper <Unit, Unit>(this,
                                                                         ReactiveCommand.CreateFromTask(ImportDriverPackage), viewServices.DialogCoordinator);

            var isBusyObs = Observable.Merge(FullInstallWrapper.Command.IsExecuting,
                                             WindowsInstallWrapper.Command.IsExecuting,
                                             InjectDriversWrapper.Command.IsExecuting,
                                             ImportDriverPackageWrapper.Command.IsExecuting);

            var dualBootIsBusyObs = DualBootViewModel.IsBusyObs;

            isBusyHelper = Observable.Merge(isBusyObs, dualBootIsBusyObs)
                           .ToProperty(this, model => model.IsBusy);

            progressHelper = progressSubject
                             .Where(d => !double.IsNaN(d))
                             .ObserveOnDispatcher()
                             .ToProperty(this, model => model.Progress);

            isProgressVisibleHelper = progressSubject
                                      .Select(d => !double.IsNaN(d))
                                      .ToProperty(this, x => x.IsProgressVisible);

            statusHelper = logEvents
                           .Where(x => x.Level == LogEventLevel.Information)
                           .Select(x => new RenderedLogEvent
            {
                Message = x.RenderMessage(),
                Level   = x.Level
            })
                           .ToProperty(this, x => x.Status);

            logLoader = logEvents
                        .Where(x => x.Level == LogEventLevel.Information)
                        .ToObservableChangeSet()
                        .Transform(x => new RenderedLogEvent
            {
                Message = x.RenderMessage(),
                Level   = x.Level
            })
                        .Bind(out this.logEvents)
                        .DisposeMany()
                        .Subscribe();

            hasWimHelper = this.WhenAnyValue(model => model.WimMetadata, (WimMetadataViewModel x) => x != null)
                           .ToProperty(this, x => x.HasWim);
        }
Example #18
0
 private static async void ExecuteStartSearchCommand(string query)
 {
     await ViewServices.OpenSearch(query);
 }
Example #19
0
 private static async void ExecuteOpenStatusCommand(StatusViewModel vm)
 {
     // TODO: If status is a retweet, display the retweeted status instead of the retweet
     await ViewServices.ViewStatus(vm);
 }
Example #20
0
 private static async void ExecuteOpenMessageCommand(MessageViewModel message)
 {
     await ViewServices.ViewDirectMessage(message);
 }
Example #21
0
 private static async void ExecuteOpenImageCommand(Uri imageUrl)
 {
     await ViewServices.ViewImage(new[] { imageUrl }, imageUrl);
 }
Example #22
0
 private static async void ExecuteOpenProfileCommand(ulong args)
 {
     await ViewServices.ViewProfile(args);
 }
Example #23
0
 private async void ExecuteInfoCommand()
 {
     await ViewServices.Execute <IInfoService>();
 }
Example #24
0
 /// <summary>
 /// Closes the Progress dialog.
 /// </summary>
 private void OnWorkEnding(object sender, EventArgs e)
 {
     ViewServices.CloseProgressDialog();
 }