An implementation of BaseMetroDialog allowing arbitrary content.
Наследование: BaseMetroDialog
Пример #1
0
 public void ShowDialog(ISSView view)
 {
     Contract.Requires(view != null);
     var dialog = new MahApps.Metro.Controls.Dialogs.CustomDialog();
     dialog.DialogTop = view;
     _dialogs.Add(view,dialog);
     this.ShowMetroDialogAsync(dialog);
 }
Пример #2
0
        public void ShowDialog(ISSView view)
        {
            Contract.Requires(view != null);
            var dialog = new MahApps.Metro.Controls.Dialogs.CustomDialog();

            dialog.DialogTop = view;
            _dialogs.Add(view, dialog);
            this.ShowMetroDialogAsync(dialog);
        }
 public async void DialogDisconnetti()
 {
     customDialog = new CustomDialog();
     disconnettiWindow = new Disconnetti();
     disconnettiWindow.BServer.Click += ButtonServerOnClick;
     disconnettiWindow.BCancel.Click += ButtonCancelOnClick;
     customDialog.Content = disconnettiWindow;
     MetroWindow mw = (MetroWindow)App.Current.MainWindow;
     await mw.ShowMetroDialogAsync(customDialog);
 }
Пример #4
0
        private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            StartProgressRing();

            documentList = new ObservableCollection<DocumentViewModel>();
            DocumentList = CollectionViewSource.GetDefaultView(documentList);
            DocumentListView.DataContext = DocumentList;

            userList = new List<UserViewModel>();
            UserList = CollectionViewSource.GetDefaultView(userList);

            startTaskWithDialog = (CustomDialog)this.Resources["StartTaskWithDialog"];
            startTaskWithDialog.DataContext = UserList;

            await UpdateServerInfo();
            await Refresh();

            StopProgressRing();
        }
Пример #5
0
 // Base on what user click, generate the corresonding dialog type
 private async void CreateDialog(object parameter)
 {
     var str = parameter as string;
     this.ChangeView();
     switch (str)
     {
         case "Rock":
             // initialize a basic dialog and set the title
             custom = new CustomDialog() { Title = str };
             // initialize rock view model and pass the close capability, collection, and new object.
             var RockViewModel = new RockViewModel(instance => dialogCoordinator.HideMetroDialogAsync(this, custom),
                 debrisFlowCollection, new Rock());
             //set the dialog's content to the rock view page
             custom.Content = new DebrisFlowRecordDialog { DataContext = RockViewModel };
             // wait for the dialog to finish
             await dialogCoordinator.ShowMetroDialogAsync(this, custom);
             break;
         case "Slope":
             break;
         case "Plantation":
             break;
         case "Protected Object":
             break;
         case "Basic Info":
             break;
         case "Catchment":
             break;
     }
 }
Пример #6
0
 // when the user's location changed, checked if the new location is in range of any designated point
 async void OnLocationChanged(object s, LocationChangedEventArgs e)
 {
     var locationSOP = sop.GetLocationSOP();
     foreach (SOP sop in locationSOP)
     {
         if (mapController.LocationIsInRange(sop.Location))
         {
             custom = new CustomDialog() { Title = "Please Record" };
             List<string> sopTask = sop.SOPTask;
             var ReminderViewModel = new DebrisFlowReminderViewModel(instance => dialogCoordinator.HideMetroDialogAsync(this, custom),
                 sopTask);
             custom.Content = new DebrisFlowReminderDialog { DataContext = ReminderViewModel };
             await dialogCoordinator.ShowMetroDialogAsync(this, custom);
             return;
         }
     }
 }
