mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Add project files.
This commit is contained in:
@@ -0,0 +1,448 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.Camera
|
||||
// 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.Animations;
|
||||
using Microsoft.Iris.Library;
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.Session;
|
||||
using Microsoft.Iris.UI;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal class Camera : SharedDisposableObject, INotifyObject, IAnimatableOwner
|
||||
{
|
||||
private ICamera _camera;
|
||||
private Vector3 _vEyeNoSend;
|
||||
private Vector3 _vAtNoSend;
|
||||
private Vector3 _vUpNoSend;
|
||||
private float _flZnNoSend;
|
||||
private bool _hasEyeNoSend;
|
||||
private bool _hasAtNoSend;
|
||||
private bool _hasUpNoSend;
|
||||
private bool _hasZnNoSend;
|
||||
private Vector<ActiveSequence> _activeAnimations;
|
||||
private IAnimationProvider _eyeAnimation;
|
||||
private IAnimationProvider _atAnimation;
|
||||
private IAnimationProvider _upAnimation;
|
||||
private IAnimationProvider _znAnimation;
|
||||
private NotifyService _notifier = new NotifyService();
|
||||
private IList _listeners = new ArrayList();
|
||||
|
||||
public Camera() => _camera = UISession.Default.RenderSession.CreateCamera(this);
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
base.OnDispose();
|
||||
Vector<ActiveSequence> activeAnimations = GetActiveAnimations(false);
|
||||
if (activeAnimations != null)
|
||||
{
|
||||
foreach (DisposableObject disposableObject in activeAnimations)
|
||||
disposableObject.Dispose(this);
|
||||
}
|
||||
_camera.UnregisterUsage(this);
|
||||
_camera = null;
|
||||
}
|
||||
|
||||
public void AddListener(Listener listener) => _notifier.AddListener(listener);
|
||||
|
||||
protected void FireNotification(string id)
|
||||
{
|
||||
_notifier.Fire(id);
|
||||
foreach (object listener in _listeners)
|
||||
{
|
||||
if (listener is ViewItem viewItem)
|
||||
viewItem.MarkPaintInvalid();
|
||||
}
|
||||
}
|
||||
|
||||
public override void RegisterUsage(object consumer)
|
||||
{
|
||||
base.RegisterUsage(consumer);
|
||||
_listeners.Add(consumer);
|
||||
}
|
||||
|
||||
public override void UnregisterUsage(object consumer)
|
||||
{
|
||||
_listeners.Remove(consumer);
|
||||
base.UnregisterUsage(consumer);
|
||||
}
|
||||
|
||||
public bool Perspective
|
||||
{
|
||||
get => _camera.Perspective;
|
||||
set
|
||||
{
|
||||
if (_camera.Perspective == value)
|
||||
return;
|
||||
_camera.Perspective = value;
|
||||
FireNotification(NotificationID.Perspective);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 Eye
|
||||
{
|
||||
get => _hasEyeNoSend ? _vEyeNoSend : _camera.Eye;
|
||||
set
|
||||
{
|
||||
if (!(_camera.Eye != value))
|
||||
return;
|
||||
CameraEyeNoSend = value;
|
||||
if (_eyeAnimation == null || !PlayAnimation(_eyeAnimation, null))
|
||||
CameraEye = value;
|
||||
FireNotification(NotificationID.Eye);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 CameraEyeNoSend
|
||||
{
|
||||
set
|
||||
{
|
||||
_hasEyeNoSend = true;
|
||||
_vEyeNoSend = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal Vector3 CameraEye
|
||||
{
|
||||
set
|
||||
{
|
||||
_camera.Eye = value;
|
||||
_hasEyeNoSend = false;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 At
|
||||
{
|
||||
get => _hasAtNoSend ? _vAtNoSend : _camera.At;
|
||||
set
|
||||
{
|
||||
if (!(_camera.At != value))
|
||||
return;
|
||||
CameraAtNoSend = value;
|
||||
if (_atAnimation == null || !PlayAnimation(_atAnimation, null))
|
||||
CameraAt = value;
|
||||
FireNotification(NotificationID.At);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 CameraAtNoSend
|
||||
{
|
||||
set
|
||||
{
|
||||
_hasAtNoSend = true;
|
||||
_vAtNoSend = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal Vector3 CameraAt
|
||||
{
|
||||
set
|
||||
{
|
||||
_camera.At = value;
|
||||
_hasAtNoSend = false;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 Up
|
||||
{
|
||||
get => _hasUpNoSend ? _vUpNoSend : _camera.Up;
|
||||
set
|
||||
{
|
||||
if (!(_camera.Up != value))
|
||||
return;
|
||||
CameraUpNoSend = value;
|
||||
if (_upAnimation == null || !PlayAnimation(_upAnimation, null))
|
||||
CameraUp = value;
|
||||
FireNotification(NotificationID.Up);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 CameraUpNoSend
|
||||
{
|
||||
set
|
||||
{
|
||||
_hasUpNoSend = true;
|
||||
_vUpNoSend = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal Vector3 CameraUp
|
||||
{
|
||||
set
|
||||
{
|
||||
_camera.Up = value;
|
||||
_hasUpNoSend = false;
|
||||
}
|
||||
}
|
||||
|
||||
public float Zn
|
||||
{
|
||||
get => _hasZnNoSend ? _flZnNoSend : _camera.Zn;
|
||||
set
|
||||
{
|
||||
if (_camera.Zn == (double)value)
|
||||
return;
|
||||
CameraZnNoSend = value;
|
||||
if (_znAnimation == null || !PlayAnimation(_znAnimation, null))
|
||||
CameraZn = value;
|
||||
FireNotification(NotificationID.Zn);
|
||||
}
|
||||
}
|
||||
|
||||
private float CameraZnNoSend
|
||||
{
|
||||
set
|
||||
{
|
||||
_hasZnNoSend = true;
|
||||
_flZnNoSend = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal float CameraZn
|
||||
{
|
||||
set
|
||||
{
|
||||
_camera.Zn = value;
|
||||
_hasZnNoSend = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal ICamera APICamera => _camera;
|
||||
|
||||
IAnimatable IAnimatableOwner.AnimationTarget => _camera;
|
||||
|
||||
public IAnimationProvider EyeAnimation
|
||||
{
|
||||
get => _eyeAnimation;
|
||||
set
|
||||
{
|
||||
if (_eyeAnimation == value)
|
||||
return;
|
||||
_eyeAnimation = value;
|
||||
FireNotification(NotificationID.EyeAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
public IAnimationProvider AtAnimation
|
||||
{
|
||||
get => _atAnimation;
|
||||
set
|
||||
{
|
||||
if (_atAnimation == value)
|
||||
return;
|
||||
_atAnimation = value;
|
||||
FireNotification(NotificationID.AtAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
public IAnimationProvider UpAnimation
|
||||
{
|
||||
get => _upAnimation;
|
||||
set
|
||||
{
|
||||
if (_upAnimation == value)
|
||||
return;
|
||||
_upAnimation = value;
|
||||
FireNotification(NotificationID.UpAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
public IAnimationProvider ZnAnimation
|
||||
{
|
||||
get => _znAnimation;
|
||||
set
|
||||
{
|
||||
if (_znAnimation == value)
|
||||
return;
|
||||
_znAnimation = value;
|
||||
FireNotification(NotificationID.ZnAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
public bool PlayAnimation(IAnimationProvider ab, AnimationHandle animationHandle)
|
||||
{
|
||||
AnimationArgs args = new AnimationArgs(this);
|
||||
return PlayAnimation(ab, ref args, UIClass.ShouldPlayAnimation(ab), animationHandle);
|
||||
}
|
||||
|
||||
private bool PlayAnimation(
|
||||
IAnimationProvider ab,
|
||||
ref AnimationArgs args,
|
||||
bool shouldPlayAnimation,
|
||||
AnimationHandle animationHandle)
|
||||
{
|
||||
AnimationTemplate anim = BuildAnimation(ab, ref args);
|
||||
if (anim == null)
|
||||
return false;
|
||||
if (shouldPlayAnimation)
|
||||
{
|
||||
PlayAnimation(anim, ref args, null, animationHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplyFinalAnimationState(anim, ref args);
|
||||
animationHandle?.FireCompleted();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void PlayAnimation(
|
||||
AnimationTemplate anim,
|
||||
ref AnimationArgs args,
|
||||
EventHandler onCompleteHandler,
|
||||
AnimationHandle animationHandle)
|
||||
{
|
||||
ActiveSequence instance = anim.CreateInstance(APICamera, ref args);
|
||||
if (instance == null)
|
||||
return;
|
||||
instance.DeclareOwner(this);
|
||||
if (onCompleteHandler != null)
|
||||
instance.AnimationCompleted += onCompleteHandler;
|
||||
animationHandle?.AssociateWithAnimationInstance(instance);
|
||||
instance.AnimationCompleted += new EventHandler(OnAnimationComplete);
|
||||
GetActiveAnimations(true).Add(instance);
|
||||
OnAnimationListChanged();
|
||||
PlayAnimationWorker(instance);
|
||||
if (!(anim is Animation animation))
|
||||
return;
|
||||
int num = animation.DisableMouseInput ? 1 : 0;
|
||||
}
|
||||
|
||||
private void PlayAnimationWorker(ActiveSequence newSequence)
|
||||
{
|
||||
StopOverlappingAnimations(newSequence);
|
||||
newSequence.Play();
|
||||
}
|
||||
|
||||
private AnimationTemplate BuildAnimation(
|
||||
IAnimationProvider ab,
|
||||
ref AnimationArgs args)
|
||||
{
|
||||
return ab.Build(ref args);
|
||||
}
|
||||
|
||||
private void StopOverlappingAnimations(ActiveSequence newSequence)
|
||||
{
|
||||
Vector<ActiveSequence> activeAnimations = GetActiveAnimations(false);
|
||||
if (activeAnimations == null)
|
||||
return;
|
||||
ActiveTransitions activeTransitions = newSequence.GetActiveTransitions();
|
||||
StopCommandSet stopCommand = null;
|
||||
foreach (ActiveSequence playingSequence in activeAnimations)
|
||||
StopAnimationIfOverlapping(playingSequence, newSequence, activeTransitions, ref stopCommand);
|
||||
}
|
||||
|
||||
private bool StopAnimationIfOverlapping(
|
||||
ActiveSequence playingSequence,
|
||||
ActiveSequence newSequence,
|
||||
ActiveTransitions newTransitions,
|
||||
ref StopCommandSet stopCommand)
|
||||
{
|
||||
if (playingSequence.Target == newSequence.Target)
|
||||
{
|
||||
ActiveTransitions activeTransitions = playingSequence.GetActiveTransitions();
|
||||
if ((newTransitions & activeTransitions) != ActiveTransitions.None)
|
||||
{
|
||||
if (stopCommand == null)
|
||||
{
|
||||
stopCommand = newSequence.GetStopCommandSet();
|
||||
StopCommandSet stopCommandSet = stopCommand;
|
||||
}
|
||||
playingSequence.Stop(stopCommand);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnAnimationComplete(object sender, EventArgs args)
|
||||
{
|
||||
ActiveSequence activeSequence = sender as ActiveSequence;
|
||||
activeSequence.AnimationCompleted -= new EventHandler(OnAnimationComplete);
|
||||
Vector<ActiveSequence> activeAnimations = GetActiveAnimations(false);
|
||||
activeAnimations.Remove(activeSequence);
|
||||
OnAnimationListChanged();
|
||||
if (activeAnimations.Count == 0)
|
||||
_activeAnimations = null;
|
||||
if (activeSequence.Template is Animation template)
|
||||
{
|
||||
int num = template.DisableMouseInput ? 1 : 0;
|
||||
}
|
||||
activeSequence.Dispose(this);
|
||||
}
|
||||
|
||||
private void StopActiveAnimations()
|
||||
{
|
||||
if (_activeAnimations == null)
|
||||
return;
|
||||
foreach (ActiveSequence activeAnimation in GetActiveAnimations(true))
|
||||
activeAnimation.Stop();
|
||||
}
|
||||
|
||||
internal void ApplyFinalAnimationState(AnimationTemplate anim, ref AnimationArgs args)
|
||||
{
|
||||
BaseKeyframe[] baseKeyframeArray = new BaseKeyframe[20];
|
||||
foreach (BaseKeyframe keyframe in anim.Keyframes)
|
||||
{
|
||||
BaseKeyframe baseKeyframe = baseKeyframeArray[(uint)keyframe.Type];
|
||||
if (baseKeyframe == null || baseKeyframe.Time <= (double)keyframe.Time)
|
||||
baseKeyframeArray[(uint)keyframe.Type] = keyframe;
|
||||
}
|
||||
foreach (BaseKeyframe baseKeyframe in baseKeyframeArray)
|
||||
baseKeyframe?.Apply(this, ref args);
|
||||
}
|
||||
|
||||
private Vector<ActiveSequence> GetActiveAnimations(bool createIfNone) => GetAnimationSequence(ref _activeAnimations, createIfNone);
|
||||
|
||||
private Vector<ActiveSequence> GetAnimationSequence(
|
||||
ref Vector<ActiveSequence> currentAnimationsList,
|
||||
bool createIfNone)
|
||||
{
|
||||
Vector<ActiveSequence> vector = null;
|
||||
if (currentAnimationsList == null)
|
||||
{
|
||||
if (createIfNone)
|
||||
{
|
||||
vector = new Vector<ActiveSequence>();
|
||||
currentAnimationsList = vector;
|
||||
}
|
||||
}
|
||||
else
|
||||
vector = currentAnimationsList;
|
||||
return vector;
|
||||
}
|
||||
|
||||
private void OnAnimationListChanged()
|
||||
{
|
||||
}
|
||||
|
||||
private static bool DoesAnimationListContainAnimationType(
|
||||
Vector<ActiveSequence> animationList,
|
||||
ActiveTransitions type)
|
||||
{
|
||||
if (animationList != null)
|
||||
{
|
||||
foreach (ActiveSequence animation in animationList)
|
||||
{
|
||||
if ((animation.GetActiveTransitions() & type) == type)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
private void DEBUG_DumpAnimation(ActiveSequence aseq)
|
||||
{
|
||||
foreach (BaseKeyframe keyframe in aseq.Template.Keyframes)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.Color
|
||||
// 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.Render;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal struct Color
|
||||
{
|
||||
private const int ARGBAlphaShift = 24;
|
||||
private const int ARGBRedShift = 16;
|
||||
private const int ARGBGreenShift = 8;
|
||||
private const int ARGBBlueShift = 0;
|
||||
private readonly uint value;
|
||||
|
||||
public Color(int red, int green, int blue) => this = FromArgb(byte.MaxValue, red, green, blue);
|
||||
|
||||
public Color(float red, float green, float blue) => this = FromArgb(1f, red, green, blue);
|
||||
|
||||
public Color(int alpha, int red, int green, int blue) => this = FromArgb(alpha, red, green, blue);
|
||||
|
||||
public Color(float alpha, float red, float green, float blue) => this = FromArgb(alpha, red, green, blue);
|
||||
|
||||
internal Color(uint value) => this.value = value;
|
||||
|
||||
public byte R
|
||||
{
|
||||
get => (byte)(Value >> 16 & byte.MaxValue);
|
||||
set => this = FromArgb(A, value, G, B);
|
||||
}
|
||||
|
||||
public byte G
|
||||
{
|
||||
get => (byte)(Value >> 8 & byte.MaxValue);
|
||||
set => this = FromArgb(A, R, value, B);
|
||||
}
|
||||
|
||||
public byte B
|
||||
{
|
||||
get => (byte)(Value & byte.MaxValue);
|
||||
set => this = FromArgb(A, R, G, value);
|
||||
}
|
||||
|
||||
public byte A
|
||||
{
|
||||
get => (byte)(Value >> 24 & byte.MaxValue);
|
||||
set => this = FromArgb(value, R, G, B);
|
||||
}
|
||||
|
||||
internal void GetArgb(out float a, out float r, out float g, out float b)
|
||||
{
|
||||
a = A / (float)byte.MaxValue;
|
||||
r = R / (float)byte.MaxValue;
|
||||
g = G / (float)byte.MaxValue;
|
||||
b = B / (float)byte.MaxValue;
|
||||
}
|
||||
|
||||
internal uint Value => value;
|
||||
|
||||
private static void CheckByte(int value, string name)
|
||||
{
|
||||
}
|
||||
|
||||
private static int ChannelFromFloat(float value) => (int)(value * (double)byte.MaxValue);
|
||||
|
||||
private static uint MakeArgb(byte alpha, byte red, byte green, byte blue) => (uint)(red << 16 | green << 8 | blue | alpha << 24);
|
||||
|
||||
internal static Color FromArgb(uint argb) => new Color(argb);
|
||||
|
||||
internal static Color FromArgb(int alpha, int red, int green, int blue)
|
||||
{
|
||||
CheckByte(alpha, nameof(alpha));
|
||||
CheckByte(red, nameof(red));
|
||||
CheckByte(green, nameof(green));
|
||||
CheckByte(blue, nameof(blue));
|
||||
return new Color(MakeArgb((byte)alpha, (byte)red, (byte)green, (byte)blue));
|
||||
}
|
||||
|
||||
internal static Color FromArgb(float alpha, float red, float green, float blue) => FromArgb(ChannelFromFloat(alpha), ChannelFromFloat(red), ChannelFromFloat(green), ChannelFromFloat(blue));
|
||||
|
||||
internal static Color FromArgb(int alpha, Color baseColor)
|
||||
{
|
||||
CheckByte(alpha, nameof(alpha));
|
||||
return new Color(MakeArgb((byte)alpha, baseColor.R, baseColor.G, baseColor.B));
|
||||
}
|
||||
|
||||
internal static Color FromArgb(int red, int green, int blue) => FromArgb(byte.MaxValue, red, green, blue);
|
||||
|
||||
internal float GetValue()
|
||||
{
|
||||
float num1 = R / (float)byte.MaxValue;
|
||||
float num2 = G / (float)byte.MaxValue;
|
||||
float num3 = B / (float)byte.MaxValue;
|
||||
float num4 = num1;
|
||||
float num5 = num1;
|
||||
if (num2 > (double)num4)
|
||||
num4 = num2;
|
||||
if (num3 > (double)num4)
|
||||
num4 = num3;
|
||||
if (num2 < (double)num5)
|
||||
num5 = num2;
|
||||
if (num3 < (double)num5)
|
||||
num5 = num3;
|
||||
return (float)((num4 + (double)num5) / 2.0);
|
||||
}
|
||||
|
||||
internal float GetHue()
|
||||
{
|
||||
if (R == G && G == B)
|
||||
return 0.0f;
|
||||
float num1 = R / (float)byte.MaxValue;
|
||||
float num2 = G / (float)byte.MaxValue;
|
||||
float num3 = B / (float)byte.MaxValue;
|
||||
float num4 = 0.0f;
|
||||
float num5 = num1;
|
||||
float num6 = num1;
|
||||
if (num2 > (double)num5)
|
||||
num5 = num2;
|
||||
if (num3 > (double)num5)
|
||||
num5 = num3;
|
||||
if (num2 < (double)num6)
|
||||
num6 = num2;
|
||||
if (num3 < (double)num6)
|
||||
num6 = num3;
|
||||
float num7 = num5 - num6;
|
||||
if (num1 == (double)num5)
|
||||
num4 = (num2 - num3) / num7;
|
||||
else if (num2 == (double)num5)
|
||||
num4 = (float)(2.0 + (num3 - (double)num1) / num7);
|
||||
else if (num3 == (double)num5)
|
||||
num4 = (float)(4.0 + (num1 - (double)num2) / num7);
|
||||
float num8 = num4 * 60f;
|
||||
if (num8 < 0.0)
|
||||
num8 += 360f;
|
||||
return num8;
|
||||
}
|
||||
|
||||
internal float GetSaturation()
|
||||
{
|
||||
float num1 = R / (float)byte.MaxValue;
|
||||
float num2 = G / (float)byte.MaxValue;
|
||||
float num3 = B / (float)byte.MaxValue;
|
||||
float num4 = 0.0f;
|
||||
float num5 = num1;
|
||||
float num6 = num1;
|
||||
if (num2 > (double)num5)
|
||||
num5 = num2;
|
||||
if (num3 > (double)num5)
|
||||
num5 = num3;
|
||||
if (num2 < (double)num6)
|
||||
num6 = num2;
|
||||
if (num3 < (double)num6)
|
||||
num6 = num3;
|
||||
if (num5 != (double)num6)
|
||||
num4 = (num5 + (double)num6) / 2.0 > 0.5 ? (float)((num5 - (double)num6) / (2.0 - num5 - num6)) : (float)((num5 - (double)num6) / (num5 + (double)num6));
|
||||
return num4;
|
||||
}
|
||||
|
||||
internal static Color FromHSV(int nAlpha, float flHue, float flSaturation, float flValue)
|
||||
{
|
||||
if (flSaturation == 0.0)
|
||||
return new Color(nAlpha, (int)(flValue * (double)byte.MaxValue), (int)(flValue * (double)byte.MaxValue), (int)(flValue * (double)byte.MaxValue));
|
||||
float num1 = flHue / 60f;
|
||||
int num2 = (int)Math.Floor(num1) % 6;
|
||||
float num3 = num1 - num2;
|
||||
float num4 = flValue * (1f - flSaturation);
|
||||
float num5 = flValue * (float)(1.0 - num3 * (double)flSaturation);
|
||||
float num6 = flValue * (float)(1.0 - (1.0 - num3) * flSaturation);
|
||||
switch (num2)
|
||||
{
|
||||
case 0:
|
||||
return new Color(nAlpha, (int)(flValue * (double)byte.MaxValue), (int)(num6 * (double)byte.MaxValue), (int)(num4 * (double)byte.MaxValue));
|
||||
case 1:
|
||||
return new Color(nAlpha, (int)(num5 * (double)byte.MaxValue), (int)(flValue * (double)byte.MaxValue), (int)(num4 * (double)byte.MaxValue));
|
||||
case 2:
|
||||
return new Color(nAlpha, (int)(num4 * (double)byte.MaxValue), (int)(flValue * (double)byte.MaxValue), (int)(num6 * (double)byte.MaxValue));
|
||||
case 3:
|
||||
return new Color(nAlpha, (int)(num4 * (double)byte.MaxValue), (int)(num5 * (double)byte.MaxValue), (int)(flValue * (double)byte.MaxValue));
|
||||
case 4:
|
||||
return new Color(nAlpha, (int)(num6 * (double)byte.MaxValue), (int)(num4 * (double)byte.MaxValue), (int)(flValue * (double)byte.MaxValue));
|
||||
case 5:
|
||||
return new Color(nAlpha, (int)(flValue * (double)byte.MaxValue), (int)(num4 * (double)byte.MaxValue), (int)(num5 * (double)byte.MaxValue));
|
||||
default:
|
||||
return new Color(nAlpha, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
internal int ToArgb() => (int)Value;
|
||||
|
||||
internal ColorF RenderConvert() => new ColorF(A, R, G, B);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder(32);
|
||||
stringBuilder.Append("A=");
|
||||
stringBuilder.Append(A);
|
||||
stringBuilder.Append(", R=");
|
||||
stringBuilder.Append(R);
|
||||
stringBuilder.Append(", G=");
|
||||
stringBuilder.Append(G);
|
||||
stringBuilder.Append(", B=");
|
||||
stringBuilder.Append(B);
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
public static bool operator ==(Color left, Color right) => (int)left.value == (int)right.value;
|
||||
|
||||
public static bool operator !=(Color left, Color right) => !(left == right);
|
||||
|
||||
public override bool Equals(object obj) => obj is Color color && (int)value == (int)color.value;
|
||||
|
||||
public bool Equals(Color right) => (int)value == (int)right.value;
|
||||
|
||||
public override int GetHashCode() => value.GetHashCode();
|
||||
|
||||
internal static Color Transparent => new Color(0U);
|
||||
|
||||
internal static Color Black => new Color(4278190080U);
|
||||
|
||||
internal static Color White => new Color(uint.MaxValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.ContentLoadCompleteHandler
|
||||
// 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.Drawing
|
||||
{
|
||||
internal delegate void ContentLoadCompleteHandler(object owner, ImageStatus status);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.EditCursorType
|
||||
// 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.Drawing
|
||||
{
|
||||
internal enum EditCursorType
|
||||
{
|
||||
Default,
|
||||
IBeam,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.Font
|
||||
// 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.Drawing
|
||||
{
|
||||
internal sealed class Font
|
||||
{
|
||||
private string _fontName;
|
||||
private float _fontHeight;
|
||||
private float _altFontHeight;
|
||||
private FontStyles _fontStyle;
|
||||
|
||||
public Font()
|
||||
: this("Arial", 12f, 0.0f, FontStyles.None)
|
||||
{
|
||||
}
|
||||
|
||||
public Font(string fontName)
|
||||
: this(fontName, 12f, 0.0f, FontStyles.None)
|
||||
{
|
||||
}
|
||||
|
||||
public Font(string fontName, float fontHeight)
|
||||
: this(fontName, fontHeight, 0.0f, FontStyles.None)
|
||||
{
|
||||
}
|
||||
|
||||
public Font(string fontName, float fontHeight, float altFontHeight)
|
||||
: this(fontName, fontHeight, altFontHeight, FontStyles.None)
|
||||
{
|
||||
}
|
||||
|
||||
public Font(string fontName, float fontHeight, FontStyles fontStyles)
|
||||
: this(fontName, fontHeight, 0.0f, fontStyles)
|
||||
{
|
||||
}
|
||||
|
||||
public Font(string fontName, float fontHeight, float altFontHeight, FontStyles fontStyles)
|
||||
{
|
||||
_fontName = fontName;
|
||||
_fontHeight = fontHeight;
|
||||
_altFontHeight = altFontHeight;
|
||||
_fontStyle = fontStyles;
|
||||
}
|
||||
|
||||
public float FontSize
|
||||
{
|
||||
get => _fontHeight;
|
||||
set => _fontHeight = value;
|
||||
}
|
||||
|
||||
public float AltFontSize
|
||||
{
|
||||
get => _altFontHeight == 0.0 ? _fontHeight : _altFontHeight;
|
||||
set => _altFontHeight = value;
|
||||
}
|
||||
|
||||
public FontStyles FontStyle
|
||||
{
|
||||
get => _fontStyle;
|
||||
set => _fontStyle = value;
|
||||
}
|
||||
|
||||
public string FontName
|
||||
{
|
||||
get => _fontName;
|
||||
set => _fontName = value;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj) => obj is Font font && _fontName == font._fontName && (_fontHeight == (double)font._fontHeight && _altFontHeight == (double)font._altFontHeight) && _fontStyle == font._fontStyle;
|
||||
|
||||
public override int GetHashCode() => _fontName.GetHashCode() ^ _fontHeight.GetHashCode() ^ _altFontHeight.GetHashCode() ^ _fontStyle.GetHashCode();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append("{Font \"");
|
||||
stringBuilder.Append(_fontName);
|
||||
stringBuilder.Append("\" ");
|
||||
stringBuilder.Append(_fontHeight);
|
||||
stringBuilder.Append("pt ");
|
||||
stringBuilder.Append(_fontStyle);
|
||||
stringBuilder.Append("}");
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.FontStyles
|
||||
// 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.Drawing
|
||||
{
|
||||
[Flags]
|
||||
internal enum FontStyles
|
||||
{
|
||||
None = 0,
|
||||
Bold = 1,
|
||||
Italic = 2,
|
||||
Underline = 4,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.ImageStatus
|
||||
// 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.Drawing
|
||||
{
|
||||
internal enum ImageStatus
|
||||
{
|
||||
PendingLoad,
|
||||
Loading,
|
||||
Complete,
|
||||
Error,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.RawImage
|
||||
// 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.OS;
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.Render.Extensions;
|
||||
using Microsoft.Iris.RenderAPI;
|
||||
using Microsoft.Iris.Session;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal class RawImage : UIImage
|
||||
{
|
||||
private string _uniqueID;
|
||||
private Size _imageSize;
|
||||
private int _stride;
|
||||
private SurfaceFormat _format;
|
||||
private IntPtr _data;
|
||||
private uint _length;
|
||||
private RawImageItemKey _cacheItemKey;
|
||||
|
||||
public RawImage(
|
||||
string uniqueID,
|
||||
Size imageSize,
|
||||
int stride,
|
||||
SurfaceFormat format,
|
||||
IntPtr data,
|
||||
bool takeOwnership,
|
||||
Inset nineGrid,
|
||||
Size maximumSize,
|
||||
bool flippable,
|
||||
bool antialiasEdges)
|
||||
: base(nineGrid, maximumSize, flippable, antialiasEdges)
|
||||
{
|
||||
Source = uniqueID;
|
||||
_uniqueID = uniqueID;
|
||||
_imageSize = imageSize;
|
||||
_stride = stride;
|
||||
_format = format;
|
||||
_contentSize = imageSize;
|
||||
int cbCopy = _imageSize.Height * Math.Abs(stride);
|
||||
_length = (uint)cbCopy;
|
||||
if (!takeOwnership)
|
||||
{
|
||||
_data = NativeApi.MemAlloc(_length, false);
|
||||
Memory.Copy(_data, data, cbCopy);
|
||||
}
|
||||
else
|
||||
_data = data;
|
||||
}
|
||||
|
||||
~RawImage()
|
||||
{
|
||||
FreeBuffer(_data);
|
||||
_data = IntPtr.Zero;
|
||||
}
|
||||
|
||||
internal static void FreeBuffer(IntPtr data)
|
||||
{
|
||||
if (!(data != IntPtr.Zero))
|
||||
return;
|
||||
NativeApi.MemFree(data);
|
||||
}
|
||||
|
||||
protected override ImageCacheItem GetCacheItem(out bool needAsyncLoad)
|
||||
{
|
||||
ImageCache instance = ScavengeImageCache.Instance;
|
||||
ImageCacheItem imageCacheItem = null;
|
||||
string str = GetHashCode().ToString();
|
||||
if (_cacheItemKey == null)
|
||||
_cacheItemKey = new RawImageItemKey(str);
|
||||
else
|
||||
imageCacheItem = instance.Lookup(_cacheItemKey);
|
||||
if (imageCacheItem == null)
|
||||
{
|
||||
Size maxSize = ClampSize(_maximumSize);
|
||||
imageCacheItem = new RawImageItem(UISession.Default.RenderSession, this, str, _data, _length, _imageSize, _stride, _format, maxSize, IsFlipped, _antialiasEdges);
|
||||
instance.Add(_cacheItemKey, imageCacheItem);
|
||||
}
|
||||
needAsyncLoad = false;
|
||||
return imageCacheItem;
|
||||
}
|
||||
|
||||
protected override void EnsureSizeMetrics()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.RawImageItem
|
||||
// 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.Render;
|
||||
using Microsoft.Iris.Render.Extensions;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal class RawImageItem : ImageCacheItem
|
||||
{
|
||||
private int _stride;
|
||||
private SurfaceFormat _format;
|
||||
private object _oKeepAlive;
|
||||
|
||||
internal RawImageItem(
|
||||
IRenderSession renderSession,
|
||||
RawImage rawImage,
|
||||
string source,
|
||||
IntPtr data,
|
||||
uint length,
|
||||
Size imageSize,
|
||||
int stride,
|
||||
SurfaceFormat format,
|
||||
Size maxSize,
|
||||
bool flippable,
|
||||
bool antialiasEdges)
|
||||
: base(renderSession, source, maxSize, flippable, antialiasEdges)
|
||||
{
|
||||
_oKeepAlive = rawImage;
|
||||
SetSize(imageSize);
|
||||
SetBuffer(data, length);
|
||||
_stride = stride;
|
||||
_format = format;
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
_oKeepAlive = null;
|
||||
m_buffer = IntPtr.Zero;
|
||||
base.OnDispose();
|
||||
}
|
||||
|
||||
protected override bool DoImageLoad() => ImageLoader.FromRaw(RenderImage, m_buffer, (int)m_length, m_size, _stride, _format, m_req.MaximumSize, m_req.Flippable, m_req.AntialiasEdges, m_req.BorderWidth, m_req.BorderColor, out m_info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.RawImageItemKey
|
||||
// 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.Render.Extensions;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal class RawImageItemKey : ImageCacheKey
|
||||
{
|
||||
private static int s_uniqueId;
|
||||
private int _uniqueId;
|
||||
|
||||
public RawImageItemKey(string id)
|
||||
: base(id)
|
||||
=> _uniqueId = ++s_uniqueId;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(this, obj))
|
||||
return true;
|
||||
return obj is RawImageItemKey rawImageItemKey && _uniqueId == rawImageItemKey._uniqueId;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => _uniqueId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.ResourceImageItem
|
||||
// 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.Render;
|
||||
using Microsoft.Iris.Render.Extensions;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal class ResourceImageItem : ImageCacheItem
|
||||
{
|
||||
private string _source;
|
||||
private Resource _resource;
|
||||
private bool _acquireCalled;
|
||||
private ResourceAcquisitionCompleteHandler _resourceAcquisitionHandler;
|
||||
|
||||
internal ResourceImageItem(
|
||||
IRenderSession renderSession,
|
||||
string source,
|
||||
Size maxSize,
|
||||
bool flippable,
|
||||
bool antialiasEdges)
|
||||
: base(renderSession, source, maxSize, flippable, antialiasEdges)
|
||||
{
|
||||
_source = source;
|
||||
_resource = ResourceManager.Instance.GetResource(_source);
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
if (_resource != null)
|
||||
{
|
||||
FreeResource();
|
||||
_resource = null;
|
||||
}
|
||||
base.OnDispose();
|
||||
}
|
||||
|
||||
internal Resource Resource
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureResource();
|
||||
return _resource;
|
||||
}
|
||||
}
|
||||
|
||||
internal ImageStatus Status
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (_resource.Status)
|
||||
{
|
||||
case ResourceStatus.NeedsAcquire:
|
||||
return ImageStatus.PendingLoad;
|
||||
case ResourceStatus.Acquiring:
|
||||
return ImageStatus.Loading;
|
||||
case ResourceStatus.Available:
|
||||
return ImageStatus.Complete;
|
||||
case ResourceStatus.Error:
|
||||
return ImageStatus.Error;
|
||||
default:
|
||||
return ImageStatus.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool EnsureBuffer()
|
||||
{
|
||||
if (EnsureResource())
|
||||
{
|
||||
if (IsResourceAvailable())
|
||||
OnResourceLoadComplete(_resource);
|
||||
else if (!_acquireCalled)
|
||||
{
|
||||
_resourceAcquisitionHandler = new ResourceAcquisitionCompleteHandler(OnResourceLoadComplete);
|
||||
_resource.Acquire(_resourceAcquisitionHandler);
|
||||
_acquireCalled = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnImageLoadComplete()
|
||||
{
|
||||
ImageStatus status = Status;
|
||||
if (LoadCompleteHandler == null)
|
||||
return;
|
||||
LoadCompleteHandler(this, status);
|
||||
}
|
||||
|
||||
private bool IsResourceAvailable() => _resource.Status == ResourceStatus.Available;
|
||||
|
||||
public bool EnsureResource()
|
||||
{
|
||||
if (_resource == null)
|
||||
_resource = ResourceManager.Instance.GetResource(_source);
|
||||
return _resource != null;
|
||||
}
|
||||
|
||||
private void OnResourceLoadComplete(Resource resource)
|
||||
{
|
||||
if (resource != _resource)
|
||||
return;
|
||||
if (!IsSuccessfulResourceLoad(_resource) || Application.IsShuttingDown)
|
||||
{
|
||||
OnImageLoadComplete();
|
||||
FreeResource();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetBuffer(_resource.Buffer, _resource.Length);
|
||||
if (_resource.Length <= 0U)
|
||||
return;
|
||||
if (!ProcessBuffer())
|
||||
_resource.Status = ResourceStatus.Error;
|
||||
OnImageLoadComplete();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsSuccessfulResourceLoad(Resource resource) => resource.Status != ResourceStatus.Error;
|
||||
|
||||
private void FreeResource()
|
||||
{
|
||||
if (_acquireCalled)
|
||||
{
|
||||
_resource.Free(_resourceAcquisitionHandler);
|
||||
_resourceAcquisitionHandler = null;
|
||||
}
|
||||
_acquireCalled = false;
|
||||
}
|
||||
|
||||
public override void StartLoad() => EnsureBuffer();
|
||||
|
||||
public override string ToString() => _source;
|
||||
|
||||
public override void ReleaseImage()
|
||||
{
|
||||
LoadCompleteHandler = null;
|
||||
base.ReleaseImage();
|
||||
}
|
||||
|
||||
public override void RemoveData()
|
||||
{
|
||||
FreeResource();
|
||||
base.RemoveData();
|
||||
}
|
||||
|
||||
public event ContentLoadCompleteHandler LoadCompleteHandler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,463 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.RichText
|
||||
// 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.OS;
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.RenderAPI;
|
||||
using Microsoft.Iris.RenderAPI.Drawing;
|
||||
using Microsoft.Iris.Session;
|
||||
using Microsoft.Iris.ViewItems;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal sealed class RichText : IDisposable
|
||||
{
|
||||
public const float MaxWidthConstraint = 4095f;
|
||||
public const float MaxHeightConstraint = 8191f;
|
||||
private Win32Api.HANDLE _rtoHandle;
|
||||
private NativeApi.ReportRunCallback _rrcb;
|
||||
private string _currentlyMeasuringText;
|
||||
private bool _oversampled;
|
||||
private bool _hosted;
|
||||
private bool _inImeCompositionMode;
|
||||
private ArrayList _timers;
|
||||
private EventHandler _timerTickHandler;
|
||||
private object _lock;
|
||||
|
||||
public RichText(bool richTextMode)
|
||||
: this(richTextMode, null)
|
||||
{
|
||||
}
|
||||
|
||||
public unsafe RichText(bool richTextMode, IRichTextCallbacks callbacks)
|
||||
{
|
||||
Size sizeMaximumSurface = Size.Zero;
|
||||
if (UISession.Default != null)
|
||||
sizeMaximumSurface = UIImage.MaximumSurfaceSize(UISession.Default);
|
||||
if (callbacks != null)
|
||||
{
|
||||
_hosted = true;
|
||||
_timers = new ArrayList(6);
|
||||
_timerTickHandler = new EventHandler(OnTimerTick);
|
||||
}
|
||||
RendererApi.IFC(NativeApi.SpRichTextBuildObject(richTextMode, sizeMaximumSurface, callbacks, out _rtoHandle));
|
||||
_oversampled = false;
|
||||
_lock = new object();
|
||||
_rrcb = new NativeApi.ReportRunCallback(OnReportRun);
|
||||
}
|
||||
|
||||
public void Dispose() => Dispose(true);
|
||||
|
||||
private void Dispose(bool inDispose)
|
||||
{
|
||||
if (!inDispose)
|
||||
return;
|
||||
GC.SuppressFinalize(this);
|
||||
lock (_lock)
|
||||
{
|
||||
NativeApi.SpRichTextDestroyObject(_rtoHandle);
|
||||
_rtoHandle.h = IntPtr.Zero;
|
||||
}
|
||||
if (_timers == null)
|
||||
return;
|
||||
for (int index = 0; index < _timers.Count; ++index)
|
||||
DisposeTimer((DispatcherTimer)_timers[index]);
|
||||
_timers.Clear();
|
||||
}
|
||||
|
||||
~RichText() => Dispose(false);
|
||||
|
||||
public string Content
|
||||
{
|
||||
set
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextSetContent(_rtoHandle, value));
|
||||
}
|
||||
}
|
||||
|
||||
public string SimpleContent
|
||||
{
|
||||
get
|
||||
{
|
||||
string str = null;
|
||||
int textLength = 0;
|
||||
lock (_lock)
|
||||
{
|
||||
RendererApi.IFC(NativeApi.SpRichTextGetSimpleContentLength(_rtoHandle, out textLength));
|
||||
if (textLength != 0)
|
||||
{
|
||||
StringBuilder textBuffer = new StringBuilder(textLength);
|
||||
RendererApi.IFC(NativeApi.SpRichTextGetSimpleContent(_rtoHandle, textBuffer, textBuffer.Capacity));
|
||||
str = textBuffer.ToString();
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Oversample
|
||||
{
|
||||
set
|
||||
{
|
||||
if (_oversampled == value)
|
||||
return;
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextSetOversampleMode(_rtoHandle, value));
|
||||
_oversampled = value;
|
||||
}
|
||||
get => _oversampled;
|
||||
}
|
||||
|
||||
public int MaxLength
|
||||
{
|
||||
set
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextSetMaximumLength(_rtoHandle, value));
|
||||
}
|
||||
}
|
||||
|
||||
public bool DetectUrls
|
||||
{
|
||||
set
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextSetDetectUrls(_rtoHandle, value));
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasCallbacks => _hosted;
|
||||
|
||||
public bool ReadOnly
|
||||
{
|
||||
set
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextSetReadOnly(_rtoHandle, value));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetWordWrap(bool wordWrap)
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextSetWordWrap(_rtoHandle, wordWrap));
|
||||
}
|
||||
|
||||
public Size GetNaturalBounds()
|
||||
{
|
||||
int cWidth;
|
||||
int cHeight;
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextGetNaturalBounds(_rtoHandle, out cWidth, out cHeight));
|
||||
return new Size(cWidth, cHeight);
|
||||
}
|
||||
|
||||
public void SetSelectionRange(int selectionStart, int selectionEnd)
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextSetSelectionRange(_rtoHandle, selectionStart, selectionEnd));
|
||||
}
|
||||
|
||||
public unsafe TextFlow Measure(string content, ref TextMeasureParams measureParams)
|
||||
{
|
||||
TextFlow textFlow = new TextFlow();
|
||||
GCHandle gcHandle = GCHandle.Alloc(textFlow);
|
||||
_currentlyMeasuringText = content != null ? content : string.Empty;
|
||||
fixed (char* content1 = _currentlyMeasuringText)
|
||||
fixed (char* chPtr = measureParams._textStyle.FontFace)
|
||||
{
|
||||
var style = new TextStyle.MarshalledData(measureParams._textStyle)
|
||||
{
|
||||
_fontFace = chPtr
|
||||
};
|
||||
measureParams.SetContent(content1);
|
||||
measureParams._data._pTextStyle = &style;
|
||||
fixed (TextMeasureParams.FormattedRange* formattedRangePtr = measureParams._formattedRanges)
|
||||
{
|
||||
measureParams._data._pFormattedRanges = formattedRangePtr;
|
||||
fixed (TextStyle.MarshalledData* marshalledDataPtr = measureParams._formattedRangeStyles)
|
||||
{
|
||||
measureParams._data._pFormattedRangeStyles = marshalledDataPtr;
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextMeasure(_rtoHandle, ref measureParams._data, _rrcb, GCHandle.ToIntPtr(gcHandle)));
|
||||
}
|
||||
}
|
||||
}
|
||||
gcHandle.Free();
|
||||
_currentlyMeasuringText = null;
|
||||
return textFlow;
|
||||
}
|
||||
|
||||
public void NotifyOfFocusChange(bool gainingFocus)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
RendererApi.IFC(NativeApi.SpRichTextSetFocus(_rtoHandle, gainingFocus));
|
||||
if (gainingFocus)
|
||||
return;
|
||||
_inImeCompositionMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void ScrollUp(ScrollbarType whichBar)
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextScroll(_rtoHandle, (int)whichBar, 0));
|
||||
}
|
||||
|
||||
public void ScrollDown(ScrollbarType whichBar)
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextScroll(_rtoHandle, (int)whichBar, 1));
|
||||
}
|
||||
|
||||
public void PageUp(ScrollbarType whichBar)
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextScroll(_rtoHandle, (int)whichBar, 2));
|
||||
}
|
||||
|
||||
public void PageDown(ScrollbarType whichBar)
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextScroll(_rtoHandle, (int)whichBar, 3));
|
||||
}
|
||||
|
||||
public void ScrollToPosition(ScrollbarType whichBar, int whereTo)
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextScrollToPosition(_rtoHandle, (int)whichBar, whereTo));
|
||||
}
|
||||
|
||||
public void SetScrollbars(bool horizontalScrollbar, bool verticalScrollbar)
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextSetScrollbars(_rtoHandle, horizontalScrollbar, verticalScrollbar));
|
||||
}
|
||||
|
||||
public bool ForwardKeyStateNotification(
|
||||
uint message,
|
||||
int virtualKey,
|
||||
int scanCode,
|
||||
int repeatCount,
|
||||
uint modifierState,
|
||||
ushort flags)
|
||||
{
|
||||
bool handled = true;
|
||||
lock (_lock)
|
||||
{
|
||||
if (!_inImeCompositionMode)
|
||||
RendererApi.IFC(NativeApi.SpRichTextForwardKeyState(_rtoHandle, message, virtualKey, scanCode, repeatCount, modifierState, flags, out handled));
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
public bool ForwardKeyCharacterNotification(
|
||||
uint message,
|
||||
int character,
|
||||
int scanCode,
|
||||
int repeatCount,
|
||||
uint modifierState,
|
||||
ushort flags)
|
||||
{
|
||||
bool handled = true;
|
||||
lock (_lock)
|
||||
{
|
||||
if (!_inImeCompositionMode)
|
||||
RendererApi.IFC(NativeApi.SpRichTextForwardKeyCharacter(_rtoHandle, message, character, scanCode, repeatCount, modifierState, flags, out handled));
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
public bool ForwardMouseInput(
|
||||
uint message,
|
||||
uint modifierState,
|
||||
int mouseButton,
|
||||
int x,
|
||||
int y,
|
||||
int mouseWheelDelta)
|
||||
{
|
||||
bool handled = true;
|
||||
lock (_lock)
|
||||
{
|
||||
if (!_inImeCompositionMode)
|
||||
RendererApi.IFC(NativeApi.SpRichTextForwardMouseInput(_rtoHandle, message, modifierState, mouseButton, x, y, mouseWheelDelta, out handled));
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
public HRESULT ForwardImeMessage(uint message, UIntPtr wParam, UIntPtr lParam)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case 269:
|
||||
_inImeCompositionMode = true;
|
||||
break;
|
||||
case 270:
|
||||
_inImeCompositionMode = false;
|
||||
break;
|
||||
}
|
||||
RendererApi.IFC(NativeApi.SpRichTextForwardImeMessage(_rtoHandle, message, wParam, lParam));
|
||||
}
|
||||
return new HRESULT(0);
|
||||
}
|
||||
|
||||
public bool CanUndo
|
||||
{
|
||||
get
|
||||
{
|
||||
bool canUndo;
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextCanUndo(_rtoHandle, out canUndo));
|
||||
return canUndo;
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextUndo(_rtoHandle));
|
||||
}
|
||||
|
||||
public void Cut()
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextCut(_rtoHandle));
|
||||
}
|
||||
|
||||
public void Copy()
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextCopy(_rtoHandle));
|
||||
}
|
||||
|
||||
public void Paste()
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextPaste(_rtoHandle));
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextDelete(_rtoHandle));
|
||||
}
|
||||
|
||||
public static LineAlignment ReverseAlignment(
|
||||
LineAlignment alignment,
|
||||
bool condition)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
switch (alignment)
|
||||
{
|
||||
case LineAlignment.Near:
|
||||
alignment = LineAlignment.Far;
|
||||
break;
|
||||
case LineAlignment.Far:
|
||||
alignment = LineAlignment.Near;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return alignment;
|
||||
}
|
||||
|
||||
internal static Dib Rasterize(
|
||||
IntPtr hGlyphRunInfo,
|
||||
bool outlineMode,
|
||||
Color textColor,
|
||||
bool shadowMode)
|
||||
{
|
||||
IntPtr phTextBitmap = IntPtr.Zero;
|
||||
IntPtr ppvBits;
|
||||
Size psizeBitmap;
|
||||
RendererApi.IFC(NativeApi.SpRichTextRasterize(hGlyphRunInfo, outlineMode ? 1 : 0, textColor, shadowMode ? 1 : 0, out phTextBitmap, out ppvBits, out psizeBitmap));
|
||||
return new Dib(phTextBitmap, ppvBits, psizeBitmap);
|
||||
}
|
||||
|
||||
public void SetTimer(uint id, uint timeout)
|
||||
{
|
||||
DispatcherTimer dispatcherTimer = FindTimer(id);
|
||||
if (dispatcherTimer == null)
|
||||
{
|
||||
dispatcherTimer = new DispatcherTimer();
|
||||
_timers.Add(dispatcherTimer);
|
||||
}
|
||||
dispatcherTimer.UserData = id;
|
||||
dispatcherTimer.Interval = (int)timeout;
|
||||
dispatcherTimer.Tick += _timerTickHandler;
|
||||
dispatcherTimer.Start();
|
||||
}
|
||||
|
||||
public void KillTimer(uint id)
|
||||
{
|
||||
DispatcherTimer timer = FindTimer(id);
|
||||
if (timer == null)
|
||||
return;
|
||||
DisposeTimer(timer);
|
||||
_timers.Remove(timer);
|
||||
}
|
||||
|
||||
private DispatcherTimer FindTimer(uint id)
|
||||
{
|
||||
for (int index = 0; index < _timers.Count; ++index)
|
||||
{
|
||||
DispatcherTimer timer = (DispatcherTimer)_timers[index];
|
||||
if ((int)(uint)timer.UserData == (int)id)
|
||||
return timer;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void DisposeTimer(DispatcherTimer timer)
|
||||
{
|
||||
timer.Tick -= _timerTickHandler;
|
||||
timer.Stop();
|
||||
}
|
||||
|
||||
private void OnTimerTick(object sender, EventArgs ea)
|
||||
{
|
||||
DispatcherTimer dispatcherTimer = (DispatcherTimer)sender;
|
||||
lock (_lock)
|
||||
RendererApi.IFC(NativeApi.SpRichTextOnTimerTick(_rtoHandle, (uint)dispatcherTimer.UserData));
|
||||
}
|
||||
|
||||
private unsafe HRESULT OnReportRun(
|
||||
IntPtr hGlyphRunInfo,
|
||||
NativeApi.RasterizeRunPacket* runPacketPtr,
|
||||
IntPtr lpString,
|
||||
uint nChars,
|
||||
IntPtr dataPtr)
|
||||
{
|
||||
bool flag = false;
|
||||
if (_currentlyMeasuringText != null && _currentlyMeasuringText.Length == nChars)
|
||||
{
|
||||
flag = true;
|
||||
char* pointer = (char*)lpString.ToPointer();
|
||||
for (int index = 0; index < nChars; ++index)
|
||||
{
|
||||
if (_currentlyMeasuringText[index] != pointer[index])
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
string content = flag ? _currentlyMeasuringText : Marshal.PtrToStringUni(lpString, (int)nChars);
|
||||
TextRun run = TextRun.FromRunPacket(hGlyphRunInfo, runPacketPtr, content);
|
||||
if (run != null)
|
||||
((TextFlow)GCHandle.FromIntPtr(dataPtr).Target).Add(run);
|
||||
return new HRESULT(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.RichTextInfoKey
|
||||
// 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.OS;
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.Render.Extensions;
|
||||
using Microsoft.Iris.RenderAPI.Drawing;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal class RichTextInfoKey : ImageCacheKey
|
||||
{
|
||||
private const int FLAGS_IS_ITALIC = 1;
|
||||
private const int FLAGS_IS_UNDERLINE = 2;
|
||||
private const int FLAGS_IS_OUTLINE = 4;
|
||||
private const int FLAGS_IS_THICK_UNDERLINE = 8;
|
||||
private const int FLAGS_IS_DOTTED_UNDERLINE = 16;
|
||||
private string _samplingMode;
|
||||
private string _content;
|
||||
private SizeF _srcSizeF;
|
||||
private Size _naturalSize;
|
||||
private Point _rasterizedOffset;
|
||||
private int _fontFaceUniqueId;
|
||||
private int _fontSize;
|
||||
private int _fontWeight;
|
||||
private byte _rasterizerConfig;
|
||||
private Color _textColor;
|
||||
private int _flags;
|
||||
private int _hashCode;
|
||||
|
||||
public RichTextInfoKey(TextRun run, string samplingMode, bool outline, Color textColor)
|
||||
: base(run.Content)
|
||||
{
|
||||
_samplingMode = samplingMode;
|
||||
_content = run.Content;
|
||||
_srcSizeF = run.RenderBounds.Size;
|
||||
_naturalSize = run.NaturalExtent;
|
||||
_rasterizedOffset = run.RasterizedOffset;
|
||||
_fontFaceUniqueId = run.FontFaceUniqueId;
|
||||
_fontSize = run.FontSize;
|
||||
_fontWeight = run.FontWeight;
|
||||
_rasterizerConfig = run.RasterizerConfig;
|
||||
_textColor = textColor;
|
||||
_flags = 0;
|
||||
if (run.Italic)
|
||||
_flags |= 1;
|
||||
if (outline)
|
||||
_flags |= 4;
|
||||
switch (run.UnderlineStyle)
|
||||
{
|
||||
case NativeApi.UnderlineStyle.Solid:
|
||||
_flags |= 2;
|
||||
break;
|
||||
case NativeApi.UnderlineStyle.Thick:
|
||||
_flags |= 8;
|
||||
break;
|
||||
case NativeApi.UnderlineStyle.Dotted:
|
||||
case NativeApi.UnderlineStyle.Dash:
|
||||
case NativeApi.UnderlineStyle.DashDot:
|
||||
case NativeApi.UnderlineStyle.DashDotDot:
|
||||
_flags |= 16;
|
||||
break;
|
||||
}
|
||||
_hashCode = _samplingMode.GetHashCode() ^ _content.GetHashCode() ^ _srcSizeF.GetHashCode() ^ _naturalSize.GetHashCode() ^ _rasterizedOffset.GetHashCode() ^ _fontFaceUniqueId.GetHashCode() ^ _fontSize ^ _fontWeight ^ _flags ^ _rasterizerConfig ^ _textColor.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(this, obj))
|
||||
return true;
|
||||
return obj is RichTextInfoKey richTextInfoKey && _hashCode == richTextInfoKey._hashCode && (_fontFaceUniqueId == richTextInfoKey._fontFaceUniqueId && _fontSize == richTextInfoKey._fontSize) && (_fontWeight == richTextInfoKey._fontWeight && _flags == richTextInfoKey._flags && (_rasterizerConfig == richTextInfoKey._rasterizerConfig && _samplingMode.Equals(richTextInfoKey._samplingMode))) && (_srcSizeF.Equals(richTextInfoKey._srcSizeF) && _naturalSize.Equals(richTextInfoKey._naturalSize) && (_rasterizedOffset.Equals(richTextInfoKey._rasterizedOffset) && _textColor.Equals(richTextInfoKey._textColor))) && _content.Equals(richTextInfoKey._content);
|
||||
}
|
||||
|
||||
public override int GetHashCode() => _hashCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.Rotation
|
||||
// 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.Render;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal struct Rotation
|
||||
{
|
||||
private Vector3 _axis;
|
||||
private float _angleRad;
|
||||
public static readonly Rotation Default = new Rotation(0.0f, new Vector3(0.0f, 0.0f, 1f));
|
||||
|
||||
public Rotation(float angleRadians)
|
||||
: this(angleRadians, new Vector3(0.0f, 0.0f, 1f))
|
||||
{
|
||||
}
|
||||
|
||||
public Rotation(float angleRadians, Vector3 axis)
|
||||
{
|
||||
_axis = axis;
|
||||
_angleRad = angleRadians;
|
||||
}
|
||||
|
||||
public Vector3 Axis
|
||||
{
|
||||
get => _axis;
|
||||
set => _axis = value;
|
||||
}
|
||||
|
||||
public float AngleRadians
|
||||
{
|
||||
get => _angleRad;
|
||||
set => _angleRad = value;
|
||||
}
|
||||
|
||||
public int AngleDegrees
|
||||
{
|
||||
get => (int)(_angleRad * 180.0 / 3.14159274101257);
|
||||
set => _angleRad = (float)(value * 3.14159274101257 / 180.0);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj) => obj is Rotation rotation && this == rotation;
|
||||
|
||||
public static bool operator ==(Rotation left, Rotation right) => left.Axis == right.Axis && left.AngleRadians == (double)right.AngleRadians;
|
||||
|
||||
public static bool operator !=(Rotation left, Rotation right) => left.Axis != right.Axis || left.AngleRadians != (double)right.AngleRadians;
|
||||
|
||||
public override int GetHashCode() => Axis.GetHashCode() ^ AngleRadians.GetHashCode();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder(128);
|
||||
stringBuilder.Append("(Axis=");
|
||||
stringBuilder.Append(Axis);
|
||||
stringBuilder.Append(", Angle=");
|
||||
stringBuilder.Append(AngleRadians);
|
||||
stringBuilder.Append(")");
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.ScavengeImageCache
|
||||
// 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.Queues;
|
||||
using Microsoft.Iris.Render.Extensions;
|
||||
using Microsoft.Iris.Session;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal sealed class ScavengeImageCache : ImageCache
|
||||
{
|
||||
private static ScavengeImageCache s_theOnlyCache;
|
||||
private static readonly DeferredHandler s_dhReschedule = new DeferredHandler(Reschedule);
|
||||
private UISession _session;
|
||||
private ScavengeImageCache.ScavengeCallback _callback;
|
||||
|
||||
public static void Initialize(UISession session)
|
||||
{
|
||||
s_theOnlyCache = new ScavengeImageCache(session);
|
||||
s_theOnlyCache.NumItemsToKeep = 200;
|
||||
s_theOnlyCache.ItemRetainTime = new TimeSpan(0, 2, 0);
|
||||
}
|
||||
|
||||
public static void Uninitialize(UISession session)
|
||||
{
|
||||
if (s_theOnlyCache == null)
|
||||
return;
|
||||
s_theOnlyCache.Dispose();
|
||||
}
|
||||
|
||||
public static ScavengeImageCache Instance => s_theOnlyCache;
|
||||
|
||||
private ScavengeImageCache(UISession session)
|
||||
: base(session.RenderSession, "GraphicImageCache")
|
||||
=> _session = session;
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
TimeoutManager timeoutManager = _session.Dispatcher.TimeoutManager;
|
||||
ScavengeImageCache.ScavengeCallback callback = _callback;
|
||||
if (callback != null)
|
||||
timeoutManager.CancelTimeout(callback);
|
||||
_callback = null;
|
||||
base.OnDispose();
|
||||
}
|
||||
|
||||
protected override void ScheduleScavenge()
|
||||
{
|
||||
if (!CleanupPending)
|
||||
DeferredCall.Post(DispatchPriority.Idle, s_dhReschedule, this);
|
||||
base.ScheduleScavenge();
|
||||
}
|
||||
|
||||
private static void Reschedule(object arg)
|
||||
{
|
||||
ScavengeImageCache cache = arg as ScavengeImageCache;
|
||||
if (!cache.CleanupPending)
|
||||
return;
|
||||
TimeoutManager timeoutManager = cache._session.Dispatcher.TimeoutManager;
|
||||
ScavengeImageCache.ScavengeCallback callback = cache._callback;
|
||||
cache._callback = null;
|
||||
if (callback != null)
|
||||
timeoutManager.CancelTimeout(callback);
|
||||
ScavengeImageCache.ScavengeCallback scavengeCallback = new ScavengeImageCache.ScavengeCallback(cache);
|
||||
timeoutManager.SetTimeoutRelative(scavengeCallback, TimeSpan.FromSeconds(5.0));
|
||||
cache._callback = scavengeCallback;
|
||||
}
|
||||
|
||||
private class ScavengeCallback : QueueItem
|
||||
{
|
||||
private ScavengeImageCache _cache;
|
||||
|
||||
public ScavengeCallback(ScavengeImageCache cache) => _cache = cache;
|
||||
|
||||
public override void Dispatch()
|
||||
{
|
||||
if (_cache._callback != this)
|
||||
return;
|
||||
_cache._callback = null;
|
||||
_cache.CullObjects();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.ScrollbarEnableFlags
|
||||
// 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.Drawing
|
||||
{
|
||||
internal enum ScrollbarEnableFlags
|
||||
{
|
||||
EnableBoth,
|
||||
DisableNear,
|
||||
DisableFar,
|
||||
DisableBoth,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.ScrollbarType
|
||||
// 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.Drawing
|
||||
{
|
||||
internal enum ScrollbarType
|
||||
{
|
||||
Horizontal = 0,
|
||||
Vertical = 1,
|
||||
Both = 3,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.SimpleText
|
||||
// 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.OS;
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.RenderAPI;
|
||||
using Microsoft.Iris.Session;
|
||||
using Microsoft.Iris.ViewItems;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal class SimpleText : IDisposable
|
||||
{
|
||||
private Win32Api.HANDLE _stoHandle;
|
||||
|
||||
public SimpleText()
|
||||
{
|
||||
Size sizeMaximumSurface = Size.Zero;
|
||||
if (UISession.Default != null)
|
||||
sizeMaximumSurface = UIImage.MaximumSurfaceSize(UISession.Default);
|
||||
RendererApi.IFC(NativeApi.SpSimpleTextBuildObject(sizeMaximumSurface, out _stoHandle));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
NativeApi.SpSimpleTextDestroyObject(_stoHandle);
|
||||
_stoHandle = Win32Api.HANDLE.NULL;
|
||||
}
|
||||
|
||||
public unsafe bool CanMeasure(string content, TextStyle textStyle)
|
||||
{
|
||||
bool fPossible;
|
||||
fixed (char* chPtr = textStyle.FontFace)
|
||||
{
|
||||
var style = new TextStyle.MarshalledData(textStyle)
|
||||
{
|
||||
_fontFace = chPtr
|
||||
};
|
||||
RendererApi.IFC(NativeApi.SpSimpleTextMeasurePossible(_stoHandle, content, &style, out fPossible));
|
||||
}
|
||||
return fPossible;
|
||||
}
|
||||
|
||||
public unsafe TextFlow Measure(
|
||||
string content,
|
||||
LineAlignment alignment,
|
||||
TextStyle textStyle,
|
||||
Size constraint)
|
||||
{
|
||||
TextFlow textFlow = new TextFlow();
|
||||
if (content == null)
|
||||
content = string.Empty;
|
||||
short wAlignment = 0;
|
||||
switch (alignment)
|
||||
{
|
||||
case LineAlignment.Near:
|
||||
wAlignment = 1;
|
||||
break;
|
||||
case LineAlignment.Center:
|
||||
wAlignment = 3;
|
||||
break;
|
||||
case LineAlignment.Far:
|
||||
wAlignment = 2;
|
||||
break;
|
||||
}
|
||||
IntPtr hGlyphRunInfo;
|
||||
NativeApi.RasterizeRunPacket rasterizeRunPacket;
|
||||
fixed (char* chPtr = textStyle.FontFace)
|
||||
{
|
||||
var style = new TextStyle.MarshalledData(textStyle)
|
||||
{
|
||||
_fontFace = chPtr
|
||||
};
|
||||
RendererApi.IFC(NativeApi.SpSimpleTextMeasure(_stoHandle, content, wAlignment,
|
||||
&style, constraint, out hGlyphRunInfo, &rasterizeRunPacket));
|
||||
}
|
||||
TextRun run = TextRun.FromRunPacket(hGlyphRunInfo, &rasterizeRunPacket, content);
|
||||
textFlow.Add(run);
|
||||
return textFlow;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.TextFlow
|
||||
// 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.OS;
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.RenderAPI.Drawing;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal sealed class TextFlow : DisposableObject
|
||||
{
|
||||
private object _runsList;
|
||||
private Vector _lineBounds;
|
||||
private Rectangle _bounds;
|
||||
private Rectangle _fitBounds;
|
||||
private TextRun _lastFitRun;
|
||||
private TextRun _firstFitOnFinalLineRun;
|
||||
private int _firstVisibleIndex;
|
||||
private int _lastVisibleIndex;
|
||||
|
||||
internal TextFlow()
|
||||
{
|
||||
_bounds = new Rectangle(int.MaxValue, int.MaxValue, int.MinValue, int.MinValue);
|
||||
ResetFitTracking();
|
||||
ResetVisibleTracking();
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
if (_runsList != null)
|
||||
{
|
||||
if (_runsList is TextRun runsList)
|
||||
{
|
||||
runsList.UnregisterUsage(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (SharedDisposableObject runs in (Vector)_runsList)
|
||||
runs.UnregisterUsage(this);
|
||||
}
|
||||
}
|
||||
base.OnDispose();
|
||||
}
|
||||
|
||||
public TextRun this[int index] => _runsList is TextRun runsList ? runsList : (TextRun)((Vector)_runsList)[index];
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_runsList is Vector runsList)
|
||||
return runsList.Count;
|
||||
return _runsList == null ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector LineBounds => _lineBounds;
|
||||
|
||||
internal Rectangle GetLastLineBounds(int lineAlignmentOffset)
|
||||
{
|
||||
Rectangle left = Rectangle.Zero;
|
||||
for (int index = Count - 1; index >= 0; --index)
|
||||
{
|
||||
TextRun run = this[index];
|
||||
if (IsOnLastLine(run))
|
||||
{
|
||||
Point position = run.Position;
|
||||
Size size = run.Size;
|
||||
int x = position.X + lineAlignmentOffset;
|
||||
int y = position.Y;
|
||||
int num1 = x + size.Width;
|
||||
int num2 = y + size.Height;
|
||||
Rectangle right = new Rectangle(x, y, num1 - x, num2 - y);
|
||||
left = !left.IsZero ? Rectangle.Union(left, right) : right;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return left;
|
||||
}
|
||||
|
||||
internal bool IsOnLastLine(TextRun run) => run.Line == LastFitRun.Line;
|
||||
|
||||
public Rectangle Bounds => _bounds;
|
||||
|
||||
public Rectangle FitBounds => _fitBounds;
|
||||
|
||||
public TextRun LastFitRun => _lastFitRun;
|
||||
|
||||
public TextRun FirstFitRunOnFinalLine => _firstFitOnFinalLineRun;
|
||||
|
||||
public int FirstVisibleIndex => _firstVisibleIndex;
|
||||
|
||||
public int LastVisibleIndex => _lastVisibleIndex;
|
||||
|
||||
public bool HasVisibleRuns => _firstVisibleIndex != -1;
|
||||
|
||||
public void Add(TextRun run)
|
||||
{
|
||||
_bounds = Rectangle.Union(_bounds, run.LayoutBounds);
|
||||
if (_runsList == null)
|
||||
{
|
||||
_runsList = run;
|
||||
_lineBounds = new Vector();
|
||||
_lineBounds.Add(run.RenderBounds);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(_runsList is Vector vector))
|
||||
{
|
||||
object runsList = _runsList;
|
||||
vector = new Vector();
|
||||
vector.Add(runsList);
|
||||
_runsList = vector;
|
||||
}
|
||||
if (run.UnderlineStyle != NativeApi.UnderlineStyle.None)
|
||||
{
|
||||
Rectangle underlineBounds = run.UnderlineBounds;
|
||||
int line1 = run.Line;
|
||||
for (int index = vector.Count - 1; index > 0; --index)
|
||||
{
|
||||
Point position = ((TextRun)vector[index]).Position;
|
||||
int line2 = ((TextRun)vector[index]).Line;
|
||||
if (position.X >= underlineBounds.Left && line1 == line2)
|
||||
((TextRun)vector[index]).UnderlineStyle = run.UnderlineStyle;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_lineBounds.Count < run.Line)
|
||||
{
|
||||
_lineBounds.Add(run.RenderBounds);
|
||||
}
|
||||
else
|
||||
{
|
||||
RectangleF lineBound = (RectangleF)_lineBounds[run.Line - 1];
|
||||
if ((int)lineBound.Y > (int)run.RenderBounds.Y || lineBound.IsEmpty)
|
||||
_lineBounds[run.Line - 1] = run.RenderBounds;
|
||||
}
|
||||
vector.Add(run);
|
||||
}
|
||||
run.RegisterUsage(this);
|
||||
}
|
||||
|
||||
public void AddFit(TextRun run)
|
||||
{
|
||||
_fitBounds = Rectangle.Union(_fitBounds, run.LayoutBounds);
|
||||
if (run.LayoutBounds.IsEmpty)
|
||||
return;
|
||||
if (_firstFitOnFinalLineRun == null || run.Line > _firstFitOnFinalLineRun.Line)
|
||||
_firstFitOnFinalLineRun = run;
|
||||
_lastFitRun = run;
|
||||
}
|
||||
|
||||
public void AddVisible(int runIndex)
|
||||
{
|
||||
this[runIndex].Visible = true;
|
||||
if (_firstVisibleIndex == -1)
|
||||
_firstVisibleIndex = runIndex;
|
||||
_lastVisibleIndex = runIndex;
|
||||
}
|
||||
|
||||
public void ResetFitTracking()
|
||||
{
|
||||
_lastFitRun = null;
|
||||
_fitBounds = new Rectangle(int.MaxValue, int.MaxValue, int.MinValue, int.MinValue);
|
||||
}
|
||||
|
||||
public void ResetVisibleTracking()
|
||||
{
|
||||
_firstVisibleIndex = -1;
|
||||
_lastVisibleIndex = int.MinValue;
|
||||
}
|
||||
|
||||
public void ClearSprites()
|
||||
{
|
||||
if (_runsList == null)
|
||||
return;
|
||||
if (_runsList is TextRun runsList)
|
||||
{
|
||||
runsList.TextSprite = null;
|
||||
runsList.HighlightSprite = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (TextRun runs in (Vector)_runsList)
|
||||
{
|
||||
runs.TextSprite = null;
|
||||
runs.HighlightSprite = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Drawing.TextImageCache
|
||||
// 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.Queues;
|
||||
using Microsoft.Iris.Render.Extensions;
|
||||
using Microsoft.Iris.Session;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.Drawing
|
||||
{
|
||||
internal sealed class TextImageCache : ImageCache
|
||||
{
|
||||
private static TextImageCache s_theOnlyCache;
|
||||
private static readonly DeferredHandler s_dhReschedule = new DeferredHandler(Reschedule);
|
||||
private UISession _session;
|
||||
private TextImageCache.ScavengeCallback _callback;
|
||||
|
||||
public static void Initialize(UISession session)
|
||||
{
|
||||
s_theOnlyCache = new TextImageCache(session);
|
||||
s_theOnlyCache.NumItemsToKeep = 500;
|
||||
s_theOnlyCache.ItemRetainTime = TimeSpan.Zero;
|
||||
}
|
||||
|
||||
public static void Uninitialize(UISession session)
|
||||
{
|
||||
if (s_theOnlyCache == null)
|
||||
return;
|
||||
s_theOnlyCache.Dispose();
|
||||
}
|
||||
|
||||
public static TextImageCache Instance => s_theOnlyCache;
|
||||
|
||||
private TextImageCache(UISession session)
|
||||
: base(session.RenderSession, nameof(TextImageCache))
|
||||
=> _session = session;
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
TimeoutManager timeoutManager = _session.Dispatcher.TimeoutManager;
|
||||
TextImageCache.ScavengeCallback callback = _callback;
|
||||
if (callback != null)
|
||||
timeoutManager.CancelTimeout(callback);
|
||||
_callback = null;
|
||||
base.OnDispose();
|
||||
}
|
||||
|
||||
protected override void ScheduleScavenge()
|
||||
{
|
||||
if (!CleanupPending)
|
||||
DeferredCall.Post(DispatchPriority.Idle, s_dhReschedule, this);
|
||||
base.ScheduleScavenge();
|
||||
}
|
||||
|
||||
private static void Reschedule(object arg)
|
||||
{
|
||||
TextImageCache cache = arg as TextImageCache;
|
||||
if (!cache.CleanupPending)
|
||||
return;
|
||||
TimeoutManager timeoutManager = cache._session.Dispatcher.TimeoutManager;
|
||||
TextImageCache.ScavengeCallback callback = cache._callback;
|
||||
cache._callback = null;
|
||||
if (callback != null)
|
||||
timeoutManager.CancelTimeout(callback);
|
||||
TextImageCache.ScavengeCallback scavengeCallback = new TextImageCache.ScavengeCallback(cache);
|
||||
timeoutManager.SetTimeoutRelative(scavengeCallback, TimeSpan.FromSeconds(5.0));
|
||||
cache._callback = scavengeCallback;
|
||||
}
|
||||
|
||||
private class ScavengeCallback : QueueItem
|
||||
{
|
||||
private TextImageCache _cache;
|
||||
|
||||
public ScavengeCallback(TextImageCache cache) => _cache = cache;
|
||||
|
||||
public override void Dispatch()
|
||||
{
|
||||
if (_cache._callback != this)
|
||||
return;
|
||||
_cache._callback = null;
|
||||
_cache.CullObjects();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user