コード例 #1
0
        private void MeasurementLogGrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            MeasurementLogEntry entry = e.Row.DataContext as MeasurementLogEntry;

            // If this entry has a valid calculator associated then change the TextBlock to a HyperlinkButton
            // that when clicked will use the Acivator object to dynamically create the appropriate calculator

            if (entry.Measurement.Calculator != null)
            {
                TextBlock measurementName = MeasurementLogGrid.Columns[0].GetCellContent(e.Row) as TextBlock;

                if (measurementName != null)
                {
                    DataGridCell    cell           = measurementName.Parent as DataGridCell;
                    HyperlinkButton calculatorLink = new HyperlinkButton();

                    calculatorLink.Content             = entry.Measurement.measurement_name;
                    calculatorLink.Margin              = new Thickness(5);
                    calculatorLink.HorizontalAlignment = HorizontalAlignment.Center;
                    calculatorLink.Click += (s, ev) =>
                    {
                        // Create an instance of the calculator using IMeasurementCalculator interface so that we have
                        // access to the calculated value and can update the selected row value

                        ChildWindow            modalWindow = new ChildWindow();
                        IMeasurementCalculator calc        = Activator.CreateInstance(Type.GetType(String.Format("FitnessTrackerPlus.Views.Measurement.Calculators.{0}",
                                                                                                                 entry.Measurement.Calculator.type_name))) as IMeasurementCalculator;

                        calc.CalculationCancelled += (se, eve) => { modalWindow.Close(); };
                        calc.CalculationComplete  += (se, eve) =>
                        {
                            modalWindow.Close();

                            entry.value = calc.CalculatedValue;
                            context.SubmitChanges();
                        };

                        modalWindow.Title   = String.Format("{0} Calculator", entry.Measurement.measurement_name);
                        modalWindow.Content = calc;
                        modalWindow.Show();
                    };

                    // Repace the TextBlock with the HyperlinkButton control

                    cell.Content = calculatorLink;
                }
            }
        }
