Esempio n. 1
0
 private void OnLibraryLoaderCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     List<LibraryItem> root = e.Result as List<LibraryItem>;
     this.rootLibraryItem = root[0];
     this.rootLibraryMethodProperty = root[1];
     initialized(null != this.rootLibraryItem);
     this.uiContainer.FinishLoadingLibrary();
 }
Esempio n. 2
0
 private void SetLibraryItemLevel(LibraryItem item, int level)
 {
     item.Level = level;
     if (item.Children != null)
         if (item.Children.Count != 0)
         {
             level++;
             foreach (LibraryItem subItem in item.Children)
                 SetLibraryItemLevel(subItem, level);
         }
 }
Esempio n. 3
0
        private void ProcessImportBuiltInFunctions(List<MethodMirror> builtinFunctions, LibraryItem rootItem)
        {
            LibraryItem assemblyItem = new LibraryItem(NodeType.None, "Built-in Functions", null);

            foreach (MethodMirror builtinFunction in builtinFunctions)
            {
                if (this.filteredClasses != string.Empty)
                {
                    string procedureName = "Built-in Functions;" + builtinFunction.MethodName + ';';
                    if (filteredClasses.Contains(procedureName.ToLower()))
                        continue;
                }

                LibraryItem builtinFunctionItem = new LibraryItem(NodeType.Function, builtinFunction.MethodName, builtinFunction);
                builtinFunctionItem.ArgumentTypes = GetArgumentTypes(builtinFunction.GetArgumentTypes());
                builtinFunctionItem.Assembly = assemblyItem.DisplayText;
                builtinFunctionItem.Type = LibraryItem.MemberType.GlobalFunction;
                assemblyItem.AddChildItem(builtinFunctionItem);
            }

            GroupOverloadedItem(assemblyItem);

            if (assemblyItem.Children != null || assemblyItem.Children.Count > 0)
                rootItem.AddChildItem(assemblyItem);
        }
Esempio n. 4
0
        private bool MatchArgumentTypes(LibraryItem item, string className, string argumentTypes)
        {
            if (argumentTypes == item.ArgumentTypes)
                return true;

            // for old files that got either classname or "" in the argumentTypes
            if ((item.Type == LibraryItem.MemberType.InstanceProperty || item.Type == LibraryItem.MemberType.InstanceMethod)
                && MatchInstancePropertyArgumentTypes(className, argumentTypes, item.ArgumentTypes))
                return true;

            return false;
        }
Esempio n. 5
0
        private void ProcessImportAssembly(string assembly, LibraryItem rootItem)
        {
            LibraryItem assemblyItem = new LibraryItem(NodeType.None, Path.GetFileName(assembly), null);

            LibraryMirror assemblyMirror = GraphToDSCompiler.GraphUtilities.GetLibraryMirror(assembly);

            // Global Functions in DS file
            if (Path.GetExtension(assembly) == ".ds")
            {
                List<MethodMirror> globalFunctions = assemblyMirror.GetGlobalMethods();

                foreach (MethodMirror globalFunctionMirror in globalFunctions)
                {
                    LibraryItem globalFunctionItem = new LibraryItem(NodeType.Function, globalFunctionMirror.MethodName, globalFunctionMirror);
                    globalFunctionItem.ArgumentTypes = GetArgumentTypes(globalFunctionMirror.GetArgumentTypes());
                    globalFunctionItem.Assembly = assemblyMirror.LibraryName;
                    globalFunctionItem.Type = LibraryItem.MemberType.GlobalFunction;
                    assemblyItem.AddChildItem(globalFunctionItem);
                }

                GroupOverloadedItem(assemblyItem);
            }

            foreach (ClassMirror classMirror in assemblyMirror.GetClasses())
            {
                LibraryItem classItem = new LibraryItem(NodeType.None, classMirror.ClassName, null);

                ProcessClassItem(classMirror, classItem);

                if (classItem != null && classItem.Children != null && classItem.Children.Count > 0)
                    assemblyItem.AddChildItem(classItem);
            }
        }
