Exemple #1
0
        private void AddDataProvider(plyTextInputWiz wiz)
        {
            string text = wiz.text;

            wiz.Close();
            if (string.IsNullOrEmpty(text))
            {
                this.isNewlyCreated    = true;
                this.bind.dataprovider = DataProviderEd.CreateDataprovider <plyVarDataProvider>("", this.isForSetter);
                plyEdUtil.SetDirty(this.bindOwner);
                this.CreateProviderEd();
            }
            else if (this.NameIsUniqueInDefined(text))
            {
                this.isNewlyCreated    = true;
                this.bind.dataprovider = DataProviderEd.CreateDataprovider <plyVarDataProvider>(text, this.isForSetter);
                plyEdUtil.SetDirty(this.bindOwner);
                this.CreateProviderEd();
            }
            else
            {
                EditorUtility.DisplayDialog("Create", "The name must be unique.", "OK");
            }
            base.Repaint();
        }
Exemple #2
0
 private void DoDataProvider()
 {
     if (this.providerLabels == null)
     {
         base.Close();
         GUIUtility.ExitGUI();
     }
     else
     {
         if (this.isNewlyCreated)
         {
             EditorGUI.BeginChangeCheck();
             this.providerIdx = EditorGUILayout.Popup(DataBindingWindow.GC_Space, this.providerIdx, this.providerLabels);
             if (EditorGUI.EndChangeCheck())
             {
                 string ident = this.bind.dataprovider.ident;
                 DataProviderEd.DestroyDataprovider(this.bind.dataprovider);
                 this.providerEd        = DataProviderEd.factory.CreateEditor(this.providerLabels[this.providerIdx].text);
                 this.bind.dataprovider = DataProviderEd.CreateDataprovider(this.providerEd.nfo.TargetType, ident, this.isForSetter);
                 plyEdUtil.SetDirty(this.bindOwner);
             }
         }
         else
         {
             GUI.enabled = false;
             EditorGUILayout.Popup(DataBindingWindow.GC_Space, this.providerIdx, this.providerLabels);
             GUI.enabled = true;
         }
         DataBindingWindow.GC_Text.text = BloxEd.PrettyTypeName(this.bind.dataprovider.DataType(), !this.isForSetter);
         EditorGUILayout.LabelField(DataBindingWindow.GC_Space, DataBindingWindow.GC_Text);
         if (this.providerEd != null)
         {
             Rect rect = GUILayoutUtility.GetRect(0f, (float)(this.providerEd.EditorHeight(this.bind.dataprovider, this.isForSetter) + 10.0), GUILayout.ExpandWidth(true));
             rect.x      += 5f;
             rect.width  -= 10f;
             rect.y      += 10f;
             rect.height -= 10f;
             this.providerEd.DrawEditor(rect, this.bind.dataprovider, this.isForSetter);
             base.Repaint();
         }
     }
 }
 public static T CreateDataprovider <T>(string ident, bool isSetter) where T : DataProvider
 {
     return((T)DataProviderEd.CreateDataprovider(typeof(T), ident, isSetter));
 }