Example #1
0
        private void createResourceViewTreeHeader(string projPath, TreeView parent)
        {
            DirectoryInfo d = new DirectoryInfo(projPath);

            FileAttributes attr = File.GetAttributes(projPath);

            if (!attr.HasFlag(FileAttributes.Directory))
            {
                return;
            }
            DirectoryInfo[] directories = d.GetDirectories();

            foreach (DirectoryInfo dir in directories)
            {
                String[] names = dir.Name.Split('-');
                if (parent.Equals(defaultExpanderTreeHeader) && names.Count() > 1 && ResourceManagerUtil.isValidLanguageID(names[0]) && ResourceManagerUtil.isValidResolution(names[1].Trim()))
                {
                    continue;
                }
                TreeViewItem item = createTreeItem(projPath, dir.Name, false);
                parent.Items.Add(item);
                createResourceViewTree(projPath + "\\" + dir.Name, item);
            }
            FileInfo[] Files = d.GetFiles();
            foreach (FileInfo file in Files)
            {
                TreeViewItem item = createTreeItem(projPath, file.Name, true);
                parent.Items.Add(item);
            }
        }
Example #2
0
        public static void updateResourceXML(Project project)
        {
            string      projFullName  = project.FullName;
            string      projPath      = projFullName.Substring(0, projFullName.LastIndexOf("\\") + 1);
            string      resFolderPath = projPath + "res\\";
            XmlDocument doc           = new XmlDocument();
            XmlNode     docNode       = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes");

            doc.AppendChild(docNode);

            XmlNode rootNode = doc.CreateElement(STR_res, "http://tizen.org/ns/rm");

            doc.AppendChild(rootNode);

            XmlElement groupImageNode = doc.CreateElement("group-image", "http://tizen.org/ns/rm");

            groupImageNode.SetAttribute(STR_folder, STR_contents);
            rootNode.AppendChild(groupImageNode);

            XmlElement groupLayoutNode = doc.CreateElement("group-layout", "http://tizen.org/ns/rm");

            groupLayoutNode.SetAttribute(STR_folder, STR_contents);
            rootNode.AppendChild(groupLayoutNode);

            XmlElement groupSoundNode = doc.CreateElement("group-sound", "http://tizen.org/ns/rm");

            groupSoundNode.SetAttribute(STR_folder, STR_contents);
            rootNode.AppendChild(groupSoundNode);

            XmlElement groupBinNode = doc.CreateElement("group-bin", "http://tizen.org/ns/rm");

            groupBinNode.SetAttribute(STR_folder, STR_contents);
            rootNode.AppendChild(groupBinNode);

            DirectoryInfo di = new DirectoryInfo(@resFolderPath + STR_contents);

            if (!di.Exists)
            {
                return;
            }
            foreach (XmlNode groupNode in doc.DocumentElement.ChildNodes)
            {
                foreach (var fi in di.GetDirectories())
                {
                    String languageID      = null;
                    String resolutionRange = null;
                    String folderPath      = null;

                    String fileName = fi.Name;
                    folderPath = "contents/" + fileName;
                    if (fileName.Contains("-"))
                    {
                        String[] names = fileName.Split('-');
                        names[0] = names[0];
                        if (ResourceManagerUtil.isValidLanguageID(names[0]))
                        {
                            languageID = names[0].Equals("default_All") ? "All" : names[0];
                        }
                        if (ResourceManagerUtil.isValidResolution(names[1]))
                        {
                            resolutionRange = ResourceManagerUtil.getResolution(names[1]);
                        }
                    }
                    if (languageID == null || resolutionRange == null)
                    {
                        continue;
                    }
                    else
                    {
                        XmlElement   node   = doc.CreateElement("node", "http://tizen.org/ns/rm");
                        XmlAttribute folder = doc.CreateAttribute(STR_folder);
                        folder.Value = folderPath;
                        node.Attributes.Append(folder);
                        if (resolutionRange.Length != 0)
                        {
                            XmlAttribute screen_dpi_range = doc.CreateAttribute("screen-dpi-range");
                            screen_dpi_range.Value = resolutionRange;
                            node.Attributes.Append(screen_dpi_range);
                        }
                        // Language attribute is not emitted when ALL language is selected
                        if (!languageID.Equals("All"))
                        {
                            XmlAttribute language = doc.CreateAttribute("language");
                            language.Value = languageID;
                            node.Attributes.Append(language);
                        }

                        groupNode.AppendChild(node);
                    }
                }
            }

            doc.Save(@resFolderPath + "res.xml");
        }
Example #3
0
        private void removeFromViewTab(string name, string fullPath, Boolean isFile)
        {
            object         viewChildElements = ((StackPanel)(StackPanelGrid.Children[0])).Children;
            ItemCollection treeViewItems     = null;

            string[] removedHierarchy = name.Split('\\');
            string   seleExt          = Path.GetExtension(fullPath);

            if (removedHierarchy.Count() == 3)
            {
                var      convViewElem = (dynamic)viewChildElements;
                string[] hieItem      = removedHierarchy[2].Split('-');
                if (hieItem.Length != 2)
                {
                    return;
                }
                string[] splittedLang = hieItem[0].Split('_');
                string   hieLang      = "";
                if (!(splittedLang.Count() < 2))
                {
                    hieLang = (hieItem[0].Equals("default_All") ? hieItem[0] : GetProperty(expando, (splittedLang[0] + "_" + splittedLang[1])));
                }

                if (!(hieLang != null && ResourceManagerUtil.isValidLanguageID(hieItem[0]) && isValidDpi(hieItem[1]) && defaultExpanderTreeHeader != null))
                {
                    return;
                }
                foreach (StackPanel sp in convViewElem)
                {
                    var      exp     = sp.Children[0];
                    string[] expItem = ((string)((Expander)exp).Header).Split(',');

                    if (hieLang.Equals(expItem[0]) && hieItem[1].Equals(expItem[1].Trim()))
                    {
                        viewContextMenu.removeSubMenuItem(((Expander)exp).Header.ToString());
                        ((StackPanel)(StackPanelGrid.Children[0])).Children.Remove(sp);
                        break;
                    }
                }
                return;
            }
            else if (removedHierarchy.Count() < 2)
            {
                ((StackPanel)(StackPanelGrid.Children[0])).Children.Clear();
                return;
            }

            for (int idx = 2; idx < removedHierarchy.Count() - 1; idx++)
            {
                var convViewElem = (dynamic)viewChildElements;
                foreach (var ele in convViewElem)
                {
                    if (ele is StackPanel)
                    {
                        StackPanel sp           = ele as StackPanel;
                        var        exp          = sp.Children[0];
                        string[]   hieItem      = removedHierarchy[idx].Split('-');
                        string[]   splittedLang = hieItem[0].Split('_');
                        string     hieLang      = "";
                        if (!(splittedLang.Count() < 2))
                        {
                            hieLang = (hieItem[0].Equals("default_All") ? hieItem[0] : GetProperty(expando, (splittedLang[0] + "_" + splittedLang[1])));
                        }

                        if (!(hieLang != null && ResourceManagerUtil.isValidLanguageID(hieItem[0]) && isValidDpi(hieItem[1]) && defaultExpanderTreeHeader != null))
                        {
                            return;
                        }
                        string[] expItem = ((string)((Expander)exp).Header).Split(',');
                        if (hieLang.Equals(expItem[0]) && hieItem[1].Equals(expItem[1].Trim()))
                        {
                            treeViewItems = (((Expander)exp).Content as TreeView).Items;
                            break;
                        }
                    }
                    else if (ele is TreeViewItem)
                    {
                        TreeViewItem tvi = ele as TreeViewItem;
                        if (tvi.Header.ToString().Equals(removedHierarchy[idx]))
                        {
                            treeViewItems = tvi.Items;
                            break;
                        }
                    }
                }
            }
            if (treeViewItems == null)
            {
                return;
            }

            if (isFile)
            {
                foreach (TreeViewItem tvcItem in treeViewItems)
                {
                    string sp = tvcItem.Header.ToString();
                    if (seleExt.Equals(Path.GetExtension(tvcItem.Tag.ToString())) && (sp.Equals(removedHierarchy[removedHierarchy.Count() - 1])))
                    {
                        treeViewItems.Remove(tvcItem);
                        break;
                    }
                }
            }
            else
            {
                foreach (TreeViewItem tvcItem in treeViewItems)
                {
                    if (tvcItem.Header.ToString().Equals(removedHierarchy[removedHierarchy.Count() - 1]))
                    {
                        treeViewItems.Remove(tvcItem);
                        break;
                    }
                }
            }
        }
