本文整理汇总了C#中PluginCore.TextEvent类的典型用法代码示例。如果您正苦于以下问题:C# TextEvent类的具体用法?C# TextEvent怎么用?C# TextEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextEvent类属于PluginCore命名空间,在下文中一共展示了TextEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: updater_Tick
void updater_Tick(object sender, EventArgs e)
{
updater.Stop();
string src = File.Exists(logFile) ? File.ReadAllText(logFile) : "";
MatchCollection matches = reError.Matches(src);
TextEvent te;
if (matches.Count == 0)
{
te = new TextEvent(EventType.ProcessEnd, "Done(0)");
EventManager.DispatchEvent(this, te);
if (!te.Handled) PlaySWF();
return;
}
NotifyEvent ne = new NotifyEvent(EventType.ProcessStart);
EventManager.DispatchEvent(this, ne);
foreach (Match m in matches)
{
string file = m.Groups["file"].Value;
string line = m.Groups["line"].Value;
string desc = m.Groups["desc"].Value.Trim();
TraceManager.Add(String.Format("{0}:{1}: {2}", file, line, desc), -3);
}
te = new TextEvent(EventType.ProcessEnd, "Done(" + matches.Count + ")");
EventManager.DispatchEvent(this, te);
(PluginBase.MainForm as Form).Activate();
(PluginBase.MainForm as Form).Focus();
}
示例2: updater_Tick
void updater_Tick(object sender, EventArgs e)
{
updater.Stop();
string src = File.Exists(logFile) ? File.ReadAllText(logFile) : "";
MatchCollection errorMatches = reError.Matches(src);
MatchCollection warningMatches = warnError.Matches(src);
TextEvent te;
if (errorMatches.Count == 0 && warningMatches.Count == 0)
{
te = new TextEvent(EventType.ProcessEnd, "Done(0)");
EventManager.DispatchEvent(this, te);
if (!te.Handled) PlaySWF();
return;
}
NotifyEvent ne = new NotifyEvent(EventType.ProcessStart);
EventManager.DispatchEvent(this, ne);
foreach (Match m in errorMatches)
{
string file = m.Groups["file"].Value;
string line = m.Groups["line"].Value;
string desc = m.Groups["desc"].Value.Trim();
Match mCol = Regex.Match(desc, @"\s*[a-z]+\s([0-9]+)\s");
if (mCol.Success)
{
line += "," + mCol.Groups[1].Value;
desc = desc.Substring(mCol.Length);
}
TraceManager.Add(String.Format("{0}({1}): {2}", file, line, desc), -3);
}
foreach (Match m in warningMatches)
{
string file = m.Groups["file"].Value;
string line = m.Groups["line"].Value;
string desc = m.Groups["desc"].Value.Trim();
Match mCol = Regex.Match(desc, @"\s*[a-z]+\s([0-9]+)\s");
if (mCol.Success)
{
line += "," + mCol.Groups[1].Value;
desc = desc.Substring(mCol.Length);
}
TraceManager.Add(String.Format("{0}({1}): {2}", file, line, desc), -3);
}
te = new TextEvent(EventType.ProcessEnd, "Done(" + errorMatches.Count + ")");
EventManager.DispatchEvent(this, te);
if (errorMatches.Count == 0)
{
if (!te.Handled)
{
PlaySWF();
return;
}
}
(PluginBase.MainForm as Form).Activate();
(PluginBase.MainForm as Form).Focus();
}
示例3: UpdateControlSyntax
/// <summary>
/// Detect syntax, ask from plugins if its correct and update
/// </summary>
public static void UpdateControlSyntax(ScintillaControl sci)
{
String language = SciConfig.GetLanguageFromFile(sci.FileName);
TextEvent te = new TextEvent(EventType.SyntaxDetect, language);
EventManager.DispatchEvent(SciConfig, te);
if (te.Handled && te.Value != null) language = te.Value;
if (sci.ConfigurationLanguage != language)
{
sci.ConfigurationLanguage = language;
}
ApplySciSettings(sci);
}
示例4: MoveDocuments
/// <summary>
/// Renames the found documents based on the specified path
/// NOTE: Directory paths should be without the last separator
/// </summary>
public static void MoveDocuments(String oldPath, String newPath)
{
Boolean reactivate = false;
oldPath = Path.GetFullPath(oldPath);
newPath = Path.GetFullPath(newPath);
ITabbedDocument current = PluginBase.MainForm.CurrentDocument;
foreach (ITabbedDocument document in PluginBase.MainForm.Documents)
{
/* We need to check for virtual models, another more generic option would be
* Path.GetFileName(document.FileName).IndexOfAny(Path.GetInvalidFileNameChars()) == -1
* But this one is used in more places */
if (document.IsEditable && !document.Text.StartsWith("[model] "))
{
String filename = Path.GetFullPath(document.FileName);
if (filename.StartsWith(oldPath))
{
TextEvent ce = new TextEvent(EventType.FileClose, document.FileName);
EventManager.DispatchEvent(PluginBase.MainForm, ce);
document.SciControl.FileName = filename.Replace(oldPath, newPath);
TextEvent oe = new TextEvent(EventType.FileOpen, document.FileName);
EventManager.DispatchEvent(PluginBase.MainForm, oe);
if (current != document)
{
document.Activate();
reactivate = true;
}
else
{
TextEvent se = new TextEvent(EventType.FileSwitch, document.FileName);
EventManager.DispatchEvent(PluginBase.MainForm, se);
}
}
PluginBase.MainForm.ClearTemporaryFiles(filename);
document.RefreshTexts();
}
}
PluginBase.MainForm.RefreshUI();
if (reactivate) current.Activate();
}
示例5: PropertyValueChanged
/// <summary>
/// When setting value has changed, dispatch event
/// </summary>
private void PropertyValueChanged(Object sender, PropertyValueChangedEventArgs e)
{
if (this.itemListView.SelectedIndices.Count > 0)
{
GridItem changedItem = (GridItem)e.ChangedItem;
String settingId = this.nameLabel.Text + "." + changedItem.Label.Replace(" ", "");
TextEvent te = new TextEvent(EventType.SettingChanged, settingId);
EventManager.DispatchEvent(Globals.MainForm, te);
}
}
示例6: Reload
/// <summary>
/// Reloads an editable document
/// </summary>
public void Reload(Boolean showQuestion)
{
if (!this.IsEditable) return;
if (showQuestion)
{
String dlgTitle = TextHelper.GetString("Title.ConfirmDialog");
String message = TextHelper.GetString("Info.AreYouSureToReload");
if (MessageBox.Show(Globals.MainForm, message, " " + dlgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
}
Globals.MainForm.ReloadingDocument = true;
Int32 position = this.SciControl.CurrentPos;
TextEvent te = new TextEvent(EventType.FileReload, this.FileName);
EventManager.DispatchEvent(Globals.MainForm, te);
if (!te.Handled)
{
EncodingFileInfo info = FileHelper.GetEncodingFileInfo(this.FileName);
if (info.CodePage == -1)
{
Globals.MainForm.ReloadingDocument = false;
return; // If the files is locked, stop.
}
Encoding encoding = Encoding.GetEncoding(info.CodePage);
this.SciControl.IsReadOnly = false;
this.SciControl.Encoding = encoding;
this.SciControl.CodePage = ScintillaManager.SelectCodePage(info.CodePage);
this.SciControl.Text = info.Contents;
this.SciControl.IsReadOnly = FileHelper.FileIsReadOnly(this.FileName);
this.SciControl.SetSel(position, position);
this.SciControl.EmptyUndoBuffer();
this.SciControl.Focus();
}
Globals.MainForm.OnDocumentReload(this);
}
示例7: SaveSelectedFile
/**
* Saves the specified file with the specified encoding
*/
public void SaveSelectedFile(string file, string text)
{
DockContent doc = this.CurDocument;
ScintillaControl sci = this.CurSciControl;
bool otherFile = ((string)sci.Tag != file);
if (otherFile)
{
NotifyEvent ne = new NotifyEvent(EventType.FileClose);
Global.Plugins.NotifyPlugins(this, ne);
}
//
TextEvent te = new TextEvent(EventType.FileSaving, file);
Global.Plugins.NotifyPlugins(this, te);
//
sci.Tag = file;
doc.Text = Path.GetFileName(file);
FileSystem.Write(file, text, sci.Encoding);
if (otherFile)
{
sci.ConfigurationLanguage = this.SciConfig.GetLanguageFromFile(file);
TextEvent te2 = new TextEvent(EventType.FileSave, file);
Global.Plugins.NotifyPlugins(this, te2);
//
this.notifyOpen = true;
this.OnActiveDocumentChanged(null, null);
}
else this.OnFileSave(file);
}
示例8: PluginCommand
/**
* Call custom plugin command
*/
public void PluginCommand(object sender, System.EventArgs e)
{
try
{
CommandBarButton cmButton;
cmButton = (CommandBarButton)sender;
NotifyEvent ne = new TextEvent(EventType.Command, cmButton.Tag.ToString());
Global.Plugins.NotifyPlugins(this, ne);
}
catch (Exception ex)
{
ErrorHandler.ShowError("Error while sending a plugin command.", ex);
}
}
示例9: New
/**
* Create a new blank document
*/
public void New(object sender, System.EventArgs e)
{
string fileName = this.GetNewDocumentName();
TextEvent te = new TextEvent(EventType.FileNew, fileName);
Global.Plugins.NotifyPlugins(this, te);
if (!te.Handled)
{
this.CreateNewDocument(fileName, "", this.DefaultCodePage);
}
}
示例10: OnChangeLanguage
/**
* Notifies the plugins for the LanguageChange event
*/
public void OnChangeLanguage(string lang)
{
TextEvent te = new TextEvent(EventType.LanguageChange, lang);
Global.Plugins.NotifyPlugins(this, te);
}
示例11: OnScintillaControlModifyRO
/// <summary>
/// Notifies when the user is trying to modify a read only file
/// </summary>
public void OnScintillaControlModifyRO(ScintillaControl sci)
{
if (!sci.Enabled || !File.Exists(sci.FileName)) return;
TextEvent te = new TextEvent(EventType.FileModifyRO, sci.FileName);
EventManager.DispatchEvent(this, te);
if (te.Handled) return; // Let plugin handle this...
String dlgTitle = TextHelper.GetString("Title.ConfirmDialog");
String message = TextHelper.GetString("Info.MakeReadOnlyWritable");
if (MessageBox.Show(Globals.MainForm, message, dlgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
ScintillaManager.MakeFileWritable(sci);
}
}
示例12: OnDocumentClosed
/// <summary>
/// Activates the previous document when document is closed
/// </summary>
public void OnDocumentClosed(Object sender, System.EventArgs e)
{
ITabbedDocument document = sender as ITabbedDocument;
TabbingManager.TabHistory.Remove(document);
TextEvent ne = new TextEvent(EventType.FileClose, document.FileName);
EventManager.DispatchEvent(this, ne);
if (this.appSettings.SequentialTabbing)
{
if (TabbingManager.SequentialIndex == 0) this.Documents[0].Activate();
else TabbingManager.NavigateTabsSequentially(-1);
}
else TabbingManager.NavigateTabHistory(0);
if (document.IsEditable && !document.IsUntitled)
{
if (this.appSettings.RestoreFileStates) FileStateManager.SaveFileState(document);
RecoveryManager.RemoveTemporaryFile(document.FileName);
OldTabsManager.SaveOldTabDocument(document.FileName);
}
ButtonManager.UpdateFlaggedButtons();
}
示例13: OnActiveDocumentChanged
/// <summary>
/// Updates the UI, tabbing, working directory and the button states.
/// Also notifies the plugins for the FileOpen and FileSwitch events.
/// </summary>
public void OnActiveDocumentChanged(Object sender, System.EventArgs e)
{
try
{
if (this.CurrentDocument == null) return;
this.OnScintillaControlUpdateControl(this.CurrentDocument.SciControl);
this.quickFind.CanSearch = this.CurrentDocument.IsEditable;
/**
* Bring this newly active document to the top of the tab history
* unless you're currently cycling through tabs with the keyboard
*/
TabbingManager.UpdateSequentialIndex(this.CurrentDocument);
if (!TabbingManager.TabTimer.Enabled)
{
TabbingManager.TabHistory.Remove(this.CurrentDocument);
TabbingManager.TabHistory.Insert(0, this.CurrentDocument);
}
if (this.CurrentDocument.IsEditable)
{
/**
* Apply correct extension when saving
*/
if (this.appSettings.ApplyFileExtension)
{
String extension = Path.GetExtension(this.CurrentDocument.FileName);
if (extension != "") this.saveFileDialog.DefaultExt = extension;
}
/**
* Set current working directory
*/
String path = Path.GetDirectoryName(this.CurrentDocument.FileName);
if (!this.CurrentDocument.IsUntitled && Directory.Exists(path))
{
this.workingDirectory = path;
}
/**
* Checks the file changes
*/
TabbedDocument document = (TabbedDocument)this.CurrentDocument;
document.Activate();
/**
* Processes the opened file
*/
if (this.notifyOpenFile)
{
ScintillaManager.UpdateControlSyntax(this.CurrentDocument.SciControl);
if (File.Exists(this.CurrentDocument.FileName))
{
TextEvent te = new TextEvent(EventType.FileOpen, this.CurrentDocument.FileName);
EventManager.DispatchEvent(this, te);
}
this.notifyOpenFile = false;
}
}
NotifyEvent ne = new NotifyEvent(EventType.FileSwitch);
EventManager.DispatchEvent(this, ne);
}
catch (Exception ex)
{
ErrorManager.ShowError(ex);
}
}
示例14: OnFileSave
/// <summary>
/// Notifies the plugins for the FileSave event
/// </summary>
public void OnFileSave(ITabbedDocument document, String oldFile)
{
if (oldFile != null)
{
String args = document.FileName + ";" + oldFile;
TextEvent rename = new TextEvent(EventType.FileRename, args);
EventManager.DispatchEvent(this, rename);
TextEvent open = new TextEvent(EventType.FileOpen, document.FileName);
EventManager.DispatchEvent(this, open);
}
this.OnUpdateMainFormDialogTitle();
if (document.IsEditable) document.SciControl.MarkerDeleteAll(2);
TextEvent save = new TextEvent(EventType.FileSave, document.FileName);
EventManager.DispatchEvent(this, save);
ButtonManager.UpdateFlaggedButtons();
TabTextManager.UpdateTabTexts();
}
示例15: SmartNew
/// <summary>
/// Creates a new blank document tracking current project
/// </summary>
public void SmartNew(Object sender, EventArgs e)
{
String ext = "";
if (PluginBase.CurrentProject != null)
{
try
{
String filter = PluginBase.CurrentProject.DefaultSearchFilter;
String tempExt = filter.Split(';')[0].Replace("*.", "");
if (Regex.Match(tempExt, "^[A-Za-z0-9]+$").Success) ext = tempExt;
}
catch { /* NO ERRORS */ }
}
String fileName = DocumentManager.GetNewDocumentName(ext);
TextEvent te = new TextEvent(EventType.FileNew, fileName);
EventManager.DispatchEvent(this, te);
if (!te.Handled)
{
this.CreateEditableDocument(fileName, "", (Int32)this.appSettings.DefaultCodePage);
}
}