Esempio n. 1
0
        public static ThumbnailView Create(IFocusNodeComponent cFocus)
        {
            var view = AmFactory.Create <ThumbnailView>();

            view.Init(cFocus);
            return(view);
        }
Esempio n. 2
0
        private ConversionContext InitConversionContext(IFileLoadInfo loadInfo, Presentation ppPresentation)
        {
            var nextId = 1;
            var world  = AmFactory.Create <World>();
            var scene  = AmFactory.Create <Scene>();

            scene.Name            = "Scene";
            scene.BackgroundColor = Color4.White;
            world.Scenes.Add(scene);
            var rootNode = commonNodeFactory.WorldRoot(true);

            scene.Root  = rootNode;
            rootNode.Id = nextId++;
            var floorNode = commonNodeFactory.StoryNode();

            floorNode.Id   = nextId++;
            floorNode.Name = "Slides";
            rootNode.ChildNodes.Add(floorNode);

            return(new ConversionContext
            {
                NextId = nextId,
                LoadInfo = loadInfo,
                PpPresentation = ppPresentation,
                World = world,
                SlideNodes = floorNode.ChildNodes
            });
        }
        public static EditRectangleGizmoComponent Create(ISceneNode rectangleNode)
        {
            var result = AmFactory.Create <EditRectangleGizmoComponent>();

            result.RectangleNode = rectangleNode;
            return(result);
        }
        public void ResetEditingViewports(IRenderGuiControl renderControl, IFocusNodeComponent aMainFocusNode)
        {
            var editingView = AmFactory.Create <EditingView>();

            editingView.FocusOn(aMainFocusNode);

            var editViewport = AmFactory.Create <Viewport>();

            editViewport.View = editingView;

            renderControl.SetViewports(
                new[] { editViewport },
                new ViewportsLayout
            {
                RowHeights = new[]
                {
                    new ViewportLength(100, ViewportLengthUnit.Percent),
                },
                ColumnWidths = new[]
                {
                    new ViewportLength(100, ViewportLengthUnit.Percent)
                },
                ViewportIndices = new[, ] {
                    { 0 }
                }
            });

            viewService.ChangeRenderingArea(renderControl, editingView);
        }
Esempio n. 5
0
        public void SplitSpan(RtPosition pos, out int nextSpanIndex)
        {
            GetParaAndSpan(pos, out var para, out var span);
            if (pos.CharIndex == 0)
            {
                nextSpanIndex = pos.SpanIndex;
                return;
            }
            if (pos.CharIndex == span.LayoutTextLength)
            {
                nextSpanIndex = pos.SpanIndex + 1;
                return;
            }
            if (!(span is IRtPureSpan pureSpan))
            {
                throw new InvalidOperationException("Cannot split non-pure spans in the middle");
            }
            var secondSpan = AmFactory.Create <RtPureSpan>();

            secondSpan.Style = span.Style.CloneTyped();
            secondSpan.Text  = pureSpan.Text.Substring(pos.CharIndex);
            pureSpan.Text    = pureSpan.Text.Substring(0, pos.CharIndex);
            para.Spans.Insert(pos.SpanIndex + 1, secondSpan);
            nextSpanIndex = pos.SpanIndex + 1;
        }
Esempio n. 6
0
 protected RichTextBox(IRichTextBoxLayoutBuilder layoutBuilder)
 {
     this.layoutBuilder = layoutBuilder;
     PixelScaling       = DefaultPixelScaling;
     CacheContainer     = new CacheContainer();
     Text = AmFactory.Create <RichText>();
 }
