Exemplo n.º 1
0
        public FORNode(Node init, ContentNode<bool> decider, Node iter, List<Node> fornodes)
            : base()
        {
            InitNode = init;
            Decider = decider;
            Iteration = iter;

            ForNodes = fornodes;
        }
		/// <summary>
		/// Sets the node to be displayed by this control.
		/// </summary>
		/// <param name="node"></param>
		public void SetDataContext(PositionedNode node)
		{
			if (node == null) {
				this.DataContext = null;
				this.listView.ItemsSource = null;
				return;
			}
			this.DataContext = node;
			this.Root = node.Content;
			this.items = GetInitialItems(this.Root);
			// data virtualization, ContentPropertyNode implements IEvaluate
			this.listView.ItemsSource = new VirtualizingObservableCollection<ContentNode>(this.items);
		}
Exemplo n.º 3
0
        public override void Clean()
        {
            base.Clean();

            Decider.Clean();
            Decider = null;

            foreach (var n in Whilenodes)
            {
                n.Clean();
            }
            Whilenodes.Clear();
            Whilenodes = null;
        }
Exemplo n.º 4
0
        public override void Clean()
        {
            base.Clean();
            InitNode.Clean();
            InitNode = null;

            Decider.Clean();
            Decider = null;

            Iteration.Clean();
            Iteration = null;

            foreach (var n in ForNodes)
            {
                n.Clean();
            }
            ForNodes.Clear();
        }
Exemplo n.º 5
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            switch (index)
            {
            case 0:
                // Set the slide's title and subtitle and add some text
                TextManager.SetTitle("Constraints");
                TextManager.SetSubtitle("SCNConstraint");

                TextManager.AddBulletAtLevel("Applied sequentially at render time", 0);
                TextManager.AddBulletAtLevel("Only affect presentation values", 0);

                TextManager.AddCode("#aNode.#Constraints# = new SCNConstraint[] { aConstraint, anotherConstraint, ... };#");

                // Tweak the near clipping plane of the spot light to get a precise shadow map
                presentationViewController.SpotLight.Light.SetAttribute(new NSNumber(10), SCNLightAttribute.ShadowNearClippingKey);
                break;

            case 1:
                // Remove previous text
                TextManager.FlipOutText(SlideTextManager.TextType.Subtitle);
                TextManager.FlipOutText(SlideTextManager.TextType.Bullet);
                TextManager.FlipOutText(SlideTextManager.TextType.Code);

                // Add new text
                TextManager.SetSubtitle("SCNLookAtConstraint");
                TextManager.AddBulletAtLevel("Makes a node to look at another node", 0);
                TextManager.AddCode("#nodeA.Constraints = new SCNConstraint[] { #SCNLookAtConstraint.Create# (nodeB) };#");

                TextManager.FlipInText(SlideTextManager.TextType.Subtitle);
                TextManager.FlipInText(SlideTextManager.TextType.Bullet);
                TextManager.FlipInText(SlideTextManager.TextType.Code);
                break;

            case 2:
                // Setup the scene
                SetupLookAtScene();

                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                // Dim the text and move back a little bit
                TextManager.TextNode.Opacity = 0.5f;
                presentationViewController.CameraHandle.Position = presentationViewController.CameraNode.ConvertPositionToNode(new SCNVector3(0, 0, 5.0f), presentationViewController.CameraHandle.ParentNode);
                SCNTransaction.Commit();
                break;

            case 3:
                // Add constraints to the arrows
                var container = ContentNode.FindChildNode("arrowContainer", true);

                // "Look at" constraint
                var constraint = SCNLookAtConstraint.Create(BallNode);

                var i = 0;
                foreach (var arrow in container.ChildNodes)
                {
                    var delayInSeconds = 0.1 * i++;
                    var popTime        = new DispatchTime(DispatchTime.Now, (long)(delayInSeconds * Utils.NSEC_PER_SEC));
                    DispatchQueue.MainQueue.DispatchAfter(popTime, () => {
                        SCNTransaction.Begin();
                        SCNTransaction.AnimationDuration = 1;
                        // Animate to the result of applying the constraint
                        ((SCNNode)arrow.ChildNodes [0]).Rotation = new SCNVector4(0, 1, 0, (float)(Math.PI / 2));
                        arrow.Constraints = new SCNConstraint[] { constraint };
                        SCNTransaction.Commit();
                    });
                }
                break;

            case 4:
                // Create a keyframe animation to move the ball
                var animation = CAKeyFrameAnimation.GetFromKeyPath("position");
                animation.KeyTimes = new NSNumber[] {
                    0.0f,
                    (1.0f / 8.0f),
                    (2.0f / 8.0f),
                    (3.0f / 8.0f),
                    (4.0f / 8.0f),
                    (5.0f / 8.0f),
                    (6.0f / 8.0f),
                    (7.0f / 8.0f),
                    1.0f
                };

                animation.Values = new NSObject[] {
                    NSValue.FromVector(new SCNVector3(0, 0.0f, 0)),
                    NSValue.FromVector(new SCNVector3(20.0f, 0.0f, 20.0f)),
                    NSValue.FromVector(new SCNVector3(40.0f, 0.0f, 0)),
                    NSValue.FromVector(new SCNVector3(20.0f, 0.0f, -20.0f)),
                    NSValue.FromVector(new SCNVector3(0, 0.0f, 0)),
                    NSValue.FromVector(new SCNVector3(-20.0f, 0.0f, 20.0f)),
                    NSValue.FromVector(new SCNVector3(-40.0f, 0.0f, 0)),
                    NSValue.FromVector(new SCNVector3(-20.0f, 0.0f, -20.0f)),
                    NSValue.FromVector(new SCNVector3(0, 0.0f, 0))
                };

                animation.CalculationMode = CAKeyFrameAnimation.AnimationCubicPaced;                 // smooth the movement between keyframes
                animation.RepeatCount     = float.MaxValue;
                animation.Duration        = 10.0f;
                animation.TimingFunction  = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Linear);
                BallNode.AddAnimation(animation, new NSString("ballNodeAnimation"));

                // Rotate the ball to give the illusion of a rolling ball
                // We need two animations to do that:
                // - one rotation to orient the ball in the right direction
                // - one rotation to spin the ball
                animation          = CAKeyFrameAnimation.GetFromKeyPath("rotation");
                animation.KeyTimes = new NSNumber[] {
                    0.0f,
                    (0.7f / 8.0f),
                    (1.0f / 8.0f),
                    (2.0f / 8.0f),
                    (3.0f / 8.0f),
                    (3.3f / 8.0f),
                    (4.7f / 8.0f),
                    (5.0f / 8.0f),
                    (6.0f / 8.0f),
                    (7.0f / 8.0f),
                    (7.3f / 8.0f),
                    1.0f
                };

                animation.Values = new NSObject[] {
                    NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI / 4))),
                    NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI / 4))),
                    NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI / 2))),
                    NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI))),
                    NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI + Math.PI / 2))),
                    NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2 - Math.PI / 4))),
                    NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2 - Math.PI / 4))),
                    NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2 - Math.PI / 2))),
                    NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI))),
                    NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI - Math.PI / 2))),
                    NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI / 4))),
                    NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI / 4)))
                };

                animation.RepeatCount    = float.MaxValue;
                animation.Duration       = 10.0f;
                animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Linear);
                BallNode.AddAnimation(animation, new NSString("ballNodeAnimation2"));

                var rotationAnimation = CABasicAnimation.FromKeyPath("rotation");
                rotationAnimation.Duration    = 1.0f;
                rotationAnimation.RepeatCount = float.MaxValue;
                rotationAnimation.To          = NSValue.FromVector(new SCNVector4(1, 0, 0, (float)(Math.PI * 2)));
                BallNode.ChildNodes [1].AddAnimation(rotationAnimation, new NSString("ballNodeRotation"));
                break;

            case 5:
                // Add a constraint to the camera
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                constraint = SCNLookAtConstraint.Create(BallNode);
                presentationViewController.CameraNode.Constraints = new SCNConstraint[] { constraint };
                SCNTransaction.Commit();
                break;

            case 6:
                // Add a constraint to the light
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                var cameraTarget = ContentNode.FindChildNode("cameraTarget", true);
                constraint = SCNLookAtConstraint.Create(cameraTarget);
                presentationViewController.SpotLight.Constraints = new SCNConstraint[] { constraint };
                SCNTransaction.Commit();
                break;
            }
        }
Exemplo n.º 6
0
        internal static void FromPlaylistNode(Database db, ContentNode node, out Track track, out int containerId)
        {
            track = null;
            containerId = 0;

            foreach (ContentNode field in (ContentNode[]) node.Value) {
                switch (field.Name) {
                case "dmap.itemid":
                    track = db.LookupTrackById ((int) field.Value);
                    break;
                case "dmap.containeritemid":
                    containerId = (int) field.Value;
                    break;
                default:
                    break;
                }
            }
        }
Exemplo n.º 7
0
		public ContentPropertyNode(PositionedNode containingNode, ContentNode parent)
			: base(containingNode, parent)
		{
		}
Exemplo n.º 8
0
        static void HtmlEncodeRecursive(ContentNode node, StringBuilder sb)
        {
            string pre, post;

            switch (node.Type) {
                case ContentNodeType.UnparseRawText:
                    pre = post = null;
                    break;
                case ContentNodeType.Container:
                    pre = post = null;
                    break;
                case ContentNodeType.Text:
                    pre = post = null;
                    break;
                case ContentNodeType.Bold:
                    pre = "<b>";
                    post = "</b>";
                    break;
                case ContentNodeType.Italic:
                    pre = "<i>";
                    post = "</i>";
                    break;
                case ContentNodeType.BoldItalic:
                    pre = "<b><i>";
                    post = "</i></b>";
                    break;
                case ContentNodeType.Underline:
                    pre = "<span class=\"underline\">";
                    post = "</span>";
                    break;
                default:
                    throw new Exception("Invalid value for ContentNodeType");
            }

            if (pre != null)
                sb.Append(pre);

            if (!string.IsNullOrEmpty(node.Value))
                sb.Append(HtmlEncode(node.Value));

            if (node.Children != null) {
                foreach (ContentNode child in node.Children) {
                    HtmlEncodeRecursive(child, sb);
                }
            }

            if (post != null)
                sb.Append(post);
        }
Exemplo n.º 9
0
        internal void    Closure(ContentNode.Type type) {
            ContentNode n;

            if (stack.Count > 0) {
                InternalNode n1;
                n = (ContentNode)stack.Pop();
                if (isPartial &&
                    n.NodeType != ContentNode.Type.Terminal &&
                    n.NodeType != ContentNode.Type.Any) {
                    // need to reach in and wrap _pRight hand side of element.
                    // and n remains the same.
                    InternalNode inNode = (InternalNode)n;
                    n1 = new InternalNode(inNode.RightNode, null, type);
                    n1.ParentNode = n;
                    if (inNode.RightNode != null)
                        inNode.RightNode.ParentNode = n1;
                    inNode.RightNode = n1;
                }
                else {
                    // wrap terminal or any node
                    n1 = new InternalNode(n, null, type);
                    n.ParentNode = n1;
                    n = n1;
                }
                stack.Push(n);
            }
            else {
                // wrap whole content
                n = new InternalNode(contentNode, null, type);
                contentNode.ParentNode = n;
                contentNode = n;
            }
        }
 public void Update(ContentNode node)
 {
     _myCustomDAL.UpdateMethod3(node);
 }
Exemplo n.º 11
0
 public IFNode(ContentNode<bool> decider, List<Node> ifnodes, List<Node> elsenodes)
     : this(decider, ifnodes)
 {
     ElseNodes = elsenodes;
 }
Exemplo n.º 12
0
		public bool IsExpanded(ContentNode contentNode)
		{
			return expanded.IsExpanded(contentNode.FullPath);
		}
Exemplo n.º 13
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            switch (index)
            {
            case 1:
                // Load the scene
                var intermediateNode = SCNNode.Create();
                intermediateNode.Position = new SCNVector3(0.0f, 0.1f, -24.5f);
                intermediateNode.Scale    = new SCNVector3(2.3f, 1.0f, 1.0f);
                intermediateNode.Opacity  = 0.0f;
                RoomNode = Utils.SCAddChildNode(intermediateNode, "Mesh", "Scenes/cornell-box/cornell-box", 15);
                ContentNode.AddChildNode(intermediateNode);

                // Hide the light maps for now
                foreach (var material in RoomNode.Geometry.Materials)
                {
                    material.Multiply.Intensity = 0.0f;
                    material.LightingModelName  = SCNLightingModel.Blinn;
                }

                // Animate the point of view with an implicit animation.
                // On completion add to move the camera from right to left and back and forth.
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 0.75f;

                SCNTransaction.SetCompletionBlock(() => {
                    SCNTransaction.Begin();
                    SCNTransaction.AnimationDuration = 2;

                    SCNTransaction.SetCompletionBlock(() => {
                        var animation            = CABasicAnimation.FromKeyPath("position");
                        animation.Duration       = 10.0f;
                        animation.Additive       = true;
                        animation.To             = NSValue.FromVector(new SCNVector3(-5, 0, 0));
                        animation.From           = NSValue.FromVector(new SCNVector3(5, 0, 0));
                        animation.TimeOffset     = -animation.Duration / 2;
                        animation.AutoReverses   = true;
                        animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
                        animation.RepeatCount    = float.MaxValue;

                        presentationViewController.CameraNode.AddAnimation(animation, new NSString("myAnim"));
                    });
                    presentationViewController.CameraHandle.Position = presentationViewController.CameraHandle.ConvertPositionToNode(new SCNVector3(0, +5, -30), presentationViewController.CameraHandle.ParentNode);
                    presentationViewController.CameraPitch.Rotation  = new SCNVector4(1, 0, 0, -(float)(Math.PI / 4) * 0.2f);
                    SCNTransaction.Commit();
                });

                intermediateNode.Opacity = 1.0f;
                SCNTransaction.Commit();
                break;

            case 2:
                // Remove the lighting by using a constant lighing model (no lighting)
                foreach (var material in RoomNode.Geometry.Materials)
                {
                    material.LightingModelName = SCNLightingModel.Constant;
                }
                break;

            case 3:
                // Activate the light maps smoothly
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                foreach (var material in RoomNode.Geometry.Materials)
                {
                    material.Multiply.Intensity = 1.0f;
                }
                SCNTransaction.Commit();
                break;
            }
        }
		private ObservableCollection<ContentNode> getInitialView(ContentNode root)
		{
			return new ObservableCollection<ContentNode>(root.FlattenChildrenExpanded());
		}
