示例#1
0
 public WpfElementHost()
 {
     _elementContainer = new WpfElementContainer(this);
     _decorator = new AdornerDecorator();
     _decorator.Child = _elementContainer;
     FocusManager.SetIsFocusScope(_decorator, true);
 }
示例#2
0
        public void InitializeComponent()
        {
            Background          = Brushes.Transparent;
            SnapsToDevicePixels = true;
            UseLayoutRounding   = true;

            scrollContainer = new ScrollViewer()
            {
                CanContentScroll = true,
                HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
                VerticalScrollBarVisibility   = ScrollBarVisibility.Auto
            };

            canvas = new GridCanvas()
            {
                HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
                VerticalAlignment   = System.Windows.VerticalAlignment.Top
            };

            var adornerDecorator = new System.Windows.Documents.AdornerDecorator();

            adornerDecorator.Child = scrollContainer;

            this.adornerLayer = adornerDecorator.AdornerLayer;

            scrollContainer.Content = canvas;

            this.Content = adornerDecorator;
        }
示例#3
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.baseGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 2:
                this.Navigation = ((System.Windows.Controls.ContentControl)(target));
                return;

            case 3:
                this.Breadcrumb = ((System.Windows.Controls.ContentControl)(target));
                return;

            case 4:
                this.PART_DragDropAdorner = ((System.Windows.Documents.AdornerDecorator)(target));
                return;

            case 5:
                this.DirectoryTree = ((System.Windows.Controls.ContentControl)(target));
                return;

            case 6:
                this.FileList = ((System.Windows.Controls.ContentControl)(target));
                return;

            case 7:
                this.Statusbar = ((System.Windows.Controls.ContentControl)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#4
0
        public TransitionPresenter()
        {
            _children = new UIElementCollection(this, null);
              ContentPresenter currentContent = new ContentPresenter();
              _currentHost = new AdornerDecorator();
              _currentHost.Child = currentContent;
              _children.Add(_currentHost);

              ContentPresenter previousContent = new ContentPresenter();
              _previousHost = new AdornerDecorator();
              _previousHost.Child = previousContent;
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.PART_DragDropAdorner = ((System.Windows.Documents.AdornerDecorator)(target));
                return;

            case 2:
                this.Items = ((FileExplorer.WPF.UserControls.TabControlEx)(target));
                return;

            case 3:
                this.PART_TitleBar = ((FileExplorer.WPF.UserControls.Titlebar)(target));
                return;
            }
            this._contentLoaded = true;
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Navigation = ((System.Windows.Controls.ContentControl)(target));
                return;

            case 2:
                this.Breadcrumb = ((System.Windows.Controls.ContentControl)(target));
                return;

            case 3:
                this.PART_DragDropAdorner = ((System.Windows.Documents.AdornerDecorator)(target));
                return;

            case 4:
                this.DirectoryTree = ((System.Windows.Controls.ContentControl)(target));
                return;

            case 5:
                this.FileList = ((System.Windows.Controls.ContentControl)(target));
                return;

            case 6:
                this.Cancel = ((System.Windows.Controls.Button)(target));
                return;

            case 7:
                this.Open = ((System.Windows.Controls.Button)(target));
                return;

            case 8:
                this.Save = ((System.Windows.Controls.Button)(target));
                return;

            case 9:
                this.tboxFileName = ((System.Windows.Controls.TextBox)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#7
0
        public FilterButton()
        {
            decorator = new AdornerDecorator();

            panel = new StackPanel
                                   {
                                           Orientation = Orientation.Vertical,
                                           Margin = new System.Windows.Thickness(0)
                                   };

            image = new Image {Margin = new System.Windows.Thickness(0)};
            panel.Children.Add(image);

            textBlock = new TextBlock{HorizontalAlignment =HorizontalAlignment.Center};
            panel.Children.Add(textBlock);

            Focusable = false;
            decorator.Child = panel;
            this.Content = decorator;
            AdornerLayer al = decorator.AdornerLayer;
            counter = new CounterAdorner(panel);
            al.Add(counter);
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _adornerDecorator = GetTemplateChild("PART_AdornerDecorator") as AdornerDecorator;

            ChangeAdornersCount(0);

            if (_adornerDecorator != null)
            {
                this.SetValue(ContentLayerProperty, _adornerDecorator.Child);
            }
        }
示例#9
0
        private void BeginTransition()
        {
            TransitionSelector selector = TransitionSelector;

              Transition transition = selector != null ?
              selector.SelectTransition(CurrentContentPresenter.Content, Content) :
              Transition;

              if (transition != null) {
            // Swap content presenters
            AdornerDecorator temp = _previousHost;
            _previousHost = _currentHost;
            _currentHost = temp;
              }

              ContentPresenter currentContent = CurrentContentPresenter;
              // Set the current content
              currentContent.Content = Content;
              currentContent.ContentTemplate = ContentTemplate;
              currentContent.ContentTemplateSelector = ContentTemplateSelector;

              if (transition != null) {
            ContentPresenter previousContent = PreviousContentPresenter;

            if (transition.IsNewContentTopmost)
              Children.Add(_currentHost);
            else
              Children.Insert(0, _currentHost);

            IsTransitioning = true;
            _activeTransition = transition;
            CoerceValue(TransitionProperty);
            CoerceValue(ClipToBoundsProperty);
            transition.BeginTransition(this, previousContent, currentContent);
              }
        }
        private void CreateScrollbars()
        {
            if (Parent != null && !(Parent is AdornerDecorator) && (Parent is Grid || Parent is SimpleView || Parent is ContentControl))
            {
                // We need to make sure this control is directly within an adorner decorator
                // so elements in the adorner layer (scroll bars) behave correctly in the Z-Order
                var decorator = new AdornerDecorator
                {
                    VerticalAlignment = VerticalAlignment,
                    HorizontalAlignment = HorizontalAlignment,
                    Margin = new Thickness(Margin.Left, Margin.Top, Margin.Right, Margin.Bottom),
                    Width = Width,
                    Height = Height
                };

                Grid.SetColumn(decorator, Grid.GetColumn(this));
                Grid.SetRow(decorator, Grid.GetRow(this));
                Grid.SetColumnSpan(decorator, Grid.GetColumnSpan(this));
                Grid.SetRowSpan(decorator, Grid.GetRowSpan(this));

                SimpleView.SetUIElementTitle(decorator, SimpleView.GetUIElementTitle(this));
                SimpleView.SetUIElementType(decorator, SimpleView.GetUIElementType(this));

                Margin = new Thickness(0d);
                VerticalAlignment = VerticalAlignment.Stretch;
                HorizontalAlignment = HorizontalAlignment.Stretch;

                var parentPanel = Parent as Panel;
                if (parentPanel != null)
                {
                    var childItemIndex = -1;
                    var found = false;
                    foreach (var child in parentPanel.Children)
                    {
                        childItemIndex++;
                        if (child == this)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        parentPanel.Children.Remove(this);
                        parentPanel.Children.Insert(childItemIndex, decorator);
                        decorator.Child = this;
                    }
                }
                else
                {
                    var parentContent = Parent as ContentControl;
                    if (parentContent != null)
                    {
                        parentContent.Content = null;
                        parentContent.Content = decorator;
                        decorator.Child = this;
                    }
                }
            }

            if (_scrollbarsCreated) return;
            _adorner = AdornerLayer.GetAdornerLayer(this);
            if (_adorner == null) return;
            _adorner.Add(new BidirectionalStackPanelScrollAdorner(this, _scrollHorizontal, _scrollVertical) {Visibility = Visibility.Visible});
            _scrollHorizontal.ValueChanged += (s, e) => Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(DispatchInvalidateScroll));
            _scrollVertical.ValueChanged += (s, e) => Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(DispatchInvalidateScroll));
            _scrollbarsCreated = true;
        }
        ///<summary> 
        /// For a given page # and a page, returns a page that include the original
        /// page along with any annotations that are displayed on that page.
        /// </summary>
        /// <param name="page"></param> 
        /// <param name="pageNumber"></param>
        private DocumentPage ComposePageWithAnnotationVisuals(int pageNumber, DocumentPage page) 
        { 
            // Need to store these because our current highlight mechanism
            // causes the page to be disposed 
            Size tempSize = page.Size;

            AdornerDecorator decorator = new AdornerDecorator();
            decorator.FlowDirection = _flowDirection; 
            DocumentPageView dpv = new DocumentPageView();
            dpv.UseAsynchronousGetPage = false; 
            dpv.DocumentPaginator = _originalPaginator; 
            dpv.PageNumber = pageNumber;
            decorator.Child = dpv; 

            // Arrange the first time to get the DPV setup right
            decorator.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            decorator.Arrange(new Rect(decorator.DesiredSize)); 
            decorator.UpdateLayout();
 
            // Create a new one for each page because it keeps a cache of annotation components 
            // and we don't want to be holding them in memory once the page is no longer used
            AnnotationComponentManager manager = new MS.Internal.Annotations.Component.AnnotationComponentManager(null); 

            // Setup DPs and processors for annotation handling.  If the service isn't already
            // enabled the processors will be registered by the service when it is enabled.
            if (_isFixedContent) 
            {
                // Setup service to look for FixedPages in the content 
                AnnotationService.SetSubTreeProcessorId(decorator, FixedPageProcessor.Id); 
                // If the service is already registered, set it up for fixed content
                _locatorManager.RegisterSelectionProcessor(new FixedTextSelectionProcessor(), typeof(TextRange)); 
            }
            else
            {
                // Setup up an initial DataId used to identify the document 
                AnnotationService.SetDataId(decorator, "FlowDocument");
                _locatorManager.RegisterSelectionProcessor(new TextViewSelectionProcessor(), typeof(DocumentPageView)); 
                // Setup the selection processor, pre-targeting it at a specific DocumentPageView 
                TextSelectionProcessor textSelectionProcessor = new TextSelectionProcessor();
                textSelectionProcessor.SetTargetDocumentPageView(dpv); 
                _locatorManager.RegisterSelectionProcessor(textSelectionProcessor, typeof(TextRange));
            }

            // Get attached annotations for the page 
            IList<IAttachedAnnotation> attachedAnnotations = ProcessAnnotations(dpv);
 
            // Now make sure they have a visual component added to the DPV via the component manager 
            foreach (IAttachedAnnotation attachedAnnotation in attachedAnnotations)
            { 
                if (attachedAnnotation.AttachmentLevel != AttachmentLevel.Unresolved && attachedAnnotation.AttachmentLevel != AttachmentLevel.Incomplete)
                {
                    manager.AddAttachedAnnotation(attachedAnnotation, false);
                } 
            }
 
            // Update layout a second time to get the annotations layed out correctly 
            decorator.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            decorator.Arrange(new Rect(decorator.DesiredSize)); 
            decorator.UpdateLayout();

/*          Look into using the VisualBrush in order to get a dead page instead of a live one...
            VisualBrush visualBrush = new VisualBrush(decorator); 
            Rectangle rectangle = new Rectangle();
            rectangle.Fill = visualBrush; 
            rectangle.Margin = new Thickness(0); 
*/
 
            return new AnnotatedDocumentPage(page, decorator, tempSize, new Rect(tempSize), new Rect(tempSize));
        }
