Example #1
0
        public static SceneElement ChooseElementForBehavior(SceneElement root, ITypeId constraintType)
        {
            PathTargetDialog pathTargetDialog = new PathTargetDialog(root, (SceneElement)null, StringTable.SelectElementDialogTitle, StringTable.SelectElementDialogInfoText, new PathTargetDialog.PathTargetValidator(PathTargetDialog.ValidateBehaviorTargets), constraintType);
            bool?            nullable         = pathTargetDialog.ShowDialog();

            if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? true : false)) != 0 && pathTargetDialog.model.SelectedElement != null)
            {
                return(pathTargetDialog.model.SelectedElement.Element);
            }
            return((SceneElement)null);
        }
Example #2
0
        protected virtual double GetNativeHeight(SceneElement element)
        {
            double        val2    = double.PositiveInfinity;
            Base2DElement context = element.Parent as Base2DElement;

            if (context != null && context.IsViewObjectValid)
            {
                val2 = context.GetComputedBounds(context).Height;
            }
            return(Math.Min(100.0, val2));
        }
Example #3
0
        private BaseFrameworkElement GetEditableTextElementAtPoint(Point point)
        {
            SceneElement         elementAtPoint   = this.ActiveView.GetElementAtPoint(point, new HitTestModifier(this.GetContainingTextElement), new InvisibleObjectHitTestModifier(SceneView.SmartInvisiblePanelSelect), (ICollection <BaseFrameworkElement>)null);
            BaseFrameworkElement frameworkElement = (BaseFrameworkElement)null;

            if (elementAtPoint != null && TextEditProxyFactory.IsEditableElement(elementAtPoint) && !elementAtPoint.IsLocked)
            {
                frameworkElement = elementAtPoint as BaseFrameworkElement;
            }
            return(frameworkElement);
        }
Example #4
0
        public static SceneElement ChooseElement(SceneElement root, SceneElement path)
        {
            PathTargetDialog pathTargetDialog = new PathTargetDialog(root, path, StringTable.SelectElementDialogTitle, StringTable.SelectElementDialogInfoText, new PathTargetDialog.PathTargetValidator(PathTargetDialog.AllowAllTargets), (ITypeId)null);
            bool?            nullable         = pathTargetDialog.ShowDialog();

            if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? true : false)) != 0 && pathTargetDialog.model.SelectedElement != null)
            {
                return(pathTargetDialog.model.SelectedElement.Element);
            }
            return((SceneElement)null);
        }
 private static void SetAutoLayoutRounding(SceneElement element, bool auto)
 {
     if (auto)
     {
         element.SetValue(DesignTimeProperties.LayoutRoundingProperty, (object)LayoutRoundingHelper.AutoLayoutRoundingValue);
     }
     else
     {
         element.ClearValue(DesignTimeProperties.LayoutRoundingProperty);
     }
 }
Example #6
0
 public void Attach(ToolBehaviorContext toolContext, SceneElement containerElement)
 {
     this.CheckAttached(false);
     this.toolContext        = toolContext;
     this.snapLineAdornerSet = new SnapLineAdornerSet(this.toolContext, containerElement);
     if (this.toolContext.View == null)
     {
         return;
     }
     this.toolContext.View.AdornerLayer.Add((IAdornerSet)this.snapLineAdornerSet);
 }
Example #7
0
        public static string RenderElement(SceneElement element)
        {
            SceneWriter     output       = new SceneWriter();
            OutputAttribute outputAttr   = OutputAttribute.Combine(element.GetAllAttributes <OutputAttribute>());
            ElementContext  sceneContext =
                new ElementContext(new ElementContext(null, new Scene()), element, outputAttr);

            sceneContext.LoadChildren(true);
            sceneContext.Write(output);
            return(output.ToString());
        }
        /// <summary>
        /// Pushes the effect onto the specified parent element.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="parentElement">The parent element.</param>
        public override void Push(OpenGL gl, SceneElement parentElement)
        {
            //  Create a combined mask.
            AttributeMask attributeFlags = AttributeMask.None;

            // accum buffer attribute already added to CSharpGL.
            attributeFlags |= accumBufferAttributes.AreAnyAttributesSet() ? accumBufferAttributes.AttributeFlags : AttributeMask.None;

            // accum buffer attribute already added to CSharpGL except one.
            attributeFlags |= colorBufferAttributes.AreAnyAttributesSet() ? colorBufferAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= currentAttributes.AreAnyAttributesSet() ? currentAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= depthBufferAttributes.AreAnyAttributesSet() ? depthBufferAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= enableAttributes.AreAnyAttributesSet() ? enableAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= fogAttributes.AreAnyAttributesSet() ? fogAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= lightingAttributes.AreAnyAttributesSet() ? lightingAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= lineAttributes.AreAnyAttributesSet() ? lineAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= pointAttributes.AreAnyAttributesSet() ? pointAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= polygonAttributes.AreAnyAttributesSet() ? polygonAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= evalAttributes.AreAnyAttributesSet() ? evalAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= hintAttributes.AreAnyAttributesSet() ? hintAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= listAttributes.AreAnyAttributesSet() ? listAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= pixelModeAttributes.AreAnyAttributesSet() ? pixelModeAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= polygonStippleAttributes.AreAnyAttributesSet() ? polygonStippleAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= scissorAttributes.AreAnyAttributesSet() ? scissorAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= stencilBufferAttributes.AreAnyAttributesSet() ? stencilBufferAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= textureAttributes.AreAnyAttributesSet() ? textureAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= transformAttributes.AreAnyAttributesSet() ? transformAttributes.AttributeFlags : AttributeMask.None;
            attributeFlags |= viewportAttributes.AreAnyAttributesSet() ? viewportAttributes.AttributeFlags : AttributeMask.None;

            //  Push the attribute stack.
            gl.PushAttrib((uint)attributeFlags);

            //  Set the attributes.
            accumBufferAttributes.SetAttributes(gl);
            colorBufferAttributes.SetAttributes(gl);
            currentAttributes.SetAttributes(gl);
            depthBufferAttributes.SetAttributes(gl);
            enableAttributes.SetAttributes(gl);
            fogAttributes.SetAttributes(gl);
            lightingAttributes.SetAttributes(gl);
            lineAttributes.SetAttributes(gl);
            pointAttributes.SetAttributes(gl);
            polygonAttributes.SetAttributes(gl);
            evalAttributes.SetAttributes(gl);
            hintAttributes.SetAttributes(gl);
            listAttributes.SetAttributes(gl);
            pixelModeAttributes.SetAttributes(gl);
            polygonStippleAttributes.SetAttributes(gl);
            scissorAttributes.SetAttributes(gl);
            stencilBufferAttributes.SetAttributes(gl);
            textureAttributes.SetAttributes(gl);
            transformAttributes.SetAttributes(gl);
            viewportAttributes.SetAttributes(gl);
        }
 public virtual ISceneInsertionPoint Create(object data)
 {
     if (this.Context != null && this.Item != null)
     {
         SceneElement dropTargetInfo = this.GetDropTargetInfo(this.Context.AllowedEffects, this.Context.Descriptor);
         if (dropTargetInfo != null)
         {
             return(dropTargetInfo.InsertionPointForProperty(this.GetContentPropertyFromDragDescriptor(this.Context.Descriptor)));
         }
     }
     return((ISceneInsertionPoint)null);
 }
Example #10
0
 private static bool ValidateBehaviorTargets(bool isRoot, SceneElement target, SceneElement path, ITypeId constraintType)
 {
     if (isRoot || !target.CanNameElement)
     {
         return(false);
     }
     if (constraintType != null)
     {
         return(constraintType.IsAssignableFrom((ITypeId)target.Type));
     }
     return(true);
 }
 private static bool ShouldConsiderLayoutRoundingAdjustment(SceneElement element)
 {
     if (element == null)
     {
         return(false);
     }
     if (element.ViewModel.AnimationEditor.IsRecording && !element.ViewModel.IsForcingBaseValue)
     {
         return(element.ViewModel.AnimationEditor.CanAnimateLayout);
     }
     return(true);
 }
Example #12
0
 internal static int GetMaxChildrenForElement(SceneElement element, IProperty property = null)
 {
     if (property == null)
     {
         property = element.DefaultContentProperty;
     }
     if (!element.IsContainer && property == element.DefaultContentProperty)
     {
         return(0);
     }
     return(element.GetCollectionForProperty((IPropertyId)property).FixedCapacity ?? int.MaxValue);
 }