Exemplo n.º 15
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            switch (index)
            {
            case 0:
                // Set the slide's title and subtitle
                TextManager.SetTitle("Scene Graph");
                TextManager.SetSubtitle("Summary");
                break;

            case 1:
                // A node that will help visualize the position of the stars
                WireframeBoxNode          = SCNNode.Create();
                WireframeBoxNode.Rotation = new SCNVector4(0, 1, 0, (float)(Math.PI / 4));
                WireframeBoxNode.Geometry = SCNBox.Create(1, 1, 1, 0);
                WireframeBoxNode.Geometry.FirstMaterial.Diffuse.Contents  = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/box_wireframe", "png"));
                WireframeBoxNode.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Constant; // no lighting
                WireframeBoxNode.Geometry.FirstMaterial.DoubleSided       = true;                      // double sided

                // Sun
                SunNode          = SCNNode.Create();
                SunNode.Position = new SCNVector3(0, 30, 0);
                ContentNode.AddChildNode(SunNode);
                SunNode.AddChildNode((SCNNode)WireframeBoxNode.Copy());

                // Earth-rotation (center of rotation of the Earth around the Sun)
                var earthRotationNode = SCNNode.Create();
                SunNode.AddChildNode(earthRotationNode);

                // Earth-group (will contain the Earth, and the Moon)
                EarthGroupNode          = SCNNode.Create();
                EarthGroupNode.Position = new SCNVector3(15, 0, 0);
                earthRotationNode.AddChildNode(EarthGroupNode);

                // Earth
                EarthNode          = (SCNNode)WireframeBoxNode.Copy();
                EarthNode.Position = new SCNVector3(0, 0, 0);
                EarthGroupNode.AddChildNode(EarthNode);

                // Rotate the Earth around the Sun
                var animation = CABasicAnimation.FromKeyPath("rotation");
                animation.Duration    = 10.0f;
                animation.To          = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2)));
                animation.RepeatCount = float.MaxValue;
                earthRotationNode.AddAnimation(animation, new NSString("earth rotation around sun"));

                // Rotate the Earth
                animation             = CABasicAnimation.FromKeyPath("rotation");
                animation.Duration    = 1.0f;
                animation.From        = NSValue.FromVector(new SCNVector4(0, 1, 0, 0));
                animation.To          = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2)));
                animation.RepeatCount = float.MaxValue;
                EarthNode.AddAnimation(animation, new NSString("earth rotation"));
                break;

            case 2:
                // Moon-rotation (center of rotation of the Moon around the Earth)
                var moonRotationNode = SCNNode.Create();
                EarthGroupNode.AddChildNode(moonRotationNode);

                // Moon
                MoonNode          = (SCNNode)WireframeBoxNode.Copy();
                MoonNode.Position = new SCNVector3(5, 0, 0);
                moonRotationNode.AddChildNode(MoonNode);

                // Rotate the moon around the Earth
                animation             = CABasicAnimation.FromKeyPath("rotation");
                animation.Duration    = 1.5f;
                animation.To          = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2)));
                animation.RepeatCount = float.MaxValue;
                moonRotationNode.AddAnimation(animation, new NSString("moon rotation around earth"));

                // Rotate the moon
                animation             = CABasicAnimation.FromKeyPath("rotation");
                animation.Duration    = 1.5f;
                animation.To          = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2)));
                animation.RepeatCount = float.MaxValue;
                MoonNode.AddAnimation(animation, new NSString("moon rotation"));
                break;

            case 3:
                // Add geometries (spheres) to represent the stars
                SunNode.Geometry   = SCNSphere.Create(2.5f);
                EarthNode.Geometry = SCNSphere.Create(1.5f);
                MoonNode.Geometry  = SCNSphere.Create(0.75f);

                // Add a textured plane to represent Earth's orbit
                var earthOrbit = SCNNode.Create();
                earthOrbit.Opacity  = 0.4f;
                earthOrbit.Geometry = SCNPlane.Create(31, 31);
                earthOrbit.Geometry.FirstMaterial.Diffuse.Contents  = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/orbit", "png"));
                earthOrbit.Geometry.FirstMaterial.Diffuse.MipFilter = SCNFilterMode.Linear;
                earthOrbit.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 2));
                earthOrbit.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Constant;                 // no lighting
                SunNode.AddChildNode(earthOrbit);
                break;

            case 4:
                // Add a halo to the Sun (a simple textured plane that does not write to depth)
                SunHaloNode          = SCNNode.Create();
                SunHaloNode.Geometry = SCNPlane.Create(30, 30);
                SunHaloNode.Rotation = new SCNVector4(1, 0, 0, Pitch * (float)(Math.PI / 180.0f));
                SunHaloNode.Geometry.FirstMaterial.Diffuse.Contents    = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/sun-halo", "png"));
                SunHaloNode.Geometry.FirstMaterial.LightingModelName   = SCNLightingModel.Constant; // no lighting
                SunHaloNode.Geometry.FirstMaterial.WritesToDepthBuffer = false;                     // do not write to depth
                SunHaloNode.Opacity = 0.2f;
                SunNode.AddChildNode(SunHaloNode);

                // Add materials to the stars
                EarthNode.Geometry.FirstMaterial.Diffuse.Contents  = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/earth-diffuse-mini", "jpg"));
                EarthNode.Geometry.FirstMaterial.Emission.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/earth-emissive-mini", "jpg"));
                EarthNode.Geometry.FirstMaterial.Specular.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/earth-specular-mini", "jpg"));
                MoonNode.Geometry.FirstMaterial.Diffuse.Contents   = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/moon", "jpg"));
                SunNode.Geometry.FirstMaterial.Multiply.Contents   = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/sun", "jpg"));
                SunNode.Geometry.FirstMaterial.Diffuse.Contents    = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/sun", "jpg"));
                SunNode.Geometry.FirstMaterial.Multiply.Intensity  = 0.5f;
                SunNode.Geometry.FirstMaterial.LightingModelName   = SCNLightingModel.Constant;

                SunNode.Geometry.FirstMaterial.Multiply.WrapS            =
                    SunNode.Geometry.FirstMaterial.Diffuse.WrapS         =
                        SunNode.Geometry.FirstMaterial.Multiply.WrapT    =
                            SunNode.Geometry.FirstMaterial.Diffuse.WrapT = SCNWrapMode.Repeat;

                EarthNode.Geometry.FirstMaterial.LocksAmbientWithDiffuse       =
                    MoonNode.Geometry.FirstMaterial.LocksAmbientWithDiffuse    =
                        SunNode.Geometry.FirstMaterial.LocksAmbientWithDiffuse = true;

                EarthNode.Geometry.FirstMaterial.Shininess          = 0.1f;
                EarthNode.Geometry.FirstMaterial.Specular.Intensity = 0.5f;
                MoonNode.Geometry.FirstMaterial.Specular.Contents   = NSColor.Gray;

                // Achieve a lava effect by animating textures
                animation          = CABasicAnimation.FromKeyPath("contentsTransform");
                animation.Duration = 10.0f;

                var animationTransform1 = CATransform3D.MakeTranslation(0, 0, 0);
                animationTransform1 = animationTransform1.Concat(CATransform3D.MakeScale(3, 3, 3));
                var animationTransform2 = CATransform3D.MakeTranslation(1, 0, 0);
                animationTransform2 = animationTransform1.Concat(CATransform3D.MakeScale(3, 3, 3));

                animation.From        = NSValue.FromCATransform3D(animationTransform1);
                animation.To          = NSValue.FromCATransform3D(animationTransform2);
                animation.RepeatCount = float.MaxValue;
                SunNode.Geometry.FirstMaterial.Diffuse.AddAnimation(animation, new NSString("sun-texture"));

                animation          = CABasicAnimation.FromKeyPath("contentsTransform");
                animation.Duration = 30.0f;

                animationTransform1 = CATransform3D.MakeTranslation(0, 0, 0);
                animationTransform1 = animationTransform1.Concat(CATransform3D.MakeScale(5, 5, 5));
                animationTransform2 = CATransform3D.MakeTranslation(1, 0, 0);
                animationTransform2 = animationTransform1.Concat(CATransform3D.MakeScale(5, 5, 5));

                animation.From        = NSValue.FromCATransform3D(animationTransform1);
                animation.To          = NSValue.FromCATransform3D(animationTransform2);
                animation.RepeatCount = float.MaxValue;
                SunNode.Geometry.FirstMaterial.Multiply.AddAnimation(animation, new NSString("sun-texture2"));
                break;

            case 5:
                // We will turn off all the lights in the scene and add a new light
                // to give the impression that the Sun lights the scene
                var lightNode = SCNNode.Create();
                lightNode.Light           = SCNLight.Create();
                lightNode.Light.Color     = NSColor.Black;             // initially switched off
                lightNode.Light.LightType = SCNLightType.Omni;
                SunNode.AddChildNode(lightNode);

                // Configure attenuation distances because we don't want to light the floor
                lightNode.Light.SetAttribute(new NSNumber(20), SCNLightAttribute.AttenuationEndKey);
                lightNode.Light.SetAttribute(new NSNumber(19.5), SCNLightAttribute.AttenuationStartKey);

                // Animation
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                lightNode.Light.Color            = NSColor.White;                               // switch on
                presentationViewController.UpdateLightingWithIntensities(new float[] { 0.0f }); //switch off all the other lights
                SunHaloNode.Opacity = 0.5f;                                                     // make the halo stronger
                SCNTransaction.Commit();
                break;
            }
        }
Exemplo n.º 16
0
 public void SetCollapsed(ContentNode contentNode)
 {
     expanded.SetCollapsed(contentNode.FullPath);
 }
Exemplo n.º 17
0
 public bool IsExpanded(ContentNode contentNode)
 {
     return(expanded.IsExpanded(contentNode.FullPath));
 }
Exemplo n.º 18
0
        private ContentNodeKit CreateContentNodeKit(ContentSourceDto dto, IContentCacheDataSerializer serializer)
        {
            ContentData d = null;
            ContentData p = null;

            if (dto.Edited)
            {
                if (dto.EditData == null && dto.EditDataRaw == null)
                {
                    if (Debugger.IsAttached)
                    {
                        throw new InvalidOperationException("Missing cmsContentNu edited content for node " + dto.Id + ", consider rebuilding.");
                    }

                    _logger.LogWarning("Missing cmsContentNu edited content for node {NodeId}, consider rebuilding.", dto.Id);
                }
                else
                {
                    bool published           = false;
                    var  deserializedContent = serializer.Deserialize(dto, dto.EditData, dto.EditDataRaw, published);

                    d = new ContentData
                    {
                        Name         = dto.EditName,
                        Published    = published,
                        TemplateId   = dto.EditTemplateId,
                        VersionId    = dto.VersionId,
                        VersionDate  = dto.EditVersionDate,
                        WriterId     = dto.EditWriterId,
                        Properties   = deserializedContent.PropertyData, // TODO: We don't want to allocate empty arrays
                        CultureInfos = deserializedContent.CultureData,
                        UrlSegment   = deserializedContent.UrlSegment
                    };
                }
            }

            if (dto.Published)
            {
                if (dto.PubData == null && dto.PubDataRaw == null)
                {
                    if (Debugger.IsAttached)
                    {
                        throw new InvalidOperationException("Missing cmsContentNu published content for node " + dto.Id + ", consider rebuilding.");
                    }

                    _logger.LogWarning("Missing cmsContentNu published content for node {NodeId}, consider rebuilding.", dto.Id);
                }
                else
                {
                    bool published           = true;
                    var  deserializedContent = serializer.Deserialize(dto, dto.PubData, dto.PubDataRaw, published);

                    p = new ContentData
                    {
                        Name         = dto.PubName,
                        UrlSegment   = deserializedContent.UrlSegment,
                        Published    = published,
                        TemplateId   = dto.PubTemplateId,
                        VersionId    = dto.VersionId,
                        VersionDate  = dto.PubVersionDate,
                        WriterId     = dto.PubWriterId,
                        Properties   = deserializedContent.PropertyData, // TODO: We don't want to allocate empty arrays
                        CultureInfos = deserializedContent.CultureData
                    };
                }
            }

            var n = new ContentNode(dto.Id, dto.Key,
                                    dto.Level, dto.Path, dto.SortOrder, dto.ParentId, dto.CreateDate, dto.CreatorId);

            var s = new ContentNodeKit
            {
                Node          = n,
                ContentTypeId = dto.ContentTypeId,
                DraftData     = d,
                PublishedData = p
            };

            return(s);
        }
Exemplo n.º 19
0
 int SubtreeSize(ContentNode node)
 {
     return(1 + node.Children.Sum(child => (child.IsExpanded ? SubtreeSize(child) : 1)));
 }
Exemplo n.º 20
0
		public void SetCollapsed(ContentNode contentNode)
		{
			expanded.SetCollapsed(contentNode.FullPath);
		}