示例#12
0
        public void InitializeComponent()
        {
            Background = Brushes.Transparent;
            SnapsToDevicePixels = true;
            UseLayoutRounding = true;

            scrollContainer = new ScrollViewer() {
                CanContentScroll = true,
                HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
                VerticalScrollBarVisibility = ScrollBarVisibility.Auto
            };

            canvas = new GridCanvas() {
                HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
                VerticalAlignment = System.Windows.VerticalAlignment.Top
            };

            var adornerDecorator = new System.Windows.Documents.AdornerDecorator();
            adornerDecorator.Child = scrollContainer;

            this.adornerLayer = adornerDecorator.AdornerLayer;

            scrollContainer.Content = canvas;

            this.Content = adornerDecorator;
        }
示例#13
0
 public void SetUp()
 {
     _decorator = new AdornerDecorator();
     _layer = _decorator.AdornerLayer;
 }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call
        ///     <see
        ///         cref="M:System.Windows.FrameworkElement.ApplyTemplate" />
        /// .
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (this.adornerLayer == null)
            {
                this.adornerLayer = this.Template.FindName(PartAdornerLayer, this) as AdornerDecorator;
                if (this.adornerLayer != null)
                {
                    this.adornerLayer.Child = this.viewport;
                }
            }

            if (this.adornerLayer == null)
            {
                throw new HelixToolkitException("{0} is missing from the template.", PartAdornerLayer);
            }

            if (this.cameraController == null)
            {
                this.cameraController = this.Template.FindName(PartCameraController, this) as CameraController;
                if (this.cameraController != null)
                {
                    this.cameraController.Viewport = this.Viewport;
                    this.cameraController.LookAtChanged += (s, e) => this.OnLookAtChanged();
                    this.cameraController.ZoomedByRectangle += (s, e) => this.OnZoomedByRectangle();
                }
            }

            if (this.cameraController == null)
            {
                throw new HelixToolkitException("{0} is missing from the template.", PartCameraController);
            }

            if (this.coordinateView == null)
            {
                this.coordinateView = this.Template.FindName(PartCoordinateView, this) as Viewport3D;

                this.coordinateSystemLights = new Model3DGroup();

                // coordinateSystemLights.Children.Add(new DirectionalLight(Colors.White, new Vector3D(1, 1, 1)));
                // coordinateSystemLights.Children.Add(new AmbientLight(Colors.DarkGray));
                this.coordinateSystemLights.Children.Add(new AmbientLight(Colors.LightGray));

                if (this.coordinateView != null)
                {
                    this.coordinateView.Camera = new PerspectiveCamera();
                    this.coordinateView.Children.Add(new ModelVisual3D { Content = this.coordinateSystemLights });
                }
            }

            if (this.coordinateView == null)
            {
                throw new HelixToolkitException("{0} is missing from the template.", PartCoordinateView);
            }

            if (this.viewCubeViewport == null)
            {
                this.viewCubeViewport = this.Template.FindName(PartViewCubeViewport, this) as Viewport3D;

                this.viewCubeLights = new Model3DGroup();
                this.viewCubeLights.Children.Add(new AmbientLight(Colors.White));
                if (this.viewCubeViewport != null)
                {
                    this.viewCubeViewport.Camera = new PerspectiveCamera();
                    this.viewCubeViewport.Children.Add(new ModelVisual3D { Content = this.viewCubeLights });
                    this.viewCubeViewport.MouseEnter += this.ViewCubeViewportMouseEnter;
                    this.viewCubeViewport.MouseLeave += this.ViewCubeViewportMouseLeave;
                }

                this.viewCube = this.Template.FindName(PartViewCube, this) as ViewCubeVisual3D;
                if (this.viewCube != null)
                {
                    this.viewCube.Viewport = this.Viewport;
                }
            }

            // update the coordinateview camera
            this.OnCameraChanged();

            // add the default headlight
            this.OnHeadlightChanged();
            base.OnApplyTemplate();
        }