Пример #7
0
        private void SetupComponents()
        {
            #region FlipViewPersona
            FlipViewPersonaImage.HideControlButtons();

            Grid[] aFlipViewAvatarArray = new Grid[28];
            for (int i = 0; i < 28; i++)
            {
                Grid Grid_FlipViewDummy;
                Image Image_FlipViewDummy;
                Image_FlipViewDummy = new Image() { Margin = new Thickness(5.5d), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Stretch = Stretch.Uniform, Source = (ImageSource)BitmapFrame.Create(new Uri("pack://application:,,,/OfflineServer;component/images/NFSW_Avatars/Avatar_" + i.ToString() + ".png", UriKind.Absolute)) };
                Grid_FlipViewDummy = new Grid() { Margin = new Thickness(0.4d) };
                Grid_FlipViewDummy.Children.Add(Image_FlipViewDummy);
                Image t1 = new Image() { Source = Image_FlipViewDummy.Source };
                t1.Effect = new BlurEffect() { Radius = 4.5d, RenderingBias = RenderingBias.Quality, KernelType = KernelType.Gaussian };
                Grid_FlipViewDummy.Background = new VisualBrush(t1);
                aFlipViewAvatarArray[i] = Grid_FlipViewDummy;
            }
            FlipViewPersonaImage.ItemsSource = aFlipViewAvatarArray;

            Binding indexBind = new Binding()
            {
                Path = new PropertyPath("ActivePersona.IconIndex"),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Mode = BindingMode.TwoWay,
                Source = Access.CurrentSession
            };
            BindingOperations.SetBinding(FlipViewPersonaImage, FlipView.SelectedIndexProperty, indexBind);
            #endregion

            #region MetroTile -> Random Persona Info
            tRandomPersonaInfo_Tick(null, null);
            RandomPersonaInfo.Tick += new EventHandler(tRandomPersonaInfo_Tick);
            RandomPersonaInfo.Interval = new TimeSpan(0, 0, 10);
            RandomPersonaInfo.Start();
            #endregion

            #region carDialog
            Binding lBindSelect = new Binding()
            {
                Path = new PropertyPath("language.Select"),
                Mode = BindingMode.OneWay,
                Source = Access.dataAccess.appSettings.uiSettings
            };
            Binding lBindCancel = new Binding()
            {
                Path = new PropertyPath("language.Cancel"),
                Mode = BindingMode.OneWay,
                Source = Access.dataAccess.appSettings.uiSettings
            };
            Binding lBindSelectCar = new Binding()
            {
                Path = new PropertyPath("language.AddACarText"),
                Mode = BindingMode.OneWay,
                Source = Access.dataAccess.appSettings.uiSettings
            };

            ComboBox carComboBox = new ComboBox();
            carComboBox.SetValue(Canvas.LeftProperty, 5d);
            carComboBox.SetValue(Canvas.TopProperty, 20d);
            carComboBox.Width = 297d;
            carComboBox.ItemsSource = CarDefinitions.physicsProfileHashNormal.Values;
            carComboBox.SelectedIndex = 0;

            Button selectButton = new Button();
            selectButton.SetValue(Canvas.LeftProperty, 148d);
            selectButton.SetValue(Canvas.TopProperty, 54d);
            selectButton.Width = 80d;
            selectButton.Click += (object sender, RoutedEventArgs routedEventArgs) =>
            {
                CarEntity carEntity = new CarEntity();
                carEntity.baseCarId = CarDefinitions.baseCarId.FirstOrDefault(key => key.Value == carComboBox.SelectedItem.ToString()).Key;
                carEntity.carId = Access.CurrentSession.ActivePersona.Cars.Last().CarId + 1;
                carEntity.durability = 100;
                carEntity.heatLevel = 1;
                carEntity.paints = "<Paints/>";
                carEntity.performanceParts = "<PerformanceParts/>";
                carEntity.physicsProfileHash = CarDefinitions.physicsProfileHashNormal.FirstOrDefault(key => key.Value == carComboBox.SelectedItem.ToString()).Key;
                carEntity.raceClass = CarClass.E;
                carEntity.rating = 123;
                carEntity.resalePrice = 0;
                carEntity.skillModParts = "<SkillModParts/>";
                carEntity.vinyls = "<Vinyls/>";
                carEntity.visualParts = "<VisualParts/>";
                PersonaManagement.addCar(carEntity);
                DialogManager.HideMetroDialogAsync(this, carDialog);
            };

            Button cancelButton = new Button();
            cancelButton.SetValue(Canvas.LeftProperty, 233d);
            cancelButton.SetValue(Canvas.TopProperty, 54d);
            cancelButton.Width = 70d;
            cancelButton.Click += (object sender, RoutedEventArgs routedEventArgs) =>
            {
                DialogManager.HideMetroDialogAsync(this, carDialog);
            };

            Canvas canvas = new Canvas();
            canvas.Children.Add(carComboBox);
            canvas.Children.Add(selectButton);
            canvas.Children.Add(cancelButton);

            carDialog = new CustomDialog();
            carDialog.Height = 200d;
            carDialog.Content = canvas;

            // internationalization
            BindingOperations.SetBinding(carDialog, CustomDialog.TitleProperty, lBindSelectCar);
            BindingOperations.SetBinding(selectButton, Button.ContentProperty, lBindSelect);
            BindingOperations.SetBinding(cancelButton, Button.ContentProperty, lBindCancel);
            #endregion
        }
