/// <summary>
 /// Called when the dialog is opened.
 /// </summary>
 /// <param name="parameters">The parameters passed to the dialog.</param>
 public override void OnDialogOpened(IDialogParameters parameters)
 {
     base.OnDialogOpened(parameters);
     // Configure parameters
     if (parameters.TryGetValue(DialogParameterNames.Message, out string message))
     {
         this.Message = message;
     }
     if (parameters.TryGetValue(DialogParameterNames.ButtonText, out string buttonText))
     {
         this.ButtonText = buttonText;
     }
 }
예제 #2
0
 /// <inheritdoc />
 public override void OnDialogOpened(IDialogParameters parameters)
 {
     if (parameters != null && parameters.TryGetValue <Brand>(nameof(Brand), out var result))
     {
         this.model.LoadBrand(result);
     }
 }
예제 #3
0
 /// <inheritdoc />
 public override void OnDialogOpened(IDialogParameters parameters)
 {
     if (parameters != null && parameters.TryGetValue <MessageDialogSettings>(nameof(MessageDialogSettings), out var result))
     {
         this.model.LoadSettings(result);
     }
 }
예제 #4
0
        void IDialogAware.OnDialogOpened(IDialogParameters parameters)
        {
            if (parameters.TryGetValue <string>("Path", out var file))
            {
                this.Files.Add(file);
            }
            else
            {
                var interactionResult = this.interactionService.SelectFiles(FileDialogSettings.FromFilterString(new DialogFilterBuilder("*" + FileConstants.MsixExtension).BuildFilter()), out string[] selection);
                if (!interactionResult || !selection.Any())
                {
                    return;
                }

                foreach (var selected in selection)
                {
                    if (this.Files.Contains(selected, StringComparer.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    this.Files.Add(selected);
                }
            }

            this.Files.Commit();
        }
        public override void OnDialogOpened(IDialogParameters parameters)
        {
            if (parameters != null)
            {
                GraphInfo = parameters.GetValue <RoomLineGraphInfo>("model");

                if (parameters.TryGetValue("id", out int reportId))
                {
                    TemperatureGraphInfo = RoomLineGraphInfo.CreateDefault();
                    HumidityGraphInfo    = RoomLineGraphInfo.CreateDefault();
                    Task.Run(async() =>
                    {
                        var collection = await _roomRepository.FilterRooms(reportId, GraphInfo.ActiveDevice.Id);
                        if (collection.Count() > 0)
                        {
                            TemperatureGraphInfo = FillTemperatureModel(collection);
                            HumidityGraphInfo    = FillHumidityModel(collection);
                        }
                    });
                }

                Title = $"{GraphInfo?.ActiveDevice?.Nick} {GraphInfo?.ActiveDevice?.IPAddress}";
                InitializeAnnotations();
                SetSettings();
            }
        }
예제 #6
0
 /// <inheritdoc />
 public override void OnDialogOpened(IDialogParameters parameters)
 {
     if (parameters != null && parameters.TryGetValue <Product>(nameof(Product), out var result))
     {
         this.model.LoadProduct(result);
     }
 }
예제 #7
0
        public override void OnDialogOpened(IDialogParameters parameters)
        {
            parameters.TryGetValue("title", out string title);
            Title   = title ?? "Confirmation";
            Message = parameters.GetValue <string>("message");
            var buttons = parameters.GetValue <string>("buttons");

            if (string.IsNullOrEmpty(buttons))
            {
                Button0Text = "Save";
                Button1Text = "Don't save";
                Button2Text = "Cancel";
            }
            else
            {
                var b = buttons.Split(',');
                for (int i = 0; i < b.Length; i++)
                {
                    if (i == 0)
                    {
                        Button0Text = b[i];
                    }
                    if (i == 1)
                    {
                        Button1Text = b[i];
                    }
                    if (i == 2)
                    {
                        Button2Text = b[i];
                    }
                }
            }
        }
예제 #8
0
        public static void ShowMessageBox(this IDialogService _, IDialogParameters parameters, Action <IDialogResult> callback)
        {
            parameters.TryGetValue(DialogParams.Title, out string title);
            parameters.TryGetValue(DialogParams.Alert.Buttons, out DialogParams.Alert.AlertButtons buttons);
            parameters.TryGetValue(DialogParams.Alert.Image, out DialogParams.Alert.AlertImage image);
            parameters.TryGetValue(DialogParams.Alert.DefaultResult, out ButtonResult defaultResult);

            var dialogResult = new DialogResult(MessageBox.Show(
                                                    parameters.GetValue <string>(DialogParams.Alert.Content),
                                                    title,
                                                    buttons.ToMessageBoxButton(),
                                                    image.ToMessageBoxImage(),
                                                    defaultResult.ToMessageBoxResult()
                                                    ).ToButtonResult());

            callback?.Invoke(dialogResult);
        }
예제 #9
0
        public void OnDialogOpened(IDialogParameters parameters)
        {
            if (parameters.TryGetValue("yaml", out string yamlSelectedPath))
            {
                this.yamlPath = Path.ChangeExtension(yamlSelectedPath, FileConstants.WingetExtension);
#pragma warning disable 4014
                this.GeneralProgress.MonitorProgress(this.Definition.LoadFromYaml(yamlSelectedPath));
            }
            else if (parameters.TryGetValue("msix", out string msixPath))
            {
                this.yamlPath = Path.ChangeExtension(Path.GetFileNameWithoutExtension(msixPath), FileConstants.WingetExtension);
                this.GeneralProgress.MonitorProgress(this.Definition.LoadFromFile(msixPath));
            }
            else
            {
                this.GeneralProgress.MonitorProgress(this.Definition.NewManifest(CancellationToken.None));
            }
        }
예제 #10
0
        public void OnDialogOpened(IDialogParameters parameters)
        {
            if (!parameters.TryGetValue("file", out string sourceFile))
            {
                return;
            }

            this.SourcePath.CurrentValue = sourceFile;
            this.TabProperties.Commit();
            this.TabParentPackage.Commit();
        }
예제 #11
0
        /// <summary>
        ///     Return a value from dialog
        /// </summary>
        /// <param name="dialogResult"></param>
        /// <param name="value">output parameter</param>
        /// <typeparam name="TValue">Value to return</typeparam>
        /// <returns>Returns a parameter from the IDialogResult. The key is TValue name.</returns>
        public static bool TryGetDialogParameter <TValue>(this IDialogParameters dialogResult, out TValue value)
        {
            if (dialogResult.TryGetValue(typeof(TValue).Name, out value))
            {
                return(true);
            }

            value = default;

            return(false);
        }
예제 #12
0
        /// <summary>
        /// Called when the dialog is opened.
        /// </summary>
        /// <param name="parameters">The parameters passed to the dialog.</param>
        public override void OnDialogOpened(IDialogParameters parameters)
        {
            base.OnDialogOpened(parameters);
            // Subscribe event
            this.eventAggregator.GetEvent <FileSelectionEvent>().Subscribe(this.OnFileSelection);
            this.eventAggregator.GetEvent <MoveCurrentFolderEvent>().Subscribe(this.OnMoveCurrentFolder);
            // Configure parameters
            if (parameters.TryGetValue(DialogParameterNames.FolderNamePrefixText, out string folderNamePrefixText))
            {
                this.FolderNamePrefixText = folderNamePrefixText;
            }
            if (parameters.TryGetValue(DialogParameterNames.SelectButtonText, out string selectButtonText))
            {
                this.SelectButtonText = selectButtonText;
            }
            if (parameters.TryGetValue(DialogParameterNames.CancelButtonText, out string cancelButtonText))
            {
                this.CancelButtonText = cancelButtonText;
            }
            var regionContext = ExplorerBaseRegionContext.CreateForSingleFolderSelect();

            if (parameters.TryGetValue(DialogParameterNames.TextResource, out ExplorerBaseTextResource textResource))
            {
                regionContext.TextResource = textResource;
            }
            if (parameters.TryGetValue(DialogParameterNames.CanMultiSelect, out bool canMultiSelect))
            {
                regionContext.CanMultiSelect = canMultiSelect;
            }
            if (parameters.TryGetValue(DialogParameterNames.RootFolders, out IEnumerable <string> rootFolders))
            {
                regionContext.RootFolders = rootFolders;
            }
            this.RegionContext = regionContext;
        }
예제 #13
0
        void IDialogAware.OnDialogOpened(IDialogParameters parameters)
        {
            if (parameters.TryGetValue <string>("Path", out var file))
            {
                this.Files.Add(file);
            }
            else
            {
                return;
            }

            this.Files.Commit();
        }
예제 #14
0
        public void OnDialogOpened(IDialogParameters parameters)
        {
            var hasToken = parameters.TryGetValue <CancellationTokenSource>(
                ScanningWifiParams.CancellationTokenSource,
                out var cancellationToken);

            if (hasToken)
            {
                _tokenSource = cancellationToken;
            }

            _id = parameters.GetValue <Guid>(ScanningWifiParams.Identifier);
        }
예제 #15
0
        /// <summary>
        /// Called when the dialog is opened.
        /// </summary>
        /// <param name="parameters">The parameters passed to the dialog.</param>
        public override void OnDialogOpened(IDialogParameters parameters)
        {
            base.OnDialogOpened(parameters);
            // Subscribe event
            this.eventAggregator.GetEvent <FileSelectionEvent>().Subscribe(this.OnFileSelection);
            this.eventAggregator.GetEvent <MoveCurrentFolderEvent>().Subscribe(this.OnMoveCurrentFolder);
            this.eventAggregator.GetEvent <FileEnterEvent>().Subscribe(this.OnFileEnter);
            // Configure parameters
            if (parameters.TryGetValue(DialogParameterNames.FileNamePrefixText, out string fileNamePrefixText))
            {
                this.FileNamePrefixText = fileNamePrefixText;
            }
            if (parameters.TryGetValue(DialogParameterNames.SelectButtonText, out string selectButtonText))
            {
                this.SelectButtonText = selectButtonText;
            }
            if (parameters.TryGetValue(DialogParameterNames.CancelButtonText, out string cancelButtonText))
            {
                this.CancelButtonText = cancelButtonText;
            }
            this.filters.Clear();
            if (parameters.TryGetValue(DialogParameterNames.Filters, out IEnumerable <FileFilter> filters))
            {
                this.filters.AddRange(filters);
            }
            else
            {
                var filter = parameters.TryGetValue(DialogParameterNames.DefaultAllFilesFilterText, out string filterText) ? new FileFilter(filterText) : FileFilter.CreateDefault();
                this.filters.Add(filter);
            }
            this.selectedFilter = this.Filters.First();
            var regionContext = ExplorerBaseRegionContext.CreateForSingleFileSelect();

            if (parameters.TryGetValue(DialogParameterNames.TextResource, out ExplorerBaseTextResource textResource))
            {
                regionContext.TextResource = textResource;
            }
            if (parameters.TryGetValue(DialogParameterNames.CanMultiSelect, out bool canMultiSelect))
            {
                regionContext.CanMultiSelect = canMultiSelect;
            }
            if (parameters.TryGetValue(DialogParameterNames.RootFolders, out IEnumerable <string> rootFolders))
            {
                regionContext.RootFolders = rootFolders;
            }
            regionContext.FileExtensions = this.Filters.First().Extensions;
            this.RegionContext           = regionContext;
        }
예제 #16
0
        public void OnDialogOpened(IDialogParameters parameters)
        {
            if (parameters is null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            if (parameters.TryGetValue(nameof(Lamp), out Lamp lamp))
            {
                this.Lamp = lamp;
            }
            else
            {
                RequestClose(new DialogResult());
            }
        }
예제 #17
0
 /// <summary>
 /// Called when the dialog is opened.
 /// </summary>
 /// <param name="parameters">The parameters passed to the dialog.</param>
 public virtual void OnDialogOpened(IDialogParameters parameters)
 {
     // Configure parameters
     if (parameters.TryGetValue(DialogParameterNames.Title, out string title))
     {
         this.Title = title;
     }
     if (parameters.TryGetValue(DialogParameterNames.StartupLoaction, out WindowStartupLocation startupLoaction))
     {
         this.StartupLocation = startupLoaction;
     }
     if (parameters.TryGetValue(DialogParameterNames.ResizeMode, out ResizeMode resizeMode))
     {
         this.ResizeMode = resizeMode;
     }
     if (parameters.TryGetValue(DialogParameterNames.SizeToContent, out SizeToContent sizeToContent))
     {
         this.SizeToContent = sizeToContent;
     }
     if (parameters.TryGetValue(DialogParameterNames.WindowStyle, out Style windwoStyle))
     {
         this.WindowStyle = windwoStyle;
     }
     if (parameters.TryGetValue(DialogParameterNames.Width, out double width))
     {
         this.Width = width;
     }
     if (parameters.TryGetValue(DialogParameterNames.Height, out double height))
     {
         this.Height = height;
     }
     if (parameters.TryGetValue(DialogParameterNames.ContentWidth, out double contentWidth))
     {
         this.ContentWidth = contentWidth;
     }
     if (parameters.TryGetValue(DialogParameterNames.ContentHeight, out double contentHeight))
     {
         this.ContentHeight = contentHeight;
     }
 }
예제 #18
0
        public override void OnDialogOpened(IDialogParameters parameters)
        {
            if (parameters != null)
            {
                bool setSetting = true;
                _current  = parameters.GetValue <MultiRoomLineGraphInfo>("model");
                GraphInfo = _current;

                var title = $"{_current?.ActiveDevice?.Nick} {_current?.ActiveDevice?.IPAddress}";
                Title = title;
                if (parameters.TryGetValue("date", out DateTimeSpanFilter date))
                {
                    setSetting = false;
                    Task.Run(async() =>
                    {
                        var collection = await _multiRoomRepository.FilterRooms(_current.ActiveDevice.IPAddress, date.FromDate, date.ToDate);
                        GraphInfo      = new MultiRoomLineGraphInfo(GraphInfo.ActiveDevice, false);

                        GraphInfo.GraphLineModelForDefault        = InitializeDefault(collection, 1);
                        GraphInfo.GraphLineModelForMiddle         = InitializeDefault(collection, 2);
                        GraphInfo.GraphLineModelForProcessForNord = InitializeDefault(collection, 3);
                        GraphInfo.GraphLineModelForProcess        = InitializeDefault(collection, 4);

                        _multiGraphMouseWheelHandler.Add(new MultiGraphMouseWheelHandler {
                            Model = GraphInfo.GraphLineModelForDefault, Code = 1
                        });
                        _multiGraphMouseWheelHandler.Add(new MultiGraphMouseWheelHandler {
                            Model = GraphInfo.GraphLineModelForMiddle, Code = 2
                        });
                        _multiGraphMouseWheelHandler.Add(new MultiGraphMouseWheelHandler {
                            Model = GraphInfo.GraphLineModelForProcessForNord, Code = 3
                        });
                        _multiGraphMouseWheelHandler.Add(new MultiGraphMouseWheelHandler {
                            Model = GraphInfo.GraphLineModelForProcess, Code = 4
                        });
                    });
                }

                if (setSetting)
                {
                    SetSettings();
                }
            }
        }
예제 #19
0
        public void OnDialogOpened(IDialogParameters parameters)
        {
            if (parameters.TryGetValue("file", out string sourceFile))
            {
                var ext = Path.GetExtension(sourceFile) ?? string.Empty;

                switch (ext.ToLowerInvariant())
                {
                case FileConstants.AppInstallerExtension:
                    this.OpenCommand.Execute(sourceFile);
                    break;

                default:
                    this.TabPackage.InputPath.CurrentValue     = sourceFile;
                    this.TabPackage.AllowChangingSourcePackage = false;
                    this.TabPackage.ShowPackageTypeSelector    = false;
                    break;
                }
            }
        }
예제 #20
0
        public void OnDialogOpened(IDialogParameters parameters)
        {
            var firstParam = parameters.Keys.FirstOrDefault();

            if (firstParam == null)
            {
                return;
            }

            if (!parameters.TryGetValue(firstParam, out string packagePath))
            {
                return;
            }

            this.FilePath = packagePath;
            this.OnPropertyChanged(nameof(FilePath));

            this.Title = Path.GetFileName(this.FilePath);
            this.OnPropertyChanged(nameof(Title));

            this.CheckIsInstalled();
        }
예제 #21
0
        public override void OnDialogOpened(IDialogParameters parameters)
        {
            if (parameters != null)
            {
                GraphInfo            = parameters.GetValue <RoomLineGraphInfo>("model");
                TemperatureGraphInfo = RoomLineGraphInfo.CreateDefault();
                TemperatureGraphInfo.GraphLineModel = ViewResolvingPlotModel.CreateDefault(18, 60);
                HumidityGraphInfo = RoomLineGraphInfo.CreateDefault();
                HumidityGraphInfo.GraphLineModel = ViewResolvingPlotModel.CreateDefault(45, 75);

                TemperatureGraphInfo.GraphLineModel.GetLast().IsVisible = false;
                HumidityGraphInfo.GraphLineModel.GetFirst().IsVisible   = false;

                GraphInfo.AddToCollectionEvent += Current_AddToCollectionEvent;
                Title = $"{GraphInfo?.ActiveDevice?.Nick} {GraphInfo?.ActiveDevice?.IPAddress}";
                var points = _roomRepository.FilterRooms(GraphInfo.ActiveDevice.Id).GetAwaiter().GetResult();
                FillTemperatureGraph(points);
                FillHumidityGraph(points);
                InitializeAnnotations();
                SetSettings();

                if (parameters.TryGetValue("dataType", out int value))
                {
                    if (value == 2)
                    {
                        TemperatureText += " Мид";
                    }
                    if (value == 3)
                    {
                        TemperatureText += " Норд";
                    }
                    if (value == 4)
                    {
                        TemperatureText += " Процесс";
                    }
                }
            }
        }
예제 #22
0
        public void OnDialogOpened(IDialogParameters parameters)
        {
            if (parameters.TryGetValue("ShareInfo", out _issue))
            {
                RaisePropertyChanged(nameof(Issue));
                RaisePropertyChanged(nameof(Banks));

                Title        = $"{Issue.CompanyName} ({Issue.Action})";
                SelectedBank = Banks?.FirstOrDefault();

                Boid          = _client.Me.Demat;
                Branch        = BankDetails.BranchName;
                AccountNumber = BankDetails.AccountNumber;
                var disclaimer = _client.GetPurchaseDisclaimer();

                Disclaimer = disclaimer?.FieldValue;
            }
            else
            {
                RequestClose?.Invoke(new DialogResult(ButtonResult.Abort));
                return;
            }
        }
 /// <summary>
 /// Called when the dialog is opened.
 /// </summary>
 /// <param name="parameters">The parameters passed to the dialog.</param>
 public override void OnDialogOpened(IDialogParameters parameters)
 {
     base.OnDialogOpened(parameters);
     // Configure parameters
     if (!parameters.TryGetValue(DialogParameterNames.ExplorerIcons, out ExplorerIcons explorerIcons))
     {
         return;
     }
     if (explorerIcons.BackWardIcon != null)
     {
         this.BackWardIcon = explorerIcons.BackWardIcon;
     }
     if (explorerIcons.ForwardIcon != null)
     {
         this.ForwardIcon = explorerIcons.ForwardIcon;
     }
     if (explorerIcons.UpIcon != null)
     {
         this.UpIcon = explorerIcons.UpIcon;
     }
     if (explorerIcons.ReloadIcon != null)
     {
         this.ReloadIcon = explorerIcons.ReloadIcon;
     }
     if (explorerIcons.FolderClosedIcon != null)
     {
         this.FolderClosedIcon = explorerIcons.FolderClosedIcon;
     }
     if (explorerIcons.FolderOpenedIcon != null)
     {
         this.FolderOpenedIcon = explorerIcons.FolderOpenedIcon;
     }
     if (explorerIcons.FileIcon != null)
     {
         this.FileIcon = explorerIcons.FileIcon;
     }
 }
예제 #24
0
        public void ShowDialog(string name, IDialogParameters parameters, Action <IDialogResult> callback)
        {
            try
            {
                parameters = UriParsingHelper.GetSegmentParameters(name, parameters);

                var view = CreateViewFor(UriParsingHelper.GetSegmentName(name));

                var dialogAware = InitializeDialog(view, parameters);
                var currentPage = GetCurrentPage();

                dialogAware.RequestClose += DialogAware_RequestClose;

                void DialogAware_RequestClose(IDialogParameters outParameters)
                {
                    try
                    {
                        var result = CloseDialog(outParameters ?? new DialogParameters(), currentPage);
                        if (result.Exception is DialogException de && de.Message == DialogException.CanCloseIsFalse)
                        {
                            return;
                        }

                        dialogAware.RequestClose -= DialogAware_RequestClose;
                        callback?.Invoke(result);
                        GC.Collect();
                    }
                    catch (DialogException dex)
                    {
                        if (dex.Message != DialogException.CanCloseIsFalse)
                        {
                            callback?.Invoke(new DialogResult
                            {
                                Exception  = dex,
                                Parameters = parameters
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        callback?.Invoke(new DialogResult
                        {
                            Exception  = ex,
                            Parameters = parameters
                        });
                    }
                }

                if (!parameters.TryGetValue <bool>(KnownDialogParameters.CloseOnBackgroundTapped, out var closeOnBackgroundTapped))
                {
                    var dialogLayoutCloseOnBackgroundTapped = DialogLayout.GetCloseOnBackgroundTapped(view);
                    if (dialogLayoutCloseOnBackgroundTapped.HasValue)
                    {
                        closeOnBackgroundTapped = dialogLayoutCloseOnBackgroundTapped.Value;
                    }
                }

                InsertPopupViewInCurrentPage(currentPage as ContentPage, view, closeOnBackgroundTapped, DialogAware_RequestClose);

                PageUtilities.InvokeViewAndViewModelAction <IActiveAware>(currentPage, aa => aa.IsActive = false);
                PageUtilities.InvokeViewAndViewModelAction <IActiveAware>(view, aa => aa.IsActive        = true);
            }
            catch (Exception ex)
            {
                var error = ex.ToString();
                callback?.Invoke(new DialogResult {
                    Exception = ex
                });
            }
        }
예제 #25
0
 public static string GetTitle(this IDialogParameters value)
 {
     value.TryGetValue("Title", out string output);
     return(output);
 }
예제 #26
0
 public static bool GetRememberPassword(this IDialogParameters value)
 {
     value.TryGetValue("RememberPassword", out bool output);
     return(output);
 }
예제 #27
0
 public static string GetPassword(this IDialogParameters value)
 {
     value.TryGetValue("Password", out string output);
     return(output);
 }
 public void OnDialogOpened(IDialogParameters parameters)
 {
     parameters.TryGetValue("id", out string id);
     parameters.TryGetValue("password", out string password);
     Debug.WriteLine($" id:{id}, password:{password}");
 }
예제 #29
0
        /// <inheritdoc />
        public void ShowDialog(string name, IDialogParameters parameters, Action <IDialogResult> callback)
        {
            try
            {
                parameters = UriParsingHelper.GetSegmentParameters(name, parameters);

                var view      = CreateViewFor(UriParsingHelper.GetSegmentName(name));
                var popupPage = CreatePopupPageForView(view);

                var dialogAware = InitializeDialog(view, parameters);

                if (!parameters.TryGetValue <bool>(KnownDialogParameters.CloseOnBackgroundTapped, out var closeOnBackgroundTapped))
                {
                    var dialogLayoutCloseOnBackgroundTapped = DialogLayout.GetCloseOnBackgroundTapped(view);
                    if (dialogLayoutCloseOnBackgroundTapped.HasValue)
                    {
                        closeOnBackgroundTapped = dialogLayoutCloseOnBackgroundTapped.Value;
                    }
                }

                if (!parameters.TryGetValue <bool>(KnownPopupDialogParameters.Animated, out var animated))
                {
                    animated = true;
                }

                var popupDialogLayoutIsAnimationEnabled = PopupDialogLayout.GetIsAnimationEnabled(view);
                popupPage.IsAnimationEnabled = popupDialogLayoutIsAnimationEnabled ?? true;

                dialogAware.RequestClose += DialogAware_RequestClose;

                void CloseOnBackgroundClicked(object sender, EventArgs args)
                {
                    DialogAware_RequestClose(new DialogParameters());
                }

                void DialogAware_RequestClose(IDialogParameters outParameters)
                {
                    try
                    {
                        var result = CloseDialog(outParameters ?? new DialogParameters(), popupPage, view);
                        if (result.Exception is DialogException de && de.Message == DialogException.CanCloseIsFalse)
                        {
                            return;
                        }

                        dialogAware.RequestClose -= DialogAware_RequestClose;
                        if (closeOnBackgroundTapped)
                        {
                            popupPage.BackgroundClicked -= CloseOnBackgroundClicked;
                        }
                        callback?.Invoke(result);
                        GC.Collect();
                    }
                    catch (DialogException dex)
                    {
                        if (dex.Message != DialogException.CanCloseIsFalse)
                        {
                            callback?.Invoke(new DialogResult
                            {
                                Exception  = dex,
                                Parameters = parameters
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        callback?.Invoke(new DialogResult
                        {
                            Exception  = ex,
                            Parameters = parameters
                        });
                    }
                }

                if (closeOnBackgroundTapped)
                {
                    popupPage.BackgroundClicked += CloseOnBackgroundClicked;
                }

                Action <IDialogParameters> closeCallback = closeOnBackgroundTapped ? DialogAware_RequestClose : p => { };
                PushPopupPage(popupPage, view, closeCallback, animated);
            }
            catch (Exception ex)
            {
                callback?.Invoke(new DialogResult {
                    Exception = ex
                });
            }
        }
예제 #30
0
        /// <summary>
        /// Called when the dialog is opened.
        /// </summary>
        /// <param name="parameters">The parameters passed to the dialog.</param>
        public override void OnDialogOpened(IDialogParameters parameters)
        {
            base.OnDialogOpened(parameters);
            // Subscribe event
            this.eventAggregator.GetEvent <FileSelectionEvent>().Subscribe(this.OnFileSelection);
            this.eventAggregator.GetEvent <MoveCurrentFolderEvent>().Subscribe(this.OnMoveDisplayFolder);
            this.eventAggregator.GetEvent <FileEnterEvent>().Subscribe(this.OnFileEnter);
            // Configure parameters
            if (parameters.TryGetValue(DialogParameterNames.FileNamePrefixText, out string fileNamePrefixText))
            {
                this.FileNamePrefixText = fileNamePrefixText;
            }
            if (parameters.TryGetValue(DialogParameterNames.FileTypePrefixText, out string fileTypePrefixText))
            {
                this.FileTypePrefixText = fileTypePrefixText;
            }
            if (parameters.TryGetValue(DialogParameterNames.SaveButtonText, out string saveButtonText))
            {
                this.SaveButtonText = saveButtonText;
            }
            if (parameters.TryGetValue(DialogParameterNames.CancelButtonText, out string cancelButtonText))
            {
                this.CancelButtonText = cancelButtonText;
            }
            if (parameters.TryGetValue(DialogParameterNames.DefaultSaveFileName, out string defaultSaveFileName))
            {
                this.SaveFileName = defaultSaveFileName;
            }
            this.filters.Clear();
            if (parameters.TryGetValue(DialogParameterNames.Filters, out IEnumerable <FileFilter> filters))
            {
                this.filters.AddRange(filters);
            }
            else
            {
                var filter = parameters.TryGetValue(DialogParameterNames.DefaultAllFilesFilterText, out string filterText) ? new FileFilter(filterText) : FileFilter.CreateDefault();
                this.filters.Add(filter);
            }
            this.selectedFilter = this.Filters.First();
            if (parameters.TryGetValue(DialogParameterNames.OverwriteConfirmationTitle, out string overwriteConfirmationTitle))
            {
                this.OverwriteConfirmationTitle = overwriteConfirmationTitle;
            }
            if (parameters.TryGetValue(DialogParameterNames.OverwriteConfirmationMessageFunc, out Func <string, string> overwriteConfirmationMessageFunc))
            {
                this.OverwriteConfirmationMessageFunc = overwriteConfirmationMessageFunc;
            }
            if (parameters.TryGetValue(DialogParameterNames.OverwriteConfirmationOKButtonText, out string overwriteConfirmationOKButtonText))
            {
                this.OverwriteConfirmationOKButtonText = overwriteConfirmationOKButtonText;
            }
            if (parameters.TryGetValue(DialogParameterNames.OverwriteConfirmationCancelButtonText, out string overwriteConfirmationCancelButtonText))
            {
                this.OverwriteConfirmationCancelButtonText = overwriteConfirmationCancelButtonText;
            }
            var regionContext = ExplorerBaseRegionContext.CreateForSingleFileSelect();

            if (parameters.TryGetValue(DialogParameterNames.TextResource, out ExplorerBaseTextResource textResource))
            {
                regionContext.TextResource = textResource;
            }
            if (parameters.TryGetValue(DialogParameterNames.RootFolders, out IEnumerable <string> rootFolders))
            {
                regionContext.RootFolders = rootFolders;
            }
            regionContext.FileExtensions = this.Filters.First().Extensions;
            this.RegionContext           = regionContext;
        }