Пример #1
0
        private void initManager(ProjectManager manager, String config)
        {
            InitMenuIcons();

            //var Assembly = Assembly.GetEntryAssembly();
            var assembly = manager.Assembly;

            //load docui config
            XmlDocument doc = new XmlDocument(); //EmbeddedResourceTools.GetXmlDocument(config, assembly);
            doc.Load(assembly.GetManifestResourceStream(config));

            XmlNode root = doc.DocumentElement;

            XmlNode componentsnode = root.SelectSingleNode("Components");
            if (componentsnode != null && componentsnode.InnerText != "")
            {
                string components = componentsnode.InnerText;
                XmlDocument fdcompdoc = new XmlDocument();
                string componentsstring = Environment.CurrentDirectory + components;
                fdcompdoc.Load(componentsstring);
                DynamicForm.InitComponents(fdcompdoc);
            }

            XmlNode currentNode = root;

            XmlNode solution = root.SelectSingleNode("Solution");
            if (solution != null && solution.InnerText != "")
            {
                SolutionManager.solFolderIcon = this.fetchIconFromXml("FolderIcon", solution, 16, assembly);
                SolutionManager.solOpenFolderIcon = this.fetchIconFromXml("OpenFolderIcon", solution, 16, assembly);

                currentNode = solution;
            }

            XmlNode project = currentNode.SelectSingleNode("Project");
            if (project != null && project.InnerText != "")
            {
                ProjectManager.projFolderIcon = this.fetchIconFromXml("FolderIcon", project, 16, assembly);
                ProjectManager.projOpenFolderIcon = this.fetchIconFromXml("OpenFolderIcon", project, 16, assembly);

                XmlNode prefnode = project.SelectSingleNode("Preferences");
                if (prefnode != null)
                {
                    ProjectManager.projFileIcon = this.fetchIconFromXml("FileIcon", prefnode, 16, assembly);
                    ProjectManager.preferencesfile = prefnode.SelectSingleNode("SchemaName").InnerText;
                }

                XmlNode dirsnode = project.SelectSingleNode("Directories");
                if (dirsnode != null)
                {
                    XmlNodeList dirs = dirsnode.SelectNodes("Directory");
                    int size = dirs.Count;
                    string[] accepted = new string[size];
                    string[] acceptedxts = new string[size];
                    string[] types = new string[size];
                    Dictionary<string, BitmapImage> openfoldericons = new Dictionary<string, BitmapImage>();
                    Dictionary<string, BitmapImage> closedfoldericons = new Dictionary<string, BitmapImage>();
                    Dictionary<string, BitmapImage> fileicons = new Dictionary<string, BitmapImage>();
                    List<string> noSchema = new List<string>();
                    int i = 0;
                    foreach (XmlNode node in dirs)
                    {
                        try
                        {
                            accepted[i] = node.SelectSingleNode("Name").InnerText;
                            acceptedxts[i] = node.SelectSingleNode("FileExtension").InnerText;
                            types[i] = node.SelectSingleNode("Type").InnerText;
                            XmlAttribute att = node.Attributes["NoSchema"];
                            if (att != null && att.InnerText == "true")
                            {
                                noSchema.Add(acceptedxts[i]);
                            }

                            BitmapImage img = fetchIconFromXml("OpenFolderIcon", node, 16, assembly);
                            if (img != null)
                            {
                                openfoldericons.Add(acceptedxts[i], img);
                            }
                            img = fetchIconFromXml("FolderIcon", node, 16, assembly);
                            if (img != null)
                            {
                                closedfoldericons.Add(acceptedxts[i], img);
                            }
                            img = fetchIconFromXml("FileIcon", node, 16, assembly);
                            if (img != null)
                            {
                                fileicons.Add(acceptedxts[i], img);
                            }
                            i++;
                        }
                        catch (NullReferenceException e)
                        {
                            //todo: solve this misconfig
                        }
                    }
                    ProjectManager.ACCEPTED = accepted;
                    ProjectManager.ACCEPTEDXTS = acceptedxts;
                    ProjectManager.TYPES = types;
                    ProjectManager.NoSchema = noSchema;

                    XmlNode projext = project.SelectSingleNode("FileExtension");
                    if (projext != null)
                    {
                        ProjectManager.PXT = projext.InnerText;
                    }

                    if (solution != null)
                    {
                        XmlNode solext = solution.SelectSingleNode("FileExtension");
                        if (solext != null)
                        {
                            SolutionManager.SXT = solext.InnerText;
                        }
                    }

                    ProjectManager.CLOSEDFOLDER_ICONS = closedfoldericons;
                    ProjectManager.OPENFOLDER_ICONS = openfoldericons;
                    ProjectManager.FILE_ICONS = fileicons;

                }
            }
            //safely initialize the tree
            manager.initTree();
        }