From 0f74078d14a5791649bc561e007c1b9081bb047e Mon Sep 17 00:00:00 2001 From: "roger.alsing" Date: Sat, 12 Dec 2009 14:23:03 +0000 Subject: [PATCH] --- .../Alsing.AlbinoHorse/Alsing.AlbinoHorse.sln | 23 + .../Alsing.AlbinoHorse/Alsing.AlbinoHorse.suo | Bin 0 -> 15872 bytes .../Alsing.AlbinoHorse.csproj | 172 + .../Infrastructure/BoundingBox.cs | 61 + .../Infrastructure/Events.cs | 10 + .../Infrastructure/RenderInfo.cs | 23 + .../Infrastructure/ShapeCancelEventArgs.cs | 10 + .../Infrastructure/ShapeKeyEventArgs.cs | 14 + .../Infrastructure/ShapeMouseEventArgs.cs | 17 + .../Alsing.AlbinoHorse/Layout/Graph.cs | 192 + .../Alsing.AlbinoHorse/Layout/Node.cs | 190 + .../Model/DefaultUmlClassData.cs | 15 + .../Model/DefaultUmlDiagramData.cs | 35 + .../Model/DefaultUmlTypeData.cs | 39 + .../Model/DefaultUmlTypeMemberData.cs | 25 + .../Model/Interfaces/IUmlClassData.cs | 11 + .../Model/Interfaces/IUmlCommentData.cs | 11 + .../Model/Interfaces/IUmlDiagramData.cs | 11 + .../Model/Interfaces/IUmlEnumData.cs | 4 + .../Model/Interfaces/IUmlInstanceTypeData.cs | 11 + .../Model/Interfaces/IUmlInterfaceData.cs | 4 + .../Model/Interfaces/IUmlPropertyData.cs | 12 + .../Model/Interfaces/IUmlRelationData.cs | 30 + .../Model/Interfaces/IUmlRenderer.cs | 7 + .../Model/Interfaces/IUmlTypeData.cs | 11 + .../Alsing.AlbinoHorse/Model/Shape.cs | 58 + .../Alsing.AlbinoHorse/Model/UmlDiagram.cs | 86 + .../Model/UmlTypeGfxSettings.cs | 83 + .../Model/UmlTypeMembers/UmlTypeMember.cs | 19 + .../UmlTypeMembers/UmlTypeMemberSection.cs | 42 + .../Model/UmlTypes/UmlClass.cs | 120 + .../Model/UmlTypes/UmlComment.cs | 238 + .../Model/UmlTypes/UmlEnum.cs | 64 + .../Model/UmlTypes/UmlInstanceType.cs | 453 ++ .../Model/UmlTypes/UmlInterface.cs | 60 + .../Model/UmlTypes/UmlRelation.cs | 574 +++ .../Model/UmlTypes/UmlShape.cs | 145 + .../Model/UmlTypes/UmlType.cs | 197 + .../Properties/AssemblyInfo.cs | 38 + .../Properties/Resources.Designer.cs | 105 + .../Properties/Resources.resx | 139 + .../Alsing.AlbinoHorse/Resources/Collapse.bmp | Bin 0 -> 574 bytes .../Alsing.AlbinoHorse/Resources/Collapse.gif | Bin 0 -> 905 bytes .../Alsing.AlbinoHorse/Resources/Expand.bmp | Bin 0 -> 574 bytes .../Alsing.AlbinoHorse/Resources/Expand.gif | Bin 0 -> 907 bytes .../Resources/InheritanceArrow.gif | Bin 0 -> 163 bytes .../Alsing.AlbinoHorse/Resources/Property.bmp | Bin 0 -> 782 bytes .../Alsing.AlbinoHorse/TestDiagram.cd | 57 + .../Windows/Forms/Canvas.Designer.cs | 37 + .../Windows/Forms/Canvas.cs | 43 + .../Windows/Forms/EditMode.cs | 9 + .../Windows/Forms/UmlDesigner.Designer.cs | 85 + .../Windows/Forms/UmlDesigner.cs | 671 +++ .../Windows/Forms/UmlDesigner.resx | 132 + .../Windows/Forms/UmlDesigner_Layout.cs | 20 + .../Alsing.SyntaxoBox/Alsing.SyntaxBox.sln | 32 + .../Alsing.SyntaxoBox/Alsing.SyntaxBox.suo | Bin 0 -> 141312 bytes ...ing.SourceCode.SourceCodePrintDocument.bmp | Bin 0 -> 246 bytes .../Alsing.SourceCode.SyntaxDocument.bmp | Bin 0 -> 246 bytes .../Alsing.SyntaxBox.NET.csproj | 426 ++ .../Alsing.Windows.Forms.SyntaxBoxControl.bmp | Bin 0 -> 246 bytes .../Alsing.SyntaxBox/AssemblyInfo.cs | 59 + .../Alsing.SyntaxBox/Classes/Caret.cs | 539 ++ .../Classes/KeyboadActionList.cs | 19 + .../Classes/KeyboardAction.cs | 59 + .../Alsing.SyntaxBox/Classes/NativePainter.cs | 1848 +++++++ .../Alsing.SyntaxBox/Classes/Selection.cs | 440 ++ .../Alsing.SyntaxBox/Classes/Structs.cs | 235 + .../Collections/CollectionBase.cs | 140 + .../Alsing.SyntaxBox/Compona.Syntaxbox.xml | 4457 +++++++++++++++++ .../Controls/Autolist/AutoListForm.cs | 380 ++ .../Controls/Autolist/AutoListForm.resx | 105 + .../Controls/Autolist/TabListBox.cs | 130 + .../Controls/Autolist/TabListBox.resx | 42 + .../Controls/BaseControls/BaseControl.cs | 320 ++ .../Controls/BaseControls/BaseControl.resx | 105 + .../BaseControls/BaseListBoxControl.cs | 289 ++ .../BaseControls/BaseListBoxControl.resx | 42 + .../Controls/BaseControls/BasePanelControl.cs | 285 ++ .../BaseControls/BasePanelControl.resx | 42 + .../Controls/BaseControls/BorderControl.cs | 25 + .../Controls/EditView/EditViewControl.cs | 3701 ++++++++++++++ .../Controls/EditView/EditViewControl.resx | 190 + .../Controls/FormatLabel/Element.cs | 64 + .../Controls/FormatLabel/Events.cs | 39 + .../FormatLabel/FormatLabelControl.cs | 1248 +++++ .../FormatLabel/FormatLabelControl.resx | 102 + .../Controls/FormatLabel/Row.cs | 25 + .../Controls/FormatLabel/Word.cs | 25 + .../Controls/InfoTip/InfoTipForm.cs | 387 ++ .../Controls/InfoTip/InfoTipForm.resx | 141 + .../Controls/IntelliMouse/Events.cs | 22 + .../Controls/IntelliMouse/IntelliMouse.cs | 378 ++ .../Controls/IntelliMouse/IntelliMouse.resx | 140 + .../Controls/RegionHandler/RegionHandler.cs | 96 + .../Controls/RegionHandler/RegionHandler.resx | 42 + .../SplitView/SplitViewChildControl.cs | 337 ++ .../SplitView/SplitViewChildControl.resx | 42 + .../Controls/SplitView/SplitViewControl.cs | 706 +++ .../Controls/SplitView/SplitViewControl.resx | 114 + .../SplitView/SplitViewParentControl.cs | 433 ++ .../SplitView/SplitViewParentControl.resx | 102 + .../Controls/Syntaxbox/Dialogs/FindReplace.cs | 565 +++ .../Syntaxbox/Dialogs/FindReplace.resx | 120 + .../Controls/Syntaxbox/Dialogs/GotoLine.cs | 180 + .../Controls/Syntaxbox/Dialogs/GotoLine.resx | 102 + .../Controls/Syntaxbox/Dialogs/Settings.cs | 295 ++ .../Controls/Syntaxbox/Dialogs/Settings.resx | 102 + .../Controls/Syntaxbox/Events.cs | 138 + .../Controls/Syntaxbox/SyntaxBoxControl.cs | 2231 +++++++++ .../Controls/Syntaxbox/SyntaxBoxControl.resx | 473 ++ .../Controls/Syntaxbox/SyntaxBoxDesigner.cs | 57 + .../ThumbControl/ThumbControl.Designer.cs | 47 + .../Controls/ThumbControl/ThumbControl.cs | 31 + .../Design/CollectionEditorGui.cs | 414 ++ .../Design/CollectionEditorGui.resx | 156 + .../Design/ComponaCollectionEditor.cs | 356 ++ .../Design/FilteredTypeConverter.cs | 45 + .../Design/Int32AutoConverter.cs | 63 + .../Design/Int32DefaultConverter.cs | 63 + .../Document/DocumentStructure/Row/Row.cs | 1096 ++++ .../DocumentStructure/Row/RowEventArgs.cs | 24 + .../DocumentStructure/Row/RowEventHandler.cs | 7 + .../Document/DocumentStructure/Row/RowList.cs | 19 + .../Document/DocumentStructure/Span/Span.cs | 78 + .../DocumentStructure/Span/SpanList.cs | 19 + .../DocumentStructure/Structs/BracketType.cs | 19 + .../DocumentStructure/Structs/TextPoint.cs | 77 + .../DocumentStructure/Structs/TextRange.cs | 123 + .../DocumentStructure/Undo/UndoBlock.cs | 55 + .../Undo/UndoBlockCollection.cs | 514 ++ .../DocumentStructure/Undo/UndoBuffer.cs | 37 + .../Document/DocumentStructure/Word/Word.cs | 114 + .../DocumentStructure/Word/WordList.cs | 19 + .../Document/Export/CollapsingHTMLExporter.cs | 181 + .../Document/Export/SimpleHTMLExporter.cs | 74 + .../Document/ImageIndexList.cs | 19 + .../Document/Parser/DefaultParser.cs | 787 +++ .../Document/Parser/IParser.cs | 63 + .../Document/Parser/NewParser.cs | 26 + .../Document/Parser/ParseTools.cs | 126 + .../Document/Parser/ParserBase.cs | 54 + .../Document/Parser/ParserEventHandler.cs | 7 + .../Document/Parser/ScanResultSegment.cs | 14 + .../Document/Parser/ScanResultWord.cs | 11 + .../Document/Print/SourceCodePrintDocument.cs | 214 + .../Print/SourceCodePrintDocument.resx | 42 + .../SyntaxDefinition/Pattern/Pattern.cs | 170 + .../Pattern/PatternCollection.cs | 19 + .../Pattern/PatternExtensions.cs | 158 + .../SyntaxDefinition/Pattern/PatternList.cs | 160 + .../Pattern/PatternListList.cs | 93 + .../Pattern/PatternScanResult.cs | 29 + .../Document/SyntaxDefinition/Scope/Scope.cs | 70 + .../SyntaxDefinition/Scope/ScopeList.cs | 28 + .../SpanDefinition/SpanDefinition.cs | 242 + .../SpanDefinition/SpanDefinitionList.cs | 19 + .../SyntaxDefinition/SyntaxDefinition.cs | 245 + .../SyntaxDefinition/SyntaxDefinitionList.cs | 69 + .../SyntaxDefinitionLoader.cs | 614 +++ .../SyntaxDefinition/TextStyle/TextStyle.cs | 187 + .../TextStyle/TextStyleDesignerDialog.cs | 261 + .../TextStyle/TextStyleDesignerDialog.resx | 102 + .../TextStyle/TextStyleUIEditor.cs | 94 + .../Document/SyntaxDocument.cs | 1745 +++++++ .../Document/SyntaxDocument.resx | 42 + .../Drawing/DesktopGraphics.cs | 29 + .../Alsing.SyntaxBox/Drawing/DrawingTools.cs | 382 ++ .../Alsing.SyntaxBox/Drawing/Enums.cs | 45 + .../Drawing/GDI32/FontEnum.cs | 194 + .../Drawing/GDI32/GDIBrushes.cs | 229 + .../Alsing.SyntaxBox/Drawing/GDI32/GDIFont.cs | 83 + .../Drawing/GDI32/GDIObject.cs | 41 + .../Alsing.SyntaxBox/Drawing/GDI32/GDIPens.cs | 35 + .../Drawing/GDI32/GDISurface.cs | 348 ++ .../Alsing.SyntaxBox/FlippedCursor.cur | Bin 0 -> 326 bytes .../Globalization/IMEWindow.cs | 105 + .../Alsing.SyntaxBox/Interfaces/IPainter.cs | 72 + .../Alsing.SyntaxBox/MoveDown.cur | Bin 0 -> 766 bytes .../Alsing.SyntaxBox/MoveUp.cur | Bin 0 -> 766 bytes .../Alsing.SyntaxBox/MoveUpDown.cur | Bin 0 -> 766 bytes .../Properties/Resources.Designer.cs | 112 + .../Properties/Resources.resx | 142 + .../Alsing.SyntaxBox/SyntaxBox.hst | 27 + .../Text/PatternMatchers/BinPatternMatcher.cs | 47 + .../Text/PatternMatchers/DecPatternMatcher.cs | 56 + .../Text/PatternMatchers/HexPatternMatcher.cs | 42 + .../Text/PatternMatchers/IPatternMatcher.cs | 21 + .../Text/PatternMatchers/IntPatternMatcher.cs | 49 + .../PatternMatchers/PatternMatcherBase.cs | 32 + .../PropertyPathPatternMatcher.cs | 84 + .../PatternMatchers/RegexPatternMatcher.cs | 101 + .../PatternMatchers/RegionPatternMatcher.cs | 66 + .../Alsing.SyntaxBox/Text/ReadMe.txt | 6 + .../Text/Tokenizer/CharUtils.cs | 137 + .../Text/Tokenizer/MatchResult.cs | 49 + .../Text/Tokenizer/PatternMatchReference.cs | 25 + .../Alsing.SyntaxBox/Text/Tokenizer/Token.cs | 29 + .../Text/Tokenizer/TokenTree-API.cs | 59 + .../Text/Tokenizer/TokenTree-Util.cs | 105 + .../Text/Tokenizer/TokenTree.cs | 194 + .../Text/Tokenizer/TokenTreeNode.cs | 168 + .../Text/Tokenizer/Tokenizer.cs | 85 + .../Alsing.SyntaxBox/Win32/Enums.cs | 762 +++ .../Alsing.SyntaxBox/Win32/NativeMethods.cs | 375 ++ .../Win32/NativeSubclasser.cs | 85 + .../Samples/HelloWorld/Form1.Designer.cs | 957 ++++ .../Samples/HelloWorld/Form1.cs | 18 + .../Samples/HelloWorld/Form1.resx | 123 + .../Samples/HelloWorld/HelloWorld.csproj | 95 + .../Samples/HelloWorld/Program.cs | 19 + .../HelloWorld/Properties/AssemblyInfo.cs | 36 + .../Properties/Resources.Designer.cs | 71 + .../HelloWorld/Properties/Resources.resx | 117 + .../Properties/Settings.Designer.cs | 30 + .../HelloWorld/Properties/Settings.settings | 7 + .../Alsing.SyntaxoBox/Samples/MdiDemo/App.ico | Bin 0 -> 1078 bytes .../Samples/MdiDemo/AssemblyInfo.cs | 58 + .../Samples/MdiDemo/Caption.ico | Bin 0 -> 1406 bytes .../Samples/MdiDemo/Document.cs | 9 + .../Samples/MdiDemo/EditForm.cs | 355 ++ .../Samples/MdiDemo/EditForm.resx | 187 + .../Samples/MdiDemo/LanguageForm.cs | 191 + .../Samples/MdiDemo/LanguageForm.resx | 157 + .../Samples/MdiDemo/MDIDemo.csproj | 191 + .../Samples/MdiDemo/MDIDemo.csproj.user | 68 + .../Samples/MdiDemo/MDIDemo.sln | 19 + .../Samples/MdiDemo/MDIDemo.suo | Bin 0 -> 23552 bytes .../Samples/MdiDemo/MDIParent.cs | 595 +++ .../Samples/MdiDemo/MDIParent.resx | 167 + .../MdiDemo/Properties/Resources.Designer.cs | 63 + .../Samples/MdiDemo/Properties/Resources.resx | 120 + .../Samples/MdiDemo/SettingsForm.cs | 243 + .../Samples/MdiDemo/SettingsForm.resx | 105 + .../Samples/MdiDemo/Style.cs | 84 + .../Samples/MdiDemo/Style.resx | 42 + .../Samples/MdiDemo/bin/Debug/6502.syn | 92 + .../Samples/MdiDemo/bin/Debug/ASP.Syn | 393 ++ .../Samples/MdiDemo/bin/Debug/C++.syn | 175 + .../Samples/MdiDemo/bin/Debug/CSS.Syn | 86 + .../Samples/MdiDemo/bin/Debug/CSharp.syn | 148 + .../Samples/MdiDemo/bin/Debug/Cobol.syn | 85 + .../Samples/MdiDemo/bin/Debug/DOSBatch.syn | 86 + .../Samples/MdiDemo/bin/Debug/DataFlex.syn | 94 + .../Samples/MdiDemo/bin/Debug/Delphi.syn | 245 + .../Samples/MdiDemo/bin/Debug/Fortran90.syn | 95 + .../Samples/MdiDemo/bin/Debug/FoxPro.syn | 68 + .../Samples/MdiDemo/bin/Debug/JSP.syn | 90 + .../Samples/MdiDemo/bin/Debug/Java.syn | 149 + .../Samples/MdiDemo/bin/Debug/JavaScript.syn | 85 + .../Samples/MdiDemo/bin/Debug/LotusScript.syn | 79 + .../Samples/MdiDemo/bin/Debug/MSIL.syn | 594 +++ .../Samples/MdiDemo/bin/Debug/MySQL_SQL.syn | 75 + .../Samples/MdiDemo/bin/Debug/Oracle_SQL.syn | 99 + .../Samples/MdiDemo/bin/Debug/PHP.Syn | 487 ++ .../Samples/MdiDemo/bin/Debug/Perl.syn | 80 + .../Samples/MdiDemo/bin/Debug/Povray.syn | 79 + .../Samples/MdiDemo/bin/Debug/Python.syn | 95 + .../MdiDemo/bin/Debug/SQLServer2K_SQL.syn | 99 + .../MdiDemo/bin/Debug/SQLServer7_SQL.syn | 99 + .../MdiDemo/bin/Debug/SystemPolicies.syn | 91 + .../Samples/MdiDemo/bin/Debug/Template.syn | 66 + .../Samples/MdiDemo/bin/Debug/Text.syn | 42 + .../Samples/MdiDemo/bin/Debug/TurboPascal.syn | 85 + .../Samples/MdiDemo/bin/Debug/VB.syn | 235 + .../Samples/MdiDemo/bin/Debug/VBScript.syn | 87 + .../Samples/MdiDemo/bin/Debug/VRML97.syn | 86 + .../Samples/MdiDemo/bin/Debug/XML.syn | 377 ++ .../Samples/MdiDemo/bin/Debug/rtf.syn | 72 + .../Alsing.SyntaxoBox/SyntaxFiles/6502.syn | 92 + .../Alsing.SyntaxoBox/SyntaxFiles/ASP.Syn | 391 ++ .../Alsing.SyntaxoBox/SyntaxFiles/C#.syn | 148 + .../Alsing.SyntaxoBox/SyntaxFiles/C++.syn | 175 + .../Alsing.SyntaxoBox/SyntaxFiles/CSS.Syn | 86 + .../Alsing.SyntaxoBox/SyntaxFiles/CSharp.syn | 148 + .../Alsing.SyntaxoBox/SyntaxFiles/Cobol.syn | 85 + .../SyntaxFiles/DOSBatch.syn | 86 + .../SyntaxFiles/DataFlex.syn | 94 + .../Alsing.SyntaxoBox/SyntaxFiles/Delphi.syn | 245 + .../SyntaxFiles/Fortran90.syn | 95 + .../Alsing.SyntaxoBox/SyntaxFiles/FoxPro.syn | 68 + .../Alsing.SyntaxoBox/SyntaxFiles/JSP.syn | 90 + .../Alsing.SyntaxoBox/SyntaxFiles/Java.syn | 149 + .../SyntaxFiles/JavaScript.syn | 85 + .../SyntaxFiles/LotusScript.syn | 79 + .../Alsing.SyntaxoBox/SyntaxFiles/MSIL.syn | 594 +++ .../SyntaxFiles/MySQL_SQL.syn | 75 + .../SyntaxFiles/Oracle_SQL.syn | 99 + .../Alsing.SyntaxoBox/SyntaxFiles/PHP.Syn | 489 ++ .../Alsing.SyntaxoBox/SyntaxFiles/Perl.syn | 80 + .../Alsing.SyntaxoBox/SyntaxFiles/Povray.syn | 79 + .../Alsing.SyntaxoBox/SyntaxFiles/Python.syn | 95 + .../SyntaxFiles/SQLServer2K_SQL.syn | 99 + .../SyntaxFiles/SQLServer7_SQL.syn | 99 + .../SyntaxFiles/SmallTalk.syn | 145 + .../SyntaxFiles/SystemPolicies.syn | 91 + .../SyntaxFiles/Template.syn | 66 + .../Alsing.SyntaxoBox/SyntaxFiles/Text.syn | 42 + .../SyntaxFiles/TurboPascal.syn | 85 + .../Alsing.SyntaxoBox/SyntaxFiles/VB.NET.syn | 525 ++ .../Alsing.SyntaxoBox/SyntaxFiles/VB.syn | 235 + .../SyntaxFiles/VBScript.syn | 87 + .../Alsing.SyntaxoBox/SyntaxFiles/VRML97.syn | 86 + .../Alsing.SyntaxoBox/SyntaxFiles/XML.syn | 377 ++ .../Alsing.SyntaxoBox/SyntaxFiles/npath.syn | 92 + .../Alsing.SyntaxoBox/SyntaxFiles/rtf.syn | 72 + 306 files changed, 55464 insertions(+) create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse.sln create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse.suo create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Alsing.AlbinoHorse.csproj create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/BoundingBox.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/Events.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/RenderInfo.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/ShapeCancelEventArgs.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/ShapeKeyEventArgs.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/ShapeMouseEventArgs.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Layout/Graph.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Layout/Node.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlClassData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlDiagramData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlTypeData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlTypeMemberData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlClassData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlCommentData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlDiagramData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlEnumData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlInstanceTypeData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlInterfaceData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlPropertyData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlRelationData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlRenderer.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlTypeData.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Shape.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlDiagram.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypeGfxSettings.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypeMembers/UmlTypeMember.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypeMembers/UmlTypeMemberSection.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlClass.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlComment.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlEnum.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlInstanceType.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlInterface.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlRelation.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlShape.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlType.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Properties/AssemblyInfo.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Properties/Resources.Designer.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Properties/Resources.resx create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Resources/Collapse.bmp create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Resources/Collapse.gif create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Resources/Expand.bmp create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Resources/Expand.gif create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Resources/InheritanceArrow.gif create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Resources/Property.bmp create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/TestDiagram.cd create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/Canvas.Designer.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/Canvas.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/EditMode.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner.Designer.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner.cs create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner.resx create mode 100644 WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner_Layout.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox.sln create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox.suo create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Alsing.SourceCode.SourceCodePrintDocument.bmp create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Alsing.SourceCode.SyntaxDocument.bmp create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Alsing.SyntaxBox.NET.csproj create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Alsing.Windows.Forms.SyntaxBoxControl.bmp create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/AssemblyInfo.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/Caret.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/KeyboadActionList.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/KeyboardAction.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/NativePainter.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/Selection.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/Structs.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Collections/CollectionBase.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Compona.Syntaxbox.xml create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/AutoListForm.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/AutoListForm.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/TabListBox.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/TabListBox.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseControl.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseControl.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseListBoxControl.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseListBoxControl.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BasePanelControl.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BasePanelControl.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BorderControl.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/EditView/EditViewControl.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/EditView/EditViewControl.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Element.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Events.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/FormatLabelControl.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/FormatLabelControl.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Row.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Word.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/InfoTip/InfoTipForm.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/InfoTip/InfoTipForm.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/IntelliMouse/Events.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/IntelliMouse/IntelliMouse.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/IntelliMouse/IntelliMouse.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/RegionHandler/RegionHandler.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/RegionHandler/RegionHandler.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewChildControl.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewChildControl.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewControl.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewControl.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewParentControl.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewParentControl.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/FindReplace.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/FindReplace.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/GotoLine.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/GotoLine.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/Settings.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/Settings.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Events.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/SyntaxBoxControl.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/SyntaxBoxControl.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/SyntaxBoxDesigner.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/ThumbControl/ThumbControl.Designer.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/ThumbControl/ThumbControl.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/CollectionEditorGui.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/CollectionEditorGui.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/ComponaCollectionEditor.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/FilteredTypeConverter.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/Int32AutoConverter.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/Int32DefaultConverter.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/Row.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/RowEventArgs.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/RowEventHandler.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/RowList.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Span/Span.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Span/SpanList.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Structs/BracketType.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Structs/TextPoint.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Structs/TextRange.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Undo/UndoBlock.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Undo/UndoBlockCollection.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Undo/UndoBuffer.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Word/Word.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Word/WordList.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Export/CollapsingHTMLExporter.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Export/SimpleHTMLExporter.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/ImageIndexList.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/DefaultParser.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/IParser.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/NewParser.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ParseTools.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ParserBase.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ParserEventHandler.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ScanResultSegment.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ScanResultWord.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Print/SourceCodePrintDocument.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Print/SourceCodePrintDocument.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/Pattern.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternCollection.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternExtensions.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternList.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternListList.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternScanResult.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Scope/Scope.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Scope/ScopeList.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SpanDefinition/SpanDefinition.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SpanDefinition/SpanDefinitionList.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SyntaxDefinition.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SyntaxDefinitionList.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SyntaxDefinitionLoader.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyle.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyleDesignerDialog.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyleDesignerDialog.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyleUIEditor.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDocument.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDocument.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/DesktopGraphics.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/DrawingTools.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/Enums.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/FontEnum.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIBrushes.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIFont.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIObject.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIPens.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDISurface.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/FlippedCursor.cur create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Globalization/IMEWindow.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Interfaces/IPainter.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/MoveDown.cur create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/MoveUp.cur create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/MoveUpDown.cur create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Properties/Resources.Designer.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Properties/Resources.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/SyntaxBox.hst create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/BinPatternMatcher.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/DecPatternMatcher.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/HexPatternMatcher.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/IPatternMatcher.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/IntPatternMatcher.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/PatternMatcherBase.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/PropertyPathPatternMatcher.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/RegexPatternMatcher.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/RegionPatternMatcher.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/ReadMe.txt create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/CharUtils.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/MatchResult.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/PatternMatchReference.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/Token.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTree-API.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTree-Util.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTree.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTreeNode.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/Tokenizer.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Win32/Enums.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Win32/NativeMethods.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Win32/NativeSubclasser.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Form1.Designer.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Form1.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Form1.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/HelloWorld.csproj create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Program.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/AssemblyInfo.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Resources.Designer.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Resources.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Settings.Designer.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Settings.settings create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/App.ico create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/AssemblyInfo.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Caption.ico create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Document.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/EditForm.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/EditForm.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/LanguageForm.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/LanguageForm.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.csproj create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.csproj.user create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.sln create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.suo create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIParent.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIParent.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Properties/Resources.Designer.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Properties/Resources.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/SettingsForm.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/SettingsForm.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Style.cs create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Style.resx create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/6502.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/ASP.Syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/C++.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/CSS.Syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/CSharp.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/Cobol.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/DOSBatch.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/DataFlex.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/Delphi.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/Fortran90.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/FoxPro.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/JSP.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/Java.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/JavaScript.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/LotusScript.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/MSIL.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/MySQL_SQL.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/Oracle_SQL.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/PHP.Syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/Perl.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/Povray.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/Python.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/SQLServer2K_SQL.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/SQLServer7_SQL.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/SystemPolicies.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/Template.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/Text.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/TurboPascal.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/VB.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/VBScript.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/VRML97.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/XML.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/rtf.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/6502.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/ASP.Syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/C#.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/C++.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/CSS.Syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/CSharp.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/Cobol.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/DOSBatch.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/DataFlex.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/Delphi.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/Fortran90.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/FoxPro.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/JSP.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/Java.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/JavaScript.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/LotusScript.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/MSIL.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/MySQL_SQL.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/Oracle_SQL.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/PHP.Syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/Perl.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/Povray.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/Python.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/SQLServer2K_SQL.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/SQLServer7_SQL.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/SmallTalk.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/SystemPolicies.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/Template.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/Text.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/TurboPascal.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/VB.NET.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/VB.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/VBScript.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/VRML97.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/XML.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/npath.syn create mode 100644 WindowsFormsComponents/Alsing.SyntaxoBox/SyntaxFiles/rtf.syn diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse.sln b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse.sln new file mode 100644 index 0000000..fa85082 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Alsing.AlbinoHorse", "Alsing.AlbinoHorse\Alsing.AlbinoHorse.csproj", "{4E22716D-047F-4CBC-9B86-785E2A0CAB67}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + NPDebug|Any CPU = NPDebug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4E22716D-047F-4CBC-9B86-785E2A0CAB67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E22716D-047F-4CBC-9B86-785E2A0CAB67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E22716D-047F-4CBC-9B86-785E2A0CAB67}.NPDebug|Any CPU.ActiveCfg = Debug|Any CPU + {4E22716D-047F-4CBC-9B86-785E2A0CAB67}.NPDebug|Any CPU.Build.0 = Debug|Any CPU + {4E22716D-047F-4CBC-9B86-785E2A0CAB67}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E22716D-047F-4CBC-9B86-785E2A0CAB67}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse.suo b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse.suo new file mode 100644 index 0000000000000000000000000000000000000000..d2bd4d1ff057865e2c37f67d26b5dfa28f588b1a GIT binary patch literal 15872 zcmeHNNo-t28ve~T30sCO%&=rkh!9&^&H~ONK)rb(-o|$99IQcJ+KrR8+heyATLVHM zKwLP3gph&+(g+X|5<-AD00%V8C2(MnI3T!i0s#j!b0MDZt9s>nOZV&79hV)XRIB>+ zd#_&ofBp6S-~U&={`|}}-@fwpP2WkVJSZ2-+10IbneTcFezU6bN0E#0gXd>gS6B5# z5&XPRen%Gg4Z2?9&Ecgua=!n7x&?JB>J_M$qjHX~^p02KxD6E$kZVw{MZFI7dej?G zx1-*O`X|&squzviGwLmMr;>vvA z%IMM0{?&3Z8hu1?p$tG`S&mCLq)+2lUY7NZgx}lcq83_`_~S9*V+y-$J1pa}C?}*x zW^k;?QG6GmlexZFr^8*4Pu$aQlFBD%(!W@8kTxMpQpAUHN1;zeCgo9_)sxNVTOptQ z(GQc#CvQ_{7W!hihB<)#Pag35zyFy={GZS5Kwp3HWZ&i;{rzzqJik!fTi~5DQq6h5Cq&B`GeleCoJH8bFnqIWi-&dSmS zZdp*iJr)pGkFx@eV@}x5G^*A^vsw`n$7L3p^g@eCoRy(L8STioBe=E*&mV`*tulmb zOEQIPWt<(vnA-5%2>KgSPgZbTL=TfV3fiuhq%i+vAfo`CPRKkop(QJjTf5u|{$Vaa zZXjA~x3qW2|A)NOuzd3WBs7?ZT-stTR=UU?$U^;IVx`pn#ks1*za47KQ<#r3=7aVw z)b0p(Aisrq6LY4d<7fNt30#!$_^tdEAZG$vlyt)y-_4Al+-kZDB8{=91i8}+X9jQP zd_8fOM6T9meeoVAmuR2F`00lQ@ZYHaT?K`QJ*DaI706tG?a741e+lP{YnfpIb5a2hk_*@}$Vi7EpZN*b z9ZCJqkN+I{oy3gKdOiEcJb-(QCUH#E*2MV9m*fkUIQb?Q&A~Di)M_Q=$!8Q!I)1L( zOx!zH{4nqAh5bs(N{nLTm`ld8`L!7oc>uc!EQe)3zW;$Zy%#f`mv)@zWsmHZjQYI~ zzxLphL-gB?R=k(SuQq(rs98kDHay8sR`$u`h?7%5XHagxiXKs^l(iS1cJz8bWU$}; zIP1W#{pc@)x*HNQasc;tDX-%!M$Z-CqRPh#z*1NXuVIY?*MF4DHBeIde*Q6tAP>$%7cwu| zP~(Pt7hfo!d`fdBmEVfC6R0f7&^`z~$jY=-K^_Cb<`5rRVXFbGm{Z6XG72eNw`S0C z3O!q&e+XymiSU#!Yid*%#)`CxC^K>rW647IqSAJY(2h19hI>AYyU{WvyRP^xeb4hB zcfI}f>u0WeZFF0YEPVEG`mPs`ANl83r=J`=``+t(sz*Nm;Fn|1?R-D~=AkbqU;OVf zL5MOW2d1z8a7=c{B*Ff=XEd5fB&_Wv3OFgo)~}a>WOD&_4KI1CFgz& z^K4tC)LFGwzMbM&<-9aFwoTm4UBDZ6uudR?GxD6k2)MRl#Mq-&QG4PZmt$v$h~`Ts zJ2Wu+_nm!DT=HShOV2L{7c?3 zC5iri{_8@dnNqUn;0q;a(*bSBAY{Qr@)hqjE5BdGz7n*UQ?=-0-W;wh)EN-?w_*7^ z(Wl9~!st!P`$nx>nvj1x9=_A-!0dCH{m&sVIAaj^Aej}^n}KG=zYDU>`nv;coL6~R z9$d^!aG&yA=43h(+$WE$p>i0SEkP&lf9S&epYI!*o&Uzw`|vuoOzV`rwPy8|cdKdZeM z9XY$?jc*z@(5u3uh|HzHc=T#k&oMRXb)r!>>@}_Cf_y>V;64J^G|XbibK{uDf*e6z z0Ror}a&IAx7DZUx>UYG6e)TLi46Uf2-jSKWuLU3{Y&-Y5>G?C-EW&pB3hhhFj^jwC zGA*p#`kdR1I_TXa;*DBRziv-My=t*5*r@fooNE|oy`bjSZe%039valD6MmxOP6gIv zCKSX!SK)5;vEFE{kaI3IXa$RG%e_{cv=eRoyN#63+;;(d$=_M!Sts%B=OQ=k9jAx3 zQZx!NLc3#cKRd>IIrnR3@zLxZ_3?vFX08YGvI5D>k;jlrFy_xArdY%bIFUZnv{EJZZno`A#EoL!4Pyr}-{)m~ z7V&P@3vt|(2Xgp+#^BBB(&+@(@!rR^{E|Ymj-fnX_A$cdMYL-1^#LaqGBd$-fQcM4 z;70Rb2s=aWb1%lM@H&KhI#!#g=eWU5)GEezZPpRaR;{Jn@JyUv1#^$uvA=(VFl4Od zUkh2wRl94g=f>-T(P0KiqdsYTbC;a|+$bStXuc@>IKWN*mIPnHJjvR}4QnUSC=ae& zf~~ABZtxU`bi+~MJ(k*-cfUHT##;vCQO0s(GynV%#lf{Iv2Iq`(YsL{HxFaRZWd#1 zcAJvht6l`kIN?;yL|mm*+YPh3U;eeGo48Y*IT`)<-$?VHJL*x}2i>q}yp8-T72VR$ z>u$U-UL%{;5q*3wQaG>IdWP?#{4nAK^M0SyJa5<_c^<*HG2A!S|3$Sd;(p(ib6=Zv z?H*OsnuE@*8Lu1fR@)g4YMRUUbaVg6u0uuVJ7wfD z?)sbp_W9m_3_JLH!5VF-_u;!;{nLv({VPfvW@RZkhVK%N`W*`2D6vwH2iL5&5qel# zL^ZKHRvV#7RK8sUZG`+_c9!z(fmWL(yAQh&y5$tgPI-IcVSNmOHy1g4ry0b!!4{Ft zLUeBirufFxubE$;^I;yhh4f>_K~^#I?br8w^9lan*>Bra=-=9YKk|=bGuf8!*MmB1 XHa7avpKKk<=JDSuJaVBpw7~xXaP_Mm literal 0 HcmV?d00001 diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Alsing.AlbinoHorse.csproj b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Alsing.AlbinoHorse.csproj new file mode 100644 index 0000000..fa18668 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Alsing.AlbinoHorse.csproj @@ -0,0 +1,172 @@ + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {4E22716D-047F-4CBC-9B86-785E2A0CAB67} + Library + Properties + Alsing.AlbinoHorse + Alsing.AlbinoHorse + + + 2.0 + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UserControl + + + Canvas.cs + + + + + + + + + + + True + True + Resources.resx + + + + + + Component + + + UmlDesigner.cs + + + Component + + + + + + + + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + + UmlDesigner.cs + Designer + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/BoundingBox.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/BoundingBox.cs new file mode 100644 index 0000000..d3cbf79 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/BoundingBox.cs @@ -0,0 +1,61 @@ +using System.Drawing; + +namespace AlbinoHorse.Infrastructure +{ + public abstract class BoundingItem + { + #region Property Target + + public object Target { get; set; } + + #endregion + + #region Property Data + + public object Data { get; set; } + + #endregion + + public abstract Rectangle GetBounds(); + + public abstract bool HitTest(int x, int y); + } + + public class BoundingBox : BoundingItem + { + #region Property Bounds + + public Rectangle Bounds { get; set; } + + #endregion + + public override Rectangle GetBounds() + { + return Bounds; + } + + public override bool HitTest(int x,int y) + { + return Bounds.Contains(x, y); + } + } + + public class BoundingLine : BoundingItem + { + public int X1 { get; set; } + public int Y1 { get; set; } + public int X2 { get; set; } + public int Y2 { get; set; } + public int Width { get; set; } + + public override Rectangle GetBounds() + { + return Rectangle.Empty; + } + + public override bool HitTest(int x, int y) + { + return false; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/Events.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/Events.cs new file mode 100644 index 0000000..2f9e1dd --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/Events.cs @@ -0,0 +1,10 @@ +using AlbinoHorse.Model; + +namespace AlbinoHorse.Infrastructure +{ + public delegate void Action(); + + public delegate void DrawRelation(Shape start, Shape end); + + public delegate void ShapeCancelHandler(object sender, ShapeCancelEventArgs args); +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/RenderInfo.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/RenderInfo.cs new file mode 100644 index 0000000..63a7ce6 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/RenderInfo.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.Drawing; + +namespace AlbinoHorse.Infrastructure +{ + public class RenderInfo + { + public RenderInfo() + { + BoundingItems = new List(); + } + + public Graphics Graphics { get; set; } + public Rectangle VisualBounds { get; set; } + public List BoundingItems { get; set; } + public int GridSize { get; set; } + public bool ShowGrid { get; set; } + public double Zoom { get; set; } + //public Size ReturnedSize { get; set; } + public Rectangle ReturnedBounds { get; set; } + public bool Preview { get; set; } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/ShapeCancelEventArgs.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/ShapeCancelEventArgs.cs new file mode 100644 index 0000000..d5b1439 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/ShapeCancelEventArgs.cs @@ -0,0 +1,10 @@ +using AlbinoHorse.Model; + +namespace AlbinoHorse.Infrastructure +{ + public class ShapeCancelEventArgs + { + public Shape Shape { get; set; } + public bool Cancel { get; set; } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/ShapeKeyEventArgs.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/ShapeKeyEventArgs.cs new file mode 100644 index 0000000..0494d24 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/ShapeKeyEventArgs.cs @@ -0,0 +1,14 @@ +using System.Windows.Forms; +using AlbinoHorse.Windows.Forms; + +namespace AlbinoHorse.Infrastructure +{ + public class ShapeKeyEventArgs + { + public Keys Key; + public bool Redraw { get; set; } + public UmlDesigner Sender { get; set; } + public int GridSize { get; set; } + public bool SnapToGrid { get; set; } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/ShapeMouseEventArgs.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/ShapeMouseEventArgs.cs new file mode 100644 index 0000000..2bc946a --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Infrastructure/ShapeMouseEventArgs.cs @@ -0,0 +1,17 @@ +using System.Windows.Forms; +using AlbinoHorse.Windows.Forms; + +namespace AlbinoHorse.Infrastructure +{ + public class ShapeMouseEventArgs + { + public int X { get; set; } + public int Y { get; set; } + public MouseButtons Button { get; set; } + public BoundingItem BoundingItem { get; set; } + public bool Redraw { get; set; } + public UmlDesigner Sender { get; set; } + public int GridSize { get; set; } + public bool SnapToGrid { get; set; } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Layout/Graph.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Layout/Graph.cs new file mode 100644 index 0000000..fa7b732 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Layout/Graph.cs @@ -0,0 +1,192 @@ +using System; +using System.Collections.Generic; +using System.Drawing; + +namespace AlbinoHorse.Layout +{ + public class Graph + { + public Graph() + { + Nodes = new List(); + } + + #region Property Nodes + + public List Nodes { get; set; } + + #endregion + + public void AutoLayout() + { + var SingleNodes = new List(); + var LinearNodeLists = new List>(); + var ConnectedNodes = new List(); + var AllLinearNodes = new List(); + + var r = new Random(0); + foreach (Node node in Nodes) + { + if (AllLinearNodes.Contains(node)) + continue; + + + if (node.Connections.Count == 0) + { + SingleNodes.Add(node); + } + else + { + var tmpNodes = new List(); + bool isLinear = true; + if (node.Connections.Count == 1) + { + tmpNodes.Add(node); + Node tmp = node.Connections[0]; + tmpNodes.Add(tmp); + while (isLinear) + { + if (tmp.Connections.Count == 1) + { + LinearNodeLists.Add(tmpNodes); + foreach (Node linearNode in tmpNodes) + ConnectedNodes.Remove(linearNode); + + AllLinearNodes.AddRange(tmpNodes); + break; + } + else if (tmp.Connections.Count == 2) + { + if (tmp.Connections[0] != tmp) + tmp = tmp.Connections[0]; + else if (tmp.Connections[1] != tmp) + tmp = tmp.Connections[1]; + + if (tmpNodes.Contains(tmp)) + { + isLinear = false; + } + else + { + tmpNodes.Add(tmp); + } + } + else + { + isLinear = false; + } + } + } + else + { + isLinear = false; + } + + if (isLinear) {} + else + { + ConnectedNodes.Add(node); + } + } + } + + + int x = 0; + int y = 0; + foreach (Node node in SingleNodes) + { + if (x == 10) + { + x = 0; + y++; + } + + node.Bounds.X = x*30; + node.Bounds.Y = y*30; + node.Bounds.Height = 20; + x++; + } + + if (SingleNodes.Count > 0) + y++; + + x = 0; + int yl = 0; + int maxY = 0; + foreach (var linearNodes in LinearNodeLists) + { + yl = y; + foreach (Node node in linearNodes) + { + node.Bounds.X = x*30; + node.Bounds.Y = (y*30) + yl*30; + yl += (int) node.Bounds.Height/20; + } + x++; + maxY = Math.Max(yl, maxY); + } + + //foreach (Node node in ConnectedNodes) + //{ + // node.Bounds.X = r.Next(0,400); + // node.Bounds.Y = r.Next(0,400); + //} + + + for (int i = 0; i < 3000; i++) + { + LayoutNodes(ConnectedNodes, 2); + } + + for (int i = 0; i < 1000; i++) + { + LayoutNodes(ConnectedNodes, 1); + } + + for (int i = 0; i < 1000; i++) + { + LayoutNodes(ConnectedNodes, 0); + } + + + float left = float.MaxValue; + float right = float.MinValue; + float top = float.MaxValue; + float bottom = float.MinValue; + + foreach (Node node in ConnectedNodes) + { + left = Math.Min(left, node.Bounds.Left); + right = Math.Max(right, node.Bounds.Right); + + top = Math.Min(top, node.Bounds.Top); + bottom = Math.Max(bottom, node.Bounds.Bottom); + } + + foreach (Node node in ConnectedNodes) + { + node.Bounds.Offset(-left + 50, -top + 10); + } + + //foreach (Node node in ConnectedNodes) + //{ + // int xp = (int)node.Bounds.X / 20; + // int yp = (int)node.Bounds.Y / 20; + + // node.Bounds.X = xp * 20; + // node.Bounds.Y = yp * 20; + + //} + } + + private static void LayoutNodes(List ConnectedNodes, float massFactor) + { + foreach (Node node in ConnectedNodes) + { + PointF force = node.GetForceDirection(ConnectedNodes, massFactor); + node.Bounds.X += force.X; + node.Bounds.Y += force.Y; + } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Layout/Node.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Layout/Node.cs new file mode 100644 index 0000000..f644590 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Layout/Node.cs @@ -0,0 +1,190 @@ +using System; +using System.Collections.Generic; +using System.Drawing; + +namespace AlbinoHorse.Layout +{ + public class Node + { + public RectangleF Bounds; + + #region Property Connections + + private List connections; + + public List Connections + { + get { return connections; } + set { connections = value; } + } + + #endregion + + public Node() + { + Connections = new List(); + } + + public PointF GetRepellingForce(PointF delta, float mass) + { + var force = new PointF(); + double dx = delta.X; + double dy = delta.Y; + + double dist = GetDistance(dx, dy); + double angle = Math.Atan2(dy, dx); + + angle += Math.PI; + + + dist++; + double power = 0; + power = (1/dist)*10*mass; + + + if (power < 0.05) + power = 0; + + if (power > 10) + power = 10; + + + force.X = (float) (Math.Cos(angle)*power); + force.Y = (float) (Math.Sin(angle)*power); + + return force; + } + + private static double GetDistance(double dx, double dy) + { + double dist = Math.Sqrt(dx*dx + dy*dy); + return dist; + } + + public PointF GetPullingForce(PointF delta) + { + var force = new PointF(); + double dx = delta.X; + double dy = delta.Y; + + double dist = GetDistance(dx, dy); + double angle = Math.Atan2(dy, dx); + + double power = (dist*dist)/1000; + if (power > 60) + power = 60; + + + force.X = (float) (Math.Cos(angle)*power); + force.Y = (float) (Math.Sin(angle)*power); + + return force; + } + + //public PointF GetLinearPullingForce(PointF target) + //{ + // PointF force = new PointF(); + // double dx = target.X - Bounds.X; + // double dy = target.Y - Bounds.Y; + + // double dist = GetDistance(dx, dy); + // double angle = Math.Atan2(dy, dx); + + // double power = 1; + + // force.X = (float)(Math.Cos(angle) * power); + // force.Y = (float)(Math.Sin(angle) * power); + + // return force; + //} + + public PointF GetForceDirection(List allNodes, float massFactor) + { + var force = new PointF(); + foreach (Node node in allNodes) + { + if (node == this) + continue; + + PointF delta = GetDelta(Bounds, node.Bounds); + double dist = GetDistance(delta.X, delta.Y); + + if (dist > 200) + continue; + + PointF nodeForce = GetRepellingForce(delta, + 1 + + ((1 + (node.Bounds.Width*node.Bounds.Height)/1000)* + node.connections.Count*massFactor)); + + force.X += nodeForce.X; + force.Y += nodeForce.Y; + } + + foreach (Node node in Connections) + { + if (node == this) + continue; + + PointF delta = GetDelta(Bounds, node.Bounds); + PointF nodeForce = GetPullingForce(delta); + + force.X += nodeForce.X; + force.Y += nodeForce.Y; + } + + //PointF delta2 = GetDelta(Bounds, new RectangleF (200,200,1,1)); + //PointF center = GetPullingForce(delta2); + //force.X += center.X; + //force.Y += center.Y; + + //PointF tl = GetRepellingForce(new PointF(0, 0)); + + //force.X += tl.X; + //force.Y += tl.Y; + + //PointF tr = GetRepellingForce(new PointF(400, 0)); + + //force.X += tr.X; + //force.Y += tr.Y; + + //PointF bl = GetRepellingForce(new PointF(0, 400)); + + //force.X += bl.X; + //force.Y += bl.Y; + + //PointF br = GetRepellingForce(new PointF(400, 400)); + + //force.X += br.X; + //force.Y += br.Y; + + return force; + } + + private PointF GetDelta(RectangleF bounds1, RectangleF bounds2) + { + float dx = 0; + float dy = 0; + + // return new PointF(bounds2.X - bounds1.X, bounds2.Y - bounds1.Y); + + if (bounds2.IntersectsWith(bounds1)) + return new PointF(4, 1); + + if (bounds2.Right < bounds1.Left) + dx = bounds2.Right - bounds1.Left; + + if (bounds2.Left > bounds1.Right) + dx = bounds2.Left - bounds1.Right; + + if (bounds2.Bottom < bounds1.Top) + dy = bounds2.Bottom - bounds1.Top; + + if (bounds2.Top > bounds1.Bottom) + dy = bounds2.Top - bounds1.Bottom; + + + return new PointF(dx, dy); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlClassData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlClassData.cs new file mode 100644 index 0000000..28b5cc3 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlClassData.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace AlbinoHorse.Model +{ + public class DefaultUmlClassData : DefaultUmlInstanceTypeData, IUmlInstanceTypeData + { + public string InheritsTypeName { get; set; } + public bool IsAbstract { get; set; } + + public IList GetImplementedInterfaces() + { + return new List(); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlDiagramData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlDiagramData.cs new file mode 100644 index 0000000..6a0ce27 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlDiagramData.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; + +namespace AlbinoHorse.Model +{ + public class DefaultUmlDiagramData : IUmlDiagramData + { + public DefaultUmlDiagramData() + { + Shapes = new List(); + } + + public List Shapes { get; set; } + + #region IUmlDiagramData Members + + public T CreateShape() where T : Shape, new() + { + var shape = new T(); + Shapes.Add(shape); + return shape; + } + + public void RemoveShape(Shape item) + { + Shapes.Remove(item); + } + + public IList GetShapes() + { + return Shapes; + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlTypeData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlTypeData.cs new file mode 100644 index 0000000..3219edc --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlTypeData.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; + +namespace AlbinoHorse.Model +{ + public class DefaultUmlInstanceTypeData : IUmlInstanceTypeData + { + private readonly List members = new List(); + + #region IUmlInstanceTypeData Members + + public int X { get; set; } + public int Y { get; set; } + public int Width { get; set; } + public bool Expanded { get; set; } + public string TypeName { get; set; } + + public void RemoveTypeMember(UmlTypeMember property) + { + members.Remove(property); + } + + public IList GetTypeMembers() + { + return members; + } + + public UmlTypeMember CreateTypeMember(string sectionName) + { + var member = new UmlTypeMember(); + var data = new DefaultUmlTypeMemberData(); + data.SectionName = sectionName; + member.DataSource = data; + members.Add(member); + return member; + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlTypeMemberData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlTypeMemberData.cs new file mode 100644 index 0000000..6277775 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/DefaultUmlTypeMemberData.cs @@ -0,0 +1,25 @@ +using System.Drawing; +using Alsing.AlbinoHorse.Properties; + +namespace AlbinoHorse.Model +{ + public class DefaultUmlTypeMemberData : IUmlTypeMemberData + { + #region IUmlTypeMemberData Members + + public string Name { get; set; } + public string SectionName { get; set; } + + public object DataObject + { + get { return null; } + } + + public Image GetImage() + { + return Resources.Property; + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlClassData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlClassData.cs new file mode 100644 index 0000000..7080b30 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlClassData.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace AlbinoHorse.Model +{ + public interface IUmlClassData : IUmlInstanceTypeData + { + string InheritsTypeName { get; set; } + bool IsAbstract { get; set; } + IList GetImplementedInterfaces(); + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlCommentData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlCommentData.cs new file mode 100644 index 0000000..5364b59 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlCommentData.cs @@ -0,0 +1,11 @@ +namespace AlbinoHorse.Model +{ + public interface IUmlCommentData + { + int X { get; set; } + int Y { get; set; } + int Width { get; set; } + int Height { get; set; } + string Text { get; set; } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlDiagramData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlDiagramData.cs new file mode 100644 index 0000000..5f97bfc --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlDiagramData.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace AlbinoHorse.Model +{ + public interface IUmlDiagramData + { + T CreateShape() where T : Shape, new(); + void RemoveShape(Shape item); + IList GetShapes(); + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlEnumData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlEnumData.cs new file mode 100644 index 0000000..6f2ce7e --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlEnumData.cs @@ -0,0 +1,4 @@ +namespace AlbinoHorse.Model +{ + public interface IUmlEnumData : IUmlInstanceTypeData {} +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlInstanceTypeData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlInstanceTypeData.cs new file mode 100644 index 0000000..fd8ca57 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlInstanceTypeData.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace AlbinoHorse.Model +{ + public interface IUmlInstanceTypeData : IUmlTypeData + { + UmlTypeMember CreateTypeMember(string sectionName); + void RemoveTypeMember(UmlTypeMember member); + IList GetTypeMembers(); + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlInterfaceData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlInterfaceData.cs new file mode 100644 index 0000000..6876e90 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlInterfaceData.cs @@ -0,0 +1,4 @@ +namespace AlbinoHorse.Model +{ + public interface IUmlInterfaceData : IUmlInstanceTypeData {} +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlPropertyData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlPropertyData.cs new file mode 100644 index 0000000..afd37ff --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlPropertyData.cs @@ -0,0 +1,12 @@ +using System.Drawing; + +namespace AlbinoHorse.Model +{ + public interface IUmlTypeMemberData + { + string Name { get; set; } + string SectionName { get; } + object DataObject { get; } + Image GetImage(); + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlRelationData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlRelationData.cs new file mode 100644 index 0000000..1c64a6c --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlRelationData.cs @@ -0,0 +1,30 @@ +namespace AlbinoHorse.Model +{ + public enum UmlPortSide + { + Top, + Right, + Bottom, + Left, + } + + public enum UmlRelationType + { + None, + Association, + Aggregation, + Inheritance, + } + + public interface IUmlRelationData + { + Shape Start { get; } + int StartPortOffset { get; set; } + UmlPortSide StartPortSide { get; set; } + UmlRelationType AssociationType { get; } + + Shape End { get; } + int EndPortOffset { get; set; } + UmlPortSide EndPortSide { get; set; } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlRenderer.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlRenderer.cs new file mode 100644 index 0000000..f5d9902 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlRenderer.cs @@ -0,0 +1,7 @@ +namespace AlbinoHorse.Model +{ + public interface IUmlRenderer + { + void DrawInstanceType(UmlInstanceType item); + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlTypeData.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlTypeData.cs new file mode 100644 index 0000000..4e9f7dd --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Interfaces/IUmlTypeData.cs @@ -0,0 +1,11 @@ +namespace AlbinoHorse.Model +{ + public interface IUmlTypeData + { + string TypeName { get; set; } + int X { get; set; } + int Y { get; set; } + int Width { get; set; } + bool Expanded { get; set; } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Shape.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Shape.cs new file mode 100644 index 0000000..6f04bbc --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/Shape.cs @@ -0,0 +1,58 @@ +using System.Drawing; +using AlbinoHorse.Infrastructure; + +namespace AlbinoHorse.Model +{ + public abstract class Shape + { + #region Property Bounds + + public virtual Rectangle Bounds { get; set; } + + #endregion + + #region Property Selected + + public virtual bool Selected { get; set; } + + #endregion + + public virtual void Draw(RenderInfo info) {} + public virtual void DrawBackground(RenderInfo info) {} + public virtual void DrawPreview(RenderInfo info) {} + public virtual void PreviewDrawBackground(RenderInfo info) {} + + + public virtual void OnMouseDown(ShapeMouseEventArgs args) {} + + public virtual void OnMouseUp(ShapeMouseEventArgs args) {} + + public virtual void OnMouseMove(ShapeMouseEventArgs args) {} + + public virtual void OnClick(ShapeMouseEventArgs args) {} + + public virtual void OnDoubleClick(ShapeMouseEventArgs args) {} + + public virtual void OnKeyPress(ShapeKeyEventArgs args) {} + + protected void DrawSelectionHandle(RenderInfo info, Point point, object identifier) + { + DrawSelectionHandle(info, point); + + var bounds = new Rectangle(point.X - 4, point.Y - 4, 8, 8); + var bBox = new BoundingBox(); + bBox.Bounds = bounds; + bBox.Data = identifier; + bBox.Target = this; + info.BoundingItems.Add(bBox); + } + + protected void DrawSelectionHandle(RenderInfo info, Point point) + { + var bounds = new Rectangle(point.X - 4, point.Y - 4, 8, 8); + info.Graphics.FillRectangle(Brushes.Gray, bounds); + bounds.Inflate(-1, -1); + info.Graphics.FillRectangle(Brushes.White, bounds); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlDiagram.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlDiagram.cs new file mode 100644 index 0000000..7aa4ff6 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlDiagram.cs @@ -0,0 +1,86 @@ +using System.Collections.Generic; +using System.Drawing; +using AlbinoHorse.Infrastructure; + +namespace AlbinoHorse.Model +{ + public class UmlDiagram + { + public UmlDiagram() + { + DataSource = new DefaultUmlDiagramData(); + } + + #region Property Shapes + + public IList Shapes + { + get { return DataSource.GetShapes(); } + } + + #endregion + + public IUmlDiagramData DataSource { get; set; } + + public virtual void Draw(RenderInfo info) + { + if (!info.Preview && info.ShowGrid) + { + int xo = info.VisualBounds.X%info.GridSize; + int yo = info.VisualBounds.Y%info.GridSize; + + for (int y = info.VisualBounds.Y - yo; + y < (info.VisualBounds.Bottom + info.GridSize)/info.Zoom; + y += info.GridSize) + { + for (int x = info.VisualBounds.X - xo; + x < (info.VisualBounds.Right + info.GridSize)/info.Zoom; + x += info.GridSize) + { + info.Graphics.FillRectangle(Brushes.Gray, x, y, 1, 1); + } + } + } + + int maxWidth = int.MinValue; + int maxHeight = int.MinValue; + int minWidth = int.MaxValue; + int minHeight = int.MaxValue; + + foreach (Shape shape in Shapes) + { + if (info.Preview) + shape.PreviewDrawBackground(info); + else + shape.DrawBackground(info); + } + + foreach (Shape shape in Shapes) + { + if (info.Preview) + shape.DrawPreview(info); + else + shape.Draw(info); + + + if (shape.Bounds.Left*info.Zoom < minWidth) + minWidth = (int) (shape.Bounds.Left*info.Zoom); + + if (shape.Bounds.Top*info.Zoom < minHeight) + minHeight = (int) (shape.Bounds.Top*info.Zoom); + + if (shape.Bounds.Right*info.Zoom > maxWidth) + maxWidth = (int) (shape.Bounds.Right*info.Zoom); + + if (shape.Bounds.Bottom*info.Zoom > maxHeight) + maxHeight = (int) (shape.Bounds.Bottom*info.Zoom); + } + + maxWidth += (int) (info.GridSize*info.Zoom); + maxHeight += (int) (info.GridSize*info.Zoom); + + info.ReturnedBounds = new Rectangle(new Point(minWidth, minHeight), + new Size(maxWidth - minWidth, maxHeight - minHeight)); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypeGfxSettings.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypeGfxSettings.cs new file mode 100644 index 0000000..73dae32 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypeGfxSettings.cs @@ -0,0 +1,83 @@ +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace AlbinoHorse.Model.Settings +{ + public static class Margins + { + public const int TypeBoxSideMargin = 10; + public const int TypeMemberNameIndent = 30; + public const int RelationPortMargin = 15; + public const int RelationArrowSize = 5; + } + + public static class Brushes + { + public static SolidBrush ClassSectionCaption = new SolidBrush(Color.FromArgb(240, 242, 249)); + public static SolidBrush EnumSectionCaption = new SolidBrush(Color.FromArgb(237, 233, 246)); + public static SolidBrush InterfaceSectionCaption = new SolidBrush(Color.FromArgb(243, 247, 240)); + public static SolidBrush SelectedTypeMember = new SolidBrush(SystemColors.Highlight); + public static HatchBrush Selection = new HatchBrush(HatchStyle.Percent50, Color.Black, Color.WhiteSmoke); + public static SolidBrush Shadow = new SolidBrush(Color.LightGray); + } + + public static class Fonts + { + private const string fontName = "Tahoma"; + public static Font AbstractTypeName = new Font(fontName, 8f, FontStyle.Bold | FontStyle.Italic); + public static Font ClassTypeMember = new Font(fontName, 8f, FontStyle.Regular); + + public static Font CommentText = new Font(fontName, 8f, FontStyle.Regular); + public static Font DefaultTypeName = new Font(fontName, 8f, FontStyle.Bold); + public static Font ImplementedInterfaces = new Font(fontName, 8f, FontStyle.Regular); + public static Font InheritsTypeName = new Font(fontName, 7f, FontStyle.Regular); + public static Font InterfaceTypeMember = new Font(fontName, 8f, FontStyle.Italic); + public static Font NewTypeMember = new Font(fontName, 8f, FontStyle.Underline); + public static Font SectionCaption = new Font(fontName, 8f, FontStyle.Regular); + public static Font TypeKind = new Font(fontName, 7f, FontStyle.Regular); + } + + + public static class Pens + { + public static Pen AbstractBorder = MakeAbstractBorderPen(); + public static Pen AssociationBorder = MakeAssociationBorder(); + public static Pen AssociationLine = MakeAssociationLine(); + public static Pen CommentBorder = new Pen(Color.Gold, 1f); + public static Pen DefaultBorder = new Pen(Color.FromArgb(130, 130, 130), 1f); + public static Pen FakeLine = new Pen(Color.FromArgb(130, 130, 130), 1.6f); + public static Pen InheritanceLine = new Pen(Color.FromArgb(130, 130, 130), 1.6f); + public static Pen Lolipop = new Pen(Color.FromArgb(130, 130, 130), 1.6f); + public static Pen Selection = new Pen(Brushes.Selection, 9); + public static Pen SelectionOuter = MakeSelectonPen(); + + private static Pen MakeAssociationLine() + { + var pen = new Pen(Color.Goldenrod, 1.6f) {StartCap = LineCap.Round, EndCap = LineCap.Round}; + return pen; + } + + private static Pen MakeAssociationBorder() + { + var pen = new Pen(Color.White, 6f) {StartCap = LineCap.Round, EndCap = LineCap.Round}; + return pen; + } + + + private static Pen MakeSelectonPen() + { + var pen = new Pen(Color.Gray, 1) {DashStyle = DashStyle.Dash}; + return pen; + } + + private static Pen MakeAbstractBorderPen() + { + var pen = new Pen(Color.FromArgb(130, 130, 130), 1.3f) + { + DashStyle = DashStyle.Dash, + Alignment = PenAlignment.Center + }; + return pen; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypeMembers/UmlTypeMember.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypeMembers/UmlTypeMember.cs new file mode 100644 index 0000000..9c15994 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypeMembers/UmlTypeMember.cs @@ -0,0 +1,19 @@ +namespace AlbinoHorse.Model +{ + public class UmlTypeMember + { + public IUmlTypeMemberData DataSource { get; set; } + + public string Name + { + get { return DataSource.Name; } + + set { DataSource.Name = value; } + } + + public string SectionName + { + get { return DataSource.SectionName; } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypeMembers/UmlTypeMemberSection.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypeMembers/UmlTypeMemberSection.cs new file mode 100644 index 0000000..0c1a023 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypeMembers/UmlTypeMemberSection.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; + +namespace AlbinoHorse.Model +{ + public class UmlTypeMemberSection + { + public readonly object AddNewIdentifier = new object(); + public readonly object CaptionIdentifier = new object(); + public readonly object ExpanderIdentifier = new object(); + + public UmlTypeMemberSection(UmlInstanceType owner) + { + Expanded = true; + Owner = owner; + } + + public UmlTypeMemberSection(UmlInstanceType owner, string caption) : this(owner) + { + Name = caption; + } + + public UmlInstanceType Owner { get; set; } + public string Name { get; set; } + public bool Expanded { get; set; } + + + public IList TypeMembers + { + get + { + var members = new List(); + foreach (UmlTypeMember member in Owner.TypeMembers) + { + if (member.SectionName == Name) + members.Add(member); + } + + return members; + } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlClass.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlClass.cs new file mode 100644 index 0000000..790a21f --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlClass.cs @@ -0,0 +1,120 @@ +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using AlbinoHorse.Infrastructure; +using AlbinoHorse.Model.Settings; +using Alsing.AlbinoHorse.Properties; +using Brushes=System.Drawing.Brushes; +using Pens=AlbinoHorse.Model.Settings.Pens; + +namespace AlbinoHorse.Model +{ + public class UmlClass : UmlInstanceType + { + #region TypedDataSource property + + private IUmlClassData TypedDataSource + { + get { return DataSource as IUmlClassData; } + } + + #endregion + + #region IsAbstract property + + public bool IsAbstract + { + get { return TypedDataSource.IsAbstract; } + set { TypedDataSource.IsAbstract = value; } + } + + #endregion + + #region InheritsTypeName property + + public string InheritsTypeName + { + get { return TypedDataSource.InheritsTypeName; } + set { TypedDataSource.InheritsTypeName = value; } + } + + #endregion + + protected override IList GetTypeMemberSections() + { + return new List + {new UmlTypeMemberSection(this, "Properties"), new UmlTypeMemberSection(this, "Methods")}; + } + + protected override Brush GetCaptionBrush(Rectangle renderBounds) + { + if (Selected) + return new LinearGradientBrush(renderBounds, Color.FromArgb(190, 202, 230), Color.White, 0, true); + else + return new LinearGradientBrush(renderBounds, Color.FromArgb(210, 222, 240), Color.White, 0, true); + } + + protected override string GetTypeKind() + { + if (IsAbstract) + return "Abstract class"; + else + return "Class"; + } + + protected override Font GetTypeNameFont() + { + if (IsAbstract) + return Fonts.AbstractTypeName; + else + return Fonts.DefaultTypeName; + } + + protected override Pen GetBorderPen() + { + if (IsAbstract) + return Pens.AbstractBorder; + else + return Pens.DefaultBorder; + } + + + protected override void DrawCustomCaptionInfo(RenderInfo info, int x, int y, int width) + { + if (InheritsTypeName != null) + { + info.Graphics.DrawImage(Resources.InheritanceArrow, x + Margins.TypeBoxSideMargin, y + 35); + var typeInheritsBounds = new Rectangle(x + 24, y + 33, width - 26, 10); + info.Graphics.DrawString(InheritsTypeName, Fonts.InheritsTypeName, Brushes.Black, typeInheritsBounds, + StringFormat.GenericTypographic); + } + + IList implementedInterfaces = TypedDataSource.GetImplementedInterfaces(); + if (implementedInterfaces.Count > 0) + { + int offsetX = 20; + int offsetY = 20 + (16*(implementedInterfaces.Count - 1)); + info.Graphics.DrawEllipse(Pens.Lolipop, x + offsetX, y - offsetY, 12, 12); + info.Graphics.DrawLine(Pens.Lolipop, x + offsetX + 6, y - offsetY + 12, x + offsetX + 6, y); + + int yy = y - offsetY; + foreach (string interfaceName in implementedInterfaces) + { + info.Graphics.DrawString(interfaceName, Fonts.ImplementedInterfaces, Brushes.Black, x + offsetX + 16, + yy); + yy += 16; + } + } + } + + protected override Brush GetSectionCaptionBrush() + { + return Settings.Brushes.ClassSectionCaption; + } + + protected override Font GetTypeMemberFont() + { + return Fonts.ClassTypeMember; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlComment.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlComment.cs new file mode 100644 index 0000000..f762f5d --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlComment.cs @@ -0,0 +1,238 @@ +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; +using AlbinoHorse.Infrastructure; +using AlbinoHorse.Model.Settings; +using AlbinoHorse.Windows.Forms; +using Brushes=System.Drawing.Brushes; +using Pens=AlbinoHorse.Model.Settings.Pens; + +namespace AlbinoHorse.Model +{ + public class UmlComment : UmlShape + { + #region Properties + + #region DataSource property + + public IUmlCommentData DataSource { get; set; } + + #endregion + + #region Bounds property + + public override Rectangle Bounds + { + get { return new Rectangle(DataSource.X, DataSource.Y, DataSource.Width, DataSource.Height); } + set + { + DataSource.X = value.X; + DataSource.Y = value.Y; + DataSource.Width = value.Width; + DataSource.Height = value.Height; + + base.Bounds = value; + } + } + + #endregion + + #region Text property + + public string Text + { + get { return DataSource.Text; } + set { DataSource.Text = value; } + } + + #endregion + + #endregion + + #region Identifiers + + //bounding box identifiers + protected readonly object TextIdentifier = new object(); + + #endregion + + public override void Draw(RenderInfo info) + { + int grid = info.GridSize; + Rectangle renderBounds = Bounds; + + var bboxThis = new BoundingBox(); + bboxThis.Bounds = renderBounds; + bboxThis.Target = this; + bboxThis.Data = BodyIdentifier; + info.BoundingItems.Add(bboxThis); + + int x = renderBounds.X; + int y = renderBounds.Y; + int width = renderBounds.Width; + int height = renderBounds.Height; + + GraphicsPath path = GetOutlinePath(x, y, width, height); + Pen borderPen = GetBorderPen(); + + info.Graphics.FillPath(SystemBrushes.Info, path); + info.Graphics.DrawPath(borderPen, path); + + renderBounds = DrawText(info, renderBounds); + + DrawSelection(info); + } + + protected virtual Rectangle DrawText(RenderInfo info, Rectangle renderBounds) + { + Rectangle textBounds = renderBounds; + textBounds.Inflate(-10, -10); + + var bboxText = new BoundingBox(); + bboxText.Bounds = textBounds; + bboxText.Target = this; + bboxText.Data = TextIdentifier; + info.BoundingItems.Add(bboxText); + + + var textBoundsF = new RectangleF(textBounds.X, textBounds.Y, textBounds.Width, textBounds.Height); + + //info.Graphics.FillRectangle(Brushes.White, textBounds); + info.Graphics.DrawString(Text, Fonts.CommentText, Brushes.Black, textBoundsF, + StringFormat.GenericTypographic); + return renderBounds; + } + + public override void DrawBackground(RenderInfo info) {} + + protected override void DrawCustomSelection(RenderInfo info) + { + Rectangle renderBounds = Bounds; + + Rectangle textBounds = renderBounds; + textBounds.Inflate(-10, -10); + + info.Graphics.DrawRectangle(Pens.SelectionOuter, textBounds); + } + + protected override int GetRadius() + { + return 5; + } + + protected override Pen GetBorderPen() + { + return Pens.CommentBorder; + } + + #region Mouse Events + + public override void OnMouseDown(ShapeMouseEventArgs args) + { + args.Sender.ClearSelection(); + Selected = true; + + if (args.BoundingItem.Data == RightResizeIdentifier) + { + mouseDownPos = new Point(args.X, args.Y); + SelectedObject = null; + args.Redraw = true; + } + else if (args.BoundingItem.Data == LeftResizeIdentifier) + { + mouseDownPos = new Point(args.X, args.Y); + SelectedObject = null; + args.Redraw = true; + } + else + { + mouseDownPos = new Point(args.X, args.Y); + mouseDownShapePos = Bounds.Location; + SelectedObject = null; + + args.Redraw = true; + } + } + + public override void OnMouseUp(ShapeMouseEventArgs args) + { + args.Redraw = true; + } + + public override void OnMouseMove(ShapeMouseEventArgs args) + { + if (args.BoundingItem.Data == RightResizeIdentifier && args.Button == MouseButtons.Left) + { + int diff = args.X - Bounds.Left; + if (diff < 100) + diff = 100; + + Bounds = new Rectangle(Bounds.X, Bounds.Y, diff, Bounds.Height); + args.Redraw = true; + } + + if (args.BoundingItem.Data == LeftResizeIdentifier && args.Button == MouseButtons.Left) + { + int diff = Bounds.Right - args.X; + if (diff < 100) + diff = 100; + + if (diff + args.X > Bounds.Right) + { + Bounds = new Rectangle(Bounds.Right - 100, Bounds.Y, 100, Bounds.Height); + args.Redraw = true; + } + else + { + Bounds = new Rectangle(args.X, Bounds.Y, diff, Bounds.Height); + args.Redraw = true; + } + } + + if ((args.BoundingItem.Data == BodyIdentifier || args.BoundingItem.Data == TextIdentifier) && + args.Button == MouseButtons.Left) + { + int dx = args.X - mouseDownPos.X; + int dy = args.Y - mouseDownPos.Y; + + int shapeX = mouseDownShapePos.X + dx; + int shapeY = mouseDownShapePos.Y + dy; + + //if (args.SnapToGrid) + //{ + // shapeX = shapeX - shapeX % args.GridSize; + // shapeY = shapeY - shapeY % args.GridSize; + //} + + if (shapeX < 0) + shapeX = 0; + + if (shapeY < 0) + shapeY = 0; + + Bounds = new Rectangle(shapeX, shapeY, Bounds.Width, Bounds.Height); + args.Redraw = true; + } + } + + public override void OnDoubleClick(ShapeMouseEventArgs args) + { + if (args.BoundingItem.Data == TextIdentifier) + { + BeginEditText(args.Sender); + } + } + + private void BeginEditText(UmlDesigner owner) + { + Rectangle inputBounds = Bounds; + inputBounds.Inflate(-10, -10); + + Action endEditText = () => { DataSource.Text = owner.GetInput(); }; + + owner.BeginInputMultiLine(inputBounds, DataSource.Text, Fonts.CommentText, endEditText); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlEnum.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlEnum.cs new file mode 100644 index 0000000..a495bcc --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlEnum.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using AlbinoHorse.Model.Settings; +using Brushes=AlbinoHorse.Model.Settings.Brushes; +using Pens=AlbinoHorse.Model.Settings.Pens; + +namespace AlbinoHorse.Model +{ + public class UmlEnum : UmlInstanceType + { + #region TypedDataSource property + + private IUmlClassData TypedDataSource + { + get { return DataSource as IUmlClassData; } + } + + #endregion + + protected override IList GetTypeMemberSections() + { + return new List {new UmlTypeMemberSection(this, "Values")}; + } + + protected override Brush GetCaptionBrush(Rectangle renderBounds) + { + if (Selected) + return new LinearGradientBrush(renderBounds, Color.FromArgb(211, 204, 229), Color.White, 0, true); + else + return new LinearGradientBrush(renderBounds, Color.FromArgb(221, 214, 239), Color.White, 0, true); + } + + protected override Brush GetSectionCaptionBrush() + { + return Brushes.EnumSectionCaption; + } + + protected override string GetTypeKind() + { + return "Enum"; + } + + protected override Font GetTypeNameFont() + { + return Fonts.DefaultTypeName; + } + + protected override Pen GetBorderPen() + { + return Pens.DefaultBorder; + } + + protected override int GetRadius() + { + return 1; + } + + protected override Font GetTypeMemberFont() + { + return Fonts.ClassTypeMember; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlInstanceType.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlInstanceType.cs new file mode 100644 index 0000000..160c749 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlInstanceType.cs @@ -0,0 +1,453 @@ +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; +using AlbinoHorse.Infrastructure; +using AlbinoHorse.Model.Settings; +using AlbinoHorse.Windows.Forms; +using Alsing.AlbinoHorse.Properties; +using Brushes=System.Drawing.Brushes; + +namespace AlbinoHorse.Model +{ + public abstract class UmlInstanceType : UmlType + { + #region Properties (+ fields) + + public IList TypeMemberSections { get; set; } + + #region Bounds property + + public override Rectangle Bounds + { + get + { + if (Expanded) + { + int sectionsHeight = 0; + foreach (UmlTypeMemberSection section in TypeMemberSections) + { + int sectionHeight = section.Expanded ? (section.TypeMembers.Count + 1)*16 + 20 : 20; + sectionsHeight += sectionHeight; + } + return new Rectangle(DataSource.X, DataSource.Y, DataSource.Width, 55 + sectionsHeight); + } + else + { + return new Rectangle(DataSource.X, DataSource.Y, DataSource.Width, 63 - 3); + } + } + set + { + DataSource.X = value.X; + DataSource.Y = value.Y; + DataSource.Width = value.Width; + + base.Bounds = value; + } + } + + #endregion + + #region TypeMembers property + + public IList TypeMembers + { + get { return TypedDataSource.GetTypeMembers(); } + } + + #endregion + + #region TypedDataSource property + + private IUmlInstanceTypeData TypedDataSource + { + get { return DataSource as IUmlInstanceTypeData; } + } + + #endregion + + #endregion + + #region Identifiers + + //bounding box identifiers + protected readonly object AddNewPropertyIdentifier = new object(); + protected readonly object PropertiesIdentifier = new object(); + + #endregion + + #region Ctor + + public UmlInstanceType() + { + TypeMemberSections = GetTypeMemberSections(); + + DataSource = new DefaultUmlInstanceTypeData(); + } + + #endregion + + #region Draw + + public override void Draw(RenderInfo info) + { + base.Draw(info); + } + + + protected override int DrawExpandedBody(RenderInfo info, int x, int width, int currentY) + { + foreach (UmlTypeMemberSection section in TypeMemberSections) + { + currentY = DrawTypeMembers(info, x, currentY, width, section); + } + return currentY; + } + + private int DrawTypeMembers(RenderInfo info, int x, int y, int width, UmlTypeMemberSection section) + { + var memberCaptionBounds = new Rectangle(x, y, width, 20); + + #region add section header bbox + + var bboxGroup = new BoundingBox(); + bboxGroup.Bounds = memberCaptionBounds; + bboxGroup.Target = this; + bboxGroup.Data = section.CaptionIdentifier; + info.BoundingItems.Add(bboxGroup); + + #endregion + + if (SelectedObject == section.CaptionIdentifier && Selected) + { + info.Graphics.FillRectangle(SystemBrushes.Highlight, memberCaptionBounds); + memberCaptionBounds.X += 20; + memberCaptionBounds.Width -= 30; + memberCaptionBounds.Y += 3; + info.Graphics.DrawString(section.Name, Fonts.SectionCaption, SystemBrushes.HighlightText, + memberCaptionBounds); + } + else + { + Brush sectionCaptionBrush = GetSectionCaptionBrush(); + info.Graphics.FillRectangle(sectionCaptionBrush, memberCaptionBounds); + + memberCaptionBounds.X += 20; + memberCaptionBounds.Width -= 30; + memberCaptionBounds.Y += 3; + info.Graphics.DrawString(section.Name, Fonts.SectionCaption, Brushes.Black, memberCaptionBounds); + } + + #region add section expander bbox + + var bboxGroupExpander = new BoundingBox(); + bboxGroupExpander.Bounds = new Rectangle(x + 4, y + 4, 13, 13); + bboxGroupExpander.Target = this; + bboxGroupExpander.Data = section.ExpanderIdentifier; + info.BoundingItems.Add(bboxGroupExpander); + + #endregion + + if (section.Expanded) + info.Graphics.DrawImage(Resources.CollapseSection, x + 3, y + 3); + else + info.Graphics.DrawImage(Resources.ExpandSection, x + 3, y + 3); + + + int currentY = y + 20; + if (section.Expanded) + { + StringFormat sf = StringFormat.GenericTypographic; + sf.Trimming = StringTrimming.EllipsisCharacter; + foreach (UmlTypeMember member in section.TypeMembers) + { + var memberBounds = new Rectangle(x + Margins.TypeBoxSideMargin, currentY, width - 20, 16); + + #region add property bbox + + var memberBBox = new BoundingBox(); + memberBBox.Target = this; + memberBBox.Bounds = memberBounds; + memberBBox.Data = member; + info.BoundingItems.Add(memberBBox); + + #endregion + + var layoutBounds = new Rectangle(x + Margins.TypeBoxSideMargin + Margins.TypeMemberNameIndent, + currentY, width - 5 - Margins.TypeMemberNameIndent, 16); + + Font font = GetTypeMemberFont(); + if (member == SelectedObject && Selected) + { + var selectionBounds = new Rectangle(x, currentY, width, 16); + info.Graphics.FillRectangle(SystemBrushes.Highlight, selectionBounds); + info.Graphics.DrawString(member.DataSource.Name, font, SystemBrushes.HighlightText, layoutBounds, + sf); + } + else + { + info.Graphics.DrawString(member.DataSource.Name, font, Brushes.Black, layoutBounds, sf); + } + info.Graphics.DrawImage(member.DataSource.GetImage(), x + 13, currentY); + currentY += 16; + } + + var newLayoutBounds = new Rectangle(x + Margins.TypeBoxSideMargin + Margins.TypeMemberNameIndent, + currentY, width - 5 - Margins.TypeMemberNameIndent, 16); + info.Graphics.DrawString("Add new", Fonts.NewTypeMember, Brushes.Blue, newLayoutBounds, sf); + + var newMemberBBox = new BoundingBox(); + newMemberBBox.Target = this; + newMemberBBox.Bounds = new Rectangle(x + Margins.TypeBoxSideMargin, currentY, width - 20, 16); + newMemberBBox.Data = section.AddNewIdentifier; + info.BoundingItems.Add(newMemberBBox); + + currentY += 16; + } + return currentY; + } + + protected abstract Font GetTypeMemberFont(); + protected abstract Brush GetSectionCaptionBrush(); + + #endregion + + #region Mouse Events + + public override void OnMouseDown(ShapeMouseEventArgs args) + { + args.Sender.ClearSelection(); + Selected = true; + + if (args.BoundingItem.Data == RightResizeIdentifier) + { + mouseDownPos = new Point(args.X, args.Y); + SelectedObject = null; + args.Redraw = true; + } + else if (args.BoundingItem.Data == LeftResizeIdentifier) + { + mouseDownPos = new Point(args.X, args.Y); + SelectedObject = null; + args.Redraw = true; + } + else if (args.BoundingItem.Data == PropertiesIdentifier) + { + SelectedObject = PropertiesIdentifier; + args.Redraw = true; + } + else if (args.BoundingItem.Data is UmlTypeMember) + { + SelectedObject = args.BoundingItem.Data as UmlTypeMember; + args.Redraw = true; + } + else if (args.BoundingItem.Data == CaptionIdentifier) + { + mouseDownPos = new Point(args.X, args.Y); + mouseDownShapePos = Bounds.Location; + SelectedObject = null; + + args.Redraw = true; + } + else + { + foreach (UmlTypeMemberSection section in TypeMemberSections) + { + if (args.BoundingItem.Data == section.CaptionIdentifier) + { + SelectedObject = section.CaptionIdentifier; + args.Redraw = true; + } + + if (args.BoundingItem.Data == section.ExpanderIdentifier) + { + SelectedObject = section.CaptionIdentifier; + section.Expanded = !section.Expanded; + args.Redraw = true; + } + } + } + } + + public override void OnMouseUp(ShapeMouseEventArgs args) + { + foreach (UmlTypeMemberSection section in TypeMemberSections) + { + if (args.BoundingItem.Data == section.AddNewIdentifier) + { + UmlTypeMember newMember = TypedDataSource.CreateTypeMember(section.Name); + SelectedObject = newMember; + BeginRenameProperty(args.Sender, newMember); + args.Redraw = true; + } + } + + //if (args.BoundingItem.Data == AddNewPropertyIdentifier) + //{ + // UmlTypeMember newProperty = TypedDataSource.CreateTypeMember("Property"); + // this.SelectedObject = newProperty; + + // BeginRenameProperty(args.Sender, newProperty); + + // args.Redraw = true; + //} + + if (args.BoundingItem.Data == TypeExpanderIdentifier) + { + Expanded = !Expanded; + } + args.Redraw = true; + } + + public override void OnMouseMove(ShapeMouseEventArgs args) + { + if (args.BoundingItem.Data == RightResizeIdentifier && args.Button == MouseButtons.Left) + { + int diff = args.X - Bounds.Left; + if (diff < 100) + diff = 100; + + Bounds = new Rectangle(Bounds.X, Bounds.Y, diff, Bounds.Height); + args.Redraw = true; + } + + if (args.BoundingItem.Data == LeftResizeIdentifier && args.Button == MouseButtons.Left) + { + int diff = Bounds.Right - args.X; + if (diff < 100) + diff = 100; + + if (diff + args.X > Bounds.Right) + { + Bounds = new Rectangle(Bounds.Right - 100, Bounds.Y, 100, Bounds.Height); + args.Redraw = true; + } + else + { + Bounds = new Rectangle(args.X, Bounds.Y, diff, Bounds.Height); + args.Redraw = true; + } + } + + if (args.BoundingItem.Data == CaptionIdentifier && args.Button == MouseButtons.Left) + { + int dx = args.X - mouseDownPos.X; + int dy = args.Y - mouseDownPos.Y; + + int shapeX = mouseDownShapePos.X + dx; + int shapeY = mouseDownShapePos.Y + dy; + + if (args.SnapToGrid) + { + shapeX = shapeX - shapeX%args.GridSize; + shapeY = shapeY - shapeY%args.GridSize; + } + + if (shapeX < 0) + shapeX = 0; + + if (shapeY < 0) + shapeY = 0; + + Bounds = new Rectangle(shapeX, shapeY, Bounds.Width, Bounds.Height); + args.Redraw = true; + } + } + + public override void OnDoubleClick(ShapeMouseEventArgs args) + { + foreach (UmlTypeMemberSection section in TypeMemberSections) + { + if (args.BoundingItem.Data == section.CaptionIdentifier) + { + section.Expanded = !section.Expanded; + args.Redraw = true; + } + } + + if (args.BoundingItem.Data == CaptionIdentifier) + { + BeginRenameType(args.Sender); + } + + if (args.BoundingItem.Data is UmlTypeMember) + { + BeginRenameProperty(args.Sender, args.BoundingItem.Data as UmlTypeMember); + args.Redraw = true; + } + } + + #endregion + + public override void OnKeyPress(ShapeKeyEventArgs args) + { + if (SelectedObject == null && args.Key == Keys.Enter) + { + BeginRenameType(args.Sender); + } + + if (SelectedObject != null && args.Key == Keys.Enter) + { + if (SelectedObject is UmlTypeMember) + { + BeginRenameProperty(args.Sender, (UmlTypeMember) SelectedObject); + } + } + + if (SelectedObject == null && args.Key == Keys.Delete) + { + args.Sender.Diagram.Shapes.Remove(this); + args.Redraw = true; + } + + if (SelectedObject != null && args.Key == Keys.Delete) + { + if (SelectedObject is UmlTypeMember) + { + DeleteSelectedMember(); + args.Redraw = true; + } + } + } + + private void DeleteSelectedMember() + { + //delete property + if (SelectedObject is UmlTypeMember) + { + TypedDataSource.RemoveTypeMember((UmlTypeMember) SelectedObject); + SelectedObject = null; + } + } + + private void BeginRenameProperty(UmlDesigner owner, UmlTypeMember property) + { + Rectangle bounds = owner.GetItemBounds(property); + if (bounds == Rectangle.Empty) + bounds = owner.GetItemBounds(AddNewPropertyIdentifier); + + var inputBounds = new Rectangle(bounds.X + Margins.TypeMemberNameIndent, bounds.Y, + bounds.Width - Margins.TypeMemberNameIndent, bounds.Height); + object oldSelectedObject = SelectedObject; + SelectedObject = null; + Action endRenameProperty = () => + { + property.DataSource.Name = owner.GetInput(); + if (property.DataSource.Name == "") + { + SelectedObject = property; + DeleteSelectedMember(); + } + else + { + SelectedObject = oldSelectedObject; + } + }; + + Font font = GetTypeMemberFont(); + owner.BeginInput(inputBounds, property.DataSource.Name, font, endRenameProperty); + } + + protected abstract IList GetTypeMemberSections(); + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlInterface.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlInterface.cs new file mode 100644 index 0000000..3e12a89 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlInterface.cs @@ -0,0 +1,60 @@ +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using AlbinoHorse.Model.Settings; +using Brushes=AlbinoHorse.Model.Settings.Brushes; +using Pens=AlbinoHorse.Model.Settings.Pens; + +namespace AlbinoHorse.Model +{ + public class UmlInterface : UmlInstanceType + { + #region TypedDataSource property + + private IUmlInterfaceData TypedDataSource + { + get { return DataSource as IUmlInterfaceData; } + } + + #endregion + + protected override IList GetTypeMemberSections() + { + return new List + {new UmlTypeMemberSection(this, "Properties"), new UmlTypeMemberSection(this, "Methods")}; + } + + protected override Brush GetCaptionBrush(Rectangle renderBounds) + { + if (Selected) + return new LinearGradientBrush(renderBounds, Color.FromArgb(220, 230, 209), Color.White, 0, true); + else + return new LinearGradientBrush(renderBounds, Color.FromArgb(230, 240, 219), Color.White, 0, true); + } + + protected override string GetTypeKind() + { + return "Interface"; + } + + protected override Font GetTypeNameFont() + { + return Fonts.DefaultTypeName; + } + + protected override Pen GetBorderPen() + { + return Pens.DefaultBorder; + } + + protected override Brush GetSectionCaptionBrush() + { + return Brushes.InterfaceSectionCaption; + } + + protected override Font GetTypeMemberFont() + { + return Fonts.InterfaceTypeMember; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlRelation.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlRelation.cs new file mode 100644 index 0000000..24ea9ab --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlRelation.cs @@ -0,0 +1,574 @@ +using System; +using System.Drawing; +using System.Windows.Forms; +using AlbinoHorse.Infrastructure; +using AlbinoHorse.Model.Settings; +using Brushes=AlbinoHorse.Model.Settings.Brushes; +using Pens=AlbinoHorse.Model.Settings.Pens; + +namespace AlbinoHorse.Model +{ + public delegate void LineDrawer(float x1, float y1, float x2, float y2); + + + public class UmlRelation : Shape + { + protected object EndPortIdentifier = new object(); + protected object StartPortIdentifier = new object(); + + #region Property Start + + public Shape Start + { + get { return DataSource.Start; } + } + + #endregion + + #region Property End + + public Shape End + { + get { return DataSource.End; } + } + + #endregion + + public IUmlRelationData DataSource { get; set; } + + public override void Draw(RenderInfo info) + { + } + + public override void DrawBackground(RenderInfo info) + { + Shape start = Start; + Shape end = End; + + if (start == null || end == null) + return; + + Rectangle startBounds = start.Bounds; + Rectangle endBounds = end.Bounds; + + + PointF startPoint = GetPoint(startBounds, DataSource.StartPortOffset, DataSource.StartPortSide); + PointF endPoint = GetPoint(endBounds, DataSource.EndPortOffset, DataSource.EndPortSide); + + Pen pen; + + if (DataSource.AssociationType == UmlRelationType.Inheritance) + pen = Pens.InheritanceLine; + else if (DataSource.AssociationType == UmlRelationType.None) + pen = Pens.FakeLine; + else + pen = Pens.AssociationLine; + + // DrawAssociation(info, startPoint, endPoint, Settings.Pens.AssociationBorder); + DrawRelationBackground(info, startPoint, endPoint); + if (Selected) + { + DrawRelation(info, startPoint, endPoint, Pens.AssociationBorder); + } + DrawRelation(info, startPoint, endPoint, pen); + DrawPortSelectionHandles(info, DataSource.StartPortSide, startPoint); + DrawPortSelectionHandles(info, DataSource.EndPortSide, endPoint); + } + + + private void DrawRelation(RenderInfo info, PointF startPoint, PointF endPoint, Pen pen) + { + //start + if (DataSource.AssociationType == UmlRelationType.Aggregation) + { + DrawAggregatePort(info, DataSource.StartPortSide, startPoint, pen); + } + else + { + DrawPort(info, DataSource.StartPortSide, startPoint, pen); + } + + //middle + DrawLine(info, pen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); + + //end + if (DataSource.AssociationType == UmlRelationType.Association) + DrawArrowPort(info, DataSource.EndPortSide, endPoint, pen); + if (DataSource.AssociationType == UmlRelationType.Aggregation) + DrawArrowPort(info, DataSource.EndPortSide, endPoint, pen); + if (DataSource.AssociationType == UmlRelationType.None) + DrawPort(info, DataSource.EndPortSide, endPoint, pen); + if (DataSource.AssociationType == UmlRelationType.Inheritance) + DrawInheritancePort(info, DataSource.EndPortSide, endPoint, pen); + } + + private void DrawRelationBackground(RenderInfo info, PointF startPoint, PointF endPoint) + { + DrawLineBackground(info, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); + DrawPortBackground(info, DataSource.StartPortSide, startPoint, StartPortIdentifier); + DrawPortBackground(info, DataSource.EndPortSide, endPoint, EndPortIdentifier); + } + + private void DrawPortSelectionHandles(RenderInfo info, UmlPortSide portSide, PointF point) + { + if (Selected) + { + const int marginSize = Margins.RelationPortMargin; + if (portSide == UmlPortSide.Left) + { + DrawSelectionHandle(info, new Point((int) point.X + marginSize, (int) point.Y)); + } + + if (portSide == UmlPortSide.Right) + { + DrawSelectionHandle(info, new Point((int) point.X - marginSize, (int) point.Y)); + } + + if (portSide == UmlPortSide.Top) + { + DrawSelectionHandle(info, new Point((int) point.X, (int) point.Y + marginSize)); + } + + if (portSide == UmlPortSide.Bottom) + { + DrawSelectionHandle(info, new Point((int) point.X, (int) point.Y - marginSize)); + } + } + } + + private void DrawPortBackground(RenderInfo info, UmlPortSide portSide, PointF point, object portIdentifier) + { + const int marginSize = Margins.RelationPortMargin; + if (portSide == UmlPortSide.Left) + { + DrawPortSelector(info, point.X, point.Y, point.X + marginSize, point.Y, portIdentifier); + } + + if (portSide == UmlPortSide.Right) + { + DrawPortSelector(info, point.X, point.Y, point.X - marginSize, point.Y, portIdentifier); + } + + if (portSide == UmlPortSide.Top) + { + DrawPortSelector(info, point.X, point.Y, point.X, point.Y + marginSize, portIdentifier); + } + + if (portSide == UmlPortSide.Bottom) + { + DrawPortSelector(info, point.X, point.Y, point.X, point.Y - marginSize, portIdentifier); + } + } + + + private static void DrawPort(RenderInfo info, UmlPortSide portSide, PointF point, Pen pen) + { + const int marginSize = Margins.RelationPortMargin; + if (portSide == UmlPortSide.Left) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X + marginSize, point.Y); + } + + if (portSide == UmlPortSide.Right) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X - marginSize, point.Y); + } + + if (portSide == UmlPortSide.Top) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y + marginSize); + } + + if (portSide == UmlPortSide.Bottom) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y - marginSize); + } + } + + private static void DrawArrowPort(RenderInfo info, UmlPortSide portSide, PointF point, Pen pen) + { + const int marginSize = Margins.RelationPortMargin; + const int arrowSize = Margins.RelationArrowSize; + + if (portSide == UmlPortSide.Left) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X + marginSize, point.Y); + info.Graphics.DrawLine(pen, point.X + arrowSize, point.Y - Margins.RelationArrowSize, point.X + marginSize, point.Y); + info.Graphics.DrawLine(pen, point.X + arrowSize, point.Y + Margins.RelationArrowSize, point.X + marginSize, point.Y); + } + + if (portSide == UmlPortSide.Right) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X - marginSize, point.Y); + info.Graphics.DrawLine(pen, point.X - arrowSize, point.Y - Margins.RelationArrowSize, point.X - marginSize, point.Y); + info.Graphics.DrawLine(pen, point.X - arrowSize, point.Y + Margins.RelationArrowSize, point.X - marginSize, point.Y); + } + + if (portSide == UmlPortSide.Top) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y + marginSize); + info.Graphics.DrawLine(pen, point.X - Margins.RelationArrowSize, point.Y + arrowSize, point.X, point.Y + marginSize); + info.Graphics.DrawLine(pen, point.X + Margins.RelationArrowSize, point.Y + arrowSize, point.X, point.Y + marginSize); + } + + if (portSide == UmlPortSide.Bottom) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y - marginSize); + info.Graphics.DrawLine(pen, point.X - Margins.RelationArrowSize, point.Y - arrowSize, point.X, point.Y - marginSize); + info.Graphics.DrawLine(pen, point.X + Margins.RelationArrowSize, point.Y - arrowSize, point.X, point.Y - marginSize); + } + } + + private static void DrawInheritancePort(RenderInfo info, UmlPortSide portSide, PointF point, Pen pen) + { + const int marginSize = Margins.RelationPortMargin; + const int arrowSize = Margins.RelationArrowSize; + var x = (int) point.X; + var y = (int) point.Y; + if (portSide == UmlPortSide.Left) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X + marginSize, point.Y); + + var points = new[] + { + new Point(x + marginSize, y), new Point(x + arrowSize, y + Margins.RelationArrowSize), + new Point(x + arrowSize, y - Margins.RelationArrowSize) + }; + info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); + info.Graphics.DrawPolygon(pen, points); + } + + if (portSide == UmlPortSide.Right) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X - marginSize, point.Y); + + var points = new[] + { + new Point(x - marginSize, y), new Point(x - arrowSize, y + Margins.RelationArrowSize), + new Point(x - arrowSize, y - Margins.RelationArrowSize) + }; + info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); + info.Graphics.DrawPolygon(pen, points); + } + + if (portSide == UmlPortSide.Top) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y + marginSize); + + var points = new[] + { + new Point(x, y + marginSize), new Point(x + Margins.RelationArrowSize, y + arrowSize), + new Point(x - Margins.RelationArrowSize, y + arrowSize) + }; + info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); + info.Graphics.DrawPolygon(pen, points); + } + + if (portSide == UmlPortSide.Bottom) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y - marginSize); + var points = new[] + { + new Point(x, y - marginSize), new Point(x + Margins.RelationArrowSize, y - arrowSize), + new Point(x - Margins.RelationArrowSize, y - arrowSize) + }; + info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); + info.Graphics.DrawPolygon(pen, points); + } + } + + private static void DrawAggregatePort(RenderInfo info, UmlPortSide portSide, PointF point, Pen pen) + { + const int marginSize = 16; + var x = (int) point.X; + var y = (int) point.Y; + if (portSide == UmlPortSide.Left) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X + marginSize, point.Y); + + var points = new[] + { + new Point(x + marginSize, y), new Point(x + marginSize/2, y + Margins.RelationArrowSize), + new Point(x + 0, y), + new Point(x + marginSize/2, y - Margins.RelationArrowSize) + }; + + info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); + info.Graphics.DrawPolygon(pen, points); + } + + if (portSide == UmlPortSide.Right) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X - marginSize, point.Y); + + var points = new[] + { + new Point(x - marginSize, y), new Point(x - marginSize/2, y + Margins.RelationArrowSize), + new Point(x - 0, y), + new Point(x - marginSize/2, y - Margins.RelationArrowSize) + }; + info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); + info.Graphics.DrawPolygon(pen, points); + } + + if (portSide == UmlPortSide.Top) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y + marginSize); + + var points = new[] + { + new Point(x, y + marginSize), new Point(x + Margins.RelationArrowSize, y + marginSize/2), new Point(x, y), + new Point(x - Margins.RelationArrowSize, y + marginSize/2) + }; + + info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); + info.Graphics.DrawPolygon(pen, points); + } + + if (portSide == UmlPortSide.Bottom) + { + info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y - marginSize); + + var points = new[] + { + new Point(x, y - marginSize), new Point(x + Margins.RelationArrowSize, y - marginSize/2), new Point(x, y), + new Point(x - Margins.RelationArrowSize, y - marginSize/2) + }; + + info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); + info.Graphics.DrawPolygon(pen, points); + } + } + + //private static void DrawLine(RenderInfo info, PointF startPoint, PointF endPoint, Pen pen) + //{ + // info.Graphics.DrawLine(pen, startPoint, endPoint); + //} + + private static PointF GetPoint(Rectangle bounds, int portOffset, UmlPortSide portSide) + { + const int marginSize = 20; + + var point = new PointF(); + if (portSide == UmlPortSide.Left) + { + point.X = bounds.Left - marginSize; + point.Y = bounds.Top + portOffset; + } + else if (portSide == UmlPortSide.Right) + { + point.X = bounds.Right + marginSize; + point.Y = bounds.Top + portOffset; + } + else if (portSide == UmlPortSide.Top) + { + point.X = bounds.Left + portOffset; + point.Y = bounds.Top - marginSize; + } + else if (portSide == UmlPortSide.Bottom) + { + point.X = bounds.Left + portOffset; + point.Y = bounds.Bottom + marginSize; + } + else + { + throw new NotSupportedException(); + } + + return point; + } + + public override void PreviewDrawBackground(RenderInfo info) + { + Shape start = Start; + Shape end = End; + + if (start == null || end == null) + return; + + Rectangle startBounds = start.Bounds; + Rectangle endBounds = end.Bounds; + + float x1 = startBounds.X + startBounds.Width/2; + float y1 = startBounds.Y + startBounds.Height/2; + + + float x2 = endBounds.X + endBounds.Width/2; + float y2 = endBounds.Y + endBounds.Height/2; + + info.Graphics.DrawLine(System.Drawing.Pens.DarkGray, x1, y1, x2, y2); + } + + private static void RouteLine(LineDrawer drawLine, float x1, float y1, float x2, float y2) + { + drawLine(x1, y1, x2, y2); + } + + private static void DrawLine(RenderInfo info, Pen pen, float x1, float y1, float x2, float y2) + { + LineDrawer drawLine = (xx1, yy1, xx2, yy2) => info.Graphics.DrawLine(pen, xx1, yy1, xx2, yy2); + RouteLine(drawLine, x1, y1, x2, y2); + } + + private void DrawLineBackground(RenderInfo info, float x1, float y1, float x2, float y2) + { + LineDrawer drawLine = (xx1, yy1, xx2, yy2) => + { + #region Add BBox + + var bbox = new BoundingBox {Target = this, Data = this}; + var tmp = new Rectangle((int) Math.Min(xx1, xx2), (int) Math.Min(yy1, yy2), + (int) Math.Abs(xx2 - xx1), + (int) Math.Abs(yy2 - yy1)); + tmp.Inflate(6, 6); + bbox.Bounds = tmp; + info.BoundingItems.Add(bbox); + + #endregion + + if (Selected) + { + info.Graphics.DrawLine(Pens.Selection, xx1, yy1, xx2, yy2); + } + }; + + RouteLine(drawLine, x1, y1, x2, y2); + } + + private void DrawPortSelector(RenderInfo info, float x1, float y1, float x2, float y2, object portIdentifier) + { + #region Add BBox + + var bbox = new BoundingBox {Target = this, Data = portIdentifier}; + var tmp = new Rectangle((int) Math.Min(x1, x2), (int) Math.Min(y1, y2), (int) Math.Abs(x2 - x1), + (int) Math.Abs(y2 - y1)); + + tmp.Inflate(6, 6); + + bbox.Bounds = tmp; + info.BoundingItems.Add(bbox); + + #endregion + + if (Selected) + { + tmp.Inflate(-2, -2); + info.Graphics.FillRectangle(Brushes.Selection, tmp); + } + } + + public override void OnMouseDown(ShapeMouseEventArgs args) + { + args.Sender.ClearSelection(); + Selected = true; + args.Redraw = true; + } + + public override void OnMouseMove(ShapeMouseEventArgs args) + { + if (args.BoundingItem.Data == StartPortIdentifier && args.Button == MouseButtons.Left) + { + Rectangle bounds = DataSource.Start.Bounds; + + int offset = 0; + UmlPortSide side = DataSource.StartPortSide; + + int oppositeOffset = DataSource.EndPortOffset; + UmlPortSide oppositeSide = DataSource.EndPortSide; + + + MovePort(args, bounds, ref offset, ref side, oppositeOffset, oppositeSide); + + DataSource.StartPortSide = side; + DataSource.StartPortOffset = offset; + args.Redraw = true; + } + + if (args.BoundingItem.Data == EndPortIdentifier && args.Button == MouseButtons.Left) + { + Rectangle bounds = DataSource.End.Bounds; + + int offset = 0; + UmlPortSide side = DataSource.EndPortSide; + + int oppositeOffset = DataSource.StartPortOffset; + UmlPortSide oppositeSide = DataSource.StartPortSide; + + + MovePort(args, bounds, ref offset, ref side, oppositeOffset, oppositeSide); + + DataSource.EndPortSide = side; + DataSource.EndPortOffset = offset; + args.Redraw = true; + } + } + + private static void MovePort(ShapeMouseEventArgs args, Rectangle bounds, ref int offset, ref UmlPortSide side, + int oppositeOffset, UmlPortSide oppositeSide) + { + int x = args.X; + int y = args.Y; + + int half = bounds.Width/2; + int center = bounds.X + half; + int xd = Math.Abs(x - center); + int top = bounds.Top + half - xd; + int bottom = bounds.Bottom - half + xd; + + + if (x < center) + { + //left of + side = UmlPortSide.Left; + } + else + { + //right of + side = UmlPortSide.Right; + } + + if (y < top) + side = UmlPortSide.Top; + + if (y > bottom) + side = UmlPortSide.Bottom; + + + if (side == UmlPortSide.Top || side == UmlPortSide.Bottom) + { + offset = args.X - bounds.Left; + + if (args.X < bounds.Left) + offset = 0; + + if (args.X > bounds.Right) + offset = bounds.Width; + } + + if (side == UmlPortSide.Left || side == UmlPortSide.Right) + { + offset = args.Y - bounds.Top; + + if (args.Y < bounds.Top) + offset = 0; + + if (args.Y > bounds.Bottom) + offset = bounds.Height; + } + + if ((side == UmlPortSide.Left || side == UmlPortSide.Right) && + (oppositeSide == UmlPortSide.Left || oppositeSide == UmlPortSide.Right)) + { + if (Math.Abs(offset - oppositeOffset) < 10) + offset = oppositeOffset; + } + + if ((side == UmlPortSide.Top || side == UmlPortSide.Bottom) && + (oppositeSide == UmlPortSide.Top || oppositeSide == UmlPortSide.Bottom)) + { + if (Math.Abs(offset - oppositeOffset) < 10) + offset = oppositeOffset; + } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlShape.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlShape.cs new file mode 100644 index 0000000..a528f72 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlShape.cs @@ -0,0 +1,145 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using AlbinoHorse.Infrastructure; +using Brushes=AlbinoHorse.Model.Settings.Brushes; +using Pens=AlbinoHorse.Model.Settings.Pens; + +namespace AlbinoHorse.Model +{ + public class UmlShape : Shape + { + protected Point mouseDownPos; + protected Point mouseDownShapePos; + + #region Properties + + #region SelectedObject property + + private object selectedObject; + + public object SelectedObject + { + get { return selectedObject; } + + set + { + selectedObject = value; + OnSelectedObjectChanged(EventArgs.Empty); + } + } + + #endregion + + #endregion + + #region Identifiers + + //bounding box identifiers + + protected readonly object BodyIdentifier = new object(); + protected readonly object BottomLeftResizeIdentifier = new object(); + protected readonly object BottomResizeIdentifier = new object(); + protected readonly object BottomRightResizeIdentifier = new object(); + protected readonly object LeftResizeIdentifier = new object(); + protected readonly object RightResizeIdentifier = new object(); + + protected readonly object TopLeftResizeIdentifier = new object(); + protected readonly object TopResizeIdentifier = new object(); + protected readonly object TopRightResizeIdentifier = new object(); + protected readonly object TypeExpanderIdentifier = new object(); + + #endregion + + #region Draw + + public override void DrawPreview(RenderInfo info) + { + info.Graphics.FillRectangle(System.Drawing.Brushes.White, Bounds); + info.Graphics.DrawRectangle(System.Drawing.Pens.Black, Bounds); + } + + protected virtual void DrawSelection(RenderInfo info) + { + if (Selected && SelectedObject == null) + { + Rectangle outerBounds = Bounds; + outerBounds.Inflate(6, 6); + outerBounds.Offset(1, 0); + Rectangle innerBounds = outerBounds; + innerBounds.Inflate(-3, -3); + + info.Graphics.SetClip(outerBounds, CombineMode.Replace); + info.Graphics.SetClip(innerBounds, CombineMode.Xor); + info.Graphics.FillRectangle(Brushes.Selection, outerBounds); + info.Graphics.ResetClip(); + //info.Graphics.DrawRectangle(Settings.Pens.SelectionInner, outerBounds); + //outerBounds.Offset(-1, 1); + //info.Graphics.DrawRectangle(Settings.Pens.SelectionOuter, outerBounds); + + + DrawSelectionHandle(info, new Point(outerBounds.Left, (outerBounds.Top + outerBounds.Bottom)/2), + LeftResizeIdentifier); + DrawSelectionHandle(info, new Point(outerBounds.Right, (outerBounds.Top + outerBounds.Bottom)/2), + RightResizeIdentifier); + + DrawCustomSelection(info); + } + } + + + protected virtual void DrawCustomSelection(RenderInfo info) {} + + public override void DrawBackground(RenderInfo info) + { + int grid = info.GridSize; + Rectangle renderBounds = Bounds; + + int x = renderBounds.X + 4; + int y = renderBounds.Y + 3; + int width = renderBounds.Width; + int height = renderBounds.Height; + + GraphicsPath shadowPath = GetOutlinePath(x, y, width, height); + + try + { + info.Graphics.FillPath(Brushes.Shadow, shadowPath); + } + catch {} + } + + #endregion + + protected virtual void OnSelectedObjectChanged(EventArgs eventArgs) {} + + protected virtual int GetRadius() + { + return 16; + } + + protected GraphicsPath GetOutlinePath(int x, int y, int width, int height) + { + int radius = GetRadius(); + + var path = new GraphicsPath(); + path.AddLine(x + radius, y, x + width - radius, y); + path.AddArc(x + width - radius, y, radius, radius, 270, 90); + path.AddLine(x + width, y + radius, x + width, y + height - radius); + path.AddArc(x + width - radius, y + height - radius, radius, radius, 0, 90); + path.AddLine(x + width - radius, y + height, x + radius, y + height); + path.AddArc(x, y + height - radius, radius, radius, 90, 90); + path.AddLine(x, y + height - radius, x, y + radius); + path.AddArc(x, y, radius, radius, 180, 90); + + path.CloseFigure(); + + return path; + } + + protected virtual Pen GetBorderPen() + { + return Pens.DefaultBorder; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlType.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlType.cs new file mode 100644 index 0000000..9e669b5 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Model/UmlTypes/UmlType.cs @@ -0,0 +1,197 @@ +using System.Drawing; +using System.Drawing.Drawing2D; +using AlbinoHorse.Infrastructure; +using AlbinoHorse.Model.Settings; +using AlbinoHorse.Windows.Forms; +using Alsing.AlbinoHorse.Properties; +using Brushes=System.Drawing.Brushes; +using Pens=System.Drawing.Pens; + +namespace AlbinoHorse.Model +{ + public abstract class UmlType : UmlShape + { + #region Properties + + #region DataSource property + + public IUmlTypeData DataSource { get; set; } + + #endregion + + #region Identifiers + + //bounding box identifiers + protected readonly object CaptionIdentifier = new object(); + + #endregion + + #region TypeName property + + public string TypeName + { + get { return DataSource.TypeName; } + set { DataSource.TypeName = value; } + } + + #endregion + + #region Expanded property + + public bool Expanded + { + get { return DataSource.Expanded; } + set { DataSource.Expanded = value; } + } + + #endregion + + #endregion + + #region Draw + + public override void Draw(RenderInfo info) + { + int grid = info.GridSize; + Rectangle renderBounds = Bounds; + + var bboxThis = new BoundingBox {Bounds = renderBounds, Target = this, Data = BodyIdentifier}; + info.BoundingItems.Add(bboxThis); + + int x = renderBounds.X; + int y = renderBounds.Y; + int width = renderBounds.Width; + int height = renderBounds.Height; + + GraphicsPath path = GetOutlinePath(x, y, width, height); + Pen borderPen = GetBorderPen(); + + using (Brush captionBrush = GetCaptionBrush(renderBounds)) + { + if (Expanded) + DrawExpanded(info, path, x, y, width, height, captionBrush, borderPen); + else + DrawCollapsed(info, path, x, y, width, height, captionBrush, borderPen); + } + + DrawTypeExpander(info, x, y, width); + DrawSelection(info); + DrawTypeName(info, x, y, width); + DrawTypeKind(info, x, y, width); + DrawCustomCaptionInfo(info, x, y, width); + } + + + protected void DrawTypeExpander(RenderInfo info, int x, int y, int width) + { + var typeExpanderBounds = new Rectangle(x + width - 20, y + 6, 13, 13); + + #region add type expander bbox + + var bboxTypeExpander = new BoundingBox(); + bboxTypeExpander.Target = this; + bboxTypeExpander.Bounds = typeExpanderBounds; + bboxTypeExpander.Data = TypeExpanderIdentifier; + info.BoundingItems.Add(bboxTypeExpander); + + #endregion + + if (Expanded) + info.Graphics.DrawImage(Resources.CollapseType, typeExpanderBounds); + else + info.Graphics.DrawImage(Resources.ExpandType, typeExpanderBounds); + } + + protected virtual void DrawExpanded(RenderInfo info, GraphicsPath path, int x, int y, int width, int height, + Brush captionBrush, Pen borderPen) + { + int currentY = y + DrawExpandedCaption(info, path, x, y, width, height, captionBrush); + + currentY = DrawExpandedBody(info, x, width, currentY); + + info.Graphics.DrawPath(borderPen, path); + } + + protected abstract int DrawExpandedBody(RenderInfo info, int x, int width, int currentY); + + protected int DrawExpandedCaption(RenderInfo info, GraphicsPath path, int x, int y, int width, int height, + Brush captionBrush) + { + int captionHeight = 48; + var captionBounds = new Rectangle(x, y, width, captionHeight); + + #region add caption bbox + + var bboxCaption = new BoundingBox(); + bboxCaption.Bounds = captionBounds; + bboxCaption.Target = this; + bboxCaption.Data = CaptionIdentifier; + info.BoundingItems.Add(bboxCaption); + + #endregion + + info.Graphics.SetClip(path); + info.Graphics.FillRectangle(captionBrush, captionBounds); + info.Graphics.FillRectangle(Brushes.White, x, y + captionHeight, width, height - captionHeight); + info.Graphics.DrawLine(Pens.LightGray, x, y + captionHeight, x + width, y + captionHeight); + info.Graphics.ResetClip(); + return captionHeight; + } + + protected void DrawCollapsed(RenderInfo info, GraphicsPath path, int x, int y, int width, int height, + Brush captionBrush, Pen borderPen) + { + var captionBounds = new Rectangle(x, y, width, height); + + var bboxCaption = new BoundingBox(); + bboxCaption.Bounds = captionBounds; + bboxCaption.Target = this; + bboxCaption.Data = CaptionIdentifier; + info.BoundingItems.Add(bboxCaption); + + info.Graphics.FillPath(captionBrush, path); + info.Graphics.DrawPath(borderPen, path); + } + + protected virtual void DrawTypeKind(RenderInfo info, int x, int y, int width) + { + var typeKindBounds = new Rectangle(x + Margins.TypeBoxSideMargin, y + 4 + 15, + width - Margins.TypeBoxSideMargin*2, 10); + string kind = GetTypeKind(); + info.Graphics.DrawString(kind, Fonts.TypeKind, Brushes.Black, typeKindBounds, + StringFormat.GenericTypographic); + } + + protected virtual void DrawTypeName(RenderInfo info, int x, int y, int width) + { + var typeNameBounds = new Rectangle(x + Margins.TypeBoxSideMargin, y + 4, width - Margins.TypeBoxSideMargin*2, + 10); + Font typeNameFont = GetTypeNameFont(); + info.Graphics.DrawString(TypeName, typeNameFont, Brushes.Black, typeNameBounds, + StringFormat.GenericTypographic); + } + + protected virtual void DrawCustomCaptionInfo(RenderInfo info, int x, int y, int width) {} + + #endregion + + protected abstract Brush GetCaptionBrush(Rectangle renderBounds); + protected abstract string GetTypeKind(); + + protected virtual Font GetTypeNameFont() + { + return Fonts.DefaultTypeName; + } + + + protected void BeginRenameType(UmlDesigner owner) + { + var inputBounds = new Rectangle(Bounds.Left + Margins.TypeBoxSideMargin, Bounds.Top + 4, + Bounds.Width - 25 - Margins.TypeBoxSideMargin, 20); + + Action endRenameType = () => { DataSource.TypeName = owner.GetInput(); }; + + owner.BeginInput(inputBounds, DataSource.TypeName, Fonts.DefaultTypeName, endRenameType); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Properties/AssemblyInfo.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..16ac8e4 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Properties/AssemblyInfo.cs @@ -0,0 +1,38 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly : AssemblyTitle("ClassEditor")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("ClassEditor")] +[assembly : AssemblyCopyright("Copyright © 2005")] +[assembly : AssemblyTrademark("")] +[assembly : AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly : ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM + +[assembly : Guid("3f90bf31-a939-4e8d-ba25-1fc2757263ba")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly : AssemblyVersion("1.0.*")] +[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Properties/Resources.Designer.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Properties/Resources.Designer.cs new file mode 100644 index 0000000..29f6b1e --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Properties/Resources.Designer.cs @@ -0,0 +1,105 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.3031 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Alsing.AlbinoHorse.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Alsing.AlbinoHorse.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + internal static System.Drawing.Bitmap CollapseSection { + get { + object obj = ResourceManager.GetObject("CollapseSection", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap CollapseType { + get { + object obj = ResourceManager.GetObject("CollapseType", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap ExpandSection { + get { + object obj = ResourceManager.GetObject("ExpandSection", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap ExpandType { + get { + object obj = ResourceManager.GetObject("ExpandType", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap InheritanceArrow { + get { + object obj = ResourceManager.GetObject("InheritanceArrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap Property { + get { + object obj = ResourceManager.GetObject("Property", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Properties/Resources.resx b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Properties/Resources.resx new file mode 100644 index 0000000..bfaaefb --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Properties/Resources.resx @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\Collapse.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\resources\collapse.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Expand.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\resources\expand.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\resources\inheritancearrow.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\resources\property.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Resources/Collapse.bmp b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Resources/Collapse.bmp new file mode 100644 index 0000000000000000000000000000000000000000..82689526b75f91ccdb9138b9e5f62eb5cdbbb526 GIT binary patch literal 574 zcmZvZyHCPU6vnHQi@SeJKVz@O#sPY{Hdjn1WC-dX zuEu^thGS0$D4j`tMgm}ot0OhnYBs1KVVE8T6pnSOnL>9~tEIe}1K$KRfCG9wKWW=u z;VU#WMd`i{h($ literal 0 HcmV?d00001 diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Resources/Collapse.gif b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Resources/Collapse.gif new file mode 100644 index 0000000000000000000000000000000000000000..ff19652e98e4338bf6ab7a54fcf61a30216e91d4 GIT binary patch literal 905 zcmZ?wbhEHb6krfw_|51J}XZBw@bKu&= zW7jVozj68G?Q3W5+&F*#_NB)UZa#T<^XbD|uUUqSn@^wKef|3J z`?t^EzJ2-r{p+7UzyAFB{r~@euqC6!Xb23(5K#Qd!pOkzpFs!YI8dHo;7DWm&ne@v zVZp&>4q+(~fdvZ>GcfV7F*t5i>R=GE&$#j;k=d=8(W>Nu!>2&*@9$r4pFOyFYWL04Aao0g_S`xRLXU5p z`S$t!zkh!j-aUVCa_fR?$G6_Sa0m_EI&JInJ1UkJ#h+QTaB+6{MVQh%7Y-uS{rK`}Q%lLxyy)jQFMt2^;q+Rt(ygn3Mxdwz zI_2rr^DpmQfA{pk(Z$n%N`YJ;8(kg5>W?pMm+XIR@id4C7Ii>REH8{(U7mLH z;Es98e#e$fhbTp{_uHrUOL8Mu6eoOn_xktG@7E7(pPS@+eCdqezkl95vm5G1J}XZBw@bKu&= zV>d3JynXG=og3%x-@f$t!ObTRZ$5o^>($H0Z{I%u_~G@34{ttwdiV9~$M4@hfBW|3 z`}ePZ{`~s$=lB2r|G~zO5~Cq7ctb$(CkrD3!+!=HkP|_9f`KE0;XkL0$A$$5n>mD~ zLb(8ia%Kx85jf^bU->lb~3OkB&c*9%W!iq>gri!wn0E) Yf|11zXN9Am<}lpv`WP*$tjJ&u0Gxs>kpKVy literal 0 HcmV?d00001 diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Resources/Property.bmp b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Resources/Property.bmp new file mode 100644 index 0000000000000000000000000000000000000000..d26da6237ac9b50a817b7ecf3b30455a49225fbd GIT binary patch literal 782 zcmb7?F;2xW42A>jPhzQ${QIycWV+1JmY9r1#)W=L;~sI5 k`0juuk5aV9gkZQV=M0l!64Nv>5{7|2MFU`%;da4%1JlSAj{pDw literal 0 HcmV?d00001 diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/TestDiagram.cd b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/TestDiagram.cd new file mode 100644 index 0000000..f8839a8 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/TestDiagram.cd @@ -0,0 +1,57 @@ + + + + + + + + + AgAAAAAEAAAAAgAAAQAAAAACABAAAAABIAAGAgACAgI= + Model\Shape.cs + + + + + + + + Model\UmlType.cs + + + + + + + + + + + + + + + + EgAAAYAEQAQAhgAAAAEZADAgUBAACABJIQClASASggA= + Model\UmlType.cs + + + + + + + + + QAIACAAAABAAAAIBQAAAAEAQAAAAABAYAACQQAIAYAA= + Model\DefaultUmlTypeData.cs + + + + + + + QAIACAAAABAAAAIBQAAAAEAQAAAAABAYAACQAAIAYAA= + Model\IUmlTypeData.cs + + + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/Canvas.Designer.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/Canvas.Designer.cs new file mode 100644 index 0000000..57e15cc --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/Canvas.Designer.cs @@ -0,0 +1,37 @@ +namespace AlbinoHorse.Windows.Forms +{ + partial class Canvas + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/Canvas.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/Canvas.cs new file mode 100644 index 0000000..eff9df3 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/Canvas.cs @@ -0,0 +1,43 @@ +using System; +using System.Windows.Forms; + +namespace AlbinoHorse.Windows.Forms +{ + public partial class Canvas : UserControl + { + private int oldScrollX; + private int oldScrollY; + + public Canvas() + { + InitializeComponent(); + SetStyle( + ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true); + + Paint += Canvas_Paint; + } + + public event EventHandler CanvasScroll; + + protected virtual void OnCanvasScroll(EventArgs e) + { + if (CanvasScroll != null) + CanvasScroll(this, e); + } + + private void Canvas_Paint(object sender, PaintEventArgs e) + { + CheckScroll(); + } + + private void CheckScroll() + { + if (AutoScrollPosition.X != oldScrollX || AutoScrollPosition.Y != oldScrollY) + { + oldScrollX = AutoScrollPosition.X; + oldScrollY = AutoScrollPosition.Y; + OnCanvasScroll(EventArgs.Empty); + } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/EditMode.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/EditMode.cs new file mode 100644 index 0000000..64958b2 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/EditMode.cs @@ -0,0 +1,9 @@ +namespace AlbinoHorse.Windows.Forms +{ + public enum EditMode + { + Normal, + BeginDrawRelation, + DrawRelation, + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner.Designer.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner.Designer.cs new file mode 100644 index 0000000..c5fcc89 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner.Designer.cs @@ -0,0 +1,85 @@ +using AlbinoHorse.Layout; +namespace AlbinoHorse.Windows.Forms +{ + partial class UmlDesigner + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.PreviewCanvas = new AlbinoHorse.Windows.Forms.Canvas(); + this.MainCanvas = new AlbinoHorse.Windows.Forms.Canvas(); + this.txtInput = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // PreviewCanvas + // + this.PreviewCanvas.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.PreviewCanvas.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(246)))), ((int)(((byte)(255))))); + this.PreviewCanvas.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.PreviewCanvas.Location = new System.Drawing.Point(241, 172); + this.PreviewCanvas.Name = "PreviewCanvas"; + this.PreviewCanvas.Size = new System.Drawing.Size(135, 135); + this.PreviewCanvas.TabIndex = 1; + // + // MainCanvas + // + this.MainCanvas.AutoScroll = true; + this.MainCanvas.Dock = System.Windows.Forms.DockStyle.Fill; + this.MainCanvas.Location = new System.Drawing.Point(0, 0); + this.MainCanvas.Name = "MainCanvas"; + this.MainCanvas.Size = new System.Drawing.Size(413, 336); + this.MainCanvas.TabIndex = 0; + // + // txtInput + // + this.txtInput.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtInput.Location = new System.Drawing.Point(0, 0); + this.txtInput.Name = "txtInput"; + this.txtInput.Size = new System.Drawing.Size(100, 20); + this.txtInput.TabIndex = 2; + this.txtInput.Visible = false; + this.txtInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyDown); + this.txtInput.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtInput_KeyPress); + // + // UmlDesigner + // + this.BackColor = System.Drawing.Color.White; + this.Controls.Add(this.txtInput); + this.Controls.Add(this.PreviewCanvas); + this.Controls.Add(this.MainCanvas); + this.Size = new System.Drawing.Size(413, 336); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Canvas MainCanvas; + private Canvas PreviewCanvas; + private System.Windows.Forms.TextBox txtInput; + } +} diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner.cs new file mode 100644 index 0000000..05da4e3 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner.cs @@ -0,0 +1,671 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; +using AlbinoHorse.Infrastructure; +using AlbinoHorse.Model; + +namespace AlbinoHorse.Windows.Forms +{ + public partial class UmlDesigner : Control + { + private BoundingItem currentBoundingItem; + private Shape currentShape; + private DrawRelation endDrawRelation; + private Action EndInputAction { get; set; } + private bool isPanning; + private Point mouseCurrentPoint; + private Point mouseDownAutoscrollPoint; + private Point mouseDownPoint; + private string originalText; + private Shape relationEnd; + private Shape relationStart; + + public UmlDesigner() + { + InitializeComponent(); + Zoom = 1; + Diagram = new UmlDiagram(); + + MainCanvas.MouseMove += MainCanvas_MouseMove; + MainCanvas.MouseDown += MainCanvas_MouseDown; + MainCanvas.MouseUp += MainCanvas_MouseUp; + MainCanvas.Paint += MainCanvas_Paint; + MainCanvas.DoubleClick += MainCanvas_DoubleClick; + MainCanvas.CanvasScroll += MainCanvas_CanvasScroll; + MainCanvas.KeyPress += MainCanvas_KeyPress; + MainCanvas.KeyDown += MainCanvas_KeyDown; + + PreviewCanvas.Paint += PreviewCanvas_Paint; + PreviewCanvas.MouseDown += PreviewCanvas_MouseDown; + PreviewCanvas.MouseMove += PreviewCanvas_MouseMove; + BoundingItemes = new List(); + GridSize = 21; + ShowGrid = true; + SnapToGrid = true; + EditMode = EditMode.Normal; + } + + public int GridSize { get; set; } + public bool ShowGrid { get; set; } + public bool SnapToGrid { get; set; } + public EditMode EditMode { get; set; } + + private void MainCanvas_KeyDown(object sender, KeyEventArgs e) + { + if (EditMode == EditMode.Normal) + { + if (currentShape != null) + { + Shape shape = currentShape; + var args = new ShapeKeyEventArgs + {SnapToGrid = SnapToGrid, Sender = this, GridSize = GridSize, Key = e.KeyCode}; + + shape.OnKeyPress(args); + + if (args.Redraw) + Refresh(); + } + } + } + + private void MainCanvas_KeyPress(object sender, KeyPressEventArgs e) + { + if (EditMode == EditMode.Normal) {} + } + + private void SetViewPort(int x, int y) + { + float width = 0; + float height = 0; + foreach (Shape type in diagram.Shapes) + { + if (type is UmlInstanceType) + { + width = Math.Max(type.Bounds.Right, width); + height = Math.Max(type.Bounds.Bottom, height); + } + } + + float max = Math.Max(width, height) + 700; + float zoom = PreviewCanvas.Width/max; + + + var xx = (int) ((double) x/zoom); + var yy = (int) ((double) y/zoom); + + + xx -= MainCanvas.Width/2; + yy -= MainCanvas.Height/2; + + MainCanvas.AutoScrollPosition = new Point(xx, yy); + } + + private void PreviewCanvas_MouseMove(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + SetViewPort(e.X, e.Y); + } + + private void PreviewCanvas_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + SetViewPort(e.X, e.Y); + } + + private void MainCanvas_CanvasScroll(object sender, EventArgs e) + { + EndInput(); + PreviewCanvas.Invalidate(); + } + + private void MainCanvas_DoubleClick(object sender, EventArgs e) + { + var x = (int) ((mouseDownPoint.X - MainCanvas.AutoScrollPosition.X)/Zoom); + var y = (int) ((mouseDownPoint.Y - MainCanvas.AutoScrollPosition.Y)/Zoom); + + for (int i = BoundingItemes.Count - 1; i >= 0; i--) + { + BoundingItem bitem = BoundingItemes[i]; + if (bitem.HitTest(x,y)) + { + if (bitem.Target is Shape) + { + currentBoundingItem = bitem; + var shape = (Shape) bitem.Target; + var args = new ShapeMouseEventArgs + {BoundingItem = bitem, X = x, Y = y, Button = MouseButtons.Left, Sender = this}; + shape.OnDoubleClick(args); + if (args.Redraw) + Refresh(); + } + + return; + } + } + } + + public void AutoLayout() + { + //Diagram.AutoLayout(); + Refresh(); + Refresh(); + } + + public Rectangle GetItemBounds(object item) + { + foreach (BoundingItem bitem in BoundingItemes) + { + if (bitem.Target == item) + return bitem.GetBounds(); + + if (bitem.Data == item) + return bitem.GetBounds(); + } + + return Rectangle.Empty; + } + + public int TransformToZoom(int x) + { + double xx = x; + xx *= Zoom; + return (int) xx; + } + + public float TransformToZoom(float x) + { + double xx = x; + xx *= Zoom; + return (float) xx; + } + + public void BeginDrawRelation(DrawRelation endDrawRelation) + { + this.endDrawRelation = endDrawRelation; + EditMode = EditMode.BeginDrawRelation; + } + + public void BeginInput(Rectangle bounds, string text, Font font, Action endInputAction) + { + originalText = text; + EndInputAction = endInputAction; + txtInput.Visible = false; + txtInput.Multiline = false; + txtInput.ScrollBars = ScrollBars.None; + int x = bounds.Left; + int y = bounds.Top; + int width = bounds.Width; + + + x = TransformToZoom(x) - 2; + y = TransformToZoom(y) - 2; + width = TransformToZoom(width); + + x += MainCanvas.AutoScrollPosition.X; + y += MainCanvas.AutoScrollPosition.Y; + + float newFontSize = TransformToZoom(font.Size); + var newFont = new Font(font.Name, newFontSize, font.Style); + + + txtInput.Left = x; + txtInput.Top = y; + txtInput.Width = width; + txtInput.Height = 1; + txtInput.Text = text; + txtInput.Font = newFont; + txtInput.Visible = true; + txtInput.SelectAll(); + txtInput.Focus(); + } + + public void BeginInputMultiLine(Rectangle bounds, string text, Font font, Action endInputAction) + { + originalText = text; + EndInputAction = endInputAction; + txtInput.Visible = false; + txtInput.Multiline = true; + txtInput.ScrollBars = ScrollBars.None; + int x = bounds.Left; + int y = bounds.Top; + int width = bounds.Width; + int height = bounds.Height; + + + x = TransformToZoom(x); + y = TransformToZoom(y); + width = TransformToZoom(width); + height = TransformToZoom(height); + + x += MainCanvas.AutoScrollPosition.X; + y += MainCanvas.AutoScrollPosition.Y; + + float newFontSize = TransformToZoom(font.Size); + var newFont = new Font(font.Name, newFontSize, font.Style); + + + txtInput.Left = x; + txtInput.Top = y; + txtInput.Width = width; + txtInput.Height = height; + txtInput.Text = text; + txtInput.Font = newFont; + txtInput.Visible = true; + txtInput.SelectAll(); + txtInput.Focus(); + } + + public void EndInput() + { + if (EndInputAction != null) + EndInputAction(); + else + return; + + EndInputAction = null; + + Font oldFont = txtInput.Font; + + txtInput.Font = Settings.inputFont; + txtInput.Visible = false; + + oldFont.Dispose(); // throw away the zoomed font + Refresh(); + MainCanvas.Focus(); + } + + + private void PreviewCanvas_Paint(object sender, PaintEventArgs e) + { + int x = 0; + int y = 0; + e.Graphics.SmoothingMode = SmoothingMode.HighSpeed; + + float width = 0; + float height = 0; + foreach (Shape type in diagram.Shapes) + { + if (type is UmlInstanceType) + { + width = Math.Max(type.Bounds.Right, width); + height = Math.Max(type.Bounds.Bottom, height); + } + } + + float max = Math.Max(width, height) + 700; + float zoom = PreviewCanvas.Width/max; + + var visibleBounds = new Rectangle(x, y, PreviewCanvas.ClientSize.Width, PreviewCanvas.ClientSize.Height); + + + var renderInfo = new RenderInfo + {Graphics = e.Graphics, Preview = true, VisualBounds = visibleBounds, GridSize = GridSize}; + + e.Graphics.ScaleTransform(zoom, zoom); + e.Graphics.TranslateTransform((-x/zoom + 50), (-y/zoom + 50)); + renderInfo.Zoom = Zoom; + Diagram.Draw(renderInfo); + + double vpWidth = MainCanvas.Width/Zoom; + double vpHeight = MainCanvas.Height/Zoom; + + var viewPort = new Rectangle((int) (-MainCanvas.AutoScrollPosition.X/Zoom), + (int) (-MainCanvas.AutoScrollPosition.Y/Zoom), (int) (vpWidth), + (int) (vpHeight)); + + var viewPortBrush = new SolidBrush(Color.FromArgb(100, 200, 200, 240)); + e.Graphics.FillRectangle(viewPortBrush, viewPort); + e.Graphics.DrawRectangle(Pens.DarkBlue, viewPort); + viewPortBrush.Dispose(); + } + + + private void MainCanvas_Paint(object sender, PaintEventArgs e) + { + int x = (-MainCanvas.AutoScrollPosition.X); + int y = (-MainCanvas.AutoScrollPosition.Y); + e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; + + + var visibleBounds = new Rectangle(x, y, ClientSize.Width, ClientSize.Height); + var renderInfo = new RenderInfo + { + Graphics = e.Graphics, + VisualBounds = visibleBounds, + GridSize = GridSize, + ShowGrid = ShowGrid + }; + e.Graphics.ScaleTransform((float) Zoom, (float) Zoom); + e.Graphics.TranslateTransform((float) (-x/zoom), (float) (-y/zoom)); + renderInfo.Zoom = Zoom; + Diagram.Draw(renderInfo); + BoundingItemes = renderInfo.BoundingItems; + + if (EditMode == EditMode.DrawRelation) + { + e.Graphics.DrawLine(Settings.DrawRelation, mouseDownPoint, mouseCurrentPoint); + } + + SetCanvasScrollSize(renderInfo); + } + + private void SetCanvasScrollSize(RenderInfo renderInfo) + { + Size newSize = renderInfo.ReturnedBounds.Size; + newSize.Height += 600; + newSize.Width += 600; + + MainCanvas.AutoScrollMinSize = newSize; + } + + private void MainCanvas_MouseUp(object sender, MouseEventArgs e) + { + var x = (int) ((e.X - MainCanvas.AutoScrollPosition.X)/Zoom); + var y = (int) ((e.Y - MainCanvas.AutoScrollPosition.Y)/Zoom); + + if (EditMode == EditMode.DrawRelation) + { + relationEnd = null; + + + for (int i = BoundingItemes.Count - 1; i >= 0; i--) + { + BoundingItem bitem = BoundingItemes[i]; + if (bitem.HitTest(x, y)) + { + if (bitem.Target is Shape) + { + relationEnd = bitem.Target as Shape; + } + } + } + + endDrawRelation(relationStart, relationEnd); + + //end drawing + EditMode = EditMode.Normal; + MainCanvas.Refresh(); + } + else if (EditMode == EditMode.Normal) + { + Cursor = Cursors.Default; + currentBoundingItem = null; + isPanning = false; + for (int i = BoundingItemes.Count - 1; i >= 0; i--) + { + BoundingItem bitem = BoundingItemes[i]; + if (bitem.HitTest(x, y)) + { + if (bitem.Target is Shape) + { + var shape = (Shape) bitem.Target; + var args = new ShapeMouseEventArgs + { + BoundingItem = bitem, + X = x, + Y = y, + Button = e.Button, + Sender = this, + GridSize = GridSize, + SnapToGrid = SnapToGrid + }; + shape.OnMouseUp(args); + if (args.Redraw) + Refresh(); + } + + return; + } + } + } + } + + private void MainCanvas_MouseDown(object sender, MouseEventArgs e) + { + EndInput(); + var x = (int) ((e.X - MainCanvas.AutoScrollPosition.X)/Zoom); + var y = (int) ((e.Y - MainCanvas.AutoScrollPosition.Y)/Zoom); + + if (EditMode == EditMode.BeginDrawRelation) + { + mouseDownPoint = new Point(e.X, e.Y); + EditMode = EditMode.DrawRelation; + relationStart = null; + + for (int i = BoundingItemes.Count - 1; i >= 0; i--) + { + BoundingItem bitem = BoundingItemes[i]; + if (bitem.HitTest(x, y)) + { + if (bitem.Target is Shape) + { + relationStart = bitem.Target as Shape; + } + } + } + } + else if (EditMode == EditMode.Normal) + { + mouseDownPoint = new Point(e.X, e.Y); + mouseDownAutoscrollPoint = new Point(-MainCanvas.AutoScrollPosition.X, -MainCanvas.AutoScrollPosition.Y); + + for (int i = BoundingItemes.Count - 1; i >= 0; i--) + { + BoundingItem bitem = BoundingItemes[i]; + if (bitem.HitTest(x, y)) + { + if (bitem.Target is Shape) + { + currentBoundingItem = bitem; + var shape = (Shape) bitem.Target; + currentShape = shape; + var args = new ShapeMouseEventArgs + { + BoundingItem = bitem, + X = x, + Y = y, + Button = e.Button, + Sender = this, + GridSize = GridSize, + SnapToGrid = SnapToGrid + }; + shape.OnMouseDown(args); + if (args.Redraw) + Refresh(); + } + + return; + } + } + isPanning = true; + } + } + + private void MainCanvas_MouseMove(object sender, MouseEventArgs e) + { + if (EditMode == EditMode.DrawRelation) + { + mouseCurrentPoint = new Point(e.X, e.Y); + MainCanvas.Refresh(); + } + else if (EditMode == EditMode.Normal) + { + var x = (int) ((e.X - MainCanvas.AutoScrollPosition.X)/Zoom); + var y = (int) ((e.Y - MainCanvas.AutoScrollPosition.Y)/Zoom); + + if (e.Button != MouseButtons.None) + { + if (currentBoundingItem == null) + { + if (isPanning) + { + int dx = mouseDownPoint.X - e.X; + int dy = mouseDownPoint.Y - e.Y; + + var newPos = new Point(mouseDownAutoscrollPoint.X + dx, mouseDownAutoscrollPoint.Y + dy); + MainCanvas.AutoScrollPosition = newPos; + Cursor = Cursors.SizeAll; + } + } + else + { + var shape = (Shape) currentBoundingItem.Target; + var args = new ShapeMouseEventArgs + { + BoundingItem = currentBoundingItem, + X = x, + Y = y, + Button = e.Button, + Sender = this, + GridSize = GridSize, + SnapToGrid = SnapToGrid + }; + shape.OnMouseMove(args); + if (args.Redraw) + MainCanvas.Refresh(); + } + } + else + { + for (int i = BoundingItemes.Count - 1; i >= 0; i--) + { + BoundingItem bitem = BoundingItemes[i]; + if (bitem.HitTest(x, y)) + { + if (bitem.Target is Shape) + { + var shape = (Shape) bitem.Target; + var args = new ShapeMouseEventArgs + {BoundingItem = bitem, X = x, Y = y, Button = e.Button, Sender = this}; + shape.OnMouseMove(args); + if (args.Redraw) + MainCanvas.Refresh(); + } + + return; + } + } + } + } + } + + public virtual string GetInput() + { + return txtInput.Text; + } + + private void txtInput_KeyPress(object sender, KeyPressEventArgs e) + { + if (!txtInput.Multiline) + { + if (e.KeyChar == '\r') + e.Handled = true; + } + } + + private void txtInput_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + if (!txtInput.Multiline) + { + txtInput.Text = originalText; + EndInput(); + } + else + { + EndInput(); + } + } + + if (e.KeyCode == Keys.Enter) + { + if (!txtInput.Multiline) + { + e.Handled = true; + EndInput(); + } + else if (e.Control && txtInput.Multiline) + { + e.Handled = true; + EndInput(); + } + } + } + + //break out to a selection class + public virtual void ClearSelection() + { + foreach (Shape shape in Diagram.Shapes) + { + shape.Selected = false; + } + } + + #region Property Diagram + + private UmlDiagram diagram; + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public UmlDiagram Diagram + { + get { return diagram; } + set { diagram = value; } + } + + #endregion + + #region Property Zoom + + private double zoom; + + public double Zoom + { + get { return zoom; } + set + { + if (value < 0.000001) + return; + + if (value > 3) + return; + + zoom = value; + Refresh(); + } + } + + #endregion + + #region Property BoundingItemes + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public List BoundingItemes { get; set; } + + #endregion + + #region Nested type: Settings + + private static class Settings + { + public static readonly Pen DrawRelation = MakeDrawRelationPen(); + public static readonly Font inputFont = new Font("Arial", 10f); + + private static Pen MakeDrawRelationPen() + { + var pen = new Pen(Color.Gray, 3) {DashStyle = DashStyle.Dash}; + + return pen; + } + } + + #endregion + + + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner.resx b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner.resx new file mode 100644 index 0000000..4849bc9 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 91 + + + 17, 54 + + + 17, 17 + + + False + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner_Layout.cs b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner_Layout.cs new file mode 100644 index 0000000..d259d74 --- /dev/null +++ b/WindowsFormsComponents/Alsing.AlbinoHorse/Alsing.AlbinoHorse/Windows/Forms/UmlDesigner_Layout.cs @@ -0,0 +1,20 @@ +namespace AlbinoHorse.Windows.Forms +{ + public partial class UmlDesigner + { + + public void LayoutDiagram() + { + //var g = new Microsoft.Glee.Drawing.Graph("My Graph"); + //int i = 0; + //foreach (Shape shape in this.Diagram.Shapes) + //{ + // if (shape is UmlType) + // { + // string id = string.Format("Node#{0}", i++); + // var node = g.AddNode(id); + // } + //} + } + } +} diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox.sln b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox.sln new file mode 100644 index 0000000..1d4c826 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Alsing.SyntaxBox.NET", "Alsing.SyntaxBox\Alsing.SyntaxBox.NET.csproj", "{19EF75B2-B414-4EB0-9486-160FAF93E62C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "Samples\HelloWorld\HelloWorld.csproj", "{FCF83FF2-7D05-4301-9CC0-09234A9ED0DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MDIDemo", "Samples\MdiDemo\MDIDemo.csproj", "{2AE13325-8AC7-4AE8-A835-F434DC3F11EF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {19EF75B2-B414-4EB0-9486-160FAF93E62C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19EF75B2-B414-4EB0-9486-160FAF93E62C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19EF75B2-B414-4EB0-9486-160FAF93E62C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19EF75B2-B414-4EB0-9486-160FAF93E62C}.Release|Any CPU.Build.0 = Release|Any CPU + {FCF83FF2-7D05-4301-9CC0-09234A9ED0DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FCF83FF2-7D05-4301-9CC0-09234A9ED0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FCF83FF2-7D05-4301-9CC0-09234A9ED0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FCF83FF2-7D05-4301-9CC0-09234A9ED0DC}.Release|Any CPU.Build.0 = Release|Any CPU + {2AE13325-8AC7-4AE8-A835-F434DC3F11EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2AE13325-8AC7-4AE8-A835-F434DC3F11EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2AE13325-8AC7-4AE8-A835-F434DC3F11EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2AE13325-8AC7-4AE8-A835-F434DC3F11EF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox.suo b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox.suo new file mode 100644 index 0000000000000000000000000000000000000000..48347117536619a1d5eaf91beb0fbfe2ad0a64b6 GIT binary patch literal 141312 zcmeHw37jNFm3|JFfC>nRfWQnl2-D2T%y3R$bHH3q4+FZT&__*A4>es)SN9xTA|e6; zBA|;Xh=|G};)v`nx~w9Limr;gi+JIIDB`ipy6fLnSK$AB8Tl$AvZ6Ahsx!M=cd~!4 zBd^MM5%J>1doNzR_~zrU`tgT8b>P!M>^LphF?jK%-GW_=`#a)%id^p%1UulI&tH7$ zrI+OPWjw)4xV8QGGpK&d>;c#l01^mZ z1=t&~4`5%ws{#7~UIW-4Z~)*yz-s{q0S*Qn0+y530MSJ3|InK3OECBCSVz0Iba1~C7>JddcbNx7hnzGEWld8*?@BZZveaz@K=BW z;7x!bz`20)0R4a-Krf&VPz0<4YyoTloDV1i1_2uZZw3qiJ_C3VZ~jD1BF$|0dwm8&ZRM zuipQ|kU#q%`=f9EJK$aRc^;$<7nnR?cf3bF!2bWr=r_zye%EOKXWyO*m==BGFr@6; z@;&x{_O*Ebe+KuY|MT4$xMm-|7Zo}iDeuii%6`xDr;#oI+>htd|9M~fKhIn7oc*8Y z(*Job{h#O3|9NiqfAXJ3`~T6vg?*U)pWo|7%Kp!D>Hj<@UsxaA7e2uI@!|UC6K3h8$}YZzYq7yxLSZQat4047T+s`zZ^kY z!54aws*ysMxCg)N#~=CL+4$ZF-dc~VG~UP3P6Ph|IfZn_l=spO@_!jCSmS2?ZNQ-j z9L~omSw?9%CMDr<4Du&GW8OT{^5%2aHDv@I@%%adknav5U)JSdV(yex8XtcsX9@q0 z=f5Z{b06BXj8)wLCf6q2jYqx; z8=Kzq%$L;Ki}JG{7Q=p~>NxE`={J6i zH`+s9z&CA_Fe|*l~&%gK|FY!K)y#VAH=KaHPeL8@$=W^g*3bEuU)Q!62 zSTt0vL26y(`IN%u;QvLzOpH*SsOx#bT#Tf%Al0?u$xOg>Kqszd;A{cT=R=yCjwdJL z&LU`Qi*R=~-Z&AzYKJz{g1)vn9Q|~@D?{#W=GvNhuB*{rq!VfnMQB#7po^`+G~l!f zIz$UNU>lyPk+cnO_5lN33#_?pYeDy;#&AiZKhcFc!jg0Y=h~wM^#5Vprhec{|D>mb zqEB(0BgYgPSN&`qsJqz zZBa`Q|Nr&V zXb@Rd}9UST2(pKIQ-DuG_+RK9@!{t(?(AhUIvUZ@jxq1>kX&Ek7X!;9wIc0FPRHCH< z$LjhYUyt&~M;A55&O&KBQ3tc}H!JMN^KqvgV=j9%pUuaal7~0oY70iq66%Ti*KjnV zQr<~EX#XPbqurNj^4sd^p-6UT#o;&$l)zlOLz%g+ijR`I>Pda-xBTA>|26sF63}8_ znD-#cTmm+WfDLPuwcwTil>LDRWlG=joB6K{$G%e7BUGTf*MZ)1Zj~z60JBlxG!o*@f0X~pL0EPk)dvYD zX8Sjme{Jg^|7za8`BPWgJ0h&M_O4a;k3N6Ez7K3$ar2e??fJ=@o<07mRha*1>uPVq zd)i8rW*4jFt<;oE%URkREf`5UK@lxz`wF;`ni*Jq()&xLUpywtNLa7Hx}80){uukx zOKg={;Bj;DeN~_-4p%Ph zi>_mF+p?vn<3W~fs^wSe%muWdlGrzaf33o~vfz=Is#YZqi!#T7b~?^ok#iG^){uAb zO3msNLO#<|o#i3d+hSnUl{-dV;pj?TUgUgQmpS5^_gG^be_0yQMpUVE?Jda|SN0)F zWc|ps5avpHW{q}-SEM#I8Y_EfCn%6OlS^x?I6s;tUB&g%LP$*x6o;>Vv9IwEegO49r%xdt=tMvj$kurp7);xt!EIfO%-uZtWP~N#keX4O-fW8@YWR zd?6VVjU7kzBK}qYU&?(NBT7nHwwJQ*DN5mdJMDgE4RmLmUu`ckXS7HYw6w5&#LA+$ z5_?wTPj$U*#X?Nk= zGcjYY-BOj(be$~A9S78JwoX$`hhFk%I>lDyBgR0b!Sq}aLAQMz=^wIqu@+u0kucI zC-c-AqpZiPT8XY6MrVhZ_8C1a|JqUGCu@W>wj3CcvN@*fal(}7v&P8eiUruJsY9tz zy9f@n2K3Tdj>v217 zGd&YEwiSGqvtZO*TSHwz(Uxw}{QIqsq_Y}WZVpE-rW!l?S!daA<8@?eQ6_)QTA!;O zeP~USG1}Gu?D5-vrfVi^n_s+@;+9eNKUyA@O_UTaR#S~r_FO8i*O~cJ`ZBLI9vvA| zOC!JX&RO%2+IElMF}a!8ghZMxKub{;OpW2Z%xl%w97RhsIqT~)&Qn??E>GE` zF0~@N57^IZd+p?~<#O(c{g(Zi)?M9pD>JUgI4x1aPPWvV7E$wD<9O~Qz)|QUx!0bB zvBW(CnLP)z`-sxK&PN;5w!9dlYB$pLXmQS8>AK9Cn@GJR_Y3wLHOlJI!|pj6!-W~Q zwmGY1&i`{3vu6vyCr;Vx)6l!|uXiT%$0rb3q@@Gl%U|9?vHDI)9_ShtIC9RRT`qeoZ zw_>gA5WnM+Ol_TC+d1oLyjfdy;yBV{&aTyTtZTVu);%PSlOL8c|Eu~AXM$@noeXn! zf~Q++O?p~eo~$(so3oHN)tfPJ-?x9SIaAg%Wxk`D_#LKBiWt{7vmz*Y%e_zoefaHB)-!nJdeQQ6E}eKaX=U zjU}VnWGiLbJlvOGYHu3St@J6bl~pCw80SBi6t6AUIF#fY!1|9%CmR2(=|bu%u2I-} zB5QRCXktsE9Y$lB^*HK}rLxTXW1634t~C;^rPx}Wu47`o4nR+^L1@ROziHO9#kwwC z80vd6;!MZf(<;~zbn9k6yRWSQq%?Ex%bxkFl^e3AG@Bn28?i3de)HPp%VPxkKV=M)BG1Y=|JvTV2D#F=z9(jNpuFIIlC(l1Yp%>5 zAfAo1+KNZ6>KQU~t4ihe%gvh3;(dYMOxi<7TTy87Cgz;uNcZK*nqSvq8NXxp*ZT8n zwcIA_9--Qly-wBuk$WinypmGw9{GlhdxReMlQ;r#vR4pojby&{p0Z!o)-sK^mQA!o zWy?^q>PvH9#{J7uLum!A)3=X&q=Y#(w(2@?Go2%&3TByO-0I9(MSJy~&O7V*lUgn+ zD+EgD@s&__lsnRc#GazD%38**#mba6MDj83Dap*_v36g}Un?}RaY;LI{VRU$nyJz? zob?LcbPq$eGRG*5L)MnD+Ey0IqBo4`g{*AR8WYCW&9Vo^M-*GqcDH6)doM%%srVM= zirK7ngj&q?+yYn3t^hCD9P;&Af3WeVsa3#+9<;h8v!LXlr#I?~9;axsJM~*^f{2OOW~+QtBP6)s^T}w+KOZZB>ohmvG~TnITG)lrow(9 z{vV?ZQNpDkF7;aKkd!)#hzXQ_Nc>~w%_IF6Y7c-Lq8F3$pY8E6$^SsS>zn_1c=x^X z?N$UjS^&f6d<42-$Rh^aoEZf~nvaQghQpbOuznZg2Qz0exSKZR^#w(8G~dYCU8q-C z2}HiR9Co3w(!zSPB`qbzr^mx#oD}A7#uifc3fkB0`z?5vp0#SVR_!VtV!+uYMF;iQ z`2@jDZ@BxKy-*<<`$qE@nc(6~@m~RICQmfi1SOTDZ|Atw$mn?-tNM_}eOg(YeP}_| zSEv!v8afjE4k_#I{IKpeg)3ROj-`O>B34gRdsMx7Bi>gr`rNHu%dQitXaxgjW$^a8Zl$~sFf`7yGfMO3k>de z(yrNJzP&iT9^8>iG%IpxX0>{kiaUQpl_p4?tZ^0X-|oZtl*6V%Y0t}1n-5KJZ3;&s z53Ii`-|c^`#`F6oxCCa4x#_`-2BP*Vx;284Cqw8jC=s^7bwb3^YMtTTf zYIJ=l(!-+jBaj{mI4Zh62I;YY*G1RIBb^?dpMZ1*U?yNzbZ-vQxquU+>-k6*08Wao zPeFQWbk4FY#Ca>AExOl%v@<$ijC2WLDd3Fg9)GhO=PLj!0jrGreD>#f*xYg~@|qvN zQk+%uSmCFfyL+#LKQ)VAe4LYc_QpM2)!u)XXNa3{Y4YpZ2#K}#q>d^X*HOI1;_PoC{p`!imXVI6T~Zr(>i?e})YIN&2QqKe*Xy*1RXlb2#nB!?$3$h5~sNWk#=`lD@H&~GWVwT;Vd{?gsqrtH(CT~YY-k_ z5-+nG(lgf^sJqfrOX#V2O6@jRY}78&2JEubdun;D*^+{t8NZFPDq|PX&P00zz5C5r zxoQtqm%M71yb&t#@t`#ER^K-HkV!+WsKc9`G*tVIxE0d%Mr|E7H{+#tp52lmW=pI6 zC*79`vLxyyOKw*?Mx{rLR67RWnPDB&ViCXN(#~Xcv5x2%q7q4Ck!Xo~w6fSgP9o+su4= zJ#MoZ7_ZL|Thn7V9{WS>kZ^s5xyAcRTvl-TJ4xS>_BsqTaA}4(nKfWa4E19cKu6BF zx7OB6{EmyO*sF2l9EI!P2c7klF5CF(CE}+dZLgd!)G{imLrOu5^~&#W_rC zXA5k8dM-hvig;_p>6V;RNxanA%$NvjFZ+D;*=G2Q;(ZIzUO$QI$(E<;$!hLM<*=4y z-14k3^y-UAaA` z)ZVXmWr)2^!_@aUt3p4UvF(6^ovBdIdF$3bnA#;2%BNR;mUb397o|7TMnO*s+cP>Y zG0_u$Ta_o;Gu^Jyu9@-B{7${OG(E1m-iXUD*8=PDl_gwz^#lR^$+EO(HY!`$D{DXab92Rf#Kr*w(Kc1e-i5Ifjj-?KTF!digwuwRwV|(d4Mlf>CLu7PmHve-tP3Us*Rki_JJQ? zNy%P$p?1QQK0pqgwMSI#2xg8NqH&n_l#Gplw^9*mdSe! z1;GKp^!5xTs#;8S)E45T_j_Z_^`Ry8^Z0M2HV*}k`C8d&-ETH}HfG*|-y5BE$TB9+ z)KEX>8(ewCnTGzV9Z>dU3GgHc?r?tJqyo|9(j_FDW|O2fw_a=iURsGOShBQc+qwA5 z=E<@A;41+RGkCO*}Mcd#C_kdfjkW zBhfrnD+oS}JL5mo5}$qIik1PClQ9Fh8(4e=g>Zez?Ly@CW@lTn9LeLG_#D`t2<`Ah z7{=e$>P**0g!auGu%zZG0!?AUGVDWhpJzViv#Sq9n0%=~;E@ zO)bDLOV5XTbA+zAMnSMs=G0?rwsF2}Kb1P*s*uv|i11msdHtohf0- zsAx(P?)kY|UN1d5ZX4B@X}OV6XtT65%9xnu)ft~X9R(g)O84$Z5V%%6 z4lz8df#*o3trwT>-LYqN;cXm_8#B?)->il>t@nEM+n!B+{rd{>HGTu z*L$7yWai=DziKJT{Eiz}@`L)CkjPwu@xj1&;$;(al%Y0E?}B3A3|R{^X8HMih-Cn$dkn@ zRo?}0@mY9d24F7!&%@O`+$9xM@LOt4E%!# z{^H|@o9(R<$4C10#8S>HP$PEF7usTf=P^0@{2st0j;9_+OqCcfj#QSEW&Ymas9-AT<1Bn1wwv$g#X6S(|-w*G{R>%!ogK5BURX`b49Xlgghc_tOkOOu= zT57}d#lgvtnpTJ5mgrThyqQl%=%sm(lxE_oI-3eZ``Yi)?qwcXjw-V;md*v1eZWHRY1|T( zY&PUa`oS@B7yVBuL-OFbkq2#vhQw7QrgW&+g)!%uz#wa?G;@}ii=1uEIv;urD9?sr z)Mb)4PW|$8hA6G z_itsD!>d(pJh9a8r~OYJzCk~gxE@=}W!R^9OpeiRyXC^q;%r+agg2;b{xV-&SBQI=Er&L`G}K7xb!J;D zu6h5teY93k!f@qidaJo4NBRM^K(poybP#-{c+kU)d?=C5u*R}7FxX${+B!JWy``#SmDx+V3$({M@uD+ zO*rPZpH%25ZYp%GU14O=)xB}3RIC)1_YHIuH~E=TC7$+Ymf$lA zFXJoq5p5kEDVGK+BL$u;!^xuZ@J2U+;txTI)AUi}NI|Ky8@3afZ+Exic~PsFBe?D9 zll*(;tb7gYdA0qr_m&^L3RS|YpwWL5d6QR=e>tfg*4rm9&Udr>%e~Ym4jz9CO_p&T~hiiF9+R^f&(*Z{nC)D zm@y2;>cKXIuMdJx(HkVbMnO0VXYZvo$eFYBR%5>8l(ch|P|9rfU=0w_TYJgJxwA>l z&GLyjwfcG4xx6l9or0?cq}Jbo(#Q(ie6Tl1EY?@87n+}ESKPzvAYgv2Q}VF6O0(?{ zUpryO@*&2QMCnq9_d`up?U5(zk8GTcwg6k!~ zHSbtMviqatIe+HCb3Q8 zG~!bWas9z1d98)qs^$Lck)!nDeE1Lhs*WD2I8b*uPdZ}xm`fcT3yhle33lykQNRqW z_-1yac3tmC-qbMiU9-e-UVCP$abI7{Y@pz?9QZs@<+1jy${ZK%MWnoOljN_(=nDf?DeQFM zl5eablaHw0$dQ!Md(=)o@ingTYuBnGsma#@ds)LD=U-+UHZK#zWy)qb?Nz|k-P6gL zlh^0zl?S9M?GvxOzI&m0Qz}ssFY7kxEvdP6z$e=g*R)V*jB8_%o2y#lD_9o(=lzdU zv)>s&|Bzh)y8*Nw6EX5$RN5fewwhWGg)(>Tn$#y_xk(xB-rXqv@fbVb|MlGO5`P2l z)G5%h>R-*&e_SS7x9RcQV)d=fPd%t}s_-1txEPm#5M*G7fhuYLIc@_-Z;qq``|nlj zi}jZDt~^_alRKh|wEVd*K+?he|1QM~?5V!_(`)3$=%Z=*&yC)zmo!s;?(}%MXa2Ml zCmk&RWq5(#^DY0<=zS!K`ybB4tiDJ2r(751?VJA(Fil2V2an|Xr@uk+(MRkP7g%;4N$<+DXOREx(M4MRwA&{g%>Qb02 zn>3bj#9NIafV-b=@f!7hx6k{}q6M42qntMmD>|&}EpHi_n-*EKB|6ftA%BrSdcv6> zJp)tEml$zL{`iZXZ7qY+PQI4(^zkc>Km9OOl=H#Qe&NmZ;jtx#xMU#OWvyi>e#f=y z*Str$MkJusP`9XP$^P#3_g`#wtdC>oH~%ED9hmD-h+{JS&w>V+e8~8FO9S-x3(()T z=(B10`;5QB)qLsyOWyr|mY4kTZj|Mw2Fm{!@@K3e9%<$G(7!|eb1S~(TmFAR{v%=T z_538_?kYF6*WC ziYg#VX!kMKOYM#8cq!F2bsJj#$TQ`biWAq0syMgVQuED5R#(xk){1^R1RlpxzYI^9 z?ELDRUu(ra>hdjf^R_hFigPx_&*@Q1TSRvGq_5~9{biS5E%oG8vSrceGm4aBkUd|- znxq9PyOOzADN)B~R0u}M=nc>7$rjnSZG44PZ4IP`oP(I;(n0Rj$eA;S zCQ>F!kG67QI8xC6Xnm;Ho`v2y5E}T!jC-}+i^Nb@duEqH{z(f&AMA}=VGSsvb!r@I(03}ph18d1qqU>$bYeA)b`q(zUMN2` zZ7rtF(|k)NR^l-n-TOz9^LGP3_lR$fy>>2Qvo+sv&$PyE3HEo~er;xXTyHExU2{*7 z(0wVaWtL;bIG00Np|~o9QJ58;_5EduVV4s_TV6`9QAKIy#F|-O_1ZtKj|*?%`tBs^ z96NSnnL*$jk=yGzeSS`60^)v=wcdY8z7laC)P7);HsgGXcyF5YV)w1F^wD^)HD_5Q-m3TvCwULk0&`x(UD7d48@JpRm;fBOd7n(F zTlQl5h|;H&Jk_4vt({FOBF`*Gnc7}0b|zxQ5xWPRrUcA7@t@MWvVRLrtOhhN)s zKL}N%)wN4+W7OF$tV$q8^qv(bM&)~PnRh#zlu&QfFe4P&y+ZYnm0|R>BJg0uTQ$;h zZuH(vv9LY)?f&H&ne_alwnw_|3C8;X;}1+Q#_qk;1j7S?;l)l2(>bt9N>h=x>1S`Y zpzBS+pbQMM;~{a*Cb?XMT(XSxUE7~)cfpZ6vSLqqyx{Z(;PmI<9XJd;WgWiRx0S3) zIoV!m*aCVI-+fohv!7AEQLfUiH>8G!kaNBxp~*YlJ>Hfc;?jm-It`fSJ6t7^1lXu3F{$qpR ze-!V37Vr;%hXKs{D^bexFW~$Uz&`=L2>3GKOMu4!d%=veC*YrP{x!hY0gnT|0r)21 zUjY9KcmnWmfNuf54R{jp9l-Yh-vxXh@B_e8fFA;W1o$!FCxE8`&j5Z3_!;2mfM)^E z0e%JeC14le@N1<14)_nie*&Hd{08t}fd2;kKfrGRzXSXp@IQb*0R9O0U%(51KLK6@ z&`F))Yj*?;!iGQ|Sw!4^wQH!*<0iayVTOG)u4~xWq)`|=O^dGknqJ9@f<>fgLd&VRO#|7-9eeCHzo-~4w%{+Baz9Lf35@$tW_mfbi1 zmmz=hMIMxP)}rs*GLo%pG%^m`qo1j{a~4u*N>@iYr;qD;4725&S}O{@P3Y_5v!aC7 zFxo})vpc5y7E!v+FaKJ3NGwV5Cu#IICv2WRBbLW7WlUc!^Wnn}Zp^cBG4-dCf#_ix9z|9&wvPt0-4Kj9@l!2zpDn z>kRx0c0>&X*q=uEPjSXp-cf$x8=?`Ez6iSpN8#OzFu&M}Z*z4Y=Ng&&eB5crnh)+S zz-RMu=7ZbGcxxzR_-%XVV=sH`+Q(kT$~$cO%FWhZ zMaqLg^(R=V{&DmEq>$YJF9+-oH~?@U;I)8*00#pO0f^Mgl{ZowDuQHvTXgM{EN5L< zKiXG^eU~&v?EK?vF6sNoy;D)TT>&gPORP)E)u8u8{6=ZdW8Le!+4bAL9J8Kv@mn7| z`VO|Rdsc#VmppT$^G~x3w1qP{NpA`D-SqP_{`+NCecM(M*W5$1(U_W@`QP_vpST$v z%%BMy$3`tTZvK&F{U_DDSS6$dj=%Nq&ahj6!HQhmOn6nZ^{?qCdBhj`6%23s!{8>; zE&1KffL#DK#%e@i4f=4Uyz#dsmLRzL(AWN++*R|G5sX}%wBYqeesE#UKPXN#OGu@Yh*sp8L57#G%&Jupt!lvC1>sH2TFZW zD0_D(_~nfSnO6bw84bT0DnIe_MX%3ylzT@v76(V7k9HK-4Ga#943q~8Yl>S&x<2^>}3^nK=B|hu1*@UjuxGz$NYLTJDoC4aWN~M;+x6sq}+#HL3$^ znszY#JpNl-RSL`_UJL z=@m%d9-Y4f=~dDBHAvqXonMFadceD)>vto)5pYv<{T`(61^jh%{XV3(0^T28--h&d zzz3u24vejjjsP5>4SjJ zMA!d-^dZ1MM%SN5`Y_-N(e*zerBBQkqw6mteJncvD$;+B&cBZI8_~J=0J84>4fmdi z?mvn2+tK-Vk$x{ae+uajqVpdi{c&{ulPLWu(gR>6eHQ7@qkF$V`pf8Cd;pmr{r~6( z$aC=l@TFGOfr;w&N^`NTdoYD~NjNSCzkH66fr3yAd(ttVuUUFqy$f zwjUAa$)f+eB)zk8Zt1v3YP^O`{Zr=o#ov>?bqIAmXh_OSbH>+}l+D$G>bxtI3)TTE z#vRc;CSSag`AjzZ=Ot24J6{rV zoIcdLwz{(nr{r1&wPUb~DfIv5W;%sFR?TtrL+oAIrc`VrZ*@96l{3i($z+NrjE7K|&M)aJiYE%q=TqOB1 z%VOA>_)G?xQ@(3L zBUf!btLK6rd6R~&cJ4y{U#I{6Pdi^SrTqgB?{@eZw}11gdk!UU=xT38`J1&C#N%YR z_b+wbRg&*eDD`Xzu6$_VUAI2{7#Dq34@TwQ3s+n@MQN@ZJg$gn3$19It-&ie?1n=YS+@#uf3DTiPr3Wl}Y9EbI;kNAFeqSS#o^G6npF@?O}Fj5*|Cb`wO*^^uFbe>OGzszHPtqvqDTB{<$}5xz-v%TfNC` zNy$7W$B4Myg5qcSc3bVXTTq&xNvLNH5f1y8Zb9+cA53wIoss0S8`uu&`|`imULa4@ zsywkpP`m1Ze&3Jzq3w1Eweo2!`YWa2?RE&Y@>tEdtCh#w?GSF?v_@!cyB(r-E^;B* z+IUK}dPYjdHdC9~Zih&+LoBPd6-OP$9mq0ro7f@D5iMO$(iFAb29cd_iLO=l4r)i+ zZ4lyjQeHMNSacWRG_NA88ZHkNhermAmBQ*`r93*^TdcUh*C@KOgxpw6 zULG77E|=V&@A5*oTFKQF>iYAmx`(j@Jh93bRx@#Xx5e$T+wD);dJmejav}+Bw?A#S zKTXcj{x9AB)X}Ltc#fR?^y|KS&2wkmJ@>bBo;v+i&vziu2t9ZhQzR>|jOFm583=tE zRQ#{_9`l^7R$ek2f@xPI2 zI5G5~R?%{DvE9*$$vEP+JI+PKYq@qWcKN_moVcuewX4J8-)zL=h~8AKXy+mLx6n7e z9Ar7)+PweKSiJb-wwO4jr+dxRU!`hlqJEa3cYB9@iblF&7UO zy@F*fXeKW%#C2xz{p+*z(uuc*tcIyAWuA2$_l~N~J=dS3*Yp)}e9J!#`QH(JRA~c2 z*v?~(CEkrSR}vG*j>Evn5-O67YlqN!PXsr{Zn!+sebX%g<{K{0c^$=*XXW60a0|V& zgX^B)Q2`!V)=^v|jK|YyBo6a&z|9>?z1DJNM+|q@kvT&lZO4^sysy`^F}A1MCgI98 zO;>gKAgl#N>7BlR__b}99)yxgkDJI{#~)fUJs|hixC8+y_11xj@jmF|w zn|nsM>b_okKF~n>rT45_iZ*dkv_o%KMsZOQYHe$t>y2gTqusEY>$QK_J?`pX|CV-L zUH2p5O4r8sf7sAK`P1k(*@g$}-SJ<(n#Sr^T9`|uEW0LzkEYf6wg&KbeM{#~jy;T8 zj&lcnU&k{_iaJPMpY+_0vK_$M83dO$)Mo_edYsE#rDE?cM2jDz@=FXE;q08>zAIB4 znu+X{zNb`x8I>&eqwfrK`1wLt_r{?T{2!JSOQrJJ<>69a!QU%lMb)Fg_+o3RGBDWh z3bDVs*pI06OS%X9O2uJ#To_kww}_MR{f^?MLf6_AMh1fN^1gwN;>L2JXJ8O-^^Eox zI#zbIb&vF}Z>ek@M3n`*oH96CDsh$tN2l>Ig=4}ulj~qhhE!ulIWnVUFGsIrtWQQ- zm8eJ9F?#OQ<4L#Ni9+*1Qnx9Gx%#~M24^Ejs!_kBKWxP}o86g0`WE>$tq9~QKl3LjfSlpW-jn$6OKGCjhdwHYLF**?)gQGrINtp70jB)XC)wPmBMIbKY z8>~e};NncV?Hg&*`q*>gzJ%NlMPekxXOEI16KG3VRyYamCPzeQ1GOl5+&5p77t}_E zvun{Mou$7a5w?Y*FWhq0*GNH{XANW4lY6YDMYvR2>OEEo)1smV0cR91vwo9Ai)OvK z<%`APD#jjAAtMi7h*Zn6OW|qIiKuhTp%0vIb3~_VpP)werAe3P;}QmCuJqkY)g02r z8P-Rm`#W&Yae|9ZwXA8kgTB8AR5BP+i_#z13XI~X?h1{Ski#v`99;az&dc>i?O0;I z#h5r-oV?BconXgadi%Iz7vFbxQADNmf#AwqGiGam8uim;Z-~l4-jMa0gxaynto8U) zsogK#-150?z+Us0AXtd&cIzH3g>1Das`%UesS->>jj$I_3+>4xVK3(xMp>p6_cw<1 zr*;oelFskY|Hu!|M>>GoAYBaO%>w?jcKEKMTE_nw#(Vr$Qkl{@vW>OW!D$1>AN+Zg zmp1Za0kjTrW?R<@%g?-J|F=BauW`=s(?yGqq{Y|9lcPK>D=v=l$fRmNk!a#2CvWDM zz*P*x!MTuyJ75o$)_U~12cDc`mD+z+^`q7DH`o8t?9cOnSJDCdbMQXA@E!nLE$Ll( zb~x}Uh>WVbmaeB^wII9f1&k#fBDqUXuBlF zJc5wd)2btuCRz;!g9~s+`T20(ggi*cVODS6on!yEwYRve-Y6H`{hQN|vpE{Mpwb-8 z-s&EU>)|q1{UytpmwNVV?h4Waot-*n1%KvD-qxLN{s!m6Y%6v|oF2*gsQt|vOyYM* z^lsuWR%~r=f7>s9({o6K=`Kk30VwMA<2vrbWLf|IYaFPLRv=*|%b#hypCy`xQJv9w zrvX$?#!1T2i|0P_?}AkCqaZj8{C^X^cOk$x|8;oxdH|0k{+~AX@b@TxIR4P4<(vNi z-o2JT#*vi&iRzWa|B`q@sJmi=&-u@8B@_mKWW;h;y<+A z922!7lGNiOyy3(Dxq3Y9p!_G)!!+%EKED)jWAtKj`O~bgs{BXdTSo(Y^M5Pey$rx3 zIsY{4LzsWH_xR@jHsmYvZ{dr792|=jCH}uz=wEUA6TZG)?k@7-bUY5Av1z%0Mau=?gt-S3-T`KL?3&G0|U zem{=#4}v${HtpV>aYgKTR3CVqWJ|yH9EfeliO)vK2zLMa;78klE3HV=0MtZU0i1nN zC1RQCmFuBQ`A0JTTscAc)%1QBpK2X}L9b8I_s)VAEHM-4Qy^tu{gH*8yIJMLMMH_Pjd}Mvtjss8<%0Z3MKFgo)s=qYu zMh&Mo)Xur?QlH2B_JRL?`+LawYRmV532#3a{?az{?pgA9vUTaf3C5qEx%BO(Pr@MD zz`kaSkUP^yz5*`>wU4W^`hI5WjE}q9gmmS5i2v3^jlaqK$It#T1BIOr@a2E^R&e9|v}KmCWJ1Z&E-{GY|Uj{)(FmmvUcnPWQ6?fi=r6wa!vBe@t%v=kmgqx_DP{ zpDV|%iA?VD)9bFDzwUig-}AY~ z{~-X6nCGIRBTv-nsPaN0RUD0I>O9 zmg^Yf7JjwnTX}v_Ixa&38-_$ygv`iT2t{Dem3H(Di~m+I|JrxHaaxkS;QCzUPmV5n zO|DCtRJ*+ORW15|ec!6RYHK-aEJt$l81YZ0KR^BVc;K}xq6`O$HMbte9iREP*`EHN zLXp1x?_ZJstr1qq<@b|+8M}BPz&HPI;oW-xJd*RzNB;c|@|E)2{x9+Qn{@i+YOVg7 z*ctC#bTAir#CQeE8$YfbBmFjlzb;MfT>iVRpLbglpNQiv*ZIbS(-?DQv3b=QMhzq9 zTM}xhTqR-p)gOAuJ1+HUfr+XAVMKM~T7Y7e@BL!5_c!!nlfEqVo0d+FmeLt=KtCn$p43UmvfLj zlJobHf2%a>TYkJb-S)`4 zfE+Em>j1iZ-H{zm(RK&MkJ*S;F%y5CNG}0Lp|y_OP;r=xL7RhEIW`S%t_se=^K~Kj z8G$6Z9%tNPHwaD*{qHHqlbSC=&9~xvGx2Rky__3NhlQ&ZUzmrpIpMSUIBN~^?Y~Pg zva0<+mZA)lc(*{(vS$SEymr5Xo7Y2=>EBQPX-ADMiP{KB>hT=j@R5J!gkA;7pKHec z_bYtTNB^3Gc27H)eyfff+AO2w;*bC{M-{r1=OI80;FZl%`TYh2^l`o)_NtTq0k z`+sIzu;n$V>7<##eElEdC31~_u6O~X7^BvqmuOGFkAL{Me{o5eW3`_q^B+I`cM~9&fiP^ow5|)ITPSp{{O|h4+3~3bpt*U&O<2L@$h8esj@p37n)Cp69|bUGXlC-s|-LTmvjPm$ES>jD0y$=80~ zZ2y(=3n#ki;Qc=Bma*+8t?nqxA zoxc+49?|(;NM9A5?}Kz-z^kL{*C5?LIzJHUYXL_B4hAsJ3-g?Y^w8-1aHK~>=SM~9 ztw@grFjf)YKOX7y===nvGotfZNM{4)MAs)Gofn-iKzdSiehSi4qw~{|E{x9GkhTLl zqU%LS7f0tyk)9EqFGIRKI$w!&72x&Jbr(`bcOaf?k)9o$zX9nRqw@mNH$~^?B0VoU z??KudofnZZRt~?j9_avJLv&q2x-mL0BOQv)hmlsI^HHRmqVp|Cw?^j|A-y;{zZB_P zqH{`RI))S1TZ>2f>VTdP{TPLWijO~W+zM$`x8bj6e)Zj^ESEg~c-cRu zbfDGA$w>r01h4~Wk3I-IlJlRXUP}1ijQ+PX@_!`yW^(?1`Y%VVl>p!J?}q$+^uM_| z>A$Z){`V!+X(Nv&UVjlES@z_ikY~m9mlvPh@i>#_&GJpW{vudw{Dt3K^2r;XN#n0$ z)qj)e-_QQB0u{O%;7k8|g8sz*keq)$_K&^2`@f(5Ly5Jkf%5N%{C)fn=7wH%_;A7j z{#PA;ee0j4lKLOJ{BOs5jQ72NpZWTA_4*!*HSy!8jepv_+WtLLuJV~zOK39dk;E@E zrF(LMt&qL!*zD#T*~$L}^jyX%msFR(6>T6H#T5Exr5BoT+%?7ya z@m$-`1FL;MqJ1=Gi=TtKx(L6Sh3|L5_C6=H$xnyXp69cXFYW#v(35G4r@g)vXEX5E z3TVgfZ8Pvo{&ALoa|3-SD>sPpO6LH4`OiV%f44`yASwS7(Ryh|GxFb5^qaoN!rQ+7^^+T=T-5;i^*_e9r@ua}s73U9(S&G|a__nJ>?dD! zZ!L#Yc-H$r1j&C0xtKGE)QwxAfpK35?(NnNTW){&#;&2xT%RAF42qBcxww|j)!f!- zK_lB5b@mO6EGiEt_dh@VXD!P1Mu0E<9|QXLng2TxJU;DcM*ca@JAXg<_YFYuuNo+S z3-Xu#mt6n($iFj@Kj&b1Wb6N9@(-8o*NkDX7^Ck%Rl2zDng8hFTtDqg`vP7K*bhLO z;(=4=k>&iQ;tb|af@|O*Fp4?Lp3ss_iEJ3$gFBAYdm_@(F&lz2?5G;Z@qa-E#N|j)DjB+{Z$9$BH~K(w`TgYIH{o070+RTY z;LG%6%h^El=#N)ph zBLX9A(elCQG=l%z{{8tUIGQC}@WyJtYn*??>pyuPsKY=0?fs^r6bIF5i7e+|UHp&U zLX4NR7XOQ(or3mK`=0UyGEcw$+ux#BEX#X(-LfU~A3y!~&G>pxlmn8~gCp#BqPLRs_tJkG zj(^aJ{2%bj-%tPP#g~(-e45%~BW21T|8?lKYtVa#qVni##&jNrbwb+g zi=Y10(T4;7X$_PiU;R}uWQ-Ma$8GW170ll;I_=CxYaWHfae1!xhkE#{IWxijXWg?t zLjK+e-Gs>F-yIWzzb;oY|Mk;<*P$F6qVh|*lG48d|9NlpLQ?+obJBm`jQk(=%HL1^ z9l*EF2l(>;Zsh*~ul)0ofBTTXjDKdowE3q{_tbq(dxCPX*vmL4rz!oa387yX_ulhY zBOj$_qQ)(%;>09h{;m6&Spkl;VP?cKFl&z_XqeJ74=zI{wR`8C5X)s9mDmWjK1T_Z=R$8%Z0Cb^J{3 zKk4|pG5%5iGk39naQ+~fe#R=lB#%FS_K!heS&1-3l6s7wC;N@R{`QYynP7M$o})D zcW$%(yY1k@vO})2o|`MP1jE}uf8^&VeficfUQIZX=zl>dHjj& zpO5~#z%TwuwI+P?e;e|@Au3jK`Tg{tQG9E21LeOG`QPZ3zrX&orGfl8t$s_C|66f> zIe_x}6-eJ6oxcO=Rnhr1NZ%QqUl*nCLV81Veq)s09Hs9?`q$C<`=a#yNIw9$4RAZ) zgMd2#9|GJ7_%Pruz()Wd1$+!}H{fpo_W-^CAda6vdLQ7EfNjyehokfXq<m=Jqj#P_`Yphd(e-zbem6S* zKGLV6^B*GpQFQ(^(w{`|IcdDn)SpR22uHTB$x(wW@tB6ms*%Axp-Td9gt!5hkZ08Sb z`Z4jhv6s-c^FZ2Y>p$=P1)s7w1ggF^TiP3;gU~RqAIiz(-S$Yr%sqjNVEbf77k+ zoa<8ie;$JG`R0E;^1s<5{{^1w?=Hf(E^Z+IcO(B1ul)V=FX2AE<-ZB}Q(jQV2}o#X zl&|nCdgPIu=iPt0K#dapiPG(o(CWZQ8EQ6={vQRb)KYVrGpjVa?VukosXx0$pAonpKIv#%<9miw|&}e%W;oC)I_-I#E$FK0$k-jy+_uCvjBQ@R6Zr~yNp4_ zQD+dmMR}rVzuyndx%^=_ULH*szLM1c7GV8c+9Ce8^l|Z}zxROteB^KLf6mc0={N%Y zzl0aw3h>SU7UWNx1&^fiGyk+1IOhKreCKTd-~3O)yE6ZlmVX)#Wd71~ee*vR`O|LC zsWLFwU+CI8IMThPt-K|=(V}m(mj_3N%cV*I3z;@{k1Xr%DVEIh=(#(K zxyEWK{mHKGjYFkkrLeqjprg34T<94XEOZomM*9nE+gd7HL$a|jUDg<;O9w}arP9Fi z@@S=4FfZIlc6fcgqgWZ}A1t(&OQmA($Uu3Ji@VChi$@3CUtQ$&)oSgwj*gT|1C^1& zn(m%uNYNJV@6L36S88+#%3VIYJY4Dvn`ox{6AhxabZ}jH&A92o&QR@|Ro<@NcFa_{KI;^0VO)$joRca=wndyDPmzG8SS zPu)4RHkN}bK=LR3kgk$JTXzM>Mm>%ftGWk^rNlmVrWexIM_m{08VS+AfAskS_I+U6 zikq+8Z_iKO^z89d0Qap7z>UncPil4`J{t3l=s03Zmdng94o<;z7EPwTV2X5Y<-)kr zAS5bbg$u4Wg($8KR@6Z?F0L#O87+Ug5kf=(DhAmuLnO-L`U1}S!F($y)*$k_7)$3D zLFt=~Ts!ce0dl8fNS_Z?yA5XyuR2@Vbt&zPVAhRM#=GFl!d(?Mg_uHuw(C6f@#2oH8l+_Vy}=P9ru9@NC0DPzhwDi zc4(E6PU1=_f6$i8`3ztAqaD-2KKd7)<)DAAZ~gxPd0&S2dAR#V?MzC1-k&~9l>GF{9Q!xYJ5HMR(bu*hKWZto zGtvK@GT~kTuEeC?eguH?E%XL>9pDnc3xEK>+Y!KcIr{^S0+<|u=c>oj##X*UyB6o{z0U&ir^wHjf>qw=;ir3>wdsys zW0#wC)$H8)*(k!6s8!8;-IQ*=;l_+sJZ1G=2ae3$hlt(Ma5oNeVA~>$u8qFsYm-RN Ry>>+Pi3!hMri|>#LfrR9KCm@pe|2+Rh zJ{+G^*9o>qb>G_1wgjwJl;9p%Ib`NH6t=e@`d<&Cppd5TNo5@I zvI%0=PSX(Nv+S79&e^|#^J@+Yw$`%B`+CcSKG+6DeqW0F5KM8NFK{qprZ6*5SCTet A{{R30 literal 0 HcmV?d00001 diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Alsing.SourceCode.SyntaxDocument.bmp b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Alsing.SourceCode.SyntaxDocument.bmp new file mode 100644 index 0000000000000000000000000000000000000000..b3ce9063d15aa7fd7d334423353ed458a6ee8f21 GIT binary patch literal 246 zcmZ9Fu?>JQ3_{jvCJW3c)>Cz=;mkSky>(l|Fy0NqHhx2pcVe)4_)=fxlK P?xyNJpK;f(=mL-%(y(%l literal 0 HcmV?d00001 diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Alsing.SyntaxBox.NET.csproj b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Alsing.SyntaxBox.NET.csproj new file mode 100644 index 0000000..a56fe06 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Alsing.SyntaxBox.NET.csproj @@ -0,0 +1,426 @@ + + + Local + 9.0.21022 + 2.0 + {19EF75B2-B414-4EB0-9486-160FAF93E62C} + Debug + AnyCPU + + + + + Alsing.SyntaxBox + + + JScript + Grid + IE50 + false + Library + + + OnBuildSuccess + + + + + + + 2.0 + v2.0 + http://localhost/Puzzle.SyntaxBox.NET2/ + true + Web + true + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + true + false + true + + + bin\Debug\ + true + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + true + 285212672 + false + + + TRACE + Compona.Syntaxbox.xml + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + System.Design + + + System.Drawing + + + + System.Windows.Forms + + + System.XML + + + + + Code + + + Component + + + ThumbControl.cs + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Form + + + Component + + + Component + + + Component + + + Component + + + + Component + + + + + Component + + + + + Form + + + + Component + + + Component + + + Component + + + Component + + + Component + + + Form + + + Form + + + Code + + + Code + + + Component + + + Code + + + UserControl + + + + + + + + + + + + + + + + + + + + + + + + + + + + Component + + + + + + + + + + + + Component + + + + + Form + + + + + + + + + + + + + + + + + + + Code + + + True + True + Resources.resx + + + + + + + + + + + + + + + + + + + + + + + + AutoListForm.cs + Designer + + + TabListBox.cs + Designer + + + BaseControl.cs + Designer + + + BaseListBoxControl.cs + Designer + + + BasePanelControl.cs + Designer + + + EditViewControl.cs + Designer + + + FormatLabelControl.cs + Designer + + + InfoTipForm.cs + Designer + + + IntelliMouse.cs + Designer + + + RegionHandler.cs + Designer + + + SplitViewChildControl.cs + Designer + + + SplitViewControl.cs + Designer + + + SplitViewParentControl.cs + Designer + + + FindReplace.cs + Designer + + + GotoLine.cs + Designer + + + Settings.cs + Designer + + + SyntaxBoxControl.cs + Designer + + + CollectionEditorGui.cs + Designer + + + SourceCodePrintDocument.cs + Designer + + + SyntaxDocument.cs + Designer + + + TextStyleDesignerDialog.cs + Designer + + + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Alsing.Windows.Forms.SyntaxBoxControl.bmp b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Alsing.Windows.Forms.SyntaxBoxControl.bmp new file mode 100644 index 0000000000000000000000000000000000000000..21cecdd08d77c880f05226b01782381806433fee GIT binary patch literal 246 zcmY*Qu@M3>3^R8WbTC6I=J=jLUm?}6k}X(+qky9_a{O?IV#~IqOqZu5t{i9f zY3rTrhoOU$zFuB*SfZMP%vE~toMHGVagUA77ZT|vl@OT1%nkrWLhS`$cEOz=jt)z` gB6PS}=;C$DTO0aZ+q)5~{pFqcM=8aBd07(r0o=uAm;e9( literal 0 HcmV?d00001 diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/AssemblyInfo.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/AssemblyInfo.cs new file mode 100644 index 0000000..78b026f --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/AssemblyInfo.cs @@ -0,0 +1,59 @@ +using System.Reflection; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// + +[assembly : AssemblyTitle("Alsing SyntaxBox")] +[assembly : AssemblyDescription("SyntaxHighlight Edit Control")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("Alsing")] +[assembly : AssemblyProduct("SyntaxBox")] +[assembly : AssemblyCopyright("2002-2003")] +[assembly : AssemblyTrademark("")] +[assembly : AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly : AssemblyVersion("1.4.10.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// + +[assembly : AssemblyDelaySign(false)] +[assembly : AssemblyKeyFile("")] +[assembly : AssemblyKeyName("")] \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/Caret.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/Caret.cs new file mode 100644 index 0000000..6f4717f --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/Caret.cs @@ -0,0 +1,539 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Diagnostics; +using Alsing.SourceCode; + +namespace Alsing.Windows.Forms.SyntaxBox +{ + /// + /// Caret class used by the SyntaxBoxControl + /// + public sealed class Caret + { + /// + /// Gets or Sets the position of the caret. + /// + public TextPoint Position + { + get { return _Position; } + set + { + _Position = value; + _Position.Change += PositionChange; + OnChange(); + } + } + + /// + /// Event fired when the carets position has changed. + /// + public event EventHandler Change = null; + + private void PositionChange(object s, EventArgs e) + { + OnChange(); + } + + private void OnChange() + { + if (Change != null) + Change(this, null); + } + + #region General Declarations + + // X Position of the caret (in logical units (eg. 1 tab = 5 chars) + + private readonly EditViewControl Control; + + /// + /// The Position of the caret in Chars (Column and Row index) + /// + private TextPoint _Position; + + /// + /// Used by the painter to determine if the caret should be rendered or not + /// + public bool Blink; + + private int OldLogicalXPos; + + // to what control does the caret belong?? + + #endregion + + #region Constructor(s) + + /// + /// Caret constructor + /// + /// The control that will use the caret + public Caret(EditViewControl control) + { + Position = new TextPoint(0, 0); + Control = control; + } + + #endregion + + #region Helpers + + private void RememberXPos() + { + OldLogicalXPos = LogicalPosition.X; + } + + /// + /// Confines the caret to a valid position within the active document + /// + public void CropPosition() + { + if (Position.X < 0) + Position.X = 0; + + if (Position.Y >= Control.Document.Count) + Position.Y = Control.Document.Count - 1; + + if (Position.Y < 0) + Position.Y = 0; + + Row xtr = CurrentRow; + + if (Position.X > xtr.Text.Length && !Control.VirtualWhitespace) + Position.X = xtr.Text.Length; + } + + #endregion + + #region Movement Methods + + /// + /// Moves the caret right one step. + /// if the caret is placed at the last column of a row the caret will move down one row and be placed at the first column of that row. + /// + /// True if a selection should be created from the current caret pos to the new pos + public void MoveRight(bool Select) + { + CropPosition(); + Position.X++; + + if (CurrentRow.IsCollapsed) + { + if (Position.X > CurrentRow.Expansion_EndChar) + { + Position.Y = CurrentRow.Expansion_EndRow.Index; + Position.X = CurrentRow.Expansion_EndRow.Expansion_StartChar; + CropPosition(); + } + RememberXPos(); + CaretMoved(Select); + } + else + { + Row xtr = CurrentRow; + if (Position.X > xtr.Text.Length && !Control.VirtualWhitespace) + { + if (Position.Y < Control.Document.Count - 1) + { + MoveDown(Select); + Position.X = 0; + //this.Position.Y ++; + CropPosition(); + } + else + CropPosition(); + } + RememberXPos(); + CaretMoved(Select); + } + } + + /// + /// Moves the caret up one row. + /// + /// True if a selection should be created from the current caret pos to the new pos + public void MoveUp(bool Select) + { + CropPosition(); + int x = OldLogicalXPos; + //error here + try + { + if (CurrentRow != null && CurrentRow.PrevVisibleRow != null) + { + Position.Y = CurrentRow.PrevVisibleRow.Index; + if (CurrentRow.IsCollapsed) + { + x = 0; + } + } + } + catch {} + finally + { + CropPosition(); + LogicalPosition = new TextPoint(x, Position.Y); + CropPosition(); + CaretMoved(Select); + } + } + + /// + /// Moves the caret up x rows + /// + /// Number of rows the caret should be moved up + /// True if a selection should be created from the current caret pos to the new pos + public void MoveUp(int rows, bool Select) + { + CropPosition(); + int x = OldLogicalXPos; + try + { + int pos = CurrentRow.VisibleIndex; + pos -= rows; + if (pos < 0) + pos = 0; + Row r = Control.Document.VisibleRows[pos]; + pos = r.Index; + + + Position.Y = pos; + + // for (int i=0;i + /// Moves the caret down x rows. + /// + /// The number of rows the caret should be moved down + /// True if a selection should be created from the current caret pos to the new pos + public void MoveDown(int rows, bool Select) + { + int x = OldLogicalXPos; + CropPosition(); + //this.Position.Y +=rows; + try + { + int pos = CurrentRow.VisibleIndex; + pos += rows; + if (pos > Control.Document.VisibleRows.Count - 1) + pos = Control.Document.VisibleRows.Count - 1; + + Row r = Control.Document.VisibleRows[pos]; + pos = r.Index; + Position.Y = pos; + + // for (int i=0;i + /// Moves the caret down one row. + /// + /// True if a selection should be created from the current caret pos to the new pos + public void MoveDown(bool Select) + { + CropPosition(); + int x = OldLogicalXPos; + //error here + try + { + Row r = CurrentRow; + Row r2 = r.NextVisibleRow; + if (r2 == null) + return; + + Position.Y = r2.Index; + if (CurrentRow.IsCollapsed) + { + x = 0; + } + } + catch {} + finally + { + CropPosition(); + LogicalPosition = new TextPoint(x, Position.Y); + CropPosition(); + CaretMoved(Select); + } + } + + /// + /// Moves the caret left one step. + /// if the caret is placed at the first column the caret will be moved up one line and placed at the last column of the row. + /// + /// True if a selection should be created from the current caret pos to the new pos + public void MoveLeft(bool Select) + { + CropPosition(); + Position.X--; + + if (CurrentRow.IsCollapsedEndPart) + { + if (Position.X < CurrentRow.Expansion_StartChar) + { + if (CurrentRow.Expansion_StartRow.Index == - 1) + Debugger.Break(); + Position.Y = CurrentRow.Expansion_StartRow.Index; + Position.X = CurrentRow.Expansion_StartRow.Expansion_EndChar; + CropPosition(); + } + RememberXPos(); + CaretMoved(Select); + } + else + { + if (Position.X < 0) + { + if (Position.Y > 0) + { + MoveUp(Select); + CropPosition(); + Row xtr = CurrentRow; + Position.X = xtr.Text.Length; + if (CurrentRow.IsCollapsed) + { + Position.Y = CurrentRow.Expansion_EndRow.Index; + Position.X = CurrentRow.Text.Length; + } + } + else + CropPosition(); + } + RememberXPos(); + CaretMoved(Select); + } + } + + + /// + /// Moves the caret to the first non whitespace column at the active row + /// + /// True if a selection should be created from the current caret pos to the new pos + public void MoveHome(bool Select) + { + CropPosition(); + if (CurrentRow.IsCollapsedEndPart) + { + Position.Y = CurrentRow.Expansion_StartRow.Index; + MoveHome(Select); + } + else + { + int i = CurrentRow.GetLeadingWhitespace().Length; + Position.X = Position.X == i ? 0 : i; + RememberXPos(); + CaretMoved(Select); + } + } + + /// + /// Moves the caret to the end of a row ignoring any whitespace characters at the end of the row + /// + /// True if a selection should be created from the current caret pos to the new pos + public void MoveEnd(bool Select) + { + if (CurrentRow.IsCollapsed) + { + Position.Y = CurrentRow.Expansion_EndRow.Index; + MoveEnd(Select); + } + else + { + CropPosition(); + Row xtr = CurrentRow; + Position.X = xtr.Text.Length; + RememberXPos(); + CaretMoved(Select); + } + } + + public void CaretMoved(bool Select) + { + Control.ScrollIntoView(); + if (!Select) + Control.Selection.ClearSelection(); + else + Control.Selection.MakeSelection(); + } + + /// + /// Moves the caret to the first column of the active row + /// + /// True if a selection should be created from the current caret pos to the new pos + public void MoveAbsoluteHome(bool Select) + { + Position.X = 0; + Position.Y = 0; + RememberXPos(); + CaretMoved(Select); + } + + /// + /// Moves the caret to the absolute end of the active row + /// + /// True if a selection should be created from the current caret pos to the new pos + public void MoveAbsoluteEnd(bool Select) + { + Position.X = Control.Document[Control.Document.Count - 1].Text.Length; + Position.Y = Control.Document.Count - 1; + RememberXPos(); + CaretMoved(Select); + } + + #endregion + + #region Get Related info from Caret Position + + /// + /// Gets the word that the caret is placed on. + /// This only applies if the active row is fully parsed. + /// + /// a Word object from the active row + public Word CurrentWord + { + get { return Control.Document.GetWordFromPos(Position); } + } + + /// + /// Returns the row that the caret is placed on + /// + /// a Row object from the active document + public Row CurrentRow + { + get { return Control.Document[Position.Y]; } + } + + /// + /// Gets the word that the caret is placed on. + /// This only applies if the active row is fully parsed. + /// + /// a Word object from the active row + public Span CurrentSegment() + { + return Control.Document.GetSegmentFromPos(Position); + } + + #endregion + + #region Set Position Methods/Props + + /// + /// Gets or Sets the Logical position of the caret. + /// + public TextPoint LogicalPosition + { + get + { + if (Position.X < 0) + return new TextPoint(0, Position.Y); + + Row xtr = CurrentRow; + int x = 0; + if (xtr == null) + return new TextPoint(0, 0); + + int Padd = Math.Max(Position.X - xtr.Text.Length, 0); + var PaddStr = new String(' ', Padd); + string TotStr = xtr.Text + PaddStr; + + char[] buffer = TotStr.ToCharArray(0, Position.X); + foreach (char c in buffer) + { + if (c == '\t') + { + x += Control.TabSize - (x%Control.TabSize); + } + else + { + x++; + } + } + return new TextPoint(x, Position.Y); + } + set + { + Row xtr = CurrentRow; + int x = 0; + int xx = 0; + if (value.X > 0) + { + char[] chars = xtr.Text.ToCharArray(); + + int i = 0; + + while (x < value.X) + { + char c = i < chars.Length ? chars[i] : ' '; + xx++; + if (c == '\t') + { + x += Control.TabSize - (x%Control.TabSize); + } + else + { + x++; + } + i++; + } + } + + + Position.Y = value.Y; + Position.X = xx; + } + } + + /// + /// Sets the position of the caret + /// + /// Point containing the new x and y positions + public void SetPos(TextPoint pos) + { + Position = pos; + RememberXPos(); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/KeyboadActionList.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/KeyboadActionList.cs new file mode 100644 index 0000000..379ffbe --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/KeyboadActionList.cs @@ -0,0 +1,19 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; + +namespace Alsing.Windows.Forms.SyntaxBox +{ + /// + /// Collection of KeyboardActions + /// + public class KeyboardActionList : List {} +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/KeyboardAction.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/KeyboardAction.cs new file mode 100644 index 0000000..46d8ef2 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/KeyboardAction.cs @@ -0,0 +1,59 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Windows.Forms; + +namespace Alsing.Windows.Forms.SyntaxBox +{ + /// + /// Delegate used when triggering keyboard actions + /// + public delegate void ActionDelegate(); + + /// + /// Instances of this class represents a relation between pressed keys and a delegate + /// + public class KeyboardAction + { + /// + /// Determines what key to associate with the action + /// + private Keys _Key = 0; + + public KeyboardAction() {} + + public KeyboardAction(Keys key, bool shift, bool control, bool alt, bool allowreadonly, + ActionDelegate actionDelegate) + { + Key = key; + Control = control; + Alt = alt; + Shift = shift; + Action = actionDelegate; + AllowReadOnly = allowreadonly; + } + + public bool Shift { get; set; } + + public bool Alt { get; set; } + + public bool Control { get; set; } + + public bool AllowReadOnly { get; set; } + + public Keys Key + { + get { return _Key; } + set { _Key = value; } + } + + public ActionDelegate Action { get; set; } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/NativePainter.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/NativePainter.cs new file mode 100644 index 0000000..b1f9411 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/NativePainter.cs @@ -0,0 +1,1848 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Diagnostics; +using System.Drawing; +using System.Globalization; +using System.Threading; +using System.Windows.Forms; +using Alsing.Drawing.GDI; +using Alsing.Globalization; +using Alsing.SourceCode; + +namespace Alsing.Windows.Forms.SyntaxBox.Painter +{ + /// + /// Painter class that uses GDI32 to render the content of a SyntaxBoxControl + /// + public class NativePainter : IPainter + { + private readonly EditViewControl Control; + private Word BracketEnd; + private Word BracketStart; + private int FirstSpanRow; + private RenderItems GFX; + private int LastRow; + private int LastSpanRow; + private bool RenderCaretRowOnly; + private int ResizeCount; + private bool SpanFound; + private int yOffset; + + /// + /// NativePainter constructor. + /// + /// The control that will use the Painter + public NativePainter(EditViewControl control) + { + Control = control; + InitGraphics(); + } + + #region IPainter Members + + /// + /// Implementation of the IPainter Resize method + /// + public void Resize() + { + ResizeCount++; + InitGraphics(); + // Console.WriteLine ("painterresize {0} {1}",ResizeCount,Control.Name); + } + + /// + /// Implementation of the IPainter MeasureString method + /// + /// String to measure + /// Size of the string in pixels + public Size MeasureString(string s) + { + try + { + GFX.StringBuffer.Font = GFX.FontNormal; + return GFX.StringBuffer.MeasureTabbedString(s, Control.TabSize); + } + catch + { + return new Size(0, 0); + } + } + + /// + /// Implementation of the IPainter InitGraphics method. + /// Initializes GDI32 backbuffers and brushes. + /// + public void InitGraphics() + { + try + { + if (GFX.BackgroundBrush != null) + GFX.BackgroundBrush.Dispose(); + + if (GFX.GutterMarginBrush != null) + GFX.GutterMarginBrush.Dispose(); + + if (GFX.LineNumberMarginBrush != null) + GFX.LineNumberMarginBrush.Dispose(); + + if (GFX.HighLightLineBrush != null) + GFX.HighLightLineBrush.Dispose(); + + if (GFX.LineNumberMarginBorderBrush != null) + GFX.LineNumberMarginBorderBrush.Dispose(); + + if (GFX.GutterMarginBorderBrush != null) + GFX.GutterMarginBorderBrush.Dispose(); + + if (GFX.OutlineBrush != null) + GFX.OutlineBrush.Dispose(); + + + GFX.BackgroundBrush = new GDIBrush(Control.BackColor); + GFX.GutterMarginBrush = new GDIBrush(Control.GutterMarginColor); + GFX.LineNumberMarginBrush = new GDIBrush(Control.LineNumberBackColor); + GFX.HighLightLineBrush = new GDIBrush(Control.HighLightedLineColor); + GFX.LineNumberMarginBorderBrush = new GDIBrush(Control.LineNumberBorderColor); + GFX.GutterMarginBorderBrush = new GDIBrush(Control.GutterMarginBorderColor); + GFX.OutlineBrush = new GDIBrush(Control.OutlineColor); + + + if (GFX.FontNormal != null) + GFX.FontNormal.Dispose(); + + if (GFX.FontBold != null) + GFX.FontBold.Dispose(); + + if (GFX.FontItalic != null) + GFX.FontItalic.Dispose(); + + if (GFX.FontBoldItalic != null) + GFX.FontBoldItalic.Dispose(); + + if (GFX.FontUnderline != null) + GFX.FontUnderline.Dispose(); + + if (GFX.FontBoldUnderline != null) + GFX.FontBoldUnderline.Dispose(); + + if (GFX.FontItalicUnderline != null) + GFX.FontItalicUnderline.Dispose(); + + if (GFX.FontBoldItalicUnderline != null) + GFX.FontBoldItalicUnderline.Dispose(); + + + // string font="courier new"; + string font = Control.FontName; + float fontsize = Control.FontSize; + GFX.FontNormal = new GDIFont(font, fontsize, false, false, false, false); + GFX.FontBold = new GDIFont(font, fontsize, true, false, false, false); + GFX.FontItalic = new GDIFont(font, fontsize, false, true, false, false); + GFX.FontBoldItalic = new GDIFont(font, fontsize, true, true, false, false); + GFX.FontUnderline = new GDIFont(font, fontsize, false, false, true, false); + GFX.FontBoldUnderline = new GDIFont(font, fontsize, true, false, true, false); + GFX.FontItalicUnderline = new GDIFont(font, fontsize, false, true, true, false); + GFX.FontBoldItalicUnderline = new GDIFont(font, fontsize, true, true, true, false); + + InitIMEWindow(); + } + catch (Exception) + { + } + + if (Control != null) + { + if (Control.IsHandleCreated) + { + if (GFX.StringBuffer != null) + GFX.StringBuffer.Dispose(); + + if (GFX.SelectionBuffer != null) + GFX.SelectionBuffer.Dispose(); + + if (GFX.BackBuffer != null) + GFX.BackBuffer.Dispose(); + + GFX.StringBuffer = new GDISurface(1, 1, Control, true) {Font = GFX.FontNormal}; + int h = GFX.StringBuffer.MeasureTabbedString("ABC", 0).Height + Control._SyntaxBox.RowPadding; + GFX.BackBuffer = new GDISurface(Control.ClientWidth, h, Control, true) {Font = GFX.FontNormal}; + + GFX.SelectionBuffer = new GDISurface(Control.ClientWidth, h, Control, true) {Font = GFX.FontNormal}; + + Control.View.RowHeight = GFX.BackBuffer.MeasureTabbedString("ABC", 0).Height + + Control._SyntaxBox.RowPadding; + Control.View.CharWidth = GFX.BackBuffer.MeasureTabbedString(" ", 0).Width; + } + } + } + + + /// + /// Implementation of the IPainter RenderAll method. + /// + public void RenderAll() + { + // + Control.View.RowHeight = GFX.BackBuffer.MeasureString("ABC").Height; + Control.View.CharWidth = GFX.BackBuffer.MeasureString(" ").Width; + + + Control.InitVars(); + + Graphics g = Control.CreateGraphics(); + + RenderAll(g); + + g.Dispose(); + } + + public void RenderCaret(Graphics g) + { + RenderCaretRowOnly = true; + RenderAll(g); + RenderCaretRowOnly = false; + } + + /// + /// Implementation of the IPainter RenderAll method + /// + /// Target Graphics object + public void RenderAll(Graphics g) + { + try + { + Control.InitVars(); + Control.InitScrollbars(); + SetBrackets(); + SetSpanIndicators(); + int j = Control.View.FirstVisibleRow; + + int diff = j - LastRow; + LastRow = j; + if (Control.SmoothScroll) + { + if (diff == 1) + { + for (int i = Control.View.RowHeight; i > 0; i -= Control.SmoothScrollSpeed) + { + yOffset = i + Control.View.YOffset; + RenderAll2(); + g.Flush(); + Thread.Sleep(0); + } + } + else if (diff == -1) + { + for (int i = -Control.View.RowHeight; i < 0; i += Control.SmoothScrollSpeed) + { + yOffset = i + Control.View.YOffset; + RenderAll2(); + g.Flush(); + Thread.Sleep(0); + } + } + } + + yOffset = Control.View.YOffset; + RenderAll2(); + //g.Flush (); + //System.Threading.Thread.Sleep (0); + } + catch + { + } + } + + /// + /// + /// + /// + public void RenderRow(int RowIndex) + { + RenderRow(RowIndex, 10); + } + + /// + /// Implementation of the iPainter CharFromPixel method + /// + /// Screen x position in pixels + /// Screen y position in pixels + /// a Point where x is the column and y is the rowindex + public TextPoint CharFromPixel(int X, int Y) + { + try + { + int RowIndex = Y/Control.View.RowHeight + Control.View.FirstVisibleRow; + RowIndex = Math.Min(RowIndex, Control.Document.VisibleRows.Count); + if (RowIndex == Control.Document.VisibleRows.Count) + { + RowIndex--; + Row r = Control.Document.VisibleRows[RowIndex]; + if (r.IsCollapsed) + r = r.Expansion_EndRow; + + return new TextPoint(r.Text.Length, r.Index); + } + + RowIndex = Math.Max(RowIndex, 0); + Row row; + if (Control.Document.VisibleRows.Count != 0) + { + row = Control.Document.VisibleRows[RowIndex]; + RowIndex = Control.Document.IndexOf(row); + } + else + { + return new TextPoint(0, 0); + } + if (RowIndex == -1) + return new TextPoint(-1, -1); + + + //normal line + if (!row.IsCollapsed) + return ColumnFromPixel(RowIndex, X); + + //this.RenderRow (xtr.Index,-200); + + if (X < row.Expansion_PixelEnd - Control.View.FirstVisibleColumn*Control.View.CharWidth) + { + //start of collapsed line + return ColumnFromPixel(RowIndex, X); + } + + if (X >= + row.Expansion_EndRow.Expansion_PixelStart - Control.View.FirstVisibleColumn*Control.View.CharWidth + + Control.View.TextMargin) + { + //end of collapsed line + return ColumnFromPixel(row.Expansion_EndRow.Index, + X - row.Expansion_EndRow.Expansion_PixelStart + + MeasureRow(row.Expansion_EndRow, row.Expansion_EndRow.Expansion_StartChar). + Width); + } + + //the collapsed text + return new TextPoint(row.Expansion_EndChar, row.Index); + } + catch + { + Control._SyntaxBox.FontName = "Courier New"; + Control._SyntaxBox.FontSize = 10; + return new TextPoint(0, 0); + } + } + + public int GetMaxCharWidth() + { + const string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + int max = 0; + foreach (char c in s) + { + int tmp = MeasureString(c + "").Width; + if (tmp > max) + max = tmp; + } + return max; + } + + public void Dispose() + { + if (GFX.FontNormal != null) + GFX.FontNormal.Dispose(); + + if (GFX.FontBold != null) + GFX.FontBold.Dispose(); + + if (GFX.FontItalic != null) + GFX.FontItalic.Dispose(); + + if (GFX.FontBoldItalic != null) + GFX.FontBoldItalic.Dispose(); + + if (GFX.FontUnderline != null) + GFX.FontUnderline.Dispose(); + + if (GFX.FontBoldUnderline != null) + GFX.FontBoldUnderline.Dispose(); + + if (GFX.FontItalicUnderline != null) + GFX.FontItalicUnderline.Dispose(); + + if (GFX.FontBoldItalicUnderline != null) + GFX.FontBoldItalicUnderline.Dispose(); + + if (GFX.BackgroundBrush != null) + GFX.BackgroundBrush.Dispose(); + + if (GFX.GutterMarginBrush != null) + GFX.GutterMarginBrush.Dispose(); + + if (GFX.LineNumberMarginBrush != null) + GFX.LineNumberMarginBrush.Dispose(); + + if (GFX.HighLightLineBrush != null) + GFX.HighLightLineBrush.Dispose(); + + if (GFX.LineNumberMarginBorderBrush != null) + GFX.LineNumberMarginBorderBrush.Dispose(); + + if (GFX.GutterMarginBorderBrush != null) + GFX.GutterMarginBorderBrush.Dispose(); + + if (GFX.OutlineBrush != null) + GFX.OutlineBrush.Dispose(); + + if (GFX.StringBuffer != null) + GFX.StringBuffer.Dispose(); + + if (GFX.SelectionBuffer != null) + GFX.SelectionBuffer.Dispose(); + + if (GFX.BackBuffer != null) + GFX.BackBuffer.Dispose(); + } + + /// + /// Implementation of the IPainter MeasureRow method. + /// + /// Row to measure + /// Last char index + /// The size of the row in pixels + public Size MeasureRow(Row xtr, int Count) + { + int width = 0; + int taborig = -Control.View.FirstVisibleColumn*Control.View.CharWidth + Control.View.TextMargin; + int xpos = Control.View.TextMargin - Control.View.ClientAreaStart; + if (xtr.InQueue) + { + SetStringFont(false, false, false); + int Padd = Math.Max(Count - xtr.Text.Length, 0); + var PaddStr = new String(' ', Padd); + string TotStr = xtr.Text + PaddStr; + width = GFX.StringBuffer.MeasureTabbedString(TotStr.Substring(0, Count), Control.PixelTabSize).Width; + } + else + { + int CharNo = 0; + int TotWidth = 0; + foreach (Word w in xtr.FormattedWords) + { + if (w.Type == WordType.Word && w.Style != null) + SetStringFont(w.Style.Bold, w.Style.Italic, w.Style.Underline); + else + SetStringFont(false, false, false); + + if (w.Text.Length + CharNo >= Count || w == xtr.FormattedWords[xtr.FormattedWords.Count - 1]) + { + int CharPos = Count - CharNo; + int MaxChars = Math.Min(CharPos, w.Text.Length); + TotWidth += + GFX.StringBuffer.DrawTabbedString(w.Text.Substring(0, MaxChars), xpos + TotWidth, 0, taborig, + Control.PixelTabSize).Width; + width = TotWidth; + break; + } + + TotWidth += + GFX.StringBuffer.DrawTabbedString(w.Text, xpos + TotWidth, 0, taborig, Control.PixelTabSize). + Width; + CharNo += w.Text.Length; + } + + SetStringFont(false, false, false); + int Padd = Math.Max(Count - xtr.Text.Length, 0); + var PaddStr = new String(' ', Padd); + width += + GFX.StringBuffer.DrawTabbedString(PaddStr, xpos + TotWidth, 0, taborig, Control.PixelTabSize).Width; + } + + + return new Size(width, 0); + + // return GFX.BackBuffer.MeasureTabbedString (xtr.Text.Substring (0,Count),Control.PixelTabSize); + } + + #endregion + + private void InitIMEWindow() + { + if (Control.IMEWindow != null) + Control.IMEWindow.SetFont(Control.FontName, Control.FontSize); + } + + private void SetBrackets() + { + Span currentSpan; + BracketEnd = null; + BracketStart = null; + + Word CurrWord = Control.Caret.CurrentWord; + if (CurrWord != null) + { + currentSpan = CurrWord.Span; + if (currentSpan != null) + { + if (CurrWord == currentSpan.StartWord || CurrWord == currentSpan.EndWord) + { + if (currentSpan.EndWord != null) + { + BracketEnd = currentSpan.EndWord; + BracketStart = currentSpan.StartWord; + } + } + + try + { + if (CurrWord.Pattern == null) + return; + + if (CurrWord.Pattern.BracketType == BracketType.EndBracket) + { + Word w = Control.Document.GetStartBracketWord(CurrWord, CurrWord.Pattern.MatchingBracket, + CurrWord.Span); + BracketEnd = CurrWord; + BracketStart = w; + } + if (CurrWord.Pattern.BracketType == BracketType.StartBracket) + { + Word w = Control.Document.GetEndBracketWord(CurrWord, CurrWord.Pattern.MatchingBracket, + CurrWord.Span); + + // if(w!=null) + // { + BracketEnd = w; + BracketStart = CurrWord; + // } + } + } + catch + { + } + } + } + } + + private void SetSpanIndicators() + { + SpanFound = false; + try + { + Span s = Control.Caret.CurrentSegment(); + + if (s == null || s.StartWord == null || s.StartWord.Row == null || s.EndWord == null || + s.EndWord.Row == null) + return; + + FirstSpanRow = s.StartWord.Row.Index; + LastSpanRow = s.EndWord.Row.Index; + SpanFound = true; + } + catch + { + } + } + + private void RenderAll2() + { + try + { + int j = Control.View.FirstVisibleRow; + + + if (Control.AutoListStartPos != null) + { + try + { + if (Control.AutoListVisible) + { + Point alP = GetTextPointPixelPos(Control.AutoListStartPos); + if (alP == new Point(-1, -1)) + { + Control.AutoList.Visible = false; + } + else + { + alP.Y += Control.View.RowHeight + 2; + alP.X += -20; + alP = Control.PointToScreen(alP); + + Screen screen = Screen.FromPoint(new Point(Control.Right, alP.Y)); + + if (alP.Y + Control.AutoList.Height > screen.WorkingArea.Height) + { + alP.Y -= Control.View.RowHeight + 2 + Control.AutoList.Height; + } + + if (alP.X + Control.AutoList.Width > screen.WorkingArea.Width) + { + alP.X -= alP.X + Control.AutoList.Width - screen.WorkingArea.Width; + } + + + Control.AutoList.Location = alP; + //Control.Controls[0].Focus(); + Control.Focus(); + } + } + } + catch + { + } + } + + if (Control.InfoTipStartPos != null) + { + try + { + if (Control.InfoTipVisible) + { + Point itP = GetTextPointPixelPos(Control.InfoTipStartPos); + if (itP == new Point(-1, -1)) + { + Control.InfoTip.Visible = false; + } + else + { + itP.Y += Control.View.RowHeight + 2; + itP.X += -20; + + itP = Control.PointToScreen(itP); + + Screen screen = Screen.FromPoint(new Point(Control.Right, itP.Y)); + + if (itP.Y + Control.InfoTip.Height > screen.WorkingArea.Height) + { + itP.Y -= Control.View.RowHeight + 2 + Control.InfoTip.Height; + } + + if (itP.X + Control.InfoTip.Width > screen.WorkingArea.Width) + { + itP.X -= itP.X + Control.InfoTip.Width - screen.WorkingArea.Width; + } + + + Control.InfoTip.Location = itP; + Control.InfoTip.Visible = true; + Debug.WriteLine("Infotip Made Visible"); + } + } + else + { + Control.InfoTip.Visible = false; + Debug.WriteLine("Infotip Made Invisible"); + } + } + catch + { + } + } + + for (int i = 0; i < Control.View.VisibleRowCount; i++) + { + if (j >= 0 && j < Control.Document.VisibleRows.Count) + { + Row r = Control.Document.VisibleRows[j]; + if (RenderCaretRowOnly) + { + if (r == Control.Caret.CurrentRow) + { + RenderRow(Control.Document.IndexOf(r), i); + } + //Control.Caret.CurrentRow.expansion_EndSpan.StartRow.Index + if (Control.Caret.CurrentRow.expansion_EndSpan != null && + Control.Caret.CurrentRow.expansion_EndSpan.StartRow != null && + Control.Caret.CurrentRow.expansion_EndSpan.StartRow == r) + { + RenderRow(Control.Document.IndexOf(r), i); + } + } + else + { + RenderRow(Control.Document.IndexOf(r), i); + } + } + else + { + if (RenderCaretRowOnly) + { + } + else + { + RenderRow(Control.Document.Count, i); + } + } + j++; + } + } + catch + { + } + } + + private void RenderRow(int RowIndex, int RowPos) + { + if (RowIndex >= 0 && RowIndex < Control.Document.Count) + { + //do keyword parse before we render the line... + if (Control.Document[RowIndex].RowState == RowState.SpanParsed) + { + Control.Document.Parser.ParseRow(RowIndex, true); + Control.Document[RowIndex].RowState = RowState.AllParsed; + } + } + + + try + { + GDISurface bbuff = GFX.BackBuffer; + bool found = false; + + + GDIBrush bg = GFX.BackgroundBrush; + + try + { + if (RowIndex < Control.Document.Count && RowIndex >= 0) + { + Row r = Control.Document[RowIndex]; + if (SpanFound && RowIndex >= FirstSpanRow && RowIndex <= LastSpanRow && + Control._SyntaxBox.ScopeBackColor != Color.Transparent) + { + bg = new GDIBrush(Control._SyntaxBox.ScopeBackColor); + found = true; + } + else if (r.BackColor != Color.Transparent) + { + bg = new GDIBrush(r.BackColor); + found = true; + } + else + { + if (r.endSpan != null) + { + Span tmp = r.expansion_EndSpan; + while (tmp != null) + { + if (tmp.spanDefinition.Transparent == false) + { + bg = new GDIBrush(tmp.spanDefinition.BackColor); + found = true; + break; + } + tmp = tmp.Parent; + } + + + if (!found) + { + tmp = r.endSpan; + while (tmp != null) + { + if (tmp.spanDefinition.Transparent == false) + { + bg = new GDIBrush(tmp.spanDefinition.BackColor); + found = true; + break; + } + tmp = tmp.Parent; + } + } + if (!found) + { + tmp = r.expansion_EndSpan; + while (tmp != null) + { + if (tmp.spanDefinition.Transparent == false) + { + bg = new GDIBrush(tmp.spanDefinition.BackColor); + found = true; + break; + } + tmp = tmp.Parent; + } + } + } + } + } + } + catch + { + } + + if (RowIndex == Control.Caret.Position.Y && Control.HighLightActiveLine) + bbuff.Clear(GFX.HighLightLineBrush); + + else if (RowIndex >= 0 && RowIndex < Control.Document.Count) + { + if (Control.Document[RowIndex].IsCollapsed) + { + if (Control.Document[RowIndex].Expansion_EndRow.Index == Control.Caret.Position.Y && + Control.HighLightActiveLine) + bbuff.Clear(GFX.HighLightLineBrush); + else + bbuff.Clear(bg); + } + else + bbuff.Clear(bg); + } + else + bbuff.Clear(bg); + + + //only render normal text if any part of the row is visible + if (RowIndex <= Control.Selection.LogicalBounds.FirstRow || + RowIndex >= Control.Selection.LogicalBounds.LastRow) + { + RenderText(RowIndex); + } + + //only render selection text if the line is selected + if (Control.Selection.IsValid) + { + if (RowIndex >= Control.Selection.LogicalBounds.FirstRow && + RowIndex <= Control.Selection.LogicalBounds.LastRow) + { + if (Control.ContainsFocus) + GFX.SelectionBuffer.Clear(Control.SelectionBackColor); + else + GFX.SelectionBuffer.Clear(Control.InactiveSelectionBackColor); + + RenderSelectedText(RowIndex); + } + } + + + if (Control.ContainsFocus || Control.View.Action == EditAction.DragText) + { + RenderCaret(RowIndex, RowPos*Control.View.RowHeight + yOffset); + } + + RenderSelection(RowIndex); + RenderMargin(RowIndex); + if (Control.Document.Folding) + RenderExpansion(RowIndex); + + var e = new RowPaintEventArgs(); + + var rec = new Rectangle(0, 0, Control.Width, Control.View.RowHeight); + e.Graphics = Graphics.FromHdc(bbuff.hDC); + e.Bounds = rec; + e.Row = null; + if (RowIndex >= 0 && RowIndex < Control.Document.Count) + e.Row = Control.Document[RowIndex]; + + Control._SyntaxBox.OnRenderRow(e); + + + bbuff.Flush(); + bbuff.RenderToControl(0, RowPos*Control.View.RowHeight + yOffset); + + //GFX.SelectionBuffer.RenderToControl (0,RowPos*Control.View.RowHeight+this.yOffset); + + + if (found) + bg.Dispose(); + } + catch + { + } + } + + private void SetFont(bool bold, bool italic, bool underline, GDISurface surface) + { + if (bold && italic && underline) + surface.Font = GFX.FontBoldItalicUnderline; + + else if (bold && italic) + surface.Font = GFX.FontBoldItalic; + + else if (bold && underline) + surface.Font = GFX.FontBoldUnderline; + + else if (bold) + surface.Font = GFX.FontBold; + + else if (italic && underline) + surface.Font = GFX.FontItalicUnderline; + + else if (!italic && underline) + surface.Font = GFX.FontUnderline; + + else if (italic) + surface.Font = GFX.FontItalic; + + else if (true) + surface.Font = GFX.FontNormal; + } + + private void SetStringFont(bool bold, bool italic, bool underline) + { + SetFont(bold, italic, underline, GFX.StringBuffer); + } + + private void RenderCollapsedSelectedText(int RowIndex, int xPos) + { + GDISurface bbuff = GFX.SelectionBuffer; + bbuff.Font = GFX.FontBold; + bbuff.FontTransparent = true; + + bbuff.TextForeColor = Control.ContainsFocus + ? Control.SelectionForeColor + : Control.InactiveSelectionForeColor; + + //bbuff.TextForeColor =Color.DarkBlue; + Row r = Control.Document[RowIndex]; + string str = r.CollapsedText; + + xPos++; + int taborig = -Control.View.FirstVisibleColumn*Control.View.CharWidth + Control.View.TextMargin; + GFX.StringBuffer.Font = GFX.FontBold; + int wdh = GFX.StringBuffer.DrawTabbedString(str, xPos + 1, 0, taborig, Control.PixelTabSize).Width; + + if (Control.ContainsFocus) + { + bbuff.FillRect(Control.SelectionForeColor, xPos + 0, 0, wdh + 2, Control.View.RowHeight); + bbuff.FillRect(Control.SelectionBackColor, xPos + 1, 1, wdh, Control.View.RowHeight - 2); + } + else + { + bbuff.FillRect(Control.InactiveSelectionForeColor, xPos + 0, 0, wdh + 2, Control.View.RowHeight); + bbuff.FillRect(Control.InactiveSelectionBackColor, xPos + 1, 1, wdh, Control.View.RowHeight - 2); + } + + + wdh = bbuff.DrawTabbedString(str, xPos + 1, 0, taborig, Control.PixelTabSize).Width; + + + //this can crash if document not fully parsed , on error resume next + try + { + if (r.expansion_StartSpan.EndRow != null) + { + if (r.expansion_StartSpan.EndRow.RowState == RowState.SpanParsed) + Control.Document.Parser.ParseRow(r.expansion_StartSpan.EndRow.Index, true); + + Word last = r.expansion_StartSpan.EndWord; + xPos += Control.View.FirstVisibleColumn*Control.View.CharWidth; + r.expansion_StartSpan.EndRow.Expansion_PixelStart = xPos + wdh - Control.View.TextMargin + 2; + r.Expansion_PixelEnd = xPos - 1; + RenderSelectedText(Control.Document.IndexOf(r.expansion_StartSpan.EndRow), + r.expansion_StartSpan.EndRow.Expansion_PixelStart, last); + } + } + catch + { + } + } + + private void RenderCollapsedText(int RowIndex, int xPos) + { + GDISurface bbuff = GFX.BackBuffer; + bbuff.Font = GFX.FontBold; + bbuff.FontTransparent = true; + + bbuff.TextForeColor = Control.OutlineColor; + + Row r = Control.Document[RowIndex]; + string str = r.CollapsedText; + + xPos++; + int taborig = -Control.View.FirstVisibleColumn*Control.View.CharWidth + Control.View.TextMargin; + GFX.StringBuffer.Font = GFX.FontBold; + int wdh = GFX.StringBuffer.DrawTabbedString(str, xPos + 1, 0, taborig, Control.PixelTabSize).Width; + bbuff.FillRect(GFX.OutlineBrush, xPos + 0, 0, wdh + 2, Control.View.RowHeight); + bbuff.FillRect(GFX.BackgroundBrush, xPos + 1, 1, wdh, Control.View.RowHeight - 2); + wdh = bbuff.DrawTabbedString(str, xPos + 1, 0, taborig, Control.PixelTabSize).Width; + + + //this can crash if document not fully parsed , on error resume next + try + { + if (r.expansion_StartSpan.EndRow != null) + { + if (r.expansion_StartSpan.EndRow.RowState == RowState.SpanParsed) + Control.Document.Parser.ParseRow(r.expansion_StartSpan.EndRow.Index, true); + + Word last = r.expansion_StartSpan.EndWord; + xPos += Control.View.FirstVisibleColumn*Control.View.CharWidth; + r.expansion_StartSpan.EndRow.Expansion_PixelStart = xPos + wdh - Control.View.TextMargin + 2; + r.Expansion_PixelEnd = xPos - 1; + RenderText(Control.Document.IndexOf(r.expansion_StartSpan.EndRow), + r.expansion_StartSpan.EndRow.Expansion_PixelStart, last); + } + } + catch + { + } + } + + private void RenderText(int RowIndex) + { + RenderText(RowIndex, 0, null); + } + + private void RenderText(int RowIndex, int XOffset, Word StartWord) + { + GDISurface bbuff = GFX.BackBuffer; + bbuff.Font = GFX.FontNormal; + bbuff.FontTransparent = true; + bool DrawBreakpoint = false; + if (RowIndex <= Control.Document.Count - 1) + { + bbuff.TextForeColor = Color.Black; + Row xtr = Control.Document[RowIndex]; + + //if (xtr.startSpan != null) + // bbuff.DrawTabbedString (xtr.startSpan.GetHashCode ().ToString (System.Globalization.CultureInfo.InvariantCulture),100,0,0,0); + + //bbuff.TextForeColor = Color.Black; + //bbuff.DrawTabbedString (xtr.Text,(int)(Control.View.TextMargin -Control.View.ClientAreaStart),1,-Control.View.FirstVisibleColumn*Control.View.CharWidth+Control.View.TextMargin,Control.PixelTabSize); + + int xpos = Control.View.TextMargin - Control.View.ClientAreaStart + XOffset; + int wdh = 0; + int taborig = -Control.View.FirstVisibleColumn*Control.View.CharWidth + Control.View.TextMargin; + + + bool ws = Control.ShowWhitespace; + bool StartDraw = false; + if (StartWord == null) + StartDraw = true; + xtr.Expansion_StartChar = 0; + xtr.Expansion_EndChar = 0; + bool HasExpansion = false; + foreach (Word w in xtr.FormattedWords) + { + if (StartDraw) + { + if (w.Span == xtr.expansion_StartSpan && xtr.expansion_StartSpan != null) + if (xtr.expansion_StartSpan.Expanded == false) + { + RenderCollapsedText(RowIndex, xpos); + HasExpansion = true; + break; + } + + if ((w.Type == WordType.Space || w.Type == WordType.Tab) && !DrawBreakpoint && + Control.ShowTabGuides) + { + int xtab = xpos - (Control.View.TextMargin - Control.View.ClientAreaStart + XOffset); + if ((xtab/(double) Control.PixelTabSize) == (xtab/Control.PixelTabSize)) + bbuff.FillRect(Control.TabGuideColor, xpos, 0, 1, Control.View.RowHeight); + } + + if (w.Type == WordType.Word || ws == false) + { + if (w.Style != null) + { + SetFont(w.Style.Bold, w.Style.Italic, w.Style.Underline, bbuff); + bbuff.TextBackColor = w.Style.BackColor; + bbuff.TextForeColor = w.Style.ForeColor; + bbuff.FontTransparent = w.Style.Transparent; + } + else + { + bbuff.Font = GFX.FontNormal; + bbuff.TextForeColor = Color.Black; + bbuff.FontTransparent = true; + } + + + if (w.Type == WordType.Word) + DrawBreakpoint = true; + + if (xtr.Breakpoint && DrawBreakpoint) + { + bbuff.TextForeColor = Control.BreakPointForeColor; + bbuff.TextBackColor = Control.BreakPointBackColor; + bbuff.FontTransparent = false; + } + + + if (Control.BracketMatching && (w == BracketEnd || w == BracketStart)) + { + bbuff.TextForeColor = Control.BracketForeColor; + + if (Control.BracketBackColor != Color.Transparent) + { + bbuff.TextBackColor = Control.BracketBackColor; + bbuff.FontTransparent = false; + } + + wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width; + if (Control.BracketBorderColor != Color.Transparent) + { + bbuff.DrawRect(Control.BracketBorderColor, xpos - 1, 0, wdh, + Control.View.RowHeight - 1); + } + } + else + { + wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width; + } + + + //render errors + if (w.HasError) + { + //bbuff.FillRect (Color.Red,xpos,Control.View.RowHeight-2,wdh,2); + int ey = Control.View.RowHeight - 1; + Color c = w.ErrorColor; + for (int x = 0; x < wdh + 3; x += 4) + { + bbuff.DrawLine(c, new Point(xpos + x, ey), new Point(xpos + x + 2, ey - 2)); + bbuff.DrawLine(c, new Point(xpos + x + 2, ey - 2), new Point(xpos + x + 4, ey)); + } + } + } + else if (w.Type == WordType.Space) + { + bbuff.Font = GFX.FontNormal; + bbuff.TextForeColor = Control.WhitespaceColor; + bbuff.FontTransparent = true; + + if (xtr.Breakpoint && DrawBreakpoint) + { + bbuff.TextForeColor = Control.BreakPointForeColor; + bbuff.TextBackColor = Control.BreakPointBackColor; + bbuff.FontTransparent = false; + } + + bbuff.DrawTabbedString("·", xpos, 0, taborig, Control.PixelTabSize); + wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width; + } + else if (w.Type == WordType.Tab) + { + bbuff.Font = GFX.FontNormal; + bbuff.TextForeColor = Control.WhitespaceColor; + bbuff.FontTransparent = true; + + if (xtr.Breakpoint && DrawBreakpoint) + { + bbuff.TextForeColor = Control.BreakPointForeColor; + bbuff.TextBackColor = Control.BreakPointBackColor; + bbuff.FontTransparent = false; + } + + bbuff.DrawTabbedString("»", xpos, 0, taborig, Control.PixelTabSize); + wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width; + } + if (w.Pattern != null) + if (w.Pattern.IsSeparator) + { + bbuff.FillRect(Control.SeparatorColor, Control.View.TextMargin - 4, + Control.View.RowHeight - 1, Control.View.ClientAreaWidth, 1); + } + + xpos += wdh; + } + + + if (!StartDraw) + xtr.Expansion_StartChar += w.Text.Length; + + if (w == StartWord) + StartDraw = true; + + xtr.Expansion_EndChar += w.Text.Length; + } + + + if (xtr.IsCollapsed) + { + } + else if (xtr.endSpan != null && xtr.endSpan.spanDefinition != null && + xtr.endSpan.spanDefinition.Style != null) + { + bbuff.FillRect(xtr.endSpan.spanDefinition.Style.BackColor, xpos, 0, Control.Width - xpos, + Control.View.RowHeight); + } + + if (Control._SyntaxBox.ShowEOLMarker && !HasExpansion) + { + bbuff.Font = GFX.FontNormal; + bbuff.TextForeColor = Control._SyntaxBox.EOLMarkerColor; + bbuff.FontTransparent = true; + bbuff.DrawTabbedString("¶", xpos, 0, taborig, Control.PixelTabSize); + } + } + } + + + private void RenderSelectedText(int RowIndex) + { + RenderSelectedText(RowIndex, 0, null); + } + + private void RenderSelectedText(int RowIndex, int XOffset, Word StartWord) + { + GDISurface bbuff = GFX.SelectionBuffer; + bbuff.Font = GFX.FontNormal; + bbuff.FontTransparent = true; + if (RowIndex <= Control.Document.Count - 1) + { + bbuff.TextForeColor = Control.ContainsFocus + ? Control.SelectionForeColor + : Control.InactiveSelectionForeColor; + + Row xtr = Control.Document[RowIndex]; + + //if (xtr.startSpan != null) + // bbuff.DrawTabbedString (xtr.startSpan.GetHashCode ().ToString (System.Globalization.CultureInfo.InvariantCulture),100,0,0,0); + + //bbuff.TextForeColor = Color.Black; + //bbuff.DrawTabbedString (xtr.Text,(int)(Control.View.TextMargin -Control.View.ClientAreaStart),1,-Control.View.FirstVisibleColumn*Control.View.CharWidth+Control.View.TextMargin,Control.PixelTabSize); + + int xpos = Control.View.TextMargin - Control.View.ClientAreaStart + XOffset; + int wdh = 0; + int taborig = -Control.View.FirstVisibleColumn*Control.View.CharWidth + Control.View.TextMargin; + + + bool ws = Control.ShowWhitespace; + bool StartDraw = false; + if (StartWord == null) + StartDraw = true; + xtr.Expansion_StartChar = 0; + xtr.Expansion_EndChar = 0; + bool HasExpansion = false; + foreach (Word w in xtr.FormattedWords) + { + if (StartDraw) + { + if (w.Span == xtr.expansion_StartSpan && xtr.expansion_StartSpan != null) + if (xtr.expansion_StartSpan.Expanded == false) + { + RenderCollapsedSelectedText(RowIndex, xpos); + HasExpansion = true; + break; + } + + + if (w.Type == WordType.Word || ws == false) + { + if (w.Style != null) + { + SetFont(w.Style.Bold, w.Style.Italic, w.Style.Underline, bbuff); + } + else + { + bbuff.Font = GFX.FontNormal; + } + + wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width; + + //render errors + if (w.HasError) + { + //bbuff.FillRect (Color.Red,xpos,Control.View.RowHeight-2,wdh,2); + int ey = Control.View.RowHeight - 1; + Color c = w.ErrorColor; + for (int x = 0; x < wdh + 3; x += 4) + { + bbuff.DrawLine(c, new Point(xpos + x, ey), new Point(xpos + x + 2, ey - 2)); + bbuff.DrawLine(c, new Point(xpos + x + 2, ey - 2), new Point(xpos + x + 4, ey)); + } + } + } + else if (w.Type == WordType.Space) + { + bbuff.Font = GFX.FontNormal; + bbuff.DrawTabbedString("·", xpos, 0, taborig, Control.PixelTabSize); + wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width; + } + else if (w.Type == WordType.Tab) + { + bbuff.Font = GFX.FontNormal; + bbuff.DrawTabbedString("»", xpos, 0, taborig, Control.PixelTabSize); + wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width; + } + if (w.Pattern != null) + if (w.Pattern.IsSeparator) + { + bbuff.FillRect(Control.SeparatorColor, Control.View.TextMargin - 4, + Control.View.RowHeight - 1, Control.View.ClientAreaWidth, 1); + } + + xpos += wdh; + } + + + if (!StartDraw) + xtr.Expansion_StartChar += w.Text.Length; + + if (w == StartWord) + StartDraw = true; + + xtr.Expansion_EndChar += w.Text.Length; + } + + if (xtr.IsCollapsed) + { + } + else if (xtr.endSpan != null && xtr.endSpan.spanDefinition != null && + xtr.endSpan.spanDefinition.Style != null) + { + GFX.BackBuffer.FillRect(xtr.endSpan.spanDefinition.Style.BackColor, xpos, 0, + Control.Width - xpos, Control.View.RowHeight); + } + + if (Control._SyntaxBox.ShowEOLMarker && !HasExpansion) + { + bbuff.Font = GFX.FontNormal; + bbuff.TextForeColor = Control.SelectionForeColor; + bbuff.FontTransparent = true; + bbuff.DrawTabbedString("¶", xpos, 0, taborig, Control.PixelTabSize); + } + } + } + + private void RenderCaret(int RowIndex, int ypos) + { + int StartRow = -1; + int cr = Control.Caret.Position.Y; + + if (cr >= 0 && cr <= Control.Document.Count - 1) + { + Row r = Control.Document[cr]; + if (r.expansion_EndSpan != null) + { + if (r.expansion_EndSpan.Expanded == false) + { + r = r.expansion_EndSpan.StartRow; + StartRow = r.Index; + } + } + } + + bool Collapsed = (RowIndex == StartRow); + + + if (RowIndex != cr && RowIndex != StartRow) + return; + + if (Control.View.Action == EditAction.DragText) + { + //drop Control.Caret + Row xtr = Control.Document[cr]; + + int pos = MeasureRow(xtr, Control.Caret.Position.X).Width + 1; + + if (Collapsed) + { + pos += xtr.Expansion_PixelStart; + pos -= MeasureRow(xtr, xtr.Expansion_StartChar).Width; + } + + GFX.BackBuffer.InvertRect(pos + Control.View.TextMargin - Control.View.ClientAreaStart - 1, 0, 3, + Control.View.RowHeight); + GFX.BackBuffer.InvertRect(pos + Control.View.TextMargin - Control.View.ClientAreaStart, 1, 1, + Control.View.RowHeight - 2); + } + else + { + //normal Control.Caret + + Row xtr = Control.Document[cr]; + if (!Control.OverWrite) + { + int pos = Control.View.TextMargin - Control.View.ClientAreaStart; + pos += MeasureRow(xtr, Control.Caret.Position.X).Width + 1; + if (Collapsed) + { + pos += xtr.Expansion_PixelStart; + pos -= MeasureRow(xtr, xtr.Expansion_StartChar).Width; + } + + int wdh = Control.View.CharWidth/12 + 1; + if (wdh < 2) + wdh = 2; + + if (Control.Caret.Blink) + { + GFX.BackBuffer.InvertRect(pos, 0, wdh, Control.View.RowHeight); + } + + if (Control.IMEWindow == null) + { + Control.IMEWindow = new IMEWindow(Control.Handle, Control.FontName, Control.FontSize); + InitIMEWindow(); + } + Control.IMEWindow.Loation = new Point(pos, ypos); + } + else + { + int pos1 = MeasureRow(xtr, Control.Caret.Position.X).Width; + int pos2 = MeasureRow(xtr, Control.Caret.Position.X + 1).Width; + int wdh = pos2 - pos1; + if (Collapsed) + { + pos1 += xtr.Expansion_PixelStart; + pos1 -= MeasureRow(xtr, xtr.Expansion_StartChar).Width; + } + + int pos = pos1 + Control.View.TextMargin - Control.View.ClientAreaStart; + if (Control.Caret.Blink) + { + GFX.BackBuffer.InvertRect(pos, 0, wdh, Control.View.RowHeight); + } + Control.IMEWindow.Loation = new Point(pos, ypos); + } + } + } + + private void RenderMargin(int RowIndex) + { + GDISurface bbuff = GFX.BackBuffer; + + if (Control.ShowGutterMargin) + { + bbuff.FillRect(GFX.GutterMarginBrush, 0, 0, Control.View.GutterMarginWidth, Control.View.RowHeight); + bbuff.FillRect(GFX.GutterMarginBorderBrush, Control.View.GutterMarginWidth - 1, 0, 1, + Control.View.RowHeight); + if (RowIndex <= Control.Document.Count - 1) + { + Row r = Control.Document[RowIndex]; + + if (Control.View.RowHeight >= Control._SyntaxBox.GutterIcons.ImageSize.Height) + { + if (r.Bookmarked) + Control._SyntaxBox.GutterIcons.Draw(Graphics.FromHdc(bbuff.hDC), 0, 0, 1); + if (r.Breakpoint) + Control._SyntaxBox.GutterIcons.Draw(Graphics.FromHdc(bbuff.hDC), 0, 0, 0); + } + else + { + int w = Control.View.RowHeight; + if (r.Bookmarked) + Control._SyntaxBox.GutterIcons.Draw(Graphics.FromHdc(bbuff.hDC), 0, 0, w, w, 1); + if (r.Breakpoint) + Control._SyntaxBox.GutterIcons.Draw(Graphics.FromHdc(bbuff.hDC), 0, 0, w, w, 0); + } + + if (r.Images != null) + { + foreach (int i in r.Images) + { + if (Control.View.RowHeight >= Control._SyntaxBox.GutterIcons.ImageSize.Height) + { + Control._SyntaxBox.GutterIcons.Draw(Graphics.FromHdc(bbuff.hDC), 0, 0, i); + } + else + { + int w = Control.View.RowHeight; + Control._SyntaxBox.GutterIcons.Draw(Graphics.FromHdc(bbuff.hDC), 0, 0, w, w, i); + } + } + } + } + } + + + if (Control.ShowLineNumbers) + { + bbuff.FillRect(GFX.LineNumberMarginBrush, Control.View.GutterMarginWidth, 0, + Control.View.LineNumberMarginWidth + 1, Control.View.RowHeight); + + //bbuff.FillRect (GFX.LineNumberMarginBrush ,Control.View.GutterMarginWidth+Control.View.LineNumberMarginWidth,0,1,Control.View.RowHeight); + + for (int j = 0; j < Control.View.RowHeight; j += 2) + { + bbuff.FillRect(GFX.LineNumberMarginBorderBrush, + Control.View.GutterMarginWidth + Control.View.LineNumberMarginWidth, j, 1, 1); + } + } + + + if (!Control.ShowLineNumbers || !Control.ShowGutterMargin) + bbuff.FillRect(GFX.BackgroundBrush, Control.View.TotalMarginWidth, 0, + Control.View.TextMargin - Control.View.TotalMarginWidth - 3, Control.View.RowHeight); + else + bbuff.FillRect(GFX.BackgroundBrush, Control.View.TotalMarginWidth + 1, 0, + Control.View.TextMargin - Control.View.TotalMarginWidth - 4, Control.View.RowHeight); + + if (Control.ShowLineNumbers) + { + bbuff.Font = GFX.FontNormal; + bbuff.FontTransparent = true; + + bbuff.TextForeColor = Control.LineNumberForeColor; + if (RowIndex <= Control.Document.Count - 1) + { + int nw = MeasureString((RowIndex + 1).ToString(CultureInfo.InvariantCulture)).Width; + + bbuff.DrawTabbedString((RowIndex + 1).ToString(CultureInfo.InvariantCulture), + Control.View.GutterMarginWidth + Control.View.LineNumberMarginWidth - nw - 1, + 1, 0, Control.PixelTabSize); + } + } + } + + private void RenderExpansion(int RowIndex) + { + if (Control == null) + throw new NullReferenceException("Control may not be null"); + + const int expansionOffset = 10; + if (RowIndex <= Control.Document.Count - 1) + { + const int yo = 4; + Row xtr = Control.Document[RowIndex]; + GDISurface bbuff = GFX.BackBuffer; + if (xtr.endSpan != null) + { + if (xtr.expansion_StartSpan != null && xtr.startSpan.Parent == null) + { + if (!xtr.IsCollapsed) + { + bbuff.FillRect(GFX.OutlineBrush, Control.View.TotalMarginWidth + expansionOffset, yo, 1, + Control.View.RowHeight - yo); + } + } + else if ((xtr.endSpan.Parent != null || xtr.expansion_EndSpan != null)) + { + bbuff.FillRect(GFX.OutlineBrush, Control.View.TotalMarginWidth + expansionOffset, 0, 1, + Control.View.RowHeight); + } + + if (xtr.expansion_StartSpan != null) + { + bbuff.FillRect(GFX.OutlineBrush, Control.View.TotalMarginWidth + expansionOffset - 4, yo, 9, 9); + bbuff.FillRect(GFX.BackgroundBrush, Control.View.TotalMarginWidth + expansionOffset - 3, yo + 1, + 7, 7); + //render plus / minus + bbuff.FillRect(GFX.OutlineBrush, Control.View.TotalMarginWidth + expansionOffset - 2, yo + 4, 5, + 1); + if (!xtr.expansion_StartSpan.Expanded) + bbuff.FillRect(GFX.OutlineBrush, Control.View.TotalMarginWidth + expansionOffset, yo + 2, 1, + 5); + } + if (xtr.expansion_EndSpan != null) + { + bbuff.FillRect(GFX.OutlineBrush, Control.View.TotalMarginWidth + expansionOffset + 1, + Control.View.RowHeight - 1, + 5, 1); + } + } + + // //RENDER SPAN LINES + // if (SpanFound) + // { + // if (RowIndex==FirstSpanRow) + // bbuff.FillRect (GFX.OutlineBrush,this.Control.View.TotalMarginWidth +14,0,Control.ClientWidth ,1); + // + // if (RowIndex==LastSpanRow) + // bbuff.FillRect (GFX.OutlineBrush,this.Control.View.TotalMarginWidth +14,Control.View.RowHeight-1,Control.ClientWidth,1); + // } + + //RENDER SPAN MARGIN + if (SpanFound && Control._SyntaxBox.ScopeIndicatorColor != Color.Transparent && + Control._SyntaxBox.ShowScopeIndicator) + { + if (RowIndex >= FirstSpanRow && RowIndex <= LastSpanRow) + bbuff.FillRect(Control._SyntaxBox.ScopeIndicatorColor, Control.View.TotalMarginWidth + 14, 0, 2, + Control.View.RowHeight); + + if (RowIndex == FirstSpanRow) + bbuff.FillRect(Control._SyntaxBox.ScopeIndicatorColor, Control.View.TotalMarginWidth + 14, 0, 4, + 2); + + if (RowIndex == LastSpanRow) + bbuff.FillRect(Control._SyntaxBox.ScopeIndicatorColor, Control.View.TotalMarginWidth + 14, + Control.View.RowHeight - 2, 4, 2); + } + + if (Control._SyntaxBox.ShowRevisionMarks) + { + if (xtr.RevisionMark == RowRevisionMark.BeforeSave) + { + bbuff.FillRect(Control._SyntaxBox.RevisionMarkBeforeSave, + Control.View.TotalMarginWidth + 1, 0, 3, Control.View.RowHeight); + } + else if (xtr.RevisionMark == RowRevisionMark.AfterSave) + { + bbuff.FillRect(Control._SyntaxBox.RevisionMarkAfterSave, + Control.View.TotalMarginWidth + 1, 0, 3, Control.View.RowHeight); + } + } + } + } + + + //draws aControl.Selection.LogicalBounds row in the backbuffer + private void RenderSelection(int RowIndex) + { + if (RowIndex <= Control.Document.Count - 1 && Control.Selection.IsValid) + { + Row xtr = Control.Document[RowIndex]; + if (!xtr.IsCollapsed) + { + if ((RowIndex > Control.Selection.LogicalBounds.FirstRow) && + (RowIndex < Control.Selection.LogicalBounds.LastRow)) + { + int width = MeasureRow(xtr, xtr.Text.Length).Width + MeasureString("¶").Width + 3; + RenderBox(Control.View.TextMargin, 0, Math.Max(width - Control.View.ClientAreaStart, 0), + Control.View.RowHeight); + } + else if ((RowIndex == Control.Selection.LogicalBounds.FirstRow) && + (RowIndex == Control.Selection.LogicalBounds.LastRow)) + { + int start = + MeasureRow(xtr, Math.Min(xtr.Text.Length, Control.Selection.LogicalBounds.FirstColumn)). + Width; + int width = + MeasureRow(xtr, Math.Min(xtr.Text.Length, Control.Selection.LogicalBounds.LastColumn)). + Width - start; + RenderBox(Control.View.TextMargin + start - Control.View.ClientAreaStart, 0, width, + Control.View.RowHeight); + } + else if (RowIndex == Control.Selection.LogicalBounds.LastRow) + { + int width = + MeasureRow(xtr, Math.Min(xtr.Text.Length, Control.Selection.LogicalBounds.LastColumn)). + Width; + RenderBox(Control.View.TextMargin, 0, Math.Max(width - Control.View.ClientAreaStart, 0), + Control.View.RowHeight); + } + else if (RowIndex == Control.Selection.LogicalBounds.FirstRow) + { + int start = + MeasureRow(xtr, Math.Min(xtr.Text.Length, Control.Selection.LogicalBounds.FirstColumn)). + Width; + int width = MeasureRow(xtr, xtr.Text.Length).Width + MeasureString("¶").Width + 3 - start; + RenderBox(Control.View.TextMargin + start - Control.View.ClientAreaStart, 0, width, + Control.View.RowHeight); + } + } + else + { + RenderCollapsedSelection(RowIndex); + } + } + } + + private void RenderCollapsedSelection(int RowIndex) + { + Row xtr = Control.Document[RowIndex]; + if ((RowIndex > Control.Selection.LogicalBounds.FirstRow) && + (RowIndex < Control.Selection.LogicalBounds.LastRow)) + { + int width = MeasureRow(xtr, xtr.Expansion_EndChar).Width; + RenderBox(Control.View.TextMargin, 0, Math.Max(width - Control.View.ClientAreaStart, 0), + Control.View.RowHeight); + } + else if ((RowIndex == Control.Selection.LogicalBounds.FirstRow) && + (RowIndex == Control.Selection.LogicalBounds.LastRow)) + { + int start = + MeasureRow(xtr, Math.Min(xtr.Text.Length, Control.Selection.LogicalBounds.FirstColumn)).Width; + int min = Math.Min(xtr.Text.Length, Control.Selection.LogicalBounds.LastColumn); + min = Math.Min(min, xtr.Expansion_EndChar); + int width = MeasureRow(xtr, min).Width - start; + RenderBox(Control.View.TextMargin + start - Control.View.ClientAreaStart, 0, width, + Control.View.RowHeight); + } + else if (RowIndex == Control.Selection.LogicalBounds.LastRow) + { + int width = + MeasureRow(xtr, Math.Min(xtr.Text.Length, Control.Selection.LogicalBounds.LastColumn)).Width; + RenderBox(Control.View.TextMargin, 0, Math.Max(width - Control.View.ClientAreaStart, 0), + Control.View.RowHeight); + } + else if (RowIndex == Control.Selection.LogicalBounds.FirstRow) + { + int start = + MeasureRow(xtr, Math.Min(xtr.Text.Length, Control.Selection.LogicalBounds.FirstColumn)).Width; + int width = MeasureRow(xtr, Math.Min(xtr.Text.Length, xtr.Expansion_EndChar)).Width - start; + RenderBox(Control.View.TextMargin + start - Control.View.ClientAreaStart, 0, width, + Control.View.RowHeight); + } + + if (Control.Selection.LogicalBounds.LastRow > RowIndex && + Control.Selection.LogicalBounds.FirstRow <= RowIndex) + { + int start = xtr.Expansion_PixelEnd; + int end = xtr.Expansion_EndRow.Expansion_PixelStart - start + Control.View.TextMargin; + //start+=100; + //end=200; + RenderBox(start - Control.View.ClientAreaStart, 0, end, Control.View.RowHeight); + } + + RowIndex = xtr.Expansion_EndRow.Index; + xtr = xtr.Expansion_EndRow; + + if (Control.Selection.LogicalBounds.FirstRow <= RowIndex && + Control.Selection.LogicalBounds.LastRow >= RowIndex) + { + int endchar = Control.Selection.LogicalBounds.LastRow != RowIndex + ? xtr.Text.Length + : Math.Min(Control.Selection.LogicalBounds.LastColumn, xtr.Text.Length); + + int end = MeasureRow(xtr, endchar).Width; + end += xtr.Expansion_PixelStart; + end -= MeasureRow(xtr, xtr.Expansion_StartChar).Width; + + int start; + + if (Control.Selection.LogicalBounds.FirstRow == RowIndex) + { + int startchar = Math.Max(Control.Selection.LogicalBounds.FirstColumn, xtr.Expansion_StartChar); + start = MeasureRow(xtr, startchar).Width; + start += xtr.Expansion_PixelStart; + start -= MeasureRow(xtr, xtr.Expansion_StartChar).Width; + } + else + { + start = MeasureRow(xtr, xtr.Expansion_StartChar).Width; + start += xtr.Expansion_PixelStart; + start -= MeasureRow(xtr, xtr.Expansion_StartChar).Width; + } + + end -= start; + + if (Control.Selection.LogicalBounds.LastRow != RowIndex) + end += 6; + + + RenderBox(Control.View.TextMargin + start - Control.View.ClientAreaStart, 0, end, Control.View.RowHeight); + } + } + + private void RenderBox(int x, int y, int width, int height) + { + GFX.SelectionBuffer.RenderTo(GFX.BackBuffer, x, y, width, height, x, y); + } + + private TextPoint ColumnFromPixel(int RowIndex, int X) + { + Row xtr = Control.Document[RowIndex]; + X -= Control.View.TextMargin - 2 - Control.View.FirstVisibleColumn*Control.View.CharWidth; + + if (xtr.Count == 0) + { + if (Control.VirtualWhitespace && Control.View.CharWidth > 0) + { + return new TextPoint(X/Control.View.CharWidth, RowIndex); + } + + return new TextPoint(0, RowIndex); + } + + + int taborig = -Control.View.FirstVisibleColumn*Control.View.CharWidth + Control.View.TextMargin; + int xpos = Control.View.TextMargin - Control.View.ClientAreaStart; + int CharNo = 0; + int TotWidth = 0; + Word Word = null; + int WordStart = 0; + foreach (Word w in xtr.FormattedWords) + { + Word = w; + WordStart = TotWidth; + + if (w.Type == WordType.Word && w.Style != null) + SetStringFont(w.Style.Bold, w.Style.Italic, w.Style.Underline); + else + SetStringFont(false, false, false); + + int tmpWidth = + GFX.StringBuffer.DrawTabbedString(w.Text, xpos + TotWidth, 0, taborig, Control.PixelTabSize).Width; + + if (TotWidth + tmpWidth >= X) + { + break; + } + + //dont do this for the last word + if (w != xtr.FormattedWords[xtr.FormattedWords.Count - 1]) + { + TotWidth += tmpWidth; + CharNo += w.Text.Length; + } + } + + //CharNo is the index in the text where 'word' starts + //'Word' is the word object that contains the 'X' + //'WordStart' contains the pixel start position for 'Word' + + if (Word != null) + if (Word.Type == WordType.Word && Word.Style != null) + SetStringFont(Word.Style.Bold, Word.Style.Italic, Word.Style.Underline); + else + SetStringFont(false, false, false); + + //now , lets measure each char and get a correct pos + + bool found = false; + if (Word != null) + foreach (char c in Word.Text) + { + int tmpWidth = + GFX.StringBuffer.DrawTabbedString(c + "", xpos + WordStart, 0, taborig, Control.PixelTabSize). + Width; + if (WordStart + tmpWidth >= X) + { + found = true; + break; + } + CharNo++; + WordStart += tmpWidth; + } + + if (!found && Control.View.CharWidth > 0 && Control.VirtualWhitespace) + { + int xx = X - WordStart; + int cn = xx/Control.View.CharWidth; + CharNo += cn; + } + + if (CharNo < 0) + CharNo = 0; + + return new TextPoint(CharNo, RowIndex); + } + + private Point GetTextPointPixelPos(TextPoint tp) + { + Row xtr = Control.Document[tp.Y]; + if (xtr.RowState == RowState.SpanParsed) + Control.Document.Parser.ParseRow(xtr.Index, true); + + Row r = xtr.IsCollapsedEndPart ? xtr.Expansion_StartRow : xtr; + + int index = r.VisibleIndex; + int yPos = (index - Control.View.FirstVisibleRow); + if (yPos < 0 || yPos > Control.View.VisibleRowCount) + return new Point(-1, -1); + + yPos *= Control.View.RowHeight; + + bool Collapsed = (xtr.IsCollapsedEndPart); + int pos = MeasureRow(xtr, tp.X).Width + 1; + + + if (Collapsed) + { + pos += xtr.Expansion_PixelStart; + pos -= MeasureRow(xtr, xtr.Expansion_StartChar).Width; + } + + int xPos = pos + Control.View.TextMargin - Control.View.ClientAreaStart; + + if (xPos < Control.View.TextMargin || xPos > Control.View.ClientAreaWidth + Control.View.TextMargin) + return new Point(-1, -1); + + + return new Point(xPos, yPos); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/Selection.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/Selection.cs new file mode 100644 index 0000000..0268616 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/Selection.cs @@ -0,0 +1,440 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using Alsing.SourceCode; + +namespace Alsing.Windows.Forms.SyntaxBox +{ + /// + /// Selection class used by the SyntaxBoxControl + /// + public class Selection + { + /// + /// Event fired when the selection has changed. + /// + public event EventHandler Change = null; + + private void PositionChange(object s, EventArgs e) + { + OnChange(); + } + + private void OnChange() + { + if (Change != null) + Change(this, null); + } + + #region Instance constructors + + /// + /// Selection Constructor. + /// + /// Control that will use this selection + public Selection(EditViewControl control) + { + Control = control; + Bounds = new TextRange(); + } + + #endregion Instance constructors + + #region Public instance properties + + /// + /// Gets the text of the active selection + /// + public String Text + { + get + { + if (!IsValid) + { + return ""; + } + else + { + return Control.Document.GetRange(LogicalBounds); + } + } + set + { + if (Text == value) + return; + + //selection text bug fix + // + //selection gets too short if \n is used instead of newline + string tmp = value.Replace(Environment.NewLine, "\n"); + tmp = tmp.Replace("\n", Environment.NewLine); + value = tmp; + //--- + + + TextPoint oCaretPos = Control.Caret.Position; + int nCaretX = oCaretPos.X; + int nCaretY = oCaretPos.Y; + Control.Document.StartUndoCapture(); + DeleteSelection(); + Control.Document.InsertText(value, oCaretPos.X, oCaretPos.Y); + SelLength = value.Length; + if (nCaretX != oCaretPos.X || nCaretY != oCaretPos.Y) + + { + Control.Caret.Position = new TextPoint(Bounds.LastColumn, Bounds.LastRow); + } + + Control.Document.EndUndoCapture(); + Control.Document.InvokeChange(); + } + } + + /// + /// Returns the normalized positions of the selection. + /// Swapping start and end values if the selection is reversed. + /// + public TextRange LogicalBounds + { + get + { + var r = new TextRange(); + if (Bounds.FirstRow < Bounds.LastRow) + { + return Bounds; + } + else if (Bounds.FirstRow == Bounds.LastRow && Bounds.FirstColumn < Bounds.LastColumn) + { + return Bounds; + } + else + { + r.FirstColumn = Bounds.LastColumn; + r.FirstRow = Bounds.LastRow; + r.LastColumn = Bounds.FirstColumn; + r.LastRow = Bounds.FirstRow; + return r; + } + } + } + + /// + /// Returns true if the selection contains One or more chars + /// + public bool IsValid + { + get + { + return (LogicalBounds.FirstColumn != LogicalBounds.LastColumn || + LogicalBounds.FirstRow != LogicalBounds.LastRow); + } + } + + /// + /// gets or sets the length of the selection in chars + /// + public int SelLength + { + get + { + var p1 = new TextPoint(Bounds.FirstColumn, Bounds.FirstRow); + var p2 = new TextPoint(Bounds.LastColumn, Bounds.LastRow); + int i1 = Control.Document.PointToIntPos(p1); + int i2 = Control.Document.PointToIntPos(p2); + return i2 - i1; + } + set { SelEnd = SelStart + value; } + } + + /// + /// Gets or Sets the Selection end as an index in the document text. + /// + public int SelEnd + { + get + { + var p = new TextPoint(Bounds.LastColumn, Bounds.LastRow); + return Control.Document.PointToIntPos(p); + } + set + { + TextPoint p = Control.Document.IntPosToPoint(value); + Bounds.LastColumn = p.X; + Bounds.LastRow = p.Y; + } + } + + + /// + /// Gets or Sets the Selection start as an index in the document text. + /// + public int SelStart + { + get + { + var p = new TextPoint(Bounds.FirstColumn, Bounds.FirstRow); + return Control.Document.PointToIntPos(p); + } + set + { + TextPoint p = Control.Document.IntPosToPoint(value); + Bounds.FirstColumn = p.X; + Bounds.FirstRow = p.Y; + } + } + + /// + /// Gets or Sets the logical Selection start as an index in the document text. + /// + public int LogicalSelStart + { + get + { + var p = new TextPoint(LogicalBounds.FirstColumn, LogicalBounds.FirstRow); + return Control.Document.PointToIntPos(p); + } + set + { + TextPoint p = Control.Document.IntPosToPoint(value); + Bounds.FirstColumn = p.X; + Bounds.FirstRow = p.Y; + } + } + + #endregion Public instance properties + + #region Public instance methods + + /// + /// Indent the active selection one step. + /// + public void Indent() + { + if (!IsValid) + return; + + Row xtr = null; + var ActionGroup = new UndoBlockCollection(); + for (int i = LogicalBounds.FirstRow; i <= LogicalBounds.LastRow; i++) + { + xtr = Control.Document[i]; + xtr.Text = "\t" + xtr.Text; + var b = new UndoBlock(); + b.Action = UndoAction.InsertRange; + b.Text = "\t"; + b.Position.X = 0; + b.Position.Y = i; + ActionGroup.Add(b); + } + if (ActionGroup.Count > 0) + Control.Document.AddToUndoList(ActionGroup); + Bounds = LogicalBounds; + Bounds.FirstColumn = 0; + Bounds.LastColumn = xtr.Text.Length; + Control.Caret.Position.X = LogicalBounds.LastColumn; + Control.Caret.Position.Y = LogicalBounds.LastRow; + } + + /// + /// Outdent the active selection one step + /// + public void Outdent() + { + if (!IsValid) + return; + + Row xtr = null; + var ActionGroup = new UndoBlockCollection(); + for (int i = LogicalBounds.FirstRow; i <= LogicalBounds.LastRow; i++) + { + xtr = Control.Document[i]; + var b = new UndoBlock(); + b.Action = UndoAction.DeleteRange; + b.Position.X = 0; + b.Position.Y = i; + ActionGroup.Add(b); + string s = xtr.Text; + if (s.StartsWith("\t")) + { + b.Text = s.Substring(0, 1); + s = s.Substring(1); + } + if (s.StartsWith(" ")) + { + b.Text = s.Substring(0, 4); + s = s.Substring(4); + } + xtr.Text = s; + } + if (ActionGroup.Count > 0) + Control.Document.AddToUndoList(ActionGroup); + Bounds = LogicalBounds; + Bounds.FirstColumn = 0; + Bounds.LastColumn = xtr.Text.Length; + Control.Caret.Position.X = LogicalBounds.LastColumn; + Control.Caret.Position.Y = LogicalBounds.LastRow; + } + + + public void Indent(string Pattern) + { + if (!IsValid) + return; + + Row xtr = null; + var ActionGroup = new UndoBlockCollection(); + for (int i = LogicalBounds.FirstRow; i <= LogicalBounds.LastRow; i++) + { + xtr = Control.Document[i]; + xtr.Text = Pattern + xtr.Text; + var b = new UndoBlock(); + b.Action = UndoAction.InsertRange; + b.Text = Pattern; + b.Position.X = 0; + b.Position.Y = i; + ActionGroup.Add(b); + } + if (ActionGroup.Count > 0) + Control.Document.AddToUndoList(ActionGroup); + Bounds = LogicalBounds; + Bounds.FirstColumn = 0; + Bounds.LastColumn = xtr.Text.Length; + Control.Caret.Position.X = LogicalBounds.LastColumn; + Control.Caret.Position.Y = LogicalBounds.LastRow; + } + + /// + /// Outdent the active selection one step + /// + public void Outdent(string Pattern) + { + if (!IsValid) + return; + + Row xtr = null; + var ActionGroup = new UndoBlockCollection(); + for (int i = LogicalBounds.FirstRow; i <= LogicalBounds.LastRow; i++) + { + xtr = Control.Document[i]; + var b = new UndoBlock(); + b.Action = UndoAction.DeleteRange; + b.Position.X = 0; + b.Position.Y = i; + ActionGroup.Add(b); + string s = xtr.Text; + if (s.StartsWith(Pattern)) + { + b.Text = s.Substring(0, Pattern.Length); + s = s.Substring(Pattern.Length); + } + xtr.Text = s; + } + if (ActionGroup.Count > 0) + Control.Document.AddToUndoList(ActionGroup); + Bounds = LogicalBounds; + Bounds.FirstColumn = 0; + Bounds.LastColumn = xtr.Text.Length; + Control.Caret.Position.X = LogicalBounds.LastColumn; + Control.Caret.Position.Y = LogicalBounds.LastRow; + } + + /// + /// Delete the active selection. + /// + /// + public void DeleteSelection() + { + TextRange r = LogicalBounds; + + int x = r.FirstColumn; + int y = r.FirstRow; + Control.Document.DeleteRange(r); + Control.Caret.Position.X = x; + Control.Caret.Position.Y = y; + ClearSelection(); + Control.ScrollIntoView(); + } + + /// + /// Clear the active selection + /// + /// + public void ClearSelection() + { + Bounds.FirstColumn = Control.Caret.Position.X; + Bounds.FirstRow = Control.Caret.Position.Y; + Bounds.LastColumn = Control.Caret.Position.X; + Bounds.LastRow = Control.Caret.Position.Y; + } + + /// + /// Make a selection from the current selection start to the position of the caret + /// + public void MakeSelection() + { + Bounds.LastColumn = Control.Caret.Position.X; + Bounds.LastRow = Control.Caret.Position.Y; + } + + /// + /// Select all text. + /// + public void SelectAll() + { + Bounds.FirstColumn = 0; + Bounds.FirstRow = 0; + Bounds.LastColumn = Control.Document[Control.Document.Count - 1].Text.Length; + Bounds.LastRow = Control.Document.Count - 1; + Control.Caret.Position.X = Bounds.LastColumn; + Control.Caret.Position.Y = Bounds.LastRow; + Control.ScrollIntoView(); + } + + #endregion Public instance methods + + #region Public instance fields + + /// + /// The bounds of the selection + /// + /// + private TextRange _Bounds; + + public TextRange Bounds + { + get { return _Bounds; } + set + { + if (_Bounds != null) + { + _Bounds.Change -= Bounds_Change; + } + + _Bounds = value; + _Bounds.Change += Bounds_Change; + OnChange(); + } + } + + private void Bounds_Change(object s, EventArgs e) + { + OnChange(); + } + + #endregion Public instance fields + + #region Protected instance fields + + private readonly EditViewControl Control; + + #endregion Protected instance fields + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/Structs.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/Structs.cs new file mode 100644 index 0000000..1dc5c17 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Classes/Structs.cs @@ -0,0 +1,235 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using Alsing.Drawing.GDI; + +namespace Alsing.Windows.Forms.SyntaxBox +{ + /// + /// Indent styles used by the control + /// + public enum IndentStyle + { + /// + /// Caret is always confined to the first column when a new line is inserted + /// + None = 0, + /// + /// New lines inherit the same indention as the previous row. + /// + LastRow = 1, + /// + /// New lines get their indention from the scoping level. + /// + Scope = 2, + /// + /// New lines get thir indention from the scoping level or from the previous row + /// depending on which is most indented. + /// + Smart = 3, + } +} + +namespace Alsing.Windows.Forms.SyntaxBox +{ + /// + /// Text actions that can be performed by the SyntaxBoxControl + /// + public enum EditAction + { + /// + /// The control is not performing any action + /// + None = 0, + /// + /// The control is in Drag Drop mode + /// + DragText = 1, + /// + /// The control is selecting text + /// + SelectText = 2 + } +} + +namespace Alsing.Windows.Forms.SyntaxBox.Painter +{ + /// + /// View point struct used by the SyntaxBoxControl. + /// The struct contains information about various rendering parameters that the IPainter needs. + /// + public struct ViewPoint + { + /// + /// The action that the SyntaxBoxControl is currently performing + /// + public EditAction Action; + + /// + /// Width of a char (space) in pixels + /// + public int CharWidth; + + + /// + /// Height of the client area in pixels + /// + public int ClientAreaStart; + + /// + /// Width of the client area in pixels + /// + public int ClientAreaWidth; + + /// + /// Index of the first visible column + /// + public int FirstVisibleColumn; + + /// + /// Index of the first visible row + /// + public int FirstVisibleRow; + + /// + /// Width of the gutter margin in pixels + /// + public int GutterMarginWidth; + + /// + /// Width of the Linenumber margin in pixels + /// + public int LineNumberMarginWidth; + + /// + /// Height of a row in pixels + /// + public int RowHeight; + + /// + /// Width of the text margin (sum of gutter + linenumber + folding margins) + /// + public int TextMargin; + + /// + /// + /// + public int TotalMarginWidth; + + /// + /// Number of rows that can be displayed in the current view + /// + public int VisibleRowCount; + + /// + /// Used for offsetting the screen in y axis. + /// + public int YOffset; + + //document items + } + + + /// + /// Struct used by the NativePainter class. + /// + public struct RenderItems + { + /// + /// For internal use only + /// + public GDISurface BackBuffer; //backbuffer surface + + /// + /// For internal use only + /// + public GDIBrush BackgroundBrush; //background brush + + /// + /// For internal use only + /// + public GDIFont FontBold; //Font , bold + + /// + /// For internal use only + /// + public GDIFont FontBoldItalic; //Font , bold & italic + + /// + /// For internal use only + /// + public GDIFont FontBoldItalicUnderline; //Font , bold & italic + + /// + /// For internal use only + /// + public GDIFont FontBoldUnderline; //Font , bold + + /// + /// For internal use only + /// + public GDIFont FontItalic; //Font , italic + + /// + /// For internal use only + /// + public GDIFont FontItalicUnderline; //Font , italic + + /// + /// For internal use only + /// + public GDIFont FontNormal; //Font , no decoration + + /// + /// For internal use only + /// + public GDIFont FontUnderline; //Font , no decoration + + /// + /// For internal use only + /// + public GDIBrush GutterMarginBorderBrush; //Gutter magrin brush + + /// + /// For internal use only + /// + public GDIBrush GutterMarginBrush; //Gutter magrin brush + + /// + /// For internal use only + /// + public GDIBrush HighLightLineBrush; //background brush + + /// + /// For internal use only + /// + public GDIBrush LineNumberMarginBorderBrush; //linenumber margin brush + + /// + /// For internal use only + /// + public GDIBrush LineNumberMarginBrush; //linenumber margin brush + + /// + /// For internal use only + /// + public GDIBrush OutlineBrush; //background brush + + /// + /// For internal use only + /// + public GDISurface SelectionBuffer; //backbuffer surface + + /// + /// For internal use only + /// + public GDISurface StringBuffer; //backbuffer surface + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Collections/CollectionBase.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Collections/CollectionBase.cs new file mode 100644 index 0000000..1353b25 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Collections/CollectionBase.cs @@ -0,0 +1,140 @@ +// * +// * Copyright (C) 2005 Roger Alsing : http://www.puzzleframework.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; + +namespace Puzzle.Collections +{ + + #region EventArgs and Delegate + + public class CollectionEventArgs : EventArgs + { + public readonly int Index; + public readonly object Item; + + public CollectionEventArgs() + { + try {} + #region ERROR HANDLER +#if DEBUG_COMPONA + catch (Exception x) + { + System.Diagnostics.Debug.Write(x, "Puzzle"); + throw; + } +#else + catch + { + throw; + } +#endif + + #endregion + } + + public CollectionEventArgs(object item, int index) + { + #region PARAMETER VALIDATIONS + + if (item == null) + throw new ArgumentNullException("item"); // Throw error if validation failed for "item" + + #endregion + + //IMPLEMENTATION + try + { + Index = index; + Item = item; + } + #region ERROR HANDLER +#if DEBUG_COMPONA + catch (Exception x) + { + System.Diagnostics.Debug.Write(x, "Puzzle"); + throw; + } +#else + catch + { + throw; + } +#endif + + #endregion + } + } + + public delegate void CollectionEventHandler(object sender, CollectionEventArgs e); + + #endregion + + public abstract class CollectionBase : System.Collections.CollectionBase + { + #region Events + + public event CollectionEventHandler ItemAdded = null; + + protected virtual void OnItemAdded(int index, object item) + { + if (ItemAdded != null) + { + var e = new CollectionEventArgs(item, index); + + ItemAdded(this, e); + } + } + + public event CollectionEventHandler ItemRemoved = null; + + protected virtual void OnItemRemoved(int index, object item) + { + if (ItemRemoved != null) + { + var e = new CollectionEventArgs(item, index); + + ItemRemoved(this, e); + } + } + + public event EventHandler ItemsCleared = null; + + protected virtual void OnItemsCleared() + { + if (ItemsCleared != null) + ItemsCleared(this, EventArgs.Empty); + } + + #endregion + + #region Overrides + + protected override void OnClearComplete() + { + base.OnClearComplete(); + OnItemsCleared(); + } + + protected override void OnRemoveComplete(int index, object value) + { + base.OnRemoveComplete(index, value); + OnItemRemoved(index, value); + } + + protected override void OnInsertComplete(int index, object value) + { + base.OnInsertComplete(index, value); + OnItemAdded(index, value); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Compona.Syntaxbox.xml b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Compona.Syntaxbox.xml new file mode 100644 index 0000000..8116f50 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Compona.Syntaxbox.xml @@ -0,0 +1,4457 @@ + + + + Alsing.SyntaxBox + + + + + Summary description for GDIObject. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + Summary description for TextStyleDesignerDialog. + + + + + Required designer variable. + + + + + Clean up any resources being used. + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + SyntaxDefinition list class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Delegate used when triggering keyboard actions + + + + + Instances of this class represents a relation between pressed keys and a delegate + + + + + Determines what key to associate with the action + + + + + Draws a 2px Raised Border for the ThumbControl + + + + + + Required designer variable. + + + + + Clean up any resources being used. + + true if managed resources should be disposed; otherwise, false. + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Word types + + + + + The word is a normal word/text + + + + + The word is a space char + + + + + The word is a tab char + + + + + The word object class represents a word in a Row object + + + + + Color of the error wave lines + + + + + True if the word has error wave lines + + + + + The ToolTip text for the word + + + + + The pattern that created this word + + + + + The parent row + + + + + The parent span + + + + + The style of the word + + + + + The text of the word + + + + + The type of the word + + + + + Gets the index of the word in the parent row + + + + + Returns the column where the word starts on the containing row. + + + + + TextStyles are used to describe the apperance of text. + + + + + Name of the style + + + + + Gets or Sets if the style uses a Bold font + + + Gets or Sets if the style uses an Italic font + + + Gets or Sets if the style uses an Underlined font + + + Gets or Sets the ForeColor of the style + + + Gets or Sets the BackColor of the style + + + Default constructor + + + + + Returns true if no color have been assigned to the backcolor + + + + + Required designer variable. + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Clean up any resources being used. + + + + + + + + + + PatternScanResult struct is redurned by the Pattern class when an .IndexIn call has been performed. + + + + + The index on which the pattern was found in the source string + + + + + The string that was found , this is always the same as the pattern StringPattern property if the pattern is a simple pattern. + if the pattern is complex this field will contain the string that was found by the scan. + + + + + A List containing patterns. + this could be for example a list of keywords or operators + + + + + Gets or Sets if this list contains case seinsitive patterns + + + + + For public use only + + + + + The name of the pattern list + + + + + Gets or Sets if the patterns in this list should be case normalized + + + + + + + + + + The parent spanDefinition of this list + + + + + for public use only + + + + + + + + + + For public use only + + + + + Gets or Sets the TextStyle that should be assigned to patterns in this list + + + + + + + + + + + + + + + + + + + + + + + + + + + + Summary description for FindReplace. + + + + + Required designer variable. + + + + + Default constructor for the FindReplaceForm. + + + + + Creates a FindReplaceForm that will be assigned to a specific Owner control. + + The SyntaxBox that will use the FindReplaceForm + + + + Clean up any resources being used. + + + + + Displays the FindReplaceForm and sets it in "Find" mode. + + + + + Displays the FindReplaceForm and sets it in "Replace" mode. + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + + + + + + Parser interface. + Implement this interface if you want to create your own parser. + + + + + Initializes the parser with a spcified SyntaxFile + + Filename of the SyntaxFile that should be used + + + + + + + + + + + Initializes the parser with a spcified syntaxDefinition object + + The Language object to assign to the parser + + + + Called by the SyntaxDocument object when a row should be parsed + + The row index in the document + true if keywords and operators should be parsed , false if only a span parse should be performed + + + + Called by the SyntaxDocument object when a row must be preview parsed. + + Row index in the document + + + + Gets or Sets the Document object for this parser + + + + + Gets or Sets the SyntaxDefinition for this parser + + + + + + + + + + + + + + + + The SyntaxDocument is a component that is responsible for Parsing , Folding , Undo / Redo actions and various text actions. + + + + + Buffer containing undo actions + + + + + For public use only + + + + + + + + + + Gets or Sets if folding needs to be recalculated + + + + + List of rows that should be parsed + + + + + The active parser of the document + + + + + Tag property , lets the user store custom data in the row. + + + + + List of rows that is not hidden by folding + + + + + + + + + + + + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + + + + + + + For internal use only + + + + + Starts an Undo Capture. + This method can be called if you with to collect multiple text operations into one undo action + + + + + Ends an Undo capture and pushes the collected actions onto the undostack + + + + + + + ReParses the document + + + + + Removes all bookmarks in the document + + + + + Removes all breakpoints in the document. + + + + + Call this method to ensure that a specific row is fully parsed + + + + + + Call this method to make the SyntaxDocument raise the Changed event + + + + + Performs a span parse on all rows. No Keyword colorizing + + + + + Parses all rows , either a span parse or a full parse with keyword colorizing + + + + + Folds all foldable rows + + + + + UnFolds all foldable rows + + + + + Parses a chunk of 1000 rows , this is not thread safe + + + + + Parse a chunk of rows, this is not thread safe + + The number of rows to parse + + + + Add a new row with the specified text to the bottom of the document + + Text to add + The row that was added + + + + Add a new row with the specified text to the bottom of the document + + Text to add + true if and undo action should be added to the undo stack + The row that was added + + + + Insert a text at the specified row index + + Text to insert + Row index where the text should be inserted + The row that was inserted + + + + Insert a text at the specified row index + + Text to insert + Row index where the text should be inserted + true if and undo action should be added to the undo stack + The row that was inserted + + + + Remove a row at specified row index + + index of the row that should be removed + + + + Remove a row at specified row index + + index of the row that should be removed + true if and undo action should be added to the undo stack + + + + + Deletes a range of text + + the range that should be deleted + + + + Forces a row to be parsed + + Row to parse + true if keywords and operators should be parsed + + + + Forces a row to be parsed + + Row to parse + + + + Gets the row index of the next bookmarked row + + Start index + Index of the next bookmarked row + + + + Gets the row index of the previous bookmarked row + + Start index + Index of the previous bookmarked row + + + + Deletes a range of text + + Range to delete + true if the actions should be pushed onto the undo stack + + + + Get a range of text + + The range to get + string containing the text inside the given range + + + + Returns the index of a given row + + row to find + Index of the given row + + + + Clear all content in the document + + + + + Inserts a text into the document at a given column,row. + + Text to insert + Column + Row index + TextPoint containing the end of the inserted text + + + + Inserts a text into the document at a given column,row. + + Text to insert + Column + Row index + true if this action should be pushed onto the undo stack + TextPoint containing the end of the inserted text + + + + Gets a Range from a given text + + + + + + + + + Add an action to the undo stack + + action to add + + + + Perform an undo action + + The position where the caret should be placed + + + + Gets a span object form a given column , Row index + (This only applies if the row is fully parsed) + + Column and Rowindex + span object at the given position + + + + Gets a Word object form a given column , Row index + (this only applies if the row is fully parsed) + + Column and Rowindex + Word object at the given position + + + + Gets a Word object form a given column , Row index + (this only applies if the row is fully parsed) + + Column and Rowindex + Word object at the given position + + + + Call this method to make the document raise the RowParsed event + + + + + + Call this method to recalculate the visible rows + + + + + Converts a Column/Row index position into a char index + + TextPoint where x is column and y is row index + Char index in the document text + + + + Converts a char index into a Column/Row index + + Char index to convert + Point where x is column and y is row index + + + + Toggle expansion of a given row + + + + + + Perform an redo action + + The position where the caret should be placed + + + + Sets a syntax file, from an embedded resource. + + The assembly which contains the embedded resource. + The name of the resource. + + + + Event that is raised when there is no more rows to parse + + + + + Raised when the parser is active + + + + + Raised when the document content is changed + + + + + Raised when the modified flag has changed + + + + + Raised when a row have been parsed + + + + + Raised when a row have been deleted + + + + + Gets or Sets the Maximum number of entries in the undobuffer + + + + + Get or Set the Modified flag + + + + + Get or Set the Name of the Syntaxfile to use + + + + + Gets or Sets if the document should use folding or not + + + + + Gets if the document is fully parsed + + + + + Returns the row at the specified index + + + + + Gets the row count of the document + + + + + Gets or Sets the text of the entire document + + + + + Gets and string array containing the text of all rows. + + + + + Pattern matcher that matches culture invariant integer values + + + + + Base implementation for pattern matchers + + + + + Pattern matcher that matches culture invariant decimal values + + + + + + + + + + Measures the length of a specific row in pixels + + + + + Renders the entire screen + + + + + Renders the entire screen + + Target Graphics object + + + + Renders the caret only + + + + + + + + + + + + Returns a Point (Column,Row in the active document) from the x and y screen pixel positions. + + + + + Called by the control to notify the Painter object that the client area has resized. + + + + + Called by the control to notify the Painter object that one or more Appearance properties has changed. + + + + + Measures the length of a string in pixels + + + + + Class representing a point in a text. + where x is the column and y is the row. + + + + + + + + + + + + + + + + + + + + + + + + + + + Event fired when the X or Y property has changed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Parser event handler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Load a specific syntax file + + File name + SyntaxDefinition object + + + + + + + + + + + + Load a specific syntax from an xml string + + + + + + + Summary description for GotoLine. + + + + + Required designer variable. + + + + + Default constructor for the GotoLineForm. + + + + + Creates a GotoLineForm that will be assigned to a specific Owner control. + + The SyntaxBox that will use the GotoLineForm + The number of lines in the owner control + + + + Clean up any resources being used. + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Summary description for SplitViewChildControl. + + + + + Gets or Sets if the Left side thumb control is visible or not. + + + + + Getd ot Sets if the Top thumb control is visible or not. + + + + + + + + + + File type struct + + + + + The file type extension + + + + + The name of the file type + + + + + The SyntaxDefinition class describes a syntax.
+ It consists of a mainSpanDefinition , which is the start spanDefinition of the SyntaxDefinition
+ It also have a list of filetypes that is valid for this syntax
+
+ + Apply a Syntax to a SyntaxBox + + SyntaxBoxControl1.Document.SyntaxFile="C#.syn"; + + +
+ + + List containing the valid filetypes for this syntax + + + + + The start spanDefinition for this syntax + + + + + Name of the SyntaxDefinition + + + + + Gets all BlockTypes in a given syntax. + + + + + Event arg for Copy/Cut actions. + + + + + The text copied to the clipboard. + + + + + Event args passed to word mouse events of the syntaxbox + + + + + The mouse buttons that was pressed when the event fired + + + + + Reference to a mouse cursor , developers can assign new values here to display new cursors for a given pattern + + + + + The pattern that triggered the event + + + + + The word where the event was fired + + + + + Event args for mouse actions on the syntaxbox + + + + + The area of the row where the event was fired + + + + + The mousebuttons that was pressed when the event was fired + + + + + The X position of the mouse cursor when the event was fired + + + + + The Y position of the mouse cursor when the event was fired + + + + + The row where the event was fired + + + + + Describes in what area a mouse event occured on a row + + + + + Represents the gutter margin + + + + + Represents the LineNumber section + + + + + Represents the area where the folding symbols are shown + + + + + Represents the actual text part of a row + + + + + Event args passed to owner draw events of the syntaxbox + + + + + the bounds of the row + + + + + The graphics surface to draw on + + + + + The row to draw + + + + + Collection of KeyboardActions + + + + + spanDefinition class + + + The spanDefinition class represents a specific code/text element
+ such as a string , comment or the code itself.
+
+ a spanDefinition can contain keywords , operators , scopes and child spans.
+
+
+ For example , if we where to describe the syntax C#
+ we would have the following span:
+
+ Code span - the spanDefinition containing all the keywords and operators.
+ Singleline comment span - a spanDefinition that starts on // terminates at the end of a line.
+ Multiline comment span - a spanDefinition that starts on /* can span multiple rows and terminates on */.
+ String span - a spanDefinition that starts on " terminates on " or at the end of a line.
+ Char span - a spanDefinition that starts on ' terminates on ' or at the end of a line.
+
+ CHILD SPANS:
+ The code span would have all the other spans as childspans , since they can only appear inside the
+ code span . A string can for example never exist inside a comment in C#.
+ a spanDefinition can also have itself as a child span.
+ For example , the C# Code span can have itself as a childspan and use the scope patterns "{" and "}"
+ this way we can accomplish FOLDING since the parser will know where a new scope starts and ends.
+
+ SCOPES:
+ Scopes describe what patterns starts and what patterns end a specific spanDefinition.
+ For example , the C# Multiline Comment have the scope patterns /* and */
+
+ KEYWORDS:
+ A Keyword is a pattern that can only exist between separator chars.
+ For example the keyword "for" in c# is valid if it is contained in this string " for ("
+ but it is not valid if the containing string is " MyFormat "
+
+ OPERATORS:
+ Operators is the same thing as keywords but are valid even if there are no separator chars around it.
+ In most cases operators are only one or two chars such as ":" or "->"
+ operators in this context should not be mixed up with code operators such as "and" or "xor" in VB6
+ in this context they are keywords.
+
+
+
+
+ + + The background color of a span. + + + + + A list containing which spanDefinitions are valid child spans in a specific span. + eg. strings and comments are child spans for a code span + + + + + A list of keyword groups. + For example , one keyword group could be "keywords" and another could be "datatypes" + theese groups could have different color shemes assigned to them. + + + + + Gets or Sets if the spanDefinition can span multiple lines or if it should terminate at the end of a line. + + + + + The name of this span. + names are not required for span but can be a good help when interacting with the parser. + + + + + A list of operator groups. + Each operator group can contain its own operator patterns and its own color shemes. + + + + + A list of scopes , most span only contain one scope , eg a scope with start and end patterns "/*" and "*/" + for multiline comments, but in some cases you will need more scopes , eg. PHP uses both "<?" , "?>" and "<?PHP" , "PHP?>" + + + + + The style to use when colorizing the content of a span, + meaning everything in this span except keywords , operators and childspans. + + + + + Gets or Sets if the parser should terminate any child span when it finds an end scope pattern for this span. + for example %> in asp terminates any asp span even if it appears inside an asp string. + + + + + Default spanDefinition constructor + + + + + Returns false if any color has been assigned to the backcolor property + + + + + Parser state of a row + + + + + the row is not parsed + + + + + the row is span parsed + + + + + the row is both span and keyword parsed + + + + + The row class represents a row in a SyntaxDocument + + + + + The owner document + + + + + The first span that terminates on this row. + + + + + Segments that ends in this row + + + + + For public use only + + + + + + + + + + For public use only + + + + + For public use only + + + + + For public use only + + + + + + + + + + Collection of Image indices assigned to a row. + + + Add an image to the current row. + + MySyntaxBox.Caret.CurrentRow.Images.Add(3); + + + + + + For public use only + + + + + Returns true if the row is in the owner documents keyword parse queue + + + + + Returns true if the row is in the owner documents parse queue + + + + + The first collapsable span on this row. + + + + + Segments that start on this row + + + + + Object tag for storage of custom user data.. + + + Assign custom data to a row + + //custom data class + class CustomData{ + public int abc=123; + publci string def="abc"; + } + + ... + + //assign custom data to a row + Row MyRow=MySyntaxBox.Caret.CurrentRow; + CustomData MyData=new CustomData(); + MyData.abc=1337; + MyRow.Tag=MyData; + + ... + + //read custom data from a row + Row MyRow=MySyntaxBox.Caret.CurrentRow; + if (MyRow.Tag != null){ + CustomData MyData=(CustomData)MyRow.Tag; + if (MyData.abc==1337){ + //Do something... + } + } + + + + + + + + Get the Word enumerator for this row + + + + + + If the row is hidden inside a collapsed span , call this method to make the collapsed segments expanded. + + + + + Adds this row to the parse queue + + + + + Assigns a new text to the row. + + + + + + Call this method to make all words match the case of their patterns. + (this only applies if the row is fully parsed) + + + + + Force a span parse on the row. + + + + + Forces the parser to parse this row directly + + true if keywords and operators should be parsed + + + + Returns the whitespace string at the begining of this row. + + a string containing the whitespace at the begining of this row + + + + Adds a word object to this row + + Word object + + + + Returns the index of a specific Word object + + Word object to find + index of the word in the row + + + + For public use only + + + + + + + + + For public use only + + + + + + + + + For public use only + + + + + + + + + For public use only + + + + + + + + + For public use only + + + + + + + + + For public use only + + + + + + + + + For public use only + + + + + + + + + For public use only + + + + + + + + + The parse state of this row + + + Test if the current row is fully parsed. + + if (MySyntaxBox.Caret.CurrentRow.RowState==RowState.AllParsed) + { + //do something + } + + + + + + Gets or Sets if this row has a bookmark or not. + + + + + Gets or Sets if this row has a breakpoint or not. + + + + + Returns the number of words in the row. + (this only applied if the row is fully parsed) + + + + + Gets or Sets the text of the row. + + + + + Return the Word object at the specified index. + + + + + Returns the index of this row in the owner SyntaxDocument. + + + + + Returns the visible index of this row in the owner SyntaxDocument + + + + + Returns the next visible row. + + + + + Returns the next row + + + + + Returns the first visible row before this row. + + + + + Returns true if the row is collapsed + + + + + Returns true if this row is the last part of a collepsed span + + + + + Returns true if this row can fold + + + + + Gets or Sets if this row is expanded. + + + + + Returns true if this row is the end part of a collapsable span + + + + + For public use only + + + + + Returns the last row of a collapsable span + (this only applies if this row is the start row of the span) + + + + + Returns the first row of a collapsable span + (this only applies if this row is the last row of the span) + + + + + For public use only + + + + + Returns the text that should be displayed if the row is collapsed. + + + + + Returns the row before this row. + + + + + Indent styles used by the control + + + + + Caret is always confined to the first column when a new line is inserted + + + + + New lines inherit the same indention as the previous row. + + + + + New lines get their indention from the scoping level. + + + + + New lines get thir indention from the scoping level or from the previous row + depending on which is most indented. + + + + + Text actions that can be performed by the SyntaxBoxControl + + + + + The control is not performing any action + + + + + The control is in Drag Drop mode + + + + + The control is selecting text + + + + + View point struct used by the SyntaxBoxControl. + The struct contains information about various rendering parameters that the IPainter needs. + + + + + The action that the SyntaxBoxControl is currently performing + + + + + Width of a char (space) in pixels + + + + + Height of the client area in pixels + + + + + Width of the client area in pixels + + + + + Index of the first visible column + + + + + Index of the first visible row + + + + + Width of the gutter margin in pixels + + + + + Width of the Linenumber margin in pixels + + + + + Height of a row in pixels + + + + + Width of the text margin (sum of gutter + linenumber + folding margins) + + + + + + + + + + Number of rows that can be displayed in the current view + + + + + Used for offsetting the screen in y axis. + + + + + Struct used by the NativePainter class. + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + For internal use only + + + + + + + + + + Pattern matcher that allows regex patterns to be matched + + + + + Raises the PatternChanged Event + + EventArgs + + + + Gets or Sets the Pattern property + + + + + Fires when the 'Pattern' Property changes + + + + + A Pattern is a specific string or a RegEx pattern that is used by the parser. + There are two types of patterns , Simple and Complex. + + Simple Patterns are patterns that consists of a simple fixed string eg. "void" or "for". + Complex Patterns are patterns that consists of RegEx patterns , eg hex numbers or urls can be described as regex patterns. + + + + + For public use only + + + + + + + + Returns the index of the pattern in a string + + + The string in which to find the pattern + Start index in the string + true if a case sensitive match should be performed + + A PatternScanResult containing information on where the pattern was found and also the text of the pattern + + + + Category of the pattern + Built in categories are: + URL + MAIL + FILE + + + + + Gets if the pattern is a simple string or a RegEx pattern + + + + + Get or Sets if this pattern needs separator chars before and after it in order to be valid. + + + + + Gets or Sets if the pattern is a separator pattern . + A separator pattern can be "End Sub" in VB6 , whenever that pattern is found , the SyntaxBoxControl will render a horizontal separator line. + NOTE: this should not be mixed up with separator chars. + + + + + For internal use only + + + + + The owning PatternList , eg a specific KeywordList or OperatorList + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets or Sets the the text of the pattern + this only applies if the pattern is a simple pattern. + + + + + Returns true if the pattern contains separator chars
+ (This is used by the parser) +
+
+ + + Designer for the SyntaxBoxControl + + + + + Resets the Splitview. + + + + + Gets or Sets the active view + + + + + Gets or Sets the border styles of the split views. + + + + + Gets or Sets the border color of the split views. + + + + + Represents which split view is currently active in the syntaxbox + + + + + Required designer variable. + + + + + Clean up any resources being used. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Row collection class. + + + + + + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Selection class used by the SyntaxBoxControl + + + + + Selection Constructor. + + Control that will use this selection + + + + Indent the active selection one step. + + + + + Outdent the active selection one step + + + + + Outdent the active selection one step + + + + + Delete the active selection. + + + + + + Clear the active selection + + + + + + Make a selection from the current selection start to the position of the caret + + + + + Select all text. + + + + + The bounds of the selection + + + + + + Event fired when the selection has changed. + + + + + Gets the text of the active selection + + + + + Returns the normalized positions of the selection. + Swapping start and end values if the selection is reversed. + + + + + Returns true if the selection contains One or more chars + + + + + gets or sets the length of the selection in chars + + + + + Gets or Sets the Selection end as an index in the document text. + + + + + Gets or Sets the Selection start as an index in the document text. + + + + + Gets or Sets the logical Selection start as an index in the document text. + + + + + Caret class used by the SyntaxBoxControl + + + + + The Position of the caret in Chars (Column and Row index) + + + + + Used by the painter to determine if the caret should be rendered or not + + + + + Caret constructor + + The control that will use the caret + + + + Confines the caret to a valid position within the active document + + + + + Moves the caret right one step. + if the caret is placed at the last column of a row the caret will move down one row and be placed at the first column of that row. + + True if a selection should be created from the current caret pos to the new pos + + + + Moves the caret up one row. + + True if a selection should be created from the current caret pos to the new pos + + + + Moves the caret up x rows + + Number of rows the caret should be moved up + True if a selection should be created from the current caret pos to the new pos + + + + Moves the caret down x rows. + + The number of rows the caret should be moved down + True if a selection should be created from the current caret pos to the new pos + + + + Moves the caret down one row. + + True if a selection should be created from the current caret pos to the new pos + + + + Moves the caret left one step. + if the caret is placed at the first column the caret will be moved up one line and placed at the last column of the row. + + True if a selection should be created from the current caret pos to the new pos + + + + Moves the caret to the first non whitespace column at the active row + + True if a selection should be created from the current caret pos to the new pos + + + + Moves the caret to the end of a row ignoring any whitespace characters at the end of the row + + True if a selection should be created from the current caret pos to the new pos + + + + Moves the caret to the first column of the active row + + True if a selection should be created from the current caret pos to the new pos + + + + Moves the caret to the absolute end of the active row + + True if a selection should be created from the current caret pos to the new pos + + + + Gets the word that the caret is placed on. + This only applies if the active row is fully parsed. + + a Word object from the active row + + + + Sets the position of the caret + + Point containing the new x and y positions + + + + Gets or Sets the position of the caret. + + + + + Event fired when the carets position has changed. + + + + + Gets the word that the caret is placed on. + This only applies if the active row is fully parsed. + + a Word object from the active row + + + + Returns the row that the caret is placed on + + a Row object from the active document + + + + Gets or Sets the Logical position of the caret. + + + + + A range of text + + + + + The start row of the range + + + The start column of the range + + + The end row of the range + + + The end column of the range + + + + + The Scope class defines what patterns starts and ends a spanDefinition + + + + + Gets or Sets if the scope patterns is case sensitive + + + + + Gets or Sets if this block should be expanded or collapsed by default + + + + + List of end patterns + + + + + The text that should be displayed if the owner block is collapsed + + + + + Gets or Sets if the scope patterns should be case normalized + + + + + The owner spanDefinition + + + + + spanDefinition that should be started directly after this block have ended + + + + + spanDefinition that should be started directly after this block have started + + + + + The Start trigger Pattern + + + + + The style that should be applied to the start and end patterns + + + + + The Point in the text where the Autolist was activated. + + + + + The Point in the text where the InfoTip was activated. + + + + + Default constructor for the SyntaxBoxControl + + + + + + + + + + For public use only + + + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Displays the GotoLine dialog. + + + + + - + + + + + Places the caret on a specified line and scrolls the caret into view. + + the zero based index of the line to jump to + + + + Clears the active selection. + + + + + Returns if a specified pixel position is over the current selection. + + X Position in pixels + Y Position in pixels + true if over selection othewise false + + + + Scrolls a given position in the text into view. + + Position in text + + + + Scrolls the caret into view. + + + + + Moves the caret to the next line that has a bookmark. + + + + + Moves the caret to the previous line that has a bookmark. + + + + + Selects next occurance of the given pattern. + + Pattern to find + Case sensitive + Match whole words only + + + + + Toggles a bookmark on/off on the active row. + + + + + Deletes selected text if possible otherwise deletes forward. (delete key) + + + + + Selects all text in the active document. (control + a) + + + + + Paste text from clipboard to current caret position. (control + v) + + + + + Copies selected text to clipboard. (control + c) + + + + + Cuts selected text to clipboard. (control + x) + + + + + Removes the current row + + + + + Redo last undo action. (control + y) + + + + + Undo last edit action. (control + z) + + + + + Returns a point where x is the column and y is the row from a given pixel position. + + X Position in pixels + Y Position in pixels + Column and Rowindex + + + + Overrides the default OnKeyDown + + + + + + Overrides the default OnKeyPress + + + + + + Overrides the default OnMouseDown + + + + + + Overrides the default OnMouseMove + + + + + + Overrides the default OnMouseUp + + + + + + Overrides the default OnMouseWheel + + + + + + Overrides the default OnPaint + + + + + + Overrides the default OnResize + + + + + + Overrides the default OnDragOver + + + + + + Overrides the default OnDragDrop + + + + + + Overrides the default OnDragEnter + + + + + + Overrides the default OnDragLeave + + + + + + Overrides the default OnDoubleClick + + + + + + An event that is fired when the caret has moved. + + + + + An event that is fired when the selection has changed. + + + + + An event that is fired when mouse down occurs on a row + + + + + An event that is fired when mouse move occurs on a row + + + + + An event that is fired when mouse up occurs on a row + + + + + An event that is fired when a click occurs on a row + + + + + An event that is fired when a double click occurs on a row + + + + + An event that is fired when the control has updated the clipboard + + + + + Returns true if the control is in overwrite mode. + + + + + Returns True if the control contains a selected text. + + + + + Returns true if there is any valid text data inside the Clipboard. + + + + + Returns true if the undobuffer contains one or more undo actions. + + + + + Returns true if the control can redo the last undo action/s + + + + + Gets the size (in pixels) of the font to use when rendering the the content. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the indention style to use when inserting new lines. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the SyntaxDocument the control is currently attatched to. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the delay in MS before the tooltip is displayed when hovering a collapsed section. + The value is retrived from the owning Syntaxbox control. + + + + + Gets if the control is readonly. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the name of the font to use when rendering the control. + The value is retrived from the owning Syntaxbox control. + + + + + Gets if the control should render bracket matching. + The value is retrived from the owning Syntaxbox control. + + + + + Gets if the control should render whitespace chars. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the Color of the horizontal separators (a'la visual basic 6). + The value is retrived from the owning Syntaxbox control. + + + + + Gets the text color to use when rendering bracket matching. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the back color to use when rendering bracket matching. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the back color to use when rendering the selected text. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the text color to use when rendering the selected text. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the back color to use when rendering the inactive selected text. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the text color to use when rendering the inactive selected text. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the color of the border between the gutter area and the line number area. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the color of the border between the line number area and the folding area. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the text color to use when rendering breakpoints. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the back color to use when rendering breakpoints. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the text color to use when rendering line numbers. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the back color to use when rendering line number area. + + + + + Gets the color of the gutter margin. + The value is retrived from the owning Syntaxbox control. + + + + + Gets or Sets the background Color of the client area. + + + + + Gets the back color to use when rendering the active line. + + + + + Get if the control should highlight the active line. + The value is retrived from the owning Syntaxbox control. + + + + + Get if the control should render whitespace chars. + The value is retrived from the owning Syntaxbox control. + + + + + Get if the line number margin is visible or not. + The value is retrived from the owning Syntaxbox control. + + + + + Get if the gutter margin is visible or not. + The value is retrived from the owning Syntaxbox control. + + + + + Get the Width of the gutter margin (in pixels) + The value is retrived from the owning Syntaxbox control. + + + + + Get the numbers of space chars in a tab. + The value is retrived from the owning Syntaxbox control. + + + + + Get whether or not TabsToSpaces is turned on. + + + + + Get if the control should render 'Tab guides' + The value is retrived from the owning Syntaxbox control. + + + + + Gets the color to use when rendering whitespace chars. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the color to use when rendering tab guides. + The value is retrived from the owning Syntaxbox control. + + + + + Get the color to use when rendering bracket matching borders. + The value is retrived from the owning Syntaxbox control. + + + NOTE: Use the Color.Transparent turn off the bracket match borders. + + + + + Get the color to use when rendering Outline symbols. + The value is retrived from the owning Syntaxbox control. + + + + + Positions the AutoList + + + + + Positions the InfoTip + + + + + Gets or Sets if the intellisense list is visible. + + + + + Gets or Sets if the infotip is visible + + + + + Get if the control should use smooth scrolling. + The value is retrived from the owning Syntaxbox control. + + + + + Get the number of pixels the screen should be scrolled per frame when using smooth scrolling. + The value is retrived from the owning Syntaxbox control. + + + + + Get if the control should parse all text when text is pasted from the clipboard. + The value is retrived from the owning Syntaxbox control. + + + + + Gets the Caret object. + + + + + Gets the Selection object. + + + + + Pattern matcher that matches case insensitive hex values + + + + + + + + + + + + + + + + + + + + + Summary description for IntelliMouseControl. + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Summary description for AutoListForm. + + + + + The imagelist that should be used by the AutoListForm + + + + + Default AltoListControl constructor. + + + + + + + + + + For public use only. + + + + + + + For public use only. + + + + + + + Adds a new ListItem to the AutoListForm. + + Text of the new ListItem + Image index that should be assigned to the new ListItem + + + + + Adds a new ListItem to the AutoListForm. + + Text of the new ListItem + text to insert when this item is selected + Image index that should be assigned to the new ListItem + + + + + Clears the content of the AutoList. + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Gets the "insert text" from the selected item. + + + + + Painter class that uses GDI32 to render the content of a SyntaxBoxControl + + + + + NativePainter constructor. + + The control that will use the Painter + + + + Implementation of the IPainter Resize method + + + + + Implementation of the IPainter MeasureString method + + String to measure + Size of the string in pixels + + + + Implementation of the IPainter InitGraphics method. + Initializes GDI32 backbuffers and brushes. + + + + + Implementation of the IPainter RenderAll method. + + + + + Implementation of the IPainter RenderAll method + + Target Graphics object + + + + + + + + + + Implementation of the iPainter CharFromPixel method + + Screen x position in pixels + Screen y position in pixels + a Point where x is the column and y is the rowindex + + + + Implementation of the IPainter MeasureRow method. + + Row to measure + Last char index + The size of the row in pixels + + + + Pattern matcher that matches a propertypath + + + + + Pattern matcher that matches binary tokens + + + + + Printer document class. + + + + + Print the content of a SyntaxDocument: + + SourceCodePrintDocument PrintDoc=new SourceCodePrintDocument(MySyntaxDocument); + + PrintDialog1.Document =PrintDoc; + if (PrintDialog1.ShowDialog ()==DialogResult.OK) + PrintDoc.Print (); + +
+ Print Preview the content of a SyntaxDocument + + SourceCodePrintDocument PrintDoc=new SourceCodePrintDocument(MySyntaxDocument); + PrintPreviewDialog1.Document = PrintDoc + PrintPreviewDialog1.ShowDialog (); + +
+
+ + + Summary description for InfoTip. + + + + + Required designer variable. + + + + + + + + + + + + + + + + Clean up any resources being used. + + + + + + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + For public use only. + + + + + + + For public use only. + + + + + + + Summary description for ListItem. + + + + + The insert text of a ListItem + + + + + The text of a ListItem + + + + + The tooltip text that should be displayed when selecting a ListItem + + + + + The type of the ListItem (the type is used as an index to choose what icon to display) + + + + + ListItem constructor , takes text and type as parameters + + The text that should be assigned to the ListItem + The type of the ListItem + + + + ListItem constructor , takes text , type and tooltip text as parameters + + The text that should be assigned to the ListItem + The type of the ListItem + The tooltip text that should be assigned to the ListItem + + + + ListItem constructor , takes text , type , tooltip text and insert text as parameters + + The text that should be assigned to the ListItem + The type of the ListItem + The tooltip text that should be assigned to the ListItem + The text that should be inserted into the text when this item is selected + + + + + + + + + + + + + + + + + + + + + + The depth of this span in the span hirarchy + + + + + The row that the span ends on + + + + + The word that ends this span + + + + + Gets or Sets if this span is expanded + + + + + The parent span + + + + + Gets or Sets what scope triggered this span + + + + + The owner spanDefinition + + + + + The row on which the span starts + + + + + The word that starts this span + + + + + + + + + + + + + + + + Html exporter class + + + + + Exports the content of a SyntaxDocument to a HTML formatted string + + SyntaxDocument object to export from + File path tho the images to use in the HTML string + + + + + Exports the content of a SyntaxDocument to a HTML formatted string + + SyntaxDocument object to export from + HTML color string to use as background color + File path tho the images to use in the HTML string + HTML style string that should be applied to the output + + + + + Syntaxbox control that can be used as a pure text editor or as a code editor when a syntaxfile is used. + + + + + Converts all tabs to spaces the size of .TabSize in the Document. + + + + + Converts all spaces the size of .TabSize in the Document to tabs. + + + + + Disables painting while loading data into the Autolist + + + + + + + MySyntaxBox.AutoListClear(); + MySyntaxBox.AutoListBeginLoad(); + MySyntaxBox.AutoListAdd ("test",1); + MySyntaxBox.AutoListAdd ("test",2); + MySyntaxBox.AutoListAdd ("test",3); + MySyntaxBox.AutoListAdd ("test",4); + MySyntaxBox.AutoListEndLoad(); + + + + + + Resumes painting and autosizes the Autolist. + + + + + Clears the content in the autolist. + + + + + Adds an item to the autolist control. + + + + MySyntaxBox.AutoListClear(); + MySyntaxBox.AutoListBeginLoad(); + MySyntaxBox.AutoListAdd ("test",1); + MySyntaxBox.AutoListAdd ("test",2); + MySyntaxBox.AutoListAdd ("test",3); + MySyntaxBox.AutoListAdd ("test",4); + MySyntaxBox.AutoListEndLoad(); + + + The text to display in the autolist + The image index in the AutoListIcons + + + + Adds an item to the autolist control. + + The text to display in the autolist + The text to insert in the code + The image index in the AutoListIcons + + + + Adds an item to the autolist control. + + The text to display in the autolist + The text to insert in the code + + The image index in the AutoListIcons + + + + Converts a Client pixel coordinate into a TextPoint (Column/Row) + + Pixel x position + Pixel y position + The row and column at the given pixel coordinate. + + + + Clears the selection in the active view. + + + + + Executes a Copy action on the selection in the active view. + + + + + Executes a Cut action on the selection in the active view. + + + + + Executes a Delete action on the selection in the active view. + + + + + Moves the caret of the active view to a specific row. + + the row to jump to + + + + Moves the caret of the active view to the next bookmark. + + + + + Moves the caret of the active view to the previous bookmark. + + + + + Takes a pixel position and returns true if that position is inside the selected text. + + + Pixel x position. + Pixel y position + true if the position is inside the selection. + + + + Execute a Paste action if possible. + + + + + Execute a ReDo action if possible. + + + + + Makes the caret in the active view visible on screen. + + + + + Scrolls the active view to a specific position. + + + + + + Select all the text in the active view. + + + + + Selects the next word (from the current caret position) that matches the parameter criterias. + + The pattern to find + Match case , true/false + Match whole words only , true/false + To be implemented + + + + Finds the next occurance of the pattern in the find/replace dialog + + + + + Shows the default GotoLine dialog. + + + + //Display the Goto Line dialog + MySyntaxBox.ShowGotoLine(); + + + + + + Not yet implemented + + + + + Toggles a bookmark on the active row of the active view. + + + + + Executes an undo action if possible. + + + + + Shows the Find dialog + + + + //Show FindReplace dialog + MySyntaxBox.ShowFind(); + + + + + + Shows the Replace dialog + + + + //Show FindReplace dialog + MySyntaxBox.ShowReplace(); + + + + + + Default constructor for the SyntaxBoxControl + + + + + + + + + + + + + + + + An event that is fired when the cursor hovers a pattern; + + + + + An event that is fired when the cursor hovers a pattern; + + + + + An event that is fired when the control has updated the clipboard + + + + + Event fired when the caret of the active view have moved. + + + + + + + + + + Event fired when the user presses the up or the down button on the infotip. + + + + + Event fired when a row is rendered. + + + + + An event that is fired when mouse down occurs on a row + + + + + An event that is fired when mouse move occurs on a row + + + + + An event that is fired when mouse up occurs on a row + + + + + An event that is fired when a click occurs on a row + + + + + An event that is fired when a double click occurs on a row + + + + + Positions the AutoList + + + + + Positions the InfoTip + + + + + Prevents the control from changing the cursor. + + + + + The row padding in pixels. + + + + + The selected index in the infotip. + + + + + Gets or Sets the image used in the infotip. + + + + + Get or Sets the number of choices that could be made in the infotip. + + + + + The text in the Infotip. + +
+ The text uses a HTML like syntax.
+
+ Supported tags are:
+
+ <Font Size="Size in Pixels" Face="Font Name" Color="Named color" ></Font> Set Font size,color and fontname.
+ <HR> : Inserts a horizontal separator line.
+ <BR> : Line break.
+ <B></B> : Activate/Deactivate Bold style.
+ <I></I> : Activate/Deactivate Italic style.
+ <U></U> : Activate/Deactivate Underline style.
+
+ + + MySyntaxBox.InfoTipText="public void MyMethod ( <b> string text </b> );"; + + +
+ + + Gets the Selection object from the active view. + + + + + Collection of KeyboardActions that is used by the control. + Keyboard actions to add shortcut key combinations to certain tasks. + + + + + Gets or Sets if the AutoList is visible in the active view. + + + + + Gets or Sets if the InfoTip is visible in the active view. + + + + + Gets if the control can perform a Copy action. + + + + + Gets if the control can perform a Paste action. + (if the clipboard contains a valid text). + + + + + Gets if the control can perform a ReDo action. + + + + + Gets if the control can perform an Undo action. + + + + + Gets or Sets the imagelist to use in the gutter margin. + + + Image Index 0 is used to display the Breakpoint icon. + Image Index 1 is used to display the Bookmark icon. + + + + + Gets or Sets the imagelist to use in the autolist. + + + + + Gets or Sets the color to use when rendering Tab guides. + + + + + Gets or Sets the color of the bracket match borders. + + + NOTE: use Color.Transparent to turn off the bracket match borders. + + + + + Gets or Sets if the control should render Tab guides. + + + + + Gets or Sets the color to use when rendering whitespace characters + + + + + Gets or Sets the color of the code Outlining (both folding lines and collapsed blocks). + + + + + Determines if the control should use a smooth scroll when scrolling one row up or down. + + + + + Gets or Sets the speed of the vertical scroll when SmoothScroll is activated + + + + + Gets or Sets if the control can display breakpoints or not. + + + + + Gets or Sets if the control should perform a full parse of the document when content is drag dropped or pasted into the control + + + + + Gets or Sets the Size of the font. + + + + + + Determines what indentstyle to use on a new line. + + + + + Gets or Sets the SyntaxDocument the control is currently attatched to. + + + + + Get or Set the delay before the tooltip is displayed over a collapsed block + + + + + Get or Set whether or not tooltips will be deplayed for collapsed blocks. + + + + + Get or Set the delay before the tooltip is displayed over a collapsed block + + + + + Gets or Sets the name of the font. + + + + + + Gets or Sets if bracketmatching is active + + + + + + + Gets or Sets if Virtual Whitespace is active. + + + + + + Gets or Sets the separator Color. + + + + + + + Gets or Sets the foreground Color to use when BracketMatching is activated. + + + + + + + Gets or Sets the background Color to use when BracketMatching is activated. + + + + + + + The inactive selection background color. + + + + + The inactive selection foreground color. + + + + + The selection background color. + + + + + The selection foreground color. + + + + + Gets or Sets the border Color of the gutter margin. + + + + + + Gets or Sets the border Color of the line number margin + + + + + + + Gets or Sets the foreground Color of a Breakpoint. + + + + + + Gets or Sets the background Color to use for breakpoint rows. + + + + + + Gets or Sets the foreground Color of line numbers. + + + + + + + Gets or Sets the background Color of line numbers. + + + + + + + Gets or Sets the Color of the gutter margin + + + + + + Gets or Sets the background Color of the client area. + + + + + Gets or Sets the background Color of the active line. + + + + + + Determines if the active line should be highlighted. + + + + + Determines if Whitespace should be rendered as symbols. + + + + + Determines if the line number margin should be visible. + + + + + Determines if the gutter margin should be visible. + + + + + Gets or Sets the witdth of the gutter margin in pixels. + + + + + Gets or Sets the 'Tabs To Spaces' feature of the editor. + + + + + Get or Sets the size of a TAB char in number of SPACES. + + + + + Gets the Caret object from the active view. + + + + + The currently highlighted text in the autolist. + + + + + + + + + + Summary description for CollectionEditorGui. + + + + + Required designer variable. + + + + + Clean up any resources being used. + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Summary description for SplitView. + + + + + Required designer variable. + + + + + Default constructor for the splitview control + + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Clean up any resources being used. + + + + + + + + + + + + + + + + + Splits the view horiziontally. + + + + + Splits teh view vertically. + + + + + Start dragging the horizontal splitter. + + + + + Start dragging the vertical splitter. + + + + + Gets or Sets the control that should be confined to the upper left view. + + + + + Gets or Sets the control that should be confined to the upper right view. + + + + + Gets or Sets the control that should be confined to the lower left view. + + + + + Gets or Sets the control that should be confined to the lower right view. + + + + + an event fired when the split view is resized. + + + + + an event fired when the top views are hidden. + + + + + an event fired when the left views are hidden. + + +
+
diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/AutoListForm.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/AutoListForm.cs new file mode 100644 index 0000000..d1ba8c4 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/AutoListForm.cs @@ -0,0 +1,380 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Runtime.InteropServices; +using System.Windows.Forms; + +namespace Alsing.Windows.Forms.SyntaxBox +{ + /// + /// Summary description for AutoListForm. + /// + [ToolboxItem(false)] + public class AutoListForm : Form + { + private IContainer components; + + + /// + /// The imagelist that should be used by the AutoListForm + /// + public ImageList Images; + + private TabListBox LB; + private ToolTip tooltip; + + /// + /// Default AltoListControl constructor. + /// + public AutoListForm() + { + // This call is required by the Windows.Forms Form Designer. + InitializeComponent(); + //SetStyle(ControlStyles.ContainerControl ,false); + SetStyle(ControlStyles.Selectable, true); + + // TODO: Add any initialization after the InitForm call + } + + /// + /// Gets the "insert text" from the selected item. + /// + public string SelectedText + { + get + { + if (LB.SelectedItem == null) + return ""; + + var li = (ListItem) LB.SelectedItem; + return li.InsertText; + } + } + + [DllImport("user32.dll", EntryPoint = "SendMessage")] + private static extern int SendMessage(IntPtr hWnd, int message, int _data, int _id); + + public void SendKey(int KeyCode) + { + SendMessage(LB.Handle, (int) WindowMessage.WM_KEYDOWN, KeyCode, 0); + } + + /// + /// + /// + protected override void OnPaint(PaintEventArgs e) + { + e.Graphics.Clear(SystemColors.Control); + ControlPaint.DrawBorder3D(e.Graphics, 0, 0, Width, Height, Border3DStyle.Raised); + } + + public void SelectItem(string text) + { + text = text.ToLowerInvariant(); + + for (int i = 0; i < LB.Items.Count; i++) + { + var li = (ListItem) LB.Items[i]; + string lis = li.Text.ToLowerInvariant(); + if (lis.StartsWith(text)) + { + LB.SelectedIndex = i; + break; + } + } + } + + private void LB_KeyDown(object sender, KeyEventArgs e) + { + OnKeyDown(e); + // e.Handled =true; + } + + private void LB_KeyPress(object sender, KeyPressEventArgs e) + { + OnKeyPress(e); + // e.Handled =true; + } + + private void LB_KeyUp(object sender, KeyEventArgs e) + { + OnKeyUp(e); + // e.Handled =true; + } + + /// + /// For public use only. + /// + /// + /// + protected override bool IsInputKey(Keys keyData) + { + return true; + } + + /// + /// For public use only. + /// + /// + /// + protected override bool IsInputChar(char charCode) + { + return true; + } + + /// + /// Adds a new ListItem to the AutoListForm. + /// + /// Text of the new ListItem + /// Image index that should be assigned to the new ListItem + /// + public ListItem Add(string text, int ImageIndex) + { + return Add(text, text, ImageIndex); + } + + /// + /// Adds a new ListItem to the AutoListForm. + /// + /// Text of the new ListItem + /// text to insert when this item is selected + /// Image index that should be assigned to the new ListItem + /// + public ListItem Add(string text, string InsertText, int ImageIndex) + { + var li = new ListItem(text, ImageIndex, "", InsertText); + LB.Items.Add(li); + + + //this.LB.Sorted =true; + return li; + } + + public ListItem Add(string text, string InsertText, string ToolTip, int ImageIndex) + { + var li = new ListItem(text, ImageIndex, "", InsertText); + LB.Items.Add(li); + li.ToolTip = ToolTip; + //this.LB.Sorted =true; + return li; + } + + /// + /// Clears the content of the AutoList. + /// + public void Clear() + { + LB.Items.Clear(); + } + + private void LB_DrawItem(object sender, DrawItemEventArgs e) + { + bool selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected; + + if (e.Index == - 1) + return; + + const int Offset = 24; + + var li = (ListItem) LB.Items[e.Index]; + string text = li.Text; + Brush bg, fg; + + if (selected) + { + bg = SystemBrushes.Highlight; + fg = SystemBrushes.HighlightText; + //fg=Brushes.Black; + } + else + { + bg = SystemBrushes.Window; + fg = SystemBrushes.WindowText; + //bg=Brushes.White; + //fg=Brushes.Black; + } + + if (!selected) + { + e.Graphics.FillRectangle(bg, 0, e.Bounds.Top, e.Bounds.Width, LB.ItemHeight); + //e.Graphics.FillRectangle (SystemBrushes.Highlight,0,e.Bounds.Top,27 ,LB.ItemHeight); + } + else + { + e.Graphics.FillRectangle(SystemBrushes.Window, Offset, e.Bounds.Top, e.Bounds.Width - Offset, + LB.ItemHeight); + e.Graphics.FillRectangle(SystemBrushes.Highlight, + new Rectangle(Offset + 1, e.Bounds.Top + 1, e.Bounds.Width - Offset - 2, + LB.ItemHeight - 2)); + + + //e.Graphics.FillRectangle (SystemBrushes.Highlight,27,e.Bounds.Top,e.Bounds.Width-27 ,LB.ItemHeight); + //e.Graphics.FillRectangle (new SolidBrush(Color.FromArgb (182,189,210)),new Rectangle (1+27,e.Bounds.Top+1,e.Bounds.Width-2- ,LB.ItemHeight-2)); + + + ControlPaint.DrawFocusRectangle(e.Graphics, + new Rectangle(Offset, e.Bounds.Top, e.Bounds.Width - Offset, + LB.ItemHeight)); + } + + + e.Graphics.DrawString(text, e.Font, fg, Offset + 2, e.Bounds.Top + 1); + + + if (Images != null) + e.Graphics.DrawImage(Images.Images[li.Type], 6, e.Bounds.Top + 0); + } + + private void LB_DoubleClick(object sender, EventArgs e) + { + OnDoubleClick(e); + } + + public void BeginLoad() + { + LB.Sorted = false; + LB.DrawMode = DrawMode.Normal; + LB.SuspendLayout(); + } + + public void EndLoad() + { + LB.ResumeLayout(); + LB.Sorted = true; + LB.DrawMode = DrawMode.OwnerDrawFixed; + + //set height + Height = 0; + if (LB.Items.Count > 10) + { + Height = LB.ItemHeight*11 + 12; + } + else + { + Height = LB.ItemHeight*(LB.Items.Count) + 12; + } + int max = 0; + Graphics g = LB.CreateGraphics(); + foreach (ListItem li in LB.Items) + { + int w = (int) g.MeasureString(li.Text, LB.Font).Width + 45; + if (w > max) + max = w; + } + Width = max + SystemInformation.VerticalScrollBarWidth; + Refresh(); + g.Dispose(); + } + + + private void AutoListForm_Resize(object sender, EventArgs e) + { + LB.Size = new Size(Width - 8, Height - 8); + } + + private void LB_SelectedIndexChanged(object sender, EventArgs e) + { + var li = (ListItem) LB.SelectedItem; + + if (li.ToolTip != "") + { + tooltip.ShowAlways = true; + tooltip.SetToolTip(LB, li.ToolTip); + tooltip.InitialDelay = 2; + tooltip.Active = true; + } + } + + private void LB_MouseDown(object sender, MouseEventArgs e) + { + SelectItem(e.X, e.Y); + } + + private void SelectItem(int x, int y) + { + var p = new Point(x, y); + int r = (p.Y/LB.ItemHeight) + LB.TopIndex; + if (r != LB.SelectedIndex) + { + if (r < LB.Items.Count && r >= 0) + { + LB.SelectedIndex = r; + } + } + } + + private void LB_MouseMove(object sender, MouseEventArgs e) + { + if (e.Button != 0) + { + SelectItem(e.X, e.Y); + } + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.LB = new Alsing.Windows.Forms.SyntaxBox.TabListBox(); + this.tooltip = new System.Windows.Forms.ToolTip(this.components); + this.SuspendLayout(); + // + // LB + // + this.LB.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.LB.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + this.LB.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, + System.Drawing.GraphicsUnit.Point, ((System.Byte) (0))); + this.LB.IntegralHeight = false; + this.LB.ItemHeight = 16; + this.LB.Location = new System.Drawing.Point(4, 4); + this.LB.Name = "LB"; + this.LB.Size = new System.Drawing.Size(168, 184); + this.LB.Sorted = true; + this.LB.TabIndex = 0; + this.LB.KeyDown += new System.Windows.Forms.KeyEventHandler(this.LB_KeyDown); + this.LB.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LB_MouseDown); + this.LB.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.LB_KeyPress); + this.LB.DoubleClick += new System.EventHandler(this.LB_DoubleClick); + this.LB.KeyUp += new System.Windows.Forms.KeyEventHandler(this.LB_KeyUp); + this.LB.SelectedIndexChanged += new System.EventHandler(this.LB_SelectedIndexChanged); + this.LB.MouseMove += new System.Windows.Forms.MouseEventHandler(this.LB_MouseMove); + this.LB.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.LB_DrawItem); + // + // tooltip + // + this.tooltip.AutoPopDelay = 5000; + this.tooltip.InitialDelay = 100; + this.tooltip.ReshowDelay = 100; + // + // AutoListForm + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(168, 165); + this.Controls.AddRange(new System.Windows.Forms.Control[] {this.LB}); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "AutoListForm"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.Resize += new System.EventHandler(this.AutoListForm_Resize); + this.ResumeLayout(false); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/AutoListForm.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/AutoListForm.resx new file mode 100644 index 0000000..c1df5d6 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/AutoListForm.resx @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + AutoListForm + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/TabListBox.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/TabListBox.cs new file mode 100644 index 0000000..6294ef6 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/TabListBox.cs @@ -0,0 +1,130 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Windows.Forms; + +namespace Alsing.Windows.Forms.SyntaxBox +{ + [ToolboxItem(false)] + public class TabListBox : ListBox + { + /// + /// For public use only. + /// + /// + /// + protected override bool IsInputKey(Keys keyData) + { + return true; + } + + /// + /// For public use only. + /// + /// + /// + protected override bool IsInputChar(char charCode) + { + return true; + } + } + + /// + /// Summary description for ListItem. + /// + public class ListItem : IComparable + { + /// + /// The insert text of a ListItem + /// + public string InsertText = ""; + + /// + /// The text of a ListItem + /// + public string Text = ""; + + /// + /// The tooltip text that should be displayed when selecting a ListItem + /// + public string ToolTip = ""; + + /// + /// The type of the ListItem (the type is used as an index to choose what icon to display) + /// + public int Type; + + /// + /// ListItem constructor , takes text and type as parameters + /// + /// The text that should be assigned to the ListItem + /// The type of the ListItem + public ListItem(string text, int type) + { + Text = text; + Type = type; + ToolTip = ""; + } + + /// + /// ListItem constructor , takes text , type and tooltip text as parameters + /// + /// The text that should be assigned to the ListItem + /// The type of the ListItem + /// The tooltip text that should be assigned to the ListItem + public ListItem(string text, int type, string tooltip) + { + Text = text; + Type = type; + ToolTip = tooltip; + } + + /// + /// ListItem constructor , takes text , type , tooltip text and insert text as parameters + /// + /// The text that should be assigned to the ListItem + /// The type of the ListItem + /// The tooltip text that should be assigned to the ListItem + /// The text that should be inserted into the text when this item is selected + public ListItem(string text, int type, string tooltip, string inserttext) + { + Text = text; + Type = type; + ToolTip = tooltip; + InsertText = inserttext; + } + + #region Implementation of IComparable + + /// + /// + /// + /// + /// + public int CompareTo(object obj) + { + var li = (ListItem) obj; + return Text.CompareTo(li.Text); + } + + #endregion + + /// + /// + /// + /// + public override string ToString() + { + return Text; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/TabListBox.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/TabListBox.resx new file mode 100644 index 0000000..6b3c4ce --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Autolist/TabListBox.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseControl.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseControl.cs new file mode 100644 index 0000000..77eaefe --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseControl.cs @@ -0,0 +1,320 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; +using Alsing.Drawing; + +namespace Alsing.Windows.Forms +{ + [ToolboxItem(true)] + public class BaseControl : Control + { + private const int WS_BORDER = unchecked(0x00800000); + private const int WS_EX_CLIENTEDGE = unchecked(0x00000200); + private Color borderColor = Color.Black; + + /// + /// Required designer variable. + /// + private BorderStyle borderStyle; + + private Container components; + private bool RunOnce = true; + + + public BaseControl() + { + SetStyle(ControlStyles.EnableNotifyMessage, true); + BorderStyle = BorderStyle.FixedSingle; + InitializeComponent(); + } + + [Browsable(false)] + public Size WindowSize + { + get + { + var s = new APIRect(); + NativeMethods.GetWindowRect(Handle, ref s); + return new Size(s.Width, s.Height); + } + } + + [Category("Appearance - Borders"), Description("The border color")] + [DefaultValue(typeof (Color), "Black")] + public Color BorderColor + { + get { return borderColor; } + + set + { + borderColor = value; + Refresh(); + Invalidate(); + UpdateStyles(); + } + } + + protected override CreateParams CreateParams + { + get + { + CreateParams cp = base.CreateParams; + + if (BorderStyle == BorderStyle.None) + return cp; + + cp.ExStyle &= (~WS_EX_CLIENTEDGE); + cp.Style &= (~WS_BORDER); + + return cp; + } + } + + [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)] + [Category("Appearance - Borders"), Description("The border style")] + public BorderStyle BorderStyle + { + get { return borderStyle; } + set + { + if (borderStyle != value) + { + if (!Enum.IsDefined(typeof (BorderStyle), value)) + { + throw new InvalidEnumArgumentException("value", (int) value, typeof (BorderStyle)); + } + borderStyle = value; + UpdateStyles(); + Refresh(); + } + } + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), Obsolete("Do not use!", true)] + public override Image BackgroundImage + { + get { return base.BackgroundImage; } + set { base.BackgroundImage = value; } + } + + + [Browsable(false)] + public int ClientWidth + { + get { return WindowSize.Width - (BorderWidth*2); } + } + + [Browsable(false)] + public int ClientHeight + { + get { return WindowSize.Height - (BorderWidth*2); } + } + + [Browsable(false)] + public int BorderWidth + { + get + { + switch (borderStyle) + { + case BorderStyle.None: + { + return 0; + } + case BorderStyle.Sunken: + { + return 2; + } + case BorderStyle.SunkenThin: + { + return 1; + } + case BorderStyle.Raised: + { + return 2; + } + + case BorderStyle.Etched: + { + return 2; + } + case BorderStyle.Bump: + { + return 6; + } + case BorderStyle.FixedSingle: + { + return 1; + } + case BorderStyle.FixedDouble: + { + return 2; + } + case BorderStyle.RaisedThin: + { + return 1; + } + case BorderStyle.Dotted: + { + return 1; + } + case BorderStyle.Dashed: + { + return 1; + } + } + + + return Height; + } + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + // + // BaseControl + // + this.Size = new System.Drawing.Size(272, 264); + } + + #endregion + + public event EventHandler Load = null; + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + protected virtual void OnLoad(EventArgs e) + { + if (Load != null) + Load(this, e); + Refresh(); + } + + protected override unsafe void WndProc(ref Message m) + { + if (m.Msg == (int) WindowMessage.WM_NCPAINT) + { + RenderBorder(); + } + else if (m.Msg == (int) WindowMessage.WM_SHOWWINDOW) + { + if (RunOnce) + { + RunOnce = false; + OnLoad(null); + base.WndProc(ref m); + UpdateStyles(); + } + else + { + UpdateStyles(); + base.WndProc(ref m); + } + } + else if (m.Msg == (int) WindowMessage.WM_NCCREATE) + { + base.WndProc(ref m); + } + else if (m.Msg == (int) WindowMessage.WM_NCCALCSIZE) + { + if (m.WParam == (IntPtr) 0) + { + var pRC = (APIRect*) m.LParam; + //pRC->left -=3; + base.WndProc(ref m); + } + else if (m.WParam == (IntPtr) 1) + { + var pNCP = (_NCCALCSIZE_PARAMS*) m.LParam; + + + int t = pNCP->NewRect.top + BorderWidth; + int l = pNCP->NewRect.left + BorderWidth; + int b = pNCP->NewRect.bottom - BorderWidth; + int r = pNCP->NewRect.right - BorderWidth; + + base.WndProc(ref m); + + pNCP->NewRect.top = t; + pNCP->NewRect.left = l; + pNCP->NewRect.right = r; + pNCP->NewRect.bottom = b; + + return; + } + } + else + { + base.WndProc(ref m); + } + } + + private void RenderBorder() + { + IntPtr hdc = NativeMethods.GetWindowDC(Handle); + var s = new APIRect(); + NativeMethods.GetWindowRect(Handle, ref s); + + using (Graphics g = Graphics.FromHdc(hdc)) + { + DrawingTools.DrawBorder((BorderStyle2) (int) BorderStyle, BorderColor, g, + new Rectangle(0, 0, s.Width, s.Height)); + } + NativeMethods.ReleaseDC(Handle, hdc); + } + + + protected override void OnEnter(EventArgs e) + { + base.OnEnter(e); + } + +// protected override void OnHandleCreated(System.EventArgs e) +// { +// base.OnHandleCreated (e); +// // this.UpdateStyles (); +// Console.WriteLine ("gapa"); +// } +// +// protected override void OnHandleDestroyed(System.EventArgs e) +// { +// base.OnHandleDestroyed (e); +// Console.WriteLine ("apa"); +// } +// +// protected override void OnParentChanged(System.EventArgs e) +// { +// base.OnParentChanged (e); +// } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseControl.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseControl.resx new file mode 100644 index 0000000..02cef55 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseControl.resx @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + BaseControl + + + False + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseListBoxControl.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseListBoxControl.cs new file mode 100644 index 0000000..9e83e48 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseListBoxControl.cs @@ -0,0 +1,289 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; +using Alsing.Drawing; + +namespace Alsing.Windows.Forms +{ + [ToolboxItem(true)] + public class BaseListBoxControl : ListBox + { + private const int WS_BORDER = unchecked(0x00800000); + private const int WS_EX_CLIENTEDGE = unchecked(0x00000200); + private Color borderColor = Color.Black; + + /// + /// Required designer variable. + /// + private BorderStyle borderStyle; + + private Container components; + private bool RunOnce = true; + + + public BaseListBoxControl() + { + SetStyle(ControlStyles.EnableNotifyMessage, true); + BorderStyle = BorderStyle.FixedSingle; + } + + [Browsable(false)] + public Size WindowSize + { + get + { + var s = new APIRect(); + NativeMethods.GetWindowRect(Handle, ref s); + return new Size(s.Width, s.Height); + } + } + + [Category("Appearance - Borders"), Description("The border color")] + [DefaultValue(typeof (Color), "Black")] + public Color BorderColor + { + get { return borderColor; } + + set + { + borderColor = value; + Refresh(); + Invalidate(); + UpdateStyles(); + } + } + + protected override CreateParams CreateParams + { + get + { + CreateParams cp = base.CreateParams; + + if (BorderStyle == BorderStyle.None) + return cp; + + cp.ExStyle &= (~WS_EX_CLIENTEDGE); + cp.Style &= (~WS_BORDER); + + return cp; + } + } + + [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)] + [Category("Appearance - Borders"), Description("The border style")] + [DefaultValue(BorderStyle.None)] + public new BorderStyle BorderStyle + { + get { return borderStyle; } + set + { + if (borderStyle != value) + { + if (!Enum.IsDefined(typeof (BorderStyle), value)) + { + throw new InvalidEnumArgumentException("value", (int) value, typeof (BorderStyle)); + } + borderStyle = value; + UpdateStyles(); + Refresh(); + } + } + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), Obsolete("Do not use!", true)] + public override Image BackgroundImage + { + get { return base.BackgroundImage; } + set { base.BackgroundImage = value; } + } + + + [Browsable(false)] + public int ClientWidth + { + get { return WindowSize.Width - (BorderWidth*2); } + } + + [Browsable(false)] + public int ClientHeight + { + get { return WindowSize.Height - (BorderWidth*2); } + } + + [Browsable(false)] + public int BorderWidth + { + get + { + switch (borderStyle) + { + case BorderStyle.None: + { + return 0; + } + case BorderStyle.Sunken: + { + return 2; + } + case BorderStyle.SunkenThin: + { + return 1; + } + case BorderStyle.Raised: + { + return 2; + } + + case BorderStyle.Etched: + { + return 2; + } + case BorderStyle.Bump: + { + return 6; + } + case BorderStyle.FixedSingle: + { + return 1; + } + case BorderStyle.FixedDouble: + { + return 2; + } + case BorderStyle.RaisedThin: + { + return 1; + } + case BorderStyle.Dotted: + { + return 1; + } + case BorderStyle.Dashed: + { + return 1; + } + } + + + return Height; + } + } + + public event EventHandler Load = null; + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + protected virtual void OnLoad(EventArgs e) + { + if (Load != null) + Load(this, e); + Refresh(); + } + + protected override unsafe void WndProc(ref Message m) + { + if (m.Msg == (int) WindowMessage.WM_NCPAINT) + { + try + { + RenderBorder(); + } + catch {} + base.WndProc(ref m); + } + else if (m.Msg == (int) WindowMessage.WM_SHOWWINDOW) + { + if (RunOnce) + { + RunOnce = false; + OnLoad(null); + base.WndProc(ref m); + UpdateStyles(); + } + else + { + UpdateStyles(); + base.WndProc(ref m); + } + } + else if (m.Msg == (int) WindowMessage.WM_NCCREATE) + { + base.WndProc(ref m); + } + else if (m.Msg == (int) WindowMessage.WM_NCCALCSIZE) + { + if (m.WParam == (IntPtr) 0) + { + var pRC = (APIRect*) m.LParam; + //pRC->left -=3; + base.WndProc(ref m); + } + else if (m.WParam == (IntPtr) 1) + { + var pNCP = (_NCCALCSIZE_PARAMS*) m.LParam; + + base.WndProc(ref m); + + int t = pNCP->NewRect.top + BorderWidth; + int l = pNCP->NewRect.left + BorderWidth; + int b = pNCP->NewRect.bottom - BorderWidth; + int r = pNCP->NewRect.right - BorderWidth; + + + pNCP->NewRect.top = t; + pNCP->NewRect.left = l; + pNCP->NewRect.right = r; + pNCP->NewRect.bottom = b; + } + } + else + { + base.WndProc(ref m); + } + } + + private void RenderBorder() + { + IntPtr hdc = NativeMethods.GetWindowDC(Handle); + var s = new APIRect(); + NativeMethods.GetWindowRect(Handle, ref s); + + using (Graphics g = Graphics.FromHdc(hdc)) + { + DrawingTools.DrawBorder((BorderStyle2) (int) BorderStyle, BorderColor, g, + new Rectangle(0, 0, s.Width, s.Height)); + } + NativeMethods.ReleaseDC(Handle, hdc); + } + + + protected override void OnEnter(EventArgs e) + { + base.OnEnter(e); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseListBoxControl.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseListBoxControl.resx new file mode 100644 index 0000000..6b3c4ce --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BaseListBoxControl.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BasePanelControl.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BasePanelControl.cs new file mode 100644 index 0000000..f4c9a18 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BasePanelControl.cs @@ -0,0 +1,285 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; +using Alsing.Drawing; + +namespace Alsing.Windows.Forms +{ + [ToolboxItem(true)] + public class BasePanelControl : Panel + { + private const int WS_BORDER = unchecked(0x00800000); + private const int WS_EX_CLIENTEDGE = unchecked(0x00000200); + private Color borderColor = Color.Black; + private BorderStyle borderStyle; + private Container components; + private bool RunOnce = true; + + + public BasePanelControl() + { + SetStyle(ControlStyles.EnableNotifyMessage, true); + BorderStyle = BorderStyle.FixedSingle; + InitializeComponent(); + } + + public Color BorderColor + { + get { return borderColor; } + + set + { + borderColor = value; + Refresh(); + Invalidate(); + UpdateStyles(); + } + } + + protected override CreateParams CreateParams + { + get + { + CreateParams cp = base.CreateParams; + + if (BorderStyle == BorderStyle.None) + return cp; + + cp.ExStyle &= (~WS_EX_CLIENTEDGE); + cp.Style &= (~WS_BORDER); + + return cp; + } + } + + [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)] + public new BorderStyle BorderStyle + { + get { return borderStyle; } + set + { + try + { + if (borderStyle != value) + { + borderStyle = value; + UpdateStyles(); + Refresh(); + } + } + catch {} + } + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), Obsolete("Do not use!", true)] + public override Image BackgroundImage + { + get { return base.BackgroundImage; } + set { base.BackgroundImage = value; } + } + + + [Browsable(false)] + public int ClientWidth + { + get { return Width - (BorderWidth*2); } + } + + [Browsable(false)] + public int ClientHeight + { + get { return Height - (BorderWidth*2); } + } + + [Browsable(false)] + public int BorderWidth + { + get + { + switch (borderStyle) + { + case BorderStyle.None: + { + return 0; + } + case BorderStyle.Sunken: + { + return 2; + } + case BorderStyle.SunkenThin: + { + return 1; + } + case BorderStyle.Raised: + { + return 2; + } + + case BorderStyle.Etched: + { + return 2; + } + case BorderStyle.Bump: + { + return 6; + } + case BorderStyle.FixedSingle: + { + return 1; + } + case BorderStyle.FixedDouble: + { + return 2; + } + case BorderStyle.RaisedThin: + { + return 1; + } + case BorderStyle.Dotted: + { + return 1; + } + case BorderStyle.Dashed: + { + return 1; + } + } + + + return Height; + } + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + // + // BasePanelControl + // + this.Size = new System.Drawing.Size(272, 264); + } + + #endregion + + public event EventHandler Load = null; + + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + protected virtual void OnLoad(EventArgs e) + { + if (Load != null) + Load(this, e); + Refresh(); + } + + protected override unsafe void WndProc(ref Message m) + { + if (m.Msg == (int) WindowMessage.WM_NCPAINT) + { + try + { + RenderBorder(); + } + catch {} + base.WndProc(ref m); + // RenderBorder(); + } + else if (m.Msg == (int) WindowMessage.WM_SHOWWINDOW) + { + if (RunOnce) + { + RunOnce = false; + OnLoad(null); + base.WndProc(ref m); + UpdateStyles(); + } + else + { + UpdateStyles(); + base.WndProc(ref m); + } + } + else if (m.Msg == (int) WindowMessage.WM_NCCREATE) + { + base.WndProc(ref m); + } + else if (m.Msg == (int) WindowMessage.WM_NCCALCSIZE) + { + if (m.WParam == (IntPtr) 0) + { + //APIRect* pRC=(APIRect*)m.LParam; + //pRC->left -=3; + base.WndProc(ref m); + } + else if (m.WParam == (IntPtr) 1) + { + var pNCP = (_NCCALCSIZE_PARAMS*) m.LParam; + + base.WndProc(ref m); + + int t = pNCP->NewRect.top + BorderWidth; + int l = pNCP->NewRect.left + BorderWidth; + int b = pNCP->NewRect.bottom - BorderWidth; + int r = pNCP->NewRect.right - BorderWidth; + + + pNCP->NewRect.top = t; + pNCP->NewRect.left = l; + pNCP->NewRect.right = r; + pNCP->NewRect.bottom = b; + + return; + } + } + else + { + base.WndProc(ref m); + } + } + + private void RenderBorder() + { + IntPtr hdc = NativeMethods.GetWindowDC(Handle); + var s = new APIRect(); + NativeMethods.GetWindowRect(Handle, ref s); + + using (Graphics g = Graphics.FromHdc(hdc)) + { + DrawingTools.DrawBorder((BorderStyle2) (int) BorderStyle, BorderColor, g, + new Rectangle(0, 0, s.Width, s.Height)); + } + NativeMethods.ReleaseDC(Handle, hdc); + } + + protected override void OnEnter(EventArgs e) + { + base.OnEnter(e); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BasePanelControl.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BasePanelControl.resx new file mode 100644 index 0000000..6b3c4ce --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BasePanelControl.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BorderControl.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BorderControl.cs new file mode 100644 index 0000000..1e357e9 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/BaseControls/BorderControl.cs @@ -0,0 +1,25 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Windows.Forms; + +namespace Alsing.Windows.Forms +{ + public class ControlBorderPainter : NativeWindow + { + public ControlBorderPainter(IntPtr Handle) + { + AssignHandle(Handle); + } + + protected override void WndProc(ref Message m) {} + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/EditView/EditViewControl.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/EditView/EditViewControl.cs new file mode 100644 index 0000000..3c70caa --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/EditView/EditViewControl.cs @@ -0,0 +1,3701 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +#region using ... + +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Resources; +using System.Text; +using System.Windows.Forms; +using Alsing.Globalization; +using Alsing.SourceCode; +using Alsing.Windows.Forms.CoreLib; +using Alsing.Windows.Forms.SyntaxBox.Painter; +using Properties; +using ScrollEventArgs=Alsing.Windows.Forms.IntelliMouse.ScrollEventArgs; + +#endregion + +namespace Alsing.Windows.Forms.SyntaxBox +{ + [ToolboxItem(false)] + public class EditViewControl : SplitViewChildControl + { + #region General Declarations + + private readonly Caret _Caret; + private readonly Selection _Selection; + + private bool _AutoListVisible; + private bool _InfoTipVisible; + private double _IntelliScrollPos; + private bool _KeyDownHandled; + private bool _OverWrite; + + /// + /// The Point in the text where the Autolist was activated. + /// + public TextPoint AutoListStartPos; + + /// + /// The Point in the text where the InfoTip was activated. + /// + public TextPoint InfoTipStartPos; + + private int MouseX; + private int MouseY; + public IPainter Painter; + public ViewPoint View; + + #endregion + + #region Internal controls + + private WeakReference _Control; + private Timer CaretTimer; + private IContainer components; + private PictureBox Filler; + + private IntelliMouseControl IntelliMouse; + private ToolTip tooltip; + + #region PUBLIC PROPERTY AUTOLIST + + private AutoListForm _AutoList; + + public AutoListForm AutoList + { + get + { + CreateAutoList(); + + return _AutoList; + } + set { _AutoList = value; } + } + + #endregion + + #region PUBLIC PROPERTY INFOTIP + + private InfoTipForm _InfoTip; + + public InfoTipForm InfoTip + { + get + { + CreateInfoTip(); + + return _InfoTip; + } + set { _InfoTip = value; } + } + + #endregion + + #region PUBLIC PROPERTY IMEWINDOW + + public IMEWindow IMEWindow { get; set; } + + #endregion + + #region PUBLIC PROPERTY FINDREPLACEDIALOG + + private FindReplaceForm _FindReplaceDialog; + + public FindReplaceForm FindReplaceDialog + { + get + { + CreateFindForm(); + + + return _FindReplaceDialog; + } + set { _FindReplaceDialog = value; } + } + + #endregion + + public bool HasAutoList + { + get { return _AutoList != null; } + } + + public bool HasInfoTip + { + get { return _InfoTip != null; } + } + + + public SyntaxBoxControl _SyntaxBox + { + get + { + try + { + if (_Control != null && _Control.IsAlive) + return (SyntaxBoxControl) _Control.Target; + return null; + } + catch + { + return null; + } + } + set { _Control = new WeakReference(value); } + } + + #endregion + + #region Public events + + /// + /// An event that is fired when the caret has moved. + /// + public event EventHandler CaretChange = null; + + /// + /// An event that is fired when the selection has changed. + /// + public event EventHandler SelectionChange = null; + + /// + /// An event that is fired when mouse down occurs on a row + /// + public event RowMouseHandler RowMouseDown = null; + + /// + /// An event that is fired when mouse move occurs on a row + /// + public event RowMouseHandler RowMouseMove = null; + + /// + /// An event that is fired when mouse up occurs on a row + /// + public event RowMouseHandler RowMouseUp = null; + + /// + /// An event that is fired when a click occurs on a row + /// + public event RowMouseHandler RowClick = null; + + /// + /// An event that is fired when a double click occurs on a row + /// + public event RowMouseHandler RowDoubleClick = null; + + /// + /// An event that is fired when the control has updated the clipboard + /// + public event CopyHandler ClipboardUpdated = null; + + #endregion + + private void CreateAutoList() + { + if (_SyntaxBox != null && !_SyntaxBox.DisableAutoList && _AutoList == null) + { + Debug.WriteLine("Creating Autolist"); + + AutoList = new AutoListForm(); + NativeMethods.SetWindowLong(AutoList.Handle, NativeMethods.GWL_STYLE, NativeMethods.WS_CHILD); + + AutoList.SendToBack(); + AutoList.Visible = false; + //this.Controls.Add (this.AutoList); + AutoList.DoubleClick += AutoListDoubleClick; + + AutoList.Images = _SyntaxBox.AutoListIcons; + AutoList.Add("a123", "a123", "Some tooltip for this item 1", 1); + AutoList.Add("b456", "b456", "Some tooltip for this item 2", 2); + AutoList.Add("c789", "c789", "Some tooltip for this item 3", 2); + AutoList.Add("d012", "d012", "Some tooltip for this item 4", 3); + AutoList.Add("e345", "e345", "Some tooltip for this item 5", 4); + } + } + + private void CreateFindForm() + { + if (!_SyntaxBox.DisableFindForm && _FindReplaceDialog == null) + { + Debug.WriteLine("Creating Findform"); + FindReplaceDialog = new FindReplaceForm(this); + } + } + + private void CreateInfoTip() + { + if (_SyntaxBox != null && !_SyntaxBox.DisableInfoTip && _InfoTip == null) + { + Debug.WriteLine("Creating Infotip"); + + InfoTip = new InfoTipForm(this); + NativeMethods.SetWindowLong(InfoTip.Handle, NativeMethods.GWL_STYLE, NativeMethods.WS_CHILD); + + InfoTip.SendToBack(); + InfoTip.Visible = false; + } + } + + private void IntelliMouse_BeginScroll(object sender, EventArgs e) + { + _IntelliScrollPos = 0; + View.YOffset = 0; + } + + private void IntelliMouse_EndScroll(object sender, EventArgs e) + { + View.YOffset = 0; + Redraw(); + } + + private void IntelliMouse_Scroll(object sender, ScrollEventArgs e) + { + if (e.DeltaY < 0 && vScroll.Value == 0) + { + View.YOffset = 0; + Redraw(); + return; + } + + if (e.DeltaY > 0 && vScroll.Value >= vScroll.Maximum - View.VisibleRowCount + 1) + { + View.YOffset = 0; + Redraw(); + return; + } + + _IntelliScrollPos += e.DeltaY/(double) 8; + + int scrollrows = (int) (_IntelliScrollPos)/View.RowHeight; + if (scrollrows != 0) + { + _IntelliScrollPos -= scrollrows*View.RowHeight; + } + View.YOffset = - (int) _IntelliScrollPos; + ScrollScreen(scrollrows); + } + + + protected override void WndProc(ref Message m) + { + if (m.Msg == (int) WindowMessage.WM_DESTROY) + { + try + { + if (FindReplaceDialog != null) + FindReplaceDialog.Close(); + + if (AutoList != null) + AutoList.Close(); + + if (InfoTip != null) + InfoTip.Close(); + } + catch + { + } + } + + base.WndProc(ref m); + } + + protected void CopyAsRTF() + { + TextStyle[] styles = Document.Parser.SyntaxDefinition.Styles; + Document.ParseAll(true); + int r1 = Selection.LogicalBounds.FirstRow; + int r2 = Selection.LogicalBounds.LastRow; + int c1 = Selection.LogicalBounds.FirstColumn; + int c2 = Selection.LogicalBounds.LastColumn; + + var sb = new StringBuilder(); + sb.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1053{\fonttbl{\f0\fmodern\fprq1\fcharset0 " + FontName + + @";}}"); + sb.Append(@"{\colortbl ;"); + + foreach (TextStyle ts in styles) + { + sb.AppendFormat("\\red{0}\\green{1}\\blue{2};", ts.ForeColor.R, ts.ForeColor.G, ts.ForeColor.B); + sb.AppendFormat("\\red{0}\\green{1}\\blue{2};", ts.BackColor.R, ts.BackColor.G, ts.BackColor.B); + } + + sb.Append(@";}"); + sb.Append(@"\viewkind4\uc1\pard\f0\fs20"); + + + bool Done = false; + for (int i = r1; i <= r2; i++) + { + Row row = Document[i]; + + + foreach (Word w in row) + { + if (i == r1 && w.Column + w.Text.Length < c1) + continue; + + bool IsFirst = (i == r1 && w.Column <= c1 && w.Column + w.Text.Length > c1); + bool IsLast = (i == r2 && w.Column < c2 && w.Column + w.Text.Length > c2); + + + if (w.Type == WordType.Word && w.Style != null) + { + int clrindex = Array.IndexOf(styles, w.Style); + clrindex *= 2; + clrindex++; + + sb.Append("{\\cf" + clrindex.ToString(CultureInfo.InvariantCulture)); + if (!w.Style.Transparent) + { + sb.Append("\\highlight" + (clrindex + 1).ToString(CultureInfo.InvariantCulture)); + } + sb.Append(" "); + } + + if (w.Style != null) + { + if (w.Style.Bold) + sb.Append(@"\b "); + if (w.Style.Underline) + sb.Append(@"\ul "); + if (w.Style.Italic) + sb.Append(@"\i "); + } + string wordtext = w.Text; + + if (IsLast) + wordtext = wordtext.Substring(0, c2 - w.Column); + + if (IsFirst) + wordtext = wordtext.Substring(c1 - w.Column); + + + wordtext = + wordtext.Replace(@"\", @" \ \ ").Replace(@" + } + ", @" \ + } + "). + Replace(@" + { + ", @" \ + { + "); + + sb.Append(wordtext); + + if (w.Style != null) + { + if (w.Style.Bold) sb.Append(@"\b0 "); + if (w.Style.Underline) + sb.Append(@"\ul0 "); + if (w.Style.Italic) sb.Append(@"\i0 "); + } + + if (w.Type == WordType.Word && w.Style != null) + { + sb.Append("}"); + } + + if (IsLast) + { + Done = true; + break; + } + } + if (Done) break; + + sb.Append(@"\par"); + } + + + var da = new DataObject(); + da.SetData(DataFormats.Rtf, sb.ToString()); + string s = Selection.Text; + da.SetData(DataFormats.Text, s); + Clipboard.SetDataObject(da); + + var ea = new CopyEventArgs {Text = s}; + OnClipboardUpdated(ea); + } + + #region Constructor + + /// + /// Default constructor for the SyntaxBoxControl + /// + public EditViewControl(SyntaxBoxControl Parent) + { + _SyntaxBox = Parent; + + Painter = new NativePainter(this); + _Selection = new Selection(this); + _Caret = new Caret(this); + + _Caret.Change += CaretChanged; + _Selection.Change += SelectionChanged; + + + InitializeComponent(); + + + CreateAutoList(); + //CreateFindForm (); + CreateInfoTip(); + + SetStyle(ControlStyles.AllPaintingInWmPaint, false); + SetStyle(ControlStyles.DoubleBuffer, false); + SetStyle(ControlStyles.Selectable, true); + SetStyle(ControlStyles.ResizeRedraw, true); + SetStyle(ControlStyles.Opaque, true); + SetStyle(ControlStyles.UserPaint, true); + UpdateStyles(); + + // this.IMEWindow = new Alsing.Globalization.IMEWindow (this.Handle,_SyntaxBox.FontName,_SyntaxBox.FontSize); + } + + #endregion + + #region DISPOSE() + + /// + /// + /// + protected override void Dispose(bool disposing) + { + RemoveFocus(); +#if DEBUG + try + { + Console.WriteLine("disposing editview"); + } + catch + { + } +#endif + + if (disposing) + { + if (components != null) + components.Dispose(); + + try + { + if (Painter != null) + Painter.Dispose(); + } + catch + { + } + } + base.Dispose(disposing); + } + + #endregion + + #region Private/Protected/public Properties + + public int PixelTabSize + { + get { return _SyntaxBox.TabSize*View.CharWidth; } + } + + #endregion + + #region Private/Protected/Internal Methods + + private int MaxCharWidth = 8; + + private void DoResize() + { + if (Visible && Width > 0 && Height > 0 && IsHandleCreated) + { + try + { + if (Filler == null) + return; + + TopThumb.Width = SystemInformation.VerticalScrollBarWidth; + LeftThumb.Height = SystemInformation.HorizontalScrollBarHeight; + vScroll.Width = SystemInformation.VerticalScrollBarWidth; + hScroll.Height = SystemInformation.HorizontalScrollBarHeight; + + if (TopThumbVisible) + { + vScroll.Top = TopThumb.Height; + if (hScroll.Visible) + vScroll.Height = ClientHeight - hScroll.Height - TopThumb.Height; + else + vScroll.Height = ClientHeight - TopThumb.Height; + } + else + { + if (hScroll.Visible) + vScroll.Height = ClientHeight - hScroll.Height; + else + vScroll.Height = ClientHeight; + + vScroll.Top = 0; + } + + if (LeftThumbVisible) + { + hScroll.Left = LeftThumb.Width; + if (vScroll.Visible) + hScroll.Width = ClientWidth - vScroll.Width - LeftThumb.Width; + else + hScroll.Width = ClientWidth - LeftThumb.Width; + } + else + { + if (vScroll.Visible) + hScroll.Width = ClientWidth - vScroll.Width; + else + hScroll.Width = ClientWidth; + + hScroll.Left = 0; + } + + + if (Width != OldWidth && Width > 0) + { + OldWidth = Width; + if (Painter != null) + Painter.Resize(); + } + + + vScroll.Left = ClientWidth - vScroll.Width; + hScroll.Top = ClientHeight - hScroll.Height; + + LeftThumb.Left = 0; + LeftThumb.Top = hScroll.Top; + + TopThumb.Left = vScroll.Left; + TopThumb.Top = 0; + + + Filler.Left = vScroll.Left; + Filler.Top = hScroll.Top; + Filler.Width = vScroll.Width; + Filler.Height = hScroll.Height; + } + catch + { + } + } + } + + private void InsertText(string text) + { + Caret.CropPosition(); + if (Selection.IsValid) + { + Selection.DeleteSelection(); + InsertText(text); + } + else + { + if (!_OverWrite || text.Length > 1) + { + TextPoint p = Document.InsertText(text, Caret.Position.X, Caret.Position.Y); + Caret.CurrentRow.Parse(true); + if (text.Length == 1) + { + Caret.SetPos(p); + Caret.CaretMoved(false); + } + else + { + //Document.i = true; + + Document.ResetVisibleRows(); + Caret.SetPos(p); + Caret.CaretMoved(false); + } + } + else + { + var r = new TextRange + { + FirstColumn = Caret.Position.X, + FirstRow = Caret.Position.Y, + LastColumn = (Caret.Position.X + 1), + LastRow = Caret.Position.Y + }; + var ag = new UndoBlockCollection(); + var b = new UndoBlock + { + Action = UndoAction.DeleteRange, + Text = Document.GetRange(r), + Position = Caret.Position + }; + ag.Add(b); + Document.DeleteRange(r, false); + b = new UndoBlock {Action = UndoAction.InsertRange}; + string NewChar = text; + b.Text = NewChar; + b.Position = Caret.Position; + ag.Add(b); + Document.AddToUndoList(ag); + Document.InsertText(NewChar, Caret.Position.X, Caret.Position.Y, false); + Caret.CurrentRow.Parse(true); + + Caret.MoveRight(false); + } + } + // this.ScrollIntoView (); + } + + private void InsertEnter() + { + Caret.CropPosition(); + if (Selection.IsValid) + { + Selection.DeleteSelection(); + InsertEnter(); + } + else + { + switch (Indent) + { + case IndentStyle.None: + { + Document.InsertText("\n", Caret.Position.X, Caret.Position.Y); + //depends on what sort of indention we are using.... + Caret.CurrentRow.Parse(); + Caret.MoveDown(false); + Caret.CurrentRow.Parse(false); + Caret.CurrentRow.Parse(true); + + Caret.Position.X = 0; + Caret.SetPos(Caret.Position); + break; + } + case IndentStyle.LastRow: + { + Row xtr = Caret.CurrentRow; + string indent = xtr.GetLeadingWhitespace(); + int Max = Math.Min(indent.Length, Caret.Position.X); + string split = "\n" + indent.Substring(0, Max); + Document.InsertText(split, Caret.Position.X, Caret.Position.Y); + Document.ResetVisibleRows(); + Caret.CurrentRow.Parse(false); + Caret.CurrentRow.Parse(true); + Caret.MoveDown(false); + Caret.CurrentRow.Parse(false); + Caret.CurrentRow.Parse(true); + + Caret.Position.X = indent.Length; + Caret.SetPos(Caret.Position); + xtr.Parse(false); + xtr.Parse(true); + xtr.NextRow.Parse(false); + xtr.NextRow.Parse(true); + + break; + } + case IndentStyle.Scope: + { + Row xtr = Caret.CurrentRow; + xtr.Parse(true); + if (xtr.ShouldOutdent) + { + OutdentEndRow(); + } + + Document.InsertText("\n", Caret.Position.X, Caret.Position.Y); + //depends on what sort of indention we are using.... + Caret.CurrentRow.Parse(); + Caret.MoveDown(false); + Caret.CurrentRow.Parse(false); + + var indent = new String('\t', Caret.CurrentRow.Depth); + Document.InsertText(indent, 0, Caret.Position.Y); + + Caret.CurrentRow.Parse(false); + Caret.CurrentRow.Parse(true); + + Caret.Position.X = indent.Length; + Caret.SetPos(Caret.Position); + Caret.CropPosition(); + Selection.ClearSelection(); + + xtr.Parse(false); + xtr.Parse(true); + xtr.NextRow.Parse(false); + xtr.NextRow.Parse(true); + + break; + } + case IndentStyle.Smart: + { + Row xtr = Caret.CurrentRow; + if (xtr.ShouldOutdent) + { + OutdentEndRow(); + } + Document.InsertText("\n", Caret.Position.X, Caret.Position.Y); + Caret.MoveDown(false); + Caret.CurrentRow.Parse(false); + Caret.CurrentRow.Parse(true); + Caret.CurrentRow.startSpan.StartRow.Parse(false); + Caret.CurrentRow.startSpan.StartRow.Parse(true); + + string prev = "\t" + Caret.CurrentRow.startSpan.StartRow.GetVirtualLeadingWhitespace(); + + string indent = Caret.CurrentRow.PrevRow.GetLeadingWhitespace(); + if (indent.Length < prev.Length) + indent = prev; + + string ts = "\t" + new String(' ', TabSize); + while (indent.IndexOf(ts) >= 0) + { + indent = indent.Replace(ts, "\t\t"); + } + + Document.InsertText(indent, 0, Caret.Position.Y); + + Caret.CurrentRow.Parse(false); + Caret.CurrentRow.Parse(true); + + Caret.Position.X = indent.Length; + Caret.SetPos(Caret.Position); + + Caret.CropPosition(); + Selection.ClearSelection(); + xtr.Parse(false); + xtr.Parse(true); + xtr.NextRow.Parse(false); + xtr.NextRow.Parse(true); + break; + } + } + ScrollIntoView(); + } + } + + private void OutdentEndRow() + { + try + { + if (Indent == IndentStyle.Scope) + { + Row xtr = Caret.CurrentRow; + var indent1 = new String('\t', Caret.CurrentRow.Depth); + var tr = new TextRange + { + FirstColumn = 0, + LastColumn = xtr.GetLeadingWhitespace().Length, + FirstRow = xtr.Index, + LastRow = xtr.Index + }; + + Document.DeleteRange(tr); + Document.InsertText(indent1, 0, xtr.Index, true); + + int diff = indent1.Length - tr.LastColumn; + Caret.Position.X += diff; + Caret.SetPos(Caret.Position); + Caret.CropPosition(); + Selection.ClearSelection(); + Caret.CurrentRow.Parse(false); + Caret.CurrentRow.Parse(true); + } + else if (Indent == IndentStyle.Smart) + { + Row xtr = Caret.CurrentRow; + + if (xtr.FirstNonWsWord == xtr.expansion_EndSpan.EndWord) + { + //int j=xtr.Expansion_StartRow.StartWordIndex; + string indent1 = xtr.startSpan.StartWord.Row.GetVirtualLeadingWhitespace(); + var tr = new TextRange + { + FirstColumn = 0, + LastColumn = xtr.GetLeadingWhitespace().Length, + FirstRow = xtr.Index, + LastRow = xtr.Index + }; + Document.DeleteRange(tr); + string ts = "\t" + new String(' ', TabSize); + while (indent1.IndexOf(ts) >= 0) + { + indent1 = indent1.Replace(ts, "\t\t"); + } + Document.InsertText(indent1, 0, xtr.Index, true); + + int diff = indent1.Length - tr.LastColumn; + Caret.Position.X += diff; + Caret.SetPos(Caret.Position); + Caret.CropPosition(); + Selection.ClearSelection(); + Caret.CurrentRow.Parse(false); + Caret.CurrentRow.Parse(true); + } + } + } + catch + { + } + } + + private void DeleteForward() + { + Caret.CropPosition(); + if (Selection.IsValid) + Selection.DeleteSelection(); + else + { + Row xtr = Caret.CurrentRow; + if (Caret.Position.X == xtr.Text.Length) + { + if (Caret.Position.Y <= Document.Count - 2) + { + var r = new TextRange {FirstColumn = Caret.Position.X, FirstRow = Caret.Position.Y}; + r.LastRow = r.FirstRow + 1; + r.LastColumn = 0; + + Document.DeleteRange(r); + Document.ResetVisibleRows(); + } + } + else + { + var r = new TextRange {FirstColumn = Caret.Position.X, FirstRow = Caret.Position.Y}; + r.LastRow = r.FirstRow; + r.LastColumn = r.FirstColumn + 1; + Document.DeleteRange(r); + Document.ResetVisibleRows(); + Caret.CurrentRow.Parse(false); + Caret.CurrentRow.Parse(true); + } + } + } + + private void DeleteBackwards() + { + Caret.CropPosition(); + if (Selection.IsValid) + Selection.DeleteSelection(); + else + { + Row xtr = Caret.CurrentRow; + if (Caret.Position.X == 0) + { + if (Caret.Position.Y > 0) + { + Caret.Position.Y--; + Caret.MoveEnd(false); + DeleteForward(); + //Caret.CurrentRow.Parse (); + Document.ResetVisibleRows(); + } + } + else + { + if (Caret.Position.X >= xtr.Text.Length) + { + var r = new TextRange {FirstColumn = (Caret.Position.X - 1), FirstRow = Caret.Position.Y}; + r.LastRow = r.FirstRow; + r.LastColumn = r.FirstColumn + 1; + Document.DeleteRange(r); + Document.ResetVisibleRows(); + Caret.MoveEnd(false); + Caret.CurrentRow.Parse(); + } + else + { + var r = new TextRange {FirstColumn = (Caret.Position.X - 1), FirstRow = Caret.Position.Y}; + r.LastRow = r.FirstRow; + r.LastColumn = r.FirstColumn + 1; + Document.DeleteRange(r); + Document.ResetVisibleRows(); + Caret.MoveLeft(false); + Caret.CurrentRow.Parse(); + } + } + } + } + + private void ScrollScreen(int Amount) + { + try + { + tooltip.RemoveAll(); + + int newval = vScroll.Value + Amount; + + newval = Math.Max(newval, vScroll.Minimum); + newval = Math.Min(newval, vScroll.Maximum); + + if (newval >= vScroll.Maximum - View.VisibleRowCount + 1) + newval = vScroll.Maximum - View.VisibleRowCount + 1; + + newval = Math.Max(newval, vScroll.Minimum); + + vScroll.Value = newval; + Redraw(); + } + catch + { + } + } + + private void PasteText() + { + try + { + IDataObject iData = Clipboard.GetDataObject(); + + if (iData != null) + if (iData.GetDataPresent(DataFormats.UnicodeText)) + { + // Yes it is, so display it in a text box. + var s = (string) iData.GetData(DataFormats.UnicodeText); + + InsertText(s); + if (ParseOnPaste) + Document.ParseAll(true); + } + else if (iData.GetDataPresent(DataFormats.Text)) + { + // Yes it is, so display it in a text box. + var s = (string) iData.GetData(DataFormats.Text); + + InsertText(s); + if (ParseOnPaste) + Document.ParseAll(true); + } + } + catch + { + //ignore + } + } + + + private void BeginDragDrop() + { + DoDragDrop(Selection.Text, DragDropEffects.All); + } + + private void Redraw() + { + Invalidate(); + } + + + private void RedrawCaret() + { + Graphics g = CreateGraphics(); + Painter.RenderCaret(g); + g.Dispose(); + } + + private void SetMouseCursor(int x, int y) + { + if (_SyntaxBox.LockCursorUpdate) + { + Cursor = _SyntaxBox.Cursor; + return; + } + + if (View.Action == EditAction.DragText) + { + Cursor = Cursors.Hand; + //Cursor.Current = Cursors.Hand; + } + else + { + if (x < View.TotalMarginWidth) + { + if (x < View.GutterMarginWidth) + { + Cursor = Cursors.Arrow; + } + else + { + var ms = new MemoryStream(Resources.FlippedCursor); + Cursor = new Cursor(ms); + } + } + else + { + if (x > View.TextMargin - 8) + { + if (IsOverSelection(x, y)) + Cursor = Cursors.Arrow; + else + { + TextPoint tp = Painter.CharFromPixel(x, y); + Word w = Document.GetWordFromPos(tp); + if (w != null && w.Pattern != null && w.Pattern.Category != null) + { + var e = new WordMouseEventArgs + { + Pattern = w.Pattern, + Button = MouseButtons.None, + Cursor = Cursors.Hand, + Word = w + }; + + _SyntaxBox.OnWordMouseHover(ref e); + + Cursor = e.Cursor; + } + else + Cursor = Cursors.IBeam; + } + } + else + { + Cursor = Cursors.Arrow; + } + } + } + } + + private void CopyText() + { + //no freaking vs.net copy empty selection + if (!Selection.IsValid) + return; + + if (_SyntaxBox.CopyAsRTF) + { + CopyAsRTF(); + } + else + { + try + { + string t = Selection.Text; + Clipboard.SetDataObject(t, true); + var ea = new CopyEventArgs {Text = t}; + OnClipboardUpdated(ea); + } + catch + { + try + { + string t = Selection.Text; + Clipboard.SetDataObject(t, true); + var ea = new CopyEventArgs {Text = t}; + OnClipboardUpdated(ea); + } + catch + { + } + } + } + } + + /// + /// For public use only + /// + /// + /// + protected override bool IsInputKey(Keys key) + { + switch (key) + { + case Keys.Up: + case Keys.Down: + case Keys.Right: + case Keys.Left: + case Keys.Tab: + case Keys.PageDown: + case Keys.PageUp: + case Keys.Enter: + return true; + } + return true; //base.IsInputKey(key); + } + + protected override bool IsInputChar(char c) + { + return true; + } + + public void RemoveFocus() + { + if (InfoTip == null || AutoList == null) + return; + + if (!ContainsFocus && !InfoTip.ContainsFocus && !AutoList.ContainsFocus) + { + CaretTimer.Enabled = false; + Caret.Blink = false; + _AutoListVisible = false; + _InfoTipVisible = false; + } + Redraw(); + } + + private void SelectCurrentWord() + { + Row xtr = Caret.CurrentRow; + if (xtr.Text == "") + return; + + if (Caret.Position.X >= xtr.Text.Length) + return; + + string Char = xtr.Text.Substring(Caret.Position.X, 1); + int Type = CharType(Char); + + int left = Caret.Position.X; + int right = Caret.Position.X; + + while (left >= 0 && CharType(xtr.Text.Substring(left, 1)) == Type) + left--; + + while (right <= xtr.Text.Length - 1 && CharType(xtr.Text.Substring(right, 1)) == Type) + right++; + + Selection.Bounds.FirstRow = Selection.Bounds.LastRow = xtr.Index; + Selection.Bounds.FirstColumn = left + 1; + Selection.Bounds.LastColumn = right; + Caret.Position.X = right; + Caret.SetPos(Caret.Position); + Redraw(); + } + + private static int CharType(string s) + { + const string g1 = " \t"; + const string g2 = ".,-+'?´=)(/&%¤#!\"\\<>[]$£@*:;{}"; + + if (g1.IndexOf(s) >= 0) + return 1; + + if (g2.IndexOf(s) >= 0) + return 2; + + return 3; + } + + private void SelectPattern(int RowIndex, int Column, int Length) + { + Selection.Bounds.FirstColumn = Column; + Selection.Bounds.FirstRow = RowIndex; + Selection.Bounds.LastColumn = Column + Length; + Selection.Bounds.LastRow = RowIndex; + Caret.Position.X = Column + Length; + Caret.Position.Y = RowIndex; + Caret.CurrentRow.EnsureVisible(); + ScrollIntoView(); + Redraw(); + } + + public void InitVars() + { + //setup viewpoint data + + + if (View.RowHeight == 0) + View.RowHeight = 48; + + if (View.CharWidth == 0) + View.CharWidth = 16; + + //View.RowHeight=16; + //View.CharWidth=8; + + View.FirstVisibleColumn = hScroll.Value; + View.FirstVisibleRow = vScroll.Value; + // View.yOffset =_yOffset; + + View.VisibleRowCount = 0; + if (hScroll.Visible) + View.VisibleRowCount = (Height - hScroll.Height)/View.RowHeight + 1; + else + View.VisibleRowCount = (Height - hScroll.Height)/View.RowHeight + 2; + + View.GutterMarginWidth = ShowGutterMargin ? GutterMarginWidth : 0; + + if (ShowLineNumbers) + { + int chars = (Document.Count).ToString(CultureInfo.InvariantCulture).Length; + var s = new String('9', chars); + View.LineNumberMarginWidth = 10 + Painter.MeasureString(s).Width; + } + else + View.LineNumberMarginWidth = 0; + + + View.TotalMarginWidth = View.GutterMarginWidth + View.LineNumberMarginWidth; + if (Document.Folding) + View.TextMargin = View.TotalMarginWidth + 20; + else + View.TextMargin = View.TotalMarginWidth + 7; + + + View.ClientAreaWidth = Width - vScroll.Width - View.TextMargin; + View.ClientAreaStart = View.FirstVisibleColumn*View.CharWidth; + } + + public void CalcMaxCharWidth() + { + MaxCharWidth = Painter.GetMaxCharWidth(); + } + + public void SetMaxHorizontalScroll() + { + CalcMaxCharWidth(); + int CharWidth = View.CharWidth; + if (CharWidth == 0) + CharWidth = 1; + + if (View.ClientAreaWidth/CharWidth < 0) + { + hScroll.Maximum = 1000; + return; + } + + hScroll.LargeChange = View.ClientAreaWidth/CharWidth; + + try + { + int max = 0; + for (int i = View.FirstVisibleRow; i < Document.VisibleRows.Count; i++) + { + if (i >= View.VisibleRowCount + View.FirstVisibleRow) + break; + + string l = Document.VisibleRows[i].IsCollapsed + ? Document.VisibleRows[i].VirtualCollapsedRow.Text + : Document.VisibleRows[i].Text; + + l = l.Replace("\t", new string(' ', TabSize)); + if (l.Length > max) + max = l.Length; + } + + int pixels = max*MaxCharWidth; + int chars = pixels/CharWidth; + + + if (hScroll.Value <= chars) + hScroll.Maximum = chars; + } + catch + { + hScroll.Maximum = 1000; + } + } + + public void InitScrollbars() + { + if (Document.VisibleRows.Count > 0) + { + vScroll.Maximum = Document.VisibleRows.Count + 1; + //+this.View.VisibleRowCount-2;// - View.VisibleRowCount ; + vScroll.LargeChange = View.VisibleRowCount; + SetMaxHorizontalScroll(); + } + else + vScroll.Maximum = 1; + } + + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new Container(); + var resources = new ResourceManager(typeof (EditViewControl)); + Filler = new PictureBox(); + CaretTimer = new Timer(components); + tooltip = new ToolTip(components); + + SuspendLayout(); + + if (!_SyntaxBox.DisableIntelliMouse) + { + IntelliMouse = new IntelliMouseControl + { + BackgroundImage = + ((Bitmap) (resources.GetObject("IntelliMouse.BackgroundImage"))), + Image = ((Bitmap) (resources.GetObject("IntelliMouse.Image"))), + Location = new Point(197, 157), + Name = "IntelliMouse", + Size = new Size(28, 28), + TabIndex = 4, + TransparencyKey = Color.FromArgb(((255)), ((0)), ((255))), + Visible = false + }; + // + // IntelliMouse + // + IntelliMouse.EndScroll += IntelliMouse_EndScroll; + IntelliMouse.BeginScroll += IntelliMouse_BeginScroll; + IntelliMouse.Scroll += IntelliMouse_Scroll; + } + + + // + // hScroll + // + hScroll.Cursor = Cursors.Default; + hScroll.Scroll += hScroll_Scroll; + // + // vScroll + // + vScroll.Cursor = Cursors.Default; + vScroll.Scroll += vScroll_Scroll; + + // + // CaretTimer + // + CaretTimer.Enabled = true; + CaretTimer.Interval = 500; + CaretTimer.Tick += CaretTimer_Tick; + // + // tooltip + // + tooltip.AutoPopDelay = 50000; + tooltip.InitialDelay = 0; + tooltip.ReshowDelay = 1000; + tooltip.ShowAlways = true; + // + // TopThumb + // + TopThumb.BackColor = SystemColors.Control; + TopThumb.Cursor = Cursors.HSplit; + TopThumb.Location = new Point(101, 17); + TopThumb.Name = "TopThumb"; + TopThumb.Size = new Size(16, 8); + TopThumb.TabIndex = 3; + TopThumb.Visible = false; + // + // LeftThumb + // + LeftThumb.BackColor = SystemColors.Control; + LeftThumb.Cursor = Cursors.VSplit; + LeftThumb.Location = new Point(423, 17); + LeftThumb.Name = "LeftThumb"; + LeftThumb.Size = new Size(8, 16); + LeftThumb.TabIndex = 3; + LeftThumb.Visible = false; + // + // EditViewControl + // + try + { + AllowDrop = true; + } + catch + { + // Console.WriteLine ("error in editview allowdrop {0}",x.Message); + } + + Controls.AddRange(new Control[] {IntelliMouse}); + Size = new Size(0, 0); + LostFocus += EditViewControl_Leave; + GotFocus += EditViewControl_Enter; + ResumeLayout(false); + } + + + public void InsertAutolistText() + { + var tr = new TextRange + { + FirstRow = Caret.Position.Y, + LastRow = Caret.Position.Y, + FirstColumn = AutoListStartPos.X, + LastColumn = Caret.Position.X + }; + + Document.DeleteRange(tr, true); + Caret.Position.X = AutoListStartPos.X; + InsertText(AutoList.SelectedText); + SetFocus(); + } + + private void MoveCaretToNextWord(bool Select) + { + int x = Caret.Position.X; + int y = Caret.Position.Y; + int StartType; + bool found = false; + if (x == Caret.CurrentRow.Text.Length) + { + StartType = 1; + } + else + { + string StartChar = Document[y].Text.Substring(Caret.Position.X, 1); + StartType = CharType(StartChar); + } + + + while (y < Document.Count) + { + while (x < Document[y].Text.Length) + { + string Char = Document[y].Text.Substring(x, 1); + int Type = CharType(Char); + if (Type != StartType) + { + if (Type == 1) + { + StartType = 1; + } + else + { + found = true; + break; + } + } + x++; + } + if (found) + break; + x = 0; + y++; + } + + if (y >= Document.Count - 1) + { + y = Document.Count - 1; + + if (x >= Document[y].Text.Length) + x = Document[y].Text.Length - 1; + + if (x == - 1) + x = 0; + } + + Caret.SetPos(new TextPoint(x, y)); + if (!Select) + Selection.ClearSelection(); + if (Select) + { + Selection.MakeSelection(); + } + + + ScrollIntoView(); + } + + public void InitGraphics() + { + Painter.InitGraphics(); + } + + + private void MoveCaretToPrevWord(bool Select) + { + int x = Caret.Position.X; + int y = Caret.Position.Y; + int StartType; + bool found = false; + if (x == Caret.CurrentRow.Text.Length) + { + StartType = 1; + x = Caret.CurrentRow.Text.Length - 1; + } + else + { + string StartChar = Document[y].Text.Substring(Caret.Position.X, 1); + StartType = CharType(StartChar); + } + + + while (y >= 0) + { + while (x >= 0 && x < Document[y].Text.Length) + { + string Char = Document[y].Text.Substring(x, 1); + int Type = CharType(Char); + if (Type != StartType) + { + found = true; + + while (x > 0) + { + string Char2 = Document[y].Text.Substring(x, 1); + int Type2 = CharType(Char2); + if (Type2 != Type) + { + x++; + break; + } + + x--; + } + + break; + } + x--; + } + if (found) + break; + + if (y == 0) + { + x = 0; + break; + } + y--; + x = Document[y].Text.Length - 1; + } + + + Caret.SetPos(new TextPoint(x, y)); + if (!Select) + Selection.ClearSelection(); + + if (Select) + { + Selection.MakeSelection(); + } + + ScrollIntoView(); + } + + + private void SetFocus() + { + Focus(); + } + + #endregion + + #region Public Methods + + /// + /// Displays the GotoLine dialog. + /// + public void ShowGotoLine() + { + var go = new GotoLineForm(this, Document.Count); + // if (this.TopLevelControl is Form) + // go.Owner=(Form)this.TopLevelControl; + + go.ShowDialog(TopLevelControl); + } + + /// + /// - + /// + public void ShowSettings() + { + // SettingsForm se=new SettingsForm (this); + // se.ShowDialog(); + } + + /// + /// Places the caret on a specified line and scrolls the caret into view. + /// + /// the zero based index of the line to jump to + public void GotoLine(int RowIndex) + { + if (RowIndex >= Document.Count) + RowIndex = Document.Count - 1; + + if (RowIndex < 0) + RowIndex = 0; + + Caret.Position.Y = RowIndex; + Caret.Position.X = 0; + Caret.CurrentRow.EnsureVisible(); + ClearSelection(); + ScrollIntoView(); + Redraw(); + } + + + /// + /// Clears the active selection. + /// + public void ClearSelection() + { + Selection.ClearSelection(); + Redraw(); + } + + /// + /// Returns if a specified pixel position is over the current selection. + /// + /// X Position in pixels + /// Y Position in pixels + /// true if over selection othewise false + public bool IsOverSelection(int x, int y) + { + TextPoint p = Painter.CharFromPixel(x, y); + + if (p.Y >= Selection.LogicalBounds.FirstRow && p.Y <= Selection.LogicalBounds.LastRow && Selection.IsValid) + { + if (p.Y > Selection.LogicalBounds.FirstRow && p.Y < Selection.LogicalBounds.LastRow && Selection.IsValid) + return true; + if (p.Y == Selection.LogicalBounds.FirstRow && + Selection.LogicalBounds.FirstRow == Selection.LogicalBounds.LastRow) + { + if (p.X >= Selection.LogicalBounds.FirstColumn && p.X <= Selection.LogicalBounds.LastColumn) + return true; + return false; + } + if (p.X >= Selection.LogicalBounds.FirstColumn && p.Y == Selection.LogicalBounds.FirstRow) + return true; + if (p.X <= Selection.LogicalBounds.LastColumn && p.Y == Selection.LogicalBounds.LastRow) + return true; + return false; + } + + return false; + //no chance we are over Selection.LogicalBounds + } + + /// + /// Scrolls a given position in the text into view. + /// + /// Position in text + public void ScrollIntoView(TextPoint Pos) + { + TextPoint tmp = Caret.Position; + Caret.Position = Pos; + Caret.CurrentRow.EnsureVisible(); + ScrollIntoView(); + Caret.Position = tmp; + Invalidate(); + } + + public void ScrollIntoView(int RowIndex) + { + Row r = Document[RowIndex]; + r.EnsureVisible(); + vScroll.Value = r.VisibleIndex; + Invalidate(); + } + + /// + /// Scrolls the caret into view. + /// + public void ScrollIntoView() + { + InitScrollbars(); + + Caret.CropPosition(); + try + { + Row xtr2 = Caret.CurrentRow; + if (xtr2.VisibleIndex >= View.FirstVisibleRow + View.VisibleRowCount - 2) + { + int Diff = Caret.CurrentRow.VisibleIndex - (View.FirstVisibleRow + View.VisibleRowCount - 2) + + View.FirstVisibleRow; + if (Diff > Document.VisibleRows.Count - 1) + Diff = Document.VisibleRows.Count - 1; + + Row r = Document.VisibleRows[Diff]; + int index = r.VisibleIndex; + if (index != - 1) + vScroll.Value = index; + } + } + catch + { + } + + + if (Caret.CurrentRow.VisibleIndex < View.FirstVisibleRow) + { + Row r = Caret.CurrentRow; + int index = r.VisibleIndex; + if (index != - 1) + vScroll.Value = index; + } + + Row xtr = Caret.CurrentRow; + + + int x; + if (Caret.CurrentRow.IsCollapsedEndPart) + { + x = Painter.MeasureRow(xtr, Caret.Position.X).Width + Caret.CurrentRow.Expansion_PixelStart; + x -= Painter.MeasureRow(xtr, xtr.Expansion_StartChar).Width; + + if (x >= View.ClientAreaWidth + View.ClientAreaStart) + hScroll.Value = Math.Min(hScroll.Maximum, ((x - View.ClientAreaWidth)/View.CharWidth) + 15); + + if (x < View.ClientAreaStart + 10) + hScroll.Value = Math.Max(hScroll.Minimum, ((x)/View.CharWidth) - 15); + } + else + { + x = Painter.MeasureRow(xtr, Caret.Position.X).Width; + + if (x >= View.ClientAreaWidth + View.ClientAreaStart) + hScroll.Value = Math.Min(hScroll.Maximum, ((x - View.ClientAreaWidth)/View.CharWidth) + 15); + + if (x < View.ClientAreaStart) + hScroll.Value = Math.Max(hScroll.Minimum, ((x)/View.CharWidth) - 15); + } + } + + /// + /// Moves the caret to the next line that has a bookmark. + /// + public void GotoNextBookmark() + { + int index = Document.GetNextBookmark(Caret.Position.Y); + Caret.SetPos(new TextPoint(0, index)); + ScrollIntoView(); + Redraw(); + } + + + /// + /// Moves the caret to the previous line that has a bookmark. + /// + public void GotoPreviousBookmark() + { + int index = Document.GetPreviousBookmark(Caret.Position.Y); + Caret.SetPos(new TextPoint(0, index)); + ScrollIntoView(); + Redraw(); + } + + /// + /// Selects next occurance of the given pattern. + /// + /// Pattern to find + /// Case sensitive + /// Match whole words only + /// + public bool SelectNext(string Pattern, bool MatchCase, bool WholeWords, bool UseRegEx) + { + string pattern = Pattern; + for (int i = Caret.Position.Y; i < Document.Count; i++) + { + Row r = Document[i]; + + string t = r.Text; + if (WholeWords) + { + string s = " " + r.Text + " "; + t = ""; + pattern = " " + Pattern + " "; + foreach (char c in s) + { + if (".,+-*^\\/()[]{}@:;'?£$#%& \t=<>".IndexOf(c) >= 0) + t += " "; + else + t += c; + } + } + + if (!MatchCase) + { + t = t.ToLowerInvariant(); + pattern = pattern.ToLowerInvariant(); + } + + int Col = t.IndexOf(pattern); + + int StartCol = Caret.Position.X; + int StartRow = Caret.Position.Y; + if ((Col >= StartCol) || (i > StartRow && Col >= 0)) + { + SelectPattern(i, Col, Pattern.Length); + return true; + } + } + return false; + } + + public bool ReplaceSelection(string text) + { + if (!Selection.IsValid) + return false; + + int x = Selection.LogicalBounds.FirstColumn; + int y = Selection.LogicalBounds.FirstRow; + + Selection.DeleteSelection(); + + Caret.Position.X = x; + Caret.Position.Y = y; + + InsertText(text); + + + Selection.Bounds.FirstRow = y; + Selection.Bounds.FirstColumn = x + text.Length; + + Selection.Bounds.LastRow = y; + Selection.Bounds.LastColumn = x + text.Length; + + Caret.Position.X = x + text.Length; + Caret.Position.Y = y; + return true; + } + + + /// + /// Toggles a bookmark on/off on the active row. + /// + public void ToggleBookmark() + { + Document[Caret.Position.Y].Bookmarked = !Document[Caret.Position.Y].Bookmarked; + Redraw(); + } + + + /// + /// Deletes selected text if possible otherwise deletes forward. (delete key) + /// + public void Delete() + { + DeleteForward(); + Refresh(); + } + + /// + /// Selects all text in the active document. (control + a) + /// + public void SelectAll() + { + Selection.SelectAll(); + Redraw(); + } + + + /// + /// Paste text from clipboard to current caret position. (control + v) + /// + public void Paste() + { + PasteText(); + Refresh(); + } + + /// + /// Copies selected text to clipboard. (control + c) + /// + public void Copy() + { + CopyText(); + } + + /// + /// Cuts selected text to clipboard. (control + x) + /// + public void Cut() + { + CopyText(); + Selection.DeleteSelection(); + } + + /// + /// Removes the current row + /// + public void RemoveCurrentRow() + { + if (Caret.CurrentRow != null && Document.Count > 1) + { + Document.Remove(Caret.CurrentRow.Index, true); + Document.ResetVisibleRows(); + Caret.CropPosition(); + Caret.CurrentRow.Text = Caret.CurrentRow.Text; + Caret.CurrentRow.Parse(true); + Document.ResetVisibleRows(); + ScrollIntoView(); + //this.Refresh (); + } + } + + public void CutClear() + { + if (Selection.IsValid) + Cut(); + else + RemoveCurrentRow(); + } + + /// + /// Redo last undo action. (control + y) + /// + public void Redo() + { + TextPoint p = Document.Redo(); + if (p.X != - 1 && p.Y != - 1) + { + Caret.Position = p; + Selection.ClearSelection(); + ScrollIntoView(); + } + } + + /// + /// Undo last edit action. (control + z) + /// + public void Undo() + { + TextPoint p = Document.Undo(); + if (p.X != - 1 && p.Y != - 1) + { + Caret.Position = p; + Selection.ClearSelection(); + ScrollIntoView(); + } + } + + /// + /// Returns a point where x is the column and y is the row from a given pixel position. + /// + /// X Position in pixels + /// Y Position in pixels + /// Column and Rowindex + public TextPoint CharFromPixel(int x, int y) + { + return Painter.CharFromPixel(x, y); + } + + public void ShowFind() + { + if (FindReplaceDialog != null) + { + FindReplaceDialog.TopLevel = true; + if (TopLevelControl is Form) + { + FindReplaceDialog.Owner = (Form) TopLevelControl; + } + FindReplaceDialog.ShowFind(); + } + } + + public void ShowReplace() + { + if (FindReplaceDialog != null) + { + FindReplaceDialog.TopLevel = true; + if (TopLevelControl is Form) + { + FindReplaceDialog.Owner = (Form) TopLevelControl; + } + FindReplaceDialog.ShowReplace(); + } + } + + public void AutoListBeginLoad() + { + AutoList.BeginLoad(); + } + + public void AutoListEndLoad() + { + AutoList.EndLoad(); + } + + public void FindNext() + { + FindReplaceDialog.FindNext(); + } + + #endregion + + #region Public Properties + + /// + /// Returns true if the control is in overwrite mode. + /// + [Browsable(false)] + public bool OverWrite + { + get { return _OverWrite; } + } + + /// + /// Returns True if the control contains a selected text. + /// + [Browsable(false)] + public bool CanCopy + { + get { return Selection.IsValid; } + } + + /// + /// Returns true if there is any valid text data inside the Clipboard. + /// + [Browsable(false)] + public bool CanPaste + { + get + { + string s = ""; + try + { + IDataObject iData = Clipboard.GetDataObject(); + + if (iData != null) + if (iData.GetDataPresent(DataFormats.Text)) + { + // Yes it is, so display it in a text box. + s = (String) iData.GetData(DataFormats.Text); + } + + if (s != null) + return true; + } + catch + { + } + return false; + } + } + + /// + /// Returns true if the undobuffer contains one or more undo actions. + /// + [Browsable(false)] + public bool CanUndo + { + get { return (Document.UndoStep > 0); } + } + + /// + /// Returns true if the control can redo the last undo action/s + /// + [Browsable(false)] + public bool CanRedo + { + get { return (Document.UndoStep < Document.UndoBuffer.Count - 1); } + } + + + /// + /// Gets the size (in pixels) of the font to use when rendering the the content. + /// The value is retrived from the owning Syntaxbox control. + /// + public float FontSize + { + get { return _SyntaxBox.FontSize; } + } + + + /// + /// Gets the indention style to use when inserting new lines. + /// The value is retrived from the owning Syntaxbox control. + /// + public IndentStyle Indent + { + get { return _SyntaxBox.Indent; } + } + + /// + /// Gets the SyntaxDocument the control is currently attatched to. + /// The value is retrived from the owning Syntaxbox control. + /// + [Category("Content")] + [Description("The SyntaxDocument that is attatched to the contro")] + public SyntaxDocument Document + { + get { return _SyntaxBox.Document; } + } + + /// + /// Gets the delay in MS before the tooltip is displayed when hovering a collapsed section. + /// The value is retrived from the owning Syntaxbox control. + /// + public int TooltipDelay + { + get { return _SyntaxBox.TooltipDelay; } + } + + // ROB: Required to support CollapsedBlockTooltipsEnabled + public bool CollapsedBlockTooltipsEnabled + { + get { return _SyntaxBox.CollapsedBlockTooltipsEnabled; } + } + + // END-ROB ---------------------------------------------------------- + + + /// + /// Gets if the control is readonly. + /// The value is retrived from the owning Syntaxbox control. + /// + public bool ReadOnly + { + get { return _SyntaxBox.ReadOnly; } + } + + + /// + /// Gets the name of the font to use when rendering the control. + /// The value is retrived from the owning Syntaxbox control. + /// + public string FontName + { + get { return _SyntaxBox.FontName; } + } + + /// + /// Gets if the control should render bracket matching. + /// The value is retrived from the owning Syntaxbox control. + /// + public bool BracketMatching + { + get { return _SyntaxBox.BracketMatching; } + } + + + /// + /// Gets if the control should render whitespace chars. + /// The value is retrived from the owning Syntaxbox control. + /// + public bool VirtualWhitespace + { + get { return _SyntaxBox.VirtualWhitespace; } + } + + + /// + /// Gets the Color of the horizontal separators (a'la visual basic 6). + /// The value is retrived from the owning Syntaxbox control. + /// + public Color SeparatorColor + { + get { return _SyntaxBox.SeparatorColor; } + } + + + /// + /// Gets the text color to use when rendering bracket matching. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color BracketForeColor + { + get { return _SyntaxBox.BracketForeColor; } + } + + + /// + /// Gets the back color to use when rendering bracket matching. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color BracketBackColor + { + get { return _SyntaxBox.BracketBackColor; } + } + + + /// + /// Gets the back color to use when rendering the selected text. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color SelectionBackColor + { + get { return _SyntaxBox.SelectionBackColor; } + } + + + /// + /// Gets the text color to use when rendering the selected text. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color SelectionForeColor + { + get { return _SyntaxBox.SelectionForeColor; } + } + + /// + /// Gets the back color to use when rendering the inactive selected text. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color InactiveSelectionBackColor + { + get { return _SyntaxBox.InactiveSelectionBackColor; } + } + + + /// + /// Gets the text color to use when rendering the inactive selected text. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color InactiveSelectionForeColor + { + get { return _SyntaxBox.InactiveSelectionForeColor; } + } + + + /// + /// Gets the color of the border between the gutter area and the line number area. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color GutterMarginBorderColor + { + get { return _SyntaxBox.GutterMarginBorderColor; } + } + + + /// + /// Gets the color of the border between the line number area and the folding area. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color LineNumberBorderColor + { + get { return _SyntaxBox.LineNumberBorderColor; } + } + + + /// + /// Gets the text color to use when rendering breakpoints. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color BreakPointForeColor + { + get { return _SyntaxBox.BreakPointForeColor; } + } + + /// + /// Gets the back color to use when rendering breakpoints. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color BreakPointBackColor + { + get { return _SyntaxBox.BreakPointBackColor; } + } + + /// + /// Gets the text color to use when rendering line numbers. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color LineNumberForeColor + { + get { return _SyntaxBox.LineNumberForeColor; } + } + + /// + /// Gets the back color to use when rendering line number area. + /// + public Color LineNumberBackColor + { + get { return _SyntaxBox.LineNumberBackColor; } + } + + /// + /// Gets the color of the gutter margin. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color GutterMarginColor + { + get { return _SyntaxBox.GutterMarginColor; } + } + + /// + /// Gets or Sets the background Color of the client area. + /// + [Category("Appearance")] + [Description("The background color of the client area")] + public new Color BackColor + { + get { return _SyntaxBox.BackColor; } + set { _SyntaxBox.BackColor = value; } + } + + /// + /// Gets the back color to use when rendering the active line. + /// + public Color HighLightedLineColor + { + get { return _SyntaxBox.HighLightedLineColor; } + } + + /// + /// Get if the control should highlight the active line. + /// The value is retrived from the owning Syntaxbox control. + /// + public bool HighLightActiveLine + { + get { return _SyntaxBox.HighLightActiveLine; } + } + + /// + /// Get if the control should render whitespace chars. + /// The value is retrived from the owning Syntaxbox control. + /// + public bool ShowWhitespace + { + get { return _SyntaxBox.ShowWhitespace; } + } + + + /// + /// Get if the line number margin is visible or not. + /// The value is retrived from the owning Syntaxbox control. + /// + public bool ShowLineNumbers + { + get { return _SyntaxBox.ShowLineNumbers; } + } + + + /// + /// Get if the gutter margin is visible or not. + /// The value is retrived from the owning Syntaxbox control. + /// + public bool ShowGutterMargin + { + get { return _SyntaxBox.ShowGutterMargin; } + } + + /// + /// Get the Width of the gutter margin (in pixels) + /// The value is retrived from the owning Syntaxbox control. + /// + public int GutterMarginWidth + { + get { return _SyntaxBox.GutterMarginWidth; } + } + + + /// + /// Get the numbers of space chars in a tab. + /// The value is retrived from the owning Syntaxbox control. + /// + public int TabSize + { + get { return _SyntaxBox.TabSize; } + } + + /// + /// Get whether or not TabsToSpaces is turned on. + /// + public bool TabsToSpaces + { + get { return _SyntaxBox.TabsToSpaces; } + } + + + /// + /// Get if the control should render 'Tab guides' + /// The value is retrived from the owning Syntaxbox control. + /// + public bool ShowTabGuides + { + get { return _SyntaxBox.ShowTabGuides; } + } + + /// + /// Gets the color to use when rendering whitespace chars. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color WhitespaceColor + { + get { return _SyntaxBox.WhitespaceColor; } + } + + /// + /// Gets the color to use when rendering tab guides. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color TabGuideColor + { + get { return _SyntaxBox.TabGuideColor; } + } + + /// + /// Get the color to use when rendering bracket matching borders. + /// The value is retrived from the owning Syntaxbox control. + /// + /// + /// NOTE: Use the Color.Transparent turn off the bracket match borders. + /// + public Color BracketBorderColor + { + get { return _SyntaxBox.BracketBorderColor; } + } + + + /// + /// Get the color to use when rendering Outline symbols. + /// The value is retrived from the owning Syntaxbox control. + /// + public Color OutlineColor + { + get { return _SyntaxBox.OutlineColor; } + } + + + /// + /// Positions the AutoList + /// + [Category("Behavior")] + public TextPoint AutoListPosition + { + get { return AutoListStartPos; } + set { AutoListStartPos = value; } + } + + /// + /// Positions the InfoTip + /// + [Category("Behavior")] + public TextPoint InfoTipPosition + { + get { return InfoTipStartPos; } + set { InfoTipStartPos = value; } + } + + + /// + /// Gets or Sets if the intellisense list is visible. + /// + [Category("Behavior")] + public bool AutoListVisible + { + set + { + CreateAutoList(); + if (AutoList == null) + return; + + if (value) + { + AutoList.TopLevel = true; + AutoList.BringToFront(); + + // ROB: Fuck knows what I did to cause having to do this.. + // Show it off the screen, let the painter position it. + AutoList.Location = new Point(-16000, -16000); + AutoList.Show(); + InfoTip.BringToFront(); + if (TopLevelControl is Form) + { + AutoList.Owner = (Form) TopLevelControl; + } + } + else + { + // ROB: Another hack. + AutoList.Hide(); + } + + _AutoListVisible = value; + InfoTip.BringToFront(); + + Redraw(); + } + get { return _AutoListVisible; } + } + + /// + /// Gets or Sets if the infotip is visible + /// + [Category("Behavior")] + public bool InfoTipVisible + { + set + { + CreateInfoTip(); + if (InfoTip == null) + return; + + if (value) + { + InfoTip.TopLevel = true; + AutoList.BringToFront(); + if (TopLevelControl is Form) + { + InfoTip.Owner = (Form) TopLevelControl; + } + } + + InfoTip.BringToFront(); + + _InfoTipVisible = value; + + if (InfoTip != null && value) + { + InfoTip.Init(); + } + + // ROB: Cludge for infotip bug, whereby infotip does not close when made invisible.. + if (_InfoTip != null && !value) + { + _InfoTip.Visible = false; + } + } + get { return _InfoTipVisible; } + } + + /// + /// Get if the control should use smooth scrolling. + /// The value is retrived from the owning Syntaxbox control. + /// + public bool SmoothScroll + { + get { return _SyntaxBox.SmoothScroll; } + } + + /// + /// Get the number of pixels the screen should be scrolled per frame when using smooth scrolling. + /// The value is retrived from the owning Syntaxbox control. + /// + public int SmoothScrollSpeed + { + get { return _SyntaxBox.SmoothScrollSpeed; } + } + + + /// + /// Get if the control should parse all text when text is pasted from the clipboard. + /// The value is retrived from the owning Syntaxbox control. + /// + public bool ParseOnPaste + { + get { return _SyntaxBox.ParseOnPaste; } + } + + + /// + /// Gets the Caret object. + /// + public Caret Caret + { + get { return _Caret; } + } + + /// + /// Gets the Selection object. + /// + public Selection Selection + { + get { return _Selection; } + } + + #endregion + + #region eventhandlers + + private int OldWidth; + + private void OnClipboardUpdated(CopyEventArgs e) + { + if (ClipboardUpdated != null) + ClipboardUpdated(this, e); + } + + + private void OnRowMouseDown(RowMouseEventArgs e) + { + if (RowMouseDown != null) + RowMouseDown(this, e); + } + + private void OnRowMouseMove(RowMouseEventArgs e) + { + if (RowMouseMove != null) + RowMouseMove(this, e); + } + + private void OnRowMouseUp(RowMouseEventArgs e) + { + if (RowMouseUp != null) + RowMouseUp(this, e); + } + + private void OnRowClick(RowMouseEventArgs e) + { + if (RowClick != null) + RowClick(this, e); + } + + private void OnRowDoubleClick(RowMouseEventArgs e) + { + if (RowDoubleClick != null) + RowDoubleClick(this, e); + } + + + protected override void OnLoad(EventArgs e) + { + DoResize(); + Refresh(); + } + + + public void OnParse() + { + Redraw(); + } + + public void OnChange() + { + if (Caret.Position.Y > Document.Count - 1) + { + Caret.Position.Y = Document.Count - 1; + //this.Caret.MoveAbsoluteHome (false); + ScrollIntoView(); + } + + try + { + if (VirtualWhitespace == false && Caret.CurrentRow != null && + Caret.Position.X > Caret.CurrentRow.Text.Length) + { + Caret.Position.X = Caret.CurrentRow.Text.Length; + Redraw(); + } + } + catch + { + } + + + if (!ContainsFocus) + { + Selection.ClearSelection(); + } + + + if (Selection.LogicalBounds.FirstRow > Document.Count) + { + Selection.Bounds.FirstColumn = Caret.Position.X; + Selection.Bounds.LastColumn = Caret.Position.X; + Selection.Bounds.FirstRow = Caret.Position.Y; + Selection.Bounds.LastRow = Caret.Position.Y; + } + + if (Selection.LogicalBounds.LastRow > Document.Count) + { + Selection.Bounds.FirstColumn = Caret.Position.X; + Selection.Bounds.LastColumn = Caret.Position.X; + Selection.Bounds.FirstRow = Caret.Position.Y; + Selection.Bounds.LastRow = Caret.Position.Y; + } + + Redraw(); + } + + /// + /// Overrides the default OnKeyDown + /// + /// + protected override void OnKeyDown(KeyEventArgs e) + { + base.OnKeyDown(e); + _KeyDownHandled = e.Handled; + + if (e.KeyCode == Keys.Escape && (InfoTipVisible || AutoListVisible)) + { + InfoTipVisible = false; + AutoListVisible = false; + e.Handled = true; + Redraw(); + return; + } + + if (!e.Handled && InfoTipVisible && InfoTip.Count > 1) + { + //move infotip selection + if (e.KeyCode == Keys.Up) + { + _SyntaxBox.InfoTipSelectedIndex++; + e.Handled = true; + return; + } + + if (e.KeyCode == Keys.Down) + { + _SyntaxBox.InfoTipSelectedIndex--; + + e.Handled = true; + return; + } + } + + if (!e.Handled && AutoListVisible) + { + //move autolist selection + if ((e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.PageUp || + e.KeyCode == Keys.PageDown)) + { + AutoList.SendKey((int) e.KeyCode); + e.Handled = true; + return; + } + + //inject inser text from autolist + if (e.KeyCode == Keys.Space || e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab) + { + string s = AutoList.SelectedText; + if (s != "") + InsertAutolistText(); + AutoListVisible = false; + e.Handled = true; + Redraw(); + return; + } + } + + + if (!e.Handled) + { + //do keyboard actions + foreach (KeyboardAction ka in _SyntaxBox.KeyboardActions) + { + if (!ReadOnly || ka.AllowReadOnly) + { + if ((ka.Key == (Keys) (int) e.KeyCode) && ka.Alt == e.Alt && ka.Shift == e.Shift && + ka.Control == e.Control) + ka.Action(); + //if keys match , call action delegate + } + } + + + //------------------------------------------------------------------------------------------------------------ + + + switch ((Keys) (int) e.KeyCode) + { + case Keys.ShiftKey: + case Keys.ControlKey: + case Keys.Alt: + return; + + case Keys.Down: + if (e.Control) + ScrollScreen(1); + else + { + Caret.MoveDown(e.Shift); + Redraw(); + } + break; + case Keys.Up: + if (e.Control) + ScrollScreen(- 1); + else + { + Caret.MoveUp(e.Shift); + } + Redraw(); + break; + case Keys.Left: + { + if (e.Control) + { + MoveCaretToPrevWord(e.Shift); + } + else + { + Caret.MoveLeft(e.Shift); + } + } + Redraw(); + break; + case Keys.Right: + { + if (e.Control) + { + MoveCaretToNextWord(e.Shift); + } + else + { + Caret.MoveRight(e.Shift); + } + } + Redraw(); + break; + case Keys.End: + if (e.Control) + Caret.MoveAbsoluteEnd(e.Shift); + else + Caret.MoveEnd(e.Shift); + Redraw(); + break; + case Keys.Home: + if (e.Control) + Caret.MoveAbsoluteHome(e.Shift); + else + Caret.MoveHome(e.Shift); + Redraw(); + break; + case Keys.PageDown: + Caret.MoveDown(View.VisibleRowCount - 2, e.Shift); + Redraw(); + break; + case Keys.PageUp: + Caret.MoveUp(View.VisibleRowCount - 2, e.Shift); + Redraw(); + break; + + default: + break; + } + + + //dont do if readonly + if (!ReadOnly) + { + switch ((Keys) (int) e.KeyCode) + { + case Keys.Enter: + { + if (e.Control) + { + if (Caret.CurrentRow.CanFold) + { + Caret.MoveHome(false); + Document.ToggleRow(Caret.CurrentRow); + Redraw(); + } + } + else + InsertEnter(); + break; + } + case Keys.Back: + if (!e.Control) + DeleteBackwards(); + else + { + if (Selection.IsValid) + Selection.DeleteSelection(); + else + { + Selection.ClearSelection(); + MoveCaretToPrevWord(true); + Selection.DeleteSelection(); + } + Caret.CurrentRow.Parse(true); + } + + break; + case Keys.Delete: + { + if (!e.Control && !e.Alt && !e.Shift) + { + Delete(); + } + else if (e.Control && !e.Alt && !e.Shift) + { + if (Selection.IsValid) + { + Cut(); + } + else + { + Selection.ClearSelection(); + MoveCaretToNextWord(true); + Selection.DeleteSelection(); + } + Caret.CurrentRow.Parse(true); + } + break; + } + case Keys.Insert: + { + if (!e.Control && !e.Alt && !e.Shift) + { + _OverWrite = !_OverWrite; + } + break; + } + case Keys.Tab: + { + if (!Selection.IsValid) + { + // ROB: Implementation of .TabsToSpaces + if (!TabsToSpaces) + { + InsertText("\t"); + } + else + { + InsertText(new string(' ', TabSize)); + } + // ROB-END + } + + break; + } + default: + { + break; + } + } + } + Caret.Blink = true; + //this.Redraw (); + } + } + + /// + /// Overrides the default OnKeyPress + /// + /// + protected override void OnKeyPress(KeyPressEventArgs e) + { + base.OnKeyPress(e); + + + if (!e.Handled && !_KeyDownHandled && e.KeyChar != (char) 127) + { + if ((e.KeyChar) < 32) + return; + + if (!ReadOnly) + { + switch ((Keys) (int) e.KeyChar) + { + default: + { + InsertText(e.KeyChar.ToString(CultureInfo.InvariantCulture)); + if (Indent == IndentStyle.Scope || Indent == IndentStyle.Smart) + { + if (Caret.CurrentRow.ShouldOutdent) + { + OutdentEndRow(); + } + } + break; + } + } + } + } + + if (AutoListVisible && !e.Handled && _SyntaxBox.AutoListAutoSelect) + { + string s = Caret.CurrentRow.Text; + try + { + if (Caret.Position.X - AutoListStartPos.X >= 0) + { + s = s.Substring(AutoListStartPos.X, Caret.Position.X - AutoListStartPos.X); + AutoList.SelectItem(s); + } + } + catch + { + } + } + } + + /// + /// Overrides the default OnMouseDown + /// + /// + protected override void OnMouseDown(MouseEventArgs e) + { + MouseX = e.X; + MouseY = e.Y; + + SetFocus(); + base.OnMouseDown(e); + TextPoint pos = Painter.CharFromPixel(e.X, e.Y); + Row row = null; + if (pos.Y >= 0 && pos.Y < Document.Count) + row = Document[pos.Y]; + + #region RowEvent + + var rea = new RowMouseEventArgs {Row = row, Button = e.Button, MouseX = MouseX, MouseY = MouseY}; + if (e.X >= View.TextMargin - 7) + { + rea.Area = RowArea.TextArea; + } + else if (e.X < View.GutterMarginWidth) + { + rea.Area = RowArea.GutterArea; + } + else if (e.X < View.LineNumberMarginWidth + View.GutterMarginWidth) + { + rea.Area = RowArea.LineNumberArea; + } + else if (e.X < View.TextMargin - 7) + { + rea.Area = RowArea.FoldingArea; + } + + OnRowMouseDown(rea); + + #endregion + + try + { + Row r2 = Document[pos.Y]; + if (r2 != null) + { + if (e.X >= r2.Expansion_PixelEnd && r2.IsCollapsed) + { + if (r2.expansion_StartSpan != null) + { + if (r2.expansion_StartSpan.StartRow != null && r2.expansion_StartSpan.EndRow != null && + r2.expansion_StartSpan.Expanded == false) + { + if (!IsOverSelection(e.X, e.Y)) + { + Caret.Position.X = pos.X; + Caret.Position.Y = pos.Y; + Selection.ClearSelection(); + + Row r3 = r2.Expansion_EndRow; + int x3 = r3.Expansion_StartChar; + + Caret.Position.X = x3; + Caret.Position.Y = r3.Index; + Selection.MakeSelection(); + + Redraw(); + View.Action = EditAction.SelectText; + + return; + } + } + } + } + } + } + catch + { + //this is untested code... + } + + bool shift = NativeMethods.IsKeyPressed(Keys.ShiftKey); + + if (e.X > View.TotalMarginWidth) + { + if (e.X > View.TextMargin - 8) + { + if (!IsOverSelection(e.X, e.Y)) + { + //selecting + if (e.Button == MouseButtons.Left) + { + if (!shift) + { + TextPoint tp = pos; + Word w = Document.GetWordFromPos(tp); + if (w != null && w.Pattern != null && w.Pattern.Category != null) + { + var pe = new WordMouseEventArgs + { + Pattern = w.Pattern, + Button = e.Button, + Cursor = Cursors.Hand, + Word = w + }; + + _SyntaxBox.OnWordMouseDown(ref pe); + + Cursor = pe.Cursor; + return; + } + + View.Action = EditAction.SelectText; + Caret.SetPos(pos); + Selection.ClearSelection(); + Caret.Blink = true; + Redraw(); + } + else + { + View.Action = EditAction.SelectText; + Caret.SetPos(pos); + Selection.MakeSelection(); + Caret.Blink = true; + Redraw(); + } + } + } + } + else + { + if (row != null) + if (row.expansion_StartSpan != null) + { + Caret.SetPos(new TextPoint(0, pos.Y)); + Selection.ClearSelection(); + Document.ToggleRow(row); + Redraw(); + } + } + } + else + { + if (e.X < View.GutterMarginWidth) + { + if (_SyntaxBox.AllowBreakPoints) + { + Row r = Document[Painter.CharFromPixel(e.X, e.Y).Y]; + r.Breakpoint = !r.Breakpoint; + Redraw(); + } + else + { + Row r = Document[Painter.CharFromPixel(e.X, e.Y).Y]; + r.Breakpoint = false; + Redraw(); + } + } + else + { + View.Action = EditAction.SelectText; + Caret.SetPos(Painter.CharFromPixel(0, e.Y)); + Selection.ClearSelection(); + Caret.MoveDown(true); + + Redraw(); + } + } + SetMouseCursor(e.X, e.Y); + } + + /// + /// Overrides the default OnMouseMove + /// + /// + protected override void OnMouseMove(MouseEventArgs e) + { + MouseX = e.X; + MouseY = e.Y; + + TextPoint pos = Painter.CharFromPixel(e.X, e.Y); + Row row = null; + if (pos.Y >= 0 && pos.Y < Document.Count) + row = Document[pos.Y]; + + #region RowEvent + + var rea = new RowMouseEventArgs {Row = row, Button = e.Button, MouseX = MouseX, MouseY = MouseY}; + if (e.X >= View.TextMargin - 7) + { + rea.Area = RowArea.TextArea; + } + else if (e.X < View.GutterMarginWidth) + { + rea.Area = RowArea.GutterArea; + } + else if (e.X < View.LineNumberMarginWidth + View.GutterMarginWidth) + { + rea.Area = RowArea.LineNumberArea; + } + else if (e.X < View.TextMargin - 7) + { + rea.Area = RowArea.FoldingArea; + } + + OnRowMouseMove(rea); + + #endregion + + try + { + if (Document != null) + { + if (e.Button == MouseButtons.Left) + { + if (View.Action == EditAction.SelectText) + { + //Selection ACTIONS!!!!!!!!!!!!!! + Caret.Blink = true; + Caret.SetPos(pos); + if (e.X <= View.TotalMarginWidth) + Caret.MoveDown(true); + Caret.CropPosition(); + Selection.MakeSelection(); + ScrollIntoView(); + Redraw(); + } + else if (View.Action == EditAction.None) + { + if (IsOverSelection(e.X, e.Y)) + { + BeginDragDrop(); + } + } + else if (View.Action == EditAction.DragText) + { + } + } + else + { + TextPoint p = pos; + Row r = Document[p.Y]; + bool DidShow = false; + + if (r != null) + { + if (e.X >= r.Expansion_PixelEnd && r.IsCollapsed) + { + // ROB: Added check for Collapsed tooltips. + if (CollapsedBlockTooltipsEnabled) + { + if (r.expansion_StartSpan != null) + { + if (r.expansion_StartSpan.StartRow != null && + r.expansion_StartSpan.EndRow != null && + r.expansion_StartSpan.Expanded == false) + { + string t = ""; + int j = 0; + for (int i = r.expansion_StartSpan.StartRow.Index; + i <= r.expansion_StartSpan.EndRow.Index; + i++) + { + if (j > 0) + t += "\n"; + Row tmp = Document[i]; + string tmpstr = tmp.Text.Replace("\t", " "); + t += tmpstr; + if (j > 20) + { + t += "..."; + break; + } + + j++; + } + + //tooltip.res + tooltip.InitialDelay = TooltipDelay; + if (tooltip.GetToolTip(this) != t) + tooltip.SetToolTip(this, t); + tooltip.Active = true; + DidShow = true; + } + } + } + } + else + { + Word w = Document.GetFormatWordFromPos(p); + if (w != null) + { + if (w.InfoTip != null) + { + tooltip.InitialDelay = TooltipDelay; + if (tooltip.GetToolTip(this) != w.InfoTip) + tooltip.SetToolTip(this, w.InfoTip); + tooltip.Active = true; + DidShow = true; + } + } + } + } + + if (tooltip != null) + { + if (!DidShow) + tooltip.SetToolTip(this, ""); + } + } + + SetMouseCursor(e.X, e.Y); + base.OnMouseMove(e); + } + } + catch + { + } + } + + /// + /// Overrides the default OnMouseUp + /// + /// + protected override void OnMouseUp(MouseEventArgs e) + { + MouseX = e.X; + MouseY = e.Y; + + TextPoint pos = Painter.CharFromPixel(e.X, e.Y); + Row row = null; + if (pos.Y >= 0 && pos.Y < Document.Count) + row = Document[pos.Y]; + + #region RowEvent + + var rea = new RowMouseEventArgs {Row = row, Button = e.Button, MouseX = MouseX, MouseY = MouseY}; + if (e.X >= View.TextMargin - 7) + { + rea.Area = RowArea.TextArea; + } + else if (e.X < View.GutterMarginWidth) + { + rea.Area = RowArea.GutterArea; + } + else if (e.X < View.LineNumberMarginWidth + View.GutterMarginWidth) + { + rea.Area = RowArea.LineNumberArea; + } + else if (e.X < View.TextMargin - 7) + { + rea.Area = RowArea.FoldingArea; + } + + OnRowMouseUp(rea); + + #endregion + + if (View.Action == EditAction.None) + { + if (e.X > View.TotalMarginWidth) + { + if (IsOverSelection(e.X, e.Y) && e.Button == MouseButtons.Left) + { + View.Action = EditAction.SelectText; + Caret.SetPos(Painter.CharFromPixel(e.X, e.Y)); + Selection.ClearSelection(); + Redraw(); + } + } + } + + View.Action = EditAction.None; + base.OnMouseUp(e); + } + + /// + /// Overrides the default OnMouseWheel + /// + /// + protected override void OnMouseWheel(MouseEventArgs e) + { + int l = SystemInformation.MouseWheelScrollLines; + ScrollScreen(- (e.Delta/120)*l); + + base.OnMouseWheel(e); + } + + /// + /// Overrides the default OnPaint + /// + /// + protected override void OnPaint(PaintEventArgs e) + { + if (Document != null && Width > 0 && Height > 0) + { + Painter.RenderAll(e.Graphics); + } + } + + /// + /// Overrides the default OnResize + /// + /// + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + DoResize(); + } + + /// + /// Overrides the default OnDragOver + /// + /// + protected override void OnDragOver(DragEventArgs drgevent) + { + if (!ReadOnly) + { + if (Document != null) + { + View.Action = EditAction.DragText; + + Point pt = PointToClient(new Point(drgevent.X, drgevent.Y)); + + int x = pt.X; + int y = pt.Y; + + // drgevent.Effect = DragDropEffects.All ; + //Caret.Position = Painter.CharFromPixel(x,y); + + drgevent.Effect = (drgevent.KeyState & 8) == 8 ? DragDropEffects.Copy : DragDropEffects.Move; + Caret.SetPos(Painter.CharFromPixel(x, y)); + Redraw(); + } + } + else + { + drgevent.Effect = DragDropEffects.None; + } + } + + /// + /// Overrides the default OnDragDrop + /// + /// + protected override void OnDragDrop(DragEventArgs drgevent) + { + if (!ReadOnly) + { + if (Document != null) + { + View.Action = EditAction.None; + int SelStart = Selection.LogicalSelStart; + int DropStart = Document.PointToIntPos(Caret.Position); + + + string s = drgevent.Data.GetData(typeof (string)).ToString(); + //int SelLen=s.Replace ("\r\n","\n").Length ; + int SelLen = s.Length; + + + if (DropStart >= SelStart && DropStart <= SelStart + Math.Abs(Selection.SelLength)) + DropStart = SelStart; + else if (DropStart >= SelStart + SelLen) + DropStart -= SelLen; + + + Document.StartUndoCapture(); + if ((drgevent.KeyState & 8) == 0) + { + _SyntaxBox.Selection.DeleteSelection(); + Caret.Position = Document.IntPosToPoint(DropStart); + } + + Document.InsertText(s, Caret.Position.X, Caret.Position.Y); + Document.EndUndoCapture(); + + Selection.SelStart = Document.PointToIntPos(Caret.Position); + Selection.SelLength = SelLen; + Document.ResetVisibleRows(); + ScrollIntoView(); + Redraw(); + drgevent.Effect = DragDropEffects.All; + + if (ParseOnPaste) + Document.ParseAll(true); + + View.Action = EditAction.None; + } + } + } + + + /// + /// Overrides the default OnDragEnter + /// + /// + protected override void OnDragEnter(DragEventArgs drgevent) + { + } + + /// + /// Overrides the default OnDragLeave + /// + /// + protected override void OnDragLeave(EventArgs e) + { + View.Action = EditAction.None; + } + + /// + /// Overrides the default OnDoubleClick + /// + /// + protected override void OnDoubleClick(EventArgs e) + { + TextPoint pos = Painter.CharFromPixel(MouseX, MouseY); + Row row = null; + if (pos.Y >= 0 && pos.Y < Document.Count) + row = Document[pos.Y]; + + #region RowEvent + + var rea = new RowMouseEventArgs {Row = row, Button = MouseButtons.None, MouseX = MouseX, MouseY = MouseY}; + if (MouseX >= View.TextMargin - 7) + { + rea.Area = RowArea.TextArea; + } + else if (MouseX < View.GutterMarginWidth) + { + rea.Area = RowArea.GutterArea; + } + else if (MouseX < View.LineNumberMarginWidth + View.GutterMarginWidth) + { + rea.Area = RowArea.LineNumberArea; + } + else if (MouseX < View.TextMargin - 7) + { + rea.Area = RowArea.FoldingArea; + } + + OnRowDoubleClick(rea); + + #endregion + + try + { + Row r2 = Document[pos.Y]; + if (r2 != null) + { + if (MouseX >= r2.Expansion_PixelEnd && r2.IsCollapsed) + { + if (r2.expansion_StartSpan != null) + { + if (r2.expansion_StartSpan.StartRow != null && r2.expansion_StartSpan.EndRow != null && + r2.expansion_StartSpan.Expanded == false) + { + r2.Expanded = true; + Document.ResetVisibleRows(); + Redraw(); + return; + } + } + } + } + } + catch + { + //this is untested code... + } + + if (MouseX > View.TotalMarginWidth) + SelectCurrentWord(); + } + + protected override void OnClick(EventArgs e) + { + TextPoint pos = Painter.CharFromPixel(MouseX, MouseY); + Row row = null; + if (pos.Y >= 0 && pos.Y < Document.Count) + row = Document[pos.Y]; + + #region RowEvent + + var rea = new RowMouseEventArgs {Row = row, Button = MouseButtons.None, MouseX = MouseX, MouseY = MouseY}; + if (MouseX >= View.TextMargin - 7) + { + rea.Area = RowArea.TextArea; + } + else if (MouseX < View.GutterMarginWidth) + { + rea.Area = RowArea.GutterArea; + } + else if (MouseX < View.LineNumberMarginWidth + View.GutterMarginWidth) + { + rea.Area = RowArea.LineNumberArea; + } + else if (MouseX < View.TextMargin - 7) + { + rea.Area = RowArea.FoldingArea; + } + + OnRowClick(rea); + + #endregion + } + + private void vScroll_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) + { + SetMaxHorizontalScroll(); + _InfoTipVisible = false; + _AutoListVisible = false; + + SetFocus(); + + + int diff = e.NewValue - vScroll.Value; + if ((diff == - 1 || diff == 1) && + (e.Type == ScrollEventType.SmallDecrement || e.Type == ScrollEventType.SmallIncrement)) + { + ScrollScreen(diff); + } + else + { + Invalidate(); + } + } + + private void hScroll_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) + { + _InfoTipVisible = false; + _AutoListVisible = false; + + SetFocus(); + Invalidate(); + } + + private void CaretTimer_Tick(object sender, EventArgs e) + { + Caret.Blink = !Caret.Blink; + RedrawCaret(); + } + + + private void AutoListDoubleClick(object sender, EventArgs e) + { + string s = AutoList.SelectedText; + if (s != "") + InsertAutolistText(); + AutoListVisible = false; + Redraw(); + } + + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + if (tooltip != null) + tooltip.RemoveAll(); + } + + private void CaretChanged(object s, EventArgs e) + { + OnCaretChange(); + } + + private void EditViewControl_Leave(object sender, EventArgs e) + { + RemoveFocus(); + } + + private void EditViewControl_Enter(object sender, EventArgs e) + { + CaretTimer.Enabled = true; + } + + private void SelectionChanged(object s, EventArgs e) + { + OnSelectionChange(); + } + + private void OnCaretChange() + { + if (CaretChange != null) + CaretChange(this, null); + } + + private void OnSelectionChange() + { + if (SelectionChange != null) + SelectionChange(this, null); + } + + protected override void OnVisibleChanged(EventArgs e) + { + if (Visible == false) + RemoveFocus(); + + base.OnVisibleChanged(e); + DoResize(); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/EditView/EditViewControl.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/EditView/EditViewControl.resx new file mode 100644 index 0000000..a5b5338 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/EditView/EditViewControl.resx @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 23, 19 + + + 168, 16 + + + 17, 53 + + + 155, 68 + + + 341, 17 + + + 101, 17 + + + Assembly + + + 423, 17 + + + Assembly + + + 197, 157 + + + Assembly + + + + R0lGODlhHAAcAPcAAP/////9///9/f8A//3///3//f39/fv7+/n5+/n5+fn59/n39/f59/f3+ff39/X3 + 9fXy8vLy9fLy8vLw8vDy8u7u7u7u7O7s7uzs7Ozs6uzq6urs7Orq7Orq6urn6ufq6ufq5+fn6ufn5+Xj + 5eXj4+Pj5ePj4+Pj4ePh4+Ph4eHj4eHh4eHe3t/i39/f397e4d7e3t7c3N3d29zc3Nvd29ra2trY2trY + 2NjY2NfX19bW1tbT1tPW09PT1tPT09LU0tLS0tHT09HR0dHRz9HP0c/R0c/Pz8/Nzc3Nz83Nzc3MzMzM + zcrKyMjKysjKyMjIysjIyMjIxsjGyMjGxsbIxsbGxsTGxsTExMTCxMLEwsLCxMLCwsHBwcDBwcDAwL+/ + vb+9vb6+vr2/v72/vb29v729vb27vby+vLu7vbu7u7u5u7q4uLm5ubi4uLi2uLe3t7e0t7a1tbW1tbW1 + s7S3t7S3tLS0t7S0tLS0srSytLOztbOysrK0srKysrKysLKwsrKwsLGysbGxsbCysrCysLCwsLCwrrCu + sLCurq+vr6+vra6wsK6wrq6usK6urqyqqqurq6urqqqrqqqqq6qqqqqqqKqoqqioqqinqKenqKSkpKKi + pKKioqCioqCgoJ6eoJ6enp2dnZycnpycnJubm5qampqamJqYmpmZmZiYmJeYl5eXmJeXl5WXl5WVlZSV + lZSUlJGQkJCQkJCQjo6OkI6Ojo2NjYyNjIyKjIyKioqMioiKiIiIiIeIiIeHh4WFhYSEhIODgoKCgoCA + gH9+f35/f35/fn5+fnp6enNzc25vb25ub2xsbGpqamZmZmNkY2NjZGBgYF5dXV1dXVJRUVFRUk5OTkxM + TEtKSklJSElISUhISEZGRkREREJCQj9APz4+Pj09Pj09PTw8PDc4ODc4NzY2NjY2NTU1NTQ0NDExMjEx + MSEhISAgIB4eHh0dHQkJCQgICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + ACwAAAAAHAAcAAAI/wAHCBxIUBk3d/DguQPnjKDDhwPBcSOmyUgLF1VAKQNnDiJEa86+MGjgoGQFESJy + 5FBFjZvHgdw0AZhJ882bCiFEuChSxRe5l9Jy0KT5xeYbByFY5DCS0RpEbkKHAjBq1IEHFzmqfGHVkaC1 + RFKnfnFD1maik0u/fCH2jaCzsG+K2hxrVifPL4ycCgT3RqrcN27kurGpSanWN77YCbTmYKhNsn8Dv2GU + SFPWoovADVBGbEHYzzMXVGiRQ0rRRNI2JmoMOqzoF2knEztohDXoojQdVMCqdZGhVe7kubANN25fACdd + MD39JqGLCsSHDo4LQHdKpm4SJfqi8AuICq0HA+ggCYI35u3swIESUQF8a+S7055elIibM2U52EP/rBvt + 3TfaSVGLMgOAQ0R+IVSQCCNGaZcIJqCAwgorvRTVCCMV6GUOKyq5gJIm2mWSiSaaRMhKLbWclogRX2g2 + QDLUVGFEhy5o8gmJn0h4Yi2DafdFAwTC5MsXMs6Ywyo67liLWYnclIheA5kDCpFVVGlELbSg6IsvTN6U + g0sPcQNKXGqp1cuWXCLiYwU5SPOSOcQcQhVixDiICBEA1PfSXtb4kkgjDmpnSBQVfKEMlHsOYI450hCz + ynZfJFKLNS4m6pBB7CTkDjdBehQQADs= + + + + + R0lGODlhHAAcAPcAAP/////9///9/f8A//3///3//f39/fv7+/n5+/n5+fn59/n39/f59/f3+ff39/X3 + 9fXy8vLy9fLy8vLw8vDy8u7u7u7u7O7s7uzs7Ozs6uzq6urs7Orq7Orq6urn6ufq6ufq5+fn6ufn5+Xj + 5eXj4+Pj5ePj4+Pj4ePh4+Ph4eHj4eHh4eHe3t/i39/f397e4d7e3t7c3N3d29zc3Nvd29ra2trY2trY + 2NjY2NfX19bW1tbT1tPW09PT1tPT09LU0tLS0tHT09HR0dHRz9HP0c/R0c/Pz8/Nzc3Nz83Nzc3MzMzM + zcrKyMjKysjKyMjIysjIyMjIxsjGyMjGxsbIxsbGxsTGxsTExMTCxMLEwsLCxMLCwsHBwcDBwcDAwL+/ + vb+9vb6+vr2/v72/vb29v729vb27vby+vLu7vbu7u7u5u7q4uLm5ubi4uLi2uLe3t7e0t7a1tbW1tbW1 + s7S3t7S3tLS0t7S0tLS0srSytLOztbOysrK0srKysrKysLKwsrKwsLGysbGxsbCysrCysLCwsLCwrrCu + sLCurq+vr6+vra6wsK6wrq6usK6urqyqqqurq6urqqqrqqqqq6qqqqqqqKqoqqioqqinqKenqKSkpKKi + pKKioqCioqCgoJ6eoJ6enp2dnZycnpycnJubm5qampqamJqYmpmZmZiYmJeYl5eXmJeXl5WXl5WVlZSV + lZSUlJGQkJCQkJCQjo6OkI6Ojo2NjYyNjIyKjIyKioqMioiKiIiIiIeIiIeHh4WFhYSEhIODgoKCgoCA + gH9+f35/f35/fn5+fnp6enNzc25vb25ub2xsbGpqamZmZmNkY2NjZGBgYF5dXV1dXVJRUVFRUk5OTkxM + TEtKSklJSElISUhISEZGRkREREJCQj9APz4+Pj09Pj09PTw8PDc4ODc4NzY2NjY2NTU1NTQ0NDExMjEx + MSEhISAgIB4eHh0dHQkJCQgICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + ACwAAAAAHAAcAAAI/wAHCBxIUBk3d/DguQPnjKDDhwPBcSOmyUgLF1VAKQNnDiJEa86+MGjgoGQFESJy + 5FBFjZvHgdw0AZhJ882bCiFEuChSxRe5l9Jy0KT5xeYbByFY5DCS0RpEbkKHAjBq1IEHFzmqfGHVkaC1 + RFKnfnFD1maik0u/fCH2jaCzsG+K2hxrVifPL4ycCgT3RqrcN27kurGpSanWN77YCbTmYKhNsn8Dv2GU + SFPWoovADVBGbEHYzzMXVGiRQ0rRRNI2JmoMOqzoF2knEztohDXoojQdVMCqdZGhVe7kubANN25fACdd + MD39JqGLCsSHDo4LQHdKpm4SJfqi8AuICq0HA+ggCYI35u3swIESUQF8a+S7055elIibM2U52EP/rBvt + 3TfaSVGLMgOAQ0R+IVSQCCNGaZcIJqCAwgorvRTVCCMV6GUOKyq5gJIm2mWSiSaaRMhKLbWclogRX2g2 + QDLUVGFEhy5o8gmJn0h4Yi2DafdFAwTC5MsXMs6Ywyo67liLWYnclIheA5kDCpFVVGlELbSg6IsvTN6U + g0sPcQNKXGqp1cuWXCLiYwU5SPOSOcQcQhVixDiICBEA1PfSXtb4kkgjDmpnSBQVfKEMlHsOYI450hCz + ynZfJFKLNS4m6pBB7CTkDjdBehQQADs= + + + + EditViewControl + + + False + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Element.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Element.cs new file mode 100644 index 0000000..2aec8e2 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Element.cs @@ -0,0 +1,64 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Drawing; + +namespace Alsing.Windows.Forms.FormatLabel +{ + public enum TextEffect + { + None = 0, + Outline, + ShadowRB, + ShadowLB, + ShadowRT, + ShadowLT, + } + + public class Element + { + protected string _Tag = ""; + protected string _TagName = ""; + public Color BackColor = Color.Black; + public TextEffect Effect = 0; + public Color EffectColor = Color.Black; + public Font Font; + public Color ForeColor = Color.Black; + + public Element Link; + public bool NewLine; + public string Text = ""; + public Word[] words; + + public string TagName + { + get { return _TagName; } + } + + + public string Tag + { + get { return _Tag; } + set + { + _Tag = value.ToLowerInvariant(); + _Tag = _Tag.Replace("\t", " "); + if (_Tag.IndexOf(" ") >= 0) + { + _TagName = _Tag.Substring(0, _Tag.IndexOf(" ")); + } + else + { + _TagName = _Tag; + } + } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Events.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Events.cs new file mode 100644 index 0000000..5a2afa5 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Events.cs @@ -0,0 +1,39 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; + +namespace Alsing.Windows.Forms.FormatLabel +{ + /// + /// + /// + public class ClickLinkEventArgs : EventArgs + { + /// + /// + /// + public string Link = ""; + + /// + /// + /// + /// + public ClickLinkEventArgs(string Link) + { + this.Link = Link; + } + } + + /// + /// + /// + public delegate void ClickLinkEventHandler(object sender, ClickLinkEventArgs e); +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/FormatLabelControl.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/FormatLabelControl.cs new file mode 100644 index 0000000..abe0239 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/FormatLabelControl.cs @@ -0,0 +1,1248 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Web; +using System.Windows.Forms; +using Alsing.Drawing.GDI; +using Alsing.Windows.Forms.FormatLabel; + +namespace Alsing.Windows.Forms.CoreLib +{ + /// + /// + /// + public class FormatLabelControl : BaseControl + { + private readonly Dictionary _Fonts = new Dictionary(); + private Element _ActiveElement; + private Element[] _Elements; + private bool _HasImageError; + + private ImageList _ImageList; + private Color _Link_Color = Color.Blue; + private Color _Link_Color_Hover = Color.Blue; + private bool _Link_UnderLine; + private bool _Link_UnderLine_Hover = true; + private List _Rows; + private ScrollBars _ScrollBars = 0; + private string _Text = "format label"; + private bool _WordWrap = true; + private PictureBox Filler; + private HScrollBar hScroll; + private VScrollBar vScroll; + + public ImageList ImageList + { + get { return _ImageList; } + set + { + _ImageList = value; + Invalidate(); + //this.Text = this.Text; + } + } + + public Color Link_Color + { + get { return _Link_Color; } + set + { + _Link_Color = value; + Invalidate(); + } + } + + public Color Link_Color_Hover + { + get { return _Link_Color_Hover; } + set + { + _Link_Color_Hover = value; + Invalidate(); + } + } + + public bool Link_UnderLine + { + get { return _Link_UnderLine; } + set + { + _Link_UnderLine = value; + Invalidate(); + } + } + + public bool Link_UnderLine_Hover + { + get { return _Link_UnderLine_Hover; } + set + { + _Link_UnderLine_Hover = value; + Invalidate(); + } + } + + + public bool AutoSizeHorizontal { get; set; } + + public bool AutoSizeVertical { get; set; } + + public bool WordWrap + { + get { return _WordWrap; } + set + { + _WordWrap = value; + CreateRows(); + Invalidate(); + } + } + + + [Browsable(true), EditorBrowsable(EditorBrowsableState.Always), Obsolete("", false)] + public override Image BackgroundImage + { + get { return base.BackgroundImage; } + set { base.BackgroundImage = value; } + } + + public ScrollBars ScrollBars + { + get { return _ScrollBars; } + set + { + _ScrollBars = value; + InitScrollbars(); + } + } + + #region Defaults + + private Container components; + + public FormatLabelControl() + { + SetStyle(ControlStyles.ResizeRedraw, true); + SetStyle(ControlStyles.Opaque, true); + InitializeComponent(); + Text = Text; + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + foreach (GDIObject o in _Fonts.Values) + o.Dispose(); + + if (components != null) + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + [Browsable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] + public override string Text + { + get { return _Text; } + set + { + try + { + //Text=value; + _Text = value; + + CreateAll(); + this.Invalidate(); + } + catch (Exception x) + { + Console.WriteLine(x.Message); + System.Diagnostics.Debugger.Break(); + } + } + } + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.Filler = new System.Windows.Forms.PictureBox(); + this.vScroll = new System.Windows.Forms.VScrollBar(); + this.hScroll = new System.Windows.Forms.HScrollBar(); + this.SuspendLayout(); + // + // Filler + // + this.Filler.BackColor = System.Drawing.SystemColors.Control; + this.Filler.Cursor = System.Windows.Forms.Cursors.Default; + this.Filler.Location = new System.Drawing.Point(136, 112); + this.Filler.Name = "Filler"; + this.Filler.Size = new System.Drawing.Size(16, 16); + this.Filler.TabIndex = 5; + this.Filler.TabStop = false; + // + // vScroll + // + this.vScroll.Cursor = System.Windows.Forms.Cursors.Default; + this.vScroll.LargeChange = 2; + this.vScroll.Location = new System.Drawing.Point(136, -8); + this.vScroll.Name = "vScroll"; + this.vScroll.Size = new System.Drawing.Size(16, 112); + this.vScroll.TabIndex = 4; + this.vScroll.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vScroll_Scroll); + // + // hScroll + // + this.hScroll.Cursor = System.Windows.Forms.Cursors.Default; + this.hScroll.LargeChange = 1; + this.hScroll.Location = new System.Drawing.Point(0, 112); + this.hScroll.Maximum = 600; + this.hScroll.Name = "hScroll"; + this.hScroll.Size = new System.Drawing.Size(128, 16); + this.hScroll.TabIndex = 3; + // + // FormatLabelControl + // + this.BackColor = System.Drawing.SystemColors.Window; + this.Controls.AddRange(new System.Windows.Forms.Control[] {this.Filler, this.vScroll, this.hScroll}); + this.Name = "FormatLabelControl"; + this.Size = new System.Drawing.Size(160, 136); + this.ResumeLayout(false); + } + + private void CreateAll() + { + _Elements = CreateElements(); + ClearFonts(); + + + ApplyFormat(_Elements); + CreateWords(_Elements); + CreateRows(); + SetAutoSize(); + } + + private void ClearFonts() + { + foreach (GDIFont gf in _Fonts.Values) + { + gf.Dispose(); + } + _Fonts.Clear(); + } + + #endregion + + #endregion + + public event ClickLinkEventHandler ClickLink = null; + + protected void OnClickLink(string Link) + { + if (ClickLink != null) + ClickLink(this, new ClickLinkEventArgs(Link)); + } + + private void SetAutoSize() + { + if (AutoSizeHorizontal) + Width = GetWidth(); + + if (AutoSizeVertical) + Height = GetHeight(); + } + + protected override void OnPaint(PaintEventArgs e) + { + SetAutoSize(); + //base.OnPaint (e); + + if (_HasImageError) + CreateAll(); + + var bbuff = new GDISurface(Width, Height, this, true); + Graphics g = Graphics.FromHdc(bbuff.hDC); + try + { + bbuff.FontTransparent = true; + + if (BackgroundImage != null) + { + g.DrawImage(BackgroundImage, 0, 0, Width, Height); + } + else + { + bbuff.Clear(BackColor); + } + int x = Margin; + int y = Margin; + for (int i = vScroll.Value; i < _Rows.Count; i++) + { + Row r = _Rows[i]; + x = Margin; + r.Visible = true; + r.Top = y; + if (r.RenderSeparator) + { + Color c1 = Color.FromArgb(120, 0, 0, 0); + Brush b1 = new SolidBrush(c1); + g.FillRectangle(b1, 0, y, Width, 1); + + Color c2 = Color.FromArgb(120, 255, 255, 255); + Brush b2 = new SolidBrush(c2); + g.FillRectangle(b2, 0, y + 1, Width, 1); + + b1.Dispose(); + b2.Dispose(); + + + //bbuff.DrawLine (this.ForeColor,new Point (0,y),new Point (this.Width,y)); + } + + foreach (Word w in r.Words) + { + int ypos = r.Height - w.Height + y; + + if (w.Image != null) + { + g.DrawImage(w.Image, x, y); + //bbuff.FillRect (Color.Red ,x,ypos,w.Width ,w.Height); + } + else + { + GDIFont gf; + if (w.Element.Link != null) + { + Font f = null; + + FontStyle fs = w.Element.Font.Style; + if (w.Element.Link == _ActiveElement) + { + if (_Link_UnderLine_Hover) + fs |= FontStyle.Underline; + + f = new Font(w.Element.Font, fs); + } + else + { + if (_Link_UnderLine) + fs |= FontStyle.Underline; + + f = new Font(w.Element.Font, fs); + } + + gf = GetFont(f); + } + else + { + gf = GetFont(w.Element.Font); + } + + bbuff.Font = gf; + if (w.Element.Effect != TextEffect.None) + { + bbuff.TextForeColor = w.Element.EffectColor; + + if (w.Element.Effect == TextEffect.Outline) + { + for (int xx = -1; xx <= 1; xx++) + for (int yy = -1; yy <= 1; yy++) + bbuff.DrawTabbedString(w.Text, x + xx, ypos + yy, 0, 0); + } + else if (w.Element.Effect != TextEffect.None) + { + bbuff.DrawTabbedString(w.Text, x + 1, ypos + 1, 0, 0); + } + } + + + if (w.Element.Link != null) + { + if (w.Element.Link == _ActiveElement) + { + bbuff.TextForeColor = Link_Color_Hover; + } + else + { + bbuff.TextForeColor = Link_Color; + } + } + else + bbuff.TextForeColor = w.Element.ForeColor; + + bbuff.TextBackColor = w.Element.BackColor; + bbuff.DrawTabbedString(w.Text, x, ypos, 0, 0); + } + + w.ScreenArea.X = x; + w.ScreenArea.Y = ypos; + x += w.Width; + } + + y += r.Height + r.BottomPadd; + if (y > Height) + break; + } + } + catch (Exception x) + { + Console.WriteLine(x.Message); + } + bbuff.RenderToControl(0, 0); + bbuff.Dispose(); + g.Dispose(); + } + + private Element[] CreateElements() + { + string text = Text.Replace("\n", ""); + text = text.Replace("\r", ""); + string[] parts = text.Split('<'); + var elements = new List(); + int i = 0; + foreach (string part in parts) + { + var cmd = new Element(); + + if (i == 0) + { + cmd.Text = part; + } + else + { + string[] TagTextPair = part.Split('>'); + cmd.Tag = TagTextPair[0].ToLowerInvariant(); + if (cmd.Tag.IndexOfAny(" \t".ToCharArray()) >= 0) + { + int ws = cmd.Tag.IndexOfAny(" \t".ToCharArray()); + string s1 = TagTextPair[0].Substring(0, ws).ToLowerInvariant(); + string s2 = TagTextPair[0].Substring(ws + 1); + cmd.Tag = s1 + " " + s2; + } + + + cmd.Text = TagTextPair[1]; + + + if (cmd.TagName == "img") + { + var img = new Element {Tag = cmd.Tag}; + + elements.Add(img); + cmd.Tag = ""; + // Elements.Add (cmd); + } +// +// if (cmd.TagName == "hr") +// { +// Element hr=new Element(); +// hr.Tag = cmd.Tag; +// Elements.Add (hr); +// cmd.Tag =""; +// cmd.Text ="a"; +// // Elements.Add (cmd); +// } + + cmd.Text = cmd.Text.Replace("\t", " "); + cmd.Text = cmd.Text.Replace("‘", "'"); + cmd.Text = cmd.Text.Replace("’", "'"); + + + cmd.Text = cmd.Text.Replace(" ", ((char) 1).ToString()); + cmd.Text = HttpUtility.HtmlDecode(cmd.Text); + // cmd.Text =cmd.Text.Replace (" ","*"); + cmd.Text = cmd.Text.Replace(((char) 1).ToString(), " "); + } + + + elements.Add(cmd); + i++; + } + + var res = new Element[elements.Count]; + elements.CopyTo(res); + return res; + } + + private string GetAttrib(string attrib, string tag) + { + try + { + if (tag.IndexOf(attrib) < 0) + return ""; + + //tag=tag.Replace("\"",""); + tag = tag.Replace("\t", " "); + + int start = tag.IndexOf(attrib); + int end = start + attrib.Length; + int valuestart = tag.IndexOf("=", end); + if (valuestart < 0) + return ""; + valuestart++; + + + string value = tag.Substring(valuestart); + + while (value.StartsWith(" ")) + value = value.Substring(1); + + //int pos=0; + + if (value.StartsWith("\"")) + { + // = "value" + value = value.Substring(1); + int valueend = value.IndexOf("\""); + value = value.Substring(0, valueend); + return value; + } + else + { + // = value + int valueend = value.IndexOf(" "); + if (valueend < 0) + valueend = value.Length; + value = value.Substring(0, valueend); + return value; + } + //return ""; + } + catch + { + return ""; + } + } + + private void ApplyFormat(Element[] Elements) + { + var bold = new Stack(); + var italic = new Stack(); + var underline = new Stack(); + var forecolor = new Stack(); + var backcolor = new Stack(); + var fontsize = new Stack(); + var fontname = new Stack(); + var link = new Stack(); + var effectcolor = new Stack(); + var effect = new Stack(); + + bold.Push(Font.Bold); + italic.Push(Font.Italic); + underline.Push(Font.Underline); + forecolor.Push(ForeColor); + backcolor.Push(Color.Transparent); + fontsize.Push((int) (Font.Size*1.3)); + fontname.Push(Font.Name); + effect.Push(TextEffect.None); + effectcolor.Push(Color.Black); + link.Push(null); + + + foreach (Element Element in Elements) + { + switch (Element.TagName) + { + case "b": + { + bold.Push(true); + break; + } + case "a": + { + //underline.Push (true); + //forecolor.Push (_l); + link.Push(Element); + break; + } + case "i": + case "em": + { + italic.Push(true); + break; + } + case "u": + { + underline.Push(true); + break; + } + case "font": + { + string _fontname = GetAttrib("face", Element.Tag); + string _size = GetAttrib("size", Element.Tag); + string _color = GetAttrib("color", Element.Tag); + string _effectcolor = GetAttrib("effectcolor", Element.Tag); + string _effect = GetAttrib("effect", Element.Tag); + + + if (_size == "") + fontsize.Push(fontsize.Peek()); + else + fontsize.Push(int.Parse(_size)); + + if (_fontname == "") + fontname.Push(fontname.Peek()); + else + fontname.Push(_fontname); + + if (_color == "") + forecolor.Push(forecolor.Peek()); + else + forecolor.Push(Color.FromName(_color)); + + if (_effectcolor == "") + effectcolor.Push(effectcolor.Peek()); + else + effectcolor.Push(Color.FromName(_effectcolor)); + + if (_effect == "") + effect.Push(effect.Peek()); + else + effect.Push(Enum.Parse(typeof (TextEffect), _effect, true)); + + break; + } + case "br": + { + Element.NewLine = true; + break; + } + case "hr": + { + Element.NewLine = true; + break; + } + case "h3": + { + fontsize.Push((int) (Font.Size*1.4)); + bold.Push(true); + Element.NewLine = true; + break; + } + case "h4": + { + fontsize.Push((int) (Font.Size*1.2)); + bold.Push(true); + Element.NewLine = true; + break; + } + case "/b": + { + bold.Pop(); + break; + } + case "/a": + { + //underline.Pop (); + //forecolor.Pop (); + link.Pop(); + break; + } + case "/i": + case "/em": + { + italic.Pop(); + break; + } + case "/u": + { + underline.Pop(); + break; + } + case "/font": + { + fontname.Pop(); + fontsize.Pop(); + forecolor.Pop(); + effect.Pop(); + effectcolor.Pop(); + break; + } + case "/h3": + { + fontsize.Pop(); + bold.Pop(); + Element.NewLine = true; + break; + } + case "/h4": + { + fontsize.Pop(); + bold.Pop(); + Element.NewLine = true; + break; + } + + default: + { + break; + } + } + + + //--------------------------------------------------------------------- + var Bold = (bool) bold.Peek(); + var Italic = (bool) italic.Peek(); + var Underline = (bool) underline.Peek(); + var Link = (Element) link.Peek(); + var FontName = (string) fontname.Peek(); + var FontSize = (int) fontsize.Peek(); + var BackColor = (Color) backcolor.Peek(); + var ForeColor1 = (Color) forecolor.Peek(); + var Effect = (TextEffect) effect.Peek(); + var EffectColor = (Color) effectcolor.Peek(); + + FontStyle fs = 0; + if (Bold) fs |= FontStyle.Bold; + if (Italic) fs |= FontStyle.Italic; + if (Underline) fs |= FontStyle.Underline; + + var font = new Font(FontName, FontSize, fs); + Element.Font = font; + Element.BackColor = BackColor; + Element.ForeColor = ForeColor1; + Element.Link = Link; + Element.Effect = Effect; + Element.EffectColor = EffectColor; + } + } + + private bool IsIndex(string src) + { + int i; + return int.TryParse(src, out i); + } + + private void CreateWords(Element[] Elements) + { + var bbuff = new GDISurface(1, 1, this, false); + + _HasImageError = false; + foreach (Element Element in Elements) + { + if (Element.TagName == "img") + { + Element.words = new Word[1]; + + Element.words[0] = new Word(); + + Image img = null; + + try + { + string SRC = GetAttrib("img", Element.Tag).ToLowerInvariant(); + if (IsIndex(SRC)) + { + int index = int.Parse(SRC); + img = ImageList.Images[index]; + } + else if (SRC.StartsWith("http://")) //from url + {} + else if (SRC.StartsWith("file://")) // from file + { + img = Image.FromFile(SRC.Substring(7)); + } + else //from file + { + img = Image.FromFile(SRC); + } + } + catch + { + img = new Bitmap(20, 20); + _HasImageError = true; + } + + Element.words[0].Image = img; + + + Element.words[0].Element = Element; + + + if (img != null) + { + Element.words[0].Height = img.Height; + Element.words[0].Width = img.Width; + Element.words[0].ScreenArea.Width = img.Width; + Element.words[0].ScreenArea.Height = img.Height; + } + } + else + { + string[] words = Element.Text.Split(' '); + Element.words = new Word[words.Length]; + int i = 0; + foreach (string word in words) + { + Element.words[i] = new Word(); + string tmp; + Element.words[i].Element = Element; + if (i == words.Length - 1) + { + Element.words[i].Text = word; + tmp = word; + } + else + { + Element.words[i].Text = word + " "; + tmp = word + " "; //last space cant be measured , lets measure an "," instead + } + //SizeF size=g.MeasureString (tmp,Element.Font); + bbuff.Font = GetFont(Element.Font); + Size s = bbuff.MeasureTabbedString(tmp, 0); + Element.words[i].Height = s.Height; + Element.words[i].Width = s.Width - 0; + Element.words[i].ScreenArea.Width = Element.words[i].Width; + Element.words[i].ScreenArea.Height = Element.words[i].Height; + // Element.words[i].Link =Element.Link ; + + i++; + } + } + } + + bbuff.Dispose(); + } + + private GDIFont GetFont(Font font) + { + GDIFont gf = null; + if (!_Fonts.TryGetValue(GetFontKey(font), out gf)) + { + gf = new GDIFont(font.Name, font.Size, font.Bold, font.Italic, font.Underline, false); + _Fonts[GetFontKey(font)] = gf; + } + + return gf; + } + + private string GetFontKey(Font font) + { + return font.Name + font.Bold + font.Italic + font.Underline + font.Size; + } + + + private void CreateRows() + { + if (_Elements != null) + { + int x = 0; + _Rows = new List(); + + //build rows--------------------------------------------- + var row = new Row(); + _Rows.Add(row); + bool WhiteSpace = false; + foreach (Element Element in _Elements) + { + if (Element.words == null) + return; + + if (Element.NewLine) + { + //tag forces a new line + x = 0; + row = new Row(); + _Rows.Add(row); + WhiteSpace = true; + } + if (Element.TagName == "hr") + { + row.RenderSeparator = true; + } + + //else + //{ + + + foreach (Word word in Element.words) + { + if (WordWrap) + { + int scrollwdh = 0; + if (ScrollBars == ScrollBars.Both || ScrollBars == ScrollBars.Vertical) + scrollwdh = vScroll.Width; + + if ((word.Width + x) > ClientWidth - Margin - scrollwdh) + { + //new line due to wordwrap + x = 0; + row = new Row(); + _Rows.Add(row); + WhiteSpace = true; + } + } + + if (word.Text.Replace(" ", "") != "" || word.Image != null) + WhiteSpace = false; + + if (!WhiteSpace) + { + row.Words.Add(word); + + x += word.Width; + } + } + //} + } + + //apply width and height to all rows + int index = 0; + foreach (Row r in _Rows) + { + int width = 0; + int height = 0; + int padd = 0; + + if (index > 0) + { + int previndex = index - 1; + Row prev = _Rows[previndex]; + while (previndex >= 0 && prev.Words.Count == 0) + { + prev = _Rows[previndex]; + previndex--; + } + + if (previndex >= 0) + { + prev = _Rows[previndex]; + if (prev.Words.Count > 0) + { + Word w = prev.Words[prev.Words.Count - 1]; + height = w.Height; + } + } + } + + + foreach (Word w in r.Words) + { + if (w.Height > height && (w.Text != "")) + height = w.Height; + + width += w.Width; + } + r.Height = height; + + int MaxImageH = 0; + foreach (Word w in r.Words) + { + if (w.Image != null) + { + if (w.Height > height) + MaxImageH = w.Height; + } + } + + foreach (Word w in r.Words) + { + int imgH = 0; + int imgPadd = 0; + if (w.Image != null) + { + string valign = GetAttrib("valign", w.Element.Tag); + switch (valign) + { + case "top": + { + imgH = r.Height; + imgPadd = w.Height - imgH; + break; + } + case "middle": + case "center": + { + imgH = r.Height; + int tmp = (w.Height - imgH)/2; + imgH += tmp; + imgPadd = tmp; + + break; + } + case "bottom": + { + imgH = w.Height; + imgPadd = 0; + break; + } + default: + { + imgH = w.Height; + imgPadd = 0; + break; + } + } + + if (imgH > height) + height = imgH; + + if (imgPadd > padd) + padd = imgPadd; + + + width += w.Width; + } + } + r.Width = width; + r.Height = height; + r.BottomPadd = padd; + index++; + } + + vScroll.Maximum = _Rows.Count; + } + } + + private void InitScrollbars() + { + if (vScroll == null || hScroll == null) + return; + + if (ScrollBars == ScrollBars.Both) + { + vScroll.Left = ClientWidth - vScroll.Width; + vScroll.Top = 0; + vScroll.Height = ClientHeight - hScroll.Height; + + hScroll.Left = 0; + hScroll.Top = ClientHeight - hScroll.Height; + hScroll.Width = ClientWidth - vScroll.Width; + + Filler.Left = vScroll.Left; + Filler.Top = hScroll.Top; + + Filler.Visible = true; + vScroll.Visible = true; + hScroll.Visible = true; + } + else if (ScrollBars == ScrollBars.Vertical) + { + vScroll.Left = ClientWidth - vScroll.Width; + vScroll.Top = 0; + vScroll.Height = ClientHeight; + + hScroll.Left = 0; + hScroll.Top = ClientHeight - hScroll.Height; + hScroll.Width = ClientWidth - vScroll.Width; + + Filler.Left = vScroll.Left; + Filler.Top = hScroll.Top; + + Filler.Visible = false; + vScroll.Visible = true; + hScroll.Visible = false; + } + else if (ScrollBars == ScrollBars.Horizontal) + { + vScroll.Left = ClientWidth - vScroll.Width; + vScroll.Top = 0; + vScroll.Height = ClientHeight; + + hScroll.Left = 0; + hScroll.Top = ClientHeight - hScroll.Height; + hScroll.Width = ClientWidth; + + Filler.Left = vScroll.Left; + Filler.Top = hScroll.Top; + + Filler.Visible = false; + vScroll.Visible = false; + hScroll.Visible = true; + } + else if (ScrollBars == ScrollBars.None) + { + vScroll.Left = ClientWidth - vScroll.Width; + vScroll.Top = 0; + vScroll.Height = ClientHeight; + + hScroll.Left = 0; + hScroll.Top = ClientHeight - hScroll.Height; + hScroll.Width = ClientWidth; + + Filler.Left = vScroll.Left; + Filler.Top = hScroll.Top; + + Filler.Visible = false; + vScroll.Visible = false; + hScroll.Visible = false; + } + } + + + protected override void OnResize(EventArgs e) + { + try + { + InitScrollbars(); + SetAutoSize(); + } + catch {} + CreateRows(); + base.OnResize(e); + } + + protected override void OnMouseUp(MouseEventArgs e) + { + int y = e.Y; + int x = e.X; + + int index = 0; + bool Link = false; + //this.Cursor =Cursors.Arrow; + _ActiveElement = null; + if (_Rows != null) + { + foreach (Row r in _Rows) + { + if (y >= r.Top && y <= r.Top + r.Height) + { + foreach (Word w in r.Words) + { + if (y >= w.ScreenArea.Top && y <= w.ScreenArea.Bottom) + { + if (x >= w.ScreenArea.Left && x <= w.ScreenArea.Right) + { + if (w.Element.Link != null) + { + Link = true; + _ActiveElement = w.Element.Link; + break; + } + } + } + } + break; + } + index++; + } + } + if (Link) + { + Cursor = Cursors.Hand; + Invalidate(); + OnClickLink(GetAttrib("href", _ActiveElement.Tag)); + } + else + { + Cursor = Cursors.Arrow; + Invalidate(); + } + + + base.OnMouseUp(e); + } + + protected override void OnMouseMove(MouseEventArgs e) + { + int y = e.Y; + int x = e.X; + + int index = 0; + bool Link = false; + //this.Cursor =Cursors.Arrow; + _ActiveElement = null; + if (_Rows != null) + { + foreach (Row r in _Rows) + { + if (y >= r.Top && y <= r.Top + r.Height) + { + foreach (Word w in r.Words) + { + if (y >= w.ScreenArea.Top && y <= w.ScreenArea.Bottom) + { + if (x >= w.ScreenArea.Left && x <= w.ScreenArea.Right) + { + if (w.Element.Link != null) + { + Link = true; + _ActiveElement = w.Element.Link; + break; + } + } + } + } + break; + } + index++; + } + } + if (Link) + { + Cursor = Cursors.Hand; + Invalidate(); + } + else + { + Cursor = Cursors.Arrow; + Invalidate(); + } + base.OnMouseMove(e); + } + + private void vScroll_Scroll(object sender, ScrollEventArgs e) + { + Invalidate(); + } + + + public int GetWidth() + { + int max = 0; + foreach (Row r in _Rows) + { + if (r.Width > max) + max = r.Width; + } + + return max + Margin*2 + BorderWidth*2; + } + + public int GetHeight() + { + int max = 0; + foreach (Row r in _Rows) + { + max += r.Height; + } + + return max + Margin*2 + BorderWidth*2; + } + + #region PUBLIC PROPERTY MARGIN + + private int _Margin; + + public new int Margin + { + get { return _Margin; } + set + { + _Margin = value; + CreateRows(); + Invalidate(); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/FormatLabelControl.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/FormatLabelControl.resx new file mode 100644 index 0000000..05292c0 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/FormatLabelControl.resx @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + FormatLabelControl + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Row.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Row.cs new file mode 100644 index 0000000..d84e5c0 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Row.cs @@ -0,0 +1,25 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; + +namespace Alsing.Windows.Forms.FormatLabel +{ + public class Row + { + public int BottomPadd; + public int Height; + public bool RenderSeparator; + public int Top; + public bool Visible; + public int Width; + public List Words = new List(); + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Word.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Word.cs new file mode 100644 index 0000000..6469cd8 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/FormatLabel/Word.cs @@ -0,0 +1,25 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Drawing; + +namespace Alsing.Windows.Forms.FormatLabel +{ + public class Word + { + public Element Element; + public int Height; + public Image Image; + public Rectangle ScreenArea = new Rectangle(0, 0, 0, 0); + public string Text = ""; + public int Width; + // public bool Link=false; + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/InfoTip/InfoTipForm.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/InfoTip/InfoTipForm.cs new file mode 100644 index 0000000..9be0776 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/InfoTip/InfoTipForm.cs @@ -0,0 +1,387 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Globalization; +using System.Runtime.InteropServices; +using System.Windows.Forms; +using Alsing.Windows.Forms.CoreLib; + +namespace Alsing.Windows.Forms +{ + /// + /// Summary description for InfoTip. + /// + public class InfoTipForm : Form + { + private WeakReference _Control; + private int _Count = 1; + private int _SelectedIndex; + + private PictureBox btnNext; + private PictureBox btnPrev; + + /// + /// Required designer variable. + /// + private Container components; + + private FormatLabelControl InfoText; + + private Label lblIndex; + private Panel panel1; + private Panel panel2; + private PictureBox picIcon; + private Panel pnlImage; + private Panel pnlSelect; + + /// + /// + /// + public InfoTipForm() + { + InitializeComponent(); + } + + /// + /// + /// + /// + public InfoTipForm(Control parent) + { + ParentControl = parent; + if (CreateParams != null) CreateParams.ClassName = "tooltips_class32"; + + InitializeComponent(); + } + + private Control ParentControl + { + get { return _Control != null ? (Control) _Control.Target : null; } + set { _Control = new WeakReference(value); } + } + + + public int SelectedIndex + { + get { return _SelectedIndex; } + set + { + if (value > _Count) + value = 1; + if (value < 1) + value = _Count; + + _SelectedIndex = value; + OnSelectedIndexChanged(); + SetPos(); + } + } + + public int Count + { + get { return _Count; } + set { _Count = value; } + } + + public Image Image + { + get { return picIcon.Image; } + set + { + picIcon.Image = value; + if (value == null) + { + pnlImage.Visible = false; + } + else + { + pnlImage.Visible = true; + pnlImage.Width = Image.Width + 6; + picIcon.Size = Image.Size; + } + DoResize(); + } + } + + public string Data + { + get { return InfoText.Text; } + set { InfoText.Text = value; } + } + + [DllImport("user32.dll", EntryPoint = "SendMessage")] + private static extern int SendMessage(IntPtr hWnd, int message, int _data, int _id); + + public event EventHandler SelectedIndexChanged = null; + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + + private void InfoText_Resize(object sender, EventArgs e) + { + DoResize(); + } + + private void DoResize() + { + int w = InfoText.Left + InfoText.Width + 8; + if (Count > 1) + { + w += pnlSelect.Width; + } + if (picIcon.Image != null) + { + w += pnlImage.Width; + } + + + int h = InfoText.Top + InfoText.Height + 6; + if (Image != null && Image.Height + picIcon.Top*2 > h) + h = Image.Height + picIcon.Top*2; + + ClientSize = new Size(w, h); + } + + /// + /// + /// + public void Init() + { + SelectedIndex = 1; + SetPos(); + } + + private void btnNext_Click(object sender, EventArgs e) + { + SelectedIndex++; + SetPos(); + } + + private void btnPrev_Click(object sender, EventArgs e) + { + SelectedIndex--; + SetPos(); + } + + private void btnPrev_DoubleClick(object sender, EventArgs e) + { + SelectedIndex--; + SetPos(); + } + + private void btnNext_DoubleClick(object sender, EventArgs e) + { + SelectedIndex++; + SetPos(); + } + + private void SetPos() + { + if (Count == 1) + { + pnlSelect.Visible = false; + } + else + { + pnlSelect.Visible = true; + } + DoResize(); + + lblIndex.Text = SelectedIndex.ToString((CultureInfo.InvariantCulture)) + " of " + + Count.ToString(CultureInfo.InvariantCulture); + + if (ParentControl != null) + ParentControl.Focus(); + } + + private void InfoTipForm_Enter(object sender, EventArgs e) + { + ParentControl.Focus(); + } + + private void InfoText_Enter(object sender, EventArgs e) + { + ParentControl.Focus(); + } + + private void OnSelectedIndexChanged() + { + if (SelectedIndexChanged != null) + SelectedIndexChanged(this, null); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + var resources = new System.Resources.ResourceManager(typeof (InfoTipForm)); + this.pnlSelect = new System.Windows.Forms.Panel(); + this.btnNext = new System.Windows.Forms.PictureBox(); + this.btnPrev = new System.Windows.Forms.PictureBox(); + this.lblIndex = new System.Windows.Forms.Label(); + this.panel2 = new System.Windows.Forms.Panel(); + this.InfoText = new Alsing.Windows.Forms.CoreLib.FormatLabelControl(); + this.pnlImage = new System.Windows.Forms.Panel(); + this.picIcon = new System.Windows.Forms.PictureBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.pnlSelect.SuspendLayout(); + this.panel2.SuspendLayout(); + this.pnlImage.SuspendLayout(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // pnlSelect + // + this.pnlSelect.Controls.AddRange(new System.Windows.Forms.Control[] + {this.btnNext, this.btnPrev, this.lblIndex}); + this.pnlSelect.Dock = System.Windows.Forms.DockStyle.Left; + this.pnlSelect.DockPadding.All = 4; + this.pnlSelect.Location = new System.Drawing.Point(32, 0); + this.pnlSelect.Name = "pnlSelect"; + this.pnlSelect.Size = new System.Drawing.Size(80, 35); + this.pnlSelect.TabIndex = 0; + // + // btnNext + // + this.btnNext.BackColor = System.Drawing.SystemColors.Control; + this.btnNext.Image = ((System.Drawing.Bitmap) (resources.GetObject("btnNext.Image"))); + this.btnNext.Location = new System.Drawing.Point(68, 6); + this.btnNext.Name = "btnNext"; + this.btnNext.Size = new System.Drawing.Size(9, 11); + this.btnNext.TabIndex = 1; + this.btnNext.TabStop = false; + this.btnNext.Click += new System.EventHandler(this.btnNext_Click); + this.btnNext.DoubleClick += new System.EventHandler(this.btnNext_DoubleClick); + // + // btnPrev + // + this.btnPrev.BackColor = System.Drawing.SystemColors.Control; + this.btnPrev.Image = ((System.Drawing.Bitmap) (resources.GetObject("btnPrev.Image"))); + this.btnPrev.Location = new System.Drawing.Point(4, 6); + this.btnPrev.Name = "btnPrev"; + this.btnPrev.Size = new System.Drawing.Size(9, 11); + this.btnPrev.TabIndex = 0; + this.btnPrev.TabStop = false; + this.btnPrev.Click += new System.EventHandler(this.btnPrev_Click); + this.btnPrev.DoubleClick += new System.EventHandler(this.btnPrev_DoubleClick); + // + // lblIndex + // + this.lblIndex.Dock = System.Windows.Forms.DockStyle.Top; + this.lblIndex.Location = new System.Drawing.Point(4, 4); + this.lblIndex.Name = "lblIndex"; + this.lblIndex.Size = new System.Drawing.Size(72, 23); + this.lblIndex.TabIndex = 2; + this.lblIndex.Text = "20 of 20"; + this.lblIndex.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // panel2 + // + this.panel2.Controls.AddRange(new System.Windows.Forms.Control[] {this.InfoText}); + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.DockPadding.All = 4; + this.panel2.Location = new System.Drawing.Point(112, 0); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(126, 35); + this.panel2.TabIndex = 1; + // + // InfoText + // + this.InfoText.AutoSizeHorizontal = true; + this.InfoText.AutoSizeVertical = true; + this.InfoText.BackColor = System.Drawing.SystemColors.Info; + this.InfoText.BorderColor = System.Drawing.Color.Black; + this.InfoText.BorderStyle = Alsing.Windows.Forms.BorderStyle.None; + this.InfoText.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, + System.Drawing.GraphicsUnit.Point, ((System.Byte) (0))); + this.InfoText.ImageList = null; + this.InfoText.Link_Color = System.Drawing.Color.Blue; + this.InfoText.Link_Color_Hover = System.Drawing.Color.Blue; + this.InfoText.Link_UnderLine = false; + this.InfoText.Link_UnderLine_Hover = true; + this.InfoText.Location = new System.Drawing.Point(2, 4); + this.InfoText.Name = "InfoText"; + this.InfoText.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.InfoText.Size = new System.Drawing.Size(59, 13); + this.InfoText.TabIndex = 0; + this.InfoText.Text = "format label"; + this.InfoText.WordWrap = false; + this.InfoText.Resize += new System.EventHandler(this.InfoText_Resize); + this.InfoText.Enter += new System.EventHandler(this.InfoText_Enter); + // + // pnlImage + // + this.pnlImage.Controls.AddRange(new System.Windows.Forms.Control[] {this.picIcon}); + this.pnlImage.Dock = System.Windows.Forms.DockStyle.Left; + this.pnlImage.Name = "pnlImage"; + this.pnlImage.Size = new System.Drawing.Size(32, 35); + this.pnlImage.TabIndex = 2; + this.pnlImage.Visible = false; + // + // picIcon + // + this.picIcon.Location = new System.Drawing.Point(5, 3); + this.picIcon.Name = "picIcon"; + this.picIcon.Size = new System.Drawing.Size(19, 20); + this.picIcon.TabIndex = 1; + this.picIcon.TabStop = false; + // + // panel1 + // + this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] + {this.panel2, this.pnlSelect, this.pnlImage}); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(240, 37); + this.panel1.TabIndex = 3; + // + // InfoTipForm + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.BackColor = System.Drawing.SystemColors.Info; + this.ClientSize = new System.Drawing.Size(240, 37); + this.ControlBox = false; + this.Controls.AddRange(new System.Windows.Forms.Control[] {this.panel1}); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "InfoTipForm"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.Enter += new System.EventHandler(this.InfoTipForm_Enter); + this.pnlSelect.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.pnlImage.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/InfoTip/InfoTipForm.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/InfoTip/InfoTipForm.resx new file mode 100644 index 0000000..9b8f1eb --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/InfoTip/InfoTipForm.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + + R0lGODlhCQALAPEAAP///wAAAMDAwAAAACH5BAEAAAIALAAAAAAJAAsAAAIOlI+pyxIPw4kSwVWb1gUA + Ow== + + + + True + + + R0lGODlhCQALAPEAAP///wAAAMDAwAAAACH5BAEAAAIALAAAAAAJAAsAAAINlI+pe7EBE5xtUoYzLgA7 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + InfoTipForm + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/IntelliMouse/Events.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/IntelliMouse/Events.cs new file mode 100644 index 0000000..8235019 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/IntelliMouse/Events.cs @@ -0,0 +1,22 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; + +namespace Alsing.Windows.Forms.IntelliMouse +{ + public class ScrollEventArgs : EventArgs + { + public int DeltaX; + public int DeltaY; + } + + public delegate void ScrollEventHandler(object sender, ScrollEventArgs e); +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/IntelliMouse/IntelliMouse.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/IntelliMouse/IntelliMouse.cs new file mode 100644 index 0000000..b5c0ee6 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/IntelliMouse/IntelliMouse.cs @@ -0,0 +1,378 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Drawing; +using System.IO; +using System.Windows.Forms; +using Properties; +using ScrollEventArgs=Alsing.Windows.Forms.IntelliMouse.ScrollEventArgs; +using ScrollEventHandler=Alsing.Windows.Forms.IntelliMouse.ScrollEventHandler; + +namespace Alsing.Windows.Forms.CoreLib +{ + /// + /// Summary description for IntelliMouseControl. + /// + public class IntelliMouseControl : Control + { + protected const int WM_CAPTURECHANGED = 0x0215; + protected const int WM_LBUTTONDOWN = 0x0201; + protected const int WM_MBUTTONDOWN = 0x0207; + protected const int WM_MBUTTONUP = 0x0208; + protected const int WM_MOUSELEAVE = 0x02A3; + protected const int WM_RBUTTONDOWN = 0x0204; + + + protected bool Active; + protected IContainer components; + + private bool IsDirty; + + #region GENERAL DECLARATIONS + + protected WeakReference _CurrentParent; + protected Point ActivationPoint = new Point(0, 0); + protected Point CurrentDelta = new Point(0, 0); + + protected Control CurrentParent + { + get + { + if (_CurrentParent != null) + return (Control) _CurrentParent.Target; + return null; + } + set { _CurrentParent = new WeakReference(value); } + } + + #endregion + + #region EVENTS + + public event EventHandler BeginScroll = null; + public event EventHandler EndScroll = null; + public event ScrollEventHandler Scroll = null; + + #endregion + + #region PUBLIC PROPERTY IMAGE + + protected Bitmap _Image; + protected PictureBox picImage; + protected RegionHandler regionHandler1; + protected Timer tmrFeedback; + + + public Bitmap Image + { + get { return _Image; } + set + { + _Image = value; + IsDirty = true; + } + } + + #endregion + + #region PUBLIC PROPERTY TRANSPARENCYKEY + + protected Color _TransparencyKey = Color.FromArgb(255, 0, 255); + + public Color TransparencyKey + { + get { return _TransparencyKey; } + set + { + _TransparencyKey = value; + IsDirty = true; + } + } + + #endregion + + #region CONSTRUCTOR + + public IntelliMouseControl() + { + InitializeComponent(); +// SetStyle(ControlStyles.Selectable,false); +// this.Image = (Bitmap)this.picImage.Image; +// this.Visible =false; + } + + #endregion + + #region DISPOSE + + protected override void Dispose(bool disposing) + { +#if DEBUG + try + { + Console.WriteLine("disposing intellimouse"); + } + catch {} +#endif + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #endregion + + #region FINALIZE + + ~IntelliMouseControl() + { +#if DEBUG + try + { + Console.WriteLine("finalizing intellimouse"); + } + catch {} +#endif + } + + #endregion + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + protected void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + var resources = new System.Resources.ResourceManager(typeof (IntelliMouseControl)); + this.tmrFeedback = new Timer(); + this.picImage = new System.Windows.Forms.PictureBox(); + this.regionHandler1 = new Alsing.Windows.Forms.CoreLib.RegionHandler(this.components); + // + // tmrFeedback + // + this.tmrFeedback.Enabled = true; + this.tmrFeedback.Interval = 10; + this.tmrFeedback.Tick += new System.EventHandler(this.tmrFeedback_Tick); + // + // picImage + // + this.picImage.Image = ((System.Drawing.Bitmap) (resources.GetObject("picImage.Image"))); + this.picImage.Location = new System.Drawing.Point(17, 17); + this.picImage.Name = "picImage"; + this.picImage.TabIndex = 0; + this.picImage.TabStop = false; + // + // regionHandler1 + // + this.regionHandler1.Control = null; + this.regionHandler1.MaskImage = null; + this.regionHandler1.TransparencyKey = System.Drawing.Color.FromArgb(((System.Byte) (255)), + ((System.Byte) (0)), + ((System.Byte) (255))); + // + // IntelliMouseControl + // + this.ParentChanged += new System.EventHandler(this.IntelliMouseControl_ParentChanged); + } + + #endregion + + protected void CreateRegion() + { + regionHandler1.ApplyRegion(this, Image, TransparencyKey); + IsDirty = false; + } + + public void Activate(int x, int y) + { + if (IsDirty) + CreateRegion(); + + Size = new Size(Image.Width, Image.Height); + Location = new Point(x - Image.Width/2, y - Image.Height/2); + ActivationPoint.X = x; + ActivationPoint.Y = y; + BringToFront(); + Visible = true; + Focus(); + Active = false; + Application.DoEvents(); + SetCursor(0, 0); + tmrFeedback.Enabled = true; + onBeginScroll(new EventArgs()); + NativeMethods.SendMessage(Handle, WM_MBUTTONDOWN, 0, 0); + Active = true; + } + + protected void SetCursor(int x, int y) + { + int dY = y; + int dX = x; + + CurrentDelta.X = dX; + CurrentDelta.Y = dY; + + if (dY > 16) + { + var ms = new MemoryStream(Resources.MoveDown); + Cursor = new Cursor(ms); + CurrentDelta.Y -= 16; + } + else if (dY < -16) + { + var ms = new MemoryStream(Resources.MoveUp); + Cursor = new Cursor(ms); + CurrentDelta.Y += 16; + } + else + { + var ms = new MemoryStream(Resources.MoveUpDown); + Cursor = new Cursor(ms); + CurrentDelta = new Point(0, 0); + } + } + + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + if (Active) + { + if (e.Button != MouseButtons.None && (e.Button != MouseButtons.Middle && e.X != 0 && e.Y != 0)) + { + Deactivate(); + var p = new Point(e.X + Left, e.Y + Top); + NativeMethods.SendMessage(Parent.Handle, WM_LBUTTONDOWN, 0, p.Y*0x10000 + p.X); + } + } + } + + protected override void OnMouseMove(MouseEventArgs e) + { + if (Active) + { + if (e.Button != MouseButtons.Middle && e.Button != MouseButtons.None) + { + Deactivate(); + } + else + { + int x = e.X; + int y = e.Y; + x -= Image.Width/2; + y -= Image.Height/2; + SetCursor(x, y); + NativeMethods.SendMessage(Handle, WM_MBUTTONDOWN, 0, 0); + } + } + else + { + base.OnMouseMove(e); + } + } + + protected void Deactivate() + { + NativeMethods.SendMessage(Handle, WM_MBUTTONUP, 0, 0); + Active = false; + tmrFeedback.Enabled = false; + Hide(); + onEndScroll(new EventArgs()); + Parent.Focus(); + } + + protected override void OnResize(EventArgs e) + { + Size = Image != null ? new Size(Image.Width, Image.Height) : new Size(32, 32); + } + + protected void Parent_MouseDown(object s, MouseEventArgs e) + { + if (e.Button == MouseButtons.Middle) + { + Activate(e.X, e.Y); + } + } + + protected void tmrFeedback_Tick(object sender, EventArgs e) + { + var a = new ScrollEventArgs {DeltaX = CurrentDelta.X, DeltaY = CurrentDelta.Y}; + onScroll(a); + } + + protected virtual void onBeginScroll(EventArgs e) + { + if (BeginScroll != null) + BeginScroll(this, e); + } + + protected virtual void onEndScroll(EventArgs e) + { + if (EndScroll != null) + EndScroll(this, e); + } + + protected virtual void onScroll(ScrollEventArgs e) + { + if (Scroll != null) + Scroll(this, e); + } + + protected void IntelliMouseControl_ParentChanged(object sender, EventArgs e) + { + if (CurrentParent != null) + { + CurrentParent.MouseDown -= Parent_MouseDown; + } + if (Parent != null) + { + Parent.MouseDown += Parent_MouseDown; + Deactivate(); + } + } + + protected override void OnKeyDown(KeyEventArgs e) + { + Deactivate(); + } + + protected override void OnLeave(EventArgs e) + { + base.OnLeave(e); + Deactivate(); + } + + protected override void OnLostFocus(EventArgs e) + { + base.OnLostFocus(e); + Deactivate(); + } + + protected override void WndProc(ref Message m) + { + if (m.Msg == WM_MOUSELEAVE) + { + base.WndProc(ref m); + Deactivate(); + return; + } + + base.WndProc(ref m); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/IntelliMouse/IntelliMouse.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/IntelliMouse/IntelliMouse.resx new file mode 100644 index 0000000..5778705 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/IntelliMouse/IntelliMouse.resx @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 114, 17 + + + 17, 17 + + + + R0lGODlhHAAcAPcAAP/////9///9/f8A//3///3//f39/fv7+/n5+/n5+fn59/n39/f59/f3+ff39/X3 + 9fXy8vLy9fLy8vLw8vDy8u7u7u7u7O7s7uzs7Ozs6uzq6urs7Orq7Orq6urn6ufq6ufq5+fn6ufn5+Xj + 5eXj4+Pj5ePj4+Pj4ePh4+Ph4eHj4eHh4eHe3t/i39/f397e4d7e3t7c3N3d29zc3Nvd29ra2trY2trY + 2NjY2NfX19bW1tbT1tPW09PT1tPT09LU0tLS0tHT09HR0dHRz9HP0c/R0c/Pz8/Nzc3Nz83Nzc3MzMzM + zcrKyMjKysjKyMjIysjIyMjIxsjGyMjGxsbIxsbGxsTGxsTExMTCxMLEwsLCxMLCwsHBwcDBwcDAwL+/ + vb+9vb6+vr2/v72/vb29v729vb27vby+vLu7vbu7u7u5u7q4uLm5ubi4uLi2uLe3t7e0t7a1tbW1tbW1 + s7S3t7S3tLS0t7S0tLS0srSytLOztbOysrK0srKysrKysLKwsrKwsLGysbGxsbCysrCysLCwsLCwrrCu + sLCurq+vr6+vra6wsK6wrq6usK6urqyqqqurq6urqqqrqqqqq6qqqqqqqKqoqqioqqinqKenqKSkpKKi + pKKioqCioqCgoJ6eoJ6enp2dnZycnpycnJubm5qampqamJqYmpmZmZiYmJeYl5eXmJeXl5WXl5WVlZSV + lZSUlJGQkJCQkJCQjo6OkI6Ojo2NjYyNjIyKjIyKioqMioiKiIiIiIeIiIeHh4WFhYSEhIODgoKCgoCA + gH9+f35/f35/fn5+fnp6enNzc25vb25ub2xsbGpqamZmZmNkY2NjZGBgYF5dXV1dXVJRUVFRUk5OTkxM + TEtKSklJSElISUhISEZGRkREREJCQj9APz4+Pj09Pj09PTw8PDc4ODc4NzY2NjY2NTU1NTQ0NDExMjEx + MSEhISAgIB4eHh0dHQkJCQgICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + ACwAAAAAHAAcAAAI/wAHCBxIUBk3d/DguQPnjKDDhwPBcSOmyUgLF1VAKQNnDiJEa86+MGjgoGQFESJy + 5FBFjZvHgdw0AZhJ882bCiFEuChSxRe5l9Jy0KT5xeYbByFY5DCS0RpEbkKHAjBq1IEHFzmqfGHVkaC1 + RFKnfnFD1maik0u/fCH2jaCzsG+K2hxrVifPL4ycCgT3RqrcN27kurGpSanWN77YCbTmYKhNsn8Dv2GU + SFPWoovADVBGbEHYzzMXVGiRQ0rRRNI2JmoMOqzoF2knEztohDXoojQdVMCqdZGhVe7kubANN25fACdd + MD39JqGLCsSHDo4LQHdKpm4SJfqi8AuICq0HA+ggCYI35u3swIESUQF8a+S7055elIibM2U52EP/rBvt + 3TfaSVGLMgOAQ0R+IVSQCCNGaZcIJqCAwgorvRTVCCMV6GUOKyq5gJIm2mWSiSaaRMhKLbWclogRX2g2 + QDLUVGFEhy5o8gmJn0h4Yi2DafdFAwTC5MsXMs6Ywyo67liLWYnclIheA5kDCpFVVGlELbSg6IsvTN6U + g0sPcQNKXGqp1cuWXCLiYwU5SPOSOcQcQhVixDiICBEA1PfSXtb4kkgjDmpnSBQVfKEMlHsOYI450hCz + ynZfJFKLNS4m6pBB7CTkDjdBehQQADs= + + + + 230, 17 + + + False + + + IntelliMouseControl + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/RegionHandler/RegionHandler.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/RegionHandler/RegionHandler.cs new file mode 100644 index 0000000..4174116 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/RegionHandler/RegionHandler.cs @@ -0,0 +1,96 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace Alsing.Windows.Forms.CoreLib +{ + [ToolboxItem(true)] + public class RegionHandler : Component + { + private Container components; + + #region PUBLIC PROPERTY TRANSPARENCYKEY + + private Color _TransparencyKey = Color.FromArgb(255, 0, 255); + + public Color TransparencyKey + { + get { return _TransparencyKey; } + set { _TransparencyKey = value; } + } + + #endregion + + #region PUBLIC PROPERTY CONTROL + + public Control Control { get; set; } + + #endregion + + #region PUBLIC PROPERTY MASKIMAGE + + public Bitmap MaskImage { get; set; } + + #endregion + + public RegionHandler(IContainer container) + { + container.Add(this); + InitializeComponent(); + } + + public RegionHandler() + { + InitializeComponent(); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + + public void ApplyRegion(Control Target, Bitmap MaskImage, Color TransparencyKey) + { + Control = Target; + this.MaskImage = MaskImage; + this.TransparencyKey = TransparencyKey; + ApplyRegion(); + } + + + public void ApplyRegion() + { + var r = new Region(new Rectangle(0, 0, MaskImage.Width, MaskImage.Height)); + + for (int y = 0; y < MaskImage.Height; y++) + for (int x = 0; x < MaskImage.Width; x++) + { + if (MaskImage.GetPixel(x, y) == TransparencyKey) + { + r.Exclude(new Rectangle(x, y, 1, 1)); + } + } + + Control.Region = r; + Control.BackgroundImage = MaskImage; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/RegionHandler/RegionHandler.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/RegionHandler/RegionHandler.resx new file mode 100644 index 0000000..6b3c4ce --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/RegionHandler/RegionHandler.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewChildControl.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewChildControl.cs new file mode 100644 index 0000000..25fd0cc --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewChildControl.cs @@ -0,0 +1,337 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace Alsing.Windows.Forms.CoreLib +{ + /// + /// Summary description for SplitViewChildControl. + /// + public class SplitViewChildControl : BaseControl + { + private Container components; + private Panel Filler; + protected HScrollBar hScroll; + public ThumbControl LeftThumb; + public ThumbControl TopThumb; + + protected VScrollBar vScroll; + + public SplitViewChildControl() + { + InitializeComponent(); + +// Alsing.Windows.NativeMethods.OpenThemeData (this.Handle,"EDIT"); +// Alsing.Windows.NativeMethods.OpenThemeData (this.vScroll.Handle,"SCROLLBAR"); +// Alsing.Windows.NativeMethods.OpenThemeData (this.hScroll.Handle,"SCROLLBAR"); + } + + + protected Rectangle ClientArea + { + get + { + Rectangle r = ClientRectangle; + r.Width -= vScroll.Width; + r.Height -= hScroll.Height; + return r; + } + } + + + /// + /// Gets or Sets if the Left side thumb control is visible or not. + /// + public bool LeftThumbVisible + { + get { return LeftThumb.Visible; } + set + { + LeftThumb.Visible = value; + DoResize(); + } + } + + /// + /// Getd ot Sets if the Top thumb control is visible or not. + /// + public bool TopThumbVisible + { + get { return TopThumb.Visible; } + set + { + TopThumb.Visible = value; + DoResize(); + } + } + + [Browsable(false)] + public int VisibleClientHeight + { + get + { + if (hScroll.Visible) + return ClientHeight - hScroll.Height; + else + return ClientHeight; + } + } + + [Browsable(false)] + public int VisibleClientWidth + { + get + { + if (hScroll.Visible) + return ClientWidth - vScroll.Width; + else + return ClientWidth; + } + } + + #region public property ScrollBars + + private ScrollBars _ScrollBars; + + + private bool HasThumbs; + + public ScrollBars ScrollBars + { + get { return _ScrollBars; } + + set + { + _ScrollBars = value; + if (ScrollBars == ScrollBars.Both) + { + hScroll.Visible = true; + vScroll.Visible = true; + } + if (ScrollBars == ScrollBars.None) + { + hScroll.Visible = false; + vScroll.Visible = false; + } + if (ScrollBars == ScrollBars.Horizontal) + { + hScroll.Visible = true; + vScroll.Visible = false; + } + if (ScrollBars == ScrollBars.Vertical) + { + hScroll.Visible = false; + vScroll.Visible = true; + } + Filler.Visible = hScroll.Visible & vScroll.Visible; + + if (vScroll.Visible && HasThumbs) + { + TopThumb.Height = 8; + } + else + { + TopThumb.Height = 0; + } + if (hScroll.Visible && HasThumbs) + { + LeftThumb.Width = 8; + } + else + { + LeftThumb.Width = 0; + } + + + DoResize(); + Refresh(); + } + } + + public void HideThumbs() + { + TopThumb.Height = 0; + LeftThumb.Width = 0; + HasThumbs = false; + DoResize(); + } + + public void ShowThumbs() + { + TopThumb.Height = 8; + LeftThumb.Width = 8; + HasThumbs = true; + DoResize(); + } + + #endregion + + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + DoResize(); + } + + private void DoResize() + { + try + { + if (TopThumb == null) + return; + + TopThumb.Width = SystemInformation.VerticalScrollBarWidth; + LeftThumb.Height = SystemInformation.HorizontalScrollBarHeight; + vScroll.Width = SystemInformation.VerticalScrollBarWidth; + hScroll.Height = SystemInformation.HorizontalScrollBarHeight; + + if (TopThumbVisible) + { + vScroll.Top = TopThumb.Height; + if (hScroll.Visible) + vScroll.Height = ClientHeight - hScroll.Height - TopThumb.Height; + else + vScroll.Height = ClientHeight - TopThumb.Height; + } + else + { + if (hScroll.Visible) + vScroll.Height = ClientHeight - hScroll.Height; + else + vScroll.Height = ClientHeight; + + vScroll.Top = 0; + } + + if (LeftThumbVisible) + { + hScroll.Left = LeftThumb.Width; + if (vScroll.Visible) + hScroll.Width = ClientWidth - vScroll.Width - LeftThumb.Width; + else + hScroll.Width = ClientWidth - LeftThumb.Width; + } + else + { + if (vScroll.Visible) + hScroll.Width = ClientWidth - vScroll.Width; + else + hScroll.Width = ClientWidth; + + hScroll.Left = 0; + } + + + vScroll.Left = ClientWidth - vScroll.Width; + hScroll.Top = ClientHeight - hScroll.Height; + + LeftThumb.Left = 0; + LeftThumb.Top = hScroll.Top; + + TopThumb.Left = vScroll.Left; + ; + TopThumb.Top = 0; + + + Filler.Left = vScroll.Left; + Filler.Top = hScroll.Top; + Filler.Width = vScroll.Width; + Filler.Height = hScroll.Height; + } + catch {} + } + + #region Component Designer generated code + + private void InitializeComponent() + { + var resources = new System.Resources.ResourceManager(typeof (SplitViewChildControl)); + this.hScroll = new System.Windows.Forms.HScrollBar(); + this.vScroll = new System.Windows.Forms.VScrollBar(); + this.Filler = new System.Windows.Forms.Panel(); + this.TopThumb = new Alsing.Windows.Forms.CoreLib.ThumbControl(); + this.LeftThumb = new Alsing.Windows.Forms.CoreLib.ThumbControl(); + + + this.SuspendLayout(); + // + // hScroll + // + this.hScroll.Location = new System.Drawing.Point(-4, 292); + this.hScroll.Name = "hScroll"; + this.hScroll.Size = new System.Drawing.Size(440, 16); + this.hScroll.TabIndex = 0; + + // + // vScroll + // + this.vScroll.Location = new System.Drawing.Point(440, 0); + this.vScroll.Maximum = 300; + this.vScroll.Minimum = 0; + this.vScroll.Name = "vScroll"; + this.vScroll.Size = new System.Drawing.Size(16, 360); + this.vScroll.TabIndex = 1; + // + // Filler + // + this.Filler.BackColor = System.Drawing.SystemColors.Control; + this.Filler.Location = new System.Drawing.Point(64, 260); + this.Filler.Name = "Filler"; + this.Filler.Size = new System.Drawing.Size(20, 20); + this.Filler.TabIndex = 3; + // + // TopThumb + // + this.TopThumb.BackColor = System.Drawing.SystemColors.Control; + this.TopThumb.Cursor = System.Windows.Forms.Cursors.HSplit; + this.TopThumb.Location = new System.Drawing.Point(101, 17); + this.TopThumb.Name = "TopThumb"; + this.TopThumb.Size = new System.Drawing.Size(16, 8); + this.TopThumb.TabIndex = 3; + this.TopThumb.Visible = false; + // + // LeftThumb + // + this.LeftThumb.BackColor = System.Drawing.SystemColors.Control; + this.LeftThumb.Cursor = System.Windows.Forms.Cursors.VSplit; + this.LeftThumb.Location = new System.Drawing.Point(423, 17); + this.LeftThumb.Name = "LeftThumb"; + this.LeftThumb.Size = new System.Drawing.Size(8, 16); + this.LeftThumb.TabIndex = 3; + this.LeftThumb.Visible = false; + + // + // SplitViewChildControl + // + this.Controls.AddRange(new System.Windows.Forms.Control[] + {this.TopThumb, this.LeftThumb, this.Filler, this.vScroll, this.hScroll}); + this.Name = "SplitViewChildControl"; + this.Size = new System.Drawing.Size(456, 376); + this.ResumeLayout(false); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewChildControl.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewChildControl.resx new file mode 100644 index 0000000..6b3c4ce --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewChildControl.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewControl.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewControl.cs new file mode 100644 index 0000000..6e717f3 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewControl.cs @@ -0,0 +1,706 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace Alsing.Windows.Forms.CoreLib +{ + /// + /// Summary description for SplitView. + /// + public class SplitViewControl : Control + { + private Control _LowerLeft; + private Control _LowerRight; + private Control _UpperLeft; + private Control _UpperRight; + + + private SizeAction Action = 0; + private Panel Center; + + /// + /// Required designer variable. + /// + private Container components; + + private bool FirstTime; + private Panel Horizontal; + private Point PrevPos = new Point(0); + + private Point StartPos = new Point(0, 0); + private Panel Vertical; + + /// + /// Default constructor for the splitview control + /// + public SplitViewControl() + { + // This call is required by the Windows.Forms Form Designer. + SetStyle(ControlStyles.ContainerControl, true); +// this.SetStyle(ControlStyles.AllPaintingInWmPaint ,false); +// this.SetStyle(ControlStyles.DoubleBuffer ,false); +// this.SetStyle(ControlStyles.Selectable,true); +// this.SetStyle(ControlStyles.ResizeRedraw ,true); +// this.SetStyle(ControlStyles.Opaque ,true); +// this.SetStyle(ControlStyles.UserPaint,true); + //SetStyle(ControlStyles.Selectable ,true); + + InitializeComponent(); + + + DoResize(); + ReSize(0, 0); + //this.Refresh (); + } + + /// + /// Gets or Sets the control that should be confined to the upper left view. + /// + public Control UpperLeft + { + get { return _UpperLeft; } + set + { + _UpperLeft = value; + DoResize(); + } + } + + /// + /// Gets or Sets the control that should be confined to the upper right view. + /// + public Control UpperRight + { + get { return _UpperRight; } + set + { + _UpperRight = value; + DoResize(); + } + } + + /// + /// Gets or Sets the control that should be confined to the lower left view. + /// + public Control LowerLeft + { + get { return _LowerLeft; } + set + { + _LowerLeft = value; + DoResize(); + } + } + + /// + /// Gets or Sets the control that should be confined to the lower right view. + /// + public Control LowerRight + { + get { return _LowerRight; } + set + { + _LowerRight = value; + DoResize(); + } + } + + public int SplitviewV + { + get { return Vertical.Left; } + set + { + Vertical.Left = value; + DoResize(); + } + } + + public int SplitviewH + { + get { return Horizontal.Top; } + set + { + Horizontal.Top = value; + DoResize(); + } + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.Vertical = new System.Windows.Forms.Panel(); + this.Horizontal = new System.Windows.Forms.Panel(); + this.Center = new System.Windows.Forms.Panel(); + this.SuspendLayout(); + // + // Vertical + // + this.Vertical.BackColor = System.Drawing.SystemColors.Control; + this.Vertical.Cursor = System.Windows.Forms.Cursors.VSplit; + this.Vertical.Name = "Vertical"; + this.Vertical.Size = new System.Drawing.Size(4, 264); + this.Vertical.TabIndex = 0; + this.Vertical.Resize += new System.EventHandler(this.Vertical_Resize); + this.Vertical.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Vertical_MouseUp); + this.Vertical.DoubleClick += new System.EventHandler(this.Vertical_DoubleClick); + this.Vertical.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Vertical_MouseMove); + this.Vertical.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Vertical_MouseDown); + // + // Horizontal + // + this.Horizontal.BackColor = System.Drawing.SystemColors.Control; + this.Horizontal.Cursor = System.Windows.Forms.Cursors.HSplit; + this.Horizontal.Name = "Horizontal"; + this.Horizontal.Size = new System.Drawing.Size(320, 4); + this.Horizontal.TabIndex = 1; + this.Horizontal.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Horizontal_MouseUp); + this.Horizontal.DoubleClick += new System.EventHandler(this.Horizontal_DoubleClick); + this.Horizontal.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Horizontal_MouseMove); + this.Horizontal.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Horizontal_MouseDown); + // + // Center + // + this.Center.BackColor = System.Drawing.SystemColors.Control; + this.Center.Cursor = System.Windows.Forms.Cursors.SizeAll; + this.Center.Location = new System.Drawing.Point(146, 69); + this.Center.Name = "Center"; + this.Center.Size = new System.Drawing.Size(24, 24); + this.Center.TabIndex = 2; + this.Center.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Center_MouseUp); + this.Center.DoubleClick += new System.EventHandler(this.Center_DoubleClick); + this.Center.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Center_MouseMove); + this.Center.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Center_MouseDown); + // + // SplitViewControl + // + this.BackColor = System.Drawing.Color.Magenta; + this.Controls.AddRange(new System.Windows.Forms.Control[] {this.Center, this.Horizontal, this.Vertical}); + this.Size = new System.Drawing.Size(200, 200); + this.VisibleChanged += new System.EventHandler(this.SplitViewControl_VisibleChanged); + this.Enter += new System.EventHandler(this.SplitViewControl_Enter); + this.Leave += new System.EventHandler(this.SplitViewControl_Leave); + this.ResumeLayout(false); + } + + #endregion + + /// + /// an event fired when the split view is resized. + /// + public event EventHandler Resizing = null; + + /// + /// an event fired when the top views are hidden. + /// + public event EventHandler HideTop = null; + + /// + /// an event fired when the left views are hidden. + /// + public event EventHandler HideLeft = null; + + private void OnResizing() + { + if (Resizing != null) + Resizing(this, new EventArgs()); + } + + private void OnHideLeft() + { + if (HideLeft != null) + HideLeft(this, new EventArgs()); + } + + private void OnHideTop() + { + if (HideTop != null) + HideTop(this, new EventArgs()); + } + +// protected override void OnLoad(EventArgs e) +// { +// +// } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { +#if DEBUG + try + { + Console.WriteLine("disposing splitview"); + } + catch {} +#endif + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + /// + /// + /// + /// + protected override void OnResize(EventArgs e) + { + DoResize(); + } + + private void DoResize() + { + // int OldWidth=Horizontal.Width ; + // int OldHeight=Vertical.Height; + int NewHeight = Height; + int NewWidth = Width; + + if (NewHeight != 0 && NewWidth != 0) + { + SuspendLayout(); + // Horizontal.Top = (int)(NewHeight*HorizontalPos); + // Vertical.Left =(int)(NewWidth*VerticalPos); + // + // int CenterY=(Horizontal.Top+Horizontal.Height /2)-Center.Height/2; + // int CenterX=(Vertical.Left+Vertical.Width /2)-Center.Width /2; + // + // Center.Location =new Point (CenterX,CenterY); + + + //ReSize (0,0); + ReSize2(); + OnResizing(); + + if (Horizontal.Top < 15) + { + Horizontal.Top = 0 - Horizontal.Height; + OnHideTop(); + } + + if (Vertical.Left < 15) + { + Vertical.Left = 0 - Vertical.Width; + OnHideLeft(); + } + + + Horizontal.Width = Width; + Vertical.Height = Height; + Horizontal.SendToBack(); + Vertical.SendToBack(); + Horizontal.BackColor = SystemColors.Control; + Vertical.BackColor = SystemColors.Control; + + + //this.SendToBack (); + int RightLeft = Vertical.Left + Vertical.Width; + int RightLowerTop = Horizontal.Top + Horizontal.Height; + int RightWidth = Width - RightLeft; + int LowerHeight = Height - RightLowerTop; + int UpperHeight = Horizontal.Top; + int LeftWidth = Vertical.Left; + + if (LowerRight != null) + { + LowerRight.BringToFront(); + LowerRight.SetBounds(RightLeft, RightLowerTop, RightWidth, LowerHeight); + } + if (UpperRight != null) + { + UpperRight.BringToFront(); + UpperRight.SetBounds(RightLeft, 0, RightWidth, UpperHeight); + } + + + if (LowerLeft != null) + { + LowerLeft.BringToFront(); + LowerLeft.SetBounds(0, RightLowerTop, LeftWidth, LowerHeight); + } + if (UpperLeft != null) + { + UpperLeft.BringToFront(); + UpperLeft.SetBounds(0, 0, LeftWidth, UpperHeight); + } + ResumeLayout(); //ggf + } + } + + + /// + /// + /// + /// + protected override void OnControlAdded(ControlEventArgs e) + { + DoResize(); + } + + + private void Vertical_Resize(object sender, EventArgs e) {} + + private void Horizontal_MouseDown(object sender, MouseEventArgs e) + { + Action = SizeAction.SizeH; + StartPos = new Point(e.X, e.Y); + Horizontal.BringToFront(); + Horizontal.BackColor = SystemColors.ControlDark; + FirstTime = true; + } + + private void Vertical_MouseDown(object sender, MouseEventArgs e) + { + Action = SizeAction.SizeV; + StartPos = new Point(e.X, e.Y); + Vertical.BringToFront(); + Vertical.BackColor = SystemColors.ControlDark; + FirstTime = true; + } + + private void Center_MouseDown(object sender, MouseEventArgs e) + { + Action = SizeAction.SizeA; + StartPos = new Point(e.X, e.Y); + Vertical.BringToFront(); + Horizontal.BringToFront(); + Vertical.BackColor = SystemColors.ControlDark; + Horizontal.BackColor = SystemColors.ControlDark; + FirstTime = true; + } + + private void Horizontal_MouseUp(object sender, MouseEventArgs e) + { + int xDiff = 0; + int yDiff = StartPos.Y - e.Y; + // StartPos=new Point (e.X,e.Y); + ReSize(xDiff, yDiff); + + Action = SizeAction.None; + DoResize(); + } + + private void Vertical_MouseUp(object sender, MouseEventArgs e) + { + int xDiff = StartPos.X - e.X; + int yDiff = 0; + // StartPos=new Point (e.X,e.Y); + ReSize(xDiff, yDiff); + + Action = SizeAction.None; + DoResize(); + Refresh(); + } + + private void Center_MouseUp(object sender, MouseEventArgs e) + { + int xDiff = StartPos.X - e.X; + int yDiff = StartPos.Y - e.Y; + // StartPos=new Point (e.X,e.Y); + ReSize(xDiff, yDiff); + + Action = SizeAction.None; + DoResize(); + } + + private void Horizontal_MouseMove(object sender, MouseEventArgs e) + { + if (Action == SizeAction.SizeH && e.Button == MouseButtons.Left) + { + Point start; + int x = e.X; + int y = e.Y; + + + if (y + Horizontal.Top > Height - 4) + y = Height - 4 - Horizontal.Top; + if (y + Horizontal.Top < 0) + y = 0 - Horizontal.Top; + + if (!FirstTime) + { + start = PointToScreen(Location); + start.Y += PrevPos.Y + Horizontal.Location.Y; + ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, Width, 3), Color.Black); + } + else + FirstTime = false; + + start = PointToScreen(Location); + start.Y += y + Horizontal.Location.Y; + ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, Width, 3), Color.Black); + + PrevPos = new Point(x, y); + } + } + + private void Vertical_MouseMove(object sender, MouseEventArgs e) + { + if (Action == SizeAction.SizeV && e.Button == MouseButtons.Left) + { + Point start; + int x = e.X; + int y = e.Y; + + if (x + Vertical.Left > Width - 4) + x = Width - 4 - Vertical.Left; + if (x + Vertical.Left < 0) + x = 0 - Vertical.Left; + + + if (!FirstTime) + { + start = PointToScreen(Location); + start.X += PrevPos.X + Vertical.Location.X; + ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, 3, Height), Color.Black); + } + else + FirstTime = false; + + start = PointToScreen(Location); + start.X += x + Vertical.Location.X; + ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, 3, Height), Color.Black); + + PrevPos = new Point(x, y); + } + } + + private void Center_MouseMove(object sender, MouseEventArgs e) + { + if (Action == SizeAction.SizeA && e.Button == MouseButtons.Left) + { + Point start; + int x = e.X - Center.Width/2; + int y = e.Y - Center.Height/2; + + // ROB: Added fix for graphics splatter when sizing both splitters. + if (y + Horizontal.Top > Height - 4) + y = Height - 4 - Horizontal.Top; + if (y + Horizontal.Top < 0) + y = 0 - Horizontal.Top; + + if (x + Vertical.Left > Width - 4) + x = Width - 4 - Vertical.Left; + if (x + Vertical.Left < 0) + x = 0 - Vertical.Left; + // END-ROB + + + if (!FirstTime) + { + start = PointToScreen(Location); + start.X += PrevPos.X + Vertical.Location.X; + ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, 3, Height), Color.Black); + + start = PointToScreen(Location); + start.Y += PrevPos.Y + Horizontal.Location.Y; + ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, Width, 3), + SystemColors.ControlDark); + } + else + FirstTime = false; + + start = PointToScreen(Location); + start.X += x + Vertical.Location.X; + ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, 3, Height), Color.Black); + + start = PointToScreen(Location); + start.Y += y + Horizontal.Location.Y; + ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, Width, 3), SystemColors.ControlDark); + + + PrevPos = new Point(x, y); + } + } + + + private void ReSize(int x, int y) + { + //if (x==0 && y==0) + // return; + + + SuspendLayout(); + + int xx = Vertical.Left - x; + int yy = Horizontal.Top - y; + + if (xx < 0) + xx = 0; + + if (yy < 0) + yy = 0; + + if (yy > Height - Horizontal.Height - SystemInformation.VerticalScrollBarWidth*3) + yy = Height - Horizontal.Height - SystemInformation.VerticalScrollBarWidth*3; + + + if (xx > Width - Vertical.Width - SystemInformation.VerticalScrollBarWidth*3) + xx = Width - Vertical.Width - SystemInformation.VerticalScrollBarWidth*3; + + if (xx != Vertical.Left) + Vertical.Left = xx; + + if (yy != Horizontal.Top) + Horizontal.Top = yy; + + + int CenterY = (Horizontal.Top + Horizontal.Height/2) - Center.Height/2; + int CenterX = (Vertical.Left + Vertical.Width/2) - Center.Width/2; + + Center.Location = new Point(CenterX, CenterY); + ResumeLayout(); + Invalidate(); + + try + { + if (UpperLeft != null) + UpperLeft.Refresh(); + if (UpperLeft != null) + UpperLeft.Refresh(); + if (UpperLeft != null) + UpperLeft.Refresh(); + if (UpperLeft != null) + UpperLeft.Refresh(); + } + catch {} + OnResizing(); + //DoResize(); + //this.Refresh (); + } + + private void ReSize2() + { + int xx = Vertical.Left; + int yy = Horizontal.Top; + + if (xx < 0) + xx = 0; + + if (yy < 0) + yy = 0; + + if (yy > Height - Horizontal.Height - SystemInformation.VerticalScrollBarWidth*3) + { + yy = Height - Horizontal.Height - SystemInformation.VerticalScrollBarWidth*3; + if (yy != Horizontal.Top) + Horizontal.Top = yy; + } + + + if (xx > Width - Vertical.Width - SystemInformation.VerticalScrollBarWidth*3) + { + xx = Width - Vertical.Width - SystemInformation.VerticalScrollBarWidth*3; + if (xx != Vertical.Left) + Vertical.Left = xx; + } + + int CenterY = (Horizontal.Top + Horizontal.Height/2) - Center.Height/2; + int CenterX = (Vertical.Left + Vertical.Width/2) - Center.Width/2; + + Center.Location = new Point(CenterX, CenterY); + } + + private void Center_DoubleClick(object sender, EventArgs e) + { + Horizontal.Top = -100; + Vertical.Left = -100; + DoResize(); + } + + private void Vertical_DoubleClick(object sender, EventArgs e) + { + Vertical.Left = -100; + DoResize(); + } + + private void Horizontal_DoubleClick(object sender, EventArgs e) + { + Horizontal.Top = -100; + DoResize(); + } + + /// + /// Splits the view horiziontally. + /// + public void Split5050h() + { + Horizontal.Top = Height/2; + DoResize(); + } + + /// + /// Splits teh view vertically. + /// + public void Split5050v() + { + Vertical.Left = Width/2; + DoResize(); + } + + + public void ResetSplitview() + { + Vertical.Left = 0; + Horizontal.Top = 0; + DoResize(); + } + + /// + /// Start dragging the horizontal splitter. + /// + public void InvokeMouseDownh() + { + IntPtr hwnd = Horizontal.Handle; + NativeMethods.SendMessage(hwnd, (int) WindowMessage.WM_LBUTTONDOWN, 0, 0); + } + + /// + /// Start dragging the vertical splitter. + /// + public void InvokeMouseDownv() + { + IntPtr hwnd = Vertical.Handle; + NativeMethods.SendMessage(hwnd, (int) WindowMessage.WM_LBUTTONDOWN, 0, 0); + } + + private void SplitViewControl_Leave(object sender, EventArgs e) {} + + private void SplitViewControl_Enter(object sender, EventArgs e) {} + + + private void SplitViewControl_VisibleChanged(object sender, EventArgs e) {} + + #region Nested type: SizeAction + + private enum SizeAction + { + None = 0, + SizeH = 1, + SizeV = 2, + SizeA = 3 + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewControl.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewControl.resx new file mode 100644 index 0000000..4b64ee1 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewControl.resx @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 0, 0 + + + 0, 0 + + + 146, 69 + + + False + + + SplitViewControl + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewParentControl.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewParentControl.cs new file mode 100644 index 0000000..7b0fa9a --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewParentControl.cs @@ -0,0 +1,433 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace Alsing.Windows.Forms.CoreLib +{ + public class SplitViewParentControl : BaseControl + { + protected SplitViewChildControl _ActiveView; + private long _ticks; //splitter doubleclick timer + public bool DisableScrollBars; + protected bool DoOnce; + protected SplitViewChildControl LowerLeft; + protected SplitViewChildControl LowerRight; + protected SplitViewControl splitView; + protected SplitViewChildControl UpperLeft; + protected SplitViewChildControl UpperRight; + + #region Private Properties + + private List _Views; + + protected List Views + { + get { return _Views; } + set { _Views = value; } + } + + #endregion + + public SplitViewParentControl() + { + OnCreate(); + + InitializeComponent(); + InitializeComponentInternal(); + splitView.Resizing += SplitView_Resizing; + splitView.HideLeft += SplitView_HideLeft; + splitView.HideTop += SplitView_HideTop; + + + LowerRight = GetNewView(); + LowerRight.AllowDrop = true; + LowerRight.BorderColor = Color.White; + LowerRight.BorderStyle = BorderStyle.None; + LowerRight.Location = new Point(0, 0); + LowerRight.Size = new Size(100, 100); + + Views = new List(); + LowerRight.TopThumb.MouseDown += TopThumb_MouseDown; + LowerRight.LeftThumb.MouseDown += LeftThumb_MouseDown; + Views.Add(LowerRight); + LowerRight.TopThumbVisible = true; + LowerRight.LeftThumbVisible = true; + splitView.Controls.Add(LowerRight); + splitView.LowerRight = LowerRight; + + SplitView = true; + ScrollBars = ScrollBars.Both; + BorderStyle = BorderStyle.None; + ChildBorderColor = SystemColors.ControlDark; + ChildBorderStyle = BorderStyle.FixedSingle; + BackColor = SystemColors.Window; + Size = new Size(100, 100); + _ActiveView = LowerRight; + } + + /// + /// Gets or Sets the active view + /// + [Browsable(false)] + public ActiveView ActiveView + { + get + { + if (_ActiveView == UpperLeft) + return ActiveView.TopLeft; + + if (_ActiveView == UpperRight) + return ActiveView.TopRight; + + if (_ActiveView == LowerLeft) + return ActiveView.BottomLeft; + + if (_ActiveView == LowerRight) + return ActiveView.BottomRight; + + return 0; + } + set + { + if (value != ActiveView.BottomRight) + { + ActivateSplits(); + } + + + if (value == ActiveView.TopLeft) + _ActiveView = UpperLeft; + + if (value == ActiveView.TopRight) + _ActiveView = UpperRight; + + if (value == ActiveView.BottomLeft) + _ActiveView = LowerLeft; + + if (value == ActiveView.BottomRight) + _ActiveView = LowerRight; + } + } + + private void InitializeComponent() {} + + /// + /// Resets the Splitview. + /// + public void ResetSplitview() + { + splitView.ResetSplitview(); + } + + private void SplitView_Resizing(object sender, EventArgs e) + { + LowerRight.TopThumbVisible = false; + LowerRight.LeftThumbVisible = false; + } + + private void SplitView_HideTop(object sender, EventArgs e) + { + LowerRight.TopThumbVisible = true; + } + + private void SplitView_HideLeft(object sender, EventArgs e) + { + LowerRight.LeftThumbVisible = true; + } + + protected virtual void ActivateSplits() + { + if (UpperLeft == null) + { + UpperLeft = GetNewView(); + UpperRight = GetNewView(); + LowerLeft = GetNewView(); + + splitView.Controls.AddRange(new Control[] {UpperLeft, LowerLeft, UpperRight}); + + splitView.UpperRight = LowerLeft; + splitView.UpperLeft = UpperLeft; + splitView.LowerLeft = UpperRight; + + CreateViews(); + } + } + + + protected void TopThumb_MouseDown(object sender, MouseEventArgs e) + { + ActivateSplits(); + + long t = DateTime.Now.Ticks - _ticks; + _ticks = DateTime.Now.Ticks; + + + if (t < 3000000) + { + splitView.Split5050h(); + } + else + { + splitView.InvokeMouseDownh(); + } + } + + protected void LeftThumb_MouseDown(object sender, MouseEventArgs e) + { + ActivateSplits(); + + long t = DateTime.Now.Ticks - _ticks; + _ticks = DateTime.Now.Ticks; + + + if (t < 3000000) + { + splitView.Split5050v(); + } + else + { + splitView.InvokeMouseDownv(); + } + } + + protected virtual void OnCreate() {} + + protected virtual void CreateViews() + { + if (UpperRight != null) + { + Views.Add(UpperRight); + Views.Add(UpperLeft); + Views.Add(LowerLeft); + } + } + + protected virtual SplitViewChildControl GetNewView() + { + return null; + } + + protected void View_Enter(object sender, EventArgs e) + { + _ActiveView = (SplitViewChildControl) sender; + } + + protected void View_Leave(object sender, EventArgs e) + { + // ((EditViewControl)sender).RemoveFocus (); + } + + protected override void WndProc(ref Message m) + { + base.WndProc(ref m); + if (m.Msg == (int) WindowMessage.WM_SETFOCUS) + { + if (_ActiveView != null) + _ActiveView.Focus(); + } + } + + #region PUBLIC PROPERTY SPLITVIEWV + + [Browsable(false)] + public int SplitviewV + { + get { return splitView.SplitviewV; } + set + { + if (splitView == null) + return; + + splitView.SplitviewV = value; + } + } + + #endregion + + #region PUBLIC PROPERTY SPLITVIEWH + + [Browsable(false)] + public int SplitviewH + { + get { return splitView.SplitviewH; } + set + { + if (splitView == null) + return; + splitView.SplitviewH = value; + } + } + + #endregion + + #region public property ScrollBars + + private ScrollBars _ScrollBars; + + [Category("Appearance"), Description("Determines what Scrollbars should be visible")] + [DefaultValue(ScrollBars.Both)] + public ScrollBars ScrollBars + { + get { return _ScrollBars; } + + set + { + if (_Views == null) + return; + + if (DisableScrollBars) + value = ScrollBars.None; + + foreach (SplitViewChildControl evc in _Views) + { + evc.ScrollBars = value; + } + _ScrollBars = value; + } + } + + #endregion + + #region public property SplitView + + //member variable + private bool _SplitView; + + [Category("Appearance"), Description("Determines if the controls should use splitviews")] + [DefaultValue(true)] + public bool SplitView + { + get { return _SplitView; } + + set + { + _SplitView = value; + + if (splitView == null) + return; + + if (!SplitView) + { + splitView.Visible = false; + Controls.Add(LowerRight); + LowerRight.HideThumbs(); + LowerRight.Dock = DockStyle.Fill; + } + else + { + splitView.Visible = true; + splitView.LowerRight = LowerRight; + LowerRight.Dock = DockStyle.None; + LowerRight.ShowThumbs(); + } + } + } + + #endregion //END PROPERTY SplitView + + #region PUBLIC PROPERTY CHILDBODERSTYLE + + /// + /// Gets or Sets the border styles of the split views. + /// + [Category("Appearance - Borders")] + [Description("Gets or Sets the border styles of the split views.")] + [DefaultValue(BorderStyle.FixedSingle)] + public BorderStyle ChildBorderStyle + { + get { return (Views[0]).BorderStyle; } + set + { + foreach (SplitViewChildControl ev in Views) + { + ev.BorderStyle = value; + } + } + } + + #endregion + + #region PUBLIC PROPERTY CHILDBORDERCOLOR + + /// + /// Gets or Sets the border color of the split views. + /// + [Category("Appearance - Borders")] + [Description("Gets or Sets the border color of the split views.")] + [DefaultValue(typeof (Color), "ControlDark")] + public Color ChildBorderColor + { + get { return (Views[0]).BorderColor; } + set + { + foreach (SplitViewChildControl ev in Views) + { + if (ev != null) + { + ev.BorderColor = value; + } + } + } + } + + #endregion + + #region roger generated code + + private void InitializeComponentInternal() + { + splitView = new SplitViewControl(); + SuspendLayout(); + // + // splitView + // + splitView.BackColor = Color.Empty; + splitView.Dock = DockStyle.Fill; + splitView.LowerLeft = null; + splitView.LowerRight = null; + splitView.Name = "splitView"; + splitView.Size = new Size(248, 216); + splitView.SplitviewH = -4; + splitView.SplitviewV = -4; + splitView.TabIndex = 0; + splitView.Text = "splitView"; + splitView.UpperLeft = null; + splitView.UpperRight = null; + // + // SplitViewParentControl + // + Controls.AddRange(new Control[] {splitView}); + Name = "SplitViewParentControl"; + Size = new Size(248, 216); + ResumeLayout(false); + } + + #endregion + } +} + +namespace Alsing.Windows.Forms +{ + /// + /// Represents which split view is currently active in the syntaxbox + /// + public enum ActiveView + { + TopLeft, + TopRight, + BottomLeft, + BottomRight, + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewParentControl.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewParentControl.resx new file mode 100644 index 0000000..23aca98 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/SplitView/SplitViewParentControl.resx @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + SplitViewParentControl + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/FindReplace.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/FindReplace.cs new file mode 100644 index 0000000..b0b71ca --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/FindReplace.cs @@ -0,0 +1,565 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Windows.Forms; + +namespace Alsing.Windows.Forms.SyntaxBox +{ + /// + /// Summary description for FindReplace. + /// + public class FindReplaceForm : Form + { + private WeakReference _Control; + private string _Last = ""; + private Button btnClose; + private Button btnDoReplace; + private Button btnFind; + private Button btnMarkAll; + private Button btnRegex1; + private Button btnReplace; + private Button btnReplaceAll; + private Button button1; + private ComboBox cboFind; + private ComboBox cboReplace; + private CheckBox chkMatchCase; + private CheckBox chkRegEx; + private CheckBox chkWholeWord; + + /// + /// Required designer variable. + /// + private Container components; + + private GroupBox groupBox1; + private Label label1; + private Label label2; + private Panel panel1; + private Panel panel3; + private Panel pnlButtons; + private Panel pnlFind; + private Panel pnlReplace; + private Panel pnlReplaceButtons; + private Panel pnlSettings; + + /// + /// Default constructor for the FindReplaceForm. + /// + public FindReplaceForm() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + } + + /// + /// Creates a FindReplaceForm that will be assigned to a specific Owner control. + /// + /// The SyntaxBox that will use the FindReplaceForm + public FindReplaceForm(EditViewControl Owner) + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + + mOwner = Owner; + } + + private EditViewControl mOwner + { + get + { + if (_Control != null) + return (EditViewControl) _Control.Target; + else + return null; + } + set { _Control = new WeakReference(value); } + } + + protected override CreateParams CreateParams + { + get + { + CreateParams cp = base.CreateParams; + // unchecked + // { + // int i= (int)0x80000000; + // cp.Style |=i; + // } + return cp; + } + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + /// + /// Displays the FindReplaceForm and sets it in "Find" mode. + /// + public void ShowFind() + { + pnlReplace.Visible = false; + pnlReplaceButtons.Visible = false; + Text = "Find"; + Show(); + Height = 160; + btnDoReplace.Visible = false; + btnReplace.Visible = true; + _Last = ""; + cboFind.Focus(); + } + + /// + /// Displays the FindReplaceForm and sets it in "Replace" mode. + /// + public void ShowReplace() + { + pnlReplace.Visible = true; + pnlReplaceButtons.Visible = true; + Text = "Replace"; + Show(); + Height = 200; + btnDoReplace.Visible = true; + btnReplace.Visible = false; + _Last = ""; + cboFind.Focus(); + } + + private void btnReplace_Click(object sender, EventArgs e) + { + ShowReplace(); + } + + private void FindReplace_Closing(object sender, CancelEventArgs e) + { + e.Cancel = true; + Hide(); + } + + private void btnFind_Click(object sender, EventArgs e) + { + FindNext(); + cboFind.Focus(); + } + + private void btnClose_Click(object sender, EventArgs e) + { + mOwner.Focus(); + Hide(); + } + + private void btnDoReplace_Click(object sender, EventArgs e) + { + mOwner.ReplaceSelection(cboReplace.Text); + btnFind_Click(null, null); + } + + private void btnReplaceAll_Click(object sender, EventArgs e) + { + string text = cboFind.Text; + if (text == "") + return; + + bool found = false; + foreach (string s in cboFind.Items) + { + if (s == text) + { + found = true; + break; + } + } + if (!found) + cboFind.Items.Add(text); + + int x = mOwner.Caret.Position.X; + int y = mOwner.Caret.Position.Y; + mOwner.Caret.Position.X = 0; + mOwner.Caret.Position.Y = 0; + while (mOwner.SelectNext(cboFind.Text, chkMatchCase.Checked, chkWholeWord.Checked, chkRegEx.Checked)) + { + mOwner.ReplaceSelection(cboReplace.Text); + } + + mOwner.Selection.ClearSelection(); + // mOwner.Caret.Position.X=x; + // mOwner.Caret.Position.Y=y; + // mOwner.ScrollIntoView (); + + cboFind.Focus(); + } + + private void btnMarkAll_Click(object sender, EventArgs e) + { + string text = cboFind.Text; + if (text == "") + return; + + bool found = false; + foreach (string s in cboFind.Items) + { + if (s == text) + { + found = true; + break; + } + } + if (!found) + cboFind.Items.Add(text); + + int x = mOwner.Caret.Position.X; + int y = mOwner.Caret.Position.Y; + mOwner.Caret.Position.X = 0; + mOwner.Caret.Position.Y = 0; + while (mOwner.SelectNext(cboFind.Text, chkMatchCase.Checked, chkWholeWord.Checked, chkRegEx.Checked)) + { + mOwner.Caret.CurrentRow.Bookmarked = true; + } + + mOwner.Selection.ClearSelection(); + // mOwner.Caret.Position.X=x; + // mOwner.Caret.Position.Y=y; + // mOwner.ScrollIntoView (); + + cboFind.Focus(); + } + + public void FindNext() + { + string text = cboFind.Text; + + if (_Last != "" && _Last != text) + { + mOwner.Caret.Position.X = 0; + mOwner.Caret.Position.Y = 0; + mOwner.ScrollIntoView(); + } + + _Last = text; + + if (text == "") + return; + + bool found = false; + foreach (string s in cboFind.Items) + { + if (s == text) + { + found = true; + break; + } + } + if (!found) + cboFind.Items.Add(text); + + mOwner.SelectNext(cboFind.Text, chkMatchCase.Checked, chkWholeWord.Checked, chkRegEx.Checked); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + var resources = new System.Resources.ResourceManager(typeof (FindReplaceForm)); + this.pnlButtons = new System.Windows.Forms.Panel(); + this.panel3 = new System.Windows.Forms.Panel(); + this.btnClose = new System.Windows.Forms.Button(); + this.btnMarkAll = new System.Windows.Forms.Button(); + this.pnlReplaceButtons = new System.Windows.Forms.Panel(); + this.btnReplaceAll = new System.Windows.Forms.Button(); + this.panel1 = new System.Windows.Forms.Panel(); + this.btnDoReplace = new System.Windows.Forms.Button(); + this.btnReplace = new System.Windows.Forms.Button(); + this.btnFind = new System.Windows.Forms.Button(); + this.pnlFind = new System.Windows.Forms.Panel(); + this.cboFind = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.btnRegex1 = new System.Windows.Forms.Button(); + this.pnlReplace = new System.Windows.Forms.Panel(); + this.cboReplace = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.pnlSettings = new System.Windows.Forms.Panel(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.chkRegEx = new System.Windows.Forms.CheckBox(); + this.chkWholeWord = new System.Windows.Forms.CheckBox(); + this.chkMatchCase = new System.Windows.Forms.CheckBox(); + this.pnlButtons.SuspendLayout(); + this.panel3.SuspendLayout(); + this.pnlReplaceButtons.SuspendLayout(); + this.panel1.SuspendLayout(); + this.pnlFind.SuspendLayout(); + this.pnlReplace.SuspendLayout(); + this.pnlSettings.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // pnlButtons + // + this.pnlButtons.Controls.AddRange(new System.Windows.Forms.Control[] + {this.panel3, this.pnlReplaceButtons, this.panel1}); + this.pnlButtons.Dock = System.Windows.Forms.DockStyle.Right; + this.pnlButtons.Location = new System.Drawing.Point(400, 0); + this.pnlButtons.Name = "pnlButtons"; + this.pnlButtons.Size = new System.Drawing.Size(96, 178); + this.pnlButtons.TabIndex = 0; + // + // panel3 + // + this.panel3.Controls.AddRange(new System.Windows.Forms.Control[] {this.btnClose, this.btnMarkAll}); + this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel3.Location = new System.Drawing.Point(0, 96); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(96, 82); + this.panel3.TabIndex = 4; + // + // btnClose + // + this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnClose.Location = new System.Drawing.Point(8, 40); + this.btnClose.Name = "btnClose"; + this.btnClose.Size = new System.Drawing.Size(80, 24); + this.btnClose.TabIndex = 3; + this.btnClose.Text = "Close"; + this.btnClose.Click += new System.EventHandler(this.btnClose_Click); + // + // btnMarkAll + // + this.btnMarkAll.Location = new System.Drawing.Point(8, 8); + this.btnMarkAll.Name = "btnMarkAll"; + this.btnMarkAll.Size = new System.Drawing.Size(80, 24); + this.btnMarkAll.TabIndex = 2; + this.btnMarkAll.Text = "Mark all"; + this.btnMarkAll.Click += new System.EventHandler(this.btnMarkAll_Click); + // + // pnlReplaceButtons + // + this.pnlReplaceButtons.Controls.AddRange(new System.Windows.Forms.Control[] {this.btnReplaceAll}); + this.pnlReplaceButtons.Dock = System.Windows.Forms.DockStyle.Top; + this.pnlReplaceButtons.Location = new System.Drawing.Point(0, 64); + this.pnlReplaceButtons.Name = "pnlReplaceButtons"; + this.pnlReplaceButtons.Size = new System.Drawing.Size(96, 32); + this.pnlReplaceButtons.TabIndex = 3; + this.pnlReplaceButtons.Visible = false; + // + // btnReplaceAll + // + this.btnReplaceAll.Location = new System.Drawing.Point(8, 8); + this.btnReplaceAll.Name = "btnReplaceAll"; + this.btnReplaceAll.Size = new System.Drawing.Size(80, 24); + this.btnReplaceAll.TabIndex = 2; + this.btnReplaceAll.Text = "Replace All"; + this.btnReplaceAll.Click += new System.EventHandler(this.btnReplaceAll_Click); + // + // panel1 + // + this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] + {this.btnDoReplace, this.btnReplace, this.btnFind}); + this.panel1.Dock = System.Windows.Forms.DockStyle.Top; + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(96, 64); + this.panel1.TabIndex = 2; + // + // btnDoReplace + // + this.btnDoReplace.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnDoReplace.Location = new System.Drawing.Point(8, 40); + this.btnDoReplace.Name = "btnDoReplace"; + this.btnDoReplace.Size = new System.Drawing.Size(80, 24); + this.btnDoReplace.TabIndex = 4; + this.btnDoReplace.Text = "Replace"; + this.btnDoReplace.Click += new System.EventHandler(this.btnDoReplace_Click); + // + // btnReplace + // + this.btnReplace.Image = ((System.Drawing.Bitmap) (resources.GetObject("btnReplace.Image"))); + this.btnReplace.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; + this.btnReplace.Location = new System.Drawing.Point(8, 40); + this.btnReplace.Name = "btnReplace"; + this.btnReplace.Size = new System.Drawing.Size(80, 24); + this.btnReplace.TabIndex = 3; + this.btnReplace.Text = "Replace"; + this.btnReplace.Click += new System.EventHandler(this.btnReplace_Click); + // + // btnFind + // + this.btnFind.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnFind.Location = new System.Drawing.Point(8, 8); + this.btnFind.Name = "btnFind"; + this.btnFind.Size = new System.Drawing.Size(80, 24); + this.btnFind.TabIndex = 2; + this.btnFind.Text = "&FindNext"; + this.btnFind.Click += new System.EventHandler(this.btnFind_Click); + // + // pnlFind + // + this.pnlFind.Controls.AddRange(new System.Windows.Forms.Control[] + {this.cboFind, this.label1, this.btnRegex1}); + this.pnlFind.Dock = System.Windows.Forms.DockStyle.Top; + this.pnlFind.Name = "pnlFind"; + this.pnlFind.Size = new System.Drawing.Size(400, 40); + this.pnlFind.TabIndex = 1; + // + // cboFind + // + this.cboFind.Location = new System.Drawing.Point(104, 8); + this.cboFind.Name = "cboFind"; + this.cboFind.Size = new System.Drawing.Size(288, 21); + this.cboFind.TabIndex = 1; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(8, 8); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(96, 24); + this.label1.TabIndex = 0; + this.label1.Text = "Fi&nd what:"; + // + // btnRegex1 + // + this.btnRegex1.Image = ((System.Drawing.Bitmap) (resources.GetObject("btnRegex1.Image"))); + this.btnRegex1.Location = new System.Drawing.Point(368, 8); + this.btnRegex1.Name = "btnRegex1"; + this.btnRegex1.Size = new System.Drawing.Size(21, 21); + this.btnRegex1.TabIndex = 2; + this.btnRegex1.Visible = false; + // + // pnlReplace + // + this.pnlReplace.Controls.AddRange(new System.Windows.Forms.Control[] + {this.cboReplace, this.label2, this.button1}); + this.pnlReplace.Dock = System.Windows.Forms.DockStyle.Top; + this.pnlReplace.Location = new System.Drawing.Point(0, 40); + this.pnlReplace.Name = "pnlReplace"; + this.pnlReplace.Size = new System.Drawing.Size(400, 40); + this.pnlReplace.TabIndex = 2; + this.pnlReplace.Visible = false; + // + // cboReplace + // + this.cboReplace.Location = new System.Drawing.Point(106, 8); + this.cboReplace.Name = "cboReplace"; + this.cboReplace.Size = new System.Drawing.Size(286, 21); + this.cboReplace.TabIndex = 4; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(10, 8); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(96, 24); + this.label2.TabIndex = 3; + this.label2.Text = "Re&place with:"; + // + // button1 + // + this.button1.Image = ((System.Drawing.Bitmap) (resources.GetObject("button1.Image"))); + this.button1.Location = new System.Drawing.Point(368, 8); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(21, 21); + this.button1.TabIndex = 5; + this.button1.Visible = false; + // + // pnlSettings + // + this.pnlSettings.Controls.AddRange(new System.Windows.Forms.Control[] {this.groupBox1}); + this.pnlSettings.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlSettings.Location = new System.Drawing.Point(0, 80); + this.pnlSettings.Name = "pnlSettings"; + this.pnlSettings.Size = new System.Drawing.Size(400, 98); + this.pnlSettings.TabIndex = 3; + // + // groupBox1 + // + this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] + {this.chkRegEx, this.chkWholeWord, this.chkMatchCase}); + this.groupBox1.Location = new System.Drawing.Point(8, 0); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(384, 88); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Search"; + // + // chkRegEx + // + this.chkRegEx.Location = new System.Drawing.Point(8, 64); + this.chkRegEx.Name = "chkRegEx"; + this.chkRegEx.Size = new System.Drawing.Size(144, 16); + this.chkRegEx.TabIndex = 2; + this.chkRegEx.Text = "Use Regular expressions"; + this.chkRegEx.Visible = false; + // + // chkWholeWord + // + this.chkWholeWord.Location = new System.Drawing.Point(8, 40); + this.chkWholeWord.Name = "chkWholeWord"; + this.chkWholeWord.Size = new System.Drawing.Size(144, 16); + this.chkWholeWord.TabIndex = 1; + this.chkWholeWord.Text = "Match &whole word"; + // + // chkMatchCase + // + this.chkMatchCase.Location = new System.Drawing.Point(8, 16); + this.chkMatchCase.Name = "chkMatchCase"; + this.chkMatchCase.Size = new System.Drawing.Size(144, 16); + this.chkMatchCase.TabIndex = 0; + this.chkMatchCase.Text = "Match &case"; + // + // FindReplaceForm + // + this.AcceptButton = this.btnFind; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.CancelButton = this.btnClose; + this.ClientSize = new System.Drawing.Size(496, 178); + this.Controls.AddRange(new System.Windows.Forms.Control[] + {this.pnlSettings, this.pnlReplace, this.pnlFind, this.pnlButtons}); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "FindReplaceForm"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Find"; + this.Closing += new System.ComponentModel.CancelEventHandler(this.FindReplace_Closing); + this.pnlButtons.ResumeLayout(false); + this.panel3.ResumeLayout(false); + this.pnlReplaceButtons.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.pnlFind.ResumeLayout(false); + this.pnlReplace.ResumeLayout(false); + this.pnlSettings.ResumeLayout(false); + this.groupBox1.ResumeLayout(false); + this.ResumeLayout(false); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/FindReplace.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/FindReplace.resx new file mode 100644 index 0000000..a094419 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/FindReplace.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + R0lGODlhCwANAPEAAP///wAAAMDAwAAAACH5BAEAAAIALAAAAAALAA0AAAIUlI+pu+EfEozqMUHlzGY2 + d3HXiBQAOw== + + + + + R0lGODlhCwANAPEAAP///wAAAMDAwAAAACH5BAEAAAIALAAAAAALAA0AAAIUlI+pGXvRHIxqUmSvsWtK + jTniKBQAOw== + + + + + R0lGODlhCwANAPEAAP///wAAAMDAwAAAACH5BAEAAAIALAAAAAALAA0AAAIUlI+pGXvRHIxqUmSvsWtK + jTniKBQAOw== + + + + FindReplaceForm + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/GotoLine.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/GotoLine.cs new file mode 100644 index 0000000..f7f12a1 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/GotoLine.cs @@ -0,0 +1,180 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Globalization; +using System.Windows.Forms; + +namespace Alsing.Windows.Forms.SyntaxBox +{ + /// + /// Summary description for GotoLine. + /// + public class GotoLineForm : Form + { + private readonly EditViewControl mOwner; + private Button btnCancel; + private Button btnOK; + + /// + /// Required designer variable. + /// + private Container components; + + private Label lblLines; + private TextBox txtRow; + + /// + /// Default constructor for the GotoLineForm. + /// + public GotoLineForm() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + } + + /// + /// Creates a GotoLineForm that will be assigned to a specific Owner control. + /// + /// The SyntaxBox that will use the GotoLineForm + /// The number of lines in the owner control + public GotoLineForm(EditViewControl Owner, int RowCount) + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + lblLines.Text = "Line number (1-" + RowCount.ToString(CultureInfo.InvariantCulture) + "):"; + mOwner = Owner; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + private void btnOK_Click(object sender, EventArgs e) + { + try + { + int row = int.Parse(txtRow.Text) - 1; + mOwner.GotoLine(row); + } + catch {} + Close(); + } + + private void btnCancel_Click(object sender, EventArgs e) + { + Close(); + } + + private void GotoLine_Closing(object sender, CancelEventArgs e) + { + //e.Cancel =true; + //this.Hide (); + } + + private void GotoLine_Activated(object sender, EventArgs e) + { + txtRow.Focus(); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnCancel = new System.Windows.Forms.Button(); + this.btnOK = new System.Windows.Forms.Button(); + this.txtRow = new System.Windows.Forms.TextBox(); + this.lblLines = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(160, 48); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(72, 24); + this.btnCancel.TabIndex = 0; + this.btnCancel.Text = "Cancel"; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnOK + // + this.btnOK.Location = new System.Drawing.Point(80, 48); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(72, 24); + this.btnOK.TabIndex = 1; + this.btnOK.Text = "OK"; + this.btnOK.Click += new System.EventHandler(this.btnOK_Click); + // + // txtRow + // + this.txtRow.Location = new System.Drawing.Point(8, 24); + this.txtRow.Name = "txtRow"; + this.txtRow.Size = new System.Drawing.Size(224, 20); + this.txtRow.TabIndex = 2; + this.txtRow.Text = ""; + // + // lblLines + // + this.lblLines.Location = new System.Drawing.Point(8, 8); + this.lblLines.Name = "lblLines"; + this.lblLines.Size = new System.Drawing.Size(128, 16); + this.lblLines.TabIndex = 3; + this.lblLines.Text = "-"; + // + // GotoLineForm + // + this.AcceptButton = this.btnOK; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(242, 82); + this.Controls.AddRange(new System.Windows.Forms.Control[] + {this.lblLines, this.txtRow, this.btnOK, this.btnCancel}); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "GotoLineForm"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Go To Line"; + this.Closing += new System.ComponentModel.CancelEventHandler(this.GotoLine_Closing); + this.Activated += new System.EventHandler(this.GotoLine_Activated); + this.ResumeLayout(false); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/GotoLine.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/GotoLine.resx new file mode 100644 index 0000000..7dc59f8 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/GotoLine.resx @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GotoLineForm + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/Settings.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/Settings.cs new file mode 100644 index 0000000..2fe69bb --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/Settings.cs @@ -0,0 +1,295 @@ +//using System; +//using System.Drawing; +//using System.Collections; +//using System.ComponentModel; +//using System.Windows.Forms; +//using Alsing.SourceCode; +// +//namespace Alsing.Windows.Forms.SyntaxBox +//{ +// /// +// /// Summary description for Settings. +// /// +// public class SettingsForm : System.Windows.Forms.Form +// { +// /// +// /// Required designer variable. +// /// +// /// +// private Hashtable SpanDefinitions=new Hashtable (); +// private Hashtable Styles=new Hashtable (); +// +// private System.ComponentModel.Container components = null; +// private System.Windows.Forms.Panel panel1; +// private System.Windows.Forms.Label label1; +// private System.Windows.Forms.Label label2; +// private System.Windows.Forms.ComboBox cboFonts; +// private System.Windows.Forms.ComboBox cboSize; +// private System.Windows.Forms.Label label3; +// private System.Windows.Forms.ComboBox comboBox1; +// private System.Windows.Forms.Label label4; +// private System.Windows.Forms.Button button1; +// private System.Windows.Forms.Button button2; +// private System.Windows.Forms.Label label5; +// private System.Windows.Forms.ComboBox comboBox2; +// private System.Windows.Forms.CheckBox checkBox1; +// private System.Windows.Forms.CheckBox checkBox2; +// private System.Windows.Forms.CheckBox checkBox3; +// private System.Windows.Forms.ListBox lstBlocks; +// private SyntaxBoxControl mOwner=null; +// +// public SettingsForm() +// { +// // +// // Required for Windows Form Designer support +// // +// InitializeComponent(); +// +// // +// // TODO: Add any constructor code after InitializeComponent call +// // +// } +// +// public SettingsForm(SyntaxBoxControl Owner) +// { +// InitializeComponent(); +// mOwner=Owner; +// lstBlocks.Items.Clear (); +// +// FillTree(Owner.Document.Parser.SyntaxDefinition.mainSpanDefinition); +// } +// +// public void FillTree(spanDefinition Block) +// { +// if (SpanDefinitions[Block]!=null) +// return; +// +// SpanDefinitions.Add (Block,Block); +// AddStyle(Block.Style); +// foreach (PatternList pl in Block.KeywordsList) +// { +// AddStyle(pl.Style); +// } +// foreach (PatternList pl in Block.OperatorsList) +// { +// AddStyle(pl.Style); +// } +// +// +// foreach (spanDefinition ChildBlock in Block.childSpanDefinitions) +// { +// FillTree(ChildBlock); +// } +// +// } +// +// private void AddStyle(TextStyle style) +// { +// if (Styles[style]!=null) +// return; +// +// Styles.Add (style,style); +// lstBlocks.Items.Add (style.Name); +// } +// +// +// +// +// /// +// /// Clean up any resources being used. +// /// +// protected override void Dispose( bool disposing ) +// { +// if( disposing ) +// { +// if(components != null) +// { +// components.Dispose(); +// } +// } +// base.Dispose( disposing ); +// } +// +// #region Windows Form Designer generated code +// /// +// /// Required method for Designer support - do not modify +// /// the contents of this method with the code editor. +// /// +// private void InitializeComponent() +// { +// this.panel1 = new System.Windows.Forms.Panel(); +// this.checkBox3 = new System.Windows.Forms.CheckBox(); +// this.checkBox2 = new System.Windows.Forms.CheckBox(); +// this.checkBox1 = new System.Windows.Forms.CheckBox(); +// this.button2 = new System.Windows.Forms.Button(); +// this.label5 = new System.Windows.Forms.Label(); +// this.comboBox2 = new System.Windows.Forms.ComboBox(); +// this.button1 = new System.Windows.Forms.Button(); +// this.label4 = new System.Windows.Forms.Label(); +// this.comboBox1 = new System.Windows.Forms.ComboBox(); +// this.label3 = new System.Windows.Forms.Label(); +// this.lstBlocks = new System.Windows.Forms.ListBox(); +// this.cboSize = new System.Windows.Forms.ComboBox(); +// this.cboFonts = new System.Windows.Forms.ComboBox(); +// this.label2 = new System.Windows.Forms.Label(); +// this.label1 = new System.Windows.Forms.Label(); +// this.panel1.SuspendLayout(); +// this.SuspendLayout(); +// // +// // panel1 +// // +// this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] { +// this.checkBox3, +// this.checkBox2, +// this.checkBox1, +// this.button2, +// this.label5, +// this.comboBox2, +// this.button1, +// this.label4, +// this.comboBox1, +// this.label3, +// this.lstBlocks, +// this.cboSize, +// this.cboFonts, +// this.label2, +// this.label1}); +// this.panel1.Location = new System.Drawing.Point(8, 0); +// this.panel1.Name = "panel1"; +// this.panel1.Size = new System.Drawing.Size(408, 344); +// this.panel1.TabIndex = 0; +// // +// // checkBox3 +// // +// this.checkBox3.Location = new System.Drawing.Point(184, 208); +// this.checkBox3.Name = "checkBox3"; +// this.checkBox3.Size = new System.Drawing.Size(128, 16); +// this.checkBox3.TabIndex = 14; +// this.checkBox3.Text = "Underline"; +// // +// // checkBox2 +// // +// this.checkBox2.Location = new System.Drawing.Point(184, 184); +// this.checkBox2.Name = "checkBox2"; +// this.checkBox2.Size = new System.Drawing.Size(128, 16); +// this.checkBox2.TabIndex = 13; +// this.checkBox2.Text = "Italic"; +// // +// // checkBox1 +// // +// this.checkBox1.Location = new System.Drawing.Point(184, 160); +// this.checkBox1.Name = "checkBox1"; +// this.checkBox1.Size = new System.Drawing.Size(128, 16); +// this.checkBox1.TabIndex = 12; +// this.checkBox1.Text = "Bold"; +// // +// // button2 +// // +// this.button2.Location = new System.Drawing.Point(320, 128); +// this.button2.Name = "button2"; +// this.button2.Size = new System.Drawing.Size(80, 21); +// this.button2.TabIndex = 11; +// this.button2.Text = "Custom..."; +// // +// // label5 +// // +// this.label5.Location = new System.Drawing.Point(184, 112); +// this.label5.Name = "label5"; +// this.label5.Size = new System.Drawing.Size(100, 16); +// this.label5.TabIndex = 10; +// this.label5.Text = "Item foregound:"; +// // +// // comboBox2 +// // +// this.comboBox2.Location = new System.Drawing.Point(184, 128); +// this.comboBox2.Name = "comboBox2"; +// this.comboBox2.Size = new System.Drawing.Size(128, 21); +// this.comboBox2.TabIndex = 9; +// this.comboBox2.Text = "comboBox2"; +// // +// // button1 +// // +// this.button1.Location = new System.Drawing.Point(320, 80); +// this.button1.Name = "button1"; +// this.button1.Size = new System.Drawing.Size(80, 21); +// this.button1.TabIndex = 8; +// this.button1.Text = "Custom..."; +// // +// // label4 +// // +// this.label4.Location = new System.Drawing.Point(184, 64); +// this.label4.Name = "label4"; +// this.label4.Size = new System.Drawing.Size(100, 16); +// this.label4.TabIndex = 7; +// this.label4.Text = "Item foregound:"; +// // +// // comboBox1 +// // +// this.comboBox1.Location = new System.Drawing.Point(184, 80); +// this.comboBox1.Name = "comboBox1"; +// this.comboBox1.Size = new System.Drawing.Size(128, 21); +// this.comboBox1.TabIndex = 6; +// this.comboBox1.Text = "comboBox1"; +// // +// // label3 +// // +// this.label3.Location = new System.Drawing.Point(8, 64); +// this.label3.Name = "label3"; +// this.label3.Size = new System.Drawing.Size(100, 16); +// this.label3.TabIndex = 5; +// this.label3.Text = "Display items:"; +// // +// // lstBlocks +// // +// this.lstBlocks.Location = new System.Drawing.Point(8, 80); +// this.lstBlocks.Name = "lstBlocks"; +// this.lstBlocks.Size = new System.Drawing.Size(168, 212); +// this.lstBlocks.TabIndex = 4; +// // +// // cboSize +// // +// this.cboSize.Location = new System.Drawing.Point(320, 32); +// this.cboSize.Name = "cboSize"; +// this.cboSize.Size = new System.Drawing.Size(80, 21); +// this.cboSize.TabIndex = 3; +// this.cboSize.Text = "comboBox1"; +// // +// // cboFonts +// // +// this.cboFonts.Location = new System.Drawing.Point(8, 32); +// this.cboFonts.Name = "cboFonts"; +// this.cboFonts.Size = new System.Drawing.Size(304, 21); +// this.cboFonts.TabIndex = 2; +// this.cboFonts.Text = "comboBox1"; +// // +// // label2 +// // +// this.label2.Location = new System.Drawing.Point(320, 16); +// this.label2.Name = "label2"; +// this.label2.Size = new System.Drawing.Size(32, 16); +// this.label2.TabIndex = 1; +// this.label2.Text = "Size:"; +// // +// // label1 +// // +// this.label1.Location = new System.Drawing.Point(8, 16); +// this.label1.Name = "label1"; +// this.label1.Size = new System.Drawing.Size(264, 16); +// this.label1.TabIndex = 0; +// this.label1.Text = "Font (bold type indicates fixed-width fonts):"; +// // +// // SettingsForm +// // +// this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); +// this.ClientSize = new System.Drawing.Size(424, 349); +// this.Controls.AddRange(new System.Windows.Forms.Control[] { +// this.panel1}); +// this.Name = "SettingsForm"; +// this.Text = "Settings"; +// this.panel1.ResumeLayout(false); +// this.ResumeLayout(false); +// +// } +// #endregion +// } +//} diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/Settings.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/Settings.resx new file mode 100644 index 0000000..0498436 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Dialogs/Settings.resx @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + SettingsForm + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Events.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Events.cs new file mode 100644 index 0000000..67e063b --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/Events.cs @@ -0,0 +1,138 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Drawing; +using System.Windows.Forms; +using Alsing.SourceCode; + +namespace Alsing.Windows.Forms.SyntaxBox +{ + public delegate void RowPaintHandler(object sender, RowPaintEventArgs e); + + public delegate void RowMouseHandler(object sender, RowMouseEventArgs e); + + public delegate void CopyHandler(object sender, CopyEventArgs e); + + public delegate void WordMouseHandler(object sender, ref WordMouseEventArgs e); + + /// + /// Event arg for Copy/Cut actions. + /// + public class CopyEventArgs + { + /// + /// The text copied to the clipboard. + /// + public string Text = ""; + } + + /// + /// Event args passed to word mouse events of the syntaxbox + /// + public class WordMouseEventArgs : EventArgs + { + /// + /// The mouse buttons that was pressed when the event fired + /// + public MouseButtons Button; + + /// + /// Reference to a mouse cursor , developers can assign new values here to display new cursors for a given pattern + /// + public Cursor Cursor; + + /// + /// The pattern that triggered the event + /// + public Pattern Pattern; + + /// + /// The word where the event was fired + /// + public Word Word; + } + + /// + /// Event args for mouse actions on the syntaxbox + /// + public class RowMouseEventArgs : EventArgs + { + /// + /// The area of the row where the event was fired + /// + public RowArea Area; + + /// + /// The mousebuttons that was pressed when the event was fired + /// + public MouseButtons Button; + + /// + /// The X position of the mouse cursor when the event was fired + /// + public int MouseX; + + /// + /// The Y position of the mouse cursor when the event was fired + /// + public int MouseY; + + /// + /// The row where the event was fired + /// + public Row Row; + } + + + /// + /// Describes in what area a mouse event occured on a row + /// + public enum RowArea + { + /// + /// Represents the gutter margin + /// + GutterArea, + /// + /// Represents the LineNumber section + /// + LineNumberArea, + /// + /// Represents the area where the folding symbols are shown + /// + FoldingArea, + /// + /// Represents the actual text part of a row + /// + TextArea, + } + + /// + /// Event args passed to owner draw events of the syntaxbox + /// + public class RowPaintEventArgs : EventArgs + { + /// + /// the bounds of the row + /// + public Rectangle Bounds; + + /// + /// The graphics surface to draw on + /// + public Graphics Graphics; + + /// + /// The row to draw + /// + public Row Row; + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/SyntaxBoxControl.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/SyntaxBoxControl.cs new file mode 100644 index 0000000..a2da7c5 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/SyntaxBoxControl.cs @@ -0,0 +1,2231 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +#region using... + +using System; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing; +using System.Drawing.Design; +using System.IO; +using System.Resources; +using System.Windows.Forms; +using Alsing.Drawing.GDI; +using Alsing.SourceCode; +using Alsing.Windows.Forms.CoreLib; +using Alsing.Windows.Forms.SyntaxBox; + +#endregion + +namespace Alsing.Windows.Forms +{ + /// + /// Syntaxbox control that can be used as a pure text editor or as a code editor when a syntaxfile is used. + /// + [Designer(typeof (SyntaxBoxDesigner), typeof (IDesigner))] + public class SyntaxBoxControl : SplitViewParentControl + { + protected internal bool DisableAutoList; + protected internal bool DisableFindForm; + protected internal bool DisableInfoTip; + protected internal bool DisableIntelliMouse; + + #region General Declarations + + private bool _AllowBreakPoints = true; + private Color _BackColor = Color.White; + private Color _BracketBackColor = Color.LightSteelBlue; + private Color _BracketBorderColor = Color.DarkBlue; + private Color _BracketForeColor = Color.Black; + private bool _BracketMatching = true; + + private Color _BreakPointBackColor = Color.DarkRed; + private Color _BreakPointForeColor = Color.White; + private SyntaxDocument _Document; + private string _FontName = "Courier new"; + private float _FontSize = 10f; + private Color _GutterMarginBorderColor = SystemColors.ControlDark; + private Color _GutterMarginColor = SystemColors.Control; + private int _GutterMarginWidth = 19; + private bool _HighLightActiveLine; + private Color _HighLightedLineColor = Color.LightYellow; + private Color _InactiveSelectionBackColor = SystemColors.ControlDark; + private Color _InactiveSelectionForeColor = SystemColors.ControlLight; + private IndentStyle _Indent = IndentStyle.LastRow; + private KeyboardActionList _KeyboardActions = new KeyboardActionList(); + private Color _LineNumberBackColor = SystemColors.Window; + private Color _LineNumberBorderColor = Color.Teal; + private Color _LineNumberForeColor = Color.Teal; + private Color _OutlineColor = SystemColors.ControlDark; + private bool _ParseOnPaste; + private Color _RevisionMarkAfterSave = Color.LimeGreen; + private Color _RevisionMarkBeforeSave = Color.Gold; + private Color _ScopeBackColor = Color.Transparent; + private Color _ScopeIndicatorColor = Color.Transparent; + private Color _SelectionBackColor = SystemColors.Highlight; + private Color _SelectionForeColor = SystemColors.HighlightText; + private Color _SeparatorColor = SystemColors.Control; + private bool _ShowGutterMargin = true; + private bool _ShowLineNumbers = true; + private bool _ShowRevisionMarks = true; + private bool _ShowTabGuides; + private bool _ShowWhitespace; + private int _SmoothScrollSpeed = 2; + + private Color _TabGuideColor = ControlPaint.Light(SystemColors.ControlLight); + + private int _TabSize = 4; + + private int _TooltipDelay = 240; + private bool _VirtualWhitespace; + private Color _WhitespaceColor = SystemColors.ControlDark; + private IContainer components; + + #endregion + + #region Internal Components/Controls + + private ImageList _AutoListIcons; + private ImageList _GutterIcons; + private Timer ParseTimer; + + #endregion + + #region Public Events + + /// + /// An event that is fired when the cursor hovers a pattern; + /// + public event WordMouseHandler WordMouseHover = null; + + /// + /// An event that is fired when the cursor hovers a pattern; + /// + public event WordMouseHandler WordMouseDown = null; + + /// + /// An event that is fired when the control has updated the clipboard + /// + public event CopyHandler ClipboardUpdated = null; + + /// + /// Event fired when the caret of the active view have moved. + /// + public event EventHandler CaretChange = null; + + /// + /// + /// + public event EventHandler SelectionChange = null; + + /// + /// Event fired when the user presses the up or the down button on the infotip. + /// + public event EventHandler InfoTipSelectedIndexChanged = null; + + /// + /// Event fired when a row is rendered. + /// + public event RowPaintHandler RenderRow = null; + + /// + /// An event that is fired when mouse down occurs on a row + /// + public event RowMouseHandler RowMouseDown = null; + + /// + /// An event that is fired when mouse move occurs on a row + /// + public event RowMouseHandler RowMouseMove = null; + + /// + /// An event that is fired when mouse up occurs on a row + /// + public event RowMouseHandler RowMouseUp = null; + + /// + /// An event that is fired when a click occurs on a row + /// + public event RowMouseHandler RowClick = null; + + /// + /// An event that is fired when a double click occurs on a row + /// + public event RowMouseHandler RowDoubleClick = null; + + #endregion //END PUBLIC EGENTS + + #region Public Properties + + #region PUBLIC PROPERTY SHOWEOLMARKER + + private bool _ShowEOLMarker; + + [Category("Appearance"), Description("Determines if a ¶ should be displayed at the end of a line")] + [DefaultValue(false)] + public bool ShowEOLMarker + { + get { return _ShowEOLMarker; } + set + { + _ShowEOLMarker = value; + Redraw(); + } + } + + #endregion + + #region PUBLIC PROPERTY EOLMARKERCOLOR + + private Color _EOLMarkerColor = Color.Red; + + [Category("Appearance"), Description("The color of the EOL marker")] + [DefaultValue(typeof (Color), "Red")] + public Color EOLMarkerColor + { + get { return _EOLMarkerColor; } + set + { + _EOLMarkerColor = value; + Redraw(); + } + } + + #endregion + + #region PUBLIC PROPERTY AUTOLISTAUTOSELECT + + private bool _AutoListAutoSelect = true; + + [DefaultValue(true)] + public bool AutoListAutoSelect + { + get { return _AutoListAutoSelect; } + set { _AutoListAutoSelect = value; } + } + + #endregion + + #region PUBLIC PROPERTY COPYASRTF + + [Category("Behavior - Clipboard"), Description("determines if the copy actions should be stored as RTF")] + [DefaultValue(typeof (Color), "false")] + public bool CopyAsRTF { get; set; } + + #endregion + + private bool _CollapsedBlockTooltipsEnabled = true; + + [Category("Appearance - Scopes"), Description("The color of the active scope")] + [DefaultValue(typeof (Color), "Transparent")] + public Color ScopeBackColor + { + get { return _ScopeBackColor; } + set + { + _ScopeBackColor = value; + Redraw(); + } + } + + [Category("Appearance - Scopes"), Description("The color of the scope indicator")] + [DefaultValue(typeof (Color), "Transparent")] + public Color ScopeIndicatorColor + { + get { return _ScopeIndicatorColor; } + set + { + _ScopeIndicatorColor = value; + Redraw(); + } + } + + /// + /// Positions the AutoList + /// + [Category("Behavior")] + [Browsable(false)] + public TextPoint AutoListPosition + { + get { return ((EditViewControl) _ActiveView).AutoListPosition; } + set + { + if ((_ActiveView) == null) + return; + + ((EditViewControl) _ActiveView).AutoListPosition = value; + } + } + + /// + /// Positions the InfoTip + /// + [Category("Behavior")] + [Browsable(false)] + public TextPoint InfoTipPosition + { + get { return ((EditViewControl) _ActiveView).InfoTipPosition; } + set + { + if ((_ActiveView) == null) + return; + + ((EditViewControl) _ActiveView).InfoTipPosition = value; + } + } + + + /// + /// Determines if the revision marks should be visible. + /// + [Category("Appearance - Revision Marks")] + [Description( + "Determines if the revision marks should be visible") + ] + [DefaultValue(true)] + public bool ShowRevisionMarks + { + get { return _ShowRevisionMarks; } + set + { + _ShowRevisionMarks = value; + Redraw(); + } + } + + /// + /// Prevents the control from changing the cursor. + /// + [Description("Prevents the control from changing the cursor.")] + [Category("Appearance")] + [Browsable(false)] + public bool LockCursorUpdate { get; set; } + + /// + /// The row padding in pixels. + /// + [Category("Appearance"), Description("The number of pixels to add between rows")] + [DefaultValue(0)] + public int RowPadding { get; set; } + + + /// + /// The selected index in the infotip. + /// + [Category("Appearance - Infotip"), Description("The currently active selection in the infotip")] + [Browsable(false)] + public int InfoTipSelectedIndex + { + get { return ((EditViewControl) _ActiveView).InfoTip.SelectedIndex; } + set + { + if ((_ActiveView) == null || ((EditViewControl) _ActiveView).InfoTip == null) + return; + + ((EditViewControl) _ActiveView).InfoTip.SelectedIndex = value; + } + } + + /// + /// Gets or Sets the image used in the infotip. + /// + [Category("Appearance - InfoTip"), Description("An image to show in the infotip")] + [DefaultValue(null)] + public Image InfoTipImage + { + get { return ((EditViewControl) _ActiveView).InfoTip.Image; } + set + { + if ((_ActiveView) == null || ((EditViewControl) _ActiveView).InfoTip == null) + return; + + + ((EditViewControl) _ActiveView).InfoTip.Image = value; + } + } + + /// + /// Get or Sets the number of choices that could be made in the infotip. + /// + [Category("Appearance"), Description("Get or Sets the number of choices that could be made in the infotip")] + [Browsable(false)] + public int InfoTipCount + { + get { return ((EditViewControl) _ActiveView).InfoTip.Count; } + set + { + if ((_ActiveView) == null || ((EditViewControl) _ActiveView).InfoTip == null) + return; + + ((EditViewControl) _ActiveView).InfoTip.Count = value; + ((EditViewControl) _ActiveView).InfoTip.Init(); + } + } + + /// + /// The text in the Infotip. + /// + ///
+ /// The text uses a HTML like syntax.
+ ///
+ /// Supported tags are:
+ ///
+ /// <Font Size="Size in Pixels" Face="Font Name" Color="Named color" ></Font> Set Font size,color and fontname.
+ /// <HR> : Inserts a horizontal separator line.
+ /// <BR> : Line break.
+ /// <B></B> : Activate/Deactivate Bold style.
+ /// <I></I> : Activate/Deactivate Italic style.
+ /// <U></U> : Activate/Deactivate Underline style.
+ ///
+ /// + /// + /// MySyntaxBox.InfoTipText="public void MyMethod ( <b> string text </b> );"; + /// + /// + [Category("Appearance - InfoTip"), Description("The infotip text")] + [DefaultValue("")] + public string InfoTipText + { + get { return ((EditViewControl) _ActiveView).InfoTip.Data; } + set + { + if ((_ActiveView) == null || ((EditViewControl) _ActiveView).InfoTip == null) + return; + + ((EditViewControl) _ActiveView).InfoTip.Data = value; + } + } + + /// + /// Gets the Selection object from the active view. + /// + [Browsable(false)] + public Selection Selection + { + get + { + if ((_ActiveView) != null) + { + return ((EditViewControl) _ActiveView).Selection; + } + return null; + } + } + + /// + /// Collection of KeyboardActions that is used by the control. + /// Keyboard actions to add shortcut key combinations to certain tasks. + /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public KeyboardActionList KeyboardActions + { + get { return _KeyboardActions; } + set { _KeyboardActions = value; } + } + + /// + /// Gets or Sets if the AutoList is visible in the active view. + /// + [Category("Appearance"), Description("Gets or Sets if the AutoList is visible in the active view.")] + [Browsable(false)] + public bool AutoListVisible + { + get { return (_ActiveView) != null && ((EditViewControl) _ActiveView).AutoListVisible; } + set + { + if ((_ActiveView) != null) + ((EditViewControl) _ActiveView).AutoListVisible = value; + } + } + + /// + /// Gets or Sets if the InfoTip is visible in the active view. + /// + [Category("Appearance"), Description("Gets or Sets if the InfoTip is visible in the active view.")] + [Browsable(false)] + public bool InfoTipVisible + { + get { return (_ActiveView) != null && ((EditViewControl) _ActiveView).InfoTipVisible; } + set + { + if ((_ActiveView) != null) + ((EditViewControl) _ActiveView).InfoTipVisible = value; + } + } + + /// + /// Gets if the control can perform a Copy action. + /// + [Browsable(false)] + public bool CanCopy + { + get { return ((EditViewControl) _ActiveView).CanCopy; } + } + + /// + /// Gets if the control can perform a Paste action. + /// (if the clipboard contains a valid text). + /// + [Browsable(false)] + public bool CanPaste + { + get { return ((EditViewControl) _ActiveView).CanPaste; } + } + + + /// + /// Gets if the control can perform a ReDo action. + /// + [Browsable(false)] + public bool CanRedo + { + get { return ((EditViewControl) _ActiveView).CanRedo; } + } + + /// + /// Gets if the control can perform an Undo action. + /// + [Browsable(false)] + public bool CanUndo + { + get { return ((EditViewControl) _ActiveView).CanUndo; } + } + + /// + /// Gets or Sets the imagelist to use in the gutter margin. + /// + /// + /// Image Index 0 is used to display the Breakpoint icon. + /// Image Index 1 is used to display the Bookmark icon. + /// + [Category("Appearance - Gutter Margin"), Description("Gets or Sets the imagelist to use in the gutter margin.")] + public ImageList GutterIcons + { + get { return _GutterIcons; } + set + { + _GutterIcons = value; + Redraw(); + } + } + + /// + /// Gets or Sets the imagelist to use in the autolist. + /// + [Category("Appearance"), Description("Gets or Sets the imagelist to use in the autolist.")] + [DefaultValue(null)] + public ImageList AutoListIcons + { + get { return _AutoListIcons; } + set + { + _AutoListIcons = value; + + + foreach (EditViewControl ev in Views) + { + if (ev != null && ev.AutoList != null) + ev.AutoList.Images = value; + } + Redraw(); + } + } + + + /// + /// Gets or Sets the color to use when rendering Tab guides. + /// + [Category("Appearance - Tabs")] + [Description("Gets or Sets the color to use when rendering Tab guides.")] + [DefaultValue(typeof (Color), "Control")] + public Color TabGuideColor + { + get { return _TabGuideColor; } + set + { + _TabGuideColor = value; + Redraw(); + } + } + + /// + /// Gets or Sets the color of the bracket match borders. + /// + /// + /// NOTE: use Color.Transparent to turn off the bracket match borders. + /// + [Category("Appearance - Bracket Match")] + [Description("Gets or Sets the color of the bracket match borders.")] + [DefaultValue(typeof (Color), "DarkBlue")] + public Color BracketBorderColor + { + get { return _BracketBorderColor; } + set + { + _BracketBorderColor = value; + Redraw(); + } + } + + /// + /// Gets or Sets if the control should render Tab guides. + /// + [Category("Appearance - Tabs")] + [Description("Gets or Sets if the control should render Tab guides.")] + [DefaultValue(false)] + public bool ShowTabGuides + { + get { return _ShowTabGuides; } + set + { + _ShowTabGuides = value; + Redraw(); + } + } + + /// + /// Gets or Sets the color to use when rendering whitespace characters + /// + [Category("Appearance")] + [Description("Gets or Sets the color to use when rendering whitespace characters.")] + [DefaultValue(typeof (Color), "Control")] + public Color WhitespaceColor + { + get { return _WhitespaceColor; } + set + { + _WhitespaceColor = value; + Redraw(); + } + } + + /// + /// Gets or Sets the color of the code Outlining (both folding lines and collapsed blocks). + /// + [Category("Appearance")] + [Description("Gets or Sets the color of the code Outlining (both folding lines and collapsed blocks).")] + [DefaultValue(typeof (Color), "ControlDark")] + public Color OutlineColor + { + get { return _OutlineColor; } + set + { + _OutlineColor = value; + InitGraphics(); + Redraw(); + } + } + + + /// + /// Determines if the control should use a smooth scroll when scrolling one row up or down. + /// + [Category("Behavior")] + [Description("Determines if the control should use a smooth scroll when scrolling one row up or down.")] + [DefaultValue(typeof (Color), "False")] + public bool SmoothScroll { get; set; } + + /// + /// Gets or Sets the speed of the vertical scroll when SmoothScroll is activated + /// + [Category("Behavior")] + [Description("Gets or Sets the speed of the vertical scroll when SmoothScroll is activated")] + [DefaultValue(2)] + public int SmoothScrollSpeed + { + get { return _SmoothScrollSpeed; } + set + { + if (value <= 0) + { + throw (new Exception("Scroll speed may not be less than 1")); + } + + _SmoothScrollSpeed = value; + } + } + + /// + /// Gets or Sets if the control can display breakpoints or not. + /// + [Category("Behavior")] + [Description("Gets or Sets if the control can display breakpoints or not.")] + [DefaultValue(true)] + public bool AllowBreakPoints + { + get { return _AllowBreakPoints; } + set { _AllowBreakPoints = value; } + } + + /// + /// Gets or Sets the RevisionMarkBeforeSave Color to use for modified rows. + /// + [Category("Appearance - Revision Marks")] + [Description( + "The color to use for revision mark when line is modified") + ] + [DefaultValue(typeof (Color), "Gold")] + public Color + RevisionMarkBeforeSave + { + get { return _RevisionMarkBeforeSave; } + set + { + _RevisionMarkBeforeSave = value; + Redraw(); + } + } + + /// + /// Gets or Sets the RevisionMarkAfterSave Color to use for saved rows. + /// + [Category("Appearance - Revision Marks")] + [Description( + "The color to use for revision mark when line is saved") + ] + [DefaultValue(typeof (Color), "LimeGreen")] + public Color + RevisionMarkAfterSave + { + get { return _RevisionMarkAfterSave; } + set + { + _RevisionMarkAfterSave = value; + Redraw(); + } + } + + /// + /// Gets or Sets if the control should perform a full parse of the document when content is drag dropped or pasted into the control + /// + [Category("Behavior - Clipboard")] + [Description( + "Gets or Sets if the control should perform a full parse of the document when content is drag dropped or pasted into the control" + )] + [DefaultValue(false)] + public bool ParseOnPaste + { + get { return _ParseOnPaste; } + set + { + _ParseOnPaste = value; + Redraw(); + } + } + + /// + /// Gets or Sets the Size of the font. + /// + /// + [Category("Appearance - Font")] + [Description("The size of the font")] + [DefaultValue(10f)] + public float FontSize + { + get { return _FontSize; } + set + { + _FontSize = value; + InitGraphics(); + Redraw(); + } + } + + /// + /// Determines what indentstyle to use on a new line. + /// + [Category("Behavior")] + [Description("Determines how the the control indents a new line")] + [DefaultValue(IndentStyle.LastRow)] + public IndentStyle Indent + { + get { return _Indent; } + set { _Indent = value; } + } + + /// + /// Gets or Sets the SyntaxDocument the control is currently attatched to. + /// + [Category("Content")] + [Description("The SyntaxDocument that is attatched to the contro")] + public SyntaxDocument Document + { + get { return _Document; } + set { AttachDocument(value); } + } + + /// + /// Get or Set the delay before the tooltip is displayed over a collapsed block + /// + [Category("Behavior")] + [Description("The delay before the tooltip is displayed over a collapsed block")] + [DefaultValue(240)] + public int TooltipDelay + { + get { return _TooltipDelay; } + set { _TooltipDelay = value; } + } + + // ROB: Added property to turn collapsed block tooltips on and off. + + /// + /// Get or Set whether or not tooltips will be deplayed for collapsed blocks. + /// + [Category("Behavior")] + [Description("The delay before the tooltip is displayed over a collapsed block")] + [DefaultValue(true)] + public bool CollapsedBlockTooltipsEnabled + { + get { return _CollapsedBlockTooltipsEnabled; } + set { _CollapsedBlockTooltipsEnabled = value; } + } + + // END-ROB ---------------------------------------------------------- + + /// + /// Get or Set the delay before the tooltip is displayed over a collapsed block + /// + [Category("Behavior")] + [Description("Determines if the control is readonly or not")] + [DefaultValue(false)] + public bool ReadOnly { get; set; } + + /// + /// Gets or Sets the name of the font. + /// + /// + [Category("Appearance - Font")] + [Description("The name of the font that is used to render the control")] + [Editor(typeof (FontList), typeof (UITypeEditor))] + [DefaultValue("Courier New")] + public string FontName + { + get { return _FontName; } + set + { + if (Views == null) + return; + + _FontName = value; + InitGraphics(); + foreach (EditViewControl evc in Views) + evc.CalcMaxCharWidth(); + + Redraw(); + } + } + + /// + /// Gets or Sets if bracketmatching is active + /// + /// + /// + [Category("Appearance - Bracket Match")] + [Description("Determines if the control should highlight scope patterns")] + [DefaultValue(true)] + public bool BracketMatching + { + get { return _BracketMatching; } + set + { + _BracketMatching = value; + Redraw(); + } + } + + /// + /// Gets or Sets if Virtual Whitespace is active. + /// + /// + [Category("Behavior")] + [Description("Determines if virtual Whitespace is active")] + [DefaultValue(false)] + public bool VirtualWhitespace + { + get { return _VirtualWhitespace; } + set + { + _VirtualWhitespace = value; + Redraw(); + } + } + + /// + /// Gets or Sets the separator Color. + /// + /// + /// + [Category("Appearance")] + [Description("The separator color")] + [DefaultValue(typeof (Color), "Control")] + public Color SeparatorColor + { + get { return _SeparatorColor; } + set + { + _SeparatorColor = value; + Redraw(); + } + } + + + /// + /// Gets or Sets the foreground Color to use when BracketMatching is activated. + /// + /// + /// + [Category("Appearance - Bracket Match")] + [Description("The foreground color to use when BracketMatching is activated")] + [DefaultValue(typeof (Color), "Black")] + public Color BracketForeColor + { + get { return _BracketForeColor; } + set + { + _BracketForeColor = value; + Redraw(); + } + } + + /// + /// Gets or Sets the background Color to use when BracketMatching is activated. + /// + /// + /// + [Category("Appearance - Bracket Match")] + [Description("The background color to use when BracketMatching is activated")] + [DefaultValue(typeof (Color), "LightSteelBlue")] + public Color BracketBackColor + { + get { return _BracketBackColor; } + set + { + _BracketBackColor = value; + Redraw(); + } + } + + + /// + /// The inactive selection background color. + /// + [Category("Appearance - Selection")] + [Description("The inactive selection background color.")] + [DefaultValue(typeof (Color), "ControlDark")] + public Color InactiveSelectionBackColor + { + get { return _InactiveSelectionBackColor; } + set + { + _InactiveSelectionBackColor = value; + Redraw(); + } + } + + /// + /// The inactive selection foreground color. + /// + [Category("Appearance - Selection")] + [Description("The inactive selection foreground color.")] + [DefaultValue(typeof (Color), "ControlLight")] + public Color InactiveSelectionForeColor + { + get { return _InactiveSelectionForeColor; } + set + { + _InactiveSelectionForeColor = value; + Redraw(); + } + } + + /// + /// The selection background color. + /// + [Category("Appearance - Selection")] + [Description("The selection background color.")] + [DefaultValue(typeof (Color), "Highlight")] + public Color SelectionBackColor + { + get { return _SelectionBackColor; } + set + { + _SelectionBackColor = value; + Redraw(); + } + } + + /// + /// The selection foreground color. + /// + [Category("Appearance - Selection")] + [Description("The selection foreground color.")] + [DefaultValue(typeof (Color), "HighlightText")] + public Color SelectionForeColor + { + get { return _SelectionForeColor; } + set + { + _SelectionForeColor = value; + Redraw(); + } + } + + /// + /// Gets or Sets the border Color of the gutter margin. + /// + /// + [Category("Appearance - Gutter Margin")] + [Description("The border color of the gutter margin")] + [DefaultValue(typeof (Color), "ControlDark")] + public Color GutterMarginBorderColor + { + get { return _GutterMarginBorderColor; } + set + { + _GutterMarginBorderColor = value; + InitGraphics(); + Redraw(); + } + } + + /// + /// Gets or Sets the border Color of the line number margin + /// + /// + /// + [Category("Appearance - Line Numbers")] + [Description("The border color of the line number margin")] + [DefaultValue(typeof (Color), "Teal")] + public Color LineNumberBorderColor + { + get { return _LineNumberBorderColor; } + set + { + _LineNumberBorderColor = value; + InitGraphics(); + Redraw(); + } + } + + + /// + /// Gets or Sets the foreground Color of a Breakpoint. + /// + /// + [Category("Appearance - BreakPoints")] + [Description("The foreground color of a Breakpoint")] + [DefaultValue(typeof (Color), "White")] + public Color BreakPointForeColor + { + get { return _BreakPointForeColor; } + set + { + _BreakPointForeColor = value; + Redraw(); + } + } + + /// + /// Gets or Sets the background Color to use for breakpoint rows. + /// + /// + [Category("Appearance - BreakPoints")] + [Description("The background color to use when BracketMatching is activated")] + [DefaultValue(typeof (Color), "DarkRed")] + public Color BreakPointBackColor + { + get { return _BreakPointBackColor; } + set + { + _BreakPointBackColor = value; + Redraw(); + } + } + + /// + /// Gets or Sets the foreground Color of line numbers. + /// + /// + /// + [Category("Appearance - Line Numbers")] + [Description("The foreground color of line numbers")] + [DefaultValue(typeof (Color), "Teal")] + public Color LineNumberForeColor + { + get { return _LineNumberForeColor; } + set + { + _LineNumberForeColor = value; + InitGraphics(); + Redraw(); + } + } + + /// + /// Gets or Sets the background Color of line numbers. + /// + /// + /// + [Category("Appearance - Line Numbers")] + [Description("The background color of line numbers")] + [DefaultValue(typeof (Color), "Window")] + public Color LineNumberBackColor + { + get { return _LineNumberBackColor; } + set + { + _LineNumberBackColor = value; + InitGraphics(); + Redraw(); + } + } + + /// + /// Gets or Sets the Color of the gutter margin + /// + /// + [Category("Appearance - Gutter Margin")] + [Description("The color of the gutter margin")] + [DefaultValue(typeof (Color), "Control")] + public Color GutterMarginColor + { + get { return _GutterMarginColor; } + set + { + _GutterMarginColor = value; + InitGraphics(); + Redraw(); + } + } + + /// + /// Gets or Sets the background Color of the client area. + /// + [Category("Appearance")] + [Description("The background color of the client area")] + [DefaultValue(typeof (Color), "Window")] + public new Color BackColor + { + get { return _BackColor; } + set + { + _BackColor = value; + InitGraphics(); + Redraw(); + } + } + + /// + /// Gets or Sets the background Color of the active line. + /// + /// + [Category("Appearance - Active Line")] + [Description("The background color of the active line")] + [DefaultValue(typeof (Color), "LightYellow")] + public Color HighLightedLineColor + { + get { return _HighLightedLineColor; } + set + { + _HighLightedLineColor = value; + InitGraphics(); + Redraw(); + } + } + + /// + /// Determines if the active line should be highlighted. + /// + [Category("Appearance - Active Line")] + [Description("Determines if the active line should be highlighted")] + [DefaultValue(false)] + public bool HighLightActiveLine + { + get { return _HighLightActiveLine; } + set + { + _HighLightActiveLine = value; + Redraw(); + } + } + + /// + /// Determines if Whitespace should be rendered as symbols. + /// + [Category("Appearance")] + [Description("Determines if Whitespace should be rendered as symbols")] + [DefaultValue(false)] + public bool ShowWhitespace + { + get { return _ShowWhitespace; } + set + { + _ShowWhitespace = value; + Redraw(); + } + } + + /// + /// Determines if the line number margin should be visible. + /// + [Category("Appearance - Line Numbers")] + [Description("Determines if the line number margin should be visible")] + [DefaultValue(true)] + public bool ShowLineNumbers + { + get { return _ShowLineNumbers; } + set + { + _ShowLineNumbers = value; + Redraw(); + } + } + + /// + /// Determines if the gutter margin should be visible. + /// + [Category("Appearance - Gutter Margin")] + [Description("Determines if the gutter margin should be visible")] + [DefaultValue(true)] + public bool ShowGutterMargin + { + get { return _ShowGutterMargin; } + set + { + _ShowGutterMargin = value; + Redraw(); + } + } + + /// + /// Gets or Sets the witdth of the gutter margin in pixels. + /// + [Category("Appearance - Gutter Margin")] + [Description("Determines the width of the gutter margin in pixels")] + [DefaultValue(19)] + public int GutterMarginWidth + { + get { return _GutterMarginWidth; } + set + { + _GutterMarginWidth = value; + Redraw(); + } + } + + // ROB: Added .TabsToSpaces property. + /// + /// Gets or Sets the 'Tabs To Spaces' feature of the editor. + /// + [Category("Appearance - Tabs")] + [Description("Determines whether or not the SyntaxBox converts tabs to spaces as you type.")] + [DefaultValue(false)] + public bool TabsToSpaces { get; set; } + + /// + /// Get or Sets the size of a TAB char in number of SPACES. + /// + [Category("Appearance - Tabs")] + [Description("Determines the size of a TAB in number of SPACE chars")] + [DefaultValue(4)] + public int TabSize + { + get { return _TabSize; } + set + { + _TabSize = value; + Redraw(); + } + } + + #region PUBLIC PROPERTY SHOWSCOPEINDICATOR + + private bool _ShowScopeIndicator; + + [Category("Appearance - Scopes"), Description("Determines if the scope indicator should be shown")] + [DefaultValue(true)] + public bool ShowScopeIndicator + { + get { return _ShowScopeIndicator; } + set + { + _ShowScopeIndicator = value; + Redraw(); + } + } + + #endregion + + // END-ROB + + // ROB: Added method: ConvertTabsToSpaces() + /// + /// Converts all tabs to spaces the size of .TabSize in the Document. + /// + public void ConvertTabsToSpaces() + { + if (_Document != null) + { + _Document.StartUndoCapture(); + var spaces = new string(' ', _TabSize); + // Iterate all rows and convert tabs to spaces. + for (int count = 0; count < _Document.Count; count++) + { + Row row = _Document[count]; + + string rowText = row.Text; + string newText = rowText.Replace("\t", spaces); + // If this has made a change to the row, update it. + if (newText != rowText) + { + _Document.DeleteRange(new TextRange(0, count, rowText.Length, count)); + _Document.InsertText(newText, 0, count, true); + } + } + _Document.EndUndoCapture(); + } + } + + // END-ROB + + // ROB: Added method: ConvertSpacesToTabs() + /// + /// Converts all spaces the size of .TabSize in the Document to tabs. + /// + public void ConvertSpacesToTabs() + { + if (_Document != null) + { + _Document.StartUndoCapture(); + var spaces = new string(' ', _TabSize); + // Iterate all rows and convert tabs to spaces. + for (int count = 0; count < _Document.Count; count++) + { + Row row = _Document[count]; + + string rowText = row.Text; + string newText = rowText.Replace(spaces, "\t"); + // If this has made a change to the row, update it. + if (newText != rowText) + { + _Document.DeleteRange(new TextRange(0, count, rowText.Length - 1, count)); + _Document.InsertText(newText, 0, count, true); + } + } + _Document.EndUndoCapture(); + } + } + + // END-ROB + + #endregion // PUBLIC PROPERTIES + + #region Public Methods + + /// + /// Gets the Caret object from the active view. + /// + [Browsable(false)] + public Caret Caret + { + get + { + if ((_ActiveView) != null) + { + return ((EditViewControl) _ActiveView).Caret; + } + return null; + } + } + + public void ScrollIntoView(int RowIndex) + { + ((EditViewControl) _ActiveView).ScrollIntoView(RowIndex); + } + + /// + /// Disables painting while loading data into the Autolist + /// + /// + /// + /// + /// + /// + /// MySyntaxBox.AutoListClear(); + /// MySyntaxBox.AutoListBeginLoad(); + /// MySyntaxBox.AutoListAdd ("test",1); + /// MySyntaxBox.AutoListAdd ("test",2); + /// MySyntaxBox.AutoListAdd ("test",3); + /// MySyntaxBox.AutoListAdd ("test",4); + /// MySyntaxBox.AutoListEndLoad(); + /// + /// + public void AutoListBeginLoad() + { + ((EditViewControl) _ActiveView).AutoListBeginLoad(); + } + + /// + /// Resumes painting and autosizes the Autolist. + /// + public void AutoListEndLoad() + { + ((EditViewControl) _ActiveView).AutoListEndLoad(); + } + + /// + /// Clears the content in the autolist. + /// + public void AutoListClear() + { + ((EditViewControl) _ActiveView).AutoList.Clear(); + } + + /// + /// Adds an item to the autolist control. + /// + /// + /// + /// MySyntaxBox.AutoListClear(); + /// MySyntaxBox.AutoListBeginLoad(); + /// MySyntaxBox.AutoListAdd ("test",1); + /// MySyntaxBox.AutoListAdd ("test",2); + /// MySyntaxBox.AutoListAdd ("test",3); + /// MySyntaxBox.AutoListAdd ("test",4); + /// MySyntaxBox.AutoListEndLoad(); + /// + /// + /// The text to display in the autolist + /// The image index in the AutoListIcons + public void AutoListAdd(string text, int ImageIndex) + { + ((EditViewControl) _ActiveView).AutoList.Add(text, ImageIndex); + } + + /// + /// Adds an item to the autolist control. + /// + /// The text to display in the autolist + /// The text to insert in the code + /// The image index in the AutoListIcons + public void AutoListAdd(string text, string InsertText, int ImageIndex) + { + ((EditViewControl) _ActiveView).AutoList.Add(text, InsertText, ImageIndex); + } + + /// + /// Adds an item to the autolist control. + /// + /// The text to display in the autolist + /// The text to insert in the code + /// + /// The image index in the AutoListIcons + public void AutoListAdd(string text, string InsertText, string ToolTip, int ImageIndex) + { + ((EditViewControl) _ActiveView).AutoList.Add(text, InsertText, ToolTip, ImageIndex); + } + + /// + /// Converts a Client pixel coordinate into a TextPoint (Column/Row) + /// + /// Pixel x position + /// Pixel y position + /// The row and column at the given pixel coordinate. + public TextPoint CharFromPixel(int x, int y) + { + return ((EditViewControl) _ActiveView).CharFromPixel(x, y); + } + + /// + /// Clears the selection in the active view. + /// + public void ClearSelection() + { + ((EditViewControl) _ActiveView).ClearSelection(); + } + + /// + /// Executes a Copy action on the selection in the active view. + /// + public void Copy() + { + ((EditViewControl) _ActiveView).Copy(); + } + + /// + /// Executes a Cut action on the selection in the active view. + /// + public void Cut() + { + ((EditViewControl) _ActiveView).Cut(); + } + + /// + /// Executes a Delete action on the selection in the active view. + /// + public void Delete() + { + ((EditViewControl) _ActiveView).Delete(); + } + + /// + /// Moves the caret of the active view to a specific row. + /// + /// the row to jump to + public void GotoLine(int RowIndex) + { + ((EditViewControl) _ActiveView).GotoLine(RowIndex); + } + + /// + /// Moves the caret of the active view to the next bookmark. + /// + public void GotoNextBookmark() + { + ((EditViewControl) _ActiveView).GotoNextBookmark(); + } + + /// + /// Moves the caret of the active view to the previous bookmark. + /// + public void GotoPreviousBookmark() + { + ((EditViewControl) _ActiveView).GotoPreviousBookmark(); + } + + + /// + /// Takes a pixel position and returns true if that position is inside the selected text. + /// + /// + /// Pixel x position. + /// Pixel y position + /// true if the position is inside the selection. + public bool IsOverSelection(int x, int y) + { + return ((EditViewControl) _ActiveView).IsOverSelection(x, y); + } + + /// + /// Execute a Paste action if possible. + /// + public void Paste() + { + ((EditViewControl) _ActiveView).Paste(); + } + + /// + /// Execute a ReDo action if possible. + /// + public void Redo() + { + ((EditViewControl) _ActiveView).Redo(); + } + + /// + /// Makes the caret in the active view visible on screen. + /// + public void ScrollIntoView() + { + ((EditViewControl) _ActiveView).ScrollIntoView(); + } + + /// + /// Scrolls the active view to a specific position. + /// + /// + public void ScrollIntoView(TextPoint Pos) + { + ((EditViewControl) _ActiveView).ScrollIntoView(Pos); + } + + /// + /// Select all the text in the active view. + /// + public void SelectAll() + { + ((EditViewControl) _ActiveView).SelectAll(); + } + + /// + /// Selects the next word (from the current caret position) that matches the parameter criterias. + /// + /// The pattern to find + /// Match case , true/false + /// Match whole words only , true/false + /// To be implemented + public void FindNext(string Pattern, bool MatchCase, bool WholeWords, bool UseRegEx) + { + ((EditViewControl) _ActiveView).SelectNext(Pattern, MatchCase, WholeWords, UseRegEx); + } + + /// + /// Finds the next occurance of the pattern in the find/replace dialog + /// + public void FindNext() + { + ((EditViewControl) _ActiveView).FindNext(); + } + + /// + /// Shows the default GotoLine dialog. + /// + /// + /// + /// //Display the Goto Line dialog + /// MySyntaxBox.ShowGotoLine(); + /// + /// + public void ShowGotoLine() + { + ((EditViewControl) _ActiveView).ShowGotoLine(); + } + + /// + /// Not yet implemented + /// + public void ShowSettings() + { + ((EditViewControl) _ActiveView).ShowSettings(); + } + + /// + /// Toggles a bookmark on the active row of the active view. + /// + public void ToggleBookmark() + { + ((EditViewControl) _ActiveView).ToggleBookmark(); + } + + /// + /// Executes an undo action if possible. + /// + public void Undo() + { + ((EditViewControl) _ActiveView).Undo(); + } + + + /// + /// Shows the Find dialog + /// + /// + /// + /// //Show FindReplace dialog + /// MySyntaxBox.ShowFind(); + /// + /// + public void ShowFind() + { + ((EditViewControl) _ActiveView).ShowFind(); + } + + /// + /// Shows the Replace dialog + /// + /// + /// + /// //Show FindReplace dialog + /// MySyntaxBox.ShowReplace(); + /// + /// + public void ShowReplace() + { + ((EditViewControl) _ActiveView).ShowReplace(); + } + + #endregion //END Public Methods + + [Browsable(false)] + [Obsolete("Use .FontName and .FontSize", true)] + public override Font Font + { + get { return base.Font; } + set { base.Font = value; } + } + + // [Browsable(true)] + // [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] + // [RefreshProperties (RefreshProperties.All)] + // public override string Text + // { + // get + // { + // return this.Document.Text; + // } + // set + // { + // this.Document.Text=value; + // } + // } + + [Browsable(false)] + [Obsolete("Apply a syntax instead", true)] + public override Color ForeColor + { + get { return base.ForeColor; } + set { base.ForeColor = value; } + } + + /// + /// The currently highlighted text in the autolist. + /// + [Browsable(false)] + public string AutoListSelectedText + { + get { return ((EditViewControl) _ActiveView).AutoList.SelectedText; } + set + { + if ((_ActiveView) == null || ((EditViewControl) _ActiveView).AutoList == null) + return; + + ((EditViewControl) _ActiveView).AutoList.SelectItem(value); + } + } + + public void Save(string filename) + { + string text = Document.Text; + + var swr = new StreamWriter(filename); + + swr.Write(text); + + swr.Flush(); + + swr.Close(); + } + + public void Open(string filename) + { + if (Document == null) + throw new NullReferenceException("CodeEditorControl.Document"); + + var swr = new StreamReader(filename); + + Document.Text = swr.ReadToEnd(); + + swr.Close(); + } + + public void AttachDocument(SyntaxDocument document) + { + //_Document=document; + + if (_Document != null) + { + _Document.ParsingCompleted -= OnParsingCompleted; + _Document.Parsing -= OnParse; + _Document.Change -= OnChange; + } + + if (document == null) + document = new SyntaxDocument(); + + _Document = document; + + if (_Document != null) + { + _Document.ParsingCompleted += OnParsingCompleted; + _Document.Parsing += OnParse; + _Document.Change += OnChange; + } + + Redraw(); + } + + protected virtual void OnParse(object Sender, EventArgs e) + { + foreach (EditViewControl ev in Views) + { + ev.OnParse(); + } + } + + protected virtual void OnParsingCompleted(object Sender, EventArgs e) + { + foreach (EditViewControl ev in Views) + { + ev.Invalidate(); + } + } + + protected virtual void OnChange(object Sender, EventArgs e) + { + if (Views == null) + return; + + + foreach (EditViewControl ev in Views) + { + ev.OnChange(); + } + OnTextChanged(EventArgs.Empty); + } + + public void RemoveCurrentRow() + { + ((EditViewControl) _ActiveView).RemoveCurrentRow(); + } + + public void CutClear() + { + ((EditViewControl) _ActiveView).CutClear(); + } + + + public void AutoListInsertSelectedText() + { + ((EditViewControl) _ActiveView).InsertAutolistText(); + } + + + protected override SplitViewChildControl GetNewView() + { + return new EditViewControl(this); + } + + protected override void OnImeModeChanged(EventArgs e) + { + base.OnImeModeChanged(e); + foreach (EditViewControl ev in Views) + { + ev.ImeMode = ImeMode; + } + } + + #region Constructor + + /// + /// Default constructor for the SyntaxBoxControl + /// + public SyntaxBoxControl() + { + try + { + Document = new SyntaxDocument(); + + + CreateViews(); + + + InitializeComponent(); + SetStyle(ControlStyles.Selectable, true); + + //assign keys + KeyboardActions.Add(new KeyboardAction(Keys.Z, false, true, false, false, Undo)); + KeyboardActions.Add(new KeyboardAction(Keys.Y, false, true, false, false, Redo)); + + KeyboardActions.Add(new KeyboardAction(Keys.F3, false, false, false, true, FindNext)); + + KeyboardActions.Add(new KeyboardAction(Keys.C, false, true, false, true, Copy)); + KeyboardActions.Add(new KeyboardAction(Keys.X, false, true, false, false, CutClear)); + KeyboardActions.Add(new KeyboardAction(Keys.V, false, true, false, false, Paste)); + + KeyboardActions.Add(new KeyboardAction(Keys.Insert, false, true, false, true, Copy)); + KeyboardActions.Add(new KeyboardAction(Keys.Delete, true, false, false, false, Cut)); + KeyboardActions.Add(new KeyboardAction(Keys.Insert, true, false, false, false, Paste)); + + KeyboardActions.Add(new KeyboardAction(Keys.A, false, true, false, true, SelectAll)); + + KeyboardActions.Add(new KeyboardAction(Keys.F, false, true, false, false, ShowFind)); + KeyboardActions.Add(new KeyboardAction(Keys.H, false, true, false, false, ShowReplace)); + KeyboardActions.Add(new KeyboardAction(Keys.G, false, true, false, true, ShowGotoLine)); + KeyboardActions.Add(new KeyboardAction(Keys.T, false, true, false, false, ShowSettings)); + + KeyboardActions.Add(new KeyboardAction(Keys.F2, false, true, false, true, ToggleBookmark)); + KeyboardActions.Add(new KeyboardAction(Keys.F2, false, false, false, true, GotoNextBookmark)); + KeyboardActions.Add(new KeyboardAction(Keys.F2, true, false, false, true, GotoPreviousBookmark)); + + KeyboardActions.Add(new KeyboardAction(Keys.Escape, false, false, false, true, ClearSelection)); + + KeyboardActions.Add(new KeyboardAction(Keys.Tab, false, false, false, false, Selection.Indent)); + KeyboardActions.Add(new KeyboardAction(Keys.Tab, true, false, false, false, Selection.Outdent)); + + AutoListIcons = _AutoListIcons; + } + catch + { + // Console.WriteLine (x.StackTrace); + } + } + + #endregion //END Constructor + + #region EventHandlers + + protected virtual void OnClipboardUpdated(CopyEventArgs e) + { + if (ClipboardUpdated != null) + ClipboardUpdated(this, e); + } + + protected virtual void OnRowMouseDown(RowMouseEventArgs e) + { + if (RowMouseDown != null) + RowMouseDown(this, e); + } + + protected virtual void OnRowMouseMove(RowMouseEventArgs e) + { + if (RowMouseMove != null) + RowMouseMove(this, e); + } + + protected virtual void OnRowMouseUp(RowMouseEventArgs e) + { + if (RowMouseUp != null) + RowMouseUp(this, e); + } + + protected virtual void OnRowClick(RowMouseEventArgs e) + { + if (RowClick != null) + RowClick(this, e); + } + + protected virtual void OnRowDoubleClick(RowMouseEventArgs e) + { + if (RowDoubleClick != null) + RowDoubleClick(this, e); + } + + + private void ParseTimer_Tick(object sender, EventArgs e) + { + Document.ParseSome(); + } + + protected virtual void OnInfoTipSelectedIndexChanged() + { + if (InfoTipSelectedIndexChanged != null) + InfoTipSelectedIndexChanged(null, null); + } + + /// + /// + /// + /// + protected override void OnEnter(EventArgs e) + { + base.OnEnter(e); + if ((_ActiveView) != null) + { + (_ActiveView).Focus(); + } + } + + + private void View_RowClick(object sender, RowMouseEventArgs e) + { + OnRowClick(e); + } + + private void View_RowDoubleClick(object sender, RowMouseEventArgs e) + { + OnRowDoubleClick(e); + } + + private void View_RowMouseDown(object sender, RowMouseEventArgs e) + { + OnRowMouseDown(e); + } + + private void View_RowMouseMove(object sender, RowMouseEventArgs e) + { + OnRowMouseMove(e); + } + + private void View_RowMouseUp(object sender, RowMouseEventArgs e) + { + OnRowMouseUp(e); + } + + private void View_ClipboardUpdated(object sender, CopyEventArgs e) + { + OnClipboardUpdated(e); + } + + + public void OnRenderRow(RowPaintEventArgs e) + { + if (RenderRow != null) + RenderRow(this, e); + } + + public void OnWordMouseHover(ref WordMouseEventArgs e) + { + if (WordMouseHover != null) + WordMouseHover(this, ref e); + } + + public void OnWordMouseDown(ref WordMouseEventArgs e) + { + if (WordMouseDown != null) + WordMouseDown(this, ref e); + } + + protected virtual void OnCaretChange(object sender) + { + if (CaretChange != null) + CaretChange(this, null); + } + + protected virtual void OnSelectionChange(object sender) + { + if (SelectionChange != null) + SelectionChange(this, null); + } + + private void View_CaretChanged(object s, EventArgs e) + { + OnCaretChange(s); + } + + private void View_SelectionChanged(object s, EventArgs e) + { + OnSelectionChange(s); + } + + private void View_DoubleClick(object sender, EventArgs e) + { + OnDoubleClick(e); + } + + private void View_MouseUp(object sender, MouseEventArgs e) + { + var ev = (EditViewControl) sender; + var ea = new MouseEventArgs(e.Button, e.Clicks, e.X + ev.Location.X + ev.BorderWidth, + e.Y + ev.Location.Y + ev.BorderWidth, e.Delta); + OnMouseUp(ea); + } + + private void View_MouseMove(object sender, MouseEventArgs e) + { + var ev = (EditViewControl) sender; + var ea = new MouseEventArgs(e.Button, e.Clicks, e.X + ev.Location.X + ev.BorderWidth, + e.Y + ev.Location.Y + ev.BorderWidth, e.Delta); + OnMouseMove(ea); + } + + private void View_MouseLeave(object sender, EventArgs e) + { + OnMouseLeave(e); + } + + private void View_MouseHover(object sender, EventArgs e) + { + OnMouseHover(e); + } + + private void View_MouseEnter(object sender, EventArgs e) + { + OnMouseEnter(e); + } + + private void View_MouseDown(object sender, MouseEventArgs e) + { + var ev = (EditViewControl) sender; + var ea = new MouseEventArgs(e.Button, e.Clicks, e.X + ev.Location.X + ev.BorderWidth, + e.Y + ev.Location.Y + ev.BorderWidth, e.Delta); + OnMouseDown(ea); + } + + private void View_KeyUp(object sender, KeyEventArgs e) + { + OnKeyUp(e); + } + + private void View_KeyPress(object sender, KeyPressEventArgs e) + { + OnKeyPress(e); + } + + private void View_KeyDown(object sender, KeyEventArgs e) + { + OnKeyDown(e); + } + + private void View_Click(object sender, EventArgs e) + { + OnClick(e); + } + + private void View_DragOver(object sender, DragEventArgs e) + { + OnDragOver(e); + } + + private void View_DragLeave(object sender, EventArgs e) + { + OnDragLeave(e); + } + + private void View_DragEnter(object sender, DragEventArgs e) + { + OnDragEnter(e); + } + + private void View_DragDrop(object sender, DragEventArgs e) + { + OnDragDrop(e); + } + + private void View_InfoTipSelectedIndexChanged(object sender, EventArgs e) + { + OnInfoTipSelectedIndexChanged(); + } + + #endregion + + #region DISPOSE() + + /// + /// + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + components.Dispose(); + } + base.Dispose(disposing); + } + + #endregion //END DISPOSE + + #region Private/Protected/Internal methods + + private void InitializeComponent() + { + components = new Container(); + var resources = new ResourceManager(typeof (SyntaxBoxControl)); + _GutterIcons = new ImageList(components); + _AutoListIcons = new ImageList(components); + ParseTimer = new Timer(components); + // + // _GutterIcons + // + _GutterIcons.ColorDepth = ColorDepth.Depth32Bit; + _GutterIcons.ImageSize = new Size(17, 17); + _GutterIcons.ImageStream = ((ImageListStreamer) (resources.GetObject("_GutterIcons.ImageStream"))); + _GutterIcons.TransparentColor = Color.Transparent; + // + // _AutoListIcons + // + _AutoListIcons.ColorDepth = ColorDepth.Depth8Bit; + _AutoListIcons.ImageSize = new Size(16, 16); + _AutoListIcons.ImageStream = ((ImageListStreamer) (resources.GetObject("_AutoListIcons.ImageStream"))); + _AutoListIcons.TransparentColor = Color.Transparent; + // + // ParseTimer + // + ParseTimer.Enabled = true; + ParseTimer.Interval = 1; + ParseTimer.Tick += ParseTimer_Tick; + } + + + protected override void OnLoad(EventArgs e) + { + Refresh(); + } + + private void Redraw() + { + if (Views == null) + return; + + foreach (EditViewControl ev in Views) + { + if (ev != null) + { + ev.Refresh(); + } + } + } + + private void InitGraphics() + { + if (Views == null || Parent == null) + return; + + foreach (EditViewControl ev in Views) + { + ev.InitGraphics(); + } + } + + + protected override void CreateViews() + { + base.CreateViews(); + + foreach (EditViewControl ev in Views) + { + if (DoOnce && ev == LowerRight) + continue; + + //attatch events to views + ev.Enter += View_Enter; + ev.Leave += View_Leave; + ev.GotFocus += View_Enter; + ev.LostFocus += View_Leave; + ev.CaretChange += View_CaretChanged; + ev.SelectionChange += View_SelectionChanged; + ev.Click += View_Click; + ev.DoubleClick += View_DoubleClick; + ev.MouseDown += View_MouseDown; + ev.MouseEnter += View_MouseEnter; + ev.MouseHover += View_MouseHover; + ev.MouseLeave += View_MouseLeave; + ev.MouseMove += View_MouseMove; + ev.MouseUp += View_MouseUp; + ev.KeyDown += View_KeyDown; + ev.KeyPress += View_KeyPress; + ev.KeyUp += View_KeyUp; + ev.DragDrop += View_DragDrop; + ev.DragOver += View_DragOver; + ev.DragLeave += View_DragLeave; + ev.DragEnter += View_DragEnter; + + if (ev.InfoTip != null) + { + ev.InfoTip.Data = ""; + ev.InfoTip.SelectedIndexChanged += View_InfoTipSelectedIndexChanged; + } + + ev.RowClick += View_RowClick; + ev.RowDoubleClick += View_RowDoubleClick; + + ev.RowMouseDown += View_RowMouseDown; + ev.RowMouseMove += View_RowMouseMove; + ev.RowMouseUp += View_RowMouseUp; + ev.ClipboardUpdated += View_ClipboardUpdated; + } + + DoOnce = true; + + AutoListIcons = AutoListIcons; + InfoTipImage = InfoTipImage; + ChildBorderStyle = ChildBorderStyle; + ChildBorderColor = ChildBorderColor; + BackColor = BackColor; + Document = Document; + ImeMode = ImeMode; + Redraw(); + } + + #endregion //END Private/Protected/Internal methods + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/SyntaxBoxControl.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/SyntaxBoxControl.resx new file mode 100644 index 0000000..56378da --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/SyntaxBoxControl.resx @@ -0,0 +1,473 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 204, 21 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFpTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0xLjAuMzMw + MC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZT + eXN0ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMA + AABoQgAAAk1TRnQBSQFMAgEBDQEAAQ4BAAEEAQABEQEAAREBAAT/ASEBAAj/AUIBTQE2BwABNgMAASgD + AAFEAwABRAMAAQEBAAEgBQABQAFILQAB/wMAAf8DAAH/AwAB/wMAAf/3AAH/AwAB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB/+sAAf8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/4wAB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/2wAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/9cAGf8B9wEjATQB/wH3ASMBNA3/AfcBIwE0Af8B9wEjATQB + /wMAAf/TAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcB + IwE0Cf8B9wEjATQB/wH3ASMBNAH/AwAB/88AAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQJ/wH3ASMBNAH/AfcBIwE0Af8DAAH/zwAB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQJ/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQJ/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB + /wMAAf/PAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcB + IwE0Cf8B9wEjATQB/wH3ASMBNAH/AwAB/88AAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQJ/wH3ASMBNAH/AfcBIwE0Af8DAAH/0wAR/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQJ/wH3ASMBNAn/AfcBIwE0Af8DAAH/1wAB/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQN/wH3ASMBNAH/AfcBIwE0Af8DAAH/2wAB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/4wAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf/rAAH/AwAB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB//cAAf8DAAH/AwAB/wMAAf8DAAH//wAB + /wMAAf8DAAH/AwAB/wMAAf8zAAH/AwAB/wMAAf8DAAH/AwAB/zMAAf8DAAH/AwAB/wMAAf8DAAH/MwAB + /wMAAf8DAAH/AwAB/wMAAf8rAAH/AwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8DAAH/AwAB/yMAAf8DAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wMAAf8DAAH/IwAB/wMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB + /wMAAf8jAAH/AwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB + /x8AAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/GwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8bAAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB + /xsAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/FwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/EwAB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/EwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8DAAH/EwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/DwAB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wsAAf8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8LAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/CwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AwAB/wsAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNA3/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8LAAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wMAAf8LAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQN + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/CwAB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNA3/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AwAB/wcAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcB + IwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wMAAf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQJ/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8DAAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQJ/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wMAAf8DAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8DAAH/AwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQJ + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wMAAf8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AwAB/wMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wMAAf8DAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQJ/wH3ASMBNAn/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8DAAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQJ/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8DAAH/AwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQR + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Ef8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AwAB/wMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Df8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQJ/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wMAAf8DAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQJ + /wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8DAAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQJ/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8HAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQJ/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wMAAf8LAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Bf8B9wEjATQB/wH3ASMBNAn/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/CwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAn/AfcBIwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8LAAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQJ/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AwAB/wsAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Df8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8LAAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Ff8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8LAAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQN/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/CwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Df8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/w8AAf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/xMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB + /xMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/xMAAf8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AwAB/xcAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/GwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8bAAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AwAB/xsAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/HwAB/wMAAf8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wMAAf8jAAH/AwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB/yMAAf8DAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wMAAf8DAAH/IwAB/wMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AwAB/wMAAf8rAAH/AwAB/wMAAf8DAAH/AwAB/zMAAf8DAAH/AwAB/wMAAf8DAAH/MwAB + /wMAAf8DAAH/AwAB/wMAAf8zAAH/AwAB/wMAAf8DAAH/AwAB/zMAAf8DAAH/AwAB/wMAAf8DAAH/MwAB + /wMAAf8DAAH/AwAB/wMAAf8zAAH/AwAB/wMAAf8DAAH/AwAB/zMAAf8DAAH/AwAB/wMAAf8DAAH/KwAB + /wMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wMAAf8jAAH/AwAB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB/yMAAf8DAAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8DAAH/IwAB/wMAAf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wMAAf8fAAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB + /xsAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/GwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8bAAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB + /xcAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/xMAAf8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AwAB/xMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/xMAAf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/w8AAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wMAAf8LAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8DAAH/CwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB + /wsAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8LAAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Ff8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wMAAf8LAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQN/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/CwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Ef8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8LAAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQN/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/BwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AwAB/wMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAX/AfcB + IwE0Af8B9wEjATQJ/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wMAAf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAX/AfcBIwE0Af8B9wEjATQJ/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQJ/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wMAAf8DAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Gf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wMAAf8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8DAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AwAB/wMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQF/wH3ASMBNAH/AfcB + IwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wMAAf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8DAAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNA3/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAX/AfcBIwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8DAAH/AwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Bf8B9wEjATQB + /wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8DAAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQJ/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8DAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQJ/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Bf8B9wEjATQJ/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wMAAf8DAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQR/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8HAAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQJ/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB + /wsAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQF/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8LAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQN/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/CwAB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/CwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Df8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB + /wsAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNA3/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8LAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wMAAf8LAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Ff8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wMAAf8PAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8TAAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8TAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wMAAf8TAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8XAAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB + /xsAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/GwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8bAAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB + /x8AAf8DAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8DAAH/IwAB + /wMAAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wMAAf8jAAH/AwAB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/AwAB/yMAAf8DAAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8DAAH/KwAB/wMAAf8DAAH/AwAB + /wMAAf8zAAH/AwAB/wMAAf8DAAH/AwAB/zMAAf8DAAH/AwAB/wMAAf8DAAH/MwAB/wMAAf8DAAH/AwAB + /wMAAf//AAH/AwAB/wMAAf8DAAH/AwAB/zIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/7MAAf8D + AAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8DAAH/IgABgAH/AgAB + gAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/GwAB/wMAAf8DAAH/AwAB + /wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/ysAAf8vAAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB + /xoAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB + /wIAAYAB/xMAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8B + AAH/AwAB/ycAAf8DAAH/JwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B + 9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/EgABgAH/AgAB + gAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgAB + gAH/AgABgAH/CwAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD + /wEAA/8BAAP/AQAB/wMAAf8jAAH/AQAD/wMAAf8fAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8DAAH/DgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgAB + gAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/CwAD/wEAA/8BAAP/AQAD/wEAA/8B + AAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAB/wMAAf8LAAH/AwAB/wMAAf8D + AAH/AwAB/wMAAf8DAAH/AQAD/wEAA/8DAAH/GwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMB + NBn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/woAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB + /wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB + /wcAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD + /wEAAf8DAAH/CwAB/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wMAAf8TAAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/BgABgAH/AgABgAH/AgAB + gAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgAB + gAH/AgABgAH/AgABgAH/BwAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8B + AAP/AQAD/wEAA/8BAAP/AQAB/wMAAf8LAAH/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8B + AAP/AQAD/wMAAf8PAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMB + NAH/AfcBIwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8D + AAH/BgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgAB + gAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/BwAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD + /wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAB/wMAAf8LAAH/AQAD/wEAA/8BAAP/AQAD + /wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8DAAH/CwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wYAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB + /wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wcAA/8B + AAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAAf8D + AAH/CwAB/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8DAAH/DwAB/wH3ASMB + NAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAn/AfcBIwE0Af8B + 9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/wYAAYAB/wIAAYAB/wIAAYAB + /wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB + /wIAAYAB/wIAAYAB/wcAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD + /wEAA/8BAAP/AQAD/wEAAf8DAAH/CwAB/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD + /wMAAf8TAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcB + IwE0Cf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/CgAB + gAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgAB + gAH/AgABgAH/AgABgAH/CwAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8B + AAP/AQAD/wEAA/8BAAP/AQAB/wMAAf8LAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AQAD/wEAA/8D + AAH/GwAB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNBH/AfcBIwE0Af8B9wEjATQB/wH3ASMB + NAH/AfcBIwE0Af8B9wEjATQB/wMAAf8OAAGAAf8CAAGAAf8CAAGAAf8CAAGAAf8CAAGAAf8CAAGAAf8C + AAGAAf8CAAGAAf8CAAGAAf8CAAGAAf8CAAGAAf8CAAGAAf8CAAGAAf8LAAP/AQAD/wEAA/8BAAP/AQAD + /wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAH/AwAB/yMAAf8BAAP/AwAB + /x8AAf8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Cf8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/xIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB + /wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/wIAAYAB/xMAA/8BAAP/AQAD/wEAA/8B + AAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAP/AQAD/wEAA/8BAAH/AwAB/ycAAf8DAAH/JwAB/wH3ASMB + NAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B + 9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8DAAH/GgABgAH/AgABgAH/AgABgAH/AgABgAH/AgABgAH/AgAB + gAH/AgABgAH/AgABgAH/AgABgAH/GwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB + /wMAAf8DAAH/AwAB/ysAAf8vAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB + /wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AwAB/yYAAYAB/wIAAYAB/wIAAYAB/wIAAYAB + /wIAAYAB/7MAAf8DAAH/AfcBIwE0Af8B9wEjATQB/wH3ASMBNAH/AfcBIwE0Af8B9wEjATQB/wMAAf8D + AAH/9wAB/wMAAf8DAAH/AwAB/wMAAf8YAAFCAU0BPgcAAT4DAAEoAwABRAMAAUQDAAEBAQABAQUAATAB + AxYAA/8BAAH8AR8BgAkAAfABBwGACQAB4AEDAYAJAAHAAQEBgAkAAYABAAGACQABgAEAAYBFAAGAAQAB + gAkAAYABAAGACQABwAEBAYAJAAHgAQMBgAkAAfABBwGACQAB/AEfAYAJAAH8AR8B/gEPAf8BBwH/AYMB + 8AMAAfABBwH4AQMB/AEBAf4BAAHwAwAB4AEDAfABAQH4AQAB/AEAAXADAAHAAQEB4AEAAfABAAF4AQAB + MAMAAYABAAHAAQABYAEAATABAAEQAwABgAEAAcABAAFgAQABMAEAARA/AAGAAQABwAEAAWABAAEwAQAB + EAMAAYABAAHAAQABYAEAATABAAEQAwABwAEBAeABAAHwAQABeAEAATADAAHgAQMB8AEBAfgBAAH8AQAB + cAMAAfABBwH4AQMB/AEBAf4BAAHwAwAB/AEfAf4BDwH/AQcB/wGDAfADAAH8AR8B/gEPAf8BBwH/AYMB + 8AMAAfABBwH4AQMB/AEBAf4BAAHwAwAB4AEDAfABAQH4AQAB/AEAAXADAAHAAQEB4AEAAfABAAF4AQAB + MAMAAYABAAHAAQABYAEAATABAAEQAwABgAEAAcABAAFgAQABMAEAARA/AAGAAQABwAEAAWABAAEwAQAB + EAMAAYABAAHAAQABYAEAATABAAEQAwABwAEBAeABAAHwAQABeAEAATADAAHgAQMB8AEBAfgBAAH8AQAB + cAMAAfABBwH4AQMB/AEBAf4BAAHwAwAB/AEfAf4BDwH/AQcB/wGDAfADAAf/AYMB8AMAAfwBHwT/Af4B + AAHwAwAB8AEHAeABAAH/Ad8B/AEAAXADAAHgAQMBwAEAAX8BzwH4AQABMAMAAcABAQGAAQABPwHHAfAB + AAEQAwABwAEBAYABAAEwAQMB8AEAARADAAGAAQABgAEAATABAQHgBQABgAEAAYABAAEwAQAB4AUAAYAB + AAGAAQABMAEAAWAFAAGAAQABgAEAATABAAHgBQABgAEAAYABAAEwAQEB4AUAAcABAQGAAQABMAEDAfAB + AAEQAwABwAEBAYABAAE/AccB8AEAARADAAHgAQMBwAEAAX8BzwH4AQABMAMAAfABBwHgAQAB/wHfAfwB + AAFwAwAB/AEfBP8B/gEAAfADAAf/AYMB8AMACw== + + + + 17, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFpTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0xLjAuMzMw + MC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZT + eXN0ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMA + AAAmDgAAAk1TRnQBSQFMAgEBCQEAAQoBAAEEAQABEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQC + AAEoAwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB + 3AHAAQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IB + AAM5AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8B + MwMAAWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYC + AAFmAZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMC + AAHMAWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQAB + ZgEAATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8B + AAEzAWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQAB + MwGZAWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQAB + MwLMAQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQAB + MwEAAWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMB + mQEAAWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQAB + ZgGZAWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYB + zAH/AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMB + mQEAAZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgAB + mQFmATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwB + AAKZAf8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB + /wEzAQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQAB + mQEAAcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYC + AAHMAWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYB + AAHMApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8C + AAHMAf8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQAB + mQEAAcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMB + AAHMAmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB + /wGZAcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC + /wEzAQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC + /wFmAQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gB + AAHwAfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/0cAAQY+AAH+AgY8 + AAP+AgY8AAP+AgYBAAEFOgAD/gEAAgUB/TgAAQMBAAH+AQACBQP9NgADAwEAAgUD/TYAAvsDAwEAA/02 + AAH7Af8C+wMDAQAB/TgAAfsB/wL7AwM6AAH7Af8C+wMDOgAB+wH/AvsBAzwAAfsB/wH7PgAB+7gAAewB + /wEHAf8BBwH/AQcB/wEHAf8BBwEAAQcB/zIAAewBBwH/AewBBwPsAf8BBwMAAQcyAAHsAf8BBwH/AQcB + /wEHAf8BBwEAAQUBAAEFAwAB7AH7AQcB+wEHAfsBBwH7KAAC7AEHAewBBwLsAQcBAAEFAf0BAAEFAwAB + 7AEHAfsDAAH7AQcPAAHsGAAB7AH/AQcB/wEHAf8BBwH/AQAB/QEAAf0EAAHsAfsBBwH7AQcB+wEHAfsO + AAHsAf4BAAHsEAABBwHsAQAB7AEHAQAB7AEHAewBBwLsAf8BBwIAA/0DAAHsAQcB+wMAAfsBBw0AAewC + /gEAAuwJAAEHBAABBwEAAQcBAAEHAQABBwHsAf8BBwH/AQcB/wEHAf8BAAP9AQAB/wIAAewB+wEHAfsB + BwH7AQcB+wEAAfsBBwH7AQcB+wcAAewB/gHsAf4BAALsBQAB7AIHBQAB7AEHAwABBwLsAQcB/wEHAf8B + BwH/AQcB/wEAAf0BAAH/AQcDAAfsAfsDAAH7AQcHAALsAf4BBgH+AQAB7AUAAewB/wEHAQAE7AcAAewB + /wEHAf8BBwH/AQcB/wEHAf8BAAH/AQcB/wgAAewB+wEHAfsBBwH7AQcB+wcAAewB/gEGAf4BBgH+BwAC + 7AUAAewBBwMAAQcP7AgAAewBBwH7AwAB+wEHCAAB7AH+AQYB/gEGAf4NAAEHAQABBwEAAQcBAAEHBAAB + 7AX/AQcLAAHsAfsBBwH7AQcB+wEHAfsJAAHsAf4BBgH+AewOAAEHAewBAAHsAQcFAAHsBf8BBwwAB+wK + AAHsAf4B7BkAAewGBx4AAeymAAHsLwAB7AH/AfsC/wH7Af8JAAHsAf8EBw0AAQcXAAEGBAAC7AH/AuwB + /wHsCQAB7AH/AQcBAAIHDQAB+wEHFQAB/gIGAwAB7AH7AewB/wH7AewB+wkAAewB/wMAAQcNAAH7FwAB + /gIGAgAC7AH/AfsB/wH7AewJAAHsBf8MAAEDAfsBBxMAA+wBAAH+AwAG7AQAAewFAAEHBuwCAAHsBwAC + +wEHAvsDAAHsDgAB7BAAAewB/gEAAewEAAHsAQcFAAHsAf4BAAHsBQAB/wEHAQABBwH7AgAB7AH+AQAB + 7AwAAewPAAHsAv4BAALsAwAB7AMHAgAB7AL+AQAC7AUAAf8BBwH7AgAB7AL+AQAC7AsAAewPAAHsAf4B + 7AH+AQAC7AMAA+wCAAHsAf4B7AH+AQAC7AQAAQMBAAEDAgAB7AH+AewB/gEAAuwKAAHsAwABAQsAAuwB + /gEGAf4BAAHsCAAC7AH+AQYB/gEAAewJAALsAf4BBgH+AQAB7AUAAQMEAAHsAgAB/QIBCgAB7AH+AQYB + /gEGAf4JAAHsAf4BBgH+AQYB/goAAewB/gEGAf4BBgH+BQAB+wIDAQAF7AEAAf0CAQoAAewB/gEGAf4B + BgH+CQAB7AH+AQYB/gEGAf4KAAHsAf4BBgH+AQYB/gMAA/sCAwcAAf0MAAHsAf4BBgH+AewKAAHsAf4B + BgH+AewLAAHsAf4BBgH+AewEAAP7AgMUAAHsAf4B7AwAAewB/gHsDQAB7AH+AewGAAP7FgAB7A4AAewP + AAHsCAAB+0sAAUIBTQE+BwABPgMAASgDAAFAAwABMAMAAQEBAAEBBQABgAEBFgAD/wEAAf0B/wYAAfgB + /wYAAfABfwYAAeABLwYAAfABBwYAAfgBAwYAAfABAQYAAeABAwYAAcABBwYAAYABDwYAAcABHwYAAeAB + DwYAAfABHwYAAfgBPwYAAfwBfwYAAf4B/wcAAQEG/wEAAQEG/wEAAQEBgAX/AQABAQEAAX8B/wF/Av8B + AAEBAQABfwH+AT8C/wEAAQEBAAF/AfwBHwH/AcEBAAEBAQABAwH4AQ8BxwGIAQABAQEAAQEB+AEHAYAB + HAEAAQEBgAEBAfgBBwGAAT4BAAEBAfwBAQH4AQcBzwGcAQABAQH8AQEB/AEHAf8BiAHwAQ8B/AEBAf4B + DwH/AcEB8AEPAf4BAwH/AR8C/wHwAQ8D/wG/Av8B+AEfDv8BAAH/AQEB/wHvAv8B7wEAAf8BAQH/AccC + /wHHAQAB/wEBAf8BwwL/AYMBAAH/AQEB/wHHAv8BwQEAAe8BAQHfAYMB3wH/AQMBAAHHAQEBjwEBAY8B + /wF3Af8BgwGbAQcBAQEHAf8BfwH/AQEBggEDAYIBAwH/AXcB/wEAAcYBAQHGAQEB7wFjAf8BAAH+AQEB + /gEBAccBQQH/AQAB/gEBAf4BAQGAAQAB/wGAAf8BAQH/AgEB8QH/AcEB/wGDAf8BgwGAAfsB/wHjAf8B + xwH/AccBwQL/AfcB/wHvAf8B7wHjB/8B9wH/FgAL + + + + 459, 331 + + + SyntaxBoxControl + + + False + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/SyntaxBoxDesigner.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/SyntaxBoxDesigner.cs new file mode 100644 index 0000000..aa22ece --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/Syntaxbox/SyntaxBoxDesigner.cs @@ -0,0 +1,57 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections; +using System.ComponentModel.Design; +using System.Windows.Forms.Design; +using Alsing.SourceCode; + +namespace Alsing.Windows.Forms.SyntaxBox +{ + /// + /// Designer for the SyntaxBoxControl + /// + public class SyntaxBoxDesigner : ControlDesigner + { + protected ISelectionService SelectionService + { + get { return (ISelectionService) GetService(typeof (ISelectionService)); } + } + + protected virtual IDesignerHost DesignerHost + { + get { return (IDesignerHost) base.GetService(typeof (IDesignerHost)); } + } + + //protected void OnActivate(object s, EventArgs e) {} + + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + if (DesignerHost != null) + { + DesignerTransaction trans = DesignerHost.CreateTransaction("Adding Syntaxdocument"); + var sd = DesignerHost.CreateComponent(typeof (SyntaxDocument)) as SyntaxDocument; + + var sb = Control as SyntaxBoxControl; + + if (sb == null) + { + trans.Cancel(); + } + else + { + sb.Document = sd; + trans.Commit(); + } + } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/ThumbControl/ThumbControl.Designer.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/ThumbControl/ThumbControl.Designer.cs new file mode 100644 index 0000000..109b17f --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/ThumbControl/ThumbControl.Designer.cs @@ -0,0 +1,47 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.Windows.Forms.CoreLib +{ + partial class ThumbControl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + + } + + #endregion + } +} diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/ThumbControl/ThumbControl.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/ThumbControl/ThumbControl.cs new file mode 100644 index 0000000..6ee3e1f --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Controls/ThumbControl/ThumbControl.cs @@ -0,0 +1,31 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Windows.Forms; + +namespace Alsing.Windows.Forms.CoreLib +{ + public partial class ThumbControl : Control + { + public ThumbControl() + { + InitializeComponent(); + } + + /// + /// Draws a 2px Raised Border for the ThumbControl + /// + /// + protected override void OnPaint(PaintEventArgs e) + { + ControlPaint.DrawBorder3D(e.Graphics, 0, 0, Width, Height, Border3DStyle.Raised); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/CollectionEditorGui.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/CollectionEditorGui.cs new file mode 100644 index 0000000..a72dbc0 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/CollectionEditorGui.cs @@ -0,0 +1,414 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Collections; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; +using System.Windows.Forms.Design; + +namespace Alsing.Design +{ + /// + /// Summary description for CollectionEditorGui. + /// + [ToolboxItem(false)] + public class CollectionEditorGui : UserControl + { + public Button btnAdd; + public Button btnCancel; + public Button btnDown; + public Button btnDropdown; + public Button btnOK; + public Button btnRemove; + public Button btnUp; + + /// + /// Required designer variable. + /// + private Container components; + + private GroupBox groupBox1; + + public Label lblMembers; + public Label lblProperties; + public ListBox lstMembers; + public Panel pnlMain; + public Panel pnlMembers; + public PropertyGrid pygProperties; + + public CollectionEditorGui() + { + // This call is required by the Windows.Forms Form Designer. + InitializeComponent(); + + // TODO: Add any initialization after the InitForm call + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + public void Bind() + { + var e = EditValue as ICollection; + if (e == null) + { + MessageBox.Show("EditValue is null"); + } + else + { + lstMembers.Items.Clear(); + foreach (object o in e) + { + lstMembers.Items.Add(o); + } + + EnableRemove(); + SelectObject(); + } + } + + private void lstMembers_DrawItem(object sender, DrawItemEventArgs e) + { + try + { + if (e.Index == -1) + return; + + int c = lstMembers.Items.Count; + SizeF s = e.Graphics.MeasureString(c.ToString(), lstMembers.Font); + var maxwidth = (int) s.Width; + if (maxwidth < 16 + 2) + maxwidth = 16 + 2; + + var r = new Rectangle(0, e.Bounds.Top, maxwidth, lstMembers.ItemHeight); + bool SupportPaint = Editor.GetPaintValueSupported(); + int w = SupportPaint ? 20 : 0; + + var rcItem = new Rectangle(r.Right + w, r.Top, e.Bounds.Width - r.Right - w, lstMembers.ItemHeight); + + ControlPaint.DrawBorder3D(e.Graphics, r, Border3DStyle.Raised, Border3DSide.All); + StringFormat sf = StringFormat.GenericDefault; + sf.Alignment = StringAlignment.Far; + r.Inflate(-1, -1); + e.Graphics.DrawString(e.Index.ToString(), lstMembers.Font, Brushes.Black, r, sf); + + + bool Selected = ((int) e.State & (int) DrawItemState.Selected) != 0; + + using (SolidBrush bg = GetBgBrush(Selected)) + using (SolidBrush fg = GetFgBrush(Selected)) + { + e.Graphics.FillRectangle(bg, rcItem); + if (Selected && e.Index != -1) + { + if (((int) e.State & (int) DrawItemState.Focus) != 0) + { + ControlPaint.DrawFocusRectangle(e.Graphics, rcItem); + } + } + + if (e.Index >= 0) + { + object o = lstMembers.Items[e.Index]; + string name = GetDisplayText(o); + e.Graphics.DrawString(name, lstMembers.Font, fg, rcItem); + } + } + } + catch {} + } + + private SolidBrush GetFgBrush(bool Selected) + { + SolidBrush fg = Selected ? new SolidBrush(SystemColors.HighlightText) : new SolidBrush(lstMembers.ForeColor); + return fg; + } + + private SolidBrush GetBgBrush(bool Selected) + { + SolidBrush bg = Selected ? new SolidBrush(SystemColors.Highlight) : new SolidBrush(lstMembers.BackColor); + return bg; + } + + private void lstMembers_SelectedIndexChanged(object sender, EventArgs e) + { + EnableRemove(); + SelectObject(); + } + + private void SelectObject() + { + pygProperties.SelectedObject = lstMembers.SelectedIndex >= 0 ? lstMembers.SelectedItem : null; + } + + private void EnableRemove() + { + btnRemove.Enabled = lstMembers.SelectedIndices.Count > 0; + } + + + private static string GetDisplayText(object Item) + { + string ObjectName = null; + + if (Item == null) + { + return string.Empty; + } + PropertyDescriptor descriptor1 = TypeDescriptor.GetProperties(Item)["Name"]; + if (descriptor1 != null) + { + ObjectName = ((string) descriptor1.GetValue(Item)); + if (!string.IsNullOrEmpty(ObjectName)) + { + return ObjectName; + } + } + + if (string.IsNullOrEmpty(ObjectName)) + { + ObjectName = Item.GetType().Name; + } + return ObjectName; + } + + public void AddObject(object o) + { + Editor.AddObject(o); + } + + public void RemoveObject(object o) + { + Editor.RemoveObject(o); + } + + private void btnDown_Click(object sender, EventArgs e) {} + + private void btnUp_Click(object sender, EventArgs e) {} + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + var resources = new System.Resources.ResourceManager(typeof (CollectionEditorGui)); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnOK = new System.Windows.Forms.Button(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.pygProperties = new System.Windows.Forms.PropertyGrid(); + this.lstMembers = new System.Windows.Forms.ListBox(); + this.btnUp = new System.Windows.Forms.Button(); + this.btnDown = new System.Windows.Forms.Button(); + this.pnlMembers = new System.Windows.Forms.Panel(); + this.btnRemove = new System.Windows.Forms.Button(); + this.lblMembers = new System.Windows.Forms.Label(); + this.btnDropdown = new System.Windows.Forms.Button(); + this.btnAdd = new System.Windows.Forms.Button(); + this.pnlMain = new System.Windows.Forms.Panel(); + this.lblProperties = new System.Windows.Forms.Label(); + this.pnlMembers.SuspendLayout(); + this.pnlMain.SuspendLayout(); + this.SuspendLayout(); + // + // btnCancel + // + this.btnCancel.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); + this.btnCancel.Location = new System.Drawing.Point(456, 312); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.TabIndex = 0; + this.btnCancel.Text = "Cancel"; + // + // btnOK + // + this.btnOK.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); + this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnOK.Location = new System.Drawing.Point(376, 312); + this.btnOK.Name = "btnOK"; + this.btnOK.TabIndex = 1; + this.btnOK.Text = "OK"; + // + // groupBox1 + // + this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | + System.Windows.Forms.AnchorStyles.Right); + this.groupBox1.Location = new System.Drawing.Point(8, 296); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(520, 8); + this.groupBox1.TabIndex = 2; + this.groupBox1.TabStop = false; + // + // pygProperties + // + this.pygProperties.CommandsVisibleIfAvailable = true; + this.pygProperties.Dock = System.Windows.Forms.DockStyle.Fill; + this.pygProperties.HelpVisible = false; + this.pygProperties.LargeButtons = false; + this.pygProperties.LineColor = System.Drawing.SystemColors.ScrollBar; + this.pygProperties.Location = new System.Drawing.Point(240, 16); + this.pygProperties.Name = "pygProperties"; + this.pygProperties.Size = new System.Drawing.Size(280, 280); + this.pygProperties.TabIndex = 3; + this.pygProperties.Text = "propertyGrid1"; + this.pygProperties.ToolbarVisible = false; + this.pygProperties.ViewBackColor = System.Drawing.SystemColors.Window; + this.pygProperties.ViewForeColor = System.Drawing.SystemColors.WindowText; + // + // lstMembers + // + this.lstMembers.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | + System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right); + this.lstMembers.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + this.lstMembers.IntegralHeight = false; + this.lstMembers.ItemHeight = 16; + this.lstMembers.Location = new System.Drawing.Point(0, 16); + this.lstMembers.Name = "lstMembers"; + this.lstMembers.Size = new System.Drawing.Size(208, 240); + this.lstMembers.TabIndex = 4; + this.lstMembers.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lstMembers_DrawItem); + this.lstMembers.SelectedIndexChanged += new System.EventHandler(this.lstMembers_SelectedIndexChanged); + // + // btnUp + // + this.btnUp.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); + this.btnUp.Image = ((System.Drawing.Bitmap) (resources.GetObject("btnUp.Image"))); + this.btnUp.Location = new System.Drawing.Point(212, 16); + this.btnUp.Name = "btnUp"; + this.btnUp.Size = new System.Drawing.Size(22, 28); + this.btnUp.TabIndex = 5; + this.btnUp.Click += new System.EventHandler(this.btnUp_Click); + // + // btnDown + // + this.btnDown.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); + this.btnDown.Image = ((System.Drawing.Bitmap) (resources.GetObject("btnDown.Image"))); + this.btnDown.Location = new System.Drawing.Point(212, 48); + this.btnDown.Name = "btnDown"; + this.btnDown.Size = new System.Drawing.Size(22, 28); + this.btnDown.TabIndex = 6; + this.btnDown.Click += new System.EventHandler(this.btnDown_Click); + // + // pnlMembers + // + this.pnlMembers.Controls.AddRange(new System.Windows.Forms.Control[] + { + this.btnRemove, this.lstMembers, this.lblMembers, this.btnDown, + this.btnUp, this.btnDropdown, this.btnAdd + }); + this.pnlMembers.Dock = System.Windows.Forms.DockStyle.Left; + this.pnlMembers.Name = "pnlMembers"; + this.pnlMembers.Size = new System.Drawing.Size(240, 296); + this.pnlMembers.TabIndex = 7; + // + // btnRemove + // + this.btnRemove.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); + this.btnRemove.Location = new System.Drawing.Point(136, 264); + this.btnRemove.Name = "btnRemove"; + this.btnRemove.Size = new System.Drawing.Size(72, 24); + this.btnRemove.TabIndex = 11; + this.btnRemove.Text = "Remove"; + // + // lblMembers + // + this.lblMembers.Dock = System.Windows.Forms.DockStyle.Top; + this.lblMembers.Name = "lblMembers"; + this.lblMembers.Size = new System.Drawing.Size(240, 16); + this.lblMembers.TabIndex = 10; + this.lblMembers.Text = "Members:"; + // + // btnDropdown + // + this.btnDropdown.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | + System.Windows.Forms.AnchorStyles.Right); + this.btnDropdown.Image = ((System.Drawing.Bitmap) (resources.GetObject("btnDropdown.Image"))); + this.btnDropdown.Location = new System.Drawing.Point(95, 264); + this.btnDropdown.Name = "btnDropdown"; + this.btnDropdown.Size = new System.Drawing.Size(24, 24); + this.btnDropdown.TabIndex = 9; + this.btnDropdown.Visible = false; + // + // btnAdd + // + this.btnAdd.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); + this.btnAdd.Location = new System.Drawing.Point(8, 264); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(88, 24); + this.btnAdd.TabIndex = 12; + this.btnAdd.Text = "Add"; + // + // pnlMain + // + this.pnlMain.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | + System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right); + this.pnlMain.Controls.AddRange(new System.Windows.Forms.Control[] + {this.pygProperties, this.lblProperties, this.pnlMembers}); + this.pnlMain.Location = new System.Drawing.Point(8, 0); + this.pnlMain.Name = "pnlMain"; + this.pnlMain.Size = new System.Drawing.Size(520, 296); + this.pnlMain.TabIndex = 8; + // + // lblProperties + // + this.lblProperties.Dock = System.Windows.Forms.DockStyle.Top; + this.lblProperties.Location = new System.Drawing.Point(240, 0); + this.lblProperties.Name = "lblProperties"; + this.lblProperties.Size = new System.Drawing.Size(280, 16); + this.lblProperties.TabIndex = 9; + this.lblProperties.Text = "Properties:"; + // + // CollectionEditorGui + // + this.Controls.AddRange(new System.Windows.Forms.Control[] + {this.groupBox1, this.btnOK, this.btnCancel, this.pnlMain}); + this.Name = "CollectionEditorGui"; + this.Size = new System.Drawing.Size(536, 352); + this.pnlMembers.ResumeLayout(false); + this.pnlMain.ResumeLayout(false); + this.ResumeLayout(false); + } + + #endregion + + #region PUBLIC PROPERTY EDITOR + + public ComponaCollectionEditor Editor { get; set; } + + #endregion + + #region PUBLIC PROPERTY EDITORSERVICE + + public IWindowsFormsEditorService EditorService { get; set; } + + #endregion + + #region PUBLIC PROPERTY EDITVALUE + + public object EditValue { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/CollectionEditorGui.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/CollectionEditorGui.resx new file mode 100644 index 0000000..73530c3 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/CollectionEditorGui.resx @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Public + + + Public + + + Public + + + Public + + + Public + + + + R0lGODlhCQAJAPEAAP///2FhYQAAAMDAwCH5BAEAAAMALAAAAAAJAAkAAAIRnBenwYrcDJxvwnNdXpEn + UwAAOw== + + + + Public + + + + R0lGODlhCQAJAPEAAP///2FhYQAAAMDAwCH5BAEAAAMALAAAAAAJAAkAAAIRnIOmg7GXXlOtJhtZlXk5 + VQAAOw== + + + + Public + + + Public + + + Public + + + Public + + + R0lGODlhCQAJAPEAAP///2FhYQAAAMDAwCH5BAEAAAMALAAAAAAJAAkAAAINnI95wd3jnolJVoXzKAA7 + + + Public + + + Public + + + Public + + + CollectionEditorGui + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/ComponaCollectionEditor.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/ComponaCollectionEditor.cs new file mode 100644 index 0000000..d54b7e3 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/ComponaCollectionEditor.cs @@ -0,0 +1,356 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing; +using System.Windows.Forms; +using System.Windows.Forms.Design; + +namespace Alsing.Design +{ + public class ComponaCollectionEditor : CollectionEditor + { + #region EditorImplementation + + private ComponaCollectionForm Form; + public ComponaCollectionEditor(Type t) : base(t) {} + + public IDesignerHost DesignerHost + { + get + { + var designer = (IDesignerHost) GetService(typeof (IDesignerHost)); + return designer; + } + } + + public void AddObject(object o) + { + Form.AddObject(o); + } + + public void RemoveObject(object o) + { + Form.RemoveObject(o); + } + + + protected virtual CollectionEditorGui CreateGUI() + { + return new CollectionEditorGui(); + } + + protected override CollectionForm CreateCollectionForm() + { + Form = new ComponaCollectionForm(this) {StartPosition = FormStartPosition.CenterScreen}; + return Form; + } + + #endregion + + #region CollectionForm + + protected class ComponaCollectionForm : CollectionForm + { + private readonly ArrayList CreatedItems = new ArrayList(); + private readonly ComponaCollectionEditor Editor; + private readonly CollectionEditorGui GUI; + private readonly ArrayList RemovedItems = new ArrayList(); + private bool IsDirty; + + + public ComponaCollectionForm(CollectionEditor e) : base(e) + { + Editor = e as ComponaCollectionEditor; + + if (Editor != null) + GUI = Editor.CreateGUI(); + + GUI.Visible = true; + GUI.Dock = DockStyle.Fill; + Controls.Add(GUI); + AcceptButton = GUI.btnOK; + CancelButton = GUI.btnCancel; + Size = new Size(630, 470); + GUI.Editor = e as ComponaCollectionEditor; + + Type[] types = NewItemTypes; + if (types.Length > 1) + { + GUI.btnDropdown.Visible = true; + GUI.btnDropdown.ContextMenu = new ContextMenu(); + for (int i = 0; (i < types.Length); i ++) + { + GUI.btnDropdown.ContextMenu.MenuItems.Add(new TypeMenuItem(types[i], btnDropDownMenuItem_Click)); + } + } + + GUI.btnRemove.Click += btnRemove_Click; + GUI.btnAdd.Click += btnAdd_Click; + GUI.btnCancel.Click += btnCancel_Click; + GUI.btnOK.Click += btnOK_Click; + GUI.btnUp.Click += btnUp_Click; + GUI.btnDown.Click += btnDown_Click; + GUI.btnDropdown.Click += btnDropDown_Click; + } + + + public void RemoveObject(object o) + { + int index = GUI.lstMembers.Items.IndexOf(o); + RemovedItems.Add(o); + object i = o; + Editor.DestroyInstance(i); + CreatedItems.Remove(i); + GUI.lstMembers.Items.RemoveAt(GUI.lstMembers.SelectedIndex); + IsDirty = true; + if (index < GUI.lstMembers.Items.Count) + GUI.lstMembers.SelectedIndex = index; + else if (GUI.lstMembers.Items.Count > 0) + GUI.lstMembers.SelectedIndex = GUI.lstMembers.Items.Count - 1; + } + + public void AddObject(object o) + { + var e = GUI.EditValue as IList; + + e.Add(o); + + IsDirty = true; + GUI.lstMembers.Items.Add(o); + CreatedItems.Add(o); + if (o is Component) + { + var cp = o as Component; + Editor.DesignerHost.Container.Add(cp); + } + var Items = new object[((uint) GUI.lstMembers.Items.Count)]; + for (int i = 0; (i < Items.Length); i++) + { + Items[i] = GUI.lstMembers.Items[i]; + } + } + + protected void btnUp_Click(object o, EventArgs e) + { + int i = GUI.lstMembers.SelectedIndex; + if (i < 1) + { + return; + } + + IsDirty = true; + int j = GUI.lstMembers.TopIndex; + object item = GUI.lstMembers.Items[i]; + GUI.lstMembers.Items[i] = GUI.lstMembers.Items[(i - 1)]; + GUI.lstMembers.Items[(i - 1)] = item; + if (j > 0) + { + GUI.lstMembers.TopIndex = (j - 1); + } + GUI.lstMembers.ClearSelected(); + GUI.lstMembers.SelectedIndex = (i - 1); + } + + protected void btnDropDown_Click(object o, EventArgs e) + { + GUI.btnDropdown.ContextMenu.Show(GUI.btnDropdown, new Point(0, GUI.btnDropdown.Height)); + } + + protected void btnDropDownMenuItem_Click(object o, EventArgs e) + { + var tmi = o as TypeMenuItem; + if (tmi != null) + CreateAndAddInstance(tmi.Type as Type); + } + + protected void btnDown_Click(object o, EventArgs e) + { + int i = GUI.lstMembers.SelectedIndex; + if (i >= GUI.lstMembers.Items.Count - 1 && i >= 0) + { + return; + } + + IsDirty = true; + int j = GUI.lstMembers.TopIndex; + object item = GUI.lstMembers.Items[i]; + + GUI.lstMembers.Items[i] = GUI.lstMembers.Items[(i + 1)]; + GUI.lstMembers.Items[(i + 1)] = item; + + + if (j < GUI.lstMembers.Items.Count - 1) + { + GUI.lstMembers.TopIndex = (j + 1); + } + GUI.lstMembers.ClearSelected(); + GUI.lstMembers.SelectedIndex = (i + 1); + } + + protected void btnRemove_Click(object o, EventArgs e) + { + int index = GUI.lstMembers.SelectedIndex; + RemovedItems.Add(GUI.lstMembers.SelectedItem); + object i = GUI.lstMembers.SelectedItem; + Editor.DestroyInstance(i); + CreatedItems.Remove(i); + GUI.lstMembers.Items.RemoveAt(GUI.lstMembers.SelectedIndex); + IsDirty = true; + if (index < GUI.lstMembers.Items.Count) + GUI.lstMembers.SelectedIndex = index; + else if (GUI.lstMembers.Items.Count > 0) + GUI.lstMembers.SelectedIndex = GUI.lstMembers.Items.Count - 1; + } + + protected void btnAdd_Click(object o, EventArgs e) + { + CreateAndAddInstance(base.NewItemTypes[0]); + } + + protected void btnCancel_Click(object o, EventArgs e) + { + if (IsDirty) + { + foreach (object i in RemovedItems) + { + base.DestroyInstance(i); + } + +// object[] items = new object[((uint) GUI.lstMembers.Items.Count)]; +// for (int i = 0; i < items.Length; i++) +// { +// items[i] = GUI.lstMembers.Items[i]; +// } +// base.Items = items; + } + ClearAll(); + } + + protected void btnOK_Click(object o, EventArgs e) + { + if (IsDirty) + { + foreach (object i in RemovedItems) + { + base.DestroyInstance(i); + } + + var items = new object[((uint) GUI.lstMembers.Items.Count)]; + for (int i = 0; i < items.Length; i++) + { + items[i] = GUI.lstMembers.Items[i]; + } + base.Items = items; + } + ClearAll(); + } + + private void ClearAll() + { + CreatedItems.Clear(); + RemovedItems.Clear(); + IsDirty = false; + } + + + protected override void OnEditValueChanged() {} + + protected static void OnComponentChanged(object o, ComponentChangedEventArgs e) {} + + protected override DialogResult ShowEditorDialog(IWindowsFormsEditorService edSvc) + { + IComponentChangeService Service = null; + DialogResult Result; + Result = DialogResult.Cancel; + GUI.EditorService = edSvc; + + try + { + Service = ((IComponentChangeService) Editor.Context.GetService(typeof (IComponentChangeService))); + if (Service != null) + { + Service.ComponentChanged += OnComponentChanged; + } + GUI.EditValue = EditValue; + GUI.Bind(); + GUI.ActiveControl = GUI.lstMembers; + ActiveControl = GUI; + + Result = base.ShowEditorDialog(edSvc); + } + finally + { + if (Service != null) + { + Service.ComponentChanged -= OnComponentChanged; + } + } + return Result; + } + + private void CreateAndAddInstance(Type type) + { + try + { + object NewInstance = CreateInstance(type); + if (NewInstance != null) + { + IsDirty = true; + CreatedItems.Add(NewInstance); + + + GUI.lstMembers.Items.Add(NewInstance); + GUI.lstMembers.Invalidate(); + GUI.lstMembers.ClearSelected(); + GUI.lstMembers.SelectedIndex = (GUI.lstMembers.Items.Count - 1); + + var array1 = new object[((uint) GUI.lstMembers.Items.Count)]; + for (int i = 0; (i < array1.Length); i++) + { + array1[i] = GUI.lstMembers.Items[i]; + } + Items = array1; + } + IsDirty = true; + } + catch (Exception x) + { + base.DisplayError(x); + } + } + } + + #endregion + + #region Nested type: TypeMenuItem + + public class TypeMenuItem : MenuItem + { + #region PUBLIC PROPERTY TYPE + + public object Type { get; set; } + + #endregion + + public TypeMenuItem(object o, EventHandler e) + { + Text = o.ToString(); + Type = o; + Click += e; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/FilteredTypeConverter.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/FilteredTypeConverter.cs new file mode 100644 index 0000000..45632f4 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/FilteredTypeConverter.cs @@ -0,0 +1,45 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Collections; +using System.ComponentModel; + +namespace Alsing.Design +{ + public class FilteredTypeConverter : TypeConverter + { + protected virtual void FilterProperties(IDictionary Properties, object value) {} + + public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, + Attribute[] attributes) + { + PropertyDescriptorCollection propps = propps = TypeDescriptor.GetProperties(value, attributes, false); + + var arr = new Hashtable(); + foreach (PropertyDescriptor pd in propps) + arr[pd.Name] = pd; + + FilterProperties(arr, value); + + //copy the modified propp arr into a typed propertydescriptor[] + var arr2 = new PropertyDescriptor[arr.Values.Count]; + arr.Values.CopyTo(arr2, 0); + + //return the new propertydescriptorcollection + return new PropertyDescriptorCollection(arr2); + } + + public override bool GetPropertiesSupported(ITypeDescriptorContext context) + { + return true; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/Int32AutoConverter.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/Int32AutoConverter.cs new file mode 100644 index 0000000..5d9b67a --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/Int32AutoConverter.cs @@ -0,0 +1,63 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Globalization; + +namespace Alsing.Design +{ + public class Int32AutoConverter : Int32Converter + { + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == typeof (string)) + return true; + + return base.CanConvertFrom(context, sourceType); + } + + public override bool CanConvertTo(ITypeDescriptorContext context, Type t) + { + if (t == typeof (string)) + return true; + + return base.CanConvertTo(context, t); + } + + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + if (value is string) + { + if (value.ToString().ToLower() == "auto") + return 0; + + return Convert.ToInt32(value); + } + + return base.ConvertFrom(context, culture, value); + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, + Type destinationType) + { + if (destinationType == typeof (string)) + { + int v = Convert.ToInt32(value); + if (v == 0) + return "auto"; + + return v.ToString(); + } + + return base.ConvertTo(context, culture, value, destinationType); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/Int32DefaultConverter.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/Int32DefaultConverter.cs new file mode 100644 index 0000000..c13d9ee --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Design/Int32DefaultConverter.cs @@ -0,0 +1,63 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Globalization; + +namespace Alsing.Design +{ + public class Int32DefaultConverter : Int32Converter + { + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == typeof (string)) + return true; + + return base.CanConvertFrom(context, sourceType); + } + + public override bool CanConvertTo(ITypeDescriptorContext context, Type t) + { + if (t == typeof (string)) + return true; + + return base.CanConvertTo(context, t); + } + + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + if (value is string) + { + if (value.ToString().ToLower() == "default") + return 0; + + return Convert.ToInt32(value); + } + + return base.ConvertFrom(context, culture, value); + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, + Type destinationType) + { + if (destinationType == typeof (string)) + { + int v = Convert.ToInt32(value); + if (v == 0) + return "default"; + + return v.ToString(); + } + + return base.ConvertTo(context, culture, value, destinationType); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/Row.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/Row.cs new file mode 100644 index 0000000..63be330 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/Row.cs @@ -0,0 +1,1096 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * +// * contributions by Sebastian Faltoni + +using System.Collections; +using System.Drawing; + +namespace Alsing.SourceCode +{ + /// + /// Parser state of a row + /// + public enum RowState + { + /// + /// the row is not parsed + /// + NotParsed = 0, + /// + /// the row is span parsed + /// + SpanParsed = 1, + /// + /// the row is both span and keyword parsed + /// + AllParsed = 2 + } + + public enum RowRevisionMark + { + Unchanged, + BeforeSave, + AfterSave + } + + /// + /// The row class represents a row in a SyntaxDocument + /// + public sealed class Row : IEnumerable + { + #region General Declarations + + private RowState _RowState = RowState.NotParsed; + + private RowRevisionMark _RevisionMark = RowRevisionMark.BeforeSave; + + /// + /// The owner document + /// + public SyntaxDocument Document; + + /// + /// The first span that terminates on this row. + /// + public Span endSpan; + + /// + /// Segments that ends in this row + /// + public SpanList endSpans = new SpanList(); + + /// + /// For public use only + /// + public int Expansion_EndChar; + + /// + /// + /// + public Span expansion_EndSpan; + + /// + /// For public use only + /// + public int Expansion_PixelEnd; + + /// + /// For public use only + /// + public int Expansion_PixelStart; + + /// + /// For public use only + /// + public int Expansion_StartChar; + + /// + /// + /// + public Span expansion_StartSpan; + + public WordList FormattedWords = new WordList(); + + /// + /// Collection of Image indices assigned to a row. + /// + /// + /// Add an image to the current row. + /// + /// MySyntaxBox.Caret.CurrentRow.Images.Add(3); + /// + /// + public ImageIndexList Images = new ImageIndexList(); + + /// + /// For public use only + /// + public int Indent; //value indicating how much this line should be indented (c style) + + + /// + /// Returns true if the row is in the owner documents keyword parse queue + /// + public bool InKeywordQueue; //is this line in the parseQueue? + + /// + /// Returns true if the row is in the owner documents parse queue + /// + public bool InQueue; //is this line in the parseQueue? + + + + private bool mBookmarked; //is this line bookmarked? + private bool mBreakpoint; //Does this line have a breakpoint? + private string mText = ""; + + /// + /// The first collapsable span on this row. + /// + public Span startSpan; + + /// + /// Segments that start on this row + /// + public SpanList startSpans = new SpanList(); + + /// + /// Object tag for storage of custom user data.. + /// + /// + /// Assign custom data to a row + /// + /// //custom data class + /// class CustomData{ + /// public int abc=123; + /// publci string def="abc"; + /// } + /// + /// ... + /// + /// //assign custom data to a row + /// Row MyRow=MySyntaxBox.Caret.CurrentRow; + /// CustomData MyData=new CustomData(); + /// MyData.abc=1337; + /// MyRow.Tag=MyData; + /// + /// ... + /// + /// //read custom data from a row + /// Row MyRow=MySyntaxBox.Caret.CurrentRow; + /// if (MyRow.Tag != null){ + /// CustomData MyData=(CustomData)MyRow.Tag; + /// if (MyData.abc==1337){ + /// //Do something... + /// } + /// } + /// + /// + /// + /// + public object Tag; + + internal WordList words = new WordList(); + + #region PUBLIC PROPERTY BACKCOLOR + + private Color _BackColor = Color.Transparent; + + public Color BackColor + { + get { return _BackColor; } + set { _BackColor = value; } + } + + #endregion + + public int Depth + { + get + { + int i = 0; + Span s = startSpan; + while (s != null) + { + if (s.Scope != null && s.Scope.CauseIndent) + i++; + + s = s.Parent; + } + // if (i>0) + // i--; + + if (ShouldOutdent) + i--; + + return i; + } + } + + public bool ShouldOutdent + { + get + { + if (startSpan.EndRow == this) + { + if (startSpan.Scope.CauseIndent) + return true; + } + + return false; + } + } + + /// + /// The parse state of this row + /// + /// + /// Test if the current row is fully parsed. + /// + /// if (MySyntaxBox.Caret.CurrentRow.RowState==RowState.AllParsed) + /// { + /// //do something + /// } + /// + /// + public RowState RowState + { + get { return _RowState; } + set + { + if (value == _RowState) + return; + + if (value == RowState.SpanParsed && !InKeywordQueue) + { + Document.KeywordQueue.Add(this); + InKeywordQueue = true; + } + + if ((value == RowState.AllParsed || value == RowState.NotParsed) && InKeywordQueue) + { + Document.KeywordQueue.Remove(this); + InKeywordQueue = false; + } + + _RowState = value; + } + } + + public RowRevisionMark RevisionMark + { + get { return _RevisionMark; } + set { _RevisionMark = value; } + } + + #endregion + + /// + /// Gets or Sets if this row has a bookmark or not. + /// + public bool Bookmarked + { + get { return mBookmarked; } + set + { + mBookmarked = value; + + if (value) + Document.InvokeBookmarkAdded(this); + else + Document.InvokeBookmarkRemoved(this); + + Document.InvokeChange(); + } + } + + /// + /// Gets or Sets if this row has a breakpoint or not. + /// + public bool Breakpoint + { + get { return mBreakpoint; } + set + { + mBreakpoint = value; + if (value) + Document.InvokeBreakPointAdded(this); + else + Document.InvokeBreakPointRemoved(this); + + Document.InvokeChange(); + } + } + + /// + /// Returns the number of words in the row. + /// (this only applied if the row is fully parsed) + /// + public int Count + { + get { return words.Count; } + } + + /// + /// Gets or Sets the text of the row. + /// + public string Text + { + get { return mText; } + + set + { + bool ParsePreview = false; + if (mText != value) + { + ParsePreview = true; + this.Document.Modified = true; + RevisionMark = RowRevisionMark.BeforeSave; + } + + mText = value; + if (Document != null) + { + if (ParsePreview) + { + Document.Parser.ParsePreviewLine(Document.IndexOf(this)); + this.Document.OnApplyFormatRanges(this); + } + + AddToParseQueue(); + } + } + } + + /// + /// Return the Word object at the specified index. + /// + public Word this[int index] + { + get + { + if (index >= 0) + return words[index]; + return new Word(); + } + } + + public int StartWordIndex + { + get + { + if (expansion_StartSpan == null) + return 0; + + // if (this.expansion_StartSpan.StartRow != this) + // return 0; + + Word w = expansion_StartSpan.StartWord; + + int i = 0; + foreach (Word wo in this) + { + if (wo == w) + break; + i += wo.Text.Length; + } + return i; + } + } + + public Word FirstNonWsWord + { + get + { + foreach (Word w in this) + { + if (w.Type == WordType.Word) + return w; + } + return null; + } + } + + /// + /// Returns the index of this row in the owner SyntaxDocument. + /// + public int Index + { + get { return Document.IndexOf(this); } + } + + /// + /// Returns the visible index of this row in the owner SyntaxDocument + /// + public int VisibleIndex + { + get + { + int i = Document.VisibleRows.IndexOf(this); + if (i == -1) + { + if (startSpan != null && startSpan.StartRow != null && startSpan.StartRow != this) + + return startSpan.StartRow.VisibleIndex; + + return Index; + } + return Document.VisibleRows.IndexOf(this); + } + } + + /// + /// Returns the next visible row. + /// + public Row NextVisibleRow + { + get + { + int i = VisibleIndex; + if (i > Document.VisibleRows.Count) + return null; + + if (i + 1 < Document.VisibleRows.Count) + { + return Document.VisibleRows[i + 1]; + } + return null; + } + } + + /// + /// Returns the next row + /// + public Row NextRow + { + get + { + int i = Index; + if (i + 1 <= Document.Lines.Length - 1) + return Document[i + 1]; + return null; + } + } + + /// + /// Returns the first visible row before this row. + /// + public Row PrevVisibleRow + { + get + { + int i = VisibleIndex; + if (i < 0) + return null; + + if (i - 1 >= 0) + return Document.VisibleRows[i - 1]; + return null; + } + } + + /// + /// Returns true if the row is collapsed + /// + public bool IsCollapsed + { + get + { + if (expansion_StartSpan != null) + if (expansion_StartSpan.Expanded == false) + return true; + return false; + } + } + + /// + /// Returns true if this row is the last part of a collepsed span + /// + public bool IsCollapsedEndPart + { + get + { + if (expansion_EndSpan != null) + if (expansion_EndSpan.Expanded == false) + return true; + return false; + } + } + + + /// + /// Returns true if this row can fold + /// + public bool CanFold + { + get + { + return (expansion_StartSpan != null && expansion_StartSpan.EndRow != null && + Document.IndexOf(expansion_StartSpan.EndRow) != 0); + } + } + + /// + /// Gets or Sets if this row is expanded. + /// + public bool Expanded + { + get + { + if (CanFold) + { + return (expansion_StartSpan.Expanded); + } + return false; + } + set + { + if (CanFold) + { + expansion_StartSpan.Expanded = value; + } + } + } + + public string ExpansionText + { + get { return expansion_StartSpan.Scope.ExpansionText; } + set + { + Scope oScope = expansion_StartSpan.Scope; + var oNewScope = new Scope + { + CaseSensitive = oScope.CaseSensitive, + CauseIndent = oScope.CauseIndent, + DefaultExpanded = oScope.DefaultExpanded, + EndPatterns = oScope.EndPatterns, + NormalizeCase = oScope.NormalizeCase, + Parent = oScope.Parent, + spawnSpanOnEnd = oScope.spawnSpanOnEnd, + spawnSpanOnStart = oScope.spawnSpanOnStart, + Start = oScope.Start, + Style = oScope.Style, + ExpansionText = value + }; + expansion_StartSpan.Scope = oNewScope; + Document.InvokeChange(); + } + } + + /// + /// Returns true if this row is the end part of a collapsable span + /// + public bool CanFoldEndPart + { + get { return (expansion_EndSpan != null); } + } + + /// + /// For public use only + /// + public bool HasExpansionLine + { + get { return (endSpan.Parent != null); } + } + + /// + /// Returns the last row of a collapsable span + /// (this only applies if this row is the start row of the span) + /// + public Row Expansion_EndRow + { + get + { + if (CanFold) + return expansion_StartSpan.EndRow; + return this; + } + } + + /// + /// Returns the first row of a collapsable span + /// (this only applies if this row is the last row of the span) + /// + public Row Expansion_StartRow + { + get + { + if (CanFoldEndPart) + return expansion_EndSpan.StartRow; + return this; + } + } + + /// + /// For public use only + /// + public Row VirtualCollapsedRow + { + get + { + var r = new Row(); + + foreach (Word w in this) + { + if (expansion_StartSpan == w.Span) + break; + r.Add(w); + } + + Word wo = r.Add(CollapsedText); + wo.Style = new TextStyle {BackColor = Color.Silver, ForeColor = Color.DarkBlue, Bold = true}; + + bool found = false; + if (Expansion_EndRow != null) + { + foreach (Word w in Expansion_EndRow) + { + if (found) + r.Add(w); + if (w == Expansion_EndRow.expansion_EndSpan.EndWord) + found = true; + } + } + return r; + } + } + + /// + /// Returns the text that should be displayed if the row is collapsed. + /// + public string CollapsedText + { + get + { + string str = ""; + int pos = 0; + foreach (Word w in this) + { + pos += w.Text.Length; + if (w.Span == expansion_StartSpan) + { + str = Text.Substring(pos).Trim(); + break; + } + } + if (expansion_StartSpan.Scope.ExpansionText != "") + str = expansion_StartSpan.Scope.ExpansionText.Replace("***", str); + return str; + } + } + + /// + /// Returns the row before this row. + /// + public Row PrevRow + { + get + { + int i = Index; + + if (i - 1 >= 0) + return Document[i - 1]; + return null; + } + } + + #region IEnumerable Members + + /// + /// Get the Word enumerator for this row + /// + /// + public IEnumerator GetEnumerator() + { + return words.GetEnumerator(); + } + + #endregion + + public void Clear() + { + words.Clear(); + } + + /// + /// If the row is hidden inside a collapsed span , call this method to make the collapsed segments expanded. + /// + public void EnsureVisible() + { + if (RowState == RowState.NotParsed) + return; + + Span seg = startSpan; + while (seg != null) + { + seg.Expanded = true; + seg = seg.Parent; + } + Document.ResetVisibleRows(); + } + + public Word Add(string text) + { + var xw = new Word {Row = this, Text = text}; + words.Add(xw); + return xw; + } + + /// + /// Adds this row to the parse queue + /// + public void AddToParseQueue() + { + if (!InQueue) + Document.ParseQueue.Add(this); + InQueue = true; + RowState = RowState.NotParsed; + } + + /// + /// Assigns a new text to the row. + /// + /// + public void SetText(string Text) + { + this.Document.StartUndoCapture(); + TextPoint tp = new TextPoint(0, this.Index); + TextRange tr = new TextRange(); + tr.FirstColumn = 0; + tr.FirstRow = tp.Y; + tr.LastColumn = this.Text.Length; + tr.LastRow = tp.Y; + + this.Document.StartUndoCapture(); + //delete the current line + this.Document.PushUndoBlock(UndoAction.DeleteRange, this.Document.GetRange(tr), tr.FirstColumn, tr.FirstRow, this.RevisionMark); + //alter the text + this.Document.PushUndoBlock(UndoAction.InsertRange, Text, tp.X, tp.Y, this.RevisionMark); + this.Text = Text; + this.Document.EndUndoCapture(); + this.Document.InvokeChange(); + } + + /// + /// Call this method to make all words match the case of their patterns. + /// (this only applies if the row is fully parsed) + /// + public void MatchCase() + { + string s = ""; + foreach (Word w in words) + { + s = s + w.Text; + } + mText = s; + } + + /// + /// Force a span parse on the row. + /// + public void Parse() + { + Document.ParseRow(this); + } + + /// + /// Forces the parser to parse this row directly + /// + /// true if keywords and operators should be parsed + public void Parse(bool ParseKeywords) + { + Document.ParseRow(this, ParseKeywords); + } + + public void SetExpansionSegment() + { + expansion_StartSpan = null; + expansion_EndSpan = null; + foreach (Span s in startSpans) + { + if (!endSpans.Contains(s)) + { + expansion_StartSpan = s; + break; + } + } + + foreach (Span s in endSpans) + { + if (!startSpans.Contains(s)) + { + expansion_EndSpan = s; + break; + } + } + + if (expansion_EndSpan != null) + expansion_StartSpan = null; + } + + /// + /// Returns the whitespace string at the begining of this row. + /// + /// a string containing the whitespace at the begining of this row + public string GetLeadingWhitespace() + { + string s = mText; + int i; + s = s.Replace(" ", " "); + for (i = 0; i < s.Length; i++) + { + if (s.Substring(i, 1) == " ") {} + else + { + break; + } + } + return mText.Substring(0, i); + } + + public string GetVirtualLeadingWhitespace() + { + int i = StartWordIndex; + string ws = ""; + foreach (char c in Text) + { + if (c == '\t') + ws += c; + else + ws += ' '; + + i--; + if (i <= 0) + break; + } + return ws; + } + + /// + /// Adds a word object to this row + /// + /// Word object + public void Add(Word word) + { + word.Row = this; + words.Add(word); + } + + /// + /// Returns the index of a specific Word object + /// + /// Word object to find + /// index of the word in the row + public int IndexOf(Word word) + { + return words.IndexOf(word); + } + + /// + /// For public use only + /// + /// + /// + /// + /// + public Word FindRightWordByPatternList(PatternList PatternList, Word StartWord, bool IgnoreStartWord) + { + int i = StartWord.Index; + if (IgnoreStartWord) + i++; + while (i < words.Count) + { + Word w = this[i]; + if (w.Pattern != null) + { + if (w.Pattern.Parent != null) + { + if (w.Pattern.Parent == PatternList && w.Type != WordType.Space && w.Type != WordType.Tab) + { + return w; + } + } + } + i++; + } + return null; + } + + /// + /// For public use only + /// + /// + /// + /// + /// + public Word FindRightWordByPatternListName(string PatternListName, Word StartWord, bool IgnoreStartWord) + { + int i = StartWord.Index; + if (IgnoreStartWord) + i++; + + while (i < words.Count) + { + Word w = this[i]; + if (w.Pattern != null) + { + if (w.Pattern.Parent != null) + { + if (w.Pattern.Parent.Name == PatternListName && w.Type != WordType.Space && + w.Type != WordType.Tab) + { + return w; + } + } + } + i++; + } + return null; + } + + /// + /// For public use only + /// + /// + /// + /// + /// + public Word FindLeftWordByPatternList(PatternList PatternList, Word StartWord, bool IgnoreStartWord) + { + int i = StartWord.Index; + if (IgnoreStartWord) + i--; + while (i >= 0) + { + Word w = this[i]; + if (w.Pattern != null) + { + if (w.Pattern.Parent != null) + { + if (w.Pattern.Parent == PatternList && w.Type != WordType.Space && w.Type != WordType.Tab) + { + return w; + } + } + } + i--; + } + return null; + } + + /// + /// For public use only + /// + /// + /// + /// + /// + public Word FindLeftWordByPatternListName(string PatternListName, Word StartWord, bool IgnoreStartWord) + { + int i = StartWord.Index; + if (IgnoreStartWord) + i--; + + while (i >= 0) + { + Word w = this[i]; + if (w.Pattern != null) + { + if (w.Pattern.Parent != null) + { + if (w.Pattern.Parent.Name == PatternListName && w.Type != WordType.Space && + w.Type != WordType.Tab) + { + return w; + } + } + } + i--; + } + return null; + } + + /// + /// For public use only + /// + /// + /// + /// + /// + public Word FindLeftWordByBlockType(SpanDefinition spanDefinition, Word StartWord, bool IgnoreStartWord) + { + int i = StartWord.Index; + if (IgnoreStartWord) + i--; + while (i >= 0) + { + Word w = this[i]; + if (w.Span.spanDefinition == spanDefinition && w.Type != WordType.Space && w.Type != WordType.Tab) + { + return w; + } + i--; + } + return null; + } + + /// + /// For public use only + /// + /// + /// + /// + /// + public Word FindRightWordByBlockType(SpanDefinition spanDefinition, Word StartWord, bool IgnoreStartWord) + { + int i = StartWord.Index; + if (IgnoreStartWord) + i++; + while (i < words.Count) + { + Word w = this[i]; + if (w.Span.spanDefinition == spanDefinition && w.Type != WordType.Space && w.Type != WordType.Tab) + { + return w; + } + i++; + } + return null; + } + + /// + /// For public use only + /// + /// + /// + /// + /// + public Word FindLeftWordByBlockTypeName(string BlockTypeName, Word StartWord, bool IgnoreStartWord) + { + int i = StartWord.Index; + if (IgnoreStartWord) + i--; + while (i >= 0) + { + Word w = this[i]; + if (w.Span.spanDefinition.Name == BlockTypeName && w.Type != WordType.Space && w.Type != WordType.Tab) + { + return w; + } + i--; + } + return null; + } + + /// + /// For public use only + /// + /// + /// + /// + /// + public Word FindRightWordByBlockTypeName(string BlockTypeName, Word StartWord, bool IgnoreStartWord) + { + int i = StartWord.Index; + if (IgnoreStartWord) + i++; + while (i < words.Count) + { + Word w = this[i]; + if (w.Span.spanDefinition.Name == BlockTypeName && w.Type != WordType.Space && w.Type != WordType.Tab) + { + return w; + } + i++; + } + return null; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/RowEventArgs.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/RowEventArgs.cs new file mode 100644 index 0000000..a79030f --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/RowEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Alsing.SourceCode +{ + /// + /// + /// + public class RowEventArgs : EventArgs + { + /// + /// + /// + public Row Row; + + /// + /// + /// + /// + public RowEventArgs(Row row) + { + Row = row; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/RowEventHandler.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/RowEventHandler.cs new file mode 100644 index 0000000..63d1938 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/RowEventHandler.cs @@ -0,0 +1,7 @@ +namespace Alsing.SourceCode +{ + /// + /// + /// + public delegate void RowEventHandler(object sender, RowEventArgs e); +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/RowList.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/RowList.cs new file mode 100644 index 0000000..adbb8c6 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Row/RowList.cs @@ -0,0 +1,19 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; + +namespace Alsing.SourceCode +{ + /// + /// Row collection class. + /// + public sealed class RowList : List {} +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Span/Span.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Span/Span.cs new file mode 100644 index 0000000..c3b9549 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Span/Span.cs @@ -0,0 +1,78 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.SourceCode +{ + /// + /// + /// + public class Span + { + /// + /// The depth of this span in the span hirarchy + /// + public int Depth; + + /// + /// The row that the span ends on + /// + public Row EndRow; + + /// + /// The word that ends this span + /// + public Word EndWord; + + /// + /// Gets or Sets if this span is expanded + /// + public bool Expanded = true; + + /// + /// The parent span + /// + public Span Parent; + + /// + /// Gets or Sets what scope triggered this span + /// + public Scope Scope; + + /// + /// The owner spanDefinition + /// + public SpanDefinition spanDefinition; + + /// + /// The row on which the span starts + /// + public Row StartRow; + + /// + /// The word that starts this span + /// + public Word StartWord; + + + /// + /// + /// + /// + public Span(Row startrow) + { + StartRow = startrow; + } + + /// + /// + /// + public Span() {} + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Span/SpanList.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Span/SpanList.cs new file mode 100644 index 0000000..ffbb8c8 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Span/SpanList.cs @@ -0,0 +1,19 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; + +namespace Alsing.SourceCode +{ + /// + /// + /// + public sealed class SpanList : List {} +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Structs/BracketType.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Structs/BracketType.cs new file mode 100644 index 0000000..d0c8b08 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Structs/BracketType.cs @@ -0,0 +1,19 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.SourceCode +{ + public enum BracketType + { + None, + StartBracket, + EndBracket, + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Structs/TextPoint.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Structs/TextPoint.cs new file mode 100644 index 0000000..1aa1086 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Structs/TextPoint.cs @@ -0,0 +1,77 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; + +namespace Alsing.SourceCode +{ + /// + /// Class representing a point in a text. + /// where x is the column and y is the row. + /// + public class TextPoint + { + private int x; + private int y; + + /// + /// + /// + public TextPoint() {} + + /// + /// + /// + /// + /// + public TextPoint(int X, int Y) + { + this.X = X; + this.Y = Y; + } + + /// + /// + /// + public int X + { + get { return x; } + set + { + x = value; + OnChange(); + } + } + + /// + /// + /// + public int Y + { + get { return y; } + set + { + y = value; + OnChange(); + } + } + + /// + /// Event fired when the X or Y property has changed. + /// + public event EventHandler Change = null; + + private void OnChange() + { + if (Change != null) + Change(this, new EventArgs()); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Structs/TextRange.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Structs/TextRange.cs new file mode 100644 index 0000000..4770341 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Structs/TextRange.cs @@ -0,0 +1,123 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; + +namespace Alsing.SourceCode +{ + /// + /// A range of text + /// + public class TextRange + { + public TextRange() {} + + public TextRange(int firstColumn, int firstRow, int lastColumn, int lastRow) + { + this.firstColumn = firstColumn; + this.firstRow = firstRow; + this.lastColumn = lastColumn; + this.lastRow = lastRow; + } + + public event EventHandler Change = null; + + protected virtual void OnChange() + { + if (Change != null) + Change(this, EventArgs.Empty); + } + + /// + /// The start row of the range + /// + /// + /// The start column of the range + /// + /// + /// The end row of the range + /// + /// + /// The end column of the range + /// + public void SetBounds(int firstColumn, int firstRow, int lastColumn, int lastRow) + { + this.firstColumn = firstColumn; + this.firstRow = firstRow; + this.lastColumn = lastColumn; + this.lastRow = lastRow; + OnChange(); + } + + #region PUBLIC PROPERTY FIRSTROW + + private int firstRow; + + public int FirstRow + { + get { return firstRow; } + set + { + firstRow = value; + OnChange(); + } + } + + #endregion + + #region PUBLIC PROPERTY FIRSTCOLUMN + + private int firstColumn; + + public int FirstColumn + { + get { return firstColumn; } + set + { + firstColumn = value; + OnChange(); + } + } + + #endregion + + #region PUBLIC PROPERTY LASTROW + + private int lastRow; + + public int LastRow + { + get { return lastRow; } + set + { + lastRow = value; + OnChange(); + } + } + + #endregion + + #region PUBLIC PROPERTY LASTCOLUMN + + private int lastColumn; + + public int LastColumn + { + get { return lastColumn; } + set + { + lastColumn = value; + OnChange(); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Undo/UndoBlock.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Undo/UndoBlock.cs new file mode 100644 index 0000000..7adf628 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Undo/UndoBlock.cs @@ -0,0 +1,55 @@ +// * +// * Copyright (C) 2005 Roger Johansson : http://www.puzzleframework.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.SourceCode +{ + //what kind of undoaction is it? + /// + /// + /// + public enum UndoAction + { + /// + /// + /// + InsertRange = 1, + /// + /// + /// + DeleteRange = 2, + } + + //object that holds undo information + /// + /// + /// + public sealed class UndoBlock + { + /// + /// + /// + public string Text = ""; + + /// + /// + /// + public TextPoint Position = new TextPoint(0, 0); + + /// + /// + /// + public UndoAction Action = 0; + + /// + /// + /// + public bool RowModified = false; + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Undo/UndoBlockCollection.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Undo/UndoBlockCollection.cs new file mode 100644 index 0000000..680ec42 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Undo/UndoBlockCollection.cs @@ -0,0 +1,514 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Collections; +using T = Alsing.SourceCode.UndoBlock; + +namespace Alsing.SourceCode +{ + /// + /// + /// + public sealed class UndoBlockCollection : IList, ICloneable + { + private const int DefaultMinimumCapacity = 16; + + private UndoBlock[] m_array = new UndoBlock[DefaultMinimumCapacity]; + private int m_count; + private int m_version; + + /// + /// + /// + public string Name = "UndoAction"; + + // Construction + + /// + /// + /// + public UndoBlockCollection() + { + } + + /// + /// + /// + /// + public UndoBlockCollection(UndoBlockCollection collection) + { + AddRange(collection); + } + + /// + /// + /// + /// + public UndoBlockCollection(UndoBlock[] array) + { + AddRange(array); + } + + /// + /// + /// + public UndoBlock this[int index] + { + get + { + ValidateIndex(index); // throws + return m_array[index]; + } + set + { + ValidateIndex(index); // throws + + ++m_version; + m_array[index] = value; + } + } + + /// + /// + /// + public int Capacity + { + get { return m_array.Length; } + set + { + if (value < m_count) + value = m_count; + if (value < DefaultMinimumCapacity) + value = DefaultMinimumCapacity; + + if (m_array.Length == value) + return; + + ++m_version; + + var temp = new UndoBlock[value]; + // for (int i=0; i < m_count; ++i) temp[i] = m_array[i]; + Array.Copy(m_array, 0, temp, 0, m_count); + m_array = temp; + } + } + + #region ICloneable Members + + object ICloneable.Clone() + { + return (Clone()); + } + + #endregion + + // Operations (type-safe ICollection) + + #region ICollection Members + + /// + /// + /// + public int Count + { + get { return m_count; } + } + + bool ICollection.IsSynchronized + { + get { return m_array.IsSynchronized; } + } + + object ICollection.SyncRoot + { + get { return m_array.SyncRoot; } + } + + void ICollection.CopyTo(Array array, int start) + { + CopyTo((UndoBlock[]) array, start); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return (GetEnumerator()); + } + + #endregion + + #region IList Members + + /// + /// + /// + public void Clear() + { + ++m_version; + m_array = new UndoBlock[DefaultMinimumCapacity]; + m_count = 0; + } + + /// + /// + /// + /// + public void RemoveAt(int index) + { + ValidateIndex(index); // throws + + ++m_version; + m_count--; + // for (int i=index; i < m_count; ++i) m_array[i] = m_array[i+1]; + Array.Copy(m_array, index + 1, m_array, index, m_count - index); + + if (NeedsTrimming()) + Trim(); + } + + bool IList.IsFixedSize + { + get { return false; } + } + + bool IList.IsReadOnly + { + get { return false; } + } + + object IList.this[int index] + { + get { return this[index]; } + set { this[index] = (UndoBlock) value; } + } + + int IList.Add(object item) + { + return Add((UndoBlock) item); + } + + /* redundant w/ type-safe method + void IList.Clear() + { + this.Clear(); + } + */ + + bool IList.Contains(object item) + { + return Contains((UndoBlock) item); + } + + int IList.IndexOf(object item) + { + return IndexOf((UndoBlock) item); + } + + void IList.Insert(int position, object item) + { + Insert(position, (UndoBlock) item); + } + + void IList.Remove(object item) + { + Remove((UndoBlock) item); + } + + #endregion + + /// + /// + /// + /// + public void CopyTo(UndoBlock[] array) + { + CopyTo(array, 0); + } + + /// + /// + /// + /// + /// + public void CopyTo(UndoBlock[] array, int start) + { + if (m_count > array.GetUpperBound(0) + 1 - start) + throw new ArgumentException("Destination array was not long enough."); + + // for (int i=0; i < m_count; ++i) array[start+i] = m_array[i]; + Array.Copy(m_array, 0, array, start, m_count); + } + + // Operations (type-safe IList) + + /// + /// + /// + /// + /// + public int Add(UndoBlock item) + { + if (NeedsGrowth()) + Grow(); + + ++m_version; + m_array[m_count] = item; + + return m_count++; + } + + /// + /// + /// + /// + /// + public bool Contains(UndoBlock item) + { + return ((IndexOf(item) == - 1) ? false : true); + } + + /// + /// + /// + /// + /// + public int IndexOf(UndoBlock item) + { + for (int i = 0; i < m_count; ++i) + if (m_array[i] == (item)) + return i; + return - 1; + } + + /// + /// + /// + /// + /// + public void Insert(int position, UndoBlock item) + { + ValidateIndex(position, true); // throws + + if (NeedsGrowth()) + Grow(); + + ++m_version; + // for (int i=m_count; i > position; --i) m_array[i] = m_array[i-1]; + Array.Copy(m_array, position, m_array, position + 1, m_count - position); + + m_array[position] = item; + m_count++; + } + + /// + /// + /// + /// + public void Remove(UndoBlock item) + { + int index = IndexOf(item); + if (index < 0) + throw new ArgumentException( + "Cannot remove the specified item because it was not found in the specified Collection."); + + RemoveAt(index); + } + + // Operations (type-safe IEnumerable) + /// + /// + /// + /// + public Enumerator GetEnumerator() + { + return new Enumerator(this); + } + + // Operations (type-safe ICloneable) + /// + /// + /// + /// + public UndoBlockCollection Clone() + { + var tc = new UndoBlockCollection(); + tc.AddRange(this); + tc.Capacity = m_array.Length; + tc.m_version = m_version; + return tc; + } + + // Public helpers (just to mimic some nice features of ArrayList) + + /// + /// + /// + /// + public void AddRange(UndoBlockCollection collection) + { + // for (int i=0; i < collection.Count; ++i) Add(collection[i]); + + ++m_version; + + Capacity += collection.Count; + Array.Copy(collection.m_array, 0, m_array, m_count, collection.m_count); + m_count += collection.Count; + } + + /// + /// + /// + /// + public void AddRange(UndoBlock[] array) + { + // for (int i=0; i < array.Length; ++i) Add(array[i]); + + ++m_version; + + Capacity += array.Length; + Array.Copy(array, 0, m_array, m_count, array.Length); + m_count += array.Length; + } + + // Implementation (helpers) + + private void ValidateIndex(int index) + { + ValidateIndex(index, false); + } + + private void ValidateIndex(int index, bool allowEqualEnd) + { + int max = (allowEqualEnd) ? (m_count) : (m_count - 1); + if (index < 0 || index > max) + throw new ArgumentOutOfRangeException( + "Index was out of range. Must be non-negative and less than the size of the collection.", index, + "Specified argument was out of the range of valid values."); + } + + private bool NeedsGrowth() + { + return (m_count >= Capacity); + } + + private void Grow() + { + if (NeedsGrowth()) + Capacity = m_count*2; + } + + private bool NeedsTrimming() + { + return (m_count <= Capacity/2); + } + + private void Trim() + { + if (NeedsTrimming()) + Capacity = m_count; + } + + // Implementation (ICollection) + + /* redundant w/ type-safe method + int ICollection.Count + { + get + { return m_count; } + } + */ + + // Nested enumerator class + + #region Nested type: Enumerator + + /// + /// + /// + public class Enumerator : IEnumerator + { + private readonly UndoBlockCollection m_collection; + private readonly int m_version; + private int m_index; + + // Construction + + public Enumerator(UndoBlockCollection tc) + { + m_collection = tc; + m_index = - 1; + m_version = tc.m_version; + } + + // Operations (type-safe IEnumerator) + + /// + /// + /// + public UndoBlock Current + { + get { return m_collection[m_index]; } + } + + #region IEnumerator Members + + /// + /// + /// + /// + public bool MoveNext() + { + if (m_version != m_collection.m_version) + throw new InvalidOperationException( + "Collection was modified; enumeration operation may not execute."); + + ++m_index; + return (m_index < m_collection.Count) ? true : false; + } + + /// + /// + /// + public void Reset() + { + if (m_version != m_collection.m_version) + throw new InvalidOperationException( + "Collection was modified; enumeration operation may not execute."); + + m_index = - 1; + } + + // Implementation (IEnumerator) + + object IEnumerator.Current + { + get { return (Current); } + } + + #endregion + + /* redundant w/ type-safe method + bool IEnumerator.MoveNext() + { + return this.MoveNext(); + } + */ + + /* redundant w/ type-safe method + void IEnumerator.Reset() + { + this.Reset(); + } + */ + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Undo/UndoBuffer.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Undo/UndoBuffer.cs new file mode 100644 index 0000000..67dafba --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Undo/UndoBuffer.cs @@ -0,0 +1,37 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; + +namespace Alsing.SourceCode +{ + /// + /// + /// + public sealed class UndoBuffer : List + { + public UndoBuffer() + { + MaxSize = 1000; + } + + public int MaxSize { get; set; } + + /// + /// + /// + /// + public void ClearFrom(int index) + { + while (index <= Count - 1) + RemoveAt(index); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Word/Word.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Word/Word.cs new file mode 100644 index 0000000..9b8b912 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Word/Word.cs @@ -0,0 +1,114 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Drawing; + +namespace Alsing.SourceCode +{ + /// + /// Word types + /// + public enum WordType + { + /// + /// The word is a normal word/text + /// + Word = 0, + /// + /// The word is a space char + /// + Space = 1, + /// + /// The word is a tab char + /// + Tab = 2 + } + + /// + /// The word object class represents a word in a Row object + /// + public sealed class Word + { + #region General Declarations + + /// + /// Color of the error wave lines + /// + public Color ErrorColor = Color.Red; + + /// + /// True if the word has error wave lines + /// + public bool HasError; + + /// + /// The ToolTip text for the word + /// + public string InfoTip; + + /// + /// The pattern that created this word + /// + public Pattern Pattern; //the pattern that found this word + + /// + /// The parent row + /// + public Row Row; //the row that holds this word + + /// + /// The parent span + /// + public Span Span; //the span that this word is located in + + /// + /// The style of the word + /// + public TextStyle Style; //the style of the word + + /// + /// The text of the word + /// + public string Text; //the text in the word + + /// + /// The type of the word + /// + public WordType Type; //word type , space , tab , word + + #endregion + + /// + /// Gets the index of the word in the parent row + /// + public int Index + { + get { return Row.IndexOf(this); } + } + + /// + /// Returns the column where the word starts on the containing row. + /// + public int Column + { + get + { + int x = 0; + foreach (Word w in Row) + { + if (w == this) + return x; + x += w.Text.Length; + } + return - 1; + } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Word/WordList.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Word/WordList.cs new file mode 100644 index 0000000..5f8053f --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/DocumentStructure/Word/WordList.cs @@ -0,0 +1,19 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; + +namespace Alsing.SourceCode +{ + /// + /// + /// + public sealed class WordList : List {} +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Export/CollapsingHTMLExporter.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Export/CollapsingHTMLExporter.cs new file mode 100644 index 0000000..57624f2 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Export/CollapsingHTMLExporter.cs @@ -0,0 +1,181 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Drawing; +using System.Globalization; +using System.Text; + +namespace Alsing.SourceCode.SyntaxDocumentExporters +{ + /// + /// Html exporter class + /// + public class CollapsingHTMLExporter + { + private StringBuilder sb; + + + /// + /// Exports the content of a SyntaxDocument to a HTML formatted string + /// + /// SyntaxDocument object to export from + /// File path tho the images to use in the HTML string + /// + public string Export(SyntaxDocument doc, string ImagePath) + { + return Export(doc, Color.Transparent, ImagePath, ""); + } + + + /// + /// Exports the content of a SyntaxDocument to a HTML formatted string + /// + /// SyntaxDocument object to export from + /// HTML color string to use as background color + /// File path tho the images to use in the HTML string + /// HTML style string that should be applied to the output + /// + public string Export(SyntaxDocument doc, Color BGColor, string ImagePath, string Style) + { + sb = new StringBuilder(); + doc.ParseAll(true); + int i = 0; + + string guid = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture); + + //style=\"font-family:courier new;font-size:13px;\" + if (BGColor.A == 0) + Out("
"); + else + Out("
"); + foreach (Row r in doc) + { + i++; + if (r.CanFold) + { + RenderCollapsed(r.VirtualCollapsedRow, r, i, ImagePath, guid); + Out("
"); + + string img = "minus.gif"; + try + { + if (r.expansion_StartSpan.Parent.Parent == null) + img = "minusNoTopLine.gif"; + } + catch {} + Out(""); + } + else + { + if (r.CanFoldEndPart) + { + Out(""); + } + else + { + if (r.HasExpansionLine) + { + Out(""); + } + else + { + Out(""); + } + } + } + foreach (Word w in r) + { + write(w.Text, w.Style); + } + if (r.CanFoldEndPart) + Out("
\n"); + else + Out("
\n"); + } + Out("
"); + + return sb.ToString(); + } + + + private void RenderCollapsed(Row r, Row TrueRow, int i, string ImagePath, string guid) + { + Out("
"); + string img = "plus.gif"; + try + { + if (TrueRow.expansion_StartSpan.Parent.Parent == null) + img = "PlusNoLines.gif"; + } + catch {} + + + Out(""); + + foreach (Word w in r) + { + write(w.Text, w.Style); + } + + Out("
"); + } + + private void write(string text, TextStyle s) + { + if (s != null) + { + if (s.Bold) + Out(""); + if (s.Italic) + Out(""); + if (s.Transparent) + Out(""); + else + Out(""); + } + + text = text.Replace("&", "&"); + text = text.Replace("<", "<"); + text = text.Replace(">", ">"); + text = text.Replace(" ", " "); + text = text.Replace("\t", "    "); + Out(text); + + if (s != null) + { + Out(""); + + if (s.Italic) + Out(""); + if (s.Bold) + Out(""); + } + } + + private static string GetHTMLColor(Color c) + { + return string.Format("#{0}{1}{2}", c.R.ToString("x2"), c.G.ToString("x2"), c.B.ToString("x2")); + } + + private void Out(string text) + { + sb.Append(text); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Export/SimpleHTMLExporter.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Export/SimpleHTMLExporter.cs new file mode 100644 index 0000000..13b2a63 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Export/SimpleHTMLExporter.cs @@ -0,0 +1,74 @@ +using System; +using System.Drawing; +using System.Text; + +namespace Alsing.SourceCode.SyntaxDocumentExporters +{ + public class SimpleHTMLExporter + { + private static StringBuilder sb; + + private static void write(string text, TextStyle s) + { + if (s != null) + { + if (s.Bold) + Out(""); + if (s.Italic) + Out(""); + if (s.Transparent) + Out(""); + else + Out(""); + } + + text = text.Replace("&", "&"); + text = text.Replace("<", "<"); + text = text.Replace(">", ">"); + text = text.Replace(" ", " "); + text = text.Replace("\t", "    "); + Out(text); + + if (s != null) + { + Out(""); + + if (s.Italic) + Out(""); + if (s.Bold) + Out(""); + } + } + + private static string GetHTMLColor(Color c) + { + return string.Format("#{0}{1}{2}", c.R.ToString("x2"), c.G.ToString("x2"), c.B.ToString("x2")); + } + + private static void Out(string text) + { + sb.Append(text); + } + + public static string Export(SyntaxDocument doc, string CssClass) + { + sb = new StringBuilder(); + doc.ParseAll(true); + + Out("
" + Environment.NewLine); + foreach (Row r in doc) + { + foreach (Word w in r) + { + write(w.Text, w.Style); + } + + Out("
" + Environment.NewLine); + } + Out("
"); + + return sb.ToString(); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/ImageIndexList.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/ImageIndexList.cs new file mode 100644 index 0000000..f960805 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/ImageIndexList.cs @@ -0,0 +1,19 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; + +namespace Alsing.SourceCode +{ + /// + /// + /// + public class ImageIndexList : List {} +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/DefaultParser.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/DefaultParser.cs new file mode 100644 index 0000000..9d29b7c --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/DefaultParser.cs @@ -0,0 +1,787 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * +//no parsing , just splitting and making whitespace possible +//1 sec to finnish ca 10000 rows + +namespace Alsing.SourceCode.SyntaxDocumentParsers +{ + /// + /// + /// + public sealed class DefaultParser : IParser + { + private SyntaxDefinition mSyntaxDefinition; + private long Version; + + /// + /// + /// + public DefaultParser() + { + mSyntaxDefinition = null; + } + + #region IParser Members + + /// + /// + /// + public SyntaxDefinition SyntaxDefinition + { + get { return mSyntaxDefinition; } + set + { + mSyntaxDefinition = value; + + if (mSyntaxDefinition == null) + { + var l = new SyntaxDefinition(); + l.mainSpanDefinition = new SpanDefinition(l) {MultiLine = true}; + mSyntaxDefinition = l; + } + + Version = long.MinValue; + mSyntaxDefinition.Version = long.MinValue + 1; + Document.ReParse(); + } + } + + /// + /// + /// + /// + /// + public void ParseRow(int index, bool ParseKeywords) + { + InternalParseLine(index, ParseKeywords); + if (SyntaxDefinition != null) + { + if (Version != SyntaxDefinition.Version) + { + SyntaxDefinition.UpdateLists(); + Version = SyntaxDefinition.Version; + } + } + + + Document.InvokeRowParsed(Document[index]); + } + + #endregion + + #region PUBLIC PROPERTY SEPARATORS + + public string Separators + { + get { return SyntaxDefinition.Separators; } + set { SyntaxDefinition.Separators = value; } + } + + #endregion + + #region Optimerat och klart + + // ska anropas om "is same but different" är true + + /// + /// + /// + public SyntaxDocument Document { get; set; } + + /// + /// + /// + /// + public void Init(string SyntaxFile) + { + try + { + if (!SyntaxFile.ToLowerInvariant().EndsWith(".syn")) + SyntaxFile += ".syn"; + + + SyntaxDefinition = new SyntaxDefinitionLoader().Load(SyntaxFile); + } + catch {} + } + + public void Init(string syntaxFile, string separators) + { + try + { + if (!syntaxFile.ToLowerInvariant().EndsWith(".syn")) + syntaxFile += ".syn"; + + + SyntaxDefinition = new SyntaxDefinitionLoader().Load(syntaxFile, separators); + } + catch {} + } + + /// + /// + /// + /// + public void Init(SyntaxDefinition syntaxDefinition) + { + SyntaxDefinition = syntaxDefinition; + } + + /// + /// + /// + /// + public void ParsePreviewLine(int RowIndex) + { + Row Row = Document[RowIndex]; + Row.Clear(); + Row.Add(Row.Text); + Row.RowState = RowState.NotParsed; + } + + private void MakeSame(int RowIndex) + { + Row row = Document[RowIndex]; + + //copy back the old segments to this line... + Span seg = row.endSpan; + Span seg2 = Document[RowIndex + 1].startSpan; + while (seg != null) + { + foreach (Word w in row) + { + if (w.Span == seg) + { + if (w.Span.StartWord == w) + seg2.StartWord = w; + + if (w.Span.EndWord == w) + seg2.EndWord = w; + + w.Span = seg2; + } + } + + if (seg == row.startSpan) + row.startSpan = seg2; + + if (seg == row.endSpan) + row.endSpan = seg2; + + + if (row.startSpans.IndexOf(seg) >= 0) + row.startSpans[row.startSpans.IndexOf(seg)] = seg2; + + if (row.endSpans.IndexOf(seg) >= 0) + row.endSpans[row.endSpans.IndexOf(seg)] = seg2; + + seg = seg.Parent; + seg2 = seg2.Parent; + } + row.SetExpansionSegment(); + } + + //om denna är true + // så ska INTE nästa rad parse'as , utan denna ska fixas så den blir som den förra... (kopiera span) + private bool IsSameButDifferent(int RowIndex, Span oldStartSpan) + { + //is this the last row ? , if so , bailout + if (RowIndex >= Document.Count - 1) + return false; + + Row row = Document[RowIndex]; + Span seg = row.endSpan; + Span oldEndSpan = Document[RowIndex + 1].startSpan; + Span oseg = oldEndSpan; + + bool diff = false; + + while (seg != null) + { + if (oseg == null) + { + diff = true; + break; + } + + //Id1+=seg.spanDefinition.GetHashCode ().ToString (System.Globalization.CultureInfo.InvariantCulture); + if (seg.spanDefinition != oseg.spanDefinition) + { + diff = true; + break; + } + + if (seg.Parent != oseg.Parent) + { + diff = true; + break; + } + + seg = seg.Parent; + oseg = oseg.Parent; + } + + + if (diff || row.startSpan != oldStartSpan) + return false; + + return true; + } + + #endregion + + private ScanResultWord GetNextWord(string Text, Span currentSpan, int StartPos, ref bool HasComplex) + { + SpanDefinition spanDefinition = currentSpan.spanDefinition; + + #region ComplexFind + + int BestComplexPos = - 1; + Pattern BestComplexPattern = null; + string BestComplexToken = ""; + var complexword = new ScanResultWord(); + if (HasComplex) + { + foreach (Pattern pattern in spanDefinition.ComplexPatterns) + { + PatternScanResult scanres = pattern.IndexIn(Text, StartPos, pattern.Parent.CaseSensitive, Separators); + if (scanres.Token != "") + { + if (scanres.Index < BestComplexPos || BestComplexPos == - 1) + { + BestComplexPos = scanres.Index; + BestComplexPattern = pattern; + BestComplexToken = scanres.Token; + } + } + } + + + if (BestComplexPattern != null) + { + complexword.HasContent = true; + complexword.ParentList = BestComplexPattern.Parent; + complexword.Pattern = BestComplexPattern; + complexword.Position = BestComplexPos; + complexword.Token = BestComplexToken; + } + else + { + HasComplex = false; + } + } + + #endregion + + #region SimpleFind + + var simpleword = new ScanResultWord(); + for (int i = StartPos; i < Text.Length; i++) + { + //bailout if we found a complex pattern before this char pos + if (i > complexword.Position && complexword.HasContent) + break; + + #region 3+ char pattern + + if (i <= Text.Length - 3) + { + string key = Text.Substring(i, 3).ToLowerInvariant(); + var patterns2 = (PatternCollection) spanDefinition.LookupTable[key]; + //ok , there are patterns that start with this char + if (patterns2 != null) + { + foreach (Pattern pattern in patterns2) + { + int len = pattern.StringPattern.Length; + if (i + len > Text.Length) + continue; + + char lastpatternchar = char.ToLower(pattern.StringPattern[len - 1]); + char lasttextchar = char.ToLower(Text[i + len - 1]); + + #region Case Insensitive + + if (lastpatternchar == lasttextchar) + { + if (!pattern.IsKeyword || (pattern.IsKeyword && pattern.HasSeparators(Text, i))) + { + if (!pattern.Parent.CaseSensitive) + { + string s = Text.Substring(i, len).ToLowerInvariant(); + + if (s == pattern.StringPattern.ToLowerInvariant()) + { + simpleword.HasContent = true; + simpleword.ParentList = pattern.Parent; + simpleword.Pattern = pattern; + simpleword.Position = i; + simpleword.Token = pattern.Parent.NormalizeCase + ? pattern.StringPattern + : Text.Substring(i, len); + break; + } + } + else + { + string s = Text.Substring(i, len); + + if (s == pattern.StringPattern) + { + simpleword.HasContent = true; + simpleword.ParentList = pattern.Parent; + simpleword.Pattern = pattern; + simpleword.Position = i; + simpleword.Token = pattern.StringPattern; + break; + } + } + } + } + } + + #endregion + } + } + + #endregion + + if (simpleword.HasContent) + break; + + #region single char pattern + + char c = Text[i]; + var patterns = (PatternCollection) spanDefinition.LookupTable[c]; + if (patterns != null) + { + //ok , there are patterns that start with this char + foreach (Pattern pattern in patterns) + { + int len = pattern.StringPattern.Length; + if (i + len > Text.Length) + continue; + + char lastpatternchar = pattern.StringPattern[len - 1]; + char lasttextchar = Text[i + len - 1]; + + if (!pattern.Parent.CaseSensitive) + { + #region Case Insensitive + + if (char.ToLower(lastpatternchar) == char.ToLower(lasttextchar)) + { + if (!pattern.IsKeyword || (pattern.IsKeyword && pattern.HasSeparators(Text, i))) + { + string s = Text.Substring(i, len).ToLowerInvariant(); + + if (s == pattern.StringPattern.ToLowerInvariant()) + { + simpleword.HasContent = true; + simpleword.ParentList = pattern.Parent; + simpleword.Pattern = pattern; + simpleword.Position = i; + simpleword.Token = pattern.Parent.NormalizeCase + ? pattern.StringPattern + : Text.Substring(i, len); + break; + } + } + } + + #endregion + } + else + { + #region Case Sensitive + + if (lastpatternchar == lasttextchar) + { + if (!pattern.IsKeyword || (pattern.IsKeyword && pattern.HasSeparators(Text, i))) + { + string s = Text.Substring(i, len); + + if (s == pattern.StringPattern) + { + simpleword.HasContent = true; + simpleword.ParentList = pattern.Parent; + simpleword.Pattern = pattern; + simpleword.Position = i; + simpleword.Token = pattern.StringPattern; + break; + } + } + } + + #endregion + } + } + + if (simpleword.HasContent) + break; + } + + #endregion + } + + #endregion + + if (complexword.HasContent && simpleword.HasContent) + { + if (simpleword.Position == complexword.Position) + { + if (simpleword.Token.Length >= complexword.Token.Length) + return simpleword; + return complexword; + } + + if (simpleword.Position < complexword.Position) + return simpleword; + + if (simpleword.Position > complexword.Position) + return complexword; + } + + if (simpleword.HasContent) + return simpleword; + + if (complexword.HasContent) + return complexword; + + + return new ScanResultWord(); + } + + + private void ParseText(Row Row, Span currentSpan, string Text) + { + int CurrentPosition = 0; + bool HasComplex = true; + while (true) + { + ScanResultWord Word = GetNextWord(Text, currentSpan, CurrentPosition, ref HasComplex); + + if (!Word.HasContent) + { + ParseTools.AddString(Text.Substring(CurrentPosition), Row, currentSpan.spanDefinition.Style, + currentSpan); + break; + } + ParseTools.AddString(Text.Substring(CurrentPosition, Word.Position - CurrentPosition), Row, + currentSpan.spanDefinition.Style, currentSpan); + ParseTools.AddPatternString(Word.Token, Row, Word.Pattern, Word.ParentList.Style, currentSpan, false); + CurrentPosition = Word.Position + Word.Token.Length; + } + } + + private void InternalParseLine(int index, bool ParseKeywords) + { + if (mSyntaxDefinition == null) + return; + + // + // if (ParseKeywords) + // return; + // ParseKeywords=true; + SyntaxDocument doc = Document; + Row Row = doc[index]; + Span oldEndSpan = Row.endSpan; + Span oldStartSpan = Row.startSpan; + bool Fold = !Row.IsCollapsed; + + + if (Row.IsCollapsedEndPart) + { + //Row.expansion_EndSpan.Expanded = true; + //Row.expansion_EndSpan.EndRow = null; + Row.expansion_EndSpan.EndWord = null; + } + + + //set startsegment for this row + if (index > 0) + { + Row.startSpan = Document[index - 1].endSpan; + } + else + { + if (Row.startSpan == null) + { + Row.startSpan = new Span(Row) {spanDefinition = mSyntaxDefinition.mainSpanDefinition}; + } + } + + int CurrentPosition = 0; + Span currentSpan = Row.startSpan; + + + //kör tills vi kommit till slutet av raden.. + Row.endSpans.Clear(); + Row.startSpans.Clear(); + Row.Clear(); + // bool HasEndSegment=false; + + while (true) + { + ScanResultSegment ChildSegment = GetNextChildSegment(Row, currentSpan, CurrentPosition); + ScanResultSegment EndSegment = GetEndSegment(Row, currentSpan, CurrentPosition); + + if ((EndSegment.HasContent && ChildSegment.HasContent && EndSegment.Position <= ChildSegment.Position) || + (EndSegment.HasContent && ChildSegment.HasContent == false)) + { + //this is an end span + + if (ParseKeywords) + { + string Text = Row.Text.Substring(CurrentPosition, EndSegment.Position - CurrentPosition); + ParseText(Row, currentSpan, Text); + } + + Span oldseg = currentSpan; + while (currentSpan != EndSegment.span) + { + Row.endSpans.Add(currentSpan); + currentSpan = currentSpan.Parent; + } + Row.endSpans.Add(currentSpan); + + TextStyle st2 = currentSpan.Scope.Style; + + ParseTools.AddPatternString(EndSegment.Token, Row, EndSegment.Pattern, st2, currentSpan, false); + while (oldseg != EndSegment.span) + { + oldseg.EndRow = Row; + oldseg.EndWord = Row[Row.Count - 1]; + oldseg = oldseg.Parent; + } + + currentSpan.EndRow = Row; + currentSpan.EndWord = Row[Row.Count - 1]; + + + if (currentSpan.Parent != null) + currentSpan = currentSpan.Parent; + + CurrentPosition = EndSegment.Position + EndSegment.Token.Length; + } + else if (ChildSegment.HasContent) + { + //this is a child block + + if (ParseKeywords) + { + string Text = Row.Text.Substring(CurrentPosition, ChildSegment.Position - CurrentPosition); + //TextStyle st=currentSpan.spanDefinition.Style; + ParseText(Row, currentSpan, Text); + //ParseTools.AddString (Text,Row,st,currentSpan); + } + + + var NewSeg = new Span + { + Parent = currentSpan, + spanDefinition = ChildSegment.spanDefinition, + Scope = ChildSegment.Scope + }; + + Row.startSpans.Add(NewSeg); + + TextStyle st2 = NewSeg.Scope.Style; + ParseTools.AddPatternString(ChildSegment.Token, Row, ChildSegment.Pattern, st2, NewSeg, false); + NewSeg.StartRow = Row; + NewSeg.StartWord = Row[Row.Count - 1]; + + + currentSpan = NewSeg; + CurrentPosition = ChildSegment.Position + ChildSegment.Token.Length; + + if (ChildSegment.Scope.spawnSpanOnStart != null) + { + var SpawnSeg = new Span + { + Parent = NewSeg, + spanDefinition = ChildSegment.Scope.spawnSpanOnStart, + Scope = new Scope(), + StartWord = NewSeg.StartWord + }; + Row.startSpans.Add(SpawnSeg); + currentSpan = SpawnSeg; + } + } + else + { + if (CurrentPosition < Row.Text.Length) + { + if (ParseKeywords) + { + //we did not find a childblock nor an endblock , just output the last pice of text + string Text = Row.Text.Substring(CurrentPosition); + //TextStyle st=currentSpan.spanDefinition.Style; + ParseText(Row, currentSpan, Text); + //ParseTools.AddString (Text,Row,st,currentSpan); + } + } + break; + } + } + + while (!currentSpan.spanDefinition.MultiLine) + { + Row.endSpans.Add(currentSpan); + currentSpan = currentSpan.Parent; + } + + Row.endSpan = currentSpan; + Row.SetExpansionSegment(); + + Row.RowState = ParseKeywords ? RowState.AllParsed : RowState.SpanParsed; + + if (IsSameButDifferent(index, oldStartSpan)) + { + MakeSame(index); + //if (!IsSameButDifferent(index)) + // System.Diagnostics.Debugger.Break(); + } + + if (Row.CanFold) + Row.expansion_StartSpan.Expanded = Fold; + + //dont flag next line as needs parsing if only parsing keywords + if (!ParseKeywords) + { + if (oldEndSpan != null) + { + if (Row.endSpan != oldEndSpan && index <= Document.Count - 2) + { + //if (Row.CanFold) + // Row.expansion_StartSpan.Expanded = true; + Document[index + 1].AddToParseQueue(); + Document.NeedResetRows = true; + } + } + else if (index <= Document.Count - 2) + { + //if (Row.CanFold) + // Row.expansion_StartSpan.Expanded = true; + Document[index + 1].AddToParseQueue(); + Document.NeedResetRows = true; + } + } + + if (oldEndSpan != null) + { + //expand span if this line dont have an end word + if (oldEndSpan.EndWord == null) + oldEndSpan.Expanded = true; + } + } + + + private ScanResultSegment GetEndSegment(Row Row, Span currentSpan, int StartPos) + { + //this row has no text , just bail out... + if (StartPos >= Row.Text.Length || currentSpan.Scope == null) + return new ScanResultSegment(); + + var Result = new ScanResultSegment {HasContent = false, IsEndSegment = false}; + + + //-------------------------------------------------------------------------------- + //scan for childblocks + //scan each scope in each childblock + + Span seg = currentSpan; + + while (seg != null) + { + if (seg == currentSpan || seg.spanDefinition.TerminateChildren) + { + foreach (Pattern end in seg.Scope.EndPatterns) + { + PatternScanResult psr = end.IndexIn(Row.Text, StartPos, seg.Scope.CaseSensitive, Separators); + int CurrentPosition = psr.Index; + if (psr.Token != "") + { + if ((psr.Index < Result.Position && Result.HasContent) || !Result.HasContent) + { + //we found a better match + //store this new match + Result.Pattern = end; + Result.Position = CurrentPosition; + Result.Token = psr.Token; + Result.HasContent = true; + Result.span = seg; + Result.Scope = null; + + + if (!end.IsComplex) + { + if (seg.Scope.NormalizeCase) + if (!seg.Scope.Start.IsComplex) + Result.Token = end.StringPattern; + } + } + } + } + } + seg = seg.Parent; + } + + //no result , return new ScanResultSegment(); + if (!Result.HasContent) + return new ScanResultSegment(); + + return Result; + } + + private ScanResultSegment GetNextChildSegment(Row Row, Span currentSpan, int StartPos) + { + //this row has no text , just bail out... + if (StartPos >= Row.Text.Length) + return new ScanResultSegment(); + + + var Result = new ScanResultSegment {HasContent = false, IsEndSegment = false}; + + + foreach (SpanDefinition ChildBlock in currentSpan.spanDefinition.childSpanDefinitions) + { + //scan each scope in each childblock + foreach (Scope Scope in ChildBlock.ScopePatterns) + { + PatternScanResult psr = Scope.Start.IndexIn(Row.Text, StartPos, Scope.CaseSensitive, Separators); + int CurrentPosition = psr.Index; + if ((!Result.HasContent || CurrentPosition < Result.Position) && psr.Token != "") + { + //we found a better match + //store this new match + Result.Pattern = Scope.Start; + Result.Position = CurrentPosition; + Result.Token = psr.Token; + Result.HasContent = true; + Result.spanDefinition = ChildBlock; + Result.Scope = Scope; + + if (Scope.NormalizeCase) + if (!Scope.Start.IsComplex) + Result.Token = Scope.Start.StringPattern; + } + } + } + + + //no result , new ScanResultSegment(); + if (!Result.HasContent) + return new ScanResultSegment(); + + return Result; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/IParser.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/IParser.cs new file mode 100644 index 0000000..395c209 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/IParser.cs @@ -0,0 +1,63 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.SourceCode.SyntaxDocumentParsers +{ + /// + /// Parser interface. + /// Implement this interface if you want to create your own parser. + /// + public interface IParser + { + /// + /// Gets or Sets the Document object for this parser + /// + SyntaxDocument Document { get; set; } + + /// + /// Gets or Sets the SyntaxDefinition for this parser + /// + SyntaxDefinition SyntaxDefinition { get; set; } + + string Separators { get; set; } + + /// + /// Initializes the parser with a spcified SyntaxFile + /// + /// Filename of the SyntaxFile that should be used + void Init(string syntaxDefinitionPath); + + /// + /// + /// + /// + /// + void Init(string syntaxDefinitionPath, string separators); + + /// + /// Initializes the parser with a spcified syntaxDefinition object + /// + /// The Language object to assign to the parser + void Init(SyntaxDefinition syntaxDefinition); + + /// + /// Called by the SyntaxDocument object when a row should be parsed + /// + /// The row index in the document + /// true if keywords and operators should be parsed , false if only a span parse should be performed + void ParseRow(int RowIndex, bool ParseKeywords); + + /// + /// Called by the SyntaxDocument object when a row must be preview parsed. + /// + /// Row index in the document + void ParsePreviewLine(int RowIndex); + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/NewParser.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/NewParser.cs new file mode 100644 index 0000000..6f2c5ef --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/NewParser.cs @@ -0,0 +1,26 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * + +namespace Alsing.SourceCode.SyntaxDocumentParsers +{ + public sealed class NewParser : ParserBase + { + public override void ParseRow(int rowIndex, bool parseKeywords) + { + if (!parseKeywords) + ParseLineStructure(rowIndex); + else + ParseLineFully(rowIndex); + } + + private void ParseLineFully(int rowIndex) {} + + private void ParseLineStructure(int rowIndex) {} + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ParseTools.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ParseTools.cs new file mode 100644 index 0000000..7325467 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ParseTools.cs @@ -0,0 +1,126 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; +using System.Text; + +namespace Alsing.SourceCode.SyntaxDocumentParsers +{ + public sealed class ParseTools + { + public static void AddPatternString(string Text, Row Row, Pattern Pattern, TextStyle Style, Span span, + bool HasError) + { + var x = new Word {Style = Style, Pattern = Pattern, HasError = HasError, Span = span, Text = Text}; + Row.Add(x); + } + + public static unsafe void AddString(string Text, Row Row, TextStyle Style, Span span) + { + if (Text == "") + return; + + var CurrentWord = new StringBuilder(); + char[] Buff = Text.ToCharArray(); + fixed (char* c = &Buff[0]) + { + for (int i = 0; i < Text.Length; i++) + { + if (c[i] == ' ' || c[i] == '\t') + { + if (CurrentWord.Length != 0) + { + Word word = Row.Add(CurrentWord.ToString()); + word.Style = Style; + word.Span = span; + CurrentWord = new StringBuilder(); + } + + Word ws = Row.Add(c[i].ToString()); + if (c[i] == ' ') + ws.Type = WordType.Space; + else + ws.Type = WordType.Tab; + ws.Style = Style; + ws.Span = span; + } + else + CurrentWord.Append(c[i].ToString()); + } + if (CurrentWord.Length != 0) + { + Word word = Row.Add(CurrentWord.ToString()); + word.Style = Style; + word.Span = span; + } + } + } + + + public static List GetWords(string text) + { + var words = new List(); + var CurrentWord = new StringBuilder(); + foreach (char c in text) + { + if (c == ' ' || c == '\t') + { + if (CurrentWord.ToString() != "") + { + words.Add(CurrentWord.ToString()); + CurrentWord = new StringBuilder(); + } + + words.Add(c.ToString()); + } + else + CurrentWord.Append(c.ToString()); + } + if (CurrentWord.ToString() != "") + words.Add(CurrentWord.ToString()); + return words; + } + + public static PatternScanResult GetFirstWord(char[] TextBuffer, PatternCollection Patterns, int StartPosition) + { + PatternScanResult Result; + Result.Index = 0; + Result.Token = ""; + + // for (int i=StartPosition;i + /// Parser event handler + /// + public delegate void ParserEventHandler(object sender, RowEventArgs e); +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ScanResultSegment.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ScanResultSegment.cs new file mode 100644 index 0000000..a402c0e --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ScanResultSegment.cs @@ -0,0 +1,14 @@ +namespace Alsing.SourceCode.SyntaxDocumentParsers +{ + public class ScanResultSegment + { + public bool HasContent; + public bool IsEndSegment; + public Pattern Pattern; + public int Position; + public Scope Scope; + public Span span; + public SpanDefinition spanDefinition; + public string Token = ""; + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ScanResultWord.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ScanResultWord.cs new file mode 100644 index 0000000..c0ffdd4 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Parser/ScanResultWord.cs @@ -0,0 +1,11 @@ +namespace Alsing.SourceCode.SyntaxDocumentParsers +{ + public class ScanResultWord + { + public bool HasContent; + public PatternList ParentList; + public Pattern Pattern; + public int Position; + public string Token = ""; + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Print/SourceCodePrintDocument.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Print/SourceCodePrintDocument.cs new file mode 100644 index 0000000..7ce7e48 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Print/SourceCodePrintDocument.cs @@ -0,0 +1,214 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Printing; + +namespace Alsing.SourceCode +{ + /// + /// Printer document class. + /// + /// + /// + /// + /// Print the content of a SyntaxDocument: + /// + /// SourceCodePrintDocument PrintDoc=new SourceCodePrintDocument(MySyntaxDocument); + /// + /// PrintDialog1.Document =PrintDoc; + /// if (PrintDialog1.ShowDialog ()==DialogResult.OK) + /// PrintDoc.Print (); + /// + ///
+ /// Print Preview the content of a SyntaxDocument + /// + /// SourceCodePrintDocument PrintDoc=new SourceCodePrintDocument(MySyntaxDocument); + /// PrintPreviewDialog1.Document = PrintDoc + /// PrintPreviewDialog1.ShowDialog (); + /// + ///
+ [ToolboxItem(true)] + public class SourceCodePrintDocument : PrintDocument + { + private Font fontBreak; + private Font fontNormal; + + + private RowList rc; + private int RowIndex; + + public SourceCodePrintDocument() {} + + public SourceCodePrintDocument(SyntaxDocument document) + { + Document = document; + } + + public SyntaxDocument Document { get; set; } + + //Override OnBeginPrint to set up the font we are going to use + protected override void OnBeginPrint(PrintEventArgs ev) + { + base.OnBeginPrint(ev); + fontNormal = new Font("Courier new", 8, FontStyle.Regular); + fontBreak = new Font("Symbol", 8, FontStyle.Bold); + // fontBold = new Font("Arial", 10,FontStyle.Bold); + // fontItalic = new Font("Arial", 10,FontStyle.Italic); + // fontBoldItalic = new Font("Arial", 10,FontStyle.Bold | FontStyle.Italic); + // fontUnderline = new Font("Arial", 10,FontStyle.Underline); + // fontBoldUnderline = new Font("Arial", 10,FontStyle.Bold | FontStyle.Underline); + // fontItalicUnderline = new Font("Arial", 10,FontStyle.Italic | FontStyle.Underline); + // fontBoldItalicUnderline = new Font("Arial", 10,FontStyle.Bold | FontStyle.Italic | FontStyle.Underline); + RowIndex = 0; + } + + //Override the OnPrintPage to provide the printing logic for the document + protected override void OnPrintPage(PrintPageEventArgs ev) + { + int count = 0; + float leftMargin = ev.MarginBounds.Left; + float rightMargin = ev.MarginBounds.Right; + float topMargin = ev.MarginBounds.Top; + //ev.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; + + if (rc == null) + { + Document.ParseAll(); + Document.ParseAll(true); + + + rc = new RowList(); + foreach (Row r in Document) + { + bool hasbreak = false; + float x = leftMargin; + var newRow = new Row(); + rc.Add(newRow); + foreach (Word w in r) + { + Font f = fontNormal; + if (w.Style != null) + { + FontStyle fs = 0; + + if (w.Style.Bold) + fs |= FontStyle.Bold; + + if (w.Style.Italic) + fs |= FontStyle.Italic; + + if (w.Style.Underline) + fs |= FontStyle.Underline; + + f = new Font("Courier new", 8, fs); + } + SizeF sf = ev.Graphics.MeasureString(w.Text, f); + if (x + sf.Width > rightMargin) + { + var chr = (char) 0xbf; + var br = new Word {Text = (chr + ""), InfoTip = "break char"}; + newRow.Add(br); + hasbreak = true; + + + newRow = new Row(); + rc.Add(newRow); + x = leftMargin; + } + x += sf.Width; + newRow.Add(w); + } + if (hasbreak) + { + rc.Add(new Row()); + } + } + } + //------------------------------------------------------ + + base.OnPrintPage(ev); + + + float lpp = ev.MarginBounds.Height/fontNormal.GetHeight(ev.Graphics); + + + while (count < lpp && (RowIndex < rc.Count)) + { + float x = leftMargin; + float yPos = topMargin + (count*fontNormal.GetHeight(ev.Graphics)); + + Row r = rc[RowIndex]; + + foreach (Word w in r) + { + if (w.InfoTip != null && w.InfoTip == "break char") + { + ev.Graphics.DrawString(w.Text, fontBreak, Brushes.Black, x, yPos, new StringFormat()); + } + else + { + SizeF sf = ev.Graphics.MeasureString(w.Text, fontNormal); + + if (w.Text != null && (".,:;".IndexOf(w.Text) >= 0)) + { + sf.Width = 6; + x -= 4; + } + if (w.Text == "\t") + { + sf.Width = ev.Graphics.MeasureString("...", fontNormal).Width; + } + + + Color c = Color.Black; + Font f = fontNormal; + if (w.Style != null) + { + c = w.Style.ForeColor; + FontStyle fs = 0; + + if (w.Style.Bold) + fs |= FontStyle.Bold; + + if (w.Style.Italic) + fs |= FontStyle.Italic; + + if (w.Style.Underline) + fs |= FontStyle.Underline; + + f = new Font("Courier new", 8, fs); + + if (!w.Style.Transparent) + { + Color bg = w.Style.BackColor; + ev.Graphics.FillRectangle(new SolidBrush(bg), x, yPos, sf.Width, + fontNormal.GetHeight(ev.Graphics)); + } + } + + c = Color.FromArgb(c.R, c.G, c.B); + + + ev.Graphics.DrawString(w.Text, f, new SolidBrush(c), x, yPos, new StringFormat()); + x += sf.Width; + } + } + + count++; + RowIndex++; + } + + //If we have more lines then print another page + ev.HasMorePages = RowIndex < rc.Count; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Print/SourceCodePrintDocument.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Print/SourceCodePrintDocument.resx new file mode 100644 index 0000000..6b3c4ce --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/Print/SourceCodePrintDocument.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/Pattern.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/Pattern.cs new file mode 100644 index 0000000..f7d8362 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/Pattern.cs @@ -0,0 +1,170 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Text.RegularExpressions; + +namespace Alsing.SourceCode +{ + /// + /// A Pattern is a specific string or a RegEx pattern that is used by the parser. + /// There are two types of patterns , Simple and Complex. + /// + /// Simple Patterns are patterns that consists of a simple fixed string eg. "void" or "for". + /// Complex Patterns are patterns that consists of RegEx patterns , eg hex numbers or urls can be described as regex patterns. + /// + public sealed partial class Pattern + { + public static readonly string DefaultSeparators = ".,+-*^\\/()[]{}@:;'?£$#%& \t=<>"; + + private string _StringPattern = ""; + public BracketType BracketType = BracketType.None; + + /// + /// Category of the pattern + /// Built in categories are: + /// URL + /// MAIL + /// FILE + /// + public string Category; + + /// + /// Gets if the pattern is a simple string or a RegEx pattern + /// + public bool IsComplex; + + /// + /// Get or Sets if this pattern needs separator chars before and after it in order to be valid. + /// + public bool IsKeyword; + + public bool IsMultiLineBracket = true; + + /// + /// Gets or Sets if the pattern is a separator pattern . + /// A separator pattern can be "End Sub" in VB6 , whenever that pattern is found , the SyntaxBoxControl will render a horizontal separator line. + /// NOTE: this should not be mixed up with separator chars. + /// + public bool IsSeparator; + + /// + /// For internal use only + /// + public string LowerStringPattern = ""; + + public Pattern MatchingBracket; + + /// + /// The owning PatternList , eg a specific KeywordList or OperatorList + /// + public PatternList Parent; + + internal Regex rx; + + #region PUBLIC PROPERTY SEPARATORS + + private string _Separators = DefaultSeparators; + + public string Separators + { + get { return _Separators; } + set { _Separators = value; } + } + + #endregion + + /// + /// + /// + /// + /// + public Pattern(string pattern, bool iscomplex) + { + StringPattern = pattern; + if (iscomplex) + { + IsComplex = true; + rx = new Regex(StringPattern, RegexOptions.Compiled); + } + else + { + IsComplex = false; + } + } + + + /// + /// + /// + /// + /// + /// + /// + public Pattern(string pattern, bool iscomplex, bool separator, bool keyword) + { + Init(pattern, iscomplex, separator, keyword); + } + + /// + /// + /// + /// + /// + /// + /// + public Pattern(string pattern, bool separator, bool keyword, string escapeChar) + { + escapeChar = Regex.Escape(escapeChar); + string escapePattern = string.Format("(?<=((? + /// Gets or Sets the the text of the pattern + /// this only applies if the pattern is a simple pattern. + /// + public string StringPattern + { + get { return _StringPattern; } + set + { + _StringPattern = value; + LowerStringPattern = _StringPattern.ToLowerInvariant(); + } + } + + /// + /// Returns true if the pattern contains separator chars
+ /// (This is used by the parser) + ///
+ public bool ContainsSeparator + { + get + { + foreach (char c in StringPattern) + { + if (Separators.IndexOf(c) >= 0) + return true; + } + return false; + } + } + + private void Init(string pattern, bool isComplex, bool separator, bool keyword) + { + StringPattern = pattern; + IsSeparator = separator; + IsKeyword = keyword; + IsComplex = isComplex; + if (isComplex) + rx = new Regex(StringPattern, RegexOptions.Compiled); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternCollection.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternCollection.cs new file mode 100644 index 0000000..e0e9905 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternCollection.cs @@ -0,0 +1,19 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; + +namespace Alsing.SourceCode +{ + /// + /// + /// + public sealed class PatternCollection : List {} +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternExtensions.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternExtensions.cs new file mode 100644 index 0000000..7270545 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternExtensions.cs @@ -0,0 +1,158 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Text.RegularExpressions; + +namespace Alsing.SourceCode +{ + public partial class Pattern + { + /// + /// For public use only + /// + /// + /// + /// + public bool HasSeparators(string text, int position) + { + return (CharIsSeparator(text, position - 1) && CharIsSeparator(text, position + StringPattern.Length)); + } + + + private bool CharIsSeparator(string Text, int Position) + { + if (Position < 0 || Position >= Text.Length) + return true; + + string s = Text.Substring(Position, 1); + if (Separators.IndexOf(s) >= 0) + return true; + return false; + } + + /// + /// Returns the index of the pattern in a string + /// + /// + /// The string in which to find the pattern + /// Start index in the string + /// true if a case sensitive match should be performed + /// + /// A PatternScanResult containing information on where the pattern was found and also the text of the pattern + public PatternScanResult IndexIn(string text, int startPosition, bool matchCase, string separators) + { + if (separators == null) {} + else + { + Separators = separators; + } + + if (!IsComplex) + { + if (!IsKeyword) + return SimpleFind(text, startPosition, matchCase); + + return SimpleFindKeyword(text, startPosition, matchCase); + } + if (!IsKeyword) + return ComplexFind(text, startPosition); + + return ComplexFindKeyword(text, startPosition); + } + + + private PatternScanResult SimpleFind(string text, int startPosition, bool matchCase) + { + int Position = matchCase + ? text.IndexOf(StringPattern, startPosition) + : text.ToLowerInvariant().IndexOf(LowerStringPattern, startPosition); + + PatternScanResult Result; + if (Position >= 0) + { + Result.Index = Position; + Result.Token = text.Substring(Position, StringPattern.Length); + } + else + { + Result.Index = 0; + Result.Token = ""; + } + + return Result; + } + + private PatternScanResult SimpleFindKeyword(string text, int startPosition, bool matchCase) + { + PatternScanResult res; + while (true) + { + res = SimpleFind(text, startPosition, matchCase); + if (res.Token == "") + return res; + + if (CharIsSeparator(text, res.Index - 1) && CharIsSeparator(text, res.Index + res.Token.Length)) + return res; + + startPosition = res.Index + 1; + if (startPosition >= text.Length) + { + res.Token = ""; + res.Index = 0; + return res; + } + } + } + + + private PatternScanResult ComplexFindKeyword(string text, int startPosition) + { + PatternScanResult res; + while (true) + { + res = ComplexFind(text, startPosition); + if (res.Token == "") + return res; + + if (CharIsSeparator(text, res.Index - 1) && CharIsSeparator(text, res.Index + res.Token.Length)) + return res; + + startPosition = res.Index + 1; + if (startPosition >= text.Length) + { + res.Token = ""; + res.Index = 0; + return res; + } + } + } + + private PatternScanResult ComplexFind(string text, int startPosition) + { + MatchCollection mc = rx.Matches(text); + foreach (Match m in mc) + { + int pos = m.Index; + string p = m.Value; + if (pos >= startPosition) + { + PatternScanResult t; + t.Index = pos; + t.Token = p; + return t; + } + } + PatternScanResult res; + res.Index = 0; + res.Token = ""; + return res; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternList.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternList.cs new file mode 100644 index 0000000..dc14dbb --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternList.cs @@ -0,0 +1,160 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Collections; + +namespace Alsing.SourceCode +{ + /// + /// A List containing patterns. + /// this could be for example a list of keywords or operators + /// + public sealed class PatternList : IEnumerable + { + private readonly PatternCollection patterns = new PatternCollection(); + + /// + /// Gets or Sets if this list contains case seinsitive patterns + /// + public bool CaseSensitive; + + /// + /// For public use only + /// + public PatternCollection ComplexPatterns = new PatternCollection(); + + /// + /// The name of the pattern list + /// + public string Name = ""; + + /// + /// Gets or Sets if the patterns in this list should be case normalized + /// + public bool NormalizeCase; + + /// + /// + /// + public PatternListList Parent; + + /// + /// The parent spanDefinition of this list + /// + public SpanDefinition parentSpanDefinition; + + /// + /// for public use only + /// + public Hashtable SimplePatterns = new Hashtable(); + + /// + /// + /// + public Hashtable SimplePatterns1Char = new Hashtable(); + + /// + /// For public use only + /// + public Hashtable SimplePatterns2Char = new Hashtable(); + + /// + /// Gets or Sets the TextStyle that should be assigned to patterns in this list + /// + public TextStyle Style = new TextStyle(); + + /// + /// + /// + public PatternList() + { + SimplePatterns = new Hashtable(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default); + } + + #region IEnumerable Members + + /// + /// + /// + /// + public IEnumerator GetEnumerator() + { + return patterns.GetEnumerator(); + } + + #endregion + + /// + /// + /// + /// + /// + public Pattern Add(Pattern Pattern) + { + if (Parent != null && Parent.Parent != null && Parent.Parent.Parent != null) + { + Pattern.Separators = Parent.Parent.Parent.Separators; + Parent.Parent.Parent.ChangeVersion(); + } + + if (!Pattern.IsComplex && !Pattern.ContainsSeparator) + { + //store pattern in lookuptable if it is a simple pattern + string s; + + if (Pattern.StringPattern.Length >= 2) + s = Pattern.StringPattern.Substring(0, 2); + else + s = Pattern.StringPattern.Substring(0, 1) + " "; + + s = s.ToLowerInvariant(); + + if (Pattern.StringPattern.Length == 1) + { + SimplePatterns1Char[Pattern.StringPattern] = Pattern; + } + else + { + if (SimplePatterns2Char[s] == null) + SimplePatterns2Char[s] = new PatternCollection(); + var ar = (PatternCollection) SimplePatterns2Char[s]; + ar.Add(Pattern); + } + + if (CaseSensitive) + SimplePatterns[Pattern.LowerStringPattern] = Pattern; + else + SimplePatterns[Pattern.StringPattern] = Pattern; + } + else + { + ComplexPatterns.Add(Pattern); + } + + patterns.Add(Pattern); + if (Pattern.Parent == null) + Pattern.Parent = this; + else + { + throw (new Exception("Pattern already assigned to another PatternList")); + } + return Pattern; + } + + /// + /// + /// + public void Clear() + { + patterns.Clear(); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternListList.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternListList.cs new file mode 100644 index 0000000..d1fcbab --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternListList.cs @@ -0,0 +1,93 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections; + +namespace Alsing.SourceCode +{ + /// + /// + /// + public sealed class PatternListList : IEnumerable + { + private readonly ArrayList mGroups = new ArrayList(); + + /// + /// + /// + public bool IsKeyword; + + /// + /// + /// + public bool IsOperator; + + /// + /// + /// + public SpanDefinition Parent; + + /// + /// + /// + public PatternListList() {} + + public PatternListList(SpanDefinition parent) + { + Parent = parent; + } + + /// + /// + /// + public PatternList this[int index] + { + get { return (PatternList) mGroups[index]; } + + set { mGroups[index] = value; } + } + + #region IEnumerable Members + + /// + /// + /// + /// + public IEnumerator GetEnumerator() + { + return mGroups.GetEnumerator(); + } + + #endregion + + /// + /// + /// + /// + /// + public PatternList Add(PatternList Group) + { + mGroups.Add(Group); + Group.Parent = this; + if (Parent != null && Parent.Parent != null) + Parent.Parent.ChangeVersion(); + + return Group; + } + + /// + /// + /// + public void Clear() + { + mGroups.Clear(); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternScanResult.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternScanResult.cs new file mode 100644 index 0000000..0ddeecf --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Pattern/PatternScanResult.cs @@ -0,0 +1,29 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.SourceCode +{ + /// + /// PatternScanResult struct is redurned by the Pattern class when an .IndexIn call has been performed. + /// + public struct PatternScanResult + { + /// + /// The index on which the pattern was found in the source string + /// + public int Index; + + /// + /// The string that was found , this is always the same as the pattern StringPattern property if the pattern is a simple pattern. + /// if the pattern is complex this field will contain the string that was found by the scan. + /// + public string Token; + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Scope/Scope.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Scope/Scope.cs new file mode 100644 index 0000000..be6560f --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Scope/Scope.cs @@ -0,0 +1,70 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.SourceCode +{ + /// + /// The Scope class defines what patterns starts and ends a spanDefinition + /// + public sealed class Scope + { + /// + /// Gets or Sets if the scope patterns is case sensitive + /// + public bool CaseSensitive; + + public bool CauseIndent; + + /// + /// Gets or Sets if this block should be expanded or collapsed by default + /// + public bool DefaultExpanded = true; + + /// + /// List of end patterns + /// + public PatternCollection EndPatterns = new PatternCollection(); + + /// + /// The text that should be displayed if the owner block is collapsed + /// + public string ExpansionText = ""; + + /// + /// Gets or Sets if the scope patterns should be case normalized + /// + public bool NormalizeCase = true; + + /// + /// The owner spanDefinition + /// + public SpanDefinition Parent; + + /// + /// spanDefinition that should be started directly after this block have ended + /// + public SpanDefinition spawnSpanOnEnd; + + /// + /// spanDefinition that should be started directly after this block have started + /// + public SpanDefinition spawnSpanOnStart; + + /// + /// The Start trigger Pattern + /// + public Pattern Start; + + /// + /// The style that should be applied to the start and end patterns + /// + public TextStyle Style; + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Scope/ScopeList.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Scope/ScopeList.cs new file mode 100644 index 0000000..ca4dbc5 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/Scope/ScopeList.cs @@ -0,0 +1,28 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; +using T = Alsing.SourceCode.Scope; + +namespace Alsing.SourceCode +{ + /// + /// + /// + public sealed class ScopeList : List + { + public ScopeList(SpanDefinition parent) + { + Parent = parent; + } + + public SpanDefinition Parent { get; private set; } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SpanDefinition/SpanDefinition.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SpanDefinition/SpanDefinition.cs new file mode 100644 index 0000000..33b50a4 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SpanDefinition/SpanDefinition.cs @@ -0,0 +1,242 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections; +using System.Collections.Generic; +using System.Drawing; + +namespace Alsing.SourceCode +{ + /// + /// spanDefinition class + /// + /// + /// The spanDefinition class represents a specific code/text element
+ /// such as a string , comment or the code itself.
+ ///
+ /// a spanDefinition can contain keywords , operators , scopes and child spans.
+ ///
+ ///
+ /// For example , if we where to describe the syntax C#
+ /// we would have the following span:
+ ///
+ /// Code span - the spanDefinition containing all the keywords and operators.
+ /// Singleline comment span - a spanDefinition that starts on // terminates at the end of a line.
+ /// Multiline comment span - a spanDefinition that starts on /* can span multiple rows and terminates on */.
+ /// String span - a spanDefinition that starts on " terminates on " or at the end of a line.
+ /// Char span - a spanDefinition that starts on ' terminates on ' or at the end of a line.
+ ///
+ /// CHILD SPANS:
+ /// The code span would have all the other spans as childspans , since they can only appear inside the
+ /// code span . A string can for example never exist inside a comment in C#.
+ /// a spanDefinition can also have itself as a child span.
+ /// For example , the C# Code span can have itself as a childspan and use the scope patterns "{" and "}"
+ /// this way we can accomplish FOLDING since the parser will know where a new scope starts and ends.
+ ///
+ /// SCOPES:
+ /// Scopes describe what patterns starts and what patterns end a specific spanDefinition.
+ /// For example , the C# Multiline Comment have the scope patterns /* and */
+ ///
+ /// KEYWORDS:
+ /// A Keyword is a pattern that can only exist between separator chars.
+ /// For example the keyword "for" in c# is valid if it is contained in this string " for ("
+ /// but it is not valid if the containing string is " MyFormat "
+ ///
+ /// OPERATORS:
+ /// Operators is the same thing as keywords but are valid even if there are no separator chars around it.
+ /// In most cases operators are only one or two chars such as ":" or "->"
+ /// operators in this context should not be mixed up with code operators such as "and" or "xor" in VB6
+ /// in this context they are keywords.
+ ///
+ ///
+ ///
+ public class SpanDefinition + { + private readonly List tmpSimplePatterns = new List(); + + /// + /// The background color of a span. + /// + public Color BackColor = Color.Transparent; + + /// + /// A list containing which spanDefinitions are valid child spans in a specific span. + /// eg. strings and comments are child spans for a code span + /// + public SpanDefinitionList childSpanDefinitions = new SpanDefinitionList(); + + public PatternCollection ComplexPatterns = new PatternCollection(); + + /// + /// A list of keyword groups. + /// For example , one keyword group could be "keywords" and another could be "datatypes" + /// theese groups could have different color shemes assigned to them. + /// + public PatternListList KeywordsList; //new PatternListList (this); + + public Hashtable LookupTable = new Hashtable(); + + /// + /// Gets or Sets if the spanDefinition can span multiple lines or if it should terminate at the end of a line. + /// + public bool MultiLine; + + /// + /// The name of this span. + /// names are not required for span but can be a good help when interacting with the parser. + /// + public string Name = ""; + + /// + /// A list of operator groups. + /// Each operator group can contain its own operator patterns and its own color shemes. + /// + public PatternListList OperatorsList; //new PatternListList (this); + + /// + /// A list of scopes , most span only contain one scope , eg a scope with start and end patterns "/*" and "*/" + /// for multiline comments, but in some cases you will need more scopes , eg. PHP uses both "<?" , "?>" and "<?PHP" , "PHP?>" + /// + public ScopeList ScopePatterns; + + /// + /// The style to use when colorizing the content of a span, + /// meaning everything in this span except keywords , operators and childspans. + /// + public TextStyle Style; + + /// + /// Gets or Sets if the parser should terminate any child span when it finds an end scope pattern for this span. + /// for example %> in asp terminates any asp span even if it appears inside an asp string. + /// + public bool TerminateChildren; + + + /// + /// Default spanDefinition constructor + /// + public SpanDefinition(SyntaxDefinition parent) : this() + { + Parent = parent; + Parent.ChangeVersion(); + } + + public SpanDefinition() + { + KeywordsList = new PatternListList(this); + OperatorsList = new PatternListList(this); + + Style = new TextStyle(); + KeywordsList.Parent = this; + KeywordsList.IsKeyword = true; + OperatorsList.Parent = this; + OperatorsList.IsOperator = true; + ScopePatterns = new ScopeList(this); + } + + #region PUBLIC PROPERTY PARENT + + public SyntaxDefinition Parent { get; set; } + + #endregion + + /// + /// Returns false if any color has been assigned to the backcolor property + /// + public bool Transparent + { + get { return (BackColor.A == 0); } + } + + public void ResetLookupTable() + { + LookupTable.Clear(); + tmpSimplePatterns.Clear(); + ComplexPatterns.Clear(); + } + + public void AddToLookupTable(Pattern pattern) + { + if (pattern.IsComplex) + { + ComplexPatterns.Add(pattern); + return; + } + tmpSimplePatterns.Add(pattern); + } + + public void BuildLookupTable() + { + tmpSimplePatterns.Sort(new PatternComparer()); + foreach (Pattern p in tmpSimplePatterns) + { + if (p.StringPattern.Length <= 2) + { + char c = p.StringPattern[0]; + + if (!p.Parent.CaseSensitive) + { + char c1 = char.ToLowerInvariant(c); + if (LookupTable[c1] == null) + LookupTable[c1] = new PatternCollection(); + + var patterns = LookupTable[c1] as PatternCollection; + if (patterns != null) + if (!patterns.Contains(p)) + patterns.Add(p); + + char c2 = char.ToUpper(c); + if (LookupTable[c2] == null) + LookupTable[c2] = new PatternCollection(); + + patterns = LookupTable[c2] as PatternCollection; + if (patterns != null) + if (!patterns.Contains(p)) + patterns.Add(p); + } + else + { + if (LookupTable[c] == null) + LookupTable[c] = new PatternCollection(); + + var patterns = LookupTable[c] as PatternCollection; + if (patterns != null) + if (!patterns.Contains(p)) + patterns.Add(p); + } + } + else + { + string c = p.StringPattern.Substring(0, 3).ToLowerInvariant(); + + if (LookupTable[c] == null) + LookupTable[c] = new PatternCollection(); + + var patterns = LookupTable[c] as PatternCollection; + if (patterns != null) + if (!patterns.Contains(p)) + patterns.Add(p); + } + } + } + } + + public class PatternComparer : IComparer + { + #region IComparer Members + + public int Compare(Pattern x, Pattern y) + { + return y.StringPattern.Length.CompareTo(x.StringPattern.Length); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SpanDefinition/SpanDefinitionList.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SpanDefinition/SpanDefinitionList.cs new file mode 100644 index 0000000..1b7e538 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SpanDefinition/SpanDefinitionList.cs @@ -0,0 +1,19 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; + +namespace Alsing.SourceCode +{ + /// + /// + /// + public class SpanDefinitionList : List {} +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SyntaxDefinition.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SyntaxDefinition.cs new file mode 100644 index 0000000..70c82e8 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SyntaxDefinition.cs @@ -0,0 +1,245 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; + +namespace Alsing.SourceCode +{ + /// + /// File type struct + /// + public class FileType + { + /// + /// The file type extension + /// + public string Extension = ""; + + /// + /// The name of the file type + /// + public string Name = ""; + } + + /// + /// The SyntaxDefinition class describes a syntax.
+ /// It consists of a mainSpanDefinition , which is the start spanDefinition of the SyntaxDefinition
+ /// It also have a list of filetypes that is valid for this syntax
+ ///
+ /// + /// Apply a Syntax to a SyntaxBox + /// + /// SyntaxBoxControl1.Document.SyntaxFile="C#.syn"; + /// + /// + public class SyntaxDefinition + { + #region PUBLIC PROPERTY SEPARATORS + + private string _Separators = ".,:;{}()[]+-*/\\ \t=&%$#@!|&"; + + public string Separators + { + get { return _Separators; } + set { _Separators = value; } + } + + #endregion + + #region PUBLIC PROPERTY VERSION + + private long _Version = long.MinValue; + + public long Version + { + get { return _Version; } + set { _Version = value; } + } + + #endregion + + private readonly Dictionary spanDefinitionLookup = + new Dictionary(); + + private readonly Dictionary styleLookup = new Dictionary(); + + /// + /// List containing the valid filetypes for this syntax + /// + public List FileTypes = new List(); + + /// + /// The start spanDefinition for this syntax + /// + public SpanDefinition mainSpanDefinition; + + /// + /// Name of the SyntaxDefinition + /// + public string Name = ""; + + /// + /// Gets all BlockTypes in a given syntax. + /// + public SpanDefinition[] SpanDefinitions + { + get + { + spanDefinitionLookup.Clear(); + FillBlocks(mainSpanDefinition); + var blocks = new SpanDefinition[spanDefinitionLookup.Values.Count]; + int i = 0; + foreach (SpanDefinition bt in spanDefinitionLookup.Values) + { + blocks[i] = bt; + i++; + } + + return blocks; + } + } + + public TextStyle[] Styles + { + get + { + styleLookup.Clear(); + SpanDefinition[] spanDefinitions = SpanDefinitions; + foreach (SpanDefinition bt in spanDefinitions) + { + styleLookup[bt.Style] = bt.Style; + + foreach (Scope sc in bt.ScopePatterns) + { + if (sc.Style != null) + styleLookup[sc.Style] = sc.Style; + } + + foreach (PatternList pl in bt.KeywordsList) + { + if (pl.Style != null) + styleLookup[pl.Style] = pl.Style; + } + + foreach (PatternList pl in bt.OperatorsList) + { + if (pl.Style != null) + styleLookup[pl.Style] = pl.Style; + } + } + + var styles = new TextStyle[styleLookup.Values.Count]; + int i = 0; + foreach (TextStyle st in styleLookup.Values) + { + styles[i] = st; + i++; + } + return styles; + } + } + + public void UpdateLists() + { + SpanDefinition[] spanDefinitions = SpanDefinitions; + foreach (SpanDefinition block in spanDefinitions) + { + block.Parent = this; + block.ResetLookupTable(); + + block.KeywordsList.Parent = block; + foreach (PatternList patterns in block.KeywordsList) + { + patterns.Parent = block.KeywordsList; + + foreach (Pattern pattern in patterns) + { + block.AddToLookupTable(pattern); + } + } + + block.OperatorsList.Parent = block; + foreach (PatternList patterns in block.OperatorsList) + { + patterns.Parent = block.OperatorsList; + + foreach (Pattern pattern in patterns) + { + block.AddToLookupTable(pattern); + } + } + block.BuildLookupTable(); + } + } + + public void ChangeVersion() + { + Version++; + if (Version > long.MaxValue - 10) + Version = long.MinValue; + } + + public static SyntaxDefinition FromSyntaxXml(string xml) + { + var sl = new SyntaxDefinitionLoader(); + return sl.LoadXML(xml); + } + + public static SyntaxDefinition FromSyntaxFile(string filename) + { + var sl = new SyntaxDefinitionLoader(); + return sl.Load(filename); + } + + public void MergeByMainBlock(SyntaxDefinition Target) + { + SpanDefinition[] spanDefinitions = SpanDefinitions; + foreach (SpanDefinition bt in spanDefinitions) + { + bt.childSpanDefinitions.Insert(0, Target.mainSpanDefinition); + } + } + + public void MergeByChildBlocks(SyntaxDefinition Target) + { + SpanDefinition[] spanDefinitions = SpanDefinitions; + foreach (SpanDefinition bt in spanDefinitions) + { + for (int i = Target.mainSpanDefinition.childSpanDefinitions.Count - 1; i >= 0; i--) + { + SpanDefinition child = Target.mainSpanDefinition.childSpanDefinitions[i]; + bt.childSpanDefinitions.Insert(0, child); + } + } + } + + + private void FillBlocks(SpanDefinition bt) + { + if (bt == null) + return; + + if (spanDefinitionLookup.ContainsKey(bt)) + return; + + spanDefinitionLookup.Add(bt, bt); + + foreach (SpanDefinition btc in bt.childSpanDefinitions) + { + FillBlocks(btc); + } + foreach (Scope sc in bt.ScopePatterns) + { + FillBlocks(sc.spawnSpanOnEnd); + FillBlocks(sc.spawnSpanOnStart); + } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SyntaxDefinitionList.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SyntaxDefinitionList.cs new file mode 100644 index 0000000..47d7e59 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SyntaxDefinitionList.cs @@ -0,0 +1,69 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Collections.Generic; +using System.IO; + +namespace Alsing.SourceCode +{ + /// + /// SyntaxDefinition list class + /// + public class SyntaxDefinitionList + { + private readonly List languages; + + + /// + /// + /// + public SyntaxDefinitionList() + { + languages = new List(); + + string[] files = Directory.GetFiles(".", "*.syn"); + foreach (string file in files) + { + var loader = new SyntaxDefinitionLoader(); + SyntaxDefinition syntax = loader.Load(file); + languages.Add(syntax); + } + } + + + /// + /// + /// + /// + /// + public SyntaxDefinition GetLanguageFromFile(string path) + { + string extension = Path.GetExtension(path); + foreach (SyntaxDefinition syntax in languages) + { + foreach (FileType ft in syntax.FileTypes) + { + if (extension.ToLowerInvariant() == ft.Extension.ToLowerInvariant()) + return syntax; + } + } + return null; + } + + /// + /// + /// + /// + public List GetSyntaxDefinitions() + { + return languages; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SyntaxDefinitionLoader.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SyntaxDefinitionLoader.cs new file mode 100644 index 0000000..9c732e3 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/SyntaxDefinitionLoader.cs @@ -0,0 +1,614 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Collections; +using System.Drawing; +using System.Xml; + +namespace Alsing.SourceCode +{ + /// + /// + /// + public class SyntaxDefinitionLoader + { + private Hashtable spanDefinitionLookup = new Hashtable(); + private Hashtable styleLookup = new Hashtable(); + private SyntaxDefinition syntaxDefinition = new SyntaxDefinition(); + + + /// + /// Load a specific syntax file + /// + /// File name + /// SyntaxDefinition object + public SyntaxDefinition Load(string File) + { + styleLookup = new Hashtable(); + spanDefinitionLookup = new Hashtable(); + syntaxDefinition = new SyntaxDefinition(); + + var xmlDocument = new XmlDocument(); + xmlDocument.Load(File); + ReadLanguageDefinition(xmlDocument); + + return syntaxDefinition; + } + + /// + /// + /// + /// + /// + /// + public SyntaxDefinition Load(string File, string Separators) + { + styleLookup = new Hashtable(); + spanDefinitionLookup = new Hashtable(); + syntaxDefinition = new SyntaxDefinition {Separators = Separators}; + + var xmlDocument = new XmlDocument(); + xmlDocument.Load(File); + ReadLanguageDefinition(xmlDocument); + + if (syntaxDefinition.mainSpanDefinition == null) + { + throw new Exception("no main block found in syntax"); + } + + return syntaxDefinition; + } + + /// + /// Load a specific syntax from an xml string + /// + /// + /// + public SyntaxDefinition LoadXML(string XML) + { + styleLookup = new Hashtable(); + spanDefinitionLookup = new Hashtable(); + syntaxDefinition = new SyntaxDefinition(); + + var xmlDocument = new XmlDocument(); + xmlDocument.LoadXml(XML); + ReadLanguageDefinition(xmlDocument); + + if (syntaxDefinition.mainSpanDefinition == null) + { + throw new Exception("no main block found in syntax"); + } + + + return syntaxDefinition; + } + + private void ReadLanguageDefinition(XmlNode xml) + { + ParseLanguage(xml["Language"]); + } + + private void ParseLanguage(XmlNode node) + { + //get syntax name and startblock + string Name = ""; + string StartBlock = ""; + + foreach (XmlAttribute att in node.Attributes) + { + if (att.Name.ToLowerInvariant() == "name") + Name = att.Value; + + if (att.Name.ToLowerInvariant() == "startblock") + StartBlock = att.Value; + } + + syntaxDefinition.Name = Name; + syntaxDefinition.mainSpanDefinition = GetBlock(StartBlock); + + foreach (XmlNode n in node.ChildNodes) + { + if (n.NodeType == XmlNodeType.Element) + { + if (n.Name.ToLowerInvariant() == "filetypes") + ParseFileTypes(n); + if (n.Name.ToLowerInvariant() == "block") + ParseBlock(n); + if (n.Name.ToLowerInvariant() == "style") + ParseStyle(n); + } + } + } + + private void ParseFileTypes(XmlNode node) + { + foreach (XmlNode n in node.ChildNodes) + { + if (n.NodeType == XmlNodeType.Element) + { + if (n.Name.ToLowerInvariant() == "filetype") + { + //add filetype + string Extension = ""; + string Name = ""; + foreach (XmlAttribute a in n.Attributes) + { + if (a.Name.ToLowerInvariant() == "name") + Name = a.Value; + if (a.Name.ToLowerInvariant() == "extension") + Extension = a.Value; + } + var ft = new FileType {Extension = Extension, Name = Name}; + syntaxDefinition.FileTypes.Add(ft); + } + } + } + } + + private void ParseBlock(XmlNode node) + { + string Name = "", Style = ""; + bool IsMultiline = false; + bool TerminateChildren = false; + Color BackColor = Color.Transparent; + foreach (XmlAttribute att in node.Attributes) + { + if (att.Name.ToLowerInvariant() == "name") + Name = att.Value; + if (att.Name.ToLowerInvariant() == "style") + Style = att.Value; + if (att.Name.ToLowerInvariant() == "ismultiline") + IsMultiline = bool.Parse(att.Value); + if (att.Name.ToLowerInvariant() == "terminatechildren") + TerminateChildren = bool.Parse(att.Value); + if (att.Name.ToLowerInvariant() == "backcolor") + { + BackColor = Color.FromName(att.Value); + //Transparent =false; + } + } + + //create block object here + SpanDefinition bl = GetBlock(Name); + bl.BackColor = BackColor; + bl.Name = Name; + bl.MultiLine = IsMultiline; + bl.Style = GetStyle(Style); + bl.TerminateChildren = TerminateChildren; + + + foreach (XmlNode n in node.ChildNodes) + { + if (n.NodeType == XmlNodeType.Element) + { + if (n.Name.ToLowerInvariant() == "scope") + { + //bool IsComplex=false; + //bool IsSeparator=false; + string Start = ""; + string End = ""; + string style = ""; + string text = ""; + string EndIsSeparator = ""; + string StartIsComplex = "false"; + string EndIsComplex = "false"; + string StartIsKeyword = "false"; + string EndIsKeyword = "false"; + string spawnStart = ""; + string spawnEnd = ""; + string EscapeChar = ""; + string CauseIndent = "false"; + + bool expanded = true; + + foreach (XmlAttribute att in n.Attributes) + { + switch (att.Name.ToLowerInvariant()) + { + case "start": + Start = att.Value; + break; + case "escapechar": + EscapeChar = att.Value; + break; + case "end": + End = att.Value; + break; + case "style": + style = att.Value; + break; + case "text": + text = att.Value; + break; + case "defaultexpanded": + expanded = bool.Parse(att.Value); + break; + case "endisseparator": + EndIsSeparator = att.Value; + break; + case "startiskeyword": + StartIsKeyword = att.Value; + break; + case "startiscomplex": + StartIsComplex = att.Value; + break; + case "endiscomplex": + EndIsComplex = att.Value; + break; + case "endiskeyword": + EndIsKeyword = att.Value; + break; + case "spawnblockonstart": + spawnStart = att.Value; + break; + case "spawnblockonend": + spawnEnd = att.Value; + break; + case "causeindent": + CauseIndent = att.Value; + break; + } + } + if (Start != "") + { + //bl.StartPattern =new Pattern (Pattern,IsComplex,false,IsSeparator); + //bl.StartPatterns.Add (new Pattern (Pattern,IsComplex,IsSeparator,true)); + bool blnStartIsComplex = bool.Parse(StartIsComplex); + bool blnEndIsComplex = bool.Parse(EndIsComplex); + bool blnCauseIndent = bool.Parse(CauseIndent); + + var scope = new Scope + { + Style = GetStyle(style), + ExpansionText = text, + DefaultExpanded = expanded, + CauseIndent = blnCauseIndent + }; + + var StartP = new Pattern(Start, blnStartIsComplex, false, bool.Parse(StartIsKeyword)); + Pattern endPattern = EscapeChar != "" + ? new Pattern(End, false, bool.Parse(EndIsKeyword), EscapeChar) + : new Pattern(End, blnEndIsComplex, false, bool.Parse(EndIsKeyword)); + + if (EndIsSeparator != "") + endPattern.IsSeparator = bool.Parse(EndIsSeparator); + + scope.Start = StartP; + scope.EndPatterns.Add(endPattern); + bl.ScopePatterns.Add(scope); + if (spawnStart != "") + { + scope.spawnSpanOnStart = GetBlock(spawnStart); + } + if (spawnEnd != "") + { + scope.spawnSpanOnEnd = GetBlock(spawnEnd); + } + } + } + if (n.Name.ToLowerInvariant() == "bracket") + { + //bool IsComplex=false; + //bool IsSeparator=false; + string Start = ""; + string End = ""; + string style = ""; + + string StartIsComplex = "false"; + string EndIsComplex = "false"; + + string StartIsKeyword = "false"; + string EndIsKeyword = "false"; + string IsMultiLineB = "true"; + + foreach (XmlAttribute att in n.Attributes) + { + switch (att.Name.ToLowerInvariant()) + { + case "start": + Start = att.Value; + break; + case "end": + End = att.Value; + break; + case "style": + style = att.Value; + break; + case "endisseparator": + if (att.Name.ToLowerInvariant() == "startisseparator") + if (att.Name.ToLowerInvariant() == "startiskeyword") + StartIsKeyword = att.Value; + break; + case "startiscomplex": + StartIsComplex = att.Value; + break; + case "endiscomplex": + EndIsComplex = att.Value; + break; + case "endiskeyword": + EndIsKeyword = att.Value; + break; + case "ismultiline": + IsMultiLineB = att.Value; + break; + } + } + if (Start != "") + { + var pl = new PatternList {Style = GetStyle(style)}; + + bool blnStartIsComplex = bool.Parse(StartIsComplex); + bool blnEndIsComplex = bool.Parse(EndIsComplex); + bool blnIsMultiLineB = bool.Parse(IsMultiLineB); + + var StartP = new Pattern(Start, blnStartIsComplex, false, bool.Parse(StartIsKeyword)); + var EndP = new Pattern(End, blnEndIsComplex, false, bool.Parse(EndIsKeyword)); + + StartP.MatchingBracket = EndP; + EndP.MatchingBracket = StartP; + StartP.BracketType = BracketType.StartBracket; + EndP.BracketType = BracketType.EndBracket; + StartP.IsMultiLineBracket = EndP.IsMultiLineBracket = blnIsMultiLineB; + + pl.Add(StartP); + pl.Add(EndP); + bl.OperatorsList.Add(pl); + } + } + } + + if (n.Name.ToLowerInvariant() == "keywords") + foreach (XmlNode cn in n.ChildNodes) + { + if (cn.Name.ToLowerInvariant() == "patterngroup") + { + var pl = new PatternList(); + bl.KeywordsList.Add(pl); + foreach (XmlAttribute att in cn.Attributes) + { + switch (att.Name.ToLowerInvariant()) + { + case "style": + pl.Style = GetStyle(att.Value); + break; + case "name": + pl.Name = att.Value; + break; + case "normalizecase": + pl.NormalizeCase = bool.Parse(att.Value); + break; + case "casesensitive": + pl.CaseSensitive = bool.Parse(att.Value); + break; + } + } + foreach (XmlNode pt in cn.ChildNodes) + { + if (pt.Name.ToLowerInvariant() == "pattern") + { + bool IsComplex = false; + bool IsSeparator = false; + string Category = null; + string Pattern = ""; + if (pt.Attributes != null) + { + foreach (XmlAttribute att in pt.Attributes) + { + switch (att.Name.ToLowerInvariant()) + { + case "text": + Pattern = att.Value; + break; + case "iscomplex": + IsComplex = bool.Parse(att.Value); + break; + case "isseparator": + IsSeparator = bool.Parse(att.Value); + break; + case "category": + Category = (att.Value); + break; + } + } + } + if (Pattern != "") + { + var pat = new Pattern(Pattern, IsComplex, IsSeparator, true) + {Category = Category}; + pl.Add(pat); + } + } + else if (pt.Name.ToLowerInvariant() == "patterns") + { + string Patterns = pt.ChildNodes[0].Value; + Patterns = Patterns.Replace("\t", " "); + while (Patterns.IndexOf(" ") >= 0) + Patterns = Patterns.Replace(" ", " "); + + + foreach (string Pattern in Patterns.Split()) + { + if (Pattern != "") + pl.Add(new Pattern(Pattern, false, false, true)); + } + } + } + } + } + //if (n.Name == "Operators") + // ParseStyle(n); + if (n.Name.ToLowerInvariant() == "operators") + foreach (XmlNode cn in n.ChildNodes) + { + if (cn.Name.ToLowerInvariant() == "patterngroup") + { + var pl = new PatternList(); + bl.OperatorsList.Add(pl); + foreach (XmlAttribute att in cn.Attributes) + { + switch (att.Name.ToLowerInvariant()) + { + case "style": + pl.Style = GetStyle(att.Value); + break; + case "name": + pl.Name = att.Value; + break; + case "normalizecase": + pl.NormalizeCase = bool.Parse(att.Value); + break; + case "casesensitive": + pl.CaseSensitive = bool.Parse(att.Value); + break; + } + } + + foreach (XmlNode pt in cn.ChildNodes) + { + if (pt.Name.ToLowerInvariant() == "pattern") + { + bool IsComplex = false; + bool IsSeparator = false; + string Pattern = ""; + string Category = null; + if (pt.Attributes != null) + { + foreach (XmlAttribute att in pt.Attributes) + { + switch (att.Name.ToLowerInvariant()) + { + case "text": + Pattern = att.Value; + break; + case "iscomplex": + IsComplex = bool.Parse(att.Value); + break; + case "isseparator": + IsSeparator = bool.Parse(att.Value); + break; + case "category": + Category = (att.Value); + break; + } + } + } + if (Pattern != "") + { + var pat = new Pattern(Pattern, IsComplex, IsSeparator, false) + {Category = Category}; + pl.Add(pat); + } + } + else if (pt.Name.ToLowerInvariant() == "patterns") + { + string Patterns = pt.ChildNodes[0].Value; + Patterns = Patterns.Replace("\t", " "); + while (Patterns.IndexOf(" ") >= 0) + Patterns = Patterns.Replace(" ", " "); + + foreach (string Pattern in Patterns.Split()) + { + if (Pattern != "") + pl.Add(new Pattern(Pattern, false, false, false)); + } + } + } + } + } + + if (n.Name.ToLowerInvariant() == "childblocks") + { + foreach (XmlNode cn in n.ChildNodes) + { + if (cn.Name.ToLowerInvariant() == "child") + { + foreach (XmlAttribute att in cn.Attributes) + if (att.Name.ToLowerInvariant() == "name") + bl.childSpanDefinitions.Add(GetBlock(att.Value)); + } + } + } + } + } + + + //done + private TextStyle GetStyle(string Name) + { + if (styleLookup[Name] == null) + { + var s = new TextStyle(); + styleLookup.Add(Name, s); + } + + return (TextStyle) styleLookup[Name]; + } + + //done + private SpanDefinition GetBlock(string Name) + { + if (spanDefinitionLookup[Name] == null) + { + var b = new SpanDefinition(syntaxDefinition); + spanDefinitionLookup.Add(Name, b); + } + + return (SpanDefinition) spanDefinitionLookup[Name]; + } + + //done + private void ParseStyle(XmlNode node) + { + string Name = ""; + string ForeColor = "", BackColor = ""; + bool Bold = false, Italic = false, Underline = false; + + + foreach (XmlAttribute att in node.Attributes) + { + switch (att.Name.ToLowerInvariant()) + { + case "name": + Name = att.Value; + break; + case "forecolor": + ForeColor = att.Value; + break; + case "backcolor": + BackColor = att.Value; + break; + case "bold": + Bold = bool.Parse(att.Value); + break; + case "italic": + Italic = bool.Parse(att.Value); + break; + case "underline": + Underline = bool.Parse(att.Value); + break; + } + } + + TextStyle st = GetStyle(Name); + + if (BackColor != "") + { + st.BackColor = Color.FromName(BackColor); + } + + st.ForeColor = Color.FromName(ForeColor); + st.Bold = Bold; + st.Italic = Italic; + st.Underline = Underline; + st.Name = Name; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyle.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyle.cs new file mode 100644 index 0000000..aef3015 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyle.cs @@ -0,0 +1,187 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Design; + +namespace Alsing.SourceCode +{ + /// + /// TextStyles are used to describe the apperance of text. + /// + [Editor(typeof (TextStyleUIEditor), typeof (UITypeEditor))] + public class TextStyle : ICloneable + { + /// + /// Name of the style + /// + public string Name; + + #region PUBLIC PROPERTY BOLD + + private bool _Bold; + + [Category("Font")] + [Description("Gets or Sets if the style uses a BOLD font")] + public bool Bold + { + get { return _Bold; } + set + { + _Bold = value; + OnChange(); + } + } + + #endregion + + #region PUBLIC PROPERTY ITALIC + + private bool _Italic; + + [Category("Font")] + [Description("Gets or Sets if the style uses an ITALIC font")] + public bool Italic + { + get { return _Italic; } + set + { + _Italic = value; + OnChange(); + } + } + + #endregion + + #region PUBLIC PROPERTY UNDERLINE + + private bool _Underline; + + [Category("Font")] + [Description("Gets or Sets if the style uses an UNDERLINED font")] + public bool Underline + { + get { return _Underline; } + set + { + _Underline = value; + OnChange(); + } + } + + #endregion + + #region PUBLIC PROPERTY FORECOLOR + + private Color _ForeColor = Color.Black; + + [Category("Color")] + [Description("Gets or Sets the fore color of the style")] + public Color ForeColor + { + get { return _ForeColor; } + set + { + _ForeColor = value; + OnChange(); + } + } + + #endregion + + #region PUBLIC PROPERTY BACKCOLOR + + private Color _BackColor = Color.Transparent; + + [Category("Color")] + [Description("Gets or Sets the background color of the style")] + public Color BackColor + { + get { return _BackColor; } + set + { + _BackColor = value; + OnChange(); + } + } + + #endregion + + /// + /// Gets or Sets if the style uses a Bold font + /// + /// + /// Gets or Sets if the style uses an Italic font + /// + /// + /// Gets or Sets if the style uses an Underlined font + /// + /// + /// Gets or Sets the ForeColor of the style + /// + /// + /// Gets or Sets the BackColor of the style + /// + /// + /// Default constructor + /// + public TextStyle() + { + ForeColor = Color.Black; + BackColor = Color.Transparent; + } + + /// + /// Returns true if no color have been assigned to the backcolor + /// + [Browsable(false)] + public bool Transparent + { + get { return (BackColor.A == 0); } + } + + public event EventHandler Change = null; + + protected virtual void OnChange() + { + if (Change != null) + Change(this, EventArgs.Empty); + } + + public override string ToString() + { + if (Name == null) + return "TextStyle"; + + return Name; + } + + #region Implementation of ICloneable + + public object Clone() + { + var ts = new TextStyle + { +//TODO: verify if this actually works + BackColor = BackColor, + Bold = Bold, + ForeColor = ForeColor, + Italic = Italic, + Underline = Underline, + Name = Name + }; + return ts; + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyleDesignerDialog.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyleDesignerDialog.cs new file mode 100644 index 0000000..38ba174 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyleDesignerDialog.cs @@ -0,0 +1,261 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace Alsing.SourceCode +{ + /// + /// Summary description for TextStyleDesignerDialog. + /// + public class TextStyleDesignerDialog : Form + { + private readonly TextStyle _Style; + private readonly TextStyle _TmpStyle; + private Button btnCancel; + private Button btnOK; + + /// + /// Required designer variable. + /// + private Container components; + + private Label lblCaption; + private Label lblPreview; + private Panel panel1; + private Panel panel2; + private Panel panel3; + private PropertyGrid pgStyles; + + public TextStyleDesignerDialog(TextStyle Style) + { + _Style = Style; + _TmpStyle = (TextStyle) Style.Clone(); + + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + pgStyles.SelectedObject = _TmpStyle; + lblCaption.Text = _Style.ToString(); + PreviewStyle(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + } + + public static event EventHandler Change; + + protected static void OnChange() + { + if (Change != null) + Change(null, EventArgs.Empty); + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + private void pgStyles_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) + { + PreviewStyle(); + } + + private void PreviewStyle() + { + TextStyle s = _TmpStyle; + + lblPreview.ForeColor = s.ForeColor; + if (s.BackColor != Color.Transparent) + lblPreview.BackColor = s.BackColor; + else + lblPreview.BackColor = Color.White; + + + FontStyle fs = FontStyle.Regular; + if (s.Bold) + fs |= FontStyle.Bold; + if (s.Italic) + fs |= FontStyle.Italic; + if (s.Underline) + fs |= FontStyle.Underline; + + lblPreview.Font = new Font("Courier New", 11f, fs); + } + + private void btnOK_Click(object sender, EventArgs e) + { + _Style.BackColor = _TmpStyle.BackColor; + _Style.ForeColor = _TmpStyle.ForeColor; + _Style.Bold = _TmpStyle.Bold; + _Style.Italic = _TmpStyle.Italic; + _Style.Underline = _TmpStyle.Underline; + OnChange(); + DialogResult = DialogResult.OK; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void TextStyleDesignerDialog_Load(object sender, EventArgs e) {} + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel2 = new System.Windows.Forms.Panel(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnOK = new System.Windows.Forms.Button(); + this.pgStyles = new System.Windows.Forms.PropertyGrid(); + this.panel1 = new System.Windows.Forms.Panel(); + this.panel3 = new System.Windows.Forms.Panel(); + this.lblCaption = new System.Windows.Forms.Label(); + this.lblPreview = new System.Windows.Forms.Label(); + this.panel2.SuspendLayout(); + this.panel3.SuspendLayout(); + this.SuspendLayout(); + // + // panel2 + // + this.panel2.Controls.AddRange(new System.Windows.Forms.Control[] + {this.lblPreview, this.btnCancel, this.btnOK}); + this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel2.Location = new System.Drawing.Point(4, 255); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(354, 80); + this.panel2.TabIndex = 8; + // + // btnCancel + // + this.btnCancel.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(279, 48); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.TabIndex = 4; + this.btnCancel.Text = "Cancel"; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnOK + // + this.btnOK.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); + this.btnOK.Location = new System.Drawing.Point(200, 48); + this.btnOK.Name = "btnOK"; + this.btnOK.TabIndex = 3; + this.btnOK.Text = "OK"; + this.btnOK.Click += new System.EventHandler(this.btnOK_Click); + // + // pgStyles + // + this.pgStyles.CommandsVisibleIfAvailable = true; + this.pgStyles.Dock = System.Windows.Forms.DockStyle.Fill; + this.pgStyles.LargeButtons = false; + this.pgStyles.LineColor = System.Drawing.SystemColors.ScrollBar; + this.pgStyles.Location = new System.Drawing.Point(4, 26); + this.pgStyles.Name = "pgStyles"; + this.pgStyles.Size = new System.Drawing.Size(354, 221); + this.pgStyles.TabIndex = 6; + this.pgStyles.Text = "propertyGrid1"; + this.pgStyles.ToolbarVisible = false; + this.pgStyles.ViewBackColor = System.Drawing.SystemColors.Window; + this.pgStyles.ViewForeColor = System.Drawing.SystemColors.WindowText; + this.pgStyles.PropertyValueChanged += + new System.Windows.Forms.PropertyValueChangedEventHandler(this.pgStyles_PropertyValueChanged); + // + // panel1 + // + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(4, 247); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(354, 8); + this.panel1.TabIndex = 9; + // + // panel3 + // + this.panel3.BackColor = System.Drawing.SystemColors.ControlDark; + this.panel3.Controls.AddRange(new System.Windows.Forms.Control[] {this.lblCaption}); + this.panel3.Dock = System.Windows.Forms.DockStyle.Top; + this.panel3.Location = new System.Drawing.Point(4, 2); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(354, 24); + this.panel3.TabIndex = 10; + // + // lblCaption + // + this.lblCaption.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblCaption.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, + System.Drawing.GraphicsUnit.Point, ((System.Byte) (0))); + this.lblCaption.ForeColor = System.Drawing.SystemColors.Window; + this.lblCaption.Name = "lblCaption"; + this.lblCaption.Size = new System.Drawing.Size(354, 24); + this.lblCaption.TabIndex = 0; + this.lblCaption.Text = "-"; + this.lblCaption.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lblPreview + // + this.lblPreview.BackColor = System.Drawing.SystemColors.Window; + this.lblPreview.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.lblPreview.Dock = System.Windows.Forms.DockStyle.Top; + this.lblPreview.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, + System.Drawing.GraphicsUnit.Point, ((System.Byte) (0))); + this.lblPreview.Name = "lblPreview"; + this.lblPreview.Size = new System.Drawing.Size(354, 40); + this.lblPreview.TabIndex = 8; + this.lblPreview.Text = "The quick brown fox jumped over the lazy dog. "; + this.lblPreview.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // TextStyleDesignerDialog + // + this.AcceptButton = this.btnOK; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(362, 335); + this.ControlBox = false; + this.Controls.AddRange(new System.Windows.Forms.Control[] + {this.pgStyles, this.panel3, this.panel1, this.panel2}); + this.DockPadding.Left = 4; + this.DockPadding.Right = 4; + this.DockPadding.Top = 2; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "TextStyleDesignerDialog"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Style Designer"; + this.Load += new System.EventHandler(this.TextStyleDesignerDialog_Load); + this.panel2.ResumeLayout(false); + this.panel3.ResumeLayout(false); + this.ResumeLayout(false); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyleDesignerDialog.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyleDesignerDialog.resx new file mode 100644 index 0000000..10cc786 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyleDesignerDialog.resx @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + TextStyleDesignerDialog + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyleUIEditor.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyleUIEditor.cs new file mode 100644 index 0000000..1d59ac9 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDefinition/TextStyle/TextStyleUIEditor.cs @@ -0,0 +1,94 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Design; +using System.Windows.Forms; +using System.Windows.Forms.Design; + +namespace Alsing.SourceCode +{ + public class TextStyleUIEditor : UITypeEditor + { + private IWindowsFormsEditorService edSvc; + + public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + { + if (context != null && context.Instance != null && provider != null) + { + edSvc = (IWindowsFormsEditorService) provider.GetService(typeof (IWindowsFormsEditorService)); + + + if (edSvc != null) + { + var style = (TextStyle) value; + using (var tsd = new TextStyleDesignerDialog(style)) + { + context.OnComponentChanging(); + if (edSvc.ShowDialog(tsd) == DialogResult.OK) + { + ValueChanged(this, EventArgs.Empty); + context.OnComponentChanged(); + return style; + } + } + } + } + + return value; + } + + + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) + { + return UITypeEditorEditStyle.Modal; + } + + + private void ValueChanged(object sender, EventArgs e) + { + if (edSvc != null) {} + } + + public override void PaintValue(PaintValueEventArgs e) + { + var ts = (TextStyle) e.Value; + using (var b = new SolidBrush(ts.BackColor)) + { + e.Graphics.FillRectangle(b, e.Bounds); + } + + FontStyle fs = FontStyle.Regular; + if (ts.Bold) + fs |= FontStyle.Bold; + if (ts.Italic) + fs |= FontStyle.Italic; + if (ts.Underline) + fs |= FontStyle.Underline; + + var f = new Font("arial", 8f, fs); + + + using (var b = new SolidBrush(ts.ForeColor)) + { + e.Graphics.DrawString("abc", f, b, e.Bounds); + } + + f.Dispose(); + } + + public override bool GetPaintValueSupported(ITypeDescriptorContext context) + { + return true; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDocument.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDocument.cs new file mode 100644 index 0000000..3569e78 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDocument.cs @@ -0,0 +1,1745 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Collections; +using System.ComponentModel; +using System.IO; +using System.Reflection; +using System.Text; +using Alsing.SourceCode.SyntaxDocumentParsers; + +namespace Alsing.SourceCode +{ + /// + /// The SyntaxDocument is a component that is responsible for Parsing , Folding , Undo / Redo actions and various text actions. + /// + public class SyntaxDocument : Component, IEnumerable + { + #region General declarations + + private readonly RowList rows = new RowList(); + + /// + /// Buffer containing undo actions + /// + public readonly UndoBuffer UndoBuffer = new UndoBuffer(); + + private UndoBlockCollection captureBlock; + private bool captureMode; + private bool folding = true; + + /// + /// For public use only + /// + private bool isParsed = true; + + /// + /// + /// + public RowList KeywordQueue = new RowList(); + + private bool modified; + + private string mSyntaxFile = ""; + + + /// + /// Gets or Sets if folding needs to be recalculated + /// + public bool NeedResetRows; + + /// + /// List of rows that should be parsed + /// + public RowList ParseQueue = new RowList(); + + + /// + /// The active parser of the document + /// + public IParser Parser = new DefaultParser(); + + /// + /// Tag property , lets the user store custom data in the row. + /// + public object Tag; + + /// + /// List of rows that is not hidden by folding + /// + public RowList VisibleRows = new RowList(); + + #region PUBLIC PROPERTY UNDOSTEP + + private int _UndoStep; + + public int UndoStep + { + get + { + if (_UndoStep > UndoBuffer.Count) + _UndoStep = UndoBuffer.Count; + + return _UndoStep; + } + set { _UndoStep = value; } + } + + #endregion + + /// + /// Event that is raised when there is no more rows to parse + /// + public event EventHandler ParsingCompleted; + + public event EventHandler UndoBufferChanged = null; + + /// + /// Raised when the parser is active + /// + public event EventHandler Parsing; + + /// + /// Raised when the document content is changed + /// + public event EventHandler Change; + + public event RowEventHandler BreakPointAdded; + public event RowEventHandler BreakPointRemoved; + + public event RowEventHandler BookmarkAdded; + public event RowEventHandler BookmarkRemoved; + + protected virtual void OnBreakPointAdded(Row r) + { + if (BreakPointAdded != null) + BreakPointAdded(this, new RowEventArgs(r)); + } + + protected virtual void OnBreakPointRemoved(Row r) + { + if (BreakPointRemoved != null) + BreakPointRemoved(this, new RowEventArgs(r)); + } + + protected virtual void OnBookmarkAdded(Row r) + { + if (BookmarkAdded != null) + BookmarkAdded(this, new RowEventArgs(r)); + } + + protected virtual void OnBookmarkRemoved(Row r) + { + if (BookmarkRemoved != null) + BookmarkRemoved(this, new RowEventArgs(r)); + } + + protected virtual void OnUndoBufferChanged() + { + if (UndoBufferChanged != null) + UndoBufferChanged(this, EventArgs.Empty); + } + + + public virtual void InvokeBreakPointAdded(Row r) + { + OnBreakPointAdded(r); + } + + public virtual void InvokeBreakPointRemoved(Row r) + { + OnBreakPointRemoved(r); + } + + public virtual void InvokeBookmarkAdded(Row r) + { + OnBookmarkAdded(r); + } + + public virtual void InvokeBookmarkRemoved(Row r) + { + OnBookmarkRemoved(r); + } + + + //public event System.EventHandler CreateParser; + + /// + /// Raised when the modified flag has changed + /// + public event EventHandler ModifiedChanged; + + //---------------------------------------------- + + /// + /// Raised when a row have been parsed + /// + public event ParserEventHandler RowParsed; + + // public event ParserEventHandler RowAdded; + /// + /// Raised when a row have been deleted + /// + public event ParserEventHandler RowDeleted; + + #endregion + + #region PUBLIC PROPERTY MAXUNDOBUFFERSIZE + + /// + /// Gets or Sets the Maximum number of entries in the undobuffer + /// + public int MaxUndoBufferSize + { + get { return UndoBuffer.MaxSize; } + set { UndoBuffer.MaxSize = value; } + } + + #endregion + + #region PUBLIC PROPERTY VERSION + + private long _Version = long.MinValue; + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public long Version + { + get { return _Version; } + set { _Version = value; } + } + + #endregion + + /// + /// + /// + /// + public SyntaxDocument(IContainer container) : this() + { + container.Add(this); + InitializeComponent(); + } + + /// + /// + /// + public SyntaxDocument() + { + Parser.Document = this; + Text = ""; + ResetVisibleRows(); + Init(); + } + + /// + /// Get or Set the Modified flag + /// + public bool Modified + { + get { return modified; } + set + { + modified = value; + OnModifiedChanged(); + } + } + + /// + /// Get or Set the Name of the Syntaxfile to use + /// + [DefaultValue("")] + public string SyntaxFile + { + get { return mSyntaxFile; } + set + { + mSyntaxFile = value; + // this.Parser=new Parser_Default(); + Parser.Init(value); + Text = Text; + } + } + + /// + /// Gets or Sets if the document should use folding or not + /// + [DefaultValue(true)] + public bool Folding + { + get { return folding; } + set + { + folding = value; + if (!value) + { + foreach (Row r in this) + { + r.Expanded = true; + } + } + ResetVisibleRows(); + + OnChange(); + } + } + + /// + /// Gets if the document is fully parsed + /// + [Browsable(false)] + public bool IsParsed + { + get { return isParsed; } + } + + /// + /// Returns the row at the specified index + /// + public Row this[int index] + { + get + { + if (index < 0 || index >= rows.Count) + { + // System.Diagnostics.Debugger.Break (); + return null; + } + return rows[index]; + } + + set { rows[index] = value; } + } + + /// + /// Gets the row count of the document + /// + [Browsable(false)] + public int Count + { + get { return rows.Count; } + } + + /// + /// Gets or Sets the text of the entire document + /// + [Browsable(false)] + // [RefreshProperties (RefreshProperties.All)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Text + { + get + { + int i = 0; + var sb = new StringBuilder(); + + ParseAll(true); + foreach (Row tr in rows) + { + if (i > 0) + sb.Append(Environment.NewLine); + tr.MatchCase(); + sb.Append(tr.Text); + i++; + } + return sb.ToString(); + } + + set + { + clear(); + Add(""); + InsertText(value, 0, 0); + UndoBuffer.Clear(); + UndoStep = 0; + Modified = false; + isParsed = false; + + foreach (Row r in this) + { + r.RevisionMark = RowRevisionMark.Unchanged; + } + + //OnChange(); + InvokeChange(); + } + } + + /// + /// Gets and string array containing the text of all rows. + /// + public string[] Lines + { + get { return Text.Split("\n".ToCharArray()); } + set + { + string s = ""; + foreach (string sl in value) + s += sl + "\n"; + Text = s.Substring(0, s.Length - 1); + } + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + new System.ComponentModel.Container(); + } + + #endregion + + #region IEnumerable Members + + /// + /// + /// + /// + public IEnumerator GetEnumerator() + { + return rows.GetEnumerator(); + } + + #endregion + + /// + /// For internal use only + /// + public void ChangeVersion() + { + Version ++; + if (Version > long.MaxValue - 10) + Version = long.MinValue; + } + + public void SaveRevisionMark() + { + foreach (Row r in this) + { + if (r.RevisionMark == RowRevisionMark.BeforeSave) + { + r.RevisionMark = RowRevisionMark.AfterSave; + } + } + + Modified = false; + ResetVisibleRows(); + } + + /// + /// Starts an Undo Capture. + /// This method can be called if you with to collect multiple text operations into one undo action + /// + public void StartUndoCapture() + { + captureMode = true; + captureBlock = new UndoBlockCollection(); + } + + /// + /// Ends an Undo capture and pushes the collected actions onto the undostack + /// + /// + /// + public UndoBlockCollection EndUndoCapture() + { + captureMode = false; + AddToUndoList(captureBlock); + return captureBlock; + } + + /// + /// ReParses the document + /// + public void ReParse() + { + Text = Text; + } + + /// + /// Removes all bookmarks in the document + /// + public void ClearBookmarks() + { + foreach (Row r in this) + { + r.Bookmarked = false; + } + InvokeChange(); + } + + /// + /// Removes all breakpoints in the document. + /// + public void ClearBreakpoints() + { + foreach (Row r in this) + { + r.Breakpoint = false; + } + InvokeChange(); + } + + + /// + /// Call this method to ensure that a specific row is fully parsed + /// + /// + public void EnsureParsed(Row Row) + { + ParseAll(); + Parser.ParseRow(Row.Index, true); + } + + private void Init() + { + var l = new SyntaxDefinition(); + l.mainSpanDefinition = new SpanDefinition(l) {MultiLine = true}; + Parser.Init(l); + } + + /// + /// Call this method to make the SyntaxDocument raise the Changed event + /// + public void InvokeChange() + { + OnChange(); + } + + /// + /// Performs a span parse on all rows. No Keyword colorizing + /// + public void ParseAll() + { + while (ParseQueue.Count > 0) + ParseSome(); + + ParseQueue.Clear(); + } + + /// + /// Parses all rows , either a span parse or a full parse with keyword colorizing + /// + public void ParseAll(bool ParseKeywords) + { + ParseAll(); + if (ParseKeywords) + { + for (int i = 0; i < Count; i++) + { + if (this[i].RowState != RowState.AllParsed) + Parser.ParseRow(i, true); + } + ParseQueue.Clear(); + KeywordQueue.Clear(); + } + } + + /// + /// Folds all foldable rows + /// + public void FoldAll() + { + ParseAll(false); + foreach (Row r in this) + { + r.Expanded = false; + } + ResetVisibleRows(); + OnChange(); + } + + /// + /// UnFolds all foldable rows + /// + public void UnFoldAll() + { + ParseAll(false); + foreach (Row r in this) + { + r.Expanded = true; + } + ResetVisibleRows(); + OnChange(); + } + + + /// + /// Parses a chunk of 1000 rows , this is not thread safe + /// + public void ParseSome() + { + ParseSome(1000); + } + + /// + /// Parse a chunk of rows, this is not thread safe + /// + /// The number of rows to parse + public void ParseSome(int RowCount) + { + if (ParseQueue.Count > 0) + { + isParsed = false; + int i = 0; + while (i < RowCount && ParseQueue.Count > 0) + { + Row row = ParseQueue[0]; + i += ParseRows(row); + } + + if (NeedResetRows) + ResetVisibleRows(); + + if (Parsing != null) + Parsing(this, new EventArgs()); + } + else + { + if (!isParsed && !Modified) + { + isParsed = true; + + foreach (Row r in this) + { + if (r.expansion_StartSpan != null && r.Expansion_EndRow != null) + { + if (r.expansion_StartSpan.Scope.DefaultExpanded == false) + r.Expanded = false; + } + } + ResetVisibleRows(); + if (ParsingCompleted != null) + ParsingCompleted(this, new EventArgs()); + } + } + + if (ParseQueue.Count == 0 && KeywordQueue.Count > 0) + { +// Console.WriteLine (this.KeywordQueue.Count.ToString ()); + int i = 0; + while (i < RowCount/20 && KeywordQueue.Count > 0) + { + Row row = KeywordQueue[0]; + i += ParseRows(row, true); + } + } + } + + + /// + /// Add a new row with the specified text to the bottom of the document + /// + /// Text to add + /// The row that was added + public Row Add(string text) + { + return Add(text, true); + } + + /// + /// Add a new row with the specified text to the bottom of the document + /// + /// Text to add + /// true if and undo action should be added to the undo stack + /// The row that was added + public Row Add(string text, bool StoreUndo) + { + var xtl = new Row(); + rows.Add(xtl); + xtl.Document = this; + xtl.Text = text; + return xtl; + } + + /// + /// Insert a text at the specified row index + /// + /// Text to insert + /// Row index where the text should be inserted + /// The row that was inserted + public Row Insert(string text, int index) + { + return Insert(text, index, true); + } + + /// + /// Insert a text at the specified row index + /// + /// Text to insert + /// Row index where the text should be inserted + /// true if and undo action should be added to the undo stack + /// The row that was inserted + public Row Insert(string text, int index, bool storeUndo) + { + var xtl = new Row {Document = this}; + rows.Insert(index, xtl); + xtl.Text = text; + if (storeUndo) + { + var undo = new UndoBlock {Text = text,}; + + undo.Position.Y = IndexOf(xtl); + AddToUndoList(undo); + } + + //this.ResetVisibleRows (); + return xtl; + } + + + /// + /// Remove a row at specified row index + /// + /// index of the row that should be removed + public void Remove(int index) + { + Remove(index, true); + } + + public void Remove(int index, bool StoreUndo) + { + Remove(index, StoreUndo, true); + } + + /// + /// Remove a row at specified row index + /// + /// index of the row that should be removed + /// true if and undo action should be added to the undo stack + /// + public void Remove(int index, bool storeUndo, bool raiseChanged) + { + Row r = this[index]; + + if (storeUndo) + { + var ra = new TextRange(); + + if (index != Count - 1) + { + ra.FirstColumn = 0; + ra.FirstRow = index; + ra.LastRow = index + 1; + ra.LastColumn = 0; + } + else + { + ra.FirstColumn = r.PrevRow.Text.Length; + ra.FirstRow = index - 1; + ra.LastRow = index; + ra.LastColumn = r.Text.Length; + } + PushUndoBlock(UndoAction.DeleteRange, GetRange(ra), ra.FirstColumn, ra.FirstRow, r.RevisionMark); + } + + + rows.RemoveAt(index); + if (r.InKeywordQueue) + KeywordQueue.Remove(r); + + if (r.InQueue) + ParseQueue.Remove(r); + + //this.ResetVisibleRows (); + OnRowDeleted(r); + if (raiseChanged) + OnChange(); + } + + /// + /// Deletes a range of text + /// + /// the range that should be deleted + public void DeleteRange(TextRange Range) + { + DeleteRange(Range, true); + } + + private int ParseRows(Row row) + { + return ParseRows(row, false); + } + + + private int ParseRows(Row row, bool Keywords) + { + if (!Keywords) + { + int index = IndexOf(row); + int count = 0; + try + { + while (row.InQueue && count < 100) + { + if (index >= 0) + { + if (index > 0) + if (this[index - 1].InQueue) + ParseRow(this[index - 1]); + + Parser.ParseRow(index, false); + } + + int i = ParseQueue.IndexOf(row); + if (i >= 0) + ParseQueue.RemoveAt(i); + row.InQueue = false; + index++; + count++; + row = this[index]; + + if (row == null) + break; + } + } + catch + { + } + + return count; + } + else + { + int index = IndexOf(row); + if (index == -1 || row.InKeywordQueue == false) + { + KeywordQueue.Remove(row); + return 0; + } + int count = 0; + try + { + while (row.InKeywordQueue && count < 100) + { + if (index >= 0) + { + if (index > 0) + if (this[index - 1].InQueue) + ParseRow(this[index - 1]); + + Parser.ParseRow(index, true); + } + index++; + count++; + row = this[index]; + + if (row == null) + break; + } + } + catch + { + } + + return count; + } + } + + + /// + /// Forces a row to be parsed + /// + /// Row to parse + /// true if keywords and operators should be parsed + public void ParseRow(Row r, bool ParseKeywords) + { + int index = IndexOf(r); + if (index >= 0) + { + if (index > 0) + if (this[index - 1].InQueue) + ParseRow(this[index - 1]); + + Parser.ParseRow(index, false); + if (ParseKeywords) + Parser.ParseRow(index, true); + } + + int i = ParseQueue.IndexOf(r); + if (i >= 0) + ParseQueue.RemoveAt(i); + + r.InQueue = false; + } + + + /// + /// Forces a row to be parsed + /// + /// Row to parse + public void ParseRow(Row r) + { + ParseRow(r, false); + } + + /// + /// Gets the row index of the next bookmarked row + /// + /// Start index + /// Index of the next bookmarked row + public int GetNextBookmark(int StartIndex) + { + for (int i = StartIndex + 1; i < Count; i++) + { + Row r = this[i]; + if (r.Bookmarked) + return i; + } + + for (int i = 0; i < StartIndex; i++) + { + Row r = this[i]; + if (r.Bookmarked) + return i; + } + + return StartIndex; + } + + /// + /// Gets the row index of the previous bookmarked row + /// + /// Start index + /// Index of the previous bookmarked row + public int GetPreviousBookmark(int StartIndex) + { + for (int i = StartIndex - 1; i >= 0; i--) + { + Row r = this[i]; + if (r.Bookmarked) + return i; + } + + for (int i = Count - 1; i >= StartIndex; i--) + { + Row r = this[i]; + if (r.Bookmarked) + return i; + } + + return StartIndex; + } + + /// + /// Deletes a range of text + /// + /// Range to delete + /// true if the actions should be pushed onto the undo stack + public void DeleteRange(TextRange Range, bool StoreUndo) + { + TextRange r = Range; + Modified = true; + if (StoreUndo) + { + string deltext = GetRange(Range); + Row xtr = this[r.FirstRow]; + PushUndoBlock(UndoAction.DeleteRange, deltext, r.FirstColumn, r.FirstRow, xtr.RevisionMark); + } + + + if (r.FirstRow == r.LastRow) + { + Row xtr = this[r.FirstRow]; + int max = Math.Min(r.FirstColumn, xtr.Text.Length); + string left = xtr.Text.Substring(0, max); + string right = ""; + if (xtr.Text.Length >= r.LastColumn) + right = xtr.Text.Substring(r.LastColumn); + xtr.Text = left + right; + } + else + { + if (r.LastRow > Count - 1) + r.LastRow = Count - 1; + + Row xtr = this[r.FirstRow]; + if (r.FirstColumn > xtr.Text.Length) + { + int diff = r.FirstColumn - xtr.Text.Length; + var ws = new string(' ', diff); + InsertText(ws, xtr.Text.Length, r.FirstRow, true); + //return; + } + + string row1 = xtr.Text.Substring(0, r.FirstColumn); + + Row xtr2 = this[r.LastRow]; + int Max = Math.Min(xtr2.Text.Length, r.LastColumn); + string row2 = xtr2.Text.Substring(Max); + + string tot = row1 + row2; + //bool fold=this[r.LastRow].IsCollapsed | this[r.FirstRow].IsCollapsed ; + + int start = r.FirstRow; + int end = r.LastRow; + + for (int i = end - 1; i >= start; i--) + { + Remove(i, false, false); + } + + //todo: DeleteRange error + //this.Insert ( tot ,r.FirstRow,false); + + + Row row = this[start]; + row.Expanded = true; + row.Text = tot; + row.startSpans.Clear(); + row.endSpans.Clear(); + row.startSpan = null; + row.endSpan = null; + row.Parse(); + } + + ResetVisibleRows(); + OnChange(); + } + + /// + /// Get a range of text + /// + /// The range to get + /// string containing the text inside the given range + public string GetRange(TextRange Range) + { + if (Range.FirstRow >= Count) + Range.FirstRow = Count; + + if (Range.LastRow >= Count) + Range.LastRow = Count; + + if (Range.FirstRow != Range.LastRow) + { + //note:error has been tracked here + Row r1 = this[Range.FirstRow]; + int mx = Math.Min(r1.Text.Length, Range.FirstColumn); + string s1 = r1.Text.Substring(mx) + Environment.NewLine; + + //if (Range.LastRow >= this.Count) + // Range.LastRow=this.Count -1; + + Row r2 = this[Range.LastRow]; + if (r2 == null) + return ""; + + int Max = Math.Min(r2.Text.Length, Range.LastColumn); + string s2 = r2.Text.Substring(0, Max); + + var sb = new StringBuilder(); + for (int i = Range.FirstRow + 1; i <= Range.LastRow - 1; i++) + { + Row r3 = this[i]; + + sb.Append(r3.Text + Environment.NewLine); + } + + string s3 = sb.ToString(); + return s1 + s3 + s2; + } + else + { + Row r = this[Range.FirstRow]; + int Max = Math.Min(r.Text.Length, Range.LastColumn); + int Length = Max - Range.FirstColumn; + if (Length <= 0) + return ""; + string s = r.Text.Substring(Range.FirstColumn, Max - Range.FirstColumn); + return s; + } + } + + + /// + /// Returns the index of a given row + /// + /// row to find + /// Index of the given row + public int IndexOf(Row xtr) + { + return rows.IndexOf(xtr); + } + + /// + /// Clear all content in the document + /// + public void clear() + { + foreach (Row r in rows) + { + OnRowDeleted(r); + } + rows.Clear(); + // this.FormatRanges.Clear (); + ParseQueue.Clear(); + KeywordQueue.Clear(); + UndoBuffer.Clear(); + UndoStep = 0; + // this.Add (""); + // ResetVisibleRows(); + // this.OnChange (); + } + + public void Clear() + { + Text = ""; + } + + /// + /// Inserts a text into the document at a given column,row. + /// + /// Text to insert + /// Column + /// Row index + /// TextPoint containing the end of the inserted text + public TextPoint InsertText(string text, int xPos, int yPos) + { + return InsertText(text, xPos, yPos, true); + } + + /// + /// Inserts a text into the document at a given column,row. + /// + /// Text to insert + /// Column + /// Row index + /// true if this action should be pushed onto the undo stack + /// TextPoint containing the end of the inserted text + public TextPoint InsertText(string text, int xPos, int yPos, bool StoreUndo) + { + Modified = true; + Row xtr = this[yPos]; + + RowRevisionMark mark = xtr.RevisionMark; + + if (xPos > xtr.Text.Length) + { + //virtualwhitespace fix + int Padd = xPos - xtr.Text.Length; + var PaddStr = new string(' ', Padd); + text = PaddStr + text; + xPos -= Padd; + } + string lft = xtr.Text.Substring(0, xPos); + string rgt = xtr.Text.Substring(xPos); + string NewText = lft + text + rgt; + + + string t = NewText.Replace(Environment.NewLine, "\n"); + string[] lines = t.Split('\n'); + xtr.Text = lines[0]; + + Row lastrow = xtr; + + //this.Parser.ParsePreviewLine(xtr); + xtr.Parse(); + if (!xtr.InQueue) + ParseQueue.Add(xtr); + xtr.InQueue = true; + + int i = IndexOf(xtr); + for (int j = 1; j <= lines.GetUpperBound(0); j++) + { + lastrow = Insert(lines[j], j + i, false); + } + + if (StoreUndo) + PushUndoBlock(UndoAction.InsertRange, text, xPos, yPos, mark); + + ResetVisibleRows(); + OnChange(); + + + return new TextPoint(lastrow.Text.Length - rgt.Length, IndexOf(lastrow)); + } + + private void OnModifiedChanged() + { + if (ModifiedChanged != null) + ModifiedChanged(this, new EventArgs()); + } + + private void OnChange() + { + if (Change != null) + Change(this, new EventArgs()); + } + + private void OnRowParsed(Row r) + { + if (RowParsed != null) + RowParsed(this, new RowEventArgs(r)); + + OnApplyFormatRanges(r); + } + + // private void OnRowAdded(Row r) + // { + // if (RowAdded != null) + // RowAdded(this,new RowEventArgs(r)); + // } + private void OnRowDeleted(Row r) + { + if (RowDeleted != null) + RowDeleted(this, new RowEventArgs(r)); + } + + public void PushUndoBlock(UndoAction Action, string Text, int x, int y, RowRevisionMark mark) + { + var undo = new UndoBlock(); + undo.Action = Action; + undo.Text = Text; + undo.Position.Y = y; + undo.Position.X = x; + undo.RowModified = (mark != RowRevisionMark.Unchanged); + //AddToUndoList(undo); + + if (captureMode) + { + captureBlock.Add(undo); + } + else + { + AddToUndoList(undo); + } + } + + /// + /// Gets a Range from a given text + /// + /// + /// + /// + /// + public TextRange GetRangeFromText(string text, int xPos, int yPos) + { + string t = text.Replace(Environment.NewLine, "\n"); + string[] lines = t.Split("\n".ToCharArray()); + var r = new TextRange + { + FirstColumn = xPos, + FirstRow = yPos, + LastRow = (lines.Length - 1 + yPos), + LastColumn = lines[lines.Length - 1].Length + }; + + if (r.FirstRow == r.LastRow) + r.LastColumn += r.FirstColumn; + + return r; + } + + public void AddToUndoList(UndoBlock undo) + { + //store the undo action in a actiongroup + var ActionGroup = new UndoBlockCollection {undo}; + + AddToUndoList(ActionGroup); + } + + /// + /// Add an action to the undo stack + /// + /// action to add + public void AddToUndoList(UndoBlockCollection ActionGroup) + { + UndoBuffer.ClearFrom(UndoStep); + UndoBuffer.Add(ActionGroup); + UndoStep++; + OnUndoBufferChanged(); + } + + /// + /// Perform an undo action + /// + /// The position where the caret should be placed + public TextPoint Undo() + { + if (UndoStep == 0) + return new TextPoint(-1, -1); + + + UndoBlockCollection ActionGroup = UndoBuffer[UndoStep - 1]; + UndoBlock undo = ActionGroup[0]; + + for (int i = ActionGroup.Count - 1; i >= 0; i--) + { + undo = ActionGroup[i]; + //TextPoint tp=new TextPoint (undo.Position.X,undo.Position.Y); + switch (undo.Action) + { + case UndoAction.DeleteRange: + InsertText(undo.Text, undo.Position.X, undo.Position.Y, false); + break; + case UndoAction.InsertRange: + { + TextRange r = GetRangeFromText(undo.Text, undo.Position.X, undo.Position.Y); + DeleteRange(r, false); + } + break; + default: + break; + } + } + + UndoStep--; + ResetVisibleRows(); + + //no undo steps left , the document is not dirty + if (UndoStep == 0) + Modified = false; + + var tp = new TextPoint(undo.Position.X, undo.Position.Y); + OnUndoBufferChanged(); + return tp; + } + + public void AutoIndentSegment(Span span) + { + if (span == null) + span = this[0].startSpan; + + Row start = span.StartRow; + Row end = span.EndRow; + if (start == null) + start = this[0]; + + if (end == null) + end = this[Count - 1]; + + + for (int i = start.Index; i <= end.Index; i++) + { + Row r = this[i]; + int depth = r.Indent; + string text = r.Text.Substring(r.GetLeadingWhitespace().Length); + var indent = new string('\t', depth); + r.Text = indent + text; + } + ResetVisibleRows(); + } + + //Returns the span object at the given position + /// + /// Gets a span object form a given column , Row index + /// (This only applies if the row is fully parsed) + /// + /// Column and Rowindex + /// span object at the given position + public Span GetSegmentFromPos(TextPoint p) + { + Row xtr = this[p.Y]; + int CharNo = 0; + + if (xtr.Count == 0) + return xtr.startSpan; + + Span prev = xtr.startSpan; + foreach (Word w in xtr) + { + if (w.Text.Length + CharNo > p.X) + { + if (CharNo == p.X) + return prev; + return w.Span; + } + CharNo += w.Text.Length; + prev = w.Span; + } + + return xtr.endSpan; + } + + //the specific word that contains the char in point p + /// + /// Gets a Word object form a given column , Row index + /// (this only applies if the row is fully parsed) + /// + /// Column and Rowindex + /// Word object at the given position + public Word GetWordFromPos(TextPoint p) + { + Row xtr = this[p.Y]; + int CharNo = 0; + Word CorrectWord = null; + foreach (Word w in xtr) + { + if (CorrectWord != null) + { + if (w.Text == "") + return w; + return CorrectWord; + } + + if (w.Text.Length + CharNo > p.X || w == xtr[xtr.Count - 1]) + { + //return w; + CorrectWord = w; + } + else + { + CharNo += w.Text.Length; + } + } + return CorrectWord; + } + + //the specific word that contains the char in point p + /// + /// Gets a Word object form a given column , Row index + /// (this only applies if the row is fully parsed) + /// + /// Column and Rowindex + /// Word object at the given position + public Word GetFormatWordFromPos(TextPoint p) + { + Row xtr = this[p.Y]; + int CharNo = 0; + Word CorrectWord = null; + foreach (Word w in xtr.FormattedWords) + { + if (CorrectWord != null) + { + if (w.Text == "") + return w; + return CorrectWord; + } + + if (w.Text.Length + CharNo > p.X || w == xtr[xtr.Count - 1]) + { + //return w; + CorrectWord = w; + } + else + { + CharNo += w.Text.Length; + } + } + return CorrectWord; + } + + /// + /// Call this method to make the document raise the RowParsed event + /// + /// + public void InvokeRowParsed(Row row) + { + OnRowParsed(row); + } + + + /// + /// Call this method to recalculate the visible rows + /// + public void ResetVisibleRows() + { + InternalResetVisibleRows(); + } + + private void InternalResetVisibleRows() + { +// if (System.DateTime.Now > new DateTime (2002,12,31)) +// { +// +// this.rows = new RowList (); +// this.Add ("BETA VERSION EXPIRED"); +// VisibleRows = this.rows; +// return; +// } + + if (!folding) + { + VisibleRows = rows; + NeedResetRows = false; + } + else + { + NeedResetRows = false; + VisibleRows = new RowList(); //.Clear (); + int RealRow = 0; + for (int i = 0; i < Count; i++) + { + Row r = this[RealRow]; + VisibleRows.Add(r); + bool collapsed = false; + if (r.CanFold) + if (r.expansion_StartSpan.Expanded == false) + { + if (r.expansion_StartSpan.EndWord == null) + { + } + else + { + r = r.Expansion_EndRow; // .expansion_StartSpan.EndRow; + collapsed = true; + } + } + + if (!collapsed) + RealRow++; + else + RealRow = IndexOf(r) + 1; + + if (RealRow >= Count) + break; + } + } + } + + /// + /// Converts a Column/Row index position into a char index + /// + /// TextPoint where x is column and y is row index + /// Char index in the document text + public int PointToIntPos(TextPoint pos) + { + int y = 0; + int p = 0; + foreach (Row r in this) + { + if (y == pos.Y) + break; + p += r.Text.Length + Environment.NewLine.Length; + y++; + } + + return p + Math.Min(pos.X, this[pos.Y].Text.Length); + } + + /// + /// Converts a char index into a Column/Row index + /// + /// Char index to convert + /// Point where x is column and y is row index + public TextPoint IntPosToPoint(int pos) + { + int p = 0; + int y = 0; + foreach (Row r in this) + { + p += r.Text.Length + Environment.NewLine.Length; + if (p > pos) + { + p -= r.Text.Length + Environment.NewLine.Length; + int x = pos - p; + return new TextPoint(x, y); + } + y++; + } + return new TextPoint(-1, -1); + } + + /// + /// Toggle expansion of a given row + /// + /// + public void ToggleRow(Row r) + { + if (!folding) + return; + + if (r.Expansion_EndRow == null || r.Expansion_StartRow == null) + return; + + +// if (r.IsCollapsed) +// { +// r.expansion_StartSpan.Expanded = true; +// ExpandRow(r); +// } +// else +// { +// r.expansion_StartSpan.Expanded = false; +// CollapseRow(r); +// } + + if (r.CanFold) + r.Expanded = !r.Expanded; + ResetVisibleRows(); + + OnChange(); + } + + /// + /// Perform an redo action + /// + /// The position where the caret should be placed + public TextPoint Redo() + { + if (UndoStep >= UndoBuffer.Count) + return new TextPoint(-1, -1); + + UndoBlockCollection ActionGroup = UndoBuffer[UndoStep]; + UndoBlock undo = ActionGroup[0]; + for (int i = 0; i < ActionGroup.Count; i++) + { + undo = ActionGroup[i]; + + switch (undo.Action) + { + case UndoAction.InsertRange: + { + InsertText(undo.Text, undo.Position.X, undo.Position.Y, false); + } + break; + case UndoAction.DeleteRange: + { + TextRange r = GetRangeFromText(undo.Text, undo.Position.X, undo.Position.Y); + DeleteRange(r, false); + } + break; + default: + break; + } + } + + TextRange ran = GetRangeFromText(undo.Text, undo.Position.X, undo.Position.Y); + UndoStep++; + ResetVisibleRows(); + OnUndoBufferChanged(); + return new TextPoint(ran.LastColumn, ran.LastRow); + } + + public Word GetStartBracketWord(Word Start, Pattern End, Span FindIn) + { + if (Start == null || Start.Pattern == null || Start.Span == null) + return null; + + int CurrentRow = Start.Row.Index; + int FirstRow = FindIn.StartRow.Index; + int x = Start.Index; + int count = 0; + while (CurrentRow >= FirstRow) + { + for (int i = x; i >= 0; i--) + { + Word w = this[CurrentRow][i]; + if (w.Span == FindIn && w.Type == WordType.Word) + { + if (w.Pattern == Start.Pattern) + count++; + if (w.Pattern == End) + count--; + + if (count == 0) + return w; + } + } + + if (!Start.Pattern.IsMultiLineBracket) + break; + + CurrentRow--; + if (CurrentRow >= 0) + x = this[CurrentRow].Count - 1; + } + return null; + } + + + public Word GetEndBracketWord(Word Start, Pattern End, Span FindIn) + { + if (Start == null || Start.Pattern == null || Start.Span == null) + return null; + + int CurrentRow = Start.Row.Index; + + int LastRow = Count - 1; + if (FindIn.EndRow != null) + LastRow = FindIn.EndRow.Index; + + + int x = Start.Index; + int count = 0; + while (CurrentRow <= LastRow) + { + for (int i = x; i < this[CurrentRow].Count; i++) + { + Word w = this[CurrentRow][i]; + if (w.Span == FindIn && w.Type == WordType.Word) + { + if (w.Pattern == Start.Pattern) + count++; + if (w.Pattern == End) + count--; + + if (count == 0) + return w; + } + } + + if (!Start.Pattern.IsMultiLineBracket) + break; + + CurrentRow++; + x = 0; + } + return null; + } + + + /// + /// Sets a syntax file, from an embedded resource. + /// + /// The assembly which contains the embedded resource. + /// The name of the resource. + public void SetSyntaxFromEmbeddedResource(Assembly assembly, String resourceName) + { + if (assembly == null) + throw new ArgumentNullException("assembly"); + + if (string.IsNullOrEmpty(resourceName)) + throw new ArgumentNullException("resourceName"); + + // + // Get the xml from an embedded resource. Load the stream. + // + + Stream stream = assembly.GetManifestResourceStream(resourceName); + if (stream != null) + { + stream.Seek(0, SeekOrigin.Begin); + + + // + // Read stream. + // + + var reader = new StreamReader(stream); + String xml = reader.ReadToEnd(); + + // + // Clean up stream. + // + + stream.Close(); + + // + // Initialize. + // + + Parser.Init(SyntaxDefinition.FromSyntaxXml(xml)); + Text = Text; + } + } + + + public void OnApplyFormatRanges(Row row) + { + row.FormattedWords = row.words; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDocument.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDocument.resx new file mode 100644 index 0000000..5b6a13f --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Document/SyntaxDocument.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/DesktopGraphics.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/DesktopGraphics.cs new file mode 100644 index 0000000..9d37a32 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/DesktopGraphics.cs @@ -0,0 +1,29 @@ +using System; +using System.Drawing; +using Alsing.Windows; + +namespace Alsing.Drawing +{ + public class DesktopGraphics : IDisposable + { + public readonly Graphics Graphics; + protected IntPtr handle = new IntPtr(0); + protected IntPtr hdc = new IntPtr(0); + + public DesktopGraphics() + { + handle = NativeMethods.GetDesktopWindow(); + hdc = NativeMethods.GetWindowDC(hdc); + Graphics = Graphics.FromHdc(hdc); + } + + #region IDisposable Members + + public void Dispose() + { + NativeMethods.ReleaseDC(handle, hdc); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/DrawingTools.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/DrawingTools.cs new file mode 100644 index 0000000..8b83988 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/DrawingTools.cs @@ -0,0 +1,382 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; +using System.Windows.Forms; +using Alsing.Windows; +using Alsing.Windows.Forms; + +namespace Alsing.Drawing +{ + public static class DrawingTools + { + public static Color MixColors(Color c1, Color c2, double mix) + { + double d = mix; + return Color.FromArgb((int) (c1.R*(1 - d) + c2.R*d), (int) (c1.G*(1 - d) + c2.G*d), + (int) (c1.B*(1 - d) + c2.B*d)); + } + + private static void DrawBorder(Border3DStyle Style, Color BorderColor, Graphics g, Rectangle r) + { + using (SolidBrush normal = GetNormalBrush(BorderColor)) + using (SolidBrush light = GetLightBrush(BorderColor)) + using (SolidBrush dark = GetDarkBrush(BorderColor)) + using (SolidBrush darkdark = GetDarkDarkBrush(BorderColor)) + { + switch (Style) + { + case Border3DStyle.Sunken: + { + DrawSunkenBorder(g, dark, r, darkdark, light, normal); + break; + } + case Border3DStyle.Raised: + { + DrawRaisedBorder(g, dark, r, darkdark, light, normal); + break; + } + case Border3DStyle.RaisedInner: + { + RaisedInnerBorder(g, dark, r, light); + break; + } + case Border3DStyle.SunkenOuter: + { + DrawSunkenOuterBorder(g, dark, r, light); + break; + } + case Border3DStyle.Etched: + { + break; + } + default: + break; + } + } + } + + private static void DrawSunkenOuterBorder(Graphics g, Brush dark, Rectangle r, Brush light) + { + g.FillRectangle(dark, r.Left, r.Top, r.Width, 1); + g.FillRectangle(dark, r.Left, r.Top, 1, r.Height); + + g.FillRectangle(light, r.Right - 1, r.Top + 1, 1, r.Height - 1); + g.FillRectangle(light, r.Left + 1, r.Bottom - 1, r.Width - 1, 1); + } + + private static void RaisedInnerBorder(Graphics g, Brush dark, Rectangle r, Brush light) + { + g.FillRectangle(light, r.Left, r.Top, r.Width - 1, 1); + g.FillRectangle(light, r.Left, r.Top, 1, r.Height - 1); + + g.FillRectangle(dark, r.Right - 1, r.Top, 1, r.Height); + g.FillRectangle(dark, r.Left, r.Bottom - 1, r.Width, 1); + } + + private static void DrawRaisedBorder(Graphics g, Brush dark, Rectangle r, Brush darkdark, Brush light, + Brush normal) + { + g.FillRectangle(normal, r.Left, r.Top, r.Width - 1, 1); + g.FillRectangle(normal, r.Left, r.Top, 1, r.Height - 1); + g.FillRectangle(light, r.Left + 1, r.Top + 1, r.Width - 2, 1); + g.FillRectangle(light, r.Left + 1, r.Top + 1, 1, r.Height - 2); + + g.FillRectangle(darkdark, r.Right - 1, r.Top, 1, r.Height); + g.FillRectangle(darkdark, r.Left, r.Bottom - 1, r.Width, 1); + g.FillRectangle(dark, r.Right - 2, r.Top + 1, 1, r.Height - 2); + g.FillRectangle(dark, r.Left + 1, r.Bottom - 2, r.Width - 2, 1); + } + + private static void DrawSunkenBorder(Graphics g, Brush dark, Rectangle r, Brush darkdark, Brush light, + Brush normal) + { + g.FillRectangle(dark, r.Left, r.Top, r.Width, 1); + g.FillRectangle(dark, r.Left, r.Top, 1, r.Height); + g.FillRectangle(darkdark, r.Left + 1, r.Top + 1, r.Width - 2, 1); + g.FillRectangle(darkdark, r.Left + 1, r.Top + 1, 1, r.Height - 2); + + g.FillRectangle(light, r.Right - 1, r.Top + 1, 1, r.Height - 1); + g.FillRectangle(light, r.Left + 1, r.Bottom - 1, r.Width - 1, 1); + g.FillRectangle(normal, r.Right - 2, r.Top + 2, 1, r.Height - 3); + g.FillRectangle(normal, r.Left + 2, r.Bottom - 2, r.Width - 3, 1); + } + + private static SolidBrush GetNormalBrush(Color BorderColor) + { + return new SolidBrush(BorderColor); + } + + private static SolidBrush GetLightBrush(Color BorderColor) + { + return BorderColor.GetBrightness() > 0.6 + ? new SolidBrush(MixColors(BorderColor, Color.White, 1)) + : new SolidBrush(MixColors(BorderColor, Color.White, 0.5)); + } + + private static SolidBrush GetDarkDarkBrush(Color BorderColor) + { + SolidBrush darkdark = BorderColor.GetBrightness() < 0.5 + ? new SolidBrush(MixColors(BorderColor, Color.Black, 1)) + : new SolidBrush(MixColors(BorderColor, Color.Black, 0.6)); + return darkdark; + } + + private static SolidBrush GetDarkBrush(Color BorderColor) + { + SolidBrush dark = BorderColor.GetBrightness() < 0.5 + ? new SolidBrush(MixColors(BorderColor, Color.Black, 0.7)) + : new SolidBrush(MixColors(BorderColor, Color.Black, 0.4)); + return dark; + } + + + public static void DrawBorder(BorderStyle2 Style, Color BorderColor, Graphics g, Rectangle r) + { + switch (Style) + { + case BorderStyle2.Dotted: + { + r.Width --; + r.Height --; + g.DrawRectangle(new Pen(SystemColors.Control), r); + var p = new Pen(BorderColor) {DashStyle = DashStyle.Dot}; + g.DrawRectangle(p, r); + break; + } + case BorderStyle2.Dashed: + { + r.Width --; + r.Height --; + g.DrawRectangle(new Pen(SystemColors.Control), r); + var p = new Pen(BorderColor) {DashStyle = DashStyle.Dash}; + g.DrawRectangle(p, r); + + break; + } + case BorderStyle2.Sunken: + { + if (BorderColor == Color.Black) + BorderColor = SystemColors.Control; + //System.Windows.Forms.ControlPaint.DrawBorder3D (g,r,Border3DStyle.Sunken); + DrawBorder(Border3DStyle.Sunken, BorderColor, g, r); + break; + } + case BorderStyle2.FixedSingle: + { + r.Width --; + r.Height --; + g.DrawRectangle(new Pen(BorderColor), r); + break; + } + case BorderStyle2.FixedDouble: + { + g.DrawRectangle(new Pen(BorderColor), r.Left, r.Top, r.Width - 1, r.Height - 1); + g.DrawRectangle(new Pen(BorderColor), r.Left + 1, r.Top + 1, r.Width - 3, r.Height - 3); + break; + } + case BorderStyle2.Raised: + { + if (BorderColor == Color.Black) + BorderColor = SystemColors.Control; + + DrawBorder(Border3DStyle.Raised, BorderColor, g, r); + //System.Windows.Forms.ControlPaint.DrawBorder3D (g,r,Border3DStyle.Raised); + break; + } + case BorderStyle2.RaisedThin: + { + if (BorderColor == Color.Black) + BorderColor = Color.FromArgb(SystemColors.Control.R, SystemColors.Control.G, + SystemColors.Control.B); + + DrawBorder(Border3DStyle.RaisedInner, BorderColor, g, r); + //System.Windows.Forms.ControlPaint.DrawBorder3D (g,r,Border3DStyle.Raised); + break; + } + case BorderStyle2.SunkenThin: + { + if (BorderColor == Color.Black) + BorderColor = Color.FromArgb(SystemColors.Control.R, SystemColors.Control.G, + SystemColors.Control.B); + + DrawBorder(Border3DStyle.SunkenOuter, BorderColor, g, r); + //System.Windows.Forms.ControlPaint.DrawBorder3D (g,r,Border3DStyle.Raised); + break; + } + case BorderStyle2.Etched: + { + ControlPaint.DrawBorder3D(g, r, Border3DStyle.Etched); + + break; + } + case BorderStyle2.Bump: + { + if (BorderColor == Color.Black) + BorderColor = SystemColors.Control; + + var b = new SolidBrush(BorderColor); + g.FillRectangle(b, r.Left, r.Top, r.Width, 4); + g.FillRectangle(b, r.Left, r.Bottom - 4, r.Width, 4); + + g.FillRectangle(b, r.Left, r.Top, 4, r.Height); + g.FillRectangle(b, r.Right - 4, r.Top, 4, r.Height); + b.Dispose(); + + DrawBorder(Border3DStyle.Raised, BorderColor, g, r); + DrawBorder(Border3DStyle.Sunken, BorderColor, g, + new Rectangle(r.Left + 4, r.Top + 4, r.Width - 8, r.Height - 8)); + break; + } + case BorderStyle2.Column: + { + var light = new SolidBrush(MixColors(BorderColor, Color.White, 1)); + var dark = new SolidBrush(MixColors(BorderColor, Color.Black, 0.4)); + + g.FillRectangle(light, r.Left, r.Top, r.Width, 1); + g.FillRectangle(light, r.Left, r.Top + 3, 1, r.Height - 1 - 6); + g.FillRectangle(dark, r.Right - 1, r.Top + 3, 1, r.Height - 6); + g.FillRectangle(dark, r.Left, r.Bottom - 1, r.Width, 1); + break; + } + case BorderStyle2.Row: + { + var light = new SolidBrush(MixColors(BorderColor, Color.White, 1)); + var dark = new SolidBrush(MixColors(BorderColor, Color.Black, 0.4)); + + g.FillRectangle(light, r.Left + 3, r.Top, r.Width - 6, 1); + g.FillRectangle(light, r.Left, r.Top, 1, r.Height - 1); + g.FillRectangle(dark, r.Right - 1, r.Top, 1, r.Height); + g.FillRectangle(dark, r.Left + 3, r.Bottom - 1, r.Width - 6, 1); + break; + } + } + } + + public static void DrawDesignTimeLine(Graphics g, int x1, int y1, int x2, int y2) + { + var p = new Pen(SystemColors.ControlDarkDark) {DashOffset = 10, DashStyle = DashStyle.Dash}; + g.DrawLine(p, x1, y1, x2, y2); + p.Dispose(); + } + + public static void DrawGrayImage(Graphics g, Image Image, int X, int Y, float TransparencyFactor) + { + var cm = new ColorMatrix(); + var ia = new ImageAttributes(); + + cm.Matrix33 = TransparencyFactor; + + cm.Matrix00 = 0.33333334F; + cm.Matrix01 = 0.33333334F; + cm.Matrix02 = 0.33333334F; + cm.Matrix10 = 0.33333334F; + cm.Matrix11 = 0.33333334F; + cm.Matrix12 = 0.33333334F; + cm.Matrix20 = 0.33333334F; + cm.Matrix21 = 0.33333334F; + cm.Matrix22 = 0.33333334F; + + ia.SetColorMatrix(cm); + g.DrawImage(Image, new Rectangle(X, Y, Image.Width, Image.Height), 0, 0, Image.Width, Image.Height, + GraphicsUnit.Pixel, ia); + } + + public static void DrawTransparentImage(Graphics g, Image Image, int X, int Y, float TransparencyFactor) + { + var ia = new ImageAttributes(); + var cm = new ColorMatrix {Matrix33 = TransparencyFactor, Matrix00 = 1.0F, Matrix11 = 1.0F, Matrix22 = 1.0F}; + + ia.SetColorMatrix(cm); + g.DrawImage(Image, new Rectangle(X, Y, Image.Width, Image.Height), 0, 0, Image.Width, Image.Height, + GraphicsUnit.Pixel, ia); + } + + public static void DrawDesignTimeBorder(Graphics g, Rectangle rect) + { + rect.Width --; + rect.Height --; + var p = new Pen(SystemColors.ControlDarkDark) {DashStyle = DashStyle.Dash}; + g.DrawRectangle(p, rect); + p.Dispose(); + } + + public static void DrawInsertIndicatorH(int x, int y, int width, Graphics g, Color c) + { + y -= 3; + x -= 2; + + ControlPaint.FillReversibleRectangle(new Rectangle(x, y, 2, 7), c); + ControlPaint.FillReversibleRectangle(new Rectangle(x + 2, y + 1, width, 5), c); + ControlPaint.FillReversibleRectangle(new Rectangle(width + 2 + x, y, 2, 7), c); + } + + public static void DrawInsertIndicatorV(int x, int y, int height, Graphics g, Color c) + { + x -= 3; + y -= 2; + + ControlPaint.FillReversibleRectangle(new Rectangle(x, y, 7, 2), c); + ControlPaint.FillReversibleRectangle(new Rectangle(x + 1, y + 2, 5, height), c); + ControlPaint.FillReversibleRectangle(new Rectangle(x, height + 2 + y, 7, 2), c); + } + + + public static Bitmap DrawControl(Control control) + { + var b = new Bitmap(control.Width, control.Height); + Graphics g = Graphics.FromImage(b); + IntPtr hdc = g.GetHdc(); + NativeMethods.SendMessage(control.Handle, (int) WindowMessage.WM_PRINT, (int) hdc, + (int) (WMPrintFlags.PRF_CLIENT | WMPrintFlags.PRF_ERASEBKGND)); + g.ReleaseHdc(hdc); + g.Dispose(); + + return b; + } + + public static bool DrawControl(Control control, Bitmap b) + { + Graphics g = Graphics.FromImage(b); + IntPtr hdc = g.GetHdc(); + int i = NativeMethods.SendMessage(control.Handle, (int) WindowMessage.WM_PRINT, (int) hdc, + (int) (WMPrintFlags.PRF_CLIENT | WMPrintFlags.PRF_ERASEBKGND)); + g.ReleaseHdc(hdc); + g.Dispose(); + return i != 0; + } + + + public static void DrawSortArrow(int x, int y, Graphics g, bool Ascending) + { + Color c1 = Color.FromArgb(220, 255, 255, 255); + Color c2 = Color.FromArgb(140, 0, 0, 0); + + var p1 = new Pen(c1); + var p2 = new Pen(c2); + + if (Ascending) + { + g.DrawLine(p1, x, y + 6, x + 7, y + 6); + g.DrawLine(p2, x + 3, y, x, y + 6); + g.DrawLine(p1, x + 4, y, x + 7, y + 6); + } + else + { + g.DrawLine(p2, x, y, x + 7, y); + g.DrawLine(p2, x, y, x + 3, y + 6); + g.DrawLine(p1, x + 7, y, x + 4, y + 6); + } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/Enums.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/Enums.cs new file mode 100644 index 0000000..67c1ed2 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/Enums.cs @@ -0,0 +1,45 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.Windows.Forms +{ + public enum BorderStyle + { + None = 0, + Sunken = 1, + SunkenThin = 2, + Raised = 3, + RaisedThin = 4, + Etched = 5, + Bump = 6, + FixedSingle = 7, + FixedDouble = 8, + Dotted = 9, + Dashed = 10, + } + + public enum BorderStyle2 + { + None = 0, + Sunken = 1, + SunkenThin = 2, + Raised = 3, + RaisedThin = 4, + Etched = 5, + Bump = 6, + FixedSingle = 7, + FixedDouble = 8, + Dotted = 9, + Dashed = 10, + Column = 11, + Row = 12, + NoCorners = 13, + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/FontEnum.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/FontEnum.cs new file mode 100644 index 0000000..d52e559 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/FontEnum.cs @@ -0,0 +1,194 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Collections; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Design; +using System.Windows.Forms; +using System.Windows.Forms.Design; +using Alsing.Windows; + +namespace Alsing.Drawing.GDI +{ + public class FontList : UITypeEditor + { + private IWindowsFormsEditorService edSvc; + private ListBox FontListbox; + private bool handleLostfocus; + + private void LB_DrawItem(object sender, DrawItemEventArgs e) + { + bool selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected; + + if (e.Index == -1) + return; + + + object li = FontListbox.Items[e.Index]; + string text = li.ToString(); + + Brush fg = selected ? SystemBrushes.HighlightText : SystemBrushes.WindowText; + + if (selected) + { + const int ofs = 37; + e.Graphics.FillRectangle(SystemBrushes.Window, + new Rectangle(ofs, e.Bounds.Top, e.Bounds.Width - ofs, FontListbox.ItemHeight)); + e.Graphics.FillRectangle(SystemBrushes.Highlight, + new Rectangle(ofs + 1, e.Bounds.Top + 1, e.Bounds.Width - ofs - 2, + FontListbox.ItemHeight - 2)); + ControlPaint.DrawFocusRectangle(e.Graphics, + new Rectangle(ofs, e.Bounds.Top, e.Bounds.Width - ofs, + FontListbox.ItemHeight)); + } + else + { + e.Graphics.FillRectangle(SystemBrushes.Window, 0, e.Bounds.Top, e.Bounds.Width, FontListbox.ItemHeight); + } + + + e.Graphics.DrawString(text, e.Font, fg, 38, e.Bounds.Top + 4); + + e.Graphics.SetClip(new Rectangle(1, e.Bounds.Top + 2, 34, FontListbox.ItemHeight - 4)); + + + e.Graphics.FillRectangle(SystemBrushes.Highlight, + new Rectangle(1, e.Bounds.Top + 2, 34, FontListbox.ItemHeight - 4)); + + IntPtr hdc = e.Graphics.GetHdc(); + var gf = new GDIFont(text, 9); + int a = 0; + IntPtr res = NativeMethods.SelectObject(hdc, gf.hFont); + NativeMethods.SetTextColor(hdc, ColorTranslator.ToWin32(SystemColors.Window)); + NativeMethods.SetBkMode(hdc, 0); + NativeMethods.TabbedTextOut(hdc, 3, e.Bounds.Top + 5, "abc", 3, 0, ref a, 0); + NativeMethods.SelectObject(hdc, res); + gf.Dispose(); + e.Graphics.ReleaseHdc(hdc); + e.Graphics.DrawRectangle(Pens.Black, new Rectangle(1, e.Bounds.Top + 2, 34, FontListbox.ItemHeight - 4)); + e.Graphics.ResetClip(); + } + + public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + { + if (context != null && context.Instance != null && provider != null) + { + edSvc = (IWindowsFormsEditorService) provider.GetService(typeof (IWindowsFormsEditorService)); + + if (edSvc != null) + { + // Create a CheckedListBox and populate it with all the enum values + FontListbox = new ListBox + {DrawMode = DrawMode.OwnerDrawFixed, BorderStyle = BorderStyle.None, Sorted = true}; + FontListbox.MouseDown += OnMouseDown; + FontListbox.DoubleClick += ValueChanged; + FontListbox.DrawItem += LB_DrawItem; + FontListbox.ItemHeight = 20; + FontListbox.Height = 200; + FontListbox.Width = 180; + + ICollection fonts = new FontEnum().EnumFonts(); + foreach (string font in fonts) + { + FontListbox.Items.Add(font); + } + edSvc.DropDownControl(FontListbox); + if (FontListbox.SelectedItem != null) + return FontListbox.SelectedItem.ToString(); + } + } + + return value; + } + + + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) + { + return UITypeEditorEditStyle.DropDown; + } + + private void OnMouseDown(object sender, MouseEventArgs e) + { + if (!handleLostfocus && FontListbox.ClientRectangle.Contains(FontListbox.PointToClient(new Point(e.X, e.Y)))) + { + FontListbox.LostFocus += ValueChanged; + handleLostfocus = true; + } + } + + private void ValueChanged(object sender, EventArgs e) + { + if (edSvc != null) + { + edSvc.CloseDropDown(); + } + } + + public override void PaintValue(PaintValueEventArgs e) + { + string text = e.Value.ToString(); + var bp = new Bitmap(e.Bounds.Width, e.Bounds.Height); + Graphics g = Graphics.FromImage(bp); + + g.FillRectangle(SystemBrushes.Highlight, e.Bounds); + + IntPtr hdc = g.GetHdc(); + var gf = new GDIFont(text, 9); + int a = 0; + IntPtr res = NativeMethods.SelectObject(hdc, gf.hFont); + NativeMethods.SetTextColor(hdc, ColorTranslator.ToWin32(SystemColors.Window)); + NativeMethods.SetBkMode(hdc, 0); + NativeMethods.TabbedTextOut(hdc, 1, 1, "abc", 3, 0, ref a, 0); + NativeMethods.SelectObject(hdc, res); + gf.Dispose(); + g.ReleaseHdc(hdc); + e.Graphics.DrawImage(bp, e.Bounds.Left, e.Bounds.Top); + + // e.Graphics.DrawString ("abc",new Font (text,10f),SystemBrushes.Window,3,0); + } + + public override bool GetPaintValueSupported(ITypeDescriptorContext context) + { + return true; + } + } + + + public class FontEnum + { + private Hashtable Fonts; + + + public ICollection EnumFonts() + { + var bmp = new Bitmap(10, 10); + Graphics g = Graphics.FromImage(bmp); + + IntPtr hDC = g.GetHdc(); + Fonts = new Hashtable(); + var lf = new LogFont {lfCharSet = 1}; + FONTENUMPROC callback = CallbackFunc; + NativeMethods.EnumFontFamiliesEx(hDC, lf, callback, 0, 0); + + g.ReleaseHdc(hDC); + g.Dispose(); + bmp.Dispose(); + return Fonts.Keys; + } + + private int CallbackFunc(ENUMLOGFONTEX f, int a, int b, int LParam) + { + Fonts[f.elfLogFont.lfFaceName] = "abc"; + return 1; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIBrushes.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIBrushes.cs new file mode 100644 index 0000000..e8c2ea0 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIBrushes.cs @@ -0,0 +1,229 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Drawing; +using Alsing.Windows; + +namespace Alsing.Drawing.GDI +{ + //wrapper class for gdi brushes + public class GDIBrush : GDIObject + { + public IntPtr hBrush; + protected bool mSystemBrush; + + public GDIBrush(Color color) + { + hBrush = NativeMethods.CreateSolidBrush(NativeMethods.ColorToInt(color)); + Create(); + } + + + public GDIBrush(Bitmap pattern) + { + hBrush = NativeMethods.CreatePatternBrush(pattern.GetHbitmap()); + Create(); + } + + public GDIBrush(IntPtr hBMP_Pattern) + { + hBrush = NativeMethods.CreatePatternBrush(hBMP_Pattern); + //if (hBrush==(IntPtr)0) + //Alsing.Debug.Debugger.WriteLine ("Failed to create brush with color : {0}",color.ToString()); + + Create(); + } + + public GDIBrush(int Style, Color color) + { + hBrush = NativeMethods.CreateHatchBrush(Style, NativeMethods.ColorToInt(color)); + Create(); + } + + public GDIBrush(int BrushIndex) + { + hBrush = (IntPtr) BrushIndex; + mSystemBrush = true; + Create(); + } + + protected override void Destroy() + { + //only destroy if brush is created by us + if (!mSystemBrush) + { + if (hBrush != (IntPtr) 0) + NativeMethods.DeleteObject(hBrush); + } + + base.Destroy(); + hBrush = (IntPtr) 0; + } + } + + + //needs to be recoded , cant create new instances for the same colors + public class GDIBrushes + { + public static GDIBrush Black + { + get { return new GDIBrush(0); } + } + + public static GDIBrush White + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Red + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Cyan + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Green + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Blue + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Yellow + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Orange + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Purple + { + get { return new GDIBrush(0); } + } + } + + public class GDISystemBrushes + { + public static GDIBrush ActiveBorder + { + get { return new GDIBrush(0); } + } + + public static GDIBrush ActiveCaption + { + get { return new GDIBrush(0); } + } + + public static GDIBrush ActiveCaptionText + { + get { return new GDIBrush(0); } + } + + public static GDIBrush AppWorkspace + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Control + { + get { return new GDIBrush(0); } + } + + public static GDIBrush ControlDark + { + get { return new GDIBrush(0); } + } + + public static GDIBrush ControlDarkDark + { + get { return new GDIBrush(0); } + } + + public static GDIBrush ControlLight + { + get { return new GDIBrush(0); } + } + + public static GDIBrush ControlLightLight + { + get { return new GDIBrush(0); } + } + + public static GDIBrush ControlText + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Desktop + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Highlight + { + get { return new GDIBrush(0); } + } + + public static GDIBrush HighlightText + { + get { return new GDIBrush(0); } + } + + public static GDIBrush HotTrack + { + get { return new GDIBrush(0); } + } + + public static GDIBrush InactiveBorder + { + get { return new GDIBrush(0); } + } + + public static GDIBrush InactiveCaption + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Info + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Menu + { + get { return new GDIBrush(0); } + } + + public static GDIBrush ScrollBar + { + get { return new GDIBrush(0); } + } + + public static GDIBrush Window + { + get { return new GDIBrush(0); } + } + + public static GDIBrush WindowText + { + get { return new GDIBrush(0); } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIFont.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIFont.cs new file mode 100644 index 0000000..7232cef --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIFont.cs @@ -0,0 +1,83 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using Alsing.Windows; + +namespace Alsing.Drawing.GDI +{ + public class GDIFont : GDIObject + { + public bool Bold; + public byte Charset; + public string FontName; + public IntPtr hFont; + public bool Italic; + public float Size; + public bool Strikethrough; + public bool Underline; + + + public GDIFont() + { + Create(); + } + + public GDIFont(string fontname, float size) + { + Init(fontname, size, false, false, false, false); + Create(); + } + + public GDIFont(string fontname, float size, bool bold, bool italic, bool underline, bool strikethrough) + { + Init(fontname, size, bold, italic, underline, strikethrough); + Create(); + } + + protected void Init(string fontname, float size, bool bold, bool italic, bool underline, bool strikethrough) + { + FontName = fontname; + Size = size; + Bold = bold; + Italic = italic; + Underline = underline; + Strikethrough = strikethrough; + + var tFont = new LogFont + { + lfItalic = ((byte) (Italic ? 1 : 0)), + lfStrikeOut = ((byte) (Strikethrough ? 1 : 0)), + lfUnderline = ((byte) (Underline ? 1 : 0)), + lfWeight = (Bold ? 700 : 400), + lfWidth = 0, + lfHeight = ((int) (-Size*1.3333333333333)), + lfCharSet = 1, + lfFaceName = FontName + }; + + + hFont = NativeMethods.CreateFontIndirect(tFont); + } + + ~GDIFont() + { + Destroy(); + } + + protected override void Destroy() + { + if (hFont != (IntPtr) 0) + NativeMethods.DeleteObject(hFont); + base.Destroy(); + hFont = (IntPtr) 0; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIObject.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIObject.cs new file mode 100644 index 0000000..1b2b6d2 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIObject.cs @@ -0,0 +1,41 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; + +namespace Alsing.Drawing.GDI +{ + /// + /// Summary description for GDIObject. + /// + public abstract class GDIObject : IDisposable + { + protected bool IsCreated; + + protected virtual void Destroy() + { + IsCreated = false; + } + + protected void Create() + { + IsCreated = true; + } + + #region Implementation of IDisposable + + public void Dispose() + { + Destroy(); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIPens.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIPens.cs new file mode 100644 index 0000000..9ff53c2 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDIPens.cs @@ -0,0 +1,35 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Drawing; +using Alsing.Windows; + +namespace Alsing.Drawing.GDI +{ + public class GDIPen : GDIObject + { + public IntPtr hPen; + + public GDIPen(Color color, int width) + { + hPen = NativeMethods.CreatePen(0, width, NativeMethods.ColorToInt(color)); + Create(); + } + + protected override void Destroy() + { + if (hPen != (IntPtr) 0) + NativeMethods.DeleteObject(hPen); + base.Destroy(); + hPen = (IntPtr) 0; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDISurface.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDISurface.cs new file mode 100644 index 0000000..944fc60 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Drawing/GDI32/GDISurface.cs @@ -0,0 +1,348 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Drawing; +using System.Windows.Forms; +using Alsing.Windows; + +namespace Alsing.Drawing.GDI +{ + public class GDISurface : GDIObject + { + private WeakReference _Control; + protected IntPtr _OldBmp = IntPtr.Zero; + protected IntPtr _OldBrush = IntPtr.Zero; + protected IntPtr _OldFont = IntPtr.Zero; + protected IntPtr _OldPen = IntPtr.Zero; + protected IntPtr mhBMP; + protected IntPtr mhDC; + protected int mHeight; + protected int mTabSize = 4; + protected int mWidth; + + public GDISurface(IntPtr hDC) + { + mhDC = hDC; + } + + public GDISurface(int width, int height, IntPtr hdc) + { + Init(width, height, hdc); + Create(); + } + + public GDISurface(int width, int height, GDISurface surface) + { + Init(width, height, surface.hDC); + Create(); + } + + + public GDISurface(int width, int height, Control CompatibleControl, bool BindControl) + { + IntPtr hDCControk = NativeMethods.ControlDC(CompatibleControl); + Init(width, height, hDCControk); + NativeMethods.ReleaseDC(CompatibleControl.Handle, hDCControk); + + if (BindControl) + { + Control = CompatibleControl; + } + + Create(); + } + + private Control Control + { + get + { + if (_Control != null) + return (Control) _Control.Target; + return null; + } + set { _Control = new WeakReference(value); } + } + + + public IntPtr hDC + { + get { return mhDC; } + } + + public IntPtr hBMP + { + get { return mhBMP; } + } + + public Color TextForeColor + { + //map get,settextcolor + get { return NativeMethods.IntToColor(NativeMethods.GetTextColor(mhDC)); } + set { NativeMethods.SetTextColor(mhDC, NativeMethods.ColorToInt(value)); } + } + + public Color TextBackColor + { + //map get,setbkcolor + get { return NativeMethods.IntToColor(NativeMethods.GetBkColor(mhDC)); } + set { NativeMethods.SetBkColor(mhDC, NativeMethods.ColorToInt(value)); } + } + + + public bool FontTransparent + { + //map get,setbkmode + //1=transparent , 2=solid + get { return NativeMethods.GetBkMode(mhDC) < 2; } + set { NativeMethods.SetBkMode(mhDC, value ? 1 : 2); } + } + + public GDIFont Font + { + get + { + var tm = new GDITextMetric(); + var fontname = new string(' ', 48); + + NativeMethods.GetTextMetrics(mhDC, ref tm); + NativeMethods.GetTextFace(mhDC, 79, fontname); + + var gf = new GDIFont + { + FontName = fontname, + Bold = (tm.tmWeight > 400), + Italic = (tm.tmItalic != 0), + Underline = (tm.tmUnderlined != 0), + Strikethrough = (tm.tmStruckOut != 0), + Size = ((int) (((tm.tmMemoryHeight)/(double) tm.tmDigitizedAspectY)*72)) + }; + + return gf; + } + set + { + IntPtr res = NativeMethods.SelectObject(mhDC, value.hFont); + if (_OldFont == IntPtr.Zero) + _OldFont = res; + } + } + + protected void Init(int width, int height, IntPtr hdc) + { + mWidth = width; + mHeight = height; + mhDC = NativeMethods.CreateCompatibleDC(hdc); + + mhBMP = NativeMethods.CreateCompatibleBitmap(hdc, width, height); + + IntPtr ret = NativeMethods.SelectObject(mhDC, mhBMP); + _OldBmp = ret; + + if (mhDC == (IntPtr) 0) + throw new OutOfMemoryException("hDC creation FAILED!!"); + + if (mhDC == (IntPtr) 0) + throw new OutOfMemoryException("hBMP creation FAILED!!"); + } + + + public Size MeasureString(string Text) + { + //map GetTabbedTextExtent + //to be implemented + return new Size(0, 0); + } + + public Size MeasureTabbedString(string Text, int tabsize) + { + int ret = NativeMethods.GetTabbedTextExtent(mhDC, Text, Text.Length, 1, ref tabsize); + return new Size(ret & 0xFFFF, (ret >> 16) & 0xFFFF); + } + + public void DrawString(string Text, int x, int y, int width, int height) + { + //to be implemented + //map DrawText + } + + public Size DrawTabbedString(string Text, int x, int y, int taborigin, int tabsize) + { + int ret = NativeMethods.TabbedTextOut(mhDC, x, y, Text, Text.Length, 1, ref tabsize, taborigin); + return new Size(ret & 0xFFFF, (ret >> 16) & 0xFFFF); + } + + + //--------------------------------------- + //render methods , + //render to dc , + //render to control + //render to gdisurface + + public void RenderTo(IntPtr hdc, int x, int y) + { + //map bitblt + NativeMethods.BitBlt(hdc, x, y, mWidth, mHeight, mhDC, 0, 0, (int) GDIRop.SrcCopy); + } + + + public void RenderTo(GDISurface target, int x, int y) + { + RenderTo(target.hDC, x, y); + } + + public void RenderTo(GDISurface target, int SourceX, int SourceY, int Width, int Height, int DestX, int DestY) + { + NativeMethods.BitBlt(target.hDC, DestX, DestY, Width, Height, hDC, SourceX, SourceY, (int) GDIRop.SrcCopy); + } + + public void RenderToControl(int x, int y) + { + IntPtr hdc = NativeMethods.ControlDC(Control); + + RenderTo(hdc, x, y); + NativeMethods.ReleaseDC(Control.Handle, hdc); + } + + //--------------------------------------- + + public Graphics CreateGraphics() + { + return Graphics.FromHdc(mhDC); + } + + //--------------------------------------- + + public void FillRect(GDIBrush brush, int x, int y, int width, int height) + { + APIRect gr; + gr.top = y; + gr.left = x; + gr.right = width + x; + gr.bottom = height + y; + + NativeMethods.FillRect(mhDC, ref gr, brush.hBrush); + } + + public void DrawFocusRect(int x, int y, int width, int height) + { + APIRect gr; + gr.top = y; + gr.left = x; + gr.right = width + x; + gr.bottom = height + y; + + NativeMethods.DrawFocusRect(mhDC, ref gr); + } + + public void FillRect(Color color, int x, int y, int width, int height) + { + var b = new GDIBrush(color); + FillRect(b, x, y, width, height); + b.Dispose(); + } + + public void InvertRect(int x, int y, int width, int height) + { + APIRect gr; + gr.top = y; + gr.left = x; + gr.right = width + x; + gr.bottom = height + y; + + NativeMethods.InvertRect(mhDC, ref gr); + } + + public void DrawLine(GDIPen pen, Point p1, Point p2) + { + IntPtr oldpen = NativeMethods.SelectObject(mhDC, pen.hPen); + APIPoint gp; + gp.x = 0; + gp.y = 0; + NativeMethods.MoveToEx(mhDC, p1.X, p1.Y, ref gp); + NativeMethods.LineTo(mhDC, p2.X, p2.Y); + NativeMethods.SelectObject(mhDC, oldpen); + } + + public void DrawLine(Color color, Point p1, Point p2) + { + var p = new GDIPen(color, 1); + DrawLine(p, p1, p2); + p.Dispose(); + } + + public void DrawRect(Color color, int left, int top, int width, int height) + { + var p = new GDIPen(color, 1); + DrawRect(p, left, top, width, height); + p.Dispose(); + } + + public void DrawRect(GDIPen pen, int left, int top, int width, int height) + { + DrawLine(pen, new Point(left, top), new Point(left + width, top)); + DrawLine(pen, new Point(left, top + height), new Point(left + width, top + height)); + DrawLine(pen, new Point(left, top), new Point(left, top + height)); + DrawLine(pen, new Point(left + width, top), new Point(left + width, top + height + 1)); + } + + public void Clear(Color color) + { + var b = new GDIBrush(color); + Clear(b); + b.Dispose(); + } + + public void Clear(GDIBrush brush) + { + FillRect(brush, 0, 0, mWidth, mHeight); + } + + public void Flush() + { + NativeMethods.GdiFlush(); + } + + protected override void Destroy() + { + if (_OldBmp != IntPtr.Zero) + NativeMethods.SelectObject(hDC, _OldBmp); + + if (_OldFont != IntPtr.Zero) + NativeMethods.SelectObject(hDC, _OldFont); + + if (_OldPen != IntPtr.Zero) + NativeMethods.SelectObject(hDC, _OldPen); + + if (_OldBrush != IntPtr.Zero) + NativeMethods.SelectObject(hDC, _OldBrush); + + if (mhBMP != (IntPtr) 0) + NativeMethods.DeleteObject(mhBMP); + + if (mhDC != (IntPtr) 0) + NativeMethods.DeleteDC(mhDC); + + mhBMP = (IntPtr) 0; + mhDC = (IntPtr) 0; + + + base.Destroy(); + } + + public void SetBrushOrg(int x, int y) + { + APIPoint p; + p.x = 0; + p.y = 0; + NativeMethods.SetBrushOrgEx(mhDC, x, y, ref p); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/FlippedCursor.cur b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/FlippedCursor.cur new file mode 100644 index 0000000000000000000000000000000000000000..b41c9db003485ce7cd28654c4b757652b522d03a GIT binary patch literal 326 zcmb8pu?@m75QX706qN3e5Jg;4dIK{`Ho>A{EHVlsP*OyG{D7%9q&9Vm d+$i3q8^bG>ZndHYxjN<#@`)E#H2BZ{tT#8qdNTk3 literal 0 HcmV?d00001 diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Globalization/IMEWindow.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Globalization/IMEWindow.cs new file mode 100644 index 0000000..8474e5f --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Globalization/IMEWindow.cs @@ -0,0 +1,105 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Drawing; +using Alsing.Windows; + +namespace Alsing.Globalization +{ + public class IMEWindow + { + private const int CFS_POINT = 0x0002; + private const byte FF_MODERN = 48; + private const byte FIXED_PITCH = 1; + private const int IMC_SETCOMPOSITIONFONT = 0x000a; + private const int IMC_SETCOMPOSITIONWINDOW = 0x000c; + private readonly IntPtr hIMEWnd; + + #region ctor + + public IMEWindow(IntPtr hWnd, string fontname, float fontsize) + { + hIMEWnd = NativeMethods.ImmGetDefaultIMEWnd(hWnd); + SetFont(fontname, fontsize); + } + + #endregion + + #region PUBLIC PROPERTY FONT + + private Font _Font; + + public Font Font + { + get { return _Font; } + set + { + if (_Font.Equals(value) == false) + { + SetFont(value); + _Font = value; + } + } + } + + public void SetFont(Font font) + { + var lf = new LogFont(); + font.ToLogFont(lf); + lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN; + + NativeMethods.SendMessage(hIMEWnd, (int) WindowMessage.WM_IME_CONTROL, IMC_SETCOMPOSITIONFONT, lf); + } + + public void SetFont(string fontname, float fontsize) + { + var tFont = new LogFont + { + lfItalic = 0, + lfStrikeOut = 0, + lfUnderline = 0, + lfWeight = 400, + lfWidth = 0, + lfHeight = ((int) (-fontsize*1.3333333333333)), + lfCharSet = 1, + lfPitchAndFamily = (FIXED_PITCH | FF_MODERN), + lfFaceName = fontname + }; + + LogFont lf = tFont; + + NativeMethods.SendMessage(hIMEWnd, (int) WindowMessage.WM_IME_CONTROL, IMC_SETCOMPOSITIONFONT, lf); + } + + #endregion + + #region PUBLIC PROPERTY LOATION + + private Point _Loation; + + public Point Loation + { + get { return _Loation; } + set + { + _Loation = value; + + var p = new APIPoint {x = value.X, y = value.Y}; + + var lParam = new COMPOSITIONFORM {dwStyle = CFS_POINT, ptCurrentPos = p, rcArea = new APIRect()}; + + NativeMethods.SendMessage(hIMEWnd, (int) WindowMessage.WM_IME_CONTROL, IMC_SETCOMPOSITIONWINDOW, lParam); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Interfaces/IPainter.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Interfaces/IPainter.cs new file mode 100644 index 0000000..fa30f2f --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Interfaces/IPainter.cs @@ -0,0 +1,72 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Drawing; +using Alsing.SourceCode; + +namespace Alsing.Windows.Forms.SyntaxBox.Painter +{ + /// + /// + /// + public interface IPainter : IDisposable + { + /// + /// Measures the length of a specific row in pixels + /// + Size MeasureRow(Row xtr, int Count); + + /// + /// Renders the entire screen + /// + void RenderAll(); + + /// + /// Renders the entire screen + /// + /// Target Graphics object + void RenderAll(Graphics g); + + /// + /// Renders the caret only + /// + /// + void RenderCaret(Graphics g); + + /// + /// + /// + /// + void RenderRow(int RowIndex); + + /// + /// Returns a Point (Column,Row in the active document) from the x and y screen pixel positions. + /// + TextPoint CharFromPixel(int X, int Y); + + /// + /// Called by the control to notify the Painter object that the client area has resized. + /// + void Resize(); + + /// + /// Called by the control to notify the Painter object that one or more Appearance properties has changed. + /// + void InitGraphics(); + + /// + /// Measures the length of a string in pixels + /// + Size MeasureString(string str); + + int GetMaxCharWidth(); + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/MoveDown.cur b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/MoveDown.cur new file mode 100644 index 0000000000000000000000000000000000000000..e3c9cb57f6382c38b268e1b7b886952dd9cf920f GIT binary patch literal 766 zcmdT?F%kkH3=HawC04dl`V0M;JdLMVT3%`4xbEie5U$g)aYMo;EP=bhEYMQgnQ&W~ z?KvOmiGHRB+b|Mbn<4eMLzV2qau%c0RAMNlumT?jh|y^(Df|X;==%(@%b9foCau7E zBXIf_OsonfQU&}DM|0$d_hGBr-McLAZ_9qoQU6Wne^=+{1$dl*`vDjtaNPoB4dgIB O89kd;Bc1fBeSsGixtvu1 literal 0 HcmV?d00001 diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/MoveUp.cur b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/MoveUp.cur new file mode 100644 index 0000000000000000000000000000000000000000..135b55423a85f83d037650d887df2d4c8dbb7922 GIT binary patch literal 766 zcmdr~ITFG!5L*K?l%b->d+p55 zj8`HPcOuz=o<^>j)Wa9*6rWa#GJ-=bx>_qc@M(ZDfe$dBV)!6h~qA8Qzu&`>^M2w7sr-j)=|gtVv_g4 z?8@^-8)*+(XD99y=2j7VzM)9S%R&&MQ5E7AV`Kz*86ZTXDx~c{(xMNgKMWEve z89PFT8(~3(uz*6~99i6xJNsd&Qax8``nRfH`(E2m+wWYvw7bmiA0&3^?D#ahtI{OY yX*c;!xXx0}?-TgkfoT9z54_GmJOZJczl^?(=ZGi1V#>+H)g9ecjcM38sO1N#uAxu> literal 0 HcmV?d00001 diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Properties/Resources.Designer.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Properties/Resources.Designer.cs new file mode 100644 index 0000000..7852a39 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Properties/Resources.Designer.cs @@ -0,0 +1,112 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.3031 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + internal static byte[] FlippedCursor { + get { + object obj = ResourceManager.GetObject("FlippedCursor", resourceCulture); + return ((byte[])(obj)); + } + } + + internal static byte[] MoveDown { + get { + object obj = ResourceManager.GetObject("MoveDown", resourceCulture); + return ((byte[])(obj)); + } + } + + internal static byte[] MoveUp { + get { + object obj = ResourceManager.GetObject("MoveUp", resourceCulture); + return ((byte[])(obj)); + } + } + + internal static byte[] MoveUpDown { + get { + object obj = ResourceManager.GetObject("MoveUpDown", resourceCulture); + return ((byte[])(obj)); + } + } + + internal static System.Drawing.Bitmap SourceCodePrintDocument { + get { + object obj = ResourceManager.GetObject("SourceCodePrintDocument", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap SyntaxBoxControl { + get { + object obj = ResourceManager.GetObject("SyntaxBoxControl", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap SyntaxDocument { + get { + object obj = ResourceManager.GetObject("SyntaxDocument", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Properties/Resources.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Properties/Resources.resx new file mode 100644 index 0000000..3e91021 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Properties/Resources.resx @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\flippedcursor.cur;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\movedown.cur;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\moveup.cur;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\moveupdown.cur;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Alsing.sourcecode.sourcecodeprintdocument.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Alsing.windows.forms.syntaxboxcontrol.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Alsing.sourcecode.syntaxdocument.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/SyntaxBox.hst b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/SyntaxBox.hst new file mode 100644 index 0000000..c8cc039 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/SyntaxBox.hst @@ -0,0 +1,27 @@ + + + + Fix: +Selection performance fix. + Fix: +InfoTip display problem in .NET 1.1 fix. + Fix: +AutoList display problem in .NET 1.1 fix. + New Feature: +Extend selection , it is now possible to hold shift and click the text to extend the selection. + New Feature: +drag drop feature , it is now possible to hold shift and copy text while drag dropping. + Fix: +Horizontal scrollbar fix. the horizontal scrollbar maxvalue is now more exact than before. + New Feature: +Disable splitview. it is now possible to remove the splitview. + New Feature: +Scrollbars , it is now possible to show/hide the scrollbars. + New Feature: +BreakPoint events . the SyntaxDocument will now raise BreakPointAdd and BreakPointRemoved when breakpoints are added/removed. + New Feature: +Bookmark events . the SyntaxDocument will now raise BookmarkAdd and BookmarkRemoved when bookmarks are added/removed. + Fix: +Multi Monitor support. infotips and autolistsare now working with multi monitor settings. + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/BinPatternMatcher.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/BinPatternMatcher.cs new file mode 100644 index 0000000..8d607c9 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/BinPatternMatcher.cs @@ -0,0 +1,47 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.Text.PatternMatchers +{ + /// + /// Pattern matcher that matches binary tokens + /// + public class BinPatternMatcher : PatternMatcherBase + { + public static readonly BinPatternMatcher Default = new BinPatternMatcher(); + //perform the match + + //patterns that trigger this matcher + public override string[] DefaultPrefixes + { + get { return new[] {"0", "1"}; } + } + + public override int Match(string textToMatch, int matchAtIndex) + { + int currentIndex = matchAtIndex; + do + { + char currentChar = textToMatch[currentIndex]; + if (currentChar == '0' || currentChar == '1') + { + //current char is hexchar + } + else + { + break; + } + currentIndex++; + } while (currentIndex < textToMatch.Length); + + return currentIndex - matchAtIndex; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/DecPatternMatcher.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/DecPatternMatcher.cs new file mode 100644 index 0000000..2a9ec19 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/DecPatternMatcher.cs @@ -0,0 +1,56 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.Text.PatternMatchers +{ + /// + /// Pattern matcher that matches culture invariant decimal values + /// + public class DecPatternMatcher : PatternMatcherBase + { + public static readonly DecPatternMatcher Default = new DecPatternMatcher(); + + //perform the match + public override int Match(string textToMatch, int matchAtIndex) + { + // matchAtIndex --; + int currentIndex = matchAtIndex; + bool comma = false; + do + { + char currentChar = textToMatch[currentIndex]; + if (currentChar >= '0' && currentChar <= '9') + { + //current char is hexchar + } + else if (currentChar == '.' && comma == false) + { + comma = true; + } + else + { + break; + } + currentIndex++; + } while (currentIndex < textToMatch.Length); + + return currentIndex - matchAtIndex; + } + +// //patterns that trigger this matcher +// public override string[] DefaultPrefixes +// { +// get +// { +// return new string[] {};//"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."}; +// } +// } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/HexPatternMatcher.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/HexPatternMatcher.cs new file mode 100644 index 0000000..827942e --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/HexPatternMatcher.cs @@ -0,0 +1,42 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.Text.PatternMatchers +{ + /// + /// Pattern matcher that matches case insensitive hex values + /// + public class HexPatternMatcher : PatternMatcherBase + { + public static readonly HexPatternMatcher Default = new HexPatternMatcher(); + + //perform the match + public override int Match(string textToMatch, int matchAtIndex) + { + int currentIndex = matchAtIndex; + do + { + char currentChar = textToMatch[currentIndex]; + if ((currentChar >= '0' && currentChar <= '9') || (currentChar >= 'a' && currentChar <= 'f') || + (currentChar >= 'A' && currentChar <= 'F')) + { + //current char is hexchar + } + else + { + break; + } + currentIndex++; + } while (currentIndex < textToMatch.Length); + + return currentIndex - matchAtIndex; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/IPatternMatcher.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/IPatternMatcher.cs new file mode 100644 index 0000000..e55b14e --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/IPatternMatcher.cs @@ -0,0 +1,21 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.Text.PatternMatchers +{ + /// + /// + /// + public interface IPatternMatcher + { + string[] DefaultPrefixes { get; } + int Match(string textToMatch, int matchAtIndex); + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/IntPatternMatcher.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/IntPatternMatcher.cs new file mode 100644 index 0000000..614f914 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/IntPatternMatcher.cs @@ -0,0 +1,49 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.Text.PatternMatchers +{ + /// + /// Pattern matcher that matches culture invariant integer values + /// + public class IntPatternMatcher : PatternMatcherBase + { + public static readonly IntPatternMatcher Default = new IntPatternMatcher(); + + //perform the match + public override int Match(string textToMatch, int matchAtIndex) + { + int currentIndex = matchAtIndex; + do + { + char currentChar = textToMatch[currentIndex]; + if (currentChar >= '0' && currentChar <= '9') + { + //current char is hexchar + } + else + { + break; + } + currentIndex++; + } while (currentIndex < textToMatch.Length); + + return currentIndex - matchAtIndex; + } + + //public override string[] DefaultPrefixes + //{ + // get + // { + // return new[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + // } + //} + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/PatternMatcherBase.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/PatternMatcherBase.cs new file mode 100644 index 0000000..bb3fe2d --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/PatternMatcherBase.cs @@ -0,0 +1,32 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.Text.PatternMatchers +{ + /// + /// Base implementation for pattern matchers + /// + public abstract class PatternMatcherBase : IPatternMatcher + { + #region IPatternMatcher Members + + public virtual int Match(string textToMatch, int matchAtIndex) + { + return 0; + } + + public virtual string[] DefaultPrefixes + { + get { return null; } + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/PropertyPathPatternMatcher.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/PropertyPathPatternMatcher.cs new file mode 100644 index 0000000..b9a746c --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/PropertyPathPatternMatcher.cs @@ -0,0 +1,84 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.Text.PatternMatchers +{ + /// + /// Pattern matcher that matches a propertypath + /// + public class PropertyPathPatterhMatcher : PatternMatcherBase + { + //perform the match + public override int Match(string textToMatch, int matchAtIndex) + { + bool start = true; + + int currentIndex = matchAtIndex; + do + { + char currentChar = textToMatch[currentIndex]; + if (start && IsValidStartChar(currentChar)) + { + start = false; + } + else if (start && IsWildcard(currentChar)) + { + currentIndex++; + break; + } + else if (!start && IsSeparator(currentChar)) + { + start = true; + } + else if (!start && IsValidChar(currentChar)) {} + else + { + break; + } + currentIndex++; + } while (currentIndex < textToMatch.Length); + + if (textToMatch.Substring(matchAtIndex, currentIndex - matchAtIndex) == "*") + return 0; + + return currentIndex - matchAtIndex; + } + + + private static bool IsWildcard(char c) + { + return c == '*' || c == '¤'; + } + + private static bool IsSeparator(char c) + { + return c == '.'; + } + + private static bool IsValidStartChar(char c) + { + if (CharUtils.IsLetter(c)) + return true; + + if ("_@".IndexOf(c) >= 0) + return true; + + return false; + } + + private static bool IsValidChar(char c) + { + if (CharUtils.IsLetterOrDigit(c) || c == '_') + return true; + + return false; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/RegexPatternMatcher.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/RegexPatternMatcher.cs new file mode 100644 index 0000000..41c5c5e --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/RegexPatternMatcher.cs @@ -0,0 +1,101 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Text.RegularExpressions; + +namespace Alsing.Text.PatternMatchers +{ + /// + /// Pattern matcher that allows regex patterns to be matched + /// + public class RegexPatternMatcher : PatternMatcherBase + { + private Regex regEx; + + public RegexPatternMatcher() + { + PatternChanged += RegexPatternMatcher_PatternChanged; + } + + public RegexPatternMatcher(string pattern) : this() + { + Pattern = pattern; + } + + #region PUBLIC PROPERTY PATTERN (+PATTERNCHANGED EVENT) + + private string pattern; + + /// + /// Gets or Sets the Pattern property + /// + public string Pattern + { + get { return pattern; } + set + { + //Ignore same value + if (pattern == value) + return; + + //Set the new value + pattern = value; + + //Raise the changed event + OnPatternChanged(EventArgs.Empty); + } + } + + #region PUBLIC EVENT PATTERNCHANGED + + /// + /// Fires when the 'Pattern' Property changes + /// + public event EventHandler PatternChanged = null; + + /// + /// Raises the PatternChanged Event + /// + /// EventArgs + protected virtual void OnPatternChanged(EventArgs e) + { + if (PatternChanged != null) + PatternChanged(this, e); + } + + #endregion //END PUBLIC EVENT PATTERNCHANGED + + #endregion //END PUBLIC PROPERTY PATTERN (+PATTERNCHANGED EVENT) + + //perform the match + public override int Match(string textToMatch, int matchAtIndex) + { + if (regEx == null) + return 0; + + Match match = regEx.Match(textToMatch, matchAtIndex); + + if (match.Success) + { + return match.Length; + } + + return 0; + } + + private void RegexPatternMatcher_PatternChanged(object sender, EventArgs e) + { + const RegexOptions options = RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.Singleline; + + regEx = new Regex(string.Format(@"\G({0})", pattern), options); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/RegionPatternMatcher.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/RegionPatternMatcher.cs new file mode 100644 index 0000000..6fbb6f3 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/PatternMatchers/RegionPatternMatcher.cs @@ -0,0 +1,66 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.Text.PatternMatchers +{ + public class RangePatternMatcher : PatternMatcherBase + { + public RangePatternMatcher(char quote) + { + StartChar = quote; + EndChar = quote; + } + + public RangePatternMatcher(char start, char end) + { + StartChar = start; + EndChar = end; + } + + public RangePatternMatcher(char start, char end, char escape) + { + StartChar = start; + EndChar = end; + EscapeChar = escape; + } + + public override string[] DefaultPrefixes + { + get { return new[] {StartChar.ToString()}; } + } + + public char StartChar { get; set; } + public char EndChar { get; set; } + public char EscapeChar { get; set; } + + public override int Match(string textToMatch, int matchAtIndex) + { + int length = 0; + int textLength = textToMatch.Length; + + while (matchAtIndex + length != textLength) + { + if (textToMatch[matchAtIndex + length] == EndChar && + (matchAtIndex + length < textLength - 1 && textToMatch[matchAtIndex + length + 1] == EndChar)) + { + length++; + } + else if (textToMatch[matchAtIndex + length] == EndChar && + (matchAtIndex + length == textLength - 1 || textToMatch[matchAtIndex + length + 1] != EndChar)) + return length + 1; + + length++; + } + + + return 0; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/ReadMe.txt b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/ReadMe.txt new file mode 100644 index 0000000..5995d19 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/ReadMe.txt @@ -0,0 +1,6 @@ +The Alsing.Text namespace contains my old DFA tokenizer. +This is not documented and there are no samples other than the usage in Alsing Framework - NPath + +Documentation and samples will come in time ;-) + + diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/CharUtils.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/CharUtils.cs new file mode 100644 index 0000000..c291d91 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/CharUtils.cs @@ -0,0 +1,137 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System.Globalization; + +namespace Alsing.Text +{ + //(c) WE WASTE MEMORY 2004 + public class CharUtils + { + private static bool[] isLetterLookup; + private static bool[] isLetterOrDigitLookup; + private static char[] lowerCharLookup; + private static bool[] separatorCharLookup; + private static char[] upperCharLookup; + + public static bool[] IsLetterOrDigitLookup + { + get + { + if (isLetterOrDigitLookup == null) + { + isLetterOrDigitLookup = new bool[65536]; + for (int i = 0; i < 65536; i++) + { + isLetterOrDigitLookup[i] = char.IsLetterOrDigit((char) i); + } + } + + return isLetterOrDigitLookup; + } + } + + public static bool[] IsLetterLookup + { + get + { + if (isLetterLookup == null) + { + isLetterLookup = new bool[65536]; + for (int i = 0; i < 65536; i++) + { + isLetterLookup[i] = char.IsLetter((char) i); + } + } + + return isLetterLookup; + } + } + + public static bool[] SeparatorCharLookup + { + get + { + if (separatorCharLookup == null) + { + separatorCharLookup = new bool[65536]; + for (int i = 0; i < 65536; i++) + { + separatorCharLookup[i] = char.IsSeparator((char) i); + } + } + + return separatorCharLookup; + } + } + + public static char[] LowerCharLookup + { + get + { + if (lowerCharLookup == null) + { + lowerCharLookup = new char[65536]; + for (int i = 0; i < 65536; i++) + { + lowerCharLookup[i] = char.ToLower((char) i, CultureInfo.InvariantCulture); + } + } + + return lowerCharLookup; + } + } + + public static char[] UpperCharLookup + { + get + { + if (upperCharLookup == null) + { + upperCharLookup = new char[65536]; + for (int i = 0; i < 65536; i++) + { + upperCharLookup[i] = char.ToUpper((char) i, CultureInfo.InvariantCulture); + } + } + + return upperCharLookup; + } + } + + //This is 4.5 times faster than a standard char.ToUpper + public static char ToUpper(char c) + { + return UpperCharLookup[c]; + } + + //This is 4.5 times faster than a standard char.ToLower + public static char ToLower(char c) + { + return LowerCharLookup[c]; + } + + //This is 2.4 times faster than a standard char.IsSeparator + public static bool IsSeparator(char c) + { + return SeparatorCharLookup[c]; + } + + public static bool IsLetter(char c) + { + return IsLetterLookup[c]; + } + + public static bool IsLetterOrDigit(char c) + { + return IsLetterOrDigitLookup[c]; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/MatchResult.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/MatchResult.cs new file mode 100644 index 0000000..27894e2 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/MatchResult.cs @@ -0,0 +1,49 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.Text +{ + public struct MatchResult + { + public bool Found; + public int Index; + public int Length; + public object[] Tags; + public string Text; + + public static MatchResult NoMatch + { + get + { + var result = new MatchResult {Found = false}; + return result; + } + } + + public override string ToString() + { + if (Found == false) + return "no match"; // do not localize + + if (Tags != null) + return Tags + " " + Index + " " + Length; + + return "MatchResult"; + } + + public string GetText() + { + if (Text != null) + return Text.Substring(Index, Length); + + return ""; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/PatternMatchReference.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/PatternMatchReference.cs new file mode 100644 index 0000000..2265519 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/PatternMatchReference.cs @@ -0,0 +1,25 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +namespace Alsing.Text.PatternMatchers +{ + public class PatternMatchReference + { + public IPatternMatcher Matcher; + public bool NeedSeparators; + public PatternMatchReference NextSibling; + public object[] Tags; + + public PatternMatchReference(IPatternMatcher matcher) + { + Matcher = matcher; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/Token.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/Token.cs new file mode 100644 index 0000000..673f47f --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/Token.cs @@ -0,0 +1,29 @@ +using System; + +namespace Alsing.Text +{ + public sealed class Token + { + public Token(string text, object[] tags) + { + if (tags == null) + tags = new object[0]; + + Text = text; + Tags = tags; + } + + public string Text { get; private set; } + public object[] Tags { get; private set; } + + public override string ToString() + { + return Text; + } + + public bool HasTag(object tag) + { + return Array.IndexOf(Tags, tag) >= 0; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTree-API.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTree-API.cs new file mode 100644 index 0000000..3195970 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTree-API.cs @@ -0,0 +1,59 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using Alsing.Text.PatternMatchers; + +namespace Alsing.Text +{ + public partial class TokenTree + { + public void AddPattern(IPatternMatcher matcher, bool caseSensitive, bool needSeparators, object[] tags) + { + if (matcher == null) + throw new ArgumentNullException("matcher"); + + AddPattern(null, matcher, caseSensitive, needSeparators, tags); + } + + public void AddPattern(string prefix, IPatternMatcher matcher, bool caseSensitive, bool needSeparators, + object[] tags) + { + if (string.IsNullOrEmpty(prefix)) + { + AddPatternWithoutPrefix(matcher, caseSensitive, needSeparators, tags); + } + else if (caseSensitive) + { + AddPatternWithCaseSensitivePrefix(prefix, matcher, needSeparators, tags); + } + else + { + AddPatternWithCaseInsensitivePrefix(prefix, matcher, needSeparators, tags); + } + } + + + public void AddToken(string text, bool caseSensitive, bool needSeparators, object[] tags) + { + if (string.IsNullOrEmpty(text)) + throw new ArgumentNullException(text); + + if (caseSensitive) + { + AddCaseSensitiveToken(text, needSeparators, tags); + } + else + { + AddCaseInsensitiveToken(text, needSeparators, tags); + } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTree-Util.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTree-Util.cs new file mode 100644 index 0000000..0084d04 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTree-Util.cs @@ -0,0 +1,105 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using Alsing.Text.PatternMatchers; + +namespace Alsing.Text +{ + public partial class TokenTree + { + private void AddCaseInsensitiveToken(string text, bool needSeparators, object[] tags) + { + //make a lowercase string and add it as a token + text = text.ToLower(); + char startChar = text[0]; + int startIndex = startChar; + + if (nodes[startIndex] == null) + nodes[startIndex] = new TokenTreeNode(); + + nodes[startIndex].AddToken(text, false, needSeparators, tags); + + //make a lowercase string with a uppercase start char and add it as a token + text = char.ToUpper(startChar) + text.Substring(1); + startChar = text[0]; + startIndex = startChar; + if (nodes[startIndex] == null) + nodes[startIndex] = new TokenTreeNode(); + + nodes[startIndex].AddToken(text, false, needSeparators, tags); + } + + private void AddCaseSensitiveToken(string text, bool needSeparators, object[] tags) + { + char startChar = text[0]; + int startIndex = startChar; + if (nodes[startIndex] == null) + nodes[startIndex] = new TokenTreeNode(); + + nodes[startIndex].AddToken(text, true, needSeparators, tags); + } + + private void AddPatternWithCaseInsensitivePrefix(string prefix, IPatternMatcher matcher, bool needSeparators, + object[] tags) + { + //make a lowercase string and add it as a token + prefix = prefix.ToLower(); + char startChar = prefix[0]; + int startIndex = startChar; + if (nodes[startIndex] == null) + nodes[startIndex] = new TokenTreeNode(); + + nodes[startIndex].AddPattern(prefix, false, needSeparators, matcher, tags); + + //make a lowercase string with a uppercase start char and add it as a token + prefix = char.ToUpper(startChar) + prefix.Substring(1); + startChar = prefix[0]; + startIndex = startChar; + if (nodes[startIndex] == null) + nodes[startIndex] = new TokenTreeNode(); + + nodes[startIndex].AddPattern(prefix, false, needSeparators, matcher, tags); + } + + private void AddPatternWithCaseSensitivePrefix(string prefix, IPatternMatcher matcher, bool needSeparators, + object[] tags) + { + char startChar = prefix[0]; + int startIndex = startChar; + if (nodes[startIndex] == null) + nodes[startIndex] = new TokenTreeNode(); + + nodes[startIndex].AddPattern(prefix, true, needSeparators, matcher, tags); + } + + private void AddPatternWithoutPrefix(IPatternMatcher matcher, bool caseSensitive, bool needSeparators, + object[] tags) + { + if (matcher.DefaultPrefixes != null) + { + foreach (string defaultPrefix in matcher.DefaultPrefixes) + { + AddPattern(defaultPrefix, matcher, caseSensitive, needSeparators, tags); + } + } + else + { + var patternMatcherReference = new PatternMatchReference(matcher) + { + Tags = tags, + NextSibling = root.FirstExpression, + NeedSeparators = needSeparators + }; + + root.FirstExpression = patternMatcherReference; + } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTree.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTree.cs new file mode 100644 index 0000000..643ca81 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTree.cs @@ -0,0 +1,194 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using Alsing.Text.PatternMatchers; + +namespace Alsing.Text +{ + public partial class TokenTree + { + private readonly TokenTreeNode[] nodes; + private readonly TokenTreeNode root; + private readonly char[] textLookup; + private bool[] separatorCharLookup; + + public TokenTree() + { + nodes = new TokenTreeNode[65536]; + Separators = ".,;:<>[](){}!\"#¤%&/=?*+-/\\ \t\n\r"; + textLookup = new char[65536]; + for (int i = 0; i < 65536; i++) + { + textLookup[i] = (char) i; + } + textLookup['\t'] = ' '; + + root = new TokenTreeNode(); + } + + #region PUBLIC PROPERTY SEPARATORS + + private string separators; + + public string Separators + { + get { return separators; } + set + { + separators = value; + separatorCharLookup = new bool[65536]; //initialize all to false + foreach (char separatorChar in value) + { + separatorCharLookup[separatorChar] = true; + } + } + } + + #endregion //END PUBLIC PROPERTY SEPARATORS + + //this is wicked fast + //do not refactor extract methods from this if you want to keep the speed + public MatchResult Match(string text, int startIndex) + { + if (string.IsNullOrEmpty(text)) + throw new ArgumentNullException(text); + + var lastMatch = new MatchResult {Text = text}; + int textLength = text.Length; + + for (int currentIndex = startIndex; currentIndex < textLength; currentIndex ++) + { + //call any prefixless patternmatchers + + #region HasExpressions + + if (root.FirstExpression != null) + { + //begin with the first expression of the _root node_ + PatternMatchReference patternMatcherReference = root.FirstExpression; + while (patternMatcherReference != null) + { + int patternMatchIndex = patternMatcherReference.Matcher.Match(text, currentIndex); + if (patternMatchIndex > 0 && patternMatchIndex > lastMatch.Length) + { + bool leftIsSeparator = currentIndex == 0 + ? true + : separatorCharLookup[text[currentIndex - 1]]; + bool rightIsSeparator = (currentIndex + patternMatchIndex) == textLength + ? true + : separatorCharLookup[text[currentIndex + patternMatchIndex]]; + + if (!patternMatcherReference.NeedSeparators || (leftIsSeparator && rightIsSeparator)) + { + lastMatch.Index = currentIndex; + lastMatch.Length = patternMatchIndex; + lastMatch.Found = true; + lastMatch.Tags = patternMatcherReference.Tags; + } + } + + patternMatcherReference = patternMatcherReference.NextSibling; + } + } + + #endregion + + //lookup the first token tree node + TokenTreeNode node = nodes[text[currentIndex]]; + if (node == null) + { + if (lastMatch.Found) + break; + + continue; + } + + + for (int matchIndex = currentIndex + 1; matchIndex <= textLength; matchIndex++) + { + //call patternmatchers for the current prefix + + #region HasExpressions + + if (node.FirstExpression != null) + { + //begin with the first expression of the _current node_ + PatternMatchReference patternMatcherReference = node.FirstExpression; + while (patternMatcherReference != null) + { + int patternMatchIndex = patternMatcherReference.Matcher.Match(text, matchIndex); + if (patternMatchIndex > 0 && patternMatchIndex > lastMatch.Length) + { + bool leftIsSeparator = currentIndex == 0 + ? true + : separatorCharLookup[text[currentIndex - 1]]; + bool rightIsSeparator = (currentIndex + patternMatchIndex + matchIndex) == textLength + ? true + : separatorCharLookup[ + text[currentIndex + patternMatchIndex + matchIndex]]; + + if (!patternMatcherReference.NeedSeparators || (leftIsSeparator && rightIsSeparator)) + { + lastMatch.Index = currentIndex; + lastMatch.Length = patternMatchIndex + matchIndex - currentIndex; + lastMatch.Found = true; + lastMatch.Tags = patternMatcherReference.Tags; + } + } + + patternMatcherReference = patternMatcherReference.NextSibling; + } + } + + #endregion + + #region IsEndNode + + if (node.IsEnd && matchIndex - currentIndex >= lastMatch.Length) + { + bool leftIsSeparator = currentIndex == 0 ? true : separatorCharLookup[text[currentIndex - 1]]; + bool rightIsSeparator = matchIndex == textLength ? true : separatorCharLookup[text[matchIndex]]; + + if (!node.NeedSeparators || (leftIsSeparator && rightIsSeparator)) + { + lastMatch.Index = currentIndex; + lastMatch.Tags = node.Tags; + lastMatch.Found = true; + lastMatch.Length = matchIndex - currentIndex; + //TODO:perform case test here , case sensitive words might be matched even if they have incorrect case + if (currentIndex + lastMatch.Length == textLength) + break; + } + } + + #endregion + + //try fetch a node at this index + node = node.GetNextNode(textLookup[text[matchIndex]]); + + //we found no node on the lookupindex or none of the siblingnodes at that index matched the current char + if (node == null) + break; // continue with the next character + } + + //return last match + if (lastMatch.Found) + return lastMatch; + } + + if (lastMatch.Found) + return lastMatch; + + //no match was found + return MatchResult.NoMatch; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTreeNode.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTreeNode.cs new file mode 100644 index 0000000..7cf9d71 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/TokenTreeNode.cs @@ -0,0 +1,168 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.rogeralsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using Alsing.Text.PatternMatchers; + +namespace Alsing.Text +{ + public class TokenTreeNode + { + public bool CaseSensitive = true; + public char Char = char.MinValue; + public TokenTreeNode[] ChildNodes; + public bool ContainsCaseInsensitiveData; + public long Count; + public PatternMatchReference FirstExpression; + public bool IsEnd; + public bool NeedSeparators; + public TokenTreeNode NextSibling; + public object[] Tags; + + public TokenTreeNode() + { + ChildNodes = new TokenTreeNode[256]; + } + + public override string ToString() + { + if (Tags != null) + return Tags.ToString(); + + return "TokenTreeNode " + Char; // do not localize + } + + public void AddPattern(string prefix, bool caseSensitive, bool needSeparators, IPatternMatcher matcher, + object[] tags) + { + if (string.IsNullOrEmpty(prefix)) + throw new ArgumentNullException("prefix"); + + TokenTreeNode node = AddTokenInternal(prefix, caseSensitive); + + var patternMatcherReference = new PatternMatchReference(matcher) + {NextSibling = FirstExpression, Tags = tags, NeedSeparators = needSeparators}; + + node.FirstExpression = patternMatcherReference; + } + + public void AddPattern(bool caseSensitive, bool needSeparators, IPatternMatcher matcher, object[] tags) + { + var patternMatcherReference = new PatternMatchReference(matcher) + {NextSibling = FirstExpression, Tags = tags, NeedSeparators = needSeparators}; + + FirstExpression = patternMatcherReference; + } + + public void AddToken(string token, bool caseSensitive, bool needSeparators, object[] tags) + { + if (string.IsNullOrEmpty(token)) + throw new ArgumentNullException("token"); + + TokenTreeNode node = AddTokenInternal(token, caseSensitive); + node.IsEnd = true; + node.Tags = tags; + node.NeedSeparators = needSeparators; + node.CaseSensitive = caseSensitive; + } + + public TokenTreeNode AddTokenInternal(string token, bool caseSensitive) + { + Char = token[0]; + + + if (!caseSensitive) + ContainsCaseInsensitiveData = true; + + if (token.Length == 1) + return this; + + string leftovers = token.Substring(1); + char childChar = leftovers[0]; + int childIndex = childChar & 0xff; + //make a lookupindex (dont mind if unicode chars end up as siblings as ascii) + + TokenTreeNode node = ChildNodes[childIndex]; + TokenTreeNode res; + if (node == null) + { + var child = new TokenTreeNode(); + ChildNodes[childIndex] = child; + res = child.AddTokenInternal(leftovers, caseSensitive); + + MakeRepeatingWS(child); + } + else + { + node = GetMatchingNode(childChar, node); + res = node.AddTokenInternal(leftovers, caseSensitive); + } + + return res; + } + + private static void MakeRepeatingWS(TokenTreeNode child) + { + if (child.Char == ' ') + { + // if the node contains " " (whitespace) + // then add the node as a childnode of itself. + // thus allowing it to parse things like + // "end sub" even if the pattern is "end sub" // do not localize + child.ChildNodes[' '] = child; + } + } + + private static TokenTreeNode GetMatchingNode(char childChar, TokenTreeNode node) + { + //find a bucket with the same childChar as we need + while (node.NextSibling != null && node.Char != childChar) + { + node = node.NextSibling; + } + + if (node.Char != childChar) + { + var child = new TokenTreeNode(); + node.NextSibling = child; + return child; + } + return node; + } + + public TokenTreeNode GetNextNode(char c) + { + char tmp = c; + //if case sensitive, to lower + if (ContainsCaseInsensitiveData) + tmp = CharUtils.ToLower(c); + + //hash the index + int index = tmp & 0xff; + + //get node at index + TokenTreeNode node = ChildNodes[index]; + + while (node != null) + { + tmp = c; + if (node.ContainsCaseInsensitiveData) + tmp = CharUtils.ToLower(c); + + if (node.Char == tmp) + break; + + node = node.NextSibling; + } + + return node; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/Tokenizer.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/Tokenizer.cs new file mode 100644 index 0000000..1af7a3b --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Text/Tokenizer/Tokenizer.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using Alsing.Text.PatternMatchers; + +namespace Alsing.Text +{ + public class Tokenizer + { + private readonly TokenTree tree; + + public Tokenizer() + { + tree = new TokenTree(); + } + + public bool IsImmutable { get; private set; } + + public string Text { get; set; } + + public Tokenizer AddPattern(IPatternMatcher matcher, bool caseSensitive, bool needsSeparators, + params object[] tags) + { + ThrowIfImmutable(); + + tree.AddPattern(matcher, caseSensitive, needsSeparators, tags); + return this; + } + + public Tokenizer AddToken(string token, bool caseSensitive, bool needsSeparators, params object[] tags) + { + ThrowIfImmutable(); + + tree.AddToken(token, caseSensitive, needsSeparators, tags); + return this; + } + + public Token[] Tokenize() + { + if (Text == null) + throw new ArgumentNullException("Text"); + + MakeImmutable(); + + var tokens = new List(); + + int index = 0; + while (index < Text.Length) + { + MatchResult match = tree.Match(Text, index); + + if (match.Found) + { + string dummyText = Text.Substring(index, match.Index - index); + var dummyToken = new Token(dummyText, null); + tokens.Add(dummyToken); + + var realToken = new Token(match.GetText(), match.Tags); + index = match.Index + match.Length; + tokens.Add(realToken); + } + else + { + string dummyText = Text.Substring(index); + var dummyToken = new Token(dummyText, null); + tokens.Add(dummyToken); + + index = Text.Length; + } + } + + return tokens.ToArray(); + } + + private void ThrowIfImmutable() + { + if (IsImmutable) + throw new Exception("Tokens can not be added to an immutable tokenizer"); + } + + public void MakeImmutable() + { + IsImmutable = true; + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Win32/Enums.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Win32/Enums.cs new file mode 100644 index 0000000..54fc170 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Win32/Enums.cs @@ -0,0 +1,762 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Drawing; +using System.Runtime.InteropServices; + +namespace Alsing.Windows +{ + + #region WINDOWPOS + + [StructLayout(LayoutKind.Sequential)] + public struct WINDOWPOS + { + public IntPtr hwnd; + public IntPtr hwndInsertAfter; + public int x; + public int y; + public int cx; + public int cy; + public uint flags; + } + + #endregion + + #region _NCCALCSIZE_PARAMS + + [StructLayout(LayoutKind.Sequential)] + public struct _NCCALCSIZE_PARAMS + { + public APIRect NewRect; + public APIRect OldRect; + public APIRect OldClientRect; + + public WINDOWPOS lppos; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct MyStruct + { + public int SomeValue; + public byte b1; + public byte b2; + public byte b3; + public byte b4; + public byte b5; + public byte b6; + public byte b7; + public byte b8; + } + + #endregion + + public enum WindowStylesEx + { + WS_EX_DLGMODALFRAME = 0x00000001, + WS_EX_NOPARENTNOTIFY = 0x00000004, + WS_EX_TOPMOST = 0x00000008, + WS_EX_ACCEPTFILES = 0x00000010, + WS_EX_TRANSPARENT = 0x00000020, + + WS_EX_MDICHILD = 0x00000040, + WS_EX_TOOLWINDOW = 0x00000080, + WS_EX_WINDOWEDGE = 0x00000100, + WS_EX_CLIENTEDGE = 0x00000200, + WS_EX_CONTEXTHELP = 0x00000400, + + WS_EX_RIGHT = 0x00001000, + WS_EX_LEFT = 0x00000000, + WS_EX_RTLREADING = 0x00002000, + WS_EX_LTRREADING = 0x00000000, + WS_EX_LEFTSCROLLBAR = 0x00004000, + WS_EX_RIGHTSCROLLBAR = 0x00000000, + + WS_EX_CONTROLPARENT = 0x00010000, + WS_EX_STATICEDGE = 0x00020000, + WS_EX_APPWINDOW = 0x00040000, + } + + public enum WindowStyles + { + WS_OVERLAPPED = 0x00000000, + WS_POPUP = unchecked((int) 0x80000000), + WS_CHILD = 0x40000000, + WS_MINIMIZE = 0x20000000, + WS_VISIBLE = 0x10000000, + WS_DISABLED = 0x08000000, + WS_CLIPSIBLINGS = 0x04000000, + WS_CLIPCHILDREN = 0x02000000, + WS_MAXIMIZE = 0x01000000, + WS_CAPTION = 0x00C00000, + WS_BORDER = 0x00800000, + WS_DLGFRAME = 0x00400000, + WS_VSCROLL = 0x00200000, + WS_HSCROLL = 0x00100000, + WS_SYSMENU = 0x00080000, + WS_THICKFRAME = 0x00040000, + WS_GROUP = 0x00020000, + WS_TABSTOP = 0x00010000, + WS_MINIMIZEBOX = 0x00020000, + WS_MAXIMIZEBOX = 0x00010000, + WS_TILED = WS_OVERLAPPED, + WS_ICONIC = WS_MINIMIZE, + WS_SIZEBOX = WS_THICKFRAME, + } + + public enum DrawTextFlags + { + DT_TOP = 0x00000000, + DT_LEFT = 0x00000000, + DT_CENTER = 0x00000001, + DT_RIGHT = 0x00000002, + DT_VCENTER = 0x00000004, + DT_BOTTOM = 0x00000008, + DT_WORDBREAK = 0x00000010, + DT_SINGLELINE = 0x00000020, + DT_EXPANDTABS = 0x00000040, + DT_TABSTOP = 0x00000080, + DT_NOCLIP = 0x00000100, + DT_EXTERNALLEADING = 0x00000200, + DT_CALCRECT = 0x00000400, + DT_NOPREFIX = 0x00000800, + DT_INTERNAL = 0x00001000, + DT_EDITCONTROL = 0x00002000, + DT_PATH_ELLIPSIS = 0x00004000, + DT_END_ELLIPSIS = 0x00008000, + DT_MODIFYSTRING = 0x00010000, + DT_RTLREADING = 0x00020000, + DT_WORD_ELLIPSIS = 0x00040000, + DT_NOFULLWIDTHCHARBREAK = 0x00080000, + DT_HIDEPREFIX = 0x00100000, + DT_PREFIXONLY = 0x00200000, + } + + public enum TextBoxNotifications + { + EN_SETFOCUS = 0x0100, + EN_KILLFOCUS = 0x0200, + EN_CHANGE = 0x0300, + EN_UPDATE = 0x0400, + EN_ERRSPACE = 0x0500, + EN_MAXTEXT = 0x0501, + EN_HSCROLL = 0x0601, + EN_VSCROLL = 0x0602, + } + + public enum TextBoxStyles + { + ES_LEFT = 0x0000, + ES_CENTER = 0x0001, + ES_RIGHT = 0x0002, + ES_MULTILINE = 0x0004, + ES_UPPERCASE = 0x0008, + ES_LOWERCASE = 0x0010, + ES_PASSWORD = 0x0020, + ES_AUTOVSCROLL = 0x0040, + ES_AUTOHSCROLL = 0x0080, + ES_NOHIDESEL = 0x0100, + ES_OEMCONVERT = 0x0400, + ES_READONLY = 0x0800, + ES_WANTRETURN = 0x1000, + } + + [StructLayout(LayoutKind.Sequential)] + public struct APIPoint + { + public int x; + public int y; + } + + [StructLayout(LayoutKind.Sequential)] + public struct APIRect + { + public int left; + public int top; + public int right; + public int bottom; + + public int Width + { + get { return right - left; } + } + + public int Height + { + get { return bottom - top; } + } + + public APIRect(Rectangle rect) + { + bottom = rect.Bottom; + left = rect.Left; + right = rect.Right; + top = rect.Top; + } + + public APIRect(int left, int top, int right, int bottom) + { + this.bottom = bottom; + this.left = left; + this.right = right; + this.top = top; + } + } + + #region HitTest + + public enum HitTest + { + HTERROR = (-2), + HTTRANSPARENT = (-1), + HTNOWHERE = 0, + HTCLIENT = 1, + HTCAPTION = 2, + HTSYSMENU = 3, + HTGROWBOX = 4, + HTSIZE = HTGROWBOX, + HTMENU = 5, + HTHSCROLL = 6, + HTVSCROLL = 7, + HTMINBUTTON = 8, + HTMAXBUTTON = 9, + HTLEFT = 10, + HTRIGHT = 11, + HTTOP = 12, + HTTOPLEFT = 13, + HTTOPRIGHT = 14, + HTBOTTOM = 15, + HTBOTTOMLEFT = 16, + HTBOTTOMRIGHT = 17, + HTBORDER = 18, + HTREDUCE = HTMINBUTTON, + HTZOOM = HTMAXBUTTON, + HTSIZEFIRST = HTLEFT, + HTSIZELAST = HTBOTTOMRIGHT, + HTOBJECT = 19, + HTCLOSE = 20, + HTHELP = 21 + } + + #endregion + + public enum TextBoxMessages + { + EM_GETSEL = 0x00B0, + EM_LINEINDEX = 0x00BB, + EM_LINEFROMCHAR = 0x00C9, + EM_POSFROMCHAR = 0x00D6, + } + + [Flags] + public enum WMPrintFlags + { + PRF_CHECKVISIBLE = 0x00000001, + PRF_NONCLIENT = 0x00000002, + PRF_CLIENT = 0x00000004, + PRF_ERASEBKGND = 0x00000008, + PRF_CHILDREN = 0x00000010, + PRF_OWNED = 0x0000020, + } + + public enum WindowMessage + { + WM_NULL = 0x0000, + WM_CREATE = 0x0001, + WM_DESTROY = 0x0002, + WM_MOVE = 0x0003, + WM_SIZE = 0x0005, + WM_ACTIVATE = 0x0006, + WM_SETFOCUS = 0x0007, + WM_KILLFOCUS = 0x0008, + WM_ENABLE = 0x000A, + WM_SETREDRAW = 0x000B, + WM_SETTEXT = 0x000C, + WM_GETTEXT = 0x000D, + WM_GETTEXTLENGTH = 0x000E, + WM_PAINT = 0x000F, + WM_CLOSE = 0x0010, + WM_QUERYENDSESSION = 0x0011, + WM_QUIT = 0x0012, + WM_QUERYOPEN = 0x0013, + WM_ERASEBKGND = 0x0014, + WM_SYSCOLORCHANGE = 0x0015, + WM_ENDSESSION = 0x0016, + WM_SHOWWINDOW = 0x0018, + WM_CTLCOLOR = 0x0019, + WM_WININICHANGE = 0x001A, + WM_SETTINGCHANGE = 0x001A, + WM_DEVMODECHANGE = 0x001B, + WM_ACTIVATEAPP = 0x001C, + WM_FONTCHANGE = 0x001D, + WM_TIMECHANGE = 0x001E, + WM_CANCELMODE = 0x001F, + WM_SETCURSOR = 0x0020, + WM_MOUSEACTIVATE = 0x0021, + WM_CHILDACTIVATE = 0x0022, + WM_QUEUESYNC = 0x0023, + WM_GETMINMAXINFO = 0x0024, + WM_PAINTICON = 0x0026, + WM_ICONERASEBKGND = 0x0027, + WM_NEXTDLGCTL = 0x0028, + WM_SPOOLERSTATUS = 0x002A, + WM_DRAWITEM = 0x002B, + WM_MEASUREITEM = 0x002C, + WM_DELETEITEM = 0x002D, + WM_VKEYTOITEM = 0x002E, + WM_CHARTOITEM = 0x002F, + WM_SETFONT = 0x0030, + WM_GETFONT = 0x0031, + WM_SETHOTKEY = 0x0032, + WM_GETHOTKEY = 0x0033, + WM_QUERYDRAGICON = 0x0037, + WM_COMPAREITEM = 0x0039, + WM_GETOBJECT = 0x003D, + WM_COMPACTING = 0x0041, + WM_COMMNOTIFY = 0x0044, + WM_WINDOWPOSCHANGING = 0x0046, + WM_WINDOWPOSCHANGED = 0x0047, + WM_POWER = 0x0048, + WM_COPYDATA = 0x004A, + WM_CANCELJOURNAL = 0x004B, + WM_NOTIFY = 0x004E, + WM_INPUTLANGCHANGEREQUEST = 0x0050, + WM_INPUTLANGCHANGE = 0x0051, + WM_TCARD = 0x0052, + WM_HELP = 0x0053, + WM_USERCHANGED = 0x0054, + WM_NOTIFYFORMAT = 0x0055, + WM_CONTEXTMENU = 0x007B, + WM_STYLECHANGING = 0x007C, + WM_STYLECHANGED = 0x007D, + WM_DISPLAYCHANGE = 0x007E, + WM_GETICON = 0x007F, + WM_SETICON = 0x0080, + WM_NCCREATE = 0x0081, + WM_NCDESTROY = 0x0082, + WM_NCCALCSIZE = 0x0083, + WM_NCHITTEST = 0x0084, + WM_NCPAINT = 0x0085, + WM_NCACTIVATE = 0x0086, + WM_GETDLGCODE = 0x0087, + WM_SYNCPAINT = 0x0088, + WM_NCMOUSEMOVE = 0x00A0, + WM_NCLBUTTONDOWN = 0x00A1, + WM_NCLBUTTONUP = 0x00A2, + WM_NCLBUTTONDBLCLK = 0x00A3, + WM_NCRBUTTONDOWN = 0x00A4, + WM_NCRBUTTONUP = 0x00A5, + WM_NCRBUTTONDBLCLK = 0x00A6, + WM_NCMBUTTONDOWN = 0x00A7, + WM_NCMBUTTONUP = 0x00A8, + WM_NCMBUTTONDBLCLK = 0x00A9, + WM_KEYDOWN = 0x0100, + WM_KEYUP = 0x0101, + WM_CHAR = 0x0102, + WM_DEADCHAR = 0x0103, + WM_SYSKEYDOWN = 0x0104, + WM_SYSKEYUP = 0x0105, + WM_SYSCHAR = 0x0106, + WM_SYSDEADCHAR = 0x0107, + WM_KEYLAST = 0x0108, + WM_IME_STARTCOMPOSITION = 0x010D, + WM_IME_ENDCOMPOSITION = 0x010E, + WM_IME_COMPOSITION = 0x010F, + WM_IME_KEYLAST = 0x010F, + WM_INITDIALOG = 0x0110, + WM_Element = 0x0111, + WM_COMMAND = 0x0111, + WM_SYSElement = 0x0112, + WM_TIMER = 0x0113, + WM_HSCROLL = 0x0114, + WM_VSCROLL = 0x0115, + WM_INITMENU = 0x0116, + WM_INITMENUPOPUP = 0x0117, + WM_MENUSELECT = 0x011F, + WM_MENUCHAR = 0x0120, + WM_ENTERIDLE = 0x0121, + WM_MENURBUTTONUP = 0x0122, + WM_MENUDRAG = 0x0123, + WM_MENUGETOBJECT = 0x0124, + WM_UNINITMENUPOPUP = 0x0125, + WM_MENUElement = 0x0126, + WM_CTLCOLORMSGBOX = 0x0132, + WM_CTLCOLOREDIT = 0x0133, + WM_CTLCOLORLISTBOX = 0x0134, + WM_CTLCOLORBTN = 0x0135, + WM_CTLCOLORDLG = 0x0136, + WM_CTLCOLORSCROLLBAR = 0x0137, + WM_CTLCOLORSTATIC = 0x0138, + WM_MOUSEMOVE = 0x0200, + WM_LBUTTONDOWN = 0x0201, + WM_LBUTTONUP = 0x0202, + WM_LBUTTONDBLCLK = 0x0203, + WM_RBUTTONDOWN = 0x0204, + WM_RBUTTONUP = 0x0205, + WM_RBUTTONDBLCLK = 0x0206, + WM_MBUTTONDOWN = 0x0207, + WM_MBUTTONUP = 0x0208, + WM_MBUTTONDBLCLK = 0x0209, + WM_MOUSEWHEEL = 0x020A, + WM_PARENTNOTIFY = 0x0210, + WM_ENTERMENULOOP = 0x0211, + WM_EXITMENULOOP = 0x0212, + WM_NEXTMENU = 0x0213, + WM_SIZING = 0x0214, + WM_CAPTURECHANGED = 0x0215, + WM_MOVING = 0x0216, + WM_DEVICECHANGE = 0x0219, + WM_MDICREATE = 0x0220, + WM_MDIDESTROY = 0x0221, + WM_MDIACTIVATE = 0x0222, + WM_MDIRESTORE = 0x0223, + WM_MDINEXT = 0x0224, + WM_MDIMAXIMIZE = 0x0225, + WM_MDITILE = 0x0226, + WM_MDICASCADE = 0x0227, + WM_MDIICONARRANGE = 0x0228, + WM_MDIGETACTIVE = 0x0229, + WM_MDISETMENU = 0x0230, + WM_ENTERSIZEMOVE = 0x0231, + WM_EXITSIZEMOVE = 0x0232, + WM_DROPFILES = 0x0233, + WM_MDIREFRESHMENU = 0x0234, + WM_IME_SETCONTEXT = 0x0281, + WM_IME_NOTIFY = 0x0282, + WM_IME_CONTROL = 0x0283, + WM_IME_COMPOSITIONFULL = 0x0284, + WM_IME_SELECT = 0x0285, + WM_IME_CHAR = 0x0286, + WM_IME_REQUEST = 0x0288, + WM_IME_KEYDOWN = 0x0290, + WM_IME_KEYUP = 0x0291, + WM_MOUSEHOVER = 0x02A1, + WM_MOUSELEAVE = 0x02A3, + WM_CUT = 0x0300, + WM_COPY = 0x0301, + WM_PASTE = 0x0302, + WM_CLEAR = 0x0303, + WM_UNDO = 0x0304, + WM_RENDERFORMAT = 0x0305, + WM_RENDERALLFORMATS = 0x0306, + WM_DESTROYCLIPBOARD = 0x0307, + WM_DRAWCLIPBOARD = 0x0308, + WM_PAINTCLIPBOARD = 0x0309, + WM_VSCROLLCLIPBOARD = 0x030A, + WM_SIZECLIPBOARD = 0x030B, + WM_ASKCBFORMATNAME = 0x030C, + WM_CHANGECBCHAIN = 0x030D, + WM_HSCROLLCLIPBOARD = 0x030E, + WM_QUERYNEWPALETTE = 0x030F, + WM_PALETTEISCHANGING = 0x0310, + + WM_PALETTECHANGED = 0x0311, + WM_HOTKEY = 0x0312, + WM_PRINT = 0x0317, + WM_PRINTCLIENT = 0x0318, + WM_HANDHELDFIRST = 0x0358, + WM_HANDHELDLAST = 0x035F, + WM_AFXFIRST = 0x0360, + WM_AFXLAST = 0x037F, + WM_PENWINFIRST = 0x0380, + WM_PENWINLAST = 0x038F, + WM_APP = 0x8000, + WM_USER = 0x0400, + WM_REFLECT = WM_USER + 0x1c00, + WM_THEMECHANGED = 794, + } + + + public enum GDIRop + { + SrcCopy = 13369376, + Blackness = 0, //to be implemented + Whiteness = 0 + } + + + [StructLayout(LayoutKind.Sequential)] + public struct GDITextMetric + { + public int tmMemoryHeight; + public int tmAscent; + public int tmDescent; + public int tmInternalLeading; + public int tmExternalLeading; + public int tmAveCharWidth; + public int tmMaxCharWidth; + public int tmWeight; + public int tmOverhang; + public int tmDigitizedAspectX; + public int tmDigitizedAspectY; + public byte tmFirstChar; + public byte tmLastChar; + public byte tmDefaultChar; + public byte tmBreakChar; + public byte tmItalic; + public byte tmUnderlined; + public byte tmStruckOut; + public byte tmPitchAndFamily; + public byte tmCharSet; + } + + // public IntPtr Fontname; + + [StructLayout(LayoutKind.Sequential)] + public class ENUMLOGFONTEX + { + public LogFont elfLogFont; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string elfFullName = ""; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] elfStyle; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] elfScript; + } + + [StructLayout(LayoutKind.Sequential)] + public class COMPOSITIONFORM + { + public int dwStyle; + public APIPoint ptCurrentPos; + public APIRect rcArea; + } + + [StructLayout(LayoutKind.Sequential)] + public class LogFont + { + public int lfHeight; + public int lfWidth; + public int lfEscapement; + public int lfOrientation; + public int lfWeight; + public byte lfItalic; + public byte lfUnderline; + public byte lfStrikeOut; + public byte lfCharSet; + public byte lfOutPrecision; + public byte lfClipPrecision; + public byte lfQuality; + public byte lfPitchAndFamily; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string lfFaceName = ""; + } + +// public enum VirtualKeys +// { +// VK_LBUTTON = 0x01, +// VK_RBUTTON =0x02, +// VK_CANCEL =0x03, +// VK_MBUTTON =0x04 , +// VK_XBUTTON1 =0x05, +// VK_XBUTTON2 =0x06, +// VK_BACK =0x08 , +// VK_TAB =0x09, +// — 0A–0B Reserved +// VK_CLEAR 0C CLEAR key +// VK_RETURN 0D ENTER key +// — 0E–0F Undefined +// VK_SHIFT 10 SHIFT key +// VK_CONTROL 11 CTRL key +// VK_MENU 12 ALT key +// VK_PAUSE 13 PAUSE key +// VK_CAPITAL 14 CAPS LOCK key +// VK_KANA 15 IME Kana mode +// VK_HANGUEL 15 IME Hanguel mode (maintained for compatibility; use VK_HANGUL) +// VK_HANGUL 15 IME Hangul mode +// — 16 Undefined +// VK_JUNJA 17 IME Junja mode +// VK_FINAL 18 IME final mode +// VK_HANJA 19 IME Hanja mode +// VK_KANJI 19 IME Kanji mode +// — 1A Undefined +// VK_ESCAPE 1B ESC key +// VK_CONVERT 1C IME convert +// VK_NONCONVERT 1D IME nonconvert +// VK_ACCEPT 1E IME accept +// VK_MODECHANGE 1F IME mode change request +// VK_SPACE 20 SPACEBAR +// VK_PRIOR 21 PAGE UP key +// VK_NEXT 22 PAGE DOWN key +// VK_END 23 END key +// VK_HOME 24 HOME key +// VK_LEFT 25 LEFT ARROW key +// VK_UP 26 UP ARROW key +// VK_RIGHT 27 RIGHT ARROW key +// VK_DOWN 28 DOWN ARROW key +// VK_SELECT 29 SELECT key +// VK_PRINT 2A PRINT key +// VK_EXECUTE 2B EXECUTE key +// VK_SNAPSHOT 2C PRINT SCREEN key +// VK_INSERT 2D INS key +// VK_DELETE 2E DEL key +// VK_HELP 2F HELP key +// 30 0 key +// 31 1 key +// 32 2 key +// 33 3 key +// 34 4 key +// 35 5 key +// 36 6 key +// 37 7 key +// 38 8 key +// 39 9 key +// — 3A–40 Undefined +// 41 A key +// 42 B key +// 43 C key +// 44 D key +// 45 E key +// 46 F key +// 47 G key +// 48 H key +// 49 I key +// 4A J key +// 4B K key +// 4C L key +// 4D M key +// 4E N key +// 4F O key +// 50 P key +// 51 Q key +// 52 R key +// 53 S key +// 54 T key +// 55 U key +// 56 V key +// 57 W key +// 58 X key +// 59 Y key +// 5A Z key +// VK_LWIN 5B Left Windows key (Microsoft® Natural® keyboard) +// VK_RWIN 5C Right Windows key (Natural keyboard) +// VK_APPS 5D Applications key (Natural keyboard) +// — 5E Reserved +// VK_SLEEP 5F Computer Sleep key +// VK_NUMPAD0 60 Numeric keypad 0 key +// VK_NUMPAD1 61 Numeric keypad 1 key +// VK_NUMPAD2 62 Numeric keypad 2 key +// VK_NUMPAD3 63 Numeric keypad 3 key +// VK_NUMPAD4 64 Numeric keypad 4 key +// VK_NUMPAD5 65 Numeric keypad 5 key +// VK_NUMPAD6 66 Numeric keypad 6 key +// VK_NUMPAD7 67 Numeric keypad 7 key +// VK_NUMPAD8 68 Numeric keypad 8 key +// VK_NUMPAD9 69 Numeric keypad 9 key +// VK_MULTIPLY 6A Multiply key +// VK_ADD 6B Add key +// VK_SEPARATOR 6C Separator key +// VK_SUBTRACT 6D Subtract key +// VK_DECIMAL 6E Decimal key +// VK_DIVIDE 6F Divide key +// VK_F1 70 F1 key +// VK_F2 71 F2 key +// VK_F3 72 F3 key +// VK_F4 73 F4 key +// VK_F5 74 F5 key +// VK_F6 75 F6 key +// VK_F7 76 F7 key +// VK_F8 77 F8 key +// VK_F9 78 F9 key +// VK_F10 79 F10 key +// VK_F11 7A F11 key +// VK_F12 7B F12 key +// VK_F13 7C F13 key +// VK_F14 7D F14 key +// VK_F15 7E F15 key +// VK_F16 7F F16 key +// VK_F17 80H F17 key +// VK_F18 81H F18 key +// VK_F19 82H F19 key +// VK_F20 83H F20 key +// VK_F21 84H F21 key +// VK_F22 85H F22 key +// VK_F23 86H F23 key +// VK_F24 87H F24 key +// — 88–8F Unassigned +// VK_NUMLOCK 90 NUM LOCK key +// VK_SCROLL 91 SCROLL LOCK key +// 92–96 OEM specific +// — 97–9F Unassigned +// VK_LSHIFT A0 Left SHIFT key +// VK_RSHIFT A1 Right SHIFT key +// VK_LCONTROL A2 Left CONTROL key +// VK_RCONTROL A3 Right CONTROL key +// VK_LMENU A4 Left MENU key +// VK_RMENU A5 Right MENU key +// VK_BROWSER_BACK A6 Windows 2000/XP: Browser Back key +// VK_BROWSER_FORWARD A7 Windows 2000/XP: Browser Forward key +// VK_BROWSER_REFRESH A8 Windows 2000/XP: Browser Refresh key +// VK_BROWSER_STOP A9 Windows 2000/XP: Browser Stop key +// VK_BROWSER_SEARCH AA Windows 2000/XP: Browser Search key +// VK_BROWSER_FAVORITES AB Windows 2000/XP: Browser Favorites key +// VK_BROWSER_HOME AC Windows 2000/XP: Browser Start and Home key +// VK_VOLUME_MUTE AD Windows 2000/XP: Volume Mute key +// VK_VOLUME_DOWN AE Windows 2000/XP: Volume Down key +// VK_VOLUME_UP AF Windows 2000/XP: Volume Up key +// VK_MEDIA_NEXT_TRACK B0 Windows 2000/XP: Next Track key +// VK_MEDIA_PREV_TRACK B1 Windows 2000/XP: Previous Track key +// VK_MEDIA_STOP B2 Windows 2000/XP: Stop Media key +// VK_MEDIA_PLAY_PAUSE B3 Windows 2000/XP: Play/Pause Media key +// VK_LAUNCH_MAIL B4 Windows 2000/XP: Start Mail key +// VK_LAUNCH_MEDIA_SELECT B5 Windows 2000/XP: Select Media key +// VK_LAUNCH_APP1 B6 Windows 2000/XP: Start Application 1 key +// VK_LAUNCH_APP2 B7 Windows 2000/XP: Start Application 2 key +// — B8-B9 Reserved +// VK_OEM_1 BA Used for miscellaneous characters; it can vary by keyboard. +// Windows 2000/XP: For the US standard keyboard, the ';:' key +// +// VK_OEM_PLUS BB Windows 2000/XP: For any country/region, the '+' key +// VK_OEM_COMMA BC Windows 2000/XP: For any country/region, the ',' key +// VK_OEM_MINUS BD Windows 2000/XP: For any country/region, the '-' key +// VK_OEM_PERIOD BE Windows 2000/XP: For any country/region, the '.' key +// VK_OEM_2 BF Used for miscellaneous characters; it can vary by keyboard. +// Windows 2000/XP: For the US standard keyboard, the '/?' key +// +// VK_OEM_3 C0 Used for miscellaneous characters; it can vary by keyboard. +// Windows 2000/XP: For the US standard keyboard, the '`~' key +// +// — C1–D7 Reserved +// — D8–DA Unassigned +// VK_OEM_4 DB Used for miscellaneous characters; it can vary by keyboard. +// Windows 2000/XP: For the US standard keyboard, the '[{' key +// +// VK_OEM_5 DC Used for miscellaneous characters; it can vary by keyboard. +// Windows 2000/XP: For the US standard keyboard, the '\|' key +// +// VK_OEM_6 DD Used for miscellaneous characters; it can vary by keyboard. +// Windows 2000/XP: For the US standard keyboard, the ']}' key +// +// VK_OEM_7 DE Used for miscellaneous characters; it can vary by keyboard. +// Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key +// +// VK_OEM_8 DF Used for miscellaneous characters; it can vary by keyboard. +// — E0 Reserved +// E1 OEM specific +// VK_OEM_102 E2 Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard +// E3–E4 OEM specific +// VK_PROCESSKEY E5 Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key +// E6 OEM specific +// VK_PACKET E7 Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP +// — E8 Unassigned +// E9–F5 OEM specific +// VK_ATTN F6 Attn key +// VK_CRSEL F7 CrSel key +// VK_EXSEL F8 ExSel key +// VK_EREOF F9 Erase EOF key +// VK_PLAY FA Play key +// VK_ZOOM FB Zoom key +// VK_NONAME FC Reserved for future use +// VK_PA1 FD PA1 key +// VK_OEM_CLEAR FE Clear key +// +// } + + + public delegate int FONTENUMPROC(ENUMLOGFONTEX f, int lpntme, int FontType, int lParam); +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Win32/NativeMethods.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Win32/NativeMethods.cs new file mode 100644 index 0000000..aad3a12 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Win32/NativeMethods.cs @@ -0,0 +1,375 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Drawing; +using System.Runtime.InteropServices; +using System.Windows.Forms; + +namespace Alsing.Windows +{ + public static class NativeMethods + { + public const int GWL_STYLE = -16; + public const int WS_CHILD = 0x40000000; + + #region uxTheme.dll + + [DllImport("uxtheme.dll", SetLastError = true, CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr OpenThemeData(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszClassList); + + [DllImport("uxtheme.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr CloseThemeData(IntPtr hTheme); + + [DllImport("uxtheme.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern bool IsThemeActive(); + + [DllImport("uxtheme.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern int DrawThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, + ref APIRect rect, ref APIRect clipRect); + + [DllImport("uxtheme.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern int DrawThemeText(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, string pszText, + int iCharCount, uint dwTextFlags, uint dwTextFlags2, + [MarshalAs(UnmanagedType.Struct)] ref APIRect rect); + + [DllImport("uxtheme.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern int GetThemeColor(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out ulong color); + + /* + [DllImportAttribute( "uxtheme.dll")] + public static extern void GetThemeBackgroundContentRect( int hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pBoundingRect, ref RECT pContentRect ); + + [DllImportAttribute( "uxtheme.dll" )] + public static extern void GetThemeBackgroundExtent( int hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pContentRect, ref RECT pExtentRect ); + + [DllImportAttribute( "uxtheme.dll")] + public static extern uint GetThemePartSize( IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, IntPtr prc, int sizeType, out SIZE psz ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern uint GetThemeTextExtent( IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, string pszText, int iCharCount, uint dwTextFlags, [MarshalAs( UnmanagedType.Struct )] ref RECT pBoundingRect, out RECT pExtentRect ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeTextMetrics( IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, out TEXTMETRIC ptm ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeBackgroundRegion( IntPtr hTheme, int iPartId, int iStateId, RECT pRect, out IntPtr pRegion ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong HitTestThemeBackground( IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ulong dwOptions, RECT pRect, IntPtr hrgn, POINT ptTest, out uint wHitTestCode ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong DrawThemeLine( IntPtr hTheme, IntPtr hdc, int iStateId, RECT pRect, ulong dwDtlFlags ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong DrawThemeEdge( IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, RECT pDestRect, uint uEdge, uint uFlags, out RECT contentRect ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong DrawThemeBorder( IntPtr hTheme, IntPtr hdc, int iStateId, RECT pRect ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong DrawThemeIcon( IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, RECT pRect, IntPtr himl, int iImageIndex ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern bool IsThemePartDefined( IntPtr hTheme, int iPartId, int iStateId ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern bool IsThemeBackgroundPartiallyTransparent( IntPtr hTheme, int iPartId, int iStateId ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern int GetThemeColor( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out ulong color ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeMetric( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int iVal ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeString( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out string pszBuff, int cchMaxBuffChars ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeBool( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out bool fVal ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeInt( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int iVal ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeEnumValue( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int iVal ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemePosition( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out POINT point ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeFont( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out LOGFONT font ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeRect( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out RECT pRect ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeMargins( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out MARGINS margins ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeIntList( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out INTLIST intList ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemePropertyOrigin( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int origin ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong SetWindowTheme( IntPtr hwnd, string pszSubAppName, string pszSubIdList ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeFilename( IntPtr hTheme, int iPartId, int iStateId, int iPropId, out string pszThemeFileName, int cchMaxBuffChars ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeSysColor( IntPtr hTheme, int iColorId ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern IntPtr GetThemeSysColorBrush( IntPtr hTheme, int iColorId ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern int GetThemeSysSize( IntPtr hTheme, int iSizeId ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern bool GetThemeSysBool( IntPtr hTheme, int iBoolId ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeSysFont( IntPtr hTheme, int iFontId, out LOGFONT lf ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeSysString( IntPtr hTheme, int iStringId, out string pszStringBuff, int cchMaxStringChars ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeSysInt( IntPtr hTheme, int iIntId, out int iValue ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern bool IsAppThemed(); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern IntPtr GetWindowTheme( IntPtr hwnd ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong EnableThemeDialogTexture( IntPtr hwnd, bool fEnable ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern bool IsThemeDialogTextureEnabled( IntPtr hwnd ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeAppProperties(); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern void SetThemeAppProperties( ulong dwFlags ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetCurrentThemeName( out string pszThemeFileName, int cchMaxNameChars, out string pszColorBuff, int cchMaxColorChars, out string pszSizeBuff, int cchMaxSizeChars ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeDocumentationProperty( string pszThemeName, string pszPropertyName, out string pszValueBuff, int cchMaxValChars ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeLastErrorContext( out THEME_ERROR_CONTEXT context ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong FormatThemeMessage( ulong dwLanguageId, THEME_ERROR_CONTEXT context, out string pszMessageBuff, int cchMaxMessageChars ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern ulong GetThemeImageFromParent( IntPtr hwnd, IntPtr hdc, RECT rc ); + + [DllImportAttribute( "uxtheme.dll", CharSet=CharSet.Auto )] + public static extern IntPtr DrawThemeParentBackground( IntPtr hwnd, IntPtr hdc, ref RECT prc ); +*/ + + #endregion + + [DllImport("imm32.dll")] + public static extern IntPtr ImmGetDefaultIMEWnd(IntPtr hWnd); + + [DllImport("user32.dll")] + public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, COMPOSITIONFORM lParam); + + [DllImport("user32.dll")] + public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, LogFont lParam); + + [DllImport("user32.DLL", SetLastError = false, CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + public static extern int DrawText(IntPtr hDC, string lpString, int nCount, ref APIRect Rect, int wFormat); + + + [DllImport("gdi32", SetLastError = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int EnumFontFamiliesEx(IntPtr hDC, [MarshalAs(UnmanagedType.LPStruct)] LogFont lf, + FONTENUMPROC proc, Int64 LParam, Int64 DW); + + [DllImport("shlwapi.dll", SetLastError = true)] + public static extern int SHAutoComplete(IntPtr hWnd, UInt32 flags); + + [DllImport("user32.dll")] + public static extern IntPtr GetDesktopWindow(); + + [DllImport("user32.DLL")] + public static extern IntPtr GetWindowRect(IntPtr hWND, ref APIRect Rect); + + [DllImport("user32.dll", EntryPoint = "SendMessage")] + public static extern int SendMessage(IntPtr hWND, int message, int WParam, int LParam); + + [DllImport("user32.dll")] + public static extern bool ReleaseCapture(); + + [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); + + [DllImport("gdi32.DLL", SetLastError = false, CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + public static extern int SetBkColor(IntPtr hDC, int crColor); + + [DllImport("gdi32.DLL", SetLastError = false, CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + public static extern int SetBkMode(IntPtr hDC, int Mode); + + [DllImport("user32.DLL", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr ReleaseDC(IntPtr hWND, IntPtr hDC); + + [DllImport("gdi32.DLL", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr DeleteDC(IntPtr hDC); + + + [DllImport("gdi32.DLL", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr GdiFlush(); + + [DllImport("user32.DLL", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr GetWindowDC(IntPtr hWND); + + [DllImport("user32.DLL", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr GetDC(IntPtr hWND); + + [DllImport("gdi32.DLL", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth, int nHeight); + + [DllImport("gdi32.DLL", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr CreateCompatibleDC(IntPtr hDC); + + [DllImport("gdi32.DLL", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); + + [DllImport("gdi32.DLL", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr DeleteObject(IntPtr hObject); + + [DllImport("gdi32.DLL", SetLastError = false, CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + public static extern int GetTextColor(IntPtr hDC); + + [DllImport("gdi32.DLL", SetLastError = false, CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + public static extern int SetTextColor(IntPtr hDC, int crColor); + + [DllImport("gdi32.DLL", SetLastError = false, CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + public static extern int GetBkColor(IntPtr hDC); + + + [DllImport("gdi32.DLL", SetLastError = false, CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + public static extern int GetBkMode(IntPtr hDC); + + [DllImport("user32", SetLastError = false, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall + )] + public static extern int DrawFocusRect(IntPtr hDC, ref APIRect rect); + + [DllImport("gdi32.DLL", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr CreateSolidBrush(int crColor); + + [DllImport("gdi32.DLL", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern int Rectangle(IntPtr hDC, int left, int top, int right, int bottom); + + [DllImport("gdi32.DLL", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr CreateHatchBrush(int Style, int crColor); + + [DllImport("user32.DLL", SetLastError = false, CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + public static extern int TabbedTextOut(IntPtr hDC, int x, int y, string lpString, int nCount, int nTabPositions, + ref int lpnTabStopPositions, int nTabOrigin); + + [DllImport("gdi32.dll", SetLastError = false, CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr BitBlt(IntPtr hDestDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, + int xSrc, int ySrc, int dwRop); + + [DllImport("user32.dll", SetLastError = false, CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + public static extern int FillRect(IntPtr hDC, ref APIRect rect, IntPtr hBrush); + + [DllImport("gdi32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern int GetTextFace(IntPtr hDC, int nCount, string lpFacename); + + [DllImport("gdi32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern int GetTextMetrics(IntPtr hDC, ref GDITextMetric TextMetric); + + [DllImport("gdi32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr CreateFontIndirect([MarshalAs(UnmanagedType.LPStruct)] LogFont LogFont); + + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] + public static extern int GetTabbedTextExtent(IntPtr hDC, string lpString, int nCount, int nTabPositions, + ref int lpnTabStopPositions); + + [DllImport("user32.dll", SetLastError = false, CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + public static extern int InvertRect(IntPtr hDC, ref APIRect rect); + + [DllImport("gdi32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr CreatePen(int nPenStyle, int nWidth, int crColor); + + [DllImport("gdi32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern int SetBrushOrgEx(IntPtr hDC, int x, int y, ref APIPoint p); + + [DllImport("gdi32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr CreatePatternBrush(IntPtr hBMP); + + [DllImport("User32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern int ShowWindow(IntPtr hWnd, short cmdShow); + + [DllImport("gdi32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr MoveToEx(IntPtr hDC, int x, int y, ref APIPoint lpPoint); + + [DllImport("gdi32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr LineTo(IntPtr hDC, int x, int y); + + [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern UInt16 GetAsyncKeyState(int vKey); + + public static bool IsKeyPressed(Keys k) + { + int s = GetAsyncKeyState((int) k); + s = (s & 0x8000) >> 15; + return (s == 1); + } + + + //--------------------------------------- + //helper , return DC of a control + public static IntPtr ControlDC(Control control) + { + return GetDC(control.Handle); + } + + //--------------------------------------- + + //--------------------------------------- + //helper , convert from and to colors from int values + public static int ColorToInt(Color color) + { + return (color.B << 16 | color.G << 8 | color.R); + } + + public static Color IntToColor(int color) + { + int b = (color >> 16) & 0xFF; + int g = (color >> 8) & 0xFF; + int r = (color) & 0xFF; + return Color.FromArgb(r, g, b); + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Win32/NativeSubclasser.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Win32/NativeSubclasser.cs new file mode 100644 index 0000000..be91e1a --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Alsing.SyntaxBox/Win32/NativeSubclasser.cs @@ -0,0 +1,85 @@ +// * +// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com +// * +// * This library is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License 2.1 or later, as +// * published by the Free Software Foundation. See the included license.txt +// * or http://www.gnu.org/copyleft/lesser.html for details. +// * +// * + +using System; +using System.Windows.Forms; + +namespace Alsing.Windows.Forms +{ + + #region params + + public class NativeMessageArgs : EventArgs + { + public bool Cancel; + public Message Message; + } + + public delegate void NativeMessageHandler(object s, NativeMessageArgs e); + + #endregion + + public class NativeSubclasser : NativeWindow + { + public NativeSubclasser() {} + + public NativeSubclasser(Control Target) + { + AssignHandle(Target.Handle); + Target.HandleCreated += Handle_Created; + Target.HandleDestroyed += Handle_Destroyed; + } + + public NativeSubclasser(IntPtr hWnd) + { + AssignHandle(hWnd); + } + + public event NativeMessageHandler Message = null; + + protected virtual void OnMessage(NativeMessageArgs e) + { + if (Message != null) + Message(this, e); + } + + private void Handle_Created(object o, EventArgs e) + { + AssignHandle(((Control) o).Handle); + } + + private void Handle_Destroyed(object o, EventArgs e) + { + ReleaseHandle(); + } + + public void Detatch() + { + // this.ReleaseHandle (); + } + + protected override void WndProc(ref Message m) + { + try + { + var e = new NativeMessageArgs {Message = m, Cancel = false}; + + OnMessage(e); + + if (!e.Cancel) + base.WndProc(ref m); + } + catch (Exception x) + { + Console.WriteLine(x.Message); + } + } + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Form1.Designer.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Form1.Designer.cs new file mode 100644 index 0000000..d43bb23 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Form1.Designer.cs @@ -0,0 +1,957 @@ +namespace HelloWorld +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.syntaxBoxControl1 = new Alsing.Windows.Forms.SyntaxBoxControl(); + this.syntaxDocument1 = new Alsing.SourceCode.SyntaxDocument(this.components); + this.SuspendLayout(); + // + // syntaxBoxControl1 + // + this.syntaxBoxControl1.ActiveView = Alsing.Windows.Forms.ActiveView.BottomRight; + this.syntaxBoxControl1.AutoListPosition = null; + this.syntaxBoxControl1.AutoListSelectedText = "a123"; + this.syntaxBoxControl1.AutoListVisible = false; + this.syntaxBoxControl1.BackColor = System.Drawing.Color.White; + this.syntaxBoxControl1.BorderStyle = Alsing.Windows.Forms.BorderStyle.None; + this.syntaxBoxControl1.CopyAsRTF = false; + this.syntaxBoxControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.syntaxBoxControl1.Document = this.syntaxDocument1; + this.syntaxBoxControl1.FontName = "Courier new"; + this.syntaxBoxControl1.FontSize = 12F; + this.syntaxBoxControl1.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.syntaxBoxControl1.InfoTipCount = 1; + this.syntaxBoxControl1.InfoTipPosition = null; + this.syntaxBoxControl1.InfoTipSelectedIndex = 1; + this.syntaxBoxControl1.InfoTipVisible = false; + this.syntaxBoxControl1.Location = new System.Drawing.Point(0, 0); + this.syntaxBoxControl1.LockCursorUpdate = false; + this.syntaxBoxControl1.Name = "syntaxBoxControl1"; + this.syntaxBoxControl1.ShowScopeIndicator = false; + this.syntaxBoxControl1.Size = new System.Drawing.Size(844, 592); + this.syntaxBoxControl1.SmoothScroll = false; + this.syntaxBoxControl1.SplitviewH = -4; + this.syntaxBoxControl1.SplitviewV = -4; + this.syntaxBoxControl1.TabGuideColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(243)))), ((int)(((byte)(234))))); + this.syntaxBoxControl1.TabIndex = 0; + this.syntaxBoxControl1.Text = "syntaxBoxControl1"; + this.syntaxBoxControl1.WhitespaceColor = System.Drawing.SystemColors.ControlDark; + // + // syntaxDocument1 + // + this.syntaxDocument1.Lines = new string[] { + "// *\r", + "// * Copyright (C) 2008 Roger Alsing : http://www.RogerAlsing.com\r", + "// *\r", + "// * This library is free software; you can redistribute it and/or modify it\r", + "// * under the terms of the GNU Lesser General Public License 2.1 or later, as\r", + "// * published by the Free Software Foundation. See the included license.txt\r", + "// * or http://www.gnu.org/copyleft/lesser.html for details.\r", + "// *\r", + "// *\r", + "//no parsing , just splitting and making whitespace possible\r", + "//1 sec to finnish ca 10000 rows\r", + "\r", + "namespace Alsing.SourceCode.SyntaxDocumentParsers\r", + "{\r", + " /// \r", + " /// \r", + " /// \r", + " public sealed class DefaultParser : IParser\r", + " {\r", + " private SyntaxDefinition mSyntaxDefinition;\r", + " private long Version;\r", + "\r", + " /// \r", + " /// \r", + " /// \r", + " public DefaultParser()\r", + " {\r", + " mSyntaxDefinition = null;\r", + " }\r", + "\r", + " #region IParser Members\r", + "\r", + " /// \r", + " /// \r", + " /// \r", + " public SyntaxDefinition SyntaxDefinition\r", + " {\r", + " get { return mSyntaxDefinition; }\r", + " set\r", + " {\r", + " mSyntaxDefinition = value;\r", + "\r", + " if (mSyntaxDefinition == null)\r", + " {\r", + " var l = new SyntaxDefinition();\r", + " l.mainSpanDefinition = new SpanDefinition(l) {MultiLine = tru" + + "e};\r", + " mSyntaxDefinition = l;\r", + " }\r", + "\r", + " Version = long.MinValue;\r", + " mSyntaxDefinition.Version = long.MinValue + 1;\r", + " Document.ReParse();\r", + " }\r", + " }\r", + "\r", + " /// \r", + " /// \r", + " /// \r", + " /// \r", + " /// \r", + " public void ParseRow(int index, bool ParseKeywords)\r", + " {\r", + " InternalParseLine(index, ParseKeywords);\r", + " if (SyntaxDefinition != null)\r", + " {\r", + " if (Version != SyntaxDefinition.Version)\r", + " {\r", + " SyntaxDefinition.UpdateLists();\r", + " Version = SyntaxDefinition.Version;\r", + " }\r", + " }\r", + "\r", + "\r", + " Document.InvokeRowParsed(Document[index]);\r", + " }\r", + "\r", + " #endregion\r", + "\r", + " #region PUBLIC PROPERTY SEPARATORS\r", + "\r", + " public string Separators\r", + " {\r", + " get { return SyntaxDefinition.Separators; }\r", + " set { SyntaxDefinition.Separators = value; }\r", + " }\r", + "\r", + " #endregion\r", + "\r", + " #region Optimerat och klart\r", + "\r", + " // ska anropas om \"is same but different\" är true\r", + "\r", + " /// \r", + " /// \r", + " /// \r", + " public SyntaxDocument Document { get; set; }\r", + "\r", + " /// \r", + " /// \r", + " /// \r", + " /// \r", + " public void Init(string SyntaxFile)\r", + " {\r", + " try\r", + " {\r", + " if (!SyntaxFile.ToLowerInvariant().EndsWith(\".syn\")\r", + " )\r", + " SyntaxFile += \".syn\";\r", + "\r", + "\r", + " SyntaxDefinition = new SyntaxDefinitionLoader().Load(SyntaxFile);" + + "\r", + " }\r", + " catch {}\r", + " }\r", + "\r", + " public void Init(string syntaxFile, string separators)\r", + " {\r", + " try\r", + " {\r", + " if (!syntaxFile.ToLowerInvariant().EndsWith(\".syn\")\r", + " )\r", + " syntaxFile += \".syn\";\r", + "\r", + "\r", + " SyntaxDefinition = new SyntaxDefinitionLoader().Load(syntaxFile, " + + "separators);\r", + " }\r", + " catch {}\r", + " }\r", + "\r", + " /// \r", + " /// \r", + " /// \r", + " /// \r", + " public void Init(SyntaxDefinition syntaxDefinition)\r", + " {\r", + " SyntaxDefinition = syntaxDefinition;\r", + " }\r", + "\r", + " /// \r", + " /// \r", + " /// \r", + " /// \r", + " public void ParsePreviewLine(int RowIndex)\r", + " {\r", + " Row Row = Document[RowIndex];\r", + " Row.Clear();\r", + " Row.Add(Row.Text);\r", + " Row.RowState = RowState.NotParsed;\r", + " }\r", + "\r", + " private void MakeSame(int RowIndex)\r", + " {\r", + " Row row = Document[RowIndex];\r", + "\r", + " //copy back the old segments to this line...\r", + " Span seg = row.endSpan;\r", + " Span seg2 = Document[RowIndex + 1].startSpan;\r", + " while (seg != null)\r", + " {\r", + " foreach (Word w in row)\r", + " {\r", + " if (w.Span == seg)\r", + " {\r", + " if (w.Span.StartWord == w)\r", + " seg2.StartWord = w;\r", + "\r", + " if (w.Span.EndWord == w)\r", + " seg2.EndWord = w;\r", + "\r", + " w.Span = seg2;\r", + " }\r", + " }\r", + "\r", + " if (seg == row.startSpan)\r", + " row.startSpan = seg2;\r", + "\r", + " if (seg == row.endSpan)\r", + " row.endSpan = seg2;\r", + "\r", + "\r", + " if (row.startSpans.IndexOf(seg) >= 0)\r", + " row.startSpans[row.startSpans.IndexOf(seg)] = seg2;\r", + "\r", + " if (row.endSpans.IndexOf(seg) >= 0)\r", + " row.endSpans[row.endSpans.IndexOf(seg)] = seg2;\r", + "\r", + " seg = seg.Parent;\r", + " seg2 = seg2.Parent;\r", + " }\r", + " row.SetExpansionSegment();\r", + " }\r", + "\r", + " //om denna är true\r", + " // sÃ¥ ska INTE nästa rad parse\'as , utan denna ska fixas sÃ¥ den blir som " + + "den förra... (kopiera span)\r", + " private bool IsSameButDifferent(int RowIndex, Span oldStartSpan)\r", + " {\r", + " //is this the last row ? , if so , bailout\r", + " if (RowIndex >= Document.Count - 1)\r", + " return false;\r", + "\r", + " Row row = Document[RowIndex];\r", + " Span seg = row.endSpan;\r", + " Span oldEndSpan = Document[RowIndex + 1].startSpan;\r", + " Span oseg = oldEndSpan;\r", + "\r", + " bool diff = false;\r", + "\r", + " while (seg != null)\r", + " {\r", + " if (oseg == null)\r", + " {\r", + " diff = true;\r", + " break;\r", + " }\r", + "\r", + " //Id1+=seg.spanDefinition.GetHashCode ().ToString (System.Globali" + + "zation.CultureInfo.InvariantCulture);\r", + " if (seg.spanDefinition != oseg.spanDefinition)\r", + " {\r", + " diff = true;\r", + " break;\r", + " }\r", + "\r", + " if (seg.Parent != oseg.Parent)\r", + " {\r", + " diff = true;\r", + " break;\r", + " }\r", + "\r", + " seg = seg.Parent;\r", + " oseg = oseg.Parent;\r", + " }\r", + "\r", + "\r", + " if (diff || row.startSpan != oldStartSpan)\r", + " return false;\r", + "\r", + " return true;\r", + " }\r", + "\r", + " #endregion\r", + "\r", + " private ScanResultWord GetNextWord(string Text, Span currentSpan, int\r", + " " + + " StartPos, ref bool HasComplex)\r", + " {\r", + " SpanDefinition spanDefinition = currentSpan.spanDefinition;\r", + "\r", + " #region ComplexFind\r", + "\r", + " int BestComplexPos = - 1;\r", + " Pattern BestComplexPattern = null;\r", + " string BestComplexToken = \"\";\r", + " var complexword = new ScanResultWord();\r", + " if (HasComplex)\r", + " {\r", + " foreach (Pattern pattern in spanDefinition.ComplexPatterns)\r", + " {\r", + " PatternScanResult scanres = pattern.IndexIn(Text, StartPos,\r", + " pattern.Parent.Ca" + + "seSensitive, Separators);\r", + " if (scanres.Token != \"\")\r", + " {\r", + " if (scanres.Index < BestComplexPos || BestComplexPos == -" + + " 1)\r", + " {\r", + " BestComplexPos = scanres.Index;\r", + " BestComplexPattern = pattern;\r", + " BestComplexToken = scanres.Token;\r", + " }\r", + " }\r", + " }\r", + "\r", + "\r", + " if (BestComplexPattern != null)\r", + " {\r", + " complexword.HasContent = true;\r", + " complexword.ParentList = BestComplexPattern.Parent;\r", + " complexword.Pattern = BestComplexPattern;\r", + " complexword.Position = BestComplexPos;\r", + " complexword.Token = BestComplexToken;\r", + " }\r", + " else\r", + " {\r", + " HasComplex = false;\r", + " }\r", + " }\r", + "\r", + " #endregion\r", + "\r", + " #region SimpleFind \r", + "\r", + " var simpleword = new ScanResultWord();\r", + " for (int i = StartPos; i < Text.Length; i++)\r", + " {\r", + " //bailout if we found a complex pattern before this char pos\r", + " if (i > complexword.Position && complexword.HasContent)\r", + " break;\r", + "\r", + " #region 3+ char pattern\r", + "\r", + " if (i <= Text.Length - 3)\r", + " {\r", + " string key = Text.Substring(i, 3).ToLowerInvariant();\r", + " var patterns2 = (PatternCollection)\r", + " spanDefinition.LookupTable[key];\r", + " //ok , there are patterns that start with this char\r", + " if (patterns2 != null)\r", + " {\r", + " foreach (Pattern pattern in patterns2)\r", + " {\r", + " int len = pattern.StringPattern.Length;\r", + " if (i + len > Text.Length)\r", + " continue;\r", + "\r", + " char lastpatternchar = char.ToLower(pattern.StringPat" + + "tern[len -\r", + " " + + " 1]);\r", + " char lasttextchar = char.ToLower(Text[i + len - 1]);\r" + + "", + "\r", + " #region Case Insensitive\r", + "\r", + " if (lastpatternchar == lasttextchar)\r", + " {\r", + " if (!pattern.IsKeyword || (pattern.IsKeyword &&\r", + " pattern.HasSeparators(" + + "Text, i)))\r", + " {\r", + " if (!pattern.Parent.CaseSensitive)\r", + " {\r", + " string s = Text.Substring(i, len).ToLower" + + "Invariant();\r", + "\r", + " if (s == pattern.StringPattern.ToLowerInv" + + "ariant())\r", + " {\r", + " simpleword.HasContent = true;\r", + " simpleword.ParentList = pattern.Paren" + + "t;\r", + " simpleword.Pattern = pattern;\r", + " simpleword.Position = i;\r", + " simpleword.Token = pattern.Parent.Nor" + + "malizeCase ? pattern.StringPattern : Text.Substring(i, len);\r", + " break;\r", + " }\r", + " }\r", + " else\r", + " {\r", + " string s = Text.Substring(i, len);\r", + "\r", + " if (s == pattern.StringPattern)\r", + " {\r", + " simpleword.HasContent = true;\r", + " simpleword.ParentList = pattern.Paren" + + "t;\r", + " simpleword.Pattern = pattern;\r", + " simpleword.Position = i;\r", + " simpleword.Token = pattern.StringPatt" + + "ern;\r", + " break;\r", + " }\r", + " }\r", + " }\r", + " }\r", + " }\r", + "\r", + " #endregion\r", + " }\r", + " }\r", + "\r", + " #endregion\r", + "\r", + " if (simpleword.HasContent)\r", + " break;\r", + "\r", + " #region single char pattern\r", + "\r", + " char c = Text[i];\r", + " var patterns = (PatternCollection) spanDefinition.LookupTable[c];" + + "\r", + " if (patterns != null)\r", + " {\r", + " //ok , there are patterns that start with this char\r", + " foreach (Pattern pattern in patterns)\r", + " {\r", + " int len = pattern.StringPattern.Length;\r", + " if (i + len > Text.Length)\r", + " continue;\r", + "\r", + " char lastpatternchar = pattern.StringPattern[len - 1];\r", + " char lasttextchar = Text[i + len - 1];\r", + "\r", + " if (!pattern.Parent.CaseSensitive)\r", + " {\r", + " #region Case Insensitive\r", + "\r", + " if (char.ToLower(lastpatternchar) == char.ToLower(las" + + "ttextchar))\r", + " {\r", + " if (!pattern.IsKeyword || (pattern.IsKeyword &&\r", + " pattern.HasSeparators(" + + "Text, i)))\r", + " {\r", + " string s = Text.Substring(i, len).ToLowerInva" + + "riant();\r", + "\r", + " if (s == pattern.StringPattern.ToLowerInvaria" + + "nt())\r", + " {\r", + " simpleword.HasContent = true;\r", + " simpleword.ParentList = pattern.Parent;\r", + " simpleword.Pattern = pattern;\r", + " simpleword.Position = i;\r", + " simpleword.Token = pattern.Parent.Normali" + + "zeCase ? pattern.StringPattern : Text.Substring(i, len);\r", + " break;\r", + " }\r", + " }\r", + " }\r", + "\r", + " #endregion\r", + " }\r", + " else\r", + " {\r", + " #region Case Sensitive\r", + "\r", + " if (lastpatternchar == lasttextchar)\r", + " {\r", + " if (!pattern.IsKeyword || (pattern.IsKeyword &&\r", + " pattern.HasSeparators(" + + "Text, i)))\r", + " {\r", + " string s = Text.Substring(i, len);\r", + "\r", + " if (s == pattern.StringPattern)\r", + " {\r", + " simpleword.HasContent = true;\r", + " simpleword.ParentList = pattern.Parent;\r", + " simpleword.Pattern = pattern;\r", + " simpleword.Position = i;\r", + " simpleword.Token = pattern.StringPattern;" + + "\r", + " break;\r", + " }\r", + " }\r", + " }\r", + "\r", + " #endregion\r", + " }\r", + " }\r", + "\r", + " if (simpleword.HasContent)\r", + " break;\r", + " }\r", + "\r", + " #endregion\r", + " }\r", + "\r", + " #endregion\r", + "\r", + " if (complexword.HasContent && simpleword.HasContent)\r", + " {\r", + " if (simpleword.Position == complexword.Position)\r", + " {\r", + " if (simpleword.Token.Length >= complexword.Token.Length)\r", + " return simpleword;\r", + " return complexword;\r", + " }\r", + "\r", + " if (simpleword.Position < complexword.Position)\r", + " return simpleword;\r", + "\r", + " if (simpleword.Position > complexword.Position)\r", + " return complexword;\r", + " }\r", + "\r", + " if (simpleword.HasContent)\r", + " return simpleword;\r", + "\r", + " if (complexword.HasContent)\r", + " return complexword;\r", + "\r", + "\r", + " return new ScanResultWord();\r", + " }\r", + "\r", + "\r", + " private void ParseText(Row Row, Span currentSpan, string Text)\r", + " {\r", + " int CurrentPosition = 0;\r", + " bool HasComplex = true;\r", + " while (true)\r", + " {\r", + " ScanResultWord Word = GetNextWord(Text, currentSpan, CurrentPosit" + + "ion,\r", + " ref HasComplex);\r", + "\r", + " if (!Word.HasContent)\r", + " {\r", + " ParseTools.AddString(Text.Substring(CurrentPosition), Row,\r", + " currentSpan.spanDefinition.Style, curren" + + "tSpan);\r", + " break;\r", + " }\r", + " ParseTools.AddString(Text.Substring(CurrentPosition, Word.Positio" + + "n -\r", + " CurrentPosit" + + "ion), Row,\r", + " currentSpan.spanDefinition.Style, currentSpa" + + "n);\r", + " ParseTools.AddPatternString(Word.Token, Row, Word.Pattern,\r", + " Word.ParentList.Style, currentSpan,\r", + " false);\r", + " CurrentPosition = Word.Position + Word.Token.Length;\r", + " }\r", + " }\r", + "\r", + " private void InternalParseLine(int index, bool ParseKeywords)\r", + " {\r", + " if (mSyntaxDefinition == null)\r", + " return;\r", + "\r", + " //\r", + " //\t\t\tif (ParseKeywords)\r", + " //\t\t\t\treturn;\r", + " //\t\t\tParseKeywords=true;\r", + " SyntaxDocument doc = Document;\r", + " Row Row = doc[index];\r", + " Span oldEndSpan = Row.endSpan;\r", + " Span oldStartSpan = Row.startSpan;\r", + " bool Fold = !Row.IsCollapsed;\r", + "\r", + "\r", + " if (Row.IsCollapsedEndPart)\r", + " {\r", + " //Row.expansion_EndSpan.Expanded = true;\r", + " //Row.expansion_EndSpan.EndRow = null;\r", + " Row.expansion_EndSpan.EndWord = null;\r", + " }\r", + "\r", + "\r", + " //set startsegment for this row\r", + " if (index > 0)\r", + " {\r", + " Row.startSpan = Document[index - 1].endSpan;\r", + " }\r", + " else\r", + " {\r", + " if (Row.startSpan == null)\r", + " {\r", + " Row.startSpan = new Span(Row) {spanDefinition = mSyntaxDefini" + + "tion.mainSpanDefinition};\r", + " }\r", + " }\r", + "\r", + " int CurrentPosition = 0;\r", + " Span currentSpan = Row.startSpan;\r", + "\r", + "\r", + " //kör tills vi kommit till slutet av raden..\r", + " Row.endSpans.Clear();\r", + " Row.startSpans.Clear();\r", + " Row.Clear();\r", + " //\t\tbool HasEndSegment=false;\r", + "\r", + " while (true)\r", + " {\r", + " ScanResultSegment ChildSegment = GetNextChildSegment(Row,\r", + " currentSpan," + + " CurrentPosition);\r", + " ScanResultSegment EndSegment = GetEndSegment(Row, currentSpan,\r", + " CurrentPosition);\r", + "\r", + " if ((EndSegment.HasContent && ChildSegment.HasContent &&\r", + " EndSegment.Position <= ChildSegment.Position) ||\r", + " (EndSegment.HasContent && ChildSegment.HasContent == false))\r" + + "", + " {\r", + " //this is an end span\r", + "\r", + " if (ParseKeywords)\r", + " {\r", + " string Text = Row.Text.Substring(CurrentPosition,\r", + " EndSegment.Position - Cu" + + "rrentPosition);\r", + " ParseText(Row, currentSpan, Text);\r", + " }\r", + "\r", + " Span oldseg = currentSpan;\r", + " while (currentSpan != EndSegment.span)\r", + " {\r", + " Row.endSpans.Add(currentSpan);\r", + " currentSpan = currentSpan.Parent;\r", + " }\r", + " Row.endSpans.Add(currentSpan);\r", + "\r", + " TextStyle st2 = currentSpan.Scope.Style;\r", + "\r", + " ParseTools.AddPatternString(EndSegment.Token, Row, EndSegment" + + ".Pattern,\r", + " st2, currentSpan, false);\r", + " while (oldseg != EndSegment.span)\r", + " {\r", + " oldseg.EndRow = Row;\r", + " oldseg.EndWord = Row[Row.Count - 1];\r", + " oldseg = oldseg.Parent;\r", + " }\r", + "\r", + " currentSpan.EndRow = Row;\r", + " currentSpan.EndWord = Row[Row.Count - 1];\r", + "\r", + "\r", + " if (currentSpan.Parent != null)\r", + " currentSpan = currentSpan.Parent;\r", + "\r", + " CurrentPosition = EndSegment.Position + EndSegment.Token.Leng" + + "th;\r", + " }\r", + " else if (ChildSegment.HasContent)\r", + " {\r", + " //this is a child block\r", + "\r", + " if (ParseKeywords)\r", + " {\r", + " string Text = Row.Text.Substring(CurrentPosition,\r", + " ChildSegment.Position - " + + "CurrentPosition);\r", + " //TextStyle st=currentSpan.spanDefinition.Style;\r", + " ParseText(Row, currentSpan, Text);\r", + " //ParseTools.AddString (Text,Row,st,currentSpan);\r", + " }\r", + "\r", + "\r", + " var NewSeg = new Span\r", + " {\r", + " Parent = currentSpan,\r", + " spanDefinition = ChildSegment.spanDefinition" + + ",\r", + " Scope = ChildSegment.Scope\r", + " };\r", + "\r", + " Row.startSpans.Add(NewSeg);\r", + "\r", + " TextStyle st2 = NewSeg.Scope.Style;\r", + " ParseTools.AddPatternString(ChildSegment.Token, Row,\r", + " ChildSegment.Pattern, st2, NewSeg" + + ", false);\r", + " NewSeg.StartRow = Row;\r", + " NewSeg.StartWord = Row[Row.Count - 1];\r", + "\r", + "\r", + " currentSpan = NewSeg;\r", + " CurrentPosition = ChildSegment.Position + ChildSegment.Token." + + "Length;\r", + "\r", + " if (ChildSegment.Scope.spawnSpanOnStart != null)\r", + " {\r", + " var SpawnSeg = new Span\r", + " {\r", + " Parent = NewSeg,\r", + " spanDefinition = ChildSegment.Scope.sp" + + "awnSpanOnStart,\r", + " Scope = new Scope(),\r", + " StartWord = NewSeg.StartWord\r", + " };\r", + " Row.startSpans.Add(SpawnSeg);\r", + " currentSpan = SpawnSeg;\r", + " }\r", + " }\r", + " else\r", + " {\r", + " if (CurrentPosition < Row.Text.Length)\r", + " {\r", + " if (ParseKeywords)\r", + " {\r", + " //we did not find a childblock nor an endblock , just" + + " output the last pice of text\r", + " string Text = Row.Text.Substring(CurrentPosition);\r", + " //TextStyle st=currentSpan.spanDefinition.Style;\t\r", + " ParseText(Row, currentSpan, Text);\r", + " //ParseTools.AddString (Text,Row,st,currentSpan);\r", + " }\r", + " }\r", + " break;\r", + " }\r", + " }\r", + "\r", + " while (!currentSpan.spanDefinition.MultiLine)\r", + " {\r", + " Row.endSpans.Add(currentSpan);\r", + " currentSpan = currentSpan.Parent;\r", + " }\r", + "\r", + " Row.endSpan = currentSpan;\r", + " Row.SetExpansionSegment();\r", + "\r", + " Row.RowState = ParseKeywords ? RowState.AllParsed : RowState.SpanPars" + + "ed;\r", + "\r", + " if (IsSameButDifferent(index, oldStartSpan))\r", + " {\r", + " MakeSame(index);\r", + " //if (!IsSameButDifferent(index))\r", + " //\tSystem.Diagnostics.Debugger.Break();\r", + " }\r", + "\r", + " if (Row.CanFold)\r", + " Row.expansion_StartSpan.Expanded = Fold;\r", + "\r", + " //dont flag next line as needs parsing if only parsing keywords\r", + " if (!ParseKeywords)\r", + " {\r", + " if (oldEndSpan != null)\r", + " {\r", + " if (Row.endSpan != oldEndSpan && index <= Document.Count - 2)" + + "\r", + " {\r", + " //if (Row.CanFold)\r", + " //\tRow.expansion_StartSpan.Expanded = true;\r", + " Document[index + 1].AddToParseQueue();\r", + " Document.NeedResetRows = true;\r", + " }\r", + " }\r", + " else if (index <= Document.Count - 2)\r", + " {\r", + " //if (Row.CanFold)\r", + " //\tRow.expansion_StartSpan.Expanded = true;\r", + " Document[index + 1].AddToParseQueue();\r", + " Document.NeedResetRows = true;\r", + " }\r", + " }\r", + "\r", + " if (oldEndSpan != null)\r", + " {\r", + " //expand span if this line dont have an end word\r", + " if (oldEndSpan.EndWord == null)\r", + " oldEndSpan.Expanded = true;\r", + " }\r", + " }\r", + "\r", + "\r", + " private ScanResultSegment GetEndSegment(Row Row, Span currentSpan,\r", + " int StartPos)\r", + " {\r", + " //this row has no text , just bail out...\r", + " if (StartPos >= Row.Text.Length || currentSpan.Scope == null)\r", + " return new ScanResultSegment();\r", + "\r", + " var Result = new ScanResultSegment {HasContent = false, IsEndSegment " + + "= false};\r", + "\r", + "\r", + " //-------------------------------------------------------------------" + + "-------------\r", + " //scan for childblocks\r", + " //scan each scope in each childblock\r", + "\r", + " Span seg = currentSpan;\r", + "\r", + " while (seg != null)\r", + " {\r", + " if (seg == currentSpan || seg.spanDefinition.TerminateChildren)\r", + " {\r", + " foreach (Pattern end in seg.Scope.EndPatterns)\r", + " {\r", + " PatternScanResult psr = end.IndexIn(Row.Text, StartPos,\r", + " seg.Scope.CaseSensiti" + + "ve, Separators);\r", + " int CurrentPosition = psr.Index;\r", + " if (psr.Token != \"\")\r", + " {\r", + " if ((psr.Index < Result.Position && Result.HasContent" + + ") ||\r", + " !Result.HasContent)\r", + " {\r", + " //we found a better match\r", + " //store this new match\r", + " Result.Pattern = end;\r", + " Result.Position = CurrentPosition;\r", + " Result.Token = psr.Token;\r", + " Result.HasContent = true;\r", + " Result.span = seg;\r", + " Result.Scope = null;\r", + "\r", + "\r", + " if (!end.IsComplex)\r", + " {\r", + " if (seg.Scope.NormalizeCase)\r", + " if (!seg.Scope.Start.IsComplex)\r", + " Result.Token = end.StringPattern;\r", + " }\r", + " }\r", + " }\r", + " }\r", + " }\r", + " seg = seg.Parent;\r", + " }\r", + "\r", + " //no result , return new ScanResultSegment();\r", + " if (!Result.HasContent)\r", + " return new ScanResultSegment();\r", + "\r", + " return Result;\r", + " }\r", + "\r", + " private ScanResultSegment GetNextChildSegment(Row Row, Span\r", + " currentSpan, i" + + "nt StartPos)\r", + " {\r", + " //this row has no text , just bail out...\r", + " if (StartPos >= Row.Text.Length)\r", + " return new ScanResultSegment();\r", + "\r", + "\r", + " var Result = new ScanResultSegment {HasContent = false, IsEndSegment " + + "= false};\r", + "\r", + "\r", + " foreach (SpanDefinition ChildBlock in currentSpan.spanDefinition.chil" + + "dSpanDefinitions)\r", + " {\r", + " //scan each scope in each childblock\r", + " foreach (Scope Scope in ChildBlock.ScopePatterns)\r", + " {\r", + " PatternScanResult psr = Scope.Start.IndexIn(Row.Text, StartPo" + + "s,\r", + " Scope.CaseSensiti" + + "ve, Separators);\r", + " int CurrentPosition = psr.Index;\r", + " if ((!Result.HasContent || CurrentPosition < Result.Position)" + + " &&\r", + " psr.Token != \"\")\r", + " {\r", + " //we found a better match\r", + " //store this new match\r", + " Result.Pattern = Scope.Start;\r", + " Result.Position = CurrentPosition;\r", + " Result.Token = psr.Token;\r", + " Result.HasContent = true;\r", + " Result.spanDefinition = ChildBlock;\r", + " Result.Scope = Scope;\r", + "\r", + " if (Scope.NormalizeCase)\r", + " if (!Scope.Start.IsComplex)\r", + " Result.Token = Scope.Start.StringPattern;\r", + " }\r", + " }\r", + " }\r", + "\r", + "\r", + " //no result , new ScanResultSegment();\r", + " if (!Result.HasContent)\r", + " return new ScanResultSegment();\r", + "\r", + " return Result;\r", + " }\r", + " }\r", + "}"}; + this.syntaxDocument1.MaxUndoBufferSize = 1000; + this.syntaxDocument1.Modified = false; + this.syntaxDocument1.SyntaxFile = "C:\\Puzzle\\SyntaxBox\\Puzzle.Syntaxbox.DefaultSyntaxFiles\\CSharp.syn"; + this.syntaxDocument1.UndoStep = 0; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(844, 592); + this.Controls.Add(this.syntaxBoxControl1); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + + } + + #endregion + + private Alsing.Windows.Forms.SyntaxBoxControl syntaxBoxControl1; + private Alsing.SourceCode.SyntaxDocument syntaxDocument1; + } +} + diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Form1.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Form1.cs new file mode 100644 index 0000000..9ca1581 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Form1.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace HelloWorld +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Form1.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Form1.resx new file mode 100644 index 0000000..af2e293 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/HelloWorld.csproj b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/HelloWorld.csproj new file mode 100644 index 0000000..6612dc8 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/HelloWorld.csproj @@ -0,0 +1,95 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {FCF83FF2-7D05-4301-9CC0-09234A9ED0DC} + WinExe + Properties + HelloWorld + HelloWorld + v2.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + 3.5 + + + 3.5 + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + Designer + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + {19EF75B2-B414-4EB0-9486-160FAF93E62C} + Alsing.SyntaxBox.NET + + + + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Program.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Program.cs new file mode 100644 index 0000000..f0009a3 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Windows.Forms; + +namespace HelloWorld +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/AssemblyInfo.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..08654bd --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("HelloWorld")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Precio Systemutveckling AB")] +[assembly: AssemblyProduct("HelloWorld")] +[assembly: AssemblyCopyright("Copyright © Precio Systemutveckling AB 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3d6e90b9-66dc-4780-9aef-40912bc86993")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Resources.Designer.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Resources.Designer.cs new file mode 100644 index 0000000..fc6eccd --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.3031 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace HelloWorld.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HelloWorld.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Resources.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Settings.Designer.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Settings.Designer.cs new file mode 100644 index 0000000..a58fcaf --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.3031 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace HelloWorld.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Settings.settings b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/HelloWorld/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/App.ico b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/App.ico new file mode 100644 index 0000000000000000000000000000000000000000..3a5525fd794f7a7c5c8e6187f470ea3af38cd2b6 GIT binary patch literal 1078 zcmeHHJr05}7=1t!Hp3A*8IHkVf+j?-!eHY14Gtcw1Eb*_9>Bq^zETJ@GKj{_2j4$w zo9}xCh!8{T3=X##Skq>ikMjsvB|y%crWBM2iW(4pI}c%z6%lW!=~4v77#3{z!dmB1 z__&l)-{KUYR+|8|;wB^R|9ET$J@(@=#rd^=)qs85?vAy(PSF5CyNkus435LVkZ$rj zNw|JG-P7^hF<(;#o*Vk}5R#e|^13tBbQkeF?djULtvqyxd3<{9 literal 0 HcmV?d00001 diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/AssemblyInfo.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/AssemblyInfo.cs new file mode 100644 index 0000000..177a4f0 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Caption.ico b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Caption.ico new file mode 100644 index 0000000000000000000000000000000000000000..203f2fc8a0882f9872ae7bc557b203ba58134dfb GIT binary patch literal 1406 zcmY+EziS&Y6vtm^O3iUY>=I8mwDHocr^NwJ$>tEq60jz3qDv+R!kG@9vbInYP^S!S zp+lGa1)e%InvPFD`s2<|y7#rD@8_QGPGpI5Wku5Q^07#hs~1F+ zo)Jq@qfHl!{^5G*AsvbElhJ6=(Q+x1$wVgKCUX1rqbx5kORZLuJkOJpl%gnP zZEa1~*VkolZ%=l1c4TvNQ#Lj>Wb{g9cUR@DoQvKB`EveK&abcK&8N>88Nv~s2#eI9 z88m}tqNa->4&9+UbcgQH<1~-%(LISr_vmyI&;xov4+sHW$(39~ayGOEf5SqCNk&wX zJ&l3Ez+hl7FeD@x3=9Sa1A~DfVZvZwFfbSx3=9b!1_OhE!N6c(Fp36;fx|=&)l>l# z`gnRG5a{uiVR4u{j2w$PSW+4I({bToaj>Maz~SI$bfczZ^rQseDm@|b!IJWL*M&!3(}Jl-Dfv>nMC9e1R3+U#3O#MyMrsi73$O(^0)A<0BL_7IaD>Rgjiv2oQh+7E5`YL8 zrbhslz{J3yfDmBeN3afi5?~3j9*HGB4RIIHU{Dwo28BUkP#DtV1Vey9VNe(X3@k%1 z9tMR$VNe)Ynm~s^VNe(p0L4GBm@-irFKFlTwKWI<)vI*UCDGhmHB)wcXxMk`%C5h$qDcAi0a07Aa<;mvbb(cRWc6V z>H8*TS-yWT$n#logUZoqRHdC|!*V$5Bw=97cG0k0K))`p4y&uQVwtIHa zK^UyIm||P2Gg6L~%C?Iiwmqyb{3Fj`AD$xR`D|F)Y)U>@+(14U7I|tG + /// Summary description for EditForm. + /// + public class EditForm : Form + { + private ToolBarButton btnFolding; + private ToolBarButton btnSettings; + private ToolBarButton btnTabGuides; + private ToolBarButton btnWhitespace; + private IContainer components; + public Document Doc; + private ImageList imlIcons; + public SyntaxBoxControl sBox; + public SyntaxDocument sDoc; + private StatusBar statusBar1; + private StatusBarPanel statusBarPanel1; + private StatusBarPanel statusBarPanel2; + private StatusBarPanel statusBarPanel3; + + private SyntaxDocument syntaxDocument1; + private ToolBar tbrSettings; + + public EditForm() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + Doc = new Document {Title = "Untitled"}; + sBox.Document = sDoc; + Text = Doc.Title; + } + + //create an EditForm and attatch our opened document and tell the parser to use the given syntax. + public EditForm(Document Document, SyntaxDefinition SyntaxDefinition) + { + InitializeComponent(); + + Doc = Document; + sBox.Document = sDoc; + sBox.Document.Parser.Init(SyntaxDefinition); + sBox.Document.Text = Document.Text; + Text = Doc.Title; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + //event fired when the caret moves + + //event fired when the modified flag of the document changes (eg if you undo every change , the modified flag will be reset + private void sDoc_ModifiedChanged(object sender, EventArgs e) + { + string s = ""; + if (sDoc.Modified) + s = "*"; + + Text = Doc.Title + s; + statusBar1.Panels[1].Text = "Undo buffer :\t" + sDoc.UndoStep; + //show number of steps in the undostack in one of the panels in the statusbar + } + + //event fired when the content is modified + private void sDoc_Change(object sender, EventArgs e) + { + statusBar1.Panels[1].Text = "Undo buffer :\t" + sDoc.UndoStep; + } + + private void tbrSettings_ButtonClick(object sender, ToolBarButtonClickEventArgs e) + { + ToolBarButton tbb = e.Button; + + if (tbb == btnFolding) + { + sDoc.Folding = tbb.Pushed; //toggle folding + } + + if (tbb == btnTabGuides) + { + sBox.ShowTabGuides = tbb.Pushed; //toggle tabguides + } + + if (tbb == btnWhitespace) + { + sBox.ShowWhitespace = tbb.Pushed; //toggle visible whitespace + } + + if (tbb == btnSettings) + { + var sf = new SettingsForm(sBox); //show a settings form + sf.ShowDialog(); + } + } + + + //save the content of the editor + public void SaveAs(string FileName) + { + try + { + var fs = new StreamWriter(FileName, false, Encoding.Default); + fs.Write(sDoc.Text); + fs.Flush(); + fs.Close(); + sDoc.SaveRevisionMark(); + } + catch (Exception x) + { + MessageBox.Show(x.Message); + } + } + + //occurs when a form is about to be closed + private void EditForm_Closing(object sender, CancelEventArgs e) + { + if (sDoc.Modified) + { + DialogResult res = MessageBox.Show("Save changes to " + Doc.Title, "SyntaxBox", + MessageBoxButtons.YesNoCancel); + if (res == DialogResult.Cancel) + { + e.Cancel = true; + return; + } + if (res == DialogResult.No) + { + e.Cancel = false; + return; + } + if (res == DialogResult.Yes) + { + if (Doc.Path != "") + { + SaveAs(Doc.Path); + } + else + { + var mp = (MDIParent) MdiParent; + mp.ShowSaveDialog(this); + } + e.Cancel = false; + return; + } + } + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditForm)); + this.statusBar1 = new System.Windows.Forms.StatusBar(); + this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel(); + this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel(); + this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel(); + this.sDoc = new Alsing.SourceCode.SyntaxDocument(this.components); + this.tbrSettings = new System.Windows.Forms.ToolBar(); + this.btnWhitespace = new System.Windows.Forms.ToolBarButton(); + this.btnTabGuides = new System.Windows.Forms.ToolBarButton(); + this.btnFolding = new System.Windows.Forms.ToolBarButton(); + this.btnSettings = new System.Windows.Forms.ToolBarButton(); + this.imlIcons = new System.Windows.Forms.ImageList(this.components); + this.sBox = new Alsing.Windows.Forms.SyntaxBoxControl(); + this.syntaxDocument1 = new Alsing.SourceCode.SyntaxDocument(this.components); + ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit(); + this.SuspendLayout(); + // + // statusBar1 + // + this.statusBar1.Location = new System.Drawing.Point(0, 471); + this.statusBar1.Name = "statusBar1"; + this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] { + this.statusBarPanel1, + this.statusBarPanel2, + this.statusBarPanel3}); + this.statusBar1.ShowPanels = true; + this.statusBar1.Size = new System.Drawing.Size(504, 22); + this.statusBar1.TabIndex = 1; + // + // statusBarPanel1 + // + this.statusBarPanel1.Name = "statusBarPanel1"; + this.statusBarPanel1.Width = 200; + // + // statusBarPanel2 + // + this.statusBarPanel2.Name = "statusBarPanel2"; + this.statusBarPanel2.Width = 200; + // + // statusBarPanel3 + // + this.statusBarPanel3.Name = "statusBarPanel3"; + // + // sDoc + // + this.sDoc.Lines = new string[] { + "abc"}; + this.sDoc.MaxUndoBufferSize = 1000; + this.sDoc.Modified = false; + this.sDoc.UndoStep = 0; + this.sDoc.Change += new System.EventHandler(this.sDoc_Change); + this.sDoc.ModifiedChanged += new System.EventHandler(this.sDoc_ModifiedChanged); + // + // tbrSettings + // + this.tbrSettings.Appearance = System.Windows.Forms.ToolBarAppearance.Flat; + this.tbrSettings.AutoSize = false; + this.tbrSettings.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { + this.btnWhitespace, + this.btnTabGuides, + this.btnFolding, + this.btnSettings}); + this.tbrSettings.Divider = false; + this.tbrSettings.Dock = System.Windows.Forms.DockStyle.Left; + this.tbrSettings.DropDownArrows = true; + this.tbrSettings.ImageList = this.imlIcons; + this.tbrSettings.Location = new System.Drawing.Point(0, 0); + this.tbrSettings.Name = "tbrSettings"; + this.tbrSettings.ShowToolTips = true; + this.tbrSettings.Size = new System.Drawing.Size(25, 471); + this.tbrSettings.TabIndex = 2; + this.tbrSettings.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbrSettings_ButtonClick); + // + // btnWhitespace + // + this.btnWhitespace.ImageIndex = 1; + this.btnWhitespace.Name = "btnWhitespace"; + this.btnWhitespace.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton; + this.btnWhitespace.ToolTipText = "Toggle Whitespace On/Off"; + // + // btnTabGuides + // + this.btnTabGuides.ImageIndex = 0; + this.btnTabGuides.Name = "btnTabGuides"; + this.btnTabGuides.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton; + this.btnTabGuides.ToolTipText = "Toggle Tab guides On/Off"; + // + // btnFolding + // + this.btnFolding.ImageIndex = 2; + this.btnFolding.Name = "btnFolding"; + this.btnFolding.Pushed = true; + this.btnFolding.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton; + this.btnFolding.ToolTipText = "Toggle Folding On/Off"; + // + // btnSettings + // + this.btnSettings.Name = "btnSettings"; + this.btnSettings.Text = "S"; + // + // imlIcons + // + this.imlIcons.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imlIcons.ImageStream"))); + this.imlIcons.TransparentColor = System.Drawing.Color.Transparent; + this.imlIcons.Images.SetKeyName(0, ""); + this.imlIcons.Images.SetKeyName(1, ""); + this.imlIcons.Images.SetKeyName(2, ""); + // + // sBox + // + this.sBox.ActiveView = Alsing.Windows.Forms.ActiveView.BottomRight; + this.sBox.AutoListPosition = null; + this.sBox.AutoListSelectedText = "a123"; + this.sBox.AutoListVisible = false; + this.sBox.BackColor = System.Drawing.Color.White; + this.sBox.BorderStyle = Alsing.Windows.Forms.BorderStyle.None; + this.sBox.ChildBorderColor = System.Drawing.Color.White; + this.sBox.ChildBorderStyle = Alsing.Windows.Forms.BorderStyle.None; + this.sBox.CopyAsRTF = false; + this.sBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.sBox.Document = this.sDoc; + this.sBox.FontName = "Courier new"; + this.sBox.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.sBox.InfoTipCount = 1; + this.sBox.InfoTipPosition = null; + this.sBox.InfoTipSelectedIndex = 1; + this.sBox.InfoTipVisible = false; + this.sBox.Location = new System.Drawing.Point(25, 0); + this.sBox.LockCursorUpdate = false; + this.sBox.Name = "sBox"; + this.sBox.ScopeIndicatorColor = System.Drawing.Color.Black; + this.sBox.ShowScopeIndicator = false; + this.sBox.Size = new System.Drawing.Size(479, 471); + this.sBox.SmoothScroll = false; + this.sBox.SplitviewH = -4; + this.sBox.SplitviewV = -4; + this.sBox.TabGuideColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(219)))), ((int)(((byte)(214))))); + this.sBox.TabIndex = 3; + this.sBox.Text = "syntaxBoxControl1"; + this.sBox.WhitespaceColor = System.Drawing.SystemColors.ControlDark; + // + // syntaxDocument1 + // + this.syntaxDocument1.Lines = new string[] { + ""}; + this.syntaxDocument1.MaxUndoBufferSize = 1000; + this.syntaxDocument1.Modified = false; + this.syntaxDocument1.UndoStep = 0; + // + // EditForm + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(504, 493); + this.Controls.Add(this.sBox); + this.Controls.Add(this.tbrSettings); + this.Controls.Add(this.statusBar1); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "EditForm"; + this.Text = "EditForm"; + this.Closing += new System.ComponentModel.CancelEventHandler(this.EditForm_Closing); + ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/EditForm.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/EditForm.resx new file mode 100644 index 0000000..cad6d79 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/EditForm.resx @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 92, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAi + BQAAAk1TRnQBSQFMAgEBAwEAAQQBAAEEAQABEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA + AwABEAMAAQEBAAEYBgABDP8ASwAMQrQAA0JFAAObAyYBBAEFAQYBBAEFAQYBBAEFAQYBBAEFAQYBBAEF + AQYBBAEFAQYBBAEFAQYBBAEFAQYBBAEFAQYBBAEFAQYBBAEFAQYBBAEFAQYDJgObSAADQkUAAyYBBAEF + AQYBBAEFAQYBBAEFAQYBBAEFAQYBBAEFAQYBBAEFAQYBBAEFAQYBBAEFAQYBBAEFAQYDqQEEAQUBBgEE + AQUBBgP/AQQBBQEGAyZIAANCRQABCgEOAQ8BCgEOAQ8BCgEOAQ8BCgEOAQ8BCgEOAQ8BCgEOAQ8BCgEO + AQ8BCgEOAQ8BCgEOAQ8BCgEOAQ8D/wOpAQoBDgEPA/8BCgEOAQ8BCgEOAQ8eAAEyAUMBSgEyAUMBSiQA + A0JFAAESARcBGgESARcBGgESARcBGgERARgBGQESARcBGgESARcBGgESARcBGg//A6kD/wESARcBGgES + ARcBGiEAATIBQwFKATIBQwFKaQABGQEhASUBGQEhASUD/wEZASEBJQEZASEBJQOpARkBIQElARkBIQEl + ARkBIQElARkBIQElA/8DqQEZASEBJQP/ARkBIQElARkBIQElJAABMgFDAUoBMgFDAUoSABtCOQABHwEq + AS8BHwEqAS8D/wEfASoBLwOpA/8BHwEqAS8BHwEqAS8BIAEqAS8BIAEqAS8DqQEfASoBLwEfASoBLwP/ + AR8BKgEvAR8BKgEvAwABMgFDAUoBMgFDAUoDAAEyAUMBSgEyAUMBSgMAATIBQwFKATIBQwFKCQABMgFD + AUoBMgFDAUoBMgFDAUoPAANCFf8DQjkAAScBNAE6AScBNAE6A/8DqQ//AScBNAE6AScBNAE6AScBNAE6 + AScBNAE6AScBNAE6AScBNAE6AScBNAE6IQABMgFDAUoBMgFDAUoBMgFDAUoSAANCCf8DAAn/A0I5AAEu + AT0BRAEuAT0BRAP/AS4BPQFEA6kD/wEuAT0BRAEuAT0BRAEuAT0BRAEuAT0BRAEuAT0BRAEuAT0BRAEu + AT0BRAEuAT0BRAEuAT0BRAEuAT0BRB4AATIBQwFKATIBQwFKATIBQwFKFQADQgn/AwAJ/wNCOQABQgFN + AVIBMgFDAUoD/wEyAUMBSgEyAUMBSgOpATIBQwFKATIBQwFKATIBQwFKATIBQwFKATIBQwFKATIBQwFK + ATIBQwFKATIBQwFKATIBQwFKAUIBTQFSHgABMgFDAUoBMgFDAUoYAANCA/8PAAP/A0I5AAGmAaoBqwFC + AU0BUgEyAUMBSgEyAUMBSgEyAUMBSgEyAUMBSgEyAUMBSgEyAUMBSgEyAUMBSgEyAUMBSgEyAUMBSgEy + AUMBSgEyAUMBSgEyAUMBSgFCAU0BUgGmAaoBqzwAA0IJ/wMACf8DQqUAA0IJ/wMACf8DQqUAA0IV/wNC + pQAbQjkAAUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEBBQABgBcAA/8BAAb/AgAF/wEPAgAF/wF/ + BAAD/wF/BAAB/wHPAf8BfwQAAf8BxwH/AX8EAAH/AeMC/wQAAZIBcQHwAQcEAAGSAXEB8AEHBAAB/wHj + AfABBwQAAf8BxwHwAQcEAAH/Ac8B8AEHBAAC/wHwAQcCAAT/AfABBwIABP8B8AEHAgAE/wHwAQcCAAs= + + + + 185, 17 + + + + + AAABAAEAEBAAAAAAAABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAB + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAMDcwADwyqYABAQEAAgICAAMDAwAERERABYW + FgAcHBwAIiIiACkpKQBVVVUATU1NAEJCQgA5OTkAgHz/AFBQ/wCTANYA/+zMAMbW7wDW5+cAkKmtAAAA + MwAAAGYAAACZAAAAzAAAMwAAADMzAAAzZgAAM5kAADPMAAAz/wAAZgAAAGYzAABmZgAAZpkAAGbMAABm + /wAAmQAAAJkzAACZZgAAmZkAAJnMAACZ/wAAzAAAAMwzAADMZgAAzJkAAMzMAADM/wAA/2YAAP+ZAAD/ + zAAzAAAAMwAzADMAZgAzAJkAMwDMADMA/wAzMwAAMzMzADMzZgAzM5kAMzPMADMz/wAzZgAAM2YzADNm + ZgAzZpkAM2bMADNm/wAzmQAAM5kzADOZZgAzmZkAM5nMADOZ/wAzzAAAM8wzADPMZgAzzJkAM8zMADPM + /wAz/zMAM/9mADP/mQAz/8wAM///AGYAAABmADMAZgBmAGYAmQBmAMwAZgD/AGYzAABmMzMAZjNmAGYz + mQBmM8wAZjP/AGZmAABmZjMAZmZmAGZmmQBmZswAZpkAAGaZMwBmmWYAZpmZAGaZzABmmf8AZswAAGbM + MwBmzJkAZszMAGbM/wBm/wAAZv8zAGb/mQBm/8wAzAD/AP8AzACZmQAAmTOZAJkAmQCZAMwAmQAAAJkz + MwCZAGYAmTPMAJkA/wCZZgAAmWYzAJkzZgCZZpkAmWbMAJkz/wCZmTMAmZlmAJmZmQCZmcwAmZn/AJnM + AACZzDMAZsxmAJnMmQCZzMwAmcz/AJn/AACZ/zMAmcxmAJn/mQCZ/8wAmf//AMwAAACZADMAzABmAMwA + mQDMAMwAmTMAAMwzMwDMM2YAzDOZAMwzzADMM/8AzGYAAMxmMwCZZmYAzGaZAMxmzACZZv8AzJkAAMyZ + MwDMmWYAzJmZAMyZzADMmf8AzMwAAMzMMwDMzGYAzMyZAMzMzADMzP8AzP8AAMz/MwCZ/2YAzP+ZAMz/ + zADM//8AzAAzAP8AZgD/AJkAzDMAAP8zMwD/M2YA/zOZAP8zzAD/M/8A/2YAAP9mMwDMZmYA/2aZAP9m + zADMZv8A/5kAAP+ZMwD/mWYA/5mZAP+ZzAD/mf8A/8wAAP/MMwD/zGYA/8yZAP/MzAD/zP8A//8zAMz/ + ZgD//5kA///MAGZm/wBm/2YAZv//AP9mZgD/Zv8A//9mACEApQBfX18Ad3d3AIaGhgCWlpYAy8vLALKy + sgDX19cA3d3dAOPj4wDq6uoA8fHxAPj4+ADw+/8ApKCgAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8ACgoKCgwMDAoKDAwMCgoKCgoKCgxtdHMMDOsc7AwKCgoKCjwSeTJZ6wp6MnrrPAoKCgoKc1ky + OBwSWTJZeQoKCgoKCkN6ODgc7Fk4WUMKCgoKPBMSSiNZeXlZI0oSEjwKX0p5dEoSWZSUWepKeVhKXwqZ + WVlYeZQyMpR5WFlZegoKmjIyWViUMjKUeVkyMnoKPHNZWUttWZSUWetLWFlzPAo8c3MVI1lYeVkjFetz + PAoKCgoQeVk4HO1ZOHoRCgoKCgoKc1kyOHNtWTJZHAoKCgoKDOt6MlkK6lkyWXMMCgoKCgoMc3ocDAxz + ehwMCgoKCgoKCgoKCgoKCgoKCgoKCvGPAADgBwAAwAMAAMADAADAAwAAgAEAAAAAAAAAAAAAAAAAAAAA + AACAAQAAwAMAAMADAADAAwAA4AcAAPGPAAA= + + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/LanguageForm.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/LanguageForm.cs new file mode 100644 index 0000000..2843cbd --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/LanguageForm.cs @@ -0,0 +1,191 @@ +using System; +using System.ComponentModel; +using System.Windows.Forms; +using Alsing.SourceCode; + +namespace MDIDemo +{ + /// + /// Summary description for LanguageForm. + /// + public class LanguageForm : Form + { + private Button btnCancel; + private Button btnOK; + private IContainer components; + public EditForm EditForm; + private ImageList imlIcons; + private ListView lvFileTypes; + private TreeView trvFileTypes; + + public LanguageForm() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + } + + public LanguageForm(SyntaxDefinitionList LangList) + { + InitializeComponent(); + trvFileTypes.Nodes.Clear(); + foreach (SyntaxDefinition syntax in LangList.GetSyntaxDefinitions()) + { + TreeNode tn = trvFileTypes.Nodes.Add(syntax.Name); + tn.Tag = syntax; + } + trvFileTypes.SelectedNode = trvFileTypes.Nodes[0]; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + private void LanguageForm_Load(object sender, EventArgs e) {} + + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void btnOK_Click(object sender, EventArgs e) + { + OK(); + } + + private void trvFileTypes_AfterSelect(object sender, TreeViewEventArgs e) + { + var syntax = (SyntaxDefinition) e.Node.Tag; + lvFileTypes.Items.Clear(); + foreach (FileType ft in syntax.FileTypes) + { + ListViewItem lvi = lvFileTypes.Items.Add(ft.Name + " (" + ft.Extension + ")"); + lvi.Tag = ft; + lvi.ImageIndex = 0; + } + } + + private void OK() + { + if (lvFileTypes.SelectedItems.Count == 0) + { + lvFileTypes.Items[0].Selected = true; + } + + var syntax = (SyntaxDefinition) trvFileTypes.SelectedNode.Tag; + var ft = (FileType) lvFileTypes.SelectedItems[0].Tag; + var doc = new Document {Title = ("Untitled" + ft.Extension), Text = ""}; + + + var ef = new EditForm(doc, syntax); + EditForm = ef; + DialogResult = DialogResult.OK; + Close(); + } + + private void lvFileTypes_DoubleClick(object sender, EventArgs e) + { + OK(); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + var resources = new System.Resources.ResourceManager(typeof (LanguageForm)); + this.lvFileTypes = new System.Windows.Forms.ListView(); + this.imlIcons = new System.Windows.Forms.ImageList(this.components); + this.btnOK = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.trvFileTypes = new System.Windows.Forms.TreeView(); + this.SuspendLayout(); + // + // lvFileTypes + // + this.lvFileTypes.HideSelection = false; + this.lvFileTypes.LargeImageList = this.imlIcons; + this.lvFileTypes.Location = new System.Drawing.Point(176, 8); + this.lvFileTypes.Name = "lvFileTypes"; + this.lvFileTypes.Size = new System.Drawing.Size(272, 224); + this.lvFileTypes.SmallImageList = this.imlIcons; + this.lvFileTypes.TabIndex = 0; + this.lvFileTypes.DoubleClick += new System.EventHandler(this.lvFileTypes_DoubleClick); + // + // imlIcons + // + this.imlIcons.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; + this.imlIcons.ImageSize = new System.Drawing.Size(25, 29); + this.imlIcons.ImageStream = + ((System.Windows.Forms.ImageListStreamer) (resources.GetObject("imlIcons.ImageStream"))); + this.imlIcons.TransparentColor = System.Drawing.Color.Transparent; + // + // btnOK + // + this.btnOK.Location = new System.Drawing.Point(288, 240); + this.btnOK.Name = "btnOK"; + this.btnOK.TabIndex = 1; + this.btnOK.Text = "OK"; + this.btnOK.Click += new System.EventHandler(this.btnOK_Click); + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(376, 240); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.TabIndex = 2; + this.btnCancel.Text = "Cancel"; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // trvFileTypes + // + this.trvFileTypes.HideSelection = false; + this.trvFileTypes.ImageIndex = -1; + this.trvFileTypes.Location = new System.Drawing.Point(8, 8); + this.trvFileTypes.Name = "trvFileTypes"; + this.trvFileTypes.SelectedImageIndex = -1; + this.trvFileTypes.Size = new System.Drawing.Size(168, 224); + this.trvFileTypes.TabIndex = 3; + this.trvFileTypes.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.trvFileTypes_AfterSelect); + // + // LanguageForm + // + this.AcceptButton = this.btnOK; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(458, 271); + this.ControlBox = false; + this.Controls.AddRange(new System.Windows.Forms.Control[] + {this.trvFileTypes, this.btnCancel, this.btnOK, this.lvFileTypes}); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "LanguageForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Select file type"; + this.Load += new System.EventHandler(this.LanguageForm_Load); + this.ResumeLayout(false); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/LanguageForm.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/LanguageForm.resx new file mode 100644 index 0000000..d6640a7 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/LanguageForm.resx @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFpTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0xLjAuMzMw + MC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZT + eXN0ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMA + AABYCgAAAk1TRnQBSQFMAwEBAAEEAQABBAEAARkBAAEdAQAE/wEhARAI/wFCAU0BNgcAATYDAAEoAwAB + ZAMAAR0DAAEBAQABIAUAAVABLRUAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8D + AAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf// + AC0AA4QB/wPOAf8DzgH/A84B/wPOAf8DzgH/A84B/wPOAf8DzgH/A84B/wPOAf8DzgH/A84B/wPOAf8D + zgH/A84B/wPOAf8DzgH/A84B/wPOAf8DzgH/A84B/wPOAf8DzgH/AwAB//8ALQADhAX/A/cF/wP3Bf8D + 9wX/A/cF/wP3Bf8D9wX/A/cF/wP3Bf8D9wX/A/cF/wP3Af8DzgH/AwAB//8ALQADhAn/A/cF/wP3Bf8D + 9wX/A/cF/wP3Bf8D9wX/A/cF/wP3Bf8D9wX/A/cF/wPOAf8DAAH//wAtAAOEBf8D9wX/AZwBYwExAf8B + nAFjATEB/wGcAWMBMQH/AZwBYwExAf8BnAFjATEB/wGcAWMBMQH/AZwBYwExAf8BnAFjATEB/wGcAWMB + MQH/AZwBYwExAf8BnAFjATEB/wGcAWMBMQH/AZwBYwExAf8BnAFjATEB/wGcAWMBMQH/AZwBYwExAf8B + nAFjATEF/wP3Af8DzgH/AwAB//8ALQADhAn/A/cF/wP3Bf8D9wX/A/cF/wP3Bf8D9wX/A/cF/wP3Bf8D + 9wX/A/cF/wPOAf8DAAH//wAtAAOEBf8D9wX/AZwBYwExAf8BnAFjATEB/wGcAWMBMQH/AZwBYwExAf8B + nAFjATEB/wGcAWMBMQH/AZwBYwExAf8BnAFjATEB/wGcAWMBMQH/AZwBYwExAf8BnAFjATEB/wGcAWMB + MQH/AZwBYwExAf8BnAFjATEB/wGcAWMBMQH/AZwBYwExAf8BnAFjATEF/wP3Af8DzgH/AwAB//8ALQAD + hAn/A/cF/wP3Bf8D9wX/A/cF/wP3Bf8D9wX/A/cF/wP3Bf8D9wX/A/cF/wPOAf8DAAH//wAtAAOEBf8D + 9wX/AZwBYwExAf8BnAFjATEB/wGcAWMBMQH/AZwBYwExAf8BnAFjATEB/wGcAWMBMQH/AZwBYwExAf8B + nAFjATEB/wGcAWMBMQH/AZwBYwExAf8BnAFjATEB/wGcAWMBMQH/AZwBYwExAf8BnAFjATEB/wGcAWMB + MQH/AZwBYwExAf8BnAFjATEF/wP3Af8DzgH/AwAB//8ALQADhAn/A/cF/wP3Bf8D9wX/A/cF/wP3Bf8D + 9wX/A/cF/wP3Bf8D9wX/A/cF/wPOAf8DAAH//wAtAAOEDf8D9wX/A/cF/wP3Bf8D9wX/A/cF/wP3Bf8D + 9wX/A/cF/wP3Bf8D9wH/A84B/wMAAf//AC0AA4QJ/wP3Bf8D9wX/A/cF/wP3Bf8D9wX/A/cF/wP3Bf8D + 9wX/A/cF/wP3Bf8DzgH/AwAB//8ALQADhA3/A/cF/wP3Bf8D9wX/A/cB/wMAAf8DAAH/AwAB/wP3Bf8D + 9wX/A/cF/wP3Bf8D9wH/A84B/wMAAf//AC0AA4QJ/wP3Bf8D9wX/A/cF/wMAAf8DAAL/AgAC/wIAAv8C + AAH/AwAB/wMABf8D9wX/A/cF/wP3Bf8DzgH/AwAB//8ALQADhA3/A/cB/wGcAgAB/wP3Bf8BAAGcATEB + /wEAAZwBMQH/AQABYwEAAv8BYwExAv8BYwExAv8BYwExAv8CAAL/AgAB/wMABf8D9wH/AZwCAAH/A/cF + /wP3Af8DzgH/AwAB//8ALQADhA3/AZwCAAH/AfcBzgGlBf8D9wH/AQABnAExAf8BMQHOATEB/wEAAWMB + AAH/AQABYwEAAv8BnAEAAv8BYwExAf8BAAFjAQAB/wEAAWMBAAH/AQABhAEAAf8DAAX/AfcBzgGlAf8B + nAIAAf8D9wX/A84B/wMAAf//AC0AA4QG/wHvAc4B/wGcAgAB/wH3Ac4BpQX/A/cB/wEAAZwBMQX/ATEB + zgExAf8BAAFjAQAC/wGcAQAC/wGcAQAB/wEAAWMBAAH/ATEBzgExAf8BAAGcATEB/wEAAZwBMQH/AwAB + /wP3Bf8B9wHOAaUB/wGcAgAC/wHvAc4B/wPOAf8DAAH//wAtAAOEBf8BnAIAAf8B9wHOAaUF/wP3Bv8B + YwExAf8BAAGcATEB/wEAAZwBMQL/AZwBAAL/Ac4BMQL/AZwBAAH/AQABYwEAAf8BAAFjAQAB/wHOAf8B + zgH/AQABnAExAf8DAAX/A/cF/wH3Ac4BpQH/AZwCAAH/A84B/wMAAf//AC0AA4QG/wHvAc4B/wGcAgAB + /wH3Ac4BpQX/A/cC/wFjATED/wHOA/8BMQL/Ac4BMQL/Ac4BMQL/Ac4BMQL/AZwBAAL/AWMBMQH/AQAB + YwEAAf8BAAGcATEB/wMAAf8D9wX/AfcBzgGlAf8BnAIAAv8B7wHOAf8DzgH/AwAB//8ALQADhA3/AZwC + AAH/AfcBzgGlBv8BYwExA/8BzgL/AZwBAAH/AQABYwExAv8BYwExAv8BzgExAv8BzgExAv8BYwExAv8B + YwExAf8BAAFjAQAB/wMABf8B9wHOAaUB/wGcAgAB/wP3Bf8DzgH/AwAB//8ALQADhBH/AZwCAAH/A/cG + /wFjATEB/wEAAWMBMQH/ATEBzgExAf8BAAFjATEB/wEAAWMBMQL/Ac4BMQL/AZwBAAL/AWMBMQH/AwAF + /wP3Af8BnAIAAf8D9wX/A/cB/wPOAf8DAAH//wAtAAOEGf8D9wH/AQABnAExBf8BzgH/Ac4B/wExAc4B + MQH/AQABnAExAf8BAAFjATEB/wEAAWMBMQL/AWMBMQL/AWMBMQH/A/cF/wP3Bf8D9wX/A84B/wMAAf// + AC0AA4Qd/wP3Af8BAAGcATEB/wEAAZwBMQX/ATEBzgExAf8BAAGcATEB/wEAAWMBMQL/AWMBMQH/A/cF + /wOEAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf//AC0AA4Qh/wP3Bf8BAAGcATEB/wEAAZwBMQH/AQAB + nAExBf8D9wX/A/cB/wOEDf8DxgH/AwAB//8AMQADhCX/A/cF/wP3Bf8D9wX/A/cF/wOECf8DxgH/AwAB + //8ANQADhCn/A/cF/wP3Bf8D9wX/A/cB/wOEBf8DxgH/AwAB//8AOQADhC3/A/cF/wP3Bf8D9wX/A4QB + /wPGAf8DAAH//wA9AAOEOf8D9wX/A/cB/wOEAf8DAAH//wBBAAOEAf8DhAH/A4QB/wOEAf8DhAH/A4QB + /wOEAf8DhAH/A4QB/wOEAf8DhAH/A4QB/wOEAf8DhAH/A4QB/wOEAf8DhAH/A4QB/wOEAf//AEUAAUIB + TQE+BwABPgMAASgDAAFkAwABHQMAAQEBAAEBBQAB0AEBFgAD//8AdQABgA4AAQEBgA4AAQMBgA4AAQcB + gA4AAQ8BgA4AAR8BgCIACw== + + + + LanguageForm + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.csproj b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.csproj new file mode 100644 index 0000000..1fe14e9 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.csproj @@ -0,0 +1,191 @@ + + + Local + 9.0.21022 + 2.0 + {2AE13325-8AC7-4AE8-A835-F434DC3F11EF} + Debug + AnyCPU + App.ico + + + SyntaxBoxMDIDemo + + + JScript + Grid + IE50 + false + WinExe + MDIDemo + MDIDemo.MDIParent + + + 0.0 + + + http://localhost/SyntaxBoxMDIDemo/ + true + Web + true + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + true + false + true + + + bin\Debug\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + System.Drawing + + + System.Web + + + System.Web.Services + + + System.Windows.Forms + + + System.XML + + + + + + + Code + + + Code + + + Form + + + Form + + + Form + + + True + True + Resources.resx + + + Form + + + Component + + + EditForm.cs + Designer + + + LanguageForm.cs + Designer + + + MDIParent.cs + Designer + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + SettingsForm.cs + Designer + + + Style.cs + Designer + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + {19EF75B2-B414-4EB0-9486-160FAF93E62C} + Alsing.SyntaxBox.NET + + + + + + + + + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.csproj.user b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.csproj.user new file mode 100644 index 0000000..5d79810 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.csproj.user @@ -0,0 +1,68 @@ + + + Debug + AnyCPU + C:\ComponaStuff\InstallPackage\BIN\;C:\ComponaStuff\Projects\SyntaxBox\SAMPLES\SyntaxBox\Binary\;C:\output\;C:\ComponaStuff\Projects\SyntaxBox\SyntaxBox 0.98\syntaxbox\bin\Release\;c:\winnt\assembly\gac\crystaldecisions.windows.forms\9.1.3300.0__692fbea5521e1304\;c:\projects\beta with license\syntaxbox\bin\release\;c:\documents and settings\rogerj\skrivbord\beta with license\syntaxbox\bin\release\;C:\Documents and Settings\rogerj\Skrivbord\working beta 020923\editor\XTextbox\bin\Debug\;c:\documents and settings\rogerj\skrivbord\working beta 020923\editor\xtextbox\bin\release\;c:\documents and settings\rogerj\skrivbord\beta with license\editor\syntaxbox\bin\debug\;C:\Documents and Settings\rogerj\Skrivbord\beta with License\syntaxbox\bin\debug\;c:\mystuff\projects\beta with license\syntaxbox\bin\release\;C:\Documents and Settings\RogerJ\Skrivbord\demos\Binary\ + + + + + 0 + ProjectFiles + 0 + + + + + + + + + + + en-US + true + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.sln b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.sln new file mode 100644 index 0000000..ec3f0b1 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MDIDemo", "MDIDemo.csproj", "{2AE13325-8AC7-4AE8-A835-F434DC3F11EF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2AE13325-8AC7-4AE8-A835-F434DC3F11EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2AE13325-8AC7-4AE8-A835-F434DC3F11EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2AE13325-8AC7-4AE8-A835-F434DC3F11EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2AE13325-8AC7-4AE8-A835-F434DC3F11EF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.suo b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIDemo.suo new file mode 100644 index 0000000000000000000000000000000000000000..0faa868904c4c078053401199286b945d4faa5ad GIT binary patch literal 23552 zcmeHPdvIJ;8NW$iwosrHD)MMkXepE?&9f;j1^1OSZMF^BHmR~Io8%^JyV;Gqo3?@S zD1z21iVvWo2skh@hz>Z8<6}lf{t#qzKph|BFbMxh#~CTkDDn@Dzu!6c?7e$)_wL=@ zbdzFF=DX+IbI(2BchC9G_c~|u>MKj$c>KAG-_&gBdTow&a&no809OOn0_p%O0apO70jvV72CM;)r>;W2+$gUz za@LDUWS_*$z%tc5`B2Q}*7-{cm88}8!L*8*qjqkiWF!b_EHFMDDE>12|P}8;j zT8|b3<}4`Ck@o;n+OQVa65?LAbiQ7x)z*-2*(d36ZZ)-5$+ca;oYD4a-N2Rs1-o%2 z4XQpf_0_zZRlrZa=UVZKpE8tdjHyfO(;`|JWL9QL=*afzRua2LYRm`zGYgMw!psP~HHz1+WotEr9i#k#`v7>yh68_$a^! z@B;#Xt$+~V>wr!`7|;dS2G|bh2J8gv07L;jfExk5fCyk0U^k!-&=1%H_!!{h0P@k- z0G|Nd1^5);W&mj$Kt5=cIn%>Nna|=V?*;4wBmkp;Bp?MC1AH2g27D2a1&jms0}cQV z0=SxQ1>6QW1h^e=2jEV?eE`mTCFz|2IlufwzFH7SjgF;~G4^t9AU%=E#u9bC`dBKR z70YjKFqRb$7wrjm*F^?z(MQGY;$S?MNR8BmhT_>22SHoduMgC9q|&3}y+yKLJt@0c z+#gR4r4D4w26MOW3UgAma{`I@*gz_l9;)k&Cr4Pdpi@uk=@`dcTNIuMq>|ZmDk1u1 zl}g9SyhxKLdF9tojt+rOhQSk*r#d7IXU#d)I9GeF<@@~f09HiQkenl^AU*%OC;3~8woe*enDS3b{V{<* z3%>P(juiM<%44JXl#KF^W3U3?6+hRN>L>yn8R)XA~?1lPm` zkGRosRT=mf054?_lO2BuJjl5i!zjctAIT!40R1m)Oxmd&1JP-b3ndnH82e5Me zTKPh@biUI5AYR(IUh$LGw6XB*_`~@2QG7S;uzrIUxeA=|uQTvdAA7~m^-5jElz~); z02lc^hOzep_d!ud2{I-uFt!O}OyXj+NFB8wQ&iXtvRv7fdWd?^S&oH)dk|xi0=={h zX|ML7E`ya51C4b;){YArQ@Cq@jt=1)qi8j#wIk=-SwT0o;;F*IwVS}W4Fg{k)KRWP zbN5msR~NUWNX?h?98q@JQzdowzTEETYeIY<7k0=p?cura&cX7SoQ&4yLJiN}v}oQ- z(M9vPVt&}X6PAsIxcTr@Pn>*vk|26Qqq6~AkH7t1>-nmlcG5k7mA3jNxDSJi5}3KT z;3DaXjDz>3Mxyn##juk$YpuAu4Hl;l{MDqj;ICP0)9PVs`oLA~D7A`b8&UG1wnaSc zKy3>kh&C;-L!0myLVi0qbqG3+mV$|Qr;vVDtX$psZ4_-fIE;4R7DzPO&85;td7FjI zNkal~B~kv->&oQ5USgnbq>PYOgQ*cVLH^Jmr~`PFKUV!4M8AU=|52l7tIX>W>pc#v zg*8E=A^(V*31k#a=cC0d6v9Yu_?0gh#K>@doKgeu)9PCc@QQya+L9NUsAm%Re)WxV zoay_Hpq6%=dLrA~uaN%&ulRV6-%s7YW3KF}9y4BuH#dWWOXn!J9vk2*>4LxLb?fj* zeBi1Ha8CgIwi~Nq7#fJ*Obf`5mP4SxTzxl8J3XfUEtM822^zKhzxv$0dnx~|M$eK! zVhzE^^+U3>3AvR1^)}zt$M$Z2>d%iI?mhXFr)xO1=j@2Q_KOo|hmWp4_I&N57rsZw zPU~=8l^&s$WLlrn2W4Hp^*M@>iHi|Z)+c%V2=MMvf*kkdBzn!2(A^4tZH2CH!MblU z^gr!@YlZ&zqtt{_8}fExHL#`;x_=|?no3;t&3MNTXvCHM)T5suavw^q=#6#-t&SGZ zMEiqQN(P*$ z65VH&>u)uhP^Wv9KThkv3+r$gUry|$q-ABSzx6=CMaQ&LjB*0pofI%)kvvVZiR%^q zzwkdxkw1;-@d=|>H>*?X8Xvf(1LM*T9;3}$FL;kOLp|=Az*UWc>-dbENX_O01h57g z@h1Oh^?J2+X_)!IeYAV_gD(P@7e?f0;nK<~tg#W}Z3B@T1gQ*kHZ}i#&Ub2sKe47( zo74R~BOf9?`}6M}cnSA=q}S_J?np_YVpMTZN8ebcqh(1!e(nAE#`2%FZ%{^zfvcmC<+b_^Tcc&{I%SAx5|$U!#RP)jCzD~aAROov?rY!NykQ`MmXBY89t6iCX(6ML4WFCG!h#fOX!(scqks! zM^k)hOiyRysOr@-sqyrno@q$y86igIUzZ$DB(9e<^$y1q`lj{k*O!Y*648NPGSR>l z4VejS1Vpq|XT9&c=DuHUeeSPMzq0hn{&TyhSb0R>t=X+aNff1TB@tlQA2pYtEBeu1 zGk{D(e`em(Gl-T?K8%{f~W^ZR)~(SPzUXQj0Y~Ch_Va?Wid=@Z#nsAF|ow zQZ!2CvlmYDG@9F6g%iC zfc~!ICJd5&_PzRj@@<}JsjcCDw~_&>-Yvfl53e#BbimdLfy-!H1;A^{ljz7u;HU3GK8{(*=DKJ6jq%P>@LT0iY51p(4)Eu2dzC-jFPl$;9Z7we^mi$Zt!E%) z8@H>ne=kKNulQ+AQeQE-+253t#S-x|?n1>TWSVM+Ac<}R`)&Z^(m7z@n{FrFTbAjR()8be(nkDk5Os~nTj5eLG~SqJ zuOG^pf*c#KdjZBcTC%=UWHDpfwBgH%LRjBn#8$@5l|OL5M={NKmx_{@QIT@?eM*^LA*^3S3 zbgrb_ug(ud<{Lh59R6K1&kuIbGP)XsPNuzd-oif!3Nfky?uwb-g?)EHdYu%5Z4ib{ z0ER7^@eU1>Vf2{5A2oXr;?$45kxp$h^nWjeXaF@#+;`fHcNtM^%9Yp$brB=-(qyD` zfyJOgPU5+Y*dGwfNXNp{MFh=0`tn|$&Xlsrcv+mcNr}CKsO2l2ta*E%5}WFWR9dMp zJwvu&l+Xw2$6$%`1VBooFD-ep9|7wfz`YaaBqEUDQ_l#PrvN%IH;gEAe}O7&AKLGS z=xe~}M}@6BjOTI}xWS-@JG=A=7?&Fsc8RpQI{n>UTXR%M`=yi+m9?RtZEYH}eGjSQL z5xZ4xa-44l=(g*{nVL=e$pLdzD4nZ4n^PsVq$e2a?&1h-$o_V6 zYo%{?$;t}~P)tcC&w427YW;@Uri&Phemyl{1xBUHLaCY{MUQgu%u-wOr$ z(hsfwf5(IcpH{Fx(NQQC`+=AXc~o;uY^KYQp>#y2d$)+o3426gWH$p=0<6FHz^#ZL zQtDajJ5doeL?P?F|5CEtxE&>#viHqjS4460C5%%!4_1Bs7osPCJ=uB~S(`~1^Oc0|u+@!te8g~|4pO?Gx7p*s)7DLH0p zo5@hQbn{;|6dsO_(!2Had(j-P=L!Y)!#@x<7=Kb_Jz|~jh)lmF2EVNWdpP)kwuc$& zw*J8NR9VAi&cR_U37!T14B#HXy@1aGJ_k4g_&ne!;0pkr8zg)QxL(VNKRk*aRs6-ZbB_dXQyZc{s*AEcGUm? literal 0 HcmV?d00001 diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIParent.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIParent.cs new file mode 100644 index 0000000..e8a5b28 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIParent.cs @@ -0,0 +1,595 @@ +using System; +using System.ComponentModel; +using System.IO; +using System.Text; +using System.Windows.Forms; +using Alsing.SourceCode; + +namespace MDIDemo +{ + /// + /// Summary description for MDIParent. + /// + public class MDIParent : Form + { + /// + /// Required designer variable. + /// + private Container components; + + private OpenFileDialog dlgOpen; + private PrintDialog dlgPrint; + private PrintPreviewDialog dlgPrintPreview; + private SaveFileDialog dlgSave; + private Label label1; + private MainMenu MainMenu; + private MenuItem menuItem1; + + private MenuItem menuItem12; + private MenuItem menuItem17; + private MenuItem menuItem19; + private MenuItem menuItem4; + private MenuItem menuItem5; + private MenuItem mnuEdit; + private MenuItem mnuEdit_Copy; + private MenuItem mnuEdit_Cut; + private MenuItem mnuEdit_Delete; + private MenuItem mnuEdit_NextBookmark; + private MenuItem mnuEdit_Paste; + private MenuItem mnuEdit_PrevBookmark; + private MenuItem mnuEdit_Redo; + private MenuItem mnuEdit_SelectAll; + private MenuItem mnuEdit_ToggleBookmark; + private MenuItem mnuEdit_Undo; + private MenuItem mnuFile; + private MenuItem mnuFile_Exit; + private MenuItem mnuFile_New; + private MenuItem mnuFile_Open; + private MenuItem mnuFile_Print; + private MenuItem mnuFile_PrintPreview; + private MenuItem mnuFile_Save; + private MenuItem mnuFile_SaveAs; + private Panel panel1; + private Panel panel2; + + #region general declarations + + private readonly SyntaxDefinitionList Languages = new SyntaxDefinitionList(); + + #endregion + + public MDIParent() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + [STAThread] + private static void Main() + { + Application.Run(new MDIParent()); + } + + private void mnuFile_Open_Click(object sender, EventArgs e) + { + //create a filter for the open dialog + + //add a *.* pattern to the filter + string filter = "All Files(*.*)|*.*"; + + //get all filetypes from our syntax list. + foreach (SyntaxDefinition l in Languages.GetSyntaxDefinitions()) + foreach (FileType ft in l.FileTypes) + //add the filetype to the filter + filter += "|" + ft.Name + "(*" + ft.Extension + ")|*" + ft.Extension; + + //apply the filter to the dialog + dlgOpen.Filter = filter; + + //Show the open dialog + dlgOpen.Title = "Select a file to open"; + DialogResult res = dlgOpen.ShowDialog(this); + + //Bail out if cancel was pressed or no file was selected. + if (res != DialogResult.OK || dlgOpen.FileName == "") + return; + + + //load the file + string FileName = dlgOpen.FileName; + var sr = new StreamReader(FileName, Encoding.Default); + //read the content into the "text" variable + string text = sr.ReadToEnd(); + + + //create a new document + var doc = new Document {Path = FileName}; + var fi = new FileInfo(FileName); + doc.Title = fi.Name; + doc.Text = text; + SyntaxDefinition syntax = Languages.GetLanguageFromFile(doc.Path); + + var ef = new EditForm(doc, syntax) {MdiParent = this}; + ef.Show(); + } + + //enable / disable menu items + private void mnuEdit_Popup(object sender, EventArgs e) + { + if (ActiveMdiChild == null) + { + foreach (MenuItem mi in mnuEdit.MenuItems) + { + mi.Enabled = false; + } + return; + } + else + { + foreach (MenuItem mi in mnuEdit.MenuItems) + { + mi.Enabled = true; + } + } + var ef = (EditForm) ActiveMdiChild; + + mnuEdit_Copy.Enabled = ef.sBox.CanCopy; + mnuEdit_Cut.Enabled = ef.sBox.CanCopy; + mnuEdit_Paste.Enabled = ef.sBox.CanPaste; + mnuEdit_Delete.Enabled = ef.sBox.CanCopy; + mnuEdit_Redo.Enabled = ef.sBox.CanRedo; + mnuEdit_Undo.Enabled = ef.sBox.CanUndo; + } + + //perform an undo action + private void mnuEdit_Undo_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + ef.sBox.Undo(); + } + + //perform a redo action + private void mnuEdit_Redo_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + ef.sBox.Redo(); + } + + //perform a copy action + private void mnuEdit_Copy_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + ef.sBox.Copy(); + } + + //perform a cut action + private void mnuEdit_Cut_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + ef.sBox.Cut(); + } + + //paste clipboard + private void mnuEdit_Paste_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + ef.sBox.Paste(); + } + + //delete selected text + private void mnuEdit_Delete_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + ef.sBox.Delete(); + } + + //select all + private void mnuEdit_SelectAll_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + ef.sBox.SelectAll(); + } + + //toggle bookmark + private void mnuEdit_ToggleBookmark_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + ef.sBox.ToggleBookmark(); + } + + //jump to next bookmark + private void mnuEdit_NextBookmark_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + ef.sBox.GotoNextBookmark(); + } + + //jump to previous bookmark + private void mnuEdit_PrevBookmark_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + ef.sBox.GotoPreviousBookmark(); + } + + private void MDIParent_Closing(object sender, CancelEventArgs e) {} + + private void mnuFile_New_Click(object sender, EventArgs e) + { + var lf = new LanguageForm(Languages); + if (lf.ShowDialog() == DialogResult.OK) + { + lf.EditForm.MdiParent = this; + lf.EditForm.Show(); + } + } + + public void ShowSaveDialog(EditForm ef) + { + dlgSave.FileName = ef.Doc.Path; + if (dlgSave.ShowDialog(this) == DialogResult.OK) + { + string f = dlgSave.FileName; + ef.SaveAs(f); + } + } + + private void mnuFile_Save_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + if (ef.Doc.Path != "") + ef.SaveAs(ef.Doc.Path); + else + { + ShowSaveDialog(ef); + } + } + + private void mnuFile_SaveAs_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + ShowSaveDialog(ef); + } + + private void mnuFile_Exit_Click(object sender, EventArgs e) + { + Close(); + } + + //print preview the active editor + private void mnuFile_PrintPreview_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + var pd = new SourceCodePrintDocument(ef.sDoc); + dlgPrintPreview.Document = pd; + dlgPrintPreview.ShowDialog(this); + } + + //print the content of the active editor + private void mnuFile_Print_Click(object sender, EventArgs e) + { + if (ActiveMdiChild == null) return; + var ef = (EditForm) ActiveMdiChild; + var pd = new SourceCodePrintDocument(ef.sDoc); + dlgPrint.Document = pd; + if (dlgPrint.ShowDialog(this) == DialogResult.OK) + pd.Print(); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + var resources = new System.Resources.ResourceManager(typeof (MDIParent)); + this.MainMenu = new System.Windows.Forms.MainMenu(); + this.mnuFile = new System.Windows.Forms.MenuItem(); + this.mnuFile_New = new System.Windows.Forms.MenuItem(); + this.mnuFile_Open = new System.Windows.Forms.MenuItem(); + this.mnuFile_Save = new System.Windows.Forms.MenuItem(); + this.mnuFile_SaveAs = new System.Windows.Forms.MenuItem(); + this.menuItem5 = new System.Windows.Forms.MenuItem(); + this.mnuFile_PrintPreview = new System.Windows.Forms.MenuItem(); + this.mnuFile_Print = new System.Windows.Forms.MenuItem(); + this.menuItem4 = new System.Windows.Forms.MenuItem(); + this.mnuFile_Exit = new System.Windows.Forms.MenuItem(); + this.mnuEdit = new System.Windows.Forms.MenuItem(); + this.mnuEdit_Undo = new System.Windows.Forms.MenuItem(); + this.mnuEdit_Redo = new System.Windows.Forms.MenuItem(); + this.menuItem12 = new System.Windows.Forms.MenuItem(); + this.mnuEdit_Copy = new System.Windows.Forms.MenuItem(); + this.mnuEdit_Cut = new System.Windows.Forms.MenuItem(); + this.mnuEdit_Paste = new System.Windows.Forms.MenuItem(); + this.mnuEdit_Delete = new System.Windows.Forms.MenuItem(); + this.menuItem17 = new System.Windows.Forms.MenuItem(); + this.mnuEdit_SelectAll = new System.Windows.Forms.MenuItem(); + this.menuItem19 = new System.Windows.Forms.MenuItem(); + this.mnuEdit_ToggleBookmark = new System.Windows.Forms.MenuItem(); + this.mnuEdit_NextBookmark = new System.Windows.Forms.MenuItem(); + this.mnuEdit_PrevBookmark = new System.Windows.Forms.MenuItem(); + this.menuItem1 = new System.Windows.Forms.MenuItem(); + this.panel1 = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.dlgOpen = new System.Windows.Forms.OpenFileDialog(); + this.dlgSave = new System.Windows.Forms.SaveFileDialog(); + this.dlgPrintPreview = new System.Windows.Forms.PrintPreviewDialog(); + this.dlgPrint = new System.Windows.Forms.PrintDialog(); + this.panel2 = new System.Windows.Forms.Panel(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // MainMenu + // + this.MainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] + {this.mnuFile, this.mnuEdit, this.menuItem1}); + // + // mnuFile + // + this.mnuFile.Index = 0; + this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] + { + this.mnuFile_New, this.mnuFile_Open, this.mnuFile_Save, this.mnuFile_SaveAs + , this.menuItem5, this.mnuFile_PrintPreview, this.mnuFile_Print, + this.menuItem4, this.mnuFile_Exit + }); + this.mnuFile.Text = "File"; + // + // mnuFile_New + // + this.mnuFile_New.Index = 0; + this.mnuFile_New.Text = "New"; + this.mnuFile_New.Click += new System.EventHandler(this.mnuFile_New_Click); + // + // mnuFile_Open + // + this.mnuFile_Open.Index = 1; + this.mnuFile_Open.Text = "&Open"; + this.mnuFile_Open.Click += new System.EventHandler(this.mnuFile_Open_Click); + // + // mnuFile_Save + // + this.mnuFile_Save.Index = 2; + this.mnuFile_Save.Text = "&Save"; + this.mnuFile_Save.Click += new System.EventHandler(this.mnuFile_Save_Click); + // + // mnuFile_SaveAs + // + this.mnuFile_SaveAs.Index = 3; + this.mnuFile_SaveAs.Text = "Save &As"; + this.mnuFile_SaveAs.Click += new System.EventHandler(this.mnuFile_SaveAs_Click); + // + // menuItem5 + // + this.menuItem5.Index = 4; + this.menuItem5.Text = "-"; + // + // mnuFile_PrintPreview + // + this.mnuFile_PrintPreview.Index = 5; + this.mnuFile_PrintPreview.Text = "Print Preview"; + this.mnuFile_PrintPreview.Click += new System.EventHandler(this.mnuFile_PrintPreview_Click); + // + // mnuFile_Print + // + this.mnuFile_Print.Index = 6; + this.mnuFile_Print.Text = "Print"; + this.mnuFile_Print.Click += new System.EventHandler(this.mnuFile_Print_Click); + // + // menuItem4 + // + this.menuItem4.Index = 7; + this.menuItem4.Text = "-"; + // + // mnuFile_Exit + // + this.mnuFile_Exit.Index = 8; + this.mnuFile_Exit.Text = "&Exit"; + this.mnuFile_Exit.Click += new System.EventHandler(this.mnuFile_Exit_Click); + // + // mnuEdit + // + this.mnuEdit.Index = 1; + this.mnuEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] + { + this.mnuEdit_Undo, this.mnuEdit_Redo, this.menuItem12, this.mnuEdit_Copy, + this.mnuEdit_Cut, this.mnuEdit_Paste, this.mnuEdit_Delete, this.menuItem17, + this.mnuEdit_SelectAll, this.menuItem19, this.mnuEdit_ToggleBookmark, + this.mnuEdit_NextBookmark, this.mnuEdit_PrevBookmark + }); + this.mnuEdit.Text = "Edit"; + this.mnuEdit.Popup += new System.EventHandler(this.mnuEdit_Popup); + // + // mnuEdit_Undo + // + this.mnuEdit_Undo.Index = 0; + this.mnuEdit_Undo.Shortcut = System.Windows.Forms.Shortcut.CtrlZ; + this.mnuEdit_Undo.Text = "Undo"; + this.mnuEdit_Undo.Click += new System.EventHandler(this.mnuEdit_Undo_Click); + // + // mnuEdit_Redo + // + this.mnuEdit_Redo.Index = 1; + this.mnuEdit_Redo.Shortcut = System.Windows.Forms.Shortcut.CtrlY; + this.mnuEdit_Redo.Text = "Redo"; + this.mnuEdit_Redo.Click += new System.EventHandler(this.mnuEdit_Redo_Click); + // + // menuItem12 + // + this.menuItem12.Index = 2; + this.menuItem12.Text = "-"; + // + // mnuEdit_Copy + // + this.mnuEdit_Copy.Index = 3; + this.mnuEdit_Copy.Shortcut = System.Windows.Forms.Shortcut.CtrlC; + this.mnuEdit_Copy.Text = "Copy"; + this.mnuEdit_Copy.Click += new System.EventHandler(this.mnuEdit_Copy_Click); + // + // mnuEdit_Cut + // + this.mnuEdit_Cut.Index = 4; + this.mnuEdit_Cut.Shortcut = System.Windows.Forms.Shortcut.CtrlX; + this.mnuEdit_Cut.Text = "Cut"; + this.mnuEdit_Cut.Click += new System.EventHandler(this.mnuEdit_Cut_Click); + // + // mnuEdit_Paste + // + this.mnuEdit_Paste.Index = 5; + this.mnuEdit_Paste.Shortcut = System.Windows.Forms.Shortcut.CtrlV; + this.mnuEdit_Paste.Text = "Paste"; + this.mnuEdit_Paste.Click += new System.EventHandler(this.mnuEdit_Paste_Click); + // + // mnuEdit_Delete + // + this.mnuEdit_Delete.Index = 6; + this.mnuEdit_Delete.Text = "Delete"; + this.mnuEdit_Delete.Click += new System.EventHandler(this.mnuEdit_Delete_Click); + // + // menuItem17 + // + this.menuItem17.Index = 7; + this.menuItem17.Text = "-"; + // + // mnuEdit_SelectAll + // + this.mnuEdit_SelectAll.Index = 8; + this.mnuEdit_SelectAll.Shortcut = System.Windows.Forms.Shortcut.CtrlA; + this.mnuEdit_SelectAll.Text = "Select All"; + this.mnuEdit_SelectAll.Click += new System.EventHandler(this.mnuEdit_SelectAll_Click); + // + // menuItem19 + // + this.menuItem19.Index = 9; + this.menuItem19.Text = "-"; + // + // mnuEdit_ToggleBookmark + // + this.mnuEdit_ToggleBookmark.Index = 10; + this.mnuEdit_ToggleBookmark.Shortcut = System.Windows.Forms.Shortcut.AltF2; + this.mnuEdit_ToggleBookmark.Text = "Toggle Bookmark"; + this.mnuEdit_ToggleBookmark.Click += new System.EventHandler(this.mnuEdit_ToggleBookmark_Click); + // + // mnuEdit_NextBookmark + // + this.mnuEdit_NextBookmark.Index = 11; + this.mnuEdit_NextBookmark.Shortcut = System.Windows.Forms.Shortcut.F2; + this.mnuEdit_NextBookmark.Text = "Next Bookmark"; + this.mnuEdit_NextBookmark.Click += new System.EventHandler(this.mnuEdit_NextBookmark_Click); + // + // mnuEdit_PrevBookmark + // + this.mnuEdit_PrevBookmark.Index = 12; + this.mnuEdit_PrevBookmark.Shortcut = System.Windows.Forms.Shortcut.ShiftF2; + this.mnuEdit_PrevBookmark.Text = "Prev Bookmark"; + this.mnuEdit_PrevBookmark.Click += new System.EventHandler(this.mnuEdit_PrevBookmark_Click); + // + // menuItem1 + // + this.menuItem1.Index = 2; + this.menuItem1.MdiList = true; + this.menuItem1.Text = "Window"; + // + // panel1 + // + this.panel1.BackColor = System.Drawing.SystemColors.ActiveCaption; + this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {this.label1}); + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(0, 549); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(696, 24); + this.panel1.TabIndex = 1; + // + // label1 + // + this.label1.BackColor = System.Drawing.SystemColors.ActiveCaption; + this.label1.Dock = System.Windows.Forms.DockStyle.Fill; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, + System.Drawing.GraphicsUnit.Point, ((System.Byte) (0))); + this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(696, 24); + this.label1.TabIndex = 0; + this.label1.Text = "Powered by Compona SyntaxBox"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // dlgSave + // + this.dlgSave.FileName = "doc1"; + // + // dlgPrintPreview + // + this.dlgPrintPreview.AutoScrollMargin = new System.Drawing.Size(0, 0); + this.dlgPrintPreview.AutoScrollMinSize = new System.Drawing.Size(0, 0); + this.dlgPrintPreview.ClientSize = new System.Drawing.Size(400, 300); + this.dlgPrintPreview.Enabled = true; + this.dlgPrintPreview.Icon = ((System.Drawing.Icon) (resources.GetObject("dlgPrintPreview.Icon"))); + this.dlgPrintPreview.Location = new System.Drawing.Point(302, 17); + this.dlgPrintPreview.MaximumSize = new System.Drawing.Size(0, 0); + this.dlgPrintPreview.Name = "dlgPrintPreview"; + this.dlgPrintPreview.Opacity = 1; + this.dlgPrintPreview.TransparencyKey = System.Drawing.Color.Empty; + this.dlgPrintPreview.Visible = false; + // + // panel2 + // + this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel2.Location = new System.Drawing.Point(0, 541); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(696, 8); + this.panel2.TabIndex = 3; + // + // MDIParent + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(696, 573); + this.Controls.AddRange(new System.Windows.Forms.Control[] {this.panel2, this.panel1}); + this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon"))); + this.IsMdiContainer = true; + this.Menu = this.MainMenu; + this.Name = "MDIParent"; + this.Text = "ComPad"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.Closing += new System.ComponentModel.CancelEventHandler(this.MDIParent_Closing); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIParent.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIParent.resx new file mode 100644 index 0000000..ceacf30 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/MDIParent.resx @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 119, 17 + + + 212, 17 + + + 302, 17 + + + + AAABAAIAICAQAAAAAADoAgAAJgAAABAQEAAAAAAAKAEAAA4DAAAoAAAAIAAAAEAAAAABAAQAAAAAAIAC + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/ + AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAiIiIiIiI + iIiIiIiIiIiIiIAACAAAAAjMzMzMzMzIAAiAAAgAAAAIzubm5ubmyAAIgAAIAAAACM5ubm5ubsgACIAA + CAAAAAjO5ubm5ubIAAiAAAgAAAAIzm5ubm5uyAAIgAAIAAAACM7m5ubm5sgACIiIiIiIiIjObm5ubm7I + AAiBEREREREYzu7u7u7uyAAIgdlZWVlZGMzMzMzMzMgACIHVlZWVlRiIiIiIiIiIiIiB2VlZWVkYMzMz + MzMzMzM4gdWVlZWVGD+4uLi4uLi4OIHZWVlZWRg/u4uLi4uLiziB1ZWVlZUYP7i4uLi4uLg4gdlZWVlZ + GD+7i4uLi4uLOIHVlZWVlRg/uLi4uLi4uDiB2VlZWVkYP7uLi4uLi4s4gdWVlZWVGD+4uLi4uLi4OIHd + 3d3d3Rg/u4uLi4uLiziBEREREREYP7i4uLi4uLg4iIiIiIiIiD+7i4uLi4uLOIAAAAAAAAg/uLi4uLi4 + uDiAAAAAAAAIP7uLi4uLi4s4gAAAAAAACD+4uLi4uLi4OIAAAAAAAAg/u7u7u7u7uziAAAAAAAAIP/// + //////84gAAAAAAACDMzMzMzMzMzOIiIiIiIiIiIiIiIiIiIiIgAAAAAAAAAAAAAAAAAAAAA//////// + //8AAAAAe/gADnv4AA57+AAOe/gADnv4AA57+AAOAAAADgAAAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf/gAAH/4AAB/+AAAf/gAAH/4AAB/+AAAAAAAAP// + //8oAAAAEAAAACAAAAABAAQAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAA + AACAAIAAgIAAAICAgADAwMAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAiIiIiIiI + iIiACACMzMzICIAIAIzmZsgIiIiIjO7uyAiBERGMzMzICIHZkYiIiIiIgdmRgzMzMziB2ZGD+7u7OIHd + 0YP7u7s4gRERg/u7uziIiIiD+7u7OIAAAIP7u7s4gAAAg////ziAAACDMzMzOIiIiIiIiIiI//8AAAAA + AABsAgAAbAIAAAACAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfAAAAHwAAAB8AAAAAAAAAA== + + + + 430, 17 + + + MDIParent + + + + AAABAAEAEBAAAAAAAABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAB + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAMDcwADwyqYABAQEAAgICAAMDAwAERERABYW + FgAcHBwAIiIiACkpKQBVVVUATU1NAEJCQgA5OTkAgHz/AFBQ/wCTANYA/+zMAMbW7wDW5+cAkKmtAAAA + MwAAAGYAAACZAAAAzAAAMwAAADMzAAAzZgAAM5kAADPMAAAz/wAAZgAAAGYzAABmZgAAZpkAAGbMAABm + /wAAmQAAAJkzAACZZgAAmZkAAJnMAACZ/wAAzAAAAMwzAADMZgAAzJkAAMzMAADM/wAA/2YAAP+ZAAD/ + zAAzAAAAMwAzADMAZgAzAJkAMwDMADMA/wAzMwAAMzMzADMzZgAzM5kAMzPMADMz/wAzZgAAM2YzADNm + ZgAzZpkAM2bMADNm/wAzmQAAM5kzADOZZgAzmZkAM5nMADOZ/wAzzAAAM8wzADPMZgAzzJkAM8zMADPM + /wAz/zMAM/9mADP/mQAz/8wAM///AGYAAABmADMAZgBmAGYAmQBmAMwAZgD/AGYzAABmMzMAZjNmAGYz + mQBmM8wAZjP/AGZmAABmZjMAZmZmAGZmmQBmZswAZpkAAGaZMwBmmWYAZpmZAGaZzABmmf8AZswAAGbM + MwBmzJkAZszMAGbM/wBm/wAAZv8zAGb/mQBm/8wAzAD/AP8AzACZmQAAmTOZAJkAmQCZAMwAmQAAAJkz + MwCZAGYAmTPMAJkA/wCZZgAAmWYzAJkzZgCZZpkAmWbMAJkz/wCZmTMAmZlmAJmZmQCZmcwAmZn/AJnM + AACZzDMAZsxmAJnMmQCZzMwAmcz/AJn/AACZ/zMAmcxmAJn/mQCZ/8wAmf//AMwAAACZADMAzABmAMwA + mQDMAMwAmTMAAMwzMwDMM2YAzDOZAMwzzADMM/8AzGYAAMxmMwCZZmYAzGaZAMxmzACZZv8AzJkAAMyZ + MwDMmWYAzJmZAMyZzADMmf8AzMwAAMzMMwDMzGYAzMyZAMzMzADMzP8AzP8AAMz/MwCZ/2YAzP+ZAMz/ + zADM//8AzAAzAP8AZgD/AJkAzDMAAP8zMwD/M2YA/zOZAP8zzAD/M/8A/2YAAP9mMwDMZmYA/2aZAP9m + zADMZv8A/5kAAP+ZMwD/mWYA/5mZAP+ZzAD/mf8A/8wAAP/MMwD/zGYA/8yZAP/MzAD/zP8A//8zAMz/ + ZgD//5kA///MAGZm/wBm/2YAZv//AP9mZgD/Zv8A//9mACEApQBfX18Ad3d3AIaGhgCWlpYAy8vLALKy + sgDX19cA3d3dAOPj4wDq6uoA8fHxAPj4+ADw+/8ApKCgAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8ACgoKCgwMDAoKDAwMCgoKCgoKCgxtdHMMDOsc7AwKCgoKCjwSeTJZ6wp6MnrrPAoKCgoKc1ky + OBwSWTJZeQoKCgoKCkN6ODgc7Fk4WUMKCgoKPBMSSiNZeXlZI0oSEjwKX0p5dEoSWZSUWepKeVhKXwqZ + WVlYeZQyMpR5WFlZegoKmjIyWViUMjKUeVkyMnoKPHNZWUttWZSUWetLWFlzPAo8c3MVI1lYeVkjFetz + PAoKCgoQeVk4HO1ZOHoRCgoKCgoKc1kyOHNtWTJZHAoKCgoKDOt6MlkK6lkyWXMMCgoKCgoMc3ocDAxz + ehwMCgoKCgoKCgoKCgoKCgoKCgoKCvGPAADgBwAAwAMAAMADAADAAwAAgAEAAAAAAAAAAAAAAAAAAAAA + AACAAQAAwAMAAMADAADAAwAA4AcAAPGPAAA= + + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Properties/Resources.Designer.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Properties/Resources.Designer.cs new file mode 100644 index 0000000..e56ca04 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.3031 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace MDIDemo.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MDIDemo.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Properties/Resources.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Properties/Resources.resx new file mode 100644 index 0000000..5ea0895 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Properties/Resources.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/SettingsForm.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/SettingsForm.cs new file mode 100644 index 0000000..abd0a99 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/SettingsForm.cs @@ -0,0 +1,243 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; +using Alsing.SourceCode; +using Alsing.Windows.Forms; + +namespace MDIDemo +{ + /// + /// Summary description for SettingsForm. + /// + public class SettingsForm : Form + { + private readonly SyntaxBoxControl sb; + private Button btnCancel; + private Button btnOK; + private IContainer components; + private ImageList imageList1; + private Label lblPreview; + private ListBox lbStyles; + private Panel panel1; + private Panel panel2; + private PropertyGrid pgStyles; + private Splitter splitter1; + private Splitter splitter2; + + public SettingsForm(SyntaxBoxControl sb) + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + this.sb = sb; + + SyntaxDefinition l = sb.Document.Parser.SyntaxDefinition; + TextStyle[] tss = l.Styles; + + + lbStyles.Items.Clear(); + for (int i = 0; i < tss.Length; i++) + { + TextStyle ts = tss[i]; + var s = new Style {TextStyle = ts, Name = ts.Name}; + //s.Name=ts.Name; + lbStyles.Items.Add(s); + } + lbStyles.SelectedIndex = 0; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + private void SettingsForm_Load(object sender, EventArgs e) {} + + private void lbStyles_SelectedIndexChanged(object sender, EventArgs e) + { + pgStyles.SelectedObject = lbStyles.SelectedItem; + var st = lbStyles.SelectedItem as Style; + PreviewStyle(st); + } + + private void pgStyles_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) + { + var st = lbStyles.SelectedItem as Style; + PreviewStyle(st); + sb.Refresh(); + } + + private void PreviewStyle(Style s) + { + lblPreview.ForeColor = s.ForeColor; + lblPreview.BackColor = s.BackColor != Color.Transparent ? s.BackColor : sb.BackColor; + + FontStyle fs = FontStyle.Regular; + if (s.FontBold) + fs |= FontStyle.Bold; + if (s.FontItalic) + fs |= FontStyle.Italic; + if (s.FontUnderline) + fs |= FontStyle.Underline; + + lblPreview.Font = new Font("Courier New", 11f, fs); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.pgStyles = new System.Windows.Forms.PropertyGrid(); + this.imageList1 = new System.Windows.Forms.ImageList(this.components); + this.splitter1 = new System.Windows.Forms.Splitter(); + this.panel1 = new System.Windows.Forms.Panel(); + this.lblPreview = new System.Windows.Forms.Label(); + this.splitter2 = new System.Windows.Forms.Splitter(); + this.lbStyles = new System.Windows.Forms.ListBox(); + this.panel2 = new System.Windows.Forms.Panel(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnOK = new System.Windows.Forms.Button(); + this.panel1.SuspendLayout(); + this.panel2.SuspendLayout(); + this.SuspendLayout(); + // + // pgStyles + // + this.pgStyles.CommandsVisibleIfAvailable = true; + this.pgStyles.Dock = System.Windows.Forms.DockStyle.Fill; + this.pgStyles.HelpVisible = false; + this.pgStyles.LargeButtons = false; + this.pgStyles.LineColor = System.Drawing.SystemColors.ScrollBar; + this.pgStyles.Name = "pgStyles"; + this.pgStyles.Size = new System.Drawing.Size(304, 265); + this.pgStyles.TabIndex = 0; + this.pgStyles.Text = "propertyGrid1"; + this.pgStyles.ToolbarVisible = false; + this.pgStyles.ViewBackColor = System.Drawing.SystemColors.Window; + this.pgStyles.ViewForeColor = System.Drawing.SystemColors.WindowText; + this.pgStyles.PropertyValueChanged += + new System.Windows.Forms.PropertyValueChangedEventHandler(this.pgStyles_PropertyValueChanged); + // + // imageList1 + // + this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; + this.imageList1.ImageSize = new System.Drawing.Size(16, 16); + this.imageList1.TransparentColor = System.Drawing.Color.Transparent; + // + // splitter1 + // + this.splitter1.Dock = System.Windows.Forms.DockStyle.Right; + this.splitter1.Location = new System.Drawing.Point(189, 7); + this.splitter1.Name = "splitter1"; + this.splitter1.Size = new System.Drawing.Size(6, 265); + this.splitter1.TabIndex = 1; + this.splitter1.TabStop = false; + // + // panel1 + // + this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] + {this.splitter2, this.lblPreview, this.pgStyles}); + this.panel1.Dock = System.Windows.Forms.DockStyle.Right; + this.panel1.Location = new System.Drawing.Point(195, 7); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(304, 265); + this.panel1.TabIndex = 3; + // + // lblPreview + // + this.lblPreview.BackColor = System.Drawing.SystemColors.Window; + this.lblPreview.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.lblPreview.Dock = System.Windows.Forms.DockStyle.Bottom; + this.lblPreview.Font = new System.Drawing.Font("Courier New", 11F, System.Drawing.FontStyle.Regular, + System.Drawing.GraphicsUnit.Point, ((System.Byte) (0))); + this.lblPreview.Location = new System.Drawing.Point(0, 169); + this.lblPreview.Name = "lblPreview"; + this.lblPreview.Size = new System.Drawing.Size(304, 96); + this.lblPreview.TabIndex = 3; + this.lblPreview.Text = "The quick brown fox jumped over the cliff"; + this.lblPreview.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // splitter2 + // + this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.splitter2.Location = new System.Drawing.Point(0, 163); + this.splitter2.Name = "splitter2"; + this.splitter2.Size = new System.Drawing.Size(304, 6); + this.splitter2.TabIndex = 4; + this.splitter2.TabStop = false; + // + // lbStyles + // + this.lbStyles.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbStyles.IntegralHeight = false; + this.lbStyles.Location = new System.Drawing.Point(7, 7); + this.lbStyles.Name = "lbStyles"; + this.lbStyles.Size = new System.Drawing.Size(182, 265); + this.lbStyles.Sorted = true; + this.lbStyles.TabIndex = 4; + this.lbStyles.SelectedIndexChanged += new System.EventHandler(this.lbStyles_SelectedIndexChanged); + // + // panel2 + // + this.panel2.Controls.AddRange(new System.Windows.Forms.Control[] {this.btnCancel, this.btnOK}); + this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel2.Location = new System.Drawing.Point(7, 272); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(492, 40); + this.panel2.TabIndex = 5; + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(408, 9); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.TabIndex = 4; + this.btnCancel.Text = "Cancel"; + // + // btnOK + // + this.btnOK.Location = new System.Drawing.Point(320, 9); + this.btnOK.Name = "btnOK"; + this.btnOK.TabIndex = 3; + this.btnOK.Text = "OK"; + // + // SettingsForm + // + this.AcceptButton = this.btnOK; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(506, 319); + this.Controls.AddRange(new System.Windows.Forms.Control[] + {this.lbStyles, this.splitter1, this.panel1, this.panel2}); + this.DockPadding.All = 7; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SettingsForm"; + this.Text = "SettingsForm"; + this.Load += new System.EventHandler(this.SettingsForm_Load); + this.panel1.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.ResumeLayout(false); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/SettingsForm.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/SettingsForm.resx new file mode 100644 index 0000000..d340b97 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/SettingsForm.resx @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + SettingsForm + + \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Style.cs b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Style.cs new file mode 100644 index 0000000..2ac0451 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Style.cs @@ -0,0 +1,84 @@ +using System.ComponentModel; +using System.Drawing; +using Alsing.SourceCode; + + +namespace MDIDemo +{ + public class Style : Component + { + private Container components; + public string Name = ""; + public TextStyle TextStyle; + + public Style(IContainer container) + { + container.Add(this); + InitializeComponent(); + } + + public Style() + { + InitializeComponent(); + } + + [Category("Color")] + public Color ForeColor + { + get { return TextStyle.ForeColor; } + set { TextStyle.ForeColor = value; } + } + + [Category("Color")] + public Color BackColor + { + get { return TextStyle.BackColor; } + set { TextStyle.BackColor = value; } + } + + [Category("Font")] + public bool FontBold + { + get { return TextStyle.Bold; } + set { TextStyle.Bold = value; } + } + + [Category("Font")] + public bool FontItalic + { + get { return TextStyle.Italic; } + set { TextStyle.Italic = value; } + } + + [Category("Font")] + public bool FontUnderline + { + get { return TextStyle.Underline; } + set { TextStyle.Underline = value; } + } + + public Container Components + { + get { return components; } + } + + + public override string ToString() + { + return Name; + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} \ No newline at end of file diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Style.resx b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Style.resx new file mode 100644 index 0000000..6b3c4ce --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/Style.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/6502.syn b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/6502.syn new file mode 100644 index 0000000..13e4518 --- /dev/null +++ b/WindowsFormsComponents/Alsing.SyntaxoBox/Samples/MdiDemo/bin/Debug/6502.syn @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + +ADC AND ASL +BCC BCS BEQ BIT BMI BNE BPL BRA BRK BVC BVS +CLC CLD CLI CLV CMP CPX CPY +DEC DEX DEY +EOR +INC INX INY +JMP JSR +LDA LDX LDY LSR +NOP +ORA +PHA PHP PHX PHY PLA PLP PLX PLY +ROL ROR RTI RTS +SBC SEC SED SEI STA STX STY STZ +TAX TAY TSX TXA TXS TYA + + + + + + +.byte .text .word .asc .scrl .scru .include .incbin .label .goto .if .end .enrty .opt +.set .title +X +Y +C + + + + + + + + + + + + + + +# +$ +% +( +) ++ +, +; +*= +* += + + + + + + + + + + + + + + + + + + +