Exemplo n.º 21
0
        private void CreateRecursively(IEnumerable <SeedEntry> seedEntries, ICollection <ContentNode> nodeCollection, ContentNode parentNode)
        {
            var branch = new List <ContentNode>();

            if (seedEntries == null)
            {
                return;
            }

            foreach (var seedItem in seedEntries)
            {
                ContentNode  node  = null;
                ContentStyle style = new ContentStyle();

                // TODO: Css classes have been moved under style (remove once old templates have been updated)
                if (!string.IsNullOrEmpty(seedItem.Css))
                {
                    style.NodeClasses = seedItem?.Css;
                }

                if (!string.IsNullOrEmpty(seedItem.Style?.Classes))
                {
                    style.NodeClasses = seedItem.Style.Classes;
                }

                if (!string.IsNullOrEmpty(seedItem.Style?.Background))
                {
                    style.BackgroundClass = seedItem.Style.Background;
                }

                if (!string.IsNullOrEmpty(seedItem.Style?.Padding))
                {
                    style.PaddingTop    = seedItem.Style.Padding;
                    style.PaddingBottom = seedItem.Style.Padding;
                }
                else
                {
                    style.PaddingTop    = seedItem.Style?.PaddingTop;
                    style.PaddingBottom = seedItem.Style?.PaddingBottom;
                }


                // TODO: rename "zone" to layout everywhere.
                if (seedItem.Type == "zone")
                {
                    node = CreateLayoutNode(seedItem.View, style, seedItem.Zone, parentNode?.Id);
                }
                else
                {
                    var          stringModel = JsonConvert.SerializeObject(seedItem.Model);
                    IWidgetModel widgetModel;

                    try
                    {
                        widgetModel = _widgetProvider.Create(seedItem.Type, stringModel);
                    }
                    catch (Exception)
                    {
                        widgetModel = null;
                    }

                    node = CreateContentNode(seedItem.Type, style, widgetModel, seedItem.Zone, parentNode?.Id);
                }


                nodeCollection.Add(node);

                if (seedItem.Children != null && seedItem.Children.Count() > 0)
                {
                    node.ChildNodes = new List <ContentNode>();
                    CreateRecursively(seedItem.Children, node.ChildNodes, node);
                }
            }
        }
Exemplo n.º 22
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            SCNTransaction.Begin();

            switch (index)
            {
            case 1:
                TextManager.FlipOutText(SlideTextManager.TextType.Bullet);

                TextManager.SetSubtitle("API");

                TextManager.AddEmptyLine();
                TextManager.AddCode("#aMaterial.#ShaderModifiers# = new SCNShaderModifiers {\n"
                                    + "     <Entry Point> = <GLSL Code>\n"
                                    + "};#");
                TextManager.FlipInText(SlideTextManager.TextType.Code);
                TextManager.FlipInText(SlideTextManager.TextType.Subtitle);

                break;

            case 2:
                TextManager.FlipOutText(SlideTextManager.TextType.Code);

                TextManager.AddEmptyLine();
                TextManager.AddCode("#aMaterial.#ShaderModifiers# = new SCNShaderModifiers { \n"
                                    + "     EntryCGPointragment = \n"
                                    + "     new Vector3 (1.0f) - #output#.Color.GetRgb () \n"
                                    + "};#");

                TextManager.FlipInText(SlideTextManager.TextType.Code);

                break;

            case 3:
                TextManager.FlipOutText(SlideTextManager.TextType.Code);
                TextManager.FlipOutText(SlideTextManager.TextType.Subtitle);

                TextManager.SetSubtitle("Entry points");

                TextManager.AddBulletAtLevel("Geometry", 0);
                TextManager.AddBulletAtLevel("Surface", 0);
                TextManager.AddBulletAtLevel("Lighting", 0);
                TextManager.AddBulletAtLevel("Fragment", 0);
                TextManager.FlipInText(SlideTextManager.TextType.Bullet);
                TextManager.FlipInText(SlideTextManager.TextType.Subtitle);

                break;

            case 4:
                SCNTransaction.AnimationDuration = 1;

                TextManager.HighlightBullet(0);

                // Create a (very) tesselated plane
                var plane = SCNPlane.Create(10, 10);
                plane.WidthSegmentCount  = 200;
                plane.HeightSegmentCount = 200;

                // Setup the material (same as the floor)
                plane.FirstMaterial.Diffuse.WrapS             = SCNWrapMode.Mirror;
                plane.FirstMaterial.Diffuse.WrapT             = SCNWrapMode.Mirror;
                plane.FirstMaterial.Diffuse.Contents          = new NSImage("/Library/Desktop Pictures/Circles.jpg");
                plane.FirstMaterial.Diffuse.ContentsTransform = SCNMatrix4.CreateFromAxisAngle(new SCNVector3(0, 0, 1), NMath.PI / 4);
                plane.FirstMaterial.Specular.Contents         = NSColor.White;
                plane.FirstMaterial.Reflective.Contents       = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/envmap", "jpg"));
                plane.FirstMaterial.Reflective.Intensity      = 0.0f;

                // Create a node to hold that plane
                PlaneNode          = SCNNode.Create();
                PlaneNode.Position = new SCNVector3(0, 0.1f, 0);
                PlaneNode.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 2));
                PlaneNode.Scale    = new SCNVector3(5, 5, 1);
                PlaneNode.Geometry = plane;
                ContentNode.AddChildNode(PlaneNode);

                // Attach the "wave" shader modifier, and set an initial intensity value of 0
                var shaderFile       = NSBundle.MainBundle.PathForResource("Shaders/wave", "shader");
                var geometryModifier = File.ReadAllText(shaderFile);
                PlaneNode.Geometry.ShaderModifiers = new SCNShaderModifiers {
                    EntryPointGeometry = geometryModifier
                };
                PlaneNode.Geometry.SetValueForKey(new NSNumber(0.0f), new NSString("intensity"));

                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 0;
                // Show the pseudo code for the deformation
                var textNode = TextManager.AddCode("#float len = #geometry#.Position.Xy.Length;\n"
                                                   + "aMaterial.ShaderModifiers = new SCNShaderModifiers { \n"
                                                   + "     #EntryPointGeometry# = geometry.Position.Y \n"
                                                   + "};#");

                textNode.Position = new SCNVector3(8.5f, 7, 0);
                SCNTransaction.Commit();
                break;

            case 5:
                // Progressively increase the intensity
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 2;
                PlaneNode.Geometry.SetValueForKey(new NSNumber(1.0f), new NSString("intensity"));
                PlaneNode.Geometry.FirstMaterial.Reflective.Intensity = 0.3f;
                SCNTransaction.Commit();

                // Redraw forever
                ((SCNView)presentationViewController.View).Playing = true;
                ((SCNView)presentationViewController.View).Loops   = true;
                break;

            case 6:
                SCNTransaction.AnimationDuration = 1;

                TextManager.FadeOutText(SlideTextManager.TextType.Code);

                // Hide the plane used for the previous modifier
                PlaneNode.Geometry.SetValueForKey(new NSNumber(0.0f), new NSString("intensity"));
                PlaneNode.Geometry.FirstMaterial.Reflective.Intensity = 0.0f;
                PlaneNode.Opacity = 0.0f;

                // Create a sphere to illustrate the "car paint" modifier
                var sphere = SCNSphere.Create(6);
                sphere.SegmentCount = 100;
                sphere.FirstMaterial.Diffuse.Contents    = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/noise", "png"));
                sphere.FirstMaterial.Diffuse.WrapS       = SCNWrapMode.Repeat;
                sphere.FirstMaterial.Diffuse.WrapT       = SCNWrapMode.Repeat;
                sphere.FirstMaterial.Reflective.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/envmap3", "jpg"));
                sphere.FirstMaterial.FresnelExponent     = 1.3f;

                SphereNode          = SCNNode.FromGeometry(sphere);
                SphereNode.Position = new SCNVector3(5, 6, 0);
                GroundNode.AddChildNode(SphereNode);

                // Attach the "car paint" shader modifier
                shaderFile = NSBundle.MainBundle.PathForResource("Shaders/carPaint", "shader");
                var surfaceModifier = File.ReadAllText(shaderFile);
                sphere.FirstMaterial.ShaderModifiers = new SCNShaderModifiers {
                    EntryPointSurface = surfaceModifier
                };

                var rotationAnimation = CABasicAnimation.FromKeyPath("rotation");
                rotationAnimation.Duration    = 15.0f;
                rotationAnimation.RepeatCount = float.MaxValue;
                rotationAnimation.By          = NSValue.FromVector(new SCNVector4(0, 1, 0, -(float)(Math.PI * 2)));
                SphereNode.AddAnimation(rotationAnimation, new NSString("sphereNodeAnimation"));

                TextManager.HighlightBullet(1);
                break;

            case 7:
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration       = 1.5f;
                SCNTransaction.AnimationTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
                // Move the camera closer
                presentationViewController.CameraNode.Position = new SCNVector3(5, -0.5f, -17);
                SCNTransaction.Commit();
                break;

            case 8:
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration       = 1.0f;
                SCNTransaction.AnimationTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
                // Move back
                presentationViewController.CameraNode.Position = new SCNVector3(0, 0, 0);
                SCNTransaction.Commit();
                break;

            case 9:
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1.0f;
                // Hide the sphere used for the previous modifier
                SphereNode.Opacity  = 0.0f;
                SphereNode.Position = new SCNVector3(6, 4, -8);
                SCNTransaction.Commit();

                SCNTransaction.AnimationDuration = 0;

                TextManager.HighlightBullet(2);

                // Load the model, animate
                var intermediateNode = SCNNode.Create();
                intermediateNode.Position = new SCNVector3(4, 0.1f, 10);
                TorusNode = Utils.SCAddChildNode(intermediateNode, "torus", "Scenes/torus/torus", 11);

                rotationAnimation             = CABasicAnimation.FromKeyPath("rotation");
                rotationAnimation.Duration    = 10.0f;
                rotationAnimation.RepeatCount = float.MaxValue;
                rotationAnimation.To          = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2)));
                TorusNode.AddAnimation(rotationAnimation, new NSString("torusNodeAnimation"));

                GroundNode.AddChildNode(intermediateNode);

                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1.0f;
                intermediateNode.Position        = new SCNVector3(4, 0.1f, 0);
                SCNTransaction.Commit();

                break;

            case 10:
                // Attach the shader modifier
                shaderFile = NSBundle.MainBundle.PathForResource("Shaders/toon", "shader");
                var lightingModifier = File.ReadAllText(shaderFile);
                TorusNode.Geometry.ShaderModifiers = new SCNShaderModifiers {
                    EntryPointLightingModel = lightingModifier
                };
                break;

            case 11:
                SCNTransaction.AnimationDuration = 1.0f;

                // Hide the torus used for the previous modifier
                TorusNode.Position = new SCNVector3(TorusNode.Position.X, TorusNode.Position.Y, TorusNode.Position.Z - 10);
                TorusNode.Opacity  = 0.0f;

                // Load the model, animate
                intermediateNode          = SCNNode.Create();
                intermediateNode.Position = new SCNVector3(4, -2.6f, 14);
                intermediateNode.Scale    = new SCNVector3(70, 70, 70);

                XRayNode          = Utils.SCAddChildNode(intermediateNode, "node", "Scenes/bunny", 12);
                XRayNode.Position = new SCNVector3(0, 0, 0);
                XRayNode.Opacity  = 0.0f;

                GroundNode.AddChildNode(intermediateNode);

                rotationAnimation             = CABasicAnimation.FromKeyPath("rotation");
                rotationAnimation.Duration    = 10.0f;
                rotationAnimation.RepeatCount = float.MaxValue;
                rotationAnimation.From        = NSValue.FromVector(new SCNVector4(0, 1, 0, 0));
                rotationAnimation.To          = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2)));
                intermediateNode.AddAnimation(rotationAnimation, new NSString("bunnyNodeAnimation"));

                TextManager.HighlightBullet(3);

                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1.0f;
                XRayNode.Opacity          = 1.0f;
                intermediateNode.Position = new SCNVector3(4, -2.6f, -2);
                SCNTransaction.Commit();
                break;

            case 12:
                // Attach the "x ray" modifier
                shaderFile = NSBundle.MainBundle.PathForResource("Shaders/xRay", "shader");
                var fragmentModifier = File.ReadAllText(shaderFile);
                XRayNode.Geometry.ShaderModifiers = new SCNShaderModifiers {
                    EntryPointFragment = fragmentModifier
                };
                XRayNode.Geometry.FirstMaterial.ReadsFromDepthBuffer = false;
                break;

            case 13:
                // Highlight everything
                TextManager.HighlightBullet(-1);

                // Hide the node used for the previous modifier
                XRayNode.Opacity             = 0.0f;
                XRayNode.ParentNode.Position = new SCNVector3(4, -2.6f, -5);

                // Create the model
                sphere = SCNSphere.Create(5);
                sphere.SegmentCount = 150;                 // tesselate a lot

                VirusNode          = SCNNode.FromGeometry(sphere);
                VirusNode.Position = new SCNVector3(3, 6, 0);
                VirusNode.Rotation = new SCNVector4(1, 0, 0, Pitch * (float)(Math.PI / 180.0f));
                GroundNode.AddChildNode(VirusNode);

                // Set the shader modifiers
                var geomFile  = NSBundle.MainBundle.PathForResource("Shaders/sm_geom", "shader");
                var surfFile  = NSBundle.MainBundle.PathForResource("Shaders/sm_surf", "shader");
                var lightFile = NSBundle.MainBundle.PathForResource("Shaders/sm_light", "shader");
                var fragFile  = NSBundle.MainBundle.PathForResource("Shaders/sm_frag", "shader");
                geometryModifier = File.ReadAllText(geomFile);
                surfaceModifier  = File.ReadAllText(surfFile);
                lightingModifier = File.ReadAllText(lightFile);
                fragmentModifier = File.ReadAllText(fragFile);
                VirusNode.Geometry.FirstMaterial.ShaderModifiers = new SCNShaderModifiers {
                    EntryPointGeometry      = geometryModifier,
                    EntryPointSurface       = surfaceModifier,
                    EntryPointLightingModel = lightingModifier,
                    EntryPointFragment      = fragmentModifier
                };
                break;

            case 14:
                SCNTransaction.AnimationDuration = 1.0f;

                // Hide the node used for the previous modifier
                VirusNode.Opacity  = 0.0f;
                VirusNode.Position = new SCNVector3(3, 6, -10);

                // Change the text
                TextManager.FadeOutText(SlideTextManager.TextType.Code);
                TextManager.FlipOutText(SlideTextManager.TextType.Bullet);
                TextManager.FlipOutText(SlideTextManager.TextType.Subtitle);

                TextManager.SetSubtitle("SCNShadable");

                TextManager.AddBulletAtLevel("Protocol adopted by SCNMaterial and SCNGeometry", 0);
                TextManager.AddBulletAtLevel("Shaders parameters are animatable", 0);
                TextManager.AddBulletAtLevel("Texture samplers are bound to a SCNMaterialProperty", 0);

                TextManager.AddCode("#var aProperty = SCNMaterialProperty.#Create# (anImage);\n"
                                    + "aMaterial.#SetValueForKey# (aProperty, #new NSString# (\"aSampler\"));#");

                TextManager.FlipInText(SlideTextManager.TextType.Subtitle);
                TextManager.FlipInText(SlideTextManager.TextType.Bullet);
                TextManager.FlipInText(SlideTextManager.TextType.Code);
                break;
            }
            SCNTransaction.Commit();
        }