Example #13
0
        protected BaseFrameworkElement GetHitElement(Point point, IList <BaseFrameworkElement> ignoredElements)
        {
            SceneElement         elementAtPoint   = this.ActiveView.GetElementAtPoint(point, new HitTestModifier(this.GetUnlockedAncestorInEditingContainer), (InvisibleObjectHitTestModifier)null, (ICollection <BaseFrameworkElement>)ignoredElements);
            BaseFrameworkElement frameworkElement = elementAtPoint as BaseFrameworkElement;
            Base3DElement        base3Delement    = elementAtPoint as Base3DElement;

            if (base3Delement != null)
            {
                frameworkElement = (BaseFrameworkElement)base3Delement.Viewport;
            }
            return(frameworkElement);
        }
Example #14
0
 private Vector SnapRect(Rect rectSnap, SceneElement container, Vector offset, EdgeFlags edgeFlags)
 {
     if (this.SnappingEngine == null)
     {
         return(new Vector(0.0, 0.0));
     }
     if (!this.SnappingEngine.IsStarted)
     {
         this.StartSnappingEngine();
     }
     return(this.SnappingEngine.SnapRect(rectSnap, container, offset, edgeFlags));
 }
Example #15
0
            public void Update(AdornerElementSet adornerElementSet, AdornerLayer adornerLayer, AdornerLayer.ElementInfoUpdateSource source)
            {
                SceneElement primaryElement = adornerElementSet.PrimaryElement;
                bool         flag           = false;

                if (!adornerLayer.SceneView.IsInArtboard(primaryElement))
                {
                    return;
                }
                Size size2 = primaryElement.Visual != null?adornerLayer.SceneView.GetRenderSize(primaryElement.Visual) : Size.Empty;

                Transform transform             = (Transform) new MatrixTransform(adornerElementSet.CalculatePrimaryElementTransformMatrixToAdornerLayer());
                Matrix    matrix                = transform == null ? Matrix.Identity : transform.Value;
                Point     renderTransformOrigin = adornerElementSet.RenderTransformOrigin;

                if (!AdornerLayer.ElementInfo.AreClose(renderTransformOrigin, this.sharedCenter) || !AdornerLayer.ElementInfo.AreClose(this.lastRenderSize, size2) || (this.primaryElementMatrix != matrix || adornerElementSet.IsPrimaryTransformNonAffine))
                {
                    flag = true;
                    this.sharedCenter         = renderTransformOrigin;
                    this.lastRenderSize       = size2;
                    this.primaryElementMatrix = matrix;
                }
                ISceneInsertionPoint sceneInsertionPoint = adornerElementSet.PrimaryElement.ViewModel.ActiveSceneInsertionPoint;

                if (flag || source == AdornerLayer.ElementInfoUpdateSource.LayoutUpdated && adornerElementSet.NeedsUpdate)
                {
                    adornerElementSet.Update();
                    this.matrix = adornerElementSet.GetTransformMatrixToAdornerLayer();
                    foreach (AdornerSet adornerSet in this.adornerSets)
                    {
                        this.UpdateMatrix(adornerSet, adornerLayer);
                    }
                    if (this.adornerSet3DContainer != null)
                    {
                        this.adornerSet3DContainer.SetMatrix(this.matrix);
                    }
                    if (sceneInsertionPoint != null && primaryElement.ParentElement is GridElement && (primaryElement.ParentElement == sceneInsertionPoint.SceneElement && primaryElement.ViewModel.IsInGridDesignMode))
                    {
                        adornerLayer.InvalidateAdornerVisuals(primaryElement.ParentElement);
                    }
                }
                if (!(primaryElement is Base3DElement) || sceneInsertionPoint == null)
                {
                    return;
                }
                Base3DElement base3Delement = sceneInsertionPoint.SceneElement as Base3DElement;

                if (base3Delement == null)
                {
                    return;
                }
                adornerLayer.InvalidateAdornerVisuals((SceneElement)base3Delement);
            }
