Browse Source

ported consoles to AvalonEdit

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4755 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 16 years ago
parent
commit
532acccbf0
  1. 17
      AddIns/ICSharpCode.SharpDevelop.addin
  2. BIN
      data/resources/image/BitmapResources/BitmapResources-data/Icons.16x16.DeleteHistory.png
  3. 1
      data/resources/image/BitmapResources/BitmapResources.res
  4. 58
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/InteractiveInterpreter.cs
  5. 73
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/ConsolePad.cs
  6. 2
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  7. 351
      src/Main/Base/Project/Src/Gui/Pads/AbstractConsolePad.cs
  8. 186
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorBasedPad.cs
  9. 42
      src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarButton.cs
  10. BIN
      src/Main/StartUp/Project/Resources/BitmapResources.resources

17
AddIns/ICSharpCode.SharpDevelop.addin

@ -2160,6 +2160,23 @@
class = "ICSharpCode.SharpDevelop.Gui.SelectScopeCommand" class = "ICSharpCode.SharpDevelop.Gui.SelectScopeCommand"
type = "ComboBox"/> type = "ComboBox"/>
</Path> </Path>
<Path name="/SharpDevelop/Pads/CommonConsole/ToolBar">
<ToolbarItem id = "ClearConsole"
tooltip = "Clear console"
class = "ICSharpCode.SharpDevelop.Gui.ClearConsoleCommand"
icon = "OutputPad.Toolbar.ClearOutputWindow" />
<ToolbarItem id = "DeleteHistory"
tooltip = "Delete history"
class = "ICSharpCode.SharpDevelop.Gui.DeleteHistoryCommand"
icon = "Icons.16x16.DeleteHistory" />
<ToolbarItem type="Separator" />
<ToolbarItem id = "ToggleWordWrap"
type = "CheckBox"
icon = "OutputPad.Toolbar.ToggleWordWrap"
tooltip = "${res:MainWindow.Windows.CompilerMessageView.ToggleWordWrapButton.ToolTip}"
class = "ICSharpCode.SharpDevelop.Gui.ToggleConsoleWordWrapComman"/>
</Path>
<Path name="/SharpDevelop/Services/ParserService/SingleFileGacReferences"> <Path name="/SharpDevelop/Services/ParserService/SingleFileGacReferences">
<String id = "System" text = "System"/> <String id = "System" text = "System"/>

BIN
data/resources/image/BitmapResources/BitmapResources-data/Icons.16x16.DeleteHistory.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

1
data/resources/image/BitmapResources/BitmapResources.res

@ -225,6 +225,7 @@ Icons.16x16.CloseFileIcon = BitmapResources-data\Icons.1
Icons.16x16.OpenFileIcon = BitmapResources-data\Icons.16x16.OpenFileIcon.png Icons.16x16.OpenFileIcon = BitmapResources-data\Icons.16x16.OpenFileIcon.png
Icons.16x16.HtmlElements.FieldSetElement = BitmapResources-data\Icons.16x16.HtmlElements.FieldSetElement.png Icons.16x16.HtmlElements.FieldSetElement = BitmapResources-data\Icons.16x16.HtmlElements.FieldSetElement.png
Icons.16x16.SplitWindow = BitmapResources-data\Icons.16x16.SplitWindow.png Icons.16x16.SplitWindow = BitmapResources-data\Icons.16x16.SplitWindow.png
Icons.16x16.DeleteHistory = BitmapResources-data\Icons.16x16.DeleteHistory.png
#pad icons #pad icons
PadIcons.ErrorList = PadIcons\ErrorList.png PadIcons.ErrorList = PadIcons\ErrorList.png

58
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/InteractiveInterpreter.cs

