Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,841 changes: 1,424 additions & 1,417 deletions source/Components/AvalonDock.Themes.VS2013/Themes/Generic.xaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,21 @@ private void UpdateMargins()
return;
// The content control in the grid, this has a different tree to walk up
var layoutContent = (LayoutContent)contentControl.Content;
if (grid != null && layoutContent.Content is FrameworkElement content)
if (grid != null)
{
FrameworkElement content = null;
var contentObj = layoutContent.Content;

if (contentObj is ILayoutContentElement layoutContentElement)
{
content = layoutContentElement.Content;
}
else if (contentObj is FrameworkElement frameworkElement)
{
content = frameworkElement;
}

if (content == null) return;
var parents = content.GetParents().ToArray();
var children = this.GetChildrenRecursive()
.TakeWhile(c => c != grid)
Expand Down Expand Up @@ -519,27 +532,30 @@ private void UpdateWindowsSizeBasedOnMinSize()
.Select(c => c.Content)
.OfType<LayoutContent>()
.Select(lc => lc.Content);
var contents = layoutContents.OfType<FrameworkElement>();
var contents = layoutContents.Select(obj => obj is ILayoutContentElement elem
? elem.Content
: obj as FrameworkElement)
.Where(fe => fe != null);
foreach (var content in contents)
{
ContentMinHeight = Math.Max(content.MinHeight, ContentMinHeight);
ContentMinWidth = Math.Max(content.MinWidth, ContentMinWidth);
if ((this.Model?.Root?.Manager?.AutoWindowSizeWhenOpened).GetValueOrDefault())
{
var parent = content.GetParents()
.OfType<FrameworkElement>()
.FirstOrDefault();
// StackPanels among others have an ActualHeight larger than visible, hence we check the parent control as well
if (content.ActualHeight < content.MinHeight ||
parent != null && parent.ActualHeight < content.MinHeight)
content.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
var desiredWidth = content.DesiredSize.Width;
var desiredHeight = content.DesiredSize.Height;

if (desiredHeight > 0)
{
Height = content.MinHeight + TotalMargin.Top + TotalMargin.Bottom;
var contentHeight = Math.Max(desiredHeight, content.MinHeight);
Height = contentHeight + TotalMargin.Top + TotalMargin.Bottom;
}

if (content.ActualWidth < content.MinWidth ||
parent != null && parent.ActualWidth < content.MinWidth)
if (desiredWidth > 0)
{
Width = content.MinWidth + TotalMargin.Left + TotalMargin.Right;
var contentWidth = Math.Max(desiredWidth, content.MinWidth);
Width = contentWidth + TotalMargin.Left + TotalMargin.Right;
}
}
}
Expand Down Expand Up @@ -730,9 +746,9 @@ private void InternalOnActivated(object sender, EventArgs e, int retryCount = 0)
{
return;
}

var windowHandle = new WindowInteropHelper(this).Handle;

// Check if the visual is connected to a PresentationSource to avoid InvalidOperationException
// in multi-DPI scenarios where the window might not be fully initialized yet
if (PresentationSource.FromVisual(this) == null)
Expand All @@ -743,21 +759,21 @@ private void InternalOnActivated(object sender, EventArgs e, int retryCount = 0)
_attachDrag = false;
return;
}

// If not connected, defer the operation until the visual is properly initialized
Dispatcher.Invoke(
async () =>
{
if (_attachDrag && Mouse.LeftButton == MouseButtonState.Pressed)
{
await Task.Delay(10);
retryCount++;
InternalOnActivated(sender, e, retryCount);
}
}, System.Windows.Threading.DispatcherPriority.Loaded);
if (_attachDrag && Mouse.LeftButton == MouseButtonState.Pressed)
{
await Task.Delay(10);
retryCount++;
InternalOnActivated(sender, e, retryCount);
}
}, System.Windows.Threading.DispatcherPriority.Loaded);
return;
}

var mousePosition = this.PointToScreenDPI(Mouse.GetPosition(this));

var area = this.GetScreenArea();
Expand Down
40 changes: 24 additions & 16 deletions source/Components/AvalonDock/Controls/NavigatorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,11 @@ public LayoutDocumentItem SelectedDocument
/// <param name="e">The event arguments.</param>
protected virtual void OnSelectedDocumentChanged(DependencyPropertyChangedEventArgs e)
{
if (_internalSetSelectedDocument || SelectedDocument == null)
if (!_internalSetSelectedDocument && SelectedDocument != null && SelectedDocument.ActivateCommand.CanExecute(null))
{
return;
}

if (!SelectedDocument.ActivateCommand.CanExecute(null))
{
return;
SelectedAnchorable = null;
CloseAndActiveSelected();
}

Close();
SelectedDocument.ActivateCommand.Execute(null);
}

/// <summary>
Expand Down Expand Up @@ -227,13 +220,10 @@ public LayoutAnchorableItem SelectedAnchorable
/// <param name="e">The event arguments.</param>
protected virtual void OnSelectedAnchorableChanged(DependencyPropertyChangedEventArgs e)
{
if (_internalSetSelectedAnchorable) return;
// TODO: What goes on here??
var selectedAnchorable = e.NewValue as LayoutAnchorableItem;
if (SelectedAnchorable != null && SelectedAnchorable.ActivateCommand.CanExecute(null))
if (!_internalSetSelectedAnchorable && SelectedAnchorable != null && SelectedAnchorable.ActivateCommand.CanExecute(null))
{
Close();
SelectedAnchorable.ActivateCommand.Execute(null);
SelectedDocument = null;
CloseAndActiveSelected();
}
}

