Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirkster99 committed Aug 21, 2020
2 parents 8222d91 + 9e0b0fb commit ca21eca
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 39 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ to also theme standard elements, such as, button and textblock etc.
- [#187 Allow to serialize CanClose if set to true for LayoutAnchorable instance](https://github.com/Dirkster99/AvalonDock/pull/187)
- [#188 Handle CanClose and CanHide in XAML](https://github.com/Dirkster99/AvalonDock/pull/188)

- Removed the additional [ToolTip](https://github.com/Dirkster99/AvalonDock/commit/5554de5c4bfadc37f974ba29803dc792b54f00d0) and [ContextMenu](https://github.com/Dirkster99/AvalonDock/commit/103e1068bc9f5bae8fef275a0e785393b4115764) styles from the Generic.xaml in VS2013 [more details here](https://github.com/Dirkster99/AvalonDock/pull/170#issuecomment-674253874)

## Fixes & Features added in Version 4.3

- Localized labels in [NavigatorWindow](https://github.com/Dirkster99/AvalonDock/wiki/NavigatorWindow)
Expand Down
20 changes: 17 additions & 3 deletions source/Components/AvalonDock.Themes.Aero/Theme.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
************************************************************************
AvalonDock
Expand Down Expand Up @@ -1059,9 +1059,23 @@
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Visible" />
</MultiDataTrigger>
<DataTrigger Binding="{Binding Path=CanClose}" Value="false">
<!--BD: 17.08.2020 use HideCommand if CanClose=false but CanHide=true-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Command" Value="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="DocumentCloseButton" Property="ToolTip" Value="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" />
</MultiDataTrigger>
<!--BD: 17.08.2020 hide button if both CanClose=false and CanHide=false-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</MultiDataTrigger>


</ControlTemplate.Triggers>
Expand Down
20 changes: 17 additions & 3 deletions source/Components/AvalonDock.Themes.Expression/Theme.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
************************************************************************
AvalonDock
Expand Down Expand Up @@ -926,9 +926,23 @@
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Visible" />
</Trigger>
<DataTrigger Binding="{Binding Path=CanClose}" Value="false">
<!--BD: 17.08.2020 use HideCommand if CanClose=false but CanHide=true-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Command" Value="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="DocumentCloseButton" Property="ToolTip" Value="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" />
</MultiDataTrigger>
<!--BD: 17.08.2020 hide button if both CanClose=false and CanHide=false-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</MultiDataTrigger>
<Trigger SourceName="DocumentCloseButton" Property="IsMouseOver" Value="True">
<Setter TargetName="PART_ImgPinClose" Property="Source" Value="/AvalonDock.Themes.Expression;component/Images/PinClose_Light.png" />
</Trigger>
Expand Down
20 changes: 17 additions & 3 deletions source/Components/AvalonDock.Themes.Metro/Theme.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
************************************************************************
AvalonDock
Expand Down Expand Up @@ -1088,9 +1088,23 @@
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Visible" />
<Setter TargetName="PART_ImgPinClose" Property="Source" Value="Images/PinClose_Dark.png" />
</MultiDataTrigger>
<DataTrigger Binding="{Binding Path=CanClose}" Value="false">
<!--BD: 17.08.2020 use HideCommand if CanClose=false but CanHide=true-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Command" Value="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="DocumentCloseButton" Property="ToolTip" Value="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" />
</MultiDataTrigger>
<!--BD: 17.08.2020 hide button if both CanClose=false and CanHide=false-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</MultiDataTrigger>
<Trigger SourceName="DocumentCloseButton" Property="IsMouseOver" Value="True">
<Setter TargetName="PART_ImgPinClose" Property="Source" Value="Images/PinClose_Black.png" />
</Trigger>
Expand Down
20 changes: 17 additions & 3 deletions source/Components/AvalonDock.Themes.VS2010/Theme.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
************************************************************************
AvalonDock
Expand Down Expand Up @@ -1134,9 +1134,23 @@
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Visible" />
<Setter TargetName="PART_ImgPinClose" Property="Source" Value="Images/PinClose_Dark.png" />
</MultiDataTrigger>
<DataTrigger Binding="{Binding Path=CanClose}" Value="false">
<!--BD: 17.08.2020 use HideCommand if CanClose=false but CanHide=true-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Command" Value="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="DocumentCloseButton" Property="ToolTip" Value="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" />
</MultiDataTrigger>
<!--BD: 17.08.2020 hide button if both CanClose=false and CanHide=false-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</MultiDataTrigger>
<Trigger SourceName="DocumentCloseButton" Property="IsMouseOver" Value="True">
<Setter TargetName="PART_ImgPinClose" Property="Source" Value="Images/PinClose_Black.png" />
</Trigger>
Expand Down
18 changes: 16 additions & 2 deletions source/Components/AvalonDock.Themes.VS2013/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1425,9 +1425,23 @@
<DataTrigger Binding="{Binding Path=IsActive}" Value="true">
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=CanClose}" Value="false">
<!--BD: 17.08.2020 use HideCommand if CanClose=false but CanHide=true-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Command" Value="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="DocumentCloseButton" Property="ToolTip" Value="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" />
</MultiDataTrigger>
<!--BD: 17.08.2020 hide button if both CanClose=false and CanHide=false-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</MultiDataTrigger>

<!-- Document Well : Tab : Button / Selected, inactive -->
<MultiDataTrigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,8 @@ protected override void Drop(LayoutAnchorableFloatingWindow floatingWindow)
checkPreviousContainer = false;
}

anchorableToImport.SetCanCloseInternal(true);
// BD: 17.08.2020 Remove that bodge and handle CanClose=false && CanHide=true in XAML
//anchorableToImport.SetCanCloseInternal(true);

paneModel.Children.Insert(i, anchorableToImport);
i++;
Expand Down Expand Up @@ -606,4 +607,4 @@ public override Geometry GetPreviewPath(OverlayWindow overlayWindow,

#endregion Overrides
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ protected override void Drop(LayoutAnchorableFloatingWindow floatingWindow)
int i = 0;
foreach (var anchorableToImport in layoutAnchorablePaneGroup.Descendents().OfType<LayoutAnchorable>().ToArray())
{
anchorableToImport.SetCanCloseInternal(true);
// BD: 18.07.2020 Remove that bodge and handle CanClose=false && CanHide=true in XAML
//anchorableToImport.SetCanCloseInternal(true);

paneModel.Children.Insert(i, anchorableToImport);
i++;
Expand Down Expand Up @@ -145,4 +146,4 @@ public override Geometry GetPreviewPath(OverlayWindow overlayWindow,

#endregion Overrides
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,12 @@ private void UpdateDragDetails()
private void StartDraggingFloatingWindowForContent()
{
ReleaseMouseCapture();
if (Model is LayoutAnchorable layoutAnchorable) layoutAnchorable.ResetCanCloseInternal();
// BD: 17.08.2020 Remove that bodge and handle CanClose=false && CanHide=true in XAML
//if (Model is LayoutAnchorable layoutAnchorable) layoutAnchorable.ResetCanCloseInternal();
var manager = Model.Root.Manager;
manager.StartDraggingFloatingWindowForContent(Model);
}

#endregion Private Methods
}
}
}
30 changes: 17 additions & 13 deletions source/Components/AvalonDock/Layout/LayoutAnchorable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/************************************************************************
/************************************************************************
AvalonDock
Copyright (C) 2007-2013 Xceed Software Inc.
Expand Down Expand Up @@ -34,7 +34,8 @@ public class LayoutAnchorable : LayoutContent
private bool _canHide = true;
private bool _canAutoHide = true;
private bool _canDockAsTabbedDocument = true;
private bool _canCloseValueBeforeInternalSet;
// BD: 17.08.2020 Remove that bodge and handle CanClose=false && CanHide=true in XAML
//private bool _canCloseValueBeforeInternalSet;
private bool _canMove = true;

#endregion fields
Expand All @@ -45,7 +46,9 @@ public class LayoutAnchorable : LayoutContent
public LayoutAnchorable()
{
// LayoutAnchorable will hide by default, not close.
_canClose = false;
// BD: 14.08.2020 Inverting both _canClose and _canCloseDefault to false as anchorables are only hidden but not closed
// That would allow CanClose to be properly serialized if set to true for an instance of LayoutAnchorable
_canClose = _canCloseDefault = false;
}

#endregion Constructors
Expand Down Expand Up @@ -575,16 +578,17 @@ internal void CloseAnchorable()
CloseInternal();
}

internal void SetCanCloseInternal(bool canClose)
{
_canCloseValueBeforeInternalSet = _canClose;
_canClose = canClose;
}
// BD: 17.08.2020 Remove that bodge and handle CanClose=false && CanHide=true in XAML
//internal void SetCanCloseInternal(bool canClose)
//{
// _canCloseValueBeforeInternalSet = _canClose;
// _canClose = canClose;
//}

internal void ResetCanCloseInternal()
{
_canClose = _canCloseValueBeforeInternalSet;
}
//internal void ResetCanCloseInternal()
//{
// _canClose = _canCloseValueBeforeInternalSet;
//}

#endregion Internal Methods

Expand All @@ -608,4 +612,4 @@ private void UpdateParentVisibility()

#endregion Private Methods
}
}
}
12 changes: 9 additions & 3 deletions source/Components/AvalonDock/Layout/LayoutContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,10 @@ public ImageSource IconSource

#region CanClose

internal bool _canClose = true;
// BD: 14.08.2020 added _canCloseDefault to properly implement inverting _canClose default value in inheritors (e.g. LayoutAnchorable)
// Thus CanClose property will be serialized only when not equal to its default for given class
// With previous code it was not possible to serialize CanClose if set to true for LayoutAnchorable instance
internal bool _canClose = true, _canCloseDefault = true;

public bool CanClose
{
Expand Down Expand Up @@ -559,7 +562,10 @@ public virtual void WriteXml(System.Xml.XmlWriter writer)
if (FloatingHeight != 0.0) writer.WriteAttributeString(nameof(FloatingHeight), FloatingHeight.ToString(CultureInfo.InvariantCulture));

if (IsMaximized) writer.WriteAttributeString(nameof(IsMaximized), IsMaximized.ToString());
if (!CanClose) writer.WriteAttributeString(nameof(CanClose), CanClose.ToString());
// BD: 14.08.2020 changed to check CanClose value against the default in _canCloseDefault
// thus CanClose property will be serialized only when not equal to its default for given class
// With previous code it was not possible to serialize CanClose if set to true for LayoutAnchorable instance
if (CanClose != _canCloseDefault) writer.WriteAttributeString(nameof(CanClose), CanClose.ToString());
if (!CanFloat) writer.WriteAttributeString(nameof(CanFloat), CanFloat.ToString());

if (LastActivationTimeStamp != null) writer.WriteAttributeString(nameof(LastActivationTimeStamp), LastActivationTimeStamp.Value.ToString(CultureInfo.InvariantCulture));
Expand Down Expand Up @@ -760,4 +766,4 @@ protected virtual void InternalDock()

#endregion Internal Methods
}
}
}
20 changes: 17 additions & 3 deletions source/Components/AvalonDock/Themes/generic.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
************************************************************************
AvalonDock
Expand Down Expand Up @@ -799,9 +799,23 @@
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Visible" />
</MultiDataTrigger>
<DataTrigger Binding="{Binding Path=CanClose}" Value="false">
<!--BD: 17.08.2020 use HideCommand if CanClose=false but CanHide=true-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Command" Value="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="DocumentCloseButton" Property="ToolTip" Value="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" />
</MultiDataTrigger>
<!--BD: 17.08.2020 hide button if both CanClose=false and CanHide=false-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
Expand Down

0 comments on commit ca21eca

Please sign in to comment.