コード例 #2
0
        void OnShutdownAttempted(IGuardClose guard, ChildWindow view, CancelEventArgs e)
        {
            if (actuallyClosing)
            {
                actuallyClosing = false;
                return;
            }

            bool runningAsync = false, shouldEnd = false;

            guard.CanClose(canClose => {
                if (runningAsync && canClose)
                {
                    actuallyClosing = true;
                    view.Close();
                }
                else
                {
                    e.Cancel = !canClose;
                }

                shouldEnd = true;
            });

            if (shouldEnd)
            {
                return;
            }

            runningAsync = e.Cancel = true;
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: avlhitech256/Price
        private void ShowImages(ChildWindowEventArg args)
        {
            var childWindow = new ChildWindow
            {
                Content     = args.View,
                DataContext = args.ViewModel
            };

            PhotoViewModel photoViewModel = args.ViewModel as PhotoViewModel;
            Action         hideWindows    = () => childWindow.Hide();

            if (photoViewModel != null)
            {
                photoViewModel.HideWindow = () => hideWindows();
            }

            Action <object, KeyEventArgs> childWindowKeyUp =
                (sender, e) =>
            {
                if (e.Key == Key.Escape)
                {
                    hideWindows();
                }
            };

            childWindow.KeyUp += (sender, e) => childWindowKeyUp(sender, e);
            Action <ChildWindowScaleEventArgs> scaleCildWindow =
                x => childWindow.WindowState = x.FullScale ? WindowState.Maximized : WindowState.Normal;
            Func <ChildWindowScaleEventArgs, bool> canScaleCildWindow = x => x != null;

            Messenger?.Register(CommandName.SetPhotoWindowState, scaleCildWindow, canScaleCildWindow);
            childWindow.ShowDialog();
            Messenger?.Unregister(CommandName.SetPhotoWindowState);
            childWindow.Close();
        }
コード例 #4
0
 public void Close()
 {
     if (cw != null)
     {
         cw.Close();
     }
 }
コード例 #5
0
 private void OnChannelOpened(object sender, EventArgs e)
 {
     if (_stateDialog != null)
     {
         _stateDialog.Close();
         _stateDialog = null;
     }
 }
コード例 #6
0
        private void CustomFood_Click(object sender, RoutedEventArgs e)
        {
            // Show a modal dialog with the create custom food form

            ChildWindow modalWindow = new ChildWindow();
            CustomFood  customFood  = new CustomFood();

            customFood.CustomFoodCanceled += (s, ev) => { modalWindow.Close(); };
            customFood.CustomFoodCreated  += (s, ev) =>
            {
                CreateFoodLogEntry(ev.CreatedFood);
                modalWindow.Close();
            };

            modalWindow.Title   = "Add Custom Food";
            modalWindow.Content = customFood;
            modalWindow.Show();
        }
コード例 #7
0
        private static void CloseAll(ChildWindow childWindows)
        {
            if (childWindows == null)
            {
                return;
            }

            childWindows.Close();
        }
コード例 #8
0
        private void CustomMeasurement_Click(object sender, RoutedEventArgs e)
        {
            // Show a modal dialog with the create custom measurement form

            ChildWindow       modalWindow       = new ChildWindow();
            CustomMeasurement customMeasurement = new CustomMeasurement();

            customMeasurement.CustomMeasurementCancelled += (s, ev) => { modalWindow.Close(); };
            customMeasurement.CustomMeasurementCreated   += (s, ev) =>
            {
                CreateMeasurementLogEntry(ev.CreatedMeasurement);
                modalWindow.Close();
            };

            modalWindow.Title   = "Add Custom Measurement";
            modalWindow.Content = customMeasurement;
            modalWindow.Show();
        }
コード例 #9
0
        private void CustomExercise_Click(object sender, RoutedEventArgs e)
        {
            // Show a modal dialog with the create custom exercise form

            ChildWindow    modalWindow    = new ChildWindow();
            CustomExercise customExercise = new CustomExercise();

            customExercise.CustomExerciseCanceled += (s, ev) => { modalWindow.Close(); };
            customExercise.CustomExerciseCreated  += (s, ev) =>
            {
                CreateExerciseLogEntry(ev.CreatedExercise);
                modalWindow.Close();
            };

            customExercise.DataContext = new FitnessTrackerPlus.Web.Data.Exercise();

            modalWindow.Title   = "Add Custom Exercise";
            modalWindow.Content = customExercise;
            modalWindow.Show();
        }
コード例 #10
0
            void Deactivated(object sender, DeactivationEventArgs e)
            {
                if (!e.WasClosed)
                {
                    return;
                }

                ((IDeactivate)model).Deactivated -= Deactivated;

                if (deactivatingFromView)
                {
                    return;
                }

                deactivateFromViewModel = true;
                actuallyClosing         = true;
                view.Close();
                actuallyClosing         = false;
                deactivateFromViewModel = false;
            }
コード例 #11
0
        void TimerForWorkaroundFireFoxIssue_Tick(object sender, object e)
#endif
        {
            // Work around an issue on Firefox where the UI disappears if the window is resized and on some other occasions:
            _childWindowForWorkaroundFireFoxIssue.Dispatcher.BeginInvoke(() =>
            {
                _timerForWorkaroundFireFoxIssue.Stop();
                _childWindowForWorkaroundFireFoxIssue.Close();
                _childWindowForWorkaroundFireFoxIssue = null;
            });
        }
コード例 #12
0
ファイル: ViewModelBase.cs プロジェクト: Vertver/oiu_csharp
        /// <summary>
        /// Методы вызываемый для закрытия окна связанного с ViewModel
        /// </summary>
        public bool Close()
        {
            var result = false;

            if (_wnd != null)
            {
                _wnd.Close();
                _wnd   = null;
                result = true;
            }
            return(result);
        }
コード例 #13
0
        /// <summary>
        /// Hides the dialog window
        /// </summary>
        /// <param name="windowContents">Contents of the window displayed earlier using ShowWindow</param>
        public void HideWindow(FrameworkElement windowContents)
        {
            if (windowContents == null)
            {
                throw new ArgumentNullException("windowContents");
            }

            int         hashCode    = windowContents.GetHashCode();
            ChildWindow childWindow = null;

            if (m_ChildWindows.TryGetValue(hashCode, out childWindow))
            {
                childWindow.Close();
                // close will automatically remove the window from the hash table in childWindow_Closed
            }
        }
コード例 #14
0
        public static ChildWindow PopupMessage(string title, string message, string closeButtonLabel, bool closeWindow)
        {
            if (CurrentPopup != null)
            {
                return(null);
            }

            var msgBox = new ChildWindow();

            CurrentPopup = msgBox;

            msgBox.Style       = Application.Current.Resources["PopupMessageWindow"] as Style;
            msgBox.BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xBA, 0xD2, 0xEC));
            msgBox.Title       = title;
            msgBox.MaxWidth    = Application.Current.Host.Content.ActualWidth * 0.5;

            StackPanel content = new StackPanel();

            content.Children.Add(new TextBlock()
            {
                Text = message, Margin = new Thickness(20), Foreground = new SolidColorBrush(Colors.White), FontSize = 14, HorizontalAlignment = HorizontalAlignment.Center
            });

            Button closeButton = new Button {
                Content = closeButtonLabel, FontSize = 14, HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(20)
            };

            closeButton.Click += (s, o) =>
            {
                msgBox.Close();
                if (closeWindow)
                {
                    BrowserWindow.Close();
                }
            };
            content.Children.Add(closeButton);
            msgBox.Content   = content;
            msgBox.IsTabStop = true;

            msgBox.Show();
            msgBox.Focus();

            _currentWindow = msgBox;
            PopupManager.CloseActivePopup();
            return(msgBox);
        }
