-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
239 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Media; | ||
using System.Windows.Shapes; | ||
|
||
namespace Dive.UI.Common.UIElements | ||
{ | ||
public class DashedBorder : Border | ||
{ | ||
private static DoubleCollection? emptyDoubleCollection; | ||
private static DoubleCollection EmptyDoubleCollection() | ||
{ | ||
if (emptyDoubleCollection == null) | ||
{ | ||
DoubleCollection doubleCollection = new DoubleCollection(); | ||
doubleCollection.Freeze(); | ||
emptyDoubleCollection = doubleCollection; | ||
} | ||
return emptyDoubleCollection; | ||
} | ||
|
||
public static readonly DependencyProperty UseDashedBorderProperty = | ||
DependencyProperty.Register(nameof(UseDashedBorder), | ||
typeof(bool), | ||
typeof(DashedBorder), | ||
new FrameworkPropertyMetadata(false, OnUseDashedBorderChanged)); | ||
|
||
public static readonly DependencyProperty DashedBorderBrushProperty = | ||
DependencyProperty.Register(nameof(DashedBorderBrush), | ||
typeof(Brush), | ||
typeof(DashedBorder), | ||
new FrameworkPropertyMetadata(null)); | ||
|
||
public static readonly DependencyProperty StrokeDashArrayProperty = | ||
DependencyProperty.Register(nameof(StrokeDashArray), | ||
typeof(DoubleCollection), | ||
typeof(DashedBorder), | ||
new FrameworkPropertyMetadata(EmptyDoubleCollection())); | ||
|
||
private static void OnUseDashedBorderChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) | ||
{ | ||
DashedBorder dashedBorder = (DashedBorder)target; | ||
dashedBorder.UseDashedBorderChanged(); | ||
} | ||
|
||
private Rectangle GetBoundRectangle() | ||
{ | ||
Rectangle rectangle = new Rectangle(); | ||
|
||
rectangle.SetBinding(Rectangle.StrokeThicknessProperty, new Binding() { Source = this, Path = new PropertyPath("BorderThickness.Left") }); | ||
rectangle.SetBinding(Rectangle.RadiusXProperty, new Binding() { Source = this, Path = new PropertyPath("CornerRadius.TopLeft") }); | ||
rectangle.SetBinding(Rectangle.RadiusYProperty, new Binding() { Source = this, Path = new PropertyPath("CornerRadius.TopLeft") }); | ||
rectangle.SetBinding(Rectangle.WidthProperty, new Binding() { Source = this, Path = new PropertyPath(ActualWidthProperty) }); | ||
rectangle.SetBinding(Rectangle.HeightProperty, new Binding() { Source = this, Path = new PropertyPath(ActualHeightProperty) }); | ||
|
||
return rectangle; | ||
} | ||
|
||
private Rectangle GetBackgroundRectangle() | ||
{ | ||
Rectangle rectangle = GetBoundRectangle(); | ||
rectangle.SetBinding(Rectangle.StrokeProperty, new Binding() { Source = this, Path = new PropertyPath(BackgroundProperty) }); | ||
return rectangle; | ||
} | ||
|
||
private Rectangle GetDashedRectangle() | ||
{ | ||
Rectangle rectangle = GetBoundRectangle(); | ||
rectangle.SetBinding(Rectangle.StrokeDashArrayProperty, new Binding() { Source = this, Path = new PropertyPath(StrokeDashArrayProperty) }); | ||
rectangle.SetBinding(Rectangle.StrokeProperty, new Binding() { Source = this, Path = new PropertyPath(DashedBorderBrushProperty) }); | ||
Panel.SetZIndex(rectangle, 2); | ||
return rectangle; | ||
} | ||
|
||
private VisualBrush CreateDashedBorderBrush() | ||
{ | ||
VisualBrush dashedBorderBrush = new VisualBrush(); | ||
Grid grid = new Grid(); | ||
Rectangle backgroundRectangle = GetBackgroundRectangle(); | ||
Rectangle dashedRectangle = GetDashedRectangle(); | ||
grid.Children.Add(backgroundRectangle); | ||
grid.Children.Add(dashedRectangle); | ||
dashedBorderBrush.Visual = grid; | ||
return dashedBorderBrush; | ||
} | ||
|
||
private void UseDashedBorderChanged() | ||
{ | ||
if (UseDashedBorder) | ||
{ | ||
BorderBrush = CreateDashedBorderBrush(); | ||
} | ||
else | ||
{ | ||
ClearValue(BorderBrushProperty); | ||
} | ||
} | ||
|
||
public bool UseDashedBorder | ||
{ | ||
get { return (bool)GetValue(UseDashedBorderProperty); } | ||
set { SetValue(UseDashedBorderProperty, value); } | ||
} | ||
|
||
public Brush DashedBorderBrush | ||
{ | ||
get { return (Brush)GetValue(DashedBorderBrushProperty); } | ||
set { SetValue(DashedBorderBrushProperty, value); } | ||
} | ||
|
||
public DoubleCollection StrokeDashArray | ||
{ | ||
get { return (DoubleCollection)GetValue(StrokeDashArrayProperty); } | ||
set { SetValue(StrokeDashArrayProperty, value); } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<UserControl x:Class="Dive.UI.Pages.TweaksPages.PlayBook.PlayBookLoad" | ||
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:ui="http://schemas.lepo.co/wpfui/2022/xaml" | ||
xmlns:local="clr-namespace:Dive.UI.Pages.TweaksPages.PlayBook" | ||
xmlns:uiElements="clr-namespace:Dive.UI.Common.UIElements" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<Grid Margin="0,-20,0,0" AllowDrop="True" | ||
Drop="UIElement_OnDrop" | ||
DragEnter="UIElement_DragEnter"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="420"/> | ||
</Grid.RowDefinitions> | ||
|
||
<uiElements:DashedBorder UseDashedBorder="True" | ||
DashedBorderBrush="White" | ||
StrokeDashArray="2 1" | ||
Background="Transparent" | ||
BorderThickness="2" | ||
CornerRadius="10" | ||
Margin="20"> | ||
<Label HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Content="Drag .dpbx file or click here to load playbook" | ||
FontSize="20"/> | ||
</uiElements:DashedBorder> | ||
</Grid> | ||
</UserControl> |
48 changes: 48 additions & 0 deletions
48
Dive/Dive.UI/Pages/TweaksPages/PlayBook/PlayBookLoad.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Windows; | ||
using Dive.UI.Common; | ||
|
||
namespace Dive.UI.Pages.TweaksPages.PlayBook | ||
{ | ||
/// <summary> | ||
/// Interaktionslogik für PlayBookLoad.xaml | ||
/// </summary> | ||
public partial class PlayBookLoad | ||
{ | ||
public event DragEventHandler DragEnter; | ||
public event DragEventHandler Drop; | ||
|
||
public PlayBookLoad() | ||
{ | ||
InitializeComponent(); | ||
|
||
if (TweaksContent.ContentWindow == null) return; | ||
TweaksContent.ContentWindow.NextBtn.IsEnabled = false; | ||
TweaksContent.ContentWindow.BackBtn.IsEnabled = true; | ||
} | ||
|
||
private void UIElement_OnDrop(object sender, DragEventArgs e) | ||
{ | ||
if (e.Data.GetDataPresent(DataFormats.FileDrop)) | ||
{ | ||
var files = (string[])e.Data.GetData(DataFormats.FileDrop); | ||
foreach (var file in files) | ||
{ | ||
Debug.WriteLine(file); | ||
} | ||
} | ||
} | ||
|
||
private void UIElement_DragEnter(object sender, DragEventArgs e) | ||
{ | ||
if (e.Data.GetDataPresent(DataFormats.FileDrop)) | ||
{ | ||
e.Effects = DragDropEffects.Copy; | ||
} | ||
else | ||
{ | ||
e.Effects = DragDropEffects.None; | ||
} | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...I/Pages/TweaksPages/AutoInitSettings.xaml → ...weaksPages/PlayBook/PlayBookSettings.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.