コード例 #1
0
        public RmlWidgetComponent(RmlView view, AnomalousMvcContext context, MyGUIViewHost viewHost)
            : base("Medical.GUI.AnomalousMvc.RmlView.RmlWidgetComponent.layout", viewHost)
        {
            this.context         = context;
            this.eventController = view.createRocketEventController(context, viewHost);

            rmlImage     = (ImageBox)widget;
            rocketWidget = new RocketWidget(rmlImage, viewHost.View.Transparent, false);
            imageHeight  = widget.Height;
            imageWidth   = widget.Width;

            if (view.RmlFile != null)
            {
                startRmlUpdate();
                if (view.RmlFile != null)
                {
                    rocketWidget.Context.ZoomLevel = view.ZoomLevel;
                    documentName = RocketInterface.createValidFileUrl(context.ResourceProvider.getFullFilePath(view.RmlFile));
                    using (ElementDocument document = rocketWidget.Context.LoadDocument(documentName))
                    {
                        if (document != null)
                        {
                            document.Show();
                            rocketWidget.removeFocus();
                            rocketWidget.renderOnNextFrame();
                        }
                    }
                }
                endRmlUpdate();
            }

            view._fireComponentCreated(this);
        }
コード例 #2
0
        public void endRmlUpdate()
        {
            RocketEventListenerInstancer.resetEventController();

            //Find all custom controls and hook them up
            ElementDocument document = rocketWidget.Context.GetDocument(0);

            foreach (Element element in document.GetElementsByTagName("data"))
            {
                switch (element.GetAttributeString("type"))
                {
                case "volume":
                    dataDisplays.Add(new VolumeDisplay(element, context, rocketWidget));
                    break;

                case "measurement":
                    dataDisplays.Add(new MeasurementDisplay(element, context, rocketWidget));
                    break;

                default:
                    element.InnerRml = String.Format("Unknown data display type '{0}'", element.GetAttributeString("type"));
                    Logging.Log.Error("Could not create a display type for '{0}'", element.GetAttributeString("type"));
                    break;
                }
            }

            float height = 0.0f;

            foreach (var child in document.Children)
            {
                height += child.ScrollHeight;
            }
            widget.Height = (int)(height + 0.5f);
        }
コード例 #3
0
        private void openRml()
        {
            VirtualFilesystemResourceProvider resourceProvider = new VirtualFilesystemResourceProvider("BuyScreens");
            String file = "TaskMenuAd/Index.rml";

            if (resourceProvider.exists(file))
            {
                ResourceProviderRocketFSExtension resourceProviderRocketFSExtension = new ResourceProviderRocketFSExtension(resourceProvider);
                RocketInterface.Instance.SystemInterface.AddRootPath(resourceProvider.BackingLocation);
                RocketInterface.Instance.FileInterface.addExtension(resourceProviderRocketFSExtension);

                DelegateRocketEventController eventController = new DelegateRocketEventController();
                eventController.addHandler("visitAnomalousPage", visitAnomalousPage);
                RocketEventListenerInstancer.setEventController(eventController);

                RocketWidgetInterface.clearAllCaches();
                rocketWidget.Context.UnloadAllDocuments();

                using (ElementDocument document = rocketWidget.Context.LoadDocument(resourceProvider.getFullFilePath(file)))
                {
                    if (document != null)
                    {
                        document.Show();
                        rocketWidget.removeFocus();
                        rocketWidget.renderOnNextFrame();
                        adImage.setSize(adImage.Width, (int)document.OffsetHeight);
                        rocketWidget.resized();
                    }
                }

                RocketEventListenerInstancer.resetEventController();
                RocketInterface.Instance.FileInterface.removeExtension(resourceProviderRocketFSExtension);
                RocketInterface.Instance.SystemInterface.RemoveRootPath(resourceProvider.BackingLocation);
            }
        }
コード例 #4
0
ファイル: GuiDocument.cs プロジェクト: raycrasher/FellSkyR2
 public void OnShutdown(ShutdownContext context)
 {
     if (context == ShutdownContext.Deactivate && _document != null)
     {
         GuiCore.Context.UnloadDocument(_document);
         _document = null;
     }
 }
