Skip to content

Commit

Permalink
Merge pull request #5 from Kimahari/cleanup-refactor
Browse files Browse the repository at this point in the history
Code Cleanup
  • Loading branch information
Kimahari authored Nov 21, 2018
2 parents 90df8d1 + 57bef7d commit 2aebef5
Show file tree
Hide file tree
Showing 31 changed files with 1,144 additions and 1,076 deletions.
3 changes: 3 additions & 0 deletions .bettercodehub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
component_depth: 6
languages:
- csharp
6 changes: 3 additions & 3 deletions App.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
Expand Down
41 changes: 20 additions & 21 deletions App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>



<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
Expand All @@ -19,22 +18,22 @@
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />

<ResourceDictionary>
<SolidColorBrush x:Key="HighlightBrush" Color="{DynamicResource Primary700}"/>
<SolidColorBrush x:Key="HighlightBrush" Color="{DynamicResource Primary700}" />
<SolidColorBrush x:Key="AccentBaseColorBrush" Color="{DynamicResource Primary600}" />
<SolidColorBrush x:Key="AccentColorBrush" Color="{DynamicResource Primary500}"/>
<SolidColorBrush x:Key="AccentColorBrush2" Color="{DynamicResource Primary400}"/>
<SolidColorBrush x:Key="AccentColorBrush3" Color="{DynamicResource Primary300}"/>
<SolidColorBrush x:Key="AccentColorBrush4" Color="{DynamicResource Primary200}"/>
<SolidColorBrush x:Key="WindowTitleColorBrush" Color="{DynamicResource Primary700}"/>
<SolidColorBrush x:Key="AccentSelectedColorBrush" Color="{DynamicResource Primary500Foreground}"/>
<SolidColorBrush x:Key="AccentColorBrush" Color="{DynamicResource Primary500}" />
<SolidColorBrush x:Key="AccentColorBrush2" Color="{DynamicResource Primary400}" />
<SolidColorBrush x:Key="AccentColorBrush3" Color="{DynamicResource Primary300}" />
<SolidColorBrush x:Key="AccentColorBrush4" Color="{DynamicResource Primary200}" />
<SolidColorBrush x:Key="WindowTitleColorBrush" Color="{DynamicResource Primary700}" />
<SolidColorBrush x:Key="AccentSelectedColorBrush" Color="{DynamicResource Primary500Foreground}" />
<LinearGradientBrush x:Key="ProgressBrush" EndPoint="0.001,0.5" StartPoint="1.002,0.5">
<GradientStop Color="{DynamicResource Primary700}" Offset="0"/>
<GradientStop Color="{DynamicResource Primary300}" Offset="1"/>
<GradientStop Color="{DynamicResource Primary700}" Offset="0" />
<GradientStop Color="{DynamicResource Primary300}" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush x:Key="CheckmarkFill" Color="{DynamicResource Primary500}"/>
<SolidColorBrush x:Key="RightArrowFill" Color="{DynamicResource Primary500}"/>
<SolidColorBrush x:Key="IdealForegroundColorBrush" Color="{DynamicResource Primary500Foreground}"/>
<SolidColorBrush x:Key="IdealForegroundDisabledBrush" Color="{DynamicResource Primary500}" Opacity="0.4"/>
<SolidColorBrush x:Key="CheckmarkFill" Color="{DynamicResource Primary500}" />
<SolidColorBrush x:Key="RightArrowFill" Color="{DynamicResource Primary500}" />
<SolidColorBrush x:Key="IdealForegroundColorBrush" Color="{DynamicResource Primary500Foreground}" />
<SolidColorBrush x:Key="IdealForegroundDisabledBrush" Color="{DynamicResource Primary500}" Opacity="0.4" />
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.OnSwitchBrush.Win10" Color="{DynamicResource Primary500}" />
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.OnSwitchMouseOverBrush.Win10" Color="{DynamicResource Primary400}" />
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorCheckedBrush.Win10" Color="{DynamicResource Primary500Foreground}" />
Expand All @@ -43,13 +42,13 @@
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Fonts.xaml" />
</ResourceDictionary.MergedDictionaries>

<converters:BooleanToVisibilityConverter x:Key="HiddenIfTrue" TriggerValue="True" IsHidden="True"/>
<converters:BooleanToVisibilityConverter x:Key="HiddenIfFalse" TriggerValue="False" IsHidden="True"/>
<converters:BooleanToVisibilityConverter x:Key="CollapsedIfTrue" TriggerValue="True" IsHidden="False"/>
<converters:BooleanToVisibilityConverter x:Key="CollapsedIfFalse" TriggerValue="False" IsHidden="False"/>
<converters:BooleanToVisibilityConverter x:Key="HiddenIfTrue" TriggerValue="True" IsHidden="True" />
<converters:BooleanToVisibilityConverter x:Key="HiddenIfFalse" TriggerValue="False" IsHidden="True" />
<converters:BooleanToVisibilityConverter x:Key="CollapsedIfTrue" TriggerValue="True" IsHidden="False" />
<converters:BooleanToVisibilityConverter x:Key="CollapsedIfFalse" TriggerValue="False" IsHidden="False" />