Пример #8
0
 private async void toViewDetailsCar()
 {
     if (SelectedCar != null)
     {
         CustomDialog d = new CustomDialog();
         d.Content = new CarDetailView(SelectedCar);
         var metro = App.Current.MainWindow as MetroWindow;
         await metro.ShowMetroDialogAsync(d);
     }
 }
Пример #9
0
 private async void AddCar()
 {
     CustomDialog d = new CustomDialog();
     d.Content = new CarAddView(w);
     var metro = App.Current.MainWindow as MetroWindow;
     await metro.ShowMetroDialogAsync(d);
 }
Пример #10
0
 private async void EditStation()
 {
     if (SelectedStation != null)
     {
         CustomDialog d = new CustomDialog();
         d.Content = new StationEditView(SelectedStation,w);
         var metro = App.Current.MainWindow as MetroWindow;
         await metro.ShowMetroDialogAsync(d);
     }
 }
Пример #11
0
        private void ExecuteAdd()
        {
            string selectedJob = "";

            //Present a dialog for the user to select the type of job they want to add
            var dialog = new CustomDialog { Title = "Add New Job" };
            var panel = new StackPanel();
            panel.Children.Add(new RadioButton { Content = "Data Update", Margin = new Thickness(5), IsChecked = true });
            panel.Children.Add(new RadioButton { Content = "Economic Release Update", Margin = new Thickness(5), IsChecked = false });

            var addBtn = new Button { Content = "Add" };
            addBtn.Click += (s, e) =>
            {
                DialogService.HideMetroDialogAsync(this, dialog);
                selectedJob = (string)panel.Children.OfType<RadioButton>().FirstOrDefault(r => r.IsChecked.HasValue && r.IsChecked.Value)?.Content;
                AddJob(selectedJob);
            };
            panel.Children.Add(addBtn);
            dialog.Content = panel;

            DialogService.ShowMetroDialogAsync(this, dialog);
        }
Пример #12
0
 /// <summary>
 /// Shows a custom dialog
 /// </summary>
 /// <param name="dialog">dialog to display</param>
 public static async void ShowDialog(CustomDialog dialog)
 {
     var main = (MainWindow)Application.Current.MainWindow;
     await main.ShowMetroDialogAsync(dialog);
 }
Пример #13
0
        private async void RunCustomFromVm()
        {
            var customDialog = new CustomDialog() { Title = "New plot" };

            var addPlotDialogViewModel = new AddPlotDialogViewModel(instance => { _dialogCoordinator.HideMetroDialogAsync(this, customDialog); }) { MainViewModel = this };
            customDialog.Content = new AddPlot { DataContext = addPlotDialogViewModel };
            await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
        }
Пример #14
0
        /// <summary>
        ///     DO NOT CALL .RESULT or .WAIT from UI thread!
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<bool?> ShowMetroDialog(IMetroDialog model) {
            ConfirmAccess();
            // Da faq mahapps!!!
            var resolvedView = ViewLocator.Current.ResolveView(model);
            resolvedView.ViewModel = model;

            var view = resolvedView as BaseMetroDialog;
            if (view != null)
                return await HandleMetroDialog(model, view);

            var dialog = new CustomDialog {Content = resolvedView};
            using (model.WhenAnyValue(x => x.DisplayName).BindTo(dialog, x => x.Title))
                return await HandleMetroDialog(model, dialog);
        }
        private async void RunCustomFromVm()
        {
            var customDialog = new CustomDialog() { Title = "Custom Dialog" };

            var customDialogExampleContent = new CustomDialogExampleContent(instance =>
            {
                _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
                System.Diagnostics.Debug.WriteLine(instance.FirstName);
            });
            customDialog.Content = new CustomDialogExample { DataContext = customDialogExampleContent};            

            await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog);            
        }