コード例 #15
0
 public LeakTest()
 {
     InitializeComponent();
     PopupCommand = new DelegateCommand(arg =>
     {
         var child     = new ChildWindow();
         child.Closed += (sender, args) =>
         {
             System.Diagnostics.Debug.WriteLine("Closed window");
         };
         child.Loaded += (sender, args) =>
         {
             child.Close();
             PopupCommand.Execute(null);
         };
         child.Show();
     });
 }
コード例 #16
0
        /// <summary>
        /// Called when shutdown attempted.
        /// </summary>
        /// <param name="rootModel">The root model.</param>
        /// <param name="view">The view.</param>
        /// <param name="handleShutdownModel">The handler for the shutdown model.</param>
        /// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param>
        protected virtual void OnShutdownAttempted(IPresenter rootModel, ChildWindow view, Action <ISubordinate, Action> handleShutdownModel, CancelEventArgs e)
        {
            if (_actuallyClosing || rootModel.CanShutdown())
            {
                _actuallyClosing = false;
                return;
            }

            bool runningAsync = false;

            var custom = rootModel as ISupportCustomShutdown;

            if (custom != null && handleShutdownModel != null)
            {
                var shutdownModel = custom.CreateShutdownModel();
                var shouldEnd     = false;

                handleShutdownModel(
                    shutdownModel,
                    () =>
                {
                    var canShutdown = custom.CanShutdown(shutdownModel);
                    if (runningAsync && canShutdown)
                    {
                        _actuallyClosing = true;
                        view.Close();
                    }
                    else
                    {
                        e.Cancel = !canShutdown;
                    }

                    shouldEnd = true;
                });

                if (shouldEnd)
                {
                    return;
                }
            }

            runningAsync = e.Cancel = true;
        }
