This commit is contained in:
Vitaliy
2017-01-09 13:25:52 +03:00
parent a9f4f0f297
commit 6ead62af6e
98 changed files with 12058 additions and 72 deletions

View File

@@ -0,0 +1,115 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Interactivity;
using System.Windows.Threading;
namespace BrightSharp.Behaviors
{
public class FilterDefaultViewTextBoxBehavior : Behavior<TextBox>
{
DispatcherTimer timer = new DispatcherTimer();
public FilterDefaultViewTextBoxBehavior()
{
timer.Tick += Timer_Tick;
FilterDelay = TimeSpan.FromSeconds(1);
IgnoreCase = null;
}
private void Timer_Tick(object sender, EventArgs e)
{
timer.Stop();
if (ItemsSource != null)
{
var view = CollectionViewSource.GetDefaultView(ItemsSource);
if (view is ListCollectionView)
{
var listCollectionView = (ListCollectionView)view;
if (listCollectionView.IsAddingNew || listCollectionView.IsEditingItem) return;
}
view.Filter = CustomFilter ?? GetDefaultFilter(ItemsSource.GetType().GetGenericArguments()[0]);
}
}
public bool HasFilterText
{
get { return (bool)GetValue(HasFilterTextProperty); }
set { SetValue(HasFilterTextProperty, value); }
}
public static readonly DependencyProperty HasFilterTextProperty =
DependencyProperty.Register("HasFilterText", typeof(bool), typeof(FilterDefaultViewTextBoxBehavior), new PropertyMetadata(false));
public IEnumerable ItemsSource
{
get { return (IEnumerable)GetValue(ItemsSourceProperty); }
set { SetValue(ItemsSourceProperty, value); }
}
// Using a DependencyProperty as the backing store for ItemsSource. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.Register("ItemsSource", typeof(IEnumerable), typeof(FilterDefaultViewTextBoxBehavior), new PropertyMetadata(null));
public bool? IgnoreCase { get; set; }
private Predicate<object> GetDefaultFilter(Type filterItemType)
{
Func<object, string> dataFunc;
var pInfo = filterItemType.GetProperty("FilterString");
if (pInfo == null)
{
dataFunc = (x) => string.Join(",", filterItemType.GetProperties().Where(p => !p.Name.EndsWith("Id")).Select(p => (p.GetValue(x, null) ?? string.Empty).ToString()));
}
else
{
dataFunc = (x) => (pInfo.GetValue(x, null) ?? string.Empty).ToString();
}
var filterText = AssociatedObject.Text;
var ic = IgnoreCase ?? !filterText.Any(char.IsUpper);
return x =>
{
if (x == null || string.IsNullOrEmpty(filterText)) return true;
var propValStr = dataFunc(x);
foreach (var item in filterText.Split(';'))
{
if (propValStr.IndexOf(item, ic ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) == -1)
return false;
}
return true;
};
}
public Predicate<object> CustomFilter { get; set; }
public TimeSpan FilterDelay { get { return timer.Interval; } set { timer.Interval = value; } }
protected override void OnAttached()
{
base.OnAttached();
HasFilterText = !string.IsNullOrEmpty(AssociatedObject.Text);
AssociatedObject.TextChanged += AssociatedObject_TextChanged;
}
private void AssociatedObject_TextChanged(object sender, TextChangedEventArgs e)
{
timer.Stop(); timer.Start();
HasFilterText = !string.IsNullOrEmpty(AssociatedObject.Text);
}
protected override void OnDetaching()
{
AssociatedObject.TextChanged -= AssociatedObject_TextChanged;
timer.Tick -= Timer_Tick;
base.OnDetaching();
}
}
}

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{acc3c556-f8e4-4f2a-a23d-8e8749679a1b}</ProjectGuid>
<ProjectGuid>{ACC3C556-F8E4-4F2A-A23D-8E8749679A1B}</ProjectGuid>
<OutputType>library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BrightSharp</RootNamespace>
@@ -14,7 +14,6 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
@@ -32,76 +31,110 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http"/>
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Page Include="UserControl1.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="UserControl1.xaml.cs">
<DependentUpon>UserControl1.xaml</DependentUpon>
<Compile Include="Behaviors\FiterGridTextBoxBehavior.cs" />
<Compile Include="Commands\AsyncCommand.cs" />
<Compile Include="Commands\RelayCommand.cs" />
<Compile Include="Diagrams\Adorners\ResizeRotateAdorner.cs" />
<Compile Include="Diagrams\Adorners\ResizeRotateChrome.cs" />
<Compile Include="Diagrams\Adorners\SizeAdorner.cs" />
<Compile Include="Diagrams\Adorners\SizeChrome.cs" />
<Compile Include="Diagrams\DesignerItemDecorator.cs" />
<Compile Include="Diagrams\SelectionBehavior.cs" />
<Compile Include="Diagrams\Thumbs\MoveThumb.cs" />
<Compile Include="Diagrams\Thumbs\ResizeThumb.cs" />
<Compile Include="Diagrams\Thumbs\RotateThumb.cs" />
<Compile Include="Extensions\WpfExtensions.cs" />
<Compile Include="Mvvm\ViewModelBase.cs" />
<Compile Include="ThemeManager.cs" />
<Compile Include="ZoomControl.cs">
<SubType>Code</SubType>
</Compile>
<Page Include="Generic.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Compile Include="Converters\ThicknessConverter.cs" />
<Compile Include="Extensions\MarkupExtensionProperties.cs" />
<Compile Include="Generic.cs" />
<Page Include="Diagrams\Resources\DesignerItem.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Diagrams\Resources\ResizeRotateChrome.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Diagrams\Resources\SizeChrome.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style.Blue.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style.DarkBlue.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style.Silver.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style.DevLab.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Resource Include="icons\app.png" />
<Resource Include="icons\copy.png" />
<Resource Include="icons\cut.png" />
<Resource Include="icons\paste.png" />
<Resource Include="icons\undo.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
@@ -110,5 +143,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@@ -0,0 +1,70 @@
using System;
using System.Threading.Tasks;
using System.Windows.Input;
namespace BrightSharp.Commands
{
public class AsyncCommand : ICommand
{
private readonly Func<object, Task> _execute;
private readonly Func<object, bool> _canExecute;
private Action _onComplete;
private Action<Exception> _onFail;
private bool _isExecuting;
public AsyncCommand(Func<object, Task> execute) : this(execute, o => true)
{
}
public AsyncCommand(Func<object, Task> execute, Func<object, bool> canExecute)
{
_execute = execute;
_canExecute = canExecute;
}
public AsyncCommand OnComplete(Action onComplete)
{
_onComplete = onComplete;
return this;
}
public AsyncCommand OnFail(Action<Exception> onFail)
{
_onFail = onFail;
return this;
}
public bool CanExecute(object parameter)
{
return !_isExecuting && _canExecute(parameter);
}
public event EventHandler CanExecuteChanged;
public async void Execute(object parameter)
{
_isExecuting = true;
OnCanExecuteChanged();
try
{
await _execute(parameter);
_onComplete?.Invoke();
}
catch (Exception ex)
{
while (ex.InnerException != null)
ex = ex.InnerException;
_onFail?.Invoke(ex);
}
finally
{
_isExecuting = false;
OnCanExecuteChanged();
}
}
protected virtual void OnCanExecuteChanged()
{
CanExecuteChanged?.Invoke(this, new EventArgs());
}
}
}

View File

@@ -0,0 +1,66 @@
using System;
using System.Windows.Input;
namespace BrightSharp.Commands
{
public class RelayCommand : ICommand
{
private readonly Action _methodToExecute;
private readonly Action<object> _methodToExecuteWithParam;
private readonly Func<object, bool> _canExecuteEvaluator;
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public RelayCommand(Action<object> methodToExecute, Func<object, bool> canExecuteEvaluator = null)
{
_methodToExecuteWithParam = methodToExecute;
_canExecuteEvaluator = canExecuteEvaluator;
}
public bool CanExecute(object parameter)
{
if (_canExecuteEvaluator == null)
return true;
else
return _canExecuteEvaluator.Invoke(parameter);
}
public void Execute(object parameter)
{
_methodToExecuteWithParam?.Invoke(parameter);
_methodToExecute?.Invoke();
}
}
public class RelayCommand<T> : ICommand
{
private readonly Action<T> _methodToExecuteWithParam;
private readonly Func<T, bool> _canExecuteEvaluator;
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public RelayCommand(Action<T> methodToExecute, Func<T, bool> canExecuteEvaluator = null)
{
_methodToExecuteWithParam = methodToExecute;
_canExecuteEvaluator = canExecuteEvaluator;
}
public bool CanExecute(object parameter)
{
if (_canExecuteEvaluator == null)
return true;
return _canExecuteEvaluator.Invoke((T)parameter);
}
public void Execute(object parameter)
{
_methodToExecuteWithParam?.Invoke((T)parameter);
}
}
}

View File