Exemplo n.º 23
0
        internal void    Finish(ValidationEventHandler eventHandler, bool compile) {
            stack = null;
            IsCompiled = !abnormalContent && compile;
            if (contentNode == null)
                return;

#if DEBUG
            StringBuilder bb = new StringBuilder();
            contentNode.Dump(bb);
            Debug.WriteLineIf(CompModSwitches.XmlSchema.TraceVerbose, "\t\t\tContent: (" + bb.ToString() + ")");
#endif

            // add end node
            endNode = NewTerminalNode(XmlQualifiedName.Empty);
            contentNode = new InternalNode(contentNode, endNode, ContentNode.Type.Sequence);
            ((InternalNode)contentNode).LeftNode.ParentNode = contentNode;
            endNode.ParentNode = contentNode;

            if (!IsCompiled) {
                CheckXsdDeterministic(eventHandler);
                return;
            }

            if (nodeTable == null)
                nodeTable = new Hashtable();

            // calculate followpos
            int terminals = terminalNodes.Count;
            BitSet[] followpos = new BitSet[terminals];
            for (int i = 0; i < terminals; i++) {
                followpos[i] = new BitSet(terminals);
            }
            contentNode.CalcFollowpos(followpos);

            // state table
            ArrayList Dstates = new ArrayList(16);
            // transition table
            dtrans = new ArrayList(16);
            // lists unmarked states
            ArrayList unmarked = new ArrayList(16);
            // state lookup table
            Hashtable statetable = new Hashtable();

            BitSet empty = new BitSet(terminals);
            statetable.Add(empty, -1);

            // start with firstpos at the root
            BitSet set = contentNode.Firstpos(terminals);
            statetable.Add(set, Dstates.Count);
            unmarked.Add(set);
            Dstates.Add(set);

            int[] a = new int[symbols.Count + 1];
            dtrans.Add(a);
            if (set.Get(endNode.Pos)) {
                a[symbols.Count] = 1;   // accepting
            }

            // current state processed
            int state = 0;

            // check all unmarked states
            while (unmarked.Count > 0) {
                int[] t = (int[])dtrans[state];

                set = (BitSet)unmarked[0];
                CheckDeterministic(set, terminals, eventHandler);
                unmarked.RemoveAt(0);

                // check all input symbols
                for (int sym = 0; sym < symbols.Count; sym++) {
                    XmlQualifiedName n = (XmlQualifiedName)symbols[sym];
                    BitSet newset = new BitSet(terminals);

                    // if symbol is in the set add followpos to new set
                    for (int i = 0; i < terminals; i++) {
                        if (set.Get(i) && n.Equals(((TerminalNode)terminalNodes[i]).Name)) {
                            newset.Or(followpos[i]);
                        }
                    }

                    Object lookup = statetable[newset];
                    // this state will transition to
                    int transitionTo;
                    // if new set is not in states add it
                    if (lookup == null) {
                        transitionTo = Dstates.Count;
                        statetable.Add(newset, transitionTo);
                        unmarked.Add(newset);
                        Dstates.Add(newset);
                        a = new int[symbols.Count + 1];
                        dtrans.Add(a);
                        if (newset.Get(endNode.Pos)) {
                            a[symbols.Count] = 1;   // accepting
                        }
                    }
                    else {
                        transitionTo = (int)lookup;
                    }
                    // set the transition for the symbol
                    t[sym] = transitionTo;
                }
                state++;
            }

            nodeTable = null;
        }
Exemplo n.º 24
0
        protected Node Klammer()
        {
            int sign = 1;

            if (Current.TokenType == TT.TT_Plus || Current.TokenType == TT.TT_Minus)
            {
                if (Current.TokenType == TT.TT_Minus)
                {
                    sign = -1;
                }
                AcceptAny(); //Accept + | -
            }

            switch (Current.TokenType)
            {
            case TT.TT_IdentCALLC:
                return(CALLC());

            case TT.TT_IdentCALLO:
                return(CALLO());

            case TT.TT_ExclaMark:
                Accept(TT.TT_ExclaMark);
                Node e = Klammer();
                if (e.ContentType == typeof(bool))
                {
                    return(new LogicNode <bool, bool>(LogicOperator.Equal, (ContentNode <bool>)e, new ContentNode <bool>(false)));
                }
                break;

            case TT.TT_Dollar:
                Node v = Variable();
                if (sign < 0)
                {
                    v = NodeFactory.GenMathNode(MathNodeOperator.MULTI, v, new ContentNode <int>(-1));
                }
                return(v);

            case TT.TT_ParenLeft:
                //Klammer auf
                Accept(TT.TT_ParenLeft);
                Node pl = Addition();
                if (sign < 0)
                {
                    if (pl.IsContentNode)
                    {
                        pl = NodeFactory.GenMathNode(MathNodeOperator.MULTI, pl, new ContentNode <int>(-1));
                    }
                    else
                    {
#warning Script Implement Error Handling
                        Console.WriteLine("Error - 5");
                    }
                }
                Accept(TT.TT_ParenRight);
                return(pl);

            case TT.TT_IntNumber:
                ContentNode <int> i = new ContentNode <int>(((TokenWithContent <int>)(Current)).Content);
                Accept(TT.TT_IntNumber);
                if (sign < 0)
                {
                    return(new MathNode <int, int>(MathNodeOperator.MULTI, i, new ContentNode <int>(-1)));
                }
                return(i);

            case TT.TT_DoubleNumber:
                ContentNode <double> d = new ContentNode <double>(((TokenWithContent <double>)(Current)).Content);
                Accept(TT.TT_DoubleNumber);
                if (sign < 0)
                {
                    return(new MathNode <double, int>(MathNodeOperator.MULTI, d, new ContentNode <int>(-1)));
                }
                return(d);

            case TT.TT_IdentCast:
                return(IdentCast());

            case TT.TT_IdentInline:
                Node n = IdentInline();
                if (sign < 0)
                {
                    n = NodeFactory.GenMathNode(MathNodeOperator.MULTI, n, new ContentNode <int>(-1));
                }
                return(n);

            case TT.TT_IdentISSET:
                return(IdentIsset());

            case TT.TT_IdentTRUEFALSE:
                Node tf = new ContentNode <bool>(((TokenWithContent <bool>)Current).Content);
                Accept(TT.TT_IdentTRUEFALSE);
                return(tf);

            case TT.TT_String:
                Node s = new ContentNode <string>(((TokenWithContent <string>)Current).Content);
                Accept(TT.TT_String);
                return(s);

            default:
#warning Script Implement Error Handling
                Console.WriteLine("Error - 6");
                break;
            }

            return(null);
        }
Exemplo n.º 25
0
 private bool Accepts(ContentNode node, XmlQualifiedName qname, int positions, Object index) {
     if (index != null) {
         BitSet first = node.Firstpos(positions);
         for (int i = 0; i < first.Count; i++) {
             if (first.Get(i) && qname.Equals(((TerminalNode)terminalNodes[i]).Name))
                 return true;
         }
         return false;
     }
     else {
         return node.Accepts(qname);
     }
 }
Exemplo n.º 26
0
        private IEnumerable<WordAndFontLine> ContentNodeToLines(ContentNode node, float widthToFill, Func<float, float> calculateIndent)
        {
            List<WordAndFont> buffer = new List<WordAndFont>();
            float currentLength = 0;
            var liner = node.Linearize().GetEnumerator();

            do {
                bool hasMore = liner.MoveNext();
                float toAdd = hasMore ? liner.Current.Word.Length * _settings.EffectiveCharWidth : 0;
                bool isTooLong = hasMore && (currentLength + toAdd > widthToFill);

                if (!hasMore || isTooLong) {
                    // Dump the buffer.
                    float indent = calculateIndent(currentLength);
                    yield return new WordAndFontLine(buffer.ToArray(), indent);
                    buffer.Clear();
                    currentLength = 0;
                }

                if (!hasMore)
                    break;

                buffer.Add(liner.Current);
                currentLength += toAdd + _settings.EffectiveCharWidth;
            } while(true);
        }
Exemplo n.º 27
0
 public WHILENode(ContentNode<bool> decider, List<Node> whilenodes)
     : base()
 {
     Decider = decider;
     Whilenodes = whilenodes;
 }
Exemplo n.º 28
0
        private void WriteContentNode(ContentNode node, float widthToFill, 
		                              Func<float, float> calculateIndent,
		                             Action<int> notEnoughRoom)
        {
            var lines = ContentNodeToLines(node, widthToFill, calculateIndent).ToArray();
            int linesWritten = 0;

            for(int x=0; x<lines.Length; x++) {
                if (!HaveRoomFor(2) && lines.Length > 2) {
                    if (notEnoughRoom == null)
                        NewPage();
                    else
                        notEnoughRoom(linesWritten);
                }

                WriteContentLine(lines[x]);
                MoveDown(1);
                linesWritten += 1;
            }
            MoveDown(1);
        }
Exemplo n.º 29
0
 void AddWriteContentNode(ContentNode n, StatementList statements, TypeNode referringType, Identifier writer, Expression source) {
   if (n.TypeNode == null) {
     Debug.Assert(n is SequenceNode);
     // In the class inheritance case we have two independent left and right children inside
     // a parent sequence that has no unified type or member.
     SequenceNode s = (SequenceNode)n;
     AddWriteContentNode(s.LeftChild, statements, referringType, writer, source);
     AddWriteContentNode(s.RightChild, statements, referringType, writer, source);
     return;
   }
   TypeNode ct = n.TypeNode;
   Expression src = source;
   if (n.Member != null && !(n.Member is Method))  {
     src = GetMemberBinding(source, n.Member, ct);
   }
   if (ct.Template == SystemTypes.GenericBoxed) {
     statements = AddCheckForNull(statements, Duplicate(src, referringType), ct);
     ct = Checker.GetCollectionElementType(ct);  
     src = CastTo(src, ct);//unbox it
   }
   if (ct is TupleType) {
     AddWriteTuple(ct as TupleType, statements, referringType, src, writer);
   } else if (ct is TypeUnion) {
     AddWriteChoice(ct as TypeUnion, statements, referringType, src, writer);
   } else if (IsStream(ct)) {
     AddWriteStream(ct, statements, referringType, src, writer);
   } else if (ct is TypeAlias) {
     TypeAlias alias = (TypeAlias)ct;
     src = CastTo(src, alias.AliasedType); //unbox it
     AddWriteElement(statements, referringType, writer, alias.Name, src, alias.AliasedType, true);
   } else {
     AddWriteElement(statements, referringType, writer, ct.Name, src, ct, true);
   }        
 }
Exemplo n.º 30
0
        public void Refresh(IContentNode ownerNode, NodeContainer nodeContainer)
        {
            var newObjectValue = ownerNode.Value;

            if (!(newObjectValue is IEnumerable))
            {
                throw new ArgumentException(@"The object is not an IEnumerable", nameof(newObjectValue));
            }

            ObjectValue = newObjectValue;

            var newReferences = new HybridDictionary <Index, ObjectReference>();

            if (IsDictionary)
            {
                foreach (var item in (IEnumerable)ObjectValue)
                {
                    var key   = GetKey(item);
                    var value = (ObjectReference)Reference.CreateReference(GetValue(item), ElementType, key);
                    newReferences.Add(key, value);
                }
            }
            else
            {
                var i = 0;
                foreach (var item in (IEnumerable)ObjectValue)
                {
                    var key   = new Index(i);
                    var value = (ObjectReference)Reference.CreateReference(item, ElementType, key);
                    newReferences.Add(key, value);
                    ++i;
                }
            }

            // The reference need to be updated if it has never been initialized, if the number of items is different, or if any index or any value is different.
            var needUpdate = items == null || newReferences.Count != items.Count || !AreItemsEqual(items, newReferences);

            if (needUpdate)
            {
                // We create a mapping values of the old list of references to their corresponding target node. We use a list because we can have multiple times the same target in items.
                var oldReferenceMapping = new List <KeyValuePair <object, ObjectReference> >();
                if (items != null)
                {
                    var existingIndices = ContentNode.GetIndices(ownerNode).ToList();
                    foreach (var item in items)
                    {
                        var boxedTarget = item.Value.TargetNode as BoxedContent;
                        // For collection of struct, we need to update the target nodes first so equity comparer will work. Careful tho, we need to skip removed items!
                        if (boxedTarget != null && existingIndices.Contains(item.Key))
                        {
                            // If we are boxing a struct, we reuse the same nodes if they are type-compatible and just overwrite the struct value.
                            var value = ownerNode.Retrieve(item.Key);
                            if (value?.GetType() == item.Value.TargetNode?.Type)
                            {
                                boxedTarget.UpdateFromOwner(ownerNode.Retrieve(item.Key));
                            }
                        }
                        if (item.Value.ObjectValue != null)
                        {
                            oldReferenceMapping.Add(new KeyValuePair <object, ObjectReference>(item.Value.ObjectValue, item.Value));
                        }
                    }
                }

                foreach (var newReference in newReferences)
                {
                    if (newReference.Value.ObjectValue != null)
                    {
                        var found = false;
                        var i     = 0;
                        foreach (var item in oldReferenceMapping)
                        {
                            if (Equals(newReference.Value.ObjectValue, item.Key))
                            {
                                // If this value was already present in the old list of reference, just use the same target node in the new list.
                                newReference.Value.SetTarget(item.Value.TargetNode);
                                // Remove consumed existing reference so if there is a second entry with the same "key", it will be the other reference that will be used.
                                oldReferenceMapping.RemoveAt(i);
                                found = true;
                                break;
                            }
                            ++i;
                        }
                        if (!found)
                        {
                            // Otherwise, do a full update that will properly initialize the new reference.
                            newReference.Value.Refresh(ownerNode, nodeContainer, newReference.Key);
                        }
                    }
                }
                items = newReferences;
                // Remark: this works because both KeyCollection and List implements IReadOnlyCollection. Any internal change to HybridDictionary might break this!
                Indices = (IReadOnlyCollection <Index>)newReferences.Keys;
            }
        }
