private void buttonOK_Click(object sender, EventArgs e)
 {
     if (_designers != null)
     {
         VisualProgrammingDesigner.SaveDesigners(_designers);
         this.DialogResult = DialogResult.OK;
     }
 }
Esempio n. 2
0
 public static bool DesignerEnabled(Type t)
 {
     if (_designers.ContainsKey(t.FullName))
     {
         VisualProgrammingDesigner d = _designers[t.FullName];
         return(d.Enabled);
     }
     return(true);
 }
 public void LoadData(List <Type> builtinDesgners)
 {
     _designers = VisualProgrammingDesigner.LoadDesigners(builtinDesgners);
     listView1.Items.Clear();
     foreach (VisualProgrammingDesigner p in _designers.Values)
     {
         addItem(p);
     }
 }
Esempio n. 4
0
 public static bool DesignerBuiltIn(Type t)
 {
     if (_buildinNames.Contains(t.FullName))
     {
         return(true);
     }
     if (_designers.ContainsKey(t.FullName))
     {
         VisualProgrammingDesigner d = _designers[t.FullName];
         return(!d.CanRemove);
     }
     return(false);
 }
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         OpenFileDialog dlg = new OpenFileDialog();
         dlg.Title  = "Select Visual Programming System";
         dlg.Filter = "*.DLL|*.DLL";
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             string   file = dlg.FileName;
             Assembly a    = Assembly.LoadFile(file);
             Type[]   tps  = a.GetExportedTypes();
             if (tps != null && tps.Length > 0)
             {
                 for (int i = 0; i < tps.Length; i++)
                 {
                     Type[] tis = tps[i].FindInterfaces(findInterface, null);
                     if (tis != null && tis.Length > 0)
                     {
                         object[] ats  = tps[i].GetCustomAttributes(typeof(DescriptionAttribute), true);
                         string   desc = "";
                         if (ats != null && ats.Length > 0)
                         {
                             DescriptionAttribute da = (DescriptionAttribute)ats[0];
                             desc = da.Description;
                         }
                         VisualProgrammingDesigner vp = new VisualProgrammingDesigner(tps[i].AssemblyQualifiedName, file, true, desc);
                         if (_designers == null)
                         {
                             _designers = new Dictionary <string, VisualProgrammingDesigner>();
                         }
                         if (!_designers.ContainsKey(vp.Name))
                         {
                             _designers.Add(vp.Name, vp);
                             addItem(vp);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message);
     }
 }
        private void addItem(VisualProgrammingDesigner p)
        {
            ListViewItem lv = listView1.Items.Add(p.Name);

            lv.Name = p.Name;
            if (p.Enabled)
            {
                lv.ImageIndex = IMG_Checked;
            }
            else
            {
                lv.ImageIndex = IMG_Unchecked;
            }
            lv.SubItems.Add(p.Enabled.ToString());
            lv.SubItems.Add(p.Description);
            lv.SubItems.Add(p.File);
        }
 private void buttonEnable_Click(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count > 0)
     {
         if (_designers != null)
         {
             if (_designers.ContainsKey(listView1.SelectedItems[0].Name))
             {
                 VisualProgrammingDesigner p = _designers[listView1.SelectedItems[0].Name];
                 p.Enabled = !p.Enabled;
                 if (p.Enabled)
                 {
                     listView1.SelectedItems[0].ImageIndex = IMG_Checked;
                 }
                 else
                 {
                     listView1.SelectedItems[0].ImageIndex = IMG_Unchecked;
                 }
             }
         }
     }
 }
Esempio n. 8
0
        public static Dictionary <string, VisualProgrammingDesigner> LoadDesigners(List <Type> builtinDesgners)
        {
            Dictionary <string, VisualProgrammingDesigner> ret = new Dictionary <string, VisualProgrammingDesigner>();
            string f = vplFile;

            if (System.IO.File.Exists(f))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(f);
                if (doc.DocumentElement != null)
                {
                    PropertyBag list  = new PropertyBag();
                    XmlNodeList nlist = doc.DocumentElement.SelectNodes(string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                                                                      "{0}/{1}",
                                                                                      XmlTags.XML_VPList, XmlTags.XML_Item));
                    if (nlist != null && nlist.Count > 0)
                    {
                        foreach (XmlNode node in nlist)
                        {
                            Dictionary <string, string> props = new Dictionary <string, string>();
                            foreach (XmlAttribute xa in node.Attributes)
                            {
                                props.Add(xa.Name, xa.Value);
                            }
                            list.Add(props);
                        }
                    }
                    foreach (Dictionary <string, string> ls in list)
                    {
                        VisualProgrammingDesigner r = VisualProgrammingDesigner.CreateDesigner(ls);
                        if (r != null)
                        {
                            if (!ret.ContainsKey(r.Name))
                            {
                                ret.Add(r.Name, r);
                            }
                        }
                    }
                }
            }
            foreach (Type t in builtinDesgners)
            {
                VisualProgrammingDesigner v;
                if (ret.ContainsKey(t.FullName))
                {
                    v = ret[t.FullName];
                }
                else
                {
                    string   desc;
                    object[] a = t.GetCustomAttributes(typeof(DescriptionAttribute), true);
                    if (a != null && a.Length > 0)
                    {
                        desc = ((DescriptionAttribute)a[0]).Description;
                    }
                    else
                    {
                        desc = t.FullName;
                    }
                    v = new VisualProgrammingDesigner(t.FullName, t.Assembly.Location, true, desc);
                    ret.Add(t.FullName, v);
                }
                v.CanRemove = false;
            }
            _designers = ret;
            return(ret);
        }