<converters:HasValueConverter x:Key="HasValue"/>
<converters:SecureStringValueConverter x:Key="SecureValue"/>
<converters:HasValueConverter x:Key="HasValue" />
<converters:SecureStringValueConverter x:Key="SecureValue" />
</ResourceDictionary>
</Application.Resources>
</Application>
9 changes: 2 additions & 7 deletions App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;

namespace DataBaseCompare {

/// <summary>
/// Interaction logic for App.xaml
/// </summary>
Expand Down
68 changes: 44 additions & 24 deletions Converters/BooleanToVisibilityConverter.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
using DataBaseCompare.Tools;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace DataBaseCompare.Converters {

/// <summary>
/// Converts Boolean Values to Control.Visibility values
/// </summary>
public class BooleanToVisibilityConverter : IValueConverter {
//Set to true if you want to show control when boolean value is true
//Set to false if you want to hide/collapse control when value is true
private bool triggerValue = false;
public bool TriggerValue {
get { return triggerValue; }
set { triggerValue = value; }
}

#region Fields

//Set to true if you just want to hide the control
//else set to false if you want to collapse the control
private bool isHidden;

//Set to true if you want to show control when boolean value is true
//Set to false if you want to hide/collapse control when value is true
private bool triggerValue;

#endregion Fields

#region Properties

public bool IsHidden {
get { return isHidden; }
set { isHidden = value; }
get => isHidden;
set => isHidden = value;
}

public bool TriggerValue {
get => triggerValue;
set => triggerValue = value;
}

#endregion Properties

#region Methods

public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
return GetVisibility(value);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
throw new NotImplementedException();
}

private object GetVisibility(object value) {
if (!(value is bool))
return DependencyProperty.UnsetValue;
bool objValue = (bool)value;
var objValue = (bool) value;
if ((objValue && TriggerValue && IsHidden) || (!objValue && !TriggerValue && IsHidden)) {
return Visibility.Hidden;
}
Expand All @@ -43,34 +61,36 @@ private object GetVisibility(object value) {
return Visibility.Visible;
}

public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
return GetVisibility(value);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
throw new NotImplementedException();
}
#endregion Methods
}


public class HasValueConverter : IValueConverter {

#region Methods

public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
return !String.IsNullOrEmpty($"{value}") ? Visibility.Visible : Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
throw new NotImplementedException();
}
}

#endregion Methods
}

public class SecureStringValueConverter : IValueConverter {

#region Methods

public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
return (value as SecureString).SecureStringToString();
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
return $"{value}".ToSecureString();
}

#endregion Methods
}
}
6 changes: 5 additions & 1 deletion CopyDatabase.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<RootNamespace>DataBaseCompare</RootNamespace>
<AssemblyName>Copy Database</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -128,9 +128,13 @@
<Compile Include="Converters\BooleanToVisibilityConverter.cs" />
<Compile Include="Helpers\PasswordHelper.cs" />
<Compile Include="Models\ConnectionModel.cs" />
<Compile Include="Models\CopyToArguments.cs" />
<Compile Include="Models\DataBaseModel.cs" />
<Compile Include="Models\ModelBase.cs" />
<Compile Include="Models\RoutineModel.cs" />
<Compile Include="Models\ScriptedModel.cs" />
<Compile Include="Models\TableModel.cs" />
<Compile Include="Tools\Constants.cs" />
<Compile Include="Tools\Extensions.cs" />
<Compile Include="ViewModels\MainViewModel.cs" />
<Compile Include="Views\ConnectionView.xaml.cs">
Expand Down
13 changes: 12 additions & 1 deletion CopyDatabase.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ VisualStudioVersion = 15.0.27703.2035
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CopyDatabase", "CopyDatabase.csproj", "{E9531BF0-F91F-414E-B19B-82DE6500A2FC}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "CopyDatabaseInstaller", "CopyDatabaseInstaller\CopyDatabaseInstaller.vdproj", "{975131A5-F92A-479E-90F4-6C8472DD5FF8}"
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Copy Database", "CopyDatabaseInstaller\CopyDatabaseInstaller.vdproj", "{975131A5-F92A-479E-90F4-6C8472DD5FF8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BetterCode", "BetterCode", "{FED15082-96C5-4473-A7AF-F7AB7CE453B6}"
ProjectSection(SolutionItems) = preProject
.bettercodehub.yml = .bettercodehub.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CopyDatabaseTests", "CopyDatabaseTests\CopyDatabaseTests.csproj", "{FC1E3829-4A8C-46CD-9C7E-1BE22CD72351}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -19,6 +26,10 @@ Global
{E9531BF0-F91F-414E-B19B-82DE6500A2FC}.Release|Any CPU.Build.0 = Release|Any CPU
{975131A5-F92A-479E-90F4-6C8472DD5FF8}.Debug|Any CPU.ActiveCfg = Debug
{975131A5-F92A-479E-90F4-6C8472DD5FF8}.Release|Any CPU.ActiveCfg = Release
{FC1E3829-4A8C-46CD-9C7E-1BE22CD72351}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC1E3829-4A8C-46CD-9C7E-1BE22CD72351}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC1E3829-4A8C-46CD-9C7E-1BE22CD72351}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC1E3829-4A8C-46CD-9C7E-1BE22CD72351}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading

0 comments on commit 2aebef5

Please sign in to comment.