From 1ae88a83f5e9b5686ad04279b6ec9dec9e6bfb3d Mon Sep 17 00:00:00 2001 From: Jeremy Vignelles Date: Tue, 5 Jun 2018 10:44:18 +0200 Subject: [PATCH 1/4] Removed all useless whitespaces It made my visual studio put squiggles everywhere, making the code unreadable. Or maybe is it Resharper? --- Dragablz.Test/Properties/AssemblyInfo.cs | 10 +- Dragablz/CanvasOrganiser.cs | 8 +- .../BooleanAndToVisibilityConverter.cs | 6 +- .../ShowDefaultCloseButtonConverter.cs | 6 +- Dragablz/Core/CollectionTeaser.cs | 6 +- Dragablz/Core/Extensions.cs | 10 +- Dragablz/Core/FuncComparer.cs | 2 +- Dragablz/Core/InterTabTransfer.cs | 2 +- Dragablz/Core/MultiComparer.cs | 10 +- Dragablz/Core/Native.cs | 6 +- .../Core/TabHeaderDragStartInformation.cs | 2 +- Dragablz/DefaultInterLayoutClient.cs | 10 +- Dragablz/DefaultInterTabClient.cs | 4 +- Dragablz/Dockablz/Branch.cs | 2 +- Dragablz/Dockablz/BranchAccessor.cs | 10 +- Dragablz/Dockablz/BranchResult.cs | 2 +- Dragablz/Dockablz/DropZone.cs | 2 +- Dragablz/Dockablz/DropZoneLocation.cs | 4 +- Dragablz/Dockablz/Finder.cs | 4 +- Dragablz/Dockablz/FloatRequestedEvent.cs | 4 +- Dragablz/Dockablz/FloatTransfer.cs | 2 +- Dragablz/Dockablz/FloatingItemSnapShot.cs | 6 +- Dragablz/Dockablz/Layout.cs | 100 ++++++------ Dragablz/Dockablz/LayoutAccessor.cs | 12 +- Dragablz/Dockablz/LocationSnapShot.cs | 4 +- Dragablz/Dockablz/Tiler.cs | 2 +- Dragablz/Dockablz/TilerCalculator.cs | 2 +- Dragablz/DragablzColors.cs | 4 +- Dragablz/DragablzDragCompletedEventArgs.cs | 6 +- Dragablz/DragablzDragDeltaEventArgs.cs | 6 +- Dragablz/DragablzDragStartedEventArgs.cs | 2 +- Dragablz/DragablzIcon.cs | 2 +- Dragablz/DragablzItem.cs | 58 +++---- Dragablz/DragablzItemEventArgs.cs | 2 +- Dragablz/DragablzItemsControl.cs | 62 ++++---- Dragablz/DragablzWindow.cs | 30 ++-- Dragablz/EmptyHeaderSizingHint.cs | 2 +- Dragablz/HeaderedDragablzItem.cs | 6 +- Dragablz/HorizontalOrganiser.cs | 2 +- Dragablz/IInterLayoutClient.cs | 2 +- Dragablz/IItemsOrganiser.cs | 2 +- Dragablz/InterTabController.cs | 2 +- Dragablz/LocationChangedEventArgs.cs | 2 +- Dragablz/LocationHint.cs | 2 +- Dragablz/PositionMonitor.cs | 4 +- Dragablz/Properties/AssemblyInfo.cs | 18 +-- Dragablz/StackOrganiser.cs | 20 +-- Dragablz/StoryboardCompletionListener.cs | 4 +- Dragablz/TabablzControl.cs | 146 +++++++++--------- Dragablz/TabablzHeaderSizeConverter.cs | 4 +- Dragablz/Themes/Ripple.cs | 10 +- Dragablz/Themes/RippleAssist.cs | 14 +- Dragablz/Trapezoid.cs | 10 +- DragablzDemo/AnotherCommandImplementation.cs | 2 +- DragablzDemo/BasicExampleMainModel.cs | 10 +- DragablzDemo/BasicExampleMainWindow.xaml.cs | 2 +- DragablzDemo/BasicExampleTemplateModel.cs | 4 +- .../BasicExampleTemplateWindow.xaml.cs | 2 +- DragablzDemo/Boot.cs | 4 +- DragablzDemo/BoundExampleInterTabClient.cs | 6 +- DragablzDemo/BoundExampleModel.cs | 10 +- DragablzDemo/BoundExampleNewItem.cs | 4 +- DragablzDemo/CustomHeaderViewModel.cs | 4 +- .../LayoutManagementExampleViewModel.cs | 4 +- DragablzDemo/Properties/Annotations.cs | 14 +- DragablzDemo/Properties/AssemblyInfo.cs | 16 +- DragablzDemo/SimpleViewModel.cs | 4 +- DragablzDemo/TabablzControlProxy.cs | 2 +- 68 files changed, 374 insertions(+), 374 deletions(-) diff --git a/Dragablz.Test/Properties/AssemblyInfo.cs b/Dragablz.Test/Properties/AssemblyInfo.cs index 1b8d52a..08b2aa4 100644 --- a/Dragablz.Test/Properties/AssemblyInfo.cs +++ b/Dragablz.Test/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Dragablz.Test")] @@ -14,8 +14,8 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,11 +25,11 @@ // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] diff --git a/Dragablz/CanvasOrganiser.cs b/Dragablz/CanvasOrganiser.cs index 65c4e92..198dc15 100644 --- a/Dragablz/CanvasOrganiser.cs +++ b/Dragablz/CanvasOrganiser.cs @@ -10,7 +10,7 @@ public class CanvasOrganiser : IItemsOrganiser { public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IEnumerable items) { - + } public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable items) @@ -31,17 +31,17 @@ public virtual void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Si public virtual void OrganiseOnDragStarted(DragablzItemsControl requestor, Size measureBounds, IEnumerable siblingItems, DragablzItem dragItem) { - + } public virtual void OrganiseOnDrag(DragablzItemsControl requestor, Size measureBounds, IEnumerable siblingItems, DragablzItem dragItem) { - + } public virtual void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable siblingItems, DragablzItem dragItem) { - + } public virtual Point ConstrainLocation(DragablzItemsControl requestor, Size measureBounds, Point itemCurrentLocation, Size itemCurrentSize, Point itemDesiredLocation, Size itemDesiredSize) diff --git a/Dragablz/Converters/BooleanAndToVisibilityConverter.cs b/Dragablz/Converters/BooleanAndToVisibilityConverter.cs index 4b66fc2..77a4d1b 100644 --- a/Dragablz/Converters/BooleanAndToVisibilityConverter.cs +++ b/Dragablz/Converters/BooleanAndToVisibilityConverter.cs @@ -12,8 +12,8 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur { if (values == null) return Visibility.Collapsed; - - return values.Select(GetBool).All(b => b) + + return values.Select(GetBool).All(b => b) ? Visibility.Visible : Visibility.Collapsed; } @@ -29,7 +29,7 @@ private static bool GetBool(object value) { return (bool)value; } - + return false; } } diff --git a/Dragablz/Converters/ShowDefaultCloseButtonConverter.cs b/Dragablz/Converters/ShowDefaultCloseButtonConverter.cs index 167a95b..8bc70c4 100644 --- a/Dragablz/Converters/ShowDefaultCloseButtonConverter.cs +++ b/Dragablz/Converters/ShowDefaultCloseButtonConverter.cs @@ -19,14 +19,14 @@ public class ShowDefaultCloseButtonConverter : IMultiValueConverter /// public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { - return ((values[0] == DependencyProperty.UnsetValue ? false : (bool)values[0]) && - (values[2] == DependencyProperty.UnsetValue ? 0 : (int)values[2]) >= + return ((values[0] == DependencyProperty.UnsetValue ? false : (bool)values[0]) && + (values[2] == DependencyProperty.UnsetValue ? 0 : (int)values[2]) >= (values[1] == DependencyProperty.UnsetValue ? 0 : (int)values[1])) ? Visibility.Visible : Visibility.Collapsed; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { - return null; + return null; } } } diff --git a/Dragablz/Core/CollectionTeaser.cs b/Dragablz/Core/CollectionTeaser.cs index 2c5a6b7..528bb9f 100644 --- a/Dragablz/Core/CollectionTeaser.cs +++ b/Dragablz/Core/CollectionTeaser.cs @@ -11,7 +11,7 @@ internal class CollectionTeaser private readonly Action _removeMethod; private CollectionTeaser(Action addMethod, Action removeMethod) - { + { _addMethod = addMethod; _removeMethod = removeMethod; } @@ -23,7 +23,7 @@ public static bool TryCreate(object items, out CollectionTeaser collectionTeaser var list = items as IList; if (list != null) { - collectionTeaser = new CollectionTeaser(i => list.Add(i), list.Remove); + collectionTeaser = new CollectionTeaser(i => list.Add(i), list.Remove); } else if (items != null) { @@ -48,7 +48,7 @@ public static bool TryCreate(object items, out CollectionTeaser collectionTeaser i => removeMethodInfo.Invoke(items, new[] {i})); } } - + return collectionTeaser != null; } diff --git a/Dragablz/Core/Extensions.cs b/Dragablz/Core/Extensions.cs index 92e2dec..3561f8c 100644 --- a/Dragablz/Core/Extensions.cs +++ b/Dragablz/Core/Extensions.cs @@ -20,14 +20,14 @@ public static IEnumerable Containers(this ItemsControl i #endif #if NET40 var fieldInfo = typeof(ItemContainerGenerator).GetField("_items", BindingFlags.NonPublic | BindingFlags.Instance); - var list = (IList)fieldInfo.GetValue(itemsControl.ItemContainerGenerator); + var list = (IList)fieldInfo.GetValue(itemsControl.ItemContainerGenerator); for (var i = 0; i < list.Count; i++) #endif { var container = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as TContainer; if (container != null) yield return container; - } + } } public static IEnumerable Except(this IEnumerable first, params TObject[] second) @@ -41,7 +41,7 @@ public static IEnumerable LogicalTreeDepthFirstTraversal(this Dependency yield return node; foreach (var child in LogicalTreeHelper.GetChildren(node).OfType() - .SelectMany(depObj => depObj.LogicalTreeDepthFirstTraversal())) + .SelectMany(depObj => depObj.LogicalTreeDepthFirstTraversal())) yield return child; } @@ -73,7 +73,7 @@ public static IEnumerable VisualTreeAncestory(this DependencyO { yield return dependencyObject; dependencyObject = VisualTreeHelper.GetParent(dependencyObject); - } + } } /// @@ -91,7 +91,7 @@ public static IEnumerable LogicalTreeAncestory(this Dependency dependencyObject = LogicalTreeHelper.GetParent(dependencyObject); } } - + /// /// Returns the actual Left of the Window independently from the WindowState /// diff --git a/Dragablz/Core/FuncComparer.cs b/Dragablz/Core/FuncComparer.cs index 1575b21..487f62f 100644 --- a/Dragablz/Core/FuncComparer.cs +++ b/Dragablz/Core/FuncComparer.cs @@ -10,7 +10,7 @@ internal class FuncComparer : IComparer public FuncComparer(Func comparer) { if (comparer == null) throw new ArgumentNullException("comparer"); - + _comparer = comparer; } diff --git a/Dragablz/Core/InterTabTransfer.cs b/Dragablz/Core/InterTabTransfer.cs index 91f2d12..2d54acb 100644 --- a/Dragablz/Core/InterTabTransfer.cs +++ b/Dragablz/Core/InterTabTransfer.cs @@ -23,7 +23,7 @@ internal class InterTabTransfer private readonly Size _itemSize; private readonly IList _floatingItemSnapShots; private readonly bool _isTransposing; - private readonly InterTabTransferReason _transferReason; + private readonly InterTabTransferReason _transferReason; public InterTabTransfer(object item, DragablzItem originatorContainer, Orientation breachOrientation, Point dragStartWindowOffset, Point dragStartItemOffset, Point itemPositionWithinHeader, Size itemSize, IList floatingItemSnapShots, bool isTransposing) { diff --git a/Dragablz/Core/MultiComparer.cs b/Dragablz/Core/MultiComparer.cs index 887771d..60b6b1c 100644 --- a/Dragablz/Core/MultiComparer.cs +++ b/Dragablz/Core/MultiComparer.cs @@ -8,7 +8,7 @@ internal class MultiComparer : IComparer { private readonly IList> _attributeComparers; - private MultiComparer(FuncComparer firstComparer) + private MultiComparer(FuncComparer firstComparer) { _attributeComparers = new List> { @@ -16,15 +16,15 @@ private MultiComparer(FuncComparer firstComparer) }; } - public static MultiComparer Ascending(Func accessor) + public static MultiComparer Ascending(Func accessor) where TAttribute : IComparable { - if (accessor == null) throw new ArgumentNullException("accessor"); + if (accessor == null) throw new ArgumentNullException("accessor"); return new MultiComparer(BuildAscendingComparer(accessor)); } - public static MultiComparer Descending(Func accessor) + public static MultiComparer Descending(Func accessor) where TAttribute : IComparable { if (accessor == null) throw new ArgumentNullException("accessor"); @@ -64,7 +64,7 @@ private static FuncComparer BuildAscendingComparer(Func((x, y) => accessor(x).CompareTo(accessor(y))); - + } private static FuncComparer BuildDescendingComparer(Func accessor) diff --git a/Dragablz/Core/Native.cs b/Dragablz/Core/Native.cs index d196ea2..3d5b04b 100644 --- a/Dragablz/Core/Native.cs +++ b/Dragablz/Core/Native.cs @@ -28,7 +28,7 @@ public struct RECT public int top; public int right; public int bottom; - } + } [DllImport("user32.dll")] private static extern bool GetCursorPos(out POINT lpPoint); @@ -58,7 +58,7 @@ public static Point GetCursorPos() public static Point ToWpf(this Point pixelPoint) { - var desktop = GetDC(IntPtr.Zero); + var desktop = GetDC(IntPtr.Zero); var dpi = GetDeviceCaps(desktop, 88); ReleaseDC(IntPtr.Zero, desktop); @@ -104,7 +104,7 @@ public struct WINDOWPLACEMENT public POINT minPosition; public POINT maxPosition; public RECT normalPosition; - } + } [DllImport("user32.dll", CharSet = CharSet.Auto)] internal static extern IntPtr SendMessage(IntPtr hWnd, WindowMessage msg, IntPtr wParam, IntPtr lParam); diff --git a/Dragablz/Core/TabHeaderDragStartInformation.cs b/Dragablz/Core/TabHeaderDragStartInformation.cs index 0a676ea..6edd409 100644 --- a/Dragablz/Core/TabHeaderDragStartInformation.cs +++ b/Dragablz/Core/TabHeaderDragStartInformation.cs @@ -6,7 +6,7 @@ internal class TabHeaderDragStartInformation { private readonly DragablzItem _dragItem; private readonly double _dragablzItemsControlHorizontalOffset; - private readonly double _dragablzItemControlVerticalOffset; + private readonly double _dragablzItemControlVerticalOffset; private readonly double _dragablzItemHorizontalOffset; private readonly double _dragablzItemVerticalOffset; diff --git a/Dragablz/DefaultInterLayoutClient.cs b/Dragablz/DefaultInterLayoutClient.cs index 8137fb4..214359d 100644 --- a/Dragablz/DefaultInterLayoutClient.cs +++ b/Dragablz/DefaultInterLayoutClient.cs @@ -7,7 +7,7 @@ namespace Dragablz { /// - /// Provides a simple implementation of , but only really useful if + /// Provides a simple implementation of , but only really useful if /// instances are specified in XAML. If you are binding via ItemsSource then /// you most likely want to create your own implementation of . /// @@ -27,7 +27,7 @@ public INewTabHost GetNewHost(object partition, TabablzControl source Partition = source.InterTabController.Partition }; Clone(source.InterTabController, newInterTabController); - tabablzControl.SetCurrentValue(TabablzControl.InterTabControllerProperty, newInterTabController); + tabablzControl.SetCurrentValue(TabablzControl.InterTabControllerProperty, newInterTabController); return new NewTabHost(tabablzControl, tabablzControl); } @@ -39,10 +39,10 @@ private static void Clone(DependencyObject from, DependencyObject to) { if (localValueEnumerator.Current.Property.ReadOnly || localValueEnumerator.Current.Value is FrameworkElement) continue; - + if (!(localValueEnumerator.Current.Value is BindingExpressionBase)) - to.SetCurrentValue(localValueEnumerator.Current.Property, localValueEnumerator.Current.Value); - } + to.SetCurrentValue(localValueEnumerator.Current.Property, localValueEnumerator.Current.Value); + } } } } \ No newline at end of file diff --git a/Dragablz/DefaultInterTabClient.cs b/Dragablz/DefaultInterTabClient.cs index 7a894b6..a9602a4 100644 --- a/Dragablz/DefaultInterTabClient.cs +++ b/Dragablz/DefaultInterTabClient.cs @@ -7,7 +7,7 @@ namespace Dragablz { public class DefaultInterTabClient : IInterTabClient - { + { public virtual INewTabHost GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source) { if (source == null) throw new ArgumentNullException("source"); @@ -23,7 +23,7 @@ public virtual INewTabHost GetNewHost(IInterTabClient interTabClient, ob if (newTabablzControl.ItemsSource == null) newTabablzControl.Items.Clear(); - return new NewTabHost(newWindow, newTabablzControl); + return new NewTabHost(newWindow, newTabablzControl); } public virtual TabEmptiedResponse TabEmptiedHandler(TabablzControl tabControl, Window window) diff --git a/Dragablz/Dockablz/Branch.cs b/Dragablz/Dockablz/Branch.cs index b836b0d..ede333a 100644 --- a/Dragablz/Dockablz/Branch.cs +++ b/Dragablz/Dockablz/Branch.cs @@ -73,7 +73,7 @@ public GridLength SecondItemLength { get { return (GridLength) GetValue(SecondItemLengthProperty); } set { SetValue(SecondItemLengthProperty, value); } - } + } /// /// Gets the proportional size of the first item, between 0 and 1, where 1 would represent the entire size of the branch. diff --git a/Dragablz/Dockablz/BranchAccessor.cs b/Dragablz/Dockablz/BranchAccessor.cs index dc2dcae..6f93eee 100644 --- a/Dragablz/Dockablz/BranchAccessor.cs +++ b/Dragablz/Dockablz/BranchAccessor.cs @@ -7,7 +7,7 @@ using Dragablz.Core; namespace Dragablz.Dockablz -{ +{ public class BranchAccessor { private readonly Branch _branch; @@ -28,7 +28,7 @@ public BranchAccessor(Branch branch) else _firstItemTabablzControl = FindTabablzControl(branch.FirstItem, branch.FirstContentPresenter); - var secondChildBranch = branch.SecondItem as Branch; + var secondChildBranch = branch.SecondItem as Branch; if (secondChildBranch != null) _secondItemBranchAccessor = new BranchAccessor(secondChildBranch); else @@ -68,7 +68,7 @@ public TabablzControl SecondItemTabablzControl /// /// Visits the content of the first or second side of a branch, according to its content type. No more than one of the provided - /// callbacks will be called. + /// callbacks will be called. /// /// /// @@ -107,7 +107,7 @@ public BranchAccessor Visit(BranchItem childItem, childBranchVisitor(branchDescription); return this; } - + var tabablzControl = tabGetter(); if (tabablzControl != null) { @@ -125,5 +125,5 @@ public BranchAccessor Visit(BranchItem childItem, return this; } - } + } } diff --git a/Dragablz/Dockablz/BranchResult.cs b/Dragablz/Dockablz/BranchResult.cs index 240d020..50a6242 100644 --- a/Dragablz/Dockablz/BranchResult.cs +++ b/Dragablz/Dockablz/BranchResult.cs @@ -11,7 +11,7 @@ public BranchResult(Branch branch, TabablzControl tabablzControl) { if (branch == null) throw new ArgumentNullException("branch"); if (tabablzControl == null) throw new ArgumentNullException("tabablzControl"); - + _branch = branch; _tabablzControl = tabablzControl; } diff --git a/Dragablz/Dockablz/DropZone.cs b/Dragablz/Dockablz/DropZone.cs index 19f9210..c7e10ba 100644 --- a/Dragablz/Dockablz/DropZone.cs +++ b/Dragablz/Dockablz/DropZone.cs @@ -7,7 +7,7 @@ public class DropZone : Control { static DropZone() { - DefaultStyleKeyProperty.OverrideMetadata(typeof(DropZone), new FrameworkPropertyMetadata(typeof(DropZone))); + DefaultStyleKeyProperty.OverrideMetadata(typeof(DropZone), new FrameworkPropertyMetadata(typeof(DropZone))); } public static readonly DependencyProperty LocationProperty = DependencyProperty.Register( diff --git a/Dragablz/Dockablz/DropZoneLocation.cs b/Dragablz/Dockablz/DropZoneLocation.cs index 1975b06..2c5c26c 100644 --- a/Dragablz/Dockablz/DropZoneLocation.cs +++ b/Dragablz/Dockablz/DropZoneLocation.cs @@ -1,11 +1,11 @@ namespace Dragablz.Dockablz { public enum DropZoneLocation - { + { Top, Right, Bottom, - Left, + Left, Floating } } \ No newline at end of file diff --git a/Dragablz/Dockablz/Finder.cs b/Dragablz/Dockablz/Finder.cs index 3c8f8de..c7d5056 100644 --- a/Dragablz/Dockablz/Finder.cs +++ b/Dragablz/Dockablz/Finder.cs @@ -8,7 +8,7 @@ internal static LocationReport Find(TabablzControl tabablzControl) { if (tabablzControl == null) throw new ArgumentNullException("tabablzControl"); - var locationReportBuilder = new LocationReportBuilder(tabablzControl); + var locationReportBuilder = new LocationReportBuilder(tabablzControl); foreach (var loadedInstance in Layout.GetLoadedInstances()) { @@ -41,7 +41,7 @@ private static void BranchVisitor(LocationReportBuilder locationReportBuilder, B branchAccessor.Visit(BranchItem.First, ba => BranchVisitor(locationReportBuilder, ba)); if (locationReportBuilder.IsFound) return; branchAccessor.Visit(BranchItem.Second, ba => BranchVisitor(locationReportBuilder, ba)); - } + } } private static void TabablzControlVisitor(LocationReportBuilder locationReportBuilder, TabablzControl tabablzControl) diff --git a/Dragablz/Dockablz/FloatRequestedEvent.cs b/Dragablz/Dockablz/FloatRequestedEvent.cs index c291e13..6e73a0b 100644 --- a/Dragablz/Dockablz/FloatRequestedEvent.cs +++ b/Dragablz/Dockablz/FloatRequestedEvent.cs @@ -11,11 +11,11 @@ namespace Dragablz.Dockablz public class FloatRequestedEventArgs : DragablzItemEventArgs { - public FloatRequestedEventArgs(RoutedEvent routedEvent, object source, DragablzItem dragablzItem) + public FloatRequestedEventArgs(RoutedEvent routedEvent, object source, DragablzItem dragablzItem) : base(routedEvent, source, dragablzItem) { } - public FloatRequestedEventArgs(RoutedEvent routedEvent, DragablzItem dragablzItem) + public FloatRequestedEventArgs(RoutedEvent routedEvent, DragablzItem dragablzItem) : base(routedEvent, dragablzItem) { } } diff --git a/Dragablz/Dockablz/FloatTransfer.cs b/Dragablz/Dockablz/FloatTransfer.cs index a35afa0..a3a155b 100644 --- a/Dragablz/Dockablz/FloatTransfer.cs +++ b/Dragablz/Dockablz/FloatTransfer.cs @@ -11,7 +11,7 @@ internal class FloatTransfer public FloatTransfer(double width, double height, object content) { if (content == null) throw new ArgumentNullException("content"); - + _width = width; _height = height; _content = content; diff --git a/Dragablz/Dockablz/FloatingItemSnapShot.cs b/Dragablz/Dockablz/FloatingItemSnapShot.cs index 1691e96..11311d0 100644 --- a/Dragablz/Dockablz/FloatingItemSnapShot.cs +++ b/Dragablz/Dockablz/FloatingItemSnapShot.cs @@ -10,7 +10,7 @@ namespace Dragablz.Dockablz { /// /// experimentational. might have to puish this back to mvvm only - /// + /// internal class FloatingItemSnapShot { private readonly object _content; @@ -33,8 +33,8 @@ public static FloatingItemSnapShot Take(DragablzItem dragablzItem) if (dragablzItem == null) throw new ArgumentNullException("dragablzItem"); return new FloatingItemSnapShot( - dragablzItem.Content, - new Rect(dragablzItem.X, dragablzItem.Y, dragablzItem.ActualWidth, dragablzItem.ActualHeight), + dragablzItem.Content, + new Rect(dragablzItem.X, dragablzItem.Y, dragablzItem.ActualWidth, dragablzItem.ActualHeight), Panel.GetZIndex(dragablzItem), Layout.GetFloatingItemState(dragablzItem)); } diff --git a/Dragablz/Dockablz/Layout.cs b/Dragablz/Dockablz/Layout.cs index e86e89a..78ce87b 100644 --- a/Dragablz/Dockablz/Layout.cs +++ b/Dragablz/Dockablz/Layout.cs @@ -31,7 +31,7 @@ public class Layout : ContentControl private const string LeftDropZonePartName = "PART_LeftDropZone"; private const string FloatingDropZonePartName = "PART_FloatDropZone"; private const string FloatingContentPresenterPartName = "PART_FloatContentPresenter"; - + private readonly IDictionary _dropZones = new Dictionary(); private static Tuple _currentlyOfferedDropZone; @@ -42,7 +42,7 @@ public class Layout : ContentControl public static RoutedCommand TileFloatingItemsCommand = new RoutedCommand(); public static RoutedCommand TileFloatingItemsVerticallyCommand = new RoutedCommand(); public static RoutedCommand TileFloatingItemsHorizontallyCommand = new RoutedCommand(); - + private readonly DragablzItemsControl _floatingItems; private static bool _isDragOpWireUpPending; private FloatTransfer _floatTransfer; @@ -50,11 +50,11 @@ public class Layout : ContentControl static Layout() { DefaultStyleKeyProperty.OverrideMetadata(typeof(Layout), new FrameworkPropertyMetadata(typeof(Layout))); - + EventManager.RegisterClassHandler(typeof(DragablzItem), DragablzItem.DragStarted, new DragablzDragStartedEventHandler(ItemDragStarted)); - EventManager.RegisterClassHandler(typeof(DragablzItem), DragablzItem.PreviewDragDelta, new DragablzDragDeltaEventHandler(PreviewItemDragDelta), true); - EventManager.RegisterClassHandler(typeof(DragablzItem), DragablzItem.DragCompleted, new DragablzDragCompletedEventHandler(ItemDragCompleted)); - } + EventManager.RegisterClassHandler(typeof(DragablzItem), DragablzItem.PreviewDragDelta, new DragablzDragDeltaEventHandler(PreviewItemDragDelta), true); + EventManager.RegisterClassHandler(typeof(DragablzItem), DragablzItem.DragCompleted, new DragablzDragCompletedEventHandler(ItemDragCompleted)); + } public Layout() { @@ -63,7 +63,7 @@ public Layout() LoadedLayouts.Add(this); MarkTopLeftItem(this); }; - Unloaded += (sender, args) => LoadedLayouts.Remove(this); + Unloaded += (sender, args) => LoadedLayouts.Remove(this); CommandBindings.Add(new CommandBinding(UnfloatItemCommand, UnfloatExecuted, CanExecuteUnfloat)); CommandBindings.Add(new CommandBinding(MaximiseFloatingItem, MaximiseFloatingItemExecuted, CanExecuteMaximiseFloatingItem)); @@ -72,7 +72,7 @@ public Layout() CommandBindings.Add(new CommandBinding(TileFloatingItemsCommand, TileFloatingItemsExecuted)); CommandBindings.Add(new CommandBinding(TileFloatingItemsCommand, TileFloatingItemsExecuted)); CommandBindings.Add(new CommandBinding(TileFloatingItemsVerticallyCommand, TileFloatingItemsVerticallyExecuted)); - CommandBindings.Add(new CommandBinding(TileFloatingItemsHorizontallyCommand, TileFloatingItemsHorizontallyExecuted)); + CommandBindings.Add(new CommandBinding(TileFloatingItemsHorizontallyCommand, TileFloatingItemsHorizontallyExecuted)); //TODO bad bad behaviour. Pick up this from the template. _floatingItems = new DragablzItemsControl @@ -90,7 +90,7 @@ public Layout() var floatingItemTemplateBinding = new Binding("FloatingItemTemplate") { Source = this }; _floatingItems.SetBinding(ItemsControl.ItemTemplateProperty, floatingItemTemplateBinding); var floatingItemTemplateSelectorBinding = new Binding("FloatingItemTemplateSelector") { Source = this }; - _floatingItems.SetBinding(ItemsControl.ItemTemplateSelectorProperty, floatingItemTemplateSelectorBinding); + _floatingItems.SetBinding(ItemsControl.ItemTemplateSelectorProperty, floatingItemTemplateSelectorBinding); var floatingItemContainerStyeBinding = new Binding("FloatingItemContainerStyle") { Source = this }; _floatingItems.SetBinding(ItemsControl.ItemContainerStyleProperty, floatingItemContainerStyeBinding); var floatingItemContainerStyleSelectorBinding = new Binding("FloatingItemContainerStyleSelector") { Source = this }; @@ -104,7 +104,7 @@ public Layout() public static IEnumerable GetLoadedInstances() { return LoadedLayouts.ToList(); - } + } /// /// Finds the location of a tab control withing a layout. @@ -115,7 +115,7 @@ public static LocationReport Find(TabablzControl tabablzControl) { if (tabablzControl == null) throw new ArgumentNullException("tabablzControl"); - return Finder.Find(tabablzControl); + return Finder.Find(tabablzControl); } /// @@ -191,7 +191,7 @@ public static BranchResult Branch(TabablzControl tabablzControl, TabablzControl DispatcherPriority.Loaded); return branchResult; - } + } /// /// Use in conjuction with the on a @@ -210,8 +210,8 @@ public IInterLayoutClient InterLayoutClient internal static bool IsContainedWithinBranch(DependencyObject dependencyObject) { - do - { + do + { dependencyObject = VisualTreeHelper.GetParent(dependencyObject); if (dependencyObject is Branch) return true; @@ -403,7 +403,7 @@ public static bool GetIsTopLeftItem(DependencyObject element) /// When overridden in a derived class, is invoked whenever application code or internal processes call . public override void OnApplyTemplate() - { + { base.OnApplyTemplate(); var floatingItemsContentPresenter = GetTemplateChild(FloatingContentPresenterPartName) as ContentPresenter; @@ -438,7 +438,7 @@ internal static void RestoreFloatingItemSnapShots(DependencyObject ancestor, IEn private static void ItemDragStarted(object sender, DragablzDragStartedEventArgs e) { //we wait until drag is in full flow so we know the partition has been setup by the owning tab control - _isDragOpWireUpPending = true; + _isDragOpWireUpPending = true; } private static void SetupParticipatingLayouts(DragablzItem dragablzItem) @@ -464,7 +464,7 @@ private void MonitorDropZones(Point cursorPos) if (myWindow == null) return; foreach (var dropZone in _dropZones.Values.Where(dz => dz != null)) - { + { var pointFromScreen = myWindow.PointFromScreen(cursorPos); var pointRelativeToDropZone = myWindow.TranslatePoint(pointFromScreen, dropZone); var inputHitTest = dropZone.InputHitTest(pointRelativeToDropZone); @@ -491,18 +491,18 @@ private static bool TryGetSourceTabControl(DragablzItem dragablzItem, out Tababl if (sourceOfDragItemsControl == null) throw new ApplicationException("Unable to determine source items control."); tabablzControl = TabablzControl.GetOwnerOfHeaderItems(sourceOfDragItemsControl); - + return tabablzControl != null; } private void Branch(DropZoneLocation location, DragablzItem sourceDragablzItem) { if (InterLayoutClient == null) - throw new InvalidOperationException("InterLayoutClient is not set."); + throw new InvalidOperationException("InterLayoutClient is not set."); var sourceOfDragItemsControl = ItemsControl.ItemsControlFromItemContainer(sourceDragablzItem) as DragablzItemsControl; if (sourceOfDragItemsControl == null) throw new ApplicationException("Unable to determin source items control."); - + var sourceTabControl = TabablzControl.GetOwnerOfHeaderItems(sourceOfDragItemsControl); if (sourceTabControl == null) throw new ApplicationException("Unable to determin source tab control."); @@ -536,7 +536,7 @@ private void Branch(DropZoneLocation location, DragablzItem sourceDragablzItem) newContent = new ContentControl { Content = new object(), - ContentTemplate = BranchTemplate, + ContentTemplate = BranchTemplate, }; ((ContentControl) newContent).Dispatcher.BeginInvoke(new Action(() => { @@ -548,9 +548,9 @@ private void Branch(DropZoneLocation location, DragablzItem sourceDragablzItem) newTabControl.AddToSource(sourceItem); newTabControl.SelectedItem = sourceItem; Dispatcher.BeginInvoke(new Action(() => RestoreFloatingItemSnapShots(newTabControl, floatingItemSnapShots)), DispatcherPriority.Loaded); - }), DispatcherPriority.Loaded); + }), DispatcherPriority.Loaded); } - + if (location == DropZoneLocation.Right || location == DropZoneLocation.Bottom) { branchItem.FirstItem = Content; @@ -564,7 +564,7 @@ private void Branch(DropZoneLocation location, DragablzItem sourceDragablzItem) SetCurrentValue(ContentProperty, branchItem); - Dispatcher.BeginInvoke(new Action(() => MarkTopLeftItem(this)), DispatcherPriority.Loaded); + Dispatcher.BeginInvoke(new Action(() => MarkTopLeftItem(this)), DispatcherPriority.Loaded); } internal static bool ConsolidateBranch(DependencyObject redundantNode) @@ -586,7 +586,7 @@ internal static bool ConsolidateBranch(DependencyObject redundantNode) return true; } - var branch = (Branch) grandParent; + var branch = (Branch) grandParent; if (isSecondLineageWhenOwnerIsBranch) branch.SecondItem = survivingItem; else @@ -601,22 +601,22 @@ internal static bool ConsolidateBranch(DependencyObject redundantNode) private static object FindLayoutOrBranchOwner(DependencyObject node, out bool isSecondLineageWhenOwnerIsBranch) { isSecondLineageWhenOwnerIsBranch = false; - + var ancestoryStack = new Stack(); do { ancestoryStack.Push(node); node = VisualTreeHelper.GetParent(node); - if (node is Layout) + if (node is Layout) return node; - + var branch = node as Branch; if (branch == null) continue; isSecondLineageWhenOwnerIsBranch = ancestoryStack.Contains(branch.SecondContentPresenter); return branch; - } while (node != null); + } while (node != null); return null; } @@ -626,13 +626,13 @@ private static BranchResult Branch(Orientation orientation, double proportion, b var branchItem = new Branch { Orientation = orientation - }; - + }; + var newContent = new ContentControl { Content = newSibling ?? new object(), ContentTemplate = branchTemplate, - }; + }; if (!makeSecond) { @@ -689,21 +689,21 @@ private static void ItemDragCompleted(object sender, DragablzDragCompletedEventA private static void Float(Layout layout, DragablzItem dragablzItem) { - //TODO we need eq of IManualInterTabClient here, so consumer can control this op'. + //TODO we need eq of IManualInterTabClient here, so consumer can control this op'. //remove from source var sourceOfDragItemsControl = ItemsControl.ItemsControlFromItemContainer(dragablzItem) as DragablzItemsControl; - if (sourceOfDragItemsControl == null) throw new ApplicationException("Unable to determin source items control."); + if (sourceOfDragItemsControl == null) throw new ApplicationException("Unable to determin source items control."); var sourceTabControl = TabablzControl.GetOwnerOfHeaderItems(sourceOfDragItemsControl); layout._floatTransfer = FloatTransfer.TakeSnapshot(dragablzItem, sourceTabControl); var floatingItemSnapShots = sourceTabControl.VisualTreeDepthFirstTraversal() .OfType() .SelectMany(l => l.FloatingDragablzItems().Select(FloatingItemSnapShot.Take)) .ToList(); - if (sourceTabControl == null) throw new ApplicationException("Unable to determin source tab control."); + if (sourceTabControl == null) throw new ApplicationException("Unable to determin source tab control."); sourceTabControl.RemoveItem(dragablzItem); - - //add to float layer + + //add to float layer CollectionTeaser collectionTeaser; if (CollectionTeaser.TryCreate(layout.FloatingItemsSource, out collectionTeaser)) collectionTeaser.Add(layout._floatTransfer.Content); @@ -724,10 +724,10 @@ private static void PreviewItemDragDelta(object sender, DragablzDragDeltaEventAr } foreach (var layout in LoadedLayouts.Where(l => l.IsParticipatingInDrag)) - { + { var cursorPos = Native.GetCursorPos(); layout.MonitorDropZones(cursorPos); - } + } } private void PrepareFloatingContainerForItemOverride(DependencyObject dependencyObject, object o) @@ -761,8 +761,8 @@ private void PrepareFloatingContainerForItemOverride(DependencyObject dependency dragablzItem.SetCurrentValue(DragablzItem.YProperty, _floatingItems.ActualHeight/2 - newHeight/2); dragablzItem.SetCurrentValue(WidthProperty, newWidth); dragablzItem.SetCurrentValue(HeightProperty, newHeight); - }), DispatcherPriority.Loaded); - + }), DispatcherPriority.Loaded); + _floatTransfer = null; } @@ -883,7 +883,7 @@ private static void MaximiseFloatingItemExecuted(object sender, ExecutedRoutedEv { var dragablzItem = e.Parameter as DragablzItem; if (dragablzItem == null) return; - + SetLocationSnapShot(dragablzItem, LocationSnapShot.Take(dragablzItem)); SetFloatingItemState(dragablzItem, WindowState.Maximized); } @@ -892,11 +892,11 @@ private static void RestoreFloatingItemExecuted(object sender, ExecutedRoutedEve { var dragablzItem = e.Parameter as DragablzItem; if (dragablzItem == null) return; - + SetFloatingItemState(dragablzItem, WindowState.Normal); var locationSnapShot = GetLocationSnapShot(dragablzItem); if (locationSnapShot != null) - locationSnapShot.Apply(dragablzItem); + locationSnapShot.Apply(dragablzItem); } private bool IsHostingTab() @@ -931,15 +931,15 @@ private void CanExecuteUnfloat(object sender, CanExecuteRoutedEventArgs canExecu canExecuteRoutedEventArgs.CanExecute = IsHostingTab(); canExecuteRoutedEventArgs.ContinueRouting = false; canExecuteRoutedEventArgs.Handled = true; - } + } private void UnfloatExecuted(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs) { var dragablzItem = executedRoutedEventArgs.Parameter as DragablzItem; if (dragablzItem == null) return; - + var exemplarTabControl = this.VisualTreeDepthFirstTraversal().OfType() - .FirstOrDefault(t => t.InterTabController != null && t.InterTabController.Partition == Partition); + .FirstOrDefault(t => t.InterTabController != null && t.InterTabController.Partition == Partition); if (exemplarTabControl == null) return; @@ -969,9 +969,9 @@ private void UnfloatExecuted(object sender, ExecutedRoutedEventArgs executedRout newTabHost.Container.Height = myWindow.RestoreBounds.Height; newTabHost.Container.Left = myWindow.Left + 20; - newTabHost.Container.Top = myWindow.Top + 20; + newTabHost.Container.Top = myWindow.Top + 20; - Dispatcher.BeginInvoke(new Action(() => + Dispatcher.BeginInvoke(new Action(() => { newTabHost.TabablzControl.AddToSource(content); newTabHost.TabablzControl.SelectedItem = content; @@ -980,7 +980,7 @@ private void UnfloatExecuted(object sender, ExecutedRoutedEventArgs executedRout Dispatcher.BeginInvoke( new Action(() => RestoreFloatingItemSnapShots(newTabHost.TabablzControl, floatingItemSnapShots))); - }), DispatcherPriority.DataBind); + }), DispatcherPriority.DataBind); } } } \ No newline at end of file diff --git a/Dragablz/Dockablz/LayoutAccessor.cs b/Dragablz/Dockablz/LayoutAccessor.cs index 002538c..3b509d3 100644 --- a/Dragablz/Dockablz/LayoutAccessor.cs +++ b/Dragablz/Dockablz/LayoutAccessor.cs @@ -15,14 +15,14 @@ public class LayoutAccessor public LayoutAccessor(Layout layout) { if (layout == null) throw new ArgumentNullException("layout"); - + _layout = layout; var branch = Layout.Content as Branch; if (branch != null) _branchAccessor = new BranchAccessor(branch); - else - _tabablzControl = Layout.Content as TabablzControl; + else + _tabablzControl = Layout.Content as TabablzControl; } public Layout Layout @@ -53,8 +53,8 @@ public TabablzControl TabablzControl /// /// Visits the content of the layout, according to its content type. No more than one of the provided - /// callbacks will be called. - /// + /// callbacks will be called. + /// public LayoutAccessor Visit( Action branchVisitor = null, Action tabablzControlVisitor = null, @@ -66,7 +66,7 @@ public LayoutAccessor Visit( { branchVisitor(_branchAccessor); } - + return this; } diff --git a/Dragablz/Dockablz/LocationSnapShot.cs b/Dragablz/Dockablz/LocationSnapShot.cs index 3a5a51e..6523ee3 100644 --- a/Dragablz/Dockablz/LocationSnapShot.cs +++ b/Dragablz/Dockablz/LocationSnapShot.cs @@ -17,7 +17,7 @@ internal class LocationSnapShot public static LocationSnapShot Take(FrameworkElement frameworkElement) { if (frameworkElement == null) throw new ArgumentNullException("frameworkElement"); - + return new LocationSnapShot(frameworkElement.Width, frameworkElement.Height); } @@ -30,7 +30,7 @@ private LocationSnapShot(double width, double height) public void Apply(FrameworkElement frameworkElement) { if (frameworkElement == null) throw new ArgumentNullException("frameworkElement"); - + frameworkElement.SetCurrentValue(FrameworkElement.WidthProperty, _width); frameworkElement.SetCurrentValue(FrameworkElement.HeightProperty, _height); } diff --git a/Dragablz/Dockablz/Tiler.cs b/Dragablz/Dockablz/Tiler.cs index a99bf3c..5854d3d 100644 --- a/Dragablz/Dockablz/Tiler.cs +++ b/Dragablz/Dockablz/Tiler.cs @@ -14,7 +14,7 @@ internal class Tiler { public static void Tile(IEnumerable dragablzItems, Size bounds) { - if (dragablzItems == null) throw new ArgumentNullException("dragablzItems"); + if (dragablzItems == null) throw new ArgumentNullException("dragablzItems"); var items = new Queue(dragablzItems.OrderBy(Panel.GetZIndex)); diff --git a/Dragablz/Dockablz/TilerCalculator.cs b/Dragablz/Dockablz/TilerCalculator.cs index c64b8fd..5c38883 100644 --- a/Dragablz/Dockablz/TilerCalculator.cs +++ b/Dragablz/Dockablz/TilerCalculator.cs @@ -11,7 +11,7 @@ public static int[] GetCellCountPerColumn(int totalCells) if (totalCells == 2) return new[] {1, 1}; - var sqrt = Math.Sqrt(totalCells); + var sqrt = Math.Sqrt(totalCells); if (unchecked(sqrt == (int) sqrt)) return Enumerable.Repeat((int) sqrt, (int) sqrt).ToArray(); diff --git a/Dragablz/DragablzColors.cs b/Dragablz/DragablzColors.cs index 0f02b7b..12eb0ad 100644 --- a/Dragablz/DragablzColors.cs +++ b/Dragablz/DragablzColors.cs @@ -68,7 +68,7 @@ private static byte BlendColorChannel(double channel1, double channel2, double c { var buff = channel1 + (channel2 - channel1) * channel2Percentage / 100D; return Math.Min((byte)Math.Round(buff), (byte)255); - } - + } + } } \ No newline at end of file diff --git a/Dragablz/DragablzDragCompletedEventArgs.cs b/Dragablz/DragablzDragCompletedEventArgs.cs index 325f9ff..b4bf35a 100644 --- a/Dragablz/DragablzDragCompletedEventArgs.cs +++ b/Dragablz/DragablzDragCompletedEventArgs.cs @@ -16,7 +16,7 @@ public DragablzDragCompletedEventArgs(DragablzItem dragablzItem, DragCompletedEv { if (dragablzItem == null) throw new ArgumentNullException("dragablzItem"); if (dragCompletedEventArgs == null) throw new ArgumentNullException("dragCompletedEventArgs"); - + _dragablzItem = dragablzItem; _dragCompletedEventArgs = dragCompletedEventArgs; } @@ -27,7 +27,7 @@ public DragablzDragCompletedEventArgs(RoutedEvent routedEvent, DragablzItem drag if (dragablzItem == null) throw new ArgumentNullException("dragablzItem"); if (dragCompletedEventArgs == null) throw new ArgumentNullException("dragCompletedEventArgs"); - _dragablzItem = dragablzItem; + _dragablzItem = dragablzItem; _dragCompletedEventArgs = dragCompletedEventArgs; } @@ -49,6 +49,6 @@ public DragablzItem DragablzItem public DragCompletedEventArgs DragCompletedEventArgs { get { return _dragCompletedEventArgs; } - } + } } } \ No newline at end of file diff --git a/Dragablz/DragablzDragDeltaEventArgs.cs b/Dragablz/DragablzDragDeltaEventArgs.cs index 316ba26..3e4ad36 100644 --- a/Dragablz/DragablzDragDeltaEventArgs.cs +++ b/Dragablz/DragablzDragDeltaEventArgs.cs @@ -18,7 +18,7 @@ public DragablzDragDeltaEventArgs(DragablzItem dragablzItem, DragDeltaEventArgs _dragDeltaEventArgs = dragDeltaEventArgs; } - public DragablzDragDeltaEventArgs(RoutedEvent routedEvent, DragablzItem dragablzItem, DragDeltaEventArgs dragDeltaEventArgs) + public DragablzDragDeltaEventArgs(RoutedEvent routedEvent, DragablzItem dragablzItem, DragDeltaEventArgs dragDeltaEventArgs) : base(routedEvent, dragablzItem) { if (dragDeltaEventArgs == null) throw new ArgumentNullException("dragDeltaEventArgs"); @@ -26,7 +26,7 @@ public DragablzDragDeltaEventArgs(RoutedEvent routedEvent, DragablzItem dragablz _dragDeltaEventArgs = dragDeltaEventArgs; } - public DragablzDragDeltaEventArgs(RoutedEvent routedEvent, object source, DragablzItem dragablzItem, DragDeltaEventArgs dragDeltaEventArgs) + public DragablzDragDeltaEventArgs(RoutedEvent routedEvent, object source, DragablzItem dragablzItem, DragDeltaEventArgs dragDeltaEventArgs) : base(routedEvent, source, dragablzItem) { if (dragDeltaEventArgs == null) throw new ArgumentNullException("dragDeltaEventArgs"); @@ -39,6 +39,6 @@ public DragDeltaEventArgs DragDeltaEventArgs get { return _dragDeltaEventArgs; } } - public bool Cancel { get; set; } + public bool Cancel { get; set; } } } \ No newline at end of file diff --git a/Dragablz/DragablzDragStartedEventArgs.cs b/Dragablz/DragablzDragStartedEventArgs.cs index 60e1fd0..dfa6196 100644 --- a/Dragablz/DragablzDragStartedEventArgs.cs +++ b/Dragablz/DragablzDragStartedEventArgs.cs @@ -33,6 +33,6 @@ public DragablzDragStartedEventArgs(RoutedEvent routedEvent, object source, Drag public DragStartedEventArgs DragStartedEventArgs { get { return _dragStartedEventArgs; } - } + } } } \ No newline at end of file diff --git a/Dragablz/DragablzIcon.cs b/Dragablz/DragablzIcon.cs index 524570a..2594760 100644 --- a/Dragablz/DragablzIcon.cs +++ b/Dragablz/DragablzIcon.cs @@ -14,7 +14,7 @@ using System.Windows.Shapes; namespace Dragablz -{ +{ public class DragablzIcon : Control { static DragablzIcon() diff --git a/Dragablz/DragablzItem.cs b/Dragablz/DragablzItem.cs index 7511d43..ddefbca 100644 --- a/Dragablz/DragablzItem.cs +++ b/Dragablz/DragablzItem.cs @@ -39,12 +39,12 @@ public class DragablzItem : ContentControl static DragablzItem() { - DefaultStyleKeyProperty.OverrideMetadata(typeof(DragablzItem), new FrameworkPropertyMetadata(typeof(DragablzItem))); + DefaultStyleKeyProperty.OverrideMetadata(typeof(DragablzItem), new FrameworkPropertyMetadata(typeof(DragablzItem))); } public DragablzItem() { - AddHandler(MouseDownEvent, new RoutedEventHandler(MouseDownHandler), true); + AddHandler(MouseDownEvent, new RoutedEventHandler(MouseDownHandler), true); } public static readonly DependencyProperty XProperty = DependencyProperty.Register( @@ -71,7 +71,7 @@ public event RoutedPropertyChangedEventHandler XChanged private static void OnXChanged( DependencyObject d, DependencyPropertyChangedEventArgs e) - { + { var instance = (DragablzItem)d; var args = new RoutedPropertyChangedEventArgs( (double)e.OldValue, @@ -79,8 +79,8 @@ private static void OnXChanged( { RoutedEvent = XChangedEvent }; - instance.RaiseEvent(args); - } + instance.RaiseEvent(args); + } public static readonly DependencyProperty YProperty = DependencyProperty.Register( "Y", typeof (double), typeof (DragablzItem), new PropertyMetadata(default(double), OnYChanged)); @@ -155,7 +155,7 @@ private static void OnLogicalIndexChanged( RoutedEvent = DragablzItem.LogicalIndexChangedEvent }; instance.RaiseEvent(args); - } + } public static readonly DependencyProperty SizeGripProperty = DependencyProperty.RegisterAttached( "SizeGrip", typeof (SizeGrip), typeof (DragablzItem), new PropertyMetadata(default(SizeGrip), SizeGripPropertyChangedCallback)); @@ -179,7 +179,7 @@ private static void SizeThumbOnDragDelta(object sender, DragDeltaEventArgs dragD var x = dragablzItem.X; var y = dragablzItem.Y; switch (sizeGrip) - { + { case SizeGrip.NotApplicable: break; case SizeGrip.Left: @@ -193,7 +193,7 @@ private static void SizeThumbOnDragDelta(object sender, DragDeltaEventArgs dragD y += dragDeltaEventArgs.VerticalChange; break; case SizeGrip.Top: - height += -dragDeltaEventArgs.VerticalChange; + height += -dragDeltaEventArgs.VerticalChange; y += dragDeltaEventArgs.VerticalChange; break; case SizeGrip.TopRight: @@ -360,7 +360,7 @@ private static void OnIsSiblingDraggingChanged( RoutedEvent = IsSiblingDraggingChangedEvent }; instance.RaiseEvent(args); - } + } public static readonly RoutedEvent DragStarted = EventManager.RegisterRoutedEvent( @@ -370,7 +370,7 @@ private static void OnIsSiblingDraggingChanged( typeof(DragablzItem)); protected void OnDragStarted(DragablzDragStartedEventArgs e) - { + { RaiseEvent(e); } @@ -382,8 +382,8 @@ protected void OnDragStarted(DragablzDragStartedEventArgs e) typeof (DragablzItem)); protected void OnDragDelta(DragablzDragDeltaEventArgs e) - { - RaiseEvent(e); + { + RaiseEvent(e); } public static readonly RoutedEvent PreviewDragDelta = @@ -394,7 +394,7 @@ protected void OnDragDelta(DragablzDragDeltaEventArgs e) typeof(DragablzItem)); protected void OnPreviewDragDelta(DragablzDragDeltaEventArgs e) - { + { RaiseEvent(e); } @@ -436,7 +436,7 @@ private static void IsCustomThumbPropertyChangedCallback(DependencyObject depend ApplyCustomThumbSetting(thumb); else thumb.Loaded += CustomThumbOnLoaded; - } + } /// /// templates contain a thumb, which is used to drag the item around. @@ -458,11 +458,11 @@ public static bool GetIsCustomThumb(Thumb element) private bool _isTemplateThumbWithMouseAfterSeize = false; public override void OnApplyTemplate() { - base.OnApplyTemplate(); - + base.OnApplyTemplate(); + var thumbAndSubscription = SelectAndSubscribeToThumb(); _templateSubscriptions.Disposable = thumbAndSubscription.Item2; - + if (_seizeDragWithTemplate && thumbAndSubscription.Item1 != null) { _isTemplateThumbWithMouseAfterSeize = true; @@ -479,7 +479,7 @@ public override void OnApplyTemplate() } protected override void OnPreviewMouseRightButtonDown(MouseButtonEventArgs e) - { + { if (_thumb != null) { var currentThumbIsHitTestVisible = _thumb.IsHitTestVisible; @@ -492,8 +492,8 @@ protected override void OnPreviewMouseRightButtonDown(MouseButtonEventArgs e) else { _rightMouseUpCleanUpDisposable.Disposable = Disposable.Empty; - } - + } + base.OnPreviewMouseRightButtonDown(e); } @@ -515,7 +515,7 @@ internal void InstigateDrag(Action continuation) var thumb = GetTemplateChild(ThumbPartName) as Thumb; if (thumb != null) { - thumb.CaptureMouse(); + thumb.CaptureMouse(); } else _seizeDragWithTemplate = true; @@ -528,17 +528,17 @@ internal void InstigateDrag(Action continuation) internal bool IsDropTargetFound { get; set; } private void ThumbOnDragCompleted(object sender, DragCompletedEventArgs dragCompletedEventArgs) - { + { OnDragCompleted(dragCompletedEventArgs); MouseAtDragStart = new Point(); - } + } private void ThumbOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs) { var thumb = (Thumb) sender; var previewEventArgs = new DragablzDragDeltaEventArgs(PreviewDragDelta, this, dragDeltaEventArgs); - OnPreviewDragDelta(previewEventArgs); + OnPreviewDragDelta(previewEventArgs); if (previewEventArgs.Cancel) thumb.CancelDrag(); if (!previewEventArgs.Handled) @@ -549,11 +549,11 @@ private void ThumbOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventAr thumb.CancelDrag(); } } - + private void ThumbOnDragStarted(object sender, DragStartedEventArgs dragStartedEventArgs) { MouseAtDragStart = Mouse.GetPosition(this); - OnDragStarted(new DragablzDragStartedEventArgs(DragStarted, this, dragStartedEventArgs)); + OnDragStarted(new DragablzDragStartedEventArgs(DragStarted, this, dragStartedEventArgs)); } private void MouseDownHandler(object sender, RoutedEventArgs routedEventArgs) @@ -571,10 +571,10 @@ private static void CustomThumbOnLoaded(object sender, RoutedEventArgs routedEve private Thumb FindCustomThumb() { return this.VisualTreeDepthFirstTraversal().OfType().FirstOrDefault(GetIsCustomThumb); - } + } private static void ApplyCustomThumbSetting(Thumb thumb) - { + { var dragablzItem = thumb.VisualTreeAncestory().OfType().FirstOrDefault(); if (dragablzItem == null) throw new ApplicationException("Cannot find parent DragablzItem for custom thumb"); @@ -592,7 +592,7 @@ private Tuple SelectAndSubscribeToThumb() { var templateThumb = GetTemplateChild(ThumbPartName) as Thumb; templateThumb?.SetCurrentValue(IsHitTestVisibleProperty, _customThumb == null); - + _thumb = _customThumb ?? templateThumb; if (_thumb != null) { diff --git a/Dragablz/DragablzItemEventArgs.cs b/Dragablz/DragablzItemEventArgs.cs index 9b4b5da..88b256e 100644 --- a/Dragablz/DragablzItemEventArgs.cs +++ b/Dragablz/DragablzItemEventArgs.cs @@ -12,7 +12,7 @@ public class DragablzItemEventArgs : RoutedEventArgs public DragablzItemEventArgs(DragablzItem dragablzItem) { - if (dragablzItem == null) throw new ArgumentNullException("dragablzItem"); + if (dragablzItem == null) throw new ArgumentNullException("dragablzItem"); _dragablzItem = dragablzItem; } diff --git a/Dragablz/DragablzItemsControl.cs b/Dragablz/DragablzItemsControl.cs index bf6d79b..000ceaf 100644 --- a/Dragablz/DragablzItemsControl.cs +++ b/Dragablz/DragablzItemsControl.cs @@ -12,19 +12,19 @@ namespace Dragablz { /// - /// Items control which typically uses a canvas and + /// Items control which typically uses a canvas and /// public class DragablzItemsControl : ItemsControl - { + { private object[] _previousSortQueryResult; static DragablzItemsControl() { - DefaultStyleKeyProperty.OverrideMetadata(typeof(DragablzItemsControl), new FrameworkPropertyMetadata(typeof(DragablzItemsControl))); - } + DefaultStyleKeyProperty.OverrideMetadata(typeof(DragablzItemsControl), new FrameworkPropertyMetadata(typeof(DragablzItemsControl))); + } public DragablzItemsControl() - { + { ItemContainerGenerator.StatusChanged += ItemContainerGeneratorOnStatusChanged; ItemContainerGenerator.ItemsChanged += ItemContainerGeneratorOnItemsChanged; AddHandler(DragablzItem.XChangedEvent, new RoutedPropertyChangedEventHandler(ItemXChanged)); @@ -32,7 +32,7 @@ public DragablzItemsControl() AddHandler(DragablzItem.DragDelta, new DragablzDragDeltaEventHandler(ItemDragDelta)); AddHandler(DragablzItem.DragCompleted, new DragablzDragCompletedEventHandler(ItemDragCompleted)); AddHandler(DragablzItem.DragStarted, new DragablzDragStartedEventHandler(ItemDragStarted)); - AddHandler(DragablzItem.MouseDownWithinEvent, new DragablzItemEventHandler(ItemMouseDownWithinHandlerTarget)); + AddHandler(DragablzItem.MouseDownWithinEvent, new DragablzItemEventHandler(ItemMouseDownWithinHandlerTarget)); } public static readonly DependencyProperty FixedItemCountProperty = DependencyProperty.Register( @@ -52,7 +52,7 @@ private void ItemContainerGeneratorOnItemsChanged(object sender, ItemsChangedEve protected override void ClearContainerForItemOverride(DependencyObject element, object item) { if (ContainerCustomisations != null && ContainerCustomisations.ClearingContainerForItemOverride != null) - ContainerCustomisations.ClearingContainerForItemOverride(element, item); + ContainerCustomisations.ClearingContainerForItemOverride(element, item); base.ClearContainerForItemOverride(element, item); @@ -66,8 +66,8 @@ protected override void ClearContainerForItemOverride(DependencyObject element, var measure = ItemsOrganiser.Measure(this, new Size(ActualWidth, ActualHeight), dragablzItems); ItemsPresenterWidth = measure.Width; ItemsPresenterHeight = measure.Height; - }), DispatcherPriority.Input); - } + }), DispatcherPriority.Input); + } public static readonly DependencyProperty ItemsOrganiserProperty = DependencyProperty.Register( "ItemsOrganiser", typeof (IItemsOrganiser), typeof (DragablzItemsControl), new PropertyMetadata(default(IItemsOrganiser))); @@ -144,7 +144,7 @@ public void AddToSource(object item, object nearItem, AddLocationHint addLocatio internal ContainerCustomisations ContainerCustomisations { get; set; } private void ItemContainerGeneratorOnStatusChanged(object sender, EventArgs eventArgs) - { + { if (ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) return; InvalidateMeasure(); @@ -153,10 +153,10 @@ private void ItemContainerGeneratorOnStatusChanged(object sender, EventArgs even } protected override bool IsItemItsOwnContainerOverride(object item) - { + { var dragablzItem = item as DragablzItem; if (dragablzItem == null) return false; - + return true; } @@ -179,7 +179,7 @@ protected override void PrepareContainerForItemOverride(DependencyObject element base.PrepareContainerForItemOverride(element, item); } - protected override Size MeasureOverride(Size constraint) + protected override Size MeasureOverride(Size constraint) { if (ItemsOrganiser == null) return base.MeasureOverride(constraint); @@ -190,14 +190,14 @@ protected override Size MeasureOverride(Size constraint) return LockedMeasure.Value; } - var dragablzItems = DragablzItems().ToList(); + var dragablzItems = DragablzItems().ToList(); var maxConstraint = new Size(double.PositiveInfinity, double.PositiveInfinity); ItemsOrganiser.Organise(this, maxConstraint, dragablzItems); var measure = ItemsOrganiser.Measure(this, new Size(ActualWidth, ActualHeight), dragablzItems); ItemsPresenterWidth = measure.Width; - ItemsPresenterHeight = measure.Height; + ItemsPresenterHeight = measure.Height; var width = double.IsInfinity(constraint.Width) ? measure.Width : constraint.Width; var height = double.IsInfinity(constraint.Height) ? measure.Height : constraint.Height; @@ -206,9 +206,9 @@ protected override Size MeasureOverride(Size constraint) } internal void InstigateDrag(object item, Action continuation) - { - var dragablzItem = (DragablzItem)ItemContainerGenerator.ContainerFromItem(item); - dragablzItem.InstigateDrag(continuation); + { + var dragablzItem = (DragablzItem)ItemContainerGenerator.ContainerFromItem(item); + dragablzItem.InstigateDrag(continuation); } /// @@ -232,11 +232,11 @@ public void MoveItem(MoveItemRequest moveItemRequest) var sortedItems = DragablzItems().OrderBy(di => di.LogicalIndex).ToList(); sortedItems.Remove(dragablzItem); - + switch (moveItemRequest.AddLocationHint) { case AddLocationHint.First: - sortedItems.Insert(0, dragablzItem); + sortedItems.Insert(0, dragablzItem); break; case AddLocationHint.Last: sortedItems.Add(dragablzItem); @@ -252,23 +252,23 @@ public void MoveItem(MoveItemRequest moveItemRequest) break; default: throw new ArgumentOutOfRangeException(); - } + } //TODO might not be too great for perf on larger lists var orderedEnumerable = sortedItems.OrderBy(di => sortedItems.IndexOf(di)); ItemsOrganiser.Organise(this, new Size(ItemsPresenterWidth, ItemsPresenterHeight), orderedEnumerable); - } + } internal IEnumerable DragablzItems() { - return this.Containers().ToList(); + return this.Containers().ToList(); } internal Size? LockedMeasure { get; set; } private void ItemDragStarted(object sender, DragablzDragStartedEventArgs eventArgs) - { + { if (ItemsOrganiser != null) { var bounds = new Size(ActualWidth, ActualHeight); @@ -299,7 +299,7 @@ private void ItemDragCompleted(object sender, DragablzDragCompletedEventArgs eve ItemsOrganiser.OrganiseOnDragCompleted(this, bounds, dragablzItems.Except(eventArgs.DragablzItem), eventArgs.DragablzItem); - } + } eventArgs.Handled = true; @@ -316,14 +316,14 @@ private void ItemDragDelta(object sender, DragablzDragDeltaEventArgs eventArgs) eventArgs.DragablzItem.Y + eventArgs.DragDeltaEventArgs.VerticalChange ); if (ItemsOrganiser != null) - { + { if (FixedItemCount > 0 && ItemsOrganiser.Sort(DragablzItems()).Take(FixedItemCount).Contains(eventArgs.DragablzItem)) { eventArgs.Handled = true; return; - } - + } + desiredLocation = ItemsOrganiser.ConstrainLocation(this, bounds, new Point(eventArgs.DragablzItem.X, eventArgs.DragablzItem.Y), new Size(eventArgs.DragablzItem.ActualWidth, eventArgs.DragablzItem.ActualHeight), @@ -345,7 +345,7 @@ private void ItemDragDelta(object sender, DragablzDragDeltaEventArgs eventArgs) this, bounds, DragablzItems().Except(new[] {eventArgs.DragablzItem}), eventArgs.DragablzItem); - + eventArgs.DragablzItem.BringIntoView(); eventArgs.Handled = true; @@ -359,7 +359,7 @@ private void ItemXChanged(object sender, RoutedPropertyChangedEventArgs private void ItemYChanged(object sender, RoutedPropertyChangedEventArgs routedPropertyChangedEventArgs) { UpdateMonitor(routedPropertyChangedEventArgs); - } + } private void UpdateMonitor(RoutedEventArgs routedPropertyChangedEventArgs) { @@ -382,7 +382,7 @@ private void UpdateMonitor(RoutedEventArgs routedPropertyChangedEventArgs) } private void ItemMouseDownWithinHandlerTarget(object sender, DragablzItemEventArgs e) - { + { if (ItemsOrganiser == null) return; var bounds = new Size(ActualWidth, ActualHeight); diff --git a/Dragablz/DragablzWindow.cs b/Dragablz/DragablzWindow.cs index cca2a0f..9bc2ed6 100644 --- a/Dragablz/DragablzWindow.cs +++ b/Dragablz/DragablzWindow.cs @@ -17,7 +17,7 @@ namespace Dragablz /// /// It is not necessary to use a to gain tab dragging features. /// What this Window does is allow a quick way to remove the Window border, and support transparency whilst - /// dragging. + /// dragging. /// [TemplatePart(Name = WindowSurfaceGridPartName, Type = typeof(Grid))] [TemplatePart(Name = WindowRestoreThumbPartName, Type = typeof(Thumb))] @@ -32,7 +32,7 @@ public class DragablzWindow : Window public static RoutedCommand CloseWindowCommand = new RoutedCommand(); public static RoutedCommand RestoreWindowCommand = new RoutedCommand(); public static RoutedCommand MaximizeWindowCommand = new RoutedCommand(); - public static RoutedCommand MinimizeWindowCommand = new RoutedCommand(); + public static RoutedCommand MinimizeWindowCommand = new RoutedCommand(); private const int ResizeMargin = 4; private Size _sizeWhenResizeBegan; @@ -51,7 +51,7 @@ public class DragablzWindow : Window static DragablzWindow() { - DefaultStyleKeyProperty.OverrideMetadata(typeof(DragablzWindow), new FrameworkPropertyMetadata(typeof(DragablzWindow))); + DefaultStyleKeyProperty.OverrideMetadata(typeof(DragablzWindow), new FrameworkPropertyMetadata(typeof(DragablzWindow))); } public DragablzWindow() @@ -61,7 +61,7 @@ public DragablzWindow() CommandBindings.Add(new CommandBinding(CloseWindowCommand, CloseWindowExecuted)); CommandBindings.Add(new CommandBinding(MaximizeWindowCommand, MaximizeWindowExecuted)); CommandBindings.Add(new CommandBinding(MinimizeWindowCommand, MinimizeWindowExecuted)); - CommandBindings.Add(new CommandBinding(RestoreWindowCommand, RestoreWindowExecuted)); + CommandBindings.Add(new CommandBinding(RestoreWindowCommand, RestoreWindowExecuted)); } private static readonly DependencyPropertyKey IsWindowBeingDraggedByTabPropertyKey = @@ -76,10 +76,10 @@ public bool IsBeingDraggedByTab { get { return (bool) GetValue(IsBeingDraggedByTabProperty); } private set { SetValue(IsWindowBeingDraggedByTabPropertyKey, value); } - } + } private void ItemDragCompleted(object sender, DragablzDragCompletedEventArgs e) - { + { IsBeingDraggedByTab = false; } @@ -141,7 +141,7 @@ public override void OnApplyTemplate() if (windowResizeThumb == null) return; - windowResizeThumb.MouseMove += WindowResizeThumbOnMouseMove; + windowResizeThumb.MouseMove += WindowResizeThumbOnMouseMove; windowResizeThumb.DragStarted += WindowResizeThumbOnDragStarted; windowResizeThumb.DragDelta += WindowResizeThumbOnDragDelta; windowResizeThumb.DragCompleted += WindowResizeThumbOnDragCompleted; @@ -189,8 +189,8 @@ private static void WindowResizeThumbOnMouseMove(object sender, MouseEventArgs m } private void WindowRestoreThumbOnMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs) - { - WindowState = WindowState.Normal; + { + WindowState = WindowState.Normal; } private void WindowResizeThumbOnDragCompleted(object sender, DragCompletedEventArgs dragCompletedEventArgs) @@ -232,12 +232,12 @@ private void WindowResizeThumbOnDragDelta(object sender, DragDeltaEventArgs drag if (_bottomMode.Contains(_resizeType)) { var diff = currentScreenMousePoint.Y - _screenMousePointWhenResizeBegan.Y; - diff /= _yScale; + diff /= _yScale; height += diff; } width = Math.Max(MinWidth, width); - height = Math.Max(MinHeight, height); + height = Math.Max(MinHeight, height); //TODO must try harder. left = Math.Min(left, _windowLocationPointWhenResizeBegan.X + _sizeWhenResizeBegan.Width - ResizeMargin*4); //TODO must try harder. @@ -304,7 +304,7 @@ private static SizeGrip SelectSizingMode(Point mousePositionInThumb, Size thumbS private static Cursor SelectCursor(SizeGrip sizeGrip) { switch (sizeGrip) - { + { case SizeGrip.Left: return Cursors.SizeWE; case SizeGrip.TopLeft: @@ -339,12 +339,12 @@ private void WindowMoveThumbOnDragDelta(object sender, DragDeltaEventArgs dragDe Top = cursorPos.Y / _yScale - 2; Left = cursorPos.X / _xScale - RestoreBounds.Width / 2; - + var lParam = (int)(uint)cursorPos.X | (cursorPos.Y << 16); Native.SendMessage(CriticalHandle, WindowMessage.WM_LBUTTONUP, (IntPtr)HitTest.HT_CAPTION, (IntPtr)lParam); Native.SendMessage(CriticalHandle, WindowMessage.WM_SYSCOMMAND, (IntPtr)SystemCommand.SC_MOUSEMOVE, - IntPtr.Zero); + IntPtr.Zero); } private void RestoreWindowExecuted(object sender, ExecutedRoutedEventArgs e) @@ -365,6 +365,6 @@ private void MaximizeWindowExecuted(object sender, ExecutedRoutedEventArgs e) private void CloseWindowExecuted(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs) { Native.PostMessage(new WindowInteropHelper(this).Handle, WindowMessage.WM_CLOSE, IntPtr.Zero, IntPtr.Zero); - } + } } } diff --git a/Dragablz/EmptyHeaderSizingHint.cs b/Dragablz/EmptyHeaderSizingHint.cs index cbaee08..c17a6a2 100644 --- a/Dragablz/EmptyHeaderSizingHint.cs +++ b/Dragablz/EmptyHeaderSizingHint.cs @@ -13,7 +13,7 @@ public enum EmptyHeaderSizingHint /// The header size remains that of the last tab prior to the tab header becoming empty. /// PreviousTab, - //TODO implement EmptyHeaderSizingHint.Stretch + //TODO implement EmptyHeaderSizingHint.Stretch /// /// The header stretches along the according axis. /// diff --git a/Dragablz/HeaderedDragablzItem.cs b/Dragablz/HeaderedDragablzItem.cs index d8681f9..e832e69 100644 --- a/Dragablz/HeaderedDragablzItem.cs +++ b/Dragablz/HeaderedDragablzItem.cs @@ -7,9 +7,9 @@ public class HeaderedDragablzItem : DragablzItem { static HeaderedDragablzItem() { - DefaultStyleKeyProperty.OverrideMetadata(typeof(HeaderedDragablzItem), new FrameworkPropertyMetadata(typeof(HeaderedDragablzItem))); + DefaultStyleKeyProperty.OverrideMetadata(typeof(HeaderedDragablzItem), new FrameworkPropertyMetadata(typeof(HeaderedDragablzItem))); } - + public static readonly DependencyProperty HeaderContentProperty = DependencyProperty.Register( "HeaderContent", typeof (object), typeof (HeaderedDragablzItem), new PropertyMetadata(default(object))); @@ -44,6 +44,6 @@ public DataTemplateSelector HeaderContentTemplateSelector { get { return (DataTemplateSelector) GetValue(HeaderContentTemplateSelectorProperty); } set { SetValue(HeaderContentTemplateSelectorProperty, value); } - } + } } } \ No newline at end of file diff --git a/Dragablz/HorizontalOrganiser.cs b/Dragablz/HorizontalOrganiser.cs index 13382d4..60a8a29 100644 --- a/Dragablz/HorizontalOrganiser.cs +++ b/Dragablz/HorizontalOrganiser.cs @@ -12,5 +12,5 @@ public HorizontalOrganiser() : base(Orientation.Horizontal) public HorizontalOrganiser(double itemOffset) : base(Orientation.Horizontal, itemOffset) { } - } + } } \ No newline at end of file diff --git a/Dragablz/IInterLayoutClient.cs b/Dragablz/IInterLayoutClient.cs index ffb5312..c241d3a 100644 --- a/Dragablz/IInterLayoutClient.cs +++ b/Dragablz/IInterLayoutClient.cs @@ -14,6 +14,6 @@ public interface IInterLayoutClient /// The source control where a dragging operation was initiated. /// INewTabHost GetNewHost(object partition, TabablzControl source); - + } } \ No newline at end of file diff --git a/Dragablz/IItemsOrganiser.cs b/Dragablz/IItemsOrganiser.cs index 1d0c4c8..8ac4a14 100644 --- a/Dragablz/IItemsOrganiser.cs +++ b/Dragablz/IItemsOrganiser.cs @@ -13,7 +13,7 @@ public interface IItemsOrganiser void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds, List siblingItems, DragablzItem dragablzItem); void OrganiseOnDragStarted(DragablzItemsControl requestor, Size measureBounds, IEnumerable siblingItems, DragablzItem dragItem); void OrganiseOnDrag(DragablzItemsControl requestor, Size measureBounds, IEnumerable siblingItems, DragablzItem dragItem); - void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable siblingItems, DragablzItem dragItem); + void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable siblingItems, DragablzItem dragItem); Point ConstrainLocation(DragablzItemsControl requestor, Size measureBounds, Point itemCurrentLocation, Size itemCurrentSize, Point itemDesiredLocation, Size itemDesiredSize); Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable items); IEnumerable Sort(IEnumerable items); diff --git a/Dragablz/InterTabController.cs b/Dragablz/InterTabController.cs index 6853e45..279f313 100644 --- a/Dragablz/InterTabController.cs +++ b/Dragablz/InterTabController.cs @@ -9,7 +9,7 @@ public InterTabController() { HorizontalPopoutGrace = 8; VerticalPopoutGrace = 8; - MoveWindowWithSolitaryTabs = true; + MoveWindowWithSolitaryTabs = true; } public static readonly DependencyProperty HorizontalPopoutGraceProperty = DependencyProperty.Register( diff --git a/Dragablz/LocationChangedEventArgs.cs b/Dragablz/LocationChangedEventArgs.cs index 8131044..ea920b0 100644 --- a/Dragablz/LocationChangedEventArgs.cs +++ b/Dragablz/LocationChangedEventArgs.cs @@ -11,7 +11,7 @@ public class LocationChangedEventArgs : EventArgs public LocationChangedEventArgs(object item, Point location) { if (item == null) throw new ArgumentNullException("item"); - + _item = item; _location = location; } diff --git a/Dragablz/LocationHint.cs b/Dragablz/LocationHint.cs index e4189cf..7efeb77 100644 --- a/Dragablz/LocationHint.cs +++ b/Dragablz/LocationHint.cs @@ -5,7 +5,7 @@ namespace Dragablz /// specifically correlate to the order of the the source items. /// public enum AddLocationHint - { + { /// /// Display item in the first position. /// diff --git a/Dragablz/PositionMonitor.cs b/Dragablz/PositionMonitor.cs index dfaf896..7f7da94 100644 --- a/Dragablz/PositionMonitor.cs +++ b/Dragablz/PositionMonitor.cs @@ -5,10 +5,10 @@ namespace Dragablz { /// - /// Consumers can provide a position monitor to receive updates regarding the location of an item. + /// Consumers can provide a position monitor to receive updates regarding the location of an item. /// /// - /// A can be used to listen to changes + /// A can be used to listen to changes /// instead of routed events, which can be easier in a MVVM scenario. /// public class PositionMonitor diff --git a/Dragablz/Properties/AssemblyInfo.cs b/Dragablz/Properties/AssemblyInfo.cs index 49a094d..62daf6d 100644 --- a/Dragablz/Properties/AssemblyInfo.cs +++ b/Dragablz/Properties/AssemblyInfo.cs @@ -5,7 +5,7 @@ using System.Windows; using System.Windows.Markup; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Dragablz")] @@ -17,18 +17,18 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: XmlnsPrefix("http://dragablz.net/winfx/xaml/dragablz", "dragablz")] -[assembly: XmlnsDefinition("http://dragablz.net/winfx/xaml/dragablz", +[assembly: XmlnsDefinition("http://dragablz.net/winfx/xaml/dragablz", "Dragablz")] [assembly: XmlnsPrefix("http://dragablz.net/winfx/xaml/dockablz", "dockablz")] [assembly: XmlnsDefinition("http://dragablz.net/winfx/xaml/dockablz", "Dragablz.Dockablz")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -//In order to begin building localizable applications, set +//In order to begin building localizable applications, set //CultureYouAreCodingWith in your .csproj file //inside a . For example, if you are using US english //in your source files, set the to en-US. Then uncomment @@ -40,10 +40,10 @@ [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, + //(used if a resource is not found in the page, // or application resource dictionaries) ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, + //(used if a resource is not found in the page, // app, or any theme specific resource dictionaries) )] @@ -51,11 +51,11 @@ // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("0.0.0.0")] diff --git a/Dragablz/StackOrganiser.cs b/Dragablz/StackOrganiser.cs index 93de288..b14f2c3 100644 --- a/Dragablz/StackOrganiser.cs +++ b/Dragablz/StackOrganiser.cs @@ -94,13 +94,13 @@ public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, if (items == null) throw new ArgumentNullException("items"); OrganiseInternal( - requestor, + requestor, measureBounds, items.Select((di, idx) => new Tuple(idx, di)) .OrderBy(tuple => tuple, MultiComparer>.Ascending(tuple => _getLocation(tuple.Item2)) .ThenAscending(tuple => tuple.Item1)) - .Select(tuple => tuple.Item2)); + .Select(tuple => tuple.Item2)); } public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable items) @@ -169,7 +169,7 @@ public virtual void OrganiseOnDrag(DragablzItemsControl requestor, Size measureB SendToLocation(location.Item, currentCoord); Panel.SetZIndex(location.Item, --zIndex); } - currentCoord += _getDesiredSize(location.Item) + _itemOffset; + currentCoord += _getDesiredSize(location.Item) + _itemOffset; } Panel.SetZIndex(dragItem, int.MaxValue); } @@ -258,20 +258,20 @@ public virtual IEnumerable Sort(IEnumerable items) } private void SetLocation(DragablzItem dragablzItem, double location) - { + { _setLocation(dragablzItem, location); } - + private void SendToLocation(DragablzItem dragablzItem, double location) - { + { double activeTarget; if (Math.Abs(_getLocation(dragablzItem) - location) < 1.0 || _activeStoryboardTargetLocations.TryGetValue(dragablzItem, out activeTarget) && Math.Abs(activeTarget - location) < 1.0) - { + { return; - } + } _activeStoryboardTargetLocations[dragablzItem] = location; @@ -290,8 +290,8 @@ private void SendToLocation(DragablzItem dragablzItem, double location) { EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut } }); - storyboard.Children.Add(timeline); - storyboard.Begin(dragablzItem, true); + storyboard.Children.Add(timeline); + storyboard.Begin(dragablzItem, true); } private LocationInfo GetLocationInfo(DragablzItem item) diff --git a/Dragablz/StoryboardCompletionListener.cs b/Dragablz/StoryboardCompletionListener.cs index bdbe757..ac4868a 100644 --- a/Dragablz/StoryboardCompletionListener.cs +++ b/Dragablz/StoryboardCompletionListener.cs @@ -30,12 +30,12 @@ private void StoryboardOnCompleted(object sender, EventArgs eventArgs) internal static class StoryboardCompletionListenerExtension { - private static readonly IDictionary> ContinuationIndex = new Dictionary>(); + private static readonly IDictionary> ContinuationIndex = new Dictionary>(); public static void WhenComplete(this Storyboard storyboard, Action continuation) { // ReSharper disable once ObjectCreationAsStatement new StoryboardCompletionListener(storyboard, continuation); - } + } } } \ No newline at end of file diff --git a/Dragablz/TabablzControl.cs b/Dragablz/TabablzControl.cs index c161770..271c7be 100644 --- a/Dragablz/TabablzControl.cs +++ b/Dragablz/TabablzControl.cs @@ -18,10 +18,10 @@ namespace Dragablz { - //original code specific to keeping visual tree "alive" sourced from http://stackoverflow.com/questions/12432062/binding-to-itemssource-of-tabcontrol-in-wpf + //original code specific to keeping visual tree "alive" sourced from http://stackoverflow.com/questions/12432062/binding-to-itemssource-of-tabcontrol-in-wpf /// - /// Extended tab control which supports tab repositioning, and drag and drop. Also + /// Extended tab control which supports tab repositioning, and drag and drop. Also /// uses the common WPF technique for pesisting the visual tree across tabs. /// [TemplatePart(Name = HeaderItemsControlPartName, Type = typeof(DragablzItemsControl))] @@ -52,7 +52,7 @@ public class TabablzControl : TabControl private Panel _itemsHolder; private TabHeaderDragStartInformation _tabHeaderDragStartInformation; - private WeakReference _previousSelection; + private WeakReference _previousSelection; private DragablzItemsControl _dragablzItemsControl; private IDisposable _templateSubscription; private readonly SerialDisposable _windowSubscription = new SerialDisposable(); @@ -64,21 +64,21 @@ static TabablzControl() DefaultStyleKeyProperty.OverrideMetadata(typeof(TabablzControl), new FrameworkPropertyMetadata(typeof(TabablzControl))); CommandManager.RegisterClassCommandBinding(typeof(FrameworkElement), new CommandBinding(CloseItemCommand, CloseItemClassHandler, CloseItemCanExecuteClassHandler)); } - + /// /// Default constructor. /// public TabablzControl() - { + { AddHandler(DragablzItem.DragStarted, new DragablzDragStartedEventHandler(ItemDragStarted), true); AddHandler(DragablzItem.PreviewDragDelta, new DragablzDragDeltaEventHandler(PreviewItemDragDelta), true); AddHandler(DragablzItem.DragDelta, new DragablzDragDeltaEventHandler(ItemDragDelta), true); - AddHandler(DragablzItem.DragCompleted, new DragablzDragCompletedEventHandler(ItemDragCompleted), true); - CommandBindings.Add(new CommandBinding(AddItemCommand, AddItemHandler)); + AddHandler(DragablzItem.DragCompleted, new DragablzDragCompletedEventHandler(ItemDragCompleted), true); + CommandBindings.Add(new CommandBinding(AddItemCommand, AddItemHandler)); Loaded += OnLoaded; - Unloaded += OnUnloaded; - IsVisibleChanged += OnIsVisibleChanged; + Unloaded += OnUnloaded; + IsVisibleChanged += OnIsVisibleChanged; } public static readonly DependencyProperty CustomHeaderItemStyleProperty = DependencyProperty.Register( @@ -107,8 +107,8 @@ public static void CloseItem(object tabContentItem) if (tabContentItem == null) return; //Do nothing. //Find all loaded TabablzControl instances with tabs backed by this item and close them - foreach(var tabWithItemContent in - GetLoadedInstances().SelectMany(tc => + foreach(var tabWithItemContent in + GetLoadedInstances().SelectMany(tc => tc._dragablzItemsControl.DragablzItems().Where(di => di.Content.Equals(tabContentItem)).Select(di => new { tc, di }))) { TabablzControl.CloseItem(tabWithItemContent.di, tabWithItemContent.tc); @@ -120,7 +120,7 @@ public static void CloseItem(object tabContentItem) /// /// /// Due to the organisable nature of the control, the order of items may not reflect the order in the source collection. This method - /// will add items to the source collection, managing their initial appearance on screen at the same time. + /// will add items to the source collection, managing their initial appearance on screen at the same time. /// If you are using a this will be used to add the item into the source collection. /// /// New item to add. @@ -136,8 +136,8 @@ public static void AddItem(object item, object nearItem, AddLocationHint addLoca .SingleOrDefault(a => nearItem.Equals(a.existingObject)); if (existingLocation == null) - throw new ArgumentException("Did not find precisely one instance of adjacentTo", "nearItem"); - + throw new ArgumentException("Did not find precisely one instance of adjacentTo", "nearItem"); + existingLocation.tabControl.AddToSource(item); if (existingLocation.tabControl._dragablzItemsControl != null) existingLocation.tabControl._dragablzItemsControl.MoveItem(new MoveItemRequest(item, nearItem, addLocationHint)); @@ -157,7 +157,7 @@ public static void SelectItem(object item) if (existingLocation == null) return; existingLocation.tabControl.SelectedItem = item; - } + } /// /// Style to apply to header items which are not their own item container (). Typically items bound via the will use this style. @@ -180,7 +180,7 @@ public DataTemplate CustomHeaderItemTemplate } public static readonly DependencyProperty DefaultHeaderItemStyleProperty = DependencyProperty.Register( - "DefaultHeaderItemStyle", typeof (Style), typeof (TabablzControl), new PropertyMetadata(default(Style))); + "DefaultHeaderItemStyle", typeof (Style), typeof (TabablzControl), new PropertyMetadata(default(Style))); [Obsolete] public Style DefaultHeaderItemStyle @@ -306,7 +306,7 @@ public DataTemplateSelector HeaderSuffixContentTemplateSelector "ShowDefaultCloseButton", typeof (bool), typeof (TabablzControl), new PropertyMetadata(default(bool))); /// - /// Indicates whether a default close button should be displayed. If manually templating the tab header content the close command + /// Indicates whether a default close button should be displayed. If manually templating the tab header content the close command /// can be called by executing the command (typically via a ). /// public bool ShowDefaultCloseButton @@ -320,7 +320,7 @@ public bool ShowDefaultCloseButton /// /// Indicates whether a default add button should be displayed. Alternately an add button - /// could be added in or , utilising + /// could be added in or , utilising /// . /// public bool ShowDefaultAddButton @@ -453,7 +453,7 @@ private static void OnIsEmptyChanged( (bool) e.OldValue, (bool) e.NewValue) {RoutedEvent = IsEmptyChangedEvent}; instance?.RaiseEvent(args); - } + } /// /// Optionally allows a close item hook to be bound in. If this propety is provided, the func must return true for the close to continue. @@ -508,7 +508,7 @@ public ItemActionCallback ConsolidatingOrphanedItemCallback set { SetValue(ConsolidatingOrphanedItemCallbackProperty, value); } } - + private static readonly DependencyPropertyKey IsDraggingWindowPropertyKey = DependencyProperty.RegisterReadOnly( @@ -516,15 +516,15 @@ public ItemActionCallback ConsolidatingOrphanedItemCallback new PropertyMetadata(default(bool), OnIsDraggingWindowChanged)); /// - /// Readonly dependency property which indicates whether the owning - /// is currently dragged + /// Readonly dependency property which indicates whether the owning + /// is currently dragged /// public static readonly DependencyProperty IsDraggingWindowProperty = IsDraggingWindowPropertyKey.DependencyProperty; /// - /// Readonly dependency property which indicates whether the owning - /// is currently dragged + /// Readonly dependency property which indicates whether the owning + /// is currently dragged /// public bool IsDraggingWindow { @@ -562,7 +562,7 @@ private static void OnIsDraggingWindowChanged( RoutedEvent = IsDraggingWindowChangedEvent }; instance.RaiseEvent(args); - + } /// @@ -688,7 +688,7 @@ public override void OnApplyTemplate() Disposable.Create( () => _dragablzItemsControl.ItemContainerGenerator.StatusChanged -= - ItemContainerGeneratorOnStatusChanged); + ItemContainerGeneratorOnStatusChanged); _dragablzItemsControl.ContainerCustomisations = new ContainerCustomisations(null, PrepareChildContainerForItemOverride); } @@ -699,10 +699,10 @@ public override void OnApplyTemplate() _itemsHolder = GetTemplateChild(ItemsHolderPartName) as Panel; UpdateSelectedItem(); MarkWrappedTabItems(); - MarkInitialSelection(); + MarkInitialSelection(); base.OnApplyTemplate(); - } + } /// /// update the visible child in the ItemsHolder @@ -723,11 +723,11 @@ protected override void OnSelectionChanged(SelectionChangedEventArgs e) l.Cast() .Where(o => !(o is TabItem)) .Select(o => _dragablzItemsControl.ItemContainerGenerator.ContainerFromItem(o)) - .OfType(); + .OfType(); foreach (var addedItem in notTabItems(e.AddedItems)) { addedItem.IsSelected = true; - addedItem.BringIntoView(); + addedItem.BringIntoView(); } foreach (var removedItem in notTabItems(e.RemovedItems)) { @@ -735,14 +735,14 @@ protected override void OnSelectionChanged(SelectionChangedEventArgs e) } foreach (var tabItem in e.AddedItems.OfType().Select(t => _dragablzItemsControl.ItemContainerGenerator.ContainerFromItem(t)).OfType()) - { + { tabItem.IsSelected = true; tabItem.BringIntoView(); - } + } foreach (var tabItem in e.RemovedItems.OfType().Select(t => _dragablzItemsControl.ItemContainerGenerator.ContainerFromItem(t)).OfType()) { - tabItem.IsSelected = false; - } + tabItem.IsSelected = false; + } } /// @@ -778,9 +778,9 @@ protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e) break; - case NotifyCollectionChangedAction.Remove: + case NotifyCollectionChangedAction.Remove: foreach (var item in e.OldItems) - { + { var cp = FindChildContentPresenter(item); if (cp != null) _itemsHolder.Children.Remove(cp); @@ -818,7 +818,7 @@ protected override void OnKeyDown(KeyEventArgs e) if ((e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { var selectedDragablzItem = (DragablzItem)_dragablzItemsControl.ItemContainerGenerator.ContainerFromItem(SelectedItem); - var selectedDragablzItemIndex = sortedDragablzItems.IndexOf(selectedDragablzItem); + var selectedDragablzItemIndex = sortedDragablzItems.IndexOf(selectedDragablzItem); var direction = ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) ? -1 : 1; var newIndex = selectedDragablzItemIndex + direction; @@ -844,7 +844,7 @@ protected override void OnKeyDown(KeyEventArgs e) } if (!e.Handled) - base.OnKeyDown(e); + base.OnKeyDown(e); } /// @@ -856,7 +856,7 @@ protected override AutomationPeer OnCreateAutomationPeer() { return new FrameworkElementAutomationPeer(this); } - + internal static TabablzControl GetOwnerOfHeaderItems(DragablzItemsControl itemsControl) { return LoadedInstances.FirstOrDefault(t => Equals(t._dragablzItemsControl, itemsControl)); @@ -875,7 +875,7 @@ private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { LoadedInstances.Add(this); var window = Window.GetWindow(this); - if (window == null) return; + if (window == null) return; window.Closing += WindowOnClosing; _windowSubscription.Disposable = Disposable.Create(() => window.Closing -= WindowOnClosing); } @@ -970,8 +970,8 @@ private void ItemDragStarted(object sender, DragablzDragStartedEventArgs e) _tabHeaderDragStartInformation = new TabHeaderDragStartInformation(e.DragablzItem, itemsControlOffset.X, itemsControlOffset.Y, e.DragStartedEventArgs.HorizontalOffset, e.DragStartedEventArgs.VerticalOffset); - foreach (var otherItem in _dragablzItemsControl.Containers().Except(e.DragablzItem)) - otherItem.IsSelected = false; + foreach (var otherItem in _dragablzItemsControl.Containers().Except(e.DragablzItem)) + otherItem.IsSelected = false; e.DragablzItem.IsSelected = true; e.DragablzItem.PartitionAtDragStart = InterTabController?.Partition; var item = _dragablzItemsControl.ItemContainerGenerator.ItemFromContainer(e.DragablzItem); @@ -1019,9 +1019,9 @@ private void PreviewItemDragDelta(object sender, DragablzDragDeltaEventArgs e) var offset = e.DragablzItem.TranslatePoint(_interTabTransfer.OriginatorContainer.MouseAtDragStart, myWindow); var borderVector = myWindow.PointToScreen(new Point()).ToWpf() - new Point(myWindow.Left, myWindow.Top); offset.Offset(borderVector.X, borderVector.Y); - myWindow.Left = cursorPos.X - offset.X; + myWindow.Left = cursorPos.X - offset.X; myWindow.Top = cursorPos.Y - offset.Y; - } + } } else { @@ -1038,7 +1038,7 @@ private bool MonitorReentry(DragablzDragDeltaEventArgs e) var sourceTabablzControl = (TabablzControl) e.Source; if (sourceTabablzControl.Items.Count > 1 && e.DragablzItem.LogicalIndex < sourceTabablzControl.FixedHeaderCount) - { + { return false; } @@ -1054,7 +1054,7 @@ private bool MonitorReentry(DragablzDragDeltaEventArgs e) var lastFixedItem = tc._dragablzItemsControl.DragablzItems() .OrderBy(di=> di.LogicalIndex) .Take(tc._dragablzItemsControl.FixedItemCount) - .LastOrDefault(); + .LastOrDefault(); //TODO work this for vert tabs if (lastFixedItem != null) topLeft.Offset(lastFixedItem.X + lastFixedItem.ActualWidth, 0); @@ -1080,14 +1080,14 @@ private bool MonitorReentry(DragablzDragDeltaEventArgs e) .ToList(); e.DragablzItem.IsDropTargetFound = true; - var item = RemoveItem(e.DragablzItem); + var item = RemoveItem(e.DragablzItem); var interTabTransfer = new InterTabTransfer(item, e.DragablzItem, mousePositionOnItem, floatingItemSnapShots); e.DragablzItem.IsDragging = false; target.tc.ReceiveDrag(interTabTransfer); e.Cancel = true; - + return true; } @@ -1099,7 +1099,7 @@ internal object RemoveItem(DragablzItem dragablzItem) var minSize = EmptyHeaderSizingHint == EmptyHeaderSizingHint.PreviousTab ? new Size(_dragablzItemsControl.ActualWidth, _dragablzItemsControl.ActualHeight) : new Size(); - + _dragablzItemsControl.MinHeight = 0; _dragablzItemsControl.MinWidth = 0; @@ -1110,8 +1110,8 @@ internal object RemoveItem(DragablzItem dragablzItem) if (Items.Count != 0) return item; var window = Window.GetWindow(this); - if (window != null - && InterTabController != null + if (window != null + && InterTabController != null && InterTabController.InterTabClient.TabEmptiedHandler(this, window) == TabEmptiedResponse.CloseWindowOrLayoutBranch) { if (Layout.ConsolidateBranch(this)) return item; @@ -1124,7 +1124,7 @@ internal object RemoveItem(DragablzItem dragablzItem) finally { SetIsClosingAsPartOfDragOperation(window, false); - } + } } else { @@ -1145,19 +1145,19 @@ private void ItemDragCompleted(object sender, DragablzDragCompletedEventArgs e) private void ItemDragDelta(object sender, DragablzDragDeltaEventArgs e) { - if (!IsMyItem(e.DragablzItem)) return; + if (!IsMyItem(e.DragablzItem)) return; if (FixedHeaderCount > 0 && _dragablzItemsControl.ItemsOrganiser.Sort(_dragablzItemsControl.DragablzItems()) .Take(FixedHeaderCount) - .Contains(e.DragablzItem)) + .Contains(e.DragablzItem)) return; if (_tabHeaderDragStartInformation == null || !Equals(_tabHeaderDragStartInformation.DragItem, e.DragablzItem) || InterTabController == null) return; - if (InterTabController.InterTabClient == null) + if (InterTabController.InterTabClient == null) throw new InvalidOperationException("An InterTabClient must be provided on an InterTabController."); - + MonitorBreach(e); } @@ -1197,7 +1197,7 @@ private void MonitorBreach(DragablzDragDeltaEventArgs e) var floatingItemSnapShots = this.VisualTreeDepthFirstTraversal() .OfType() .SelectMany(l => l.FloatingDragablzItems().Select(FloatingItemSnapShot.Take)) - .ToList(); + .ToList(); var interTabTransfer = new InterTabTransfer(item, e.DragablzItem, breachOrientation.Value, dragStartWindowOffset, e.DragablzItem.MouseAtDragStart, dragableItemHeaderPoint, dragableItemSize, floatingItemSnapShots, isTransposing); @@ -1289,9 +1289,9 @@ private Point ConfigureNewHostSizeAndGetDragStartWindowOffset(Window currentWind dragStartWindowOffset = isTransposing ? new Point() : dragablzItem.TranslatePoint(new Point(), this); dragStartWindowOffset.Offset(dragablzItem.MouseAtDragStart.X, dragablzItem.MouseAtDragStart.Y); return dragStartWindowOffset; - } - } - + } + } + dragStartWindowOffset.Offset(dragablzItem.MouseAtDragStart.X, dragablzItem.MouseAtDragStart.Y); var borderVector = currentWindow.PointToScreen(new Point()).ToWpf() - new Point(currentWindow.GetActualLeft(), currentWindow.GetActualTop()); dragStartWindowOffset.Offset(borderVector.X, borderVector.Y); @@ -1325,7 +1325,7 @@ internal void ReceiveDrag(InterTabTransfer interTabTransfer) AddToSource(interTabTransfer.Item); SelectedItem = interTabTransfer.Item; - + Dispatcher.BeginInvoke(new Action(() => Layout.RestoreFloatingItemSnapShots(this, interTabTransfer.FloatingItemSnapShots)), DispatcherPriority.Loaded); _dragablzItemsControl.InstigateDrag(interTabTransfer.Item, newContainer => { @@ -1374,19 +1374,19 @@ internal void ReceiveDrag(InterTabTransfer interTabTransfer) } newContainer.MouseAtDragStart = interTabTransfer.DragStartItemOffset; }); - } + } /// /// generate a ContentPresenter for the selected item /// - private void UpdateSelectedItem() - { + private void UpdateSelectedItem() + { if (_itemsHolder == null) { return; } - - CreateChildContentPresenter(SelectedItem); + + CreateChildContentPresenter(SelectedItem); // show the right child var selectedContent = GetContent(SelectedItem); @@ -1410,7 +1410,7 @@ private static object GetContent(object item) /// private void CreateChildContentPresenter(object item) { - if (item == null) return; + if (item == null) return; var cp = FindChildContentPresenter(item); if (cp != null) return; @@ -1422,9 +1422,9 @@ private void CreateChildContentPresenter(object item) ContentTemplate = ContentTemplate, ContentTemplateSelector = ContentTemplateSelector, ContentStringFormat = ContentStringFormat, - Visibility = Visibility.Collapsed, + Visibility = Visibility.Collapsed, }; - _itemsHolder.Children.Add(cp); + _itemsHolder.Children.Add(cp); } /// @@ -1496,7 +1496,7 @@ private static Tuple FindOwner(object eventParamet var popup = dependencyObject.LogicalTreeAncestory().OfType().LastOrDefault(); if (popup?.PlacementTarget != null) { - dragablzItem = popup.PlacementTarget.VisualTreeAncestory().OfType().FirstOrDefault(); + dragablzItem = popup.PlacementTarget.VisualTreeAncestory().OfType().FirstOrDefault(); } } } @@ -1506,10 +1506,10 @@ private static Tuple FindOwner(object eventParamet var tabablzControl = LoadedInstances.FirstOrDefault(tc => tc.IsMyItem(dragablzItem)); return tabablzControl == null ? null : new Tuple(dragablzItem, tabablzControl); - } + } private void AddItemHandler(object sender, ExecutedRoutedEventArgs e) - { + { if (NewItemFactory == null) throw new InvalidOperationException("NewItemFactory must be provided."); @@ -1532,7 +1532,7 @@ private void PrepareChildContainerForItemOverride(DependencyObject dependencyObj dragablzItem.UnderlyingContent = o; } - SetIsWrappingTabItem(dependencyObject, o is TabItem); + SetIsWrappingTabItem(dependencyObject, o is TabItem); } } } diff --git a/Dragablz/TabablzHeaderSizeConverter.cs b/Dragablz/TabablzHeaderSizeConverter.cs index bd380c7..d42d6e5 100644 --- a/Dragablz/TabablzHeaderSizeConverter.cs +++ b/Dragablz/TabablzHeaderSizeConverter.cs @@ -12,11 +12,11 @@ namespace Dragablz /// Provides a little help for sizing the header panel in the tab control /// public class TabablzHeaderSizeConverter : IMultiValueConverter - { + { public Orientation Orientation { get; set; } /// - /// The first value should be the total size available size, typically the parent control size. + /// The first value should be the total size available size, typically the parent control size. /// The second value should be from or (height equivalent) /// All additional values should be siblings sizes (width or height) which will affect (reduce) the available size. /// diff --git a/Dragablz/Themes/Ripple.cs b/Dragablz/Themes/Ripple.cs index 3b58f79..646ad58 100644 --- a/Dragablz/Themes/Ripple.cs +++ b/Dragablz/Themes/Ripple.cs @@ -169,17 +169,17 @@ public double RippleY } /// - /// The DependencyProperty for the RecognizesAccessKey property. - /// Default Value: false - /// + /// The DependencyProperty for the RecognizesAccessKey property. + /// Default Value: false + /// public static readonly DependencyProperty RecognizesAccessKeyProperty = DependencyProperty.Register( "RecognizesAccessKey", typeof(bool), typeof(Ripple), new PropertyMetadata(default(bool))); - /// + /// /// Determine if Ripple should use AccessText in its style - /// + /// public bool RecognizesAccessKey { get { return (bool)GetValue(RecognizesAccessKeyProperty); } diff --git a/Dragablz/Themes/RippleAssist.cs b/Dragablz/Themes/RippleAssist.cs index 06e933a..a0b364b 100644 --- a/Dragablz/Themes/RippleAssist.cs +++ b/Dragablz/Themes/RippleAssist.cs @@ -24,15 +24,15 @@ public static bool GetClipToBounds(DependencyObject element) #region StayOnCenter /// - /// Set to true to cause the ripple to originate from the centre of the - /// content. Otherwise the effect will originate from the mouse down position. + /// Set to true to cause the ripple to originate from the centre of the + /// content. Otherwise the effect will originate from the mouse down position. /// public static readonly DependencyProperty IsCenteredProperty = DependencyProperty.RegisterAttached( "IsCentered", typeof(bool), typeof(RippleAssist), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits)); /// - /// Set to true to cause the ripple to originate from the centre of the - /// content. Otherwise the effect will originate from the mouse down position. + /// Set to true to cause the ripple to originate from the centre of the + /// content. Otherwise the effect will originate from the mouse down position. /// /// /// @@ -42,10 +42,10 @@ public static void SetIsCentered(DependencyObject element, bool value) } /// - /// Set to true to cause the ripple to originate from the centre of the - /// content. Otherwise the effect will originate from the mouse down position. + /// Set to true to cause the ripple to originate from the centre of the + /// content. Otherwise the effect will originate from the mouse down position. /// - /// + /// public static bool GetIsCentered(DependencyObject element) { return (bool)element.GetValue(IsCenteredProperty); diff --git a/Dragablz/Trapezoid.cs b/Dragablz/Trapezoid.cs index 0f210d7..87972ff 100644 --- a/Dragablz/Trapezoid.cs +++ b/Dragablz/Trapezoid.cs @@ -81,7 +81,7 @@ private static PathGeometry CreateGeometry(Size contentDesiredSize) //TODO Make better :) do some funky beziers or summit const double cheapRadiusBig = 6.0; const double cheapRadiusSmall = cheapRadiusBig/2; - + const int angle = 20; const double radians = angle * (Math.PI / 180); @@ -107,7 +107,7 @@ private static PathGeometry CreateGeometry(Size contentDesiredSize) var bottomRightSegment = new ArcSegment(bottomRightPoint, new Size(cheapRadiusSmall, cheapRadiusSmall), 25, false, SweepDirection.Counterclockwise, true); var bottomLeftPoint = new Point(0, bottomRightSegment.Point.Y); - var bottomSegment = new LineSegment(bottomLeftPoint, true); + var bottomSegment = new LineSegment(bottomLeftPoint, true); var pathSegmentCollection = new PathSegmentCollection { @@ -121,15 +121,15 @@ private static PathGeometry CreateGeometry(Size contentDesiredSize) { pathFigure }; - var geometryGroup = new PathGeometry(pathFigureCollection); - geometryGroup.Freeze(); + var geometryGroup = new PathGeometry(pathFigureCollection); + geometryGroup.Freeze(); return geometryGroup; } protected override void OnRender(DrawingContext drawingContext) { - base.OnRender(drawingContext); + base.OnRender(drawingContext); drawingContext.DrawGeometry(Background, CreatePen(), _pathGeometry); if (_pathGeometry == null) return; diff --git a/DragablzDemo/AnotherCommandImplementation.cs b/DragablzDemo/AnotherCommandImplementation.cs index cfc910d..c3c7c80 100644 --- a/DragablzDemo/AnotherCommandImplementation.cs +++ b/DragablzDemo/AnotherCommandImplementation.cs @@ -18,7 +18,7 @@ public AnotherCommandImplementation(Action execute) : this(execute, null public AnotherCommandImplementation(Action execute, Func canExecute) { if (execute == null) throw new ArgumentNullException("execute"); - + _execute = execute; _canExecute = canExecute ?? (x => true); } diff --git a/DragablzDemo/BasicExampleMainModel.cs b/DragablzDemo/BasicExampleMainModel.cs index 835e199..1ac023d 100644 --- a/DragablzDemo/BasicExampleMainModel.cs +++ b/DragablzDemo/BasicExampleMainModel.cs @@ -82,7 +82,7 @@ public string BasicColourMonitorText #endif #if NET45 OnPropertyChanged(); -#endif +#endif } } @@ -99,13 +99,13 @@ public string PeopleMonitorText #endif #if NET45 OnPropertyChanged(); -#endif +#endif } } public ReadOnlyObservableCollection People { - get { return new ReadOnlyObservableCollection(_people); } + get { return new ReadOnlyObservableCollection(_people); } } public ICommand AddNewPerson @@ -130,7 +130,7 @@ public SimpleViewModel SelectedViewModel #endif #if NET45 OnPropertyChanged(); -#endif +#endif } } @@ -141,7 +141,7 @@ public ICommand AddNewViewModel public PositionMonitor BasicColourMonitor { - get { return _basicColourMonitor; } + get { return _basicColourMonitor; } } public PositionMonitor PeopleMonitor diff --git a/DragablzDemo/BasicExampleMainWindow.xaml.cs b/DragablzDemo/BasicExampleMainWindow.xaml.cs index 6626f68..325d2ba 100644 --- a/DragablzDemo/BasicExampleMainWindow.xaml.cs +++ b/DragablzDemo/BasicExampleMainWindow.xaml.cs @@ -11,7 +11,7 @@ public BasicExampleMainWindow() { InitializeComponent(); - DataContext = new BasicExampleMainModel(); + DataContext = new BasicExampleMainModel(); } } } diff --git a/DragablzDemo/BasicExampleTemplateModel.cs b/DragablzDemo/BasicExampleTemplateModel.cs index bef98af..c801496 100644 --- a/DragablzDemo/BasicExampleTemplateModel.cs +++ b/DragablzDemo/BasicExampleTemplateModel.cs @@ -10,7 +10,7 @@ public class BasicExampleTemplateModel public BasicExampleTemplateModel(IInterTabClient interTabClient, object partition) { _interTabClient = interTabClient; - _partition = partition; + _partition = partition; } public IInterTabClient InterTabClient @@ -22,6 +22,6 @@ public object Partition { get { return _partition; } } - + } } \ No newline at end of file diff --git a/DragablzDemo/BasicExampleTemplateWindow.xaml.cs b/DragablzDemo/BasicExampleTemplateWindow.xaml.cs index 2a75177..2e35d8b 100644 --- a/DragablzDemo/BasicExampleTemplateWindow.xaml.cs +++ b/DragablzDemo/BasicExampleTemplateWindow.xaml.cs @@ -22,6 +22,6 @@ public partial class BasicExampleTemplateWindow : Window public BasicExampleTemplateWindow() { InitializeComponent(); - } + } } } diff --git a/DragablzDemo/Boot.cs b/DragablzDemo/Boot.cs index 97ba0f5..262c503 100644 --- a/DragablzDemo/Boot.cs +++ b/DragablzDemo/Boot.cs @@ -52,7 +52,7 @@ public static void Main(string[] args) //new HeaderedItemViewModel { Header = "Thu", Content = "Thursday's child has far to go" }, //new HeaderedItemViewModel { Header = "Fri", Content = "Friday's child loving and giving" }//, //new HeaderedItemViewModel { Header = "Sat", Content = "Saturday's child works hard for a living" }, - //new HeaderedItemViewModel { Header = "Sun", Content = "Sunday's child is awkwardly not fitting into this demo" } + //new HeaderedItemViewModel { Header = "Sun", Content = "Sunday's child is awkwardly not fitting into this demo" } ); boundExampleModel.ToolItems.Add( new HeaderedItemViewModel {Header = "January", Content = "Welcome to the January tool/float item."}); @@ -78,5 +78,5 @@ public static void Main(string[] args) } } - + } diff --git a/DragablzDemo/BoundExampleInterTabClient.cs b/DragablzDemo/BoundExampleInterTabClient.cs index 5de3dfc..98e3360 100644 --- a/DragablzDemo/BoundExampleInterTabClient.cs +++ b/DragablzDemo/BoundExampleInterTabClient.cs @@ -11,9 +11,9 @@ public class BoundExampleInterTabClient : IInterTabClient public INewTabHost GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source) { var view = new BoundExampleWindow(); - var model = new BoundExampleModel(); - view.DataContext = model; - return new NewTabHost(view, view.InitialTabablzControl); + var model = new BoundExampleModel(); + view.DataContext = model; + return new NewTabHost(view, view.InitialTabablzControl); } public TabEmptiedResponse TabEmptiedHandler(TabablzControl tabControl, Window window) diff --git a/DragablzDemo/BoundExampleModel.cs b/DragablzDemo/BoundExampleModel.cs index 184a50b..eb16cfc 100644 --- a/DragablzDemo/BoundExampleModel.cs +++ b/DragablzDemo/BoundExampleModel.cs @@ -55,7 +55,7 @@ public ItemActionCallback ClosingTabItemHandler /// /// Callback to handle tab closing. - /// + /// private static void ClosingTabItemHandlerImpl(ItemActionCallbackArgs args) { //in here you can dispose stuff or cancel the close @@ -65,7 +65,7 @@ private static void ClosingTabItemHandlerImpl(ItemActionCallbackArgs /// Callback to handle floating toolbar/MDI window closing. - /// + /// private static void ClosingFloatingItemHandlerImpl(ItemActionCallbackArgs args) { //in here you can dispose stuff or cancel the close - //here's your view model: + //here's your view model: var disposable = args.DragablzItem.DataContext as IDisposable; if (disposable != null) disposable.Dispose(); //here's how you can cancel stuff: - //args.Cancel(); + //args.Cancel(); } } } diff --git a/DragablzDemo/BoundExampleNewItem.cs b/DragablzDemo/BoundExampleNewItem.cs index 244efca..275b2ba 100644 --- a/DragablzDemo/BoundExampleNewItem.cs +++ b/DragablzDemo/BoundExampleNewItem.cs @@ -5,7 +5,7 @@ namespace DragablzDemo { public static class BoundExampleNewItem { - public static Func Factory + public static Func Factory { get { @@ -20,7 +20,7 @@ public static Func Factory Content = dateTime.ToString("R") }; }; - } + } } } } \ No newline at end of file diff --git a/DragablzDemo/CustomHeaderViewModel.cs b/DragablzDemo/CustomHeaderViewModel.cs index 3c1bca4..36c8f7a 100644 --- a/DragablzDemo/CustomHeaderViewModel.cs +++ b/DragablzDemo/CustomHeaderViewModel.cs @@ -26,7 +26,7 @@ public string Header #endif #if NET45 OnPropertyChanged(); -#endif +#endif } } @@ -42,7 +42,7 @@ public bool IsSelected #endif #if NET45 OnPropertyChanged(); -#endif +#endif } } diff --git a/DragablzDemo/LayoutManagementExampleViewModel.cs b/DragablzDemo/LayoutManagementExampleViewModel.cs index a832b0e..8098178 100644 --- a/DragablzDemo/LayoutManagementExampleViewModel.cs +++ b/DragablzDemo/LayoutManagementExampleViewModel.cs @@ -57,7 +57,7 @@ private void QueryLayouts() private static void FloatingItemsVisitor(TreeNode layoutNode, LayoutAccessor layoutAccessor) { var floatingItems = layoutAccessor.FloatingItems.ToList(); - var floatingItemsNode = new TreeNode {Content = "Floating Items " + floatingItems.Count}; + var floatingItemsNode = new TreeNode {Content = "Floating Items " + floatingItems.Count}; foreach (var floatingItemNode in floatingItems.Select(floatingItem => new TreeNode { Content = @@ -73,7 +73,7 @@ private static void FloatingItemsVisitor(TreeNode layoutNode, LayoutAccessor lay private static void TabablzControlVisitor(TreeNode treeNode, TabablzControl tabablzControl) { - treeNode.Children.Add(new TreeNode { Content = new TabablzControlProxy(tabablzControl) }); + treeNode.Children.Add(new TreeNode { Content = new TabablzControlProxy(tabablzControl) }); } private static void BranchAccessorVisitor(TreeNode treeNode, BranchAccessor branchAccessor) diff --git a/DragablzDemo/Properties/Annotations.cs b/DragablzDemo/Properties/Annotations.cs index 1e6b076..52f55e1 100644 --- a/DragablzDemo/Properties/Annotations.cs +++ b/DragablzDemo/Properties/Annotations.cs @@ -167,7 +167,7 @@ public NotifyPropertyChangedInvocatorAttribute(string parameterName) /// /// // A method that returns null if the parameter is null, and not null if the parameter is not null /// [ContractAnnotation("null => null; notnull => notnull")] - /// public object Transform(object data) + /// public object Transform(object data) /// /// /// [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")] @@ -293,7 +293,7 @@ public UsedImplicitlyAttribute( [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public sealed class MeansImplicitUseAttribute : Attribute { - public MeansImplicitUseAttribute() + public MeansImplicitUseAttribute() : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) @@ -312,7 +312,7 @@ public MeansImplicitUseAttribute( [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; } [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; } } - + [Flags] public enum ImplicitUseKindFlags { @@ -440,7 +440,7 @@ public sealed class AspMvcViewLocationFormatAttribute : Attribute { public AspMvcViewLocationFormatAttribute(string format) { } } - + /// /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter /// is an MVC action. If applied to a method, the MVC action name is calculated @@ -480,7 +480,7 @@ public AspMvcAreaAttribute([NotNull] string anonymousProperty) /// ASP.NET MVC attribute. If applied to a parameter, indicates that /// the parameter is an MVC controller. If applied to a method, /// the MVC controller name is calculated implicitly from the context. - /// Use this attribute for custom wrappers similar to + /// Use this attribute for custom wrappers similar to /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String) /// [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] @@ -530,7 +530,7 @@ public sealed class AspMvcSupressViewErrorAttribute : Attribute { } /// /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. - /// Use this attribute for custom wrappers similar to + /// Use this attribute for custom wrappers similar to /// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String) /// [AttributeUsage(AttributeTargets.Parameter)] @@ -606,7 +606,7 @@ public HtmlAttributeValueAttribute([NotNull] string name) /// /// Razor attribute. Indicates that a parameter or a method is a Razor section. - /// Use this attribute for custom wrappers similar to + /// Use this attribute for custom wrappers similar to /// System.Web.WebPages.WebPageBase.RenderSection(String) /// [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, Inherited = true)] diff --git a/DragablzDemo/Properties/AssemblyInfo.cs b/DragablzDemo/Properties/AssemblyInfo.cs index 5b904fd..386a83e 100644 --- a/DragablzDemo/Properties/AssemblyInfo.cs +++ b/DragablzDemo/Properties/AssemblyInfo.cs @@ -4,7 +4,7 @@ using System.Runtime.InteropServices; using System.Windows; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("SaucyDemo")] @@ -16,12 +16,12 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -//In order to begin building localizable applications, set +//In order to begin building localizable applications, set //CultureYouAreCodingWith in your .csproj file //inside a . For example, if you are using US english //in your source files, set the to en-US. Then uncomment @@ -33,10 +33,10 @@ [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, + //(used if a resource is not found in the page, // or application resource dictionaries) ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, + //(used if a resource is not found in the page, // app, or any theme specific resource dictionaries) )] @@ -44,11 +44,11 @@ // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] diff --git a/DragablzDemo/SimpleViewModel.cs b/DragablzDemo/SimpleViewModel.cs index 0da4584..f560559 100644 --- a/DragablzDemo/SimpleViewModel.cs +++ b/DragablzDemo/SimpleViewModel.cs @@ -8,7 +8,7 @@ namespace DragablzDemo public class SimpleViewModel : INotifyPropertyChanged { private bool _isSelected; - + public string Name { get; set; } public object SimpleContent { get; set; } @@ -25,7 +25,7 @@ public bool IsSelected #endif #if NET45 OnPropertyChanged(); -#endif +#endif } } diff --git a/DragablzDemo/TabablzControlProxy.cs b/DragablzDemo/TabablzControlProxy.cs index 37f6fce..949a006 100644 --- a/DragablzDemo/TabablzControlProxy.cs +++ b/DragablzDemo/TabablzControlProxy.cs @@ -58,7 +58,7 @@ private void Branch(Orientation orientation) } public event PropertyChangedEventHandler PropertyChanged; - + protected virtual void OnPropertyChanged(string propertyName) { var handler = PropertyChanged; From 929834ee585a279e3eb01c00263a3898eaabf6ea Mon Sep 17 00:00:00 2001 From: Jeremy Vignelles Date: Fri, 8 Jun 2018 15:08:36 +0200 Subject: [PATCH 2/4] Initial implementation of WindowStateSaver --- Dragablz.sln | 21 +- Dragablz/Core/Extensions.cs | 4 +- Dragablz/Dragablz.net40.csproj | 5 + Dragablz/Dragablz.net45.csproj | 5 + Dragablz/Savablz/BranchItemState.cs | 30 +++ Dragablz/Savablz/BranchState.cs | 48 ++++ Dragablz/Savablz/LayoutWindowState.cs | 60 +++++ Dragablz/Savablz/TabSetState.cs | 34 +++ Dragablz/Savablz/WindowsStateSaver.cs | 220 ++++++++++++++++++ DragablzSaveDemo/App.config | 18 ++ DragablzSaveDemo/App.xaml | 34 +++ DragablzSaveDemo/App.xaml.cs | 86 +++++++ DragablzSaveDemo/DragablzSaveDemo.csproj | 109 +++++++++ DragablzSaveDemo/MainWindow.xaml | 24 ++ DragablzSaveDemo/MainWindow.xaml.cs | 18 ++ DragablzSaveDemo/Properties/AssemblyInfo.cs | 55 +++++ .../Properties/Resources.Designer.cs | 71 ++++++ DragablzSaveDemo/Properties/Resources.resx | 117 ++++++++++ .../Properties/Settings.Designer.cs | 38 +++ DragablzSaveDemo/Properties/Settings.settings | 9 + DragablzSaveDemo/TabContentModel.cs | 22 ++ DragablzSaveDemo/TabContentViewModel.cs | 65 ++++++ DragablzSaveDemo/TabsViewModel.cs | 32 +++ DragablzSaveDemo/packages.config | 4 + 24 files changed, 1126 insertions(+), 3 deletions(-) create mode 100644 Dragablz/Savablz/BranchItemState.cs create mode 100644 Dragablz/Savablz/BranchState.cs create mode 100644 Dragablz/Savablz/LayoutWindowState.cs create mode 100644 Dragablz/Savablz/TabSetState.cs create mode 100644 Dragablz/Savablz/WindowsStateSaver.cs create mode 100644 DragablzSaveDemo/App.config create mode 100644 DragablzSaveDemo/App.xaml create mode 100644 DragablzSaveDemo/App.xaml.cs create mode 100644 DragablzSaveDemo/DragablzSaveDemo.csproj create mode 100644 DragablzSaveDemo/MainWindow.xaml create mode 100644 DragablzSaveDemo/MainWindow.xaml.cs create mode 100644 DragablzSaveDemo/Properties/AssemblyInfo.cs create mode 100644 DragablzSaveDemo/Properties/Resources.Designer.cs create mode 100644 DragablzSaveDemo/Properties/Resources.resx create mode 100644 DragablzSaveDemo/Properties/Settings.Designer.cs create mode 100644 DragablzSaveDemo/Properties/Settings.settings create mode 100644 DragablzSaveDemo/TabContentModel.cs create mode 100644 DragablzSaveDemo/TabContentViewModel.cs create mode 100644 DragablzSaveDemo/TabsViewModel.cs create mode 100644 DragablzSaveDemo/packages.config diff --git a/Dragablz.sln b/Dragablz.sln index 5b3e476..670bab7 100644 --- a/Dragablz.sln +++ b/Dragablz.sln @@ -1,6 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2026 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dragablz.net45", "Dragablz\Dragablz.net45.csproj", "{7B11011C-7FD7-4AB0-A1AD-04E940B026DE}" ProjectSection(ProjectDependencies) = postProject {B127C87D-C212-40D1-895E-3B6341E81C21} = {B127C87D-C212-40D1-895E-3B6341E81C21} @@ -14,6 +16,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dragablz.net40", "Dragablz\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DragablzDemo.net40", "DragablzDemo\DragablzDemo.net40.csproj", "{B127C87D-C212-40D1-895E-3B6341E81C21}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DragablzSaveDemo", "DragablzSaveDemo\DragablzSaveDemo.csproj", "{6709408B-A312-4CA3-B687-0FD22B5BFCF8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -74,8 +78,23 @@ Global {B127C87D-C212-40D1-895E-3B6341E81C21}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {B127C87D-C212-40D1-895E-3B6341E81C21}.Release|Mixed Platforms.Build.0 = Release|Any CPU {B127C87D-C212-40D1-895E-3B6341E81C21}.Release|x86.ActiveCfg = Release|Any CPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8}.Debug|x86.ActiveCfg = Debug|Any CPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8}.Debug|x86.Build.0 = Debug|Any CPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8}.Release|Any CPU.Build.0 = Release|Any CPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8}.Release|x86.ActiveCfg = Release|Any CPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {14740FC0-D2AE-4AD5-A428-D00E52009FFD} + EndGlobalSection EndGlobal diff --git a/Dragablz/Core/Extensions.cs b/Dragablz/Core/Extensions.cs index 3561f8c..ecd8b75 100644 --- a/Dragablz/Core/Extensions.cs +++ b/Dragablz/Core/Extensions.cs @@ -93,7 +93,7 @@ public static IEnumerable LogicalTreeAncestory(this Dependency } /// - /// Returns the actual Left of the Window independently from the WindowState + /// Returns the actual Left of the Window independently from the LayoutWindowState /// /// /// @@ -109,7 +109,7 @@ public static double GetActualLeft(this Window window) } /// - /// Returns the actual Top of the Window independently from the WindowState + /// Returns the actual Top of the Window independently from the LayoutWindowState /// /// /// diff --git a/Dragablz/Dragablz.net40.csproj b/Dragablz/Dragablz.net40.csproj index 1294fd7..b770792 100644 --- a/Dragablz/Dragablz.net40.csproj +++ b/Dragablz/Dragablz.net40.csproj @@ -108,6 +108,11 @@ + + + + + diff --git a/Dragablz/Dragablz.net45.csproj b/Dragablz/Dragablz.net45.csproj index 9120146..6c96f2d 100644 --- a/Dragablz/Dragablz.net45.csproj +++ b/Dragablz/Dragablz.net45.csproj @@ -110,6 +110,11 @@ + + + + + diff --git a/Dragablz/Savablz/BranchItemState.cs b/Dragablz/Savablz/BranchItemState.cs new file mode 100644 index 0000000..934ec73 --- /dev/null +++ b/Dragablz/Savablz/BranchItemState.cs @@ -0,0 +1,30 @@ +namespace Dragablz.Savablz +{ + /// + /// The item that is stored in a branch state (first or second) + /// + /// The tab item type + public class BranchItemState + { + /// + /// The generic constructor, used by the Json deserializer + /// + /// If this item is a branch, this parameter must contain the branch state (null otherwise) + /// If this item is a tab set, this parameter must contain the tab set state (null otherwise) + public BranchItemState(BranchState itemAsBranch, TabSetState itemAsTabSet) + { + this.ItemAsBranch = itemAsBranch; + this.ItemAsTabSet = itemAsTabSet; + } + + /// + /// The branch, if this item is a branch, null otherwise + /// + public BranchState ItemAsBranch { get; } + + /// + /// The tab set, if this item is a tab set, null otherwise + /// + public TabSetState ItemAsTabSet { get; } + } +} \ No newline at end of file diff --git a/Dragablz/Savablz/BranchState.cs b/Dragablz/Savablz/BranchState.cs new file mode 100644 index 0000000..8f67473 --- /dev/null +++ b/Dragablz/Savablz/BranchState.cs @@ -0,0 +1,48 @@ +namespace Dragablz.Savablz +{ + using System; + using System.Windows.Controls; + + /// + /// The state of a layout branching + /// + /// The type of the tab content model + public class BranchState + { + /// + /// The constructor + /// + /// The first child + /// The second child + /// The split orientation + /// The split ratio + public BranchState(BranchItemState firstChild, BranchItemState secondChild, + Orientation orientation, double ratio) + { + this.FirstChild = firstChild; + this.SecondChild = secondChild; + this.Orientation = orientation; + this.Ratio = ratio; + } + + /// + /// The first branch + /// + public BranchItemState FirstChild { get; } + + /// + /// The second branch + /// + public BranchItemState SecondChild { get; } + + /// + /// The split orientation + /// + public Orientation Orientation { get; } + + /// + /// The split ratio + /// + public double Ratio { get; } + } +} \ No newline at end of file diff --git a/Dragablz/Savablz/LayoutWindowState.cs b/Dragablz/Savablz/LayoutWindowState.cs new file mode 100644 index 0000000..a5f9047 --- /dev/null +++ b/Dragablz/Savablz/LayoutWindowState.cs @@ -0,0 +1,60 @@ +namespace Dragablz.Savablz +{ + using System.Windows; + + /// + /// Represents the state of a window + /// + /// The type of the tab content model + public class LayoutWindowState + { + /// + /// The constructor + /// + /// The X position of the window + /// The Y position of the window + /// The window width + /// The window height + /// The window state + /// The root of this layout + public LayoutWindowState(double x, double y, double width, double height, WindowState windowState, BranchItemState child) + { + this.X = x; + this.Y = y; + this.Width = width; + this.Height = height; + this.WindowState = windowState; + this.Child = child; + } + + /// + /// The window's X position + /// + public double X { get; } + + /// + /// The window's Y position + /// + public double Y { get; } + + /// + /// The window's width + /// + public double Width { get; } + + /// + /// The window's height + /// + public double Height { get; } + + /// + /// The window state (maximized, restored, minimize) + /// + public WindowState WindowState { get; } + + /// + /// The root of this layout + /// + public BranchItemState Child { get; } + } +} \ No newline at end of file diff --git a/Dragablz/Savablz/TabSetState.cs b/Dragablz/Savablz/TabSetState.cs new file mode 100644 index 0000000..d4541cd --- /dev/null +++ b/Dragablz/Savablz/TabSetState.cs @@ -0,0 +1,34 @@ +namespace Dragablz.Savablz +{ + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents the state of a TabSet, in a serializable way + /// + /// The type of the tab content model + public class TabSetState + { + /// + /// The constructor + /// + /// The index of the tab item that is currently selected in the TabSet + /// The tab items + public TabSetState(int? selectedTabItemIndex, IEnumerable tabItems) + { + this.SelectedTabItemIndex = selectedTabItemIndex; + this.TabItems = tabItems.ToArray(); + } + + /// + /// The tab item that is currently selected in the TabSet + /// + public int? SelectedTabItemIndex { get; } + + /// + /// The tab items + /// + public TTabModel[] TabItems { get; } + + } +} \ No newline at end of file diff --git a/Dragablz/Savablz/WindowsStateSaver.cs b/Dragablz/Savablz/WindowsStateSaver.cs new file mode 100644 index 0000000..f0c30d6 --- /dev/null +++ b/Dragablz/Savablz/WindowsStateSaver.cs @@ -0,0 +1,220 @@ +namespace Dragablz.Savablz +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Windows; + using System.Windows.Threading; + using Dragablz.Dockablz; + + /// + /// Saves/restore the state of the windows + /// + public static class WindowsStateSaver + { + /// + /// Gets the state of all windows in the app + /// + /// The type of tab model + /// The type of tab view model, currently displayed in the app. + /// The converter that transforms tab view models to models + /// The state of all windows + public static IEnumerable> GetWindowsState(Func tabContentModelConverter) + { + return Layout.GetLoadedInstances().Select(layout => GetLayoutState(layout, tabContentModelConverter)); + } + + /// + /// Gets the state of a single window + /// + /// The type of tab model + /// The type of tab view model, currently displayed in the app. + /// The layout to be inspected + /// The converter that transforms tab view models to models + /// The state of the specified window + private static LayoutWindowState GetLayoutState(Layout layout, Func tabContentModelConverter) + { + var window = Window.GetWindow(layout) ?? throw new InvalidOperationException("The layout is not bound to any window"); + + var layoutAccessor = layout.Query(); + + BranchItemState root = null; + layoutAccessor.Visit( + branchVisitor => root = new BranchItemState(GetBranchState(branchVisitor, tabContentModelConverter), null), + tabablzControl => root = new BranchItemState(null, GetTabSetState(tabablzControl, tabContentModelConverter)) + ); + + return new LayoutWindowState(window.Left, window.Top, window.Width, window.Height, window.WindowState, root); + } + + /// + /// Gets the state of a branch + /// + /// The type of tab model + /// The type of tab view model, currently displayed in the app. + /// The branch to be inspected + /// The converter that transforms tab view models to models + /// The read state of the branch + private static BranchState GetBranchState(BranchAccessor branchVisitor, Func tabContentModelConverter) + { + BranchItemState firstState = null; + BranchItemState secondState = null; + + if (branchVisitor.FirstItemBranchAccessor != null) + { + firstState = new BranchItemState(GetBranchState(branchVisitor.FirstItemBranchAccessor, tabContentModelConverter), null); + } + else + { + firstState = new BranchItemState(null, GetTabSetState(branchVisitor.FirstItemTabablzControl, tabContentModelConverter)); + } + + if (branchVisitor.SecondItemBranchAccessor != null) + { + secondState = new BranchItemState(GetBranchState(branchVisitor.SecondItemBranchAccessor, tabContentModelConverter), null); + } + else + { + secondState = new BranchItemState(null, GetTabSetState(branchVisitor.SecondItemTabablzControl, tabContentModelConverter)); + } + + return new BranchState( + firstState, + secondState, + branchVisitor.Branch.Orientation, + branchVisitor.Branch.GetFirstProportion()); + } + + /// + /// Gets the state of a TabablzControl so that it can be serialized + /// + /// The type of tab model + /// The type of tab view model, currently displayed in the app. + /// The control to be + /// The converter that transforms tab view models to models + /// The state of the tab set + public static TabSetState GetTabSetState(TabablzControl tabablzControl, Func tabContentModelConverter) + { + int? selectedIndex = tabablzControl.SelectedIndex; + if (selectedIndex == -1) + { + selectedIndex = null; + } + + return new TabSetState(selectedIndex, tabablzControl.Items.Cast().Select(tabContentModelConverter)); + } + + /// + /// Restors the state of all windows + /// + /// The type of tab model + /// The type of tab view model to be displayed in the app. + /// The initial tabablz control that will be used for restore + /// The state of the windows + /// The function that creates the view model based on a model + public static void RestoreWindowsState(TabablzControl windowInitialTabablzControl, LayoutWindowState[] layoutWindowsState, Func viewModelFactory) + { + if (!layoutWindowsState.Any()) + { + return; + } + + var mainWindowState = layoutWindowsState[0]; + var mainWindow = Window.GetWindow(windowInitialTabablzControl) ?? throw new InvalidOperationException("Window not found"); + mainWindow.Width = mainWindowState.Width; + mainWindow.Height = mainWindowState.Height; + mainWindow.Left = mainWindowState.X; + mainWindow.Top = mainWindowState.Y; + mainWindow.WindowState = mainWindowState.WindowState; + + RestoreBranchItemState(windowInitialTabablzControl, mainWindowState.Child, viewModelFactory); + + foreach (var windowState in layoutWindowsState.Skip(1)) + { + var interTabController = windowInitialTabablzControl.InterTabController; + var newHost = interTabController.InterTabClient.GetNewHost(interTabController.InterTabClient, interTabController.Partition, windowInitialTabablzControl); + newHost.Container.Width = windowState.Width; + newHost.Container.Height = windowState.Height; + newHost.Container.Left = windowState.X; + newHost.Container.Top = windowState.Y; + newHost.Container.WindowState = windowState.WindowState; + newHost.Container.Show(); + RestoreBranchItemState(newHost.TabablzControl, windowState.Child, viewModelFactory); + } + } + + /// + /// Restores the state of the tabSet + /// + /// The type of tab model + /// The type of tab view model to be displayed in the app. + /// The control in which to restore the items + /// The state of the tab set to be restored + /// The function that creates the view model based on a model + public static void RestoreTabSetState(TabablzControl tabablzControl, TabSetState tabSetState, Func viewModelFactory) + { + foreach (var tabModel in tabSetState.TabItems) + { + tabablzControl.AddToSource(viewModelFactory(tabModel)); + } + + tabablzControl.Dispatcher.BeginInvoke(new Action(() => + { + tabablzControl.SelectedIndex = tabSetState.SelectedTabItemIndex ?? -1; + }), DispatcherPriority.Loaded); + } + + /// + /// Restores the state of the branch + /// + /// The type of tab model + /// The type of tab view model to be displayed in the app. + /// The control in which to restore the items + /// The state of the branch to be restored + /// The function that creates the view model based on a model + private static void RestoreBranchState(TabablzControl tabablzControl, BranchState branchState, Func viewModelFactory) + { + var branchResult = Layout.Branch(tabablzControl, CopyTabablzControl(tabablzControl), branchState.Orientation, false, branchState.Ratio); + RestoreBranchItemState(tabablzControl, branchState.FirstChild, viewModelFactory); + RestoreBranchItemState(branchResult.TabablzControl, branchState.SecondChild, viewModelFactory); + } + + /// + /// Restores the state of a branch item + /// + /// The type of tab model + /// The type of tab view model to be displayed in the app. + /// The control in which to restore the items + /// The state of the branch item to be restored + /// The function that creates the view model based on a model + private static void RestoreBranchItemState(TabablzControl tabablzControl, BranchItemState branchItemState, Func viewModelFactory) + { + if (branchItemState.ItemAsTabSet != null) + { + RestoreTabSetState(tabablzControl, branchItemState.ItemAsTabSet, viewModelFactory); + } + else if(branchItemState.ItemAsBranch != null) + { + RestoreBranchState(tabablzControl, branchItemState.ItemAsBranch, viewModelFactory); + } + } + + /// + /// Creates a new TabablzControl based on the specified control + /// + /// The control to copy + /// The created control + private static TabablzControl CopyTabablzControl(TabablzControl tabablzControl) + { + var result = new TabablzControl + { + InterTabController = new InterTabController + { + InterTabClient = tabablzControl.InterTabController.InterTabClient, + Partition = tabablzControl.InterTabController.Partition + } + }; + return result; + } + } +} \ No newline at end of file diff --git a/DragablzSaveDemo/App.config b/DragablzSaveDemo/App.config new file mode 100644 index 0000000..ede2737 --- /dev/null +++ b/DragablzSaveDemo/App.config @@ -0,0 +1,18 @@ + + + + +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/DragablzSaveDemo/App.xaml b/DragablzSaveDemo/App.xaml new file mode 100644 index 0000000..9bdf6cf --- /dev/null +++ b/DragablzSaveDemo/App.xaml @@ -0,0 +1,34 @@ + + + + + + + + + + diff --git a/DragablzSaveDemo/App.xaml.cs b/DragablzSaveDemo/App.xaml.cs new file mode 100644 index 0000000..c0103d7 --- /dev/null +++ b/DragablzSaveDemo/App.xaml.cs @@ -0,0 +1,86 @@ +using System.Windows; + +namespace DragablzSaveDemo +{ + using Dragablz.Savablz; + using DragablzSaveDemo.Properties; + using Newtonsoft.Json; + using System; + using System.ComponentModel; + using System.Linq; + + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + /// + /// This method is called on application startup + /// + /// The event arguments + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + + var viewModel = new TabsViewModel(); + var window = new MainWindow + { + DataContext = viewModel + }; + + // A choice has been made for this app : There is a main window, and you can create other windows. + // The app exits when the main window is closed, whether or not there are other windows open. + // When the main window is closing, save the state into the settings + window.Closing += this.MainWindow_Closing; + + var l = Settings.Default.Layout; + + if (string.IsNullOrWhiteSpace(l)) + { + // Default layout and tabs + for (var i = 0 ; i < 4 ; i++) + { + viewModel.TabContents.Add(new TabContentViewModel(new TabContentModel(Guid.NewGuid().ToString()))); + } + window.Show(); + } + else + { + // Restore layout + var windowsState = JsonConvert.DeserializeObject[]>(l); + window.Show(); + WindowsStateSaver.RestoreWindowsState(window.InitialTabablzControl, windowsState, m => new TabContentViewModel(m)); + } + } + + /// + /// Called when the main window is closing + /// + /// The sender + /// The event args + private void MainWindow_Closing(object sender, CancelEventArgs e) + { + // Saves the layout and exit + var windowsState = + WindowsStateSaver.GetWindowsState(vm => + new TabContentModel(vm.Header)); + + if (windowsState.First().Child == null) + { + // All tabs in the main window have been closed. + // A choice have been made for this sample app : When all tabs in the main window have been closed, + // resets the settings so that a fresh window is created next time. + // Feel free to implement that the way you want here + Settings.Default.Layout = null; + } + else + { + Settings.Default.Layout = JsonConvert.SerializeObject(windowsState, Formatting.None); + } + + Settings.Default.Save(); + + this.Shutdown(); + } + } +} diff --git a/DragablzSaveDemo/DragablzSaveDemo.csproj b/DragablzSaveDemo/DragablzSaveDemo.csproj new file mode 100644 index 0000000..adc946f --- /dev/null +++ b/DragablzSaveDemo/DragablzSaveDemo.csproj @@ -0,0 +1,109 @@ + + + + + Debug + AnyCPU + {6709408B-A312-4CA3-B687-0FD22B5BFCF8} + WinExe + DragablzSaveDemo + DragablzSaveDemo + v4.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + {7B11011C-7FD7-4AB0-A1AD-04E940B026DE} + Dragablz.net45 + + + + \ No newline at end of file diff --git a/DragablzSaveDemo/MainWindow.xaml b/DragablzSaveDemo/MainWindow.xaml new file mode 100644 index 0000000..93fb2b1 --- /dev/null +++ b/DragablzSaveDemo/MainWindow.xaml @@ -0,0 +1,24 @@ + + + DragablzSaveDemo + + + + + + + + + diff --git a/DragablzSaveDemo/MainWindow.xaml.cs b/DragablzSaveDemo/MainWindow.xaml.cs new file mode 100644 index 0000000..8771e9f --- /dev/null +++ b/DragablzSaveDemo/MainWindow.xaml.cs @@ -0,0 +1,18 @@ +using System.Windows; + +namespace DragablzSaveDemo +{ + /// + /// The windows of this app + /// + public partial class MainWindow : Window + { + /// + /// The constructor + /// + public MainWindow() + { + this.InitializeComponent(); + } + } +} diff --git a/DragablzSaveDemo/Properties/AssemblyInfo.cs b/DragablzSaveDemo/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a156844 --- /dev/null +++ b/DragablzSaveDemo/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// Les informations générales relatives à un assembly dépendent de +// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations +// associées à un assembly. +[assembly: AssemblyTitle("DragablzSaveDemo")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("DragablzSaveDemo")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly +// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de +// COM, affectez la valeur true à l'attribut ComVisible sur ce type. +[assembly: ComVisible(false)] + +//Pour commencer à générer des applications localisables, définissez +//CultureUtiliséePourCoder dans votre fichier .csproj +//dans . Par exemple, si vous utilisez le français +//dans vos fichiers sources, définissez à fr-FR. Puis, supprimez les marques de commentaire de +//l'attribut NeutralResourceLanguage ci-dessous. Mettez à jour "fr-FR" dans +//la ligne ci-après pour qu'elle corresponde au paramètre UICulture du fichier projet. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //où se trouvent les dictionnaires de ressources spécifiques à un thème + //(utilisé si une ressource est introuvable dans la page, + // ou dictionnaires de ressources de l'application) + ResourceDictionaryLocation.SourceAssembly //où se trouve le dictionnaire de ressources générique + //(utilisé si une ressource est introuvable dans la page, + // dans l'application ou dans l'un des dictionnaires de ressources spécifiques à un thème) +)] + + +// Les informations de version pour un assembly se composent des quatre valeurs suivantes : +// +// Version principale +// Version secondaire +// Numéro de build +// Révision +// +// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut +// en utilisant '*', comme indiqué ci-dessous : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DragablzSaveDemo/Properties/Resources.Designer.cs b/DragablzSaveDemo/Properties/Resources.Designer.cs new file mode 100644 index 0000000..f21a646 --- /dev/null +++ b/DragablzSaveDemo/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Ce code a été généré par un outil. +// Version du runtime :4.0.30319.42000 +// +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. +// +//------------------------------------------------------------------------------ + +namespace DragablzSaveDemo.Properties +{ + + + /// + /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. + /// + // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder + // à l'aide d'un outil, tel que ResGen ou Visual Studio. + // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen + // avec l'option /str ou régénérez votre projet VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DragablzSaveDemo.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Remplace la propriété CurrentUICulture du thread actuel pour toutes + /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/DragablzSaveDemo/Properties/Resources.resx b/DragablzSaveDemo/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/DragablzSaveDemo/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DragablzSaveDemo/Properties/Settings.Designer.cs b/DragablzSaveDemo/Properties/Settings.Designer.cs new file mode 100644 index 0000000..5415473 --- /dev/null +++ b/DragablzSaveDemo/Properties/Settings.Designer.cs @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +// +// Ce code a été généré par un outil. +// Version du runtime :4.0.30319.42000 +// +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. +// +//------------------------------------------------------------------------------ + +namespace DragablzSaveDemo.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.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 { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string Layout { + get { + return ((string)(this["Layout"])); + } + set { + this["Layout"] = value; + } + } + } +} diff --git a/DragablzSaveDemo/Properties/Settings.settings b/DragablzSaveDemo/Properties/Settings.settings new file mode 100644 index 0000000..b7a50a2 --- /dev/null +++ b/DragablzSaveDemo/Properties/Settings.settings @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/DragablzSaveDemo/TabContentModel.cs b/DragablzSaveDemo/TabContentModel.cs new file mode 100644 index 0000000..d974df7 --- /dev/null +++ b/DragablzSaveDemo/TabContentModel.cs @@ -0,0 +1,22 @@ +namespace DragablzSaveDemo +{ + /// + /// The serializable model that stores the state of the tab + /// + public class TabContentModel + { + /// + /// The constructor + /// + /// The tab content + public TabContentModel(string content) + { + this.Content = content; + } + + /// + /// The tab content + /// + public string Content {get;} + } +} \ No newline at end of file diff --git a/DragablzSaveDemo/TabContentViewModel.cs b/DragablzSaveDemo/TabContentViewModel.cs new file mode 100644 index 0000000..7781db0 --- /dev/null +++ b/DragablzSaveDemo/TabContentViewModel.cs @@ -0,0 +1,65 @@ +namespace DragablzSaveDemo +{ + using System.ComponentModel; + using System.Runtime.CompilerServices; + using System.Windows.Controls; + using System.Windows.Documents; + + /// + /// A tab content + /// + public class TabContentViewModel: INotifyPropertyChanged + { + /// + /// The header + /// + private string _header; + + /// + /// The constructor + /// + /// The model to be displayed on the tab + public TabContentViewModel(TabContentModel model) + { + this._header = model.Content; + + // I personally don't find it great to put a control in the ViewModel. Maybe we should use a converter or a datatemplate for that? + this.Control = new TextBlock(new Run(model.Content)); + } + + /// + /// The tab header + /// + public string Header + { + get => this._header; + set + { + if (this._header != value) + { + this._header = value; + this.OnPropertyChanged(); + } + } + } + + /// + /// The control that is displayed in the tab + /// + public TextBlock Control { get; } + + /// + /// The event that is raised when a property value is changed. + /// + public event PropertyChangedEventHandler PropertyChanged; + + /// + /// Raises the event + /// + /// The name of the property that was changed + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} \ No newline at end of file diff --git a/DragablzSaveDemo/TabsViewModel.cs b/DragablzSaveDemo/TabsViewModel.cs new file mode 100644 index 0000000..cb64759 --- /dev/null +++ b/DragablzSaveDemo/TabsViewModel.cs @@ -0,0 +1,32 @@ +namespace DragablzSaveDemo +{ + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + + /// + /// The view model that contains the tabs status. + /// + public class TabsViewModel + { + private readonly ObservableCollection _tabContents; + + /// + /// Constructor + /// + public TabsViewModel() + { + this._tabContents = new ObservableCollection(); + } + + /// + /// The content of the tabs + /// + public ObservableCollection TabContents => this._tabContents; + + /// + /// The factory that creates new viewModels + /// + public static Func NewItemFactory => () => new TabContentViewModel(new TabContentModel(Guid.NewGuid().ToString())); + } +} \ No newline at end of file diff --git a/DragablzSaveDemo/packages.config b/DragablzSaveDemo/packages.config new file mode 100644 index 0000000..c8b3ae6 --- /dev/null +++ b/DragablzSaveDemo/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From 2286f43f06c131f6e59f61d8e129a8ed57dada66 Mon Sep 17 00:00:00 2001 From: Jeremy Vignelles Date: Tue, 26 Jun 2018 15:51:29 +0200 Subject: [PATCH 3/4] Revert use of "?? throw" expressions to support appveyor build --- Dragablz/Savablz/WindowsStateSaver.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Dragablz/Savablz/WindowsStateSaver.cs b/Dragablz/Savablz/WindowsStateSaver.cs index f0c30d6..585f469 100644 --- a/Dragablz/Savablz/WindowsStateSaver.cs +++ b/Dragablz/Savablz/WindowsStateSaver.cs @@ -34,7 +34,11 @@ public static IEnumerable> GetWindowsStateThe state of the specified window private static LayoutWindowState GetLayoutState(Layout layout, Func tabContentModelConverter) { - var window = Window.GetWindow(layout) ?? throw new InvalidOperationException("The layout is not bound to any window"); + var window = Window.GetWindow(layout); + if (window == null) + { + throw new InvalidOperationException("The layout is not bound to any window"); + } var layoutAccessor = layout.Query(); @@ -120,7 +124,12 @@ public static void RestoreWindowsState(TabablzControl } var mainWindowState = layoutWindowsState[0]; - var mainWindow = Window.GetWindow(windowInitialTabablzControl) ?? throw new InvalidOperationException("Window not found"); + var mainWindow = Window.GetWindow(windowInitialTabablzControl); + if (mainWindow == null) + { + throw new InvalidOperationException("Window not found"); + } + mainWindow.Width = mainWindowState.Width; mainWindow.Height = mainWindowState.Height; mainWindow.Left = mainWindowState.X; From 3d27ea7d0028dc5c40177033382972398a26d6fe Mon Sep 17 00:00:00 2001 From: Jeremy Vignelles Date: Tue, 26 Jun 2018 16:02:37 +0200 Subject: [PATCH 4/4] removed expression-bodied members to make appveyor happy --- DragablzSaveDemo/TabContentViewModel.cs | 6 +++++- DragablzSaveDemo/TabsViewModel.cs | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/DragablzSaveDemo/TabContentViewModel.cs b/DragablzSaveDemo/TabContentViewModel.cs index 7781db0..3e7a955 100644 --- a/DragablzSaveDemo/TabContentViewModel.cs +++ b/DragablzSaveDemo/TabContentViewModel.cs @@ -32,7 +32,11 @@ public TabContentViewModel(TabContentModel model) /// public string Header { - get => this._header; + get + { + return this._header; + } + set { if (this._header != value) diff --git a/DragablzSaveDemo/TabsViewModel.cs b/DragablzSaveDemo/TabsViewModel.cs index cb64759..972746b 100644 --- a/DragablzSaveDemo/TabsViewModel.cs +++ b/DragablzSaveDemo/TabsViewModel.cs @@ -22,7 +22,13 @@ public TabsViewModel() /// /// The content of the tabs /// - public ObservableCollection TabContents => this._tabContents; + public ObservableCollection TabContents + { + get + { + return this._tabContents; + } + } /// /// The factory that creates new viewModels