Esempio n. 6
0
        internal void HandleAddNodeToCanvas(LibraryItem item)
        {
            ScrollViewer scrollViewer = graphControl.canvasScrollViewer;

            Random rand = new Random();
            int xShift = rand.Next(-Configurations.AddNodeToCanvasRegion, Configurations.AddNodeToCanvasRegion);
            int yShift = rand.Next(-Configurations.AddNodeToCanvasRegion, Configurations.AddNodeToCanvasRegion);

            Point centerPosition = new Point(scrollViewer.ActualWidth / 2 + xShift, scrollViewer.ActualHeight / 2 + yShift);
            Point centerPositionOnCanvas = scrollViewer.TranslatePoint(centerPosition, graphControl.CurrentGraphCanvas);
            CreateNode(item, centerPositionOnCanvas);
        }
Esempio n. 7
0
        private LibraryItem ProcessProcedureNode(ProtoCore.DSASM.ProcedureNode procedureNode, ProtoCore.DSASM.ClassTable classTable)
        {
            LibraryItem item;
            string argumentTypes = string.Empty;
            string argumentNames = string.Empty;
            string returnType = string.Empty;

            string getterPrefix = ProtoCore.DSASM.Constants.kGetterPrefix;
            string setterPrefix = ProtoCore.DSASM.Constants.kSetterPrefix;

            if (procedureNode.name.StartsWith(getterPrefix))  //Property
            {
                item = new LibraryItem(NodeType.Property, procedureNode.name.Remove(0, getterPrefix.Length));

                if (procedureNode.isStatic)
                    item.Type = LibraryItem.MemberType.StaticProperty;
                else
                    item.Type = LibraryItem.MemberType.InstanceProperty;
            }
            else // Constructor or Method
            {
                if (procedureNode.name.StartsWith(setterPrefix))
                {
                    item = new LibraryItem(NodeType.Function, procedureNode.name.Remove(0, setterPrefix.Length));

                    if (procedureNode.isStatic)
                        item.Type = LibraryItem.MemberType.StaticProperty;
                    else
                        item.Type = LibraryItem.MemberType.InstanceProperty;
                }
                else
                {
                    item = new LibraryItem(NodeType.Function, procedureNode.name);

                    if (procedureNode.isConstructor)
                        item.Type = LibraryItem.MemberType.Constructor;
                    else if (procedureNode.isStatic)
                        item.Type = LibraryItem.MemberType.StaticMethod;
                    else
                        item.Type = LibraryItem.MemberType.InstanceMethod;
                }
                if (procedureNode.argInfoList != null && procedureNode.argInfoList.Count() > 0)
                {
                    for (int i = 0; i < procedureNode.argInfoList.Count; i++)
                    {
                        if (argumentNames.Length > 0)
                            argumentNames += ",";

                        argumentNames += procedureNode.argInfoList[i].Name;

                        if (argumentTypes.Length > 0)
                            argumentTypes += ",";

                        argumentTypes += procedureNode.argTypeList[i].Name;
                    }
                }
            }
            item.ReturnType = classTable.ClassNodes[procedureNode.returntype.UID].name;
            item.ArgumentNames = argumentNames;
            item.ArgumentTypes = argumentTypes;

            return item;
        }