Esempio n. 7
0
        public ISceneNode RectangleEditGizmo(ISceneNode rectangleNode)
        {
            var gizmoRoot = AmFactory.Create <SceneNode>();

            gizmoRoot.Name = "RectangleEditGizmo";
            gizmoRoot.Components.Add(EditRectangleGizmoComponent.Create(rectangleNode));
            var dragGizmo     = AmFactory.Create <SceneNode>();
            var dragComponent = AmFactory.Create <DragRectangleGizmoComponent>();

            dragGizmo.Components.Add(dragComponent);
            gizmoRoot.ChildNodes.Add(dragGizmo);

            ISceneNode CreateResizeGizmo(ResizeRectangleGizmoPlace place)
            {
                var resizeGizmo     = AmFactory.Create <SceneNode>();
                var resizeComponent = AmFactory.Create <ResizeRectangleGizmoComponent>();

                resizeComponent.Place = place;
                resizeGizmo.Components.Add(resizeComponent);
                return(resizeGizmo);
            }

            gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.Left));
            gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.Right));
            gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.Bottom));
            gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.Top));
            gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.BottomLeft));
            gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.BottomRight));
            gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.TopLeft));
            gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.TopRight));

            return(gizmoRoot);
        }
Esempio n. 8
0
        public static PresentationRootComponent Create(Guid presentationGuid)
        {
            var self = AmFactory.Create <PresentationRootComponent>();

            self.PresentationGuid = presentationGuid;
            return(self);
        }
        private static IRtParagraph CreatePara(IRtParagraphStyle paraStyleProto, IRtSpanStyle spanStyleProto)
        {
            var para = AmFactory.Create <RtParagraph>();

            para.Style = paraStyleProto.CloneTyped();
            para.Spans.Add(CreatePureSpan(spanStyleProto));
            return(para);
        }
Esempio n. 10
0
        private static IRtPureSpan CreateSpan(string text, IRtSpanStyle style)
        {
            var span = AmFactory.Create <RtPureSpan>();

            span.Text  = text;
            span.Style = style;
            return(span);
        }
        private static IRtPureSpan CreatePureSpan(IRtSpanStyle styleProto, string initialText = "")
        {
            var span = AmFactory.Create <RtPureSpan>();

            span.Style = styleProto.CloneTyped();
            span.Text  = initialText;
            return(span);
        }
Esempio n. 12
0
 public ViewService(IEventRoutingService eventRoutingService, IRenderLoopDispatcher renderLoopDispatcher, IStoryService storyService)
 {
     this.storyService = storyService;
     model             = AmFactory.Create <ViewServiceModel>();
     eventRoutingService.RegisterServiceDependency(typeof(IViewService), typeof(IWorldTreeService));
     eventRoutingService.Subscribe <IAppModeChangedEvent>(typeof(IViewService), nameof(OnAppModeChange), OnAppModeChange);
     renderLoopDispatcher.Update += OnUpdate;
 }
        private static ISceneNode CreateDragAxisGizmo(Axis3D axis)
        {
            var node      = AmFactory.Create <SceneNode>();
            var component = AmFactory.Create <DragAlongAxisGizmoComponent>();

            component.Axis = axis;
            node.Components.Add(component);
            return(node);
        }
        private static IRtEmbeddingSpan CreateEmbeddingSpan(IRtSpanStyle styleProto, string embeddingType, string initialSource = "")
        {
            var span = AmFactory.Create <RtEmbeddingSpan>();

            span.Style         = styleProto.CloneTyped();
            span.EmbeddingType = embeddingType;
            span.SourceCode    = initialSource;
            return(span);
        }
Esempio n. 15
0
        public void OnActivate()
        {
            var entity = AmFactory.Create <SceneNode>();

            entity.Components.Add(AmFactory.Create <FluidSimulationComponent>());
            var tool = new MoveEntityTool(entity, true, toolService, undoRedoService);

            toolService.CurrentTool = tool;
        }
 public RichTextHeadlessEditor(IRichText text)
 {
     this.text        = text;
     defaultParaStyle = AmFactory.Create <RtParagraphStyle>();
     defaultSpanStyle = AmFactory.Create <RtSpanStyle>();
     inputSpanStyle   = AmFactory.Create <RtSpanStyle>();
     NormalizeText(text, defaultParaStyle, defaultSpanStyle);
     MoveCursor(0, false);
 }
