Example #1
0
 private void ContextMenu(Model instance)
 {
     var menu = new GenericMenu();
     menu.AddItem(new GUIContent("New"), false, New);
     if (instance != null) {
         menu.AddItem(new GUIContent("Edit"), false, ShowEditWindow, instance);
     } else {
         menu.AddDisabledItem(new GUIContent("Edit"));
     }
     menu.AddSeparator("");
     if (instance != null) {
         menu.AddItem(new GUIContent("Copy"), false, Copy, instance);
     } else {
         menu.AddDisabledItem(new GUIContent("Copy"));
     }
     if (CanPaste()) {
         menu.AddItem(new GUIContent("Paste"), false, Paste);
     } else {
         menu.AddDisabledItem(new GUIContent("Paste"));
     }
     if (instance != null) {
         menu.AddItem(new GUIContent("Delete"), false, Delete, instance);
     } else {
         menu.AddDisabledItem(new GUIContent("Delete"));
     }
     menu.ShowAsContext();
 }
Example #2
0
 private void Initialise(Model model)
 {
     PropertyInfo[] properties = model.GetType().GetProperties();
     foreach (PropertyInfo pi in properties) {
         if (!pi.CanWrite) {
             continue;
         }
         // get the value of the current property in the passed model
         var value = pi.GetValue(model, null);
         // set the value in the current model
         pi.SetValue(this, value, null);
     }
 }
Example #3
0
 public Model(Model model)
     : base()
 {
     Initialise(model);
 }
Example #4
0
        private void HandleRowSelection(Table.SelectionType t, Model instance)
        {
            if (t != Table.SelectionType.None) {
                _listHasFocus = false;
            }

            switch (t) {
                case Table.SelectionType.ContextSelect:
                    ContextMenu(instance);
                    break;
                case Table.SelectionType.ContextOutside:
                    ContextMenu(null);
                    break;
                case Table.SelectionType.Delete:
                    Delete(instance);
                    break;
                case Table.SelectionType.Select:
                    ShowEditWindow(instance);
                    break;
            }
        }