Add project files.

This commit is contained in:
Joshua Askharoun
2022-03-03 08:14:05 -06:00
parent cfa6f93211
commit 1198cc8a66
967 changed files with 118389 additions and 0 deletions
+142
View File
@@ -0,0 +1,142 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.AnchorEdge
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using System.Text;
namespace Microsoft.Iris.Layouts
{
internal class AnchorEdge
{
private string _idName;
private float _percentValue;
private int _offsetValue;
private float _maximumPercentValue;
private int _maximumOffsetValue;
private float _minimumPercentValue;
private int _minimumOffsetValue;
private bool _maximumSetFlag;
private bool _minimumSetFlag;
public AnchorEdge()
{
}
public AnchorEdge(string id, float percent)
{
Id = id;
Percent = percent;
}
public string Id
{
get => _idName;
set => _idName = value;
}
public float Percent
{
get => _percentValue;
set => _percentValue = value;
}
public int Offset
{
get => _offsetValue;
set => _offsetValue = value;
}
public float MaximumPercent
{
get => _maximumPercentValue;
set
{
_maximumPercentValue = value;
_maximumSetFlag = true;
}
}
public int MaximumOffset
{
get => _maximumOffsetValue;
set
{
_maximumOffsetValue = value;
_maximumSetFlag = true;
}
}
public float MinimumPercent
{
get => _minimumPercentValue;
set
{
_minimumPercentValue = value;
_minimumSetFlag = true;
}
}
public int MinimumOffset
{
get => _minimumOffsetValue;
set
{
_minimumOffsetValue = value;
_minimumSetFlag = true;
}
}
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("(");
stringBuilder.Append(_idName);
stringBuilder.Append(", ");
stringBuilder.Append(_percentValue);
if (_offsetValue != 0)
{
stringBuilder.Append(", ");
stringBuilder.Append(_offsetValue);
}
if (_maximumPercentValue > 0.0)
{
stringBuilder.Append(", MaximumPercent=");
stringBuilder.Append(_maximumPercentValue);
stringBuilder.Append(", MaximumOffset=");
stringBuilder.Append(_maximumOffsetValue);
}
if (_minimumPercentValue > 0.0)
{
stringBuilder.Append(", MinimumPercent=");
stringBuilder.Append(_minimumPercentValue);
stringBuilder.Append(", MinimumOffset=");
stringBuilder.Append(_minimumOffsetValue);
}
stringBuilder.Append(")");
return stringBuilder.ToString();
}
public static bool operator ==(AnchorEdge lhs, AnchorEdge rhs)
{
if ((object)lhs == null && (object)rhs == null)
return true;
return (object)lhs != null && lhs.Equals(rhs);
}
public static bool operator !=(AnchorEdge lhs, AnchorEdge rhs) => !(lhs == rhs);
public override bool Equals(object obj)
{
AnchorEdge anchorEdge = obj as AnchorEdge;
return (object)anchorEdge != null && Id == anchorEdge.Id && (Percent == (double)anchorEdge.Percent && Offset == anchorEdge.Offset) && (MaximumSet == anchorEdge.MaximumSet && MaximumPercent == (double)anchorEdge.MaximumPercent && (MaximumOffset == anchorEdge.MaximumOffset && MinimumSet == anchorEdge.MinimumSet)) && MinimumPercent == (double)anchorEdge.MinimumPercent && MinimumOffset == anchorEdge.MinimumOffset;
}
public override int GetHashCode() => (Id != null ? Id.GetHashCode() : 0) ^ Percent.GetHashCode() ^ Offset << 8 ^ MaximumSet.GetHashCode() ^ MaximumPercent.GetHashCode() ^ MaximumOffset << 16 ^ MinimumSet.GetHashCode() ^ MinimumPercent.GetHashCode() ^ MinimumOffset << 24;
internal bool MaximumSet => _maximumSetFlag;
internal bool MinimumSet => _minimumSetFlag;
}
}
+415
View File
@@ -0,0 +1,415 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.AnchorLayout
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Layout;
using Microsoft.Iris.Library;
using Microsoft.Iris.Render;
using Microsoft.Iris.Session;
using Microsoft.Iris.UI;
using System;
namespace Microsoft.Iris.Layouts
{
internal class AnchorLayout : ILayout
{
private bool _sizeToHorizontalChildrenFlag = true;
private bool _sizeToVerticalChildrenFlag = true;
private ItemAlignment _defaultChildAlignment;
private static readonly DataCookie s_dataProperty = DataCookie.ReserveSlot();
private static AnchorEdge s_anchorParent0 = new AnchorEdge("Parent", 0.0f);
private static AnchorEdge s_anchorParent1 = new AnchorEdge("Parent", 1f);
private static AnchorEdge s_anchorParentActual0 = new AnchorEdge("ParentActual", 0.0f);
private static AnchorEdge s_anchorParentActual1 = new AnchorEdge("ParentActual", 1f);
public bool SizeToHorizontalChildren
{
get => _sizeToHorizontalChildrenFlag;
set => _sizeToHorizontalChildrenFlag = value;
}
public bool SizeToVerticalChildren
{
get => _sizeToVerticalChildrenFlag;
set => _sizeToVerticalChildrenFlag = value;
}
public ItemAlignment DefaultChildAlignment
{
get => _defaultChildAlignment;
set => _defaultChildAlignment = value;
}
Size ILayout.Measure(ILayoutNode layoutNode, Size constraint)
{
if (!(layoutNode.MeasureData is AnchorLayout.Packet packet))
{
packet = new AnchorLayout.Packet();
layoutNode.MeasureData = packet;
packet.ParentRecord = new AnchorLayout.Record("Parent", new Rectangle(Point.Zero, constraint), LayoutPhase.Done);
packet.ParentActualRecord = new AnchorLayout.Record("ParentActual", Rectangle.Zero, LayoutPhase.Arrange);
packet.AreaOfInterestRecord = new AnchorLayout.Record("Focus", Rectangle.Zero, LayoutPhase.Arrange);
packet.Records = new Vector<AnchorLayout.Record>(layoutNode.LayoutChildrenCount);
}
else
{
packet.ParentRecord.Bounds = new Rectangle(Point.Zero, constraint);
packet.CircularitiesDetected = false;
packet.CircularityBreakerRecord = null;
}
packet.Subject = layoutNode;
packet.Constraint = constraint;
packet.TotalBounds = new Rectangle(int.MaxValue, int.MaxValue, int.MinValue, int.MinValue);
Size zero = Size.Zero;
if (layoutNode.LayoutChildrenCount == 0)
{
packet.Records.Clear();
if (!_sizeToHorizontalChildrenFlag)
zero.Width = constraint.Width;
if (!_sizeToVerticalChildrenFlag)
zero.Height = constraint.Height;
layoutNode.RequestMoreChildren(int.MaxValue);
return zero;
}
int index = 0;
foreach (ILayoutNode layoutChild in layoutNode.LayoutChildren)
{
if (index < packet.Records.Count)
{
packet.Records[index].Initialize(layoutChild);
}
else
{
AnchorLayout.Record record = new AnchorLayout.Record(layoutChild);
packet.Records.Add(record);
}
++index;
}
packet.Records.RemoveRange(index, packet.Records.Count - index);
foreach (AnchorLayout.Record record in packet.Records)
{
if (record.Phase == LayoutPhase.Untouched)
{
packet.CircularityBreakerRecord = null;
MeasureChild(packet, record);
}
}
if (packet.CircularitiesDetected)
{
foreach (AnchorLayout.Record record in packet.Records)
{
if (record.Phase == LayoutPhase.Circular)
record.Phase = LayoutPhase.Untouched;
}
packet.CircularitiesDetected = false;
foreach (AnchorLayout.Record record in packet.Records)
{
if (record.Phase == LayoutPhase.Untouched)
MeasureChild(packet, record);
}
}
Size size = constraint;
if (_sizeToHorizontalChildrenFlag || _sizeToVerticalChildrenFlag)
{
if (_sizeToHorizontalChildrenFlag)
size.Width = packet.TotalBounds.Width;
if (_sizeToVerticalChildrenFlag)
size.Height = packet.TotalBounds.Height;
foreach (AnchorLayout.Record record in packet.Records)
{
Rectangle bounds = record.Bounds;
if (_sizeToHorizontalChildrenFlag)
bounds.X -= packet.TotalBounds.X;
if (_sizeToVerticalChildrenFlag)
bounds.Y -= packet.TotalBounds.Y;
record.Bounds = bounds;
}
}
layoutNode.RequestMoreChildren(int.MaxValue);
return size;
}
private void MeasureChild(AnchorLayout.Packet packet, AnchorLayout.Record record)
{
AnchorLayoutInput input = record.Input;
record.Phase = LayoutPhase.InProgress;
bool allArrangePhase = true;
bool anyArrangePhase = false;
int edge1 = ComputeEdge(packet, "Left", input.Left, s_anchorParent0, Orientation.Horizontal, record, out AnchorLayout.Record _, ref allArrangePhase, ref anyArrangePhase);
int edge2 = ComputeEdge(packet, "Top", input.Top, s_anchorParent0, Orientation.Vertical, record, out AnchorLayout.Record _, ref allArrangePhase, ref anyArrangePhase);
int edge3 = ComputeEdge(packet, "Right", input.Right, s_anchorParent1, Orientation.Horizontal, record, out AnchorLayout.Record _, ref allArrangePhase, ref anyArrangePhase);
int edge4 = ComputeEdge(packet, "Bottom", input.Bottom, s_anchorParent1, Orientation.Vertical, record, out AnchorLayout.Record _, ref allArrangePhase, ref anyArrangePhase);
if (anyArrangePhase)
{
if (!allArrangePhase)
{
ErrorManager.ReportError("All AnchorEdges must refer to actual positions on AnchorLayoutInput {0}.", record.Input);
record.Invalid = true;
}
if (record.Input.ContributesToHeight || record.Input.ContributesToWidth)
{
ErrorManager.ReportError("AnchorLayoutInput {0} cannot contribute to width or height.", record.Input);
record.Invalid = true;
}
record.Phase = LayoutPhase.Arrange;
}
else
{
Normalize(ref edge1, ref edge3);
Normalize(ref edge2, ref edge4);
int constraintMaxValue1;
ComputeConstraint(edge1, edge3, out constraintMaxValue1);
int constraintMaxValue2;
ComputeConstraint(edge2, edge4, out constraintMaxValue2);
Size constraint = new Size(constraintMaxValue1, constraintMaxValue2);
record.LayoutNode.Measure(constraint);
int size1;
int x = LocationFromEdges(input.Left, input.Right, edge1, edge3, record.LayoutNode.DesiredSize.Width, record.LayoutNode.AlignedSize.Width, record.LayoutNode.AlignmentOffset.X, out size1);
int size2;
int y = LocationFromEdges(input.Top, input.Bottom, edge2, edge4, record.LayoutNode.DesiredSize.Height, record.LayoutNode.AlignedSize.Height, record.LayoutNode.AlignmentOffset.Y, out size2);
record.Bounds = new Rectangle(x, y, size1, size2);
bool flag = packet.CircularityBreakerRecord == record;
if (record.Phase != LayoutPhase.InProgress && !flag)
return;
record.Phase = LayoutPhase.Done;
Rectangle bounds = record.Bounds;
if (!input.ContributesToWidth)
{
bounds.X = int.MaxValue;
bounds.Width = int.MinValue;
}
if (!input.ContributesToHeight)
{
bounds.Y = int.MaxValue;
bounds.Height = int.MinValue;
}
packet.TotalBounds = Rectangle.Union(packet.TotalBounds, bounds);
}
}
private int ComputeEdge(
AnchorLayout.Packet packet,
string edgeName,
AnchorEdge anchor,
AnchorEdge fallback,
Orientation orientation,
AnchorLayout.Record record,
out AnchorLayout.Record recordRef,
ref bool allArrangePhase,
ref bool anyArrangePhase)
{
anchor = anchor != null ? anchor : fallback;
recordRef = GetReferenceRecord(packet, anchor.Id);
if (recordRef == null)
{
allArrangePhase = false;
return 0;
}
bool flag = recordRef.Phase == LayoutPhase.Arrange;
allArrangePhase &= flag;
anyArrangePhase |= flag;
record.Visible &= recordRef.Visible;
Rectangle bounds = recordRef.Bounds;
if (recordRef.Phase != LayoutPhase.Done && recordRef.Phase != LayoutPhase.Arrange)
{
record.Phase = LayoutPhase.Circular;
bounds = packet.ParentRecord.Bounds;
if (recordRef.Phase == LayoutPhase.InProgress && packet.CircularityBreakerRecord == null)
{
packet.CircularityBreakerRecord = recordRef;
packet.CircularitiesDetected = true;
}
}
int val1 = Weigh(orientation == Orientation.Horizontal ? bounds.Width : bounds.Height, anchor.Percent) + (orientation == Orientation.Horizontal ? bounds.X : bounds.Y) + anchor.Offset;
int num = orientation == Orientation.Horizontal ? packet.ParentRecord.Bounds.Width : packet.ParentRecord.Bounds.Height;
if (anchor.MaximumSet)
{
int val2 = Weigh(num, anchor.MaximumPercent) + anchor.MaximumOffset;
val1 = Math.Min(val1, val2);
}
if (anchor.MinimumSet)
{
int val2 = Weigh(num, anchor.MinimumPercent) + anchor.MinimumOffset;
val1 = Math.Max(val1, val2);
}
return val1;
}
private static void ComputeConstraint(int nearValue, int farValue, out int constraintMaxValue) => constraintMaxValue = farValue - nearValue;
private static int LocationFromEdges(
AnchorEdge near,
AnchorEdge far,
int nearValue,
int farValue,
int desiredSize,
int alignedSize,
int alignmentOffset,
out int size)
{
size = desiredSize;
int num;
if (near == null && far == null)
num = (nearValue + farValue - desiredSize) / 2;
else if (near != null && far == null)
num = nearValue;
else if (near == null && far != null)
{
num = farValue - desiredSize;
}
else
{
num = nearValue + alignmentOffset;
size = alignedSize;
}
return num;
}
private static void Normalize(ref int nearValue, ref int farValue)
{
if (farValue >= nearValue)
return;
farValue = nearValue;
}
private static int Weigh(int value, float percentValue) => (int)(value * (double)percentValue);
void ILayout.Arrange(ILayoutNode layoutNode, LayoutSlot slot)
{
AnchorLayout.Packet measureData = (AnchorLayout.Packet)layoutNode.MeasureData;
if (measureData.Records == null)
return;
measureData.ParentActualRecord.Bounds = new Rectangle(Point.Zero, slot.Bounds);
measureData.AreaOfInterestRecord.Bounds = Rectangle.Zero;
Vector<AnchorLayout.Record> vector = null;
AnchorLayout.Record record1 = null;
foreach (AnchorLayout.Record record2 in measureData.Records)
{
if (record2.Phase != LayoutPhase.Arrange)
{
record2.LayoutNode.Arrange(slot, record2.Bounds);
if (record1 == null && (record2.LayoutNode.ContainsAreaOfInterest(AreaOfInterestID.FocusOverride) || record2.LayoutNode.ContainsAreaOfInterest(AreaOfInterestID.Focus)))
record1 = record2;
}
else if (!record2.Invalid)
{
if (vector == null)
vector = new Vector<AnchorLayout.Record>();
vector.Add(record2);
}
else
record2.LayoutNode.MarkHidden();
}
if (vector == null)
return;
if (record1 != null)
{
AreaOfInterest area;
if (!record1.LayoutNode.TryGetAreaOfInterest(AreaOfInterestID.FocusOverride, out area))
record1.LayoutNode.TryGetAreaOfInterest(AreaOfInterestID.Focus, out area);
measureData.AreaOfInterestRecord.Bounds = Rectangle.Offset(area.DisplayRectangle, record1.Bounds.Location);
}
foreach (AnchorLayout.Record record2 in vector)
{
AnchorLayoutInput input = record2.Input;
bool flag = false;
AnchorLayout.Record recordRef;
int edge1 = ComputeEdge(measureData, "Left", input.Left, null, Orientation.Horizontal, record2, out recordRef, ref flag, ref flag);
int edge2 = ComputeEdge(measureData, "Top", input.Top, null, Orientation.Vertical, record2, out recordRef, ref flag, ref flag);
int edge3 = ComputeEdge(measureData, "Right", input.Right, null, Orientation.Horizontal, record2, out recordRef, ref flag, ref flag);
int edge4 = ComputeEdge(measureData, "Bottom", input.Bottom, null, Orientation.Vertical, record2, out recordRef, ref flag, ref flag);
int width = edge3 - edge1;
int height = edge4 - edge2;
record2.LayoutNode.Measure(new Size(width, height));
record2.LayoutNode.Arrange(slot, new Rectangle(edge1, edge2, width, height));
}
}
private AnchorLayout.Record GetReferenceRecord(
AnchorLayout.Packet packet,
string id)
{
if (id == "Parent")
return packet.ParentRecord;
if (id == "ParentActual")
return packet.ParentActualRecord;
if (id == "Focus")
return packet.AreaOfInterestRecord;
foreach (AnchorLayout.Record record in packet.Records)
{
if (record.ID == id)
{
if (record.Phase == LayoutPhase.Untouched)
MeasureChild(packet, record);
return record;
}
}
ErrorManager.ReportError("Anchor layout: {0} cannot find the '{1}' child", GetType().Name, id);
return null;
}
internal static DataCookie InputData => s_dataProperty;
internal enum LayoutPhase
{
Untouched,
InProgress,
Circular,
Done,
Arrange,
}
internal class Record
{
public ILayoutNode LayoutNode;
public string ID;
public AnchorLayoutInput Input;
public Rectangle Bounds;
public AnchorLayout.LayoutPhase Phase;
public bool Visible = true;
public bool Invalid;
private static AnchorLayoutInput s_defaultInput = new AnchorLayoutInput();
public Record(ILayoutNode layoutNode) => Initialize(layoutNode);
public void Initialize(ILayoutNode layoutNode)
{
LayoutNode = layoutNode;
Input = layoutNode.GetLayoutInput(InputData) as AnchorLayoutInput;
if (Input == null)
Input = s_defaultInput;
ID = ((ViewItem)layoutNode).Name;
Bounds = Rectangle.Zero;
Phase = LayoutPhase.Untouched;
Visible = true;
Invalid = false;
}
public Record(string idName, Rectangle bounds, AnchorLayout.LayoutPhase phaseOverride)
{
ID = idName;
Bounds = bounds;
Phase = phaseOverride;
}
public override string ToString() => string.Format("AnchorLayout.Record({0}, Phase={1})", ID, Phase);
}
private class Packet
{
public ILayoutNode Subject;
public Vector<AnchorLayout.Record> Records;
public AnchorLayout.Record ParentRecord;
public AnchorLayout.Record ParentActualRecord;
public AnchorLayout.Record AreaOfInterestRecord;
public Size Constraint;
public Rectangle TotalBounds;
public bool CircularitiesDetected;
public AnchorLayout.Record CircularityBreakerRecord;
public override string ToString() => string.Format("AnchorLayout.Packet({0})", Subject);
}
}
}
@@ -0,0 +1,63 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.AnchorLayoutInput
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Layout;
using Microsoft.Iris.Library;
namespace Microsoft.Iris.Layouts
{
internal class AnchorLayoutInput : ILayoutInput
{
private AnchorEdge _anchorLeft;
private AnchorEdge _anchorTop;
private AnchorEdge _anchorRight;
private AnchorEdge _anchorBottom;
private bool _contributesToWidthFlag = true;
private bool _contributesToHeightFlag = true;
public AnchorEdge Left
{
get => _anchorLeft;
set => _anchorLeft = value;
}
public AnchorEdge Top
{
get => _anchorTop;
set => _anchorTop = value;
}
public AnchorEdge Right
{
get => _anchorRight;
set => _anchorRight = value;
}
public AnchorEdge Bottom
{
get => _anchorBottom;
set => _anchorBottom = value;
}
public bool ContributesToWidth
{
get => _contributesToWidthFlag;
set => _contributesToWidthFlag = value;
}
public bool ContributesToHeight
{
get => _contributesToHeightFlag;
set => _contributesToHeightFlag = value;
}
DataCookie ILayoutInput.Data => Data;
internal static DataCookie Data => AnchorLayout.InputData;
public override string ToString() => InvariantString.Format("AnchorLayoutInput(Left={0}, Top={1}, Right={2}, Bottom={3}{4}{5})", Left, Top, Right, Bottom, ContributesToWidth ? ", ContributesToWidth=true" : string.Empty, ContributesToHeight ? ", ContributesToHeight=true" : string.Empty);
}
}
@@ -0,0 +1,14 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.ContentPositioningPolicy
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
namespace Microsoft.Iris.Layouts
{
internal enum ContentPositioningPolicy
{
RespectPaddingAndLocking,
ShowMaximalContent,
}
}
@@ -0,0 +1,46 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.DefaultLayout
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Layout;
using Microsoft.Iris.Render;
namespace Microsoft.Iris.Layouts
{
internal class DefaultLayout : ILayout
{
private static DefaultLayout s_sharedLayout = new DefaultLayout();
private DefaultLayout()
{
}
public static DefaultLayout Instance => s_sharedLayout;
public ItemAlignment DefaultChildAlignment => ItemAlignment.Default;
Size ILayout.Measure(ILayoutNode layoutNode, Size constraint) => Measure(layoutNode, constraint);
public static Size Measure(ILayoutNode layoutNode, Size constraint)
{
Size sz1 = Size.Zero;
foreach (ILayoutNode layoutChild in layoutNode.LayoutChildren)
{
Size sz2 = layoutChild.Measure(constraint);
sz1 = Size.Max(sz1, sz2);
}
layoutNode.RequestMoreChildren(int.MaxValue);
return sz1;
}
void ILayout.Arrange(ILayoutNode layoutNode, LayoutSlot slot) => Arrange(layoutNode, slot);
public static void Arrange(ILayoutNode layoutNode, LayoutSlot slot)
{
foreach (ILayoutNode layoutChild in layoutNode.LayoutChildren)
layoutChild.Arrange(slot);
}
}
}
+124
View File
@@ -0,0 +1,124 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.DockLayout
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Layout;
using Microsoft.Iris.Library;
using Microsoft.Iris.Render;
namespace Microsoft.Iris.Layouts
{
internal class DockLayout : ILayout
{
private DockLayoutInput _defaultLayoutInput;
private ItemAlignment _defaultChildAlignment;
private static int s_numberOfAdditionalItemsToRequestAtATime = 42;
private static DockLayoutInput s_defaultLayoutInput = DockLayoutInput.Client;
private static readonly DataCookie s_dataProperty = DataCookie.ReserveSlot();
internal static DataCookie DockData => s_dataProperty;
public DockLayoutInput DefaultLayoutInput
{
get => _defaultLayoutInput;
set => _defaultLayoutInput = value;
}
public ItemAlignment DefaultChildAlignment
{
get => _defaultChildAlignment;
set => _defaultChildAlignment = value;
}
Size ILayout.Measure(ILayoutNode layoutNode, Size constraint)
{
Size size1 = constraint;
Size sz2_1 = Size.Zero;
Size constraint1 = size1;
bool flag = false;
foreach (ILayoutNode layoutChild in layoutNode.LayoutChildren)
{
Size size2 = layoutChild.Measure(constraint1);
sz2_1 = Size.Max(size1 - constraint1 + size2, sz2_1);
DockLayoutInput layoutInputForNode = GetLayoutInputForNode(layoutChild);
if (layoutInputForNode == DockLayoutInput.Left || layoutInputForNode == DockLayoutInput.Right)
constraint1.Width -= size2.Width;
else if (layoutInputForNode == DockLayoutInput.Top || layoutInputForNode == DockLayoutInput.Bottom)
constraint1.Height -= size2.Height;
else if (layoutInputForNode == DockLayoutInput.Client)
flag = true;
}
if (flag)
{
Size sz2_2 = Size.Zero;
foreach (ILayoutNode layoutChild in layoutNode.LayoutChildren)
{
if (GetLayoutInputForNode(layoutChild) == DockLayoutInput.Client)
sz2_2 = Size.Max(layoutChild.Measure(constraint1), sz2_2);
}
sz2_1 = Size.Max(size1 - constraint1 + sz2_2, sz2_1);
}
if (sz2_1.Width < size1.Width || sz2_1.Height < size1.Height)
layoutNode.RequestMoreChildren(s_numberOfAdditionalItemsToRequestAtATime);
return sz2_1;
}
void ILayout.Arrange(ILayoutNode layoutNode, LayoutSlot slot)
{
Rectangle bounds1 = new Rectangle(Point.Zero, slot.Bounds);
bool flag = false;
foreach (ILayoutNode layoutChild in layoutNode.LayoutChildren)
{
Size desiredSize = layoutChild.DesiredSize;
Rectangle bounds2 = bounds1;
DockLayoutInput layoutInputForNode = GetLayoutInputForNode(layoutChild);
if (layoutInputForNode == DockLayoutInput.Left)
{
bounds2.Width = desiredSize.Width;
bounds1.X += desiredSize.Width;
bounds1.Width -= desiredSize.Width;
}
else if (layoutInputForNode == DockLayoutInput.Right)
{
bounds2.X = bounds1.Right - desiredSize.Width;
bounds2.Width = desiredSize.Width;
bounds1.Width -= desiredSize.Width;
}
else if (layoutInputForNode == DockLayoutInput.Top)
{
bounds2.Height = desiredSize.Height;
bounds1.Y += desiredSize.Height;
bounds1.Height -= desiredSize.Height;
}
else if (layoutInputForNode == DockLayoutInput.Bottom)
{
bounds2.Y = bounds1.Bottom - desiredSize.Height;
bounds2.Height = desiredSize.Height;
bounds1.Height -= desiredSize.Height;
}
else if (layoutInputForNode == DockLayoutInput.Client)
{
flag = true;
continue;
}
layoutChild.Arrange(slot, bounds2);
}
if (!flag)
return;
foreach (ILayoutNode layoutChild in layoutNode.LayoutChildren)
{
if (GetLayoutInputForNode(layoutChild) == DockLayoutInput.Client)
layoutChild.Arrange(slot, bounds1);
}
}
private DockLayoutInput GetLayoutInputForNode(ILayoutNode node)
{
if (!(node.GetLayoutInput(s_dataProperty) is DockLayoutInput dockLayoutInput))
dockLayoutInput = _defaultLayoutInput ?? s_defaultLayoutInput;
return dockLayoutInput;
}
}
}
@@ -0,0 +1,44 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.DockLayoutInput
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Layout;
using Microsoft.Iris.Library;
namespace Microsoft.Iris.Layouts
{
internal class DockLayoutInput : ILayoutInput
{
public static readonly DockLayoutInput Left = new DockLayoutInput();
public static readonly DockLayoutInput Top = new DockLayoutInput();
public static readonly DockLayoutInput Right = new DockLayoutInput();
public static readonly DockLayoutInput Bottom = new DockLayoutInput();
public static readonly DockLayoutInput Client = new DockLayoutInput();
private DockLayoutInput()
{
}
DataCookie ILayoutInput.Data => Data;
internal static DataCookie Data => DockLayout.DockData;
internal string PositionString
{
get
{
if (this == Left)
return "Left";
if (this == Top)
return "Top";
if (this == Right)
return "Right";
return this == Bottom ? "Bottom" : "Client";
}
}
public override string ToString() => InvariantString.Format("{0}(Position={1})", GetType().Name, PositionString);
}
}
@@ -0,0 +1,19 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.FlipDirection
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using System;
namespace Microsoft.Iris.Layouts
{
[Flags]
internal enum FlipDirection
{
None = 0,
Horizontal = 1,
Vertical = 2,
Both = Vertical | Horizontal, // 0x00000003
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,50 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.FlowSizeMemoryLayoutInput
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Layout;
using Microsoft.Iris.Library;
using Microsoft.Iris.Render;
using System.Text;
namespace Microsoft.Iris.Layouts
{
internal class FlowSizeMemoryLayoutInput : ILayoutInput
{
private static readonly DataCookie s_dataProperty = DataCookie.ReserveSlot();
private Vector<Size> _cache;
public FlowSizeMemoryLayoutInput() => _cache = new Vector<Size>();
public Vector<Size> KnownSizes
{
get => _cache;
set => _cache = value;
}
DataCookie ILayoutInput.Data => Data;
public static DataCookie Data => s_dataProperty;
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
bool flag = true;
int num = 0;
foreach (Size size in _cache)
{
if (!flag)
stringBuilder.Append(", ");
flag = false;
stringBuilder.Append("[");
stringBuilder.Append(num);
stringBuilder.Append("]=");
stringBuilder.Append(size);
++num;
}
return InvariantString.Format("{0}({1})", GetType().Name, stringBuilder);
}
}
}
@@ -0,0 +1,12 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.FormLayoutInput
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
namespace Microsoft.Iris.Layouts
{
internal class FormLayoutInput : AnchorLayoutInput
{
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,18 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.InterestPoint
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
namespace Microsoft.Iris.Layouts
{
internal enum InterestPoint
{
TopLeft,
TopRight,
BottomLeft,
BottomRight,
Center,
NumPoints,
}
}
@@ -0,0 +1,31 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.KeepAliveLayoutInput
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Layout;
using Microsoft.Iris.Library;
namespace Microsoft.Iris.Layouts
{
internal class KeepAliveLayoutInput : ILayoutInput
{
private static readonly DataCookie s_dataProperty = DataCookie.ReserveSlot();
private int _count;
public static bool ShouldKeepVisible(ILayoutNode layoutNode) => layoutNode.GetLayoutInput(Data) != null;
public int Count
{
get => _count;
set => _count = value;
}
DataCookie ILayoutInput.Data => Data;
public static DataCookie Data => s_dataProperty;
public override string ToString() => InvariantString.Format("{0}", GetType().Name);
}
}
+105
View File
@@ -0,0 +1,105 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.MajorMinor
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Library;
using Microsoft.Iris.Render;
using Microsoft.Iris.RenderAPI.Drawing;
using System;
namespace Microsoft.Iris.Layouts
{
internal struct MajorMinor
{
private int major;
private int minor;
public static readonly MajorMinor Zero = new MajorMinor(0, 0);
public MajorMinor(int major, int minor)
{
this.major = major;
this.minor = minor;
}
public MajorMinor(Size size, Orientation o)
{
switch (o)
{
case Orientation.Horizontal:
major = size.Width;
minor = size.Height;
break;
default:
major = size.Height;
minor = size.Width;
break;
}
}
public SizeF ToSizeF(Orientation o)
{
switch (o)
{
case Orientation.Horizontal:
return new SizeF(major, minor);
default:
return new SizeF(minor, major);
}
}
public Size ToSize(Orientation o)
{
switch (o)
{
case Orientation.Horizontal:
return new Size(major, minor);
default:
return new Size(minor, major);
}
}
public Point ToPoint(Orientation o) => ToSize(o).ToPoint();
public static MajorMinor Min(MajorMinor a, MajorMinor b) => new MajorMinor(Math.Min(a.Major, b.Major), Math.Min(a.Minor, b.Minor));
public static MajorMinor Max(MajorMinor a, MajorMinor b) => new MajorMinor(Math.Max(a.Major, b.Major), Math.Max(a.Minor, b.Minor));
public static MajorMinor Clamp(MajorMinor original, MajorMinor min, MajorMinor max) => new MajorMinor(Math2.Clamp(original.Major, min.Major, max.Major), Math2.Clamp(original.Minor, min.Minor, max.Minor));
public static MajorMinor operator +(MajorMinor left, MajorMinor right) => new MajorMinor(left.Major + right.Major, left.Minor + right.Minor);
public static MajorMinor operator -(MajorMinor left, MajorMinor right) => new MajorMinor(left.Major - right.Major, left.Minor - right.Minor);
public static MajorMinor operator *(MajorMinor left, MajorMinor right) => new MajorMinor(left.Major * right.Major, left.Minor * right.Minor);
public static MajorMinor operator /(MajorMinor left, MajorMinor right) => new MajorMinor(left.Major / right.Major, left.Minor / right.Minor);
public static bool operator ==(MajorMinor left, MajorMinor right) => left.Major == right.Major && left.Minor == right.Minor;
public static bool operator !=(MajorMinor left, MajorMinor right) => !(left == right);
public override bool Equals(object obj) => obj is MajorMinor majorMinor && majorMinor == this;
public override int GetHashCode() => major ^ minor;
public MajorMinor Swap() => new MajorMinor(Minor, Major);
public int Major
{
get => major;
set => major = value;
}
public int Minor
{
get => minor;
set => minor = value;
}
public bool IsEmpty => Major == 0 || Minor == 0;
public override string ToString() => InvariantString.Format("(Major={0}, Minor={1})", Major, Minor);
}
}
@@ -0,0 +1,16 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.MissingItemPolicy
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
namespace Microsoft.Iris.Layouts
{
internal enum MissingItemPolicy
{
SizeToAverage,
SizeToSmallest,
SizeToLargest,
Wait,
}
}
+15
View File
@@ -0,0 +1,15 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.MouseTarget
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
namespace Microsoft.Iris.Layouts
{
internal enum MouseTarget
{
None,
Fixed,
Follow,
}
}
+242
View File
@@ -0,0 +1,242 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.PlacementMode
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
namespace Microsoft.Iris.Layouts
{
internal class PlacementMode
{
private PopupPosition[] _popupPositions;
private MouseTarget _mouseTarget;
private bool _usesTargetSize;
private static PlacementMode s_origin;
private static PlacementMode s_left;
private static PlacementMode s_right;
private static PlacementMode s_top;
private static PlacementMode s_bottom;
private static PlacementMode s_center;
private static PlacementMode s_mouseOrigin;
private static PlacementMode s_mouseBottom;
private static PlacementMode s_followMouseOrigin;
private static PlacementMode s_followMouseBottom;
public PopupPosition[] PopupPositions
{
get => _popupPositions;
set
{
_popupPositions = value;
_usesTargetSize = false;
if (_popupPositions == null)
return;
for (int index = 0; index < _popupPositions.Length; ++index)
{
if (_popupPositions[index].Target != InterestPoint.TopLeft)
{
_usesTargetSize = true;
break;
}
}
}
}
public MouseTarget MouseTarget
{
get => _mouseTarget;
set => _mouseTarget = value;
}
internal bool UsesTargetSize => _usesTargetSize;
public override string ToString()
{
if (this == s_origin)
return "Origin";
if (this == s_bottom)
return "Bottom";
if (this == s_top)
return "Top";
if (this == s_left)
return "Left";
if (this == s_right)
return "Right";
if (this == s_center)
return "Center";
if (this == s_mouseOrigin)
return "MouseOrigin";
if (this == s_mouseBottom)
return "MouseBottom";
if (this == s_followMouseOrigin)
return "FollowMouseOrigin";
return this == s_followMouseBottom ? "FollowMouseBottom" : base.ToString();
}
public static PlacementMode Origin
{
get
{
if (s_origin == null)
{
s_origin = new PlacementMode();
s_origin.PopupPositions = new PopupPosition[1]
{
new PopupPosition(InterestPoint.TopLeft, InterestPoint.TopLeft, FlipDirection.None)
};
}
return s_origin;
}
}
public static PlacementMode Bottom
{
get
{
if (s_bottom == null)
{
s_bottom = new PlacementMode();
s_bottom.PopupPositions = new PopupPosition[2]
{
new PopupPosition(InterestPoint.BottomLeft, InterestPoint.TopLeft, FlipDirection.None),
new PopupPosition(InterestPoint.TopLeft, InterestPoint.BottomLeft, FlipDirection.Vertical)
};
}
return s_bottom;
}
}
public static PlacementMode Center
{
get
{
if (s_center == null)
{
s_center = new PlacementMode();
s_center.PopupPositions = new PopupPosition[1]
{
new PopupPosition(InterestPoint.Center, InterestPoint.Center, FlipDirection.None)
};
}
return s_center;
}
}
public static PlacementMode Right
{
get
{
if (s_right == null)
{
s_right = new PlacementMode();
s_right.PopupPositions = new PopupPosition[4]
{
new PopupPosition(InterestPoint.TopRight, InterestPoint.TopLeft, FlipDirection.None),
new PopupPosition(InterestPoint.BottomRight, InterestPoint.BottomLeft, FlipDirection.Vertical),
new PopupPosition(InterestPoint.TopLeft, InterestPoint.TopRight, FlipDirection.Horizontal),
new PopupPosition(InterestPoint.BottomLeft, InterestPoint.BottomRight, FlipDirection.Both)
};
}
return s_right;
}
}
public static PlacementMode Left
{
get
{
if (s_left == null)
{
s_left = new PlacementMode();
s_left.PopupPositions = new PopupPosition[4]
{
new PopupPosition(InterestPoint.TopLeft, InterestPoint.TopRight, FlipDirection.None),
new PopupPosition(InterestPoint.BottomLeft, InterestPoint.BottomRight, FlipDirection.Vertical),
new PopupPosition(InterestPoint.TopRight, InterestPoint.TopLeft, FlipDirection.Horizontal),
new PopupPosition(InterestPoint.BottomRight, InterestPoint.BottomLeft, FlipDirection.Both)
};
}
return s_left;
}
}
public static PlacementMode Top
{
get
{
if (s_top == null)
{
s_top = new PlacementMode();
s_top.PopupPositions = new PopupPosition[2]
{
new PopupPosition(InterestPoint.TopLeft, InterestPoint.BottomLeft, FlipDirection.None),
new PopupPosition(InterestPoint.BottomLeft, InterestPoint.TopLeft, FlipDirection.Vertical)
};
}
return s_top;
}
}
public static PlacementMode MouseOrigin
{
get
{
if (s_mouseOrigin == null)
{
s_mouseOrigin = new PlacementMode();
s_mouseOrigin.MouseTarget = MouseTarget.Fixed;
s_mouseOrigin.PopupPositions = new PopupPosition[4]
{
new PopupPosition(InterestPoint.TopLeft, InterestPoint.TopLeft, FlipDirection.None),
new PopupPosition(InterestPoint.TopLeft, InterestPoint.TopRight, FlipDirection.Horizontal),
new PopupPosition(InterestPoint.TopLeft, InterestPoint.BottomLeft, FlipDirection.Vertical),
new PopupPosition(InterestPoint.TopLeft, InterestPoint.BottomRight, FlipDirection.Both)
};
}
return s_mouseOrigin;
}
}
public static PlacementMode MouseBottom
{
get
{
if (s_mouseBottom == null)
{
s_mouseBottom = new PlacementMode();
s_mouseBottom.MouseTarget = MouseTarget.Fixed;
s_mouseBottom.PopupPositions = Bottom.PopupPositions;
}
return s_mouseBottom;
}
}
public static PlacementMode FollowMouseOrigin
{
get
{
if (s_followMouseOrigin == null)
{
s_followMouseOrigin = new PlacementMode();
s_followMouseOrigin.MouseTarget = MouseTarget.Follow;
s_followMouseOrigin.PopupPositions = MouseOrigin.PopupPositions;
}
return s_followMouseOrigin;
}
}
public static PlacementMode FollowMouseBottom
{
get
{
if (s_followMouseBottom == null)
{
s_followMouseBottom = new PlacementMode();
s_followMouseBottom.MouseTarget = MouseTarget.Follow;
s_followMouseBottom.PopupPositions = MouseBottom.PopupPositions;
}
return s_followMouseBottom;
}
}
}
}
+288
View File
@@ -0,0 +1,288 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.PopupLayout
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Data;
using Microsoft.Iris.Layout;
using Microsoft.Iris.Library;
using Microsoft.Iris.OS;
using Microsoft.Iris.Render;
using Microsoft.Iris.RenderAPI.Drawing;
using Microsoft.Iris.Session;
using Microsoft.Iris.UI;
using System;
using System.Collections;
namespace Microsoft.Iris.Layouts
{
internal class PopupLayout : ILayout
{
private const float c_tolerance = 0.01f;
private static DeferredHandler s_checkForLayoutChanges = new DeferredHandler(CheckForLayoutChanges);
private Vector<ViewItem> _followMouseSubjects;
private static readonly DataCookie s_dataProperty = DataCookie.ReserveSlot();
internal static DataCookie DataCookie => s_dataProperty;
public ItemAlignment DefaultChildAlignment => ItemAlignment.Default;
Size ILayout.Measure(ILayoutNode layoutNode, Size constraint)
{
foreach (ILayoutNode layoutChild in layoutNode.LayoutChildren)
{
if (!(layoutChild.GetLayoutInput(s_dataProperty) is PopupLayoutInput layoutInput) || !layoutInput.ConstrainToTarget)
layoutChild.Measure(constraint);
}
layoutNode.RequestMoreChildren(int.MaxValue);
return constraint;
}
void ILayout.Arrange(ILayoutNode layoutNode, LayoutSlot slot)
{
bool hook = false;
ViewItem viewItem = (ViewItem)layoutNode;
if (layoutNode.LayoutChildrenCount > 0)
{
RectangleF layoutBounds = new RectangleF(PointF.Zero, new SizeF(slot.Bounds.Width, slot.Bounds.Height));
foreach (ILayoutNode layoutChild in layoutNode.LayoutChildren)
{
if (!(layoutChild.GetLayoutInput(s_dataProperty) is PopupLayoutInput layoutInput))
layoutInput = PopupLayoutInput.Default;
if (layoutInput.TargetIsFollowMouse)
hook = true;
ViewItem child = (ViewItem)layoutChild;
Point zero = Point.Zero;
Size size = Size.Zero;
RectangleF placementTargetRect = GetPlacementTargetRect(child, viewItem, layoutInput, slot);
if (layoutInput.ConstrainToTarget)
{
size = new Size((int)placementTargetRect.Width, (int)placementTargetRect.Height);
layoutChild.Measure(size);
}
else
size = layoutChild.DesiredSize;
Point childPosition = GetChildPosition(viewItem, layoutBounds, layoutInput, layoutChild, child, slot, placementTargetRect);
layoutChild.Arrange(slot, new Rectangle(childPosition, size));
}
}
HookMousePositionChanged(viewItem, hook);
}
private Point GetChildPosition(
ViewItem layoutElement,
RectangleF layoutBounds,
PopupLayoutInput layoutInput,
ILayoutNode childNode,
ViewItem child,
LayoutSlot slot,
RectangleF placementRect)
{
PlacementMode placement = layoutInput.Placement;
if (placement == null || ListUtility.IsNullOrEmpty(placement.PopupPositions))
return Point.Zero;
PointF[] interestPoints = InterestPointsFromRect(placementRect);
PointF[] childInterestPoints = GetChildInterestPoints(childNode);
GetBounds(interestPoints);
RectangleF bounds = GetBounds(childInterestPoints);
double width = bounds.Width;
double height = bounds.Height;
bool flag1 = layoutInput.RespectMenuDropAlignment && Win32Api.GetMenuDropAlignment();
PointF bestPosition = PointF.Zero;
float num1 = -1f;
FlipDirection flipDirection = FlipDirection.None;
int length = placement.PopupPositions.Length;
for (int index = 0; index < length; ++index)
{
PopupPosition popupPosition = placement.PopupPositions[index];
InterestPoint target = popupPosition.Target;
InterestPoint popup = popupPosition.Popup;
SizeF sizeF = interestPoints[(int)target] - childInterestPoints[(int)popup];
PointF pos = new PointF(sizeF.Width, sizeF.Height);
RectangleF b = RectangleF.Offset(bounds, pos);
RectangleF rectangleF = RectangleF.Intersect(layoutBounds, b);
float num2 = !rectangleF.IsEmpty ? rectangleF.Width * rectangleF.Height : 0.0f;
bool flag2 = (popupPosition.Flipped & FlipDirection.Horizontal) == FlipDirection.Horizontal;
bool flag3 = (popupPosition.Flipped & FlipDirection.Vertical) == FlipDirection.Vertical;
if (flag2 && flag1 || !flag2 && !flag1)
num2 += 0.1f;
if (!flag3)
num2 += 0.1f;
if (num2 - (double)num1 > 0.00999999977648258)
{
bestPosition = pos;
num1 = num2;
flipDirection = popupPosition.Flipped;
}
if (!layoutInput.StayInBounds)
break;
}
layoutInput.FlippedHorizontally = (flipDirection & FlipDirection.Horizontal) == FlipDirection.Horizontal;
layoutInput.FlippedVertically = (flipDirection & FlipDirection.Vertical) == FlipDirection.Vertical;
if (layoutInput.StayInBounds)
bestPosition = NudgeIntoBounds(layoutBounds, bestPosition, bounds, placement);
return new Point((int)bestPosition.X, (int)bestPosition.Y);
}
private RectangleF GetPlacementTargetRect(
ViewItem child,
ViewItem layoutElement,
PopupLayoutInput layoutInput,
LayoutSlot slot)
{
PlacementMode placement = layoutInput.Placement;
ViewItem placementTarget = layoutInput.PlacementTarget;
bool flag = false;
RectangleF rectangleF;
if (layoutInput.TargetIsMouse || layoutInput.TargetIsFollowMouse)
{
if (layoutInput.MouseRect == RectangleF.Zero || layoutInput.TargetIsFollowMouse)
layoutInput.MouseRect = GetMouseRect(placement);
rectangleF = layoutInput.MouseRect;
flag = true;
}
else if (placementTarget == null || placementTarget.IsDisposed)
{
rectangleF = new RectangleF(Point.Zero, slot.Bounds);
}
else
{
rectangleF = placementTarget.BoundsRelativeToAncestor(null);
flag = true;
PopupLayout.PlacementTargetInfo placementTargetInfo = new PopupLayout.PlacementTargetInfo(child, placementTarget, rectangleF);
DeferredCall.Post(DispatchPriority.LayoutSync, s_checkForLayoutChanges, placementTargetInfo);
}
rectangleF.Offset(layoutInput.Offset.X, layoutInput.Offset.Y);
if (flag)
rectangleF = layoutElement.TransformFromAncestor(null, rectangleF);
return rectangleF;
}
private static void CheckForLayoutChanges(object args)
{
PopupLayout.PlacementTargetInfo placementTargetInfo = (PopupLayout.PlacementTargetInfo)args;
if (placementTargetInfo.placementTarget.IsDisposed || placementTargetInfo.child.IsDisposed)
return;
RectangleF ancestor = placementTargetInfo.placementTarget.BoundsRelativeToAncestor(null);
if (!(placementTargetInfo.bounds != ancestor))
return;
placementTargetInfo.child.MarkLayoutInvalid();
}
private PointF[] GetChildInterestPoints(ILayoutNode childNode)
{
Size desiredSize = childNode.DesiredSize;
return InterestPointsFromRect(new RectangleF(0.0f, 0.0f, desiredSize.Width, desiredSize.Height));
}
private static PointF[] InterestPointsFromRect(RectangleF rect) => new PointF[5]
{
rect.TopLeft,
rect.TopRight,
rect.BottomLeft,
rect.BottomRight,
rect.Center
};
private RectangleF GetBounds(PointF[] interestPoints)
{
float num1;
float x1 = num1 = interestPoints[0].X;
float num2;
float y1 = num2 = interestPoints[0].Y;
for (int index = 1; index < interestPoints.Length; ++index)
{
float x2 = interestPoints[index].X;
float y2 = interestPoints[index].Y;
if (x2 < (double)x1)
x1 = x2;
if (x2 > (double)num1)
num1 = x2;
if (y2 < (double)y1)
y1 = y2;
if (y2 > (double)num2)
num2 = y2;
}
return new RectangleF(x1, y1, num1 - x1, num2 - y1);
}
private PointF NudgeIntoBounds(
RectangleF layoutBounds,
PointF bestPosition,
RectangleF childBounds,
PlacementMode placement)
{
bestPosition.X = Math2.Clamp(bestPosition.X, layoutBounds.Left, layoutBounds.Right - childBounds.Width);
bestPosition.Y = Math2.Clamp(bestPosition.Y, layoutBounds.Top, layoutBounds.Bottom - childBounds.Height);
return bestPosition;
}
private RectangleF GetMouseRect(PlacementMode placement)
{
Point physicalMousePos = UISession.Default.InputManager.MostRecentPhysicalMousePos;
if (!placement.UsesTargetSize)
return new RectangleF(physicalMousePos.X, physicalMousePos.Y, 0.0f, 0.0f);
int height;
int hotY;
NativeApi.SpGetMouseCursorInfo(out height, out hotY);
return new RectangleF(physicalMousePos.X, physicalMousePos.Y - hotY - 1, 0.0f, height + 2);
}
private void HookMousePositionChanged(ViewItem subject, bool hook)
{
if ((_followMouseSubjects != null && _followMouseSubjects.Contains(subject)) == hook)
return;
if (hook)
{
if (_followMouseSubjects == null)
{
_followMouseSubjects = new Vector<ViewItem>();
UISession.Default.InputManager.MousePositionChanged += new EventHandler(OnMousePositionChanged);
}
_followMouseSubjects.Add(subject);
}
else
{
_followMouseSubjects.Remove(subject);
if (_followMouseSubjects.Count != 0)
return;
_followMouseSubjects = null;
UISession.Default.InputManager.MousePositionChanged -= new EventHandler(OnMousePositionChanged);
}
}
private void OnMousePositionChanged(object sender, EventArgs args)
{
for (int index = 0; index < _followMouseSubjects.Count; ++index)
{
ViewItem followMouseSubject = _followMouseSubjects[index];
if (followMouseSubject.Layout == this && !followMouseSubject.IsDisposed)
{
followMouseSubject.MarkLayoutInvalid();
}
else
{
HookMousePositionChanged(followMouseSubject, false);
if (_followMouseSubjects == null)
break;
--index;
}
}
}
private class PlacementTargetInfo
{
public ViewItem child;
public ViewItem placementTarget;
public RectangleF bounds;
public PlacementTargetInfo(ViewItem child, ViewItem placementTarget, RectangleF bounds)
{
this.child = child;
this.placementTarget = placementTarget;
this.bounds = bounds;
}
}
}
}
@@ -0,0 +1,120 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Layouts.PopupLayoutInput
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Layout;
using Microsoft.Iris.Library;
using Microsoft.Iris.Markup;
using Microsoft.Iris.Render;
using Microsoft.Iris.RenderAPI.Drawing;
using Microsoft.Iris.UI;
namespace Microsoft.Iris.Layouts
{
internal class PopupLayoutInput : NotifyObjectBase, ILayoutInput
{
private ViewItem _target;
private PlacementMode _placementMode;
private Point _offset;
private bool _stayInBounds;
private bool _respectMenuDropAlignment;
private bool _constrainToTarget;
private RectangleF _mouseRect = RectangleF.Zero;
private bool _flippedHorizontally;
private bool _flippedVertically;
private static PopupLayoutInput s_default;
public PopupLayoutInput()
{
_stayInBounds = true;
_respectMenuDropAlignment = true;
Placement = PlacementMode.Origin;
}
public ViewItem PlacementTarget
{
get => _target;
set => _target = value;
}
public PlacementMode Placement
{
get => _placementMode;
set => _placementMode = value;
}
public Point Offset
{
get => _offset;
set => _offset = value;
}
public bool StayInBounds
{
get => _stayInBounds;
set => _stayInBounds = value;
}
public bool RespectMenuDropAlignment
{
get => _respectMenuDropAlignment;
set => _respectMenuDropAlignment = value;
}
public bool ConstrainToTarget
{
get => _constrainToTarget;
set => _constrainToTarget = value;
}
DataCookie ILayoutInput.Data => Data;
internal static DataCookie Data => PopupLayout.DataCookie;
internal RectangleF MouseRect
{
get => _mouseRect;
set => _mouseRect = value;
}
public bool FlippedHorizontally
{
get => _flippedHorizontally;
set
{
if (_flippedHorizontally == value)
return;
_flippedHorizontally = value;
FireNotification(NotificationID.FlippedHorizontally);
}
}
public bool FlippedVertically
{
get => _flippedVertically;
set
{
if (_flippedVertically == value)
return;
_flippedVertically = value;
FireNotification(NotificationID.FlippedVertically);
}
}
internal bool TargetIsMouse => _placementMode != null && _placementMode.MouseTarget == MouseTarget.Fixed;
internal bool TargetIsFollowMouse => _placementMode != null && _placementMode.MouseTarget == MouseTarget.Follow;
internal static PopupLayoutInput Default
{
get
{
if (s_default == null)
s_default = new PopupLayoutInput();
return s_default;
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More