Пример #16
0
        private async void RunCustomFromVm()
        {
            var customDialog = new CustomDialog() { Title = "Custom, wait 3 seconds" };

            await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog);

            await TaskEx.Delay(3000);

            await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
        }
Пример #17
0
        private async void GoToStationDialog(string stationType)
        {

            CustomDialog d = new CustomDialog();
            d.Content = new StationOrderView(stationType, _theCustomer);
            var metro = App.Current.MainWindow as MetroWindow;
            await metro.ShowMetroDialogAsync(d);

        }
Пример #18
0
 private async void GoToEditProfileDlg()
 {
     CustomDialog d = new CustomDialog();
     d.Content = new ProfileEditView(_theCustomer);
     var metro = App.Current.MainWindow as MetroWindow;
     await metro.ShowMetroDialogAsync(d);
 }
Пример #19
0
 private async void GoToSubmitOrderDialog()
 {
     if (StartingStation != null && EndingStation != null && SelectedCars != null)//to implement
     {
         CustomDialog d = new CustomDialog();
         d.Content = new SubmitOrderView();
         var metro = App.Current.MainWindow as MetroWindow;
         await metro.ShowMetroDialogAsync(d);
     }
     else
     {
         //
     }
 }
Пример #20
0
 private async void GoToCarsDialog()
 {
     if (StartingStation != null)
     {
         CustomDialog d = new CustomDialog();
         d.Content = new CarsOrderView(StartingStation,TheCustomer);
         var metro = App.Current.MainWindow as MetroWindow;
         await metro.ShowMetroDialogAsync(d);
     }
     else
     {
         //
     }
 }
Пример #21
0
 private async void messaggioDisconnetti()
 {
     _customDialog = new CustomDialog();
     _exitwindow = new Esci();
     _exitwindow.BOk.Click += ButtonOkOnClick;
     _exitwindow.BCancel.Click += ButtonCancelOnClick;
     _customDialog.Content = _exitwindow;
     await this.ShowMetroDialogAsync(_customDialog);
 }
Пример #22
0
        private void CreateNewScript()
        {
            HandleUnsavedChanges();

            //Build a dialog for the user to enter the script name and type
            var dialog = new CustomDialog();

            StackPanel panel = new StackPanel();

            Label label = new Label() { Content = "Enter script name:" };
            TextBox textBox = new TextBox();

            StackPanel radioBtnPanel = new StackPanel { Orientation = Orientation.Horizontal };
            var orderRadioBtn = new RadioButton { Content = "Order Script", IsChecked = true, Margin = new Thickness(5) };
            var tradeRadioBtn = new RadioButton { Content = "Trade Script", IsChecked = false, Margin = new Thickness(5) };
            radioBtnPanel.Children.Add(orderRadioBtn);
            radioBtnPanel.Children.Add(tradeRadioBtn);

            UniformGrid btnPanel = new UniformGrid { Columns = 2, HorizontalAlignment = HorizontalAlignment.Stretch };
            Button nextBtn = new Button { Content = "Create Script", Margin = new Thickness(5) };
            nextBtn.Click += (s, e) =>
                {
                    string scriptType = (orderRadioBtn.IsChecked.HasValue && orderRadioBtn.IsChecked.Value) ? "Order" : "Trade";
                    CreateNewScript(textBox.Text, scriptType);
                    _dialogService.HideMetroDialogAsync(this, dialog);

                };

            Button cancelBtn = new Button { Content = "Cancel", Margin = new Thickness(5) };
            cancelBtn.Click += (s, e) =>
                {
                    _dialogService.HideMetroDialogAsync(this, dialog);
                };

            btnPanel.Children.Add(nextBtn);
            btnPanel.Children.Add(cancelBtn);


            panel.Children.Add(label);
            panel.Children.Add(textBox);
            panel.Children.Add(radioBtnPanel);
            panel.Children.Add(btnPanel);

            dialog.Content = panel;

            //There is no point to awaiting this one, it returns immediately
            _dialogService.ShowMetroDialogAsync(this, dialog);
        }
Пример #23
-1
 public async void ShowTimedDialog()
 {
     var customDialog = new CustomDialog() { Title = "Dialog with time-out; will close in 2 seconds." };
     await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
     await Task.Delay(2000);
     await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
 }