示例#15
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate" />.
        /// </summary>
        /// <exception cref="HelixToolkitException">{0} is missing from the template.</exception>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            this.RenderHost = this.GetTemplateChild("PART_Canvas") as DPFCanvas;
            if (this.RenderHost != null)
            {
                this.RenderHost.Renderable = this;
            }

            if (this.adornerLayer == null)
            {
                this.adornerLayer = this.Template.FindName(PartAdornerLayer, this) as AdornerDecorator;
            }

            if (this.adornerLayer == null)
            {
                throw new HelixToolkitException("{0} is missing from the template.", PartAdornerLayer);
            }

            if (this.coordinateView == null)
            {
                this.coordinateView = this.Template.FindName(PartCoordinateView, this) as Viewport3D;

                this.coordinateSystemLights = new Model3DGroup();

                // coordinateSystemLights.Children.Add(new DirectionalLight(Colors.White, new Vector3D(1, 1, 1)));
                // coordinateSystemLights.Children.Add(new AmbientLight(Colors.DarkGray));
                this.coordinateSystemLights.Children.Add(new System.Windows.Media.Media3D.AmbientLight(Colors.LightGray));

                if (this.coordinateView != null)
                {
                    this.coordinateView.Camera = new System.Windows.Media.Media3D.PerspectiveCamera();
                    this.coordinateView.Children.Add(new ModelVisual3D { Content = this.coordinateSystemLights });
                }
            }

            if (this.coordinateView == null)
            {
                throw new HelixToolkitException("{0} is missing from the template.", PartCoordinateView);
            }

            if (this.viewCubeViewport == null)
            {
                this.viewCubeViewport = this.Template.FindName(PartViewCubeViewport, this) as Viewport3D;

                this.viewCubeLights = new Model3DGroup();
                this.viewCubeLights.Children.Add(new System.Windows.Media.Media3D.AmbientLight(Colors.White));
                if (this.viewCubeViewport != null)
                {
                    this.viewCubeViewport.Camera = new System.Windows.Media.Media3D.PerspectiveCamera();
                    this.viewCubeViewport.Children.Add(new ModelVisual3D { Content = this.viewCubeLights });
                    this.viewCubeViewport.MouseEnter += this.ViewCubeViewportMouseEnter;
                    this.viewCubeViewport.MouseLeave += this.ViewCubeViewportMouseLeave;
                }

                this.viewCube = this.Template.FindName(PartViewCube, this) as ViewCubeVisual3D;
                if (this.viewCube != null)
                {
                    this.viewCube.Clicked += this.ViewCubeClicked;

                    // this.viewCube.Viewport = this.Viewport;
                }
            }

            // update the coordinateview camera
            this.OnCameraChanged();
        }
        /// <summary>
        /// Kaldes for at skifte til et andet view. Parameter er typen på den viewmodel man vil have vist.
        /// Det passende view findes ved at generere det matchende navn ud fra viewmodelnavnet, og 
        /// lave en instans af typen med det genererede navn, hvorefter viewet sættes som content i root vinduet.
        /// Desuden laves en instans af viewmodel'en, og denne sættes som datacontext på viewet.
        /// Navn genereres f.eks. som: CustomerListViewModel -> CustomerListView.
        /// </summary>
        public void NavigateTo(Type viewModelType, object parameter = null)
        {
            Guard.AgainstNull(() => viewModelType);

            if (_viewModelFactory == null)
                throw new InvalidOperationException("ViewModelFactory not defined. Must call 'Init' before use.");

            if (_currentViewModel != null && _currentViewModel.GetType() == viewModelType)
                return;

            AdornerDecorator view;

            if (!_viewCache.TryGetValue(viewModelType, out view))
            {
                var viewModelName = viewModelType.Name;

                if (!viewModelName.EndsWith(ViewModelSuffix))
                {
                    throw new InvalidOperationException(
                        string.Format("Can't navigate to view. Invalid viewmodel name: '{0}'", viewModelName));
                }

                var viewName = viewModelName.Substring(0, viewModelName.Length - ViewModelSuffix.Length);
                var viewType = _viewTypes.SingleOrDefault(p => p.Name == viewName);

                if (viewType == null)
                {
                    throw new InvalidOperationException(
                        string.Format("Can't navigate to view. No view found with name: '{0}'", viewName));
                }

                var userControl = Activator.CreateInstance(viewType) as UserControl;

                if (userControl == null)
                {
                    throw new InvalidOperationException(
                        string.Format("Can't navigate to view. Found view is not a usercontrol: '{0}'", viewName));
                }

                // Tilføjer selve viewet (usercontrollen) til en AdornerDecorator, som så bruges som content.
                // I nogle tilfælde virker ting der benytter adorner layer ikke korrekt ellers. (F.eks. validationerrortemplates).
                view = new AdornerDecorator();
                view.Child = userControl;
                view.DataContext = _viewModelFactory(viewModelType);
                _viewCache[viewModelType] = view;
            }

            var viewModel = view.DataContext as ViewModelBase;

            if (viewModel == null)
                throw new InvalidOperationException(
                    string.Format("The views datacontext is not a viewmodel: '{0}'", viewModelType.Name));

            _nextViewModel = viewModel;

            parameter = FindAndUpdateCachedParameter(parameter, viewModelType);
            viewModel.WasNavigatedTo(parameter);
            UpdateNavigationStack(viewModel);
            UpdateSelectedGlobalButton(viewModelType);
            CurrentPageTitle = (viewModel.PageTitle ?? "MISSING PAGE TITLE!!").ToUpper();
            CurrentPageSubTitle = viewModel.PageSubTitle;
            CanCurrentViewNavigateBack = viewModel.IsBackNavigationEnabled;
            CurrentView = view;

            _currentViewModel = viewModel;
            _nextViewModel = null;
        }