Example #16
0
        /// <summary>
        /// Get picked primitive by <paramref name="stageVertexID"/> as the last vertex that constructs the primitive.
        /// </summary>
        /// <param name="stageVertexID">The last vertex that constructs the primitive.</param>
        /// <returns></returns>
        public IPickedGeometry Pick(uint stageVertexID)
        {
            if (stageVertexID < 0)
            {
                return(null);
            }

            SceneElement    element        = this.SceneContainer;
            IPickedGeometry pickedGeometry = Pick(element, stageVertexID);

            return(pickedGeometry);
        }
Example #17
0
            private string GetCandidateName(SceneElement element)
            {
                if (element == null)
                {
                    return(string.Empty);
                }
                SceneNode         root = element.StoryboardContainer as SceneNode ?? this.view.ViewModel.RootNode;
                SceneNodeIDHelper sceneNodeIdHelper = new SceneNodeIDHelper(element.ViewModel, root);
                string            namePrefix        = SceneNodeIDHelper.DefaultNamePrefixForType((ITypeId)element.Type);

                return(sceneNodeIdHelper.GetValidElementID((SceneNode)element, namePrefix));
            }
        /// <summary>
        /// Pops the specified parent element.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="parentElement">The parent element.</param>
        public override void Pop(OpenGL gl, SceneElement parentElement)
        {
            LookAtCamera camera = parentElement.TraverseToRootElement().ParentScene.CurrentCamera as LookAtCamera;

            if (camera != null)
            {
                gl.Viewport(0, 0, result[2], result[3]);
            }

            //  Pop the stack.
            gl.PopMatrix();
        }
Example #19
0
        private static SceneElement ChangeLayoutType(SceneElement sourceElement, ITypeId layoutType, ref SceneElement elementContainingChildren)
        {
            IDocumentRoot        documentRoot     = sourceElement.DocumentNode.DocumentRoot;
            IDocumentContext     documentContext  = documentRoot.DocumentContext;
            SceneViewModel       viewModel        = sourceElement.ViewModel;
            Size                 size             = Size.Empty;
            BaseFrameworkElement frameworkElement = sourceElement as BaseFrameworkElement;

            if (frameworkElement != null)
            {
                size = frameworkElement.GetComputedTightBounds().Size;
            }
            using (viewModel.ForceBaseValue())
            {
                SceneElement sceneElement = (SceneElement)viewModel.CreateSceneNode(layoutType);
                using (viewModel.DisableUpdateChildrenOnAddAndRemove())
                {
                    using (viewModel.DisableDrawIntoState())
                    {
                        viewModel.AnimationEditor.DeleteAllAnimations((SceneNode)sourceElement);
                        Dictionary <IPropertyId, SceneNode>         properties     = SceneElementHelper.StoreProperties((SceneNode)sourceElement);
                        Dictionary <IPropertyId, List <SceneNode> > storedChildren = ChangeLayoutTypeCommand.StoreChildren(sourceElement);
                        if (sourceElement.DocumentNode == documentRoot.RootNode)
                        {
                            documentRoot.RootNode = sceneElement.DocumentNode;
                            sceneElement.DocumentNode.NameScope = new DocumentNodeNameScope();
                        }
                        else
                        {
                            ISceneNodeCollection <SceneNode> collectionContainer = sourceElement.GetCollectionContainer();
                            int index = collectionContainer.IndexOf((SceneNode)sourceElement);
                            sourceElement.Remove();
                            collectionContainer.Insert(index, (SceneNode)sceneElement);
                        }
                        SceneElementHelper.ApplyProperties((SceneNode)sceneElement, properties);
                        elementContainingChildren = ChangeLayoutTypeCommand.ApplyChildren(sceneElement, storedChildren, size);
                    }
                }
                if (sceneElement is GridElement || sceneElement is CanvasElement)
                {
                    ILayoutDesigner designerForChild = sceneElement.ViewModel.GetLayoutDesignerForChild(sceneElement, true);
                    if ((designerForChild.GetWidthConstraintMode((BaseFrameworkElement)sceneElement) & LayoutConstraintMode.CanvasLike) != LayoutConstraintMode.NonOverlappingGridlike)
                    {
                        sceneElement.SetValue(BaseFrameworkElement.WidthProperty, (object)size.Width);
                    }
                    if ((designerForChild.GetHeightConstraintMode((BaseFrameworkElement)sceneElement) & LayoutConstraintMode.CanvasLike) != LayoutConstraintMode.NonOverlappingGridlike)
                    {
                        sceneElement.SetValue(BaseFrameworkElement.HeightProperty, (object)size.Height);
                    }
                }
                return(sceneElement);
            }
        }
