Free cookie consent management tool by TermsFeed Policy Generator

source: branches/RuntimeOptimizer/HeuristicLab.CodeEditor/3.3/HostCallbackImplementation.cs @ 9065

Last change on this file since 9065 was 2659, checked in by epitzer, 15 years ago

Add new Plugin that provides a code editor with syntax highlighting and code completion (#842)

File size: 3.2 KB
Line 
1// CSharp Editor Example with Code Completion
2// Copyright (c) 2006, Daniel Grunwald
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without modification, are
6// permitted provided that the following conditions are met:
7//
8// - Redistributions of source code must retain the above copyright notice, this list
9//   of conditions and the following disclaimer.
10//
11// - Redistributions in binary form must reproduce the above copyright notice, this list
12//   of conditions and the following disclaimer in the documentation and/or other materials
13//   provided with the distribution.
14//
15// - Neither the name of the ICSharpCode team nor the names of its contributors may be used to
16//   endorse or promote products derived from this software without specific prior written
17//   permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
20// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28using System;
29using System.Windows.Forms;
30using ICSharpCode.SharpDevelop.Dom;
31
32namespace HeuristicLab.CodeEditor {
33  /// <summary>
34  /// ICSharpCode.SharpDevelop.Dom was created by extracting code from ICSharpCode.SharpDevelop.dll.
35  /// There are a few static method calls that refer to GUI code or the code for keeping the parse
36  /// information. These calls have to be implemented by the application hosting
37  /// ICSharpCode.SharpDevelop.Dom by settings static fields with a delegate to their method
38  /// implementation.
39  /// </summary>
40  static class HostCallbackImplementation {
41    public static void Register(CodeEditor codeEditor) {
42      // Must be implemented. Gets the project content of the active project.
43      HostCallback.GetCurrentProjectContent = delegate {
44        return codeEditor.projectContent;
45      };
46
47      // The default implementation just logs to Log4Net. We want to display a MessageBox.
48      // Note that we use += here - in this case, we want to keep the default Log4Net implementation.
49      HostCallback.ShowError += delegate(string message, Exception ex) {
50        MessageBox.Show(message + Environment.NewLine + ex.ToString());
51      };
52      HostCallback.ShowMessage += delegate(string message) {
53        MessageBox.Show(message);
54      };
55      HostCallback.ShowAssemblyLoadError += delegate(string fileName, string include, string message) {
56        MessageBox.Show("Error loading code-completion information for "
57                        + include + " from " + fileName
58                        + ":\r\n" + message + "\r\n");
59      };
60    }
61  }
62}
Note: See TracBrowser for help on using the repository browser.