private BaseNode MakeNewNode(int id)
        {
            string nodeId = DataViewHierarchyAccessor.GetNodeId(id);

            nodeId = nodeId.ToLowerInvariant();

            BaseNode newNode;

            switch (nodeId)
            {
            case "table":
                newNode = new TableNode(DataViewHierarchyAccessor, id);
                break;

            case "storedprocedure":
                newNode = new StoredProcedureNode(DataViewHierarchyAccessor, id, false);
                break;

            case "storedfunction":
                newNode = new StoredProcedureNode(DataViewHierarchyAccessor, id, true);
                break;

            case "view":
                newNode = new ViewNode(DataViewHierarchyAccessor, id);
                break;

            case "udf":
                newNode = new UdfNode(DataViewHierarchyAccessor, id);
                break;

            case "trigger":
                newNode = new TriggerNode(DataViewHierarchyAccessor, id);
                break;

            default:
                throw new NotSupportedException("Node type not supported");
            }
            Debug.Assert(newNode != null);
            return(newNode);
        }
        public override bool Instantiate(IInstanceBuilderContext context, ViewNode viewNode)
        {
            bool flag = viewNode.Instance != null;

            base.Instantiate(context, viewNode);
            if (flag)
            {
                return(false);
            }
            SampleDataSet sampleDataSet = SampleDataSet.SampleDataSetFromType(viewNode.DocumentNode.Type.RuntimeType);

            if (sampleDataSet == null)
            {
                return(!flag);
            }
            DocumentCompositeNode documentCompositeNode = sampleDataSet != null ? sampleDataSet.ValidRootNodeFromXamlDocument : (DocumentCompositeNode)null;

            if (documentCompositeNode == null || !PlatformTypes.PlatformsCompatible((IPlatformMetadata)context.Platform.Metadata, documentCompositeNode.PlatformMetadata) || (this.IsSampleDataXamlContext(context, documentCompositeNode.DocumentRoot) || DesignDataHelper.GetDesignDataFile(viewNode.DocumentNode) != null))
            {
                return(!flag);
            }
            using (StandaloneInstanceBuilderContext instanceBuilderContext = new StandaloneInstanceBuilderContext(context.DocumentContext, context))
            {
                using (instanceBuilderContext.ChangeSerializationContext(context.SerializationContext))
                {
                    ViewNode viewNode1 = this.GetViewNode((IInstanceBuilderContext)instanceBuilderContext, (DocumentNode)documentCompositeNode);
                    viewNode1.Instance = viewNode.Instance;
                    this.Initialize((IInstanceBuilderContext)instanceBuilderContext, viewNode1, true);
                    viewNode1.Instance     = (object)null;
                    viewNode.InstanceState = InstanceState.Valid;
                }
            }
            context.DocumentRootResolver.GetDocumentRoot(documentCompositeNode.DocumentRoot.DocumentContext.DocumentUrl);
            IProperty index           = context.DocumentContext.TypeResolver.ResolveProperty(DesignTimeProperties.SampleDataTagProperty);
            ViewNode  referenceSource = new ViewNode(context.ViewNodeManager, (DocumentNode)documentCompositeNode);

            viewNode.Properties[index] = referenceSource;
            context.ViewNodeManager.AddRelatedDocumentRoot(referenceSource, documentCompositeNode.DocumentRoot);
            return(!flag);
        }
Пример #3
0
        protected override IView OnConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService)
        {
            var frame = (FigmaFrame)currentNode;

            frame.TryGetNativeControlType(out var controlType);

            var scrollView = new NSScrollView();

            var textView = new NSTextView(
                new CoreGraphics.CGRect(0, 0, scrollView.ContentSize.Width, scrollView.ContentSize.Height));

            textView.Font               = NSFont.SystemFontOfSize(NSFont.SystemFontSize);
            textView.AutoresizingMask   = NSViewResizingMask.WidthSizable;
            textView.TextContainer.Size = new CoreGraphics.CGSize(scrollView.ContentSize.Width, float.MaxValue);

            var       texts = frame.children.OfType <FigmaText>();
            FigmaText text  = texts.FirstOrDefault(s => s.name == "lbl" && s.visible);

            if (text != null)
            {
                textView.Value = rendererService.GetTranslatedText(text.characters);

                // TODO: text styling
                // textView.TextStorage.Append(new Foundation.NSAttributedString(""), null);
            }

            scrollView.BorderType            = NSBorderType.LineBorder;
            scrollView.HasHorizontalScroller = false;
            scrollView.HasVerticalScroller   = true;
            scrollView.DocumentView          = textView;

            frame.TryGetNativeControlVariant(out var controlVariant);

            if (controlVariant == NativeControlVariant.Small)
            {
                textView.Font = NSFont.SystemFontOfSize(NSFont.SmallSystemFontSize);
            }

            return(new View(scrollView));
        }
Пример #4
0
        public Field(ViewNode node)
        {
            Id              = node.Id;
            IdEntry         = node.IdEntry;
            AutofillId      = node.AutofillId;
            AutofillType    = node.AutofillType;
            InputType       = node.InputType;
            Focused         = node.IsFocused;
            Selected        = node.IsSelected;
            Clickable       = node.IsClickable;
            Visible         = node.Visibility == ViewStates.Visible;
            Hints           = FilterForSupportedHints(node.GetAutofillHints());
            AutofillOptions = node.GetAutofillOptions()?.ToList();
            Node            = node;

            if (node.AutofillValue != null)
            {
                if (node.AutofillValue.IsList)
                {
                    var autofillOptions = node.GetAutofillOptions();
                    if (autofillOptions != null && autofillOptions.Length > 0)
                    {
                        ListValue = node.AutofillValue.ListValue;
                        TextValue = autofillOptions[node.AutofillValue.ListValue];
                    }
                }
                else if (node.AutofillValue.IsDate)
                {
                    DateValue = node.AutofillValue.DateValue;
                }
                else if (node.AutofillValue.IsText)
                {
                    TextValue = node.AutofillValue.TextValue;
                }
                else if (node.AutofillValue.IsToggle)
                {
                    ToggleValue = node.AutofillValue.ToggleValue;
                }
            }
        }
Пример #5
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (viewNodes.Count == 0)
        {
            return;
        }
        ViewNode viewNode = getFirstView();
        float    dist     = Vector3.Distance(viewNode.position, Camera.main.transform.position);

        if (viewNodes.Count > 1 && dist < 1.0f)
        {
            //Change "currentView"
            viewNode = changeCurrentView();
        }
        if (viewNodes.Count < 2 && dist < 0.1f)
        {
            viewNode = changeCurrentView();
        }
        Vector3 newRot         = Camera.main.transform.localEulerAngles;
        Vector3 wantedRotation = viewNode.rotation;
        float   t = Time.deltaTime * 2;

        newRot.x = Mathf.LerpAngle(newRot.x, wantedRotation.x, t);
        newRot.y = Mathf.LerpAngle(newRot.y, wantedRotation.y, t);
        newRot.z = Mathf.LerpAngle(newRot.z, wantedRotation.z, t);
        Camera.main.transform.localEulerAngles = newRot;

        Camera.main.transform.position = Vector3.Slerp(Camera.main.transform.position, viewNode.position, t);

        /*
         * Vector3 newRot = Camera.main.transform.localEulerAngles;
         * float t = Time.deltaTime * 2;
         * newRot.x = Mathf.LerpAngle(newRot.x, wantedRotation.x, t);
         * newRot.y = Mathf.LerpAngle(newRot.y, wantedRotation.y, t);
         * newRot.z = Mathf.LerpAngle(newRot.z, wantedRotation.z, t);
         *
         * Camera.main.transform.localEulerAngles = newRot;
         */
    }
Пример #6
0
        // OnViewBegin marks the beginning of a 3D view to be exported.
        public RenderNodeAction OnViewBegin(
            ViewNode InViewNode             // render node associated with the 3D view
            )
        {
            // Set the level of detail when tessellating faces (between -1 and 15).
            InViewNode.LevelOfDetail = LevelOfTessellation;

            // Initialize the world transform for the 3D view being processed.
            WorldTransformStack.Push(Transform.Identity);

            // Create an empty Datasmith scene.
            if (DirectLink != null)
            {
                DirectLink.OnBeginExport();
                DatasmithScene = DirectLink.DatasmithScene;
            }
            else
            {
                DatasmithScene = new FDatasmithFacadeScene(HOST_NAME, VENDOR_NAME, PRODUCT_NAME, ProductVersion);
            }

            DatasmithScene.PreExport();

            View3D ViewToExport = RevitDocument.GetElement(InViewNode.ViewId) as View3D;

            if (DatasmithFilePaths != null && !DatasmithFilePaths.TryGetValue(ViewToExport.Id, out CurrentDatasmithFilePath))
            {
                return(RenderNodeAction.Skip);                // TODO log error?
            }

            // Keep track of the active Revit document being exported.
            PushDocument(RevitDocument);

            // Add a new camera actor to the Datasmith scene for the 3D view camera.
            AddCameraActor(ViewToExport, InViewNode.GetCameraInfo());

            // We want to export the 3D view.
            return(RenderNodeAction.Proceed);
        }
