Ok, Just Do It!

This commit is contained in:
Vitaliy
2017-02-18 00:15:59 +03:00
parent f0913f9873
commit 5c46ef7b7f
122 changed files with 1712 additions and 2177 deletions

View File

@@ -9,10 +9,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BrightSharp</RootNamespace>
<AssemblyName>BrightSharp</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -22,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -30,6 +32,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -40,7 +43,6 @@
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
@@ -52,11 +54,13 @@
<Compile Include="Behaviors\FiterGridTextBoxBehavior.cs" />
<Compile Include="Commands\AsyncCommand.cs" />
<Compile Include="Commands\RelayCommand.cs" />
<Compile Include="Converters\StringHelpConverter.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\VisualExtensions.cs" />
<Compile Include="Diagrams\SelectionBehavior.cs" />
<Compile Include="Diagrams\Thumbs\MoveThumb.cs" />
<Compile Include="Diagrams\Thumbs\ResizeThumb.cs" />
@@ -127,9 +131,10 @@
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Resource Include="icons\app.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="icons\copy.png" />
<Resource Include="icons\cut.png" />
<Resource Include="icons\paste.png" />

View File

@@ -12,6 +12,10 @@ namespace BrightSharp.Commands
private Action<Exception> _onFail;
private bool _isExecuting;
public AsyncCommand(Func<Task> execute) : this(p => execute?.Invoke())
{
}
public AsyncCommand(Func<object, Task> execute) : this(execute, o => true)
{
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Windows.Data;
namespace BrightSharp.Converters
{
public class StringHelpConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (parameter is string && value is string)
{
var parStr = (string)parameter;
switch (parStr)
{
case "SpaceBetweenCaps":
var src = (value ?? string.Empty).ToString();
return Regex.Replace(src, "([a-z])([A-Z])", "$1 $2");
default:
break;
}
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Windows;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
@@ -6,6 +7,7 @@ using System.Windows.Media;
namespace Diagrams
{
[ToolboxItem(false)]
public class ResizeRotateAdorner : Adorner
{
private VisualCollection visuals;

View File

@@ -1,8 +1,10 @@
using System.Windows;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
namespace Diagrams
{
[ToolboxItem(false)]
public class ResizeRotateChrome : Control
{
static ResizeRotateChrome()

View File

@@ -1,10 +1,12 @@
using System.Windows;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
namespace Diagrams
{
[ToolboxItem(false)]
public class SizeAdorner : Adorner
{
private SizeChrome chrome;

View File

@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
@@ -6,6 +7,8 @@ using System.Windows.Data;
namespace Diagrams
{
[ToolboxItem(false)]
public class SizeChrome : Control
{
static SizeChrome()

View File

@@ -8,9 +8,11 @@ using System.Windows;
using System.Windows.Media;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.ComponentModel;
namespace Diagrams
{
[ToolboxItem(false)]
public class DesignerItemDecorator : Control
{
private Adorner adorner;

View File

@@ -5,7 +5,7 @@ using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System;
namespace BrightSharp.Diagrams
namespace Diagrams
{
public static class SelectionBehavior
{

View File

@@ -1,4 +1,5 @@
using System.Windows;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
@@ -6,6 +7,7 @@ using System.Windows.Media;
namespace Diagrams
{
[ToolboxItem(false)]
public class MoveThumb : Thumb
{
private RotateTransform rotateTransform;

View File

@@ -6,9 +6,11 @@ using System.Windows.Documents;
using System.Windows.Media;
using System.Collections.Generic;
using System.Windows.Input;
using System.ComponentModel;
namespace Diagrams
{
[ToolboxItem(false)]
public class ResizeThumb : Thumb
{
private RotateTransform rotateTransform;
@@ -86,12 +88,14 @@ namespace Diagrams
{
case System.Windows.VerticalAlignment.Bottom:
deltaVertical = Math.Min(-e.VerticalChange, this.designerItem.ActualHeight - this.designerItem.MinHeight);
deltaVertical = Math.Max(deltaVertical, this.designerItem.ActualHeight - this.designerItem.MaxHeight);
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);
deltaVertical = Math.Max(deltaVertical, this.designerItem.ActualHeight - this.designerItem.MaxHeight);
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;
@@ -104,12 +108,14 @@ namespace Diagrams
{
case System.Windows.HorizontalAlignment.Left:
deltaHorizontal = Math.Min(e.HorizontalChange, this.designerItem.ActualWidth - this.designerItem.MinWidth);
deltaHorizontal = Math.Max(deltaHorizontal, this.designerItem.ActualWidth - this.designerItem.MaxWidth);
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);
deltaHorizontal = Math.Max(deltaHorizontal, this.designerItem.ActualWidth - this.designerItem.MaxWidth);
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;

View File

@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
@@ -7,6 +8,7 @@ using System.Windows.Media;
namespace Diagrams
{
[ToolboxItem(false)]
public class RotateThumb : Thumb
{
private double initialAngle;

View File

@@ -0,0 +1,115 @@
using BrightSharp;
using BrightSharp.Extensions;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace Diagrams
{
/// <summary>
/// If starts with a(A) then use animation,
/// $FromZoom-$ToZoom pattern
/// </summary>
public class VisualExtensions : DependencyObject
{
#region LevelOfDetails Attached Property
public static readonly DependencyProperty LODZoomProperty =
DependencyProperty.RegisterAttached("LODZoom",
typeof(string),
typeof(VisualExtensions),
new UIPropertyMetadata(null, OnChangeLODZoomProperty));
public static void SetLODZoom(UIElement element, string o)
{
element.SetValue(LODZoomProperty, o);
}
public static string GetLODZoom(UIElement element)
{
return (string)element.GetValue(LODZoomProperty);
}
#endregion
private static void OnChangeLODZoomProperty(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var element = d as FrameworkElement;
if (element == null) return;
var window = Window.GetWindow(element);
if (window == null) return;
if (e.NewValue != e.OldValue)
{
var zoomControl = element.FindAncestor<ZoomControl>();
if (zoomControl == null) return;
var zoomChangedHandler = new RoutedEventHandler((sender, args) =>
{
var lodInfo = new LodInfo(GetLODZoom(element));
var transform = element.TransformToVisual(window) as MatrixTransform;
var scaleX = transform.Matrix.M11;
var newOpacity = (scaleX >= lodInfo.StartRange && scaleX <= lodInfo.EndRange) ? 1 : 0;
if (lodInfo.UseAnimation && args.RoutedEvent != FrameworkElement.LoadedEvent)
{
element.Visibility = Visibility.Visible;
var animation = new DoubleAnimation(newOpacity, TimeSpan.FromSeconds(.5));
element.BeginAnimation(UIElement.OpacityProperty, animation);
}
else
{
element.Visibility = newOpacity == 1 ? Visibility.Visible : Visibility.Hidden;
element.Opacity = newOpacity;
}
});
if (string.IsNullOrWhiteSpace((string)e.NewValue))
{
element.Opacity = 1;
zoomControl.ZoomChanged -= zoomChangedHandler;
zoomControl.Loaded -= zoomChangedHandler;
}
else
{
zoomControl.ZoomChanged += zoomChangedHandler;
zoomControl.Loaded += zoomChangedHandler;
}
}
}
sealed class LodInfo
{
public LodInfo(string lod)
{
UseAnimation = lod.StartsWith("a", true, CultureInfo.InvariantCulture);
lod = lod.TrimStart('a', 'A').Trim();
double rangeStart = 0;
double rangeEnd = double.PositiveInfinity;
var vals = lod.Split('-');
double.TryParse(vals[0], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out rangeStart);
if (vals.Length > 1)
{
if (!double.TryParse(vals[1], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out rangeEnd))
{
rangeEnd = double.PositiveInfinity;
}
}
EndRange = rangeEnd;
StartRange = rangeStart;
}
public double StartRange { get; set; }
public double EndRange { get; set; }
public bool UseAnimation { get; set; }
}
}
}

View File

@@ -9,7 +9,6 @@ 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); }
@@ -22,5 +21,25 @@ namespace BrightSharp
child = VisualTreeHelper.GetParent(child) ?? LogicalTreeHelper.GetParent(child);
if (((AdornerDecorator)child)?.Child is Calendar) ((AdornerDecorator)child).Child = null;
}
private void closeButton_Click(object sender, RoutedEventArgs e)
{
var window = Window.GetWindow((DependencyObject)sender);
window.Close();
}
private void maximizeButton_Click(object sender, RoutedEventArgs e)
{
var window = Window.GetWindow((DependencyObject)sender);
window.WindowState = window.WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal;
}
private void minimizeButton_Click(object sender, RoutedEventArgs e)
{
var window = Window.GetWindow((DependencyObject)sender);
window.WindowState = WindowState.Minimized;
}
}
}

View File

@@ -5,6 +5,7 @@
xmlns:bs="clr-namespace:BrightSharp.Extensions"
xmlns:conv="clr-namespace:BrightSharp.Converters"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:diag="clr-namespace:Diagrams"
xmlns:local="clr-namespace:BrightSharp">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Diagrams/Resources/DesignerItem.xaml" />
@@ -757,7 +758,7 @@
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)" Storyboard.TargetName="path"/>
<DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="path"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
@@ -780,7 +781,7 @@
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)" Storyboard.TargetName="path"/>
<DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="path"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
@@ -813,7 +814,7 @@
<VisualState x:Name="MouseOver"/>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)" Storyboard.TargetName="path"/>
<DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="path"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
@@ -855,7 +856,7 @@
<VisualState x:Name="MouseOver"/>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)" Storyboard.TargetName="path"/>
<DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="path"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
@@ -1473,6 +1474,9 @@
<Setter Property="MaxHeight" Value="22" />
</Style>
<Style TargetType="DataGridColumnHeader">
<Style.Resources>
<conv:StringHelpConverter x:Key="StringHelper" />
</Style.Resources>
<Setter Property="Foreground" Value="{DynamicResource UiForegroundBrush}" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
@@ -1480,8 +1484,7 @@
<Setter Property="SeparatorBrush" Value="{DynamicResource NormalBorderBrush}" />
<Setter Property="Background" Value="{DynamicResource LightBrush}" />
<Setter Property="Padding" Value="4" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridColumnHeader">
@@ -1502,7 +1505,7 @@
VerticalAlignment="Top" RenderTransformOrigin=".5 .5"
Data="M 0 0 L 4 4 L 8 0 Z"/>
<Grid Margin="{TemplateBinding Padding}">
<ContentPresenter RecognizesAccessKey="True" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<ContentPresenter RecognizesAccessKey="True" Content="{Binding Path=Content, Converter={StaticResource StringHelper}, RelativeSource={RelativeSource TemplatedParent}}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
<Thumb Name="PART_LeftHeaderGripper" HorizontalAlignment="Left">
@@ -1907,7 +1910,7 @@
OverridesDefaultStyle="True" Opacity="0.7"
Template="{DynamicResource ExpanderToggleButton}"
Background="{DynamicResource NormalBrush}" />
<ContentPresenter
<ContentPresenter
Grid.Column="1"
Margin="4" IsHitTestVisible="False"
ContentSource="Header"
@@ -2587,7 +2590,7 @@
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="MainEllipse" Property="Opacity" Value="0.65" />
<Setter TargetName="MainEllipse" Property="Stroke" Value="DarkGray" />
<Setter Property="Foreground" Value="DarkGray"/>
<!--<Setter TargetName="MainGrid" Property="TextBlock.Foreground" Value="DarkGray"/>-->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -3126,9 +3129,9 @@
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Height" Value="2"/>
<Setter Property="BorderThickness" Value="0,1,0,0" />
<Setter Property="BorderBrush" Value="#FF686868" />
<Setter Property="BorderBrush" Value="{DynamicResource SolidBorderBrush}" />
<Setter Property="Margin" Value="5,3"/>
<Setter Property="Background" Value="WhiteSmoke" />
<Setter Property="Background" Value="{DynamicResource WindowSolidBrush}" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Template">
<Setter.Value>
@@ -3969,7 +3972,8 @@
</Style.Triggers>
</Style>
</Style.Resources>
<Setter Property="MinWidth" Value="10"/>
<Setter Property="MinWidth" Value="10" />
<Setter Property="Foreground" Value="{DynamicResource OnWindowForegroundBrush}" />
<Style.BasedOn>
<StaticResource ResourceKey="{x:Type TextBoxBase}"/>
</Style.BasedOn>
@@ -4380,7 +4384,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Separator}">
<Border BorderBrush="{DynamicResource SolidBorderColor}" BorderThickness="1" />
<Border BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
@@ -4652,6 +4656,8 @@
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="BorderBrush" Value="{DynamicResource SolidBorderBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="4" />
<Setter Property="Template">
<Setter.Value>
@@ -4675,7 +4681,7 @@
<Border
x:Name="Border"
Grid.Row="1" Grid.Column="1"
BorderBrush="{DynamicResource SolidBorderBrush}"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
KeyboardNavigation.TabNavigation="Local"
@@ -5604,7 +5610,7 @@
<Style TargetType="{x:Type local:ZoomControl}">
<Style TargetType="{x:Type diag:ZoomControl}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="ClipToBounds" Value="True" />
<Setter Property="Focusable" Value="False" />
@@ -5617,7 +5623,7 @@
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:ZoomControl}">
<ControlTemplate TargetType="{x:Type diag:ZoomControl}">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="{TemplateBinding Padding}">
<Grid>
<ItemsPresenter>
@@ -5639,6 +5645,110 @@
</Style>
<!-- Window (Experimental) Style -->
<LinearGradientBrush x:Key="WindowSolidBrush" EndPoint="0,1">
<GradientStop Color="White" />
<GradientStop Color="#FFE0E0E0" Offset="0.2" />
<GradientStop Color="#FFECECEC" Offset="0.7" />
<GradientStop Color="#FFC3E0FF" Offset="1" />
</LinearGradientBrush>
<Style x:Key="TestWindowStyle" TargetType="{x:Type Window}">
<Setter Property="WindowStyle" Value="None" />
<Setter Property="BorderBrush" >
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FF898989" Offset="0"/>
<GradientStop Color="#FF898989" Offset="1"/>
<GradientStop Color="LightGray" Offset="0.841"/>
<GradientStop Color="#FFCBCBCB" Offset="0.23"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Icon" Value="icons/app.png" />
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome CaptionHeight="30" ResizeBorderThickness="4" GlassFrameThickness="1" UseAeroCaptionButtons="False" />
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="bs:MarkupExtensionProperties.Header" Value="{Binding Path=Title, RelativeSource={RelativeSource Self}}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
</Grid.RowDefinitions>
<Border Background="{DynamicResource WindowSolidBrush}">
<DockPanel>
<Image Width="16" Height="16" Source="{TemplateBinding Icon}" Margin="8" VerticalAlignment="Top" DockPanel.Dock="Left" />
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" VerticalAlignment="Top" Margin="2">
<Button VerticalAlignment="Center" Name="PART_MinimizeButton" Click="minimizeButton_Click" Focusable="False" WindowChrome.IsHitTestVisibleInChrome="True" Content="0" bs:MarkupExtensionProperties.CornerRadius="0" BorderBrush="Transparent" FontFamily="Webdings">
<Button.ToolTip>
<Label FontFamily="{TemplateBinding FontFamily}">Minimize</Label>
</Button.ToolTip>
</Button>
<Button VerticalAlignment="Center" Name="PART_MaximizeButton" Click="maximizeButton_Click" Focusable="False" WindowChrome.IsHitTestVisibleInChrome="True" Content="1" bs:MarkupExtensionProperties.CornerRadius="0" BorderBrush="Transparent" FontFamily="Webdings">
<Button.ToolTip>
<Label FontFamily="{TemplateBinding FontFamily}" Name="MaximizeBtnTooltip">Maximize</Label>
</Button.ToolTip>
</Button>
<Button Padding="6" Name="PART_CloseButton" Click="closeButton_Click" Focusable="False" WindowChrome.IsHitTestVisibleInChrome="True" Content="r" bs:MarkupExtensionProperties.CornerRadius="0" BorderBrush="Transparent" FontFamily="Webdings">
<Button.ToolTip>
<Label FontFamily="{TemplateBinding FontFamily}">Close (Alt+F4)</Label>
</Button.ToolTip>
<Button.Background>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFDEC3C3" Offset="0"/>
<GradientStop Color="#FFCDA2A2" Offset="1"/>
</LinearGradientBrush>
</Button.Background>
<Button.Resources>
<LinearGradientBrush x:Key="DarkBrush" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFF8A8A" Offset="0"/>
<GradientStop Color="#FFD14D4D" Offset="1"/>
</LinearGradientBrush>
</Button.Resources>
</Button>
</StackPanel>
<Label HorizontalContentAlignment="{TemplateBinding bs:MarkupExtensionProperties.HeaderHorizontalAlignment}" Content="{TemplateBinding bs:MarkupExtensionProperties.Header}" FontSize="15">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="2" Color="#7F4F5EA4" />
</Label.Effect>
</Label>
</DockPanel>
</Border>
<AdornerDecorator Grid.Row="1" x:Name="Decorator" ClipToBounds="True">
<ContentPresenter />
</AdornerDecorator>
<ResizeGrip WindowChrome.ResizeGripDirection="BottomRight" Grid.Row="3" x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="false" Visibility="Collapsed" VerticalAlignment="Bottom"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="WindowState" Value="Maximized">
<Setter TargetName="PART_MaximizeButton" Property="Content" Value="2" />
<Setter TargetName="MaximizeBtnTooltip" Property="Content" Value="Normalize" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
<Condition Property="WindowState" Value="Normal"/>
</MultiTrigger.Conditions>
<Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
</MultiTrigger>
<Trigger Property="WindowState" Value="Maximized">
<Setter Property="Margin" TargetName="Decorator" Value="6,0,4,0" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View File

@@ -59,11 +59,7 @@ namespace BrightSharp.Mvvm
protected virtual void RaisePropertyChanged<T>(Expression<Func<T>> propertyExpression)
{
PropertyChangedEventHandler handler = PropertyChanged;
if(handler != null)
{
handler(this, new PropertyChangedEventArgs(GetPropertyName(propertyExpression)));
}
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(GetPropertyName(propertyExpression)));
}
protected Boolean Set<T>(Expression<Func<T>> propertyExpression, ref T field, T newValue)

View File

@@ -57,4 +57,9 @@ using System.Windows.Markup;
[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")]
[assembly: XmlnsDefinition("http://schemas.brightsharp.com/developer", "BrightSharp.Behaviors")]
[assembly: XmlnsDefinition("http://schemas.brightsharp.com/developer", "BrightSharp.Converters")]
[assembly: XmlnsPrefix("http://schemas.brightsharp.com/diagrams", "bsDiag")]
[assembly: XmlnsDefinition("http://schemas.brightsharp.com/diagrams", "Diagrams")]

View File

@@ -9,6 +9,7 @@
//------------------------------------------------------------------------------
namespace BrightSharp.Properties {
using System;
/// <summary>
@@ -37,7 +38,7 @@ namespace BrightSharp.Properties {
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if ((resourceMan == null)) {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BrightSharp.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}

View File

@@ -8,21 +8,17 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace BrightSharp.Properties
{
namespace BrightSharp.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
public static Settings Default {
get {
return defaultInstance;
}
}

View File

@@ -5,9 +5,8 @@ using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media.Animation;
using BrightSharp.Diagrams;
namespace BrightSharp
namespace Diagrams
{
public partial class ZoomControl : ItemsControl
@@ -15,13 +14,14 @@ namespace BrightSharp
public ZoomControl()
{
Loaded += ZoomControl_Loaded;
}
private void ZoomControl_Loaded(object sender, RoutedEventArgs e)
{
SelectionBehavior.Attach(this);
}
public ContentControl SelectedControl
{
get { return (ContentControl)GetValue(SelectedControlProperty); }
@@ -206,5 +206,6 @@ namespace BrightSharp
BeginAnimation(TranslateYProperty, null);
}
}
}
}