Example #20
0
        private AnnotationEditor.ReferenceInfo References_InsertedHandler(object sender, SceneNode basisNode, object basisContent, SceneNode newPathNode)
        {
            SceneElement         sceneElement = (SceneElement)newPathNode.Parent;
            IEnumerable <string> enumerable   = AnnotationUtils.ParseAnnotationReferences(((DocumentPrimitiveNode)newPathNode.DocumentNode).GetValue <string>());

            return(new AnnotationEditor.ReferenceInfo()
            {
                ReferenceOwner = sceneElement,
                ReferencedAnnotationIds = Enumerable.ToList <string>(enumerable),
                ReferencedAnnotations = this.ComputeReferencedAnnotations(enumerable)
            });
        }
Example #21
0
 public static double GetStrokeWidth(SceneElement element)
 {
     if (element.GetComputedValue(ShapeElement.StrokeProperty) != null)
     {
         double d = (double)element.GetComputedValue(ShapeElement.StrokeThicknessProperty);
         if (!double.IsNaN(d) && !double.IsInfinity(d))
         {
             return(d);
         }
     }
     return(0.0);
 }
Example #22
0
        public virtual Rect GetElementBounds(SceneElement sceneElement)
        {
            if (sceneElement == null || sceneElement.ViewTargetElement == null)
            {
                return(Rect.Empty);
            }
            Rect   actualBounds            = sceneElement.ViewModel.DefaultView.GetActualBounds(sceneElement.ViewTargetElement);
            Matrix computedTransformToRoot = sceneElement.ViewModel.DefaultView.GetComputedTransformToRoot(sceneElement);

            actualBounds.Transform(computedTransformToRoot);
            return(actualBounds);
        }
Example #23
0
 public override void Execute()
 {
     using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitCreateGroup))
     {
         SceneElement selectionToSet = this.GroupElements();
         if (selectionToSet != null)
         {
             this.SceneViewModel.ElementSelectionSet.SetSelection(selectionToSet);
         }
         editTransaction.Commit();
     }
 }
Example #24
0
 private Breadcrumb FindBreadcrumb(SceneElement targetElement)
 {
     foreach (Breadcrumb breadcrumb in (Collection <Breadcrumb>) this.Trail)
     {
         DocumentNodePath selectedElementPath = breadcrumb.SelectedElementPath;
         if (selectedElementPath != null && selectedElementPath.Equals((object)targetElement.DocumentNodePath))
         {
             return(breadcrumb);
         }
     }
     return((Breadcrumb)null);
 }
Example #25
0
            private bool DoHitTestOverArtboard(Point artboardPoint)
            {
                bool flag = false;

                if (this.view.Artboard.ArtboardBounds.Contains(artboardPoint))
                {
                    this.topElement = this.view.GetSelectableElementAtPoint(artboardPoint, SelectionFor3D.Deep, false);
                    if (this.topElement == null)
                    {
                        this.topElement = this.view.GetElementAtPoint(artboardPoint, new HitTestModifier(this.view.GetSelectableElement), (InvisibleObjectHitTestModifier)null, (ICollection <BaseFrameworkElement>)null);
                    }
                    if (this.topElement != null)
                    {
                        if (this.elementSelectionStrategy.CanSelectElement(this.topElement))
                        {
                            this.editor.Cursor = this.cursor;
                            flag = true;
                        }
                        if (this.previewHighlighter.PreviewElement != this.topElement)
                        {
                            if (this.topElement.IsNamed)
                            {
                                this.feedbackAdorner.Text = this.topElement.Name;
                            }
                            else if (flag)
                            {
                                this.feedbackAdorner.Text = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.NamingNotification, new object[2]
                                {
                                    (object)this.topElement.DisplayNameNoTextContent,
                                    (object)this.GetCandidateName(this.topElement)
                                });
                            }
                            else
                            {
                                this.feedbackAdorner.Text = this.topElement.DisplayNameNoTextContent;
                            }
                            this.feedbackAdorner.DrawAdorner();
                            this.previewHighlighter.PreviewElement = this.topElement;
                        }
                    }
                    else
                    {
                        this.feedbackAdorner.CloseAdorner();
                        this.previewHighlighter.PreviewElement = (SceneElement)null;
                    }
                }
                else
                {
                    this.previewHighlighter.PreviewElement = (SceneElement)null;
                }
                return(flag);
            }