Esempio n. 8
0
        private void GroupOverloadedItem(LibraryItem parentItem)
        {
            int i = 0;
            while (i < parentItem.Children.Count)
            {
                // find items that should be grouped together (from i to j)
                int j = i + 1;
                while (j < parentItem.Children.Count && parentItem.Children[i].DisplayText == parentItem.Children[j].DisplayText)
                    j++;
                j--;

                // grouping
                if (i < j && parentItem.Children[i].DisplayText == parentItem.Children[j].DisplayText)
                {
                    // create group folder
                    LibraryItem groupItem = new LibraryItem(NodeType.None, parentItem.Children[i].QualifiedName, null);
                    groupItem.Assembly = parentItem.Children[i].Assembly;
                    groupItem.Type = parentItem.Children[i].Type;

                    // group i to j to the folder
                    for (int k = i; k <= j; k++)
                    {
                        parentItem.Children[i].IsOverloaded = true;

                        if (parentItem.Children[i].ArgumentNames == "")
                            parentItem.Children[i].DisplayText = UiStrings.OverloadDisplayTextNoParameter;
                        else
                        {
                            List<string> argumentNames = ((MethodMirror)parentItem.Children[i].DataMirror).GetArgumentNames();
                            parentItem.Children[i].DisplayText = GetArgumentNames(argumentNames);
                        }

                        groupItem.AddChildItem(parentItem.Children[i]);
                        parentItem.Children.RemoveAt(i);
                    }

                    parentItem.AddChildItem(groupItem);
                }
                i++;
            }
        }
Esempio n. 9
0
        private void ProcessImportBuiltInFunctions(List<ProtoCore.DSASM.ProcedureNode> functionList, LibraryItem rootItem)
        {
            LibraryItem assemblyItem = new LibraryItem(NodeType.None, "Built-in Functions");

            foreach (ProtoCore.DSASM.ProcedureNode procedureNode in functionList)
            {
                if (this.filteredClasses != string.Empty)
                {
                    string procedureName = "Built-in Functions;" + procedureNode.name + ';';
                    if (filteredClasses.Contains(procedureName.ToLower()))
                        continue;
                }

                LibraryItem item = ProcessProcedureNode(procedureNode, GraphToDSCompiler.GraphUtilities.ClassTable);
                if (item != null)
                {
                    item.Type = LibraryItem.MemberType.GlobalFunction;
                    item.Assembly = assemblyItem.DisplayText;
                    item.QualifiedName = item.DisplayText;
                    assemblyItem.AddChildItem(item);
                }
            }

            if (assemblyItem.Children != null || assemblyItem.Children.Count > 0)
                rootItem.AddChildItem(assemblyItem);
        }
Esempio n. 10
0
        private void ProcessImportClassTable(ProtoCore.DSASM.ClassTable classTable, LibraryItem parentItem, LibraryItem parentItemMethodProperty)
        {
            if (classTable == null && classTable.ClassNodes.Count <= (int)ProtoCore.PrimitiveType.kMaxPrimitives)
                return;

            for (int i = (int)ProtoCore.PrimitiveType.kMaxPrimitives; i < classTable.ClassNodes.Count; i++)
            {
                if (this.filteredClasses != string.Empty)
                {
                    string className = classTable.ClassNodes[i].ExternLib + ';' + classTable.ClassNodes[i].name + ';';
                    if (filteredClasses.Contains(className.ToLower()))
                        continue;
                }

                LibraryItem classItem = new LibraryItem(NodeType.None, classTable.ClassNodes[i].name);
                LibraryItem classItemMethodProperty = new LibraryItem(NodeType.None, classTable.ClassNodes[i].name);

                ProcessClassNode(classTable.ClassNodes[i], classTable, classItem, classItemMethodProperty);

                // add the libraryItem to respect assembly libraryItem,
                // if there is no such assembly, create one
                LibraryItem assemblyItem = null;
                LibraryItem assemblyItemMethodProperty = null;

                // Only include the class if it has at least one method listed.
                if (null != classItem.Children && (classItem.Children.Count > 0))
                {
                    if (!string.IsNullOrEmpty(classTable.ClassNodes[i].ExternLib) && parentItem.Children != null && parentItem.Children.Count > 0)
                    {
                        foreach (LibraryItem item in parentItem.Children)
                        {
                            if (item.Assembly == classTable.ClassNodes[i].ExternLib)
                            {
                                assemblyItem = item;
                                break;
                            }
                        }
                    }

                    if (assemblyItem == null)
                    {
                        if (string.IsNullOrEmpty(classTable.ClassNodes[i].ExternLib)) // Custom Class
                        {
                        }
                        assemblyItem = new LibraryItem(NodeType.None, Path.GetFileName(classTable.ClassNodes[i].ExternLib));
                        assemblyItem.Assembly = classTable.ClassNodes[i].ExternLib;
                        assemblyItem.IsExternal = false;
                        parentItem.AddChildItem(assemblyItem);
                    }
                    assemblyItem.AddChildItem(classItem);
                }

                if (null != classItemMethodProperty.Children && (classItemMethodProperty.Children.Count > 0))
                {
                    if (!string.IsNullOrEmpty(classTable.ClassNodes[i].ExternLib) && parentItemMethodProperty.Children != null && parentItemMethodProperty.Children.Count > 0)
                    {
                        foreach (LibraryItem itemMethodProperty in parentItemMethodProperty.Children)
                        {
                            if (itemMethodProperty.Assembly == classTable.ClassNodes[i].ExternLib)
                            {
                                assemblyItemMethodProperty = itemMethodProperty;
                                break;
                            }
                        }
                    }

                    if (assemblyItemMethodProperty == null)
                    {
                        if (string.IsNullOrEmpty(classTable.ClassNodes[i].ExternLib)) // Custom Class
                        {
                        }
                        assemblyItemMethodProperty = new LibraryItem(NodeType.None, Path.GetFileName(classTable.ClassNodes[i].ExternLib));
                        assemblyItemMethodProperty.Assembly = classTable.ClassNodes[i].ExternLib;
                        assemblyItemMethodProperty.IsExternal = false;
                        parentItemMethodProperty.AddChildItem(assemblyItemMethodProperty);
                    }
                    assemblyItemMethodProperty.AddChildItem(classItemMethodProperty);
                }
            }
        }
