Skip to content

Commit 5b1e188

Browse files
author
Eric Amodio
committed
Fixes theming colors - moved into webview
Adds editorconfig & formatting options
1 parent 80e1f75 commit 5b1e188

File tree

8 files changed

+730
-1216
lines changed

8 files changed

+730
-1216
lines changed

Diff for: vs/.editorconfig

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
indent_style = tab
8+
indent_size = tab
9+
tab_width = 4
10+
11+
[*.cs]
12+
# Organize usings
13+
dotnet_sort_system_directives_first = true:silent
14+
dotnet_separate_import_directive_groups = false:silent
15+
16+
# Language keywords vs BCL types preferences
17+
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
18+
dotnet_style_predefined_type_for_member_access = true:silent
19+
20+
# Modifier preferences
21+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
22+
dotnet_style_readonly_field = true:suggestion
23+
24+
# Expression-level preferences
25+
dotnet_style_object_initializer = true:suggestion
26+
dotnet_style_collection_initializer = true:suggestion
27+
dotnet_style_explicit_tuple_names = true:silent
28+
dotnet_style_null_propagation = true:suggestion
29+
dotnet_style_coalesce_expression = true:silent
30+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
31+
dotnet_style_prefer_inferred_tuple_names = false:silent
32+
dotnet_style_prefer_inferred_anonymous_type_member_names = false:silent
33+
dotnet_style_prefer_auto_properties = true:silent
34+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
35+
36+
# Style Definitions
37+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case:suggestion
38+
39+
# Use PascalCase for constant fields
40+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
41+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
42+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
43+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
44+
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
45+
dotnet_naming_symbols.constant_fields.required_modifiers = const
46+
47+
# var preferences
48+
csharp_style_var_for_built_in_types = true:silent
49+
csharp_style_var_when_type_is_apparent = true:silent
50+
csharp_style_var_elsewhere = true:silent
51+
52+
# Expression-bodied members
53+
csharp_style_expression_bodied_methods = false:silent
54+
csharp_style_expression_bodied_constructors = false:silent
55+
csharp_style_expression_bodied_operators = false:silent
56+
csharp_style_expression_bodied_properties = true:silent
57+
csharp_style_expression_bodied_indexers = true:silent
58+
csharp_style_expression_bodied_accessors = true:silent
59+
60+
# Pattern-matching preferences
61+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
62+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
63+
64+
# Null-checking preferences
65+
csharp_style_throw_expression = true:suggestion
66+
csharp_style_conditional_delegate_call = true:suggestion
67+
68+
# Modifier preferences
69+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
70+
71+
# Expression-level preferences
72+
csharp_prefer_braces = true:silent
73+
csharp_style_deconstructed_variable_declaration = true:suggestion
74+
csharp_prefer_simple_default_expression = true:suggestion
75+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
76+
csharp_style_inlined_variable_declaration = true:suggestion
77+
78+
# New line preferences
79+
csharp_new_line_before_open_brace = none:warning
80+
csharp_new_line_before_else = true:warning
81+
csharp_new_line_before_catch = true:warning
82+
csharp_new_line_before_finally = true:warning
83+
csharp_new_line_before_members_in_object_initializers = true:silent
84+
csharp_new_line_before_members_in_anonymous_types = true:silent
85+
csharp_new_line_between_query_expression_clauses = true:silent
86+
87+
# Indentation preferences
88+
csharp_indent_case_contents = true:silent
89+
csharp_indent_switch_labels = true:silent
90+
csharp_indent_labels = flush_left:silent
91+
92+
# Space preferences
93+
csharp_space_after_cast = false:silent
94+
csharp_space_after_keywords_in_control_flow_statements = true:silent
95+
csharp_space_between_method_call_parameter_list_parentheses = false:silent
96+
csharp_space_between_method_declaration_parameter_list_parentheses = false:silent
97+
csharp_space_between_parentheses = false:silent
98+
csharp_space_before_colon_in_inheritance_clause = true:silent
99+
csharp_space_after_colon_in_inheritance_clause = true:silent
100+
csharp_space_around_binary_operators = before_and_after:silent
101+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false:silent
102+
csharp_space_between_method_call_name_and_opening_parenthesis = false:silent
103+
csharp_space_between_method_call_empty_parameter_list_parentheses = false:silent
104+
105+
# Wrapping preferences
106+
csharp_preserve_single_line_statements = false:silent
107+
csharp_preserve_single_line_blocks = true:silent

