Browse Source

Editing highlighting colors is now supported for C#, VB, XML and .patch files.

Fixed FxCop issues in AvalonEdit.

Still missing in highlighting editor:
 - edit environment colors (normal text, line number margin, etc.)
 - support all syntax definitions shipping with SharpDevelop

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5575 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
471ec831c6
  1. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml
  2. 40
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs
  3. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/UndoStack.cs
  4. 101
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CSharp-Mode.xshd
  5. 22
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Patch-Mode.xshd
  6. 6
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/VBNET-Mode.xshd
  7. 26
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/XML-Mode.xshd
  8. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
  9. 8
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Indentation/CSharp/DocumentAccessor.cs
  10. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Indentation/CSharp/IndentationReformatter.cs
  11. 26
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/PixelSnapHelpers.cs
  12. 32
      src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml
  13. 11
      src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml

@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
Click="ResetButtonClick" Padding="8,0" Height="21" Margin="0,4"
Content="Reset" />
<Label Content="{core:StringParse ${res:Dialog.HighlightingEditor.SampleText}:}" />
<core:RestrictDesiredSize Height="50">
<core:RestrictDesiredSize Height="50" MinWidth="200">
<avalonedit:TextEditor Name="textEditor" IsReadOnly="True" />
</core:RestrictDesiredSize>
</StackPanel>

40
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs

@ -55,6 +55,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -55,6 +55,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
&& name.EndsWith(".xshd", StringComparison.OrdinalIgnoreCase)
&& !name.EndsWith("XmlDoc.xshd", StringComparison.OrdinalIgnoreCase)
let def = LoadBuiltinXshd(name)
where def.Elements.OfType<XshdColor>().Any(c => c.ExampleText != null)
orderby def.Name
select def
).ToList();
@ -63,35 +64,30 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -63,35 +64,30 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
customizationList = CustomizedHighlightingColor.LoadColors();
languageComboBox.Items.Clear();
languageComboBox.Items.Add(new XshdSyntaxDefinition { Name = "All languages" });
//languageComboBox.Items.Add(new XshdSyntaxDefinition { Name = "All languages" });
foreach (XshdSyntaxDefinition def in allSyntaxDefinitions)
languageComboBox.Items.Add(def);
languageComboBox.SelectedIndex = 0;
if (allSyntaxDefinitions.Count > 0)
languageComboBox.SelectedIndex = 0;
}
void LanguageComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
listBox.Items.Clear();
if (languageComboBox.SelectedIndex == 0) {
var namedColors =
from def in allSyntaxDefinitions
from color in def.Elements.OfType<XshdColor>()
where color.ExampleText != null
group new { DefinitionName = def.Name, Color = color } by color.Name into g
orderby g.Key
select g.First();
foreach (var namedColor in namedColors) {
var def = HighlightingManager.Instance.GetDefinition(namedColor.DefinitionName);
IHighlightingItem item = new NamedColorHighlightingItem(def, namedColor.Color);
item = new CustomizedHighlightingItem(customizationList, item, null);
listBox.Items.Add(item);
item.PropertyChanged += item_PropertyChanged;
XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem;
if (xshd != null) {
IHighlightingDefinition def = HighlightingManager.Instance.GetDefinition(xshd.Name);
foreach (XshdColor namedColor in xshd.Elements.OfType<XshdColor>()) {
if (namedColor.ExampleText != null) {
IHighlightingItem item = new NamedColorHighlightingItem(def, namedColor);
item = new CustomizedHighlightingItem(customizationList, item, xshd.Name);
listBox.Items.Add(item);
item.PropertyChanged += item_PropertyChanged;
}
}
} else {
throw new NotImplementedException();
if (listBox.Items.Count > 0)
listBox.SelectedIndex = 0;
}
listBox.SelectedIndex = 0;
}
void item_PropertyChanged(object sender, PropertyChangedEventArgs e)
@ -107,7 +103,9 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -107,7 +103,9 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
void ResetButtonClick(object sender, RoutedEventArgs e)
{
((IHighlightingItem)resetButton.DataContext).Reset();
IHighlightingItem item = resetButton.DataContext as IHighlightingItem;
if (item != null)
item.Reset();
}
void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/UndoStack.cs

@ -27,7 +27,6 @@ namespace ICSharpCode.AvalonEdit.Document @@ -27,7 +27,6 @@ namespace ICSharpCode.AvalonEdit.Document
internal const int StatePlaybackModifyDocument = 2;
/// state is used for checking that noone but the UndoStack performs changes
/// during Undo events
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1085:DoNotInitializeUnnecessarily")]
internal int state = StateListen;
Deque<IUndoableOperation> undostack = new Deque<IUndoableOperation>();

101
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CSharp-Mode.xshd

@ -1,9 +1,29 @@ @@ -1,9 +1,29 @@
<?xml version="1.0"?>
<SyntaxDefinition name="C#" extensions=".cs" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<!-- The named colors 'Comment' and 'String' are used in SharpDevelop to detect if a line is inside a multiline string/comment -->
<Color name="Comment" foreground="Green" exampleText = "// comment" />
<Color name="String" foreground="Blue" exampleText = "string text = &quot;Hello, World!&quot;"/>
<Color name="Char" foreground="Magenta" exampleText = "char linefeed = '\n';"/>
<Color name="Comment" foreground="Green" exampleText="// comment" />
<Color name="String" foreground="Blue" exampleText="string text = &quot;Hello, World!&quot;"/>
<Color name="Char" foreground="Magenta" exampleText="char linefeed = '\n';"/>
<Color name="Preprocessor" foreground="Green" exampleText="#region Title" />
<Color name="Punctuation" foreground="DarkGreen" exampleText="a(b.c);" />
<Color name="ValueTypes" fontWeight="bold" foreground="Red" exampleText="bool b = true;" />
<Color name="ReferenceTypes" foreground="Red" exampleText="object o;" />
<Color name="MethodCall" foreground="MidnightBlue" fontWeight="bold" exampleText="o.ToString();"/>
<Color name="NumberLiteral" foreground="DarkBlue" exampleText="3.1415f"/>
<Color name="ThisReference" fontWeight="bold" exampleText="this"/>
<Color name="NullOrValueKeywords" fontWeight="bold" exampleText="if (value == null)"/>
<Color name="Keywords" fontWeight="bold" foreground="Blue" exampleText="if (a) {} else {}"/>
<Color name="GotoKeywords" foreground="Navy" exampleText="continue; return null;"/>
<Color name="ContextKeywords" foreground="Navy" exampleText="var a = from x in y select z;"/>
<Color name="ExceptionKeywords" fontWeight="bold" foreground="Teal" exampleText="try {} catch {} finally {}"/>
<Color name="CheckedKeyword" fontWeight="bold" foreground="DarkGray" exampleText="checked {}"/>
<Color name="UnsafeKeywords" foreground="Olive" exampleText="unsafe { fixed (..) {} }"/>
<Color name="OperatorKeywords" fontWeight="bold" foreground="Pink" exampleText="public static implicit operator..."/>
<Color name="ParameterModifiers" fontWeight="bold" foreground="DeepPink" exampleText="(ref int a, params int[] b)"/>
<Color name="Modifiers" foreground="Brown" exampleText="static readonly int a;"/>
<Color name="Visibility" fontWeight="bold" foreground="Blue" exampleText="public override void ToString();"/>
<Color name="NamespaceKeywords" fontWeight="bold" foreground="Green" exampleText="namespace A.B { using System; }"/>
<Color name="GetSetAddRemove" foreground="SaddleBrown" exampleText="int Prop { get; set; }"/>
<RuleSet name="CommentMarkerSet">
<Keywords fontWeight="bold" foreground="Red">
@ -18,7 +38,7 @@ @@ -18,7 +38,7 @@
<!-- This is the main ruleset. -->
<RuleSet>
<Span foreground="Green">
<Span color="Preprocessor">
<Begin>\#</Begin>
<RuleSet name="PreprocessorSet">
<Keywords fontWeight="bold">
@ -82,31 +102,9 @@ @@ -82,31 +102,9 @@
</RuleSet>
</Span>
<Keywords foreground="DarkGreen">
<Word>?</Word>
<Word>,</Word>
<Word>.</Word>
<Word>;</Word>
<Word>(</Word>
<Word>)</Word>
<Word>[</Word>
<Word>]</Word>
<Word>{</Word>
<Word>}</Word>
<Word>+</Word>
<Word>-</Word>
<Word>/</Word>
<Word>%</Word>
<Word>*</Word>
<Word>&lt;</Word>
<Word>&gt;</Word>
<Word>^</Word>
<Word>=</Word>
<Word>~</Word>
<Word>!</Word>
<Word>|</Word>
<Word>&amp;</Word>
</Keywords>
<Rule color="Punctuation">
[?,.;()\[\]{}+\-/%*&lt;&gt;^+~!|&amp;]+
</Rule>
<Keywords fontWeight="bold" foreground="Black">
<Word>this</Word>
@ -125,30 +123,28 @@ @@ -125,30 +123,28 @@
</Keywords>
<Keywords fontWeight="bold" foreground="Blue">
<Keywords color="Keywords">
<Word>else</Word>
<Word>if</Word>
<Word>switch</Word>
<Word>case</Word>
<Word>default</Word>
</Keywords>
<Keywords fontWeight="bold" foreground="Blue">
<Word>do</Word>
<Word>for</Word>
<Word>foreach</Word>
<Word>in</Word>
<Word>while</Word>
<Word>lock</Word>
</Keywords>
<Keywords foreground="Navy">
<Keywords color="GotoKeywords">
<Word>break</Word>
<Word>continue</Word>
<Word>goto</Word>
<Word>return</Word>
</Keywords>
<Keywords foreground="Navy">
<Keywords color="ContextKeywords">
<Word>yield</Word>
<Word>partial</Word>
<Word>global</Word>
@ -169,24 +165,24 @@ @@ -169,24 +165,24 @@
<Word>dynamic</Word>
</Keywords>
<Keywords fontWeight="bold" foreground="Teal">
<Keywords color="ExceptionKeywords">
<Word>try</Word>
<Word>throw</Word>
<Word>catch</Word>
<Word>finally</Word>
</Keywords>
<Keywords fontWeight="bold" foreground="DarkGray">
<Keywords color="CheckedKeyword">
<Word>checked</Word>
<Word>unchecked</Word>
</Keywords>
<Keywords foreground="Olive">
<Keywords color="UnsafeKeywords">
<Word>fixed</Word>
<Word>unsafe</Word>
</Keywords>
<Keywords fontWeight="bold" foreground="Red">
<Keywords color="ValueTypes">
<Word>bool</Word>
<Word>byte</Word>
<Word>char</Word>
@ -204,31 +200,28 @@ @@ -204,31 +200,28 @@
<Word>ulong</Word>
</Keywords>
<Keywords foreground="Red">
<Keywords color="ReferenceTypes">
<Word>class</Word>
<Word>interface</Word>
<Word>delegate</Word>
<Word>object</Word>
<Word>string</Word>
</Keywords>
<Keywords foreground="Red">
<Word>void</Word>
</Keywords>
<Keywords fontWeight="bold" foreground="Pink">
<Keywords color="OperatorKeywords">
<Word>explicit</Word>
<Word>implicit</Word>
<Word>operator</Word>
</Keywords>
<Keywords fontWeight="bold" foreground="DeepPink">
<Keywords color="ParameterModifiers">
<Word>params</Word>
<Word>ref</Word>
<Word>out</Word>
</Keywords>
<Keywords foreground="Brown">
<Keywords color="Modifiers">
<Word>abstract</Word>
<Word>const</Word>
<Word>event</Word>
@ -241,43 +234,39 @@ @@ -241,43 +234,39 @@
<Word>volatile</Word>
</Keywords>
<Keywords fontWeight="bold" foreground="Blue">
<Keywords color="Visibility">
<Word>public</Word>
<Word>protected</Word>
<Word>private</Word>
<Word>internal</Word>
</Keywords>
<Keywords fontWeight="bold" foreground="Green">
<Keywords color="NamespaceKeywords">
<Word>namespace</Word>
<Word>using</Word>
</Keywords>
<Keywords foreground="DarkViolet">
<Word>lock</Word>
</Keywords>
<Keywords foreground="SaddleBrown">
<Keywords color="GetSetAddRemove">
<Word>get</Word>
<Word>set</Word>
<Word>add</Word>
<Word>remove</Word>
</Keywords>
<Keywords fontWeight="bold" foreground="Black">
<Keywords color="NullOrValueKeywords">
<Word>null</Word>
<Word>value</Word>
</Keywords>
<!-- Mark previous rule-->
<Rule foreground="MidnightBlue" fontWeight="bold">
<Rule color="MethodCall">
\b
[\d\w_]+ # an identifier
(?=\s*\() # followed by (
</Rule>
<!-- Digits -->
<Rule foreground="DarkBlue">
<Rule color="NumberLiteral">
\b0[xX][0-9a-fA-F]+ # hex number
| \b
( \d+(\.[0-9]+)? #number with optional floating point

22
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Patch-Mode.xshd

@ -1,28 +1,34 @@ @@ -1,28 +1,34 @@
<?xml version="1.0"?>
<SyntaxDefinition name="Patch" extensions=".patch;.diff" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="AddedText" foreground="Navy" exampleText="+added" />
<Color name="RemovedText" foreground="#FF339966" exampleText="-removed" />
<Color name="UnchangedText" exampleText=" unchanged" />
<Color name="Position" foreground="Navy" exampleText="@@ -186,6 +186,12 @@" />
<Color name="Header" foreground="DarkRed" exampleText="--- (oldversion)&#10;+++ (newversion)" />
<Color name="FileName" foreground="Green" fontWeight="bold" exampleText="Index: path/to/file" />
<RuleSet>
<Span foreground="Green" fontWeight="bold">
<Span color="FileName">
<Begin>Index:\s</Begin>
</Span>
<Span foreground="DarkRed">
<Span color="Header">
<Begin>==</Begin>
</Span>
<Span foreground="DarkRed">
<Span color="Header">
<Begin>---</Begin>
</Span>
<Span foreground="DarkRed">
<Span color="Header">
<Begin>\+\+\+</Begin>
</Span>
<Span foreground="Purple">
<Begin>@</Begin>
<Begin>@@</Begin>
</Span>
<Span foreground="#FF339966">
<Span color="RemovedText">
<Begin>-</Begin>
</Span>
<Span foreground="Navy">
<Span color="AddedText">
<Begin>\+</Begin>
</Span>
<Span foreground="SystemColors.WindowText">
<Span color="UnchangedText">
<Begin>\s</Begin>
</Span>
</RuleSet>

6
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/VBNET-Mode.xshd

@ -5,13 +5,13 @@ @@ -5,13 +5,13 @@
<!-- Converted to AvalonEdit format by Daniel Grunwald in 2010 -->
<SyntaxDefinition name="VBNET" extensions=".vb" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="Comment" foreground="Green" exampleText="' comment" />
<Color name="String" exampleText="Dim text As String = &quot;Hello, World!&quot;" />
<Color name="String" exampleText="text = &quot;Hello, World!&quot;" />
<Color name="DateLiteral" foreground="Blue" exampleText="Dim endOfWorld As DateTime = #2012-12-21#" />
<Color name="DateLiteral" foreground="Blue" exampleText="endOfWorld = #2012-12-21#" />
<Color name="Preprocessor" foreground="Maroon" exampleText="#Region &quot;Title&quot;" />
<Color name="DataTypes" foreground="#FF6F002F" exampleText="Dim b As Boolean = True" />
<Color name="Operators" foreground="#FF8515EA" exampleText="If a OrElse b Then"/>
<Color name="Constants" foreground="Blue" exampleText="Dim b As Boolean = True" />
<Color name="Constants" foreground="Blue" exampleText="b = False" />
<Color name="Keywords" foreground="Blue" exampleText="If a OrElse b Then" />
<Color name="FunctionKeywords" foreground="Blue" exampleText="CInt(a)" />
<Color name="ContextKeywords" foreground="Blue" exampleText="Declare Unicode Sub SomeMethod" />

26
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/XML-Mode.xshd

@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
<SyntaxDefinition name="XML" extensions=".xml;.xsl;.xslt;.xsd;.manifest;.config;.addin;.xshd;.wxs;.wxi;.wxl;.proj;.csproj;.vbproj;.ilproj;.booproj;.build;.xfrm;.targets;.xaml;.xpt;.xft;.map;.wsdl;.disco" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color foreground="Green" name="Comment" />
<Color foreground="Blue" name="CData" />
<Color foreground="Blue" name="DocType" />
<Color foreground="Blue" name="XmlDecl" />
<Color foreground="DarkMagenta" name="XmlTag" />
<Color foreground="Red" name="AttributeName" />
<Color foreground="Blue" name="AttributeValue" />
<Color foreground="Teal" name="Entity" />
<Color foreground="Olive" name="BrokenEntity" />
<Color foreground="Green" name="Comment" exampleText="&lt;!-- comment --&gt;" />
<Color foreground="Blue" name="CData" exampleText="&lt;![CDATA[data]]&gt;" />
<Color foreground="Blue" name="DocType" exampleText="&lt;!DOCTYPE rootElement&gt;" />
<Color foreground="Blue" name="XmlDeclaration" exampleText='&lt;?xml version="1.0"?&gt;' />
<Color foreground="DarkMagenta" name="XmlTag" exampleText='&lt;tag attribute="value" /&gt;' />
<Color foreground="Red" name="AttributeName" exampleText='&lt;tag attribute="value" /&gt;' />
<Color foreground="Blue" name="AttributeValue" exampleText='&lt;tag attribute="value" /&gt;' />
<Color foreground="Teal" name="Entity" exampleText="index.aspx?a=1&amp;amp;b=2" />
<Color foreground="Olive" name="BrokenEntity" exampleText="index.aspx?a=1&amp;b=2" />
<RuleSet>
<Span color="Comment" multiline="true">
@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
<Begin>&lt;!DOCTYPE</Begin>
<End>&gt;</End>
</Span>
<Span color="XmlDecl" multiline="true">
<Span color="XmlDeclaration" multiline="true">
<Begin>&lt;\?</Begin>
<End>\?&gt;</End>
</Span>
@ -30,13 +30,15 @@ @@ -30,13 +30,15 @@
<Begin>&lt;</Begin>
<End>&gt;</End>
<RuleSet>
<!-- Treat the position before '<' as end, as that's not a valid character
in attribute names and indicates the user forgot a closing quote. -->
<Span color="AttributeValue" multiline="true" ruleSet="EntitySet">
<Begin>"</Begin>
<End>"</End>
<End>"|(?=&lt;)</End>
</Span>
<Span color="AttributeValue" multiline="true" ruleSet="EntitySet">
<Begin>'</Begin>
<End>'</End>
<End>'|(?=&lt;)</End>
</Span>
<Rule color="AttributeName">[\d\w_\-\.]+(?=(\s*=))</Rule>
<Rule color="AttributeValue">=</Rule>

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Design#CA1020;-Microsoft.Design#CA1033;-Microsoft.Performance#CA1810</CodeAnalysisRules>
<CodeAnalysisRules>-Microsoft.Design#CA1020;-Microsoft.Design#CA1033;-Microsoft.Performance#CA1805;-Microsoft.Performance#CA1810</CodeAnalysisRules>
<OutputPath>..\..\..\..\bin\</OutputPath>
<DocumentationFile>..\..\..\..\bin\ICSharpCode.AvalonEdit.xml</DocumentationFile>
</PropertyGroup>

8
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Indentation/CSharp/DocumentAccessor.cs

@ -20,13 +20,13 @@ namespace ICSharpCode.AvalonEdit.Indentation.CSharp @@ -20,13 +20,13 @@ namespace ICSharpCode.AvalonEdit.Indentation.CSharp
{
/// <summary>Gets if the current line is read only (because it is not in the
/// selected text region)</summary>
bool ReadOnly { get; }
bool IsReadOnly { get; }
/// <summary>Gets the number of the current line.</summary>
int LineNumber { get; }
/// <summary>Gets/Sets the text of the current line.</summary>
string Text { get; set; }
/// <summary>Advances to the next line.</summary>
bool Next();
bool MoveNext();
}
#region TextDocumentAccessor
@ -68,7 +68,7 @@ namespace ICSharpCode.AvalonEdit.Indentation.CSharp @@ -68,7 +68,7 @@ namespace ICSharpCode.AvalonEdit.Indentation.CSharp
DocumentLine line;
/// <inheritdoc/>
public bool ReadOnly {
public bool IsReadOnly {
get {
return num < minLine;
}
@ -94,7 +94,7 @@ namespace ICSharpCode.AvalonEdit.Indentation.CSharp @@ -94,7 +94,7 @@ namespace ICSharpCode.AvalonEdit.Indentation.CSharp
}
/// <inheritdoc/>
public bool Next()
public bool MoveNext()
{
if (lineDirty) {
doc.Replace(line, text);

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Indentation/CSharp/IndentationReformatter.cs

@ -121,7 +121,7 @@ namespace ICSharpCode.AvalonEdit.Indentation.CSharp @@ -121,7 +121,7 @@ namespace ICSharpCode.AvalonEdit.Indentation.CSharp
{
Init();
while (doc.Next()) {
while (doc.MoveNext()) {
Step(doc, set);
}
}
@ -389,7 +389,7 @@ namespace ICSharpCode.AvalonEdit.Indentation.CSharp @@ -389,7 +389,7 @@ namespace ICSharpCode.AvalonEdit.Indentation.CSharp
oldBlock.OneLineBlock = block.OneLineBlock - 1;
}
if (doc.ReadOnly) {
if (doc.IsReadOnly) {
// We can't change the current line, but we should accept the existing
// indentation if possible (=if the current statement is not a multiline
// statement).

26
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/PixelSnapHelpers.cs

@ -34,18 +34,18 @@ namespace ICSharpCode.AvalonEdit.Utils @@ -34,18 +34,18 @@ namespace ICSharpCode.AvalonEdit.Utils
}
/// <summary>
/// Aligns val on the next middle of a pixel.
/// Aligns <paramref name="value"/> on the next middle of a pixel.
/// </summary>
/// <param name="val">The value that should be aligned</param>
/// <param name="value">The value that should be aligned</param>
/// <param name="pixelSize">The size of one pixel</param>
public static double PixelAlign(double val, double pixelSize)
public static double PixelAlign(double value, double pixelSize)
{
// 0 -> 0.5
// 0.1 -> 0.5
// 0.5 -> 0.5
// 0.9 -> 0.5
// 1 -> 1.5
return pixelSize * (Math.Round((val / pixelSize) + 0.5) - 0.5);
return pixelSize * (Math.Round((value / pixelSize) + 0.5) - 0.5);
}
/// <summary>
@ -61,11 +61,11 @@ namespace ICSharpCode.AvalonEdit.Utils @@ -61,11 +61,11 @@ namespace ICSharpCode.AvalonEdit.Utils
}
/// <summary>
/// Rounds val to whole number of pixels.
/// Rounds <paramref name="point"/> to whole number of pixels.
/// </summary>
public static Point Round(Point val, Size pixelSize)
public static Point Round(Point point, Size pixelSize)
{
return new Point(Round(val.X, pixelSize.Width), Round(val.Y, pixelSize.Height));
return new Point(Round(point.X, pixelSize.Width), Round(point.Y, pixelSize.Height));
}
/// <summary>
@ -78,19 +78,19 @@ namespace ICSharpCode.AvalonEdit.Utils @@ -78,19 +78,19 @@ namespace ICSharpCode.AvalonEdit.Utils
}
/// <summary>
/// Rounds val to a whole number of pixels.
/// Rounds <paramref name="value"/> to a whole number of pixels.
/// </summary>
public static double Round(double val, double pixelSize)
public static double Round(double value, double pixelSize)
{
return pixelSize * Math.Round(val / pixelSize);
return pixelSize * Math.Round(value / pixelSize);
}
/// <summary>
/// Rounds val to an whole odd number of pixels.
/// Rounds <paramref name="value"/> to an whole odd number of pixels.
/// </summary>
public static double RoundToOdd(double val, double pixelSize)
public static double RoundToOdd(double value, double pixelSize)
{
return Round(val - pixelSize, pixelSize * 2) + pixelSize;
return Round(value - pixelSize, pixelSize * 2) + pixelSize;
}
}
}

32
src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml

@ -1,15 +1,21 @@ @@ -1,15 +1,21 @@
<UserControl x:Class="ICSharpCode.SharpDevelop.Gui.ColorPicker" x:Name="colorPicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Gui">
<Button Name="button" Click="ButtonClick">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border CornerRadius="3" BorderBrush="Black" BorderThickness="1.5" Background="{TemplateBinding Background}">
<ContentPresenter Content="{TemplateBinding Content}"
HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
</ControlTemplate>
</Button.Template>
<?xml version="1.0" encoding="utf-8"?>
<UserControl
x:Class="ICSharpCode.SharpDevelop.Gui.ColorPicker"
x:Name="colorPicker" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Gui">
<Button
Name="button"
Click="ButtonClick"
Padding="2"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch">
<Border
BorderBrush="Black"
BorderThickness="1"
Padding="1"
Name="border">
<TextBlock
Name="textBlock"
TextAlignment="Center" />
</Border>
</Button>
</UserControl>

11
src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs

@ -44,16 +44,16 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -44,16 +44,16 @@ namespace ICSharpCode.SharpDevelop.Gui
ColorPicker picker = obj as ColorPicker;
if (picker != null) {
Color color = picker.Value;
picker.button.Background = new SolidColorBrush(color);
picker.border.Background = new SolidColorBrush(color);
// find a foreground color that is visible on the background
if (color.A < 128)
picker.button.Foreground = SystemColors.WindowTextBrush;
picker.textBlock.Foreground = SystemColors.WindowTextBrush;
else if (0.299f * color.R + 0.587f * color.G + 0.114f * color.B > 128)
picker.button.Foreground = Brushes.Black;
picker.textBlock.Foreground = Brushes.Black;
else
picker.button.Foreground = Brushes.WhiteSmoke;
picker.textBlock.Foreground = Brushes.WhiteSmoke;
picker.button.Content = picker.Text ?? color.ToString();
picker.textBlock.Text = picker.Text ?? color.ToString();
}
}
@ -64,6 +64,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -64,6 +64,7 @@ namespace ICSharpCode.SharpDevelop.Gui
void ButtonClick(object sender, RoutedEventArgs e)
{
e.Handled = true;
using (SharpDevelopColorDialog dlg = new SharpDevelopColorDialog()) {
dlg.WpfColor = this.Value;
if (dlg.ShowWpfDialog() == true) {

Loading…
Cancel
Save