Esempio n. 11
0
        private int ProcessImportAssembly(string assemblyFilePath, out LibraryItem assemblyItem, out LibraryItem assemblyItemMethodProperty)
        {
            int importedNodes = -1;

            assemblyItem = null;
            assemblyItemMethodProperty = null;

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());

            IList<ProtoCore.DSASM.ClassNode> classNodes = GraphToDSCompiler.GraphUtilities.GetClassesForAssembly(assemblyFilePath);
            importedNodes = classNodes.Count();

            ProtoCore.BuildStatus buildStatus = GraphToDSCompiler.GraphUtilities.BuildStatus;
            if (buildStatus.ErrorCount > 0)
                return -1;

            assemblyItem = new LibraryItem(NodeType.None, Path.GetFileName(assemblyFilePath));
            assemblyItemMethodProperty = new LibraryItem(NodeType.None, Path.GetFileName(assemblyFilePath));

            foreach (ProtoCore.DSASM.ClassNode classNode in classNodes)
            {
                LibraryItem classItem = new LibraryItem(NodeType.None, classNode.name);
                LibraryItem classItemMethodProperty = new LibraryItem(NodeType.None, classNode.name);

                ProcessClassNode(classNode, GraphToDSCompiler.GraphUtilities.ClassTable, classItem, classItemMethodProperty);

                if (classItem != null && classItem.Children != null && classItem.Children.Count > 0)
                    assemblyItem.AddChildItem(classItem);
                if (classItemMethodProperty != null && classItemMethodProperty.Children != null && classItemMethodProperty.Children.Count > 0)
                    assemblyItemMethodProperty.AddChildItem(classItemMethodProperty);
            }

            // Global Functions in DS file
            if (Path.GetExtension(assemblyFilePath) == ".ds")
            {
                List<ProtoCore.DSASM.ProcedureNode> procNodes = GraphToDSCompiler.GraphUtilities.GetGlobalMethods(assemblyFilePath);

                importedNodes += procNodes.Count();

                foreach (ProtoCore.DSASM.ProcedureNode procedureNode in procNodes)
                {
                    LibraryItem item = ProcessProcedureNode(procedureNode, GraphToDSCompiler.GraphUtilities.ClassTable);
                    if (item != null)
                    {
                        item.Type = LibraryItem.MemberType.GlobalFunction;
                        item.Assembly = Path.GetFileName(assemblyFilePath);
                        item.QualifiedName = item.DisplayText;
                        assemblyItem.AddChildItem(item);
                    }
                }
            }

            return importedNodes;
        }