Пример #7
0
        protected override IView OnConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService)
        {
            var colorWell = new NSColorWell();
            var frame     = (FigmaFrame)currentNode;

            FigmaVector rectangle = frame.children
                                    .OfType <FigmaVector>()
                                    .FirstOrDefault(s => s.name == ComponentString.VALUE);

            foreach (var styleMap in rectangle?.styles)
            {
                if (rendererService.FileProvider.TryGetStyle(styleMap.Value, out FigmaStyle style))
                {
                    if (styleMap.Key == "fill")
                    {
                        colorWell.Color = ColorService.GetNSColor(style.name);
                    }
                }
            }

            return(new View(colorWell));
        }
Пример #8
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            base.PaintValue(e);

            ViewNode vNode = e.Context.Instance as ViewNode;

            if (null == vNode)
            {
                return;
            }

            try
            {
                Color backColor = Color.FromArgb((int)(vNode.Alpha * 255), vNode.BackgroundColor);
                Image img       = ImageHelper.CreateImage(backColor);
                e.Graphics.DrawImage(img, new Rectangle(1, 1, 20, 14));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #9
0
        /// <summary>
        /// Removes a view from the table.
        /// </summary>
        /// <param name="viewId">The view identifier.</param>
        public void Remove(NodeId viewId)
        {
            if (NodeId.IsNull(viewId))
            {
                throw new ArgumentNullException("viewId");
            }

            lock (m_lock) {
                // find view.
                ViewNode view = null;

                if (!m_views.TryGetValue(viewId, out view))
                {
                    throw new ServiceResultException(
                              StatusCodes.BadViewIdUnknown,
                              Utils.Format("A reference type with the node id '{0}' does not exist.", viewId));
                }

                // remove view node.
                m_views.Remove(viewId);
            }
        }
Пример #10
0
        protected override IView OnConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService)
        {
            var combobox = new NSComboBox();

            var frame = (FigmaFrame)currentNode;

            frame.TryGetNativeControlVariant(out var controlVariant);

            combobox.ControlSize = ViewHelper.GetNSControlSize(controlVariant);
            combobox.Font        = ViewHelper.GetNSFont(controlVariant);

            FigmaText text = frame.children
                             .OfType <FigmaText> ()
                             .FirstOrDefault(s => s.name == ComponentString.TITLE);

            if (text != null && !string.IsNullOrEmpty(text.characters))
            {
                combobox.StringValue = rendererService.GetTranslatedText(text);
            }

            return(new View(combobox));
        }
Пример #11
0
        private void ComputePosition(ViewNode <T> node, long parentNodeAxis, long currentTreeHeight, int leftBorder, int rightBorder)
        {
            node.Position = (parentNodeAxis - GetAxisPrefixLength(node.View.Width),
                             currentTreeHeight + node.View.Height + VerticalMargin);

            if (node is BinaryViewNode <T> binaryNode)
            {
                long leftNodeAxis  = leftBorder + GetAxisPrefixLength(binaryNode.LeftChild.TreeWidth);
                long rightNodeAxis = rightBorder - binaryNode.RightChild.TreeWidth + GetAxisPrefixLength(binaryNode.RightChild.TreeWidth);

                ComputePosition(binaryNode.LeftChild, leftNodeAxis, node.Position.Y, leftBorder, leftBorder + (int)binaryNode.LeftChild.TreeWidth);
                ComputePosition(binaryNode.RightChild, rightNodeAxis, node.Position.Y, rightBorder - (int)binaryNode.RightChild.TreeWidth, rightBorder);
            }
            else if (node is UnaryViewNode <T> unaryNode)
            {
                ComputePosition(unaryNode.Child, parentNodeAxis, node.Position.Y, leftBorder, rightBorder);
            }
            else if (node is CompletionViewNode <T> completionNode)
            {
                return;
            }
        }
Пример #12
0
        private static (List <Node>, int) GenerateLevel(List <ViewNode> angularGraph, List <Node> currentNodes, int level)
        {
            var childNodes = new List <Node>();

            currentNodes.ForEach(node =>
            {
                var item = new ViewNode
                {
                    Text      = node.Text,
                    Id        = node.Id.ToString().Replace("-", string.Empty),
                    Number    = level,
                    FillColor = $"#{node.FillColor.R:X2}{node.FillColor.G:X2}{node.FillColor.B:X2}",
                    FontColor = $"#{node.FontColor.R:X2}{node.FontColor.G:X2}{node.FontColor.B:X2}",
                    Shape     = (int)node.Shape,
                    Tooltip   = node.Tooltip,
                    ParentId  = node.ParentId != null ? node.ParentId.ToString().Replace("-", string.Empty) : string.Empty,
                    SubGraph  = node.SubGraph != null ? "cluster" + node.SubGraph.ToString().Replace("-", string.Empty) : string.Empty,
                    Edges     = new List <ViewEdge>()
                };

                foreach (var edge in node.Edges)
                {
                    item.Edges.Add(new ViewEdge()
                    {
                        Parent    = edge.Parent.Id.ToString().Replace("-", String.Empty),
                        Child     = edge.Child.Id.ToString().Replace("-", String.Empty),
                        Color     = $"#{edge.Color.R:X2}{edge.Color.G:X2}{edge.Color.B:X2}",
                        ArrowType = (int)edge.ArrowType,
                        Style     = (int)edge.Style
                    });
                    childNodes.Add(edge.Child);
                }

                angularGraph.Add(item);
            });

            CheckExisting(childNodes, angularGraph);
            return(childNodes.Distinct().ToList(), ++level);
        }
Пример #13
0
        /// <summary>
        /// 判断pNode及其子孙node,如为PageNode则Clone
        /// </summary>
        /// <param name="pNode"></param>
        private void CopyNode(ViewNode pNode)
        {
            if (null != pNode)
            {
                switch (pNode.Name)
                {
                case MyConst.View.KnxAppType:
                case MyConst.View.KnxAreaType:
                case MyConst.View.KnxRoomType:
                    foreach (ViewNode cNode in pNode.Nodes)
                    {
                        CopyNode(cNode);
                    }
                    break;

                case MyConst.View.KnxPageType:
                    PageNode pageNode = pNode as PageNode;
                    if (null != pageNode)
                    {
                        //PageNode pageNodeClone = pNode.Tag as PageNode;
                        //if (null != pageNodeClone)
                        //{
                        //    PageNode pageNodeCopy = pageNodeClone.Copy() as PageNode;
                        //    pNode.Text = pageNodeCopy.Text;
                        //    //pNode.Title = pageNodeCopy.Title;
                        //    pNode.Tag = pageNodeCopy;
                        //    pageNodeCopy.Tag = pNode;
                        //}
                        pageNode.CopyPageNode();
                    }

                    break;

                default:
                    break;
                }
            }
        }
Пример #14
0
        private void UpdateUIChildrenInstancesInternal(ViewNode root)
        {
            InlineUIContainer inlineUIContainerInstance = root.Instance as InlineUIContainer;

            if (inlineUIContainerInstance != null && inlineUIContainerInstance.Child != null)
            {
                this.UpdateUIChildInstance((DocumentCompositeNode)root.DocumentNode, inlineUIContainerInstance);
            }
            BlockUIContainer blockUIContainerInstance = root.Instance as BlockUIContainer;

            if (blockUIContainerInstance != null && blockUIContainerInstance.Child != null)
            {
                this.UpdateUIChildInstance((DocumentCompositeNode)root.DocumentNode, blockUIContainerInstance);
            }
            foreach (ViewNode root1 in (IEnumerable <ViewNode>)root.Children)
            {
                this.UpdateUIChildrenInstancesInternal(root1);
            }
            foreach (ViewNode root1 in (IEnumerable <ViewNode>)root.Properties.Values)
            {
                this.UpdateUIChildrenInstancesInternal(root1);
            }
        }
