コード例 #1
0
ファイル: OutputForm.cs プロジェクト: leexioua2/js-builder
        public OutputForm(Target t)
        {
			Project p = Project.GetInstance();
			InitializeComponent();
			files.BeginUpdate();

			if (t == null)
			{
				this.target = new Target("New Target", "$output\\target.js", new List<string>());
				this.originalName = "";
			}
			else
			{
				this.target = t;
				this.originalName = target.Name;
			}
            
            List<FileInfo> selFiles = p.SelectedFiles;
            ListViewItem[] incItems = new ListViewItem[target.Includes.Count];

            foreach(FileInfo sf in selFiles)
            {
                string name = p.GetPath(sf.FullName);
                int index = target.Includes.IndexOf(name);
                if(index != -1)
                {
                    (incItems[index] = new ListViewItem(new string[] { sf.Name, sf.FullName }, 9)).Name = name;
                }
                else
                {
                    ListViewItem li = files.Items.Add(name, sf.Name, 9);
                    li.SubItems.Add(sf.FullName);
                }
            }
            incs.BeginUpdate();
            foreach(ListViewItem li in incItems)
            {
                if(li != null)
                    incs.Items.Add(li);
            }
            incs.EndUpdate();

            files.EndUpdate();
            txtName.DataBindings.Add("Text", target, "Name");
            txtFile.DataBindings.Add("Text", target, "File");
            cbWrap.DataBindings.Add("Checked", target, "Shorthand");
            txtList.DataBindings.Add("Text", target, "ShorthandList");
            debug.DataBindings.Add("Checked", target, "Debug");

            if(t == null)
            {
                FileInfo fi = new FileInfo(new FileInfo(Application.ExecutablePath).Directory.FullName + "\\shorthand.txt");
                if(fi.Exists)
                {
                    StreamReader sr = new StreamReader(fi.FullName);
                    this.target.ShorthandList = sr.ReadToEnd();
                    sr.Close();
                }
            }
        }
コード例 #2
0
ファイル: Project.cs プロジェクト: leexioua2/js-builder
 public Target GetTarget(string name)
 {
     XmlElement node = (XmlElement)root.SelectSingleNode("target[@name='" + name + "']");
     if(node != null)
     {
         Target t = new Target(node.GetAttribute("name"), node.GetAttribute("file"), null);
         t.Debug = "True".Equals(node.GetAttribute("debug"));
         t.Shorthand = "True".Equals(node.GetAttribute("shorthand"));
         t.ShorthandList = node.GetAttribute("shorthand-list");
         XmlNodeList incs = node.GetElementsByTagName("include");
         foreach(XmlNode inc in incs)
         {
             string iname = inc.Attributes.GetNamedItem("name").Value;
             if(IsSelected(iname))
             {
                 t.Add(iname);
             }
         }
         return t;
     }
     return null;
 }
コード例 #3
0
ファイル: Project.cs プロジェクト: leexioua2/js-builder
 public List<Target> GetTargets(bool loadIncs)
 {
     List<Target> results = new List<Target>();
     XmlNodeList targets = root.GetElementsByTagName("target");
     foreach(XmlElement node in targets)
     {
         Target t = new Target(node.GetAttribute("name"), node.GetAttribute("file"), null);
         t.Debug = "True".Equals(node.GetAttribute("debug"));
         t.Shorthand = "True".Equals(node.GetAttribute("shorthand"));
         t.ShorthandList = node.GetAttribute("shorthand-list");
         if(loadIncs)
         {
             XmlNodeList incs = node.GetElementsByTagName("include");
             foreach(XmlNode inc in incs)
             {
                 string iname = inc.Attributes.GetNamedItem("name").Value;
                 if(IsSelected(iname) && FileExists(iname))
                 {
                     t.Add(iname);
                 }
             }
         }
         results.Add(t);
     }
     return results;
 }
コード例 #4
0
ファイル: Project.cs プロジェクト: leexioua2/js-builder
 public bool AddTarget(Target t, string originalName)
 {
     XmlElement node = (XmlElement)root.SelectSingleNode("target[@name='" + originalName + "']");
     if(node == null)
     {
         XmlElement el = doc.CreateElement("target");
         el.SetAttribute("name", t.Name);
         el.SetAttribute("file", t.File);
         el.SetAttribute("debug", t.Debug.ToString());
         el.SetAttribute("shorthand", t.Shorthand.ToString());
         el.SetAttribute("shorthand-list", t.ShorthandList);
         root.AppendChild(el);
         foreach(string f in t.Includes)
         {
             XmlElement fe = doc.CreateElement("include");
             fe.SetAttribute("name", f);
             el.AppendChild(fe);
         }
         return true;
     }
     else
     {
         node.RemoveAll();
         node.SetAttribute("name", t.Name);
         node.SetAttribute("file", t.File);
         node.SetAttribute("debug", t.Debug.ToString());
         node.SetAttribute("shorthand", t.Shorthand.ToString());
         node.SetAttribute("shorthand-list", t.ShorthandList);
         foreach(string f in t.Includes)
         {
             XmlElement fe = doc.CreateElement("include");
             fe.SetAttribute("name", f);
             node.AppendChild(fe);
         }
         return true;
     }
 }