Esempio n. 12
0
        private void ProcessClassNode(ProtoCore.DSASM.ClassNode classNode, ProtoCore.DSASM.ClassTable classTable, LibraryItem classItem, LibraryItem classItemMethodProperty)
        {
            //TODO: Victor
            // Temperarily fix for multiple setter
            LibraryItem setterItem = null;

            string friendlyName = GetFriendlyName(classNode.ExternLib);
            if (UiStrings.ProtoGeometryFriendlyName == friendlyName)
            {
                // Fix: IDE-1604 Usage of text crashes the IDE. The OpenGL renderer
                // does not have a way of accepting text inputs, therefore we don't
                // have a way to render text on the preview, filter it out for now.
                if (classNode.name == "Text")
                    return;
            }

            classItem.Assembly = classNode.ExternLib;
            classItemMethodProperty.Assembly = classNode.ExternLib;

            foreach (ProtoCore.DSASM.ProcedureNode procedureNode in classNode.vtable.procList)
            {
                if (procedureNode.isAutoGeneratedThisProc) // Temporary functions to be excluded.
                    continue;

                LibraryItem item = ProcessProcedureNode(procedureNode, classTable);
                if (item != null)
                {
                    //TODO: Victor
                    // Temperarily fix for multiple setter
                    if (procedureNode.name.StartsWith(ProtoCore.DSASM.Constants.kSetterPrefix))
                    {
                        if (setterItem != null && item.DisplayText == setterItem.DisplayText)
                            continue;
                        else
                            setterItem = item;
                    }

                    if (classNode.ExternLib != null)
                        item.Assembly = classNode.ExternLib;
                    else
                        item.Assembly = string.Empty;

                    item.QualifiedName = string.Format("{0}.{1}", classNode.name, item.DisplayText);

                    if (item.Type == LibraryItem.MemberType.InstanceMethod ||  // add the "this" input to instance method and property(setter only)
                        (item.Type == LibraryItem.MemberType.InstanceProperty && procedureNode.name.StartsWith(ProtoCore.DSASM.Constants.kSetterPrefix)))
                    {
                        if (string.IsNullOrEmpty(item.ArgumentNames))
                        {
                            item.ArgumentNames = "this";
                            item.ArgumentTypes = "this";
                        }
                        else
                        {
                            item.ArgumentNames = "this," + item.ArgumentNames;
                            item.ArgumentTypes = "this," + item.ArgumentTypes;
                        }
                    }

                    if (procedureNode.isStatic || procedureNode.isConstructor)
                        classItem.AddChildItem(item);
                    else
                        classItemMethodProperty.AddChildItem(item);
                }
            }
        }
Esempio n. 13
0
        private void GroupOverloadProcedure(LibraryItem parentItem)
        {
            int i = 0;
            while (i < parentItem.Children.Count)
            {
                // it's a folder, no grouping needed, process to group its children
                if (parentItem.Children[i].ItemType == NodeType.None)
                {
                    if (parentItem.Children[i].Children.Count > 1)
                        GroupOverloadProcedure(parentItem.Children[i]);
                }
                else
                {
                    // find items that should be grouped together (from i to j)
                    int j = i + 1;
                    while (j < parentItem.Children.Count && parentItem.Children[i].DisplayText == parentItem.Children[j].DisplayText)
                        j++;

                    j--;

                    // grouping
                    if (i < j && parentItem.Children[i].DisplayText == parentItem.Children[j].DisplayText)
                    {
                        // create group folder
                        LibraryItem groupItem = new LibraryItem(NodeType.None, parentItem.Children[i].QualifiedName);
                        groupItem.Assembly = parentItem.Children[i].Assembly;
                        groupItem.Type = parentItem.Children[i].Type;

                        // group i to j to the folder
                        for (int k = i; k <= j; k++)
                        {
                            parentItem.Children[i].IsOverloaded = true;

                            // Update the display text
                            if (parentItem.Children[i].Type == LibraryItem.MemberType.StaticProperty
                                || parentItem.Children[i].Type == LibraryItem.MemberType.InstanceProperty)
                            {
                                if (parentItem.Children[i].ArgumentNames == "" || parentItem.Children[i].ItemType == NodeType.Property)
                                    parentItem.Children[i].DisplayText += UiStrings.OverloadDisplayTextGetter;
                                else
                                    parentItem.Children[i].DisplayText += UiStrings.OverloadDisplayTextSetter;
                            }
                            else
                            {
                                if (parentItem.Children[i].ArgumentNames == "")
                                    parentItem.Children[i].DisplayText = UiStrings.OverloadDisplayTextNoParameter;
                                else
                                    parentItem.Children[i].DisplayText = parentItem.Children[i].ArgumentNames;
                            }

                            groupItem.AddChildItem(parentItem.Children[i]);
                            parentItem.Children.RemoveAt(i);
                        }

                        parentItem.AddChildItem(groupItem);
                    }
                }
                i++;
            }
        }