Пример #15
0
    private void UpdateNode(Node node)
    {
        _onUpdateNode(curViewNode.gameObject, node.Value, true);
        curViewNode.node = node;
        ViewNode leftViewNode  = curViewNode.Previous;
        ViewNode rightViewNode = curViewNode.Next;
        Node     leftNode      = node.Previous;
        Node     rightNode     = node.Next;

        while (leftViewNode != null && rightViewNode != null)
        {
            _onUpdateNode(leftViewNode.gameObject, leftNode.Value, false);
            leftViewNode.node = leftNode;

            _onUpdateNode(rightViewNode.gameObject, rightNode.Value, false);
            rightViewNode.node = rightNode;
            leftNode           = leftNode.Previous;
            rightNode          = rightNode.Next;

            leftViewNode  = leftViewNode.Previous;
            rightViewNode = rightViewNode.Next;
        }
    }
Пример #16
0
        private bool ErgodicPageNode(TreeNode p, PageNode pageNode)
        {
            foreach (TreeNode c in p.Nodes)
            {
                ViewNode cNode = c as ViewNode;
                if (MyConst.View.KnxPageType == cNode.Name)
                {
                    if (cNode.Id == pageNode.Id)
                    {
                        return(true);
                    }
                }
                else if ((MyConst.View.KnxAppType == cNode.Name) || (MyConst.View.KnxAreaType == cNode.Name) || (MyConst.View.KnxRoomType == cNode.Name))
                {
                    if (ErgodicPageNode(cNode, pageNode))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #17
0
        public RenderNodeAction OnViewBegin(ViewNode node)
        {
            View3D view = m_doc.GetElement(node.ViewId) as View3D;

            if (view != null)
            {
                MessageBuffer mb = new MessageBuffer();
                mb.add(view.Id.IntegerValue);
                mb.add(view.Name);
                mb.add(view.Origin);
                mb.add(view.ViewDirection);
                mb.add(view.UpDirection);
                OpenCOVERPlugin.COVER.Instance.sendMessage(mb.buf, OpenCOVERPlugin.COVER.MessageTypes.AddView);
            }

            // Setting our default LoD for the view
            // The scale goes from 0 to 10, but the value close to the edges
            // aren't really that usable, except maybe of experimenting

            node.LevelOfDetail = 5;   // a good middle ground

            return(RenderNodeAction.Proceed);
        }
Пример #18
0
        private void ucProperty_NodePropertyChanged(object sender, EventArgs e)
        {
            this.Saved = false;

            ViewNode node = sender as ViewNode;

            if (null != (node as PageNode))
            {
                STPage pagePanel = node.panel as STPage;
                pagePanel.ChangeSize();
            }
            else
            {
                PageNode pageNode = GetPageNodeFromParent(node);
                if (null != pageNode)
                {
                    STPage pagePanel = pageNode.panel as STPage;
                    pagePanel.ControlPropertyChanged(node);
                }
            }

            ProjectChanged(node);
        }
Пример #19
0
        void ParseLocked(bool forFill, ViewNode viewNode)
        {
            if (viewNode.GetAutofillHints() != null && viewNode.GetAutofillHints().Length > 0)
            {
                if (forFill)
                {
                    AutofillFields.Add(new AutofillFieldMetadata(viewNode));
                }
                else
                {
                    ClientFormData.Add(new FilledAutofillField(viewNode));
                }
            }
            var childrenSize = viewNode.ChildCount;

            if (childrenSize > 0)
            {
                for (int i = 0; i < childrenSize; i++)
                {
                    ParseLocked(forFill, viewNode.GetChildAt(i));
                }
            }
        }
Пример #20
0
 public void SetSelectedNode(ViewNode node)
 {
     if (null != node)
     {
         if (MyConst.View.KnxPageType == node.Name)
         {
             foreach (ViewNode pNode in this.tvProject.Nodes)
             {
                 PageNode pageNode = GetPageNode(pNode, node.Id);
                 if (null != pageNode)
                 {
                     this.CurSelectedNode        = pageNode;
                     this.tvProject.SelectedNode = this.CurSelectedNode;
                     break;
                 }
             }
         }
     }
     else
     {
         this.tvProject.SelectedNode = null;
     }
 }
Пример #21
0
        internal object FindMissingImplicitStyle()
        {
            if (this.Platform.Metadata.IsCapabilitySet(PlatformCapability.IsWpf) || !this.Platform.Metadata.IsCapabilitySet(PlatformCapability.SupportsImplicitStyles))
            {
                return((object)null);
            }
            if (!PlatformTypes.FrameworkElement.IsAssignableFrom((ITypeId)this.Type))
            {
                return((object)null);
            }
            DocumentNode node = new ExpressionEvaluator(this.ViewModel.DefaultView.InstanceBuilderContext.DocumentRootResolver).EvaluateResource(this.DocumentNodePath, this.DocumentContext.CreateNode(typeof(Type), (object)this.Type.RuntimeType));

            if (node == null)
            {
                return((object)null);
            }
            DocumentNodePath        nodePath    = new DocumentNodePath(node.DocumentRoot.RootNode, node);
            IInstanceBuilderContext viewContext = this.ViewModel.DefaultView.InstanceBuilderContext.GetViewContext(node.DocumentRoot);

            if (viewContext == null || viewContext.ViewNodeManager.Root == null || viewContext.ViewNodeManager.Root.InstanceState == InstanceState.Invalid)
            {
                return((object)null);
            }
            ViewNode correspondingViewNode = viewContext.ViewNodeManager.GetCorrespondingViewNode(nodePath);

            if (correspondingViewNode == null || viewContext.ExceptionDictionary.Contains(correspondingViewNode))
            {
                return((object)null);
            }
            object instance = correspondingViewNode.Instance;

            if (instance == null || !PlatformTypes.Style.IsAssignableFrom((ITypeId)viewContext.DocumentContext.TypeResolver.GetType(instance.GetType())))
            {
                return((object)null);
            }
            return(instance);
        }
Пример #22
0
        public ViewNode ConnectViewToViewNode(View view, ViewNode parentViewNode)
        {
            if (view != null && parentViewNode != null)
            {
                // First update/create the view
                View readView = ViewDao.FindById(view.Id);
                parentViewNode = ViewNodeDao.FindById(parentViewNode.Id);

                // Create viewnode to connect the view to
                ViewNode viewNode = new ViewNode();

                viewNode.Dialog   = parentViewNode.Dialog;
                viewNode.Parent   = parentViewNode;
                viewNode.Sequence = viewNode.Dialog.ViewNodes.Max(node => node.Sequence) + 1;
                viewNode.Title    = null;
                viewNode.View     = readView;

                // Save the new ViewNode
                viewNode = ViewNodeDao.SaveOrUpdate(viewNode);

                if (NHibernateUtil.IsInitialized(parentViewNode.Dialog) && NHibernateUtil.IsInitialized(parentViewNode.Dialog.ViewNodes))
                {
                    // Connect the ViewNode to the Dialogs ViewNodes
                    parentViewNode.Dialog.ViewNodes.Add(viewNode);
                }

                if (NHibernateUtil.IsInitialized(parentViewNode.Children))
                {
                    // Connect the ViewNode as a child to the Parent ViewNode
                    parentViewNode.Children.Add(viewNode);
                }

                return(viewNode);
            }

            return(null);
        }
Пример #23
0
        protected override IView OnConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService)
        {
            var frame = (FigmaFrame)currentNode;

            var disclosureView = new NSView();

            /* TODO
             * var subView = new NSView(disclosureView.Bounds);
             * subView.WantsLayer = true;
             * subView.Layer.BackgroundColor = NSColor.Red.CGColor;
             *
             *
             * var disclosureTriangle = new NSButton();
             * disclosureTriangle.SetFrameSize(new CoreGraphics.CGSize(130, 13));
             * disclosureTriangle.SetButtonType(NSButtonType.PushOnPushOff);
             * disclosureTriangle.BezelStyle = NSBezelStyle.Disclosure;
             *
             * disclosureTriangle.Activated += delegate {
             *
             * //	disclosureTriangle.State = NSCellStateValue.Off;
             *
             * };
             *
             *
             * disclosureView.AddSubview(disclosureTriangle);
             * disclosureView.AddSubview(subView);
             *
             *
             * disclosureTriangle.LeftAnchor.ConstraintEqualToAnchor(disclosureView.LeftAnchor, 8)
             *                              .Active = true;
             *
             * disclosureTriangle.TopAnchor.ConstraintEqualToAnchor(disclosureView.TopAnchor, 8)
             *                              .Active = true;
             */
            return(new View(disclosureView));
        }
Пример #24
0
 protected override bool SetViewContentInternal(ViewContentType contentType, ViewNode target, object content)
 {
     if (this.settingContentReentranceDepth > 1)
     {
         return(false);
     }
     if (contentType == ViewContentType.Error)
     {
         FormattedException formattedException = content as FormattedException;
         if (formattedException != null)
         {
             content = (object)this.FilterCatastrophicFailure(formattedException);
         }
     }
     try
     {
         ++this.settingContentReentranceDepth;
         return(this.SetViewContentWorker(contentType, target, content));
     }
     finally
     {
         --this.settingContentReentranceDepth;
     }
 }
Пример #25
0
        /// <summary>
        /// Заполнить выпадающий список представлений
        /// </summary>
        public static void FillViewList(DropDownList ddlView, int preferableViewID, UserViews userViews)
        {
            int             selInd1      = -1; // индекс выбранного элемента, соответствующего непустому представлению
            int             selInd2      = -1; // индекс выбранного элемента, соответствующего предпочтительному представлению
            List <ViewNode> viewNodes    = userViews.GetLinearViewNodes();
            int             viewNodesCnt = viewNodes.Count;

            // заполнение списка представлений и определение индексов выбранного элемента
            ddlView.Items.Clear();
            for (int i = 0; i < viewNodesCnt; i++)
            {
                ViewNode viewNode = viewNodes[i];

                if (selInd1 <= 0 && !viewNode.IsEmpty)
                {
                    selInd1 = i;
                }
                if (selInd2 <= 0 && preferableViewID > 0 && viewNode.ViewID == preferableViewID)
                {
                    selInd2 = i;
                }

                string text = new string('-', viewNode.Level) + " " + viewNode.Text;
                ddlView.Items.Add(new ListItem(text, viewNode.ViewID.ToString()));
            }

            // установка выбранного элемента
            if (selInd2 >= 0)
            {
                ddlView.SelectedIndex = selInd2;
            }
            else if (selInd1 >= 0)
            {
                ddlView.SelectedIndex = selInd1;
            }
        }
Пример #26
0
 public void DisplayNode(ViewNode node)
 {
     try
     {
         if (null != node)
         {
             this.CurNode = node;
             this.propertyGrid.SelectedObject = node;
             //node.Tag = this.propertyGrid;
             SetPropertyGridTitle(node);
         }
         else
         {
             this.CurNode = null;
             this.propertyGrid.SelectedObject = null;
             SetPropertyGridTitle(null);
             SetCommandQueue(null);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        private void ParseLocked(bool forFill, ViewNode viewNode)
        {
            var autofillHints = viewNode.GetAutofillHints();
            var autofillType  = (AutofillType)(int)viewNode.AutofillType;
            var inputType     = (InputTypes)(int)viewNode.InputType;
            var isEditText    = viewNode.ClassName == "android.widget.EditText";

            if (isEditText || (autofillHints?.Length ?? 0) > 0)
            {
                if (forFill)
                {
                    AutofillFields.Add(new AutofillFieldMetadata(viewNode));
                }
                else
                {
                    _filledAutofillFieldCollection.Add(new FilledAutofillField(viewNode));
                }
            }

            for (var i = 0; i < viewNode.ChildCount; i++)
            {
                ParseLocked(forFill, viewNode.GetChildAt(i));
            }
        }
Пример #28
0
        public override IView ConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService)
        {
            var converted = OnConvertToView(currentNode, parentNode, rendererService);

            if (converted != null)
            {
                var nativeView = converted.NativeObject as AppKit.NSView;

                if (!currentNode.visible)
                {
                    nativeView.Hidden = true;
                }

                if (currentNode.IsA11Group())
                {
                    nativeView.AccessibilityRole = AppKit.NSAccessibilityRoles.GroupRole;
                }

                //label
                if (currentNode.TrySearchA11Label(out var label))
                {
                    try {
                        nativeView.AccessibilityTitle = label;
                    } catch (Exception) {
                        nativeView.AccessibilityLabel = label;
                    }
                }
                //help
                if (currentNode.TrySearchA11Help(out var help))
                {
                    nativeView.AccessibilityHelp = help;
                }
            }

            return(converted);
        }
Пример #29
0
        private void SetToolStripButtonStatus(ViewNode node)
        {
            SetTSBExpandCollapseStatus(node);
            SetTSBMoveUpDown(node);
            SetEntityStatus(false);

            switch (node.Name)
            {
            case MyConst.View.KnxAppType:
                this.tsrBtnAddArea.Enabled = true;
                break;

            case MyConst.View.KnxAreaType:
                this.tsrBtnAddRoom.Enabled = true;
                break;

            case MyConst.View.KnxRoomType:
                this.tsrBtnAddPage.Enabled = true;
                break;

            default:
                break;
            }
        }
Пример #30
0
        private void ProjectChanged(ViewNode node)
        {
            this.Saved = false;

            switch (node.Name)
            {
            case MyConst.View.KnxAppType:
            case MyConst.View.KnxAreaType:
            case MyConst.View.KnxRoomType:
                break;

            case MyConst.View.KnxPageType:
                SetTabPageTitle(node.Id.ToString(), node.Text + " " + "*");
                break;

            default:
                PageNode pageNode = GetPageNodeFromParent(node);
                if (null != pageNode)
                {
                    SetTabPageTitle(pageNode.Id.ToString(), pageNode.Text + " " + "*");
                }
                break;
            }
        }
Пример #31
0
        public RenderNodeAction OnViewBegin(ViewNode node)
        {
            View3D view = m_doc.GetElement(node.ViewId) as View3D;
            if (view != null)
            {
                MessageBuffer mb = new MessageBuffer();
                mb.add(view.Id.IntegerValue);
                mb.add(view.Name);
                mb.add(view.Origin);
                mb.add(view.ViewDirection);
                mb.add(view.UpDirection);
                OpenCOVERPlugin.COVER.Instance.sendMessage(mb.buf, OpenCOVERPlugin.COVER.MessageTypes.AddView);
            }

            // Setting our default LoD for the view
            // The scale goes from 0 to 10, but the value close to the edges
            // aren't really that usable, except maybe of experimenting

            node.LevelOfDetail = 5;   // a good middle ground

            return RenderNodeAction.Proceed;
        }
Пример #32
0
        // -----------------------------
        // - Begin constructors region -
        // -----------------------------
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="path">Path of the Structured Report file that has been validated.</param>
        /// <param name="resultsPath">Path of the directory where the .html results are located.</param>
        public StructuredReportNode(string fileName, string resultsPath)
        {
            this.fileName = fileName;
            this.resultsPath = resultsPath;

            DateTime dateTime = DateTime.Now;
            this.Name = System.IO.Path.GetFileName(this.fileName) + " (validated on " + dateTime.ToString("yyyy-MM-dd HH.mm.ss") + ")";
            this.Text = this.Name;

            this.saveValidationResultsPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"DVTk\Structured Report Validator\" + this.Name);

            //
            // "Save Validation Results" context menu item.
            //

            System.Windows.Forms.ToolStripMenuItem saveValidationResultsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();

            saveValidationResultsToolStripMenuItem.Name = "saveValidationResultsToolStripMenuItem";
            saveValidationResultsToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
            saveValidationResultsToolStripMenuItem.Text = "Save Validation Results to \"" + this.saveValidationResultsPath + "\"";
            saveValidationResultsToolStripMenuItem.Click += new System.EventHandler(SaveValidationResults);

            //
            // Context menu.
            //

            this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { saveValidationResultsToolStripMenuItem });
            this.contextMenuStrip.Name = "contextMenuStrip";
            this.contextMenuStrip.Size = new System.Drawing.Size(186, 48);

            //
            // Create the view nodes and add them as childs to this node.
            //

            foreach (string viewPath in System.IO.Directory.GetFiles(this.resultsPath, "*.html"))
            {
                ViewNode viewNode = new ViewNode(viewPath);
                Nodes.Add(viewNode);
            }
        }
Пример #33
0
	public virtual void Initialize(ViewNode viewNode)
	{
		m_ViewNode = viewNode;
	}
Пример #34
0
        public Node ReadNode(NodeId nodeId)
        {
            // build list of attributes.
            SortedDictionary<uint,DataValue> attributes = new SortedDictionary<uint,DataValue>();
            
            attributes.Add(Attributes.NodeId, null);
            attributes.Add(Attributes.NodeClass, null);
            attributes.Add(Attributes.BrowseName, null);
            attributes.Add(Attributes.DisplayName, null);
            attributes.Add(Attributes.Description, null);
            attributes.Add(Attributes.WriteMask, null);
            attributes.Add(Attributes.UserWriteMask, null);
            attributes.Add(Attributes.DataType, null);
            attributes.Add(Attributes.ValueRank, null);
            attributes.Add(Attributes.ArrayDimensions, null);
            attributes.Add(Attributes.AccessLevel, null);
            attributes.Add(Attributes.UserAccessLevel, null);
            attributes.Add(Attributes.Historizing, null);
            attributes.Add(Attributes.MinimumSamplingInterval, null);
            attributes.Add(Attributes.EventNotifier, null);
            attributes.Add(Attributes.Executable, null);
            attributes.Add(Attributes.UserExecutable, null);
            attributes.Add(Attributes.IsAbstract, null);
            attributes.Add(Attributes.InverseName, null);
            attributes.Add(Attributes.Symmetric, null);
            attributes.Add(Attributes.ContainsNoLoops, null);

            // build list of values to read.
            ReadValueIdCollection itemsToRead = new ReadValueIdCollection();

            foreach (uint attributeId in attributes.Keys)
            {
                ReadValueId itemToRead = new ReadValueId();

                itemToRead.NodeId      = nodeId;
                itemToRead.AttributeId = attributeId;
                
                itemsToRead.Add(itemToRead);
            }

            // read from server.
            DataValueCollection values = null;
            DiagnosticInfoCollection diagnosticInfos = null;

            ResponseHeader responseHeader = Read(
                null,
                0,
                TimestampsToReturn.Neither,
                itemsToRead,
                out values, 
                out diagnosticInfos);
            
            ClientBase.ValidateResponse(values, itemsToRead);
            ClientBase.ValidateDiagnosticInfos(diagnosticInfos, itemsToRead);

            // process results.
            int? nodeClass = null;

            for (int ii = 0; ii < itemsToRead.Count; ii++)
            {
                uint attributeId = itemsToRead[ii].AttributeId;
                
                // the node probably does not exist if the node class is not found.
                if (attributeId == Attributes.NodeClass)
                {
                    if (!DataValue.IsGood(values[ii]))
                    {
                        throw ServiceResultException.Create(values[ii].StatusCode, ii, diagnosticInfos, responseHeader.StringTable);
                    }       
     
                    // check for valid node class.
                    nodeClass  = values[ii].Value as int?;

                    if (nodeClass == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Node does not have a valid value for NodeClass: {0}.", values[ii].Value);
                    }
                }
                else
                {
                    if (!DataValue.IsGood(values[ii]))
                    {
                        // check for unsupported attributes.
                        if (values[ii].StatusCode == StatusCodes.BadAttributeIdInvalid)
                        {
                            continue;
                        }

                        // all supported attributes must be readable.
                        if (attributeId != Attributes.Value)
                        {
                            throw ServiceResultException.Create(values[ii].StatusCode, ii, diagnosticInfos, responseHeader.StringTable);
                        }
                    }      
                }

                attributes[attributeId] = values[ii];
            }

            Node node = null;
            DataValue value = null;

            switch ((NodeClass)nodeClass.Value)
            {
                default:
                {
                    throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Node does not have a valid value for NodeClass: {0}.", nodeClass.Value);
                }

                case NodeClass.Object:
                {
                    ObjectNode objectNode = new ObjectNode();

                    value = attributes[Attributes.EventNotifier];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Object does not support the EventNotifier attribute.");
                    }

                    objectNode.EventNotifier = (byte)attributes[Attributes.EventNotifier].GetValue(typeof(byte));
                    node = objectNode;
                    break;
                }

                case NodeClass.ObjectType:
                {
                    ObjectTypeNode objectTypeNode = new ObjectTypeNode();

                    value = attributes[Attributes.IsAbstract];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "ObjectType does not support the IsAbstract attribute.");
                    }

                    objectTypeNode.IsAbstract = (bool)attributes[Attributes.IsAbstract].GetValue(typeof(bool));
                    node = objectTypeNode;
                    break;
                }

                case NodeClass.Variable:
                {
                    VariableNode variableNode = new VariableNode();
                    
                    // DataType Attribute
                    value = attributes[Attributes.DataType];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Variable does not support the DataType attribute.");
                    }

                    variableNode.DataType = (NodeId)attributes[Attributes.DataType].GetValue(typeof(NodeId));     

                    // ValueRank Attribute
                    value = attributes[Attributes.ValueRank];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Variable does not support the ValueRank attribute.");
                    }

                    variableNode.ValueRank = (int)attributes[Attributes.ValueRank].GetValue(typeof(int));                                      
                    
                    // ArrayDimensions Attribute
                    value = attributes[Attributes.ArrayDimensions];

                    if (value != null)
                    {
                        if (value.Value == null)
                        {
                            variableNode.ArrayDimensions = new uint[0];
                        }
                        else
                        {
                            variableNode.ArrayDimensions = (uint[])value.GetValue(typeof(uint[]));
                        }
                    }
                    
                    // AccessLevel Attribute
                    value = attributes[Attributes.AccessLevel];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Variable does not support the AccessLevel attribute.");
                    }

                    variableNode.AccessLevel = (byte)attributes[Attributes.AccessLevel].GetValue(typeof(byte));     
                    
                    // UserAccessLevel Attribute
                    value = attributes[Attributes.UserAccessLevel];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Variable does not support the UserAccessLevel attribute.");
                    }

                    variableNode.UserAccessLevel = (byte)attributes[Attributes.UserAccessLevel].GetValue(typeof(byte));     
                    
                    // Historizing Attribute
                    value = attributes[Attributes.Historizing];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Variable does not support the Historizing attribute.");
                    }

                    variableNode.Historizing = (bool)attributes[Attributes.Historizing].GetValue(typeof(bool));    
                    
                    // MinimumSamplingInterval Attribute
                    value = attributes[Attributes.MinimumSamplingInterval];

                    if (value != null)
                    {
                        variableNode.MinimumSamplingInterval = Convert.ToDouble(attributes[Attributes.MinimumSamplingInterval].Value);
                    }

                    node = variableNode;
                    break;
                }
                    
                case NodeClass.VariableType:
                {
                    VariableTypeNode variableTypeNode = new VariableTypeNode();

                    // IsAbstract Attribute
                    value = attributes[Attributes.IsAbstract];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "VariableType does not support the IsAbstract attribute.");
                    }

                    variableTypeNode.IsAbstract = (bool)attributes[Attributes.IsAbstract].GetValue(typeof(bool));
                    
                    // DataType Attribute
                    value = attributes[Attributes.DataType];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "VariableType does not support the DataType attribute.");
                    }

                    variableTypeNode.DataType = (NodeId)attributes[Attributes.DataType].GetValue(typeof(NodeId));     

                    // ValueRank Attribute
                    value = attributes[Attributes.ValueRank];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "VariableType does not support the ValueRank attribute.");
                    }

                    variableTypeNode.ValueRank = (int)attributes[Attributes.ValueRank].GetValue(typeof(int));                                      
                    
                    // ArrayDimensions Attribute
                    value = attributes[Attributes.ArrayDimensions];

                    if (value != null && value.Value != null)
                    {
                        variableTypeNode.ArrayDimensions = (uint[])attributes[Attributes.ArrayDimensions].GetValue(typeof(uint[]));
                    }
                    
                    node = variableTypeNode;
                    break;
                }
                    
                case NodeClass.Method:
                {
                    MethodNode methodNode = new MethodNode();

                    // Executable Attribute
                    value = attributes[Attributes.Executable];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Method does not support the Executable attribute.");
                    }

                    methodNode.Executable = (bool)attributes[Attributes.Executable].GetValue(typeof(bool));
                    
                    // UserExecutable Attribute
                    value = attributes[Attributes.UserExecutable];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Method does not support the UserExecutable attribute.");
                    }

                    methodNode.UserExecutable = (bool)attributes[Attributes.UserExecutable].GetValue(typeof(bool));

                    node = methodNode;
                    break;
                }
                    
                case NodeClass.DataType:
                {
                    DataTypeNode dataTypeNode = new DataTypeNode();

                    // IsAbstract Attribute
                    value = attributes[Attributes.IsAbstract];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "DataType does not support the IsAbstract attribute.");
                    }

                    dataTypeNode.IsAbstract = (bool)attributes[Attributes.IsAbstract].GetValue(typeof(bool));

                    node = dataTypeNode;
                    break;
                }
                    
                case NodeClass.ReferenceType:
                {
                    ReferenceTypeNode referenceTypeNode = new ReferenceTypeNode();

                    // IsAbstract Attribute
                    value = attributes[Attributes.IsAbstract];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "ReferenceType does not support the IsAbstract attribute.");
                    }

                    referenceTypeNode.IsAbstract = (bool)attributes[Attributes.IsAbstract].GetValue(typeof(bool));

                    // Symmetric Attribute
                    value = attributes[Attributes.Symmetric];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "ReferenceType does not support the Symmetric attribute.");
                    }

                    referenceTypeNode.Symmetric = (bool)attributes[Attributes.IsAbstract].GetValue(typeof(bool));

                    // InverseName Attribute
                    value = attributes[Attributes.InverseName];

                    if (value != null && value.Value != null)
                    {
                        referenceTypeNode.InverseName = (LocalizedText)attributes[Attributes.InverseName].GetValue(typeof(LocalizedText));
                    }
                    
                    node = referenceTypeNode;
                    break;
                }
                    
                case NodeClass.View:
                {
                    ViewNode viewNode = new ViewNode();

                    // EventNotifier Attribute
                    value = attributes[Attributes.EventNotifier];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "View does not support the EventNotifier attribute.");
                    }

                    viewNode.EventNotifier = (byte)attributes[Attributes.EventNotifier].GetValue(typeof(byte));
                    
                    // ContainsNoLoops Attribute
                    value = attributes[Attributes.ContainsNoLoops];

                    if (value == null)
                    {
                        throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "View does not support the ContainsNoLoops attribute.");
                    }

                    viewNode.ContainsNoLoops = (bool)attributes[Attributes.ContainsNoLoops].GetValue(typeof(bool));

                    node = viewNode;
                    break;
                }                    
            }
                
            // NodeId Attribute
            value = attributes[Attributes.NodeId];

            if (value == null)
            {
                throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Node does not support the NodeId attribute.");
            }

            node.NodeId = (NodeId)attributes[Attributes.NodeId].GetValue(typeof(NodeId));
            node.NodeClass = (NodeClass)nodeClass.Value;

            // BrowseName Attribute
            value = attributes[Attributes.BrowseName];

            if (value == null)
            {
                throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Node does not support the BrowseName attribute.");
            }

            node.BrowseName = (QualifiedName)attributes[Attributes.BrowseName].GetValue(typeof(QualifiedName));

            // DisplayName Attribute
            value = attributes[Attributes.DisplayName];

            if (value == null)
            {
                throw ServiceResultException.Create(StatusCodes.BadUnexpectedError, "Node does not support the DisplayName attribute.");
            }

            node.DisplayName = (LocalizedText)attributes[Attributes.DisplayName].GetValue(typeof(LocalizedText));
    
            // Description Attribute
            value = attributes[Attributes.Description];

            if (value != null && value.Value != null)
            {
                node.Description = (LocalizedText)attributes[Attributes.Description].GetValue(typeof(LocalizedText));
            }

            // WriteMask Attribute
            value = attributes[Attributes.WriteMask];

            if (value != null)
            {
                node.WriteMask = (uint)attributes[Attributes.WriteMask].GetValue(typeof(uint));
            }

            // UserWriteMask Attribute
            value = attributes[Attributes.UserWriteMask];

            if (value != null)
            {
                node.WriteMask = (uint)attributes[Attributes.UserWriteMask].GetValue(typeof(uint));
            }
                
            return node;
        }