@ -19,44 +19,21 @@ namespace Grunwald.BooBinding
/// <summary> /// <summary>
/// Interactive Boo interpreter. /// Interactive Boo interpreter.
/// </summary> /// </summary>
public class InteractiveInterpreterPad : TextEditorBasedPad public class InteractiveInterpreterPad : AbstractConsolePad
{ {
InteractiveInterpreterControl ctl = new InteractiveInterpreterControl(); InteractiveInterpreter interpreter;
public override ICSharpCode.TextEditor.TextEditorControl TextEditorControl { protected override string Prompt {
get { get {
return ctl; return ">>> ";
} }
} }
}
sealed class InteractiveInterpreterControl : CommandPromptControl
{
InteractiveInterpreter interpreter;
public InteractiveInterpreterControl() protected override void InitializeConsole()
{ {
base.InitializeConsole();
SetHighlighting("Boo"); SetHighlighting("Boo");
PrintPrompt();
}
void PrintLine(object text)
{
if (text == null)
return;
if (WorkbenchSingleton.InvokeRequired) {
WorkbenchSingleton.SafeThreadAsyncCall(PrintLine, text);
} else {
if (processing)
Append(Environment.NewLine + text.ToString());
else
InsertLineBeforePrompt(text.ToString());
}
}
protected override void PrintPromptInternal()
{
Append(">>> ");
} }
protected override void AcceptCommand(string command) protected override void AcceptCommand(string command)
@ -66,8 +43,7 @@ namespace Grunwald.BooBinding
} else if (!command.Contains("\n") && !command.EndsWith(":")) { } else if (!command.Contains("\n") && !command.EndsWith(":")) {
ProcessCommand(command); ProcessCommand(command);
} else { } else {
Append(Environment.NewLine); TextEditor.Caret.Position = TextEditor.Document.OffsetToPosition(TextEditor.Document.TextLength);
ActiveTextAreaControl.Caret.Position = this.Document.OffsetToPosition(this.Document.TextLength);
} }
} }
@ -105,10 +81,22 @@ namespace Grunwald.BooBinding
PrintLine(ex.InnerException); PrintLine(ex.InnerException);
} }
processing = false; processing = false;
if (this.Document.TextLength != 0) {
Append(Environment.NewLine); Append(Environment.NewLine);
}
void PrintLine(object text)
{
if (text == null)
return;
if (WorkbenchSingleton.InvokeRequired) {
WorkbenchSingleton.SafeThreadAsyncCall(PrintLine, text);
} else {
if (processing)
Append(text.ToString());
else
InsertLineBeforePrompt(text.ToString());
} }
PrintPrompt();
} }
protected override void Clear() protected override void Clear()

73
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/ConsolePad.cs

@ -16,56 +16,15 @@ using ICSharpCode.TextEditor;
namespace ICSharpCode.SharpDevelop.Gui.Pads namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
public class ConsolePad : TextEditorBasedPad public class ConsolePad : AbstractConsolePad
{ {
ConsoleControl editor = new ConsoleControl();
public override TextEditorControl TextEditorControl {
get {
return editor;
}
}
public ConsolePad()
{
WindowsDebugger debugger = (WindowsDebugger)DebuggerService.CurrentDebugger;
debugger.ProcessSelected += delegate(object sender, ProcessEventArgs e) {
editor.Process = e.Process;
};
editor.Process = debugger.DebuggedProcess;
}
}
class ConsoleControl : CommandPromptControl
{
Process process;
public Process Process {
get { return process; }
set { process = value; }
}
public ConsoleControl()
{
SetHighlighting("C#");
PrintPrompt();
}
protected override void PrintPromptInternal()
{
Append("> ");
}
protected override void AcceptCommand(string command) protected override void AcceptCommand(string command)
{ {
if (!string.IsNullOrEmpty(command)) { if (!string.IsNullOrEmpty(command)) {
string result = Evaluate(command); string result = Evaluate(command);
Append(Environment.NewLine);
if (!string.IsNullOrEmpty(result)) { if (!string.IsNullOrEmpty(result)) {
Append(result + Environment.NewLine); Append(result + Environment.NewLine);
} }
PrintPrompt();
} }
} }
@ -84,5 +43,35 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
return e.Message; return e.Message;
} }
} }
Process process;
public Process Process {
get { return process; }
set { process = value; }
}
protected override string Prompt {
get {
return "> ";
}
}
protected override void InitializeConsole()
{
base.InitializeConsole();
SetHighlighting("C#");
}
public ConsolePad()
{
WindowsDebugger debugger = (WindowsDebugger)DebuggerService.CurrentDebugger;
debugger.ProcessSelected += delegate(object sender, ProcessEventArgs e) {
this.Process = e.Process;
};
this.Process = debugger.DebuggedProcess;
}
} }
} }