Example #26
0
        private void CreateInstance(Point dropPoint, ResourceEntryItem resource, IType type)
        {
            ISceneInsertionPoint pointFromPosition = this.ActiveSceneViewModel.GetActiveSceneInsertionPointFromPosition(new InsertionPointContext(dropPoint));
            TypeAsset            typeAsset         = new TypeAsset(type);

            if (!typeAsset.CanCreateInstance(pointFromPosition))
            {
                return;
            }
            this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, (BaseFrameworkElement)null, (IList <BaseFrameworkElement>)null);
            dropPoint = this.ToolBehaviorContext.SnappingEngine.SnapPoint(dropPoint, EdgeFlags.All);
            this.ToolBehaviorContext.SnappingEngine.Stop();
            Matrix inverseMatrix = ElementUtilities.GetInverseMatrix(this.ActiveView.GetComputedTransformToRoot(pointFromPosition.SceneElement));

            dropPoint *= inverseMatrix;
            using (SceneEditTransaction editTransaction = this.ActiveDocument.CreateEditTransaction(StringTable.CreateResourceViaToolUndoUnit))
            {
                using (this.ActiveSceneViewModel.DesignerContext.AmbientPropertyManager.SuppressApplyAmbientProperties())
                {
                    typeAsset.CreateInstance(this.ActiveSceneViewModel.DesignerContext.LicenseManager, pointFromPosition, new Rect(dropPoint, new Size(double.PositiveInfinity, double.PositiveInfinity)), (OnCreateInstanceAction)(sceneNode =>
                    {
                        SceneElement targetElement = sceneNode as SceneElement;
                        if (targetElement == null)
                        {
                            return;
                        }
                        if (resource is StyleResourceItem)
                        {
                            this.ApplyResourceOnExistingElement(targetElement, BaseFrameworkElement.StyleProperty, resource);
                        }
                        else if (resource is ControlTemplateResourceItem)
                        {
                            this.ApplyResourceOnExistingElement(targetElement, ControlElement.TemplateProperty, resource);
                        }
                        else if (resource is DrawingImageResourceItem)
                        {
                            this.ApplyResourceOnExistingElement(targetElement, ImageElement.SourceProperty, resource);
                        }
                        else
                        {
                            if (!(resource is BrushResourceItem))
                            {
                                return;
                            }
                            this.ApplyResourceOnExistingElement(targetElement, ShapeElement.FillProperty, resource);
                            targetElement.SetValue(ShapeElement.StrokeProperty, (object)null);
                        }
                    }));
                    editTransaction.Commit();
                }
            }
        }
Example #27
0
        internal AnnotationSceneNode CreateAnnotation(IEnumerable <SceneElement> targets)
        {
            Artboard            artboard             = this.sceneViewModel.DefaultView.Artboard;
            SceneElement        sceneElement         = Enumerable.First <SceneElement>(targets);
            int                 num                  = Enumerable.Count <SceneElement>(targets);
            bool                treatTopLeftAsCenter = num > 1 || sceneElement.Equals((object)sceneElement.ViewModel.RootNode);
            AnnotationSceneNode annotation;

            using (SceneEditTransaction editTransaction = sceneElement.ViewModel.CreateEditTransaction(StringTable.AddAnnotationUndoUnit))
            {
                annotation = AnnotationManagerSceneNode.CreateAnnotation((SceneNode)sceneElement);
                foreach (SceneElement element in Enumerable.Skip <SceneElement>(targets, 1))
                {
                    AnnotationUtils.AddAnnotationReference(element, annotation);
                }
                Point point1;
                if (treatTopLeftAsCenter)
                {
                    Rect rect = Rect.Empty;
                    if (num > 1 || !sceneElement.Equals((object)annotation.ViewModel.RootNode))
                    {
                        rect = artboard.GetElementListBounds(targets);
                    }
                    if (rect.IsEmpty)
                    {
                        rect = artboard.ArtboardBounds;
                    }
                    point1 = new Point(rect.Left + rect.Width / 2.0, rect.Top + rect.Height / 2.0);
                }
                else
                {
                    point1 = artboard.GetElementBounds(sceneElement).TopRight;
                }
                Point point2 = RoundingHelper.RoundPosition(point1);
                annotation.Left = point2.X;
                annotation.Top  = point2.Y;
                string authorName = this.AnnotationService.DesignerContext.AnnotationsOptionsModel.AuthorName;
                if (!string.IsNullOrEmpty(authorName))
                {
                    annotation.Author = authorName;
                }
                string authorInitials = this.AnnotationService.DesignerContext.AnnotationsOptionsModel.AuthorInitials;
                if (!string.IsNullOrEmpty(authorInitials))
                {
                    annotation.AuthorInitials = authorInitials;
                }
                AnnotationUtils.SetSerialNumber(annotation);
                editTransaction.Commit();
            }
            this.CreateAnnotationVisual(annotation).Initialize(treatTopLeftAsCenter);
            return(annotation);
        }