Пример #35
0
        public static void UpdateTree(TreeView treeView, TypeSystem typeSystem, MosaTypeLayout typeLayout, bool showSizes)
        {
            treeView.BeginUpdate();
            treeView.Nodes.Clear();

            foreach (var module in typeSystem.Modules)
            {
                TreeNode moduleNode = new TreeNode(module.Name);
                treeView.Nodes.Add(moduleNode);

                foreach (MosaType type in module.Types.Values)
                {
                    TreeNode typeNode = new TreeNode(type.FullName);
                    moduleNode.Nodes.Add(typeNode);

                    if (type.BaseType != null)
                    {
                        TreeNode baseTypeNode = new TreeNode("Base Type: " + type.BaseType.FullName);
                        typeNode.Nodes.Add(baseTypeNode);
                    }

                    if (type.DeclaringType != null)
                    {
                        TreeNode baseTypeNode = new TreeNode("Enclosing Type: " + type.DeclaringType.FullName);
                        typeNode.Nodes.Add(baseTypeNode);
                    }

                    if (type.Interfaces.Count != 0)
                    {
                        TreeNode interfacesNodes = new TreeNode("Interfaces");
                        typeNode.Nodes.Add(interfacesNodes);

                        foreach (MosaType interfaceType in type.Interfaces)
                        {
                            TreeNode interfaceNode = new TreeNode(interfaceType.FullName);
                            interfacesNodes.Nodes.Add(interfaceNode);
                        }
                    }

                    if (type.Fields.Count != 0)
                    {
                        TreeNode fieldsNode = new TreeNode("Fields");
                        if (showSizes)
                            fieldsNode.Text = fieldsNode.Text + " (Count: " + type.Fields.Count.ToString() + " - Size: " + typeLayout.GetTypeSize(type).ToString() + ")";

                        typeNode.Nodes.Add(fieldsNode);

                        foreach (MosaField field in type.Fields)
                        {
                            TreeNode fieldNode = new TreeNode(field.ShortName);
                            fieldsNode.Nodes.Add(fieldNode);

                            if (field.IsStatic)
                                fieldNode.Text = fieldNode.Text + " [Static]";

                            if (showSizes)
                            {
                                fieldNode.Text = fieldNode.Text + " (Size: " + typeLayout.GetFieldSize(field).ToString();

                                if (!field.IsStatic)
                                    fieldNode.Text = fieldNode.Text + " - Offset: " + typeLayout.GetFieldOffset(field).ToString();

                                fieldNode.Text = fieldNode.Text + ")";
                            }
                        }
                    }

                    if (type.Methods.Count != 0)
                    {
                        TreeNode methodsNode = new TreeNode("Methods");
                        typeNode.Nodes.Add(methodsNode);

                        foreach (MosaMethod method in type.Methods)
                        {
                            TreeNode methodNode = new ViewNode<MosaMethod>(method, method.ShortName);
                            methodsNode.Nodes.Add(methodNode);

                            if (method.IsStatic)
                                methodNode.Text = methodNode.Text + " [Static]";

                            if (method.IsAbstract)
                                methodNode.Text = methodNode.Text + " [Abstract]";

                            if (method.IsNewSlot)
                                methodNode.Text = methodNode.Text + " [NewSlot]";

                            if (method.IsVirtual)
                                methodNode.Text = methodNode.Text + " [Virtual]";

                            if (method.IsFinal)
                                methodNode.Text = methodNode.Text + " [Final]";

                            if (method.IsSpecialName)
                                methodNode.Text = methodNode.Text + " [SpecialName]";

                            if (method.IsRTSpecialName)
                                methodNode.Text = methodNode.Text + " [RTSpecialName]";

                            if (method.GenericArguments.Count != 0)
                            {
                                TreeNode genericParameterNodes = new TreeNode("Generic Arguments Types");
                                methodNode.Nodes.Add(genericParameterNodes);

                                foreach (var genericParameter in method.GenericArguments)
                                {
                                    TreeNode GenericParameterNode = new TreeNode(genericParameter.Name);
                                    genericParameterNodes.Nodes.Add(GenericParameterNode);
                                }
                            }
                        }
                    }

                    if (typeLayout.GetMethodTable(type) != null)
                    {
                        TreeNode methodTableNode = new TreeNode("Method Table");
                        typeNode.Nodes.Add(methodTableNode);

                        foreach (MosaMethod method in typeLayout.GetMethodTable(type))
                        {
                            TreeNode methodNode = new ViewNode<MosaMethod>(method, method.ShortName);
                            methodTableNode.Nodes.Add(methodNode);
                        }
                    }
                }
            }

            treeView.EndUpdate();
        }