示例#17
0
        internal static void OnVisualChanged(Object sender, DependencyPropertyChangedEventArgs e)
        {
            InteractiveVisual3D imv3D = ((InteractiveVisual3D)sender);

            if (imv3D.InternalVisual != null)
            {
                if (((AdornerDecorator)imv3D.InternalVisual).Child is VisualDecorator)
                {
                    VisualDecorator oldVisualDecorator = (VisualDecorator)((AdornerDecorator)imv3D.InternalVisual).Child;
                    oldVisualDecorator.Content = null;
                }

                ((AdornerDecorator)imv3D.InternalVisual).Child = null;
            }

            // so that the patterns on visuals caused by tabbing, etc... work, 
            // we put an adorner layer here so that anything adorned gets adorned 
            // within the visual and not at the adorner layer on the window
            AdornerDecorator ad = new AdornerDecorator();

            UIElement adornerDecoratorChild;
            if (imv3D.Visual is UIElement)
            {
                adornerDecoratorChild = (UIElement)imv3D.Visual;
            }
            else
            {
                VisualDecorator visDecorator = new VisualDecorator();
                visDecorator.Content = imv3D.Visual;
                adornerDecoratorChild = visDecorator;
            }

            ad.Child = adornerDecoratorChild;
            imv3D._internalVisual = ad;
            imv3D.InternalVisualBrush.Visual = imv3D.InternalVisual;            
        }
