예제 #1
0
 public void SetValueString(string value)
 {
     if (string.IsNullOrEmpty(value))
     {
         _value = null;
     }
     else
     {
         if (value[0] == '[' && value[value.Length - 1] == ']')
         {
             string s = value.Substring(1);
             s = s.Substring(0, s.Length - 1);
             string[] ss = s.Split(',');
             _value = new IJavascriptType[ss.Length];
             for (int i = 0; i < ss.Length; i++)
             {
                 _value[i] = WebClientData.FromString(ss[i]);
                 JsString jss = _value[i] as JsString;
                 if (jss != null)
                 {
                     jss.SetValueString(jss.GetValueString().Replace(COMMACODE, ","));
                 }
             }
         }
         else
         {
             IJavascriptType js = WebClientData.FromString(value);
             _value    = new IJavascriptType[1];
             _value[0] = js;
         }
     }
 }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (edSvc != null)
         {
             VplPropertyBag ps = context.Instance as VplPropertyBag;
             if (ps != null)
             {
                 StringCollection names = new StringCollection();
                 for (int i = 0; i < ps.Count; i++)
                 {
                     names.Add(ps[i].Name);
                 }
                 DlgNewTypedNamedValue dlg = new DlgNewTypedNamedValue();
                 dlg.LoadData(names, "Define Javascript variable", null, WebClientData.GetJavascriptTypes(), false);
                 if (edSvc.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK)
                 {
                     ps.AddValue(dlg.DataName, dlg.DataType);
                     IDevClassReferencer dcr = ps.Owner as IDevClassReferencer;
                     if (dcr != null)
                     {
                         IDevClass dc = dcr.GetDevClass();
                         if (dc != null)
                         {
                             dc.NotifyChange(dcr, context.PropertyDescriptor.Name);
                         }
                     }
                 }
             }
         }
     }
     return(value);
 }
 public DlgWebClientVariable()
 {
     InitializeComponent();
     _types = WebClientData.GetJavascriptTypes();
     foreach (string s in _types.Keys)
     {
         listBox1.Items.Add(s);
     }
 }