Esempio n. 1
0
	/// <summary>
	/// Adds templates to File -> New.
	/// </summary>
	public void ZFillMenuNew(ToolStripDropDownMenu ddm)
	{
		if(_newMenuDone) return; _newMenuDone = true;

		var templDir = FileNode.Templates.DefaultDirBS;
		var xroot = AExtXml.LoadElem(FileNode.Templates.DefaultFilesXml);

		_CreateMenu(ddm, xroot, null, 0);

		void _CreateMenu(ToolStripDropDownMenu ddParent, XElement xParent, string dir, int level)
		{
			ddParent.SuspendLayout();
			int i = level == 0 ? 4 : 0;
			foreach(var x in xParent.Elements()) {
				string tag = x.Name.LocalName, name = x.Attr("n");
				int isFolder = tag == "d" ? 1 : 0;
				if(isFolder == 1) {
					isFolder = name[0] switch { '@' => 2, '!' => 3, _ => 1 }; //@ project, ! simple folder
				} else {
					if(level == 0 && FileNode.Templates.IsStandardTemplateName(name, out _)) continue;
				}
				string relPath = dir + name;
				if(isFolder == 3) name = name[1..];
				var item = new ToolStripMenuItem(name, null, (unu, sed) => ZModel.NewItem(relPath, beginRenaming: true));
				if(isFolder == 1) {
					var ddSub = new ToolStripDropDownMenu();
					item.DropDown = ddSub;
					_CreateMenu(ddSub, x, dir + name + "\\", level + 1);
				} else {
					string si = null;
					if(isFolder != 0) si = nameof(Au.Editor.Resources.Resources.folder);
					else if(tag == "s") si = nameof(Au.Editor.Resources.Resources.fileScript);
					else if(tag == "c") si = nameof(Au.Editor.Resources.Resources.fileClass);
					Bitmap im = si != null
						? EdResources.GetImageUseCache(si)
						: FileNode.IconCache.GetImage(templDir + relPath, useExt: true);
					if(im != null) item.Image = im;
				}
				ddParent.Items.Insert(i++, item);
			}
Esempio n. 2
0
 public Image GetImage(string imageName)
 {
     return(EdResources.GetImageUseCache(imageName));
 }