Esempio n. 14
0
        private List<LibraryItem> LoadLibraryInternal()
        {
            LibraryItem rootItem = new LibraryItem();
            LibraryItem rootItemMethodProperty = new LibraryItem();

            LoadBuiltInItems(rootItem);

            try
            {
                DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
                List<string> coreAssemblies = new List<string>();
                coreAssemblies.Add("ProtoGeometry.dll");
                coreAssemblies.Add("Math.dll");

                GraphToDSCompiler.GraphUtilities.PreloadAssembly(coreAssemblies);

                ProcessImportClassTable(GraphToDSCompiler.GraphUtilities.ClassTable, rootItem, rootItemMethodProperty);

                ProcessImportBuiltInFunctions(GraphToDSCompiler.GraphUtilities.BuiltInMethods, rootItem);

                LoadExternalLibraries(rootItem, rootItemMethodProperty);
            }
            catch (ProtoCore.BuildHaltException exception)
            {
                System.Diagnostics.Debug.WriteLine("DSS: " + exception.Message);
                System.Diagnostics.Debug.WriteLine("DSS: " + exception.errorMsg);
                System.Diagnostics.Debug.WriteLine("DSS: " + exception.StackTrace);
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine("DSS: " + exception.Message);
                System.Diagnostics.Debug.WriteLine("DSS: " + exception.StackTrace);
            }

            if (rootItem.Children != null)
            {
                foreach (LibraryItem assemblyItem in rootItem.Children)
                    GroupOverloadProcedure(assemblyItem);
            }

            if (rootItemMethodProperty.Children != null)
            {
                foreach (LibraryItem assemblyItemMethodProperty in rootItemMethodProperty.Children)
                    GroupOverloadProcedure(assemblyItemMethodProperty);
            }

            SetLibraryItemLevel(rootItem, -1);

            List<LibraryItem> root = new List<LibraryItem>();
            root.Add(rootItem);
            root.Add(rootItemMethodProperty);

            return root;
        }
Esempio n. 15
0
 public void Initialize()
 {
     List<LibraryItem> root = LoadLibraryInternal();
     this.rootLibraryItem = root[0];
     this.rootLibraryMethodProperty = root[1];
 }
Esempio n. 16
0
        private LibraryItem LoadLibraryInternal()
        {
            LibraryItem rootItem = new LibraryItem();

            LoadBuiltInItems(rootItem);

            try
            {
                ProcessImportBuiltInFunctions(StaticMirror.BuiltInMethods, rootItem);

                List<string> assemblies = new List<string>();
                assemblies.Add("ProtoGeometry.dll");
                assemblies.Add("Math.dll");

                if (coreComponent.studioSettings.LoadedAssemblies != null
                && coreComponent.studioSettings.LoadedAssemblies.Count > 0)
                {
                    foreach (string externalLibrary in coreComponent.studioSettings.LoadedAssemblies)
                        assemblies.Add(externalLibrary);
                }

                foreach (string assembly in assemblies)
                    ProcessImportAssembly(assembly, rootItem);
            }
            catch (ProtoCore.BuildHaltException exception)
            {
                System.Diagnostics.Debug.WriteLine("DSS: " + exception.Message);
                System.Diagnostics.Debug.WriteLine("DSS: " + exception.errorMsg);
                System.Diagnostics.Debug.WriteLine("DSS: " + exception.StackTrace);
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine("DSS: " + exception.Message);
                System.Diagnostics.Debug.WriteLine("DSS: " + exception.StackTrace);
            }

            SetLibraryItemLevel(rootItem, -1);
            return rootItem;
        }
