Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » General » Downloads
 
Add your own
alternative version

CodeDom Assistant

, 21 Sep 2007
Generating CodeDom Code By Parsing C# or VB
codedomassistant_demo.zip
CodeDomAssistant_Demo
CodeDomAssistant.exe
ICSharpCode.NRefactory.dll
RemoteLoader.dll
SciLexer.dll
ScintillaNet.dll
codedomassistant_src.zip
sln.CodeDomAssistant
CodeDomAssistant
bin
Debug
SciLexer.dll
Properties
Settings.settings
NRefactory
NRefactoryASTGenerator
AST
Project
Configuration
Resources
ICSharpCode.NRefactory.snk
Src
Ast
General
Lexer
BuildKeywords.pl
CSharp
Special
VBNet
Parser
CSharp
cs.ATG
Frames
Parser.frame
Scanner.frame
SharpCoco.exe
VBNet
VBNET.ATG
PrettyPrinter
CSharp
VBNet
Visitors
Test
General
Lexer
CSharp
VBNet
Output
CodeDOM
CSharp
VBNet
Parser
Expressions
GlobalScope
Statements
TypeLevel
RemoteLoader
Properties
ScintillaNET
Configuration
Builtin
LexerKeywordListNames
LexerStyleNames
FindReplace
Printing
Properties
Resources
DeleteHS.png
GoToNextMessage - Copy.png
GoToNextMessage.png
GoToPreviousMessage.png
LineColorHS.png
Thumbs.db
ScintillaNET.csproj.vspscc
Snippets
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace ScintillaNet
{
	public class Line : ScintillaHelperBase
	{
		private int _number = 0;
		protected internal Line(Scintilla scintilla, int number) : base(scintilla) 
		{
			_number = number;
		}

		public int Number
		{
			get
			{
				return _number;
			}
			set
			{
				_number = value;
			}
		}

		public string Text
		{
			get
			{
				string s;
				NativeScintilla.GetLine(_number, out s);
				return s;
			}
			set
			{
				NativeScintilla.SetTargetStart(StartPosition);
				NativeScintilla.SetTargetEnd(EndPosition);
				NativeScintilla.ReplaceTarget(-1, value);
			}
		}

		public Range Range
		{
			get
			{
				return Scintilla.GetRange(StartPosition, EndPosition);
			}
		}

		public void Select()
		{
			NativeScintilla.SetSel(StartPosition, EndPosition);
		}

		public int StartPosition
		{
			get
			{
				return NativeScintilla.PositionFromLine(_number);
			}
		}

		public int EndPosition
		{
			get
			{
				return NativeScintilla.GetLineEndPosition(_number);
			}
		}

		public int Length
        {
			get				
			{
				return NativeScintilla.LineLength(_number);
			}
        }

		public int Height
		{
			get
			{
				return NativeScintilla.TextHeight(_number);
			}
		}

		public void Goto()
		{
			NativeScintilla.GotoLine(_number);
		}

		public int LineState
		{
			get
			{
				return NativeScintilla.GetLineState(_number);
			}
			set
			{
				NativeScintilla.SetLineState(_number, value);
			}
		}

		public int Indentation
		{
			get
			{
				return NativeScintilla.GetLineIndentation(_number);
			}
			set
            {
				NativeScintilla.SetLineIndentation(_number, value);
            }
		}

		public int IndentPosition
		{
			get
			{
				return NativeScintilla.GetLineIndentPosition(_number);
			}
		}

		public int SelectionStartPosition
		{
			get
			{
				return NativeScintilla.GetLineSelStartPosition(_number);
			}
		}

		public int SelectionEndPosition
		{
			get
			{
				return NativeScintilla.GetLineSelEndPosition(_number);
			}
		}

		public MarkerInstance AddMarker(int markerNumber)
		{
			return new MarkerInstance(Scintilla, new Marker(Scintilla, markerNumber), NativeScintilla.MarkerAdd(_number, markerNumber));
		}

		public MarkerInstance AddMarker(Marker marker)
		{
			return new MarkerInstance(Scintilla, marker, NativeScintilla.MarkerAdd(_number, marker.Number));
		}

		public void AddMarkerSet(uint markerMask)
		{
			NativeScintilla.MarkerAddSet(_number, markerMask);
		}

		public void AddMarkerSet(IEnumerable<Marker> markers)
		{
			AddMarkerSet(Utilities.GetMarkerMask(markers));
		}

		public void AddMarkerSet(IEnumerable<int> markers)
		{
			AddMarkerSet(Utilities.GetMarkerMask(markers));
		}

		public void DeleteMarker(int markerNumber)
		{
			NativeScintilla.MarkerDelete(_number, markerNumber);
		}

		public void DeleteMarkerSet(IEnumerable<int> markerNumbers)
		{
			foreach (int markerNumber in markerNumbers)
				NativeScintilla.MarkerDelete(_number, markerNumber);
		}

		public void DeleteMarkerSet(IEnumerable<Marker> markers)
		{
			foreach (Marker m in markers)
				NativeScintilla.MarkerDelete(_number, m.Number);
		}

		public void DeleteAllMarkers()
		{
			DeleteMarker(-1);
		}

		public int GetMarkerMask()
		{
			return NativeScintilla.MarkerGet(_number);
		}

		public List<Marker> GetMarkers()
		{
			List<Marker> ret = new List<Marker>();
			int mask = GetMarkerMask();
			for (int i = 0; i < 32; i++)
				if ((mask & i) == i)
					ret.Add(new Marker(Scintilla, i));

			return ret;
		}

		public Line FindNextMarker(uint markerMask)
		{
			int foundLine = NativeScintilla.MarkerNext(_number + 1, markerMask);
			if (foundLine < 0)
				return null;

			return Scintilla.Lines[foundLine];
		}

		public Line FindNextMarker(Marker marker)
		{
			return FindNextMarker((uint)marker.Number);
		}

		public Line FindNextMarker(IEnumerable<int> markers)
		{
			return FindNextMarker(Utilities.GetMarkerMask(markers));
		}

		public Line FindNextMarker(IEnumerable<Marker> markers)
		{
			return FindNextMarker(Utilities.GetMarkerMask(markers));
		}

		public Line FindPreviousMarker(uint markerMask)
		{
			int foundLine = NativeScintilla.MarkerPrevious(_number - 1, markerMask);
			if (foundLine < 0)
				return null;

			return Scintilla.Lines[foundLine];
		}

		public Line FindPreviousMarker(Marker marker)
		{
			return FindPreviousMarker((uint)marker.Number);
		}

		public Line FindPreviousMarker(IEnumerable<int> markers)
		{
			return FindPreviousMarker(Utilities.GetMarkerMask(markers));
		}

		public Line FindPreviousMarker(IEnumerable<Marker> markers)
		{
			return FindPreviousMarker(Utilities.GetMarkerMask(markers));
		}

		public int VisibleLineNumber
		{
			get
			{
				return NativeScintilla.VisibleFromDocLine(_number);
			}
		}

		public bool IsVisible
		{
			get
			{
				return NativeScintilla.GetLineVisible(_number);
			}
			set
            {
				if (value)
					NativeScintilla.ShowLines(_number, _number);
				else
					NativeScintilla.HideLines(_number, _number);
            }
		}

		public void EnsureVisible()
		{
			NativeScintilla.EnsureVisible(_number);
		}

		public int FoldLevel
		{
			get
			{
				return (int)(NativeScintilla.GetFoldLevel(_number) & Constants.SC_FOLDLEVELNUMBERMASK);
			}
			set
			{
				uint flags = NativeScintilla.GetFoldLevel(_number) & (Constants.SC_FOLDLEVELHEADERFLAG | Constants.SC_FOLDLEVELWHITEFLAG);
				NativeScintilla.SetFoldLevel(_number, (uint)value | flags);
			}
		}

		public bool IsFoldPoint
		{
			get
			{
				return (NativeScintilla.GetFoldLevel(_number) & Constants.SC_FOLDLEVELHEADERFLAG) == Constants.SC_FOLDLEVELHEADERFLAG;
			}
			set
			{
				if (value)
					NativeScintilla.SetFoldLevel(_number, NativeScintilla.GetFoldLevel(_number) | Constants.SC_FOLDLEVELHEADERFLAG);
				else
					NativeScintilla.SetFoldLevel(_number, NativeScintilla.GetFoldLevel(_number) & ~Constants.SC_FOLDLEVELHEADERFLAG);
			}
		}

		public bool IsFoldWhiteSpace
		{
			get
			{
				return (NativeScintilla.GetFoldLevel(_number) & Constants.SC_FOLDLEVELWHITEFLAG) == Constants.SC_FOLDLEVELWHITEFLAG;
			}
			set
			{
				if (value)
					NativeScintilla.SetFoldLevel(_number, NativeScintilla.GetFoldLevel(_number) | Constants.SC_FOLDLEVELWHITEFLAG);
				else
					NativeScintilla.SetFoldLevel(_number, NativeScintilla.GetFoldLevel(_number) & ~Constants.SC_FOLDLEVELWHITEFLAG);
			}
		}

		public void ToggleFoldExpanded()
		{
			NativeScintilla.ToggleFold(_number);
		}

		public bool FoldExpanded
		{
			get
			{
				return NativeScintilla.GetFoldExpanded(_number);
			}
			set
            {
				NativeScintilla.SetFoldExpanded(_number, value);
            }
		}

		public Line GetLastFoldChild()
		{
			return GetLastFoldChild(-1);
		}

		public Line GetLastFoldChild(int level)
		{
			int num = NativeScintilla.GetLastChild(_number, level);
			if (num < 0)
				return null;

			return new Line(Scintilla, num);
		}

		public Line FoldParent
		{
			get
			{
				int num = NativeScintilla.GetFoldParent(_number);
				if (num < 0)
					return null;

				return new Line(Scintilla, num);
			}
		}

		public int WrapCount
		{
			get
			{
				return NativeScintilla.WrapCount(_number);
			}
		}

		public override bool Equals(object obj)
		{
			Line l = obj as Line;
			if (l == null)
				return false;

			return l.Scintilla == Scintilla && l._number == _number;
		}

		public override string ToString()
		{
			return "Line " + _number.ToString();
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}

		public Line Next
		{
			get
			{
				return new Line(Scintilla, _number + 1);
			}
		}

		public Line Previous
		{
			get
			{
				return new Line(Scintilla, _number - 1);
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

raygilbert
Web Developer
Australia Australia
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411022.1 | Last Updated 21 Sep 2007
Article Copyright 2007 by raygilbert
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid