Skip to content

Commit

Permalink
Merge pull request #1714 from yahiheb/refactoring
Browse files Browse the repository at this point in the history
Simplify member access
  • Loading branch information
nopara73 committed Jul 3, 2019
2 parents 8de1014 + c5f9511 commit de6df9e
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 29 deletions.
5 changes: 3 additions & 2 deletions WalletWasabi.Gui/Behaviors/BindSelectedTextBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Avalonia;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Xaml.Interactivity;
using System;
using System.Reactive.Disposables;
Expand All @@ -12,7 +13,7 @@ internal class BindSelectedTextBehavior : Behavior<TextBox>
private CompositeDisposable Disposables { get; } = new CompositeDisposable();

private static readonly AvaloniaProperty<string> SelectedTextProperty =
AvaloniaProperty.Register<BindSelectedTextBehavior, string>(nameof(SelectedText), defaultBindingMode: Avalonia.Data.BindingMode.TwoWay);
AvaloniaProperty.Register<BindSelectedTextBehavior, string>(nameof(SelectedText), defaultBindingMode: BindingMode.TwoWay);

public string SelectedText
{
Expand Down
3 changes: 2 additions & 1 deletion WalletWasabi.Gui/Behaviors/CommandOnEnterBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using System.Reactive.Disposables;

Expand All @@ -16,7 +17,7 @@ protected override void OnAttached()

Disposables.Add(AssociatedObject.AddHandler(TextBox.KeyDownEvent, (sender, e) =>
{
if (e.Key == Avalonia.Input.Key.Enter)
if (e.Key == Key.Enter)
{
e.Handled = ExecuteCommand();
}
Expand Down
3 changes: 2 additions & 1 deletion WalletWasabi.Gui/Behaviors/FocusBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Xaml.Interactivity;
using System;
using System.Reactive.Disposables;
Expand All @@ -11,7 +12,7 @@ internal class FocusBehavior : Behavior<Control>
private CompositeDisposable Disposables { get; } = new CompositeDisposable();

private static readonly AvaloniaProperty<bool> IsFocusedProperty =
AvaloniaProperty.Register<FocusBehavior, bool>(nameof(IsFocused), defaultBindingMode: Avalonia.Data.BindingMode.TwoWay);
AvaloniaProperty.Register<FocusBehavior, bool>(nameof(IsFocused), defaultBindingMode: BindingMode.TwoWay);

public bool IsFocused
{
Expand Down
7 changes: 4 additions & 3 deletions WalletWasabi.Gui/Behaviors/PasteAddressOnClickBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.Interactivity;
using Avalonia.Xaml.Interactivity;
Expand Down Expand Up @@ -33,19 +34,19 @@ private TextBoxState MyTextBoxState
{
case TextBoxState.NormalTextBoxOperation:
{
AssociatedObject.Cursor = new Avalonia.Input.Cursor(Avalonia.Input.StandardCursorType.Ibeam);
AssociatedObject.Cursor = new Cursor(StandardCursorType.Ibeam);
}
break;

case TextBoxState.AddressInsert:
{
AssociatedObject.Cursor = new Avalonia.Input.Cursor(Avalonia.Input.StandardCursorType.Arrow);
AssociatedObject.Cursor = new Cursor(StandardCursorType.Arrow);
}
break;

case TextBoxState.SelectAll:
{
AssociatedObject.Cursor = new Avalonia.Input.Cursor(Avalonia.Input.StandardCursorType.Arrow);
AssociatedObject.Cursor = new Cursor(StandardCursorType.Arrow);
}
break;
}
Expand Down
12 changes: 7 additions & 5 deletions WalletWasabi.Gui/Behaviors/SuggestionBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Xaml.Interactivity;
using System;
using System.Collections.Generic;
Expand All @@ -15,7 +17,7 @@ internal class SuggestionBehavior : Behavior<TextBox>
private CompositeDisposable Disposables { get; set; }

private static readonly AvaloniaProperty<IEnumerable<SuggestionViewModel>> SuggestionItemsProperty =
AvaloniaProperty.Register<SuggestionBehavior, IEnumerable<SuggestionViewModel>>(nameof(SuggestionItems), defaultBindingMode: Avalonia.Data.BindingMode.TwoWay);
AvaloniaProperty.Register<SuggestionBehavior, IEnumerable<SuggestionViewModel>>(nameof(SuggestionItems), defaultBindingMode: BindingMode.TwoWay);

public IEnumerable<SuggestionViewModel> SuggestionItems
{
Expand All @@ -31,12 +33,12 @@ protected override void OnAttached()

Disposables.Add(AssociatedObject.AddHandler(TextBox.KeyDownEvent, (sender, e) =>
{
if (e.Key == Avalonia.Input.Key.Tab)
if (e.Key == Key.Tab)
{
HandleAutoUpdate();
e.Handled = true;
}
if (e.Key == Avalonia.Input.Key.Down)
if (e.Key == Key.Down)
{
if (SuggestionItems != null)
{
Expand Down Expand Up @@ -67,7 +69,7 @@ protected override void OnAttached()
e.Handled = true;
}
}
if (e.Key == Avalonia.Input.Key.Up)
if (e.Key == Key.Up)
{
if (SuggestionItems != null)
{
Expand All @@ -78,7 +80,7 @@ protected override void OnAttached()
e.Handled = true;
}
}
if (e.Key == Avalonia.Input.Key.Enter)
if (e.Key == Key.Enter)
{
if (SuggestionItems != null)
{
Expand Down
3 changes: 2 additions & 1 deletion WalletWasabi.Gui/Controls/ExtendedListBox.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Styling;
using System;

Expand All @@ -21,7 +22,7 @@ public ExtendedListBox()
(e.InputModifiers & InputModifiers.Shift) != 0,
(e.InputModifiers & InputModifiers.Control) != 0);
}
}, Avalonia.Interactivity.RoutingStrategies.Tunnel, true);
}, RoutingStrategies.Tunnel, true);
}

protected override void OnPointerPressed(PointerPressedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Gui/Controls/MultiTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
var border = e.NameScope.Get<Border>("border");
if (IsSelectable)
{
text.Cursor = new Cursor(Avalonia.Input.StandardCursorType.Ibeam);
text.Cursor = new Cursor(StandardCursorType.Ibeam);
}

Observable.FromEventPattern(text, nameof(text.PointerPressed))
Expand Down
12 changes: 7 additions & 5 deletions WalletWasabi.Gui/Controls/SortingArrow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.Interactivity;
using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Styling;
using ReactiveUI;
Expand Down Expand Up @@ -37,15 +39,15 @@ public SortingArrow()
Background = Application.Current.Resources[Global.ThemeBackgroundBrushResourceKey] as IBrush;
}

HorizontalContentAlignment = Avalonia.Layout.HorizontalAlignment.Stretch;
HorizontalContentAlignment = HorizontalAlignment.Stretch;
IconPath = new Path {
Stretch = Stretch.Fill,
Stroke = Design.IsDesignMode ? Brushes.White : Application.Current.Resources[Global.ApplicationAccentForegroundBrushResourceKey] as IBrush,
StrokeThickness = 0.8,
Width = 10,
Height = 10,
Margin = new Thickness(7, 0),
HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right
HorizontalAlignment = HorizontalAlignment.Right
};
TextBox = new TextBlock();

Expand All @@ -54,12 +56,12 @@ public SortingArrow()
{
new StackPanel
{
Orientation = Orientation.Horizontal, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left,
Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Left,
Children = { TextBox }
},
new StackPanel
{
Orientation = Orientation.Horizontal, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right,
Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right,
Children =
{
IconPath
Expand All @@ -86,7 +88,7 @@ protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
Click += SortingArrow_Click;
}

private void SortingArrow_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
private void SortingArrow_Click(object sender, RoutedEventArgs e)
{
switch (SortDirection)
{
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Gui/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ private async Task AddKnownBitcoinFullNodeAsHiddenServiceAsync(AddressManager ad
onions.Shuffle();
foreach (var onion in onions.Take(60))
{
if (NBitcoin.Utils.TryParseEndpoint(onion, Network.DefaultPort, out var endpoint))
if (Utils.TryParseEndpoint(onion, Network.DefaultPort, out var endpoint))
{
await addressManager.AddAsync(endpoint);
}
Expand Down
3 changes: 2 additions & 1 deletion WalletWasabi.Gui/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Avalonia.Native;
using AvalonStudio.Extensibility;
using AvalonStudio.Extensibility.Theme;
using AvalonStudio.Shell;
Expand Down Expand Up @@ -39,7 +40,7 @@ public MainWindow()

// This will need implementing properly once this is supported by avalonia itself.
var color = (ColorTheme.CurrentTheme.Background as SolidColorBrush).Color;
(PlatformImpl as Avalonia.Native.WindowImpl).SetTitleBarColor(color);
(PlatformImpl as WindowImpl).SetTitleBarColor(color);
}
}

Expand Down
4 changes: 2 additions & 2 deletions WalletWasabi.Packager/NSubsys/PeUtility.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -454,7 +454,7 @@ public enum DataSectionFlags : uint
public PeUtility(string filePath)
{
// Read in the DLL or EXE and get the timestamp
Stream = new FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite);
Stream = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite);

BinaryReader reader = new BinaryReader(Stream);
_dosHeader = FromBinaryReader<IMAGE_DOS_HEADER>(reader);
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Packager/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class Program
public static string WixProjectDirectory = Path.GetFullPath(Path.Combine(SolutionDirectory, "WalletWasabi.WindowsInstaller\\"));
public static string BinDistDirectory = Path.GetFullPath(Path.Combine(GuiProjectDirectory, "bin\\dist"));

public static string VersionPrefix = Helpers.Constants.ClientVersion.ToString();
public static string VersionPrefix = Constants.ClientVersion.ToString();

public static bool OnlyBinaries;
public static bool OnlyCreateDigests;
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Tests/P2pTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public async Task TestServicesAsync(string networkString)
var memPoolService = new MemPoolService();
connectionParameters.TemplateBehaviors.Add(new MemPoolBehavior(memPoolService));

var nodes = new NodesGroup(network, connectionParameters, requirements: Helpers.Constants.NodeRequirements);
var nodes = new NodesGroup(network, connectionParameters, requirements: Constants.NodeRequirements);

BitcoinStore bitcoinStore = new BitcoinStore();
await bitcoinStore.InitializeAsync(Path.Combine(Global.Instance.DataDir, nameof(TestServicesAsync)), network);
Expand Down
4 changes: 2 additions & 2 deletions WalletWasabi/Mono/ResponseFileSource.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Options.cs
//
// Authors:
Expand Down Expand Up @@ -177,7 +177,7 @@ public override bool GetArguments(string value, out IEnumerable<string> replacem
replacement = null;
return false;
}
replacement = ArgumentSource.GetArgumentsFromFile(value.Substring(1));
replacement = GetArgumentsFromFile(value.Substring(1));
return true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions WalletWasabi/Mono/StringCoda.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Options.cs
//
// Authors:
Expand Down Expand Up @@ -246,7 +246,7 @@ private static bool IsEolChar(char c)

private static int GetLineEnd(int start, int length, string description)
{
int end = System.Math.Min(start + length, description.Length);
int end = Math.Min(start + length, description.Length);
int sep = -1;
for (int i = start; i < end; ++i)
{
Expand Down

0 comments on commit de6df9e

Please sign in to comment.