2
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -183,6 +183,7 @@
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Src\Gui\IImage.cs" /> <Compile Include="Src\Gui\IImage.cs" />
<Compile Include="Src\Gui\Pads\AbstractConsolePad.cs" />
<Compile Include="Src\Gui\Pads\OutlinePad.cs" /> <Compile Include="Src\Gui\Pads\OutlinePad.cs" />
<Compile Include="Src\Gui\Pads\ProjectBrowser\TreeNodes\DirectoryNodeFactory.cs" /> <Compile Include="Src\Gui\Pads\ProjectBrowser\TreeNodes\DirectoryNodeFactory.cs" />
<Compile Include="Src\Gui\Pads\TaskList\TaskListPadCommands.cs" /> <Compile Include="Src\Gui\Pads\TaskList\TaskListPadCommands.cs" />
@ -611,7 +612,6 @@
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Src\TextEditor\Gui\Editor\SharpDevelopTextEditorProperties.cs" /> <Compile Include="Src\TextEditor\Gui\Editor\SharpDevelopTextEditorProperties.cs" />
<Compile Include="Src\TextEditor\Gui\Editor\TextEditorBasedPad.cs" />
<Compile Include="Src\TextEditor\Gui\Editor\TextEditorDisplayBinding.cs" /> <Compile Include="Src\TextEditor\Gui\Editor\TextEditorDisplayBinding.cs" />
<Compile Include="Src\TextEditor\Gui\OptionPanels\BehaviorTextEditorPanel.cs"> <Compile Include="Src\TextEditor\Gui\OptionPanels\BehaviorTextEditorPanel.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>

351
src/Main/Base/Project/Src/Gui/Pads/AbstractConsolePad.cs