Diff for: vs/omnisharp.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"FormattingOptions": {
3+
"SpacingAfterMethodDeclarationName": false,
4+
"SpaceWithinMethodDeclarationParenthesis": false,
5+
"SpaceBetweenEmptyMethodDeclarationParentheses": false,
6+
"SpaceAfterMethodCallName": false,
7+
"SpaceWithinMethodCallParentheses": false,
8+
"SpaceBetweenEmptyMethodCallParentheses": false,
9+
"SpaceAfterControlFlowStatementKeyword": true,
10+
"SpaceWithinExpressionParentheses": false,
11+
"SpaceWithinCastParentheses": false,
12+
"SpaceWithinOtherParentheses": false,
13+
"SpaceAfterCast": false,
14+
"SpacesIgnoreAroundVariableDeclaration": false,
15+
"SpaceBeforeOpenSquareBracket": false,
16+
"SpaceBetweenEmptySquareBrackets": false,
17+
"SpaceWithinSquareBrackets": false,
18+
"SpaceAfterColonInBaseTypeDeclaration": true,
19+
"SpaceAfterComma": true,
20+
"SpaceAfterDot": false,
21+
"SpaceAfterSemicolonsInForStatement": true,
22+
"SpaceBeforeColonInBaseTypeDeclaration": true,
23+
"SpaceBeforeComma": false,
24+
"SpaceBeforeDot": false,
25+
"SpaceBeforeSemicolonsInForStatement": false,
26+
"SpacingAroundBinaryOperator": "single",
27+
"IndentBraces": false,
28+
"IndentBlock": true,
29+
"IndentSwitchSection": true,
30+
"IndentSwitchCaseSection": true,
31+
"IndentSwitchCaseSectionWhenBlock": true,
32+
"LabelPositioning": "oneLess",
33+
"WrappingPreserveSingleLine": true,
34+
"WrappingKeepStatementsOnSingleLine": true,
35+
"NewLinesForBracesInTypes": false,
36+
"NewLinesForBracesInMethods": false,
37+
"NewLinesForBracesInProperties": false,
38+
"NewLinesForBracesInAccessors": false,
39+
"NewLinesForBracesInAnonymousMethods": false,
40+
"NewLinesForBracesInControlBlocks": false,
41+
"NewLinesForBracesInAnonymousTypes": false,
42+
"NewLinesForBracesInObjectCollectionArrayInitializers": false,
43+
"NewLinesForBracesInLambdaExpressionBody": false,
44+
"NewLineForElse": true,
45+
"NewLineForCatch": true,
46+
"NewLineForFinally": true,
47+
"NewLineForMembersInObjectInit": true,
48+
"NewLineForMembersInAnonymousTypes": true,
49+
"NewLineForClausesInQuery": true
50+
}
51+
}
+75-74
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,89 @@
1-
using System.Drawing;
1+
using System;
2+
using System.Drawing;
23

