-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
224 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
src/NiceHashMiner/Views/Common/EnterWalletDialogDemo.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<UserControl x:Class="NiceHashMiner.Views.Common.EnterWalletDialogDemo" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:NiceHashMiner.Views.Common" | ||
mc:Ignorable="d" | ||
d:DesignHeight="500" d:DesignWidth="800"> | ||
<UserControl.Resources> | ||
<Style x:Key="local.ExitTextBlock" TargetType="TextBlock"> | ||
<Setter Property="FontFamily" Value="{StaticResource FontAwesome}" /> | ||
<Setter Property="FontSize" Value="14" /> | ||
<Setter Property="FontWeight" Value="Normal" /> | ||
<Setter Property="FontStretch" Value="Normal" /> | ||
<Setter Property="FontStyle" Value="Normal" /> | ||
<Setter Property="LineHeight" Value="1.5" /> | ||
<Setter Property="TextAlignment" Value="Center" /> | ||
<Setter Property="Foreground" Value="{StaticResource Gray2ColorBrush}" /> | ||
<Setter Property="Text" Value="" /> | ||
<Style.Triggers> | ||
<Trigger Property="IsMouseOver" Value="True"> | ||
<Setter Property="Foreground" Value="{DynamicResource PrimaryColorBrush}" /> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
|
||
<Style x:Key="local.ExitTextButton" TargetType="Button" BasedOn="{StaticResource ButtonTextBlock}"> | ||
<Style.Resources> | ||
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource local.ExitTextBlock}" /> | ||
</Style.Resources> | ||
</Style> | ||
|
||
<Style x:Key="local.WalletHeader" TargetType="TextBlock"> | ||
<Setter Property="FontFamily" Value="{StaticResource Ubuntu-Regular}" /> | ||
<Setter Property="FontSize" Value="18" /> | ||
<Setter Property="FontWeight" Value="Normal" /> | ||
<Setter Property="FontStretch" Value="Normal" /> | ||
<Setter Property="FontStyle" Value="Normal" /> | ||
<Setter Property="LineHeight" Value="1.24" /> | ||
<Setter Property="TextAlignment" Value="Center" /> | ||
<Setter Property="Foreground" Value="{StaticResource Gray1ColorBrush}" /> | ||
</Style> | ||
|
||
|
||
<Style x:Key="local.WalletSubHeader" TargetType="TextBlock"> | ||
<Setter Property="FontFamily" Value="{StaticResource Ubuntu-Regular}" /> | ||
<Setter Property="FontSize" Value="12" /> | ||
<Setter Property="FontWeight" Value="Normal" /> | ||
<Setter Property="FontStretch" Value="Normal" /> | ||
<Setter Property="FontStyle" Value="Normal" /> | ||
<Setter Property="LineHeight" Value="1.5" /> | ||
<Setter Property="TextAlignment" Value="Center" /> | ||
<Setter Property="Foreground" Value="{DynamicResource TextColorBrush}" /> | ||
</Style> | ||
|
||
</UserControl.Resources> | ||
<Grid MaxHeight="260" MaxWidth="392" Height="Auto" Width="Auto" MinHeight="232" MinWidth="392" Background="{DynamicResource BackgroundColor}"> | ||
<Grid.Effect> | ||
<DropShadowEffect BlurRadius="50" ShadowDepth="10" Direction="-75" RenderingBias="Performance" Opacity="0.4"/> | ||
</Grid.Effect> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<Button Grid.Row="0" | ||
Style="{StaticResource local.ExitTextButton}" | ||
Content="" | ||
Margin="0,20,20,0" | ||
VerticalAlignment="Center" | ||
HorizontalAlignment="Right" | ||
Click="CloseDialog"/> | ||
<TextBlock Grid.Row="1" | ||
Style="{StaticResource local.WalletHeader}" | ||
VerticalAlignment="Stretch" | ||
HorizontalAlignment="Left" | ||
Margin="24,0,0,0" | ||
Text="Demo Mode"/> | ||
<TextBlock Grid.Row="2" | ||
Style="{StaticResource local.WalletSubHeader}" | ||
TextWrapping="WrapWithOverflow" | ||
TextAlignment="Left" | ||
VerticalAlignment="Stretch" | ||
HorizontalAlignment="Left" | ||
Margin="25,8,6,0"> | ||
<Run Text="You are currently mining in Demo Mode. "/> | ||
<Run Text="Add your Wallet Address " FontWeight="Bold"/> | ||
<Run Text="to start earning Bitcoins." /> | ||
</TextBlock> | ||
<TextBlock Grid.Row="3" | ||
Style="{StaticResource local.WalletSubHeader}" | ||
VerticalAlignment="Stretch" | ||
HorizontalAlignment="Left" | ||
Margin="25,8,0,0" | ||
Text="Wallet Address"/> | ||
<TextBox Grid.Row="4" | ||
Style="{StaticResource inputBox}" | ||
x:Name="textBoxBTCAddress" | ||
Text="{Binding CredentialsSettings.BitcoinAddress, Mode=OneWay}" | ||
TextChanged="TextBoxBitcoinAddress_TextChanged" | ||
KeyUp="TextBoxBitcoinAddress_KeyUp" | ||
LostFocus="TextBoxBitcoinAddress_LostFocus" | ||
Margin="0,8,0,0" /> | ||
<TextBlock Grid.Row="5" | ||
Margin="25,8,0,0"> | ||
<Hyperlink x:Name="addressHyperlink" RequestNavigate="AddressHyperlink_RequestNavigate" NavigateUri="https://www.nicehash.com/support/general-help/account/creating-a-new-account" TextDecorations="{x:Null}" Foreground="{StaticResource Brushes.Light.Basic.NoticeColor}"> | ||
How to create a Wallet Address? | ||
</Hyperlink> | ||
</TextBlock> | ||
<Button Grid.Row="6" | ||
x:Name="SaveButton" | ||
Style="{DynamicResource OKButton}" | ||
FontSize="10" | ||
Width="136" | ||
Height="24" | ||
VerticalAlignment="Top" | ||
HorizontalAlignment="Right" | ||
Content="SAVE" | ||
IsEnabled="False" | ||
Click="SaveButtonClicked" | ||
Margin="25,24,24,24"/> | ||
</Grid> | ||
</UserControl> |
89 changes: 89 additions & 0 deletions
89
src/NiceHashMiner/Views/Common/EnterWalletDialogDemo.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using NHMCore; | ||
using NHMCore.Utils; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace NiceHashMiner.Views.Common | ||
{ | ||
/// <summary> | ||
/// Interaction logic for EnterWalletDialogDemo.xaml | ||
/// </summary> | ||
public partial class EnterWalletDialogDemo : UserControl | ||
{ | ||
public EnterWalletDialogDemo() | ||
{ | ||
InitializeComponent(); | ||
} | ||
private void BtcTextValidation() | ||
{ | ||
var trimmedBtcText = textBoxBTCAddress.Text.Trim(); | ||
var btcOK = CredentialValidators.ValidateBitcoinAddress(trimmedBtcText); | ||
SaveButton.IsEnabled = btcOK; | ||
if (btcOK) | ||
{ | ||
textBoxBTCAddress.Style = Application.Current.FindResource("InputBoxGood") as Style; | ||
textBoxBTCAddress.BorderBrush = (Brush)Application.Current.FindResource("NastyGreenBrush"); | ||
} | ||
else | ||
{ | ||
textBoxBTCAddress.Style = Application.Current.FindResource("InputBoxBad") as Style; | ||
textBoxBTCAddress.BorderBrush = (Brush)Application.Current.FindResource("RedDangerColorBrush"); | ||
} | ||
} | ||
|
||
private void TextBoxBitcoinAddress_TextChanged(object sender, TextChangedEventArgs e) | ||
{ | ||
BtcTextValidation(); | ||
} | ||
|
||
private void TextBoxBitcoinAddress_KeyUp(object sender, KeyEventArgs e) | ||
{ | ||
BtcTextValidation(); | ||
} | ||
|
||
private void TextBoxBitcoinAddress_LostFocus(object sender, RoutedEventArgs e) | ||
{ | ||
BtcTextValidation(); | ||
} | ||
|
||
private void AddressHyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e) | ||
{ | ||
Process.Start(e.Uri.AbsoluteUri); | ||
} | ||
|
||
private void CloseDialog(object sender, RoutedEventArgs e) | ||
{ | ||
CustomDialogManager.HideCurrentModal(); | ||
} | ||
|
||
private async void SaveButtonClicked(object sender, RoutedEventArgs e) | ||
{ | ||
var trimmedBtcText = textBoxBTCAddress.Text.Trim(); | ||
var result = await ApplicationStateManager.SetBTCIfValidOrDifferent(trimmedBtcText); | ||
if (ApplicationStateManager.SetResult.INVALID == result) | ||
{ | ||
textBoxBTCAddress.Style = Application.Current.FindResource("InputBoxBad") as Style; | ||
textBoxBTCAddress.BorderBrush = (Brush)Application.Current.FindResource("RedDangerColorBrush"); | ||
} | ||
else | ||
{ | ||
CustomDialogManager.HideCurrentModal(); | ||
textBoxBTCAddress.Style = Application.Current.FindResource("InputBoxGood") as Style; | ||
textBoxBTCAddress.BorderBrush = (Brush)Application.Current.FindResource("NastyGreenBrush"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters