コード例 #1
0
        public void ShowMessage(string title, string message, int closedInSeconds)
        {
            var window = new MessageWindow(title, message, closedInSeconds);

            window.Owner = WpfHelper.GetActiveWindow();
            window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            window.ShowDialog();
        }
コード例 #2
0
        public static void Print(this RadGridView grid, PrintSettings settings)
        {
            var rtb    = CreateRadRichTextBox(grid, settings);
            var window = new RadWindow()
            {
                Height = 0, Width = 0, Opacity = 0, Content = rtb, Owner = WpfHelper.GetActiveWindow()
            };

            rtb.PrintCompleted += (s, e) => { window.Close(); };
            window.Show();

            rtb.Print("MyDocument", Telerik.Windows.Documents.UI.PrintMode.Native);
        }
コード例 #3
0
 public void ShowError(string content, Action onErrorClosed)
 {
     this._onErrorClosed = onErrorClosed;
     RadWindow.Alert(new DialogParameters()
     {
         Content = FormatContent(content),
         Closed  = new EventHandler <WindowClosedEventArgs>(OnErrorClosed),
         DialogStartupLocation = System.Windows.WindowStartupLocation.CenterOwner,
         Header          = UiResources.Error,
         OkButtonContent = UiResources.Ok,
         Owner           = WpfHelper.GetActiveWindow()
     });
 }
コード例 #4
0
 public void ShowConfirmation(string content, Action <bool> onConfirmationClosed)
 {
     this._onConfirmationClosed = onConfirmationClosed;
     RadWindow.Confirm(new DialogParameters()
     {
         Content = FormatContent(content),
         Closed  = new EventHandler <WindowClosedEventArgs>(OnConfirmationClosed),
         DialogStartupLocation = System.Windows.WindowStartupLocation.CenterOwner,
         Header              = UiResources.Confirm,
         OkButtonContent     = UiResources.Ok,
         CancelButtonContent = UiResources.Cancel,
         Owner = WpfHelper.GetActiveWindow()
     });
 }
コード例 #5
0
        public void ShowProgress(ProgressViewModel progressViewModel, RoutedEventHandler onLoaded, bool closeOnCompleted)
        {
            var window = new ProgressWindow(progressViewModel);

            window.Loaded += onLoaded;
            window.Owner   = WpfHelper.GetActiveWindow();
            window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            window.SizeToContent         = true;
            if (closeOnCompleted)
            {
                progressViewModel.Completed += (message) => window.Dispatcher.Invoke(new Action(() => window.Close()));
            }
            window.ShowDialog();
        }
コード例 #6
0
 public void ShowPrompt(string content, string defaultPromptResult, Action <bool, string> onPrompted)
 {
     this._onPromptClosed = onPrompted;
     RadWindow.Prompt(new DialogParameters()
     {
         Content = FormatContent(content),
         Closed  = OnPromptClosed,
         DialogStartupLocation = WindowStartupLocation.CenterOwner,
         Header              = UiResources.Prompt,
         OkButtonContent     = UiResources.Ok,
         CancelButtonContent = UiResources.Cancel,
         Owner = WpfHelper.GetActiveWindow(),
         DefaultPromptResultValue = defaultPromptResult
     });
 }
コード例 #7
0
        public void ShowReportWindow(ReportSource reportSource)
        {
            var reportViewer = new ReportViewer();

            reportViewer.ReportSource = reportSource;

            var window = new RadWindow();

            window.Header  = UiResources.Reports;
            window.Content = reportViewer;
            window.Owner   = WpfHelper.GetActiveWindow();
            window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            window.SizeToContent         = false;
            window.WindowState           = WindowState.Maximized;
            window.Show();
        }
コード例 #8
0
        public void ShowView(object viewOrViewType, bool modal, object arg, Action <bool> onClosed)
        {
            FrameworkElement content = null;

            if (viewOrViewType is Type)
            {
                var container = ServiceLocator.Current.GetInstance <IUnityContainer>();
                var viewType  = (Type)viewOrViewType;
                content = container.Resolve(viewType) as FrameworkElement;
            }
            else
            {
                content = viewOrViewType as FrameworkElement;
            }

            if (content != null)
            {
                var dialog = content.DataContext as IDialog;
                if (dialog != null)
                {
                    dialog.IsDialog = true;
                    dialog.OnShow(arg);

                    var window = new MyWindow();
                    window.HideMaximizeButton = true;
                    window.OnWindowClosing    = dialog.OnClosing;
                    window.OnWindowClosed     = onClosed;
                    window.Content            = content;
                    window.DataContext        = content.DataContext;
                    window.Owner = WpfHelper.GetActiveWindow();
                    window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;

                    if (modal)
                    {
                        window.ShowDialog();
                    }
                    else
                    {
                        window.Show();
                    }
                }
            }
        }
コード例 #9
0
        private static RadWindow CreatePreviewWindow(RadRichTextBox rtb)
        {
            var printButton = new RadButton()
            {
                Content    = "Print",
                Margin     = new Thickness(10, 0, 10, 0),
                FontWeight = FontWeights.Bold,
                Width      = 80
            };

            printButton.Click += (s, e) =>
            {
                rtb.Print("MyDocument", Telerik.Windows.Documents.UI.PrintMode.Native);
            };

            var sp = new StackPanel()
            {
                Height = 26, Orientation = Orientation.Horizontal, Margin = new Thickness(10)
            };

            sp.Children.Add(new RadRichTextBoxStatusBar()
            {
                AssociatedRichTextBox = rtb, Margin = new Thickness(20, 0, 10, 0)
            });

            sp.Children.Add(new TextBlock()
            {
                Text = "Orientation:", Margin = new Thickness(10, 0, 3, 0), VerticalAlignment = VerticalAlignment.Center
            });

            var radComboBoxPageOrientation = new RadComboBox()
            {
                ItemsSource   = new string[] { "Portrait", "Landscape" },
                SelectedIndex = 0
            };

            sp.Children.Add(radComboBoxPageOrientation);

            radComboBoxPageOrientation.SelectionChanged += (s, e) =>
            {
                rtb.ChangeSectionPageOrientation((PageOrientation)Enum.Parse(typeof(PageOrientation),
                                                                             radComboBoxPageOrientation.Items[radComboBoxPageOrientation.SelectedIndex].ToString(), true));
            };

            sp.Children.Add(new TextBlock()
            {
                Text = "Size:", Margin = new Thickness(10, 0, 3, 0), VerticalAlignment = VerticalAlignment.Center
            });

            var radComboBoxPageSize = new RadComboBox()
            {
                ItemsSource   = new string[] { "A0", "A1", "A2", "A3", "A4", "A5", "Letter" },
                Height        = 25,
                SelectedIndex = 4,
            };

            sp.Children.Add(radComboBoxPageSize);

            radComboBoxPageSize.SelectionChanged += (s, e) =>
            {
                rtb.ChangeSectionPageSize(PaperTypeConverter.ToSize((PaperTypes)Enum.Parse(typeof(PaperTypes),
                                                                                           radComboBoxPageSize.Items[radComboBoxPageSize.SelectedIndex].ToString(), true)));
            };

            sp.Children.Add(printButton);

            var g = new Grid();

            g.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            g.RowDefinitions.Add(new RowDefinition());
            g.Children.Add(sp);
            g.Children.Add(rtb);

            Grid.SetRow(rtb, 1);

            return(new RadWindow()
            {
                Content = g,
                Width = 900,
                Height = 600,
                Header = "Print Preview",
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                Owner = WpfHelper.GetActiveWindow()
            });
        }