Пример #36
0
        public static void UpdateTree(TreeView treeView, TypeSystem typeSystem, MosaTypeLayout typeLayout, bool showSizes)
        {
            treeView.BeginUpdate();
            treeView.Nodes.Clear();

            foreach (var module in typeSystem.Modules)
            {
                List<TreeNode> namespaces = new List<TreeNode>();

                TreeNode moduleNode = new TreeNode(module.Name);
                treeView.Nodes.Add(moduleNode);

                List<MosaType> typeList = (new List<MosaType>(module.Types.Values)).OrderBy(o => o.FullName).ToList();

                foreach (MosaType type in typeList)
                {
                    TreeNode namespaceNode = null;
                    string @namespace = (string.IsNullOrWhiteSpace(type.Namespace)) ? "[No Namespace]" : type.Namespace;
                    foreach (TreeNode node in namespaces)
                    {
                        if (node.Text.Equals(@namespace))
                        {
                            namespaceNode = node;
                            break;
                        }
                    }

                    if (namespaceNode == null)
                    {
                        namespaceNode = new TreeNode(@namespace);
                        moduleNode.Nodes.Add(namespaceNode);
                        namespaces.Add(namespaceNode);
                    }

                    TreeNode typeNode = new TreeNode(type.FullName);
                    namespaceNode.Nodes.Add(typeNode);

                    if (type.BaseType != null)
                    {
                        TreeNode baseTypeNode = new TreeNode("Base Type: " + type.BaseType.FullName);
                        typeNode.Nodes.Add(baseTypeNode);
                    }

                    if (type.DeclaringType != null)
                    {
                        TreeNode declaringTypeNode = new TreeNode("Declaring Type: " + type.DeclaringType.FullName);
                        typeNode.Nodes.Add(declaringTypeNode);
                    }

                    if (type.ElementType != null)
                    {
                        TreeNode elementTypeNode = new TreeNode("Element Type: " + type.ElementType.FullName);
                        typeNode.Nodes.Add(elementTypeNode);
                    }

                    if (type.Interfaces.Count != 0)
                    {
                        TreeNode interfacesNodes = new TreeNode("Interfaces");
                        typeNode.Nodes.Add(interfacesNodes);

                        foreach (MosaType interfaceType in type.Interfaces)
                        {
                            TreeNode interfaceNode = new TreeNode(interfaceType.FullName);
                            interfacesNodes.Nodes.Add(interfaceNode);
                        }
                    }

                    if (type.Fields.Count != 0)
                    {
                        TreeNode fieldsNode = new TreeNode("Fields");
                        if (showSizes)
                            fieldsNode.Text = fieldsNode.Text + " (Count: " + type.Fields.Count.ToString() + " - Size: " + typeLayout.GetTypeSize(type).ToString() + ")";

                        typeNode.Nodes.Add(fieldsNode);

                        foreach (MosaField field in type.Fields)
                        {
                            TreeNode fieldNode = new TreeNode(field.ShortName);
                            fieldsNode.Nodes.Add(fieldNode);

                            if (field.IsStatic)
                                fieldNode.Text = fieldNode.Text + " [Static]";

                            if (showSizes)
                            {
                                fieldNode.Text = fieldNode.Text + " (Size: " + typeLayout.GetFieldSize(field).ToString();

                                if (!field.IsStatic)
                                    fieldNode.Text = fieldNode.Text + " - Offset: " + typeLayout.GetFieldOffset(field).ToString();

                                fieldNode.Text = fieldNode.Text + ")";
                            }
                        }
                    }

                    if (type.Properties.Count != 0)
                    {
                        TreeNode propertiesNode = new TreeNode("Properties");
                        if (showSizes)
                            propertiesNode.Text = propertiesNode.Text + " (Count: " + type.Properties.Count.ToString() + ")";

                        typeNode.Nodes.Add(propertiesNode);

                        foreach (MosaProperty property in type.Properties)
                        {
                            TreeNode propertyNode = new ViewNode<MosaProperty>(property, property.ShortName);
                            propertiesNode.Nodes.Add(propertyNode);

                            if (property.GetterMethod != null)
                            {
                                TreeNode getterNode = new ViewNode<MosaMethod>(property.GetterMethod, property.GetterMethod.ShortName);
                                propertyNode.Nodes.Add(getterNode);

                                if (property.GetterMethod.IsStatic)
                                    getterNode.Text = getterNode.Text + " [Static]";

                                if (property.GetterMethod.IsAbstract)
                                    getterNode.Text = getterNode.Text + " [Abstract]";

                                if (property.GetterMethod.IsNewSlot)
                                    getterNode.Text = getterNode.Text + " [NewSlot]";

                                if (property.GetterMethod.IsVirtual)
                                    getterNode.Text = getterNode.Text + " [Virtual]";

                                if (property.GetterMethod.IsFinal)
                                    getterNode.Text = getterNode.Text + " [Final]";

                                if (property.GetterMethod.IsSpecialName)
                                    getterNode.Text = getterNode.Text + " [SpecialName]";

                                if (property.GetterMethod.IsRTSpecialName)
                                    getterNode.Text = getterNode.Text + " [RTSpecialName]";

                                if (property.GetterMethod.GenericArguments.Count != 0)
                                {
                                    TreeNode genericParameterNodes = new TreeNode("Generic Arguments Types");
                                    getterNode.Nodes.Add(genericParameterNodes);

                                    foreach (var genericParameter in property.GetterMethod.GenericArguments)
                                    {
                                        TreeNode GenericParameterNode = new TreeNode(genericParameter.Name);
                                        genericParameterNodes.Nodes.Add(GenericParameterNode);
                                    }
                                }
                            }

                            if (property.SetterMethod != null)
                            {
                                TreeNode setterNode = new ViewNode<MosaMethod>(property.SetterMethod, property.SetterMethod.ShortName);
                                propertyNode.Nodes.Add(setterNode);

                                if (property.SetterMethod.IsStatic)
                                    setterNode.Text = setterNode.Text + " [Static]";

                                if (property.SetterMethod.IsAbstract)
                                    setterNode.Text = setterNode.Text + " [Abstract]";

                                if (property.SetterMethod.IsNewSlot)
                                    setterNode.Text = setterNode.Text + " [NewSlot]";

                                if (property.SetterMethod.IsVirtual)
                                    setterNode.Text = setterNode.Text + " [Virtual]";

                                if (property.SetterMethod.IsFinal)
                                    setterNode.Text = setterNode.Text + " [Final]";

                                if (property.SetterMethod.IsSpecialName)
                                    setterNode.Text = setterNode.Text + " [SpecialName]";

                                if (property.SetterMethod.IsRTSpecialName)
                                    setterNode.Text = setterNode.Text + " [RTSpecialName]";

                                if (property.SetterMethod.GenericArguments.Count != 0)
                                {
                                    TreeNode genericParameterNodes = new TreeNode("Generic Arguments Types");
                                    setterNode.Nodes.Add(genericParameterNodes);

                                    foreach (var genericParameter in property.SetterMethod.GenericArguments)
                                    {
                                        TreeNode GenericParameterNode = new TreeNode(genericParameter.Name);
                                        genericParameterNodes.Nodes.Add(GenericParameterNode);
                                    }
                                }
                            }
                        }
                    }

                    if (type.Methods.Count != 0)
                    {
                        TreeNode methodsNode = new TreeNode("Methods");
                        typeNode.Nodes.Add(methodsNode);

                        foreach (MosaMethod method in type.Methods)
                        {
                            if (method.ShortName.StartsWith("set_") || method.ShortName.StartsWith("get_")) continue;

                            TreeNode methodNode = new ViewNode<MosaMethod>(method, method.ShortName);
                            methodsNode.Nodes.Add(methodNode);

                            if (method.IsStatic)
                                methodNode.Text = methodNode.Text + " [Static]";

                            if (method.IsAbstract)
                                methodNode.Text = methodNode.Text + " [Abstract]";

                            if (method.IsNewSlot)
                                methodNode.Text = methodNode.Text + " [NewSlot]";

                            if (method.IsVirtual)
                                methodNode.Text = methodNode.Text + " [Virtual]";

                            if (method.IsFinal)
                                methodNode.Text = methodNode.Text + " [Final]";

                            if (method.IsSpecialName)
                                methodNode.Text = methodNode.Text + " [SpecialName]";

                            if (method.IsRTSpecialName)
                                methodNode.Text = methodNode.Text + " [RTSpecialName]";

                            if (method.GenericArguments.Count != 0)
                            {
                                TreeNode genericParameterNodes = new TreeNode("Generic Arguments Types");
                                methodNode.Nodes.Add(genericParameterNodes);

                                foreach (var genericParameter in method.GenericArguments)
                                {
                                    TreeNode GenericParameterNode = new TreeNode(genericParameter.Name);
                                    genericParameterNodes.Nodes.Add(GenericParameterNode);
                                }
                            }
                        }
                    }

                    if (typeLayout.GetMethodTable(type) != null)
                    {
                        TreeNode methodTableNode = new TreeNode("Method Table");
                        typeNode.Nodes.Add(methodTableNode);

                        foreach (MosaMethod method in typeLayout.GetMethodTable(type))
                        {
                            TreeNode methodNode = new ViewNode<MosaMethod>(method, method.ShortName);
                            methodTableNode.Nodes.Add(methodNode);
                        }
                    }
                }
            }

            treeView.EndUpdate();
        }
 public RenderNodeAction OnViewBegin(ViewNode inNode)
 {
     return 0;
 }
    private void DoConvert()
    {
        var oldGraph = target as IGraphData;

        IGraphData graphData = null;
        var graph = ScriptableObject.CreateInstance<UnityGraphData>();
        if (oldGraph is ExternalStateMachineGraph)
        {
            graph.Graph = new StateMachineGraph();
        }
        else if (oldGraph is ExternalSubsystemGraph)
        {
            graph.Graph = new StateMachineGraph();
        }
        else
        {
            graph.Graph = new MVVMGraph();
        }

        graphData = graph;
        graph.name = oldGraph.Name;
        graph.Identifier = oldGraph.Identifier;
        graph.Graph.Identifier = oldGraph.Identifier;

        // Convert all the nodes
        Dictionary<DiagramNode, DiagramNode> converted = new Dictionary<DiagramNode, DiagramNode>();
        List<ConnectionData> connections = new List<ConnectionData>();
        foreach (var oldNode in oldGraph.NodeItems.OfType<SceneManagerData>())
        {
            var node = new SceneTypeNode
            {
                Identifier = oldNode.Identifier,
                Name = oldNode.Name
            };
            //foreach (var item in oldNode.Transitions)
            //{
            //    node.ChildItems.Add(new SceneTransitionsReference()
            //    {
            //        Node = node,
            //        Identifier = item.Identifier,
            //        SourceIdentifier = item.CommandIdentifier,
            //    });
            //    if (string.IsNullOrEmpty(item.ToIdentifier)) continue;
            //    connections.Add(new ConnectionData(item.Identifier, item.ToIdentifier));
            //}
            converted.Add(oldNode, node);
        }
        foreach (var oldNode in oldGraph.NodeItems.OfType<SubSystemData>())
        {
            var node = new SubsystemNode()
            {
                Identifier = oldNode.Identifier,
                Name = oldNode.Name
            };
            converted.Add(oldNode, node);
        }
        foreach (var oldNode in oldGraph.NodeItems.OfType<ComputedPropertyData>())
        {
            var node = new ComputedPropertyNode()
            {
                Identifier = oldNode.Identifier,
                Name = oldNode.Name,
                PropertyType = oldNode.RelatedType
            };

            foreach (var item in oldNode.DependantProperties)
            {
                connections.Add(new ConnectionData(item.Identifier, node.Identifier));
            }

            foreach (var x in oldNode.DependantNodes)
            {
                foreach (var item in x.AllProperties)
                {
                    if (x[item.Identifier])
                    {
                        node.ChildItems.Add(new SubPropertiesReference()
                        {
                            SourceIdentifier = item.Identifier,
                            Node = node,
                        });
                    }
                }
            }

            converted.Add(oldNode, node);
        }
        foreach (var oldNode in oldGraph.NodeItems.OfType<ElementData>())
        {
            var node = new ElementNode()
            {
                Identifier = oldNode.Identifier,
                Name = oldNode.Name,
            };
            if (!string.IsNullOrEmpty(oldNode.BaseIdentifier))
            {
                connections.Add(new ConnectionData(oldNode.BaseIdentifier, oldNode.Identifier));
            }
            foreach (var item in oldNode.Properties)
            {
                node.ChildItems.Add(new PropertiesChildItem()
                {
                    Identifier = item.Identifier,
                    Node = node,
                    Name = item.Name,
                    RelatedType = item.RelatedType
                });
            }
            foreach (var item in oldNode.Collections)
            {
                node.ChildItems.Add(new CollectionsChildItem()
                {
                    Identifier = item.Identifier,
                    Name = item.Name,
                    Node = node,
                    RelatedType = item.RelatedType
                });
            }
            foreach (var item in oldNode.Commands)
            {
                node.ChildItems.Add(new CommandsChildItem()
                {
                    Identifier = item.Identifier,
                    Name = item.Name,
                    Node = node,
                    RelatedType = item.RelatedType
                });

                if (!string.IsNullOrEmpty(item.TransitionToIdentifier))
                    connections.Add(new ConnectionData(item.Identifier, item.TransitionToIdentifier));
            }
            converted.Add(oldNode, node);
        }
        foreach (var oldNode in oldGraph.NodeItems.OfType<ClassNodeData>())
        {
            var node = new ElementNode()
            {
                Identifier = oldNode.Identifier,
                Name = oldNode.Name,
            };
            if (!string.IsNullOrEmpty(oldNode.BaseIdentifier))
            {
                connections.Add(new ConnectionData(oldNode.BaseIdentifier, oldNode.Identifier));
            }
            foreach (var item in oldNode.Properties)
            {
                node.ChildItems.Add(new PropertiesChildItem()
                {
                    Identifier = item.Identifier,
                    Node = node,
                    Name = item.Name,
                    RelatedType = item.RelatedType
                });
            }
            foreach (var item in oldNode.Collections)
            {
                node.ChildItems.Add(new CollectionsChildItem()
                {
                    Identifier = item.Identifier,
                    Name = item.Name,
                    Node = node,
                    RelatedType = item.RelatedType
                });
            }

            converted.Add(oldNode, node);
        }
        foreach (var oldNode in oldGraph.NodeItems.OfType<ViewData>())
        {
            var node = new ViewNode()
            {
                Identifier = oldNode.Identifier,
                Name = oldNode.Name
            };
            // TODO CONVERT INHERITANCE
            // Connect the scene property
            foreach (var sceneProperty in oldNode.SceneProperties)
            {
                connections.Add(new ConnectionData(sceneProperty.Identifier, node.ScenePropertiesInputSlot.Identifier));
            }

            // TODO CONVERT BINDINGS

            converted.Add(oldNode, node);
        }

        foreach (var oldNode in oldGraph.NodeItems.OfType<ViewComponentData>())
        {
            var node = new ViewComponentNode()
            {
                Identifier = oldNode.Identifier,
                Name = oldNode.Name
            };
            // TODO CONVERT INHERITANCE
            converted.Add(oldNode, node);
        }

        foreach (var oldNode in oldGraph.NodeItems.OfType<EnumData>())
        {
            var node = new EnumNode()
            {
                Identifier = oldNode.Identifier,
                Name = oldNode.Name
            };
            foreach (var item in oldNode.EnumItems)
            {
                node.ChildItems.Add(new EnumChildItem()
                {
                    Identifier = item.Identifier,
                    Node = node,
                    Name = item.Name
                });
            }
            converted.Add(oldNode, node);
            //Debug.Log(string.Format("Converted {0}", oldNode.Name));
        }

        foreach (var oldNode in oldGraph.NodeItems.OfType<StateMachineNodeData>())
        {
            var node = new StateMachineNode()
            {
                Identifier = oldNode.Identifier,
                Name = oldNode.Name
            };
            if (oldNode.StartState != null)
            {
                connections.Add(new ConnectionData(node.StartStateOutputSlot.Identifier, oldNode.StartState.Identifier));
            }

            foreach (var transition in oldNode.Transitions)
            {
                node.ChildItems.Add(new TransitionsChildItem()
                {
                    Name = transition.Name,
                    Identifier = transition.Identifier,
                    Node = node,
                });
                connections.Add(new ConnectionData(transition.PropertyIdentifier, transition.Identifier));
                //connections.Add();
            }
            connections.Add(new ConnectionData(oldNode.StatePropertyIdentifier, oldNode.Identifier));
            converted.Add(oldNode, node);
        }

        foreach (var oldNode in oldGraph.NodeItems.OfType<StateMachineStateData>())
        {
            var node = new StateNode()
            {
                Identifier = oldNode.Identifier,
                Name = oldNode.Name
            };
            foreach (var transition in oldNode.Transitions)
            {
                node.ChildItems.Add(new StateTransitionsReference()
                {
                    Name = transition.Name,
                    Identifier = transition.Identifier,
                    Node = node,
                });
                connections.Add(new ConnectionData(transition.Identifier, transition.TransitionToIdentifier));
            }

            converted.Add(oldNode, node);
        }

        // Grab all the connections
        ConvertSubsystems(converted, connections);
        ConvertSceneManagers(converted, connections);
        ConvertElements(converted, connections);
        ConvertStateMachines(converted, connections);
        ConvertViews(converted, connections);
        foreach (var item in converted.Values)
        {
            graphData.AddNode(item);
        }

        foreach (var item in connections)
        {
            if (item == null) continue;
            if (item.OutputIdentifier == item.InputIdentifier)
            {
                continue;
            }
            graphData.AddConnection(item.OutputIdentifier, item.InputIdentifier);
            Debug.Log(string.Format("Added connection {0} - {1}", item.OutputIdentifier, item.InputIdentifier));
        }
        // Reconstruct the filters
        var oldElementGraph = oldGraph as IGraphData;
        if (oldElementGraph != null)
        {
            foreach (var node in converted.Keys)
            {
                var newNOde = converted[node];

                if (oldGraph.PositionData.HasPosition(oldGraph.RootFilter, node))
                {
                    graph.SetItemLocation(newNOde, oldGraph.GetItemLocation(node));
                }
            }

            foreach (var item in oldElementGraph.PositionData.Positions)
            {
                graph.PositionData.Positions.Add(item.Key, item.Value);
            }
        }

        AssetDatabase.CreateAsset(graph, AssetDatabase.GetAssetPath(Selection.activeObject).Replace(".asset", "-new.asset"));
        AssetDatabase.SaveAssets();
    }