Пример #1
0
 public static string UTF8ArrayToString(byte[] b)
 {
     if (b.Length >= 3 && b[0] == 239 && b[1] == 187 && b[2] == 191) // UTF-8 chars
     {
         b = PyList.SliceFrom(b, 3);
     }
     return(Encoding.UTF8.GetString(b));
 }
Пример #2
0
 public MenuItemInfo FindOrCreateItem(string[] path)
 {
     if (path.Length == 0)
     {
         return(this);
     }
     if (!Items.ContainsKey(path[0]))
     {
         var newitem = new MenuItemInfo();
         newitem.Name   = path[0];
         Items[path[0]] = newitem;
         ItemsNaturalOrder.Add(newitem);
     }
     return(Items[path[0]].FindOrCreateItem(PyList.SliceFrom(path, 1)));
 }
Пример #3
0
        private TreeNode FindOrCreate(TreeNode parent, TreeNodeCollection parentNodes, string[] subpath, SettingsPageStruct page)
        {
            if (subpath.Length == 0)
            {
                return(parent);
            }
            //TreeNode[] childs = parentNodes.Find(Texts.Get(subpath[0]), false);
            TreeNode child = null;

            foreach (TreeNode n in parentNodes)
            {
                if (n.Text == Texts.Get(subpath[0]))
                {
                    child = n;
                    break;
                }
            }
            //if (childs.Length > 0) child = childs[0];
            if (child != null)
            {
                return(FindOrCreate(child, child.Nodes, PyList.SliceFrom(subpath, 1), page));
            }
            child = new TreeNode();
            if (page != null && page.Attribute.ImageName != null)
            {
                child.ImageIndex = m_imgCache.GetImageIndex(ImageTool.ImageFromName(page.Attribute.ImageName, CoreIcons.settings));
            }
            else
            {
                child.ImageIndex = m_imgCache.GetImageIndex(CoreIcons.settings);
            }
            child.SelectedImageIndex = child.ImageIndex;
            parentNodes.Add(child);
            child.Text = Texts.Get(subpath[0]);
            if (subpath.Length == 1)
            {
                child.Tag = page;
                if ((page.Attribute.Targets & Target) == 0)
                {
                    parentNodes.Remove(child);
                }
            }
            return(FindOrCreate(child, child.Nodes, PyList.SliceFrom(subpath, 1), page));
        }
Пример #4
0
        public static ICommandLineCommandInstance LoadCommand(string[] args)
        {
            if (args.Length < 1)
            {
                throw new CommandLineError("DAE-00260 Missing command parameter");
            }
            ICommandLineCommand cmd = FindCommand(args[0]);

            if (cmd != null)
            {
                ICommandLineCommandInstance res       = cmd.CreateInstance();
                Dictionary <string, string> extparams = null;
                if (cmd.AllowExtParams)
                {
                    extparams = new Dictionary <string, string>();
                }
                LoadParameters(PyList.SliceFrom(args, 1), new object[] { res }, extparams);
                res.ExtParams = extparams;
                return(res);
            }
            throw new CommandLineError("DAE-00261 Command not defined:" + args[0]);
        }