private void RadWindow_Loaded(object sender, RoutedEventArgs e) { //apply template - gray out window when it's deactivated. var hostWindow = WpfHelper.GetParentVisualElement <Window>(this); var template = Application.Current.FindResource("WindowTemplate") as ControlTemplate; hostWindow.Template = template; hostWindow.ApplyTemplate(); //set focus on first control hostWindow.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Loaded, new Action(() => { hostWindow.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)); }) ); //select all text on focus var textBoxes = this.ChildrenOfType <TextBox>(); foreach (var textBox in textBoxes) { textBox.AddHandler(TextBox.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(SelectivelyIgnoreMouseButton), true); textBox.AddHandler(TextBox.GotKeyboardFocusEvent, new RoutedEventHandler(SelectAllText), true); textBox.AddHandler(TextBox.MouseDoubleClickEvent, new RoutedEventHandler(SelectAllText), true); } //override command of close(X) button if (this.OnWindowClosing != null) { var closeButton = this.ChildrenOfType <RadButton>().FirstOrDefault(x => x.Name == "PART_CloseButton"); Action <object> temp = obj => OnWindowClosing(); closeButton.Command = new DelegateCommand(temp); } }
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(); }
public CrudBar() { if (WpfHelper.GetIsInDesignMode()) { return; } InitializeComponent(); }
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); }
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() }); }
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() }); }
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(); }
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 }); }
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(); }
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(); } } } }
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() }); }