Esempio n. 17
0
 internal ObservableCollection<LibraryItem> GetOverloads(LibraryItem item)
 {
     if (item == null)
         return new ObservableCollection<LibraryItem>();
     if (item.Children == null || item.Children.Count <= 0)
         return new ObservableCollection<LibraryItem>();
     return item.Children;
 }
Esempio n. 18
0
        private void ProcessClassItem(ClassMirror classMirror, LibraryItem classItem)
        {
            classItem.Assembly = classMirror.GetAssembly().LibraryName;

            foreach (MethodMirror constructorMirror in classMirror.GetConstructors())
            {
                LibraryItem constructorItem = new LibraryItem(NodeType.Function, constructorMirror.MethodName, constructorMirror);
                constructorItem.ArgumentTypes = GetArgumentTypes(constructorMirror.GetArgumentTypes());
                constructorItem.Assembly = classMirror.GetAssembly().LibraryName;
                constructorItem.Type = LibraryItem.MemberType.Constructor;
                classItem.AddChildItem(constructorItem);
            }

            foreach (MethodMirror methodMirror in classMirror.GetFunctions())
            {
                if (!methodMirror.IsStatic)
                    continue;

                LibraryItem staticMethodItem = new LibraryItem(NodeType.Function, methodMirror.MethodName, methodMirror);
                staticMethodItem.ArgumentTypes = GetArgumentTypes(methodMirror.GetArgumentTypes());
                staticMethodItem.Assembly = classMirror.GetAssembly().LibraryName;
                staticMethodItem.Type = LibraryItem.MemberType.StaticMethod;
                classItem.AddChildItem(staticMethodItem);
            }

            GroupOverloadedItem(classItem);

            foreach (PropertyMirror propertyMirror in classMirror.GetProperties())
            {
                if (!propertyMirror.IsStatic)
                    continue;

                LibraryItem staticPropertyItem = new LibraryItem(NodeType.Function, propertyMirror.PropertyName, propertyMirror);
                staticPropertyItem.ArgumentTypes = string.Empty;//GetArgumentTypes(propertyMirror.
                staticPropertyItem.Type = LibraryItem.MemberType.StaticProperty;

                if (propertyMirror.IsSetter)
                    staticPropertyItem.DisplayText += UiStrings.OverloadDisplayTextSetter;
                else
                    staticPropertyItem.DisplayText += UiStrings.OverloadDisplayTextGetter;

                classItem.AddChildItem(staticPropertyItem);
            }
        }
Esempio n. 19
0
        private void LoadBuiltInItems(LibraryItem rootItem)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(LibraryItem));
            TextReader stringReader = new StringReader(Properties.Resources.BuiltInLibrary);

            LibraryItem libraryItem = serializer.Deserialize(stringReader) as LibraryItem;
            stringReader.Close();

            foreach (LibraryItem item in libraryItem.Children)
                rootItem.AddChildItem(item);
        }