34
namespace CodeStream.VisualStudio.Extensions
45
{
5-
public static class ColorExtensions
6-
{
7-
public static System.Windows.Media.Color ConvertToMediaColor(this System.Drawing.Color color)
8-
{
9-
return System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B);
10-
}
6+
public static class ColorExtensions
7+
{
8+
public static System.Windows.Media.Color ConvertToMediaColor(this System.Drawing.Color color)
9+
{
10+
return System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B);
11+
}
1112

12-
public static string ToHex(this Color color)
13-
{
14-
return "#"+ color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
15-
}
13+
public static string ToRgba(this Color color)
14+
{
15+
return $"rgba({color.R}, {color.G}, {color.B}, {(double)color.A / 255})";
16+
}
1617

17-
public static string ToArgb(this Color color, double percentage = 100)
18-
{
19-
return $"rgba({color.R}, {color.G}, {color.B}, {(percentage / 100)})";
20-
}
18+
public static float Lerp(this float start, float end, float amount)
19+
{
20+
float difference = end - start;
21+
float adjusted = difference * amount;
22+
return start + adjusted;
23+
}
2124

22-
public static float Lerp(this float start, float end, float amount)
23-
{
24-
float difference = end - start;
25-
float adjusted = difference * amount;
26-
return start + adjusted;
27-
}
25+
/// <summary>
26+
/// https://stackoverflow.com/questions/97646/how-do-i-determine-darker-or-lighter-color-variant-of-a-given-color/2690026#2690026
27+
/// </summary>
28+
/// <param name="color"></param>
29+
/// <param name="to"></param>
30+
/// <param name="amount"></param>
31+
/// <returns></returns>
32+
public static Color Lerp(this Color color, Color to, float amount)
33+
{
34+
// start colours as lerp-able floats
35+
float sr = color.R, sg = color.G, sb = color.B;
2836

29-
/// <summary>
30-
/// https://stackoverflow.com/questions/97646/how-do-i-determine-darker-or-lighter-color-variant-of-a-given-color/2690026#2690026
31-
/// </summary>
32-
/// <param name="color"></param>
33-
/// <param name="to"></param>
34-
/// <param name="amount"></param>
35-
/// <returns></returns>
36-
public static Color Lerp(this Color color, Color to, float amount)
37-
{
38-
// start colours as lerp-able floats
39-
float sr = color.R, sg = color.G, sb = color.B;
37+
// end colours as lerp-able floats
38+
float er = to.R, eg = to.G, eb = to.B;
4039

41-
// end colours as lerp-able floats
42-
float er = to.R, eg = to.G, eb = to.B;
40+
// lerp the colours to get the difference
41+
byte r = (byte)sr.Lerp(er, amount),
42+
g = (byte)sg.Lerp(eg, amount),
43+
b = (byte)sb.Lerp(eb, amount);
4344

44-
// lerp the colours to get the difference
45-
byte r = (byte)sr.Lerp(er, amount),
46-
g = (byte)sg.Lerp(eg, amount),
47-
b = (byte)sb.Lerp(eb, amount);
45+
// return the new colour
46+
return Color.FromArgb(r, g, b);
47+
}
4848

49-
// return the new colour
50-
return Color.FromArgb(r, g, b);
51-
}
49+
/// <summary>
50+
/// Darken a color
51+
/// </summary>
52+
/// <param name="color"></param>
53+
/// <param name="rate">0.1f == 10%</param>
54+
/// <param name="darker"></param>
55+
/// <returns></returns>
56+
public static Color Darken(this Color color, float rate = 0.1f, Color? darker = null)
57+
{
58+
return color.Lerp(darker ?? Color.Black, rate);
59+
}
5260

53-
/// <summary>
54-
/// Darken a color
55-
/// </summary>
56-
/// <param name="color"></param>
57-
/// <param name="rate">0.1f == 10%</param>
58-
/// <param name="darker"></param>
59-
/// <returns></returns>
60-
public static Color Darken(this Color color, float rate = 0.1f, Color? darker = null)
61-
{
62-
return color.Lerp(darker ?? Color.Black, rate);
63-
}
61+
/// <summary>
62+
/// Lighten a color
63+
/// </summary>
64+
/// <param name="color"></param>
65+
/// <param name="rate">0.1f == 10%</param>
66+
/// <param name="lighter"></param>
67+
/// <returns></returns>
68+
public static Color Lighten(this Color color, float rate = 0.1f, Color? lighter = null)
69+
{
70+
return color.Lerp(lighter ?? Color.White, rate);
71+
}
6472

65-
/// <summary>
66-
/// Lighten a color
67-
/// </summary>
68-
/// <param name="color"></param>
69-
/// <param name="rate">0.1f == 10%</param>
70-
/// <param name="lighter"></param>
71-
/// <returns></returns>
72-
public static Color Lighten(this Color color, float rate = 0.1f, Color? lighter = null)
73-
{
74-
return color.Lerp(lighter ?? Color.White, rate);
75-
}
73+
public static Color Opacity(this Color color, double percentage = 100)
74+
{
75+
return Color.FromArgb(Convert.ToInt32(255 * (color.A / 255 * percentage / 100)), color);
76+
}
7677

77-
/// <summary>
78-
/// Returns whether a color is closer to black rather than white
79-
/// </summary>
80-
/// <param name="c2"></param>
81-
/// <remarks>https://stackoverflow.com/a/9780689/208022</remarks>
82-
/// <returns></returns>
83-
public static bool IsDark(this Color c2)
84-
{
85-
return (0.2126 * c2.R + 0.7152 * c2.G + 0.0722 * c2.B) < 128;
86-
}
87-
}
78+
/// <summary>
79+
/// Returns whether a color is closer to black rather than white
80+
/// </summary>
81+
/// <param name="c2"></param>
82+
/// <remarks>https://stackoverflow.com/a/9780689/208022</remarks>
83+
/// <returns></returns>
84+
public static bool IsDark(this Color c2)
85+
{
86+
return (0.2126 * c2.R + 0.7152 * c2.G + 0.0722 * c2.B) < 128;
87+
}
88+
}
8889
}

0 commit comments

Comments
 (0)