Example #28
0
        protected override void RefreshInstance(SceneElement element, SceneDocument sceneDocument, string url)
        {
            ImageElement imageElement = element as ImageElement;

            if (imageElement == null)
            {
                return;
            }
            string uri = imageElement.Uri;

            imageElement.Uri = (string)null;
            imageElement.Uri = uri;
        }
Example #29
0
        private void ClearLayoutProperties(IEnumerable <IPropertyId> properties, SceneElement element)
        {
            DocumentCompositeNode documentCompositeNode = element.DocumentNode as DocumentCompositeNode;

            foreach (IPropertyId propertyId in properties)
            {
                IProperty property = element.ViewModel.ProjectContext.ResolveProperty(propertyId);
                if (property != null)
                {
                    documentCompositeNode.ClearValue((IPropertyId)property);
                }
            }
        }
 public bool CanSelectElement(SceneElement element)
 {
     if (element == null)
     {
         return(false);
     }
     if (this.lastElement != element)
     {
         this.lastElement         = element;
         this.lastCanSelectResult = element.CanNameElement && MiniSourceBindingDialogModel.AnyBindableProperties((SceneNode)element, this.targetProperty.PropertyType);
     }
     return(this.lastCanSelectResult);
 }
Example #31
0
 /// <summary>
 /// Pushes the effect onto the specified parent element.
 /// </summary>
 /// <param name="gl">The OpenGL instance.</param>
 /// <param name="parentElement">The parent element.</param>
 public override void Push(OpenGL gl, SceneElement parentElement)
 {
     //  Use this shader object.
     gl.UseProgram(ProgramObject);
 }
Example #32
0
 private void sceneControl1_MouseClick(object sender, MouseEventArgs e)
 {
     //  Do a hit test.
     SelectedSceneElement = null;
     listBox1.Items.Clear();
     var itemsHit = sceneControl1.Scene.DoHitTest(e.X, e.Y);
     foreach (var item in itemsHit)
         listBox1.Items.Add(item);
     if (listBox1.Items.Count >0)
     {
         listBox1.SetSelected(0, true);
        // listBox1_SelectedIndexChanged(this, null);
     }
 }
Example #33
0
 /// <summary>
 /// Handles the AfterSelect event of the treeView1 control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Windows.Forms.TreeViewEventArgs"/> instance containing the event data.</param>
 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
 {
     SelectedSceneElement = e.Node.Tag as SceneElement;
 }
Example #34
0
        /// <summary>
        /// Adds the element to tree.
        /// </summary>
        /// <param name="sceneElement">The scene element.</param>
        /// <param name="nodes">The nodes.</param>
        private void AddElementToTree(SceneElement sceneElement, TreeNodeCollection nodes)
        {
            //  Add the element.
            TreeNode newNode = new TreeNode()
            {
                Text = sceneElement.Name,
                Tag = sceneElement
            };
            nodes.Add(newNode);

            //  Add each child.
            foreach (var element in sceneElement.Children)
                AddElementToTree(element, newNode.Nodes);
        }