@ -0,0 +1,351 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core.Presentation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
namespace ICSharpCode.SharpDevelop.Gui
{
public abstract class AbstractConsolePad : AbstractPadContent, IEditable, IPositionable, ITextEditorProvider, IToolsHost
{
const string toolBarTreePath = "/SharpDevelop/Pads/CommonConsole/ToolBar";
DockPanel panel;
ConsoleControl console;
ToolBar toolbar;
bool cleared;
IList<string> history;
int historyPointer;
protected AbstractConsolePad()
{
this.panel = new DockPanel();
this.toolbar = ToolBarService.CreateToolBar(this, toolBarTreePath);
this.toolbar.SetValue(DockPanel.DockProperty, Dock.Top);
this.console = new ConsoleControl();
this.panel.Children.Add(toolbar);
this.panel.Children.Add(console);
this.history = new List<string>();
this.console.editor.TextArea.PreviewKeyDown += (sender, e) => {
e.Handled = HandleInput(e.Key);
};
this.InitializeConsole();
}
public virtual ITextEditor TextEditor {
get {
return console.TextEditor;
}
}
public override object Control {
get { return panel; }
}
string GetText()
{
return this.TextEditor.Document.Text;
}
/// <summary>
/// Creates a snapshot of the editor content.
/// This method is thread-safe.
/// </summary>
public ITextBuffer CreateSnapshot()
{
return new StringTextBuffer(GetText());
}
string IEditable.Text {
get {
return GetText();
}
}
public virtual ICSharpCode.SharpDevelop.Editor.IDocument GetDocumentForFile(OpenedFile file)
{
return null;
}
#region IPositionable implementation
void IPositionable.JumpTo(int line, int column)
{
this.TextEditor.JumpTo(line, column);
}
int IPositionable.Line {
get {
return this.TextEditor.Caret.Line;
}
}
int IPositionable.Column {
get {
return this.TextEditor.Caret.Column;
}
}
#endregion
object IToolsHost.ToolsContent {
get { return TextEditorSideBar.Instance; }
}
protected virtual bool HandleInput(Key key) {
switch (key) {
case Key.Down:
this.historyPointer = Math.Min(this.historyPointer + 1, this.history.Count);
if (this.historyPointer == this.history.Count)
console.CommandText = "";
else
console.CommandText = this.history[this.historyPointer];
console.editor.ScrollToEnd();
return true;
case Key.Up:
this.historyPointer = Math.Max(this.historyPointer - 1, 0);
if (this.historyPointer == this.history.Count)
console.CommandText = "";
else
console.CommandText = this.history[this.historyPointer];
console.editor.ScrollToEnd();
return true;
case Key.Return:
if (Keyboard.Modifiers == ModifierKeys.Shift)
return false;
string commandText = console.CommandText;
this.console.TextEditor.Document.Insert(this.console.TextEditor.Document.TextLength, "\n");
if (!string.IsNullOrEmpty(commandText))
AcceptCommand(commandText);
if (!cleared)
AppendPrompt();
else
console.CommandText = "";
cleared = false;
this.history.Add(commandText);
this.historyPointer = this.history.Count;
console.editor.ScrollToEnd();
return true;
}
return false;
}
/// <summary>
/// Deletes the content of the console and prints a new prompt.
/// </summary>
public void ClearConsole()
{
this.console.editor.Document.Text = "";
cleared = true;
AppendPrompt();
}
/// <summary>
/// Deletes the console history.
/// </summary>
public void DeleteHistory()
{
this.history.Clear();
this.historyPointer = 0;
}
public void SetHighlighting(string language)
{
this.console.SetHighlighting(language);
}
public bool WordWrap {
get { return this.console.editor.WordWrap; }
set { this.console.editor.WordWrap = value; }
}
protected abstract string Prompt {
get;
}
protected abstract void AcceptCommand(string command);
protected virtual void InitializeConsole()
{
AppendPrompt();
}
protected virtual void AppendPrompt()
{
console.Append(Prompt);
console.SetReadonly();
console.editor.Document.UndoStack.ClearAll();
}
protected void Append(string text)
{
console.Append(text);
}
protected void InsertLineBeforePrompt(string text)
{
text += Environment.NewLine;
this.console.editor.Document.Insert(this.console.readOnlyRegion.EndOffset - Prompt.Length, text);
this.console.SetReadonly(this.console.readOnlyRegion.EndOffset + text.Length);
}
protected virtual void Clear()
{
this.ClearConsole();
}
}
class ConsoleControl : Grid
{
internal AvalonEdit.TextEditor editor;
internal BeginReadOnlySectionProvider readOnlyRegion;
public ConsoleControl()
{
this.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
this.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
this.editor = new ICSharpCode.AvalonEdit.TextEditor();
this.editor.SetValue(Grid.ColumnProperty, 0);
this.editor.SetValue(Grid.RowProperty, 0);
this.editor.Background = Brushes.White;
this.editor.FontFamily = new FontFamily("Consolas");
this.editor.FontSize = 13;
this.Children.Add(editor);
editor.TextArea.ReadOnlySectionProvider = readOnlyRegion = new BeginReadOnlySectionProvider();
}
public ITextEditor TextEditor {
get {
return new AvalonEditTextEditorAdapter(editor);
}
}
public void SetHighlighting(string language)
{
editor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition(language);
}
public void Append(string text)
{
editor.AppendText(text);
}
/// <summary>
/// Sets the readonly region to a specified offset.
/// </summary>
public void SetReadonly(int offset)
{
readOnlyRegion.EndOffset = offset;
}
/// <summary>
/// Sets the readonly region to the end of the document.
/// </summary>
public void SetReadonly()
{
readOnlyRegion.EndOffset = editor.Document.TextLength;
}
/// <summary>
/// Gets/sets the command text displayed at the command prompt.
/// </summary>
public string CommandText {
get {
return editor.Document.GetText(new TextSegment() { StartOffset = readOnlyRegion.EndOffset, EndOffset = editor.Document.TextLength });
}
set {
editor.Document.Replace(new TextSegment() { StartOffset = readOnlyRegion.EndOffset, EndOffset = editor.Document.TextLength }, value);
}
}
}
class BeginReadOnlySectionProvider : IReadOnlySectionProvider
{
public int EndOffset { get; set; }
public bool CanInsert(int offset)
{
return offset >= EndOffset;
}
public IEnumerable<ISegment> GetDeletableSegments(ISegment segment)
{
return new[] {
new TextSegment() {
StartOffset = Math.Max(this.EndOffset, segment.Offset),
EndOffset = segment.EndOffset
}
};
}
}
class ClearConsoleCommand : AbstractMenuCommand
{
public override void Run()
{
var pad = this.Owner as AbstractConsolePad;
if (pad != null)
pad.ClearConsole();
}
}
class DeleteHistoryCommand : AbstractMenuCommand
{
public override void Run()
{
var pad = this.Owner as AbstractConsolePad;
if (pad != null)
pad.DeleteHistory();
}
}
class ToggleConsoleWordWrapCommand : AbstractCheckableMenuCommand
{
AbstractConsolePad pad;
public override object Owner {
get { return base.Owner; }
set {
if (!(value is AbstractConsolePad))
throw new Exception("Owner has to be a AbstractConsolePad");
pad = value as AbstractConsolePad;
base.Owner = value;
}
}
public override bool IsChecked {
get { return pad.WordWrap; }
set { pad.WordWrap = value; }
}
public override void Run()
{
IsChecked = !IsChecked;
}
}
}

186
src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorBasedPad.cs

