├── ChangeLog.txt ├── Makefile ├── Mono.Design.vpw ├── Prepare Visual Studio Build.bat ├── README.md ├── build ├── ICSharpCode.NRefactory.dll ├── Mono.Design.dll ├── Mono.Design.dll.mdb ├── mwf-designer.exe └── mwf-designer.exe.mdb ├── deps ├── ICSharpCode.NRefactory.dll ├── Mono.Design.dll ├── Mono.Design.dll.mdb └── Mono.Design │ ├── .generated │ ├── Makefile │ ├── Mono.Design.csproj │ ├── Mono.Design.sources │ ├── Mono.Design.vpj │ ├── build │ └── common │ │ ├── Consts.cs.in │ │ └── MonoTODOAttribute.cs │ ├── class │ ├── System.Design │ │ ├── System.ComponentModel.Design.Serialization │ │ │ ├── BasicDesignerLoader.cs │ │ │ ├── CodeDomComponentSerializationService.cs │ │ │ ├── CodeDomComponentSerializationService.cs.orig │ │ │ ├── CodeDomDesignerLoader.cs │ │ │ ├── CodeDomSerializationProvider.cs │ │ │ ├── CodeDomSerializer.cs │ │ │ ├── CodeDomSerializerBase.cs │ │ │ ├── CodeDomSerializerBase.cs.orig │ │ │ ├── CollectionCodeDomSerializer.cs │ │ │ ├── ComponentCodeDomSerializer.cs │ │ │ ├── DesignerSerializationManager.cs │ │ │ ├── DesignerSerializationManager.cs.orig │ │ │ ├── EnumCodeDomSerializer.cs │ │ │ ├── EventCodeDomSerializer.cs │ │ │ ├── ExpressionContext.cs │ │ │ ├── MemberCodeDomSerializer.cs │ │ │ ├── ObjectStatementCollection.cs │ │ │ ├── PrimitiveCodeDomSerializer.cs │ │ │ ├── PropertyCodeDomSerializer.cs │ │ │ ├── RootCodeDomSerializer.cs │ │ │ ├── RootContext.cs │ │ │ ├── SerializeAbsoluteContext.cs │ │ │ ├── StatementContext.cs │ │ │ └── TypeCodeDomSerializer.cs │ │ ├── System.ComponentModel.Design │ │ │ ├── ActiveDesignSurfaceChangedEventArgs.cs │ │ │ ├── ActiveDesignSurfaceChangedEventHandler.cs │ │ │ ├── ComponentDesigner.cs │ │ │ ├── DesignModeNestedContainer.cs │ │ │ ├── DesignModeSite.cs │ │ │ ├── DesignSurface.cs │ │ │ ├── DesignSurfaceCollection.cs │ │ │ ├── DesignSurfaceEventArgs.cs │ │ │ ├── DesignSurfaceEventHandler.cs │ │ │ ├── DesignSurfaceManager.cs │ │ │ ├── DesignSurfaceServiceContainer.cs │ │ │ ├── DesignerActionListCollection.cs │ │ │ ├── DesignerEventService.cs │ │ │ ├── DesignerHost.cs │ │ │ ├── DesignerHost.cs.orig │ │ │ ├── EventBindingService.cs │ │ │ ├── ExtenderService.cs │ │ │ ├── LoadedEventArgs.cs │ │ │ ├── LoadedEventHandler.cs │ │ │ ├── MenuCommandService.cs │ │ │ ├── ReferenceService.cs │ │ │ ├── SelectionService.cs │ │ │ ├── TypeDescriptorFilterService.cs │ │ │ └── UndoEngine.cs │ │ └── System.Windows.Forms.Design │ │ │ ├── ComponentTray.cs │ │ │ ├── ControlCodeDomSerializer.cs │ │ │ ├── ControlCollectionCodeDomSerializer.cs │ │ │ ├── ControlDataObject.cs │ │ │ ├── ControlDesigner.cs │ │ │ ├── DefaultMenuCommands.cs │ │ │ ├── DocumentDesigner.cs │ │ │ ├── FormDocumentDesigner.cs │ │ │ ├── IMessageReceiver.cs │ │ │ ├── IUISelectionService.cs │ │ │ ├── Native.cs │ │ │ ├── Native.cs.orig │ │ │ ├── Native.cs.rej │ │ │ ├── PanelDesigner.cs │ │ │ ├── ParentControlDesigner.cs │ │ │ ├── ScrollableControlDesigner.cs │ │ │ ├── SelectionFrame.cs │ │ │ ├── SplitContainerDesigner.cs │ │ │ ├── UISelectionService.cs │ │ │ └── WndProcRouter.cs │ └── System │ │ ├── System.ComponentModel.Design.Serialization │ │ ├── ComponentSerializationService.cs │ │ ├── DefaultSerializationProviderAttribute.cs │ │ ├── MemberRelationshipService.cs │ │ └── SerializationStore.cs │ │ ├── System.ComponentModel.Design │ │ ├── AssemblyRef.cs │ │ ├── DesignerOptionService.cs │ │ ├── IComponentInitializer.cs │ │ ├── ITreeDesigner.cs │ │ └── SR.cs │ │ └── System.ComponentModel │ │ ├── INestedContainer.cs │ │ ├── INestedSite.cs │ │ └── NestedContainer.cs │ ├── generate-mono-design.py │ ├── obj │ └── Debug │ │ ├── .NETFramework,Version=v4.5.AssemblyAttribute.cs │ │ ├── Mono.Design.csproj.FilesWrittenAbsolute.txt │ │ ├── Mono.Design.dll │ │ └── Mono.Design.dll.mdb │ └── patches │ ├── CodeDomComponentSerializationService-error-reporting.patch │ ├── CodeDomSerializerBase-msnet-extenderproperty-fix.patch │ ├── DesignerHost-designer-type-replacement.patch │ ├── DesignerSerializationManager-serializer-type-replacement.patch │ ├── Native-win32 (复件).patch │ ├── Native.patch │ └── patch.exe ├── docs ├── LICENSE.txt ├── README.txt └── WinForms Designer.pdf ├── mwf-designer.csproj ├── mwf-designer.sln ├── mwf-designer.userprefs ├── mwf-designer.vpj ├── obj └── Debug │ ├── .NETFramework,Version=v4.5.AssemblyAttribute.cs │ ├── mwf-designer.csproj.FilesWrittenAbsolute.txt │ ├── mwf-designer.exe │ └── mwf-designer.exe.mdb └── src ├── AssemblyInfo.cs ├── DesignTime ├── CodeProvider.cs ├── CodeProviderDesignerLoader.cs ├── CodeProviderEventBindingService.cs ├── ToolboxFiller.cs ├── TypeResolutionService.cs └── UndoRedoEngine.cs ├── Program.cs ├── Project ├── Document.cs ├── References.cs ├── TemplateManager.cs └── Workspace.cs └── UI ├── ErrorList.Designer.cs ├── ErrorList.cs ├── ErrorListTabPage.cs ├── MainView.Designer.cs ├── MainView.cs ├── NewFileDialog.Designer.cs ├── NewFileDialog.cs ├── PropertyGrid.Designer.cs ├── PropertyGrid.cs ├── ReferencesDialog.Designer.cs ├── ReferencesDialog.cs └── ToolBoxList ├── ToolBoxGroupHeader.cs ├── ToolBoxGroupPanel.cs ├── ToolBoxList.cs └── ToolBoxListItem.cs /Makefile: -------------------------------------------------------------------------------- 1 | SOURCES=src/*.cs src/*/*.cs src/*/*/*.cs 2 | BUILD_DIR=build 3 | DEPS_DIR = deps 4 | DEPS = ${DEPS_DIR}/*.dll 5 | DIST_DIR = ${BUILD_DIR}/mwf-designer-dist 6 | MD_DIST_DIR = ${MD_BUILD_DIR}/mwf-designer 7 | ASSEMBLY=mwf-designer.exe 8 | REFERENCES=System.Design,System.Windows.Forms,System.Drawing,System.Data,${DEPS_DIR}/ICSharpCode.NRefactory.dll 9 | 10 | all: ${BUILD_DIR}/${ASSEMBLY} 11 | 12 | ${BUILD_DIR}/${ASSEMBLY}: ${SOURCES} 13 | mkdir -p ${BUILD_DIR} 14 | MCS_COLORS=disable mcs -debug -r:${REFERENCES} -out:${BUILD_DIR}/${ASSEMBLY} ${SOURCES} 15 | 16 | run: all 17 | cp ${DEPS_DIR}/*.dll ${BUILD_DIR} 18 | cp ${DEPS_DIR}/*.mdb ${BUILD_DIR} || true 19 | mono --debug ${BUILD_DIR}/mwf-designer.exe 20 | 21 | mono-design: all 22 | cd ${DEPS_DIR}/Mono.Design && make 23 | export MCS_COLORS=disable;mcs -debug -r:${REFERENCES},${DEPS_DIR}/Mono.Design.dll -out:${BUILD_DIR}/${ASSEMBLY} ${SOURCES} 24 | 25 | mono-design-update: 26 | cd ${DEPS_DIR}/Mono.Design && make update 27 | -------------------------------------------------------------------------------- /Mono.Design.vpw: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Prepare Visual Studio Build.bat: -------------------------------------------------------------------------------- 1 | cd deps\Mono.Design && generate-mono-design.py 2 | pause -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mono.winform.designer 2 | mono winform designer 3 | 4 | mono 下 winform 设计时 类库,可以拖拽控件,具体使用说明待续。。。 5 | 6 | ![1](http://www.mono-project.com/archived/images/d/df/Mwf-designer.png) 7 | ![2](http://www.mono-project.com/archived/images/d/dd/Mwf-designer-win32.png) 8 | -------------------------------------------------------------------------------- /build/ICSharpCode.NRefactory.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/build/ICSharpCode.NRefactory.dll -------------------------------------------------------------------------------- /build/Mono.Design.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/build/Mono.Design.dll -------------------------------------------------------------------------------- /build/Mono.Design.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/build/Mono.Design.dll.mdb -------------------------------------------------------------------------------- /build/mwf-designer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/build/mwf-designer.exe -------------------------------------------------------------------------------- /build/mwf-designer.exe.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/build/mwf-designer.exe.mdb -------------------------------------------------------------------------------- /deps/ICSharpCode.NRefactory.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/deps/ICSharpCode.NRefactory.dll -------------------------------------------------------------------------------- /deps/Mono.Design.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/deps/Mono.Design.dll -------------------------------------------------------------------------------- /deps/Mono.Design.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/deps/Mono.Design.dll.mdb -------------------------------------------------------------------------------- /deps/Mono.Design/.generated: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/deps/Mono.Design/.generated -------------------------------------------------------------------------------- /deps/Mono.Design/Makefile: -------------------------------------------------------------------------------- 1 | SOURCES=`cat Mono.Design.sources` 2 | BUILD_DIR=.. 3 | ASSEMBLY=${BUILD_DIR}/Mono.Design.dll 4 | REFERENCES=System.Design,System.Windows.Forms,System.Drawing 5 | 6 | all: generate-md net-2 7 | 8 | net-2: 9 | export MCS_COLORS=disable;mcs -d:NET_4_5,DEBUG -target:library -debug -r:${REFERENCES} -out:${ASSEMBLY} ${SOURCES} 10 | 11 | net-1: 12 | export MCS_COLORS=disable;mcs -d:DEBUG,NET_1_1 -t:library -debug -r:${REFERENCES} -out:${ASSEMBLY} ${SOURCES} 13 | 14 | clean: 15 | rm -f .generated 16 | 17 | update: clean 18 | make generate-md 19 | 20 | generate-md: 21 | ifeq (,$(findstring .generated,$(wildcard .*))) 22 | python generate-mono-design.py 23 | touch .generated 24 | endif 25 | -------------------------------------------------------------------------------- /deps/Mono.Design/build/common/MonoTODOAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | // MonoTODOAttribute.cs 3 | // 4 | // Authors: 5 | // Ravi Pratap (ravi@ximian.com) 6 | // Eyal Alaluf 7 | // 8 | // (C) Ximian, Inc. http://www.ximian.com 9 | // 10 | 11 | // 12 | // Copyright (C) 2004 Novell, Inc (http://www.novell.com) 13 | // Copyright (C) 2006 Mainsoft, Inc (http://www.mainsoft.com) 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining 16 | // a copy of this software and associated documentation files (the 17 | // "Software"), to deal in the Software without restriction, including 18 | // without limitation the rights to use, copy, modify, merge, publish, 19 | // distribute, sublicense, and/or sell copies of the Software, and to 20 | // permit persons to whom the Software is furnished to do so, subject to 21 | // the following conditions: 22 | // 23 | // The above copyright notice and this permission notice shall be 24 | // included in all copies or substantial portions of the Software. 25 | // 26 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 28 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 30 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 31 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 32 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 | // 34 | 35 | using System; 36 | namespace Mono.Design { 37 | #pragma warning disable 436 38 | [AttributeUsage (AttributeTargets.All, AllowMultiple=true)] 39 | internal class MonoTODOAttribute : Attribute { 40 | 41 | string comment; 42 | 43 | public MonoTODOAttribute () 44 | { 45 | } 46 | 47 | public MonoTODOAttribute (string comment) 48 | { 49 | this.comment = comment; 50 | } 51 | 52 | public string Comment { 53 | get { return comment; } 54 | } 55 | } 56 | 57 | [AttributeUsage (AttributeTargets.All, AllowMultiple=true)] 58 | internal class MonoDocumentationNoteAttribute : MonoTODOAttribute { 59 | 60 | public MonoDocumentationNoteAttribute (string comment) 61 | : base (comment) 62 | { 63 | } 64 | } 65 | 66 | [AttributeUsage (AttributeTargets.All, AllowMultiple=true)] 67 | internal class MonoExtensionAttribute : MonoTODOAttribute { 68 | 69 | public MonoExtensionAttribute (string comment) 70 | : base (comment) 71 | { 72 | } 73 | } 74 | 75 | [AttributeUsage (AttributeTargets.All, AllowMultiple=true)] 76 | internal class MonoInternalNoteAttribute : MonoTODOAttribute { 77 | 78 | public MonoInternalNoteAttribute (string comment) 79 | : base (comment) 80 | { 81 | } 82 | } 83 | 84 | [AttributeUsage (AttributeTargets.All, AllowMultiple=true)] 85 | internal class MonoLimitationAttribute : MonoTODOAttribute { 86 | 87 | public MonoLimitationAttribute (string comment) 88 | : base (comment) 89 | { 90 | } 91 | } 92 | 93 | [AttributeUsage (AttributeTargets.All, AllowMultiple=true)] 94 | internal class MonoNotSupportedAttribute : MonoTODOAttribute { 95 | 96 | public MonoNotSupportedAttribute (string comment) 97 | : base (comment) 98 | { 99 | } 100 | } 101 | #pragma warning restore 436 102 | } 103 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design.Serialization/CodeDomSerializationProvider.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.Serialization.CodeDomSerializationProvider 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.Collections; 33 | using System.ComponentModel; 34 | using System.ComponentModel.Design; 35 | 36 | using System.CodeDom; 37 | 38 | using System.ComponentModel.Design.Serialization; 39 | namespace Mono.Design 40 | { 41 | // Added as a provider by the RootCodeDomSerializationProvider 42 | // 43 | internal class CodeDomSerializationProvider : IDesignerSerializationProvider 44 | { 45 | 46 | private static CodeDomSerializationProvider _instance = null; 47 | 48 | public static CodeDomSerializationProvider Instance { 49 | get { 50 | if (_instance == null) 51 | _instance = new CodeDomSerializationProvider (); 52 | return _instance; 53 | } 54 | } 55 | 56 | public CodeDomSerializationProvider () 57 | { 58 | _componentSerializer = new ComponentCodeDomSerializer (); 59 | _propertySerializer = new PropertyCodeDomSerializer (); 60 | _eventSerializer = new EventCodeDomSerializer (); 61 | _collectionSerializer = new CollectionCodeDomSerializer (); 62 | _primitiveSerializer = new PrimitiveCodeDomSerializer (); 63 | _rootSerializer = new RootCodeDomSerializer (); 64 | _enumSerializer = new EnumCodeDomSerializer (); 65 | _othersSerializer = new CodeDomSerializer (); 66 | } 67 | 68 | private CodeDomSerializerBase _componentSerializer; 69 | private CodeDomSerializerBase _propertySerializer; 70 | private CodeDomSerializerBase _eventSerializer; 71 | private CodeDomSerializerBase _primitiveSerializer; 72 | private CodeDomSerializerBase _collectionSerializer; 73 | private CodeDomSerializerBase _rootSerializer; 74 | private CodeDomSerializerBase _enumSerializer; 75 | private CodeDomSerializerBase _othersSerializer; 76 | 77 | public object GetSerializer (IDesignerSerializationManager manager, object currentSerializer, 78 | Type objectType, Type serializerType) 79 | { 80 | CodeDomSerializerBase serializer = null; 81 | 82 | if (serializerType == typeof(CodeDomSerializer)) { // CodeDomSerializer 83 | if (objectType == null) // means that value to serialize is null CodePrimitiveExpression (null) 84 | serializer = _primitiveSerializer; 85 | else if (typeof(IComponent).IsAssignableFrom (objectType)) 86 | serializer = _componentSerializer; 87 | else if (objectType.IsEnum || typeof (Enum).IsAssignableFrom (objectType)) 88 | serializer = _enumSerializer; 89 | else if (objectType.IsPrimitive || objectType == typeof (String)) 90 | serializer = _primitiveSerializer; 91 | else if (typeof(ICollection).IsAssignableFrom (objectType)) 92 | serializer = _collectionSerializer; 93 | else 94 | serializer = _othersSerializer; 95 | } else if (serializerType == typeof(MemberCodeDomSerializer)) { // MemberCodeDomSerializer 96 | if (typeof (PropertyDescriptor).IsAssignableFrom (objectType)) 97 | serializer = _propertySerializer; 98 | else if (typeof (EventDescriptor).IsAssignableFrom (objectType)) 99 | serializer = _eventSerializer; 100 | } else if (serializerType == typeof (RootCodeDomSerializer)) { 101 | serializer = _rootSerializer; 102 | } 103 | 104 | return serializer; 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design.Serialization/ComponentCodeDomSerializer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.Serialization.ComponentCodeDomSerializer 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.Collections; 33 | using System.ComponentModel; 34 | using System.ComponentModel.Design; 35 | 36 | using System.CodeDom; 37 | 38 | using System.ComponentModel.Design.Serialization; 39 | namespace Mono.Design 40 | { 41 | // A serializer for the IComponent Type, supplied by the CodeDomSerializationProvider, 42 | // added as a provider by the RootComponentCodeDomSerializer 43 | // 44 | internal class ComponentCodeDomSerializer : CodeDomSerializer 45 | { 46 | 47 | public ComponentCodeDomSerializer () 48 | { 49 | } 50 | 51 | public override object Serialize (IDesignerSerializationManager manager, object value) 52 | { 53 | if (value == null) 54 | throw new ArgumentNullException ("value"); 55 | if (manager == null) 56 | throw new ArgumentNullException ("manager"); 57 | 58 | RootContext rootContext = manager.Context[typeof (RootContext)] as RootContext; 59 | if (rootContext != null && rootContext.Value == value) 60 | return rootContext.Expression; 61 | 62 | CodeStatementCollection statements = new CodeStatementCollection (); 63 | 64 | if (((IComponent)value).Site == null) { 65 | ReportError (manager, "Component of type '" + value.GetType().Name + "' not sited"); 66 | return statements; 67 | } 68 | 69 | // the trick with the nested components is that GetName will return the full name 70 | // e.g splitter1.Panel1 and thus the code below will create a reference to that. 71 | // 72 | string name = manager.GetName (value); 73 | 74 | CodeExpression componentRef = null; 75 | if (rootContext != null) 76 | componentRef = new CodeFieldReferenceExpression (rootContext.Expression , name); 77 | else 78 | componentRef = new CodeFieldReferenceExpression (new CodeThisReferenceExpression () , name); 79 | 80 | base.SetExpression (manager, value, componentRef); 81 | 82 | ExpressionContext context = manager.Context[typeof (ExpressionContext)] as ExpressionContext; 83 | // Perform some heuristics here. 84 | // 85 | // If there is an ExpressionContext of PropertyReference where PresetValue == this 86 | // partial serialization doesn't make sense, so perform full. E.g in the case of: 87 | // 88 | // PropertyCodeDomSerializer.SerializeContentProperty and splitContainer1.*Panel1* 89 | // 90 | if (context == null || context.PresetValue != value || 91 | (context.PresetValue == value && (context.Expression is CodeFieldReferenceExpression || 92 | context.Expression is CodePropertyReferenceExpression))) { 93 | bool isComplete = true; 94 | statements.Add (new CodeCommentStatement (String.Empty)); 95 | statements.Add (new CodeCommentStatement (name)); 96 | statements.Add (new CodeCommentStatement (String.Empty)); 97 | 98 | // Do not serialize a creation expression for Nested components 99 | // 100 | if (! (((IComponent)value).Site is INestedSite)) { 101 | CodeStatement assignment = new CodeAssignStatement (componentRef, 102 | base.SerializeCreationExpression (manager, value, 103 | out isComplete)); 104 | assignment.UserData["statement-order"] = "initializer"; 105 | statements.Add (assignment); 106 | } 107 | 108 | base.SerializeProperties (manager, statements, value, new Attribute[0]); 109 | base.SerializeEvents (manager, statements, value); 110 | } 111 | 112 | return statements; 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design.Serialization/EnumCodeDomSerializer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.Serialization.EnumCodeDomSerializer 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.ComponentModel; 33 | using System.ComponentModel.Design; 34 | 35 | using System.CodeDom; 36 | 37 | using System.ComponentModel.Design.Serialization; 38 | namespace Mono.Design 39 | { 40 | internal class EnumCodeDomSerializer : CodeDomSerializer 41 | { 42 | 43 | public EnumCodeDomSerializer () 44 | { 45 | } 46 | 47 | public override object Serialize (IDesignerSerializationManager manager, object value) 48 | { 49 | if (manager == null) 50 | throw new ArgumentNullException ("manager"); 51 | if (value == null) 52 | throw new ArgumentNullException ("value"); 53 | 54 | Enum[] enums = null; 55 | TypeConverter converter = TypeDescriptor.GetConverter (value); 56 | if (converter.CanConvertTo (typeof (Enum[]))) 57 | enums = (Enum[]) converter.ConvertTo (value, typeof (Enum[])); 58 | else 59 | enums = new Enum[] { (Enum) value }; 60 | CodeExpression left = null; 61 | CodeExpression right = null; 62 | foreach (Enum e in enums) { 63 | right = GetEnumExpression (e); 64 | if (left == null) // just the first time 65 | left = right; 66 | else 67 | left = new CodeBinaryOperatorExpression (left, CodeBinaryOperatorType.BitwiseOr, right); 68 | } 69 | 70 | return left; 71 | } 72 | 73 | private CodeExpression GetEnumExpression (Enum e) 74 | { 75 | TypeConverter converter = TypeDescriptor.GetConverter (e); 76 | if (converter != null && converter.CanConvertTo (typeof (string))) 77 | return new CodeFieldReferenceExpression (new CodeTypeReferenceExpression (e.GetType().FullName), 78 | (string) converter.ConvertTo (e, typeof (string))); 79 | else 80 | return null; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design.Serialization/EventCodeDomSerializer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.Serialization.EventCodeDomSerializer 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.ComponentModel; 33 | using System.ComponentModel.Design; 34 | 35 | using System.CodeDom; 36 | 37 | using System.ComponentModel.Design.Serialization; 38 | namespace Mono.Design 39 | { 40 | internal class EventCodeDomSerializer : MemberCodeDomSerializer 41 | { 42 | 43 | private CodeThisReferenceExpression _thisReference; 44 | 45 | public EventCodeDomSerializer () 46 | { 47 | // don't waste memory on something that is constant when generating the 48 | // event codedom code - keep it as a field. 49 | _thisReference = new CodeThisReferenceExpression (); 50 | } 51 | 52 | 53 | public override void Serialize (IDesignerSerializationManager manager, object value, MemberDescriptor descriptor, 54 | CodeStatementCollection statements) 55 | { 56 | if (statements == null) 57 | throw new ArgumentNullException ("statements"); 58 | if (manager == null) 59 | throw new ArgumentNullException ("manager"); 60 | if (value == null) 61 | throw new ArgumentNullException ("value"); 62 | if (descriptor == null) 63 | throw new ArgumentNullException ("descriptor"); 64 | 65 | IEventBindingService service = manager.GetService (typeof (IEventBindingService)) as IEventBindingService; 66 | if (service != null) { 67 | EventDescriptor eventDescriptor = (EventDescriptor) descriptor; 68 | string methodName = (string) service.GetEventProperty (eventDescriptor).GetValue (value); 69 | 70 | if (methodName != null) { 71 | CodeDelegateCreateExpression listener = new CodeDelegateCreateExpression (new CodeTypeReference (eventDescriptor.EventType), 72 | _thisReference, methodName); 73 | CodeExpression targetObject = base.SerializeToExpression (manager, value); 74 | CodeEventReferenceExpression eventRef = new CodeEventReferenceExpression (targetObject, eventDescriptor.Name); 75 | statements.Add (new CodeAttachEventStatement (eventRef, listener)); 76 | } 77 | } 78 | } 79 | 80 | public override bool ShouldSerialize (IDesignerSerializationManager manager, object value, MemberDescriptor descriptor) 81 | { 82 | IEventBindingService service = manager.GetService (typeof (IEventBindingService)) as IEventBindingService; 83 | if (service != null) // serialize only if there is an event to serialize 84 | return service.GetEventProperty ((EventDescriptor)descriptor).GetValue (value) != null; 85 | return false; 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design.Serialization/ExpressionContext.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.Serialization.ExpressionContext 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact@i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.CodeDom; 33 | 34 | using System.ComponentModel.Design.Serialization; 35 | namespace Mono.Design 36 | { 37 | public sealed class ExpressionContext 38 | { 39 | 40 | private object _owner; 41 | private Type _expressionType; 42 | private CodeExpression _expression; 43 | private object _presetValue; 44 | 45 | public ExpressionContext (CodeExpression expression, Type expressionType, object owner) 46 | { 47 | _expression = expression; 48 | _expressionType = expressionType; 49 | _owner = owner; 50 | _presetValue = null; 51 | } 52 | 53 | public ExpressionContext (CodeExpression expression, Type expressionType, object owner, object presetValue) 54 | { 55 | _expression = expression; 56 | _expressionType = expressionType; 57 | _owner = owner; 58 | _presetValue = presetValue; 59 | } 60 | 61 | public object PresetValue { 62 | get { return _presetValue; } 63 | } 64 | 65 | public CodeExpression Expression { 66 | get { return _expression; } 67 | } 68 | 69 | public Type ExpressionType { 70 | get { return _expressionType; } 71 | } 72 | 73 | public object Owner { 74 | get { return _owner; } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design.Serialization/MemberCodeDomSerializer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.Serialization.MemberCodeDomSerializer 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.ComponentModel; 33 | using System.ComponentModel.Design; 34 | 35 | using System.CodeDom; 36 | 37 | using System.ComponentModel.Design.Serialization; 38 | namespace Mono.Design 39 | { 40 | public abstract class MemberCodeDomSerializer : CodeDomSerializerBase 41 | { 42 | 43 | protected MemberCodeDomSerializer () 44 | { 45 | } 46 | 47 | public abstract void Serialize (IDesignerSerializationManager manager, object value, MemberDescriptor descriptor, CodeStatementCollection statements); 48 | public abstract bool ShouldSerialize (IDesignerSerializationManager manager, object value, MemberDescriptor descriptor); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design.Serialization/ObjectStatementCollection.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.Serialization.ObjectStatementCollection 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.Collections; 33 | using System.CodeDom; 34 | 35 | using System.ComponentModel.Design.Serialization; 36 | namespace Mono.Design 37 | { 38 | public sealed class ObjectStatementCollection : IEnumerable 39 | { 40 | 41 | private Hashtable _statements; 42 | 43 | internal ObjectStatementCollection () 44 | { 45 | _statements = new Hashtable (); 46 | } 47 | 48 | public bool ContainsKey (object statementOwner) 49 | { 50 | return _statements.ContainsKey (statementOwner); 51 | } 52 | 53 | public IDictionaryEnumerator GetEnumerator() 54 | { 55 | return _statements.GetEnumerator (); 56 | } 57 | 58 | public CodeStatementCollection this[object owner] 59 | { 60 | get { return _statements[owner] as CodeStatementCollection; } 61 | } 62 | 63 | IEnumerator IEnumerable.GetEnumerator() 64 | { 65 | return this.GetEnumerator (); 66 | } 67 | 68 | public void Populate (object owner) 69 | { 70 | if (_statements[owner] == null) 71 | _statements[owner] = null; 72 | } 73 | 74 | public void Populate (ICollection statementOwners) 75 | { 76 | foreach (object o in statementOwners) 77 | this.Populate (o); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design.Serialization/PrimitiveCodeDomSerializer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.Serialization.PrimitiveCodeDomSerializer 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.ComponentModel; 33 | using System.ComponentModel.Design; 34 | 35 | using System.CodeDom; 36 | 37 | using System.ComponentModel.Design.Serialization; 38 | namespace Mono.Design 39 | { 40 | internal class PrimitiveCodeDomSerializer : CodeDomSerializer 41 | { 42 | 43 | public override object Serialize (IDesignerSerializationManager manager, object value) 44 | { 45 | return new CodePrimitiveExpression (value); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design.Serialization/RootContext.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.Serialization.RootContext 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.CodeDom; 33 | 34 | using System.ComponentModel.Design.Serialization; 35 | namespace Mono.Design 36 | { 37 | 38 | public sealed class RootContext 39 | { 40 | 41 | CodeExpression _expression; 42 | object _value; 43 | 44 | public RootContext (CodeExpression expresion, object value) 45 | { 46 | if (expresion == null) 47 | throw new ArgumentNullException ("expression"); 48 | if (value == null) 49 | throw new ArgumentNullException ("value"); 50 | _expression = expresion; 51 | _value = value; 52 | } 53 | 54 | public CodeExpression Expression { 55 | get { return _expression; } 56 | } 57 | 58 | public object Value { 59 | get { return _value; } 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design.Serialization/SerializeAbsoluteContext.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.Serialization.SerializeAbsoluteContext 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.ComponentModel; 33 | using System.ComponentModel.Design; 34 | 35 | 36 | using System.ComponentModel.Design.Serialization; 37 | namespace Mono.Design 38 | { 39 | public sealed class SerializeAbsoluteContext 40 | { 41 | 42 | private MemberDescriptor _member; 43 | 44 | public SerializeAbsoluteContext () 45 | { 46 | } 47 | 48 | public SerializeAbsoluteContext (MemberDescriptor member) 49 | { 50 | _member = member; 51 | } 52 | 53 | // null indicates that the context will be used for all members 54 | // 55 | public MemberDescriptor Member { 56 | get { return _member; } 57 | } 58 | 59 | public bool ShouldSerialize (MemberDescriptor member) 60 | { 61 | return member == _member; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design.Serialization/StatementContext.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.Serialization.StatementContext 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact@i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.CodeDom; 33 | 34 | using System.ComponentModel.Design.Serialization; 35 | namespace Mono.Design 36 | { 37 | public sealed class StatementContext 38 | { 39 | 40 | ObjectStatementCollection _statements; 41 | 42 | public StatementContext () 43 | { 44 | } 45 | 46 | public ObjectStatementCollection StatementCollection { 47 | get { 48 | if (_statements == null) 49 | _statements = new ObjectStatementCollection (); 50 | return _statements; 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design.Serialization/TypeCodeDomSerializer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.Serialization.TypeCodeDomSerializer 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.Collections; 33 | using System.ComponentModel; 34 | using System.ComponentModel.Design; 35 | 36 | using System.CodeDom; 37 | 38 | using System.ComponentModel.Design.Serialization; 39 | namespace Mono.Design 40 | { 41 | public class TypeCodeDomSerializer : CodeDomSerializerBase 42 | { 43 | 44 | public TypeCodeDomSerializer () 45 | { 46 | } 47 | 48 | public virtual CodeTypeDeclaration Serialize (IDesignerSerializationManager manager, object root, ICollection members) 49 | { 50 | if (root == null) 51 | throw new ArgumentNullException ("root"); 52 | if (manager == null) 53 | throw new ArgumentNullException ("manager"); 54 | 55 | RootContext rootContext = new RootContext (new CodeThisReferenceExpression (), root); 56 | StatementContext statementContext = new StatementContext (); 57 | if (members != null) 58 | statementContext.StatementCollection.Populate (members); 59 | statementContext.StatementCollection.Populate (root); 60 | CodeTypeDeclaration declaration = new CodeTypeDeclaration (manager.GetName (root)); 61 | 62 | manager.Context.Push (rootContext); 63 | manager.Context.Push (statementContext); 64 | manager.Context.Push (declaration); 65 | 66 | if (members != null) { 67 | foreach (object member in members) 68 | base.SerializeToExpression (manager, member); 69 | } 70 | base.SerializeToExpression (manager, root); 71 | 72 | manager.Context.Pop (); 73 | manager.Context.Pop (); 74 | manager.Context.Pop (); 75 | 76 | return declaration; 77 | } 78 | 79 | // TODO - http://msdn2.microsoft.com/en-us/library/system.componentmodel.design.serialization.typecodedomserializer.deserialize.aspx 80 | // 81 | public virtual object Deserialize (IDesignerSerializationManager manager, CodeTypeDeclaration declaration) 82 | { 83 | throw new NotImplementedException (); 84 | } 85 | 86 | protected virtual CodeMemberMethod GetInitializeMethod (IDesignerSerializationManager manager, CodeTypeDeclaration declaration, object value) 87 | { 88 | if (value == null) 89 | throw new ArgumentNullException ("value"); 90 | if (declaration == null) 91 | throw new ArgumentNullException ("declaration"); 92 | if (manager == null) 93 | throw new ArgumentNullException ("manager"); 94 | 95 | return new CodeConstructor (); 96 | } 97 | 98 | protected virtual CodeMemberMethod[] GetInitializeMethods (IDesignerSerializationManager manager, CodeTypeDeclaration declaration) 99 | { 100 | if (manager == null) 101 | throw new ArgumentNullException ("manager"); 102 | if (declaration == null) 103 | throw new ArgumentNullException ("declaration"); 104 | 105 | return (new CodeMemberMethod[] { new CodeConstructor () }); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/ActiveDesignSurfaceChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.ActiveDesignSurfaceChangedEventArgs 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | 33 | using System.ComponentModel.Design; 34 | namespace Mono.Design 35 | { 36 | 37 | public class ActiveDesignSurfaceChangedEventArgs : EventArgs 38 | { 39 | 40 | private DesignSurface _oldSurface; 41 | private DesignSurface _newSurface; 42 | 43 | public ActiveDesignSurfaceChangedEventArgs (DesignSurface oldSurface, DesignSurface newSurface) 44 | { 45 | _newSurface = newSurface; 46 | _oldSurface = oldSurface; 47 | } 48 | 49 | public DesignSurface OldSurface { 50 | get { return _oldSurface; } 51 | } 52 | 53 | public DesignSurface NewSurface { 54 | get { return _newSurface; } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/ActiveDesignSurfaceChangedEventHandler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.ActiveDesignSurfaceChangedEventHandler 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | 33 | using System.ComponentModel.Design; 34 | namespace Mono.Design 35 | { 36 | 37 | public delegate void ActiveDesignSurfaceChangedEventHandler (object sender, ActiveDesignSurfaceChangedEventArgs e); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/DesignModeNestedContainer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.DesignModeSite 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | 30 | using System; 31 | using System.Collections; 32 | using System.ComponentModel; 33 | using System.ComponentModel.Design.Serialization; 34 | 35 | using System.ComponentModel.Design; 36 | namespace Mono.Design 37 | { 38 | 39 | internal class DesignModeNestedContainer : NestedContainer 40 | { 41 | 42 | // DesignModeNestedContainer is a NestedContainer where: 43 | // * Site's Name property is a qualified name that includes the owning component's name 44 | // followed by a period (.) and the child component's name. 45 | // * GetService is routed through the owner 46 | 47 | private class Site : DesignModeSite, INestedSite 48 | { 49 | 50 | public Site (IComponent component, string name, IContainer container, IServiceProvider serviceProvider) : 51 | base (component, name, container, serviceProvider) 52 | { 53 | } 54 | 55 | // [owner].[container].[site] 56 | // 57 | public string FullName { 58 | get { 59 | if (this.Name == null) 60 | return null; 61 | 62 | string ownerName = ((DesignModeNestedContainer)this.Container).OwnerName; 63 | if (ownerName == null) 64 | return this.Name; 65 | 66 | return ownerName + "." + this.Name; 67 | } 68 | } 69 | } 70 | 71 | private string _containerName; 72 | 73 | public DesignModeNestedContainer (IComponent owner, string containerName) : base (owner) 74 | { 75 | _containerName = containerName; 76 | } 77 | 78 | public override void Add (IComponent component, string name) 79 | { 80 | if (this.Owner.Site != null) { 81 | DesignerHost host = this.Owner.Site.GetService (typeof (IDesignerHost)) as DesignerHost; 82 | if (host != null) { 83 | host.AddPreProcess (component, name); 84 | base.Add (component, name); 85 | host.AddPostProcess (component, name); 86 | } 87 | } 88 | } 89 | 90 | public override void Remove (IComponent component) 91 | { 92 | if (this.Owner.Site != null) { 93 | DesignerHost host = this.Owner.Site.GetService (typeof (IDesignerHost)) as DesignerHost; 94 | if (host != null) { 95 | host.RemovePreProcess (component); 96 | base.Remove (component); 97 | host.RemovePostProcess (component); 98 | } 99 | } 100 | } 101 | 102 | // [owner].[container] 103 | // 104 | protected override string OwnerName { 105 | get { 106 | if (_containerName != null) 107 | return base.OwnerName + "." + _containerName; 108 | else 109 | return base.OwnerName; 110 | } 111 | } 112 | 113 | protected override ISite CreateSite (IComponent component, string name) 114 | { 115 | if (component == null) 116 | throw new ArgumentNullException("component"); 117 | 118 | if (Owner.Site == null) 119 | throw new InvalidOperationException ("Owner not sited."); 120 | 121 | return new DesignModeNestedContainer.Site (component, name, this, (IServiceProvider)Owner.Site); 122 | } 123 | 124 | protected override object GetService (Type service) 125 | { 126 | if (service == typeof (INestedContainer)) 127 | return this; 128 | 129 | object serviceInstance = null; 130 | 131 | if (this.Owner.Site != null) 132 | serviceInstance = this.Owner.Site.GetService (service); 133 | 134 | if (serviceInstance == null) 135 | return base.GetService (service); 136 | 137 | return null; 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/DesignSurfaceCollection.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.DesignSurfaceCollection 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.ComponentModel; 33 | using System.Collections; 34 | 35 | using System.ComponentModel.Design; 36 | namespace Mono.Design 37 | { 38 | // A read-only collection of design surfaces. 39 | // A wrapper around a DesignerCollection, which get's the DesignSurface for the IDesignerHost 40 | // on the fly. 41 | // 42 | public sealed class DesignSurfaceCollection : ICollection, IEnumerable 43 | { 44 | 45 | private class DesignSurfaceEnumerator : IEnumerator 46 | { 47 | IEnumerator _designerCollectionEnumerator; 48 | 49 | public DesignSurfaceEnumerator (IEnumerator designerCollectionEnumerator) 50 | { 51 | _designerCollectionEnumerator = designerCollectionEnumerator; 52 | } 53 | 54 | public bool MoveNext () 55 | { 56 | return _designerCollectionEnumerator.MoveNext (); 57 | } 58 | 59 | public void Reset () 60 | { 61 | _designerCollectionEnumerator.Reset (); 62 | } 63 | 64 | public object Current { 65 | get { 66 | IDesignerHost designer = (IDesignerHost) _designerCollectionEnumerator.Current; 67 | DesignSurface surface = designer.GetService (typeof (DesignSurface)) as DesignSurface; 68 | if (surface == null) 69 | throw new NotSupportedException (); 70 | 71 | return surface; 72 | } 73 | } 74 | 75 | } // DesignSurfaceEnumerator 76 | 77 | 78 | private DesignerCollection _designers; 79 | 80 | internal DesignSurfaceCollection (DesignerCollection designers) 81 | { 82 | if (designers == null) 83 | designers = new DesignerCollection (null); 84 | 85 | _designers = designers; 86 | } 87 | 88 | public int Count { 89 | get { return _designers.Count; } 90 | } 91 | 92 | public DesignSurface this[int index] { 93 | get { 94 | IDesignerHost designer = _designers[index]; 95 | DesignSurface surface = designer.GetService (typeof (DesignSurface)) as DesignSurface; 96 | if (surface == null) 97 | throw new NotSupportedException (); 98 | 99 | return surface; 100 | } 101 | } 102 | 103 | public void CopyTo (DesignSurface[] array, int index) 104 | { 105 | ((ICollection) this).CopyTo (array, index); 106 | } 107 | 108 | void ICollection.CopyTo (Array array, int index) 109 | { 110 | foreach (DesignSurface surface in this) { 111 | array.SetValue (surface, index); 112 | index++; 113 | } 114 | } 115 | 116 | public IEnumerator GetEnumerator () 117 | { 118 | return new DesignSurfaceEnumerator (_designers.GetEnumerator ()); 119 | } 120 | 121 | IEnumerator IEnumerable.GetEnumerator () 122 | { 123 | return GetEnumerator (); 124 | } 125 | 126 | int ICollection.Count { 127 | get { return this.Count; } 128 | } 129 | 130 | bool ICollection.IsSynchronized { 131 | get { return false; } 132 | } 133 | 134 | object ICollection.SyncRoot { 135 | get { return null; } 136 | } 137 | 138 | } 139 | 140 | } 141 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/DesignSurfaceEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.DesignSurfaceEventArgs 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.ComponentModel; 33 | 34 | using System.ComponentModel.Design; 35 | namespace Mono.Design 36 | { 37 | 38 | public class DesignSurfaceEventArgs : EventArgs 39 | { 40 | 41 | private DesignSurface _surface; 42 | 43 | public DesignSurface Surface { 44 | get { return _surface; } 45 | } 46 | 47 | public DesignSurfaceEventArgs (DesignSurface surface) 48 | { 49 | _surface = surface; 50 | } 51 | 52 | } 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/DesignSurfaceEventHandler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.DesignSurfaceEventHandler 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.ComponentModel; 33 | 34 | using System.ComponentModel.Design; 35 | namespace Mono.Design 36 | { 37 | 38 | public delegate void DesignSurfaceEventHandler (Object sender, DesignSurfaceEventArgs e); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/DesignSurfaceServiceContainer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.DesignSurfaceServiceContainer 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nz.net) 6 | // 7 | // (C) 2006 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.Collections; 33 | using System.ComponentModel; 34 | 35 | using System.ComponentModel.Design; 36 | namespace Mono.Design 37 | { 38 | 39 | // Implements a ServiceContainer, which allows specific sets of services 40 | // to be non-replacable for users of the IServiceContainer . 41 | // 42 | internal sealed class DesignSurfaceServiceContainer : ServiceContainer 43 | { 44 | 45 | private Hashtable _nonRemoveableServices; 46 | 47 | public DesignSurfaceServiceContainer () : this (null) 48 | { 49 | } 50 | 51 | public DesignSurfaceServiceContainer (IServiceProvider parentProvider) : base (parentProvider) 52 | { 53 | } 54 | 55 | internal void AddNonReplaceableService (Type serviceType, object instance) 56 | { 57 | if (_nonRemoveableServices == null) 58 | _nonRemoveableServices = new Hashtable (); 59 | 60 | _nonRemoveableServices[serviceType] = serviceType; 61 | base.AddService (serviceType, instance); 62 | } 63 | 64 | 65 | internal void RemoveNonReplaceableService (Type serviceType, object instance) 66 | { 67 | if (_nonRemoveableServices != null) 68 | _nonRemoveableServices.Remove (serviceType); 69 | base.RemoveService (serviceType); 70 | } 71 | 72 | public override void RemoveService (Type serviceType, bool promote) 73 | { 74 | if (serviceType != null && _nonRemoveableServices != null && _nonRemoveableServices.ContainsKey (serviceType)) 75 | throw new InvalidOperationException ("Cannot remove non-replaceable service: " + serviceType.AssemblyQualifiedName); 76 | 77 | base.RemoveService (serviceType, promote); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/DesignerActionListCollection.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.DesignerActionListCollection 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006-2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.Collections; 33 | using System.ComponentModel; 34 | 35 | using System.ComponentModel.Design; 36 | namespace Mono.Design 37 | { 38 | [System.Runtime.InteropServices.ComVisible (true)] 39 | public class DesignerActionListCollection : CollectionBase 40 | { 41 | 42 | public DesignerActionListCollection () 43 | { 44 | } 45 | 46 | public DesignerActionListCollection (DesignerActionList[] value) 47 | { 48 | AddRange (value); 49 | } 50 | 51 | public DesignerActionList this[int index] { 52 | get { return (DesignerActionList) base.List[index]; } 53 | set { base.List[index] = value; } 54 | } 55 | 56 | public int Add (DesignerActionList value) 57 | { 58 | return base.List.Add (value); 59 | } 60 | 61 | public void AddRange (DesignerActionList[] value) 62 | { 63 | if (value == null) 64 | throw new ArgumentNullException ("value"); 65 | 66 | foreach (DesignerActionList actionList in value) 67 | Add (actionList); 68 | } 69 | 70 | public void AddRange (DesignerActionListCollection value) 71 | { 72 | if (value == null) 73 | throw new ArgumentNullException ("value"); 74 | 75 | foreach (DesignerActionList actionList in value) 76 | Add (actionList); 77 | } 78 | 79 | public bool Contains (DesignerActionList value) 80 | { 81 | return base.List.Contains (value); 82 | } 83 | 84 | public void CopyTo (DesignerActionList[] array, int index) 85 | { 86 | base.List.CopyTo (array, index); 87 | } 88 | 89 | public int IndexOf (DesignerActionList value) 90 | { 91 | return base.List.IndexOf (value); 92 | } 93 | 94 | public void Insert (int index, DesignerActionList value) 95 | { 96 | base.List.Insert (index, value); 97 | } 98 | 99 | public void Remove (DesignerActionList value) 100 | { 101 | base.List.Remove (value); 102 | } 103 | 104 | protected override void OnClear () 105 | { 106 | } 107 | 108 | protected override void OnInsert (int index, object value) 109 | { 110 | } 111 | 112 | protected override void OnRemove (int index, object value) 113 | { 114 | } 115 | 116 | protected override void OnSet (int index, object oldValue, object newValue) 117 | { 118 | } 119 | 120 | protected override void OnValidate (object value) 121 | { 122 | } 123 | 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/DesignerEventService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.DesignerEventService 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006-2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.ComponentModel; 33 | using System.Collections; 34 | 35 | using System.ComponentModel.Design; 36 | namespace Mono.Design 37 | { 38 | // IDesignerEventService provides a global eventing mechanism for designer events. With this mechanism, 39 | // an application is informed when a designer becomes active. The service provides a collection of 40 | // designers and a single place where global objects, such as the Properties window, can monitor selection 41 | // change events. 42 | // 43 | // IDesignerEventService is practicly replaced by the DesignSurfaceManager and also the 44 | // meaning of Designer in IDesignerEventService is actually DesignerHost. 45 | // 46 | internal sealed class DesignerEventService : IDesignerEventService 47 | { 48 | 49 | public DesignerEventService () 50 | { 51 | _designerList = new ArrayList (); 52 | } 53 | 54 | private ArrayList _designerList; 55 | private IDesignerHost _activeDesigner; 56 | 57 | public IDesignerHost ActiveDesigner { 58 | get { 59 | return _activeDesigner; 60 | } 61 | internal set { 62 | IDesignerHost old = _activeDesigner; 63 | _activeDesigner = value; 64 | if (ActiveDesignerChanged != null) 65 | ActiveDesignerChanged (this, new ActiveDesignerEventArgs (old, value)); 66 | } 67 | } 68 | 69 | public DesignerCollection Designers { 70 | get { return new DesignerCollection (_designerList); } 71 | } 72 | 73 | public event ActiveDesignerEventHandler ActiveDesignerChanged; 74 | public event DesignerEventHandler DesignerCreated; 75 | public event DesignerEventHandler DesignerDisposed; 76 | public event EventHandler SelectionChanged; 77 | 78 | public void RaiseDesignerCreated (IDesignerHost host) 79 | { 80 | if (DesignerCreated != null) 81 | DesignerCreated (this, new DesignerEventArgs (host)); 82 | } 83 | 84 | public void RaiseDesignerDisposed (IDesignerHost host) 85 | { 86 | if (DesignerDisposed != null) 87 | DesignerDisposed (this, new DesignerEventArgs (host)); 88 | } 89 | 90 | public void RaiseSelectionChanged () 91 | { 92 | if (SelectionChanged != null) 93 | SelectionChanged (this, EventArgs.Empty); 94 | } 95 | 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/ExtenderService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.ExtenderService 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | using System; 31 | using System.Collections; 32 | using System.ComponentModel; 33 | 34 | using System.ComponentModel.Design; 35 | namespace Mono.Design 36 | { 37 | 38 | internal sealed class ExtenderService : IExtenderProviderService, IExtenderListService, IDisposable 39 | { 40 | 41 | private ArrayList _extenderProviders; 42 | 43 | public ExtenderService () 44 | { 45 | _extenderProviders = new ArrayList (); 46 | } 47 | 48 | public void AddExtenderProvider (IExtenderProvider provider) 49 | { 50 | if (_extenderProviders != null) { 51 | if (!_extenderProviders.Contains (provider)) 52 | _extenderProviders.Add (provider); 53 | } 54 | } 55 | 56 | public void RemoveExtenderProvider (IExtenderProvider provider) 57 | { 58 | if (_extenderProviders != null) { 59 | if (_extenderProviders.Contains (provider)) 60 | _extenderProviders.Remove (provider); 61 | } 62 | } 63 | 64 | public IExtenderProvider[] GetExtenderProviders() 65 | { 66 | if (_extenderProviders != null) { 67 | IExtenderProvider[] result = new IExtenderProvider[_extenderProviders.Count]; 68 | _extenderProviders.CopyTo (result, 0); 69 | 70 | return result; 71 | } 72 | return null; 73 | } 74 | 75 | public void Dispose () 76 | { 77 | if (_extenderProviders != null) { 78 | _extenderProviders.Clear (); 79 | _extenderProviders = null; 80 | } 81 | } 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/LoadedEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.LoadedEventArgs 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.Collections; 33 | using System.ComponentModel; 34 | 35 | using System.ComponentModel.Design; 36 | namespace Mono.Design 37 | { 38 | 39 | public sealed class LoadedEventArgs : EventArgs 40 | { 41 | 42 | public LoadedEventArgs (bool succeeded, ICollection errors) 43 | { 44 | _succeeded = succeeded; 45 | _errors = errors; 46 | } 47 | 48 | private ICollection _errors; 49 | private bool _succeeded; 50 | 51 | public ICollection Errors { 52 | get { return _errors; } 53 | } 54 | 55 | public bool HasSucceeded { 56 | get { return _succeeded;} 57 | } 58 | 59 | 60 | 61 | 62 | } 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/LoadedEventHandler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.LoadedEventHandler 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.ComponentModel; 33 | 34 | using System.ComponentModel.Design; 35 | namespace Mono.Design 36 | { 37 | 38 | public delegate void LoadedEventHandler (Object sender, LoadedEventArgs e); 39 | } 40 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/ReferenceService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.ReferenceService 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.Collections.Generic; 33 | using System.Globalization; 34 | using System.ComponentModel; 35 | 36 | using System.ComponentModel.Design; 37 | namespace Mono.Design 38 | { 39 | 40 | internal class ReferenceService : IReferenceService, IDisposable 41 | { 42 | 43 | private List _references; 44 | 45 | internal ReferenceService (IServiceProvider provider) 46 | { 47 | if (provider == null) 48 | throw new ArgumentNullException ("provider"); 49 | 50 | _references = new List(); 51 | IComponentChangeService serv = provider.GetService (typeof (IComponentChangeService)) as IComponentChangeService; 52 | if (serv != null) { 53 | serv.ComponentAdded += OnComponentAdded; 54 | serv.ComponentRemoved += OnComponentRemoved; 55 | } 56 | } 57 | 58 | private void OnComponentAdded (object sender, ComponentEventArgs args) 59 | { 60 | _references.Add (args.Component); 61 | } 62 | 63 | private void OnComponentRemoved (object sender, ComponentEventArgs args) 64 | { 65 | _references.Remove (args.Component); 66 | } 67 | 68 | public IComponent GetComponent (object reference) 69 | { 70 | return reference as IComponent; 71 | } 72 | 73 | public string GetName (object reference) 74 | { 75 | IComponent comp = reference as IComponent; 76 | if (comp != null && comp.Site != null) 77 | return comp.Site.Name; 78 | return null; 79 | } 80 | 81 | public object GetReference (string name) 82 | { 83 | foreach (IComponent component in _references) 84 | if (component.Site != null && component.Site.Name == name) 85 | return component; 86 | return null; 87 | } 88 | 89 | public object[] GetReferences () 90 | { 91 | IComponent[] references = new IComponent[_references.Count]; 92 | _references.CopyTo (references); 93 | return references; 94 | } 95 | 96 | public object[] GetReferences (Type baseType) 97 | { 98 | List references = new List(); 99 | 100 | foreach (IComponent component in _references) 101 | if (baseType.IsAssignableFrom ((component.GetType ()))) 102 | references.Add (component); 103 | 104 | IComponent[] refArray = new IComponent[references.Count]; 105 | references.CopyTo (refArray); 106 | return refArray; 107 | } 108 | 109 | public void Dispose () 110 | { 111 | _references.Clear (); 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.ComponentModel.Design/TypeDescriptorFilterService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.ComponentModel.Design.TypeDescriptorFilterService 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.Collections; 33 | using System.ComponentModel; 34 | 35 | using System.ComponentModel.Design; 36 | namespace Mono.Design 37 | { 38 | 39 | internal sealed class TypeDescriptorFilterService : ITypeDescriptorFilterService, IDisposable 40 | { 41 | 42 | IServiceProvider _serviceProvider; 43 | 44 | public TypeDescriptorFilterService (IServiceProvider serviceProvider) 45 | { 46 | if (serviceProvider == null) 47 | throw new ArgumentNullException ("serviceProvider"); 48 | 49 | _serviceProvider = serviceProvider; 50 | } 51 | 52 | // Return values are: 53 | // true if the set of filtered attributes is to be cached; false if the filter service must query again. 54 | // 55 | public bool FilterAttributes (IComponent component, IDictionary attributes) 56 | { 57 | if (_serviceProvider == null) 58 | throw new ObjectDisposedException ("TypeDescriptorFilterService"); 59 | if (component == null) 60 | throw new ArgumentNullException ("component"); 61 | 62 | IDesignerHost designerHost = _serviceProvider.GetService (typeof (IDesignerHost)) as IDesignerHost; 63 | if (designerHost != null) { 64 | IDesigner designer = designerHost.GetDesigner (component); 65 | if (designer is IDesignerFilter) { 66 | ((IDesignerFilter) designer).PreFilterAttributes (attributes); 67 | ((IDesignerFilter) designer).PostFilterAttributes (attributes); 68 | } 69 | } 70 | 71 | return true; 72 | } 73 | 74 | public bool FilterEvents (IComponent component, IDictionary events) 75 | { 76 | if (_serviceProvider == null) 77 | throw new ObjectDisposedException ("TypeDescriptorFilterService"); 78 | if (component == null) 79 | throw new ArgumentNullException ("component"); 80 | 81 | IDesignerHost designerHost = _serviceProvider.GetService (typeof (IDesignerHost)) as IDesignerHost; 82 | if (designerHost != null) { 83 | IDesigner designer = designerHost.GetDesigner (component); 84 | if (designer is IDesignerFilter) { 85 | ((IDesignerFilter) designer).PreFilterEvents (events); 86 | ((IDesignerFilter) designer).PostFilterEvents (events); 87 | } 88 | } 89 | 90 | return true; 91 | } 92 | 93 | public bool FilterProperties (IComponent component, IDictionary properties) 94 | { 95 | if (_serviceProvider == null) 96 | throw new ObjectDisposedException ("TypeDescriptorFilterService"); 97 | if (component == null) 98 | throw new ArgumentNullException ("component"); 99 | 100 | IDesignerHost designerHost = _serviceProvider.GetService (typeof (IDesignerHost)) as IDesignerHost; 101 | if (designerHost != null) { 102 | IDesigner designer = designerHost.GetDesigner (component); 103 | if (designer is IDesignerFilter) { 104 | ((IDesignerFilter) designer).PreFilterProperties (properties); 105 | ((IDesignerFilter) designer).PostFilterProperties (properties); 106 | } 107 | } 108 | 109 | return true; 110 | } 111 | 112 | public void Dispose () 113 | { 114 | _serviceProvider = null; 115 | } 116 | 117 | } 118 | } 119 | 120 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.Windows.Forms.Design/ControlCodeDomSerializer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Windows.Forms.Design.ControlCodeDomSerializaer 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.Collections; 33 | using System.Reflection; 34 | using System.ComponentModel; 35 | using System.ComponentModel.Design; 36 | using System.ComponentModel.Design.Serialization; 37 | using System.CodeDom; 38 | using System.Windows.Forms; 39 | 40 | using System.Windows.Forms.Design; 41 | namespace Mono.Design 42 | { 43 | internal class ControlCodeDomSerializer : ComponentCodeDomSerializer 44 | { 45 | 46 | public ControlCodeDomSerializer () 47 | { 48 | } 49 | 50 | public override object Serialize (IDesignerSerializationManager manager, object value) 51 | { 52 | if (value == null) 53 | throw new ArgumentNullException ("value"); 54 | if (manager == null) 55 | throw new ArgumentNullException ("manager"); 56 | 57 | if (!(value is Control)) 58 | throw new InvalidOperationException ("value is not a Control"); 59 | 60 | object serialized = base.Serialize (manager, value); 61 | CodeStatementCollection statements = serialized as CodeStatementCollection; 62 | if (statements != null) { // the root control is serialized to CodeExpression 63 | ICollection childControls = TypeDescriptor.GetProperties (value)["Controls"].GetValue (value) as ICollection; 64 | if (childControls.Count > 0) { 65 | CodeExpression componentRef = base.GetExpression (manager, value); 66 | 67 | CodeStatement statement = new CodeExpressionStatement ( 68 | new CodeMethodInvokeExpression (componentRef, "SuspendLayout")); 69 | statement.UserData["statement-order"] = "begin"; 70 | statements.Add (statement); 71 | statement = new CodeExpressionStatement ( 72 | new CodeMethodInvokeExpression (componentRef, "ResumeLayout", 73 | new CodeExpression[] { 74 | new CodePrimitiveExpression (false) })); 75 | statement.UserData["statement-order"] = "end"; 76 | statements.Add (statement); 77 | serialized = statements; 78 | } 79 | } 80 | return serialized; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.Windows.Forms.Design/ControlCollectionCodeDomSerializer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Windows.Forms.Design.ControlCollectionCodeDomSerializaer 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.Collections; 33 | using System.Reflection; 34 | using System.ComponentModel; 35 | using System.ComponentModel.Design; 36 | using System.ComponentModel.Design.Serialization; 37 | using System.CodeDom; 38 | using System.Windows.Forms; 39 | 40 | using System.Windows.Forms.Design; 41 | namespace Mono.Design 42 | { 43 | internal class ControlCollectionCodeDomSerializaer : CollectionCodeDomSerializer 44 | { 45 | 46 | public ControlCollectionCodeDomSerializaer () 47 | { 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.Windows.Forms.Design/ControlDataObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | using System.Windows.Forms.Design; 5 | namespace Mono.Design 6 | { 7 | // A IDataObject that supports Control and Control[] format 8 | // 9 | internal class ControlDataObject : IDataObject 10 | { 11 | private object _data = null; 12 | private string _format = null; 13 | 14 | public ControlDataObject () 15 | { 16 | _data = null; 17 | _format = null; 18 | } 19 | 20 | public ControlDataObject (Control control) 21 | { 22 | SetData (control); 23 | } 24 | 25 | public ControlDataObject (Control[] controls) 26 | { 27 | SetData (controls); 28 | } 29 | 30 | public object GetData (Type format) 31 | { 32 | return this.GetData (format.ToString ()); 33 | } 34 | 35 | public object GetData (string format) 36 | { 37 | return this.GetData (format, true); 38 | } 39 | 40 | public object GetData (string format, bool autoConvert) 41 | { 42 | if (format == _format) { 43 | return _data; 44 | } 45 | return null; 46 | } 47 | 48 | public bool GetDataPresent (Type format) 49 | { 50 | return this.GetDataPresent (format.ToString()); 51 | } 52 | 53 | public bool GetDataPresent (string format) 54 | { 55 | return this.GetDataPresent (format, true); 56 | } 57 | 58 | public bool GetDataPresent (string format, bool autoConvert) 59 | { 60 | if (format == _format) { 61 | return true; 62 | } 63 | return false; 64 | } 65 | 66 | public string[] GetFormats () 67 | { 68 | return this.GetFormats (true); 69 | } 70 | 71 | public string[] GetFormats (bool autoConvert) 72 | { 73 | string[] formats = new string[2]; 74 | formats[0] = typeof (Control).ToString (); 75 | formats[1] = typeof (Control[]).ToString (); 76 | return formats; 77 | } 78 | 79 | public void SetData (object data) 80 | { 81 | if (data is Control) 82 | this.SetData (typeof (Control), data); 83 | else if (data is Control[]) 84 | this.SetData (typeof (Control[]), data); 85 | } 86 | 87 | public void SetData (Type format, object data) 88 | { 89 | this.SetData (format.ToString (), data); 90 | } 91 | 92 | public void SetData (string format, object data) 93 | { 94 | this.SetData (format, true, data); 95 | } 96 | 97 | public void SetData (string format, bool autoConvert, object data) 98 | { 99 | if (ValidateFormat (format)) { 100 | _data = data; 101 | _format = format; 102 | } 103 | } 104 | 105 | private bool ValidateFormat (string format) 106 | { 107 | bool valid = false; 108 | 109 | string[] formats = GetFormats (); 110 | foreach (string f in formats) { 111 | if (f == format) { 112 | valid = true; 113 | break; 114 | } 115 | } 116 | 117 | return valid; 118 | } 119 | } 120 | } 121 | 122 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.Windows.Forms.Design/FormDocumentDesigner.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Windows.Forms.Design.FormDocumentDesigner 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2008 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | using System; 31 | using System.ComponentModel; 32 | using System.ComponentModel.Design; 33 | using System.Windows.Forms; 34 | using System.Drawing; 35 | using System.Drawing.Design; 36 | using System.Collections; 37 | 38 | using System.Windows.Forms.Design; 39 | namespace Mono.Design 40 | { 41 | internal class FormDocumentDesigner : DocumentDesigner 42 | { 43 | 44 | public FormDocumentDesigner () 45 | { 46 | } 47 | 48 | public override void Initialize (IComponent component) 49 | { 50 | Form form = component as Form; 51 | if (form == null) 52 | throw new NotSupportedException ("FormDocumentDesigner can be initialized only with Forms"); 53 | 54 | form.TopLevel = false; 55 | form.Visible = true; 56 | base.Initialize (component); 57 | } 58 | 59 | public override bool CanParent (Control control) 60 | { 61 | if (control is Form) 62 | return false; 63 | return base.CanParent (control); 64 | } 65 | 66 | protected override void WndProc (ref Message m) 67 | { 68 | // Filter out titlebar clicks 69 | // 70 | switch ((Native.Msg) m.Msg) { 71 | case Native.Msg.WM_NCLBUTTONDBLCLK: 72 | case Native.Msg.WM_NCLBUTTONDOWN: 73 | case Native.Msg.WM_NCMBUTTONDBLCLK: 74 | case Native.Msg.WM_NCMBUTTONDOWN: 75 | case Native.Msg.WM_NCRBUTTONDBLCLK: 76 | case Native.Msg.WM_NCRBUTTONDOWN: 77 | ISelectionService selectionServ = this.GetService (typeof (ISelectionService)) as ISelectionService; 78 | if (selectionServ != null) 79 | selectionServ.SetSelectedComponents (new object[] { this.Component }); 80 | break; 81 | default: 82 | base.WndProc (ref m); 83 | break; 84 | } 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.Windows.Forms.Design/IMessageReceiver.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Windows.Forms.Design.IMessageReceiver 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006-2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | using System; 31 | using System.Windows.Forms; 32 | 33 | using System.Windows.Forms.Design; 34 | namespace Mono.Design 35 | { 36 | internal interface IMessageReceiver 37 | { 38 | void WndProc (ref Message m); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.Windows.Forms.Design/IUISelectionService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Windows.Forms.Design.IUISelectionService 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006-2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | using System; 31 | using System.Collections; 32 | using System.ComponentModel; 33 | using System.ComponentModel.Design; 34 | using System.Drawing; 35 | using System.Drawing.Drawing2D; 36 | using System.Windows.Forms; 37 | 38 | using System.Windows.Forms.Design; 39 | namespace Mono.Design 40 | { 41 | 42 | 43 | internal interface IUISelectionService 44 | { 45 | bool SelectionInProgress { 46 | get; 47 | } 48 | bool DragDropInProgress { 49 | get; 50 | } 51 | bool ResizeInProgress { 52 | get; 53 | } 54 | 55 | Rectangle SelectionBounds { 56 | get; 57 | } 58 | 59 | void MouseDragBegin (Control container, int x, int y); 60 | void MouseDragMove (int x, int y); 61 | void MouseDragEnd (bool cancel); 62 | 63 | void DragBegin (); 64 | void DragOver (Control container, int x, int y); 65 | void DragDrop (bool cancel, Control container, int x, int y); 66 | 67 | void PaintAdornments (Control container, Graphics gfx); 68 | bool SetCursor (int x, int y); 69 | 70 | bool AdornmentsHitTest (Control control, int x, int y); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.Windows.Forms.Design/Native.cs.rej: -------------------------------------------------------------------------------- 1 | --- class/System.Design/System.Windows.Forms.Design/Native.cs 2008-07-10 16:24:08.000000000 +0100 2 | +++ class/System.Design/System.Windows.Forms.Design/Native.cs 2008-04-07 14:28:36.000000000 +0100 3 | @@ -40,16 +40,18 @@ 4 | { 5 | 6 | private static Type _xplatuiType; 7 | + private static bool _onMSNET; 8 | 9 | static Native () 10 | { 11 | - Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); 12 | + _onMSNET = false; 13 | + Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); 14 | if (assembly == null) 15 | throw new InvalidOperationException ("Can't load System.Windows.Forms assembly."); 16 | 17 | _xplatuiType = assembly.GetType ("System.Windows.Forms.XplatUI"); 18 | if (_xplatuiType == null) 19 | - throw new InvalidOperationException ("Can't find the System.Windows.Forms.XplatUI type."); 20 | + _onMSNET = true; 21 | } 22 | 23 | private static object InvokeMethod (string methodName, object[] args) 24 | @@ -78,19 +80,27 @@ 25 | 26 | public static void DefWndProc (ref Message m) 27 | { 28 | - object[] args = new object[] { m }; 29 | - m.Result = (IntPtr) InvokeMethod ("DefWndProc", args); 30 | - m = (Message) args[0]; 31 | + if (_onMSNET) { 32 | + m.Result = DefWindowProc (m.HWnd, m.Msg, m.WParam, m.LParam); 33 | + } 34 | + else { 35 | + object[] args = new object[] { m }; 36 | + m.Result = (IntPtr) InvokeMethod ("DefWndProc", args); 37 | + m = (Message) args[0]; 38 | + } 39 | } 40 | 41 | public static IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) 42 | { 43 | - 44 | - Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); 45 | - Type refType = assembly.GetType ("System.Windows.Forms.Message&"); 46 | - object[] args = new object[] { Message.Create (hwnd, (int)message, wParam, lParam) }; 47 | - InvokeMethod ("SendMessage", args, new Type[] { refType }); 48 | - return ((Message)args[0]).Result; 49 | + if (_onMSNET) { 50 | + return SendMessage_Win32 (hwnd, (int) message, wParam, lParam); 51 | + } else { 52 | + Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); 53 | + Type refType = assembly.GetType ("System.Windows.Forms.Message&"); 54 | + object[] args = new object[] { Message.Create (hwnd, (int)message, wParam, lParam) }; 55 | + InvokeMethod ("SendMessage", args, new Type[] { refType }); 56 | + return ((Message)args[0]).Result; 57 | + } 58 | } 59 | 60 | public static Point PointToClient (Control control, Point point) 61 | @@ -98,14 +108,24 @@ 62 | if (control == null) 63 | throw new ArgumentNullException ("control"); 64 | 65 | - object[] args = new object[] { control.Handle, point.X, point.Y }; 66 | - InvokeMethod ("ScreenToClient", args); 67 | - return new Point ((int) args[1], (int) args[2]); 68 | + if (_onMSNET) { 69 | + POINT pt = new POINT (point.X, point.Y); 70 | + ScreenToClient (control.Handle, ref pt); 71 | + return new Point (pt.X, pt.Y); 72 | + } 73 | + else { 74 | + object[] args = new object[] { control.Handle, point.X, point.Y }; 75 | + InvokeMethod ("ScreenToClient", args); 76 | + return new Point ((int) args[1], (int) args[2]); 77 | + } 78 | } 79 | 80 | public static IntPtr SetParent (IntPtr childHandle, IntPtr parentHandle) 81 | { 82 | - return (IntPtr) InvokeMethod ("SetParent", new object[] { childHandle, parentHandle }); 83 | + if (_onMSNET) 84 | + return SetParent_Win32 (childHandle, parentHandle); 85 | + else 86 | + return (IntPtr) InvokeMethod ("SetParent", new object[] { childHandle, parentHandle }); 87 | } 88 | 89 | 90 | @@ -211,6 +231,31 @@ 91 | // 92 | WM_MOUSE_ENTER = 0x0401, 93 | } 94 | + 95 | +#region Win32 Native Method Signatures 96 | + [StructLayout(LayoutKind.Sequential)] 97 | + private struct POINT { 98 | + public POINT (int x, int y) { 99 | + this.X = x; 100 | + this.Y = y; 101 | + } 102 | + 103 | + public int X; 104 | + public int Y; 105 | + } 106 | + 107 | + [DllImport("user32.dll", CharSet=CharSet.Auto)] 108 | + private static extern IntPtr DefWindowProc (IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); 109 | + 110 | + [DllImport ("user32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto)] 111 | + private static extern IntPtr SendMessage_Win32 (IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); 112 | + 113 | + [DllImport ("user32.dll", CharSet = CharSet.Auto)] 114 | + private static extern bool ScreenToClient (IntPtr hWnd, ref POINT pt); 115 | + 116 | + [DllImport ("user32.dll", EntryPoint = "SetParent", CharSet = CharSet.Auto)] 117 | + private static extern IntPtr SetParent_Win32 (IntPtr childHandle, IntPtr parentHandle); 118 | +#endregion 119 | } 120 | } 121 | 122 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.Windows.Forms.Design/PanelDesigner.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Windows.Forms.Design.PanelDesigner 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2008 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | using System; 31 | using System.ComponentModel; 32 | using System.ComponentModel.Design; 33 | using System.Windows.Forms; 34 | using System.Drawing; 35 | using System.Drawing.Drawing2D; 36 | using System.Drawing.Design; 37 | using System.Collections; 38 | 39 | using System.Windows.Forms.Design; 40 | namespace Mono.Design 41 | { 42 | internal class PanelDesigner : ParentControlDesigner 43 | { 44 | 45 | public PanelDesigner () 46 | { 47 | } 48 | 49 | public override void Initialize (IComponent component) 50 | { 51 | base.Initialize (component); 52 | } 53 | 54 | protected override void OnPaintAdornments (PaintEventArgs pe) 55 | { 56 | base.OnPaintAdornments (pe); 57 | 58 | GraphicsState state = pe.Graphics.Save (); 59 | pe.Graphics.TranslateTransform (this.Control.ClientRectangle.X, 60 | this.Control.ClientRectangle.Y); 61 | ControlPaint.DrawBorder (pe.Graphics, Control.ClientRectangle, SystemColors.ControlDarkDark, 62 | ButtonBorderStyle.Dashed); 63 | pe.Graphics.Restore (state); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.Windows.Forms.Design/ScrollableControlDesigner.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Windows.Forms.Design.ScrollableControlDesigner 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006-2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.ComponentModel; 33 | using System.ComponentModel.Design; 34 | using System.Windows.Forms; 35 | using System.Drawing; 36 | using System.Drawing.Design; 37 | using System.Collections; 38 | 39 | 40 | 41 | using System.Windows.Forms.Design; 42 | namespace Mono.Design 43 | { 44 | 45 | public class ScrollableControlDesigner : ParentControlDesigner 46 | { 47 | 48 | public ScrollableControlDesigner () 49 | { 50 | } 51 | 52 | private const int HTHSCROLL = 6; 53 | private const int HTVSCROLL = 7; 54 | 55 | protected override bool GetHitTest (Point point) 56 | { 57 | if (base.GetHitTest (point)) { 58 | return true; 59 | } 60 | 61 | // Check if the user has clicked on the scroll bars and forward the message to 62 | // the ScrollableControl. (Don't filter out the scrolling.). Keep in mind that scrollbars 63 | // will be shown only if ScrollableControl.AutoScroll = true 64 | // 65 | if (this.Control is ScrollableControl && ((ScrollableControl)Control).AutoScroll) { 66 | int hitTestResult = (int) Native.SendMessage (this.Control.Handle, 67 | Native.Msg.WM_NCHITTEST, 68 | IntPtr.Zero, 69 | (IntPtr) Native.LParam (point.X, point.Y)); 70 | if (hitTestResult == HTHSCROLL || hitTestResult == HTVSCROLL) 71 | return true; 72 | } 73 | return false; 74 | } 75 | 76 | 77 | protected override void WndProc (ref Message m) 78 | { 79 | base.WndProc (ref m); 80 | if (m.Msg == (int)Native.Msg.WM_HSCROLL || m.Msg == (int)Native.Msg.WM_VSCROLL) 81 | this.DefWndProc (ref m); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.Windows.Forms.Design/SplitContainerDesigner.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Windows.Forms.Design.SplitContainerDesigner 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | 31 | using System; 32 | using System.ComponentModel; 33 | using System.ComponentModel.Design; 34 | using System.Windows.Forms; 35 | using System.Drawing; 36 | using System.Drawing.Design; 37 | using System.Collections; 38 | 39 | 40 | 41 | using System.Windows.Forms.Design; 42 | namespace Mono.Design 43 | { 44 | 45 | internal class SplitContainerDesigner : ParentControlDesigner 46 | { 47 | 48 | public SplitContainerDesigner () 49 | { 50 | } 51 | 52 | public override void Initialize (IComponent component) 53 | { 54 | base.Initialize (component); 55 | SplitContainer container = (SplitContainer) component; 56 | base.EnableDesignMode (container.Panel1, "Panel1"); 57 | base.EnableDesignMode (container.Panel2, "Panel2"); 58 | } 59 | 60 | public override ControlDesigner InternalControlDesigner (int internalControlIndex) 61 | { 62 | switch (internalControlIndex) { 63 | case 0: 64 | return GetDesigner (((SplitContainer)this.Control).Panel1); 65 | case 1: 66 | return GetDesigner (((SplitContainer)this.Control).Panel2); 67 | } 68 | return null; 69 | } 70 | 71 | private ControlDesigner GetDesigner (IComponent component) 72 | { 73 | IDesignerHost host = this.GetService (typeof (IDesignerHost)) as IDesignerHost; 74 | if (host != null) 75 | return host.GetDesigner (component) as ControlDesigner; 76 | else 77 | return null; 78 | } 79 | 80 | public override int NumberOfInternalControlDesigners () 81 | { 82 | return 2; 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System.Design/System.Windows.Forms.Design/WndProcRouter.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Windows.Forms.Design.WndProcRouter 3 | // 4 | // Authors: 5 | // Ivan N. Zlatev (contact i-nZ.net) 6 | // 7 | // (C) 2006-2007 Ivan N. Zlatev 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | using System; 31 | using System.ComponentModel; 32 | using System.ComponentModel.Design; 33 | using System.Windows.Forms; 34 | using System.Drawing; 35 | using System.Drawing.Design; 36 | using System.Collections; 37 | 38 | // Automatically reroutes Messages to the designer 39 | // 40 | 41 | using System.Windows.Forms.Design; 42 | namespace Mono.Design 43 | { 44 | 45 | internal class WndProcRouter : IWindowTarget, IDisposable 46 | { 47 | private IWindowTarget _oldTarget; 48 | private IMessageReceiver _receiver; 49 | private Control _control; 50 | 51 | public WndProcRouter (Control control, IMessageReceiver receiver) 52 | { 53 | if (control == null) 54 | throw new ArgumentNullException ("control"); 55 | if (receiver == null) 56 | throw new ArgumentNullException ("receiver"); 57 | 58 | _oldTarget = control.WindowTarget; 59 | _control = control; 60 | _receiver = receiver; 61 | } 62 | 63 | public Control Control { 64 | get { return _control; } 65 | } 66 | 67 | public IWindowTarget OldWindowTarget { 68 | get { return _oldTarget; } 69 | } 70 | 71 | // Route the message to the control 72 | // 73 | public void ToControl (ref Message m) 74 | { 75 | //Console.WriteLine ("Control: " + ((Native.Msg)m.Msg).ToString ()); 76 | if (_oldTarget != null) 77 | _oldTarget.OnMessage (ref m); 78 | } 79 | 80 | public void ToSystem (ref Message m) 81 | { 82 | //Console.WriteLine ("System: " + ((Native.Msg)m.Msg).ToString ()); 83 | Native.DefWndProc (ref m); 84 | } 85 | 86 | // Just pass it to the old IWindowTarget 87 | // 88 | void IWindowTarget.OnHandleChange (IntPtr newHandle) 89 | { 90 | if (_oldTarget != null) 91 | _oldTarget.OnHandleChange (newHandle); 92 | } 93 | 94 | // Route the msg to the designer if available, else to 95 | // control itself. 96 | // 97 | void IWindowTarget.OnMessage (ref Message m) 98 | { 99 | //Console.WriteLine ("Message: " + ((Native.Msg)m.Msg).ToString ()); 100 | if (_receiver != null) 101 | _receiver.WndProc (ref m); 102 | else 103 | this.ToControl (ref m); 104 | } 105 | 106 | // Disposes and puts back the old IWindowTarget 107 | // 108 | public void Dispose () 109 | { 110 | if (_control != null) 111 | _control.WindowTarget = _oldTarget; 112 | 113 | _control = null; 114 | _oldTarget = null; 115 | } 116 | 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System/System.ComponentModel.Design.Serialization/DefaultSerializationProviderAttribute.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System.ComponentModel.Design.Serialization; 8 | namespace Mono.Design { 9 | using System.Security.Permissions; 10 | using System; 11 | 12 | /// 13 | /// The default serialization provider attribute is placed on a serializer 14 | /// to indicate the class to use as a default provider of that type of 15 | /// serializer. To be a default serialization provider, a class must 16 | /// implement IDesignerSerilaizationProvider and have an empty 17 | /// constructor. The class itself can be internal to the assembly. 18 | /// 19 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 20 | public sealed class DefaultSerializationProviderAttribute : Attribute { 21 | 22 | private string _providerTypeName; 23 | 24 | /// 25 | /// Creates a new DefaultSerializationProviderAttribute 26 | /// 27 | public DefaultSerializationProviderAttribute(Type providerType) { 28 | 29 | if (providerType == null) { 30 | throw new ArgumentNullException("providerType"); 31 | } 32 | 33 | _providerTypeName = providerType.AssemblyQualifiedName; 34 | } 35 | 36 | /// 37 | /// Creates a new DefaultSerializationProviderAttribute 38 | /// 39 | public DefaultSerializationProviderAttribute(string providerTypeName) { 40 | 41 | if (providerTypeName == null) { 42 | throw new ArgumentNullException("providerTypeName"); 43 | } 44 | 45 | _providerTypeName = providerTypeName; 46 | } 47 | 48 | /// 49 | /// Returns the type name for the default serialization provider. 50 | /// 51 | public string ProviderTypeName { 52 | get { 53 | return _providerTypeName; 54 | } 55 | } 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System/System.ComponentModel.Design.Serialization/SerializationStore.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System.ComponentModel.Design.Serialization; 8 | namespace Mono.Design { 9 | 10 | using System.Collections; 11 | using System.ComponentModel; 12 | using System.IO; 13 | using System.Security.Permissions; 14 | using System; 15 | /// 16 | /// The SerializationStore class is an implementation-specific class that stores 17 | /// serialization data for the component serialization service. The 18 | /// service adds state to this serialization store. Once the store is 19 | /// closed it can be saved to a stream. A serialization store can be 20 | /// deserialized at a later date by the same type of serialization service. 21 | /// SerializationStore implements the IDisposable interface such that Dispose 22 | /// simply calls the Close method. Dispose is implemented as a private 23 | /// interface to avoid confusion. The IDisposable pattern is provided 24 | /// for languages that support a "using" syntax like C# and VB .NET. 25 | /// 26 | [HostProtection(SharedState = true)] 27 | public abstract class SerializationStore : IDisposable 28 | { 29 | 30 | /// 31 | /// If there were errors generated during serialization or deserialization of the store, they will be 32 | /// added to this collection. 33 | /// 34 | public abstract ICollection Errors { get; } 35 | 36 | /// 37 | /// The Close method closes this store and prevents any objects 38 | /// from being serialized into it. Once closed, the serialization store may be saved. 39 | /// 40 | public abstract void Close(); 41 | 42 | /// 43 | /// The Save method saves the store to the given stream. If the store 44 | /// is open, Save will automatically close it for you. You 45 | /// can call save as many times as you wish to save the store 46 | /// to different streams. 47 | /// 48 | public abstract void Save(Stream stream); 49 | 50 | /// 51 | /// Disposes this object by calling the Close method. 52 | /// 53 | void IDisposable.Dispose() {Dispose(true);} 54 | 55 | protected virtual void Dispose(bool disposing) { 56 | if(disposing) Close(); 57 | } 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System/System.ComponentModel.Design/AssemblyRef.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Mono.Design 4 | { 5 | internal static class AssemblyRef 6 | { 7 | internal const string SystemConfiguration = "System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; 8 | 9 | internal const string System = "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; 10 | 11 | public const string EcmaPublicKey = "b77a5c561934e089"; 12 | 13 | public const string FrameworkPublicKeyFull = "00000000000000000400000000000000"; 14 | 15 | public const string FrameworkPublicKeyFull2 = "00000000000000000400000000000000"; 16 | 17 | public const string MicrosoftPublicKey = "b03f5f7f11d50a3a"; 18 | 19 | public const string MicrosoftJScript = "Microsoft.JScript, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; 20 | 21 | public const string MicrosoftVSDesigner = "Microsoft.VSDesigner, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; 22 | 23 | public const string SystemData = "System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; 24 | 25 | public const string SystemDesign = "System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; 26 | 27 | public const string SystemDrawing = "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; 28 | 29 | public const string SystemWeb = "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; 30 | 31 | public const string SystemWebExtensions = "System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; 32 | 33 | public const string SystemWindowsForms = "System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System/System.ComponentModel.Design/IComponentInitializer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | /* 8 | */ 9 | using System.ComponentModel.Design; 10 | namespace Mono.Design { 11 | 12 | using System; 13 | using System.Collections; 14 | 15 | /// 16 | /// IComponentInitializer can be implemented on an object that also implements IDesigner. 17 | /// This interface allows a newly created component to be given some stock default values, 18 | /// such as a caption, default size, or other values. Recommended default values for 19 | /// the component's properties are passed in as a dictionary. 20 | /// 21 | public interface IComponentInitializer { 22 | 23 | /// 24 | /// This method is called when an existing component is being re-initialized. This may occur after 25 | /// dragging a component to another container, for example. The defaultValues 26 | /// property contains a name/value dictionary of default values that should be applied 27 | /// to properties. This dictionary may be null if no default values are specified. 28 | /// You may use the defaultValues dictionary to apply recommended defaults to proeprties 29 | /// but you should not modify component properties beyond what is stored in the 30 | /// dictionary, because this is an existing component that may already have properties 31 | /// set on it. 32 | /// 33 | void InitializeExistingComponent(IDictionary defaultValues); 34 | 35 | /// 36 | /// This method is called when a component is first initialized, typically after being first added 37 | /// to a design surface. The defaultValues property contains a name/value dictionary of default 38 | /// values that should be applied to properties. This dictionary may be null if no default values 39 | /// are specified. You may perform any initialization of this component that you like, and you 40 | /// may even ignore the defaultValues dictionary altogether if you wish. 41 | /// 42 | void InitializeNewComponent(IDictionary defaultValues); 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System/System.ComponentModel.Design/ITreeDesigner.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | /* 8 | */ 9 | using System.ComponentModel.Design; 10 | namespace Mono.Design { 11 | 12 | using System; 13 | using System.Collections; 14 | 15 | /// 16 | /// ITreeDesigner is a variation of IDesigner that provides support for 17 | /// generically indicating parent / child relationships within a designer. 18 | /// 19 | public interface ITreeDesigner : IDesigner { 20 | 21 | /// 22 | /// Retrieves the children of this designer. This will return an empty collection 23 | /// if this designer has no children. 24 | /// 25 | ICollection Children { get; } 26 | 27 | /// 28 | /// Retrieves the parent designer for this designer. This may return null if 29 | /// there is no parent. 30 | /// 31 | IDesigner Parent { get; } 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System/System.ComponentModel/INestedContainer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System.ComponentModel; 8 | namespace Mono.Design { 9 | 10 | /// 11 | /// A "nested container" is an object that logically contains zero or more child 12 | /// components and is controlled (owned) by some parent component. 13 | /// 14 | /// In this context, "containment" refers to logical containment, not visual 15 | /// containment. Components and containers can be used in a variety of 16 | /// scenarios, including both visual and non-visual scenarios. 17 | /// 18 | public interface INestedContainer : IContainer { 19 | 20 | /// 21 | /// The component that owns this nested container. 22 | /// 23 | IComponent Owner { get; } 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /deps/Mono.Design/class/System/System.ComponentModel/INestedSite.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System.ComponentModel; 8 | namespace Mono.Design { 9 | 10 | using System; 11 | 12 | /// 13 | /// Nested containers site objects using INestedSite. A nested 14 | /// site is simply a site with an additional property that can 15 | /// retrieve the full nested name of a component. 16 | /// 17 | public interface INestedSite : ISite { 18 | 19 | /// 20 | /// Returns the full name of the component in this site in the format 21 | /// of .. If this component's site has a null 22 | /// name, FullName also returns null. 23 | /// 24 | string FullName { get; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /deps/Mono.Design/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = "")] 3 | -------------------------------------------------------------------------------- /deps/Mono.Design/obj/Debug/Mono.Design.csproj.FilesWrittenAbsolute.txt: -------------------------------------------------------------------------------- 1 | /home/leo/mwf-designer/deps/Mono.Design/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs 2 | /home/leo/mwf-designer/deps/Mono.Design.dll.mdb 3 | /home/leo/mwf-designer/deps/Mono.Design.dll 4 | /home/leo/mwf-designer/deps/Mono.Design/obj/Debug/Mono.Design.dll 5 | /home/leo/mwf-designer/deps/Mono.Design/obj/Debug/Mono.Design.dll.mdb 6 | -------------------------------------------------------------------------------- /deps/Mono.Design/obj/Debug/Mono.Design.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/deps/Mono.Design/obj/Debug/Mono.Design.dll -------------------------------------------------------------------------------- /deps/Mono.Design/obj/Debug/Mono.Design.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/deps/Mono.Design/obj/Debug/Mono.Design.dll.mdb -------------------------------------------------------------------------------- /deps/Mono.Design/patches/CodeDomComponentSerializationService-error-reporting.patch: -------------------------------------------------------------------------------- 1 | --- class/System.Design/System.ComponentModel.Design.Serialization/CodeDomComponentSerializationService.cs 2008-07-10 16:24:08.000000000 +0100 2 | +++ class/System.Design/System.ComponentModel.Design.Serialization/CodeDomComponentSerializationService.cs 2008-03-01 23:30:26.000000000 +0000 3 | @@ -38,6 +38,8 @@ 4 | using System.Collections.Generic; 5 | using System.IO; 6 | 7 | +using System.Windows.Forms.Design; 8 | + 9 | namespace System.ComponentModel.Design.Serialization 10 | { 11 | // A ComponentSerializationService that uses a CodeDomSerializationStore 12 | @@ -371,9 +373,25 @@ 13 | } 14 | } 15 | _errors = manager.Errors; 16 | + ReportErrors (provider, _errors); 17 | session.Dispose (); 18 | } 19 | 20 | + private void ReportErrors (IServiceProvider provider, ICollection errors) 21 | + { 22 | + IUIService service = provider.GetService (typeof (IUIService)) as IUIService; 23 | + if (service != null) { 24 | + foreach (object error in errors) { 25 | + if (error is Exception) 26 | + service.ShowError ((Exception) error); 27 | + else if (error is string) 28 | + service.ShowError ((string) error); 29 | + else 30 | + service.ShowError (error.ToString ()); 31 | + } 32 | + } 33 | + } 34 | + 35 | internal void AddObject (object instance, bool absolute) 36 | { 37 | if (_closed) 38 | @@ -451,6 +469,7 @@ 39 | foreach (ObjectEntry entry in _objects.Values) 40 | objectInstances.Add (DeserializeEntry (manager, entry)); 41 | _errors = manager.Errors; 42 | + ReportErrors (provider, _errors); 43 | session.Dispose (); 44 | return objectInstances; 45 | } 46 | -------------------------------------------------------------------------------- /deps/Mono.Design/patches/CodeDomSerializerBase-msnet-extenderproperty-fix.patch: -------------------------------------------------------------------------------- 1 | --- class/System.Design/System.ComponentModel.Design.Serialization/CodeDomSerializerBase.cs 2008-07-10 16:24:08.000000000 +0100 2 | +++ class/System.Design/System.ComponentModel.Design.Serialization/CodeDomSerializerBase.cs 2008-03-06 19:55:40.000000000 +0000 3 | @@ -850,7 +850,11 @@ 4 | if (value != null && value != _errorMarker && propertyHolder != null) { 5 | PropertyDescriptor property = TypeDescriptor.GetProperties (propertyHolder)[propRef.PropertyName]; 6 | if (property != null) { 7 | - property.SetValue (propertyHolder, value); 8 | + try { 9 | + property.SetValue (propertyHolder, value); 10 | + } catch { 11 | + // FIXME: This is just for testing on MSNET 12 | + } 13 | } else { 14 | ReportError (manager, 15 | "Missing property '" + propRef.PropertyName + 16 | -------------------------------------------------------------------------------- /deps/Mono.Design/patches/DesignerHost-designer-type-replacement.patch: -------------------------------------------------------------------------------- 1 | --- class/System.Design/System.ComponentModel.Design/DesignerHost.cs 2008-07-10 16:24:08.000000000 +0100 2 | +++ class/System.Design/System.ComponentModel.Design/DesignerHost.cs 2008-06-28 02:26:15.000000000 +0100 3 | @@ -322,9 +324,7 @@ 4 | if (designerAttr != null && 5 | (designerBaseType.FullName == designerAttr.DesignerBaseTypeName || 6 | designerBaseType.AssemblyQualifiedName == designerAttr.DesignerBaseTypeName)) { 7 | - Type type = Type.GetType (designerAttr.DesignerTypeName); 8 | - if (type == null && designerBaseType == typeof (IRootDesigner)) 9 | - type = typeof (System.Windows.Forms.Design.DocumentDesigner); 10 | + Type type = this.GetDesignerType (designerAttr.DesignerTypeName); 11 | if (type != null) 12 | instance = (IDesigner) Activator.CreateInstance (type); 13 | break; 14 | @@ -340,9 +340,10 @@ 15 | if (designerAttr != null && 16 | (designerBaseType.FullName == designerAttr.DesignerBaseTypeName || 17 | designerBaseType.AssemblyQualifiedName == designerAttr.DesignerBaseTypeName)) { 18 | - Type type = Type.GetType (designerAttr.DesignerTypeName); 19 | - if (type != null) 20 | + Type type = this.GetDesignerType (designerAttr.DesignerTypeName); 21 | + if (type != null) { 22 | instance = (IDesigner) Activator.CreateInstance (type); 23 | + } 24 | break; 25 | } 26 | } 27 | @@ -353,6 +354,39 @@ 28 | return instance; 29 | } 30 | 31 | + // reroutes types to Mono.Design temoprary for testing 32 | + private Type GetDesignerType (string name) 33 | + { 34 | + Type type = null; 35 | + if (name.StartsWith ("System.Windows.Forms.Design.ControlDesigner")) 36 | + type = typeof (Mono.Design.ControlDesigner); 37 | + else if (name.StartsWith ("System.Windows.Forms.Design.SplitContainerDesigner")) 38 | + type = typeof (Mono.Design.SplitContainerDesigner); 39 | + else if (name.StartsWith ("System.Windows.Forms.Design.ParentControlDesigner")) 40 | + type = typeof (Mono.Design.ParentControlDesigner); 41 | + else if (name.StartsWith ("System.Windows.Forms.Design.PanelDesigner")) 42 | + type = typeof (Mono.Design.PanelDesigner); 43 | + else if (name.StartsWith ("System.Windows.Forms.Design.DocumentDesigner")) 44 | + type = typeof (Mono.Design.DocumentDesigner); 45 | + else if (name.StartsWith ("System.Windows.Forms.Design.UserControlDocumentDesigner")) 46 | + type = typeof (Mono.Design.DocumentDesigner); 47 | + else if (name.StartsWith ("System.Windows.Forms.Design.FormDocumentDesigner")) 48 | + type = typeof (Mono.Design.FormDocumentDesigner); 49 | + else if (name.StartsWith ("System.Windows.Forms.Design.ScrollableControlDesigner")) 50 | + type = typeof (Mono.Design.ScrollableControlDesigner); 51 | + else if (name.StartsWith ("System.ComponentModel.Design.ComponentDesigner")) 52 | + type = typeof (Mono.Design.ComponentDesigner); 53 | + else if (name.StartsWith ("Mono.Design")) 54 | + type = Type.GetType (name); 55 | + 56 | + if (type != null) 57 | + Console.WriteLine ("type " + type.FullName +" replaced " + name); 58 | + //else 59 | + //Console.WriteLine ("type not found: " + name); 60 | + 61 | + return type; 62 | + } 63 | + 64 | public void DestroyComponent (IComponent component) 65 | { 66 | if (component.Site != null && component.Site.Container == this) { 67 | -------------------------------------------------------------------------------- /deps/Mono.Design/patches/DesignerSerializationManager-serializer-type-replacement.patch: -------------------------------------------------------------------------------- 1 | --- class/System.Design/System.ComponentModel.Design.Serialization/DesignerSerializationManager.cs 2008-07-10 16:24:08.000000000 +0100 2 | +++ class/System.Design/System.ComponentModel.Design.Serialization/DesignerSerializationManager.cs 2008-02-29 01:39:38.000000000 +0000 3 | @@ -257,9 +257,9 @@ 4 | AttributeCollection attributes = TypeDescriptor.GetAttributes (componentType); 5 | DesignerSerializerAttribute serializerAttribute = attributes[typeof (DesignerSerializerAttribute)] as DesignerSerializerAttribute; 6 | if (serializerAttribute != null && 7 | - this.GetType (serializerAttribute.SerializerBaseTypeName) == serializerType) { 8 | + this.GetSerializerType (serializerAttribute.SerializerBaseTypeName) == serializerType) { 9 | try { 10 | - serializer = Activator.CreateInstance (this.GetType (serializerAttribute.SerializerTypeName), 11 | + serializer = Activator.CreateInstance (this.GetSerializerType (serializerAttribute.SerializerTypeName), 12 | BindingFlags.CreateInstance | BindingFlags.Instance | 13 | BindingFlags.Public | BindingFlags.NonPublic, 14 | null, null, null); 15 | @@ -283,6 +283,22 @@ 16 | return serializer; 17 | } 18 | 19 | + private Type GetSerializerType (string name) 20 | + { 21 | + Type type = null; 22 | + if (name.StartsWith ("System.ComponentModel.Design.Serialization.CodeDomSerializer")) 23 | + type = typeof (Mono.Design.CodeDomSerializer); 24 | + else if (name.StartsWith ("System.Windows.Forms.Design.ControlCodeDomSerializer")) 25 | + type = typeof (Mono.Design.ControlCodeDomSerializer); 26 | + else if (name.StartsWith ("System.ComponentModel.Design.Serialization.RootCodeDomSerializer")) 27 | + type = typeof (Mono.Design.RootCodeDomSerializer); 28 | + 29 | + // if (type != null) 30 | + // Console.WriteLine ("type " + type.FullName +" replaced " + name); 31 | + 32 | + return type; 33 | + } 34 | + 35 | private void VerifyInSession () 36 | { 37 | if (_session == null) 38 | -------------------------------------------------------------------------------- /deps/Mono.Design/patches/Native-win32 (复件).patch: -------------------------------------------------------------------------------- 1 | --- class/System.Design/System.Windows.Forms.Design/Native.cs 2008-07-10 16:24:08.000000000 +0100 2 | +++ class/System.Design/System.Windows.Forms.Design/Native.cs 2008-04-07 14:28:36.000000000 +0100 3 | @@ -40,16 +40,18 @@ 4 | { 5 | 6 | private static Type _xplatuiType; 7 | + private static bool _onMSNET; 8 | 9 | static Native () 10 | { 11 | - Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); 12 | + _onMSNET = false; 13 | + Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); 14 | if (assembly == null) 15 | throw new InvalidOperationException ("Can't load System.Windows.Forms assembly."); 16 | 17 | _xplatuiType = assembly.GetType ("System.Windows.Forms.XplatUI"); 18 | if (_xplatuiType == null) 19 | - throw new InvalidOperationException ("Can't find the System.Windows.Forms.XplatUI type."); 20 | + _onMSNET = true; 21 | } 22 | 23 | private static object InvokeMethod (string methodName, object[] args) 24 | @@ -78,19 +80,27 @@ 25 | 26 | public static void DefWndProc (ref Message m) 27 | { 28 | - object[] args = new object[] { m }; 29 | - m.Result = (IntPtr) InvokeMethod ("DefWndProc", args); 30 | - m = (Message) args[0]; 31 | + if (_onMSNET) { 32 | + m.Result = DefWindowProc (m.HWnd, m.Msg, m.WParam, m.LParam); 33 | + } 34 | + else { 35 | + object[] args = new object[] { m }; 36 | + m.Result = (IntPtr) InvokeMethod ("DefWndProc", args); 37 | + m = (Message) args[0]; 38 | + } 39 | } 40 | 41 | public static IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) 42 | { 43 | - 44 | - Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); 45 | - Type refType = assembly.GetType ("System.Windows.Forms.Message&"); 46 | - object[] args = new object[] { Message.Create (hwnd, (int)message, wParam, lParam) }; 47 | - InvokeMethod ("SendMessage", args, new Type[] { refType }); 48 | - return ((Message)args[0]).Result; 49 | + if (_onMSNET) { 50 | + return SendMessage_Win32 (hwnd, (int) message, wParam, lParam); 51 | + } else { 52 | + Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); 53 | + Type refType = assembly.GetType ("System.Windows.Forms.Message&"); 54 | + object[] args = new object[] { Message.Create (hwnd, (int)message, wParam, lParam) }; 55 | + InvokeMethod ("SendMessage", args, new Type[] { refType }); 56 | + return ((Message)args[0]).Result; 57 | + } 58 | } 59 | 60 | public static Point PointToClient (Control control, Point point) 61 | @@ -98,14 +108,24 @@ 62 | if (control == null) 63 | throw new ArgumentNullException ("control"); 64 | 65 | - object[] args = new object[] { control.Handle, point.X, point.Y }; 66 | - InvokeMethod ("ScreenToClient", args); 67 | - return new Point ((int) args[1], (int) args[2]); 68 | + if (_onMSNET) { 69 | + POINT pt = new POINT (point.X, point.Y); 70 | + ScreenToClient (control.Handle, ref pt); 71 | + return new Point (pt.X, pt.Y); 72 | + } 73 | + else { 74 | + object[] args = new object[] { control.Handle, point.X, point.Y }; 75 | + InvokeMethod ("ScreenToClient", args); 76 | + return new Point ((int) args[1], (int) args[2]); 77 | + } 78 | } 79 | 80 | public static IntPtr SetParent (IntPtr childHandle, IntPtr parentHandle) 81 | { 82 | - return (IntPtr) InvokeMethod ("SetParent", new object[] { childHandle, parentHandle }); 83 | + if (_onMSNET) 84 | + return SetParent_Win32 (childHandle, parentHandle); 85 | + else 86 | + return (IntPtr) InvokeMethod ("SetParent", new object[] { childHandle, parentHandle }); 87 | } 88 | 89 | 90 | @@ -211,6 +231,31 @@ 91 | // 92 | WM_MOUSE_ENTER = 0x0401, 93 | } 94 | + 95 | +#region Win32 Native Method Signatures 96 | + [StructLayout(LayoutKind.Sequential)] 97 | + private struct POINT { 98 | + public POINT (int x, int y) { 99 | + this.X = x; 100 | + this.Y = y; 101 | + } 102 | + 103 | + public int X; 104 | + public int Y; 105 | + } 106 | + 107 | + [DllImport("user32.dll", CharSet=CharSet.Auto)] 108 | + private static extern IntPtr DefWindowProc (IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); 109 | + 110 | + [DllImport ("user32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto)] 111 | + private static extern IntPtr SendMessage_Win32 (IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); 112 | + 113 | + [DllImport ("user32.dll", CharSet = CharSet.Auto)] 114 | + private static extern bool ScreenToClient (IntPtr hWnd, ref POINT pt); 115 | + 116 | + [DllImport ("user32.dll", EntryPoint = "SetParent", CharSet = CharSet.Auto)] 117 | + private static extern IntPtr SetParent_Win32 (IntPtr childHandle, IntPtr parentHandle); 118 | +#endregion 119 | } 120 | } 121 | 122 | -------------------------------------------------------------------------------- /deps/Mono.Design/patches/Native.patch: -------------------------------------------------------------------------------- 1 | --- class/System.Design/System.Windows.Forms.Design/Native.cs 2008-07-10 16:24:08.000000000 +0100 2 | +++ class/System.Design/System.Windows.Forms.Design/Native.cs 2008-04-07 14:28:36.000000000 +0100 3 | @@ -40,16 +40,18 @@ 4 | { 5 | 6 | private static Type _xplatuiType; 7 | + private static bool _onMSNET; 8 | 9 | static Native () 10 | { 11 | - Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); 12 | + _onMSNET = false; 13 | + Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); 14 | if (assembly == null) 15 | throw new InvalidOperationException ("Can't load System.Windows.Forms assembly."); 16 | 17 | _xplatuiType = assembly.GetType ("System.Windows.Forms.XplatUI"); 18 | if (_xplatuiType == null) 19 | - throw new InvalidOperationException ("Can't find the System.Windows.Forms.XplatUI type."); 20 | + _onMSNET = true; 21 | } 22 | 23 | private static object InvokeMethod (string methodName, object[] args) 24 | @@ -78,19 +80,27 @@ 25 | 26 | public static void DefWndProc (ref Message m) 27 | { 28 | - object[] args = new object[] { m }; 29 | - m.Result = (IntPtr) InvokeMethod ("DefWndProc", args); 30 | - m = (Message) args[0]; 31 | + if (_onMSNET) { 32 | + m.Result = DefWindowProc (m.HWnd, m.Msg, m.WParam, m.LParam); 33 | + } 34 | + else { 35 | + object[] args = new object[] { m }; 36 | + m.Result = (IntPtr) InvokeMethod ("DefWndProc", args); 37 | + m = (Message) args[0]; 38 | + } 39 | } 40 | 41 | public static IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) 42 | { 43 | - 44 | - Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); 45 | - Type refType = assembly.GetType ("System.Windows.Forms.Message&"); 46 | - object[] args = new object[] { Message.Create (hwnd, (int)message, wParam, lParam) }; 47 | - InvokeMethod ("SendMessage", args, new Type[] { refType }); 48 | - return ((Message)args[0]).Result; 49 | + if (_onMSNET) { 50 | + return SendMessage_Win32 (hwnd, (int) message, wParam, lParam); 51 | + } else { 52 | + Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); 53 | + Type refType = assembly.GetType ("System.Windows.Forms.Message&"); 54 | + object[] args = new object[] { Message.Create (hwnd, (int)message, wParam, lParam) }; 55 | + InvokeMethod ("SendMessage", args, new Type[] { refType }); 56 | + return ((Message)args[0]).Result; 57 | + } 58 | } 59 | 60 | public static Point PointToClient (Control control, Point point) 61 | @@ -98,14 +108,24 @@ 62 | if (control == null) 63 | throw new ArgumentNullException ("control"); 64 | 65 | - object[] args = new object[] { control.Handle, point.X, point.Y }; 66 | - InvokeMethod ("ScreenToClient", args); 67 | - return new Point ((int) args[1], (int) args[2]); 68 | + if (_onMSNET) { 69 | + POINT pt = new POINT (point.X, point.Y); 70 | + ScreenToClient (control.Handle, ref pt); 71 | + return new Point (pt.X, pt.Y); 72 | + } 73 | + else { 74 | + object[] args = new object[] { control.Handle, point.X, point.Y }; 75 | + InvokeMethod ("ScreenToClient", args); 76 | + return new Point ((int) args[1], (int) args[2]); 77 | + } 78 | } 79 | 80 | public static IntPtr SetParent (IntPtr childHandle, IntPtr parentHandle) 81 | { 82 | - return (IntPtr) InvokeMethod ("SetParent", new object[] { childHandle, parentHandle }); 83 | + if (_onMSNET) 84 | + return SetParent_Win32 (childHandle, parentHandle); 85 | + else 86 | + return (IntPtr) InvokeMethod ("SetParent", new object[] { childHandle, parentHandle }); 87 | } 88 | 89 | 90 | @@ -211,6 +231,31 @@ 91 | // 92 | WM_MOUSE_ENTER = 0x0401, 93 | } 94 | + 95 | +#region Win32 Native Method Signatures 96 | + [StructLayout(LayoutKind.Sequential)] 97 | + private struct POINT { 98 | + public POINT (int x, int y) { 99 | + this.X = x; 100 | + this.Y = y; 101 | + } 102 | + 103 | + public int X; 104 | + public int Y; 105 | + } 106 | + 107 | + [DllImport("user32.dll", CharSet=CharSet.Auto)] 108 | + private static extern IntPtr DefWindowProc (IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); 109 | + 110 | + [DllImport ("user32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto)] 111 | + private static extern IntPtr SendMessage_Win32 (IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); 112 | + 113 | + [DllImport ("user32.dll", CharSet = CharSet.Auto)] 114 | + private static extern bool ScreenToClient (IntPtr hWnd, ref POINT pt); 115 | + 116 | + [DllImport ("user32.dll", EntryPoint = "SetParent", CharSet = CharSet.Auto)] 117 | + private static extern IntPtr SetParent_Win32 (IntPtr childHandle, IntPtr parentHandle); 118 | +#endregion 119 | } 120 | } 121 | 122 | -------------------------------------------------------------------------------- /deps/Mono.Design/patches/patch.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/deps/Mono.Design/patches/patch.exe -------------------------------------------------------------------------------- /docs/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 Ivan N. Zlatev 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /docs/README.txt: -------------------------------------------------------------------------------- 1 | === On Mono === 2 | 3 | make && make run 4 | 5 | === On Microsoft .NET with Visual Studio === 6 | 7 | 1) Install Python - http://python.org/download/ 8 | 2) Run "Prepare Visual Studio Build.bat" 9 | 3) Open mwf-designer.sln with Visual Studio and you are done! 10 | 11 | What is happening automatically behind the scenes is the generation of a 12 | Mono.Design assembly - a subset of Mono's System.Design. 13 | 14 | The python script will: 15 | - Download a subset of Mono System.Design assembly's source code from SVN 16 | - Apply a set of patches to make it run against Microsoft .NET 17 | - Change namespaces to "Mono.Design". 18 | 19 | === On Mono with Mono.Design === 20 | 21 | make mono-design && make run 22 | 23 | === Status and Documentation === 24 | 25 | http://www.mono-project.com/WinForms_Designer 26 | -------------------------------------------------------------------------------- /docs/WinForms Designer.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/docs/WinForms Designer.pdf -------------------------------------------------------------------------------- /mwf-designer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mwf-designer", "mwf-designer.csproj", "{E8A1D7EA-AB41-4908-8715-F76FC155A164}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Design", "deps\Mono.Design\Mono.Design.csproj", "{53DB609E-CCAB-40F8-BA30-E98B9111627A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {53DB609E-CCAB-40F8-BA30-E98B9111627A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {53DB609E-CCAB-40F8-BA30-E98B9111627A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {53DB609E-CCAB-40F8-BA30-E98B9111627A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {53DB609E-CCAB-40F8-BA30-E98B9111627A}.Release|Any CPU.Build.0 = Release|Any CPU 18 | {E8A1D7EA-AB41-4908-8715-F76FC155A164}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {E8A1D7EA-AB41-4908-8715-F76FC155A164}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {E8A1D7EA-AB41-4908-8715-F76FC155A164}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {E8A1D7EA-AB41-4908-8715-F76FC155A164}.Release|Any CPU.Build.0 = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /mwf-designer.userprefs: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /mwf-designer.vpj: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | 20 | 21 | 22 | 30 | 31 | 32 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = "")] 3 | -------------------------------------------------------------------------------- /obj/Debug/mwf-designer.csproj.FilesWrittenAbsolute.txt: -------------------------------------------------------------------------------- 1 | /home/leo/mwf-designer/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs 2 | /home/leo/mwf-designer/build/mwf-designer.exe.mdb 3 | /home/leo/mwf-designer/build/mwf-designer.exe 4 | /home/leo/mwf-designer/obj/Debug/mwf-designer.exe 5 | /home/leo/mwf-designer/obj/Debug/mwf-designer.exe.mdb 6 | /home/leo/mwf-designer/build/ICSharpCode.NRefactory.dll 7 | /home/leo/mwf-designer/build/Mono.Design.dll 8 | /home/leo/mwf-designer/build/Mono.Design.dll.mdb 9 | -------------------------------------------------------------------------------- /obj/Debug/mwf-designer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/obj/Debug/mwf-designer.exe -------------------------------------------------------------------------------- /obj/Debug/mwf-designer.exe.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake2002/mono.winform.designer/3267b79b5e0d19bead2805bfddcf0312c15d45ad/obj/Debug/mwf-designer.exe.mdb -------------------------------------------------------------------------------- /src/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("mwf-designer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("mwf-designer")] 13 | [assembly: AssemblyCopyright("Copyright © Ivan N. Zlatev")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("91fb238c-5f6a-4308-b478-1ac6b67d2f83")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /src/DesignTime/CodeProviderDesignerLoader.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Ivan N. Zlatev (contact i-nZ.net) 4 | // 5 | // (C) 2007-2008 Ivan N. Zlatev 6 | 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | using System; 29 | using System.Collections; 30 | using System.CodeDom; 31 | using System.CodeDom.Compiler; 32 | using System.ComponentModel; 33 | using System.ComponentModel.Design; 34 | using System.ComponentModel.Design.Serialization; 35 | using System.IO; 36 | using System.Windows.Forms.Design; 37 | 38 | 39 | #if WITH_MONO_DESIGN 40 | using Mono.Design; 41 | using CodeDomDesignerLoader = Mono.Design.CodeDomDesignerLoader; 42 | #endif 43 | 44 | namespace mwf_designer 45 | { 46 | internal class CodeProviderDesignerLoader : CodeDomDesignerLoader 47 | { 48 | 49 | private CodeProvider _provider; 50 | 51 | public CodeProviderDesignerLoader (CodeProvider provider) 52 | { 53 | if (provider == null) 54 | throw new ArgumentNullException ("provider"); 55 | _provider = provider; 56 | } 57 | 58 | protected override CodeDomProvider CodeDomProvider { 59 | get { return _provider.CodeDomProvider; } 60 | } 61 | 62 | protected override ITypeResolutionService TypeResolutionService { 63 | get { return base.GetService (typeof (ITypeResolutionService)) as ITypeResolutionService; } 64 | } 65 | 66 | protected override CodeCompileUnit Parse () 67 | { 68 | return _provider.Parse (); 69 | } 70 | 71 | protected override void Write (CodeCompileUnit unit) 72 | { 73 | _provider.Write (unit); 74 | } 75 | 76 | protected override void OnEndLoad (bool successful, ICollection errors) 77 | { 78 | ReportErrors (errors); 79 | base.OnEndLoad (successful, errors); 80 | } 81 | 82 | protected override void ReportFlushErrors (ICollection errors) 83 | { 84 | ReportErrors (errors); 85 | } 86 | 87 | private void ReportErrors (ICollection errors) 88 | { 89 | if (errors == null) 90 | return; 91 | 92 | IUIService service = base.GetService (typeof (IUIService)) as IUIService; 93 | if (service != null) { 94 | foreach (object error in errors) { 95 | if (error is Exception) 96 | service.ShowError ((Exception) error); 97 | else if (error is string) 98 | service.ShowError ((string) error); 99 | else 100 | service.ShowError (error.ToString ()); 101 | } 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/DesignTime/CodeProviderEventBindingService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Ivan N. Zlatev (contact i-nZ.net) 4 | // 5 | // (C) 2007 Ivan N. Zlatev 6 | 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | using System; 29 | using System.Collections.Generic; 30 | using System.Collections; 31 | using System.ComponentModel; 32 | using System.ComponentModel.Design; 33 | 34 | #if WITH_MONO_DESIGN 35 | using Mono.Design; 36 | using EventBindingService = Mono.Design.EventBindingService; 37 | #endif 38 | 39 | namespace mwf_designer 40 | { 41 | internal class CodeProviderEventBindingService : EventBindingService 42 | { 43 | 44 | private CodeProvider _codeProvider; 45 | 46 | public CodeProviderEventBindingService (CodeProvider codeProvider, IServiceProvider provider) : base (provider) 47 | { 48 | if (codeProvider == null) 49 | throw new ArgumentNullException ("codeProvider"); 50 | _codeProvider = codeProvider; 51 | } 52 | 53 | protected override string CreateUniqueMethodName (IComponent component, EventDescriptor eventDescriptor) 54 | { 55 | string methodName = component.Site.Name + "_" + eventDescriptor.Name; 56 | ICollection compatibleMethodNames = this.GetCompatibleMethods (eventDescriptor); 57 | if (compatibleMethodNames.Count == 0) 58 | return methodName; 59 | 60 | bool interrupt = false; 61 | int i = 0; 62 | while (!interrupt) { 63 | string tmpName = methodName; 64 | foreach (string existingName in compatibleMethodNames) { 65 | if (existingName == tmpName) 66 | tmpName += i.ToString (); 67 | else { 68 | methodName = tmpName; 69 | interrupt = true; 70 | } 71 | } 72 | i++; 73 | } 74 | 75 | return methodName; 76 | } 77 | 78 | protected override ICollection GetCompatibleMethods (EventDescriptor eventDescriptor) 79 | { 80 | return _codeProvider.GetCompatibleMethods (eventDescriptor.EventType.GetMethod ("Invoke").GetParameters ()); 81 | } 82 | 83 | 84 | protected override bool ShowCode (IComponent component, EventDescriptor e, string methodName) 85 | { 86 | return this.ShowCode (0); 87 | } 88 | 89 | protected override bool ShowCode (int lineNumber) 90 | { 91 | // XXX: No text editor control 92 | return false; 93 | } 94 | 95 | protected override bool ShowCode () 96 | { 97 | return ShowCode (0); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/DesignTime/TypeResolutionService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Ivan N. Zlatev (contact i-nZ.net) 4 | // 5 | // (C) 2007 Ivan N. Zlatev 6 | 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | 29 | using System; 30 | using System.Collections; 31 | using System.ComponentModel; 32 | using System.ComponentModel.Design; 33 | using System.Reflection; 34 | 35 | #if WITH_MONO_DESIGN 36 | using Mono.Design; 37 | #endif 38 | 39 | namespace mwf_designer 40 | { 41 | internal class TypeResolutionService : ITypeResolutionService 42 | { 43 | private References _references; 44 | 45 | public TypeResolutionService (References references) 46 | { 47 | if (references == null) 48 | throw new ArgumentNullException ("references"); 49 | _references = references; 50 | } 51 | 52 | public References References { 53 | get { return _references; } 54 | set { _references = value; } 55 | } 56 | 57 | public Assembly GetAssembly (AssemblyName name) 58 | { 59 | return this.GetAssembly (name, false); 60 | } 61 | 62 | public Assembly GetAssembly (AssemblyName name, bool throwOnError) 63 | { 64 | Assembly result = null; 65 | 66 | foreach (Assembly assembly in _references.Assemblies) 67 | if (assembly.GetName().Name == name.Name) 68 | result = assembly; 69 | 70 | if (result == null && throwOnError) 71 | throw new ArgumentException ("Assembly not found: " + name.Name); 72 | return result; 73 | } 74 | 75 | public string GetPathOfAssembly (AssemblyName name) 76 | { 77 | throw new NotImplementedException (); 78 | } 79 | 80 | public Type GetType (string name) 81 | { 82 | return this.GetType (name, false); 83 | } 84 | 85 | public Type GetType (string name, bool throwOnError) 86 | { 87 | return this.GetType (name, throwOnError, false); 88 | } 89 | 90 | public Type GetType (string name, bool throwOnError, bool ignoreCase) 91 | { 92 | if (name == null) 93 | throw new ArgumentNullException ("name"); 94 | 95 | Type result = null; 96 | 97 | foreach (Assembly assembly in _references.Assemblies) { 98 | if (name.IndexOf (".") != -1) { // a fully qualified name, e.g System.Windows.Forms.Button 99 | result = assembly.GetType (name, false, ignoreCase); 100 | if (result != null) 101 | break; 102 | } else { 103 | Type[] types = assembly.GetTypes (); 104 | foreach (Type type in types) { 105 | if (String.Compare (type.Name, name, ignoreCase) == 0) { 106 | result = type; 107 | break; 108 | } 109 | } 110 | } 111 | } 112 | 113 | if (result == null) 114 | result = Type.GetType (name, false, ignoreCase); 115 | 116 | if (result == null) 117 | result = Assembly.GetExecutingAssembly ().GetType (name, false, ignoreCase); 118 | 119 | return result; 120 | } 121 | 122 | public void ReferenceAssembly (AssemblyName name) 123 | { 124 | _references.AddReference (name.FullName); 125 | } 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /src/DesignTime/UndoRedoEngine.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Ivan N. Zlatev (contact i-nZ.net) 4 | // 5 | // (C) 2007-2008 Ivan N. Zlatev 6 | 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | using System; 29 | using System.Collections.Generic; 30 | using System.Collections; 31 | using System.ComponentModel; 32 | using System.ComponentModel.Design; 33 | 34 | #if WITH_MONO_DESIGN 35 | using Mono.Design; 36 | using UndoEngine = Mono.Design.UndoEngine; 37 | #endif 38 | 39 | namespace mwf_designer 40 | { 41 | internal class UndoRedoEngine : UndoEngine 42 | { 43 | private Stack _undoUnits; 44 | private Stack _redoUnits; 45 | 46 | public UndoRedoEngine (IServiceProvider provider) : base (provider) 47 | { 48 | _undoUnits = new Stack (); 49 | _redoUnits = new Stack (); 50 | } 51 | 52 | protected override void AddUndoUnit (UndoEngine.UndoUnit unit) 53 | { 54 | _undoUnits.Push (unit); 55 | _redoUnits.Clear (); 56 | } 57 | 58 | protected override void DiscardUndoUnit (UndoEngine.UndoUnit unit) 59 | { 60 | base.DiscardUndoUnit (unit); 61 | if (_undoUnits.Count > 0 && Object.ReferenceEquals (unit, _undoUnits.Peek ())) 62 | _undoUnits.Pop (); 63 | } 64 | 65 | public void Undo () 66 | { 67 | this.Undo (1); 68 | } 69 | 70 | public void Undo (int actionsCount) 71 | { 72 | if (actionsCount <= 0 || actionsCount > _undoUnits.Count) 73 | return; 74 | for (; actionsCount != 0; actionsCount--) { 75 | UndoUnit unit = _undoUnits.Pop (); 76 | // Console.WriteLine ("undo: " + unit.Name); 77 | unit.Undo (); 78 | _redoUnits.Push (unit); 79 | } 80 | } 81 | 82 | public void Redo () 83 | { 84 | this.Redo (1); 85 | } 86 | 87 | public void Redo (int actionsCount) 88 | { 89 | if (actionsCount <= 0 || actionsCount > _redoUnits.Count) 90 | return; 91 | 92 | for (; actionsCount != 0; actionsCount--) { 93 | UndoUnit unit = _redoUnits.Pop (); 94 | // Console.WriteLine ("redo: " + unit.Name); 95 | unit.Undo (); 96 | _undoUnits.Push (unit); 97 | } 98 | } 99 | 100 | public List UndoUnitsNames { 101 | get { 102 | List names = new List (); 103 | foreach (UndoUnit unit in _undoUnits) 104 | names.Add (unit.Name); 105 | return names; 106 | } 107 | } 108 | 109 | public List RedoUnitsNames { 110 | get { 111 | List names = new List (); 112 | foreach (UndoUnit unit in _redoUnits) 113 | names.Add (unit.Name); 114 | return names; 115 | } 116 | } 117 | 118 | protected override void Dispose (bool disposing) 119 | { 120 | if (disposing) { 121 | _undoUnits.Clear (); 122 | _redoUnits.Clear (); 123 | } 124 | base.Dispose (disposing); 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | 5 | namespace mwf_designer 6 | { 7 | static class Program 8 | { 9 | /// 10 | /// The main entry point for the application. 11 | /// 12 | [STAThread] 13 | static void Main(string[] args) 14 | { 15 | AppDomain.CurrentDomain.UnhandledException += delegate (object sender, UnhandledExceptionEventArgs ueargs) { 16 | System.Windows.Forms.MessageBox.Show (ueargs.ExceptionObject.GetType ().Name); 17 | if (ueargs.ExceptionObject is Exception) 18 | OnException ((Exception) ueargs.ExceptionObject); 19 | }; 20 | 21 | try { 22 | Application.EnableVisualStyles(); 23 | Application.SetCompatibleTextRenderingDefault(false); 24 | Application.Run(new MainView(args)); 25 | } catch (Exception e) { 26 | OnException (e); 27 | System.Windows.Forms.Application.Exit (); 28 | } 29 | } 30 | 31 | private static void OnException (Exception e) 32 | { 33 | MessageBox.Show ("A fatal error occurred. Please file a bug report with the following details (Ctrl-C to copy to clipboard):" + System.Environment.NewLine + System.Environment.NewLine + e.ToString (), "Fatal Error"); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Project/References.cs: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // Authors: 4 | // Ivan N. Zlatev (contact i-nZ.net) 5 | // 6 | // (C) 2007-2008 Ivan N. Zlatev 7 | 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Collections.Generic; 31 | using System.Text; 32 | using System.Reflection; 33 | using System.IO; 34 | 35 | namespace mwf_designer 36 | { 37 | internal class References 38 | { 39 | private List _assemblies; 40 | 41 | public References () 42 | { 43 | _assemblies = new List (); 44 | } 45 | 46 | public void Dispose () 47 | { 48 | _assemblies.Clear (); 49 | _assemblies = null; 50 | } 51 | 52 | public void AddReference (Assembly assembly) 53 | { 54 | if (assembly == null) 55 | throw new ArgumentNullException ("assembly"); 56 | 57 | _assemblies.Add (assembly); 58 | OnReferenceAdded (assembly); 59 | } 60 | 61 | public bool AddReference (string fileName) 62 | { 63 | Assembly assembly = null; 64 | try { 65 | assembly = Assembly.LoadFile (fileName); 66 | } catch { } 67 | if (assembly != null) 68 | this.AddReference (assembly); 69 | return assembly != null; 70 | } 71 | 72 | public void RemoveReference (string fileName) 73 | { 74 | int toRemove = -1; 75 | for (int i = 0; i < _assemblies.Count; i++) { 76 | if (String.Equals (fileName, Path.GetFileName (_assemblies[i].Location))) { 77 | toRemove = i; 78 | break; 79 | } 80 | } 81 | if (toRemove != -1) { 82 | Assembly assembly = _assemblies[toRemove]; 83 | _assemblies.RemoveAt (toRemove); 84 | OnReferenceRemoved (assembly); 85 | } 86 | } 87 | 88 | public string[] FileNames { 89 | get { 90 | string[] files = new string[_assemblies.Count]; 91 | for (int i = 0; i < _assemblies.Count; i++) 92 | files[i] = Path.GetFileName (_assemblies[i].Location); 93 | return files; 94 | } 95 | } 96 | 97 | public List Assemblies { 98 | get{ return _assemblies; } 99 | } 100 | 101 | private void OnReferenceAdded (Assembly assembly) 102 | { 103 | if (ReferenceAdded != null) 104 | ReferenceAdded (this, new ReferenceAddedEventArgs (assembly)); 105 | } 106 | 107 | private void OnReferenceRemoved (Assembly assembly) 108 | { 109 | if (ReferenceRemoved != null) 110 | ReferenceRemoved (this, new ReferenceRemovedEventArgs (assembly)); 111 | } 112 | 113 | public event ReferenceAddedEventHandler ReferenceAdded; 114 | public event ReferenceRemovedEventHandler ReferenceRemoved; 115 | } 116 | 117 | internal delegate void ReferenceAddedEventHandler (object sender, ReferenceAddedEventArgs args); 118 | internal delegate void ReferenceRemovedEventHandler (object sender, ReferenceRemovedEventArgs args); 119 | 120 | internal class ReferenceAddedEventArgs : EventArgs 121 | { 122 | private Assembly _assembly; 123 | 124 | public ReferenceAddedEventArgs (Assembly assembly) 125 | { 126 | if (assembly == null) 127 | throw new ArgumentNullException ("assembly"); 128 | _assembly = assembly; 129 | } 130 | 131 | public Assembly Assembly { 132 | get { return _assembly; } 133 | } 134 | } 135 | 136 | 137 | internal class ReferenceRemovedEventArgs : EventArgs 138 | { 139 | private Assembly _assembly; 140 | 141 | public ReferenceRemovedEventArgs (Assembly assembly) 142 | { 143 | if (assembly == null) 144 | throw new ArgumentNullException ("assembly"); 145 | _assembly = assembly; 146 | } 147 | 148 | public Assembly Assembly { 149 | get { return _assembly; } 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/Project/TemplateManager.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Ivan N. Zlatev (contact i-nZ.net) 4 | // 5 | // (C) 2007 Ivan N. Zlatev 6 | 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | using System; 29 | using System.Collections.Generic; 30 | using System.Reflection; 31 | using System.Text; 32 | using System.IO; 33 | 34 | namespace mwf_designer 35 | { 36 | internal static class TemplateManager 37 | { 38 | 39 | public static void WriteCode (string templateName, string fileName, string codeBehindFileName, 40 | string namespaceName, string className) 41 | { 42 | 43 | string main = null; 44 | string codeBehind = null; 45 | switch (templateName) { 46 | case "Form C#": 47 | main = _formCSharpMain; 48 | codeBehind = _formCSharpCodeBehind; 49 | break; 50 | default: 51 | return; 52 | } 53 | 54 | while (main.IndexOf ("${namespace}") != -1) 55 | main = main.Replace ("${namespace}", namespaceName); 56 | while (codeBehind.IndexOf ("${namespace}") != -1) 57 | codeBehind = codeBehind.Replace ("${namespace}", namespaceName); 58 | 59 | while (main.IndexOf ("${class}") != -1) 60 | main = main.Replace ("${class}", className); 61 | while (codeBehind.IndexOf ("${class}") != -1) 62 | codeBehind = codeBehind.Replace ("${class}", className); 63 | 64 | // write main file 65 | FileStream stream = File.OpenWrite (fileName); 66 | byte [] bytes = Encoding.Default.GetBytes (main); 67 | stream.Write (bytes, 0, bytes.Length); 68 | stream.Close (); 69 | stream.Dispose (); 70 | 71 | // write codebehind file 72 | stream = File.OpenWrite (codeBehindFileName); 73 | bytes = Encoding.Default.GetBytes (codeBehind); 74 | stream.Write (bytes, 0, bytes.Length); 75 | stream.Close (); 76 | stream.Dispose (); 77 | } 78 | 79 | public static string[] AvailableTemplates { 80 | get { 81 | return new string [] { 82 | "Form C#", 83 | }; 84 | } 85 | } 86 | 87 | 88 | private static string _formCSharpMain = @"using System; 89 | using System.Collections.Generic; 90 | using System.ComponentModel; 91 | using System.Data; 92 | using System.Drawing; 93 | using System.Text; 94 | using System.Windows.Forms; 95 | 96 | namespace ${namespace} 97 | { 98 | public partial class ${class} : Form 99 | { 100 | public ${class}() 101 | { 102 | InitializeComponent(); 103 | } 104 | } 105 | } 106 | "; 107 | 108 | 109 | private static string _formCSharpCodeBehind = @"namespace ${namespace} 110 | { 111 | partial class ${class} 112 | { 113 | private System.ComponentModel.IContainer components = null; 114 | 115 | protected override void Dispose(bool disposing) 116 | { 117 | if (disposing && (components != null)) 118 | { 119 | components.Dispose(); 120 | } 121 | base.Dispose(disposing); 122 | } 123 | 124 | #region Windows Form Designer generated code 125 | 126 | private void InitializeComponent() 127 | { 128 | this.components = new System.ComponentModel.Container(); 129 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 130 | this.Text = ""${class}""; 131 | } 132 | 133 | #endregion 134 | } 135 | }"; 136 | 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/UI/ErrorList.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Ivan N. Zlatev (contact i-nZ.net) 4 | // 5 | // (C) 2007 Ivan N. Zlatev 6 | 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | using System; 29 | using System.Collections; 30 | using System.Collections.Generic; 31 | using System.ComponentModel; 32 | using System.Drawing; 33 | using System.Data; 34 | using System.Text; 35 | using System.Windows.Forms; 36 | using System.IO; 37 | 38 | namespace mwf_designer 39 | { 40 | internal partial class ErrorList : UserControl 41 | { 42 | 43 | private class Error 44 | { 45 | private string _details; 46 | private string _message; 47 | 48 | public Error (string message, string details) 49 | { 50 | if (message == null) 51 | throw new ArgumentNullException ("message"); 52 | _details = details; 53 | _message = message; 54 | } 55 | 56 | public string Details { 57 | get { return _details; } 58 | set { _details = value; } 59 | } 60 | 61 | public string Message { 62 | get { return _message; } 63 | set { _message = value; } 64 | } 65 | 66 | public override string ToString () 67 | { 68 | return _message; 69 | } 70 | } 71 | 72 | public ErrorList () 73 | { 74 | InitializeComponent (); 75 | } 76 | 77 | private void saveButton_Click (object sender, EventArgs e) 78 | { 79 | SaveFileDialog dialog = new SaveFileDialog(); 80 | dialog.OverwritePrompt = true; 81 | if (dialog.ShowDialog() == DialogResult.OK) 82 | WriteErrorsToFile (dialog.FileName); 83 | } 84 | 85 | private void errorsList_SelectedIndexChanged (object sender, EventArgs e) 86 | { 87 | if (_errorsList.SelectedIndex != -1) { 88 | Error error = (Error) _errorsList.Items[_errorsList.SelectedIndex]; 89 | _detailedText.Text = error.Details; 90 | } 91 | } 92 | 93 | public void AddError (string message, string details) 94 | { 95 | _errorsList.Items.Add (new Error (message, details)); 96 | } 97 | 98 | private void WriteErrorsToFile (string fileName) 99 | { 100 | StringBuilder sb = new StringBuilder (); 101 | foreach (Error error in _errorsList.Items) { 102 | sb.AppendLine ("==== " + error.Message + " ===="); 103 | sb.Append (Environment.NewLine); 104 | sb.Append (error.Details); 105 | sb.Append (Environment.NewLine); 106 | sb.Append (Environment.NewLine); 107 | } 108 | 109 | FileStream stream = File.OpenWrite (fileName); 110 | byte [] bytes = Encoding.Default.GetBytes (sb.ToString ()); 111 | stream.Write (bytes, 0, bytes.Length); 112 | stream.Close (); 113 | stream.Dispose (); 114 | } 115 | 116 | public void Clear () 117 | { 118 | _errorsList.SuspendLayout (); 119 | _errorsList.Items.Clear (); 120 | _errorsList.ResumeLayout (); 121 | _detailedText.Text = ""; 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/UI/ErrorListTabPage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Ivan N. Zlatev (contact i-nZ.net) 4 | // 5 | // (C) 2007 Ivan N. Zlatev 6 | 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | using System; 29 | using System.Collections; 30 | using System.Collections.Generic; 31 | using System.Windows.Forms; 32 | using System.Windows.Forms.Design; 33 | 34 | namespace mwf_designer 35 | { 36 | internal class ErrorListTabPage : TabPage, IUIService 37 | { 38 | private ErrorList _errorList; 39 | private readonly string ERRORS_TAB_KEY = @"!?\/#__Errors__!?\/#"; 40 | private readonly string ERRORS_TAB_TEXT = "Errors"; 41 | 42 | public ErrorListTabPage () 43 | { 44 | InitializeComponent (); 45 | } 46 | 47 | private void InitializeComponent () 48 | { 49 | _errorList = new ErrorList (); 50 | _errorList.Dock = DockStyle.Fill; 51 | 52 | this.Name = ERRORS_TAB_KEY; 53 | this.Text = ERRORS_TAB_TEXT; 54 | this.Controls.Add (_errorList); 55 | } 56 | 57 | #region IUIService 58 | 59 | private IDictionary _styles; 60 | 61 | void IUIService.SetUIDirty () 62 | { 63 | _errorList.Clear (); 64 | } 65 | 66 | void IUIService.ShowError (Exception exception) 67 | { 68 | string details = exception.StackTrace; 69 | 70 | if (exception.Data["Details"] != null) 71 | details = (string)exception.Data["Details"] + System.Environment.NewLine + System.Environment.NewLine + details; 72 | _errorList.AddError (exception.Message, details); 73 | } 74 | 75 | void IUIService.ShowError (string message) 76 | { 77 | _errorList.AddError (message, Environment.StackTrace); 78 | } 79 | 80 | void IUIService.ShowError (Exception exception, string message) 81 | { 82 | _errorList.AddError (message, exception.ToString ()); 83 | } 84 | 85 | void IUIService.ShowMessage (string message) 86 | { 87 | _errorList.AddError (message, Environment.StackTrace); 88 | } 89 | 90 | void IUIService.ShowMessage (string message, string caption) 91 | { 92 | _errorList.AddError (caption, message); 93 | } 94 | 95 | DialogResult IUIService.ShowMessage (string message, string caption, MessageBoxButtons buttons) 96 | { 97 | throw new NotImplementedException (); 98 | } 99 | 100 | IDictionary IUIService.Styles { 101 | get { 102 | if (_styles == null) 103 | _styles = new Hashtable (); 104 | return _styles; 105 | } 106 | } 107 | 108 | IWin32Window IUIService.GetDialogOwnerWindow () 109 | { 110 | Control parent = this.Parent; 111 | 112 | while (parent != null) { 113 | if (parent is Form) 114 | return (Form)parent; 115 | parent = parent.Parent; 116 | } 117 | 118 | return null; 119 | } 120 | 121 | bool IUIService.CanShowComponentEditor (object component) 122 | { 123 | return false; // TODO 124 | // throw new NotImplementedException (); 125 | } 126 | 127 | bool IUIService.ShowComponentEditor (object component, IWin32Window parent) 128 | { 129 | throw new NotImplementedException (); 130 | } 131 | 132 | DialogResult IUIService.ShowDialog (Form form) 133 | { 134 | throw new NotImplementedException (); 135 | } 136 | 137 | bool IUIService.ShowToolWindow (Guid toolWindow) 138 | { 139 | throw new NotImplementedException (); 140 | } 141 | #endregion 142 | 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/UI/NewFileDialog.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Ivan N. Zlatev (contact i-nZ.net) 4 | // 5 | // (C) 2007 Ivan N. Zlatev 6 | 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | using System; 29 | using System.Collections.Generic; 30 | using System.ComponentModel; 31 | using System.Data; 32 | using System.Drawing; 33 | using System.Text; 34 | using System.Windows.Forms; 35 | 36 | namespace mwf_designer 37 | { 38 | internal partial class NewFileDialog : Form 39 | { 40 | private string _templateName; 41 | private string _fileName; 42 | private string _class; 43 | private string _namespace; 44 | 45 | public NewFileDialog() 46 | { 47 | InitializeComponent(); 48 | } 49 | 50 | public NewFileDialog(string[] templateNames) : this () 51 | { 52 | templatesListbox.Items.AddRange (templateNames); 53 | if (templatesListbox.Items.Count >= 1) 54 | templatesListbox.SelectedIndex = 0; 55 | } 56 | 57 | public string Class { 58 | get { return _class; } 59 | } 60 | 61 | public string File { 62 | get { return _fileName; } 63 | } 64 | 65 | 66 | public string Namespace { 67 | get { return _namespace; } 68 | } 69 | 70 | public string Template { 71 | get { return _templateName; } 72 | } 73 | 74 | private void cancelButton_Click(object sender, EventArgs e) 75 | { 76 | this.DialogResult = DialogResult.Cancel; 77 | this.Close(); 78 | } 79 | 80 | private void browseButton_Click(object sender, EventArgs e) 81 | { 82 | filenameTextbox.Text = SelectSaveLocation (); 83 | } 84 | 85 | private void filenameTextbox_Click (object sender, EventArgs e) 86 | { 87 | filenameTextbox.Text = SelectSaveLocation (); 88 | } 89 | 90 | private string SelectSaveLocation () 91 | { 92 | SaveFileDialog dialog = new SaveFileDialog(); 93 | dialog.OverwritePrompt = true; 94 | dialog.Filter = "C# Source Code (*.cs)|*.cs| VB.NET Source Code (*.vb)|*.vb|Other|*.*"; 95 | if (dialog.ShowDialog() == DialogResult.OK) 96 | return dialog.FileName; 97 | return null; 98 | } 99 | 100 | private void doneButton_Click(object sender, EventArgs e) 101 | { 102 | _templateName = (string)templatesListbox.SelectedItem; 103 | _namespace = namespaceTextbox.Text; 104 | _class = classTextbox.Text; 105 | _fileName = filenameTextbox.Text; 106 | if (!IsValidEntry (_templateName) || !IsValidEntry (_namespace) || 107 | !IsValidEntry (_class) || !IsValidEntry (_fileName)) { 108 | MessageBox.Show ("Please select a template from the list, specify the class and namespace names and " + 109 | "then choose file name and location."); 110 | } else { 111 | this.DialogResult = DialogResult.OK; 112 | this.Close(); 113 | } 114 | } 115 | 116 | private bool IsValidEntry (string s) 117 | { 118 | if (s == null || s == String.Empty) 119 | return false; 120 | return true; 121 | } 122 | } 123 | } -------------------------------------------------------------------------------- /src/UI/PropertyGrid.Designer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace mwf_designer 5 | { 6 | partial class PropertyGrid 7 | { 8 | /// 9 | /// Required designer variable. 10 | /// 11 | private System.ComponentModel.IContainer components = null; 12 | 13 | /// 14 | /// Clean up any resources being used. 15 | /// 16 | /// true if managed resources should be disposed; otherwise, false. 17 | protected override void Dispose(bool disposing) 18 | { 19 | if (disposing && (components != null)) 20 | { 21 | components.Dispose(); 22 | } 23 | base.Dispose(disposing); 24 | } 25 | 26 | #region Component Designer generated code 27 | 28 | /// 29 | /// Required method for Designer support - do not modify 30 | /// the contents of this method with the code editor. 31 | /// 32 | private void InitializeComponent() 33 | { 34 | this._componentsCombo = new System.Windows.Forms.ComboBox(); 35 | this._propertyGrid = new System.Windows.Forms.PropertyGrid(); 36 | this.SuspendLayout(); 37 | // 38 | // _componentsCombo 39 | // 40 | this._componentsCombo.Dock = System.Windows.Forms.DockStyle.Top; 41 | this._componentsCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 42 | this._componentsCombo.FormattingEnabled = true; 43 | this._componentsCombo.Location = new System.Drawing.Point(0, 0); 44 | this._componentsCombo.Name = "_componentsCombo"; 45 | this._componentsCombo.Size = new System.Drawing.Size(256, 21); 46 | this._componentsCombo.TabIndex = 1; 47 | this._componentsCombo.SelectedIndexChanged += new EventHandler (OnComponentsCombo_SelectedIndexChanged); 48 | // 49 | // _propertyGrid 50 | // 51 | this._propertyGrid.Dock = System.Windows.Forms.DockStyle.Fill; 52 | this._propertyGrid.Location = new System.Drawing.Point(0, 21); 53 | this._propertyGrid.Name = "_propertyGrid"; 54 | this._propertyGrid.Size = new System.Drawing.Size(256, 390); 55 | this._propertyGrid.TabIndex = 2; 56 | // 57 | // PropertyGrid 58 | // 59 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 60 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 61 | this.Controls.Add(this._propertyGrid); 62 | this.Controls.Add(this._componentsCombo); 63 | this.Name = "PropertyGrid"; 64 | this.Size = new System.Drawing.Size(256, 411); 65 | this.ResumeLayout(false); 66 | 67 | } 68 | 69 | #endregion 70 | 71 | private System.Windows.Forms.ComboBox _componentsCombo; 72 | private System.Windows.Forms.PropertyGrid _propertyGrid; 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/UI/ReferencesDialog.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace mwf_designer 2 | { 3 | partial class ReferencesDialog 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.referencesList = new System.Windows.Forms.ListBox(); 32 | this.remove = new System.Windows.Forms.Button(); 33 | this.done = new System.Windows.Forms.Button(); 34 | this.add = new System.Windows.Forms.Button(); 35 | this.SuspendLayout(); 36 | // 37 | // referencesList 38 | // 39 | this.referencesList.FormattingEnabled = true; 40 | this.referencesList.Location = new System.Drawing.Point(12, 12); 41 | this.referencesList.Name = "referencesList"; 42 | this.referencesList.Size = new System.Drawing.Size(219, 264); 43 | this.referencesList.TabIndex = 0; 44 | // 45 | // remove 46 | // 47 | this.remove.Location = new System.Drawing.Point(237, 41); 48 | this.remove.Name = "remove"; 49 | this.remove.Size = new System.Drawing.Size(75, 23); 50 | this.remove.TabIndex = 2; 51 | this.remove.Text = "Remove"; 52 | this.remove.UseVisualStyleBackColor = true; 53 | this.remove.Click += new System.EventHandler(this.remove_Click); 54 | // 55 | // done 56 | // 57 | this.done.Location = new System.Drawing.Point(237, 253); 58 | this.done.Name = "done"; 59 | this.done.Size = new System.Drawing.Size(75, 23); 60 | this.done.TabIndex = 3; 61 | this.done.Text = "Done"; 62 | this.done.UseVisualStyleBackColor = true; 63 | this.done.Click += new System.EventHandler(this.done_Click); 64 | // 65 | // add 66 | // 67 | this.add.Location = new System.Drawing.Point(237, 12); 68 | this.add.Name = "add"; 69 | this.add.Size = new System.Drawing.Size(75, 23); 70 | this.add.TabIndex = 4; 71 | this.add.Text = "Add"; 72 | this.add.UseVisualStyleBackColor = true; 73 | this.add.Click += new System.EventHandler(this.add_Click); 74 | // 75 | // ReferencesDialog 76 | // 77 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 78 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 79 | this.ClientSize = new System.Drawing.Size(317, 287); 80 | this.Controls.Add(this.add); 81 | this.Controls.Add(this.done); 82 | this.Controls.Add(this.remove); 83 | this.Controls.Add(this.referencesList); 84 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 85 | this.MaximizeBox = false; 86 | this.MinimizeBox = false; 87 | this.Name = "ReferencesDialog"; 88 | this.ShowIcon = false; 89 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 90 | this.Text = "Referenced Assemblies"; 91 | this.ResumeLayout(false); 92 | 93 | } 94 | 95 | #endregion 96 | 97 | private System.Windows.Forms.ListBox referencesList; 98 | private System.Windows.Forms.Button remove; 99 | private System.Windows.Forms.Button done; 100 | private System.Windows.Forms.Button add; 101 | } 102 | } -------------------------------------------------------------------------------- /src/UI/ReferencesDialog.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Ivan N. Zlatev (contact i-nZ.net) 4 | // 5 | // (C) 2007 Ivan N. Zlatev 6 | 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | using System; 29 | using System.Collections.Generic; 30 | using System.ComponentModel; 31 | using System.Data; 32 | using System.Drawing; 33 | using System.Text; 34 | using System.Windows.Forms; 35 | using System.Reflection; 36 | using System.IO; 37 | 38 | namespace mwf_designer 39 | { 40 | internal partial class ReferencesDialog : Form 41 | { 42 | private References _references; 43 | 44 | public ReferencesDialog (References references) 45 | { 46 | if (references == null) 47 | throw new ArgumentNullException ("references"); 48 | _references = references; 49 | 50 | InitializeComponent (); 51 | PopulateReferencesList (); 52 | } 53 | 54 | private void PopulateReferencesList () 55 | { 56 | referencesList.Items.AddRange (_references.FileNames); 57 | } 58 | 59 | private void done_Click (object sender, EventArgs e) 60 | { 61 | this.Close (); 62 | } 63 | 64 | private void add_Click (object sender, EventArgs e) 65 | { 66 | OpenFileDialog dialog = new OpenFileDialog (); 67 | dialog.CheckFileExists = true; 68 | dialog.Multiselect = true; 69 | dialog.Filter = ".Net Assembly (*.dll, *.exe)|*.dll;*.exe"; 70 | if (dialog.ShowDialog () == DialogResult.OK) { 71 | foreach (string file in dialog.FileNames) { 72 | if (_references.AddReference (file)) 73 | referencesList.Items.Add (Path.GetFileName (file)); 74 | } 75 | } 76 | dialog.Dispose (); 77 | } 78 | 79 | private void remove_Click (object sender, EventArgs e) 80 | { 81 | if (referencesList.SelectedIndex != -1) { 82 | _references.RemoveReference ((string)referencesList.Items[referencesList.SelectedIndex]); 83 | referencesList.Items.RemoveAt (referencesList.SelectedIndex); 84 | } 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /src/UI/ToolBoxList/ToolBoxGroupHeader.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Jonathan Pobst (monkey@jpobst.com>) 4 | // 5 | // (C) 2007 Jonathan Pobst 6 | 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | using System; 29 | using System.Drawing; 30 | using System.Windows.Forms; 31 | 32 | namespace mwf_designer 33 | { 34 | public class ToolBoxGroupHeader : UserControl 35 | { 36 | 37 | #region Fields 38 | private bool expanded = true; 39 | #endregion 40 | 41 | #region Public Constructor 42 | public ToolBoxGroupHeader () 43 | { 44 | Size = new Size (200, 20); 45 | SetStyle (ControlStyles.ResizeRedraw, true); 46 | BackColor = SystemColors.ControlDark; 47 | Font = new Font (this.Font, FontStyle.Bold); 48 | } 49 | #endregion 50 | 51 | #region Public Properties 52 | public bool Expanded { 53 | get { return expanded;} 54 | set { 55 | if (expanded != value) { 56 | expanded = value; 57 | Invalidate (); 58 | } 59 | } 60 | } 61 | #endregion 62 | 63 | #region Protected Methods 64 | protected override void OnClick (EventArgs e) 65 | { 66 | base.OnClick (e); 67 | 68 | Expanded = !expanded; 69 | OnExpandedChanged (EventArgs.Empty); 70 | } 71 | 72 | protected virtual void OnExpandedChanged (EventArgs e) 73 | { 74 | EventHandler eh = (EventHandler)(Events[ExpandedChangedEvent]); 75 | if (eh != null) 76 | eh (this, e); 77 | } 78 | 79 | protected override void OnPaint (PaintEventArgs e) 80 | { 81 | base.OnPaint (e); 82 | 83 | Graphics g = e.Graphics; 84 | 85 | g.Clear (BackColor); 86 | 87 | if (expanded) 88 | DrawDownChevron (g, new Point (7, 8), Pens.LightGray); 89 | else 90 | DrawRightChevron (g, new Point (10, 5), Pens.LightGray); 91 | 92 | TextRenderer.DrawText (g, Text, Font, new Point (18, 2), Color.White); 93 | } 94 | #endregion 95 | 96 | #region Public Events 97 | static object ExpandedChangedEvent = new object (); 98 | 99 | public event EventHandler ExpandedChanged { 100 | add { Events.AddHandler (ExpandedChangedEvent, value);} 101 | remove { Events.RemoveHandler (ExpandedChangedEvent, value);} 102 | } 103 | #endregion 104 | 105 | #region Private Methods 106 | private void DrawDownChevron (Graphics g, Point location, Pen p) 107 | { 108 | g.DrawLine (p, location.X, location.Y, location.X + 8, location.Y); 109 | g.DrawLine (p, location.X + 1, location.Y + 1, location.X + 7, location.Y + 1); 110 | g.DrawLine (p, location.X + 2, location.Y + 2, location.X + 6, location.Y + 2); 111 | g.DrawLine (p, location.X + 3, location.Y + 3, location.X + 5, location.Y + 3); 112 | } 113 | 114 | private void DrawRightChevron (Graphics g, Point location, Pen p) 115 | { 116 | g.DrawLine (p, location.X, location.Y, location.X, location.Y + 8); 117 | g.DrawLine (p, location.X + 1, location.Y + 1, location.X + 1, location.Y + 7); 118 | g.DrawLine (p, location.X + 2, location.Y + 2, location.X + 2, location.Y + 6); 119 | g.DrawLine (p, location.X + 3, location.Y + 3, location.X + 3, location.Y + 5); 120 | } 121 | #endregion 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/UI/ToolBoxList/ToolBoxGroupPanel.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Jonathan Pobst (monkey@jpobst.com>) 4 | // 5 | // (C) 2007 Jonathan Pobst 6 | 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | using System; 29 | using System.Drawing; 30 | using System.Windows.Forms; 31 | 32 | namespace mwf_designer 33 | { 34 | public class ToolBoxGroupPanel : UserControl 35 | { 36 | 37 | #region Fields 38 | private ToolBoxGroupHeader GroupHeader1; 39 | private Panel ItemPanel; 40 | #endregion 41 | 42 | #region Public Constructor 43 | public ToolBoxGroupPanel () 44 | { 45 | ItemPanel = new Panel (); 46 | GroupHeader1 = new ToolBoxGroupHeader (); 47 | SuspendLayout (); 48 | 49 | // 50 | // ItemPanel 51 | // 52 | ItemPanel.Dock = DockStyle.Fill; 53 | ItemPanel.Location = new Point (1, 21); 54 | ItemPanel.Name = "ItemPanel"; 55 | ItemPanel.Size = new Size (198, 0); 56 | ItemPanel.TabIndex = 1; 57 | // 58 | // GroupHeader1 59 | // 60 | GroupHeader1.Dock = DockStyle.Top; 61 | GroupHeader1.Expanded = true; 62 | GroupHeader1.Location = new Point (1, 1); 63 | GroupHeader1.Margin = new Padding (0); 64 | GroupHeader1.Name = "GroupHeader1"; 65 | GroupHeader1.Padding = new Padding (1, 1, 1, 0); 66 | GroupHeader1.Size = new Size (198, 20); 67 | GroupHeader1.TabIndex = 0; 68 | 69 | Controls.Add (this.ItemPanel); 70 | Controls.Add (this.GroupHeader1); 71 | Name = "ToolBoxGroupPanel"; 72 | Padding = new System.Windows.Forms.Padding (1, 1, 1, 0); 73 | Size = new System.Drawing.Size (200, 20); 74 | ResumeLayout (false); 75 | 76 | GroupHeader1.ExpandedChanged += new EventHandler (GroupHeader1_ExpandedChanged); 77 | ItemPanel.ControlAdded += new ControlEventHandler (ItemPanel_ControlAdded); 78 | Layout += new LayoutEventHandler (ToolBoxGroupPanel_Layout); 79 | } 80 | #endregion 81 | 82 | #region Public Properties 83 | public bool Expanded { 84 | get { return GroupHeader1.Expanded;} 85 | set { 86 | if (GroupHeader1.Expanded != value) { 87 | GroupHeader1.Expanded = value; 88 | PerformLayout (); 89 | } 90 | } 91 | } 92 | 93 | public ControlCollection Items { 94 | get { return ItemPanel.Controls;} 95 | } 96 | 97 | public override string Text { 98 | get { return GroupHeader1.Text;} 99 | set { GroupHeader1.Text = value;} 100 | } 101 | #endregion 102 | 103 | #region Private Methods 104 | private void ToolBoxGroupPanel_Layout (object sender, LayoutEventArgs e) 105 | { 106 | // Figure out how tall we need to be 107 | if (GroupHeader1.Expanded) { 108 | int y = 0; 109 | 110 | foreach (Control c in Items) 111 | if (c.Enabled) 112 | y += c.Height; 113 | 114 | if (y == 0) 115 | Visible = false; 116 | else 117 | Visible = true; 118 | 119 | Height = y + GroupHeader1.Height + 1; 120 | } else { 121 | Height = GroupHeader1.Bottom; 122 | } 123 | } 124 | 125 | private void ItemPanel_ControlAdded (object sender, ControlEventArgs e) 126 | { 127 | // Sort incoming items 128 | ToolBoxListItem new_tbi = (ToolBoxListItem)e.Control; 129 | 130 | foreach (Control c in ItemPanel.Controls) { 131 | ToolBoxListItem tbi = c as ToolBoxListItem; 132 | 133 | if (tbi == null) 134 | continue; 135 | 136 | if (string.Compare (new_tbi.Text, tbi.Text) > 0) { 137 | ItemPanel.Controls.SetChildIndex (new_tbi, ItemPanel.Controls.GetChildIndex (tbi)); 138 | break; 139 | } 140 | } 141 | 142 | e.Control.Dock = DockStyle.Top; 143 | PerformLayout (); 144 | } 145 | 146 | private void GroupHeader1_ExpandedChanged (object sender, EventArgs e) 147 | { 148 | PerformLayout (); 149 | } 150 | #endregion 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/UI/ToolBoxList/ToolBoxListItem.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Jonathan Pobst (monkey@jpobst.com>) 4 | // 5 | // (C) 2007 Jonathan Pobst 6 | 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining 9 | // a copy of this software and associated documentation files (the 10 | // "Software"), to deal in the Software without restriction, including 11 | // without limitation the rights to use, copy, modify, merge, publish, 12 | // distribute, sublicense, and/or sell copies of the Software, and to 13 | // permit persons to whom the Software is furnished to do so, subject to 14 | // the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be 17 | // included in all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | using System; 29 | using System.Drawing; 30 | using System.Windows.Forms; 31 | using System.Drawing.Design; 32 | 33 | namespace mwf_designer 34 | { 35 | public class ToolBoxListItem : UserControl 36 | { 37 | 38 | #region Fields 39 | private bool hover; 40 | private Image image; 41 | private bool selected; 42 | private ToolboxItem tool_box_item; 43 | #endregion 44 | 45 | #region Public Constructor 46 | public ToolBoxListItem (ToolboxItem toolBoxItem) 47 | { 48 | Size = new Size (150, 20); 49 | 50 | SetStyle (ControlStyles.ResizeRedraw, true); 51 | 52 | Text = toolBoxItem.DisplayName; 53 | 54 | if (toolBoxItem.Bitmap != null) 55 | image = toolBoxItem.Bitmap; 56 | else 57 | image = SystemIcons.Exclamation.ToBitmap (); 58 | 59 | tool_box_item = toolBoxItem; 60 | } 61 | #endregion 62 | 63 | #region Public Properties 64 | public bool Selected { 65 | get { return selected;} 66 | set { 67 | if (selected != value) { 68 | selected = value; 69 | Invalidate (); 70 | } 71 | } 72 | } 73 | 74 | public ToolboxItem ToolBoxItem { 75 | get { return tool_box_item;} 76 | } 77 | #endregion 78 | 79 | #region Public Methods 80 | public void Deselect () 81 | { 82 | if (selected) { 83 | selected = false; 84 | Invalidate (); 85 | } 86 | } 87 | #endregion 88 | 89 | #region Protected Methods 90 | protected override void OnClick (EventArgs e) 91 | { 92 | selected = true; 93 | Invalidate (); 94 | 95 | base.OnClick (e); 96 | } 97 | 98 | protected override void OnMouseEnter (EventArgs e) 99 | { 100 | base.OnMouseEnter (e); 101 | 102 | hover = true; 103 | Invalidate (); 104 | } 105 | 106 | protected override void OnMouseLeave (EventArgs e) 107 | { 108 | base.OnMouseLeave (e); 109 | 110 | hover = false; 111 | Invalidate (); 112 | } 113 | 114 | protected override void OnPaintBackground (PaintEventArgs e) 115 | { 116 | base.OnPaintBackground (e); 117 | 118 | if (hover) { 119 | using (SolidBrush b = new SolidBrush (ProfessionalColors.ButtonPressedGradientMiddle)) 120 | e.Graphics.FillRectangle (b, ClientRectangle); 121 | 122 | using (Pen p = new Pen (ProfessionalColors.ButtonPressedHighlightBorder)) 123 | e.Graphics.DrawRectangle (p, new Rectangle (0, 0, Width - 1, Height - 1)); 124 | } else if (selected) { 125 | using (SolidBrush b = new SolidBrush (ProfessionalColors.ButtonSelectedGradientMiddle)) 126 | e.Graphics.FillRectangle (b, ClientRectangle); 127 | 128 | using (Pen p = new Pen (ProfessionalColors.ButtonSelectedHighlightBorder)) 129 | e.Graphics.DrawRectangle (p, new Rectangle (0, 0, Width - 1, Height - 1)); 130 | } 131 | } 132 | 133 | protected override void OnPaint (PaintEventArgs e) 134 | { 135 | base.OnPaint (e); 136 | 137 | if (image != null) 138 | e.Graphics.DrawImage (image, new Rectangle (2, 2, 16, 16)); 139 | 140 | TextRenderer.DrawText (e.Graphics, Text, Font, new Rectangle (20, 1, Width - 21, Height - 2), Color.Black, TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine); 141 | } 142 | #endregion 143 | } 144 | } 145 | --------------------------------------------------------------------------------