コード例 #5
0
ファイル: MainMenu.cs プロジェクト: raycrasher/FellSkyR9
 void ICmpInitializable.OnInit(InitContext context)
 {
     if (context == InitContext.Activate && DualityApp.ExecEnvironment == DualityApp.ExecutionEnvironment.Launcher)
     {
         _document = GuiCore.Context.LoadDocument(DocumentPath);
         _document.Show();
     }
 }
コード例 #6
0
ファイル: GuiDocument.cs プロジェクト: raycrasher/FellSkyR2
 public void OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         if (GuiCore.Context != null && _document == null && Filename != null)
         {
             _document = GuiCore.Context.LoadDocument(Filename);
             _document?.Show();
         }
     }
 }
コード例 #7
0
        public override ViewHostControl findControl(string name)
        {
            ElementDocument document = rocketWidget.Context.GetDocument(0);
            Element         element  = document.GetElementById(name);

            if (element != null)
            {
                return(new RmlViewHostControl(element, this, rocketWidget));
            }
            return(null);
        }
コード例 #8
0
        private bool setDocumentRml(String rml, bool maintainScrollPosition)
        {
            float   scrollLeft = 0.0f;
            float   scrollTop  = 0.0f;
            Element topContentElement;

            if (maintainScrollPosition)
            {
                topContentElement = TopContentElement;
                if (topContentElement != null)
                {
                    scrollLeft = topContentElement.ScrollLeft;
                    scrollTop  = topContentElement.ScrollTop;
                }
            }

            RocketWidgetInterface.clearAllCaches();
            rocketWidget.Context.UnloadAllDocuments();
            cancelAndHideEditor();
            selectedElementManager.clearSelectedAndHighlightedElement();

            if (rml != null)
            {
                using (ElementDocument document = rocketWidget.Context.LoadDocumentFromMemory(rml, FakeLoadLocation))
                {
                    if (document != null)
                    {
                        saveDocumentStartAndEnd(rml);
                        document.Show();
                        rocketWidget.removeFocus();
                        rocketWidget.renderOnNextFrame();

                        if (maintainScrollPosition)
                        {
                            topContentElement = TopContentElement;
                            if (topContentElement != null)
                            {
                                topContentElement.ScrollLeft = scrollLeft;
                                topContentElement.ScrollTop  = scrollTop;
                            }
                        }

                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #9
0
        public void setFile(String file)
        {
            RocketEventListenerInstancer.setEventController(eventController);
            RocketWidgetInterface.clearAllCaches();
            rocketWidget.Context.UnloadAllDocuments();

            using (ElementDocument document = rocketWidget.Context.LoadDocument(resourceProvider.getFullFilePath(file)))
            {
                if (document != null)
                {
                    document.Show();
                    rocketWidget.removeFocus();
                    rocketWidget.renderOnNextFrame();
                }
            }
            RocketEventListenerInstancer.resetEventController();
        }
コード例 #10
0
        public void showPreviewElement(ElementDocument document, String innerRmlHint, Element parent, Element sibling, String previewElementTagType, bool insertBefore)
        {
            if (previewElement == null)
            {
                previewElement = document.CreateElement(previewElementTagType);
            }

            previewElement.InnerRml = innerRmlHint;

            if (sibling == null)
            {
                parent.AppendChild(previewElement);
            }
            else
            {
                parent.Insert(previewElement, sibling, insertBefore);
            }
        }
コード例 #11
0
        public override void analyzeViewData(IDataProvider dataProvider)
        {
            base.analyzeViewData(dataProvider);
            ElementDocument document = rocketWidget.Context.GetDocument(0);

            runIfAnalysis(dataProvider, document);

            //Print statements
            foreach (Element print in document.GetElementsByTagName("print"))
            {
                String name  = print.GetAttributeString("name");
                String value = dataProvider.getValue(name);
                if (value != null)
                {
                    print.InnerRml = value;
                }
            }
        }
コード例 #12
0
        private void insertRmlIntoDocument(String rml)
        {
            if (allowEdit)
            {
                previewElement.hidePreviewElement();

                ElementDocument document = rocketWidget.Context.GetDocument(0);
                using (Element div = document.CreateElement("temp"))
                {
                    Element topContentElement = TopContentElement;
                    if (selectedElementManager.HasSelection && selectedElementManager.SelectedElement != topContentElement)
                    {
                        Element insertInto = selectedElementManager.SelectedElement.ParentNode;
                        if (insertInto != null)
                        {
                            insertInto.Insert(div, selectedElementManager.SelectedElement, lastInsertBefore);
                        }
                    }
                    else
                    {
                        topContentElement.AppendChild(div);
                    }

                    div.InnerRml = rml;

                    Element parent = div.ParentNode;
                    Element child;
                    Element next = div.FirstChild;

                    while (next != null)
                    {
                        child = next;
                        next  = child.NextSibling;
                        parent.InsertBefore(child, div);
                    }
                    parent.RemoveChild(div);

                    rmlModified();
                }
            }
        }
コード例 #13
0
        public RocketWindow()
            : base("Anomalous.Minimus.Full.GUI.RocketWindow.RocketWindow.layout")
        {
            RocketInterface.Instance.FileInterface.addExtension(new RocketAssemblyResourceLoader(typeof(RocketWindow).Assembly));

            rocketWidget = new RocketWidget(window.findWidget("Image") as ImageBox, false);
            //rocketWidget.Context.LoadDocument ("~/Phoneworld_droid.GUI.RocketWindow.TestRml.rml");

            RocketWidgetInterface.clearAllCaches();
            rocketWidget.Context.UnloadAllDocuments();
            using (ElementDocument document = rocketWidget.Context.LoadDocumentFromMemory(testRml))
            {
                if (document != null)
                {
                    document.Show();
                    rocketWidget.removeFocus();
                    rocketWidget.renderOnNextFrame();
                }
            }

            window.WindowChangedCoord += HandleWindowChangedCoord;
        }
コード例 #14
0
        public SceneErrorWindow(GUIManager guiManager)
            : base("Medical.GUI.SceneErrorWindow.SceneErrorWindow.layout")
        {
            rmlImage     = (ImageBox)window.findWidget("RmlImage");
            rocketWidget = new RocketWidget(rmlImage, false);

            window.WindowChangedCoord += window_WindowChangedCoord;
            this.guiManager            = guiManager;
            guiManager.addManagedDialog(this);
            guiManager.autoDisposeDialog(this);

            rocketWidget.Context.UnloadAllDocuments();

            StringBuilder htmlString = new StringBuilder();

            htmlString.Append(DocumentStart);

            foreach (var error in SimObjectErrorManager.Errors)
            {
                htmlString.AppendFormat(ErrorLine, error.Subsystem, error.SimObject, error.Type, error.ElementName, error.Message);
            }

            htmlString.Append(DocumentEnd);

            var resourceLoader = new RocketAssemblyResourceLoader(this.GetType().Assembly);

            RocketInterface.Instance.FileInterface.addExtension(resourceLoader);
            using (ElementDocument document = rocketWidget.Context.LoadDocumentFromMemory(htmlString.ToString()))
            {
                if (document != null)
                {
                    document.Show();
                    rocketWidget.removeFocus();
                    rocketWidget.renderOnNextFrame();
                }
            }
            RocketInterface.Instance.FileInterface.removeExtension(resourceLoader);
        }
コード例 #15
0
        /// <summary>
        /// 根据 Xml获取菜单列表json数据集
        /// </summary>
        /// <returns></returns>
        public string GetJson(Controller controller)
        {
            var menus = from menu in ElementDocument.Elements("menu")
                        orderby menu.Attribute("order").Value ascending
                        select menu;

            StringBuilder sb = new StringBuilder();

            sb.Append("[");


            foreach (var menu in menus)
            {
                sb.Append("{");
                sb.Append("\"menuName\":\"" + menu.Attribute("name").Value + "\",");
                sb.Append("\"items\":[");
                var items = from item in menu.Elements("item")
                            orderby item.Attribute("order").Value ascending
                            select item;

                foreach (var item in items)
                {
                    sb.Append("{");
                    sb.Append("\"text\":\"" + item.Attribute("text").Value + "\",");
                    sb.Append("\"leaf\":\"true\",");
                    sb.Append("\"url\":\"" + controller.Url.Content(item.Element("url").Value) + "\"");
                    sb.Append("},");
                }
                sb.Remove(sb.Length - 1, 1);
                sb.Append("]");
                sb.Append("},");
            }
            sb.Remove(sb.Length - 1, 1);
            sb.Append("]");
            return(sb.ToString());
        }
コード例 #16
0
        public void reloadDocument()
        {
            if (rocketWidget != null)
            {
                RocketWidgetInterface.clearAllCaches();

                rocketWidget.Context.UnloadAllDocuments();

                if (documentName != null)
                {
                    startRmlUpdate();
                    using (ElementDocument document = loadDocument())
                    {
                        if (document != null)
                        {
                            document.Show();
                            rocketWidget.removeFocus();
                            rocketWidget.renderOnNextFrame();
                        }
                    }
                    endRmlUpdate();
                }
            }
        }
コード例 #17
0
ファイル: MainMenuScene.cs プロジェクト: raycrasher/Fell-Sky
 private void InitializeDocument()
 {
     if (document == null)
     {
         LibRocketNet.Core.ScriptEvent += (o, e) => Instance?.OnScriptEvent(o, e);
         document = _guiService.Context.LoadDocument(MainMenuDocumentPath);
     }
 }
コード例 #18
0
ファイル: GuiSystem.cs プロジェクト: raycrasher/Fell-Sky
 public override void LoadContent()
 {
     _document =  _service.Context.LoadDocument(Properties.Settings.Default.GuiDocument);
     _document.Show(ElementDocument.FocusFlags.None);
     base.LoadContent();
 }
コード例 #19
0
        private void runIfAnalysis(IDataProvider dataProvider, ElementDocument document)
        {
            List <Element> removeElements = new List <Element>();

            foreach (Element element in document.GetElementsWithAttribute("condition"))
            {
                bool   success   = false;
                String statement = element.GetAttributeString("condition").Replace("&lt;", "<").Replace("&gt;", ">");
                Match  match     = Regex.Match(statement, ifRegex);
                if (match.Success)
                {
                    String left  = statement.Substring(0, match.Index).Trim();
                    String right = statement.Substring(match.Index + match.Length).Trim();
                    String op    = match.Value;

                    if (!String.IsNullOrEmpty(op) && !String.IsNullOrEmpty(left) && !String.IsNullOrEmpty(right))
                    {
                        if (left[0] == '%')
                        {
                            left = dataProvider.getValue(left.Substring(1, left.Length - 1));
                        }
                        if (right[0] == '%')
                        {
                            right = dataProvider.getValue(right.Substring(1, right.Length - 1));
                        }
                        if (!String.IsNullOrEmpty(left) && !String.IsNullOrEmpty(right))
                        {
                            switch (op)
                            {
                            case "==":
                                success = left == right;
                                break;

                            case "!=":
                                success = left != right;
                                break;

                            case ">=":
                                decimal leftNum, rightNum;
                                if (decimal.TryParse(left, out leftNum) && decimal.TryParse(right, out rightNum))
                                {
                                    success = leftNum >= rightNum;
                                }
                                break;

                            case "<=":
                                if (decimal.TryParse(left, out leftNum) && decimal.TryParse(right, out rightNum))
                                {
                                    success = leftNum <= rightNum;
                                }
                                break;

                            case ">":
                                if (decimal.TryParse(left, out leftNum) && decimal.TryParse(right, out rightNum))
                                {
                                    success = leftNum > rightNum;
                                }
                                break;

                            case "<":
                                if (decimal.TryParse(left, out leftNum) && decimal.TryParse(right, out rightNum))
                                {
                                    success = leftNum < rightNum;
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        Log.Warning("Invalid condition statement on element '{0}' statement: {1}", element.TagName, statement);
                    }
                }
                else
                {
                    Log.Warning("Invalid operator on condition statement on element '{0}' statement: {1}", element.TagName, statement);
                }

                if (!success)
                {
                    removeElements.Add(element);
                }
            }

            foreach (Element remove in removeElements)
            {
                Element parent = remove.ParentNode;
                if (parent != null)
                {
                    parent.RemoveChild(remove);
                }
            }
        }
コード例 #20
0
        /// <summary>
        /// Set the preview element at position if position is inside this widget. Returns true if the position is inside this widget.
        /// </summary>
        public bool setPreviewElement(IntVector2 position, String innerRmlHint, String previewElementTagType)
        {
            if (widget.contains(position.x, position.y))
            {
                position.x -= widget.AbsoluteLeft;
                position.y -= widget.AbsoluteTop;

                Element toSelect = rocketWidget.Context.FindElementAtPoint(position);
                if (toSelect != null && !toSelect.isDescendentOf(TopContentElement))
                {
                    toSelect = null;
                }
                Element selectedElement = selectedElementManager.SelectedElement;

                bool insertBefore         = lastInsertBefore;
                bool toSelectIsNotPreview = true;
                if (toSelect != null)
                {
                    toSelectIsNotPreview = !previewElement.isPreviewOrDescendent(toSelect);
                    if (toSelectIsNotPreview)
                    {
                        insertBefore = insertBeforeOrAfter(toSelect, position);
                    }
                }
                if (toSelectIsNotPreview && (toSelect != selectedElement || insertBefore != lastInsertBefore))
                {
                    if (toSelect != null)
                    {
                        Element topContentElement = TopContentElement;
                        if (toSelect != topContentElement)
                        {
                            selectedElementManager.SelectedElement = toSelect;
                            previewElement.hidePreviewElement();
                            ElementDocument document = rocketWidget.Context.GetDocument(0);
                            previewElement.showPreviewElement(document, innerRmlHint, toSelect.ParentNode, toSelect, previewElementTagType, insertBefore);
                            selectedElementManager.HighlightElement = previewElement.HighlightPreviewElement;
                        }
                        else
                        {
                            selectedElementManager.SelectedElement = null;
                            previewElement.hidePreviewElement();
                            ElementDocument document = rocketWidget.Context.GetDocument(0);
                            previewElement.showPreviewElement(document, innerRmlHint, toSelect, null, previewElementTagType, insertBefore);
                            selectedElementManager.HighlightElement = previewElement.HighlightPreviewElement;
                        }
                        selectedElementManager.ElementStrategy = null;
                    }
                    else
                    {
                        selectedElementManager.clearSelectedAndHighlightedElement();
                        previewElement.hidePreviewElement();
                    }

                    lastInsertBefore = insertBefore;

                    rocketWidget.Context.Update();
                    selectedElementManager.updateHighlightPosition();
                    rocketWidget.renderOnNextFrame();
                }
                return(true);
            }
            else
            {
                selectedElementManager.clearSelectedAndHighlightedElement();
                previewElement.hidePreviewElement();
                rocketWidget.renderOnNextFrame();
                return(false);
            }
        }
コード例 #21
0
        public override void populateViewData(IDataProvider dataProvider)
        {
            base.populateViewData(dataProvider);
            ElementDocument document = rocketWidget.Context.GetDocument(0);

            foreach (Element form in document.GetElementsByTagName("form"))
            {
                foreach (Element input in form.GetElementsByTagName("input"))
                {
                    String name = input.GetAttributeString("name");
                    if (name != null)
                    {
                        String value = dataProvider.getValue(name);
                        String type  = input.GetAttributeString("type").ToLowerInvariant();
                        if (value != null)
                        {
                            switch (type)
                            {
                            case "text":
                                input.SetAttribute("value", value);
                                break;

                            case "password":
                                input.SetAttribute("value", value);
                                break;

                            case "radio":
                                if (input.GetAttributeString("value") == value)
                                {
                                    input.SetAttribute("checked", "true");
                                }
                                break;

                            case "checkbox":
                                if (input.GetAttributeString("value") == value)
                                {
                                    input.SetAttribute("checked", "true");
                                }
                                break;

                            case "range":
                                input.SetAttribute("value", value);
                                break;
                            }
                        }
                    }
                }
                foreach (Element textArea in form.GetElementsByTagName("textarea"))
                {
                    String name = textArea.GetAttributeString("name");
                    if (name != null)
                    {
                        String value = dataProvider.getValue(name);
                        if (value != null)
                        {
                            textArea.SetAttribute("value", value);
                        }
                    }
                }
                foreach (ElementFormControl select in form.GetElementsByTagName("select"))
                {
                    String name = select.GetAttributeString("name");
                    if (name != null)
                    {
                        String value = dataProvider.getValue(name);
                        if (value != null)
                        {
                            select.Value = value;
                        }
                    }
                }
            }
        }