@@ -0,0 +1,40 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace BrightSharp.Converters
{
internal class ThicknessConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if(value is Thickness)
{
var offset = double.Parse(parameter.ToString(), CultureInfo.InvariantCulture.NumberFormat);
var thick = (Thickness)value;
return new Thickness(Math.Max(0, thick.Left + offset),
Math.Max(0, thick.Top + offset),
Math.Max(0, thick.Right + offset),
Math.Max(0, thick.Bottom + offset));
}
else if(value is CornerRadius)
{
var offset = double.Parse(parameter.ToString(), CultureInfo.InvariantCulture.NumberFormat);
var thick = (CornerRadius)value;
return new CornerRadius(Math.Max(0, thick.TopLeft + offset),
Math.Max(0, thick.TopRight + offset),
Math.Max(0, thick.BottomRight + offset),
Math.Max(0, thick.BottomLeft + offset));
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,47 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
namespace Diagrams
{
public class ResizeRotateAdorner : Adorner
{
private VisualCollection visuals;
private ResizeRotateChrome chrome;
protected override int VisualChildrenCount
{
get
{
return this.visuals.Count;
}
}
public ResizeRotateAdorner(ContentControl designerItem)
: base(designerItem)
{
SnapsToDevicePixels = true;
this.chrome = new ResizeRotateChrome();
this.chrome.DataContext = designerItem;
this.visuals = new VisualCollection(this);
this.visuals.Add(this.chrome);
this.Focusable = true;
}
protected override Size ArrangeOverride(Size arrangeBounds)
{
this.chrome.Arrange(new Rect(arrangeBounds));
return arrangeBounds;
}
protected override Visual GetVisualChild(int index)
{
return this.visuals[index];
}
}
}

View File

@@ -0,0 +1,13 @@
using System.Windows;
using System.Windows.Controls;
namespace Diagrams
{
public class ResizeRotateChrome : Control
{
static ResizeRotateChrome()
{
FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(ResizeRotateChrome), new FrameworkPropertyMetadata(typeof(ResizeRotateChrome)));
}
}
}

View File

@@ -0,0 +1,44 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
namespace Diagrams
{
public class SizeAdorner : Adorner
{
private SizeChrome chrome;
private VisualCollection visuals;
private ContentControl designerItem;
protected override int VisualChildrenCount
{
get
{
return this.visuals.Count;
}
}
public SizeAdorner(ContentControl designerItem)
: base(designerItem)
{
this.SnapsToDevicePixels = true;
this.designerItem = designerItem;
this.chrome = new SizeChrome();
this.chrome.DataContext = designerItem;
this.visuals = new VisualCollection(this);
this.visuals.Add(this.chrome);
}
protected override Visual GetVisualChild(int index)
{
return this.visuals[index];
}
protected override Size ArrangeOverride(Size arrangeBounds)
{
this.chrome.Arrange(new Rect(new Point(0.0, 0.0), arrangeBounds));
return arrangeBounds;
}
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace Diagrams
{
public class SizeChrome : Control
{
static SizeChrome()
{
FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(SizeChrome), new FrameworkPropertyMetadata(typeof(SizeChrome)));
}
}
public class DoubleFormatConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double d = (double)value;
if (double.IsNaN(d)) return "(Auto)";
return Math.Round(d);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View File

@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows;
using System.Windows.Media;
using System.Windows.Input;
using System.Windows.Media.Animation;
namespace Diagrams
{
public class DesignerItemDecorator : Control
{
private Adorner adorner;
public bool ShowDecorator
{
get { return (bool)GetValue(ShowDecoratorProperty); }
set { SetValue(ShowDecoratorProperty, value); }
}
public static readonly DependencyProperty ShowDecoratorProperty =
DependencyProperty.Register("ShowDecorator", typeof(bool), typeof(DesignerItemDecorator),
new FrameworkPropertyMetadata(false, new PropertyChangedCallback(ShowDecoratorProperty_Changed)));
public DesignerItemDecorator()
{
Unloaded += new RoutedEventHandler(this.DesignerItemDecorator_Unloaded);
}
private void HideAdorner()
{
if (this.adorner != null)
{
this.adorner.Visibility = Visibility.Hidden;
}
}
private void ShowAdorner()
{
if (this.adorner == null)
{
AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this);
if (adornerLayer != null)
{
ContentControl designerItem = this.DataContext as ContentControl;
Canvas canvas = VisualTreeHelper.GetParent(designerItem) as Canvas;
this.adorner = new ResizeRotateAdorner(designerItem);
adornerLayer.Add(this.adorner);
if (this.ShowDecorator)
{
this.adorner.Visibility = Visibility.Visible;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(.2));
this.adorner.BeginAnimation(OpacityProperty, anim);
}
else
{
this.adorner.Visibility = Visibility.Hidden;
}
}
}
else
{
this.adorner.Visibility = Visibility.Visible;
var anim = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(.2));
this.adorner.BeginAnimation(OpacityProperty, anim);
}
}
private void DesignerItemDecorator_Unloaded(object sender, RoutedEventArgs e)
{
if (this.adorner != null)
{
AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this);
if (adornerLayer != null)
{
adornerLayer.Remove(this.adorner);
}
this.adorner = null;
}
}
private static void ShowDecoratorProperty_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
DesignerItemDecorator decorator = (DesignerItemDecorator)d;
bool showDecorator = (bool)e.NewValue;
if (showDecorator)
{
decorator.ShowAdorner();
}
else
{
decorator.HideAdorner();
}
}
}
}

View File