Esempio n. 17
0
        public override bool ValidValue(object aValue)
        {
            Check.Require(aValue != null, string.Format(CommonStrings.XMustNotBeNull, "aValue"));

            CComplexObject rootDefinition = AmFactory.GetRootDefinition(this);

            CObject cObjAtTargetPath = Archetype.GetCObjectAtTargetPath(rootDefinition, this.TargetPath);

            return(cObjAtTargetPath.ValidValue(aValue));
        }
        public void OnActivate()
        {
            var entity = AmFactory.Create <SceneNode>();

            entity.Name = "CirclePacking";
            entity.Components.Add(AmFactory.Create <PresentationComponent>());
            entity.Components.Add(AmFactory.Create <CirclePackingNodeComponent>());
            var tool = new MoveEntityTool(entity, true, toolService, undoRedoService);

            toolService.CurrentTool = tool;
        }
Esempio n. 19
0
 public void Normalize()
 {
     if (!Paragraphs.Any())
     {
         Paragraphs.Add(AmFactory.Create <RtParagraph>());
     }
     foreach (var para in Paragraphs)
     {
         para.Normalize();
     }
 }
Esempio n. 20
0
        public static Viewport Create(IntVector2 topLeft, IntSize2 size, IView view)
        {
            var viewport = AmFactory.Create <Viewport>();

            viewport.Left   = topLeft.X;
            viewport.Top    = topLeft.Y;
            viewport.Width  = size.Width;
            viewport.Height = size.Height;
            viewport.View   = view;
            return(viewport);
        }
        // TODO: this must be reinstated when ConfigurationSource is able to be specified

        #endregion



        void ReadCAttribute(XmlReader reader, CAttribute cAttribute)
        {
            Check.Require(cAttribute != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute"));

            if (reader.LocalName != "rm_attribute_name")
            {
                throw new InvalidXmlException("rm_attribute_name", reader.LocalName);
            }
            cAttribute.RmAttributeName = reader.ReadElementContentAsString("rm_attribute_name", OpenEhrNamespace);
            reader.MoveToContent();

            if (reader.LocalName != "existence")
            {
                throw new InvalidXmlException("existence", reader.LocalName);
            }
            cAttribute.Existence = new Interval <int>();
            amSerializer.ReadExistence(reader, cAttribute.Existence);

            if (reader.LocalName == "children")
            {
                cAttribute.Children = new OpenEhr.AssumedTypes.List <CObject>();
                do
                {
                    string cObjectType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace);
                    DesignByContract.Check.Assert(!string.IsNullOrEmpty(cObjectType), "cObjectType must not be null or empty.");

                    CObject cObj;
                    switch (cObjectType)
                    {
                    case "C_ARCHETYPE_ROOT":

                        CArchetypeRoot archetypeRoot = new CArchetypeRoot();
                        ReadCArchetypeRoot(reader, archetypeRoot);
                        cObj = archetypeRoot;
                        break;

                    case "C_COMPLEX_OBJECT":
                        CComplexObject complexObject = new CComplexObject();
                        ReadCComplexObject(reader, complexObject);
                        cObj = complexObject;
                        break;

                    default:
                        cObj = AmFactory.CObject(cObjectType);
                        amSerializer.ReadCObject(reader, cObj);
                        break;
                    }

                    cObj.Parent = cAttribute;
                    cAttribute.Children.Add(cObj);
                } while (reader.LocalName == "children" && reader.NodeType != XmlNodeType.EndElement);
            }
        }
Esempio n. 22
0
        protected void Validate(ArchetypeInternalRef archetypeInternalRef)
        {
            this.ValidateBase((CObject)archetypeInternalRef);

            Invariant(!string.IsNullOrEmpty(archetypeInternalRef.TargetPath), string.Format(
                          CommonStrings.XMustNotBeNullOrEmpty, "AarchetypeInternalRef.TargetPath"));

            // TODO: Consistency: not any_allowed
            CComplexObject rootDefinition = AmFactory.GetRootDefinition(archetypeInternalRef);

            Invariant(rootDefinition.HasPath(archetypeInternalRef.TargetPath),
                      AmValidationStrings.ArchetypeInternalRefTargetPathMissing);
        }
