void Main_DuplicateMapView_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) { var vm = e.Parameter as MapViewModel; if (vm != null) { var mapView = new MapView { DataContext = vm, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Margin = new Thickness(0, 0, 3, 0), MapImage = { Stretch = Stretch.Uniform, MinWidth = 500 } }; var newPlotWindow = new FloatableWindow() { Name = "wndMapView" + _numMapViews++, Content = mapView, ParentLayoutRoot = this.layoutRoot, Background = new SolidColorBrush(Colors.White), VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(0), Width = 700, Height = 540 }; newPlotWindow.Show(); } }
void Main_DuplicatePlotView_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) { var vm = e.Parameter as PlotViewModel; if (vm != null) { var plotView = new PlotView { DataContext = vm, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Margin = new Thickness(0, 0, 3, 0) }; var newPlotWindow = new FloatableWindow() { Name = "wndPlotView" + _numPlotViews++, Content = plotView, ParentLayoutRoot = this.layoutRoot, Background = new SolidColorBrush(Colors.White), VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left }; newPlotWindow.Show(); } }
public SolverDemoView() { InitializeComponent(); _numPlotViews = 0; _numMapViews = 0; Current = this; _floatableWindow = new FloatableWindow() { Name = "wndIsolatedStorageView", Content = new IsolatedStorageView(), ParentLayoutRoot = this.layoutRoot, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; #if WHITELIST tabFem.Visibility = Visibility.Collapsed; #endif Commands.IsoStorage_IncreaseSpaceQuery.Executed += IsoStorage_IncreaseSpaceQuery_Executed; Commands.IsoStorage_IncreaseSpaceQuery.Executed += IsoStorage_IncreaseSpaceQuery_Executed; Commands.Main_DuplicatePlotView.Executed += Main_DuplicatePlotView_Executed; Commands.Main_DuplicateMapView.Executed += Main_DuplicateMapView_Executed; }
/// <summary> /// Initializes a new instance of the /// <see cref="T:System.Windows.Automation.Peers.FloatableWindowAutomationPeer" /> /// class. /// </summary> /// <param name="owner"> /// The <see cref="T:System.Windows.Controls.FloatableWindow" /> to /// associate with this /// <see cref="T:System.Windows.Automation.Peers.FloatableWindowAutomationPeer" />. /// </param> public FloatableWindowAutomationPeer(FloatableWindow owner) : base(owner) { if (owner == null) { throw new ArgumentNullException("owner"); } this.RefreshIsTopMostProperty(); }
/// <summary> /// Causes the current window to be re-z-indexed to the top most window. /// </summary> public void BringToFront() { Canvas.SetZIndex(this, FloatableWindow.GetNextZ()); //// Search the top most "Window" and swap z-indexes. //Panel parent = this.Parent as Panel; // Panel is the base for Canvas, Grid and StackPanel. //if (parent != null) //{ // int currentZIndex = (int)this.GetValue(Canvas.ZIndexProperty); // var child = (from c in parent.Children where c is Window select c as Window).OrderByDescending(c => (int)c.GetValue(Canvas.ZIndexProperty)).FirstOrDefault(); // if (child != null) // { // int topZIndex = (int)child.GetValue(Canvas.ZIndexProperty); // if (topZIndex == 0) topZIndex = 1; // If the value has not been set then just default it to 1. // if (topZIndex > currentZIndex) // { // this.SetValue(Canvas.ZIndexProperty, topZIndex); // child.SetValue(Canvas.ZIndexProperty, currentZIndex); // } // } //} }
private void BringToFront() { var z = FloatableWindow.GetNextZ(); this.SetValue(Canvas.ZIndexProperty, z); }
/// <summary> /// Check if there are drop zones an specific position. /// </summary> /// <param name="e">The mouse event args.</param> /// <returns>A list of possible drop zones.</returns> private FrameworkElement GetDropZone(MouseEventArgs e) { IList <FrameworkElement> dropZonesAtCurrentCord = new List <FrameworkElement>(); if (this.DragPopup != null && this.DragPopupChild != null && this.DragPopupChild.Children.Count > 0) { DragDropControl dragDropControl = this.DragPopupChild.Children[0] as DragDropControl; if (dragDropControl != null) { IList <FrameworkElement> invalidDropZones = new List <FrameworkElement>(); foreach (FrameworkElement frameworkElement in DragDropManager.DropZones) { IDropInfo dropInfo = DragDropManager.GetDropInfo(frameworkElement); Type dragSourceType = dragDropControl.DragContent.GetType(); try { Point dropPoint = e.GetPosition(frameworkElement); if (frameworkElement.Visibility == Visibility.Visible && frameworkElement.ActualHeight != 0 && frameworkElement.ActualWidth != 0 && (dropPoint.X >= 0 && dropPoint.X <= frameworkElement.ActualWidth) && (dropPoint.Y >= 0 && dropPoint.Y <= frameworkElement.ActualHeight) && dropInfo.AllowedDragTypes.Contains(dragSourceType)) { dropZonesAtCurrentCord.Add(frameworkElement); } } catch (Exception) { invalidDropZones.Add(frameworkElement); } } foreach (FrameworkElement element in invalidDropZones) { DragDropManager.DropZones.Remove(element); } invalidDropZones.Clear(); } } int maxIndex = -1; FrameworkElement topMostDropZone = null; foreach (FrameworkElement dropZone in dropZonesAtCurrentCord) { FloatableWindow parentWindow = dropZone.GetParentControl <FloatableWindow>(); int canvasZIndex = Canvas.GetZIndex(parentWindow); if (canvasZIndex > maxIndex) { maxIndex = canvasZIndex; topMostDropZone = dropZone; } } return(topMostDropZone); }
private void ShowPopup(string viewName, Uri uri, string title, Action completedAction, bool maximize = false, bool isModal = false) { if (!_popupWindows.ContainsKey(viewName)) { var navigationContext = new NavigationContext(null, uri); object view; try { view = _regionNavigationContentLoader.LoadContent(new Region(), navigationContext); } catch (Exception e) { OnLoadContentException(e); view = null; } if (view != null) { if (view is FrameworkElement) { var navigatable = (view as FrameworkElement).DataContext as INavigationAware; if (navigatable != null) { navigatable.OnNavigatedTo(navigationContext); } } var configurationBehaviorService = new ConfigurationBehaviorService(); if (isModal) { var popupWindow = new PopupWindow(); popupWindow.IsMaximized = maximize; if (title == null) { SetupPopupWindowTitle(popupWindow, view); } else { popupWindow.Title = title; } popupWindow.SubContent = view; popupWindow.IsModal = isModal; _popupWindows.Add(viewName, popupWindow); configurationBehaviorService.Watch(popupWindow); EventHandler closedEventHandler = null; closedEventHandler = (s, e) => { popupWindow.Closed -= closedEventHandler; configurationBehaviorService.Stop(); _popupWindows.Remove(viewName); completedAction.Invoke(); }; popupWindow.Closed += closedEventHandler; popupWindow.Show(); } else { var floatableWindow = new FloatableWindow(); if (floatableWindow.Title == null) { SetupPopupWindowTitle(floatableWindow, view); } else { floatableWindow.Title = title; } floatableWindow.Content = view; _popupWindows.Add(viewName, floatableWindow); configurationBehaviorService.Watch(floatableWindow); EventHandler closedEventHandler = null; closedEventHandler = (s, e) => { floatableWindow.Closed -= closedEventHandler; configurationBehaviorService.Stop(); _popupWindows.Remove(viewName); completedAction.Invoke(); }; floatableWindow.Closed += closedEventHandler; floatableWindow.Show(); } } } }
private void ShowPopup(string viewName, Uri uri, string title, Action completedAction, bool maximize = false, bool isModal = false) { if ( !_popupWindows.ContainsKey ( viewName ) ) { var navigationContext = new NavigationContext ( null, uri ); object view; try { view = _regionNavigationContentLoader.LoadContent ( new Region (), navigationContext ); } catch ( Exception e ) { OnLoadContentException ( e ); view = null; } if ( view != null ) { if ( view is FrameworkElement ) { var navigatable = ( view as FrameworkElement ).DataContext as INavigationAware; if ( navigatable != null ) { navigatable.OnNavigatedTo ( navigationContext ); } } var configurationBehaviorService = new ConfigurationBehaviorService(); if ( isModal ) { var popupWindow = new PopupWindow(); popupWindow.IsMaximized = maximize; if (title == null) { SetupPopupWindowTitle ( popupWindow, view ); } else { popupWindow.Title = title; } popupWindow.SubContent = view; popupWindow.IsModal = isModal; _popupWindows.Add(viewName, popupWindow); configurationBehaviorService.Watch(popupWindow); EventHandler closedEventHandler = null; closedEventHandler = (s, e) => { popupWindow.Closed -= closedEventHandler; configurationBehaviorService.Stop(); _popupWindows.Remove(viewName); completedAction.Invoke(); }; popupWindow.Closed += closedEventHandler; popupWindow.Show(); } else { var floatableWindow = new FloatableWindow (); if( floatableWindow.Title == null) { SetupPopupWindowTitle ( floatableWindow, view ); } else { floatableWindow.Title = title; } floatableWindow.Content = view; _popupWindows.Add(viewName, floatableWindow); configurationBehaviorService.Watch(floatableWindow); EventHandler closedEventHandler = null; closedEventHandler = (s, e) => { floatableWindow.Closed -= closedEventHandler; configurationBehaviorService.Stop(); _popupWindows.Remove(viewName); completedAction.Invoke(); }; floatableWindow.Closed += closedEventHandler; floatableWindow.Show(); } } } }
public FloatableWindowAdapter() { this.window = new FloatableWindow(); this.window.Closed += this.WindowClosed; this.window.Closing += this.WindowClosing; }