@@ -0,0 +1,43 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:Diagrams">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="SizeChrome.xaml"/>
<ResourceDictionary Source="ResizeRotateChrome.xaml"/>
</ResourceDictionary.MergedDictionaries>
<ControlTemplate x:Key="MoveThumbTemplate" TargetType="{x:Type s:MoveThumb}">
<Rectangle Fill="Transparent"/>
</ControlTemplate>
<Style x:Key="DesignerItemStyle" TargetType="ContentControl">
<Setter Property="MinHeight" Value="26"/>
<Setter Property="MinWidth" Value="30"/>
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="Focusable" Value="False" />
<Setter Property="MaxHeight" Value="900" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ContentControl">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
<s:MoveThumb Focusable="False" Cursor="SizeAll" Template="{StaticResource MoveThumbTemplate}" />
<ContentPresenter Content="{TemplateBinding ContentControl.Content}"
Margin="{TemplateBinding Padding}"/>
<s:DesignerItemDecorator x:Name="ItemDecorator" Focusable="False"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Selector.IsSelected" Value="True">
<Setter TargetName="ItemDecorator" Property="ShowDecorator" Value="True" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,112 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:Diagrams">
<Style TargetType="{x:Type Shape}" x:Key="ThumbCorner">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Stroke" Value="#FF0166AC" />
<Setter Property="StrokeThickness" Value="1" />
<Setter Property="Width" Value="7" />
<Setter Property="Height" Value="7" />
<Setter Property="Margin" Value="-2" />
<Setter Property="Fill">
<Setter.Value>
<RadialGradientBrush Center="0.2, 0.2" GradientOrigin="0.2, 0.2" RadiusX="0.8" RadiusY="0.8">
<GradientStop Color="White" Offset="0.0" />
<GradientStop Color="#FF9AFF9F" Offset="0.8" />
</RadialGradientBrush>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type s:ResizeRotateChrome}">
<Setter Property="Focusable" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type s:ResizeRotateChrome}">
<Grid>
<Grid Opacity="0" Margin="-3">
<s:MoveThumb Margin="0,-20,0,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Height="16"
Width="16"
Cursor="SizeAll"
Template="{DynamicResource MoveThumbTemplate}" />
<s:RotateThumb Width="20"
Height="20"
Margin="0,-20,0,0"
Cursor="Hand"
VerticalAlignment="Top"
HorizontalAlignment="Center"/>
<s:ResizeThumb Height="3"
Cursor="SizeNS"
VerticalAlignment="Top"
HorizontalAlignment="Stretch"/>
<s:ResizeThumb Width="3"
Cursor="SizeWE"
VerticalAlignment="Stretch"
HorizontalAlignment="Left"/>
<s:ResizeThumb Width="3"
Cursor="SizeWE"
VerticalAlignment="Stretch"
HorizontalAlignment="Right"/>
<s:ResizeThumb Height="3"
Cursor="SizeNS"
VerticalAlignment="Bottom"
HorizontalAlignment="Stretch"/>
<s:ResizeThumb Width="7"
Height="7"
Margin="-2"
Cursor="SizeNWSE"
VerticalAlignment="Top"
HorizontalAlignment="Left"/>
<s:ResizeThumb Width="7"
Height="7"
Margin="-2"
Cursor="SizeNESW"
VerticalAlignment="Top"
HorizontalAlignment="Right"/>
<s:ResizeThumb Width="7"
Height="7"
Margin="-2"
Cursor="SizeNESW"
VerticalAlignment="Bottom"
HorizontalAlignment="Left"/>
<s:ResizeThumb Width="7"
Height="7"
Margin="-2"
Cursor="SizeNWSE"
VerticalAlignment="Bottom"
HorizontalAlignment="Right"/>
</Grid>
<Canvas HorizontalAlignment="Right" VerticalAlignment="Top">
<ContentControl Canvas.Left="10" Content="{Binding Tag}" />
</Canvas>
<Grid IsHitTestVisible="False" Opacity="1" Margin="-3">
<Rectangle SnapsToDevicePixels="True"
StrokeThickness="1"
Margin="1"
Stroke="{DynamicResource DisabledBorderBrush}" StrokeDashArray="1 0 1"/>
<Line StrokeThickness="1" X1="0" Y1="0" X2="0" Y2="20"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Margin="0,-19,0,0"
Stroke="White" StrokeDashArray="1 2"/>
<Path Style="{StaticResource ThumbCorner}" Stretch="Uniform" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,-20,0,0" Width="20" Height="20" Data="M 11.7927,9.92031C 12.5184,8.74318 12.6759,7.05297 12.1717,5.75967C 11.5909,4.44354 10.2501,3.37314 8.87896,3.04485C 7.39649,2.74559 5.63977,3.1934 4.48733,4.196C 3.50995,5.1756 2.91946,6.75691 3.08599,8.14841L 0.0842173,8.57665C 0.0347556,8.20576 0.00766225,7.8312 -1.64198e-005,7.45693C 0.038148,6.21681 0.383575,4.9557 0.968669,3.8699C 1.5589,2.89611 2.36362,2.03356 3.28126,1.37902C 5.28605,0.0810452 8.05891,-0.284222 10.3301,0.412526C 12.1794,1.09169 13.9099,2.53647 14.8289,4.31779C 15.3434,5.43808 15.5957,6.72245 15.5449,7.95982C 15.4307,9.19718 15.0066,10.4344 14.358,11.484L 16.0043,12.4819L 11.226,13.5191L 10.1463,8.92239L 11.7927,9.92031 Z M -1.64198e-005,-1.90735e-006 Z M 15.564,14.9728 Z "
Fill="YellowGreen" Stroke="{DynamicResource PressedBorderBrush}" />
<Rectangle Style="{StaticResource ThumbCorner}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Rectangle Style="{StaticResource ThumbCorner}" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<Rectangle Style="{StaticResource ThumbCorner}" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
<Rectangle Style="{StaticResource ThumbCorner}" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
<Viewbox Width="16" Height="16" HorizontalAlignment="Right" VerticalAlignment="Top" IsHitTestVisible="False" Margin="0,-20,0,0">
<Path Width="16" Height="16" Stretch="Fill" Fill="{DynamicResource NormalBrush}" StrokeThickness=".5" Stroke="{DynamicResource GlyphBrush}" Data="M 0,8.L 3.18485,4.81417L 3.18485,6.37077L 6.37181,6.37077L 6.37181,3.18408L 4.81418,3.18408L 8.00114,0L 11.1881,3.18408L 9.63047,3.18408L 9.63047,6.37077L 12.8174,6.37077L 12.8174,4.81417L 16.0044,8.L 12.8174,11.1876L 12.8174,9.63096L 9.63047,9.63096L 9.63047,12.8177L 11.1881,12.8177L 8.00114,16.0044L 4.81418,12.8177L 6.37181,12.8177L 6.37181,9.63096L 3.18485,9.63096L 3.18485,11.1876L 0,8. Z M 0,0 Z M 16.0044,16.0044 Z"/>
</Viewbox>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,49 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:Diagrams">
<s:DoubleFormatConverter x:Key="doubleFormatConverter"/>
<Style TargetType="{x:Type s:SizeChrome}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type s:SizeChrome}">
<Grid SnapsToDevicePixels="True">
<Path Stroke="Red"
StrokeThickness="1"
Height="10"
VerticalAlignment="Bottom"
Margin="-2,0,-2,-15"
Stretch="Fill"
Data="M0,0 0,10 M 0,5 100,5 M 100,0 100,10" StrokeDashArray="1 2"/>
<TextBlock Text="{Binding Path=Width, Converter={StaticResource doubleFormatConverter}}"
Background="White"
Padding="3,0,3,0"
Foreground="#FF9C3535"
Margin="0,0,0,-18"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"/>
<Path Stroke="#FF9C3535"
StrokeThickness="1"
Width="10"
HorizontalAlignment="Right"
Margin="0,-2,-15,-2"
Stretch="Fill"
Data="M5,0 5,100 M 0,0 10,0 M 0,100 10,100" StrokeDashArray="1 2"/>
<TextBlock Text="{Binding Path=Height, Converter={StaticResource doubleFormatConverter}}"
Background="White"
Foreground="#FF9C3535"
Padding="3,0,3,0"
Margin="0,0,-18,0"
HorizontalAlignment="Right"
VerticalAlignment="Center">
<TextBlock.LayoutTransform>
<RotateTransform Angle="90" CenterX="1" CenterY="0.5"/>
</TextBlock.LayoutTransform>
</TextBlock>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,91 @@
using BrightSharp.Extensions;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System;
namespace BrightSharp.Diagrams
{
public static class SelectionBehavior
{
public static void Attach(FrameworkElement fe)
{
ContentControl selectedControl = null;
Style designerStyle = (Style)Application.Current.FindResource("DesignerItemStyle");
if (fe is Panel)
{
var fePanel = (Panel)fe;
fe.PreviewMouseLeftButtonDown += (s, e) =>
{
if (e.Source is DependencyObject)
{
var clickedElement = ((DependencyObject)e.OriginalSource).Ancestors<ContentControl>().FirstOrDefault(el => el.Style == designerStyle && WpfExtensions.GetItemsPanel(el.GetParent(true)) == fe);
if (clickedElement == null)
{
foreach (DependencyObject item in fePanel.Children)
{
Selector.SetIsSelected(item, false);
}
selectedControl = null;
return;
}
foreach (var control in fePanel.Children.OfType<ContentControl>())
{
if (ProcessControl(control, clickedElement, ref selectedControl))
{
e.Handled = selectedControl.Content is ButtonBase;
return;
}
}
}
};
}
else if (fe is ItemsControl)
{
var feItemsControl = (ItemsControl)fe;
fe.PreviewMouseLeftButtonDown += (s, e) =>
{
if (e.Source is DependencyObject)
{
var clickedElement = ((DependencyObject)e.Source).Ancestors<ContentControl>().FirstOrDefault(el => el.Style == designerStyle && el.Parent == fe);
if (clickedElement == null)
{
foreach (DependencyObject item in feItemsControl.Items)
{
Selector.SetIsSelected(item, false);
}
selectedControl = null;
return;
}
foreach (var control in feItemsControl.Items.OfType<ContentControl>())
{
if (ProcessControl(control, clickedElement, ref selectedControl))
{
e.Handled = selectedControl.Content is ButtonBase;
return;
}
}
}
};
}
}
private static bool ProcessControl(ContentControl control, ContentControl clickedElement, ref ContentControl selectedControl)
{
if (control == clickedElement && control != selectedControl)
{
if (selectedControl != null)
{
Selector.SetIsSelected(selectedControl, false);
}
Selector.SetIsSelected(control, true);
selectedControl = control;
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,49 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
namespace Diagrams
{
public class MoveThumb : Thumb
{
private RotateTransform rotateTransform;
private ContentControl designerItem;
public MoveThumb()
{
DragStarted += new DragStartedEventHandler(this.MoveThumb_DragStarted);
DragDelta += new DragDeltaEventHandler(this.MoveThumb_DragDelta);
}
private void MoveThumb_DragStarted(object sender, DragStartedEventArgs e)
{
this.designerItem = DataContext as ContentControl;
if (this.designerItem != null)
{
this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
}
}
private void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
if (this.designerItem != null)
{
Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange);
if (this.rotateTransform != null)
{
dragDelta = this.rotateTransform.Transform(dragDelta);
}
if (double.IsNaN(Canvas.GetLeft(this.designerItem))) Canvas.SetLeft(this.designerItem, 0);
if (double.IsNaN(Canvas.GetTop(this.designerItem))) Canvas.SetTop(this.designerItem, 0);
Canvas.SetLeft(this.designerItem, Canvas.GetLeft(this.designerItem) + dragDelta.X);
Canvas.SetTop(this.designerItem, Canvas.GetTop(this.designerItem) + dragDelta.Y);
}
}
}
}

View File

@@ -0,0 +1,139 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Media;
using System.Collections.Generic;
using System.Windows.Input;
namespace Diagrams
{
public class ResizeThumb : Thumb
{
private RotateTransform rotateTransform;
private double angle;
private Adorner adorner;
private Point transformOrigin;
private ContentControl designerItem;
private Canvas canvas;
public ResizeThumb()
{
DragStarted += new DragStartedEventHandler(this.ResizeThumb_DragStarted);
DragDelta += new DragDeltaEventHandler(this.ResizeThumb_DragDelta);
DragCompleted += new DragCompletedEventHandler(this.ResizeThumb_DragCompleted);
MouseRightButtonDown += new MouseButtonEventHandler(this.ResizeThumb_MouseRightButtonDown);
}
private void ResizeThumb_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
this.designerItem = this.designerItem ?? this.DataContext as ContentControl;
if (VerticalAlignment == VerticalAlignment.Top || VerticalAlignment == VerticalAlignment.Bottom)
{
this.designerItem.Height = double.NaN;
}
if (HorizontalAlignment == HorizontalAlignment.Left || HorizontalAlignment == HorizontalAlignment.Right)
{
this.designerItem.Width = double.NaN;
}
}
private void ResizeThumb_DragStarted(object sender, DragStartedEventArgs e)
{
this.designerItem = this.DataContext as ContentControl;
if (this.designerItem != null)
{
this.canvas = VisualTreeHelper.GetParent(this.designerItem) as Canvas;
if (this.canvas != null)
{
this.transformOrigin = this.designerItem.RenderTransformOrigin;
this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
if (this.rotateTransform != null)
{
this.angle = this.rotateTransform.Angle * Math.PI / 180.0;
}
else
{
this.angle = 0.0d;
}
AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.canvas);
if (adornerLayer != null)
{
this.adorner = new SizeAdorner(this.designerItem);
adornerLayer.Add(this.adorner);
}
}
}
}
private void ResizeThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
if (this.designerItem != null)
{
double deltaVertical, deltaHorizontal;
if (double.IsNaN(Canvas.GetTop(this.designerItem))) Canvas.SetTop(this.designerItem, 0);
if (double.IsNaN(Canvas.GetLeft(this.designerItem))) Canvas.SetLeft(this.designerItem, 0);
if ((VerticalAlignment == VerticalAlignment.Top || VerticalAlignment == VerticalAlignment.Bottom) && double.IsNaN(this.designerItem.Height)) this.designerItem.Height = this.designerItem.ActualHeight;
if ((HorizontalAlignment == HorizontalAlignment.Left || HorizontalAlignment == HorizontalAlignment.Right) && double.IsNaN(this.designerItem.Width)) this.designerItem.Width = this.designerItem.ActualWidth;
switch (VerticalAlignment)
{
case System.Windows.VerticalAlignment.Bottom:
deltaVertical = Math.Min(-e.VerticalChange, this.designerItem.ActualHeight - this.designerItem.MinHeight);
Canvas.SetTop(this.designerItem, Canvas.GetTop(this.designerItem) + (this.transformOrigin.Y * deltaVertical * (1 - Math.Cos(-this.angle))));
Canvas.SetLeft(this.designerItem, Canvas.GetLeft(this.designerItem) - deltaVertical * this.transformOrigin.Y * Math.Sin(-this.angle));
this.designerItem.Height -= deltaVertical;
break;
case System.Windows.VerticalAlignment.Top:
deltaVertical = Math.Min(e.VerticalChange, this.designerItem.ActualHeight - this.designerItem.MinHeight);
Canvas.SetTop(this.designerItem, Canvas.GetTop(this.designerItem) + deltaVertical * Math.Cos(-this.angle) + (this.transformOrigin.Y * deltaVertical * (1 - Math.Cos(-this.angle))));
Canvas.SetLeft(this.designerItem, Canvas.GetLeft(this.designerItem) + deltaVertical * Math.Sin(-this.angle) - (this.transformOrigin.Y * deltaVertical * Math.Sin(-this.angle)));
this.designerItem.Height -= deltaVertical;
break;
default:
break;
}
switch (HorizontalAlignment)
{
case System.Windows.HorizontalAlignment.Left:
deltaHorizontal = Math.Min(e.HorizontalChange, this.designerItem.ActualWidth - this.designerItem.MinWidth);
Canvas.SetTop(this.designerItem, Canvas.GetTop(this.designerItem) + deltaHorizontal * Math.Sin(this.angle) - this.transformOrigin.X * deltaHorizontal * Math.Sin(this.angle));
Canvas.SetLeft(this.designerItem, Canvas.GetLeft(this.designerItem) + deltaHorizontal * Math.Cos(this.angle) + (this.transformOrigin.X * deltaHorizontal * (1 - Math.Cos(this.angle))));
this.designerItem.Width -= deltaHorizontal;
break;
case System.Windows.HorizontalAlignment.Right:
deltaHorizontal = Math.Min(-e.HorizontalChange, this.designerItem.ActualWidth - this.designerItem.MinWidth);
Canvas.SetTop(this.designerItem, Canvas.GetTop(this.designerItem) - this.transformOrigin.X * deltaHorizontal * Math.Sin(this.angle));
Canvas.SetLeft(this.designerItem, Canvas.GetLeft(this.designerItem) + (deltaHorizontal * this.transformOrigin.X * (1 - Math.Cos(this.angle))));
this.designerItem.Width -= deltaHorizontal;
break;
default:
break;
}
}
e.Handled = true;
}
private void ResizeThumb_DragCompleted(object sender, DragCompletedEventArgs e)
{
if (this.adorner != null)
{
AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.canvas);
if (adornerLayer != null)
{
adornerLayer.Remove(this.adorner);
}
this.adorner = null;
}
}
}
}

View File