コード例 #17
0
        void RejeterDemande(Galatee.Silverlight.ServiceAccueil.CsInfoDemandeWorkflow dmdInfo)
        {
            prgBar.Visibility        = System.Windows.Visibility.Visible;
            LblChargement.Visibility = System.Windows.Visibility.Visible;
            OKButton.IsEnabled       = false;
            CancelButton.IsEnabled   = false;

            WorkflowClient client = new WorkflowClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Workflow"));

            client.Endpoint.Binding.OpenTimeout       = new TimeSpan(0, 1, 0);
            client.Endpoint.Binding.CloseTimeout      = new TimeSpan(5, 0, 0);
            client.Endpoint.Binding.SendTimeout       = new TimeSpan(5, 0, 0);
            client.ExecuterActionSurDemandeCompleted += (sender, args) =>
            {
                prgBar.Visibility        = System.Windows.Visibility.Collapsed;
                LblChargement.Visibility = System.Windows.Visibility.Collapsed;
                OKButton.IsEnabled       = true;
                CancelButton.IsEnabled   = true;

                if (args.Cancelled || args.Error != null)
                {
                    string error = args.Error.Message;
                    Message.Show(error, "Rejet demande");
                    return;
                }
                if (args.Result == null)
                {
                    Message.ShowError(Languages.msgErreurChargementDonnees, "Rejet demande");
                    return;
                }
                if (args.Result.StartsWith("ERR"))
                {
                    Message.ShowError(args.Result, "Rejet demande");
                }
                else
                {
                    Message.ShowInformation(args.Result, "Rejet demande");
                    ParentG.Close();
                    this.DialogResult = true;
                }
            };
            client.ExecuterActionSurDemandeAsync(null != dmdInfo ? dmdInfo.CODE : _infoDemande.CODE, SessionObject.Enumere.REJETER, UserConnecte.matricule, txtMotif.Text);
        }
コード例 #18
0
        public void CloseAllChildWindows()
        {
            LoggerUtility.WriteLog("<Info: Closing The Child Windows Method>");
            List <Window> wChildWindows = wVStoreMainWindow.ModalWindows();

            LoggerUtility.WriteLog("dsda" + wChildWindows);

            if (wChildWindows != null)
            {
                LoggerUtility.WriteLog("The Value is Not Equal To Null" + wChildWindows);
            }
            {
                foreach (Window ChildWindow in wChildWindows)
                {
                    LoggerUtility.WriteLog("The Current Child Window Is " + ChildWindow.Title);
                    ChildWindow.Close();
                }
            }
        }
コード例 #19
0
ファイル: DisplayService.cs プロジェクト: CarlosVV/mediavf
 public void Display(ViewModelBase viewModel)
 {
     if (viewModel != null)
     {
         string viewTypeText = Application.Current.Resources[viewModel.GetType().FullName] as string;
         if (!string.IsNullOrEmpty(viewTypeText))
         {
             Type viewType = Type.GetType(viewTypeText);
             if (viewType != null)
             {
                 if (typeof(ChildWindow).IsAssignableFrom(viewType))
                 {
                     ChildWindow childWindow = Container.Resolve(viewType) as ChildWindow;
                     childWindow.DataContext = viewModel;
                     childWindow.VerticalAlignment = VerticalAlignment.Center;
                     viewModel.Close += () => childWindow.Close();
                     childWindow.Show();
                 }
                 else
                 {
                     IRegionManager regionManager = Container.Resolve<IRegionManager>();
                     IRegion region = regionManager.Regions.FirstOrDefault(r => r.Views.Any(v => v != null && v.GetType() == viewType));
                     if (region != null)
                     {
                         object obj = region.Views.First(v => v != null && v.GetType() == viewType);
                         if (obj is FrameworkElement)
                         {
                             ((FrameworkElement)obj).DataContext = viewModel;
                             region.Activate(obj);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #20
0
 public void HideSendDialog()
 {
     _sendView.Close();
 }
コード例 #21
0
 public void HideConversionConfirmationDialog()
 {
     _conversionConfirmationView.Close();
 }
コード例 #22
0
        public static ChildWindow PopupContent(string title, object content, IEnumerable <Button> buttons)
        {
            if (CurrentPopup != null)
            {
                return(null);
            }

            var msgBox = new ChildWindow();

            CurrentPopup       = msgBox;
            msgBox.Style       = Application.Current.Resources["PopupMessageWindow"] as Style;
            msgBox.BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xBA, 0xD2, 0xEC));
            msgBox.Title       = title;

            msgBox.MaxWidth = Application.Current.Host.Content.ActualWidth * 0.5;

            StackPanel panel = new StackPanel();

            panel.Children.Add(new ContentPresenter()
            {
                Content = content
            });

            StackPanel buttonPanel = new StackPanel()
            {
                Margin = new Thickness(20), Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center
            };

            if (buttons != null)
            {
                foreach (Button b in buttons)
                {
                    b.Click += (s, e) =>
                    {
                        msgBox.Close();
                    };
                    buttonPanel.Children.Add(b);
                }
            }
            else
            {
                var closeButton = new Button {
                    Content = Labels.ButtonClose, HorizontalAlignment = HorizontalAlignment.Center,
                };
                closeButton.Click += (s, e) =>
                {
                    msgBox.Close();
                };
                buttonPanel.Children.Add(closeButton);
            }

            panel.Children.Add(buttonPanel);
            msgBox.Content = panel;

            msgBox.IsTabStop = true;
            msgBox.Show();
            msgBox.Focus();

            PopupManager.CloseActivePopup();
            return(msgBox);
        }
コード例 #23
0
 public void HideReceiveDialog()
 {
     _receiveView.Close();
 }
コード例 #24
0
 public void HideMyWalletsDialog()
 {
     _myWalletsView?.Close();
 }
コード例 #25
0
 public void HideUnlockDialog()
 {
     _unlockView?.Close();
 }
コード例 #26
0
 public void HideStartDialog()
 {
     _startView.Close();
 }
コード例 #27
0
        /// <summary>
        ///     Generate the page layout using controls defined in the HUD schema.
        /// </summary>
        public Grid GetControls()
        {
            // Skip this process if the controls have already been rendered.
            if (isRendered)
            {
                return(controls);
            }

            // Define the container that will hold the title and content.
            var container = new Grid();
            var titleRow  = new RowDefinition
            {
                Height = GridLength.Auto
            };
            var contentRow = new RowDefinition();

            if (layout != null)
            {
                contentRow.Height = GridLength.Auto;
            }
            container.RowDefinitions.Add(titleRow);
            container.RowDefinitions.Add(contentRow);

            // Define the title of the HUD displayed at the top of the page.
            var title = new Label
            {
                Style   = (Style)Application.Current.Resources["PageTitle"],
                Content = Name
            };

            Grid.SetRow(title, 0);
            container.Children.Add(title);

            // Create the preview modal
            var preview = new ChildWindow
            {
                Style = (Style)Application.Current.Resources["PreviewPanel"]
            };

            preview.MouseDoubleClick += (_, _) => { preview.Close(); };

            var image = new Image
            {
                Style = (Style)Application.Current.Resources["PreviewImage"]
            };

            preview.Content = image;

            container.Children.Add(preview);

            // NOTE: ColumnDefinition and RowDefinition only exist on Grid, not Panel, so we are forced to use dynamic for each section.
            dynamic sectionsContainer;

            if (LayoutOptions != null)
            {
                // Splits Layout string[] into 2D Array using \s+
                layout = LayoutOptions.Select(t => Regex.Split(t, "\\s+")).ToArray();

                sectionsContainer = new Grid
                {
                    VerticalAlignment = VerticalAlignment.Top,
                    MaxWidth          = 1280,
                    MaxHeight         = 720
                };

                // Assume that all row arrays are the same length, use column information from Layout[0].
                for (var i = 0; i < layout[0].Length; i++)
                {
                    sectionsContainer.ColumnDefinitions.Add(new ColumnDefinition());
                }
                for (var i = 0; i < layout.Length; i++)
                {
                    sectionsContainer.RowDefinitions.Add(new RowDefinition());
                }
            }
            else
            {
                sectionsContainer = new WrapPanel
                {
                    Margin = new Thickness(10)
                };
            }

            Grid.SetRow(sectionsContainer, 1);

            var lastMargin    = new Thickness(10, 2, 0, 0);
            var lastTop       = lastMargin.Top;
            var groupBoxIndex = 0;

            // Generate each control section as defined in the schema.
            foreach (var section in ControlOptions.Keys)
            {
                var sectionContainer = new GroupBox
                {
                    Header = section
                };

                var sectionContentContainer = new Grid();
                sectionContentContainer.ColumnDefinitions.Add(new ColumnDefinition());
                sectionContentContainer.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });

                // Create the reset button for each control section.
                var resetInput = new Button
                {
                    Style = (Style)Application.Current.Resources["PreviewButton"],
                    HorizontalAlignment = HorizontalAlignment.Right,
                    Content             = ".",
                    Opacity             = 0.4
                };

                resetInput.MouseEnter += (_, _) => resetInput.Opacity = 1;
                resetInput.MouseLeave += (_, _) => resetInput.Opacity = 0.4;

                Grid.SetColumn(resetInput, 1);

                resetInput.Click += (_, _) =>
                {
                    ResetSection(section);
                    Settings.SaveSettings();
                    if (!MainWindow.CheckHudInstallation())
                    {
                        ApplyCustomizations();
                    }
                    DirtyControls.Clear();
                };

                sectionContentContainer.Children.Add(resetInput);

                Panel sectionContent = layout != null ? new WrapPanel() : new StackPanel();
                sectionContent.Margin = new Thickness(3);

                // Generate each individual control, add it to user settings.
                foreach (var controlItem in ControlOptions[section])
                {
                    var id      = controlItem.Name;
                    var label   = controlItem.Label;
                    var tooltip = controlItem.Tooltip;
                    Settings.AddSetting(id, controlItem);

                    switch (controlItem.Type.ToLowerInvariant())
                    {
                    case "checkbox":
                        // Create the Control.
                        var checkBoxInput = new CheckBox
                        {
                            Name      = id,
                            Content   = label,
                            Margin    = new Thickness(10, lastTop + 10, 30, 0),
                            IsChecked = Settings.GetSetting <bool>(id),
                            ToolTip   = tooltip
                        };

                        // Add Events.
                        checkBoxInput.Checked += (sender, _) =>
                        {
                            var input = sender as CheckBox;
                            Settings.SetSetting(input?.Name, "true");
                            CheckIsDirty(controlItem);
                        };
                        checkBoxInput.Unchecked += (sender, _) =>
                        {
                            var input = sender as CheckBox;
                            Settings.SetSetting(input?.Name, "false");
                            CheckIsDirty(controlItem);
                        };

                        // Add to Page.
                        sectionContent.Children.Add(checkBoxInput);
                        controlItem.Control = checkBoxInput;
                        MainWindow.Logger.Info($"Added checkbox to the page ({checkBoxInput.Name}).");

                        // Create a preview button if the control has a preview image.
                        if (!string.IsNullOrWhiteSpace(controlItem.Preview))
                        {
                            var previewBtn = new Button
                            {
                                Style             = (Style)Application.Current.Resources["PreviewButton"],
                                Margin            = new Thickness(0, lastTop, 0, 0),
                                VerticalAlignment = VerticalAlignment.Bottom
                            };
                            previewBtn.Click += (_, _) =>
                            {
                                preview.Caption = !string.IsNullOrWhiteSpace(tooltip) ? tooltip : id;
                                image.Source    = new BitmapImage(new Uri(controlItem.Preview));
                                preview.Show();
                            };
                            sectionContent.Children.Add(previewBtn);
                            MainWindow.Logger.Info($"{checkBoxInput.Name} - Added preview: {controlItem.Preview}.");
                        }

                        break;

                    case "color":
                    case "colour":
                    case "colorpicker":
                    case "colourpicker":
                        // Create the Control.
                        var colorContainer = new StackPanel
                        {
                            Margin = new Thickness(10, lastTop, 0, 10)
                        };
                        var colorLabel = new Label
                        {
                            Content = label,
                            Style   = (Style)Application.Current.Resources["ColorPickerLabel"]
                        };
                        var colorInput = new ColorPicker
                        {
                            Name    = id,
                            ToolTip = tooltip
                        };

                        // Attempt to bind the color from the settings.
                        try
                        {
                            colorInput.SelectedColor = Settings.GetSetting <Color>(id);
                        }
                        catch
                        {
                            colorInput.SelectedColor = Color.FromArgb(255, 0, 255, 0);
                        }

                        // Add Events.
                        colorInput.SelectedColorChanged += (sender, _) =>
                        {
                            var input = sender as ColorPicker;
                            Settings.SetSetting(input?.Name,
                                                Utilities.ConvertToRgba(input?.SelectedColor.ToString()));
                        };
                        colorInput.Closed += (sender, _) =>
                        {
                            var input = sender as ColorPicker;
                            Settings.SetSetting(input?.Name,
                                                Utilities.ConvertToRgba(input?.SelectedColor.ToString()));
                            CheckIsDirty(controlItem);
                        };

                        // Add to Page.
                        colorContainer.Children.Add(colorLabel);
                        colorContainer.Children.Add(colorInput);
                        sectionContent.Children.Add(colorContainer);
                        controlItem.Control = colorInput;
                        MainWindow.Logger.Info($"Added color picker to the page ({colorInput.Name}).");

                        // Create a preview button if the control has a preview image.
                        if (!string.IsNullOrWhiteSpace(controlItem.Preview))
                        {
                            var previewBtn = new Button
                            {
                                Style  = (Style)Application.Current.Resources["PreviewButton"],
                                Margin = new Thickness(5, lastTop, 0, 0)
                            };
                            previewBtn.Click += (_, _) =>
                            {
                                preview.Caption = !string.IsNullOrWhiteSpace(tooltip)
                                        ? tooltip
                                        : id;
                                image.Source = new BitmapImage(new Uri(controlItem.Preview));
                                preview.Show();
                            };
                            sectionContent.Children.Add(previewBtn);
                            MainWindow.Logger.Info($"{colorInput.Name} - Added preview: {controlItem.Preview}.");
                        }

                        break;

                    case "dropdown":
                    case "dropdownmenu":
                    case "select":
                    case "combobox":
                        // Do not create a ComboBox if there are no defined options.
                        if (controlItem.Options is not {
                            Length: > 0
                        })
                        {
                            break;
                        }

                        // Create the Control.
                        var comboBoxContainer = new StackPanel
                        {
                            Margin = new Thickness(10, lastTop, 0, 5)
                        };
                        var comboBoxLabel = new Label
                        {
                            Content = label,
                            Style   = (Style)Application.Current.Resources["ComboBoxLabel"]
                        };
                        var comboBoxInput = new ComboBox
                        {
                            Name    = id,
                            ToolTip = tooltip
                        };

                        // Add items to the ComboBox.
                        foreach (var option in controlItem.Options)
                        {
                            var item = new ComboBoxItem
                            {
                                Content = option.Label
                            };

                            comboBoxInput.Items.Add(item);
                        }

                        // Set the selected value depending on the what's retrieved from the setting file.
                        var comboValue = Settings.GetSetting <string>(id);
                        if (!Regex.IsMatch(comboValue, "\\D"))
                        {
                            comboBoxInput.SelectedIndex = int.Parse(comboValue);
                        }
                        else
                        {
                            comboBoxInput.SelectedValue = comboValue;
                        }

                        // Add Events.
                        comboBoxInput.SelectionChanged += (sender, _) =>
                        {
                            var input = sender as ComboBox;
                            Settings.SetSetting(input?.Name, comboBoxInput.SelectedIndex.ToString());
                            CheckIsDirty(controlItem);
                        };

                        // Add to Page.
                        comboBoxContainer.Children.Add(comboBoxLabel);
                        comboBoxContainer.Children.Add(comboBoxInput);
                        sectionContent.Children.Add(comboBoxContainer);
                        controlItem.Control = comboBoxInput;
                        MainWindow.Logger.Info($"Added combo-box to the page ({comboBoxInput.Name}).");

                        // Create a preview button if the control has a preview image.
                        if (!string.IsNullOrWhiteSpace(controlItem.Preview))
                        {
                            var previewBtn = new Button
                            {
                                Style  = (Style)Application.Current.Resources["PreviewButton"],
                                Margin = new Thickness(0, lastTop, 0, 0)
                            };
                            previewBtn.Click += (_, _) =>
                            {
                                preview.Caption = !string.IsNullOrWhiteSpace(tooltip)
                                        ? tooltip
                                        : id;
                                image.Source = new BitmapImage(new Uri(controlItem.Preview));
                                preview.Show();
                            };
                            sectionContent.Children.Add(previewBtn);
                            MainWindow.Logger.Info($"{comboBoxInput.Name} - Added preview: {controlItem.Preview}.");
                        }

                        break;
コード例 #28
0
 public void Close()
 {
     _window.Close();
 }
コード例 #29
0
ファイル: newDateTimePicker.cs プロジェクト: jjg0519/OA
 void btnClose_Click(object sender, RoutedEventArgs e)
 {
     windowSelectdateTime.Close();
 }
コード例 #30
0
        private void MakeGranularityBox(string filename, IEnumerable <Path> paths)
        {
            ChildWindow popup = new ChildWindow();

            popup.MinWidth              = 400;
            popup.MinHeight             = 100;
            popup.CaptionForeground     = gray;
            popup.Caption               = "Enter a value";
            popup.WindowStartupLocation = Xceed.Wpf.Toolkit.WindowStartupLocation.Center;
            popup.Closed            += GranularityPopup_Closed;
            popup.Resources["file"]  = filename;
            popup.Resources["paths"] = paths;
            Grid layoutRoot = new Grid()
            {
                Margin = new Thickness(7)
            };
            StackPanel inputRegion = new StackPanel()
            {
                Orientation         = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Top
            };
            StackPanel buttonRegion = new StackPanel()
            {
                Orientation         = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Bottom
            };

            Extensions.SetSpacing(inputRegion, new Thickness(2));
            Extensions.SetSpacing(buttonRegion, new Thickness(2));
            popup.Content = layoutRoot;
            layoutRoot.Children.Add(inputRegion);
            layoutRoot.Children.Add(buttonRegion);

            inputRegion.Children.Add(new TextBlock()
            {
                Text = "Interval:"
            });
            DoubleUpDown intervalPicker = new DoubleUpDown()
            {
                Increment               = 0.01,
                Minimum                 = 0,
                Value                   = 0.01,
                Maximum                 = 1,
                MinWidth                = 100,
                FormatString            = "F2",
                MouseWheelActiveTrigger = MouseWheelActiveTrigger.MouseOver
            };

            popup.Resources["value"] = intervalPicker;
            inputRegion.Children.Add(intervalPicker);

            Button cancel = new Button {
                Content = "Cancel", MinWidth = 100, Padding = new Thickness(2)
            };
            Button ok = new Button {
                Content = "Ok", MinWidth = 100, Padding = new Thickness(2)
            };

            cancel.Click += (obj, args) =>
            {
                popup.Resources["success"] = false;
                popup.Close();
            };
            ok.Click += (obj, args) =>
            {
                popup.Resources["success"] = true;
                popup.Close();
            };
            buttonRegion.Children.Add(cancel);
            buttonRegion.Children.Add(ok);

            DialogArea.Children.Add(popup);
            popup.IsModal = true;
            popup.Show();
        }