Esempio n. 23
0
 public StoryService(IEventRoutingService eventRoutingService, IWorldTreeService worldTreeService, IRenderLoopDispatcher renderLoopDispatcher, IReadOnlyList <IStoryLayout> allLayouts)
 {
     this.worldTreeService = worldTreeService;
     layoutsByType         = allLayouts.ToDictionary(x => x.Type, x => x);
     layouts      = new Dictionary <ISceneNode, IStoryLayout>();
     transactions = new List <object>();
     editingScene = Scene.Create(AmFactory.Create <SceneNode>());
     editingScene.BackgroundColor = Color4.Black;
     editSceneComponent           = AmFactory.Create <StoryFlowchartEditSceneComponent>();
     editingScene.Root.Components.Add(editSceneComponent);
     eventRoutingService.RegisterServiceDependency(typeof(IStoryService), typeof(IWorldTreeService));
     eventRoutingService.Subscribe <IWorldTreeUpdatedEvent>(typeof(IStoryService), nameof(OnWorldUpdated), OnWorldUpdated);
     renderLoopDispatcher.Update += editingScene.Root.Update;
 }
Esempio n. 24
0
        protected override System.Collections.Generic.List <string> GetPhysicalPaths()
        {
            CComplexObject rootDefinition = AmFactory.GetRootDefinition(this);

            CObject cObjAtTargetPath = Archetype.GetCObjectAtTargetPath(rootDefinition, this.TargetPath);

            if (cObjAtTargetPath == null)
            {
                throw new ApplicationException(string.Format(
                                                   AmValidationStrings.NoNodeMatchAtPath, this.TargetPath));
            }

            return(cObjAtTargetPath.PhysicalPaths);
        }
        public void Initialize()
        {
            minimap      = GameObject.CreatePrimitive(PrimitiveType.Quad);
            minimap.name = "Minimap";
            minimap.transform.SetParent(globalObjectService.VrLeftHand.transform, false);
            minimap.transform.localRotation = Quaternion.AngleAxis(75.0f, Vector3.right);
            minimap.transform.localPosition = new Vector3(0.0F, -0.1F, 0.25F);
            minimap.transform.localScale    = new Vector3(0.8f, -0.4f, 1f);
            var material = new Material(Shader.Find("Unlit/Texture"));

            rttImge = (UcRenderTextureImage)renderService.CreateRenderTargetImage(MinimapImageSize);
            material.mainTexture = rttImge.Texture;
            minimap.transform.GetComponent <MeshRenderer>().material = material;

            var textCanvasObj = new GameObject("Minimap - Text Above");

            textCanvasObj.transform.SetParent(minimap.transform, false);
            //textAbove.transform.localRotation = Quaternion.AngleAxis(75.0f, Vector3.right);
            //textAbove.transform.localPosition = new Vector3(0.0F, 1F, 0.25F);
            //textAbove.transform.localScale
            var canvas = textCanvasObj.AddComponent <Canvas>();

            canvas.renderMode = RenderMode.WorldSpace;
            var textAboveTransform = textCanvasObj.GetComponent <RectTransform>();

            textAboveTransform.localPosition = new Vector3(0, -0.6f, 0);
            textAboveTransform.localScale    = new Vector3(1.25f, -2.5f, 1);
            textAboveTransform.sizeDelta     = new Vector2(100, 100);
            var canvasScaler = textCanvasObj.AddComponent <CanvasScaler>();

            canvasScaler.dynamicPixelsPerUnit = 100;
            var textObject = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/MinimapTextPrefab"));

            textObject.transform.SetParent(textCanvasObj.transform, false);
            textAbove = textObject.GetComponent <Text>();
            var textTransform = textAbove.GetComponent <RectTransform>();

            textAbove.text = "";

            var storyGraphView = AmFactory.Create <StoryGraphView>();
            var viewport       = AmFactory.Create <Viewport>();

            viewport.Width  = MinimapImageSize.Width;
            viewport.Height = MinimapImageSize.Height;
            viewport.View   = storyGraphView;
            viewports       = new IViewport[] { viewport };
            laser           = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Laser"));
            SetEnabled(false);
        }
Esempio n. 26
0
        public void Run()
        {
            var eventSender = di.Get <IGlobalObjectService>().EventObject.GetComponent <EventSender>();

            SetupLoop(eventSender);

            var saveLoadService = di.Get <ISaveLoadService>();

            saveLoadService.Format   = di.GetMulti <ISaveLoadFormat>().First(x => x is ZipSaveLoadFormat);
            saveLoadService.FileName = SceneParameters.PresentationFilePath;
            saveLoadService.Load(LoadWorldPreference.ReadOnlyOnly);
            var appModeService = di.Get <IAppModeService>();

            appModeService.SetMode(AppMode.Presentation);
            var worldTreeService = di.Get <IWorldTreeService>();
            var storyGraph       = di.Get <IStoryService>().GlobalGraph;
            var firstNodeId      = storyGraph.Leaves.First();

            while (storyGraph.Previous[firstNodeId].HasItems())
            {
                firstNodeId = storyGraph.Previous[firstNodeId].First();
            }
            di.Get <INavigationService>().GoToSpecific(firstNodeId);
            var presentationView = AmFactory.Create <PresentationView>();

            presentationView.FocusOn(worldTreeService.GetById(firstNodeId).GetComponent <IFocusNodeComponent>());
            var viewport = AmFactory.Create <Viewport>();

            viewport.View = presentationView;
            RenderControl.SetViewports(
                new [] { viewport },
                new ViewportsLayout
            {
                RowHeights      = new[] { new ViewportLength(100, ViewportLengthUnit.Percent) },
                ColumnWidths    = new[] { new ViewportLength(100, ViewportLengthUnit.Percent) },
                ViewportIndices = new[, ] {
                    { 0 }
                }
            });
            var viewService = di.Get <IViewService>();

            viewService.ChangeRenderingArea(RenderControl, presentationView);
            if (SceneParameters.IsTutorial)
            {
                var tutorialScenario        = di.Instantiate <TutorialScenario>();
                var vrInitializationService = di.Get <IVrInitializerService>();
                vrInitializationService.Initialized += () => tutorialScenario.RunTutorial();
            }
        }
Esempio n. 27
0
 public void Apply()
 {
     index = source.ChildNodes.IndexOf(sourceItem);
     if (copy)
     {
         destinationItem    = sourceItem.CloneTyped();
         destinationItem.Id = AmFactory.Create <SceneNode>().Id;
     }
     else
     {
         destinationItem = sourceItem;
         destinationItem.Deparent();
     }
     destination.ChildNodes.Add(destinationItem);
 }
Esempio n. 28
0
 public void Normalize()
 {
     if (Spans.Count == 0)
     {
         Spans.Add(AmFactory.Create <RtPureSpan>());
     }
     else
     {
         for (var i = Spans.Count - 1; i > 0; i--)
         {
             if (Spans[i].IsEmpty)
             {
                 Spans.RemoveAt(i);
             }
         }
     }
     // todo: merge spans
 }
Esempio n. 29
0
        public ISceneNode WorldRoot(bool withStoryComponent)
        {
            var node = objectFactory.Create <SceneNode>();

            node.Name = "World";

            if (withStoryComponent)
            {
                node.Components.Add(PresentationRootComponent.Create(Guid.NewGuid()));
                node.Components.Add(AmFactory.Create <StoryServiceRootComponent>());
                var storyComponent = objectFactory.Create <StoryComponent>();
                storyComponent.StartLayoutType = typeof(SphereStoryLayout);
                node.Components.Add(storyComponent);
            }
            else
            {
                node.Components.Add(PresentationComponent.Create());
            }
            return(node);
        }
Esempio n. 30
0
        // todo: switch out of VR mode

        private void InitView()
        {
            var presentationView = new VrPresentationView(storyService, navigationService, globalObjectService, userQueryService, vrInputDispatcher);

            presentationView.FocusOn(navigationService.Current.GetComponent <IFocusNodeComponent>());
            var viewport = AmFactory.Create <Viewport>();

            viewport.Width  = 128;
            viewport.Height = 128;
            viewport.View   = presentationView;
            guiLazy.Value.RenderControl.SetViewports(
                new[] { viewport },
                new ViewportsLayout
            {
                RowHeights      = new[] { new ViewportLength(100, ViewportLengthUnit.Percent) },
                ColumnWidths    = new[] { new ViewportLength(100, ViewportLengthUnit.Percent) },
                ViewportIndices = new[, ] {
                    { 0 }
                }
            });
        }