@@ -0,0 +1,86 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
namespace Diagrams
{
public class RotateThumb : Thumb
{
private double initialAngle;
private RotateTransform rotateTransform;
private Vector startVector;
private Point centerPoint;
private ContentControl designerItem;
private Canvas canvas;
public RotateThumb()
{
DragDelta += new DragDeltaEventHandler(this.RotateThumb_DragDelta);
DragStarted += new DragStartedEventHandler(this.RotateThumb_DragStarted);
MouseRightButtonDown += RotateThumb_MouseLeftButtonDown;
}
private void RotateThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.RightButton == MouseButtonState.Pressed)
{
this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
if (this.rotateTransform != null)
{
this.rotateTransform.Angle = 0;
this.designerItem.InvalidateMeasure();
}
}
}
private void RotateThumb_DragStarted(object sender, DragStartedEventArgs e)
{
this.designerItem = DataContext as ContentControl;
if (this.designerItem != null)
{
this.canvas = VisualTreeHelper.GetParent(this.designerItem) as Canvas;
if (this.canvas != null)
{
this.centerPoint = this.designerItem.TranslatePoint(
new Point(this.designerItem.ActualWidth * this.designerItem.RenderTransformOrigin.X,
this.designerItem.ActualHeight * this.designerItem.RenderTransformOrigin.Y),
this.canvas);
Point startPoint = Mouse.GetPosition(this.canvas);
this.startVector = Point.Subtract(startPoint, this.centerPoint);
this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
if (this.rotateTransform == null)
{
this.designerItem.RenderTransform = new RotateTransform(0);
this.initialAngle = 0;
}
else
{
this.initialAngle = this.rotateTransform.Angle;
}
}
}
}
private void RotateThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
if (this.designerItem != null && this.canvas != null)
{
Point currentPoint = Mouse.GetPosition(this.canvas);
Vector deltaVector = Point.Subtract(currentPoint, this.centerPoint);
double angle = Vector.AngleBetween(this.startVector, deltaVector);
RotateTransform rotateTransform = this.designerItem.RenderTransform as RotateTransform;
rotateTransform.Angle = this.initialAngle + Math.Round(angle, 0);
this.designerItem.InvalidateMeasure();
}
}
}
}

View File