Exemplo n.º 31
0
        private void SetupLookAtScene()
        {
            var intermediateNode = SCNNode.Create();

            intermediateNode.Scale    = new SCNVector3(0.5f, 0.5f, 0.5f);
            intermediateNode.Position = new SCNVector3(0, 0, 10);
            ContentNode.AddChildNode(intermediateNode);

            var ballMaterial = SCNMaterial.Create();

            ballMaterial.Diffuse.Contents     = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/pool/pool_8", "png"));
            ballMaterial.Specular.Contents    = NSColor.White;
            ballMaterial.Shininess            = 0.9f;  // shinny
            ballMaterial.Reflective.Contents  = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/color_envmap", "png"));
            ballMaterial.Reflective.Intensity = 0.5f;

            // Node hierarchy for the ball :
            //   _ballNode
            //  |__ cameraTarget      : the target for the "look at" constraint
            //  |__ ballRotationNode  : will rotate to animate the rolling ball
            //      |__ ballPivotNode : will own the geometry and will be rotated so that the "8" faces the camera at the beginning

            BallNode          = SCNNode.Create();
            BallNode.Rotation = new SCNVector4(0, 1, 0, (float)(Math.PI / 4));
            intermediateNode.AddChildNode(BallNode);

            var cameraTarget = SCNNode.Create();

            cameraTarget.Name     = "cameraTarget";
            cameraTarget.Position = new SCNVector3(0, 6, 0);
            BallNode.AddChildNode(cameraTarget);

            var ballRotationNode = SCNNode.Create();

            ballRotationNode.Position = new SCNVector3(0, 4, 0);
            BallNode.AddChildNode(ballRotationNode);

            var ballPivotNode = SCNNode.Create();

            ballPivotNode.Geometry = SCNSphere.Create(4.0f);
            ballPivotNode.Geometry.FirstMaterial = ballMaterial;
            ballPivotNode.Rotation = new SCNVector4(0, 1, 0, (float)(Math.PI / 2));
            ballRotationNode.AddChildNode(ballPivotNode);

            var arrowMaterial = SCNMaterial.Create();

            arrowMaterial.Diffuse.Contents    = NSColor.White;
            arrowMaterial.Reflective.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/chrome", "jpg"));

            var arrowContainer = SCNNode.Create();

            arrowContainer.Name = "arrowContainer";
            intermediateNode.AddChildNode(arrowContainer);

            var arrowPath = Utils.SCArrowBezierPath(new CGSize(6, 2), new CGSize(3, 5), 0.5f, false);

            // Create the arrows
            for (var i = 0; i < 11; i++)
            {
                var arrowNode = SCNNode.Create();
                arrowNode.Position = new SCNVector3((float)Math.Cos(Math.PI * i / 10.0f) * 20.0f, 3 + 18.5f * (float)Math.Sin(Math.PI * i / 10.0f), 0);

                var arrowGeometry = SCNShape.Create(arrowPath, 1);
                arrowGeometry.ChamferRadius = 0.2f;

                var arrowSubNode = SCNNode.Create();
                arrowSubNode.Geometry = arrowGeometry;
                arrowSubNode.Geometry.FirstMaterial = arrowMaterial;
                arrowSubNode.Pivot    = SCNMatrix4.CreateTranslation(new SCNVector3(0, 2.5f, 0));                // place the pivot (center of rotation) at the middle of the arrow
                arrowSubNode.Rotation = new SCNVector4(0, 0, 1, (float)(Math.PI / 2));

                arrowNode.AddChildNode(arrowSubNode);
                arrowContainer.AddChildNode(arrowNode);
            }
        }
Exemplo n.º 32
0
 public void Visit(ContentNode node)
 {
     query.Add(new TermQuery(new Term("__nodeType", node.ContentType)), BooleanClause.Occur.MUST);
 }
Exemplo n.º 33
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            switch (index)
            {
            case (int)TechniqueSteps.Intro:
                break;

            case (int)TechniqueSteps.Code:
                TextManager.FlipOutText(SlideTextManager.TextType.Bullet);
                PlistGroup.RemoveFromParentNode();

                TextManager.AddEmptyLine();
                TextManager.AddCode("#// Load a technique\nSCNTechnique *technique = [SCNTechnique #techniqueWithDictionary#:aDictionary];\n\n\n"
                                    + "// Chain techniques\ntechnique = [SCNTechnique #techniqueBySequencingTechniques#:@[t1, t2 ...];\n\n\n\t\t\t\t\t"
                                    + "// Set a technique\naSCNView.#technique# = technique;#");

                TextManager.FlipInText(SlideTextManager.TextType.Bullet);
                TextManager.FlipInText(SlideTextManager.TextType.Code);
                break;

            case (int)TechniqueSteps.Files:
                Pass2.RemoveFromParentNode();

                TextManager.FlipOutText(SlideTextManager.TextType.Bullet);
                TextManager.AddBulletAtLevel("Load from Plist", 0);
                TextManager.FlipInText(SlideTextManager.TextType.Code);

                PlistGroup = SCNNode.Create();
                ContentNode.AddChildNode(PlistGroup);

                //add plist icon
                var node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/plist", "png"), 8, true);
                node.Position = new SCNVector3(0, 3.7f, 10);
                PlistGroup.AddChildNode(node);

                //add plist icon
                node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/vsh", "png"), 3, true);
                for (var i = 0; i < 5; i++)
                {
                    node          = node.Clone();
                    node.Position = new SCNVector3(6, 1.4f, 10 - i);
                    PlistGroup.AddChildNode(node);
                }

                node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/fsh", "png"), 3, true);
                for (var i = 0; i < 5; i++)
                {
                    node          = node.Clone();
                    node.Position = new SCNVector3(9, 1.4f, 10 - i);
                    PlistGroup.AddChildNode(node);
                }
                break;

            case (int)TechniqueSteps.Plist:
                //add plist icon
                node          = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/technique", "png"), 9, true);
                node.Position = new SCNVector3(0, 3.5f, 10.1f);
                node.Opacity  = 0.0f;
                PlistGroup.AddChildNode(node);
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 0.75f;
                node.Position = new SCNVector3(0, 3.5f, 11);
                node.Opacity  = 1.0f;
                SCNTransaction.Commit();
                break;

            case (int)TechniqueSteps.Pass1:
                TextManager.FlipOutText(SlideTextManager.TextType.Bullet);

                node          = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/pass1", "png"), 15, true);
                node.Position = new SCNVector3(0, 3.5f, 10.1f);
                node.Opacity  = 0.0f;
                ContentNode.AddChildNode(node);
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 0.75f;
                node.Position = new SCNVector3(0, 3.5f, 11);
                node.Opacity  = 1.0f;
                SCNTransaction.Commit();
                Pass1 = node;
                break;

            case (int)TechniqueSteps.Passes3:
                Pass1.RemoveFromParentNode();
                Pass2          = SCNNode.Create();
                Pass2.Opacity  = 0.0f;
                Pass2.Position = new SCNVector3(0, 3.5f, 6);

                node          = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/pass2", "png"), 8, true);
                node.Position = new SCNVector3(-8, 0, 0);
                Pass2.AddChildNode(node);

                node          = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/pass3", "png"), 8, true);
                node.Position = new SCNVector3(0, 0, 0);
                Pass2.AddChildNode(node);

                node          = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/pass4", "png"), 8, true);
                node.Position = new SCNVector3(8, 0, 0);
                Pass2.AddChildNode(node);

                ContentNode.AddChildNode(Pass2);
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 0.75f;
                Pass2.Position = new SCNVector3(0, 3.5f, 9);
                Pass2.Opacity  = 1.0f;
                SCNTransaction.Commit();
                break;

            case (int)TechniqueSteps.Passes3Connected:
                TextManager.AddEmptyLine();
                TextManager.AddBulletAtLevel("Connect pass inputs / outputs", 0);

                node          = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/link", "png"), 8.75f, true);
                node.Position = new SCNVector3(0.01f, -2, 0);
                node.Opacity  = 0.0f;
                Pass2.AddChildNode(node);

                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 0.75f;
                var n = Pass2.ChildNodes [0];
                n.Position = new SCNVector3(-7.5f, -0.015f, 0);

                n          = Pass2.ChildNodes [2];
                n.Position = new SCNVector3(7.5f, 0.02f, 0);

                node.Opacity = 1.0f;

                SCNTransaction.Commit();
                break;

            case (int)TechniqueSteps.Sample:
                TextManager.FlipOutText(SlideTextManager.TextType.Code);
                TextManager.FlipOutText(SlideTextManager.TextType.Subtitle);
                TextManager.SetSubtitle("Example: simple depth of field");
                TextManager.FlipInText(SlideTextManager.TextType.Code);

                Pass3 = SCNNode.Create();

                node          = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/pass5", "png"), 15, true);
                node.Position = new SCNVector3(-3, 5, 10.1f);
                node.Opacity  = 0.0f;
                Pass3.AddChildNode(node);

                var t0 = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/technique0", "png"), 4, false);
                t0.Position = new SCNVector3(-8.5f, 1.5f, 10.1f);
                t0.Opacity  = 0.0f;
                Pass3.AddChildNode(t0);

                var t1 = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/technique1", "png"), 4, false);
                t1.Position = new SCNVector3(-3.6f, 1.5f, 10.1f);
                t1.Opacity  = 0.0f;
                Pass3.AddChildNode(t1);

                var t2 = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/technique2", "png"), 4, false);
                t2.Position = new SCNVector3(1.4f, 1.5f, 10.1f);
                t2.Opacity  = 0.0f;
                Pass3.AddChildNode(t2);

                var t3 = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/technique3", "png"), 8, false);
                t3.Position = new SCNVector3(8, 5, 10.1f);
                t3.Opacity  = 0.0f;
                Pass3.AddChildNode(t3);

                ContentNode.AddChildNode(Pass3);

                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 0.75f;
                node.Opacity = 1.0f;
                t0.Opacity   = 1.0f;
                t1.Opacity   = 1.0f;
                t2.Opacity   = 1.0f;
                t3.Opacity   = 1.0f;
                SCNTransaction.Commit();
                break;
            }
        }
        private ContentNodeKit CreateContentNodeKit(ContentSourceDto dto, IContentCacheDataSerializer serializer)
        {
            ContentData?d = null;
            ContentData?p = null;

            if (dto.Edited)
            {
                if (dto.EditData == null && dto.EditDataRaw == null)
                {
                    if (Debugger.IsAttached)
                    {
                        throw new InvalidOperationException("Missing cmsContentNu edited content for node " + dto.Id + ", consider rebuilding.");
                    }

                    _logger.LogWarning("Missing cmsContentNu edited content for node {NodeId}, consider rebuilding.", dto.Id);
                }
                else
                {
                    bool published           = false;
                    var  deserializedContent = serializer.Deserialize(dto, dto.EditData, dto.EditDataRaw, published);

                    d = new ContentData(
                        dto.EditName,
                        deserializedContent?.UrlSegment,
                        dto.VersionId,
                        dto.EditVersionDate,
                        dto.EditWriterId,
                        dto.EditTemplateId,
                        published,
                        deserializedContent?.PropertyData,
                        deserializedContent?.CultureData);
                }
            }

            if (dto.Published)
            {
                if (dto.PubData == null && dto.PubDataRaw == null)
                {
                    if (Debugger.IsAttached)
                    {
                        throw new InvalidOperationException("Missing cmsContentNu published content for node " + dto.Id + ", consider rebuilding.");
                    }

                    _logger.LogWarning("Missing cmsContentNu published content for node {NodeId}, consider rebuilding.", dto.Id);
                }
                else
                {
                    bool published           = true;
                    var  deserializedContent = serializer.Deserialize(dto, dto.PubData, dto.PubDataRaw, published);

                    p = new ContentData(
                        dto.PubName,
                        deserializedContent?.UrlSegment,
                        dto.VersionId,
                        dto.PubVersionDate,
                        dto.PubWriterId,
                        dto.PubTemplateId,
                        published,
                        deserializedContent?.PropertyData,
                        deserializedContent?.CultureData);
                }
            }

            var n = new ContentNode(dto.Id, dto.Key,
                                    dto.Level, dto.Path, dto.SortOrder, dto.ParentId, dto.CreateDate, dto.CreatorId);

            var s = new ContentNodeKit(n, dto.ContentTypeId, d, p);

            return(s);
        }
Exemplo n.º 35
0
 ObservableCollection <ContentNode> GetInitialItems(ContentNode root)
 {
     return(new ObservableCollection <ContentNode>(root.FlattenChildrenExpanded()));
 }
Exemplo n.º 36
0
 public Navigation(ContentNode node, bool isRoot, ContentNode activeNode)
 {
     _node       = node;
     _activeNode = activeNode;
     _isRoot     = isRoot;
 }
Exemplo n.º 37
0
 public IFNode(ContentNode<bool> decider, List<Node> ifnodes)
 {
     Decider = decider;
     IfNodes = ifnodes;
     ElseNodes = null;
 }