Esempio n. 20
0
        private void CreateNode(LibraryItem item, Point position)
        {
            if (null == item)
                return;

            switch (item.ItemType)
            {
                case NodeType.Identifier:
                    graphController.DoCreateIdentifierNode(position.X, position.Y);
                    break;

                case NodeType.Render:
                    graphController.DoCreateRenderNode(position.X, position.Y);
                    break;

                case NodeType.Driver:
                    graphController.DoCreateDriverNode(position.X, position.Y);
                    break;

                case NodeType.CodeBlock:
                    // @TODO(Ben/Joy): Create a "code box" for script input?
                    graphController.DoCreateCodeBlockNode(position.X, position.Y, Configurations.CodeBlockInitialMessage);

                    uint compId;
                    Rect rect = new Rect();
                    NodeType type = NodeType.None;
                    string temp;

                    graphController.GetLastNodeId(out compId);
                    graphController.GetNodePartRegion(compId, NodePart.Text, mouseDownPosition, out rect, out type);
                    CreateEditTextbox(true, Configurations.RectWhite, Configurations.Font, FontWeights.Normal, Configurations.TextSize, 0);
                    graphController.GetNodeText(compId, NodePart.Text, out temp);

                    editTextbox.Text = temp;
                    double x = rect.X + Configurations.TextHorizontalOffset;
                    double y = rect.Y + Configurations.TextVerticalOffset;
                    editTextbox.SetValue(Canvas.LeftProperty, x);
                    editTextbox.SetValue(Canvas.TopProperty, y);
                    nodeEditFlag = true;
                    nodeEditId = compId;

                    graphController.DoBeginNodeEdit(nodeEditId, NodePart.Text);
                    graphController.UpdateNodeText(compId, editTextbox.Text);
                    break;

                case NodeType.Function:
                    graphController.DoCreateFunctionNode(position.X, position.Y,
                        item.Assembly, item.QualifiedName, item.ArgumentTypes);
                    break;

                case NodeType.Property:
                    graphController.DoCreatePropertyNode(position.X, position.Y, item.Assembly, item.QualifiedName, item.ArgumentTypes);
                    break;

                default:
                    throw new ArgumentException("Unhandled type!", "item.ItemType");
            }
        }
Esempio n. 21
0
        private void LoadExternalLibraries(LibraryItem rootItem, LibraryItem rootItemMethodProperty)
        {
            if (coreComponent.studioSettings.LoadedAssemblies != null
                && coreComponent.studioSettings.LoadedAssemblies.Count > 0)
            {
                foreach (string externalLibrary in coreComponent.studioSettings.LoadedAssemblies)
                {
                    LibraryItem assemblyItem, assemblyItemMethodProperty;
                    ProcessImportAssembly(externalLibrary, out assemblyItem, out assemblyItemMethodProperty);

                    if (assemblyItem != null && assemblyItem.Children != null && assemblyItem.Children.Count > 0)
                    {
                        assemblyItem.IsExternal = true;
                        rootItem.AddChildItem(assemblyItem);
                    }
                    if (assemblyItemMethodProperty != null && assemblyItemMethodProperty.Children != null && assemblyItemMethodProperty.Children.Count > 0)
                    {
                        assemblyItemMethodProperty.IsExternal = true;
                        rootItemMethodProperty.AddChildItem(assemblyItemMethodProperty);
                    }
                }
            }
        }
Esempio n. 22
0
        internal void HandleDrop(object sender, LibraryItem item, DragEventArgs e)
        {
            if (graphController.CurrentDragState != DragState.None)
                return;

            System.Windows.Point mouse = e.GetPosition(graphCanvas);

            CreateNode(item, mouse);
        }
Esempio n. 23
0
        public void AddRootChildItem(LibraryItem childItem)
        {
            if (null == Children)
            {
                Children = new ObservableCollection<LibraryItem>();
                Children.Add(childItem);
                return;
            }

            if (String.Compare(Children[1].DisplayText, childItem.DisplayText) >= 0)
            {
                Children.Insert(1, childItem);
                return;
            }

            for (int i = 2; i < Children.Count(); i++)
            {
                if ((String.Compare(Children[i - 1].DisplayText, childItem.DisplayText) < 0) && (String.Compare(Children[i].DisplayText, childItem.DisplayText) >= 0))
                {
                    Children.Insert(i, childItem);
                    return;
                }
            }
            Children.Add(childItem);
        }