示例#18
0
        public override void OnApplyTemplate()
        {
            if (adornerLayer == null)
            {
                adornerLayer = Template.FindName(PART_ADORNER_LAYER, this) as AdornerDecorator;
                if (adornerLayer != null)
                    adornerLayer.Child = viewport;
            }
            Debug.Assert(adornerLayer != null, String.Format("{0} is missing from the template.", PART_ADORNER_LAYER));

            if (cameraController == null)
            {
                cameraController = Template.FindName(PART_CAMERA_CONTROLLER, this) as CameraController;
                if (cameraController != null)
                {
                    cameraController.Viewport = Viewport;
                    cameraController.SelectionChanged += CameraControllerSelectionChanged;
                }
            }
            Debug.Assert(cameraController != null,
                         String.Format("{0} is missing from the template.", PART_CAMERA_CONTROLLER));

            if (coordinateView == null)
            {
                coordinateView = Template.FindName(PART_COORDINATE_VIEW, this) as Viewport3D;

                coordinateSystemLights = new Model3DGroup();
                coordinateSystemLights.Children.Add(new DirectionalLight(Colors.White, new Vector3D(1, 1, 1)));
                coordinateSystemLights.Children.Add(new AmbientLight(Colors.DarkGray));
                if (coordinateView != null)
                {
                    coordinateView.Camera = new PerspectiveCamera();
                    coordinateView.Children.Add(new ModelVisual3D { Content = coordinateSystemLights });
                }
            }
            Debug.Assert(coordinateView != null, String.Format("{0} is missing from the template.", PART_COORDINATE_VIEW));

            if (viewCubeView == null)
            {
                viewCubeView = Template.FindName(PART_VIEW_CUBE_VIEW, this) as Viewport3D;

                viewCubeLights = new Model3DGroup();
                // _viewCubeLights.Children.Add(new DirectionalLight(Colors.White, new Vector3D(1, 1, 1)));
                viewCubeLights.Children.Add(new AmbientLight(Colors.White));
                if (viewCubeView != null)
                {
                    viewCubeView.Camera = new PerspectiveCamera();
                    viewCubeView.Children.Add(new ModelVisual3D { Content = viewCubeLights });
                    viewCubeView.MouseEnter += ViewCubeViewMouseEnter;
                    viewCubeView.MouseLeave += ViewCubeViewMouseLeave;
                }
                viewCube = Template.FindName(PART_VIEW_CUBE, this) as ViewCubeVisual3D;
                if (viewCube != null)
                    viewCube.Viewport = Viewport;
            }
            Debug.Assert(coordinateView != null, String.Format("{0} is missing from the template.", PART_COORDINATE_VIEW));

            // update the coordinateview camera
            OnCameraChanged();

            // add the default headlight
            OnHeadlightChanged();
            base.OnApplyTemplate();
        }
