Datei: SimpleMappingTool/NDOTreeNode.cs
Last Commit (2ee4f7f)
| 1 | // |
| 2 | // Copyright (c) 2002-2016 Mirko Matytschak |
| 3 | // (www.netdataobjects.de) |
| 4 | // |
| 5 | // Author: Mirko Matytschak |
| 6 | // |
| 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
| 8 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
| 9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
| 10 | // Software, and to permit persons to whom the Software is furnished to do so, subject to the following |
| 11 | // conditions: |
| 12 | |
| 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions |
| 14 | // of the Software. |
| 15 | // |
| 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
| 17 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 19 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 20 | // DEALINGS IN THE SOFTWARE. |
| 21 | |
| 22 | |
| 23 | using System; |
| 24 | using System.Collections; |
| 25 | using System.Windows.Forms; |
| 26 | using NDO; |
| 27 | using NDO.Mapping; |
| 28 | |
| 29 | namespace SimpleMappingTool |
| 30 | { |
| 31 | ····/// <summary> |
| 32 | ····/// Zusammenfassung für NDOTreeNode. |
| 33 | ····/// </summary> |
| 34 | ····internal class NDOTreeNode : TreeNode |
| 35 | ····{ |
| 36 | protected object o; |
| 37 | public object Object |
| 38 | ········{ |
| 39 | ············get { return o; } |
| 40 | ············set { o = value; } |
| 41 | ········} |
| 42 | public NDOTreeNode( string s, object o) : base ( s) |
| 43 | ········{ |
| 44 | ············this.o = o; |
| 45 | ············if (!(o is MappingNode)) // Base class of all NDO entities |
| 46 | ················return; |
| 47 | ············if (o is NDO.Mapping.Property)··// Properties don't have Properties |
| 48 | ················return; |
| 49 | ············foreach(DictionaryEntry de in ((MappingNode)o).Properties) |
| 50 | ············{ |
| 51 | this. Nodes. Add( new PropertyNode( this, ( Property) de. Value) ) ; |
| 52 | ············} |
| 53 | ········} |
| 54 | |
| 55 | public virtual ContextMenu GetContextMenu( ) |
| 56 | ········{ |
| 57 | ContextMenu menu = new ContextMenu( ) ; |
| 58 | if ( !( this is PropertyNode) ) |
| 59 | menu. MenuItems. Add( new MenuItem( "Add Property", new EventHandler( AddProperty) ) ) ; |
| 60 | menu. MenuItems. Add( new MenuItem( "Delete item", new EventHandler( DeleteItem) ) ) ; |
| 61 | ············return menu; |
| 62 | ········} |
| 63 | |
| 64 | protected virtual void DeleteItem( Object sender, EventArgs ea) |
| 65 | ········{ |
| 66 | ············((MappingNode)o).Remove(); |
| 67 | ············this.Remove(); |
| 68 | ········} |
| 69 | |
| 70 | |
| 71 | ········public void RemoveProperty(PropertyNode propNode) |
| 72 | ········{ |
| 73 | ············this.Nodes.Remove(propNode); |
| 74 | ············((MappingNode)this.o).RemoveProperty(propNode.Text); |
| 75 | ········} |
| 76 | |
| 77 | void AddProperty( object sender, EventArgs args) |
| 78 | ········{ |
| 79 | ············AddPropertyDialog dlg = new AddPropertyDialog(); |
| 80 | if ( dlg. ShowDialog( ) == DialogResult. OK) |
| 81 | ············{ |
| 82 | ················MappingNode mappingNode = (MappingNode)this.o; |
| 83 | ················Property prop = new Property(mappingNode, dlg.PropName, dlg.Type, dlg.Value); |
| 84 | ················mappingNode.AddProperty(prop); |
| 85 | ················this.Nodes.Add(new PropertyNode(this, prop)); |
| 86 | ············} |
| 87 | ········} |
| 88 | ····} |
| 89 | } |
| 90 |
New Commit (37eab6b)
| 1 | // |
| 2 | // Copyright (c) 2002-2016 Mirko Matytschak |
| 3 | // (www.netdataobjects.de) |
| 4 | // |
| 5 | // Author: Mirko Matytschak |
| 6 | // |
| 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
| 8 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
| 9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
| 10 | // Software, and to permit persons to whom the Software is furnished to do so, subject to the following |
| 11 | // conditions: |
| 12 | |
| 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions |
| 14 | // of the Software. |
| 15 | // |
| 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
| 17 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 19 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 20 | // DEALINGS IN THE SOFTWARE. |
| 21 | |
| 22 | |
| 23 | using System; |
| 24 | using System.Collections; |
| 25 | using System.Windows.Forms; |
| 26 | using NDO; |
| 27 | using NDO.Mapping; |
| 28 | |
| 29 | namespace SimpleMappingTool |
| 30 | { |
| 31 | ····/// <summary> |
| 32 | ····/// Zusammenfassung für NDOTreeNode. |
| 33 | ····/// </summary> |
| 34 | ····internal class NDOTreeNode : TreeNode |
| 35 | ····{ |
| 36 | protected object? o; |
| 37 | public object? Object |
| 38 | ········{ |
| 39 | ············get { return o; } |
| 40 | ············set { o = value; } |
| 41 | ········} |
| 42 | public NDOTreeNode( string s, object? o) : base ( s) |
| 43 | ········{ |
| 44 | ············this.o = o; |
| 45 | ············if (!(o is MappingNode)) // Base class of all NDO entities |
| 46 | ················return; |
| 47 | ············if (o is NDO.Mapping.Property)··// Properties don't have Properties |
| 48 | ················return; |
| 49 | ············foreach(DictionaryEntry de in ((MappingNode)o).Properties) |
| 50 | ············{ |
| 51 | this. Nodes. Add( new PropertyNode( this, ( Property?) de. Value) ) ; |
| 52 | ············} |
| 53 | ········} |
| 54 | |
| 55 | public virtual ContextMenuStrip GetContextMenu( ) |
| 56 | ········{ |
| 57 | var menu = new ContextMenuStrip( ) ; |
| 58 | if ( !( this is PropertyNode ) ) |
| 59 | menu. Items. Add( new ToolStripMenuItem( "Add Property", null, AddProperty ) ) ; |
| 60 | menu. Items. Add( new ToolStripMenuItem( "Delete item", null, DeleteItem) ) ; |
| 61 | ············return menu; |
| 62 | ········} |
| 63 | |
| 64 | protected virtual void DeleteItem( object? sender, EventArgs ea) |
| 65 | ········{ |
| 66 | ············if (o != null) |
| 67 | ················((MappingNode)o).Remove(); |
| 68 | ············this.Remove(); |
| 69 | ········} |
| 70 | |
| 71 | |
| 72 | ········public void RemoveProperty(PropertyNode propNode) |
| 73 | ········{ |
| 74 | ············this.Nodes.Remove(propNode); |
| 75 | ············if (o != null) |
| 76 | ················((MappingNode)this.o).RemoveProperty(propNode.Text); |
| 77 | ········} |
| 78 | |
| 79 | void AddProperty( object? sender, EventArgs args) |
| 80 | ········{ |
| 81 | ············AddPropertyDialog dlg = new AddPropertyDialog(); |
| 82 | if ( dlg. ShowDialog( ) == DialogResult. OK && this. o != null) |
| 83 | ············{ |
| 84 | ················MappingNode mappingNode = (MappingNode)this.o; |
| 85 | ················Property prop = new Property(mappingNode, dlg.PropName, dlg.Type, dlg.Value); |
| 86 | ················mappingNode.AddProperty(prop); |
| 87 | ················this.Nodes.Add(new PropertyNode(this, prop)); |
| 88 | ············} |
| 89 | ········} |
| 90 | ····} |
| 91 | } |
| 92 |