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();
            }
        }
        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();
            }
        }
Exemplo n.º 3
0
        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();
                    }
                }
            }
        }
Exemplo n.º 4
0
        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();
                    }
                }
            }
        }