Exemplo n.º 38
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            switch (index)
            {
            case 0:
                // Set the slide's title and subtitle and add some text
                TextManager.SetTitle("Performance");
                TextManager.SetSubtitle("Copying");

                TextManager.AddBulletAtLevel("Attributes are shared by default", 0);
                TextManager.AddBulletAtLevel("Unshare if needed", 0);
                TextManager.AddBulletAtLevel("Copying geometries is cheap", 0);

                break;

            case 1:
                // New "Node B" box
                var nodeB = Utils.SCBoxNode("Node B", new CGRect(-55, -36, 110, 50), GreenColor, 10, true);
                nodeB.Name     = "nodeB";
                nodeB.Position = new SCNVector3(140, 0, 0);
                nodeB.Opacity  = 0;

                var nodeA = ContentNode.FindChildNode("nodeA", true);
                nodeA.AddChildNode(nodeB);

                // Arrow from "Root Node" to "Node B"
                var arrowNode = SCNNode.Create();
                arrowNode.Geometry = SCNShape.Create(Utils.SCArrowBezierPath(new CGSize(140, 3), new CGSize(10, 14), 4, true), 0);
                arrowNode.Position = new SCNVector3(-130, 60, 0);
                arrowNode.Rotation = new SCNVector4(0, 0, 1, -(float)(Math.PI * 0.12f));
                arrowNode.Geometry.FirstMaterial.Diffuse.Contents = GreenColor;
                nodeB.AddChildNode(arrowNode);

                // Arrow from "Node B" to the shared geometry
                arrowNode          = SCNNode.Create();
                arrowNode.Name     = "arrow-shared-geometry";
                arrowNode.Geometry = SCNShape.Create(Utils.SCArrowBezierPath(new CGSize(140, 3), new CGSize(10, 14), 4, false), 0);
                arrowNode.Position = new SCNVector3(0, -28, 0);
                arrowNode.Rotation = new SCNVector4(0, 0, 1, (float)(Math.PI * 1.12f));
                arrowNode.Geometry.FirstMaterial.Diffuse.Contents = PurpleColor;
                nodeB.AddChildNode(arrowNode);

                // Reveal
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                nodeB.Opacity = 1.0f;

                // Show the related code
                TextManager.AddCode("#// Copy a node \n"
                                    + "var nodeB = nodeA.#Copy# ();#");
                SCNTransaction.Commit();
                break;

            case 2:
                var geometryNodeA = ContentNode.FindChildNode("geometry", true);
                var oldArrowNode  = ContentNode.FindChildNode("arrow-shared-geometry", true);

                // New "Geometry" box
                var geometryNodeB = Utils.SCBoxNode("Geometry", new CGRect(-55, -20, 110, 40), PurpleColor, 10, true);
                geometryNodeB.Position = new SCNVector3(140, 0, 0);
                geometryNodeB.Opacity  = 0;
                geometryNodeA.AddChildNode(geometryNodeB);

                // Arrow from "Node B" to the new geometry
                arrowNode          = SCNNode.Create();
                arrowNode.Geometry = SCNShape.Create(Utils.SCArrowBezierPath(new CGSize(55, 3), new CGSize(10, 14), 4, false), 0);
                arrowNode.Position = new SCNVector3(0, 75, 0);
                arrowNode.Rotation = new SCNVector4(0, 0, 1, -(float)(Math.PI * 0.5f));
                arrowNode.Geometry.FirstMaterial.Diffuse.Contents = PurpleColor;
                geometryNodeB.AddChildNode(arrowNode);

                // Arrow from the new geometry to "Material"
                arrowNode          = SCNNode.Create();
                arrowNode.Name     = "arrow-shared-material";
                arrowNode.Geometry = SCNShape.Create(Utils.SCArrowBezierPath(new CGSize(140, 3), new CGSize(10, 14), 4, true), 0);
                arrowNode.Position = new SCNVector3(-130, -80, 0);
                arrowNode.Rotation = new SCNVector4(0, 0, 1, (float)(Math.PI * 0.12f));
                arrowNode.Geometry.FirstMaterial.Diffuse.Contents = RedColor;
                geometryNodeB.AddChildNode(arrowNode);

                // Reveal
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                geometryNodeB.Opacity            = 1.0f;
                oldArrowNode.Opacity             = 0.0f;

                // Show the related code
                TextManager.AddEmptyLine();
                TextManager.AddCode("#// Unshare geometry \n"
                                    + "nodeB.Geometry = nodeB.Geometry.#Copy# ();#");
                SCNTransaction.Commit();
                break;

            case 3:
                var materialANode = ContentNode.FindChildNode("material", true);
                oldArrowNode = ContentNode.FindChildNode("arrow-shared-material", true);

                // New "Material" box
                var materialBNode = Utils.SCBoxNode("Material", new CGRect(-55, -20, 110, 40), NSColor.Orange, 10, true);
                materialBNode.Position = new SCNVector3(140, 0, 0);
                materialBNode.Opacity  = 0;
                materialANode.AddChildNode(materialBNode);

                // Arrow from the unshared geometry to the new material
                arrowNode          = SCNNode.Create();
                arrowNode.Geometry = SCNShape.Create(Utils.SCArrowBezierPath(new CGSize(55, 3), new CGSize(10, 14), 4, false), 0);
                arrowNode.Position = new SCNVector3(0, 75, 0);
                arrowNode.Rotation = new SCNVector4(0, 0, 1, -(float)(Math.PI * 0.5f));
                arrowNode.Geometry.FirstMaterial.Diffuse.Contents = NSColor.Orange;
                materialBNode.AddChildNode(arrowNode);

                // Reveal
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                materialBNode.Opacity            = 1.0f;
                oldArrowNode.Opacity             = 0.0f;
                SCNTransaction.Commit();
                break;
            }
        }
Exemplo n.º 39
0
		public ContentNodeEventArgs(ContentNode node)
		{
			this.node = node;
		}
Exemplo n.º 40
0
 private void ParseSessionId(ContentNode node)
 {
     fetcher.SessionId = (int) node.GetChild ("dmap.sessionid").Value;
 }
        }                                                                                   // <== This implementaiton supports only doc types 27 and 28

        public void Create(ContentNode node)
        {
            _myCustomDAL.CreateMethod3(node);
        }
Exemplo n.º 42
0
 public ContentNodeKitBuilder WithContentNode(ContentNode contentNode)
 {
     _contentNode = contentNode;
     return(this);
 }
 public void Delete(ContentNode node)
 {
     _myCustomDAL.DeleteMethod3(node);
 }
Exemplo n.º 44
0
 public ContentNodeKitBuilder WithContentNode(int id, Guid uid, int level, string path, int sortOrder, int parentContentId, DateTime createDate, int creatorId)
 {
     _contentNode = new ContentNode(id, uid, level, path, sortOrder, parentContentId, createDate, creatorId);
     return(this);
 }
Exemplo n.º 45
0
        internal void    CloseGroup() {
            ContentNode n = (ContentNode)stack.Pop();
            if (n == null) {
                return;
            }
            if (stack.Count == 0) {
                if (n.NodeType == ContentNode.Type.Terminal) {
                    TerminalNode t = (TerminalNode)n;
                    if (t.Name == schemaNames.QnPCData) {
                        // we had a lone (#PCDATA) which needs to be
                        // wrapped in a STAR node.
                        ContentNode n1 = new InternalNode(n, null, ContentNode.Type.Star);
                        n.ParentNode = n1;
                        n = n1;
                    }
                }
                contentNode = n;
                isPartial = false;
            }
            else {
                // some collapsing to do...
                InternalNode inNode = (InternalNode)stack.Pop();
                if (inNode != null) {
                    inNode.RightNode = n;
                    n.ParentNode = inNode;
                    n = inNode;
                    isPartial = true;
                }
                else {
                    isPartial = false;
                }

                stack.Push(n);
            }
        }
Exemplo n.º 46
0
        private void SeedHomePage(string homePageId)
        {
            // init version & content tree
            var publishedVersion = new ContentVersion
            {
                ContentId    = homePageId,
                ContentType  = HtmlDbSeedConstants.ContentType_SitePage,
                VersionLabel = "Master Page Content Added",
                UserId       = "admin",
                Status       = ContentStatus.Published,
            };

            var contentTree = new ContentTree(publishedVersion);

            _dbContext.ContentVersions.Add(publishedVersion);
            _dbContext.ContentTrees.Add(contentTree);


            // styles
            var topImageStyle = new ContentStyle
            {
                FullWidth       = true,
                BackgroundClass = SiteTemplateConstants.Backgrounds.Default,
            };

            var topGridStyle = new ContentStyle
            {
                BackgroundClass = SiteTemplateConstants.Backgrounds.Default,
                PaddingTop      = SiteTemplateConstants.RootContentPaddingTop,
                PaddingBottom   = SiteTemplateConstants.RootContentPaddingBottom
            };

            var heroUnitStyle = new ContentStyle
            {
                BackgroundClass = SiteTemplateConstants.Backgrounds.Fancy,
                PaddingTop      = SiteTemplateConstants.RootContentPaddingTop,
                PaddingBottom   = SiteTemplateConstants.RootContentPaddingBottom
            };

            var bottomGridStyle = new ContentStyle
            {
                BackgroundClass = SiteTemplateConstants.Backgrounds.Contrast,
                PaddingTop      = SiteTemplateConstants.RootContentPaddingTop,
                PaddingBottom   = SiteTemplateConstants.RootContentPaddingBottom
            };


            // content nodes
            var homePageContentNodes = new ContentNode[]
            {
                // full width zone with image
                new ContentNode(topImageStyle)
                {
                    Id            = Guid.NewGuid().ToString(),
                    ContentTreeId = contentTree.Id,
                    Zone          = "body",
                    Index         = 0,
                    WidgetId      = HtmlDbSeedConstants.WidgetId_Image_GuidanceImageMain,
                    WidgetType    = "image",
                    ViewId        = "image-fitted",
                    Locked        = false,
                },

                // Hero Unit
                new ContentNode(heroUnitStyle)
                {
                    Id            = Guid.NewGuid().ToString(),
                    ContentTreeId = contentTree.Id,
                    ParentId      = null,
                    Zone          = "body",
                    Index         = 1,
                    WidgetId      = null,
                    WidgetType    = "zone",
                    ViewId        = "zone-1",
                    Locked        = false,

                    ChildNodes = new ContentNode[]
                    {
                        new ContentNode
                        {
                            Id            = Guid.NewGuid().ToString(),
                            ContentTreeId = contentTree.Id,
                            Zone          = "cell-1",
                            Index         = 1,
                            WidgetId      = HtmlDbSeedConstants.WidgetId_Hero_GuidanceWelcome,
                            WidgetType    = "hero",
                            ViewId        = "hero-hero1",
                            Locked        = false,
                        }
                    }
                },

                // 4 images in a grid
                new ContentNode(topGridStyle)
                {
                    Id            = Guid.NewGuid().ToString(),
                    ContentTreeId = contentTree.Id,
                    ParentId      = null,
                    Zone          = "body",
                    Index         = 2,
                    WidgetId      = null,
                    WidgetType    = "zone",
                    ViewId        = "zone-3",
                    Locked        = false,

                    ChildNodes = new ContentNode[]
                    {
                        new ContentNode
                        {
                            Id            = Guid.NewGuid().ToString(),
                            ContentTreeId = contentTree.Id,
                            Zone          = "cell-1",
                            Index         = 0,
                            WidgetId      = HtmlDbSeedConstants.WidgetId_Image_GuidanceImage1,
                            WidgetType    = "image",
                            ViewId        = "image-fitted",
                            Locked        = false
                        },
                        new ContentNode
                        {
                            Id            = Guid.NewGuid().ToString(),
                            ContentTreeId = contentTree.Id,
                            Zone          = "cell-2",
                            Index         = 1,
                            WidgetId      = HtmlDbSeedConstants.WidgetId_Image_GuidanceImage2,
                            WidgetType    = "image",
                            ViewId        = "image-fitted",
                            Locked        = false
                        },
                        new ContentNode
                        {
                            Id            = Guid.NewGuid().ToString(),
                            ContentTreeId = contentTree.Id,
                            Zone          = "cell-3",
                            Index         = 2,
                            WidgetId      = HtmlDbSeedConstants.WidgetId_Image_GuidanceImage3,
                            WidgetType    = "image",
                            ViewId        = "image-fitted",
                            Locked        = false
                        }
                    }
                },
            };


            _dbContext.ContentNodes.AddRange(homePageContentNodes);
            _dbContext.SaveChanges();
        }
Exemplo n.º 47
0
        internal void     MinMax(decimal min, decimal max) {
            ContentNode n;

            if (stack.Count > 0) {
                InternalNode n1;
                n = (ContentNode)stack.Pop();
                if (isPartial &&
                    n.NodeType != ContentNode.Type.Terminal &&
                    n.NodeType != ContentNode.Type.Any) {
                    // need to reach in and wrap _pRight hand side of element.
                    // and n remains the same.
                    InternalNode inNode = (InternalNode)n;
                    n1 = new MinMaxNode(inNode.RightNode, min, max);
                    n1.ParentNode = n;
                    if (inNode.RightNode != null)
                        inNode.RightNode.ParentNode = n1;
                    inNode.RightNode = n1;
                }
                else {
                    // wrap terminal or any node
                    n1 = new MinMaxNode(n, min, max);
                    n.ParentNode = n1;
                    n = n1;
                }
                stack.Push(n);
            }
            else {
                // wrap whole content
                n = new MinMaxNode(contentNode, min, max);
                contentNode.ParentNode = n;
                contentNode = n;
            }

            abnormalContent = true;
        }