@@ -0,0 +1,140 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace BrightSharp.Extensions
{
public static class MarkupExtensionProperties
{
public static CornerRadius GetCornerRadius(DependencyObject obj)
{
return (CornerRadius)obj.GetValue(CornerRadiusProperty);
}
public static void SetCornerRadius(DependencyObject obj, CornerRadius value)
{
obj.SetValue(CornerRadiusProperty, value);
}
public static object GetHeader(DependencyObject obj)
{
return obj.GetValue(HeaderProperty);
}
public static void SetHeader(DependencyObject obj, object value)
{
obj.SetValue(HeaderProperty, value);
}
public static object GetLeadingElement(DependencyObject obj)
{
return obj.GetValue(CornerRadiusProperty);
}
public static void SetLeadingElement(DependencyObject obj, object value)
{
obj.SetValue(CornerRadiusProperty, value);
}
public static object GetTrailingElement(DependencyObject obj)
{
return obj.GetValue(CornerRadiusProperty);
}
public static void SetTrailingElement(DependencyObject obj, object value)
{
obj.SetValue(CornerRadiusProperty, value);
}
public static object GetIcon(DependencyObject obj)
{
return obj.GetValue(IconProperty);
}
public static void SetIcon(DependencyObject obj, object value)
{
obj.SetValue(IconProperty, value);
}
public static void SetHeaderHeight(DependencyObject obj, double value)
{
obj.SetValue(HeaderHeightProperty, value);
}
public static double GetHeaderHeight(DependencyObject obj)
{
return (double)obj.GetValue(HeaderHeightProperty);
}
public static void SetHeaderVerticalAlignment(DependencyObject obj, VerticalAlignment value)
{
obj.SetValue(HeaderVerticalAlignmentProperty, value);
}
public static VerticalAlignment GetHeaderVerticalAlignment(DependencyObject obj)
{
return (VerticalAlignment)obj.GetValue(HeaderVerticalAlignmentProperty);
}
public static void SetHeaderHorizontalAlignment(DependencyObject obj, HorizontalAlignment value)
{
obj.SetValue(HeaderHorizontalAlignmentProperty, value);
}
public static HorizontalAlignment GetHeaderHorizontalAlignment(DependencyObject obj)
{
return (HorizontalAlignment)obj.GetValue(HeaderHorizontalAlignmentProperty);
}
public static void SetSpecialHeight(DependencyObject obj, double value)
{
obj.SetValue(SpecialHeightProperty, value);
}
public static double GetSpecialHeight(DependencyObject obj)
{
return (double)obj.GetValue(SpecialHeightProperty);
}
public static void SetSpecialWidth(DependencyObject obj, double value)
{
obj.SetValue(SpecialWidthProperty, value);
}
public static double GetSpecialWidth(DependencyObject obj)
{
return (double)obj.GetValue(SpecialWidthProperty);
}
public static Dock GetDocking(DependencyObject obj)
{
return (Dock)obj.GetValue(DockingProperty);
}
public static void SetDocking(DependencyObject obj, Dock value)
{
obj.SetValue(DockingProperty, value);
}
public static Thickness GetHeaderPadding(DependencyObject obj)
{
return (Thickness)obj.GetValue(HeaderPaddingProperty);
}
public static void SetHeaderPadding(DependencyObject obj, Thickness value)
{
obj.SetValue(HeaderPaddingProperty, value);
}
public static bool GetIsDragHelperVisible(DependencyObject obj)
{
return (bool)obj.GetValue(IsDragHelperVisibleProperty);
}
public static void SetIsDragHelperVisible(DependencyObject obj, bool value)
{
obj.SetValue(IsDragHelperVisibleProperty, value);
}
public static Brush GetSpecialBrush(DependencyObject obj)
{
return (Brush)obj.GetValue(SpecialBrushProperty);
}
public static void SetSpecialBrush(DependencyObject obj, Brush value)
{
obj.SetValue(SpecialBrushProperty, value);
}
public static readonly DependencyProperty SpecialBrushProperty = DependencyProperty.RegisterAttached("SpecialBrush", typeof(Brush), typeof(MarkupExtensionProperties), new PropertyMetadata(null));
public static readonly DependencyProperty IsDragHelperVisibleProperty = DependencyProperty.RegisterAttached("IsDragHelperVisible", typeof(bool), typeof(MarkupExtensionProperties), new FrameworkPropertyMetadata(true));
public static readonly DependencyProperty HeaderPaddingProperty = DependencyProperty.RegisterAttached("HeaderPadding", typeof(Thickness), typeof(MarkupExtensionProperties), new PropertyMetadata(null));
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.RegisterAttached("CornerRadius", typeof(CornerRadius), typeof(MarkupExtensionProperties), new PropertyMetadata(null));
public static readonly DependencyProperty LeadingElementProperty = DependencyProperty.RegisterAttached("LeadingElement", typeof(object), typeof(MarkupExtensionProperties), new PropertyMetadata(null));
public static readonly DependencyProperty TrailingElementProperty = DependencyProperty.RegisterAttached("TrailingElement", typeof(object), typeof(MarkupExtensionProperties), new PropertyMetadata(null));
public static readonly DependencyProperty HeaderProperty = DependencyProperty.RegisterAttached("Header", typeof(object), typeof(MarkupExtensionProperties), new FrameworkPropertyMetadata(null));
public static readonly DependencyProperty DockingProperty = DependencyProperty.RegisterAttached("Docking", typeof(Dock), typeof(MarkupExtensionProperties), new PropertyMetadata(null));
public static readonly DependencyProperty IconProperty = DependencyProperty.RegisterAttached("Icon", typeof(object), typeof(MarkupExtensionProperties), new PropertyMetadata(null));
public static readonly DependencyProperty HeaderHeightProperty = DependencyProperty.RegisterAttached("HeaderHeight", typeof(double), typeof(MarkupExtensionProperties), new PropertyMetadata(null));
public static readonly DependencyProperty HeaderVerticalAlignmentProperty = DependencyProperty.RegisterAttached("HeaderVerticalAlignment", typeof(VerticalAlignment), typeof(MarkupExtensionProperties), new PropertyMetadata(VerticalAlignment.Center));
public static readonly DependencyProperty HeaderHorizontalAlignmentProperty = DependencyProperty.RegisterAttached("HeaderHorizontalAlignment", typeof(HorizontalAlignment), typeof(MarkupExtensionProperties), new PropertyMetadata(HorizontalAlignment.Left));
public static readonly DependencyProperty SpecialHeightProperty = DependencyProperty.RegisterAttached("SpecialHeight", typeof(double), typeof(MarkupExtensionProperties), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
public static readonly DependencyProperty SpecialWidthProperty = DependencyProperty.RegisterAttached("SpecialWidth", typeof(double), typeof(MarkupExtensionProperties), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
}
}

View File

@@ -0,0 +1,72 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Media3D;
namespace BrightSharp.Extensions
{
public static class WpfExtensions
{
public static DependencyObject GetParent(this DependencyObject obj, bool useLogicalTree = false)
{
if (!useLogicalTree && (obj is Visual || obj is Visual3D))
return VisualTreeHelper.GetParent(obj) ?? LogicalTreeHelper.GetParent(obj);
else
return LogicalTreeHelper.GetParent(obj);
}
public static IEnumerable<T> Ancestors<T>(this DependencyObject obj, bool useLogicalTree = false) where T : DependencyObject
{
if (obj == null) yield break;
var x = GetParent(obj, useLogicalTree);
while (x != null && !(x is T))
{
x = GetParent(x, useLogicalTree);
}
if (x != null)
yield return x as T;
else
yield break;
foreach (var item in Ancestors<T>(x, useLogicalTree))
{
yield return item;
}
}
public static T FindAncestor<T>(this DependencyObject obj) where T : DependencyObject
{
return Ancestors<T>(obj).FirstOrDefault();
}
public static Panel GetItemsPanel(DependencyObject itemsControl)
{
if (itemsControl is Panel) return (Panel)itemsControl;
ItemsPresenter itemsPresenter = GetVisualChild<ItemsPresenter>(itemsControl);
var itemsPanel = VisualTreeHelper.GetChild(itemsPresenter, 0) as Panel;
return itemsPanel;
}
public static T GetVisualChild<T>(DependencyObject parent) where T : Visual
{
T child = default(T);
int numVisuals = VisualTreeHelper.GetChildrenCount(parent);
for (int i = 0; i < numVisuals; i++)
{
Visual v = (Visual)VisualTreeHelper.GetChild(parent, i);
child = v as T;
if (child == null)
{
child = GetVisualChild<T>(v);
}
if (child != null)
{
break;
}
}
return child;
}
}
}

26
BrightSharp/Generic.cs Normal file
View File

@@ -0,0 +1,26 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
namespace BrightSharp
{
internal partial class Generic
{
private const string StyleDictionaryPattern = @"(?<=.+style\.)(.*?)(?=\.xaml)";
public void CalendarPreviewMouseUp(object sender, MouseEventArgs e)
{
if (Mouse.Captured is CalendarItem) { Mouse.Capture(null); }
}
public void DatePickerUnloaded(object sender, RoutedEventArgs e)
{
if (sender == null) return;
DependencyObject child = ((Popup)((DatePicker)sender).Template.FindName("PART_Popup", (FrameworkElement)sender))?.Child;
while (child != null && !(child is AdornerDecorator))
child = VisualTreeHelper.GetParent(child) ?? LogicalTreeHelper.GetParent(child);
if (((AdornerDecorator)child)?.Child is Calendar) ((AdornerDecorator)child).Child = null;
}
}
}

5648
BrightSharp/Generic.xaml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Reflection;
using System.Windows;
namespace BrightSharp.Mvvm
{
public class ObservableObject : INotifyPropertyChanged
{
static readonly DependencyObject designTimeObject = new DependencyObject();
public static bool IsInDesignTime
{
get
{
try
{
return DesignerProperties.GetIsInDesignMode(designTimeObject);
}
catch(Exception)
{
return true;
}
}
}
protected PropertyChangedEventHandler PropertyChangedHandler
{
get
{
return PropertyChanged;
}
}
public ObservableObject()
{
}
protected static string GetPropertyName<T>(Expression<Func<T>> propertyExpression)
{
if(propertyExpression == null)
{
throw new ArgumentNullException("propertyExpression");
}
MemberExpression body = propertyExpression.Body as MemberExpression;
if(body == null)
{
throw new ArgumentException("Invalid argument", "propertyExpression");
}
PropertyInfo property = body.Member as PropertyInfo;
if(property == null)
{
throw new ArgumentException("Argument is not a property", "propertyExpression");
}
return property.Name;
}
protected virtual void RaisePropertyChanged<T>(Expression<Func<T>> propertyExpression)
{
PropertyChangedEventHandler handler = PropertyChanged;
if(handler != null)
{
handler(this, new PropertyChangedEventArgs(GetPropertyName(propertyExpression)));
}
}
protected Boolean Set<T>(Expression<Func<T>> propertyExpression, ref T field, T newValue)
{
if(EqualityComparer<T>.Default.Equals(field, newValue))
{
return false;
}
field = newValue;
this.RaisePropertyChanged(propertyExpression);
return true;
}
protected bool Set<T>(string propertyName, ref T field, T newValue)
{
if(EqualityComparer<T>.Default.Equals(field, newValue))
{
return false;
}
field = newValue;
RaisePropertyChanged(propertyName);
return true;
}
protected void RaisePropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if(handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}

View File

@@ -3,6 +3,7 @@ using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Markup;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
@@ -53,3 +54,7 @@ using System.Windows;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: XmlnsPrefix("http://schemas.brightsharp.com/developer", "bs")]
[assembly: XmlnsDefinition("http://schemas.brightsharp.com/developer", "BrightSharp")]
[assembly: XmlnsDefinition("http://schemas.brightsharp.com/developer", "BrightSharp.Extensions")]
[assembly: XmlnsDefinition("http://schemas.brightsharp.com/developer", "BrightSharp.Behaviors")]

286
BrightSharp/Style.Blue.xaml Normal file
View File

@@ -0,0 +1,286 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<sys:Boolean x:Key="IsInverseTheme">False</sys:Boolean>
<CornerRadius x:Key="DefaultRadiusSmall">1</CornerRadius>
<CornerRadius x:Key="DefaultRadiusNormal">3</CornerRadius>
<CornerRadius x:Key="TabItemRadius">0,8,0,0</CornerRadius>
<CornerRadius x:Key="TabRadiusTop">0,2,2,2</CornerRadius>
<CornerRadius x:Key="TabRadiusLeft">0,5,5,0</CornerRadius>
<CornerRadius x:Key="TabRadiusRight">5,0,0,5</CornerRadius>
<CornerRadius x:Key="TabRadiusBottom">5,5,0,0</CornerRadius>
<Color x:Key="ValidationErrorColor">Red</Color>
<LinearGradientBrush x:Key="NormalBrush" StartPoint="0,1" EndPoint="0,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="White" Offset="1.0"/>
<GradientStop Color="#FFC4C8E6" Offset="0.6"/>
<GradientStop Color="#FFC0C4DE" Offset="0.55"/>
<GradientStop Color="#FFC6DAFF" Offset="0.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="VerticalNormalBrush" StartPoint="1,0" EndPoint="0,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="White" Offset="1.0"/>
<GradientStop Color="#FFC4C8E6" Offset="0.6"/>
<GradientStop Color="#FFC0C4DE" Offset="0.55"/>
<GradientStop Color="#FFC6DAFF" Offset="0.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="NormalProgressBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF3CCF37" Offset="0.0"/>
<GradientStop Color="#FF2FA22A" Offset="0.5"/>
<GradientStop Color="#FFA6C5A5" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ProgressBarIndicatorAnimatedFill">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#00ffffff"
Offset="0" />
<GradientStop Color="#c0ffffff"
Offset="0.3" />
<GradientStop Color="#d0ffffff"
Offset="0.8" />
<GradientStop Color="#00ffffff"
Offset="1" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ProgressBarIndeterminateRootBrush" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#F6BCD5FF" Offset="0.046" />
<GradientStop Color="#96D4E4FF" Offset="0.18" />
<GradientStop Color="#4FFFFFFF" Offset="0.512" />
<GradientStop Color="#00D6D6D6" Offset="0.521" />
<GradientStop Color="#BABCD5FF" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="ProgressBarIndeterminateFillBrush" EndPoint="0,1" StartPoint="20,1" MappingMode="Absolute" SpreadMethod="Repeat">
<LinearGradientBrush.Transform>
<TransformGroup>
<SkewTransform AngleX="-10" />
</TransformGroup>
</LinearGradientBrush.Transform>
<GradientStop Color="#FFBCD5FF" Offset="0.088" />
<GradientStop Color="#006EA4FD" Offset="0.475" />
<GradientStop Color="#FFBCD5FF" Offset="0.899" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="NormalBorderBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF605CBB" Offset="0.0"/>
<GradientStop Color="#FF5B4F4F" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="HorizontalNormalBorderBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFACA3D4" Offset="0.0"/>
<GradientStop Color="#FF4F2A2A" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush x:Key="TopLevelMenuBackgroundHover" Color="#FFFCFFBD" />
<!-- Light Brush -->
<LinearGradientBrush x:Key="LightBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="White" Offset="0.0"/>
<GradientStop Color="#FFD9E1F9" Offset="0.5"/>
<GradientStop Color="#FFDDDDFB" Offset="0.85"/>
<GradientStop Color="#FF9B9B9B" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="HorizontalLightBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="White" Offset="0.0"/>
<GradientStop Color="#FFD9E1F9" Offset="0.5"/>
<GradientStop Color="#FFDDDDFB" Offset="0.85"/>
<GradientStop Color="#FF9B9B9B" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Dark Brush -->
<LinearGradientBrush x:Key="DarkBrush" StartPoint="0,1" EndPoint="0,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="White" Offset="1.0"/>
<GradientStop Color="#FFCCD0E8" Offset="0.6"/>
<GradientStop Color="#FFC4CAF1" Offset="0.55"/>
<GradientStop Color="#FFD1E1FF" Offset="0.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="VerticalDarkBrush" StartPoint="1,0" EndPoint="0,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFCDD6F5" Offset="1.0"/>
<GradientStop Color="#FF99A6E6" Offset="0.6"/>
<GradientStop Color="#FFB5B3EC" Offset="0.55"/>
<GradientStop Color="#FFD8E8FD" Offset="0.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Pressed Brush -->
<LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF6FBC5" Offset="0.0"/>
<GradientStop Color="#FFE2D231" Offset="0.2"/>
<GradientStop Color="#FFE5FFB9" Offset="0.9"/>
<GradientStop Color="#FFF" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="TogglePressedBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF6FBC5" Offset="0.0"/>
<GradientStop Color="#FFE2D231" Offset="0.2"/>
<GradientStop Color="#FFE5FFB9" Offset="0.9"/>
<GradientStop Color="#FFF" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="VerticalPressedBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF6FBC5" Offset="0.0"/>
<GradientStop Color="#FFE2D231" Offset="0.2"/>
<GradientStop Color="#FFE5FFB9" Offset="0.9"/>
<GradientStop Color="#FFF" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="PressedBorderBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF870000" Offset="0.0"/>
<GradientStop Color="#FF5D5D5D" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Defaulted Brush -->
<LinearGradientBrush x:Key="DefaultedBorderBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#777" Offset="0.0"/>
<GradientStop Color="#000" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Disabled Brush -->
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#FF303030" />
<SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#FFB7B7B7" />
<SolidColorBrush x:Key="DisabledBorderBrush" Color="#FF7E7070" />
<!-- Border Brushes -->
<SolidColorBrush x:Key="SolidBorderBrush" Color="#FF1D426E" />
<SolidColorBrush x:Key="LightBorderBrush" Color="#FF9E9E9E" />
<!-- Miscellaneous Brushes -->
<LinearGradientBrush x:Key="ScrollBarPageButtonVertBrush" StartPoint="0,0" EndPoint="1,0">
<GradientStopCollection>
<GradientStop Offset="0" Color="#FFD3DBFF" />
<GradientStop Offset="0.3" Color="White" />
<GradientStop Offset="0.7" Color="White" />
<GradientStop Offset="1" Color="#FFD3DBFF" />
</GradientStopCollection>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ScrollBarPageButtonHorizBrush" StartPoint="0,0" EndPoint="0,1">
<GradientStopCollection>
<GradientStop Offset="0" Color="#FFD3DBFF" />
<GradientStop Offset="0.3" Color="White" />
<GradientStop Offset="0.7" Color="White" />
<GradientStop Offset="1" Color="#FFD3DBFF" />
</GradientStopCollection>
</LinearGradientBrush>
<LinearGradientBrush x:Key="TabItemSelectedBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFE0FFC1" Offset="0.0"/>
<GradientStop Color="#FFBCE6B2" Offset="0.2"/>
<GradientStop Color="#FFE3FFD5" Offset="0.85"/>
<GradientStop Color="White" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush x:Key="MainMenuForegroundBrush" Color="Black"/>
<!--Color STYLED Brush-->
<LinearGradientBrush x:Key="WindowBackgroundBrush">
<GradientStopCollection>
<GradientStop Offset="0" Color="#EFEBF8FF" />
<GradientStop Offset="1" Color="#EFF3F3F3" />
</GradientStopCollection>
</LinearGradientBrush>
<Color x:Key="WindowBackgroundHoverColor">#FFF</Color>
<LinearGradientBrush x:Key="SelectedBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#CC9ACBFF" Offset="0" />
<GradientStop Color="#FF7DBAFF" Offset=".3" />
<GradientStop Color="#FF7DBAFF" Offset=".7" />
<GradientStop Color="#CC9ACBFF" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush x:Key="GlyphBrush" Color="#FF2B1717" />
<SolidColorBrush x:Key="LightColorBrush" Color="#E9ECF8" />
<Color x:Key="OnWindowForegroundColor">#FF1B140F</Color>
<Color x:Key="SelectedUnfocusedColor">#FFB6B6B6</Color>
<SolidColorBrush x:Key="ScrollBarBackgroundBrush" Color="#F0F0F0" />
<SolidColorBrush x:Key="SynWindowBackgroundBrush" Color="#FFD1D1D1" />
<Color x:Key="SelectedBackgroundColor">#FFE6D745</Color>
<SolidColorBrush x:Key="OnWindowForegroundBrush" Color="{DynamicResource OnWindowForegroundColor}" />
<SolidColorBrush x:Key="HighLightForegroundBrush" Color="#FF500000" />
<Color x:Key="UiForegroundColor">Black</Color>
<SolidColorBrush x:Key="AlternatingRowBackgroundBrush" Color="White" />
<SolidColorBrush x:Key="UiForegroundBrush" Color="{DynamicResource UiForegroundColor}" />
</ResourceDictionary>

View File

@@ -0,0 +1,277 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<sys:Boolean x:Key="IsInverseTheme">True</sys:Boolean>
<CornerRadius x:Key="DefaultRadiusSmall">1</CornerRadius>
<CornerRadius x:Key="DefaultRadiusNormal">3</CornerRadius>
<CornerRadius x:Key="TabItemRadius">0,8,0,0</CornerRadius>
<CornerRadius x:Key="TabRadiusTop">0,2,2,2</CornerRadius>
<CornerRadius x:Key="TabRadiusLeft">0,5,5,0</CornerRadius>
<CornerRadius x:Key="TabRadiusRight">5,0,0,5</CornerRadius>
<CornerRadius x:Key="TabRadiusBottom">5,5,0,0</CornerRadius>
<Color x:Key="SelectedBackgroundColor" >#99BDFF</Color>
<Color x:Key="SelectedUnfocusedColor" >#999999</Color>
<Color x:Key="ControlLightColor" >#FF2F596E</Color>
<Color x:Key="ControlMediumColor" >#FF10405B</Color>
<Color x:Key="ControlDarkColor" >#FF2B404B</Color>
<Color x:Key="ControlMouseOverColor" >#FFA5A7BA</Color>
<Color x:Key="ControlPressedColor" >#FF47909B</Color>
<Color x:Key="ValidationErrorColor" >#FF3333</Color>
<Color x:Key="UiForegroundColor">#ffffff</Color>
<SolidColorBrush x:Key="UiForegroundBrush" Color="White" />
<Color x:Key="WindowBackgroundHoverColor">#555555</Color>
<SolidColorBrush x:Key="TopLevelMenuBackgroundHover" Color="#FF414566" />
<SolidColorBrush x:Key="DisabledBorderBrush" Color="#FF575757" />
<SolidColorBrush x:Key="SolidBorderBrush" Color="Black" />
<SolidColorBrush x:Key="LightBorderBrush" Color="DarkGray" />
<SolidColorBrush x:Key="MainMenuForegroundBrush" Color="White"/>
<LinearGradientBrush x:Key="WindowBackgroundBrush">
<GradientStop Color="#444444" />
</LinearGradientBrush>
<SolidColorBrush x:Key="GlyphBrush" Color="#ffffff" />
<SolidColorBrush x:Key="LightColorBrush" Color="#FF57575F" />
<Color x:Key="OnWindowForegroundColor">White</Color>
<SolidColorBrush x:Key="OnWindowForegroundBrush" Color="{DynamicResource OnWindowForegroundColor}" />
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#bbb" />
<SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#FF303030" />
<SolidColorBrush x:Key="ScrollBarBackgroundBrush" Color="#FF404040" />
<SolidColorBrush x:Key="HighLightForegroundBrush" Color="Black" />
<SolidColorBrush x:Key="AlternatingRowBackgroundBrush" Color="#555555" />
<LinearGradientBrush x:Key="NormalBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF08547D" Offset="0.02"/>
<GradientStop Color="#FF2A546A" Offset="0.25"/>
<GradientStop Color="#FF1F3A49" Offset="0.75"/>
<GradientStop Color="#FF3A6F90" Offset="1"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="VerticalNormalBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF2F596E" Offset="0.02"/>
<GradientStop Color="#FF10405B" Offset="1"/>
<GradientStop Color="#FF2B404B" Offset="0.209"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="NormalBorderBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF7A8DAA" Offset="0.0"/>
<GradientStop Color="#FF4B4B4B" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="HorizontalNormalBorderBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF6C6C6C" Offset="0.0"/>
<GradientStop Color="#FF8B8B8B" Offset=".5"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Light Brush -->
<LinearGradientBrush x:Key="HorizontalLightBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF616161" Offset="0.0"/>
<GradientStop Color="#FF3F3E49" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="DarkBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF2F4249" Offset="0"/>
<GradientStop Color="#FF2D566C" Offset="1"/>
<GradientStop Color="#FF004161" Offset="0.507"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="VerticalDarkBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF5C7783" Offset="0.0"/>
<GradientStop Color="#FF47545B" Offset="1"/>
<GradientStop Color="#FF134B66" Offset="0.557"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Pressed Brush -->
<LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF7599AA" Offset="0.0"/>
<GradientStop Color="#FF37738F" Offset="1.0"/>
<GradientStop Color="#FF306178" Offset="0.55"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="TogglePressedBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF7599AA" Offset="0.0"/>
<GradientStop Color="#FF37738F" Offset="1.0"/>
<GradientStop Color="#FF306178" Offset="0.55"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="VerticalPressedBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF7599AA" Offset="0.0"/>
<GradientStop Color="#FF37738F" Offset="1.0"/>
<GradientStop Color="#FF306178" Offset="0.55"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="PressedBorderBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#444" Offset="0.0"/>
<GradientStop Color="#888" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Defaulted Brush -->
<LinearGradientBrush x:Key="DefaultedBorderBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#777" Offset="0.3"/>
<GradientStop Color="#000" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Disabled Brush -->
<!-- Border Brushes -->
<!-- Miscellaneous Brushes -->
<LinearGradientBrush x:Key="ScrollBarPageButtonVertBrush" StartPoint="0,0" EndPoint="1,0">
<GradientStopCollection>
<GradientStop Offset="0" Color="#FF707070" />
<GradientStop Offset="0.3" Color="#FF494949" />
<GradientStop Offset="0.7" Color="#FF494949" />
<GradientStop Offset="1" Color="#FF707070" />
</GradientStopCollection>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ScrollBarPageButtonHorizBrush" StartPoint="0,0" EndPoint="0,1">
<GradientStopCollection>
<GradientStop Offset="0" Color="#FF707070" />
<GradientStop Offset="0.3" Color="#FF494949" />
<GradientStop Offset="0.7" Color="#FF494949" />
<GradientStop Offset="1" Color="#FF707070" />
</GradientStopCollection>
</LinearGradientBrush>
<LinearGradientBrush x:Key="TabItemSelectedBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF3DE459" Offset="0"/>
<GradientStop Color="#FF0071A8" Offset="0.05"/>
<GradientStop Color="#FF0071A8" Offset="0.5"/>
<GradientStop Color="#FF0B374F" Offset="1"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!--Color STYLED Brush-->
<LinearGradientBrush x:Key="SelectedBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#CC9ACBFF" Offset="0" />
<GradientStop Color="#FF7DBAFF" Offset=".3" />
<GradientStop Color="#FF7DBAFF" Offset=".7" />
<GradientStop Color="#CC9ACBFF" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="LightBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF616161" Offset="0.0"/>
<GradientStop Color="#FF3F3E49" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ListViewFileItemBrush">
</LinearGradientBrush>
<LinearGradientBrush x:Key="ProgressBarIndeterminateRootBrush" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#F6BCD5FF" Offset="0.046" />
<GradientStop Color="#96D4E4FF" Offset="0.18" />
<GradientStop Color="#4FFFFFFF" Offset="0.512" />
<GradientStop Color="#00D6D6D6" Offset="0.521" />
<GradientStop Color="#BABCD5FF" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="ProgressBarIndeterminateFillBrush" EndPoint="0,1" StartPoint="20,1" MappingMode="Absolute" SpreadMethod="Repeat">
<LinearGradientBrush.Transform>
<TransformGroup>
<SkewTransform AngleX="-10" />
</TransformGroup>
</LinearGradientBrush.Transform>
<GradientStop Color="#FFBCD5FF" Offset="0.088" />
<GradientStop Color="#006EA4FD" Offset="0.475" />
<GradientStop Color="#FFBCD5FF" Offset="0.899" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="NormalProgressBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF9BA8FD" Offset="0.0"/>
<GradientStop Color="#FF0B1C89" Offset="0.4"/>
<GradientStop Color="#FF4B678F" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ProgressBarIndicatorAnimatedFill">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#00eeeeee"
Offset="0" />
<GradientStop Color="#c0eeeeee"
Offset="0.3" />
<GradientStop Color="#d0eeeeee"
Offset="0.8" />
<GradientStop Color="#00eeeeee"
Offset="1" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</ResourceDictionary>

View File

@@ -0,0 +1,236 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<system:Boolean x:Key="IsInverseTheme">False</system:Boolean>
<CornerRadius x:Key="DefaultRadiusSmall">0</CornerRadius>
<CornerRadius x:Key="DefaultRadiusNormal">1</CornerRadius>
<CornerRadius x:Key="TabRadiusTop">0</CornerRadius>
<CornerRadius x:Key="TabRadiusLeft">0</CornerRadius>
<CornerRadius x:Key="TabRadiusRight">0</CornerRadius>
<CornerRadius x:Key="TabRadiusBottom">0</CornerRadius>
<CornerRadius x:Key="TabItemRadius">0,2,0,0</CornerRadius>
<Color x:Key="ValidationErrorColor">Red</Color>
<SolidColorBrush x:Key="NormalBrush" Color="#FFDFE1EF" />
<SolidColorBrush x:Key="VerticalNormalBrush" Color="#FFDFE1EF" />
<LinearGradientBrush x:Key="ProgressBarIndeterminateRootBrush" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#F6BCD5FF" Offset="0.046" />
<GradientStop Color="#96D4E4FF" Offset="0.18" />
<GradientStop Color="#4FFFFFFF" Offset="0.512" />
<GradientStop Color="#00D6D6D6" Offset="0.521" />
<GradientStop Color="#BABCD5FF" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="ProgressBarIndeterminateFillBrush" EndPoint="0,1" StartPoint="20,1" MappingMode="Absolute" SpreadMethod="Repeat">
<LinearGradientBrush.Transform>
<TransformGroup>
<SkewTransform AngleX="-10" />
</TransformGroup>
</LinearGradientBrush.Transform>
<GradientStop Color="#FFBCD5FF" Offset="0.088" />
<GradientStop Color="#006EA4FD" Offset="0.475" />
<GradientStop Color="#FFBCD5FF" Offset="0.899" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="NormalProgressBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF678D66" Offset="0.0"/>
<GradientStop Color="#FF2FA22A" Offset="0.4"/>
<GradientStop Color="#FF576A56" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ProgressBarIndicatorAnimatedFill">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#00ffffff"
Offset="0" />
<GradientStop Color="#c0ffffff"
Offset="0.3" />
<GradientStop Color="#d0ffffff"
Offset="0.8" />
<GradientStop Color="#00ffffff"
Offset="1" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="NormalBorderBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#CCC" Offset="0.0"/>
<GradientStop Color="#444" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="HorizontalNormalBorderBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#CCC" Offset="0.0"/>
<GradientStop Color="#444" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush x:Key="TopLevelMenuBackgroundHover" Color="White" />
<!-- Light Brush -->
<LinearGradientBrush x:Key="HorizontalLightBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#EEE" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Dark Brush -->
<LinearGradientBrush x:Key="DarkBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#FFD7DDFF" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="VerticalDarkBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#FFD7DDFF" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Pressed Brush -->
<LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="White" Offset="0.0"/>
<GradientStop Color="#FFFFBC8D" Offset="0.1"/>
<GradientStop Color="#FFFFB49E" Offset="0.796"/>
<GradientStop Color="#FFFFF4F4" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="TogglePressedBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="White" Offset="0.0"/>
<GradientStop Color="#FFFFBC8D" Offset="0.1"/>
<GradientStop Color="#FFFFB49E" Offset="0.796"/>
<GradientStop Color="#FFFFF4F4" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="VerticalPressedBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="White" Offset="0.0"/>
<GradientStop Color="#FFFFBC8D" Offset="0.1"/>
<GradientStop Color="#FFFFB49E" Offset="0.796"/>
<GradientStop Color="#FFFFF4F4" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="PressedBorderBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#444" Offset="0.0"/>
<GradientStop Color="#444" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Defaulted Brush -->
<SolidColorBrush x:Key="DefaultedBorderBrush" Color="Black"/>
<!-- Disabled Brush -->
<SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA" />
<!-- Border Brushes -->
<SolidColorBrush x:Key="SolidBorderBrush" Color="#888" />
<SolidColorBrush x:Key="LightBorderBrush" Color="#AAA" />
<!-- Miscellaneous Brushes -->
<SolidColorBrush x:Key="ScrollBarPageButtonVertBrush" Color="#FFF3F3F3" />
<SolidColorBrush x:Key="ScrollBarPageButtonHorizBrush" Color="White" />
<SolidColorBrush x:Key="TabItemSelectedBackgroundBrush" Color="#FFF0E0FF"/>
<SolidColorBrush x:Key="MainMenuForegroundBrush" Color="Black"/>
<!--Color STYLED Brush-->
<SolidColorBrush x:Key="WindowBackgroundBrush" Color="White" />
<Color x:Key="WindowBackgroundHoverColor">White</Color>
<SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#FFFFE0E0" />
<SolidColorBrush x:Key="GlyphBrush" Color="#444" />
<SolidColorBrush x:Key="LightColorBrush" Color="#FFF3F3F3" />
<Color x:Key="OnWindowForegroundColor">Black</Color>
<SolidColorBrush x:Key="OnWindowForegroundBrush" Color="{DynamicResource OnWindowForegroundColor}" />
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#FF4D4D4D" />
<SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE" />
<LinearGradientBrush x:Key="LightBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="White" Offset="0.0"/>
<GradientStop Color="#FFF3F3F3" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush x:Key="ScrollBarBackgroundBrush" Color="#F0F0F0" />
<SolidColorBrush x:Key="SynWindowBackgroundBrush" Color="#FFE4E4E4" />
<SolidColorBrush x:Key="HighLightForegroundBrush" Color="#FF500000" />
<Color x:Key="UiForegroundColor">Black</Color>
<SolidColorBrush x:Key="UiForegroundBrush" Color="{DynamicResource UiForegroundColor}" />
<SolidColorBrush x:Key="AlternatingRowBackgroundBrush" Color="White" />
<Color x:Key="SelectedBackgroundColor">#C5C5C5</Color>
<Color x:Key="SelectedUnfocusedColor">#FFB6B6B6</Color>
<Color x:Key="ControlLightColor">#FFFFFFFF</Color>
<Color x:Key="ControlMediumColor">#FFC5C5C5</Color>
<Color x:Key="ControlDarkColor">#FF6B6B6B</Color>
<Color x:Key="ControlMouseOverColor">#FFA5A7BA</Color>
<Color x:Key="ControlPressedColor">#FF47909B</Color>
</ResourceDictionary>

View File

@@ -0,0 +1,284 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<sys:Boolean x:Key="IsInverseTheme">False</sys:Boolean>
<CornerRadius x:Key="DefaultRadiusSmall">1</CornerRadius>
<CornerRadius x:Key="DefaultRadiusNormal">3</CornerRadius>
<CornerRadius x:Key="TabItemRadius">0,8,0,0</CornerRadius>
<CornerRadius x:Key="TabRadiusTop">0,2,2,2</CornerRadius>
<CornerRadius x:Key="TabRadiusLeft">0,5,5,0</CornerRadius>
<CornerRadius x:Key="TabRadiusRight">5,0,0,5</CornerRadius>
<CornerRadius x:Key="TabRadiusBottom">5,5,0,0</CornerRadius>
<Color x:Key="ValidationErrorColor">Red</Color>
<LinearGradientBrush x:Key="NormalBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#CCC" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="VerticalNormalBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#CCC" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ProgressBarIndeterminateRootBrush" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#F6BCD5FF" Offset="0.046" />
<GradientStop Color="#96D4E4FF" Offset="0.18" />
<GradientStop Color="#4FFFFFFF" Offset="0.512" />
<GradientStop Color="#00D6D6D6" Offset="0.521" />
<GradientStop Color="#BABCD5FF" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="ProgressBarIndeterminateFillBrush" EndPoint="0,1" StartPoint="20,1" MappingMode="Absolute" SpreadMethod="Repeat">
<LinearGradientBrush.Transform>
<TransformGroup>
<SkewTransform AngleX="-10" />
</TransformGroup>
</LinearGradientBrush.Transform>
<GradientStop Color="#FFBCD5FF" Offset="0.088" />
<GradientStop Color="#006EA4FD" Offset="0.475" />
<GradientStop Color="#FFBCD5FF" Offset="0.899" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="NormalProgressBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF9B9B9B" Offset="0"/>
<GradientStop Color="#FFB9B9B9" Offset="0.5"/>
<GradientStop Color="#FFE8E8E8" Offset="1"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ProgressBarIndicatorAnimatedFill">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#00ffffff"
Offset="0" />
<GradientStop Color="#c0ffffff"
Offset="0.3" />
<GradientStop Color="#d0ffffff"
Offset="0.8" />
<GradientStop Color="#00ffffff"
Offset="1" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="NormalBorderBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#CCC" Offset="0.0"/>
<GradientStop Color="#444" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="HorizontalNormalBorderBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#CCC" Offset="0.0"/>
<GradientStop Color="#444" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush x:Key="TopLevelMenuBackgroundHover" Color="Pink" />
<!-- Light Brush -->
<LinearGradientBrush x:Key="HorizontalLightBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#EEE" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Dark Brush -->
<LinearGradientBrush x:Key="DarkBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#AAA" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="VerticalDarkBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#AAA" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Pressed Brush -->
<LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#BBB" Offset="0.0"/>
<GradientStop Color="#EEE" Offset="0.1"/>
<GradientStop Color="#EEE" Offset="0.9"/>
<GradientStop Color="#FFF" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="TogglePressedBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#E8D4D4" Offset="0.0"/>
<GradientStop Color="#E3E8A6" Offset="0.1"/>
<GradientStop Color="#ECF699" Offset="0.796"/>
<GradientStop Color="#F3F3F3" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="VerticalPressedBrush" StartPoint="0,0" EndPoint="1,0">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#BBB" Offset="0.0"/>
<GradientStop Color="#EEE" Offset="0.1"/>
<GradientStop Color="#EEE" Offset="0.9"/>
<GradientStop Color="#FFF" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="PressedBorderBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#444" Offset="0.0"/>
<GradientStop Color="#888" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Defaulted Brush -->
<LinearGradientBrush x:Key="DefaultedBorderBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#777" Offset="0.3"/>
<GradientStop Color="#000" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- Disabled Brush -->
<SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA" />
<!-- Border Brushes -->
<SolidColorBrush x:Key="SolidBorderBrush" Color="#888" />
<SolidColorBrush x:Key="LightBorderBrush" Color="#AAA" />
<!-- Miscellaneous Brushes -->
<LinearGradientBrush x:Key="ScrollBarPageButtonVertBrush" StartPoint="0,0" EndPoint="1,0">
<GradientStopCollection>
<GradientStop Offset="0" Color="#FFD3DBFF" />
<GradientStop Offset="0.3" Color="White" />
<GradientStop Offset="0.7" Color="White" />
<GradientStop Offset="1" Color="#FFD3DBFF" />
</GradientStopCollection>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ScrollBarPageButtonHorizBrush" StartPoint="0,0" EndPoint="0,1">
<GradientStopCollection>
<GradientStop Offset="0" Color="#FFD3DBFF" />
<GradientStop Offset="0.3" Color="White" />
<GradientStop Offset="0.7" Color="White" />
<GradientStop Offset="1" Color="#FFD3DBFF" />
</GradientStopCollection>
</LinearGradientBrush>
<LinearGradientBrush x:Key="TabItemSelectedBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#BBB" Offset="0.0"/>
<GradientStop Color="#EEE" Offset="0.1"/>
<GradientStop Color="#EEE" Offset="0.85"/>
<GradientStop Color="#FFF" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush x:Key="MainMenuForegroundBrush" Color="Black"/>
<!--Color STYLED Brush-->
<LinearGradientBrush x:Key="WindowBackgroundBrush">
<GradientStop Color="#EEE" />
</LinearGradientBrush>
<Color x:Key="WindowBackgroundHoverColor">#FFF</Color>
<LinearGradientBrush x:Key="SelectedBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#CC9ACBFF" Offset="0" />
<GradientStop Color="#FF7DBAFF" Offset=".3" />
<GradientStop Color="#FF7DBAFF" Offset=".7" />
<GradientStop Color="#CC9ACBFF" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush x:Key="GlyphBrush" Color="#444" />
<SolidColorBrush x:Key="LightColorBrush" Color="#DDD" />
<Color x:Key="OnWindowForegroundColor">Black</Color>
<SolidColorBrush x:Key="OnWindowForegroundBrush" Color="{DynamicResource OnWindowForegroundColor}" />
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#FF4D4D4D" />
<SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE" />
<SolidColorBrush x:Key="AlternatingRowBackgroundBrush" Color="White" />
<LinearGradientBrush x:Key="LightBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#EEE" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush x:Key="ScrollBarBackgroundBrush" Color="#F0F0F0" />
<SolidColorBrush x:Key="SynWindowBackgroundBrush" Color="#FFE4E4E4" />
<SolidColorBrush x:Key="HighLightForegroundBrush" Color="DarkRed" />
<Color x:Key="UiForegroundColor">Black</Color>
<SolidColorBrush x:Key="UiForegroundBrush" Color="{DynamicResource UiForegroundColor}" />
<Color x:Key="SelectedBackgroundColor">SkyBlue</Color>
<Color x:Key="SelectedUnfocusedColor">#FFB6B6B6</Color>
<Color x:Key="ControlLightColor">#FFFFFFFF</Color>
<Color x:Key="ControlMediumColor">#FFC5C5C5</Color>
<Color x:Key="ControlDarkColor">#FF6B6B6B</Color>
<Color x:Key="ControlMouseOverColor">#FFA5A7BA</Color>
<Color x:Key="ControlPressedColor">#FF47909B</Color>
</ResourceDictionary>

View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
namespace BrightSharp
{
public enum ColorThemes
{
Classic,
DevLab,
Silver,
Blue,
DarkBlue
}
public static class ThemeManager
{
private const string StyleDictionaryPattern = @"(?<=.+style\.)(.*?)(?=\.xaml)";
public static ColorThemes Theme
{
get
{
var curStyleRes = Resources.Where(r => r.Source != null &&
Regex.IsMatch(r.Source.OriginalString, StyleDictionaryPattern, RegexOptions.IgnoreCase)).FirstOrDefault();
if (curStyleRes == null) return ColorThemes.Classic;
var match = Regex.Match(curStyleRes.Source.OriginalString, StyleDictionaryPattern, RegexOptions.IgnoreCase);
return (ColorThemes)Enum.Parse(typeof(ColorThemes), match.Value, true);
}
set
{
var curStyleRes = Resources.Where(r => r.Source != null &&
Regex.IsMatch(r.Source.OriginalString, StyleDictionaryPattern, RegexOptions.IgnoreCase)).FirstOrDefault();
if (curStyleRes != null)
Resources.Remove(curStyleRes);
if (value == ColorThemes.Classic)
return;
Resources.Add(new ResourceDictionary()
{
Source = new Uri($"/brightsharp;component/style.{value}.xaml", UriKind.RelativeOrAbsolute)
});
}
}
private static ICollection<ResourceDictionary> Resources
{
get { return Application.Current.Resources.MergedDictionaries; }
}
}
}

View File

@@ -1,12 +0,0 @@
<UserControl x:Class="BrightSharp.UserControl1"
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:BrightSharp"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
</UserControl>

View File

@@ -1,28 +0,0 @@
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 BrightSharp
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
}
}

210
BrightSharp/ZoomControl.cs Normal file
View File

@@ -0,0 +1,210 @@
using BrightSharp.Extensions;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media.Animation;
using BrightSharp.Diagrams;
namespace BrightSharp
{
public partial class ZoomControl : ItemsControl
{
public ZoomControl()
{
Loaded += ZoomControl_Loaded;
}
private void ZoomControl_Loaded(object sender, RoutedEventArgs e)
{
SelectionBehavior.Attach(this);
}
public ContentControl SelectedControl
{
get { return (ContentControl)GetValue(SelectedControlProperty); }
set { SetValue(SelectedControlProperty, value); }
}
public static readonly DependencyProperty SelectedControlProperty =
DependencyProperty.Register("SelectedControl", typeof(ContentControl), typeof(ZoomControl), new PropertyMetadata(null));
protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
{
base.OnPreviewMouseDown(e);
if (e.MiddleButton == MouseButtonState.Pressed)
{
_panPoint = e.GetPosition(this);
}
}
private Point? _panPoint;
#region Props
public double TranslateX
{
get { return (double)GetValue(TranslateXProperty); }
set { SetValue(TranslateXProperty, value); }
}
public static readonly DependencyProperty TranslateXProperty =
DependencyProperty.Register("TranslateX", typeof(double), typeof(ZoomControl), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsArrange, TranslateChangedHandler));
public double TranslateY
{
get { return (double)GetValue(TranslateYProperty); }
set { SetValue(TranslateYProperty, value); }
}
public static readonly DependencyProperty TranslateYProperty =
DependencyProperty.Register("TranslateY", typeof(double), typeof(ZoomControl), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsArrange, TranslateChangedHandler));
public double RenderZoom
{
get { return (double)GetValue(RenderZoomProperty); }
set { SetValue(RenderZoomProperty, value); }
}
public static readonly DependencyProperty RenderZoomProperty =
DependencyProperty.Register("RenderZoom", typeof(double), typeof(ZoomControl), new FrameworkPropertyMetadata(1.0, FrameworkPropertyMetadataOptions.AffectsArrange, ZoomChangedHandler));
private static void ZoomChangedHandler(DependencyObject d, DependencyPropertyChangedEventArgs baseValue)
{
ZoomControl zc = (ZoomControl)d;
}
private static void TranslateChangedHandler(DependencyObject d, DependencyPropertyChangedEventArgs baseValue)
{
ZoomControl zc = (ZoomControl)d;
}
#endregion
private static readonly RoutedEvent ZoomChangedEvent = EventManager.RegisterRoutedEvent("ZoomChanged", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ZoomControl));
public event RoutedEventHandler ZoomChanged
{
add { AddHandler(ZoomChangedEvent, value); }
remove { RemoveHandler(ZoomChangedEvent, value); }
}
private void RaiseZoomChangedEvent()
{
var newEventArgs = new RoutedEventArgs(ZoomChangedEvent);
RaiseEvent(newEventArgs);
}
static ZoomControl()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ZoomControl), new FrameworkPropertyMetadata(typeof(ZoomControl)));
}
protected override void OnPreviewMouseWheel(MouseWheelEventArgs e)
{
if (CheckMouseOverControlWheelHandle(_panPoint.HasValue))
return;
var point = e.GetPosition(this);
var oldValue = RenderZoom;
const double zoomPower = 1.25;
var newValue = RenderZoom * (e.Delta > 0 ? zoomPower : 1 / zoomPower);
if (UseAnimation)
{
DoubleAnimation anim = new DoubleAnimation(newValue, TimeSpan.FromSeconds(.3));
anim.EasingFunction = new SineEase() { EasingMode = EasingMode.EaseInOut };
this.BeginAnimation(ZoomControl.RenderZoomProperty, anim);
}
else
{
RenderZoom = newValue;
}
RaiseZoomChangedEvent();
var translateXTo = CoercePanTranslate(TranslateX, point.X, oldValue, newValue);
var translateYTo = CoercePanTranslate(TranslateY, point.Y, oldValue, newValue);
if (UseAnimation)
{
DoubleAnimation anim = new DoubleAnimation(translateXTo, TimeSpan.FromSeconds(.3));
anim.EasingFunction = new SineEase() { EasingMode = EasingMode.EaseInOut };
this.BeginAnimation(ZoomControl.TranslateXProperty, anim);
anim = new DoubleAnimation(translateYTo, TimeSpan.FromSeconds(.3));
anim.EasingFunction = new SineEase() { EasingMode = EasingMode.EaseInOut };
this.BeginAnimation(ZoomControl.TranslateYProperty, anim);
}
else
{
TranslateX = translateXTo; TranslateY = translateYTo;
}
e.Handled = true;
base.OnPreviewMouseWheel(e);
}
public bool UseAnimation { get; set; }
private static bool CheckMouseOverControlWheelHandle(bool checkFlowDoc = false)
{
if (Keyboard.IsKeyDown(Key.LeftCtrl)) return false;
var element = Mouse.DirectlyOver as DependencyObject;
if (element is ScrollViewer) return true;
var scrollViewer = element.FindAncestor<ScrollViewer>();
if (scrollViewer != null)
{
return scrollViewer.ComputedVerticalScrollBarVisibility == Visibility.Visible
|| scrollViewer.ComputedHorizontalScrollBarVisibility == Visibility.Visible;
}
if (checkFlowDoc)
{
var flowDocument = element.FindAncestor<FlowDocument>();
if (flowDocument != null)
{
return true;
}
}
return false;
}
private static double CoercePanTranslate(double oldTranslate, double mousePos, double oldZoom, double newZoom)
{
return Math.Round(oldTranslate + (oldTranslate - mousePos) * (newZoom - oldZoom) / oldZoom);
}
protected override void OnMouseUp(MouseButtonEventArgs e)
{
base.OnMouseUp(e);
if (e.MiddleButton == MouseButtonState.Released)
{
_panPoint = null;
ReleaseMouseCapture();
}
}
protected override void OnPreviewMouseMove(MouseEventArgs e)
{
base.OnPreviewMouseMove(e);
if (e.MiddleButton == MouseButtonState.Pressed && _panPoint.HasValue)
{
//PAN MODE
var vector = e.GetPosition(this) - _panPoint.Value;
_panPoint = _panPoint + vector;
CaptureMouse();
TranslateX += vector.X;
TranslateY += vector.Y;
BeginAnimation(TranslateXProperty, null);
BeginAnimation(TranslateYProperty, null);
}
}
}
}

BIN
BrightSharp/icons/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

BIN
BrightSharp/icons/copy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

BIN
BrightSharp/icons/cut.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

BIN
BrightSharp/icons/paste.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

BIN
BrightSharp/icons/undo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB