/// <summary> /// Initializes a new instance of the <see cref="SceneView"/> class. /// </summary> public SceneView() { InitializeComponent(); // Handle the size changed event. SizeChanged += new SizeChangedEventHandler(SceneView_SizeChanged); }
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { //Get self var self = (sender as FrameworkElement); //Check we have a parent Border if (!(self.Parent is Border border)) { Debugger.Break(); return; } //Setup loaded event mBorder_Loaded = (ss, ee) => Border_OnChange(ss, ee, self); //Setup size changed event mBorder_SizeChanged = (ss, ee) => Border_OnChange(ss, ee, self); //If true, hook into events if ((bool)e.NewValue) { border.Loaded += mBorder_Loaded; border.SizeChanged += mBorder_SizeChanged; } //Otherwise, unhook else { border.Loaded -= mBorder_Loaded; border.SizeChanged -= mBorder_SizeChanged; } }
public DocumentView() { InitializeComponent(); Loaded += DocumentViewLoaded; wb.Loaded += WbLoaded; wb.OpenExternalLink += WebControl_LinkClicked; SizeChanged += new SizeChangedEventHandler(DocumentViewSizeChanged); Editor.TextArea.SelectionChanged += SelectionChanged; Editor.PreviewMouseLeftButtonUp += HandleMouseUp; hunspell = IoC.Get <ISpellingService>(); spellCheckRenderer = new SpellCheckBackgroundRenderer(); Editor.TextArea.TextView.BackgroundRenderers.Add(spellCheckRenderer); Editor.TextArea.TextView.VisualLinesChanged += TextView_VisualLinesChanged; CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleBold, (x, y) => ToggleBold(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleItalic, (x, y) => ToggleItalic(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleCode, (x, y) => ToggleCode(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleCodeBlock, (x, y) => ToggleCodeBlock(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.SetHyperlink, (x, y) => SetHyperlink(), CanEditDocument)); }
private static void OnWatermarkTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var tb = d as TextBox; if (tb != null) { var textChangedHandler = new TextChangedEventHandler((s, ea) => ShowOrHideWatermark(s as TextBox)); var focusChangedHandler = new DependencyPropertyChangedEventHandler((s, ea) => ShowOrHideWatermark(s as TextBox)); var sizeChangedHandler = new SizeChangedEventHandler((s, ea) => ShowOrHideWatermark(s as TextBox)); if (string.IsNullOrEmpty(e.OldValue as string)) { tb.TextChanged += textChangedHandler; tb.IsKeyboardFocusedChanged += focusChangedHandler; // subscribe to SizeChanged events in substitution for FontSize change events tb.SizeChanged += sizeChangedHandler; } if (string.IsNullOrEmpty(e.NewValue as string)) { tb.TextChanged -= textChangedHandler; tb.IsKeyboardFocusedChanged -= focusChangedHandler; tb.SizeChanged -= sizeChangedHandler; } ShowOrHideWatermark(tb); } }
/// <summary> /// Adds a Metro Dialog instance to the specified window and makes it visible asynchronously. /// If you want to wait until the user has closed the dialog, use <see cref="ShowMetroDialogAsyncAwaitable"/> /// <para>You have to close the resulting dialog yourself with <see cref="HideMetroDialogAsync"/>.</para> /// </summary> /// <param name="window">The owning window of the dialog.</param> /// <param name="dialog">The dialog instance itself.</param> /// <param name="settings">An optional pre-defined settings instance.</param> /// <returns>A task representing the operation.</returns> /// <exception cref="InvalidOperationException">The <paramref name="dialog"/> is already visible in the window.</exception> public Task ShowMetroDialogAsync( IMetroWindow metroWindow , IBaseMetroDialogFrame dialog , IMetroDialogFrameSettings settings = null) { metroWindow.Dispatcher.VerifyAccess(); if (metroWindow.MetroActiveDialogContainer.Children.Contains(dialog as UIElement) || metroWindow.MetroInactiveDialogContainer.Children.Contains(dialog as UIElement)) { throw new InvalidOperationException("The provided dialog is already visible in the specified window."); } return(this.HandleOverlayOnShow(metroWindow, settings).ContinueWith(z => { return (Task)metroWindow.Dispatcher.Invoke(new Func <Task>(() => { settings = settings ?? new MetroDialogFrameSettings(); SizeChangedEventHandler sizeHandler = this.SetupAndOpenDialog(metroWindow, dialog); dialog.SizeChangedHandler = sizeHandler; return dialog.WaitForLoadAsync().ContinueWith(x => { dialog.OnShown(); if (DialogOpened != null) { metroWindow.Dispatcher.BeginInvoke(new Action(() => DialogOpened(this, new DialogStateChangedEventArgs()))); } }); })); }).Unwrap()); }
private static void OnWatermarkTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var tb = d as TextBox; if (tb != null) { var textChangedHandler = new TextChangedEventHandler((s, ea) => ShowOrHideWatermark(s as TextBox)); var focusChangedHandler = new DependencyPropertyChangedEventHandler((s, ea) => ShowOrHideWatermark(s as TextBox)); var sizeChangedHandler = new SizeChangedEventHandler((s, ea) => ShowOrHideWatermark(s as TextBox)); if (string.IsNullOrEmpty(e.OldValue as string)) { tb.TextChanged += textChangedHandler; tb.IsKeyboardFocusedChanged += focusChangedHandler; // We need SizeChanged events because the Background brush is sized according to the control size tb.SizeChanged += sizeChangedHandler; } if (string.IsNullOrEmpty(e.NewValue as string)) { tb.TextChanged -= textChangedHandler; tb.IsKeyboardFocusedChanged -= focusChangedHandler; tb.SizeChanged -= sizeChangedHandler; } ShowOrHideWatermark(tb); } }
private void NotificationWindow_Loaded(object sender, RoutedEventArgs e) { var element = (Border)sender; // When the hide animation starts, wait until // it finishes, then remove the notification. // I wish I could listen the Completed event, // but I can only get it from a resource, and // I can't figure out how to find the target. SizeChangedEventHandler sizeChangedHandler = null; sizeChangedHandler = async(s, se) => { if (se.PreviousSize.Height == 0) { return; } element.SizeChanged -= sizeChangedHandler; while (element.Height > 0) { await Task.Delay(500); } RemoveNotification((Notification)element.DataContext); }; element.SizeChanged += sizeChangedHandler; }
/// <summary> /// Adds a Metro Dialog instance of the given type to the specified window and makes it visible asynchronously. /// If you want to wait until the user has closed the dialog, use <see cref="BaseMetroDialog.WaitUntilUnloadedAsync"/> /// <para>You have to close the resulting dialog yourself with <see cref="HideMetroDialogAsync"/>.</para> /// </summary> /// <param name="window">The owning window of the dialog.</param> /// <param name="settings">An optional pre-defined settings instance.</param> /// <returns>A task with the dialog representing the operation.</returns> public static Task <TDialog> ShowMetroDialogAsync <TDialog>([NotNull] this MetroWindow window, [CanBeNull] MetroDialogSettings settings = null) where TDialog : BaseMetroDialog { if (window == null) { throw new ArgumentNullException(nameof(window)); } window.Dispatcher.VerifyAccess(); var dialog = (TDialog)Activator.CreateInstance(typeof(TDialog), window, settings); return(HandleOverlayOnShow(dialog.DialogSettings, window).ContinueWith(z => { return (Task <TDialog>)window.Dispatcher.Invoke(new Func <Task <TDialog> >(() => { SetDialogFontSizes(dialog.DialogSettings, dialog); SizeChangedEventHandler sizeHandler = SetupAndOpenDialog(window, dialog); dialog.SizeChangedHandler = sizeHandler; return dialog.WaitForLoadAsync().ContinueWith(x => { dialog.OnShown(); if (DialogOpened != null) { window.Dispatcher.BeginInvoke(new Action(() => DialogOpened(window, new DialogStateChangedEventArgs()))); } }).ContinueWith(x => dialog); })); }).Unwrap()); }
public ColorButton() { this.DefaultStyleKey = typeof(ColorButton); //if (System.ComponentModel.DesignerProperties.IsInDesignTool) // return; SizeChanged += new SizeChangedEventHandler(ColorButton_SizeChanged); }
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { //get self var self = (sender as FrameworkElement); //check we have a parent border if (!(self.Parent is Border border)) { Debugger.Break(); return; } //setup loaded event mBorder_Loaded = (s1, e1) => Border_OnChange(s1, e1, self); //setup size changed event mBorder_SizeChanged = (s1, e1) => Border_OnChange(s1, e1, self); //if true, hook events if ((bool)e.NewValue) { //if true hook border.Loaded += mBorder_Loaded; border.SizeChanged += mBorder_SizeChanged; } else { //unhook border.Loaded -= mBorder_Loaded; border.SizeChanged -= mBorder_SizeChanged; } }
/// <summary> /// Initializes a new instance of the <see cref="OpenGLControl"/> class. /// </summary> public OpenGLControl() { InitializeComponent(); // Set default size. writeableBitmap = new WriteableBitmap(100, 100, 96, 96, PixelFormats.Bgra32, null); SizeChanged += new SizeChangedEventHandler(OpenGLControl_SizeChanged); }
/// <summary> /// Creates a MessageDialog inside of the current window. /// </summary> /// <param name="window">The MetroWindow</param> /// <param name="title">The title of the MessageDialog.</param> /// <param name="message">The message contained within the MessageDialog.</param> /// <param name="style">The type of buttons to use.</param> /// <param name="settings">Optional settings that override the global metro dialog settings.</param> /// <returns>A task promising the result of which button was pressed.</returns> public static Task <MessageDialogResult> ShowMessageAsync(this MetroWindow window, string title, string message, MessageDialogStyle style = MessageDialogStyle.Affirmative, MetroDialogSettings settings = null) { window.Dispatcher.VerifyAccess(); return(HandleOverlayOnShow(settings, window).ContinueWith(z => { return (Task <MessageDialogResult>)window.Dispatcher.Invoke(new Func <Task <MessageDialogResult> >(() => { if (settings == null) { settings = window.MetroDialogOptions; } //create the dialog control var dialog = new MessageDialog(window, settings) { Message = message, Title = title, ButtonStyle = style, }; SizeChangedEventHandler sizeHandler = SetupAndOpenDialog(window, dialog); dialog.SizeChangedHandler = sizeHandler; // dialog.Style.Setters.Add(new Setter()); return dialog.WaitForLoadAsync().ContinueWith(x => { if (DialogOpened != null) { window.Dispatcher.BeginInvoke(new Action(() => DialogOpened(window, new DialogStateChangedEventArgs()))); } return dialog.WaitForButtonPressAsync().ContinueWith(y => { //once a button as been clicked, begin removing the dialog. dialog.OnClose(); if (DialogClosed != null) { window.Dispatcher.BeginInvoke(new Action(() => DialogClosed(window, new DialogStateChangedEventArgs()))); } Task closingTask = (Task)window.Dispatcher.Invoke(new Func <Task>(() => dialog._WaitForCloseAsync())); return closingTask.ContinueWith(a => { return ((Task)window.Dispatcher.Invoke(new Func <Task>(() => { window.SizeChanged -= sizeHandler; window.RemoveDialog(dialog); return HandleOverlayOnHide(settings, window); }))).ContinueWith(y3 => y).Unwrap(); }); }).Unwrap(); }).Unwrap().Unwrap(); })); }).Unwrap()); }
/// <summary> /// Adds a TMP Dialog instance to the specified window and makes it visible. /// <para>Note that this method returns as soon as the dialog is loaded and won't wait on a call of <see cref="HideTMPDialogAsync"/>.</para> /// <para>You can still close the resulting dialog with <see cref="HideTMPDialogAsync"/>.</para> /// </summary> /// <param name="window">The owning window of the dialog.</param> /// <param name="dialog">The dialog instance itself.</param> /// <returns>A task representing the operation.</returns> /// <exception cref="InvalidOperationException">The <paramref name="dialog"/> is already visible in the window.</exception> public static Task ShowTMPDialogAsync(this TMPWindow window, BaseTMPDialog dialog, TMPDialogSettings settings = null) { window.Dispatcher.VerifyAccess(); if (window.tmpDialogContainer.Children.Contains(dialog)) { throw new InvalidOperationException("The provided dialog is already visible in the specified window."); } return(HandleOverlayOnShow(settings, window).ContinueWith(z => { dialog.Dispatcher.Invoke(new Action(() => { SizeChangedEventHandler sizeHandler = SetupAndOpenDialog(window, dialog); dialog.SizeChangedHandler = sizeHandler; })); }).ContinueWith(y => ((Task)dialog.Dispatcher.Invoke(new Func <Task>(() => dialog.WaitForLoadAsync().ContinueWith(x => { dialog.OnShown(); if (DialogOpened != null) { DialogOpened(window, new DialogStateChangedEventArgs()); } })))))); }
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var self = (sender as FrameworkElement); if (self == null) { return; } //check we have a parent border if (!(self.Parent is Border)) { Debugger.Break(); return; } mBorder_Loaded = (ss, ee) => Border_OnChange(ss, ee, self); mBorder_SizeChanged = (ss, ee) => Border_OnChange(ss, ee, self); Border border = self.Parent as Border; //if true hook into events if ((bool)e.NewValue) { border.Loaded += mBorder_Loaded; border.SizeChanged += mBorder_SizeChanged; } else { //otherwise unhook border.Loaded -= mBorder_Loaded; border.SizeChanged -= mBorder_SizeChanged; } }
public CustomMarkerRed(MainClientWindow window, GMapMarker marker, string title) { InitializeComponent(); MainWindow = window; Marker = marker; Popup = new Popup(); Label = new Label(); Loaded += new RoutedEventHandler(CustomMarkerDemo_Loaded); SizeChanged += new SizeChangedEventHandler(CustomMarkerDemo_SizeChanged); MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter); MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave); MouseMove += new MouseEventHandler(CustomMarkerDemo_MouseMove); MouseLeftButtonUp += new MouseButtonEventHandler(CustomMarkerDemo_MouseLeftButtonUp); MouseLeftButtonDown += new MouseButtonEventHandler(CustomMarkerDemo_MouseLeftButtonDown); Popup.Placement = PlacementMode.Mouse; { Label.Background = Brushes.Blue; Label.Foreground = Brushes.White; Label.BorderBrush = Brushes.WhiteSmoke; Label.BorderThickness = new Thickness(2); Label.Padding = new Thickness(5); Label.FontSize = 22; Label.Content = title; } Popup.Child = Label; }
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var self = sender as FrameworkElement; if (!(self.Parent is Border border)) { Debugger.Break(); return; } border_Loaded = (ss, ee) => Border_OnChange(ss, ee, self); border_SizeChanged = (ss, ee) => Border_OnChange(ss, ee, self); if ((bool)e.NewValue) { border.Loaded += border_Loaded; border.SizeChanged += border_SizeChanged; } else { border.Loaded -= border_Loaded; border.SizeChanged -= border_SizeChanged; } }
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var self = (sender as FrameworkElement); if (!(self.Parent is Border border)) { Debugger.Break(); return; } //border = parent //self = image mBorder_Loaded = (s1, e1) => Border_OnChange(s1, e1, self); mBorder_SizeChanged = (s1, e1) => Border_OnChange(s1, e1, self); //새로 변경된 값이 참이면 if ((bool)e.NewValue) { border.Loaded += mBorder_Loaded; border.SizeChanged += mBorder_SizeChanged; } //새로 변경된 값이 거짓이면 else { border.Loaded -= mBorder_Loaded; border.SizeChanged -= mBorder_SizeChanged; } }
public ImageSequence() { DefaultStyleKey = typeof(ImageSequence); imageHeight = 1600; Loaded += new System.Windows.RoutedEventHandler(ImageSequence_Loaded); SizeChanged += new SizeChangedEventHandler(ImageSequence_SizeChanged); }
private static SizeChangedEventHandler SetupAndOpenDialog(MetroWindow window, BaseMetroDialog dialog) { dialog.SetValue(Panel.ZIndexProperty, (int)window.overlayBox.GetValue(Panel.ZIndexProperty) + 1); dialog.MinHeight = window.ActualHeight / 4.0; SizeChangedEventHandler sizeHandler = null; //an event handler for auto resizing an open dialog. sizeHandler = new SizeChangedEventHandler((sender, args) => { dialog.MinHeight = window.ActualHeight / 4.0; }); window.SizeChanged += sizeHandler; //window.overlayBox.Visibility = Visibility.Visible; //activate the overlay effect window.messageDialogContainer.Children.Add(dialog); //add the dialog to the container dialog.OnShown(); if (window.TextBlockStyle != null && !dialog.Resources.Contains(typeof(TextBlock))) { dialog.Resources.Add(typeof(TextBlock), window.TextBlockStyle); } return(sizeHandler); }
private static void OnWatermarkTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var tb = d as TextBox; if (tb != null) { var textChangedHandler = new TextChangedEventHandler((s, ea) => ShowOrHideWatermark(s as TextBox)); var focusChangedHandler = new DependencyPropertyChangedEventHandler((s, ea) => ShowOrHideWatermark(s as TextBox)); var sizeChangedHandler = new SizeChangedEventHandler((s, ea) => ShowOrHideWatermark(s as TextBox)); if (e.OldValue == null) { tb.TextChanged += textChangedHandler; tb.IsKeyboardFocusedChanged += focusChangedHandler; tb.SizeChanged += sizeChangedHandler; } if (e.NewValue == null) { tb.TextChanged -= textChangedHandler; tb.IsKeyboardFocusedChanged -= focusChangedHandler; tb.SizeChanged -= sizeChangedHandler; } ShowOrHideWatermark(tb); } }
/// <summary> /// Raises the ContentSizeChanged event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.Windows.SizeChangedEventArgs"/> /// instance containing the event data.</param> private void OnContentSiteSizeChanged(object sender, SizeChangedEventArgs e) { this.Log("Before Content "); if (this.RecalculateOnSizeChanged) { this.MeasureContent(this.CalculateDesiredContentSize()); this.RecalculatePercentage(this.TargetSize); // set the non-reveal dimension this.SetNonRevealDimension(); // calculate the reveal dimension this.SetRevealDimension(); } SizeChangedEventHandler handler = this.ContentSizeChanged; if (handler != null) { handler(this, e); } this.Log("After Content "); }
public TPill() { InitializeComponent(); tb.DataContext = this; foreColor = Colors.White; SizeChanged += new SizeChangedEventHandler(TPill_SizeChanged); }
private void Window_Resized(object sender, SizeChangedEventArgs e) { double width = CommandsBottomGrid.ColumnDefinitions[0].ActualWidth; SizeChangedEventHandler eventHandler = null; CommandTextbox.Width = width * 0.8; }
public MainWindow() { InitializeComponent(); Title = "Homeschooling Tools"; Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/schulbistum"); if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/schulbistum" + "/notes.rtf")) { FileStream file = File.Create(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/schulbistum" + "/notes.rtf"); file.Close(); } else { FileStream fi = File.OpenRead(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/schulbistum" + "/notes.rtf"); StreamReader reader = new StreamReader(fi); RtB.Document.Blocks.Clear(); RtB.Document.Blocks.Add(new Paragraph(new Run(reader.ReadToEnd()))); } var cli = new WebClient(); cli.DownloadFile("https://raw.githubusercontent.com/JOmyyYT/Klasse-9.1-Tools/main/Table.html", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/schulbistum" + "/Table.html"); TableBrowser.Source = new UriBuilder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/schulbistum" + "/Table.html").Uri; TableBrowser.Navigating += new System.Windows.Navigation.NavigatingCancelEventHandler(CheckNavigating); SizeChanged += new SizeChangedEventHandler(ChangedSize); Closing += new CancelEventHandler(SafeNotes); }
/// <summary> /// Initializes a new instance of the AnimateOrientationChangesFrame class. /// </summary> public AnimateOrientationChangesFrame() { // Find existing "offset transform" and take it over (if possible) to support SIP raise/lower var transformGroup = new TransformGroup(); var oldTransformGroup = RenderTransform as TransformGroup; if ((null != oldTransformGroup) && (3 <= oldTransformGroup.Children.Count)) { var offsetTransform = oldTransformGroup.Children[0] as TranslateTransform; if (null != offsetTransform) { transformGroup.Children.Add(offsetTransform); } } // Add custom transforms transformGroup.Children.Add(_rotateTransform); transformGroup.Children.Add(_translateTransform); // Replace existing transform(s) RenderTransform = transformGroup; // Set up animation _progressAnimation.From = 0; _progressAnimation.To = 1; Storyboard.SetTarget(_progressAnimation, this); Storyboard.SetTargetProperty(_progressAnimation, new PropertyPath("Progress")); _progressStoryboard.Children.Add(_progressAnimation); // Initialize variables EasingFunction = new QuarticEase(); // Initialized here to avoid a single shared instance // Hook events SizeChanged += new SizeChangedEventHandler(HandleSizeChanged); OrientationChanged += new EventHandler <OrientationChangedEventArgs>(HandleOrientationChanged); }
private void GlassWindow_Loaded( object sender, RoutedEventArgs e ) { // update GlassRegion on window size change SizeChanged += new SizeChangedEventHandler( Window1_SizeChanged ); // update background color on change of desktop composition mode AeroGlassCompositionChanged += new AeroGlassCompositionChangedEvent( Window1_AeroGlassCompositionChanged ); // Set the window background color if( AeroGlassCompositionEnabled ) { // exclude the GDI rendered controls from the initial GlassRegion ExcludeElementFromAeroGlass( eb1 ); SetAeroGlassTransparency( ); } else { this.Background = System.Windows.Media.Brushes.Teal; } // initialize the explorer browser control eb1.NavigationTarget = (ShellObject)KnownFolders.Computer; // set the state of the Desktop Composition check box. EnableCompositionCheck.IsChecked = AeroGlassCompositionEnabled; }
public RedUnderlineAdorner(SpellTextBox textbox) : base(textbox) { sizeChangedEventHandler = new SizeChangedEventHandler( delegate { SignalInvalidate(); }); routedEventHandler = new RoutedEventHandler( delegate { SignalInvalidate(); }); scrollChangedEventHandler = new ScrollChangedEventHandler( delegate { SignalInvalidate(); }); textbox.SizeChanged += sizeChangedEventHandler; textbox.SpellcheckCompleted += routedEventHandler; textbox.AddHandler(ScrollViewer.ScrollChangedEvent, scrollChangedEventHandler); }
/// <summary> /// Adds a Metro Dialog instance to the specified window and makes it visible asynchronously. /// If you want to wait until the user has closed the dialog, use <see cref="ShowMetroDialogAsyncAwaitable"/> /// <para>You have to close the resulting dialog yourself with <see cref="HideMetroDialogAsync"/>.</para> /// </summary> /// <param name="window">The owning window of the dialog.</param> /// <param name="dialog">The dialog instance itself.</param> /// <param name="settings">An optional pre-defined settings instance.</param> /// <returns>A task representing the operation.</returns> /// <exception cref="InvalidOperationException">The <paramref name="dialog"/> is already visible in the window.</exception> public static Task ShowMetroDialogAsync(this MetroWindow window, BaseMetroDialog dialog, MetroDialogSettings settings = null) { window.Dispatcher.VerifyAccess(); if (window.metroActiveDialogContainer.Children.Contains(dialog) || window.metroInactiveDialogContainer.Children.Contains(dialog)) { throw new InvalidOperationException("The provided dialog is already visible in the specified window."); } return(HandleOverlayOnShow(settings, window).ContinueWith(z => { return (Task)window.Dispatcher.Invoke(new Func <Task>(() => { settings = settings ?? window.MetroDialogOptions; SetDialogFontSizes(settings, dialog); SizeChangedEventHandler sizeHandler = SetupAndOpenDialog(window, dialog); dialog.SizeChangedHandler = sizeHandler; return dialog.WaitForLoadAsync().ContinueWith(x => { dialog.OnShown(); if (DialogOpened != null) { window.Dispatcher.BeginInvoke(new Action(() => DialogOpened(window, new DialogStateChangedEventArgs()))); } }); })); }).Unwrap()); }
public static async Task WaitForSizeChangedAsync(this FrameworkElement frameworkElement) { if (frameworkElement == null) { throw new ArgumentNullException(nameof(frameworkElement)); } var initW = frameworkElement.ActualWidth; var initH = frameworkElement.ActualHeight; while (frameworkElement.ActualWidth == initW && frameworkElement.ActualHeight == initH) { var tcs = new TaskCompletionSource <object>(); SizeChangedEventHandler handler = null; handler = (sender, e) => { frameworkElement.SizeChanged -= handler; tcs.SetResult(null); }; frameworkElement.SizeChanged += handler; await tcs.Task; } }
/// <summary> /// Creates a LoginDialog inside of the current window. /// </summary> /// <param name="title">The title of the LoginDialog.</param> /// <param name="message">The message contained within the LoginDialog.</param> /// <param name="settings">Optional settings that override the global metro dialog settings.</param> /// <returns>The text that was entered or null (Nothing in Visual Basic) if the user cancelled the operation.</returns> public static Task <LoginDialogData> ShowLoginAsync(this MetroWindow window, string title, string message, LoginDialogSettings settings = null) { window.Dispatcher.VerifyAccess(); return(HandleOverlayOnShow(settings, window).ContinueWith(z => { return (Task <LoginDialogData>)window.Dispatcher.Invoke(new Func <Task <LoginDialogData> >(() => { if (settings == null) { settings = new LoginDialogSettings(); } //create the dialog control LoginDialog dialog = new LoginDialog(window, settings); dialog.Title = title; dialog.Message = message; SizeChangedEventHandler sizeHandler = SetupAndOpenDialog(window, dialog); dialog.SizeChangedHandler = sizeHandler; return dialog.WaitForLoadAsync().ContinueWith(x => { if (DialogOpened != null) { window.Dispatcher.BeginInvoke(new Action(() => DialogOpened(window, new DialogStateChangedEventArgs() { }))); } return dialog.WaitForButtonPressAsync().ContinueWith(y => { //once a button as been clicked, begin removing the dialog. dialog.OnClose(); if (DialogClosed != null) { window.Dispatcher.BeginInvoke(new Action(() => DialogClosed(window, new DialogStateChangedEventArgs() { }))); } Task closingTask = (Task)window.Dispatcher.Invoke(new Func <Task>(() => dialog._WaitForCloseAsync())); return closingTask.ContinueWith <Task <LoginDialogData> >(a => { return ((Task)window.Dispatcher.Invoke(new Func <Task>(() => { window.SizeChanged -= sizeHandler; window.metroDialogContainer.Children.Remove(dialog); //remove the dialog from the container return HandleOverlayOnHide(settings, window); //window.overlayBox.Visibility = System.Windows.Visibility.Hidden; //deactive the overlay effect }))).ContinueWith(y3 => y).Unwrap(); }); }).Unwrap(); }).Unwrap().Unwrap(); })); }).Unwrap()); }
public CircleVisual(GMapMarker m, Brush background) { Marker = m; Marker.ZIndex = 100; Popup.AllowsTransparency = true; Popup.PlacementTarget = this; Popup.Placement = PlacementMode.Mouse; Popup.Child.Opacity = 0.777; SizeChanged += new SizeChangedEventHandler(CircleVisual_SizeChanged); MouseEnter += new System.Windows.Input.MouseEventHandler(CircleVisual_MouseEnter); MouseLeave += new System.Windows.Input.MouseEventHandler(CircleVisual_MouseLeave); Loaded += new RoutedEventHandler(OnLoaded); Text = "?"; StrokeArrow.EndLineCap = PenLineCap.Triangle; StrokeArrow.LineJoin = PenLineJoin.Round; RenderTransform = scale; Width = Height = 22; FontSize = (Width/1.55); Background = background; Angle = null; }
public CircleVisual(GMapMarker m, Brush background) { Marker = m; Marker.ZIndex = 100; Popup.AllowsTransparency = true; Popup.PlacementTarget = this; Popup.Placement = PlacementMode.Mouse; Popup.Child = Tooltip; Popup.Child.Opacity = 0.777; SizeChanged += new SizeChangedEventHandler(CircleVisual_SizeChanged); MouseEnter += new System.Windows.Input.MouseEventHandler(CircleVisual_MouseEnter); MouseLeave += new System.Windows.Input.MouseEventHandler(CircleVisual_MouseLeave); Loaded += new RoutedEventHandler(OnLoaded); Text = "?"; StrokeArrow.EndLineCap = PenLineCap.Triangle; StrokeArrow.LineJoin = PenLineJoin.Round; RenderTransform = scale; Width = Height = 22; FontSize = (Width / 1.55); Background = background; Angle = null; }
/// <summary> /// Closes the Popup. /// </summary> private void ClosePopup() { if (null != _popup) { _popup.IsOpen = false; _popup.Child = null; _popup = null; } if (null != _overlay) { _overlay.Children.Clear(); _overlay = null; } SizeChanged -= new SizeChangedEventHandler(HandleContextMenuOrRootVisualSizeChanged); if (null != _rootVisual) { _rootVisual.SizeChanged -= new SizeChangedEventHandler(HandleContextMenuOrRootVisualSizeChanged); } // Update IsOpen _settingIsOpen = true; IsOpen = false; _settingIsOpen = false; OnClosed(new RoutedEventArgs()); }
private void OnHostPopupOpened(object sender, object e) { // there seems to be some issue where the mesaure is happening too fast when the size // of the flyout is 0,0. This attempts to solve this. // credit to avidgator/jvlppm for suggestions on github project if (_hostPopup.ActualHeight == 0 || _hostPopup.ActualWidth == 0) { SizeChangedEventHandler updatePosition = null; updatePosition = (s, eP) => { if (eP.NewSize.Width != 0 && eP.NewSize.Height != 0) { OnHostPopupOpened(s, eP); SizeChanged -= updatePosition; } }; SizeChanged += updatePosition; } _hostPopup.HorizontalOffset = this.HorizontalOffset; _hostPopup.VerticalOffset = this.VerticalOffset; Measure(new Size(Double.PositiveInfinity, double.PositiveInfinity)); PerformPlacement(this.HorizontalOffset, this.VerticalOffset); }
public MainWindow() { InitializeComponent(); devlistCaption.CreateBinding(TextBlock.TextProperty, LocalTitles.instance, s => s.devicesList); this.CommandBindings.Add( new CommandBinding( DeviceListView.HideCommand, (s, a) => { devlist.Visibility = Visibility.Collapsed; deviceListButton.Visibility = Visibility.Visible; } ) ); deviceListButton.Command = new DelegateCommand( () => { devlist.Visibility = Visibility.Visible; deviceListButton.Visibility = Visibility.Collapsed; } ); //AppDefaults.InitConfigs(); InitPosition(); SizeChanged += new SizeChangedEventHandler((obj, evargs) => { var mvs = AppDefaults.visualSettings; mvs.WndState = this.WindowState; if (this.WindowState == System.Windows.WindowState.Maximized) { AppDefaults.UpdateVisualSettings(mvs); return; } if (this.WindowState == System.Windows.WindowState.Minimized) { AppDefaults.UpdateVisualSettings(mvs); return; } mvs.WndSize = new Rect(mvs.WndSize.X, mvs.WndSize.Y, evargs.NewSize.Width, evargs.NewSize.Height); AppDefaults.UpdateVisualSettings(mvs); }); LocationChanged += new EventHandler((obj, evargs) => { var vs = AppDefaults.visualSettings; vs.WndState = this.WindowState; if (this.WindowState == System.Windows.WindowState.Maximized) { AppDefaults.UpdateVisualSettings(vs); return; } if (this.WindowState == System.Windows.WindowState.Minimized) { AppDefaults.UpdateVisualSettings(vs); return; } vs.WndSize = new Rect(this.Left, this.Top, vs.WndSize.Width, vs.WndSize.Height); AppDefaults.UpdateVisualSettings(vs); }); }
public RibbonWindow() : base() { SizeChanged += new SizeChangedEventHandler(OnSizeChanged); HookWndProc(); RegisterCommands(); SkinManager.SkinChanged += new EventHandler(OnSkinChanged); }
public MainPage() { InitializeComponent(); SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape; SizeChanged += new SizeChangedEventHandler(BinaryClock_SizeChanged); Loaded += new RoutedEventHandler(BinaryClock_Loaded); }
public GraphicsControlBase() { Loaded += new RoutedEventHandler(XnaWindowHost_Loaded); SizeChanged += new SizeChangedEventHandler(XnaWindowHost_SizeChanged); Application.Current.Activated += new EventHandler(Current_Activated); Application.Current.Deactivated += new EventHandler(Current_Deactivated); CompositionTarget.Rendering += CompositionTarget_Rendering; }
public TiledBackground() { // create an image as the content of the control tiledImage.Stretch = Stretch.None; Content = tiledImage; // no sizechanged to override SizeChanged += new SizeChangedEventHandler(TiledBackground_SizeChanged); }
/// <summary> /// Unsets the size changed event handler. /// </summary> public void RemoveSizeChanged() { var sizeChangedEventHandler = _sizeChangedEventHandler; if (sizeChangedEventHandler != null) { SizeChanged -= sizeChangedEventHandler; } _sizeChangedEventHandler = null; }
public Viewport2D() { // ClipToBounds = true; Grid.SetColumn(this, 1); Grid.SetRow(this, 1); visible = new Rect(new Point(0, 0), new Point(1, 1)); SizeChanged += new SizeChangedEventHandler(Viewport2D_SizeChanged); UpdateTransform(); }
public Outline() { moves = new ObservableCollection<TXY>(outLineMoves); DataContext = this; fOutLineSize = 0.05; InitializeComponent(); SizeChanged += new SizeChangedEventHandler(TPill_SizeChanged); text = "0"; fKW = 1; fKH = 1; }
internal LayoutDocumentPaneControl(LayoutDocumentPane model) { if (model == null) throw new ArgumentNullException("model"); _model = model; SetBinding(ItemsSourceProperty, new Binding("Model.Children") { Source = this }); SetBinding(FlowDirectionProperty, new Binding("Model.Root.Manager.FlowDirection") { Source = this }); this.LayoutUpdated += new EventHandler(OnLayoutUpdated); SizeChanged += new SizeChangedEventHandler(LayoutDocumentPaneControl_SizeChanged); }
public UIContainer() { m_elements = new VisualCollection(this); CreateElements(); SnapsToDevicePixels = true; RenderOptions.SetEdgeMode(this, EdgeMode.Aliased); SizeChanged += new SizeChangedEventHandler((sender, e) => { VisualClip = new RectangleGeometry(new Rect(0, 0, ActualWidth, ActualHeight)); }); }
/// <summary> /// Sets and registers the event handler responsible for monitoring /// size change events. /// </summary> /// <param name="sizeChangedEventHandler">The event handler.</param> public void SetOnSizeChangedListener(SizeChangedEventHandler sizeChangedEventHandler) { var current = _sizeChangedEventHandler; if (current != null) { SizeChanged -= current; } if (sizeChangedEventHandler != null) { _sizeChangedEventHandler = sizeChangedEventHandler; SizeChanged += _sizeChangedEventHandler; } }
public GraphicsDeviceControl() { // We must be notified of the control finishing loading so we can get the GraphicsDeviceService Loaded += new System.Windows.RoutedEventHandler(XnaWindowHost_Loaded); // We must be notified of the control changing sizes so we can resize the GraphicsDeviceService SizeChanged += new SizeChangedEventHandler(XnaWindowHost_SizeChanged); // We must be notified of the application foreground status for our mouse input events Application.Current.Activated += new EventHandler(Current_Activated); Application.Current.Deactivated += new EventHandler(Current_Deactivated); // We use the CompositionTarget.Rendering event to trigger the control to draw itself CompositionTarget.Rendering += CompositionTarget_Rendering; }
public ChapterViewModel(Chapter chapter, FlipView flipView) { sizeChangedEventHandler = new SizeChangedEventHandler(textBlockResized); loadedEventHandler = new RoutedEventHandler(checkOverflow); this.flipView = flipView; this.chapter = chapter; this.Overflows = new List<RichTextBlockOverflow>(); Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; string currentChapter = (string)localSettings.Values["currentChapter"]; if (currentChapter == null || currentChapter == "") { currentChapter = "jhn.1.esv"; } ChangeChapter(currentChapter); }
public MainWindow() { InitializeComponent(); SizeChanged += new SizeChangedEventHandler(WindowSizeChangedEvent); numParticlesSlider.ValueChanged += NumParticlesValueChanged; SetNumCoresSliderProperties(); ResetSimulation(true, Convert.ToInt32(numParticlesSlider.Value)); FillDelegateLists(); algorithmList.ItemsSource = m_executeAlgorithm.Keys; m_timer.Interval = TimeSpan.FromMilliseconds(20); m_timer.Tick += new EventHandler(ComputeNextPosition); }
private FloatingWindow(DockPanel dockPanel) { Root = dockPanel; ShowInTaskbar = false; WindowStyle = WindowStyle.ToolWindow; WindowStartupLocation = WindowStartupLocation.Manual; m_dockOver = new List<IDockable>(); Loaded += new RoutedEventHandler(FloatingWindow_Loaded); Closing += new System.ComponentModel.CancelEventHandler(FloatingWindow_Closing); MouseMove += new MouseEventHandler(FloatingWindow_MouseMove); MouseUp += new MouseButtonEventHandler(FloatingWindow_MouseUp); MouseLeave += new MouseEventHandler(FloatingWindow_MouseLeave); Activated += new EventHandler(FloatingWindow_Activated); LocationChanged += new EventHandler(FloatingWindow_LocationChanged); SizeChanged += new SizeChangedEventHandler(FloatingWindow_SizeChanged); }
public SnapGrid() { LayoutUpdated += new EventHandler(SnapGrid_LayoutUpdated); SizeChanged += new SizeChangedEventHandler(SnapGrid_SizeChanged); MouseLeftButtonDown += new MouseButtonEventHandler(SnapGrid_MouseLeftButtonDown); MouseLeftButtonUp += new MouseButtonEventHandler(SnapGrid_MouseLeftButtonUp); LostMouseCapture += new MouseEventHandler(SnapGrid_LostMouseCapture); MouseMove += new MouseEventHandler(SnapGrid_MouseMove); Loaded += new RoutedEventHandler(SnapGrid_Loaded); ColumnCount = 20; RowCount = 20; ShowGridLines = true; Init(); }
/// <summary> /// Constructor /// </summary> /// <param name="dockPanel">Root dock panel</param> public TabLayout(DockPanel dockPanel) { Root = dockPanel; Header = String.Empty; Children = new ObservableCollection<DockContent>(); ItemsCount = 0; SizeChanged += new SizeChangedEventHandler(TabLayout_SizeChanged); //PreviewMouseDown += TabControl_PreviewMouseDown; MouseMove += TabControl_MouseMove; MouseUp += TabControl_MouseUp; MouseLeave += TabControl_MouseLeave; ItemsSource = Children; m_timer = new System.Timers.Timer(); m_timer.AutoReset = false; m_timer.Interval = 500; m_timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed); }
public DocumentView() { eventAggregator = IoC.Get<IEventAggregator>(); InitializeComponent(); Loaded += DocumentViewLoaded; wb.Loaded += WbLoaded; SizeChanged += new SizeChangedEventHandler(DocumentViewSizeChanged); Editor.TextArea.SelectionChanged += SelectionChanged; Editor.PreviewMouseLeftButtonUp += HandleMouseUp; CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleBold, (x, y) => ToggleBold(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleItalic, (x, y) => ToggleItalic(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleCode, (x, y) => ToggleCode(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleCodeBlock, (x, y) => ToggleCodeBlock(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.SetHyperlink, (x, y) => SetHyperlink(), CanEditDocument)); }
internal void MucConversationInit(Service service, string nick, string password) { _mucRoom = Account.Instance.JoinMuc(service, nick, password); _mucRoom.OnClickMucContact += _mucRoom_OnClickMucContact; DataContext = _mucRoom; new MucNikcnames(_text, _mucRoom); Loaded += MucConversation_Loaded; SizeChanged += new SizeChangedEventHandler(MucConversation_SizeChanged); _text.Loaded += _text_Loaded; Account.Instance.Self.PropertyChanged += Self_PropertyChanged; _timer.Interval = new TimeSpan(0,0,0,0,750); _timer.Tick += _timer_Tick; }
public PlanDesignerView() { InitializeComponent(); _scrollViewer.PreviewMouseDown += OnMouseMiddleDown; _scrollViewer.PreviewMouseUp += OnMouseMiddleUp; _scrollViewer.PreviewMouseMove += OnMiddleMouseMove; _scrollViewer.MouseLeave += OnMiddleMouseLeave; _scrollViewer.PreviewMouseWheel += OnPreviewMouseWheel; _scrollViewer.PreviewMouseLeftButtonDown += OnMouseLeftButtonDown; _scrollViewer.PreviewMouseLeftButtonUp += OnMouseLeftButtonUp; _scrollViewer.MouseMove += OnMouseMove; _scrollViewer.ScrollChanged += OnScrollViewerScrollChanged; slider.ValueChanged += OnSliderValueChanged; deviceSlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(deviceSlider_ValueChanged); Loaded += new RoutedEventHandler(OnLoaded); SizeChanged += new SizeChangedEventHandler(OnSizeChanged); }
int _trim; // as recorded in Settings #endregion Fields #region Constructors public MainWindow() { InitializeComponent(); string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); //_ntconnection = new NetworkTableConnection(); //_ntconnection.Connect(); //_smartdashboard = _ntconnection.GetTable("/SmartDashboard"); SizeChanged += new SizeChangedEventHandler(MainWindow_SizeChanged); Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); _tmppath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "tmpimg.jpg"); _direction.Background = Brushes.Firebrick; _direction.Foreground = Brushes.Yellow; _direction.FontSize = 20; _report.Background = Brushes.White; _report.TextAlignment = TextAlignment.Left; _report.FontFamily = new FontFamily("Courier New"); _report.FontSize = 16; dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1); dispatcherTimer.Start(); Left = Settings.Default.Left; Top = Settings.Default.Top; Width = Settings.Default.Width; Height = Settings.Default.Height; Start(); }
/// <summary> /// Attaches handler plot area after loading it from XAML. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); // Get reference to new ChartArea and hook its SizeChanged event PlotArea = GetTemplateChild(PlotAreaName) as Panel; if (!TemplateApplied) { TemplateApplied = true; SizeChanged += new SizeChangedEventHandler(OnSizeChanged); } }
private static Popup ShowDialog(FrameworkElement control, bool isLightDismissEnabled = false, bool isHorizontal = true, Action<Popup> closedCallback = null) { var popup = new Popup(); var parent = (FrameworkElement)Window.Current.Content; var windowActivated = new WindowActivatedEventHandler((sender, e) => { UpdatePopupControlSize(control, isHorizontal); UpdatePopupOffsets(control, isHorizontal, popup); }); var controlSizeChanged = new SizeChangedEventHandler((sender, e) => UpdatePopupOffsets(control, isHorizontal, popup)); Window.Current.Activated += windowActivated; UpdatePopupControlSize(control, isHorizontal); control.SizeChanged += controlSizeChanged; control.Tag = popup; var oldOpacity = parent.Opacity; parent.Opacity = 0.5; parent.IsHitTestVisible = false; var topAppBarVisibility = Visibility.Collapsed; var bottomAppBarVisibility = Visibility.Collapsed; if (parent is Paging.MtFrame) { var page = ((Paging.MtFrame)parent).CurrentPage.Page; if (page != null) { if (page.TopAppBar != null) { topAppBarVisibility = page.TopAppBar.Visibility; page.TopAppBar.Visibility = Visibility.Collapsed; } if (page.BottomAppBar != null) { bottomAppBarVisibility = page.BottomAppBar.Visibility; page.BottomAppBar.Visibility = Visibility.Collapsed; } } } else if (parent is Frame) { var page = ((Frame)parent).Content as Page; if (page != null) { if (page.TopAppBar != null) { topAppBarVisibility = page.TopAppBar.Visibility; page.TopAppBar.Visibility = Visibility.Collapsed; } if (page.BottomAppBar != null) { bottomAppBarVisibility = page.BottomAppBar.Visibility; page.BottomAppBar.Visibility = Visibility.Collapsed; } } } popup.Child = control; popup.IsLightDismissEnabled = isLightDismissEnabled; popup.Closed += delegate { parent.Opacity = oldOpacity; parent.IsHitTestVisible = true; if (parent is Paging.MtFrame) { var page = ((Paging.MtFrame)parent).CurrentPage.Page; if (page != null) { if (page.TopAppBar != null) page.TopAppBar.Visibility = topAppBarVisibility; if (page.BottomAppBar != null) page.BottomAppBar.Visibility = bottomAppBarVisibility; } } else if (parent is Frame) { var page = ((Frame)parent).Content as Page; if (page != null) { if (page.TopAppBar != null) page.TopAppBar.Visibility = topAppBarVisibility; if (page.BottomAppBar != null) page.BottomAppBar.Visibility = bottomAppBarVisibility; } } Window.Current.Activated -= windowActivated; control.SizeChanged -= controlSizeChanged; if (closedCallback != null) closedCallback(popup); }; popup.IsOpen = true; popup.Tag = 0.0; InputPane.GetForCurrentView().Showing += (s, args) => UpdateElementLocation(popup); InputPane.GetForCurrentView().Hiding += (s, args) => { popup.VerticalOffset += (double)popup.Tag; popup.Tag = 0.0; }; return popup; }
public static Popup ShowPane(FrameworkElement control, bool showLeft = true, Action<Popup> closedCallback = null) { var bounds = Window.Current.Bounds; control.Height = bounds.Height; var popup = new Popup(); var del = new WindowActivatedEventHandler((sender, e) => { if (e.WindowActivationState == CoreWindowActivationState.Deactivated) popup.IsOpen = false; }); var del2 = new SizeChangedEventHandler((sender, e) => { if (!showLeft) popup.HorizontalOffset = bounds.Left + (bounds.Width - control.ActualWidth); }); Window.Current.Activated += del; control.SizeChanged += del2; popup.IsLightDismissEnabled = true; popup.Child = control; popup.Closed += delegate { Window.Current.Activated -= del; control.SizeChanged -= del2; if (closedCallback != null) closedCallback(popup); }; popup.IsOpen = true; return popup; }