Exemplo n.º 48
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            SCNTransaction.Begin();
            switch (index)
            {
            case 0:
                // Set the slide's title and subtitle and add some text
                TextManager.SetTitle("Node Attributes");
                TextManager.SetSubtitle("Camera");
                TextManager.AddBulletAtLevel("Point of view for renderers", 0);

                // Start with the "sign" model hidden
                var group = ContentNode.FindChildNode("group", true);
                group.Scale  = new SCNVector3(0, 0, 0);
                group.Hidden = true;
                break;

            case 1:
                // Reveal the model (unhide then scale)
                group = ContentNode.FindChildNode("group", true);

                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 0;
                group.Hidden = false;
                SCNTransaction.Commit();

                SCNTransaction.AnimationDuration = 1.0f;
                group.Scale = new SCNVector3(1, 1, 1);
                break;

            case 2:
                TextManager.AddCode("#aNode.#Camera# = #SCNCamera#.Create (); \naView.#PointOfView# = aNode;#");
                break;

            case 3:
                // Switch to camera1
                SCNTransaction.AnimationDuration = 2.0f;
                ((SCNView)presentationViewController.View).PointOfView = ContentNode.FindChildNode("camera1", true);
                break;

            case 4:
                // Switch to camera2
                SCNTransaction.AnimationDuration = 2.0f;
                ((SCNView)presentationViewController.View).PointOfView = ContentNode.FindChildNode("camera2", true);
                break;

            case 5:
                // On completion add some code
                SCNTransaction.SetCompletionBlock(() => {
                    TextManager.FadesIn = true;
                    TextManager.AddEmptyLine();
                    TextManager.AddCode("#aNode.#Camera#.XFov = angleInDegrees;#");
                });

                // Switch back to the default camera
                SCNTransaction.AnimationDuration = 1.0f;
                ((SCNView)presentationViewController.View).PointOfView = presentationViewController.CameraNode;
                break;

            case 6:
                // Switch to camera 3
                SCNTransaction.AnimationDuration = 1.0f;
                var target = ContentNode.FindChildNode("camera3", true);

                // Don't let the default transition animate the FOV (we will animate the FOV separately)
                var wantedFOV = target.Camera.XFov;
                target.Camera.XFov = ((SCNView)presentationViewController.View).PointOfView.Camera.XFov;

                // Animate point of view with an ease-in/ease-out function
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration       = 1.0f;
                SCNTransaction.AnimationTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
                ((SCNView)presentationViewController.View).PointOfView = target;
                SCNTransaction.Commit();

                // Animate the FOV with the default timing function (for a better looking transition)
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1.0f;
                ((SCNView)presentationViewController.View).PointOfView.Camera.XFov = wantedFOV;
                SCNTransaction.Commit();
                break;

            case 7:
                // Switch to camera 4
                var cameraNode = ContentNode.FindChildNode("camera4", true);

                // Don't let the default transition animate the FOV (we will animate the FOV separately)
                wantedFOV = cameraNode.Camera.XFov;
                cameraNode.Camera.XFov = ((SCNView)presentationViewController.View).PointOfView.Camera.XFov;

                // Animate point of view with the default timing function
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1.0f;
                ((SCNView)presentationViewController.View).PointOfView = cameraNode;
                SCNTransaction.Commit();

                // Animate the FOV with an ease-in/ease-out function
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration       = 1.0f;
                SCNTransaction.AnimationTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
                ((SCNView)presentationViewController.View).PointOfView.Camera.XFov = wantedFOV;
                SCNTransaction.Commit();
                break;

            case 8:
                // Quickly switch back to the default camera
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 0.75f;
                ((SCNView)presentationViewController.View).PointOfView = presentationViewController.CameraNode;
                SCNTransaction.Commit();
                break;
            }
            SCNTransaction.Commit();
        }
Exemplo n.º 49
0
 //  returns names of all legal elements following the specified state
 private ArrayList ExpectedXsdElements(ContentNode cnode, int NodeMatched) {
     return null;
 }
        // Create a carousel of 3D primitives
        private void PresentPrimitives()
        {
            // Create the carousel node. It will host all the primitives as child nodes.
            CarouselNode          = SCNNode.Create();
            CarouselNode.Position = new SCNVector3(0, 0.1f, -5);
            CarouselNode.Scale    = new SCNVector3(0, 0, 0);           // start infinitely small
            ContentNode.AddChildNode(CarouselNode);

            // Animate the scale to achieve a "grow" effect
            SCNTransaction.Begin();
            SCNTransaction.AnimationDuration = 1;
            CarouselNode.Scale = new SCNVector3(1, 1, 1);
            SCNTransaction.Commit();

            // Rotate the carousel forever
            var rotationAnimation = CABasicAnimation.FromKeyPath("rotation");

            rotationAnimation.Duration    = 40.0f;
            rotationAnimation.RepeatCount = float.MaxValue;
            rotationAnimation.To          = NSValue.FromVector(new SCNVector4(0, 1, 0, NMath.PI * 2));
            CarouselNode.AddAnimation(rotationAnimation, new NSString("rotationAnimation"));

            // A material shared by all the primitives
            var sharedMaterial = SCNMaterial.Create();

            sharedMaterial.Reflective.Contents  = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/envmap", "jpg"));
            sharedMaterial.Reflective.Intensity = 0.2f;
            sharedMaterial.DoubleSided          = true;

            PrimitiveIndex = 0;

            // SCNBox
            var box = SCNBox.Create(5.0f, 5.0f, 5.0f, 5.0f * 0.05f);

            box.WidthSegmentCount   = 4;
            box.HeightSegmentCount  = 4;
            box.LengthSegmentCount  = 4;
            box.ChamferSegmentCount = 4;
            AddPrimitive(box, 5.0f / 2, rotationAnimation, sharedMaterial);

            // SCNPyramid
            var pyramid = SCNPyramid.Create(5.0f * 0.8f, 5.0f, 5.0f * 0.8f);

            pyramid.WidthSegmentCount  = 4;
            pyramid.HeightSegmentCount = 10;
            pyramid.LengthSegmentCount = 4;
            AddPrimitive(pyramid, 0, rotationAnimation, sharedMaterial);

            // SCNCone
            var cone = SCNCone.Create(0, 5.0f / 2, 5.0f);

            cone.RadialSegmentCount = 20;
            cone.HeightSegmentCount = 4;
            AddPrimitive(cone, 5.0f / 2, rotationAnimation, sharedMaterial);

            // SCNTube
            var tube = SCNTube.Create(5.0f * 0.25f, 5.0f * 0.5f, 5.0f);

            tube.HeightSegmentCount = 5;
            tube.RadialSegmentCount = 40;
            AddPrimitive(tube, 5.0f / 2, rotationAnimation, sharedMaterial);

            // SCNCapsule
            var capsule = SCNCapsule.Create(5.0f * 0.4f, 5.0f * 1.4f);

            capsule.HeightSegmentCount = 5;
            capsule.RadialSegmentCount = 20;
            AddPrimitive(capsule, 5.0f * 0.7f, rotationAnimation, sharedMaterial);

            // SCNCylinder
            var cylinder = SCNCylinder.Create(5.0f * 0.5f, 5.0f);

            cylinder.HeightSegmentCount = 5;
            cylinder.RadialSegmentCount = 40;
            AddPrimitive(cylinder, 5.0f / 2, rotationAnimation, sharedMaterial);

            // SCNSphere
            var sphere = SCNSphere.Create(5.0f * 0.5f);

            sphere.SegmentCount = 20;
            AddPrimitive(sphere, 5.0f / 2, rotationAnimation, sharedMaterial);

            // SCNTorus
            var torus = SCNTorus.Create(5.0f * 0.5f, 5.0f * 0.25f);

            torus.RingSegmentCount = 40;
            torus.PipeSegmentCount = 20;
            AddPrimitive(torus, 5.0f / 4, rotationAnimation, sharedMaterial);

            // SCNPlane
            var plane = SCNPlane.Create(5.0f, 5.0f);

            plane.WidthSegmentCount  = 5;
            plane.HeightSegmentCount = 5;
            plane.CornerRadius       = 5.0f * 0.1f;
            AddPrimitive(plane, 5.0f / 2, rotationAnimation, sharedMaterial);
        }
		ObservableCollection<ContentNode> GetInitialItems(ContentNode root)
		{
			return new ObservableCollection<ContentNode>(root.FlattenChildrenExpanded());
		}
		protected virtual void OnContentNodeCollapsed(ContentNode node)
		{
			if (this.ContentNodeCollapsed != null)
				this.ContentNodeCollapsed(this, new ContentNodeEventArgs(node));
		}
Exemplo n.º 53
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            SCNTransaction.Begin();

            switch (index)
            {
            case 1:
                TextManager.FlipOutText(SlideTextManager.TextType.Code);
                TextManager.FlipOutText(SlideTextManager.TextType.Subtitle);
                TextManager.FlipOutText(SlideTextManager.TextType.Bullet);

                TextManager.SetSubtitle("Entry points");

                var textNode = Utils.SCLabelNode("Geometry", Utils.LabelSize.Normal, false);
                textNode.Position = new SCNVector3(-13.5f, 9, 0);
                ContentNode.AddChildNode(textNode);
                textNode          = Utils.SCLabelNode("Surface", Utils.LabelSize.Normal, false);
                textNode.Position = new SCNVector3(-5.3f, 9, 0);
                ContentNode.AddChildNode(textNode);
                textNode          = Utils.SCLabelNode("Lighting", Utils.LabelSize.Normal, false);
                textNode.Position = new SCNVector3(2, 9, 0);
                ContentNode.AddChildNode(textNode);
                textNode          = Utils.SCLabelNode("Fragment", Utils.LabelSize.Normal, false);
                textNode.Position = new SCNVector3(9.5f, 9, 0);
                ContentNode.AddChildNode(textNode);

                TextManager.FlipInText(SlideTextManager.TextType.Subtitle);

                //add spheres
                var sphere = SCNSphere.Create(3);
                sphere.FirstMaterial.Diffuse.Contents   = NSColor.Red;
                sphere.FirstMaterial.Specular.Contents  = NSColor.White;
                sphere.FirstMaterial.Specular.Intensity = 1.0f;

                sphere.FirstMaterial.Shininess           = 0.1f;
                sphere.FirstMaterial.Reflective.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/envmap", "jpg"));
                sphere.FirstMaterial.FresnelExponent     = 2;

                //GEOMETRY
                var node = SCNNode.Create();
                node.Geometry = (SCNGeometry)sphere.Copy();
                node.Position = new SCNVector3(-12, 3, 0);
                node.Geometry.ShaderModifiers = new SCNShaderModifiers {
                    EntryPointGeometry = "// Waves Modifier\n"
                                         + "uniform float Amplitude = 0.2;\n"
                                         + "uniform float Frequency = 5.0;\n"
                                         + "vec2 nrm = _geometry.position.xz;\n"
                                         + "float len = length(nrm)+0.0001; // for robustness\n"
                                         + "nrm /= len;\n"
                                         + "float a = len + Amplitude*sin(Frequency * _geometry.position.y + u_time * 10.0);\n"
                                         + "_geometry.position.xz = nrm * a;\n"
                };

                GroundNode.AddChildNode(node);

                // SURFACE
                node          = SCNNode.Create();
                node.Geometry = (SCNGeometry)sphere.Copy();
                node.Position = new SCNVector3(-4, 3, 0);

                var surfaceModifier = File.ReadAllText(NSBundle.MainBundle.PathForResource("Shaders/sm_surf", "shader"));

                node.Rotation = new SCNVector4(1, 0, 0, -NMath.PI / 4);
                node.Geometry.FirstMaterial = (SCNMaterial)node.Geometry.FirstMaterial.Copy();
                node.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Lambert;
                node.Geometry.ShaderModifiers = new SCNShaderModifiers {
                    EntryPointSurface = surfaceModifier
                };
                GroundNode.AddChildNode(node);

                // LIGHTING
                node          = SCNNode.Create();
                node.Geometry = (SCNGeometry)sphere.Copy();
                node.Position = new SCNVector3(4, 3, 0);

                var lightingModifier = File.ReadAllText(NSBundle.MainBundle.PathForResource("Shaders/sm_light", "shader"));
                node.Geometry.ShaderModifiers = new SCNShaderModifiers {
                    EntryPointLightingModel = lightingModifier
                };

                GroundNode.AddChildNode(node);

                // FRAGMENT
                node          = SCNNode.Create();
                node.Geometry = (SCNGeometry)sphere.Copy();
                node.Position = new SCNVector3(12, 3, 0);

                node.Geometry.FirstMaterial = (SCNMaterial)node.Geometry.FirstMaterial.Copy();
                node.Geometry.FirstMaterial.Diffuse.Contents = NSColor.Green;

                var fragmentModifier = File.ReadAllText(NSBundle.MainBundle.PathForResource("Shaders/sm_frag", "shader"));
                node.Geometry.ShaderModifiers = new SCNShaderModifiers {
                    EntryPointFragment = fragmentModifier
                };

                GroundNode.AddChildNode(node);


                //redraw forever
                ((SCNView)presentationViewController.View).Playing = true;
                ((SCNView)presentationViewController.View).Loops   = true;

                break;
            }
            SCNTransaction.Commit();
        }
Exemplo n.º 54
0
 public static string HtmlEncode(ContentNode node)
 {
     StringBuilder sb = new StringBuilder();
     HtmlEncodeRecursive(node, sb);
     return sb.ToString();
 }
		int SubtreeSize(ContentNode node)
		{
			return 1 + node.Children.Sum(child => (child.IsExpanded ? SubtreeSize(child) : 1));
		}
Exemplo n.º 56
0
        private static ContentNodeKit CreateContentNodeKit(ContentSourceDto dto)
        {
            ContentData d = null;
            ContentData p = null;

            if (dto.Edited)
            {
                if (dto.EditData == null)
                {
                    if (Debugger.IsAttached)
                    {
                        throw new Exception("Missing cmsContentNu edited content for node " + dto.Id + ", consider rebuilding.");
                    }
                    Current.Logger.Warn <DatabaseDataSource>("Missing cmsContentNu edited content for node {NodeId}, consider rebuilding.", dto.Id);
                }
                else
                {
                    var nested = DeserializeNestedData(dto.EditData);

                    d = new ContentData
                    {
                        Name         = dto.EditName,
                        Published    = false,
                        TemplateId   = dto.EditTemplateId,
                        VersionId    = dto.VersionId,
                        VersionDate  = dto.EditVersionDate,
                        WriterId     = dto.EditWriterId,
                        Properties   = nested.PropertyData,
                        CultureInfos = nested.CultureData
                    };
                }
            }

            if (dto.Published)
            {
                if (dto.PubData == null)
                {
                    if (Debugger.IsAttached)
                    {
                        throw new Exception("Missing cmsContentNu published content for node " + dto.Id + ", consider rebuilding.");
                    }
                    Current.Logger.Warn <DatabaseDataSource>("Missing cmsContentNu published content for node {NodeId}, consider rebuilding.", dto.Id);
                }
                else
                {
                    var nested = DeserializeNestedData(dto.PubData);

                    p = new ContentData
                    {
                        Name         = dto.PubName,
                        UrlSegment   = nested.UrlSegment,
                        Published    = true,
                        TemplateId   = dto.PubTemplateId,
                        VersionId    = dto.VersionId,
                        VersionDate  = dto.PubVersionDate,
                        WriterId     = dto.PubWriterId,
                        Properties   = nested.PropertyData,
                        CultureInfos = nested.CultureData
                    };
                }
            }

            var n = new ContentNode(dto.Id, dto.Uid,
                                    dto.Level, dto.Path, dto.SortOrder, dto.ParentId, dto.CreateDate, dto.CreatorId);

            var s = new ContentNodeKit
            {
                Node          = n,
                ContentTypeId = dto.ContentTypeId,
                DraftData     = d,
                PublishedData = p
            };

            return(s);
        }