Example #35
0
        /// <summary>
        /// Renders the element.
        /// </summary>
        /// <param name="gl">The gl.</param>
        /// <param name="renderMode">The render mode.</param>
        public void RenderElement(SceneElement sceneElement, RenderMode renderMode)
        {
            //  If the element is disabled, we're done.
            if (sceneElement.IsEnabled == false)
                return;

            //  Push each effect.
            foreach (var effect in sceneElement.Effects)
                if(effect.IsEnabled)
                    effect.Push(gl, sceneElement);

            //  If the element can be bound, bind it.
            if (sceneElement is IBindable)
                ((IBindable)sceneElement).Bind(gl);

            //  If the element has an object space, transform into it.
            if (sceneElement is IHasObjectSpace)
                ((IHasObjectSpace)sceneElement).PushObjectSpace(gl);

            //  If the element has a material, push it.
            if (sceneElement is IHasMaterial && ((IHasMaterial)sceneElement).Material != null)
                ((IHasMaterial)sceneElement).Material.Push(gl);

            //  If the element can be rendered, render it.
            if (sceneElement is IRenderable)
                ((IRenderable)sceneElement).Render(gl, renderMode);

            //  If the element has a material, pop it.
            if (sceneElement is IHasMaterial && ((IHasMaterial)sceneElement).Material != null)
                ((IHasMaterial)sceneElement).Material.Pop(gl);

            //  IF the element is volume bound and we are rendering volumes, render the volume.
            if (RenderBoundingVolumes && sceneElement is IVolumeBound)
                ((IVolumeBound)sceneElement).BoundingVolume.Render(gl, renderMode);

            //  Recurse through the children.
            foreach (var childElement in sceneElement.Children)
                RenderElement(childElement, renderMode);

            //  If the element has an object space, transform out of it.
            if (sceneElement is IHasObjectSpace)
                ((IHasObjectSpace)sceneElement).PopObjectSpace(gl);

            //  Pop each effect.
            for (int i = sceneElement.Effects.Count - 1; i >= 0; i--)
                if(sceneElement.Effects[i].IsEnabled)
                    sceneElement.Effects[i].Pop(gl, sceneElement);
        }
Example #36
0
        /// <summary>
        /// Renders the element for hit test.
        /// </summary>
        /// <param name="sceneElement">The scene element.</param>
        /// <param name="hitMap">The hit map.</param>
        /// <param name="currentName">Current hit name.</param>
        private void RenderElementForHitTest(SceneElement sceneElement, 
            Dictionary<uint, SceneElement> hitMap, ref uint currentName)
        {
            //  If the element is disabled, we're done.
            //  Also, never hit test the current camera.
            if (sceneElement.IsEnabled == false || sceneElement == currentCamera)
                return;

            //  Push each effect.
            foreach (var effect in sceneElement.Effects)
                if (effect.IsEnabled)
                    effect.Push(gl, sceneElement);

            //  If the element has an object space, transform into it.
            if (sceneElement is IHasObjectSpace)
                ((IHasObjectSpace)sceneElement).PushObjectSpace(gl);

            //  If the element is volume bound, render the volume.
            if (sceneElement is IVolumeBound)
            {
                //  Load and map the name.
                gl.LoadName(currentName);
                hitMap[currentName] = sceneElement;

                //  Render the bounding volume.
                ((IVolumeBound)sceneElement).BoundingVolume.Render(gl, RenderMode.HitTest);

                //  Increment the name.
                currentName++;
            }

            //  Recurse through the children.
            foreach (var childElement in sceneElement.Children)
                RenderElementForHitTest(childElement, hitMap, ref currentName);

            //  If the element has an object space, transform out of it.
            if (sceneElement is IHasObjectSpace)
                ((IHasObjectSpace)sceneElement).PopObjectSpace(gl);

            //  Pop each effect.
            for (int i = sceneElement.Effects.Count - 1; i >= 0; i--)
                if (sceneElement.Effects[i].IsEnabled)
                    sceneElement.Effects[i].Pop(gl, sceneElement);
        }
Example #37
0
 /// <summary>
 /// Pops the effect off the specified parent element.
 /// </summary>
 /// <param name="gl">The OpenGL instance.</param>
 /// <param name="parentElement">The parent element.</param>
 public override void Pop(OpenGL gl, SceneElement parentElement)
 {
     //  Un-use this shader object.
     gl.UseProgram(0);
 }
Example #38
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     SelectedSceneElement = listBox1.SelectedItem as SceneElement;
 }