Example #4
0
        private void addToViewTab(string name, string fullPath, Boolean isFile)
        {
            object viewChildElements = ((StackPanel)(StackPanelGrid.Children[0])).Children;

            string[] createdHierarchy   = name.Split('\\');
            int      contentNotFoundIdx = -1;
            Boolean  isDefaultConf      = false;

            if (createdHierarchy.Count() == 2 && createdHierarchy[1].Equals("contents"))
            {
                createDefaultPanel();
                return;
            }
            for (int idx = 2; idx < createdHierarchy.Count(); idx++)
            {
                Boolean isContentFound = false;
                var     convViewElem   = (dynamic)viewChildElements;
                try
                {
                    convViewElem = convViewElem.Items;
                }
                catch (Exception)
                {
                    convViewElem = (dynamic)viewChildElements;
                }
                foreach (var ele in convViewElem)
                {
                    if (ele is StackPanel)
                    {
                        StackPanel sp      = ele as StackPanel;
                        var        exp     = sp.Children[0];
                        string[]   hieItem = createdHierarchy[idx].Split('-');
                        if (hieItem.Length != 2)
                        {
                            return;
                        }
                        string[] splittedLang = hieItem[0].Split('_');
                        if (splittedLang.Count() < 2)
                        {
                            viewChildElements = defaultExpanderTreeHeader;
                            isContentFound    = false;
                            isDefaultConf     = true;
                            break;
                        }

                        string hieLang = hieItem[0].Equals("default_All") ? hieItem[0] : GetProperty(expando, (splittedLang[0] + "_" + splittedLang[1]));
                        if (!(hieLang != null && ResourceManagerUtil.isValidLanguageID(hieItem[0]) && isValidDpi(hieItem[1]) && defaultExpanderTreeHeader != null))
                        {
                            viewChildElements = defaultExpanderTreeHeader;
                            isContentFound    = false;
                            isDefaultConf     = true;
                            break;
                        }
                        string[] expItem = ((string)((Expander)exp).Header).Split(',');
                        if (hieLang.Equals(expItem[0]) && hieItem[1].Equals(expItem[1].Trim()))
                        {
                            viewChildElements = (((Expander)exp).Content as TreeView);
                            isContentFound    = true;
                            isDefaultConf     = false;
                            break;
                        }
                    }
                    else if (ele is TreeViewItem)
                    {
                        TreeViewItem tvi = ele as TreeViewItem;
                        if (tvi.Header is StackPanel)
                        {
                            StackPanel sp = tvi.Header as StackPanel;
                            if ((sp.Children[0] as TextBlock).Text.ToString().Equals(createdHierarchy[idx]))
                            {
                                isContentFound = true;
                                isDefaultConf  = false;
                                break;
                            }
                        }
                        if (tvi.Header.ToString().Equals(createdHierarchy[idx]))
                        {
                            viewChildElements = tvi;
                            isContentFound    = true;
                            isDefaultConf     = false;
                            break;
                        }
                    }
                }
                if (!isContentFound)
                {
                    contentNotFoundIdx = idx;
                    break;
                }
            }

            if (contentNotFoundIdx == 2 && !isDefaultConf)
            {
                createdHierarchy = createdHierarchy.Take(3).ToArray();
                var projFilePath = projPath.Substring(0, projPath.LastIndexOf("\\") + 1) + (string.Join("\\", createdHierarchy));
                populateViewTab(projFilePath);
            }
            else if (contentNotFoundIdx != -1)
            {
                var      foundTVI     = (dynamic)viewChildElements;
                string[] projPathArr  = createdHierarchy.Take(contentNotFoundIdx).ToArray();
                var      projFilePath = projPath.Substring(0, projPath.LastIndexOf("\\") + 1) + (string.Join("\\", projPathArr));
                if (isFile && (contentNotFoundIdx == createdHierarchy.Count() - 1))
                {
                    projFilePath = Path.GetDirectoryName(fullPath);
                    TreeViewItem item = createTreeItem(projFilePath, createdHierarchy[createdHierarchy.Count() - 1], true);
                    foundTVI.Items.Remove(item);
                    foundTVI.Items.Add(item);
                }
                else
                {
                    if (foundTVI is TreeView)
                    {
                        TreeView tv = foundTVI as TreeView;
                        tv.Items.Clear();
                        createResourceViewTreeHeader(projFilePath, tv);
                    }
                    else
                    {
                        TreeViewItem tvi = foundTVI;
                        tvi.Items.Clear();
                        createResourceViewTree(projFilePath, tvi);
                    }
                }
            }
        }