Expand Down Expand Up @@ -271,10 +261,12 @@ private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)
if (isListOfDocuments)
{
container.IsKeyboardFocusedChanged += DocumentsItemContainer_IsKeyboardFocusedChanged;
container.PreviewMouseLeftButtonDown += DocumentsItemContainer_PreviewMouseLeftButtonDown;
}
else
{
container.IsKeyboardFocusedChanged += AnchorablesItemContainer_IsKeyboardFocusedChanged;
container.PreviewMouseLeftButtonDown += AnchorablesItemContainer_PreviewMouseLeftButtonDown;
}
}
}
Expand All @@ -283,6 +275,14 @@ private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)
}
}

private void AnchorablesItemContainer_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
ListBoxItem item = (ListBoxItem)sender;
_internalSetSelectedAnchorable = false;
item.IsSelected = true;
_internalSetSelectedAnchorable = false;
}

private void AnchorablesItemContainer_IsKeyboardFocusedChanged(object sender, DependencyPropertyChangedEventArgs e)
{
ListBoxItem item = (ListBoxItem)sender;
Expand All @@ -294,6 +294,14 @@ private void AnchorablesItemContainer_IsKeyboardFocusedChanged(object sender, De
}
}

private void DocumentsItemContainer_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
ListBoxItem item = (ListBoxItem)sender;
_internalSetSelectedDocument = false;
item.IsSelected = true;
_internalSetSelectedDocument = false;
}

private void DocumentsItemContainer_IsKeyboardFocusedChanged(object sender, DependencyPropertyChangedEventArgs e)
{
ListBoxItem item = (ListBoxItem)sender;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**************************************************************************\
/**************************************************************************\
Copyright Microsoft Corporation. All Rights Reserved.
\**************************************************************************/

Expand Down Expand Up @@ -571,11 +571,13 @@ public static string HashStreamMD5(Stream stm)
{
stm.Position = 0;
var hashBuilder = new StringBuilder();
#pragma warning disable S4790
using (var md5 = MD5.Create())
{
foreach (var b in md5.ComputeHash(stm)) hashBuilder.Append(b.ToString("x2", CultureInfo.InvariantCulture));
return hashBuilder.ToString();
}
#pragma warning restore S4790
}

/// <summary>Performs the EnsureDirectory operation.</summary>
Expand Down
15 changes: 15 additions & 0 deletions source/Components/AvalonDock/Layout/ILayoutContentElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Windows;

namespace AvalonDock.Layout
{
/// <summary>
/// Represents a layout element that holds a WPF UI content element
/// </summary>
public interface ILayoutContentElement
{
/// <summary>
/// Gets the root WPF FrameworkElement hosted by this layout element
/// </summary>
FrameworkElement Content { get; }
}
}
4 changes: 2 additions & 2 deletions source/Components/AvalonDock/Properties/Resources.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<value>Esconder</value>
</data>
<data name="Anchorable_CxMenu_Hint" xml:space="preserve">
<value>Posición de la ventana </value>
<value>Posición de la ventana</value>
</data>
<data name="Anchorable_Dock" xml:space="preserve">
<value>Anclar</value>
Expand Down Expand Up @@ -172,7 +172,7 @@
<value>Mover al siguiente grupo de fichas</value>
</data>
<data name="Document_MoveToPreviousTabGroup" xml:space="preserve">
<value>Mover al anterior grupo de fichas </value>
<value>Mover al anterior grupo de fichas</value>
</data>
<data name="Document_NewHorizontalTabGroup" xml:space="preserve">
<value>Nuevo grupo de fichas horizontal</value>
Expand Down
5 changes: 4 additions & 1 deletion source/Components/AvalonDock/Properties/Resources.pt.resx
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,7 @@
<data name="Window_Restore" xml:space="preserve">
<value>Recuperar</value>
</data>
</root>
<data name="Document_BtnPinned_Hint" xml:space="preserve">
<value>Alternar estado fixo</value>
</data>
</root>
4 changes: 3 additions & 1 deletion source/Components/AvalonDock/ToggleDockingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,12 @@ internal ContextMenu BuildToggleContextMenu(LayoutAnchorable anchorable)
var moveToItem = new MenuItem { Header = "Move To" };
foreach (DockZone zone in Enum.GetValues(typeof(DockZone)))
{
#pragma warning disable S6444
var zoneLabel = System.Text.RegularExpressions.Regex.Replace(zone.ToString(), "(\\B[A-Z])", " $1");
var z = zone;
var mi = new MenuItem { Header = zoneLabel };
mi.Click += (s, e) => MoveAnchorableToZone(anchorable, z);
mi.Click += (s, e) => MoveAnchorableToZone(anchorable, zone);
#pragma warning restore S6444
moveToItem.Items.Add(mi);
}

Expand Down