Esempio n. 1
0
 /// <summary>
 /// Raises the <see cref="FoldChanged"/> event.
 /// </summary>
 /// <param name="e">An <see cref="FoldChangedEventArgs"/> that contains the event data.</param>
 protected virtual void OnFoldChanged(FoldChangedEventArgs e)
 {
     EventHandler<FoldChangedEventArgs> handler = Events[_foldChangedEventKey] as EventHandler<FoldChangedEventArgs>;
     if (handler != null)
         handler(this, e);
 }
		internal void FireModified(NativeScintillaEventArgs ea)
		{
			//	First we fire the INativeScintilla Modified event.
			if(Events[_modifiedEventKey] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_modifiedEventKey])(this, ea);

			//	Now we use raw information from the Modified event to construct
			//	some more user friendly Events to fire.
			SCNotification scn	= ea.SCNotification;
			int modType			= scn.modificationType;

			if((modType & TEXT_MODIFIED_FLAGS) > 0)
			{
				TextModifiedEventArgs mea = new TextModifiedEventArgs
					(
					modType,
					(modType & Constants.SC_PERFORMED_USER) != 0,
					scn.line,
					scn.position,
					scn.length,
					scn.linesAdded,
					Utilities.IntPtrToString(_encoding, scn.text, scn.length)
					);

				//	Adding in TextChanged because it's really common to 
				//	just want to know when the damned text changed
				bool textChanged = false;

				//	These messages all get fired seperately hence the if else ifs
				if ((modType & Constants.SC_MOD_BEFOREDELETE) > 0)
				{
					OnBeforeTextDelete(mea);
					textChanged = true;
				}
				else if ((modType & Constants.SC_MOD_BEFOREINSERT) > 0)
				{
					OnBeforeTextInsert(mea);
					textChanged = true;
				}
				else if ((modType & Constants.SC_MOD_DELETETEXT) > 0)
				{
					OnTextDeleted(mea);
					textChanged = true;
				}
				else if ((modType & Constants.SC_MOD_INSERTTEXT) > 0)
				{
					OnTextInserted(mea);
					textChanged = true;
				}

				if (textChanged)
				{
					_textChangedTimer.Start();
				}
			}
			else if((modType & Constants.SC_MOD_CHANGEFOLD) > 0)
			{
				FoldChangedEventArgs fea = new FoldChangedEventArgs(scn.line, scn.foldLevelNow, scn.foldLevelPrev, scn.modificationType);
				OnFoldChanged(fea);
			}
			else if((modType & Constants.SC_MOD_CHANGESTYLE) > 0)
			{
				StyleChangedEventArgs sea = new StyleChangedEventArgs(scn.position, scn.length, scn.modificationType);
				OnStyleChanged(sea);
			}
			else if((modType & Constants.SC_MOD_CHANGEMARKER) > 0)
			{
				MarkerChangedEventArgs mea = new MarkerChangedEventArgs(scn.line, scn.modificationType);
				OnMarkerChanged(mea);
			}

			OnDocumentChange(ea);
		}