Exemplo n.º 57
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            // Animate by default
            SCNTransaction.Begin();
            SCNTransaction.AnimationDuration = 0;

            switch (index)
            {
            case 0:
                TextManager.FlipInText(SlideTextManager.TextType.Bullet);
                break;

            case 1:
                TextManager.FlipOutText(SlideTextManager.TextType.Bullet);
                TextManager.AddEmptyLine();
                TextManager.AddCode("#// Rotate forever\n"
                                    + "[aNode #runAction:#\n"
                                    + "  [SCNAction repeatActionForever:\n"
                                    + "  [SCNAction rotateByX:0 y:M_PI*2 z:0 duration:5.0]]];#");

                TextManager.FlipInText(SlideTextManager.TextType.Code);
                break;

            case 2:
                TextManager.FlipOutText(SlideTextManager.TextType.Bullet);
                TextManager.FlipOutText(SlideTextManager.TextType.Code);

                TextManager.AddBulletAtLevel("Move", 0);
                TextManager.AddBulletAtLevel("Rotate", 0);
                TextManager.AddBulletAtLevel("Scale", 0);
                TextManager.AddBulletAtLevel("Opacity", 0);
                TextManager.AddBulletAtLevel("Remove", 0);
                TextManager.AddBulletAtLevel("Wait", 0);
                TextManager.AddBulletAtLevel("Custom block", 0);

                TextManager.FlipInText(SlideTextManager.TextType.Bullet);
                break;

            case 3:
                TextManager.FlipOutText(SlideTextManager.TextType.Bullet);
                TextManager.AddEmptyLine();
                TextManager.AddBulletAtLevel("Directly targets the render tree", 0);
                TextManager.FlipInText(SlideTextManager.TextType.Bullet);
                break;

            case 4:
                TextManager.AddBulletAtLevel("node.position / node.presentationNode.position", 0);

                //labels
                var label1 = TextManager.AddTextAtLevel("Action", 0);
                label1.Position = new SCNVector3(-15, 3, 0);
                var label2 = TextManager.AddTextAtLevel("Animation", 0);
                label2.Position = new SCNVector3(-15, -2, 0);

                //animation
                var animNode = SCNNode.Create();
                var cubeSize = 4.0f;
                animNode.Position = new SCNVector3(-5, cubeSize / 2, 0);

                var cube = SCNBox.Create(cubeSize, cubeSize, cubeSize, 0.05f * cubeSize);

                cube.FirstMaterial.Diffuse.Contents  = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/texture", "png"));
                cube.FirstMaterial.Diffuse.MipFilter = SCNFilterMode.Linear;
                cube.FirstMaterial.Diffuse.WrapS     = SCNWrapMode.Repeat;
                cube.FirstMaterial.Diffuse.WrapT     = SCNWrapMode.Repeat;
                animNode.Geometry = cube;
                ContentNode.AddChildNode(animNode);

                SCNTransaction.Begin();


                SCNNode           animPosIndicator = null;
                SCNAnimationEvent startEvt         = SCNAnimationEvent.Create(0, (CAAnimation animation, NSObject animatedObject, bool playingBackward) => {
                    SCNTransaction.Begin();
                    SCNTransaction.AnimationDuration = 0;
                    animPosIndicator.Position        = new SCNVector3(10, animPosIndicator.Position.Y, animPosIndicator.Position.Z);
                    SCNTransaction.Commit();
                });
                SCNAnimationEvent endEvt = SCNAnimationEvent.Create(1, (CAAnimation animation, NSObject animatedObject, bool playingBackward) => {
                    SCNTransaction.Begin();
                    SCNTransaction.AnimationDuration = 0;
                    animPosIndicator.Position        = new SCNVector3(-5, animPosIndicator.Position.Y, animPosIndicator.Position.Z);
                    SCNTransaction.Commit();
                });

                var anim = CABasicAnimation.FromKeyPath("position.x");
                anim.Duration        = 3;
                anim.From            = new NSNumber(0.0);
                anim.To              = new NSNumber(15.0);
                anim.Additive        = true;
                anim.AutoReverses    = true;
                anim.AnimationEvents = new SCNAnimationEvent[] { startEvt, endEvt };
                anim.RepeatCount     = float.MaxValue;
                animNode.AddAnimation(anim, new NSString("cubeAnimation"));

                //action
                var actionNode = SCNNode.Create();
                actionNode.Position = new SCNVector3(-5, cubeSize * 1.5f + 1, 0);
                actionNode.Geometry = cube;

                ContentNode.AddChildNode(actionNode);

                var mv = SCNAction.MoveBy(15, 0, 0, 3);

                actionNode.RunAction(SCNAction.RepeatActionForever(SCNAction.Sequence(new SCNAction[] {
                    mv,
                    mv.ReversedAction()
                })));

                //position indicator
                var positionIndicator = SCNNode.Create();
                positionIndicator.Geometry = SCNCylinder.Create(0.5f, 0.01f);
                positionIndicator.Geometry.FirstMaterial.Diffuse.Contents  = NSColor.Red;
                positionIndicator.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Constant;
                positionIndicator.EulerAngles = new SCNVector3(NMath.PI / 2, 0, 0);
                positionIndicator.Position    = new SCNVector3(0, 0, cubeSize * 0.5f);
                actionNode.AddChildNode(positionIndicator);

                //anim pos indicator
                animPosIndicator          = positionIndicator.Clone();
                animPosIndicator.Position = new SCNVector3(5, cubeSize / 2, cubeSize * 0.5f);
                ContentNode.AddChildNode(animPosIndicator);

                SCNTransaction.Commit();

                break;
            }
            SCNTransaction.Commit();
        }
Exemplo n.º 58
0
        public override void PresentStep(int switchIndex, PresentationViewController presentationViewController)
        {
            switch (switchIndex)
            {
            case 0:
                // Set the slide's title and subtitle and add some text
                TextManager.SetTitle("Core Image");
                TextManager.SetSubtitle("CI Filters");

                TextManager.AddBulletAtLevel("Screen-space effects", 0);
                TextManager.AddBulletAtLevel("Applies to a node hierarchy", 0);
                TextManager.AddBulletAtLevel("Filter parameters are animatable", 0);
                TextManager.AddCode("#aNode.#Filters# = new CIFilter[] { filter1, filter2 };#");
                break;

            case 1:
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1.0f;
                // Dim the text and move back a little
                TextManager.TextNode.Opacity = 0.0f;
                presentationViewController.CameraHandle.Position = presentationViewController.CameraNode.ConvertPositionToNode(new SCNVector3(0, 0, 5.0f), presentationViewController.CameraHandle.ParentNode);
                SCNTransaction.Commit();

                // Reveal the grid
                GroupNode.Opacity = 1;
                break;

            case 2:
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                // Highlight an item
                HighlightContact(13, presentationViewController);
                SCNTransaction.Commit();
                break;

            case 3:
                var index   = 13;
                var subStep = 0;

                // Successively select items
                for (var i = 0; i < 5; ++i)
                {
                    var popTime = new DispatchTime(DispatchTime.Now, (Int64)(i * 0.2 * Utils.NSEC_PER_SEC));
                    DispatchQueue.MainQueue.DispatchAfter(popTime, () => {
                        SCNTransaction.Begin();
                        SCNTransaction.AnimationDuration = 0.2f;
                        UnhighlightContact(index);

                        if (subStep++ == 3)
                        {
                            index += ColumnCount;
                        }
                        else
                        {
                            index++;
                        }

                        HighlightContact(index, presentationViewController);
                        SCNTransaction.Commit();
                    });
                }
                break;

            case 4:
                // BLUR+DESATURATE in the background, GLOW in the foreground

                // Here we will change the node hierarchy in order to group all the nodes in the background under a single node.
                // This way we can use a single Core Image filter and apply it on the whole grid, and have another CI filter for the node in the foreground.

                var selectionParent = HeroNode.ParentNode;

                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 0;
                // Stop the animations of the selected node
                HeroNode.Transform = HeroNode.PresentationNode.Transform;                 // set the current rotation to the current presentation value
                HeroNode.RemoveAllAnimations();

                // Re-parent the node by preserving its world tranform
                var wantedWorldTransform = selectionParent.WorldTransform;
                GroupNode.ParentNode.AddChildNode(selectionParent);
                selectionParent.Transform = selectionParent.ParentNode.ConvertTransformFromNode(wantedWorldTransform, null);
                SCNTransaction.Commit();

                // Add CIFilters

                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                // A negative 'centerX' value means no scaling.
                //TODO HeroNode.Filters [0].SetValueForKey (new NSNumber (-1), new NSString ("centerX"));

                // Move the selection to the foreground
                selectionParent.Rotation = new SCNVector4(0, 1, 0, 0);
                HeroNode.Transform       = ContentNode.ConvertTransformToNode(SCNMatrix4.CreateTranslation(0, Altitude, 29), selectionParent);
                HeroNode.Scale           = new SCNVector3(1, 1, 1);
                HeroNode.Rotation        = new SCNVector4(1, 0, 0, -(float)(Math.PI / 4) * 0.25f);

                // Upon completion, rotate the selection forever
                SCNTransaction.SetCompletionBlock(() => {
                    var animation            = CABasicAnimation.FromKeyPath("rotation");
                    animation.Duration       = 4.0f;
                    animation.From           = NSValue.FromVector(new SCNVector4(0, 1, 0, 0));
                    animation.To             = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)Math.PI * 2));
                    animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
                    animation.RepeatCount    = float.MaxValue;

                    HeroNode.ChildNodes [0].AddAnimation(animation, new NSString("heroNodeAnimation"));
                });

                // Add the filters
                var blurFilter = CIFilter.FromName("CIGaussianBlur");
                blurFilter.SetDefaults();
                blurFilter.Name = "blur";
                blurFilter.SetValueForKey(new NSNumber(0), CIFilterInputKey.Radius);

                var desaturateFilter = CIFilter.FromName("CIColorControls");
                desaturateFilter.SetDefaults();
                desaturateFilter.Name = "desaturate";
                GroupNode.Filters     = new CIFilter[] { blurFilter, desaturateFilter };
                SCNTransaction.Commit();

                // Increate the blur radius and desaturate progressively
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 2;
                GroupNode.SetValueForKey(new NSNumber(10), new NSString("filters.blur.inputRadius"));
                GroupNode.SetValueForKey(new NSNumber(0.1), new NSString("filters.desaturate.inputSaturation"));
                SCNTransaction.Commit();

                break;
            }
        }
Exemplo n.º 59
0
    void AddReadContentNode(ContentNode n, Block block, StatementList statements, Identifier reader, 
      Expression target, Expression required, Expression result, SchemaValidator validator) {
      if (n.TypeNode == null) {
        Debug.Assert(n is SequenceNode);
        // In the class inheritance case we have two independent left and right children inside
        // a parent sequence that has no unified type or member.
        SequenceNode s = (SequenceNode)n;
        AddReadContentNode(s.LeftChild, block, statements, reader, target, required, result, validator);
        AddReadContentNode(s.RightChild, block, statements, reader, target, required, result, validator);
        return;
      }
      TypeNode ct = n.TypeNode;
      Debug.Assert(ct != null);
      if (n.Member != null && !(n.Member is Method))  {
        target = GetMemberBinding(target, n.Member);
        ct = target.Type;
      }

      // todo: might be content model AND mixed, in which case we have to pass the MixedMember
      // to AddReadTuple, AddReadChoice and AddReadStream.
      if (ct.Template == SystemTypes.GenericBoxed){
        ct = Checker.GetCollectionElementType(ct);
      }
      if (ct is TupleType) {
        AddReadTuple(block, ct as TupleType, statements, reader, target, required, result);
      } else if (ct is TypeUnion) {
        AddReadChoice(block, ct as TypeUnion, statements, reader, target, required, result);
      } else if (IsStream(ct)) {
        AddReadStream(block, ct, statements, reader, target, result);
      } else if (ct is TypeAlias) {
        AddReadAlias(block, ct as TypeAlias, statements, reader, target, required, result);
      } else {
        Identifier name = Checker.GetDefaultElementName(ct);
        AddReadRequiredChild(block, statements, name, ct, target, reader, result, required, true, false);
      }
    }
Exemplo n.º 60
0
        internal static Track FromNode(ContentNode node)
        {
            Track track = new Track ();

            foreach (ContentNode field in (ContentNode[]) node.Value) {
                switch (field.Name) {
                case "dmap.itemid":
                    track.id = (int) field.Value;
                    break;
                case "daap.songartist":
                    track.artist = (string) field.Value;
                    break;
                case "dmap.itemname":
                    track.title = (string) field.Value;
                    break;
                case "daap.songalbum":
                    track.album = (string) field.Value;
                    break;
                case "daap.songtime":
                    track.duration = TimeSpan.FromMilliseconds ((int) field.Value);
                    break;
                case "daap.songformat":
                    track.format = (string) field.Value;
                    break;
                case "daap.songgenre":
                    track.genre = (string) field.Value;
                    break;
                case "daap.songsize":
                    track.size = (int) field.Value;
                    break;
                case "daap.songtrackcount":
                    track.trackCount = (short) field.Value;
                    break;
                case "daap.songtracknumber":
                    track.trackNumber = (short) field.Value;
                    break;
                case "daap.bitrate":
                    track.bitrate = (short) field.Value;
                    break;
                case "daap.songdateadded":
                    track.dateAdded = (DateTime) field.Value;
                    break;
                case "daap.songdatemodified":
                    track.dateModified = (DateTime) field.Value;
                    break;
                case "daap.songdiscnumber":
                    track.discNumber = (short) field.Value;
                    break;
                case "daap.songdisccount":
                    track.discCount = (short) field.Value;
                    break;
                default:
                    break;
                }
            }

            return track;
        }