示例#19
0
    public override void OnApplyTemplate()
    {
      DataGridContext dataGridContext = DataGridControl.GetDataGridContext( this );

      DataGridControl parentGrid = ( dataGridContext != null )
        ? dataGridContext.DataGridControl
        : null;

      if( parentGrid == null )
      {
        this.SetValue( ParentDataGridControlPropertyKey, this );
      }

      base.OnApplyTemplate();

      m_scrollViewer = this.Template.FindName( "PART_ScrollViewer", this ) as ScrollViewer;
      m_dragDropAdornerDecorator = this.Template.FindName( "PART_DragDropAdornerDecorator", this ) as AdornerDecorator;

      this.CustomItemContainerGenerator.InvalidateIsInUse();

      m_itemsHost = null;

      Xceed.Wpf.DataGrid.Views.ViewBase view = this.GetView();

      if( view.UseDefaultHeadersFooters )
        view.InvokeAddDefaultHeadersFooters();

      // Cache if the view requires to preserve container size
      this.ViewPreservesContainerSize = view.PreserveContainerSize;

      // Notify the template was reapplied
      if( this.TemplateApplied != null )
        this.TemplateApplied( this, EventArgs.Empty );

    }
示例#20
0
		/// <summary>
		/// Initializes or returns an existing adorner layer.
		/// </summary>
		/// <exception cref="NullReferenceException">
		/// Throws NullReferenceException when adorner layer still isn't initialized.
		/// </exception>
		/// <returns>Returns adorner layer of main window.</returns>
		private AdornerLayer InitializeAdornerLayer()
		{
			var mainWindow = Application.Current.MainWindow;
			var shell = (UIElement)mainWindow.Content;

			// trying to get an existing adorner layer
			var layer = AdornerLayer.GetAdornerLayer(shell);
			if (layer == null)
			{
				mainWindow.Content = null; // disconnects main window's content from it's parent

				// Creating adorner decorator (which provides adorner layer),
				// setting main window's content as decorator's child and
				// setting decorator as main window's content.
				// These steps will create an adorner layer for main window's content.
				var adornerDecorator = new AdornerDecorator { Child = shell };
				mainWindow.Content = adornerDecorator;
			}

			// trying to get an adorner layer again and if it's null we will thow NullReferenceException
			layer = AdornerLayer.GetAdornerLayer(shell);
			if (layer == null)
				throw new NullReferenceException("Content of main window hasn't got a adorner layer.");

			return layer;
		}