@ -1,186 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.Drawing.Printing;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
{
/// <summary>
/// Description of TextEditorBasedPad.
/// </summary>
public abstract class TextEditorBasedPad : AbstractPadContent, IEditable, IUndoHandler, IPositionable, ITextEditorControlProvider, IPrintable, IToolsHost, IClipboardHandler
{
public abstract TextEditorControl TextEditorControl {
get;
}
public virtual ICSharpCode.SharpDevelop.Editor.ITextEditor TextEditor {
get {
return new TextEditorAdapter(this.TextEditorControl);
}
}
public override object Control {
get { return this.TextEditorControl; }
}
bool IUndoHandler.EnableUndo {
get {
return this.TextEditorControl.EnableUndo;
}
}
bool IUndoHandler.EnableRedo {
get {
return this.TextEditorControl.EnableRedo;
}
}
string GetText()
{
return this.TextEditorControl.Document.TextContent;
}
void SetText(string value)
{
this.TextEditorControl.Document.Replace(0, this.TextEditorControl.Document.TextLength, value);
}
/// <summary>
/// Creates a snapshot of the editor content.
/// This method is thread-safe.
/// </summary>
public ITextBuffer CreateSnapshot()
{
string content = WorkbenchSingleton.SafeThreadFunction<string>(GetText);
return new StringTextBuffer(content);
}
string IEditable.Text {
get {
if (WorkbenchSingleton.InvokeRequired)
return WorkbenchSingleton.SafeThreadFunction<string>(GetText);
else
return GetText();
}
}
public virtual ICSharpCode.SharpDevelop.Editor.IDocument GetDocumentForFile(OpenedFile file)
{
return null;
}
PrintDocument IPrintable.PrintDocument {
get {
return this.TextEditorControl.PrintDocument;
}
}
void IUndoHandler.Undo()
{
this.TextEditorControl.Undo();
}
void IUndoHandler.Redo()
{
this.TextEditorControl.Redo();
}
#region IPositionable implementation
void IPositionable.JumpTo(int line, int column)
{
this.TextEditorControl.ActiveTextAreaControl.JumpTo(line - 1, column - 1);
// we need to delay this call here because the text editor does not know its height if it was just created
WorkbenchSingleton.SafeThreadAsyncCall(
delegate {
this.TextEditorControl.ActiveTextAreaControl.CenterViewOn(
line - 1, (int)(0.3 * this.TextEditorControl.ActiveTextAreaControl.TextArea.TextView.VisibleLineCount));
});
}
int IPositionable.Line {
get {
return this.TextEditorControl.ActiveTextAreaControl.Caret.Line + 1;
}
}
int IPositionable.Column {
get {
return this.TextEditorControl.ActiveTextAreaControl.Caret.Column + 1;
}
}
#endregion
object IToolsHost.ToolsContent {
get { return TextEditorSideBar.Instance; }
}
#region ICSharpCode.SharpDevelop.Gui.IClipboardHandler interface implementation
public bool EnableCut {
get {
return this.TextEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableCut;
}
}
public bool EnableCopy {
get {
return this.TextEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableCopy;
}
}
public bool EnablePaste {
get {
return this.TextEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnablePaste;
}
}
public bool EnableDelete {
get {
return this.TextEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableDelete;
}
}
public bool EnableSelectAll {
get {
return this.TextEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableSelectAll;
}
}
public void SelectAll()
{
this.TextEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.SelectAll(null, null);
}
public void Delete()
{
this.TextEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.Delete(null, null);
}
public void Paste()
{
this.TextEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.Paste(null, null);
}
public void Copy()
{
this.TextEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.Copy(null, null);
}
public void Cut()
{
this.TextEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.Cut(null, null);
}
#endregion
}
}

42
src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarButton.cs

@ -56,4 +56,46 @@ namespace ICSharpCode.Core.Presentation
this.Visibility = Visibility.Visible; this.Visibility = Visibility.Visible;
} }
} }
sealed class ToolBarCheckBox : CheckBox, IStatusUpdate
{
readonly Codon codon;
readonly object caller;
public ToolBarCheckBox(Codon codon, object caller, bool createCommand)
{
ToolTipService.SetShowOnDisabled(this, true);
this.codon = codon;
this.caller = caller;
this.Command = CommandWrapper.GetCommand(codon, caller, createCommand);
if (codon.Properties.Contains("icon")) {
var image = PresentationResourceService.GetImage(StringParser.Parse(codon.Properties["icon"]));
image.Height = 16;
image.SetResourceReference(StyleProperty, ToolBarService.ImageStyleKey);
this.Content = new PixelSnapper(image);
} else {
this.Content = codon.Id;
}
UpdateText();
SetResourceReference(FrameworkElement.StyleProperty, ToolBar.ButtonStyleKey);
}
public void UpdateText()
{
if (codon.Properties.Contains("tooltip")) {
this.ToolTip = StringParser.Parse(codon.Properties["tooltip"]);
}
}
public void UpdateStatus()
{
if (codon.GetFailedAction(caller) == ConditionFailedAction.Exclude)
this.Visibility = Visibility.Collapsed;
else
this.Visibility = Visibility.Visible;
}
}
} }

BIN
src/Main/StartUp/Project/Resources/BitmapResources.resources

Binary file not shown.
Loading…
Cancel
Save