Commit 9f708bbf authored by 潘栩锋's avatar 潘栩锋 🚴

数据库浏览器,开始动工

parent e90e958f
......@@ -4,6 +4,17 @@
xmlns:local="clr-namespace:DB.Browser"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
<ResourceDictionary Source="Themes/Styles.xaml" />
<ResourceDictionary Source="Converters/Converters.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
using System;
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
......@@ -13,5 +14,31 @@ namespace DB.Browser
/// </summary>
public partial class App : Application
{
NLog.Logger log = NLog.LogManager.GetLogger("app");
public static MetroWindow MetroWindow { get; set; }
public App()
{
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
{
string err = e.ExceptionObject.ToString();
log.Error(err);
MessageBox.Show("程序出现异常,请把下面信息拍照发给厂家" + Environment.NewLine + err,
"异常,联系厂家",
MessageBoxButton.OK, MessageBoxImage.Error);
};
//AutoMapper 初始化
//所有使用到 AutoMapper 的程序集 必须主动显式 在这里加载。
//当为 dll 反射加载的 程序集, 应该在此提前 加载。
var cfg = new AutoMapper.Configuration.MapperConfigurationExpression();
var assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
cfg.AddMaps(assemblies);
//cfg.AddMaps("FLY.Thick.Normal");
AutoMapper.Mapper.Initialize(cfg);
}
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:DB.Browser.Converter"
>
<conv:VisibilityConverter x:Key="visbilityconv" />
<conv:Equals2VisibleConverter_Collapsed x:Key="e2visconv_collapsed" />
<conv:Equals2VisibleConverter x:Key="e2visconv" />
<conv:Equals2HiddenConverter x:Key="e2hiddenconv" />
<conv:Equals2CollapsedConverter x:Key="e2collapsedconv" />
<conv:Equals2BoolConverter x:Key="e2bconv"/>
<conv:BoolReverseConverter x:Key="brconv"/>
</ResourceDictionary>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
namespace DB.Browser.Converter
{
public class Equals2BoolConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
return false;
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return true;
}
return false;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if ((bool)value == true)
{
return parameter;
}
else
{
return null;
}
}
#endregion
}
/// <summary>
/// 逻辑反向
/// </summary>
public class BoolReverseConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool b = (bool)value;
return !b;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool b = (bool)value;
return !b;
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
namespace DB.Browser.Converter
{
public class Equals2VisibleConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return System.Windows.Visibility.Visible;
}
return System.Windows.Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
public class Equals2VisibleConverter_Collapsed : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return System.Windows.Visibility.Visible;
}
return System.Windows.Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
public class Equals2CollapsedConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return System.Windows.Visibility.Collapsed;
}
return System.Windows.Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
public class Equals2HiddenConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return System.Windows.Visibility.Hidden;
}
return System.Windows.Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
namespace DB.Browser.Converter
{
public class VisibilityConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool enable = (bool)value;
string p = null;
if(parameter!=null)
p = parameter as string;
if (p == "Collapsed")
{
if (enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Collapsed;
}
else if (p == "HiddenWhenTrue")
{
if (!enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Hidden;
}
else if (p == "CollapsedWhenTrue")
{
if (!enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Collapsed;
}
else
{
if (enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Hidden;
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
}
......@@ -55,6 +55,11 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Themes\Styles.cs" />
<Page Include="Converters\Converters.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -63,12 +68,30 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Converters\Equals2BoolConverter.cs" />
<Compile Include="Converters\Equals2VisibleConverter.cs" />
<Compile Include="Converters\VisibilityConverter.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="PgMain.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\CustomTabControl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Styles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="PgMain.xaml.cs">
<DependentUpon>PgMain.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
......@@ -94,5 +117,31 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper">
<Version>8.1.1</Version>
</PackageReference>
<PackageReference Include="MahApps.Metro">
<Version>2.0.0-alpha0409</Version>
</PackageReference>
<PackageReference Include="MahApps.Metro.IconPacks">
<Version>3.0.0-alpha0206</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.2</Version>
</PackageReference>
<PackageReference Include="NLog">
<Version>4.6.6</Version>
</PackageReference>
<PackageReference Include="NLog.Config">
<Version>4.6.6</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>2.6.1</Version>
</PackageReference>
<PackageReference Include="System.Data.SQLite">
<Version>1.0.111</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
......@@ -5,6 +5,10 @@ VisualStudioVersion = 15.0.28307.572
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DB.Browser", "DB.Browser.csproj", "{77A8A78B-6C8B-4231-821F-8250B48AFBFB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Misc", "..\thick_public\Project.FLY.Misc\MISC\Misc.csproj", "{5EE61AC6-5269-4F0F-B8FA-4334FE4A678F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLiteHelper", "..\thick_public\Project.SQLiteHelper\SQLiteHelper\SQLiteHelper.csproj", "{4CBABFAA-1C62-4510-AC63-A51EE5FD50FF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -15,6 +19,14 @@ Global
{77A8A78B-6C8B-4231-821F-8250B48AFBFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77A8A78B-6C8B-4231-821F-8250B48AFBFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77A8A78B-6C8B-4231-821F-8250B48AFBFB}.Release|Any CPU.Build.0 = Release|Any CPU
{5EE61AC6-5269-4F0F-B8FA-4334FE4A678F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5EE61AC6-5269-4F0F-B8FA-4334FE4A678F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5EE61AC6-5269-4F0F-B8FA-4334FE4A678F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5EE61AC6-5269-4F0F-B8FA-4334FE4A678F}.Release|Any CPU.Build.0 = Release|Any CPU
{4CBABFAA-1C62-4510-AC63-A51EE5FD50FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4CBABFAA-1C62-4510-AC63-A51EE5FD50FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CBABFAA-1C62-4510-AC63-A51EE5FD50FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CBABFAA-1C62-4510-AC63-A51EE5FD50FF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
</Weavers>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="PropertyChanged" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="InjectOnPropertyNameChanged" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EventInvokerNames" type="xs:string">
<xs:annotation>
<xs:documentation>Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEquality" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEqualityUsingBaseEquals" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseStaticEqualsFromBase" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the static Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
\ No newline at end of file
<Window x:Class="DB.Browser.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DB.Browser"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>
<controls:MetroWindow x:Class="DB.Browser.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
Title="枫莱尔数据库浏览" WindowState="Maximized" >
<controls:MetroWindow.WindowButtonCommands>
<controls:WindowButtonCommands Template="{StaticResource MahApps.Metro.Templates.WindowButtonCommands.Win10}" />
</controls:MetroWindow.WindowButtonCommands>
<controls:MetroWindow.IconTemplate>
<DataTemplate>
<iconPacks:PackIconMaterial Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Margin="2"
Padding="4"
Foreground="{StaticResource IdealForegroundColorBrush}"
Kind="Database" />
</DataTemplate>
</controls:MetroWindow.IconTemplate>
<Frame NavigationUIVisibility="Hidden" x:Name="frame"/>
</controls:MetroWindow>
using System;
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
......@@ -18,11 +19,13 @@ namespace DB.Browser
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
public partial class MainWindow :MetroWindow
{
public MainWindow()
{
InitializeComponent();
App.MetroWindow = this;
this.frame.Content = new PgMain();
}
}
}
<Page x:Class="DB.Browser.PgMain"
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:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:local="DB.Browser"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="Page_Main">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="30" HorizontalAlignment="Center">
<StackPanel.Resources>
<Style x:Key="AccentCircleButtonStyle2"
BasedOn="{StaticResource AccentCircleButtonStyle}"
TargetType="{x:Type ButtonBase}">
<Setter Property="Width" Value="96"/>
<Setter Property="Height" Value="96"/>
</Style>
<Style x:Key="AccentCircleIconPackStyle2"
BasedOn="{StaticResource AccentCircleIconPackStyle}"
TargetType="{x:Type iconPacks:PackIconBase}">
<Setter Property="Width" Value="40"/>
<Setter Property="Height" Value="40"/>
</Style>
</StackPanel.Resources>
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" Margin="0,-20,-100,0">
<TextBlock Text="Step 1" FontSize="20" Foreground="{DynamicResource AccentColorBrush}" />
<TextBlock Text="选择数据" VerticalAlignment="Bottom" Margin="4,0"/>
</StackPanel>
<Button Style="{StaticResource AccentCircleButtonStyle2}" Click="ButtonSelect_Click">
<iconPacks:PackIconMaterial Style="{StaticResource AccentCircleIconPackStyle2}"
Kind="DatabaseImport" />
</Button>
<Grid Margin="0,0,-100,-45">
<StackPanel Orientation="Vertical" Visibility="{Binding IsDBReady, Converter={StaticResource visbilityconv}}">
<TextBlock FontSize="15">
<Run Text="{Binding Profile.PName}"/><Run Text="-"/><Run Text="{Binding Profile.Batch}"/><Run Text="-"/><Run Text="{Binding Profile.Number}"/>
</TextBlock>
<TextBlock Text="{Binding Profile.StartTime,StringFormat={}{0:MM-dd HH:mm}}"/>
<TextBlock Text="{Binding Profile.EndTime,StringFormat={}{0:MM-dd HH:mm}}"/>
</StackPanel>
</Grid>
</StackPanel>
<Line X2="96" VerticalAlignment="Center" Stroke="{DynamicResource GrayBrush7}" StrokeThickness="3" Margin="40,0"/>
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" Margin="0,-20,-100,0">
<TextBlock Text="Step 2" FontSize="20" Foreground="{DynamicResource AccentColorBrush}" />
<TextBlock Text="查看图表" VerticalAlignment="Bottom" Margin="4,0"/>
</StackPanel>
<Button Style="{StaticResource AccentCircleButtonStyle2}" Click="ButtonChart_Click" IsEnabled="{Binding IsDBReady}">
<iconPacks:PackIconMaterial Style="{StaticResource AccentCircleIconPackStyle2}"
Kind="ChartAreaspline" />
</Button>
</StackPanel>
<Line X2="96" VerticalAlignment="Center" Stroke="{DynamicResource GrayBrush7}" StrokeThickness="3" Margin="40,0"/>
<StackPanel Orientation="Vertical" VerticalAlignment="Center" >
<StackPanel Orientation="Horizontal" Margin="0,-20,-100,0">
<TextBlock Text="Step 3" FontSize="20" Foreground="{DynamicResource AccentColorBrush}" />
<TextBlock Text="导出excel" VerticalAlignment="Bottom" Margin="4,0"/>
</StackPanel>
<Button Style="{StaticResource AccentCircleButtonStyle2}" Click="ButtonExcel_Click" IsEnabled="{Binding IsDBReady}">
<iconPacks:PackIconModern Style="{StaticResource AccentCircleIconPackStyle2}"
Kind="OfficeExcel" />
</Button>
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="10,30">
<Rectangle Height="1" Fill="{DynamicResource GrayBrush7}" Width="800"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="{StaticResource ControlMargin}">
<StackPanel Orientation="Vertical">
<TextBlock Text="枫莱尔数据库浏览器" FontSize="25" Foreground="{DynamicResource AccentColorBrush}"/>
</StackPanel>
<TextBlock Text="by flyautomation" VerticalAlignment="Bottom" Margin="{StaticResource ControlMargin}"/>
</StackPanel>
</StackPanel>
</Grid>
</Page>
using System;
using System.Collections.Generic;
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 DB.Browser
{
/// <summary>
/// PgMain.xaml 的交互逻辑
/// </summary>
public partial class PgMain : Page
{
public PgMain()
{
InitializeComponent();
//this.DataContext = DBViewerModel.Instance;
}
private void ButtonSelect_Click(object sender, RoutedEventArgs e)
{
//PageSelect p = new PageSelect();
//p.Init();
//this.NavigationService.Navigate(p);
}
private void ButtonChart_Click(object sender, RoutedEventArgs e)
{
//PageChartView p = new PageChartView();
//p.Init();
//this.NavigationService.Navigate(p);
}
private async void ButtonExcel_Click(object sender, RoutedEventArgs e)
{
}
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:behaviours="http://metro.mahapps.com/winfx/xaml/shared"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:converter="clr-namespace:MahApps.Metro.IconPacks.Converter;assembly=MahApps.Metro.IconPacks.Core">
<SolidColorBrush x:Key="TabItemPanelBackgroundBrush" Color="{DynamicResource Gray8}" />
<SolidColorBrush x:Key="TabItemBackgroundIsSelectedBrush" Color="{DynamicResource Gray2}" />
<SolidColorBrush x:Key="TabItemBackgroundIsMouseOverBrush" Color="{DynamicResource Gray5}" />
<SolidColorBrush x:Key="TabItemForegroundIsSelectedBrush" Color="{DynamicResource IdealForegroundColor}" />
<SolidColorBrush x:Key="TabItemSelectorBrush" Color="LawnGreen" />
<SolidColorBrush x:Key="TabControlBackgroundBrush" Color="WhiteSmoke" />
<Style x:Key="CustomTabItemStyle" TargetType="{x:Type TabItem}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="10" />
<Setter Property="MinWidth" Value="100" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid x:Name="PART_Grid"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="True"
Margin="0">
<ContentPresenter x:Name="PART_HeaderContent"
Margin="{TemplateBinding Padding}"
ContentSource="Header"
HorizontalAlignment="Center"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Rectangle x:Name="PART_Selector"
VerticalAlignment="Bottom"
Height="4"
Visibility="Collapsed"
Fill="{StaticResource TabItemSelectorBrush}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Trigger.Setters>
<Setter Property="Background" Value="{StaticResource TabItemBackgroundIsSelectedBrush}" />
<Setter Property="Foreground" Value="{StaticResource TabItemForegroundIsSelectedBrush}" />
<Setter TargetName="PART_Selector" Property="Visibility" Value="Visible" />
</Trigger.Setters>
</Trigger>
<Trigger SourceName="PART_Grid" Property="IsMouseOver" Value="True">
<Trigger.Setters>
<Setter Property="Background" Value="{StaticResource TabItemBackgroundIsMouseOverBrush}" />
<Setter Property="Cursor" Value="Hand" />
</Trigger.Setters>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="CustomTabControlStyle" TargetType="{x:Type TabControl}">
<Setter Property="Background" Value="{StaticResource TabControlBackgroundBrush}" />
<Setter Property="TabStripPlacement" Value="Top" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="ItemContainerStyle" Value="{StaticResource CustomTabItemStyle}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<DockPanel LastChildFill="True">
<Grid x:Name="HeaderGrid"
DockPanel.Dock="Left"
Background="{StaticResource TabItemPanelBackgroundBrush}">
<TabPanel x:Name="HeaderPanel"
HorizontalAlignment="Center"
Panel.ZIndex="1"
IsItemsHost="True"
KeyboardNavigation.TabIndex="1" />
</Grid>
<Border x:Name="ContentPanel"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
KeyboardNavigation.DirectionalNavigation="Contained"
KeyboardNavigation.TabIndex="2"
KeyboardNavigation.TabNavigation="Local"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
<controls:TransitioningContentControl UseLayoutRounding="True"
behaviours:ReloadBehavior.OnSelectedTabChanged="True"
RestartTransitionOnContentChange="True"
Transition="{TemplateBinding controls:TabControlHelper.Transition}">
<ContentPresenter x:Name="PART_SelectedContentHost"
UseLayoutRounding="False"
Margin="{TemplateBinding Padding}"
ContentSource="SelectedContent"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</controls:TransitioningContentControl>
</Border>
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="TabStripPlacement" Value="Top">
<Setter TargetName="HeaderGrid" Property="DockPanel.Dock" Value="Top" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace DB.Browser.Themes
{
public static class Styles
{
public static Brush GetForeground(int index)
{
IEnumerable<SolidColorBrush> randomColors = App.Current.FindResource("RandomColors") as IEnumerable<SolidColorBrush>;
return randomColors.ElementAt(index % randomColors.Count());
}
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
>
<Style TargetType="Button" x:Key="ButtonStyle_empty">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border
Background="{TemplateBinding Background}"
Height="{TemplateBinding Height}"
Width="{TemplateBinding Width}"
>
<ContentPresenter RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsKeyboardFocused" Value="true">
</Trigger>
<Trigger Property="IsEnabled" Value="false">
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Opacity" Value="0.5"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style TargetType="Grid" x:Key="GridStyle_shadow">
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="15" Direction="-90" RenderingBias="Quality" Opacity=".2" ShadowDepth="1"/>
</Setter.Value>
</Setter>
</Style>
<x:Array x:Key="RandomColors" Type="SolidColorBrush">
<SolidColorBrush>#2195f2</SolidColorBrush>
<SolidColorBrush>#f34336</SolidColorBrush>
<SolidColorBrush>#fec007</SolidColorBrush>
<SolidColorBrush>#607d8a</SolidColorBrush>
<SolidColorBrush>#e81e63</SolidColorBrush>
<SolidColorBrush>#4cae50</SolidColorBrush>
<SolidColorBrush>#3f51b4</SolidColorBrush>
<SolidColorBrush>#ccdb39</SolidColorBrush>
</x:Array>
<SolidColorBrush x:Key="AreaColors0">Red</SolidColorBrush>
<SolidColorBrush x:Key="AreaColors1">Orange</SolidColorBrush>
<SolidColorBrush x:Key="AreaColors2">Green</SolidColorBrush>
<SolidColorBrush x:Key="AreaColors3">Blue</SolidColorBrush>
<SolidColorBrush x:Key="AreaColors4">Purple</SolidColorBrush>
<Style x:Key="AccentCircleButtonStyle"
BasedOn="{StaticResource MahApps.Metro.Styles.MetroCircleButtonStyle}"
TargetType="{x:Type ButtonBase}">
<Setter Property="Width" Value="48"/>
<Setter Property="Height" Value="48"/>
<Setter Property="Margin" Value="4"/>
<Setter Property="Foreground" Value="{DynamicResource AccentColorBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource AccentColorBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource GrayBrush7}" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="AccentCircleIconPackStyle"
TargetType="{x:Type iconPacks:PackIconBase}">
<Setter Property="Width" Value="20"/>
<Setter Property="Height" Value="20"/>
</Style>
<Thickness x:Key="ControlMargin">5</Thickness>
</ResourceDictionary>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment