VS All Access
Microsoft wanted a showcase piece to prove to the Internet that Silverlight could do what Flash could do. This was that proof.






If I recall correctly, Netflix used Silverlight to stream movies on the web in the early days. Microsoft intended for it to be a Flash competitor, especially for video, but that obviously didn’t pan out. But that wasn’t for lack of trying. This is a story of how they tried and my small part in all that.
By 2009, Big Spaceship was well known for its polished Flash experiences. Adobe would often partner with us and movie studios to build showcase pieces. We’d get more budget, the client got more features & functionality, and Adobe got a case study. When one of Adobe’s principal Flash evangelists jumped ship to Microsoft, it only made sense that they’d reach out with a similar deal.
I don’t recall whether it was Microsoft or Victoria’s Secret who reached out first. What I remember is that a showcase was required for the famous Victoria’s Secret Fashion Show, that there wasn’t a lot of time (<= 3 months), and that the requirement was to build a showcase streaming experience in Silverlight.
There was only one problem: Nobody at the company had ever even opened Visual Studio or knew a thing about Silverlight.
As the solo engineer, my job was to figure all that out. I needed to teach the designers about the tech, too – we were used to collaborating on Flash timelines but we didn’t know what was even possible in Silverlight. Shine Draw’s website was essential here. A developer named Terence Tsang would build the same small thing twice, once in Flash and once in Silverlight, and post the source for both. Here is how you load a SWF. Here is how you load a XAP. It was like a Rosetta Stone for me. Stuff like this:
movieclip.x = 100; // actionscript
usercontrol.SetValue(Canvas.LeftProperty, 100); // c# / silverlight
Using that, I was able to go from prototypes to frameworks. I actually ported a good chunk of Big Spaceship’s ActionScript library to Silverlight, largely around loading and animation states.
- display
- videoplayer
- controls
- overlays
- controls
- videoplayer
- events
- loading
- utils
using System;
using System.Collections.Generic;
using com.bigspaceship.events;
using com.bigspaceship.utils;
namespace com.bigspaceship.loading
{
public class BigLoader
{
private static int __MAX_CONNECTIONS = 2;
private bool _verbose = true;
private List<BigLoadItem> _itemsToLoad;
private int _curLoadIndex = 0;
private int _activeLoads = 0;
private int _numComplete = 0;
private bool _loaderActive = false;
private Dictionary<string, object> _contentDict;
public event BigLoadItemEventHandler Progress;
public event EventHandler Completed;
public event EventHandler ItemCompleted;
public BigLoader()
{
_contentDict = new Dictionary<string, object>();
_itemsToLoad = new List<BigLoadItem>();
disableLog();
}
public void destroy()
{
_contentDict.Clear();
for (int i = 0; i < _itemsToLoad.Count; i++)
{
_itemsToLoad[i].Completed -= _onItemLoadCompleted;
_itemsToLoad[i].Progress -= _onItemLoadCompleted;
_itemsToLoad[i].destroy();
}
_itemsToLoad.Clear();
_contentDict = null;
_itemsToLoad = null;
}
public void enableLog()
{
_verbose = true;
}
public void disableLog()
{
_verbose = false;
}
public BigLoadItem add(string url)
{
return add(url, null, 1.0, null);
}
public BigLoadItem add(string url, string id)
{
return add(url, id, 1.0, null);
}
public BigLoadItem add(string url, string id, double weight)
{
return add(url, id, weight, null);
}
public BigLoadItem add(string url, string id, string extension)
{
return add(url, id, 1.0, extension);
}
public BigLoadItem add(string url, string id, double weight, string extension)
{
if (_loaderActive)
{
Out.fatal(this, "You can't add anything after the loader is started.");
return null;
}
if (id == null)
{
id = url;
}
BigLoadItem bigLoadItem = new BigLoadItem(url, id, weight, extension);
bigLoadItem.Progress += _onItemProgress;
bigLoadItem.Completed += _onItemLoadCompleted;
_itemsToLoad.Add(bigLoadItem);
return bigLoadItem;
}
public void start()
{
if (_loaderActive)
{
Out.fatal(this, "Loader is already started");
return;
}
_log("Starting load of " + _itemsToLoad.Count + " items.");
_loaderActive = true;
int num = Math.Min(_itemsToLoad.Count, __MAX_CONNECTIONS);
while (_activeLoads < num)
{
_loadItem();
}
}
public object getAsset(string id)
{
if (!_contentDict.ContainsKey(id))
{
_log("Warning: Asset not loaded yet.");
return null;
}
return _contentDict[id];
}
private void _loadItem()
{
BigLoadItem bigLoadItem = _itemsToLoad[_curLoadIndex];
bigLoadItem.startLoad();
_log("Starting load of " + bigLoadItem.ToString());
_activeLoads++;
_curLoadIndex++;
}
private void _onItemProgress(object sender, EventArgs e)
{
double num = 0.0;
int num2 = _itemsToLoad.Count;
while (--num2 > -1)
{
num += _itemsToLoad[num2].getWeightedPercentage();
}
if (this.Progress != null)
{
this.Progress(this, new BigLoadEvent(num * 100.0));
}
}
private void _onItemLoadCompleted(object sender, EventArgs e)
{
BigLoadItem bigLoadItem = sender as BigLoadItem;
_activeLoads--;
_contentDict[bigLoadItem.id] = bigLoadItem.content;
_log("COMPLETE :: " + bigLoadItem.ToString());
if (this.ItemCompleted != null)
{
this.ItemCompleted(sender, e);
}
_numComplete++;
if (_numComplete == _itemsToLoad.Count)
{
_allLoadsComplete();
}
else if (_curLoadIndex < _itemsToLoad.Count)
{
_loadItem();
}
}
private void _allLoadsComplete()
{
_loaderActive = false;
if (this.Completed != null)
{
this.Completed(this, new EventArgs());
}
}
private void _log(string str)
{
if (_verbose)
{
Out.info(this, str.ToString());
}
}
}
}using System;
using System.IO;
using System.Net;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.Windows.Resources;
using com.bigspaceship.utils;
namespace com.bigspaceship.loading
{
public class BigLoadItem
{
public const string TEXT = "bssText";
public const string IMAGE = "bssImage";
public const string XAP = "bssXap";
public const string VIDEO = "bssVideo";
private static double __totalWeight = 0.0;
private string _id;
private string _url;
private string _type;
private string _xapNameSpace;
private double _weight;
private double _pctLoaded = 0.0;
private bool _loaded = false;
private bool _loading = false;
private bool _loaderIsSetUp = false;
private int _loadAttempts = 0;
private object _content;
private WebClient _loader;
private MediaElement _videoLoader;
public string type => _type;
public string url => _url;
public string id => _id;
public string xapNameSpace
{
get
{
return _xapNameSpace;
}
set
{
_xapNameSpace = value;
}
}
public object content => _content;
public bool loaded => _loaded;
public event EventHandler Progress;
public event EventHandler Completed;
public BigLoadItem(string url, string id, double weight)
: this(url, id, weight, null)
{
}
public BigLoadItem(string url, string id, double weight, string extension)
{
_url = url;
_id = id;
_weight = weight;
__totalWeight += (int)_weight;
string text = ((extension != null) ? extension : Path.GetExtension(_url).Split(new char[1] { '?' })[0]);
if (text == ".xml" || text == ".txt" || text == ".json")
{
_type = "bssText";
}
else if (text == ".xap")
{
_type = "bssXap";
}
else if (text == ".mp4" || text == ".wmv")
{
_type = "bssVideo";
}
else
{
_type = "bssImage";
}
_setupLoader();
}
public void destroy()
{
if (_loading)
{
if (type != "bssVideo" && _loader.IsBusy)
{
_loader.CancelAsync();
}
else if (type == "bssVideo")
{
_videoLoader.set_Source((Uri)null);
}
_removeLoader();
}
_loader = null;
_videoLoader = null;
_content = null;
}
public void startLoad()
{
if (_loading)
{
return;
}
_loading = true;
if (!_loaded)
{
Uri uri = new Uri(_url, UriKind.RelativeOrAbsolute);
if (_type == "bssText")
{
_loader.DownloadStringAsync(uri);
}
else if (_type == "bssXap" || _type == "bssImage")
{
_loader.OpenReadAsync(uri);
}
else if (_type == "bssVideo")
{
_videoLoader.set_Source(uri);
}
}
else
{
_onComplete(_content);
}
}
private void _setupLoader()
{
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Expected O, but got Unknown
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Expected O, but got Unknown
if (_loaderIsSetUp)
{
return;
}
_loaderIsSetUp = true;
if (_type != "bssVideo")
{
_loader = new WebClient();
_loader.DownloadProgressChanged += _onProgress;
if (_type == "bssText")
{
_loader.DownloadStringCompleted += _onComplete;
}
else if (_type == "bssImage" || _type == "bssXap")
{
_loader.OpenReadCompleted += _onComplete;
}
}
else
{
_videoLoader = new MediaElement();
_videoLoader.set_AutoPlay(false);
_videoLoader.add_DownloadProgressChanged(new RoutedEventHandler(_onProgress));
}
}
private void _removeLoader()
{
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Expected O, but got Unknown
if (!_loaderIsSetUp)
{
return;
}
if (_type != "bssVideo")
{
_loaderIsSetUp = false;
_loader.DownloadProgressChanged -= _onProgress;
if (_type == "bssText")
{
_loader.DownloadStringCompleted -= _onComplete;
}
else if (_type == "bssImage" || _type == "bssXap" || _type == "bssVideo")
{
_loader.OpenReadCompleted -= _onComplete;
}
}
else
{
_videoLoader.remove_DownloadProgressChanged(new RoutedEventHandler(_onProgress));
}
}
private void _onProgress(object sender, RoutedEventArgs e)
{
_pctLoaded = _videoLoader.get_DownloadProgress();
Out.debug(this, "Video Progress: " + _pctLoaded);
if (_pctLoaded == 1.0)
{
_onComplete(sender);
}
else if (this.Progress != null)
{
this.Progress(this, new EventArgs());
}
}
private void _onProgress(object sender, DownloadProgressChangedEventArgs e)
{
_pctLoaded = e.BytesReceived / e.TotalBytesToReceive;
if (this.Progress != null)
{
this.Progress(this, new EventArgs());
}
}
private void _onComplete(object sender, OpenReadCompletedEventArgs e)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
if (e.Error == null)
{
if (_type == "bssXap")
{
if (_xapNameSpace == null)
{
_xapNameSpace = Path.GetFileNameWithoutExtension(_url);
}
string uriString = _xapNameSpace + ".dll";
StreamResourceInfo resourceStream = Application.GetResourceStream(new StreamResourceInfo(e.Result, (string)null), new Uri(uriString, UriKind.Relative));
AssemblyPart val = new AssemblyPart();
Assembly assembly = val.Load(resourceStream.get_Stream());
_onComplete(assembly);
}
else if (_type == "bssImage")
{
BitmapImage val2 = new BitmapImage();
((BitmapSource)val2).SetSource(e.Result);
_onComplete(val2);
}
else
{
_onComplete(e.Result);
}
}
else
{
_onIOError(e.Error.Message);
}
}
private void _onComplete(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(e.Result);
_onComplete(stringBuilder);
}
else
{
_onIOError(e.Error.Message);
}
}
private void _onComplete(object content)
{
_loading = false;
if (!_loaded)
{
_loaded = true;
_removeLoader();
}
_content = content;
_pctLoaded = 1.0;
if (this.Completed != null)
{
this.Completed(this, new EventArgs());
}
}
private void _onIOError(string error)
{
_loading = false;
_loadAttempts++;
if (_loadAttempts > 3)
{
_removeLoader();
Out.fatal(this, "_onIOError(): " + error.ToString() + ", URL: " + _url);
}
else
{
startLoad();
}
}
public override string ToString()
{
return "BigLoadItem :: " + _id;
}
public double getWeightedPercentage()
{
return _weight / __totalWeight * _pctLoaded;
}
}
}using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using com.bigspaceship.utils;
namespace com.bigspaceship.display
{
public class Standard
{
protected const string __IN = "_in";
protected const string __OUT = "_out";
protected bool _isDestroyed;
protected UserControl _uc;
protected string _curState;
protected string _xapNameSpace;
protected Assembly _xapAssembly;
public UserControl uc => _uc;
public Assembly xapAssembly
{
get
{
return _xapAssembly;
}
set
{
_xapAssembly = value;
}
}
public string xapNameSpace
{
get
{
return _xapNameSpace;
}
set
{
_xapNameSpace = value;
}
}
public string state => _curState;
public Standard(UserControl uc)
{
_uc = uc;
if (_uc == null)
{
Out.fatal(this, "UserControl is null");
}
}
public Standard(UserControl uc, Assembly assembly, string classname)
: this(uc)
{
_xapAssembly = assembly;
_xapNameSpace = classname;
}
public virtual void destroy()
{
_uc = null;
_xapAssembly = null;
_xapNameSpace = null;
_isDestroyed = true;
}
public virtual void gotoAndPlay(string frameLabel)
{
if (!_isDestroyed)
{
VisualStateManager.GoToState((Control)(object)_uc, frameLabel.ToLower(), true);
}
}
public virtual FrameworkElement _(string path)
{
if (_isDestroyed)
{
return null;
}
string[] array = path.Split(new char[1] { '.' });
FrameworkElement val = (FrameworkElement)(object)_uc;
string[] array2 = array;
foreach (string text in array2)
{
string text2 = text;
if (text2 == "layoutroot")
{
text2 = "LayoutRoot";
}
if (val == null)
{
Out.fatal(this, "Control not found: " + text2 + " in " + path);
}
if (text2 != "this")
{
object obj = val.FindName(text2);
val = (FrameworkElement)((obj is FrameworkElement) ? obj : null);
}
}
return val;
}
}
}using System;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
using com.bigspaceship.utils;
namespace com.bigspaceship.display
{
public class StandardInOut : Standard
{
private bool _isCollapsedOnAnimateOut = false;
private bool _dispatchCompleteOnUnchangedState = false;
private Storyboard _in;
private Storyboard _out;
public bool dispatchCompleteOnUnchangedState
{
get
{
return _dispatchCompleteOnUnchangedState;
}
set
{
_dispatchCompleteOnUnchangedState = value;
}
}
public bool isAnimating => _curState == AnimationState.IN_START || _curState == AnimationState.OUT_START;
public virtual event EventHandler AnimatedIn;
public virtual event EventHandler AnimationInStarted;
public virtual event EventHandler AnimatedOut;
public virtual event EventHandler AnimationOutStarted;
public StandardInOut(UserControl uc)
: this(uc, isCollapsedOnAnimateOut: false)
{
}
public StandardInOut(UserControl uc, Assembly assembly, string classname)
: this(uc, isCollapsedOnAnimateOut: false, assembly, classname)
{
}
public StandardInOut(UserControl uc, bool isCollapsedOnAnimateOut, Assembly assembly, string classname)
: this(uc, isCollapsedOnAnimateOut)
{
_xapAssembly = assembly;
_xapNameSpace = classname;
}
public StandardInOut(UserControl uc, bool isCollapsedOnAnimateOut)
: base(uc)
{
_curState = AnimationState.OUT;
_isCollapsedOnAnimateOut = isCollapsedOnAnimateOut;
if (_isCollapsedOnAnimateOut)
{
((UIElement)_uc).set_Visibility((Visibility)1);
}
_in = DisplayUtils.getIn(_uc);
_out = DisplayUtils.getOut(_uc);
}
public override void destroy()
{
try
{
((Timeline)_out).remove_Completed((EventHandler)_onAnimateOut_handler);
}
catch
{
}
try
{
((Timeline)_in).remove_Completed((EventHandler)_onAnimateIn_handler);
}
catch
{
}
try
{
_in.Stop();
}
catch
{
}
try
{
_out.Stop();
}
catch
{
}
base.destroy();
}
public virtual void animateIn()
{
animateIn(forceAnimation: false);
}
public virtual void animateIn(bool forceAnimation)
{
if ((_curState != AnimationState.IN_START && _curState != AnimationState.IN) || forceAnimation)
{
_curState = AnimationState.IN_START;
((Timeline)_in).add_Completed((EventHandler)_onAnimateIn_handler);
if (_isCollapsedOnAnimateOut)
{
((UIElement)_uc).set_Visibility((Visibility)0);
}
gotoAndPlay("_in");
_onAnimateInStart();
if (this.AnimationInStarted != null)
{
this.AnimationInStarted(this, null);
}
}
else if (_curState == AnimationState.IN && _dispatchCompleteOnUnchangedState)
{
_onAnimateIn_handler(null, null);
}
}
private void _onAnimateIn_handler(object sender, EventArgs e)
{
if (sender != null)
{
((Timeline)((sender is Storyboard) ? sender : null)).remove_Completed((EventHandler)_onAnimateIn_handler);
}
_curState = AnimationState.IN;
_onAnimateIn();
if (this.AnimatedIn != null)
{
this.AnimatedIn(this, null);
}
}
protected virtual void _onAnimateInStart()
{
}
protected virtual void _onAnimateIn()
{
}
public virtual void animateOut()
{
animateOut(forceAnimation: false);
}
public virtual void animateOut(bool forceAnimation)
{
if ((_curState == AnimationState.IN && _curState != AnimationState.OUT_START && _curState != AnimationState.OUT) || forceAnimation)
{
_curState = AnimationState.OUT_START;
((Timeline)_out).add_Completed((EventHandler)_onAnimateOut_handler);
gotoAndPlay("_out");
_onAnimateOutStart();
if (this.AnimationOutStarted != null)
{
this.AnimationOutStarted(this, null);
}
}
else if (_curState == AnimationState.OUT && _dispatchCompleteOnUnchangedState)
{
_onAnimateOut_handler(null, null);
}
}
private void _onAnimateOut_handler(object sender, EventArgs e)
{
if (sender != null)
{
((Timeline)((sender is Storyboard) ? sender : null)).remove_Completed((EventHandler)_onAnimateOut_handler);
}
if (_isCollapsedOnAnimateOut)
{
((UIElement)_uc).set_Visibility((Visibility)1);
}
_curState = AnimationState.OUT;
_onAnimateOut();
if (this.AnimatedOut != null)
{
this.AnimatedOut(this, new EventArgs());
}
}
protected virtual void _onAnimateOutStart()
{
}
protected virtual void _onAnimateOut()
{
}
}
}namespace com.bigspaceship.display
{
public class AnimationState
{
public static readonly string INIT = "animateInit";
public static readonly string IN_START = "animateInStart";
public static readonly string IN = "animateIn";
public static readonly string OUT_START = "animateOutStart";
public static readonly string OUT = "animateOut";
public static readonly string START = "animateBegin";
public static readonly string UPDATE = "animateUpdate";
public static readonly string CANCEL = "animateCancel";
public static readonly string COMPLETE = "animateComplete";
public static readonly string IDLE = "animateIdle";
public static readonly string ROLL_OVER = "animateRollOver";
public static readonly string ROLL_OVER_START = "animateRollOverStart";
public static readonly string ROLL_OUT = "animateRollOut";
public static readonly string ROLL_OUT_START = "animateRollOutStart";
public static readonly string CLICK = "animateClick";
public static readonly string CLICK_START = "animateClickStart";
public static readonly string MOUSE_DOWN = "animateMouseDown";
public static readonly string MOUSE_DOWN_START = "animateMouseDownStart";
public static readonly string MOUSE_UP = "animateMouseUp";
public static readonly string MOUSE_UP_START = "animateMouseUpStart";
}
}using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
using com.bigspaceship.utils;
namespace com.bigspaceship.display
{
public class Preloader : StandardInOut
{
private double _percentLoaded;
private int _statesCompleted;
private bool _isComplete;
private bool _isAnimating;
public Preloader(UserControl uc)
: base(uc, isCollapsedOnAnimateOut: true)
{
}
protected override void _onAnimateInStart()
{
_isComplete = false;
base._onAnimateInStart();
}
protected override void _onAnimateIn()
{
base._onAnimateIn();
_percentLoaded = 0.0;
_statesCompleted = 0;
}
protected override void _onAnimateOut()
{
base._onAnimateOut();
_statesCompleted = 0;
_percentLoaded = 0.0;
}
public void updateProgress(double percentageLoaded)
{
_percentLoaded = percentageLoaded;
if (Convert.ToInt32(_percentLoaded * 0.1) > _statesCompleted && _statesCompleted < 10 && !_isAnimating)
{
_isAnimating = true;
string text = "_" + (_statesCompleted + 1) * 10 + "p";
Storyboard storyboardFromVisualStateGroupById = DisplayUtils.getStoryboardFromVisualStateGroupById(_uc, "transitions", text);
((Timeline)storyboardFromVisualStateGroupById).add_Completed((EventHandler)_stateOnCompleted);
VisualStateManager.GoToState((Control)(object)_uc, text, true);
}
}
private void _stateOnCompleted(object sender, EventArgs e)
{
((Timeline)((sender is Storyboard) ? sender : null)).remove_Completed((EventHandler)_stateOnCompleted);
_isAnimating = false;
_statesCompleted++;
if (_statesCompleted >= 10 && _isComplete)
{
animateOut();
}
else
{
updateProgress(_percentLoaded);
}
}
public void setComplete()
{
_isComplete = true;
_percentLoaded = 100.0;
if (_statesCompleted >= 10 && !_isAnimating)
{
animateOut();
}
else
{
updateProgress(_percentLoaded);
}
}
}
}using System.Reflection;
using System.Windows.Controls;
using com.bigspaceship.display;
namespace com.bigspaceship.utils
{
public class Lib
{
public static UserControl createMainPage(string xri, Assembly assembly)
{
return createUserControl(xri + ".MainPage", assembly);
}
public static UserControl createUserControl(Standard standard, string classname)
{
return createUserControl(standard.xapNameSpace, classname, standard.xapAssembly);
}
public static UserControl createUserControl(string xri, string classname, Assembly assembly)
{
return createUserControl(xri + "." + classname, assembly);
}
public static UserControl createUserControl(string classname, Assembly assembly)
{
object obj = assembly.CreateInstance(classname);
return (UserControl)((obj is UserControl) ? obj : null);
}
}
}using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
using com.bigspaceship.utils;
namespace com.bigspaceship.display
{
public class StandardButton : Standard
{
protected const string __ROLL_OUT = "rollout";
protected const string __ROLL_OVER = "rollover";
protected const string __MOUSE_UP = "mouseUp";
protected const string __MOUSE_DOWN = "mouseDown";
protected FrameworkElement _btn;
protected bool _active = true;
private bool _isListenersAdded;
private bool _useWeakListeners = false;
private bool _isMouseEntered;
private bool _isMouseLeftButtonDown;
protected string _selectAnimStartLabel = "rollover";
protected string _deselectAnimStartLabel = "rollout";
private List<string> _labels;
public FrameworkElement btn => _btn;
public bool active
{
get
{
return _active;
}
set
{
bool flag = _active;
_active = value;
if (_active && !flag)
{
addBtnEventListeners();
}
else if (!_active && flag)
{
removeBtnEventListeners();
}
}
}
public string selectedLabel
{
set
{
_selectAnimStartLabel = value;
}
}
public string deselectedLabel
{
set
{
_deselectAnimStartLabel = value;
}
}
public event EventHandler MouseUpAnimationStarted;
public event EventHandler MouseDownAnimationStarted;
public event EventHandler RollOutAnimationStarted;
public event EventHandler RollOverAnimationStarted;
public virtual event MouseEventHandler MouseEnter
{
[MethodImpl(MethodImplOptions.Synchronized)]
add
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MouseEnter = (MouseEventHandler)Delegate.Combine((Delegate)(object)this.MouseEnter, (Delegate)(object)value);
}
[MethodImpl(MethodImplOptions.Synchronized)]
remove
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MouseEnter = (MouseEventHandler)Delegate.Remove((Delegate)(object)this.MouseEnter, (Delegate)(object)value);
}
}
public virtual event MouseEventHandler MouseLeave
{
[MethodImpl(MethodImplOptions.Synchronized)]
add
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MouseLeave = (MouseEventHandler)Delegate.Combine((Delegate)(object)this.MouseLeave, (Delegate)(object)value);
}
[MethodImpl(MethodImplOptions.Synchronized)]
remove
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MouseLeave = (MouseEventHandler)Delegate.Remove((Delegate)(object)this.MouseLeave, (Delegate)(object)value);
}
}
public virtual event MouseButtonEventHandler MouseDown
{
[MethodImpl(MethodImplOptions.Synchronized)]
add
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MouseDown = (MouseButtonEventHandler)Delegate.Combine((Delegate)(object)this.MouseDown, (Delegate)(object)value);
}
[MethodImpl(MethodImplOptions.Synchronized)]
remove
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MouseDown = (MouseButtonEventHandler)Delegate.Remove((Delegate)(object)this.MouseDown, (Delegate)(object)value);
}
}
public virtual event MouseButtonEventHandler MouseUp
{
[MethodImpl(MethodImplOptions.Synchronized)]
add
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MouseUp = (MouseButtonEventHandler)Delegate.Combine((Delegate)(object)this.MouseUp, (Delegate)(object)value);
}
[MethodImpl(MethodImplOptions.Synchronized)]
remove
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MouseUp = (MouseButtonEventHandler)Delegate.Remove((Delegate)(object)this.MouseUp, (Delegate)(object)value);
}
}
public virtual event MouseButtonEventHandler MouseClick
{
[MethodImpl(MethodImplOptions.Synchronized)]
add
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MouseClick = (MouseButtonEventHandler)Delegate.Combine((Delegate)(object)this.MouseClick, (Delegate)(object)value);
}
[MethodImpl(MethodImplOptions.Synchronized)]
remove
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MouseClick = (MouseButtonEventHandler)Delegate.Remove((Delegate)(object)this.MouseClick, (Delegate)(object)value);
}
}
public StandardButton(UserControl uc)
: this(uc, null)
{
}
public StandardButton(UserControl uc, Assembly assembly, string classname)
: this(uc, null, useWeakListeners: false, assembly, classname)
{
}
public StandardButton(UserControl uc, FrameworkElement btn, Assembly assembly, string classname)
: this(uc, btn, useWeakListeners: false, assembly, classname)
{
}
public StandardButton(UserControl uc, FrameworkElement btn)
: this(uc, btn, useWeakListeners: false)
{
}
public StandardButton(UserControl uc, FrameworkElement btn, bool useWeakListeners)
: this(uc, btn, useWeakListeners, null, null)
{
}
public StandardButton(UserControl uc, FrameworkElement btn, bool useWeakListeners, Assembly assembly, string classname)
: base(uc, assembly, classname)
{
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Expected O, but got Unknown
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Expected O, but got Unknown
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Expected O, but got Unknown
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Expected O, but got Unknown
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Expected O, but got Unknown
_useWeakListeners = useWeakListeners;
((FrameworkElement)_uc).add_LayoutUpdated((EventHandler)_onLayoutUpdated);
_labels = new List<string>();
if (btn != null)
{
_btn = btn;
}
else if (((FrameworkElement)_uc).FindName("btn") != null)
{
ref FrameworkElement reference = ref _btn;
object obj = ((FrameworkElement)_uc).FindName("btn");
reference = (FrameworkElement)((obj is FrameworkElement) ? obj : null);
}
else
{
_btn = (FrameworkElement)(object)_uc;
}
List<string> list = new List<string> { "rollout", "rollover", "mouseUp", "mouseDown" };
for (int i = 0; i < list.Count; i++)
{
Storyboard storyboardFromVisualStateGroupById = DisplayUtils.getStoryboardFromVisualStateGroupById(_uc, "transitions", "rollover");
if (storyboardFromVisualStateGroupById != null)
{
_labels.Add(list[i]);
}
}
DisplayUtils.getVisualStateGroupById(_uc, "transitions").add_CurrentStateChanged((EventHandler<VisualStateChangedEventArgs>)_onTimelineEvent_handler);
((UIElement)_btn).add_MouseEnter(new MouseEventHandler(_btnOnMouseEnter));
((UIElement)_btn).add_MouseLeave(new MouseEventHandler(_btnOnMouseLeave));
((UIElement)_btn).add_LostMouseCapture(new MouseEventHandler(_btnOnMouseLeave));
((UIElement)_btn).add_MouseLeftButtonUp(new MouseButtonEventHandler(_buttonOnMouseUp));
((UIElement)_btn).add_MouseLeftButtonDown(new MouseButtonEventHandler(_buttonOnMouseDown));
_isListenersAdded = false;
addBtnEventListeners();
}
public virtual void deselect()
{
if (!_active)
{
_curState = "rollout";
gotoAndPlay(_deselectAnimStartLabel);
}
((UIElement)_btn).set_Visibility((Visibility)0);
active = true;
}
public virtual void select()
{
if (_active)
{
_curState = "rollover";
gotoAndPlay(_selectAnimStartLabel);
}
((UIElement)_btn).set_Visibility((Visibility)1);
active = false;
}
public override void destroy()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
removeBtnEventListeners();
((UIElement)_btn).remove_MouseEnter(new MouseEventHandler(_btnOnMouseEnter));
((UIElement)_btn).remove_MouseLeave(new MouseEventHandler(_btnOnMouseLeave));
((UIElement)_btn).remove_LostMouseCapture(new MouseEventHandler(_btnOnMouseLeave));
((UIElement)_btn).remove_MouseLeftButtonDown(new MouseButtonEventHandler(_buttonOnMouseDown));
((UIElement)_btn).remove_MouseLeftButtonUp(new MouseButtonEventHandler(_buttonOnMouseUp));
_btn = null;
((FrameworkElement)_uc).remove_LayoutUpdated((EventHandler)_onLayoutUpdated);
DisplayUtils.getVisualStateGroupById(_uc, "transitions").remove_CurrentStateChanged((EventHandler<VisualStateChangedEventArgs>)_onTimelineEvent_handler);
base.destroy();
}
protected virtual void addBtnEventListeners()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Expected O, but got Unknown
if (!_isListenersAdded)
{
_isListenersAdded = true;
if (_labels.Contains("rollout"))
{
((UIElement)_btn).add_MouseLeave(new MouseEventHandler(_onMouseRollOut_handler));
}
if (_labels.Contains("rollover"))
{
((UIElement)_btn).add_MouseEnter(new MouseEventHandler(_onMouseRollOver_handler));
}
if (_labels.Contains("mouseUp"))
{
((UIElement)_btn).add_MouseLeftButtonUp(new MouseButtonEventHandler(_onMouseUp_handler));
}
if (_labels.Contains("mouseDown"))
{
((UIElement)_btn).add_MouseLeftButtonDown(new MouseButtonEventHandler(_onMouseDown_handler));
}
}
}
protected virtual void removeBtnEventListeners()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
if (_isListenersAdded)
{
_isListenersAdded = false;
if (_labels.Contains("rollout"))
{
((UIElement)_btn).remove_MouseLeave(new MouseEventHandler(_onMouseRollOut_handler));
}
if (_labels.Contains("rollover"))
{
((UIElement)_btn).remove_MouseEnter(new MouseEventHandler(_onMouseRollOver_handler));
}
if (_labels.Contains("mouseUp"))
{
((UIElement)_btn).remove_MouseLeftButtonUp(new MouseButtonEventHandler(_onMouseUp_handler));
}
if (_labels.Contains("mouseDown"))
{
((UIElement)_btn).remove_MouseLeftButtonDown(new MouseButtonEventHandler(_onMouseDown_handler));
}
}
}
protected virtual void _onTimelineEvent_handler(object sender, VisualStateChangedEventArgs e)
{
_curState = e.get_NewState().get_Name();
switch (_curState)
{
case "_in":
break;
case "rollout":
if (this.RollOutAnimationStarted != null)
{
this.RollOutAnimationStarted(this, null);
}
break;
case "rollover":
if (this.RollOverAnimationStarted != null)
{
this.RollOverAnimationStarted(this, null);
}
break;
case "mouseUp":
if (this.MouseUpAnimationStarted != null)
{
this.MouseUpAnimationStarted(this, null);
}
break;
case "mouseDown":
if (this.MouseDownAnimationStarted != null)
{
this.MouseDownAnimationStarted(this, null);
}
break;
}
}
private void _onMouseRollOver_handler(object sender, MouseEventArgs e)
{
gotoAndPlay("rollover");
}
private void _onMouseRollOut_handler(object sender, MouseEventArgs e)
{
gotoAndPlay("rollout");
}
private void _onMouseUp_handler(object sender, MouseButtonEventArgs e)
{
gotoAndPlay("mouseUp");
}
private void _onMouseDown_handler(object sender, MouseButtonEventArgs e)
{
gotoAndPlay("mouseDown");
}
private void _onLayoutUpdated(object sender, EventArgs e)
{
if (((FrameworkElement)_uc).get_Parent() == null && _useWeakListeners)
{
destroy();
}
}
private void _btnOnMouseEnter(object sender, MouseEventArgs e)
{
_isMouseEntered = true;
if (this.MouseEnter != null)
{
this.MouseEnter.Invoke((object)this, e);
}
}
private void _btnOnMouseLeave(object sender, MouseEventArgs e)
{
_isMouseEntered = false;
if (this.MouseLeave != null)
{
this.MouseLeave.Invoke((object)this, e);
}
}
private void _buttonOnMouseUp(object sender, MouseButtonEventArgs e)
{
if (this.MouseUp != null)
{
this.MouseUp.Invoke((object)this, e);
}
if (_isMouseEntered && _isMouseLeftButtonDown && this.MouseClick != null)
{
this.MouseClick.Invoke((object)this, e);
}
_isMouseLeftButtonDown = false;
}
private void _buttonOnMouseDown(object sender, MouseButtonEventArgs e)
{
_isMouseLeftButtonDown = true;
if (this.MouseDown != null)
{
this.MouseDown.Invoke((object)this, e);
}
}
}
}using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Shapes;
namespace com.bigspaceship.display
{
public class StandardSlider : Standard
{
private Rect _bounds;
private bool _isVertical;
private bool _isDragging;
private double _offset;
protected StandardButton _dragger;
public string time
{
set
{
FrameworkElement obj = _dragger._("tf");
((TextBlock)((obj is TextBlock) ? obj : null)).set_Text(value);
}
}
public virtual double position
{
get
{
DependencyProperty val;
double num;
if (_isVertical)
{
val = Canvas.TopProperty;
num = ((Rect)(ref _bounds)).get_Bottom();
}
else
{
val = Canvas.LeftProperty;
num = ((Rect)(ref _bounds)).get_Right();
}
return (double)((DependencyObject)_dragger.uc).GetValue(val) / num;
}
set
{
DependencyProperty val;
double num;
if (_isVertical)
{
val = Canvas.TopProperty;
num = ((Rect)(ref _bounds)).get_Bottom();
}
else
{
val = Canvas.LeftProperty;
num = ((Rect)(ref _bounds)).get_Right();
}
try
{
((DependencyObject)_dragger.uc).SetValue(val, (object)(value * num));
}
catch
{
}
}
}
public event EventHandler DragStop;
public event EventHandler DragStart;
public event EventHandler DragUpdate;
public StandardSlider(UserControl uc)
: this(uc, isVertical: false)
{
}
public StandardSlider(UserControl uc, bool isVertical)
: base(uc)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
_isVertical = isVertical;
ref StandardButton dragger = ref _dragger;
FrameworkElement obj = _("dragger_uc");
dragger = new StandardButton((UserControl)(object)((obj is UserControl) ? obj : null));
_dragger.MouseDown += new MouseButtonEventHandler(_dragStart);
FrameworkElement obj2 = _("trough");
Rectangle val = (Rectangle)(object)((obj2 is Rectangle) ? obj2 : null);
double num;
double num2;
double num4;
double num3;
if (_isVertical)
{
DependencyProperty topProperty = Canvas.TopProperty;
num = (double)((DependencyObject)val).GetValue(topProperty);
num2 = num + ((FrameworkElement)val).get_Height() - ((FrameworkElement)_dragger.uc).get_Height();
num4 = (num3 = 0.0);
}
else
{
DependencyProperty topProperty = Canvas.LeftProperty;
num4 = (double)((DependencyObject)val).GetValue(topProperty);
num3 = num4 + ((FrameworkElement)val).get_Width() - ((FrameworkElement)_dragger.uc).get_Width();
num = (num2 = 0.0);
}
_bounds = new Rect(num4, num, num3, num2);
}
public override void destroy()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Expected O, but got Unknown
if (_isDragging)
{
Application.get_Current().get_RootVisual().remove_MouseMove(new MouseEventHandler(_dragOnUpdate));
Application.get_Current().get_RootVisual().remove_LostFocus(new RoutedEventHandler(_dragOnStop));
Application.get_Current().get_RootVisual().remove_LostMouseCapture(new MouseEventHandler(_dragOnStop));
Application.get_Current().get_RootVisual().remove_MouseLeave(new MouseEventHandler(_dragOnStop));
Application.get_Current().get_RootVisual().remove_MouseLeftButtonUp(new MouseButtonEventHandler(_dragOnStop));
}
_dragger.MouseDown -= new MouseButtonEventHandler(_dragStart);
_dragger.destroy();
_dragger = null;
base.destroy();
}
private void _dragStart(object sender, MouseButtonEventArgs e)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Expected O, but got Unknown
if (!_isDragging)
{
_isDragging = true;
Point val = ((MouseEventArgs)e).GetPosition((UIElement)(object)_dragger.uc);
_offset = (_isVertical ? ((Point)(ref val)).get_Y() : ((Point)(ref val)).get_X());
if (this.DragStart != null)
{
this.DragStart(this, null);
}
Application.get_Current().get_RootVisual().add_MouseMove(new MouseEventHandler(_dragOnUpdate));
Application.get_Current().get_RootVisual().add_LostFocus(new RoutedEventHandler(_dragOnStop));
Application.get_Current().get_RootVisual().add_LostMouseCapture(new MouseEventHandler(_dragOnStop));
Application.get_Current().get_RootVisual().add_MouseLeave(new MouseEventHandler(_dragOnStop));
Application.get_Current().get_RootVisual().add_MouseLeftButtonUp(new MouseButtonEventHandler(_dragOnStop));
}
}
private void _dragOnUpdate(object sender, MouseEventArgs e)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
Point val = e.GetPosition((UIElement)(object)_uc);
double num;
double num2;
double num3;
DependencyProperty val2;
if (_isVertical)
{
num = ((Point)(ref val)).get_Y() - _offset;
num2 = ((Rect)(ref _bounds)).get_Bottom();
num3 = ((Rect)(ref _bounds)).get_Top();
val2 = Canvas.TopProperty;
}
else
{
num = ((Point)(ref val)).get_X() - _offset;
num3 = ((Rect)(ref _bounds)).get_Left();
num2 = ((Rect)(ref _bounds)).get_Right();
val2 = Canvas.LeftProperty;
}
if (num <= num3)
{
num = num3;
}
if (num >= num2)
{
num = num2;
}
((DependencyObject)_dragger.uc).SetValue(val2, (object)num);
if (this.DragUpdate != null)
{
this.DragUpdate(this, null);
}
}
public void stopDrag()
{
_dragOnStop();
}
private void _dragOnStop(object sender, MouseEventArgs e)
{
_dragOnStop();
}
private void _dragOnStop(object sender, RoutedEventArgs e)
{
_dragOnStop();
}
private void _dragOnStop(object sender, MouseButtonEventArgs e)
{
_dragOnStop();
}
private void _dragOnStop()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Expected O, but got Unknown
if (_isDragging)
{
_isDragging = false;
if (this.DragStop != null)
{
this.DragStop(this, null);
}
Application.get_Current().get_RootVisual().remove_MouseMove(new MouseEventHandler(_dragOnUpdate));
Application.get_Current().get_RootVisual().remove_LostFocus(new RoutedEventHandler(_dragOnStop));
Application.get_Current().get_RootVisual().remove_LostMouseCapture(new MouseEventHandler(_dragOnStop));
Application.get_Current().get_RootVisual().remove_MouseLeave(new MouseEventHandler(_dragOnStop));
Application.get_Current().get_RootVisual().remove_MouseLeftButtonUp(new MouseButtonEventHandler(_dragOnStop));
}
}
}
}using System;
namespace com.bigspaceship.events
{
public class BigLoadEvent : EventArgs
{
public double pctLoaded;
public BigLoadEvent(double p)
{
pctLoaded = p;
}
}
}namespace com.bigspaceship.events
{
public delegate void BigLoadItemEventHandler(object source, BigLoadEvent e);
}using System;
using System.Collections.Generic;
using System.Windows.Browser;
namespace com.bigspaceship.utils
{
[ScriptableType]
public class BrowserUtils
{
private string _deeplink;
private List<string> _directories;
private static BrowserUtils __instance;
public static BrowserUtils instance
{
get
{
if (__instance == null)
{
__instance = new BrowserUtils();
}
return __instance;
}
}
public string path => _deeplink;
public List<string> pathSplit => _directories;
public event EventHandler URLChanged;
public BrowserUtils()
{
if (__instance != null)
{
Out.warning(this, "Only one instance of BrowserUtils should exist at a time.");
}
__instance = this;
HtmlPage.RegisterScriptableObject("BrowserUtils", (object)this);
}
public void navigateTo(string newurl)
{
((ScriptObject)HtmlPage.get_Window()).Invoke("silverlightChangedURL", new object[1] { newurl });
}
[ScriptableMember]
public void javascriptChangedURL(string str)
{
_deeplink = str;
string[] array = _deeplink.Split(new char[1] { '/' });
_directories = new List<string>();
for (int i = 0; i < array.Length; i++)
{
_directories.Add(array[i]);
}
if (this.URLChanged != null)
{
this.URLChanged(this, null);
}
}
}
}using System.Collections;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
namespace com.bigspaceship.utils
{
public class DisplayUtils
{
public static Storyboard getIn(UserControl uc)
{
return getStoryboardFromVisualStateGroupById(uc, "transitions", "_in");
}
public static Storyboard getOut(UserControl uc)
{
return getStoryboardFromVisualStateGroupById(uc, "transitions", "_out");
}
public static Storyboard getStoryboardFromVisualStateGroupById(UserControl uc, string group_id, string storyboard_id)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
VisualStateGroup visualStateGroupById = getVisualStateGroupById(uc, group_id);
if (visualStateGroupById != null && visualStateGroupById.get_States() != null)
{
foreach (VisualState state in visualStateGroupById.get_States())
{
VisualState val = state;
if (val.get_Name() == storyboard_id)
{
return val.get_Storyboard();
}
}
}
else
{
Out.warning(new object(), "No storyboard with name " + storyboard_id + " found in group " + group_id);
}
return null;
}
public static VisualStateGroup getVisualStateGroupById(UserControl uc, string id)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
object obj = ((FrameworkElement)uc).FindName("LayoutRoot");
IList visualStateGroups = VisualStateManager.GetVisualStateGroups((FrameworkElement)((obj is FrameworkElement) ? obj : null));
foreach (VisualStateGroup item in visualStateGroups)
{
VisualStateGroup val = item;
if (val != null && val.get_Name() == id)
{
return val;
}
}
Out.warning(new object(), "No group named " + id + " found in " + ((object)uc).ToString());
return null;
}
}
}using System.Collections.Generic;
using System.Windows;
namespace com.bigspaceship.utils
{
public class Environment
{
private static Dictionary<string, string> __params;
public static string DOMAIN => Application.get_Current().get_Host().get_Source()
.Host;
public static bool IS_AREA51 => DOMAIN == "area51.bigspaceship.com";
public static bool IS_LOCALHOST => DOMAIN == "localhost";
public static bool IS_BIGSPACESHIP => DOMAIN == "bigspaceship.com" || DOMAIN == "www.bigspaceship.com";
public static string getParameter(string id)
{
if (Application.get_Current().get_Host().get_InitParams()
.ContainsKey(id))
{
return Application.get_Current().get_Host().get_InitParams()[id];
}
if (__params == null)
{
__params = new Dictionary<string, string>();
string query = Application.get_Current().get_Host().get_Source()
.Query;
if (query.Length == 0)
{
return null;
}
query = query.Substring(1);
string[] array = query.Split(new char[1] { '&' });
for (int i = 0; i < array.Length; i++)
{
string[] array2 = array[i].Split(new char[1] { '=' });
__params[array2[0]] = array2[1];
}
}
if (__params.ContainsKey(id))
{
return __params[id];
}
return null;
}
}
}#define DEBUG
using System.Collections.Generic;
using System.Diagnostics;
namespace com.bigspaceship.utils
{
public class Out
{
private const int INFO = 0;
private const int DEBUG = 1;
private const int FATAL = 2;
private const int ERROR = 3;
private const int STATUS = 4;
private const int WARNING = 5;
private static bool __isInit = false;
private static List<bool> __levels = new List<bool>();
public static void enableLevel(int level)
{
__levels[level] = true;
}
public static void disableLevel(int level)
{
__levels[level] = false;
}
public static void enableAllLevels()
{
if (!__isInit)
{
__isInit = true;
__levels.Add(item: false);
__levels.Add(item: false);
__levels.Add(item: false);
__levels.Add(item: false);
__levels.Add(item: false);
__levels.Add(item: false);
}
enableLevel(0);
enableLevel(4);
enableLevel(1);
enableLevel(5);
enableLevel(3);
enableLevel(2);
}
public static void disableAllLevels()
{
if (!__isInit)
{
__isInit = true;
__levels.Add(item: false);
__levels.Add(item: false);
__levels.Add(item: false);
__levels.Add(item: false);
__levels.Add(item: false);
__levels.Add(item: false);
}
disableLevel(0);
disableLevel(4);
disableLevel(1);
disableLevel(5);
disableLevel(3);
disableLevel(2);
}
public static void info(object origin, string str)
{
if (__levels[0])
{
__output(0, origin, str);
}
}
public static void debug(object origin, string str)
{
if (__levels[1])
{
__output(1, origin, str);
}
}
public static void status(object origin, string str)
{
if (__levels[4])
{
__output(4, origin, str);
}
}
public static void warning(object origin, string str)
{
if (__levels[5])
{
__output(5, origin, str);
}
}
public static void fatal(object origin, string str)
{
if (__levels[2])
{
__output(2, origin, str);
}
}
public static void error(object origin, string str)
{
if (__levels[3])
{
__output(3, origin, str);
}
}
private static void __output(int level, object origin, string str)
{
string text = "";
switch (level)
{
case 0:
text = "INFO";
break;
case 1:
text = "DEBUG";
break;
case 3:
text = "ERROR";
break;
case 4:
text = "STATUS";
break;
case 5:
text = "WARNING";
break;
case 2:
text = "FATAL";
break;
}
Debug.WriteLine(text + " :::\t" + origin.ToString() + " :: " + str);
}
}
}using System;
using System.Collections.Generic;
using System.Windows.Browser;
namespace com.bigspaceship.utils
{
public class SocialNetworkingUtils
{
public const string FACEBOOK = "facebook";
public const string TWITTER = "twitter";
public const string MYSPACE = "myspace";
public const string DIGG = "digg";
public const string DELICIOUS = "delicious";
public const string STUMBLEUPON = "stumbleupon";
public const string EMAIL = "email";
private static Dictionary<string, string> __urls;
private static void __initUrls()
{
__urls = new Dictionary<string, string>();
__urls["facebook"] = "http://www.facebook.com/sharer.php?src=bm&v=4&i=1253714522&u=[URL]&t=[TITLE]";
__urls["twitter"] = "http://twitter.com/home?status=[NOTE][URL]";
__urls["myspace"] = "http://www.myspace.com/index.cfm?fuseaction=postto&u=[URL]&c=[NOTE]&l=1";
__urls["digg"] = "http://digg.com/submit?url=[URL]&title=[TITLE]&bodytext=[NOTE]";
__urls["delicious"] = "http://delicious.com/save?url=[URL]&title=[TITLE]¬es=[NOTE]";
__urls["stumbleupon"] = "http://www.stumbleupon.com/submit?url=[URL]&title=[TITLE]";
__urls["email"] = "mailto:[EMAIL]?subject=[SUBJECT]&body=[MESSAGE]%0D%0A%0D%0A[URL]";
}
public static void email(string email, string subject, string url, string body)
{
if (__urls == null)
{
__initUrls();
}
string text = __urls["email"];
text = text.Replace("[EMAIL]", email);
text = text.Replace("[SUBJECT]", subject);
text = text.Replace("[MESSAGE]", body);
text = text.Replace("[URL]", url);
HtmlPage.get_Window().Navigate(new Uri(text), "_blank");
}
public static void share(string type, string url, string title, string note)
{
if (__urls == null)
{
__initUrls();
}
string text = __urls[type];
text = ((!(type != "twitter")) ? text.Replace("[URL]", HttpUtility.UrlEncode(url)) : text.Replace("[URL]", HttpUtility.UrlEncode(url)));
text = ((!(type != "twitter")) ? text.Replace("[NOTE]", HttpUtility.UrlEncode(note)) : text.Replace("[NOTE]", HttpUtility.UrlEncode(note)));
text = text.Replace("[TITLE]", HttpUtility.UrlEncode(title));
HtmlPage.get_Window().Navigate(new Uri(text), "_blank");
}
}
}using System;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using com.bigspaceship.utils;
using Microsoft.Web.Media.SmoothStreaming;
namespace com.bigspaceship.display.videoplayer
{
public class Video
{
private string _url;
private int _loadAttempts;
private bool _isSmoothPlaying;
private Rect _initialPosition;
private MediaElement _progressive;
private SmoothStreamingMediaElement _smooth;
public Rect initialPosition => _initialPosition;
public double BufferingProgress => _isSmoothPlaying ? _smooth.BufferingProgress : _progressive.get_BufferingProgress();
public double Volume
{
get
{
return _progressive.get_Volume();
}
set
{
MediaElement progressive = _progressive;
double volume = (_smooth.Volume = value);
progressive.set_Volume(volume);
}
}
public MediaElementState CurrentState => _isSmoothPlaying ? _smooth.CurrentState : _progressive.get_CurrentState();
public TimeSpan Position
{
get
{
if (_isSmoothPlaying)
{
return _smooth.Position;
}
return _progressive.get_Position();
}
set
{
if (_isSmoothPlaying)
{
if (!_smooth.IsLive || !_smooth.IsLivePosition)
{
_smooth.Position = value;
}
else if (_smooth.IsLive && value.TotalMilliseconds >= _smooth.LivePosition)
{
_smooth.StartSeekToLive();
}
}
else
{
_progressive.set_Position(value);
}
}
}
public Duration NaturalDuration
{
get
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if (_isSmoothPlaying)
{
return _smooth.NaturalDuration;
}
return _progressive.get_NaturalDuration();
}
}
public bool isLiveStream
{
get
{
if (_isSmoothPlaying)
{
return _smooth.IsLive;
}
return false;
}
}
public event RoutedEventHandler MediaOpened
{
[MethodImpl(MethodImplOptions.Synchronized)]
add
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MediaOpened = (RoutedEventHandler)Delegate.Combine((Delegate)(object)this.MediaOpened, (Delegate)(object)value);
}
[MethodImpl(MethodImplOptions.Synchronized)]
remove
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MediaOpened = (RoutedEventHandler)Delegate.Remove((Delegate)(object)this.MediaOpened, (Delegate)(object)value);
}
}
public event EventHandler<ExceptionRoutedEventArgs> MediaFailed;
public event RoutedEventHandler MediaEnded
{
[MethodImpl(MethodImplOptions.Synchronized)]
add
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MediaEnded = (RoutedEventHandler)Delegate.Combine((Delegate)(object)this.MediaEnded, (Delegate)(object)value);
}
[MethodImpl(MethodImplOptions.Synchronized)]
remove
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.MediaEnded = (RoutedEventHandler)Delegate.Remove((Delegate)(object)this.MediaEnded, (Delegate)(object)value);
}
}
public event RoutedEventHandler BufferingProgressChanged
{
[MethodImpl(MethodImplOptions.Synchronized)]
add
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.BufferingProgressChanged = (RoutedEventHandler)Delegate.Combine((Delegate)(object)this.BufferingProgressChanged, (Delegate)(object)value);
}
[MethodImpl(MethodImplOptions.Synchronized)]
remove
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.BufferingProgressChanged = (RoutedEventHandler)Delegate.Remove((Delegate)(object)this.BufferingProgressChanged, (Delegate)(object)value);
}
}
public Video(MediaElement progressive, SmoothStreamingMediaElement smooth)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Expected O, but got Unknown
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
_smooth = smooth;
_smooth.AutoPlay = true;
_smooth.SmoothStreamingErrorOccurred += _smoothStreamingOnError;
_smooth.MediaEnded += new RoutedEventHandler(_playerOnMediaEnded);
_smooth.MediaOpened += new RoutedEventHandler(_playerOnMediaOpened);
_smooth.MediaFailed += _playerOnMediaFailed;
_smooth.BufferingProgressChanged += new RoutedEventHandler(_playerOnBufferingProgressChanged);
_progressive = progressive;
_progressive.add_MediaEnded(new RoutedEventHandler(_playerOnMediaEnded));
_progressive.add_MediaOpened(new RoutedEventHandler(_playerOnMediaOpened));
_progressive.add_MediaFailed((EventHandler<ExceptionRoutedEventArgs>)_playerOnMediaFailed);
_progressive.add_BufferingProgressChanged(new RoutedEventHandler(_playerOnBufferingProgressChanged));
_smooth.Stretch = (Stretch)2;
_progressive.set_Stretch((Stretch)2);
SmoothStreamingMediaElement smooth2 = _smooth;
double volume;
_progressive.set_Volume(volume = 1.0);
smooth2.Volume = volume;
_initialPosition = new Rect((double)((DependencyObject)_progressive).GetValue(Canvas.LeftProperty), (double)((DependencyObject)_progressive).GetValue(Canvas.TopProperty), ((FrameworkElement)_progressive).get_Width(), ((FrameworkElement)_progressive).get_Height());
}
private void _smoothStreamingOnError(object sender, SmoothStreamingErrorEventArgs e)
{
Out.fatal(this, e.ErrorMessage);
}
private void _playerOnMediaEnded(object sender, RoutedEventArgs e)
{
if (this.MediaEnded != null)
{
this.MediaEnded.Invoke((object)this, e);
}
}
private void _playerOnMediaFailed(object sender, ExceptionRoutedEventArgs e)
{
if (_loadAttempts > 2)
{
if (this.MediaFailed != null)
{
this.MediaFailed(this, e);
}
}
else
{
_loadAttempts++;
load(_url, _isSmoothPlaying);
}
}
private void _playerOnMediaOpened(object sender, RoutedEventArgs e)
{
if (this.MediaOpened != null)
{
this.MediaOpened.Invoke((object)this, e);
}
}
private void _playerOnBufferingProgressChanged(object sender, RoutedEventArgs e)
{
if (this.BufferingProgressChanged != null)
{
this.BufferingProgressChanged.Invoke((object)this, e);
}
}
public void load(string url, bool isSmooth)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
_url = url;
_loadAttempts = 0;
unload();
_isSmoothPlaying = isSmooth;
SmoothStreamingMediaElement smooth = _smooth;
MediaElement progressive = _progressive;
Visibility visibility = (Visibility)1;
((UIElement)progressive).set_Visibility((Visibility)1);
((UIElement)smooth).set_Visibility(visibility);
if (_isSmoothPlaying)
{
_smooth.SmoothStreamingSource = new Uri(url, UriKind.Absolute);
((UIElement)_smooth).set_Visibility((Visibility)0);
}
else
{
_progressive.set_Source(new Uri(url, UriKind.RelativeOrAbsolute));
((UIElement)_progressive).set_Visibility((Visibility)0);
}
}
public void reload()
{
if (_isSmoothPlaying)
{
load(_url, isSmooth: true);
}
}
public void regularSize()
{
((FrameworkElement)_smooth).set_Width(((Rect)(ref _initialPosition)).get_Width());
((FrameworkElement)_smooth).set_Height(((Rect)(ref _initialPosition)).get_Height());
((FrameworkElement)_progressive).set_Width(((Rect)(ref _initialPosition)).get_Width());
((FrameworkElement)_progressive).set_Height(((Rect)(ref _initialPosition)).get_Height());
}
public void fullScreen()
{
double actualWidth = Application.get_Current().get_Host().get_Content()
.get_ActualWidth();
double actualHeight = Application.get_Current().get_Host().get_Content()
.get_ActualHeight();
((FrameworkElement)_smooth).set_Width(actualWidth);
((FrameworkElement)_smooth).set_Height(actualHeight);
((FrameworkElement)_progressive).set_Width(actualWidth);
((FrameworkElement)_progressive).set_Height(actualHeight);
}
public void destroy()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Expected O, but got Unknown
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Expected O, but got Unknown
unload();
_smooth.SmoothStreamingErrorOccurred -= _smoothStreamingOnError;
_smooth.MediaEnded -= new RoutedEventHandler(_playerOnMediaEnded);
_smooth.MediaOpened -= new RoutedEventHandler(_playerOnMediaOpened);
_smooth.MediaFailed -= _playerOnMediaFailed;
_smooth.BufferingProgressChanged -= new RoutedEventHandler(_playerOnBufferingProgressChanged);
_progressive.remove_MediaEnded(new RoutedEventHandler(_playerOnMediaEnded));
_progressive.remove_MediaOpened(new RoutedEventHandler(_playerOnMediaOpened));
_progressive.remove_MediaFailed((EventHandler<ExceptionRoutedEventArgs>)_playerOnMediaFailed);
_progressive.remove_BufferingProgressChanged(new RoutedEventHandler(_playerOnBufferingProgressChanged));
_url = null;
_smooth = null;
_progressive = null;
}
public void unload()
{
_smooth.Source = null;
_progressive.set_Source((Uri)null);
}
public void Play()
{
if (_isSmoothPlaying)
{
_smooth.Play();
}
else
{
_progressive.Play();
}
}
public void Stop()
{
if (_isSmoothPlaying)
{
_smooth.Stop();
}
else
{
_progressive.Stop();
}
}
public void Pause()
{
if (_isSmoothPlaying)
{
_smooth.Pause();
}
else
{
_progressive.Pause();
}
}
public void seekToLive()
{
if (_isSmoothPlaying && _smooth.IsLive)
{
_smooth.StartSeekToLive();
}
}
}
}using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using com.bigspaceship.display.videoplayer.controls;
using com.bigspaceship.display.videoplayer.overlays;
using com.bigspaceship.utils;
using Microsoft.Web.Media.SmoothStreaming;
namespace com.bigspaceship.display.videoplayer
{
public class VideoPlayer : Standard
{
private Video _video;
private VolumeSlider _volume;
private PlayToggle _playpause;
private PlayheadMaskSlider _playhead;
private StandardInOut _controlbar;
private VideoOverlayManager _overlayManager;
private Standard _loading;
private StandardButton _liveButton;
private StandardButton _shareButton;
private StandardButton _fullscreenButton;
private string _title;
private bool _videoIsOpened;
private bool _videoIsPlaying;
private bool _videoIsComplete;
private bool _playheadIsDragging;
private int _controlbarIdleCount;
private Rect _loadingRect;
private Rect _controlbarRect;
private Point _offset;
private TimeSpan _lastPosition;
private bool _isEmbeddable;
public event EventHandler FullScreenClick;
public VideoPlayer(UserControl uc)
: this(uc, isEmbeddable: false)
{
}
public VideoPlayer(UserControl uc, bool isEmbeddable)
: base(uc)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Expected O, but got Unknown
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Expected O, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Expected O, but got Unknown
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_032e: Expected O, but got Unknown
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
//IL_0366: Expected O, but got Unknown
//IL_0394: Unknown result type (might be due to invalid IL or missing references)
//IL_039e: Expected O, but got Unknown
Out.info(this, "VideoPlayer");
_offset = new Point((double)((DependencyObject)_uc).GetValue(Canvas.LeftProperty), (double)((DependencyObject)_uc).GetValue(Canvas.TopProperty));
_isEmbeddable = isEmbeddable;
ref Video video = ref _video;
FrameworkElement obj = _("progressive_video");
video = new Video((MediaElement)(object)((obj is MediaElement) ? obj : null), _("smooth_video") as SmoothStreamingMediaElement);
_video.MediaOpened += new RoutedEventHandler(_videoOnLoadStart);
_video.MediaFailed += _videoOnLoadFail;
_video.MediaEnded += new RoutedEventHandler(_videoOnEnded);
_video.BufferingProgressChanged += new RoutedEventHandler(_videoOnBufferringStateChanged);
ref StandardInOut controlbar = ref _controlbar;
FrameworkElement obj2 = _("controlbar_uc");
controlbar = new StandardInOut((UserControl)(object)((obj2 is UserControl) ? obj2 : null), isCollapsedOnAnimateOut: true);
_controlbar.AnimationInStarted += _controlbarOnAnimateInStart;
_controlbar.AnimationOutStarted += _controlbarOnAnimateOutStart;
FrameworkElement obj3 = _controlbar._("tf");
((TextBlock)((obj3 is TextBlock) ? obj3 : null)).set_Text("");
_controlbarRect = new Rect((double)((DependencyObject)_controlbar.uc).GetValue(Canvas.LeftProperty), (double)((DependencyObject)_controlbar.uc).GetValue(Canvas.TopProperty), ((FrameworkElement)_controlbar.uc).get_Width(), ((FrameworkElement)_controlbar.uc).get_Height());
ref Standard loading = ref _loading;
FrameworkElement obj4 = _("loading_uc");
loading = new Standard((UserControl)(object)((obj4 is UserControl) ? obj4 : null));
_loading.gotoAndPlay("loading");
_loadingRect = new Rect((double)((DependencyObject)_loading.uc).GetValue(Canvas.LeftProperty), (double)((DependencyObject)_loading.uc).GetValue(Canvas.TopProperty), ((FrameworkElement)_loading.uc).get_Width(), ((FrameworkElement)_loading.uc).get_Height());
ref VolumeSlider volume = ref _volume;
FrameworkElement obj5 = _controlbar._("volume_uc");
volume = new VolumeSlider((UserControl)(object)((obj5 is UserControl) ? obj5 : null));
_volume.slider.DragUpdate += _volumeOnDragUpdate;
ref PlayToggle playpause = ref _playpause;
FrameworkElement obj6 = _controlbar._("playpause_uc");
playpause = new PlayToggle((UserControl)(object)((obj6 is UserControl) ? obj6 : null));
_playpause.MouseClick += new MouseButtonEventHandler(_playPauseOnClick);
ref PlayheadMaskSlider playhead = ref _playhead;
FrameworkElement obj7 = _controlbar._("scrubber_uc");
playhead = new PlayheadMaskSlider((UserControl)(object)((obj7 is UserControl) ? obj7 : null));
_playhead.DragStart += _playheadOnDragStart;
_playhead.DragStop += _playheadOnDragStop;
ref StandardButton fullscreenButton = ref _fullscreenButton;
FrameworkElement obj8 = _controlbar._("fullscreen_uc");
fullscreenButton = new StandardButton((UserControl)(object)((obj8 is UserControl) ? obj8 : null));
_fullscreenButton.MouseClick += new MouseButtonEventHandler(_fullscreenOnClick);
ref StandardButton shareButton = ref _shareButton;
FrameworkElement obj9 = _controlbar._("share_uc");
shareButton = new StandardButton((UserControl)(object)((obj9 is UserControl) ? obj9 : null));
_shareButton.MouseClick += new MouseButtonEventHandler(_shareOnClick);
ref StandardButton liveButton = ref _liveButton;
FrameworkElement obj10 = _controlbar._("live_uc");
liveButton = new StandardButton((UserControl)(object)((obj10 is UserControl) ? obj10 : null));
_liveButton.MouseClick += new MouseButtonEventHandler(_liveOnClick);
_overlayManager = new VideoOverlayManager();
_overlayManager.Open += _overlayManagerOnOpen;
VideoOverlayManager overlayManager = _overlayManager;
FrameworkElement obj11 = _("share_uc");
overlayManager.add("share", new ShareOverlay((UserControl)(object)((obj11 is UserControl) ? obj11 : null)));
FrameworkElement obj12 = _("replay_uc");
ReplayOverlay replayOverlay = new ReplayOverlay((UserControl)(object)((obj12 is UserControl) ? obj12 : null));
replayOverlay.Click += _replayOnClick;
_overlayManager.add("replay", replayOverlay);
Application.get_Current().get_Host().get_Content()
.add_FullScreenChanged((EventHandler)_fullscreenOnChanged);
}
public override void destroy()
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Expected O, but got Unknown
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Expected O, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Expected O, but got Unknown
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Expected O, but got Unknown
_videoIsOpened = false;
_videoIsComplete = false;
unload();
_loading.destroy();
_loading = null;
_controlbar.AnimationInStarted -= _controlbarOnAnimateInStart;
_controlbar.AnimationOutStarted -= _controlbarOnAnimateOutStart;
_controlbar.destroy();
_controlbar = null;
_video.MediaOpened -= new RoutedEventHandler(_videoOnLoadStart);
_video.MediaFailed -= _videoOnLoadFail;
_video.BufferingProgressChanged -= new RoutedEventHandler(_videoOnBufferringStateChanged);
_video.destroy();
_video = null;
_volume.slider.DragUpdate -= _volumeOnDragUpdate;
_volume.destroy();
_volume = null;
_playpause.MouseClick -= new MouseButtonEventHandler(_playPauseOnClick);
_playpause.destroy();
_playpause = null;
_playhead.DragStart -= _playheadOnDragStart;
_playhead.DragStop -= _playheadOnDragStop;
_playhead.destroy();
_playhead = null;
_fullscreenButton.MouseClick -= new MouseButtonEventHandler(_fullscreenOnClick);
_fullscreenButton.destroy();
_fullscreenButton = null;
_liveButton.MouseClick -= new MouseButtonEventHandler(_liveOnClick);
_liveButton.destroy();
_liveButton = null;
_shareButton.MouseClick -= new MouseButtonEventHandler(_shareOnClick);
_shareButton.destroy();
_shareButton = null;
(_overlayManager.getOverlayById("replay") as ReplayOverlay).Click -= _replayOnClick;
_overlayManager.Open -= _overlayManagerOnOpen;
_overlayManager.destroy();
_overlayManager = null;
Application.get_Current().get_Host().get_Content()
.remove_FullScreenChanged((EventHandler)_fullscreenOnChanged);
base.destroy();
}
public void load(string url, string title)
{
load(url, title, isSmooth: false, new VideoPlayerStrings());
}
public void load(string url, string title, bool isSmooth)
{
load(url, title, isSmooth, new VideoPlayerStrings());
}
public void load(string url, string title, bool isSmooth, VideoPlayerStrings strings)
{
unload();
_title = title;
_video.load(url, isSmooth);
_loading.gotoAndPlay("loading");
(_overlayManager.getOverlayById("share") as ShareOverlay).strings = strings;
}
public void unload()
{
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
_video.unload();
_playpause.setPaused();
_overlayManager.close();
_lastPosition = TimeSpan.Zero;
if (_videoIsOpened)
{
FrameworkElement obj = _controlbar._("tf");
((TextBlock)((obj is TextBlock) ? obj : null)).set_Text("");
_playhead.position = 0.0;
_volume.slider.position = 0.0;
_controlbarIdleCount = 0;
_volume.animateOut();
_controlbar.animateOut();
((UIElement)_uc).remove_MouseMove(new MouseEventHandler(_stageOnMouseMove));
CompositionTarget.remove_Rendering((EventHandler)_onEnterFrame);
}
_videoIsOpened = false;
_videoIsPlaying = false;
_videoIsComplete = false;
}
private void _fullscreenOnChanged(object sender, EventArgs e)
{
((UIElement)_shareButton.uc).set_Visibility((Visibility)(Application.get_Current().get_Host().get_Content()
.get_IsFullScreen() ? 1 : 0));
double num3;
double num4;
double num5;
double num6;
if (Application.get_Current().get_Host().get_Content()
.get_IsFullScreen())
{
double num = 0.0;
double num2 = 0.0;
if (!_isEmbeddable)
{
FrameworkElement val = (FrameworkElement)(object)_uc;
while (val != null)
{
num += (double)((DependencyObject)val).GetValue(Canvas.LeftProperty);
num2 += (double)((DependencyObject)val).GetValue(Canvas.TopProperty);
DependencyObject parent = val.get_Parent();
val = (FrameworkElement)(object)((parent is FrameworkElement) ? parent : null);
}
((DependencyObject)_uc).SetValue(Canvas.LeftProperty, (object)(0.0 - num - Application.get_Current().get_Host().get_Content()
.get_ActualWidth() * 0.5 + 470.0));
((DependencyObject)_uc).SetValue(Canvas.TopProperty, (object)(0.0 - num2 - Application.get_Current().get_Host().get_Content()
.get_ActualHeight() * 0.5 + 342.5));
}
_video.fullScreen();
num3 = Application.get_Current().get_Host().get_Content()
.get_ActualWidth() * 0.5 - ((Rect)(ref _controlbarRect)).get_Width() * 0.5;
num4 = Application.get_Current().get_Host().get_Content()
.get_ActualHeight() - ((Rect)(ref _controlbarRect)).get_Height() - 10.0;
num5 = Application.get_Current().get_Host().get_Content()
.get_ActualWidth();
num6 = Application.get_Current().get_Host().get_Content()
.get_ActualHeight();
_stageOnMouseMove(null, null);
}
else
{
_video.regularSize();
((DependencyObject)_uc).SetValue(Canvas.LeftProperty, (object)((Point)(ref _offset)).get_X());
((DependencyObject)_uc).SetValue(Canvas.TopProperty, (object)((Point)(ref _offset)).get_Y());
num3 = ((Rect)(ref _controlbarRect)).get_Left();
num4 = ((Rect)(ref _controlbarRect)).get_Top();
num5 = ((Rect)(ref _loadingRect)).get_Width();
num6 = ((Rect)(ref _loadingRect)).get_Height();
((UIElement)_shareButton.uc).set_Visibility((Visibility)0);
}
((DependencyObject)_controlbar.uc).SetValue(Canvas.LeftProperty, (object)num3);
((DependencyObject)_controlbar.uc).SetValue(Canvas.TopProperty, (object)num4);
FrameworkElement val2 = _loading._("e1");
((DependencyObject)val2).SetValue(Canvas.TopProperty, (object)((num6 - val2.get_Height()) * 0.5));
((DependencyObject)val2).SetValue(Canvas.LeftProperty, (object)((num5 - val2.get_Width()) * 0.5));
FrameworkElement val3 = _loading._("e2");
((DependencyObject)val3).SetValue(Canvas.TopProperty, (object)((num6 - val3.get_Height()) * 0.5));
((DependencyObject)val3).SetValue(Canvas.LeftProperty, (object)((num5 - val3.get_Width()) * 0.5));
_loading._("placeholder").set_Width(num5);
_loading._("placeholder").set_Height(num6);
if (!_videoIsPlaying)
{
_video.Pause();
}
}
private void _replayOnClick(object sender, EventArgs e)
{
_videoIsPlaying = true;
_videoIsComplete = false;
_video.Position = TimeSpan.Zero;
_videoPlay();
}
private void _overlayManagerOnOpen(object sender, EventArgs e)
{
if (_overlayManager.state != "replay")
{
_volume.animateOut();
_controlbar.animateOut();
}
}
private void _videoOnLoadFail(object sender, ExceptionRoutedEventArgs e)
{
Out.fatal(this, e.get_ErrorException().Message);
}
private void _videoOnEnded(object sender, RoutedEventArgs e)
{
_videoIsPlaying = false;
_videoIsComplete = true;
_playpause.setPlaying();
_controlbar.animateIn();
_overlayManager.open("replay");
}
private void _videoOnLoadStart(object sender, RoutedEventArgs e)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
Out.status(this, "_videoOnLoadStart");
_loading.gotoAndPlay("loaded");
if (_lastPosition == TimeSpan.Zero)
{
_videoIsOpened = true;
_videoIsPlaying = true;
CompositionTarget.add_Rendering((EventHandler)_onEnterFrame);
((UIElement)_uc).add_MouseMove(new MouseEventHandler(_stageOnMouseMove));
if (!_video.isLiveStream)
{
Duration naturalDuration = _video.NaturalDuration;
string text;
if (((Duration)(ref naturalDuration)).get_TimeSpan().Minutes < 10)
{
naturalDuration = _video.NaturalDuration;
text = "0" + ((Duration)(ref naturalDuration)).get_TimeSpan().Minutes;
}
else
{
naturalDuration = _video.NaturalDuration;
text = ((Duration)(ref naturalDuration)).get_TimeSpan().Minutes.ToString();
}
string text2 = text;
naturalDuration = _video.NaturalDuration;
string text3;
if (((Duration)(ref naturalDuration)).get_TimeSpan().Seconds < 10)
{
naturalDuration = _video.NaturalDuration;
text3 = "0" + ((Duration)(ref naturalDuration)).get_TimeSpan().Seconds;
}
else
{
naturalDuration = _video.NaturalDuration;
text3 = ((Duration)(ref naturalDuration)).get_TimeSpan().Seconds.ToString();
}
string text4 = text3;
FrameworkElement obj = _controlbar._("tf");
((TextBlock)((obj is TextBlock) ? obj : null)).set_Text(text2 + ":" + text4);
((UIElement)_liveButton.uc).set_Visibility((Visibility)1);
}
else
{
((UIElement)_liveButton.uc).set_Visibility((Visibility)0);
_video.seekToLive();
}
string text5 = com.bigspaceship.utils.Environment.getParameter("title");
if (text5 == null)
{
text5 = _title;
}
FrameworkElement obj2 = _controlbar._("title");
((TextBlock)((obj2 is TextBlock) ? obj2 : null)).set_Text(text5);
_stageOnMouseMove(null, null);
}
else
{
_video.Position = _lastPosition;
_lastPosition = TimeSpan.Zero;
}
}
private void _videoOnBufferringStateChanged(object sender, RoutedEventArgs e)
{
if (_video.BufferingProgress == 1.0 && _videoIsPlaying)
{
_video.Play();
}
}
private void _stageOnMouseMove(object sender, MouseEventArgs e)
{
_controlbarIdleCount = 0;
if (_videoIsOpened && _overlayManager.state == null)
{
_controlbar.animateIn();
}
}
private void _controlbarOnAnimateInStart(object sender, EventArgs e)
{
((Control)_controlbar.uc).set_IsEnabled(true);
}
private void _controlbarOnAnimateOutStart(object sender, EventArgs e)
{
((Control)_controlbar.uc).set_IsEnabled(false);
}
private void _fullscreenOnClick(object sender, MouseButtonEventArgs e)
{
_lastPosition = _video.Position;
if (this.FullScreenClick != null)
{
this.FullScreenClick(this, null);
}
}
private void _shareOnClick(object sender, MouseButtonEventArgs e)
{
_overlayManager.open("share");
}
private void _liveOnClick(object sender, MouseButtonEventArgs e)
{
_video.seekToLive();
}
private void _volumeOnDragUpdate(object sender, EventArgs e)
{
_video.Volume = 1.0 - _volume.slider.position;
}
private void _playheadOnDragStop(object sender, EventArgs e)
{
_playheadIsDragging = false;
if (_videoIsPlaying)
{
_videoPlay();
}
}
private void _playheadOnDragStart(object sender, EventArgs e)
{
_playheadIsDragging = true;
_video.Pause();
}
public void play()
{
if (!_videoIsPlaying && _videoIsOpened)
{
_playPauseOnClick(null, null);
}
}
public void pause()
{
if (_videoIsPlaying && _videoIsOpened)
{
_playPauseOnClick(null, null);
}
}
private void _videoPlay()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
if ((int)_video.CurrentState != 2)
{
_video.Play();
}
_playpause.setPaused();
_overlayManager.close();
}
private void _playPauseOnClick(object sender, MouseButtonEventArgs e)
{
if (_videoIsComplete)
{
_replayOnClick(null, null);
return;
}
_videoIsPlaying = !_videoIsPlaying;
Out.debug(this, "Video is playing: " + _videoIsPlaying);
if (_videoIsPlaying)
{
_videoPlay();
return;
}
_video.Pause();
_playpause.setPlaying();
}
private void _onEnterFrame(object sender, EventArgs e)
{
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
if (!_videoIsOpened)
{
return;
}
if (_overlayManager.state != null && _overlayManager.state != "replay")
{
_volume.animateOut();
_controlbar.animateOut();
}
else if (Application.get_Current().get_Host().get_Content()
.get_IsFullScreen() || _overlayManager.state == "replay")
{
_controlbar.animateIn();
}
else
{
_controlbarIdleCount++;
if (_controlbarIdleCount > 120)
{
_volume.animateOut();
_controlbar.animateOut();
}
}
Duration naturalDuration;
if (_playheadIsDragging)
{
_videoIsComplete = false;
if (_overlayManager.state != null)
{
_overlayManager.close();
}
naturalDuration = _video.NaturalDuration;
double value = (double)((Duration)(ref naturalDuration)).get_TimeSpan().Ticks * _playhead.position;
_video.Position = new TimeSpan(Convert.ToInt64(value));
}
else
{
double totalSeconds = _video.Position.TotalSeconds;
naturalDuration = _video.NaturalDuration;
double value = totalSeconds / ((Duration)(ref naturalDuration)).get_TimeSpan().TotalSeconds;
_playhead.position = Math.Min(value, 1.0);
}
int num = _video.Position.Minutes + 60 * _video.Position.Hours;
string text = ((num >= 10) ? num.ToString() : ("0" + num));
string text2 = ((_video.Position.Seconds >= 10) ? _video.Position.Seconds.ToString() : ("0" + _video.Position.Seconds));
_playhead.time = text + ":" + text2;
}
}
}namespace com.bigspaceship.display.videoplayer
{
public class VideoPlayerStrings
{
public string url;
public string note;
public string title;
public string embedCode;
public string twitterNote;
public VideoPlayerStrings()
: this("", "", "", "", "")
{
}
public VideoPlayerStrings(string ec, string u, string t, string n, string tn)
{
url = u;
note = n;
title = t;
embedCode = ec;
twitterNote = tn;
}
}
}using System.Windows;
using System.Windows.Controls;
namespace com.bigspaceship.display.videoplayer.controls
{
public class PlayToggle : StandardButton
{
private Standard _icon;
public PlayToggle(UserControl uc)
: base(uc)
{
ref Standard icon = ref _icon;
FrameworkElement obj = _("icon_uc");
icon = new Standard((UserControl)(object)((obj is UserControl) ? obj : null));
}
public override void destroy()
{
_icon.destroy();
_icon = null;
base.destroy();
}
public void setPlaying()
{
_icon.gotoAndPlay("play");
}
public void setPaused()
{
_icon.gotoAndPlay("pause");
}
}
}using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace com.bigspaceship.display.videoplayer.controls
{
public class PlayheadMaskSlider : StandardSlider
{
public override double position
{
get
{
return base.position;
}
set
{
base.position = value;
_updateMask(null, null);
}
}
public PlayheadMaskSlider(UserControl uc)
: base(uc, isVertical: false)
{
base.DragUpdate += _updateMask;
}
public override void destroy()
{
base.DragUpdate -= _updateMask;
base.destroy();
}
private void _updateMask(object sender, EventArgs e)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
Geometry clip = ((UIElement)_("bar")).get_Clip();
RectangleGeometry val = (RectangleGeometry)(object)((clip is RectangleGeometry) ? clip : null);
Rect rect = val.get_Rect();
double x = ((Rect)(ref rect)).get_X();
rect = val.get_Rect();
double y = ((Rect)(ref rect)).get_Y();
double num = (double)((DependencyObject)_dragger.uc).GetValue(Canvas.LeftProperty) + ((FrameworkElement)_dragger.uc).get_Width() * 0.5;
rect = val.get_Rect();
val.set_Rect(new Rect(x, y, num, ((Rect)(ref rect)).get_Height()));
}
}
}using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace com.bigspaceship.display.videoplayer.controls
{
public class VolumeSlider : StandardButton
{
private bool _isIn;
private StandardSlider _slider;
public StandardSlider slider => _slider;
public VolumeSlider(UserControl uc)
: base(uc)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
ref StandardSlider reference = ref _slider;
FrameworkElement obj = _("scrubber_uc");
reference = new StandardSlider((UserControl)(object)((obj is UserControl) ? obj : null), isVertical: true);
MouseEnter += new MouseEventHandler(_animateIn);
((UIElement)_("rollover_hitarea")).add_MouseEnter(new MouseEventHandler(_animateOut));
}
public override void destroy()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
_slider.destroy();
_slider = null;
MouseEnter -= new MouseEventHandler(_animateIn);
((UIElement)_("rollover_hitarea")).remove_MouseEnter(new MouseEventHandler(_animateOut));
base.destroy();
}
private void _animateIn(object sender, MouseEventArgs e)
{
if (!_isIn)
{
_isIn = true;
select();
}
}
public void animateOut()
{
_animateOut(null, null);
}
private void _animateOut(object sender, MouseEventArgs e)
{
if (_isIn)
{
_isIn = false;
_slider.stopDrag();
deselect();
}
}
}
}using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace com.bigspaceship.display.videoplayer.overlays
{
public class ReplayOverlay : VideoOverlay
{
private Rect _dimensions;
private StandardButton _icon;
public event EventHandler Click;
public ReplayOverlay(UserControl uc)
: base(uc)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
_dimensions = new Rect((double)((DependencyObject)_uc).GetValue(Canvas.LeftProperty), (double)((DependencyObject)_uc).GetValue(Canvas.TopProperty), ((FrameworkElement)_uc).get_Width(), ((FrameworkElement)_uc).get_Height());
ref StandardButton icon = ref _icon;
FrameworkElement obj = _("replay_uc");
icon = new StandardButton((UserControl)(object)((obj is UserControl) ? obj : null));
_icon.MouseClick += new MouseButtonEventHandler(_iconOnMouseClick);
Application.get_Current().get_Host().get_Content()
.add_FullScreenChanged((EventHandler)_fullscreenOnChanged);
}
public override void destroy()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
_icon.MouseClick -= new MouseButtonEventHandler(_iconOnMouseClick);
_icon.destroy();
_icon = null;
base.destroy();
Application.get_Current().get_Host().get_Content()
.remove_FullScreenChanged((EventHandler)_fullscreenOnChanged);
}
private void _iconOnMouseClick(object sender, MouseButtonEventArgs e)
{
if (this.Click != null)
{
this.Click(this, null);
}
}
private void _fullscreenOnChanged(object sender, EventArgs e)
{
double num3;
double num4;
if (Application.get_Current().get_Host().get_Content()
.get_IsFullScreen())
{
double num = Application.get_Current().get_Host().get_Content()
.get_ActualWidth() * 0.5 - ((Rect)(ref _dimensions)).get_Width() * 0.5;
double num2 = Application.get_Current().get_Host().get_Content()
.get_ActualHeight() * 0.5 - ((Rect)(ref _dimensions)).get_Height() * 0.5;
num3 = Application.get_Current().get_Host().get_Content()
.get_ActualWidth();
num4 = Application.get_Current().get_Host().get_Content()
.get_ActualHeight();
}
else
{
double num = ((Rect)(ref _dimensions)).get_X();
double num2 = ((Rect)(ref _dimensions)).get_Y();
num3 = ((Rect)(ref _dimensions)).get_Width();
num4 = ((Rect)(ref _dimensions)).get_Height();
}
_("overlay").set_Width(num3);
_("overlay").set_Height(num4);
((DependencyObject)_icon.uc).SetValue(Canvas.TopProperty, (object)((num4 - ((FrameworkElement)_icon.uc).get_Height()) * 0.5));
((DependencyObject)_icon.uc).SetValue(Canvas.LeftProperty, (object)((num3 - ((FrameworkElement)_icon.uc).get_Width()) * 0.5));
}
}
}using System.Collections.Generic;
using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;
using System.Windows.Input;
using com.bigspaceship.utils;
namespace com.bigspaceship.display.videoplayer.overlays
{
public class ShareOverlay : VideoOverlay
{
private StandardButton _close;
private StandardButton _copyLink;
private StandardButton _copyEmbed;
private VideoPlayerStrings _strings;
private Dictionary<string, StandardButton> _socialNetworkingButtons;
public VideoPlayerStrings strings
{
get
{
return _strings;
}
set
{
_strings = value;
FrameworkElement obj = _("link_tf");
((TextBox)((obj is TextBox) ? obj : null)).set_Text(strings.url);
FrameworkElement obj2 = _("code_text_box");
((TextBox)((obj2 is TextBox) ? obj2 : null)).set_Text(strings.embedCode);
}
}
public ShareOverlay(UserControl uc)
: base(uc)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Expected O, but got Unknown
ref StandardButton close = ref _close;
FrameworkElement obj = _("close_uc");
close = new StandardButton((UserControl)(object)((obj is UserControl) ? obj : null));
_close.MouseClick += new MouseButtonEventHandler(_closeOnClick);
ref StandardButton copyLink = ref _copyLink;
FrameworkElement obj2 = _("copy_link_btn");
copyLink = new StandardButton((UserControl)(object)((obj2 is UserControl) ? obj2 : null));
_copyLink.MouseClick += new MouseButtonEventHandler(_copyLinkOnClick);
((UIElement)_copyLink.uc).set_Visibility((Visibility)1);
ref StandardButton copyEmbed = ref _copyEmbed;
FrameworkElement obj3 = _("copy_embed_btn");
copyEmbed = new StandardButton((UserControl)(object)((obj3 is UserControl) ? obj3 : null));
_copyEmbed.MouseClick += new MouseButtonEventHandler(_copyEmbedOnClick);
((UIElement)_copyEmbed.uc).set_Visibility((Visibility)1);
_socialNetworkingButtons = new Dictionary<string, StandardButton>();
Dictionary<string, StandardButton> socialNetworkingButtons = _socialNetworkingButtons;
FrameworkElement obj4 = _("social_network_icons.facebook");
socialNetworkingButtons.Add("facebook", new StandardButton((UserControl)(object)((obj4 is UserControl) ? obj4 : null)));
Dictionary<string, StandardButton> socialNetworkingButtons2 = _socialNetworkingButtons;
FrameworkElement obj5 = _("social_network_icons.twitter");
socialNetworkingButtons2.Add("twitter", new StandardButton((UserControl)(object)((obj5 is UserControl) ? obj5 : null)));
Dictionary<string, StandardButton> socialNetworkingButtons3 = _socialNetworkingButtons;
FrameworkElement obj6 = _("social_network_icons.myspace");
socialNetworkingButtons3.Add("myspace", new StandardButton((UserControl)(object)((obj6 is UserControl) ? obj6 : null)));
Dictionary<string, StandardButton> socialNetworkingButtons4 = _socialNetworkingButtons;
FrameworkElement obj7 = _("social_network_icons.digg");
socialNetworkingButtons4.Add("digg", new StandardButton((UserControl)(object)((obj7 is UserControl) ? obj7 : null)));
Dictionary<string, StandardButton> socialNetworkingButtons5 = _socialNetworkingButtons;
FrameworkElement obj8 = _("social_network_icons.delicious");
socialNetworkingButtons5.Add("delicious", new StandardButton((UserControl)(object)((obj8 is UserControl) ? obj8 : null)));
Dictionary<string, StandardButton> socialNetworkingButtons6 = _socialNetworkingButtons;
FrameworkElement obj9 = _("social_network_icons.stumbledupon");
socialNetworkingButtons6.Add("stumbleupon", new StandardButton((UserControl)(object)((obj9 is UserControl) ? obj9 : null)));
Dictionary<string, StandardButton> socialNetworkingButtons7 = _socialNetworkingButtons;
FrameworkElement obj10 = _("email_icon");
socialNetworkingButtons7.Add("email", new StandardButton((UserControl)(object)((obj10 is UserControl) ? obj10 : null)));
foreach (KeyValuePair<string, StandardButton> socialNetworkingButton in _socialNetworkingButtons)
{
FrameworkElement obj11 = socialNetworkingButton.Value._("icons_uc");
Standard standard = new Standard((UserControl)(object)((obj11 is UserControl) ? obj11 : null));
standard.gotoAndPlay(socialNetworkingButton.Key);
standard.destroy();
socialNetworkingButton.Value.MouseClick += new MouseButtonEventHandler(_socialNetworkOnClick);
}
}
private void _closeOnClick(object sender, MouseButtonEventArgs e)
{
animateOut();
}
public override void destroy()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Expected O, but got Unknown
base.destroy();
_copyLink.MouseClick -= new MouseButtonEventHandler(_copyLinkOnClick);
_copyLink.destroy();
_copyLink = null;
_copyEmbed.MouseClick -= new MouseButtonEventHandler(_copyEmbedOnClick);
_copyEmbed.destroy();
_copyEmbed = null;
foreach (KeyValuePair<string, StandardButton> socialNetworkingButton in _socialNetworkingButtons)
{
socialNetworkingButton.Value.MouseClick -= new MouseButtonEventHandler(_socialNetworkOnClick);
}
_socialNetworkingButtons.Clear();
_socialNetworkingButtons = null;
}
private void _copyLinkOnClick(object sender, MouseButtonEventArgs e)
{
HtmlPage.get_Window().Eval("window.clipboardData.setData('Text','" + _strings.url + "')");
}
private void _copyEmbedOnClick(object sender, MouseButtonEventArgs e)
{
HtmlPage.get_Window().Eval("window.clipboardData.setData('Text','" + _strings.embedCode + "')");
}
private void _socialNetworkOnClick(object sender, MouseButtonEventArgs e)
{
string text = "";
foreach (KeyValuePair<string, StandardButton> socialNetworkingButton in _socialNetworkingButtons)
{
if (socialNetworkingButton.Value == sender)
{
text = socialNetworkingButton.Key;
}
}
string text2 = "";
switch (text)
{
case "facebook":
text2 = "facebook";
break;
case "twitter":
text2 = "twitter";
break;
case "myspace":
text2 = "myspace";
break;
case "digg":
text2 = "digg";
break;
case "delicious":
text2 = "delicious";
break;
case "stumbleupon":
text2 = "stumbleupon";
break;
default:
SocialNetworkingUtils.email("", "Check out the NEW VSAllAccess.com", "", _strings.title + "%0D%0A" + _strings.url + "%0D%0A%0D%0ACatch more behind-the-scenes action, pics and videos at www.VSAllAccess.com.%0D%0ADon’t miss the 2009 Victoria's Secret Fashion Show: Tuesday, December 1, at 10/9C on CBS.");
return;
}
string note = _strings.note;
if (text2 == "twitter")
{
note = strings.twitterNote;
}
SocialNetworkingUtils.share(text2, _strings.url, _strings.title, note);
}
}
}using System;
using System.Windows.Controls;
namespace com.bigspaceship.display.videoplayer.overlays
{
public class VideoOverlay : StandardInOut
{
public event EventHandler Close;
public VideoOverlay(UserControl uc)
: base(uc, isCollapsedOnAnimateOut: true)
{
}
public override void destroy()
{
}
protected override void _onAnimateOutStart()
{
base._onAnimateOutStart();
if (this.Close != null)
{
this.Close(this, null);
}
}
}
}using System;
using System.Collections.Generic;
namespace com.bigspaceship.display.videoplayer.overlays
{
public class VideoOverlayManager
{
private string _overlayCurrent;
private Dictionary<string, VideoOverlay> _overlays;
public string state => _overlayCurrent;
public event EventHandler Open;
public VideoOverlayManager()
{
_overlays = new Dictionary<string, VideoOverlay>();
_overlayCurrent = null;
}
public void destroy()
{
foreach (KeyValuePair<string, VideoOverlay> overlay in _overlays)
{
overlay.Value.Close -= _overlayOnClose;
overlay.Value.destroy();
}
_overlays.Clear();
_overlays = null;
}
public void add(string id, VideoOverlay overlay)
{
if (!_overlays.ContainsKey(id))
{
overlay.Close += _overlayOnClose;
_overlays.Add(id, overlay);
}
}
public VideoOverlay getOverlayById(string id)
{
return _overlays[id];
}
public void open(string id)
{
close();
_overlayCurrent = id;
_overlays[id].animateIn();
if (this.Open != null)
{
this.Open(this, null);
}
}
private void _overlayOnClose(object sender, EventArgs e)
{
close();
}
public void close()
{
if (_overlayCurrent != null)
{
_overlays[_overlayCurrent].animateOut();
_overlayCurrent = null;
}
}
}
}Loading a XAP the way you’d load a SWF
The piece I remember fighting hardest was loading. In Flash you load a SWF, add it to the stage, and you’re done. Silverlight had no equivalent. A XAP is a ZIP, the class you want is inside a .dll inside it, and getting from one to the other is entirely your problem.
BigLoadItem is where that ended up. Pull the assembly out of the downloaded XAP by name, hand the stream to an AssemblyPart, and let it load:
string uriString = _xapNameSpace + ".dll";
StreamResourceInfo resourceStream = Application.GetResourceStream(new StreamResourceInfo(e.Result, null), new Uri(uriString, UriKind.Relative));
AssemblyPart val = new AssemblyPart();
Assembly assembly = val.Load(resourceStream.get_Stream());
Then Lib reaches into that assembly and instantiates the class by string, which is the part that actually gives you something to put on screen:
public static UserControl createMainPage(string xri, Assembly assembly)
{
return createUserControl(xri + ".MainPage", assembly);
}
Four steps to do what loadMovie did in one. But once it was written it was written, and the rest of the site got to treat a XAP like a SWF.
Here’s the payoff, from Main. Every screen, the header, the footer, the background, the carousel and the video player are all separate XAPs listed in a config XML. The loader fetches them, Main switches on the id and news up the right class against the assembly that just arrived:
Assembly assembly = _loader.getAsset(_screenCurrent) as Assembly;
string value = screenInfoById.Attribute("class").Value;
UserControl uc = Lib.createMainPage(value, assembly);
XDocument xml = XDocument.Parse((_loader.getAsset(_screenCurrent + "_xml") as StringBuilder).ToString());
switch (_screenCurrent)
{
case "screen_landing":
_screens[_screenCurrent] = new Landing(uc, _screenCurrent, xml, assembly, value);
(_screens[_screenCurrent] as Landing).Navigate += _navigateTo;
break;
case "screen_highlights":
_screens[_screenCurrent] = new Highlights(uc, _screenCurrent, xml, assembly, value);
break;
// ...
}
The stage is five stacked Canvas layers, built in a loop, so the background, header, footer, screen and preloader never argue about z-order:
_layers = new List<Canvas>(5);
for (int i = 0; i < 5; i++)
{
Canvas val = new Canvas();
((Panel)_stageCanvas).get_Children().Add(val);
_layers.Add(val);
}
And a section change is just: animate the old screen and background out, preload the new one, animate it in. Deep links go through the browser URL, so the back button worked, which in 2009 was not a given.
The carousel

One thing I always liked about working at Big Spaceship was the collaboration between coder and designer. This carousel was generally possible to code, but getting it exactly correct for the animation and positioning would’ve been a big pain. Instead, we leveraged storyboards, similar to how 3D game character reactions work. In code nothing really moves – no photos traveling anywhere. There are seven fixed positions on stage, and what rotates is the assignment of pictures to positions. Position 3 is the center slot, the big one. Positions 0 through 2 and 4 through 6 are the receding panels. Click the arrow and every slot animates one step over, wrapping around from 6 back to 0. The photo doesn’t slide anywhere. It gets handed off.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Xml.Linq;
using com.bigspaceship.display;
using com.bigspaceship.utils;
using com.victoriassecret.fashionshow.events;
namespace com.victoriassecret.fashionshow.ui.widgets.carousel
{
public class Carousel : StandardInOut
{
private const int __CENTER_INDEX = 3;
private const int __TOTAL_ITEMS_VISIBLE = 7;
private const string __VIDEO = "video";
private const string __PORTRAIT = "portrait";
private const string __LANDSCAPE = "landscape";
private List<CarouselItem> _items;
private List<CarouselTransition> _transitions;
private bool _isInit;
public IEnumerable<XElement> items
{
set
{
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Expected O, but got Unknown
_itemsCleanUp();
if (value == null)
{
return;
}
int num = 0;
int num2 = Math.Max(8, value.Count());
for (int i = 0; i < num2; i++)
{
if (num > value.Count() - 1)
{
num -= value.Count();
}
XElement xElement = value.ElementAt(num);
UserControl val = null;
CarouselItem carouselItem = null;
switch (xElement.Attribute("type").Value)
{
case "landscape":
val = Lib.createUserControl(this, "item_photo_3_4");
carouselItem = new PhotoItem(val, i, xElement);
break;
case "portrait":
val = Lib.createUserControl(this, "item_photo_4_3");
carouselItem = new PhotoItem(val, i, xElement);
break;
case "video":
val = Lib.createUserControl(this, "item_video");
carouselItem = new CarouselItem(val, i, xElement);
break;
}
carouselItem.MouseClick += new MouseButtonEventHandler(_itemOnMouseUp);
carouselItem.ActionOnClick += new MouseButtonEventHandler(_itemActionOnClick);
_items.Add(carouselItem);
num++;
}
for (int i = 0; i < 3; i++)
{
CarouselItem carouselItem = _items[_items.Count() - 1];
_items.RemoveAt(_items.Count() - 1);
_items.Insert(0, carouselItem);
}
}
}
public event RichMediaEventHandler ItemActionClick;
public Carousel(UserControl uc, Assembly assembly, string classname)
: base(uc, isCollapsedOnAnimateOut: true, assembly, classname)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
_items = new List<CarouselItem>();
_transitions = new List<CarouselTransition>();
FrameworkElement obj = _("next_uc");
new StandardButton((UserControl)(object)((obj is UserControl) ? obj : null)).MouseClick += new MouseButtonEventHandler(_nextOnClick);
FrameworkElement obj2 = _("prev_uc");
new StandardButton((UserControl)(object)((obj2 is UserControl) ? obj2 : null)).MouseClick += new MouseButtonEventHandler(_prevOnClick);
}
public override void destroy()
{
_itemsCleanUp();
for (int i = 0; i < _transitions.Count(); i++)
{
_transitions[i].destroy();
}
_transitions.Clear();
_items = null;
_transitions = null;
base.destroy();
}
private void _initialize()
{
if (!_isInit)
{
_isInit = true;
for (int i = 0; i < 7; i++)
{
FrameworkElement obj = _("t" + i);
CarouselTransition carouselTransition = new CarouselTransition((UserControl)(object)((obj is UserControl) ? obj : null), i);
carouselTransition.PrevItemRequested += _transitionOnPrevItemRequested;
carouselTransition.NextItemRequested += _transitionOnNextItemRequested;
_transitions.Add(carouselTransition);
}
}
}
public void setContainer(Canvas canvas)
{
if (((FrameworkElement)_uc).get_Parent() != null)
{
DependencyObject parent = ((FrameworkElement)_uc).get_Parent();
((PresentationFrameworkCollection<UIElement>)(object)((Panel)((parent is Canvas) ? parent : null)).get_Children()).Remove((UIElement)(object)_uc);
}
((UIElement)_uc).set_Visibility((Visibility)1);
((PresentationFrameworkCollection<UIElement>)(object)((Panel)canvas).get_Children()).Add((UIElement)(object)_uc);
}
protected override void _onAnimateInStart()
{
_initialize();
for (int i = 0; i < _transitions.Count(); i++)
{
_transitions[i].item = _items[i];
}
base._onAnimateInStart();
}
protected override void _onAnimateOut()
{
for (int i = 0; i < _transitions.Count(); i++)
{
_transitions[i].reset();
}
base._onAnimateOut();
}
private void _nextOnClick(object sender, MouseButtonEventArgs e)
{
for (int i = 0; i < _transitions.Count(); i++)
{
_transitions[i].prev();
}
}
private void _prevOnClick(object sender, MouseButtonEventArgs e)
{
for (int i = 0; i < _transitions.Count(); i++)
{
_transitions[i].next();
}
}
private void _itemsCleanUp()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
for (int i = 0; i < _items.Count(); i++)
{
_items[i].MouseClick -= new MouseButtonEventHandler(_itemOnMouseUp);
if (_items[i].transition == null)
{
_items[i].destroy();
}
}
_items.Clear();
}
private void _itemOnMouseUp(object sender, MouseButtonEventArgs e)
{
CarouselItem carouselItem = sender as CarouselItem;
if (carouselItem.transition == null)
{
return;
}
if (carouselItem.transition.position < 3)
{
int num = 3 - carouselItem.transition.position;
for (int i = 0; i < num; i++)
{
_prevOnClick(null, null);
}
}
else if (carouselItem.transition.position > 3)
{
int num = carouselItem.transition.position - 3;
for (int i = 0; i < num; i++)
{
_nextOnClick(null, null);
}
}
}
private void _itemActionOnClick(object sender, EventArgs e)
{
CarouselItem carouselItem = sender as CarouselItem;
if (this.ItemActionClick != null)
{
this.ItemActionClick(this, new RichMediaEvent(carouselItem.data));
}
}
private void _transitionOnNextItemRequested(object sender, EventArgs e)
{
CarouselTransition carouselTransition = sender as CarouselTransition;
int num = _items.IndexOf(carouselTransition.item) + 7;
if (num > _items.Count() - 1)
{
num -= _items.Count();
}
carouselTransition.item = _items[num];
}
private void _transitionOnPrevItemRequested(object sender, EventArgs e)
{
CarouselTransition carouselTransition = sender as CarouselTransition;
int num = _items.IndexOf(carouselTransition.item) - 7;
if (num < 0)
{
num += _items.Count();
}
carouselTransition.item = _items[num];
}
}
}using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
using com.bigspaceship.display;
using com.bigspaceship.utils;
namespace com.victoriassecret.fashionshow.ui.widgets.carousel
{
public class CarouselTransition : Standard
{
private const int __CENTER_INDEX = 3;
private const int __TOTAL_STATES = 7;
private bool _isAnimating;
private bool _isAnimatingBackwards;
private int _positionStart;
private int _positionCurrent;
private int _positionDestination;
private CarouselItem _item;
private Storyboard _storyboardStart;
private Storyboard _storyboardPlaying;
public CarouselItem item
{
get
{
return _item;
}
set
{
if (_item != null)
{
_item.transition = null;
}
_item = value;
if (_item != null)
{
Out.debug(this, "Transition " + _positionStart + " is now holding: " + _item.id);
_item.transition = this;
if (_positionCurrent == 3)
{
_item.select();
_item.animateIn();
}
else
{
_item.animateOut();
}
}
else
{
Out.debug(this, "Transition " + _positionStart + " is now empty.");
}
}
}
public int index => _positionStart;
public int position => _positionCurrent;
public bool isAnimatingBackwards => _isAnimatingBackwards;
public event EventHandler Completed;
public event EventHandler PrevItemRequested;
public event EventHandler NextItemRequested;
public CarouselTransition(UserControl uc, int positionStart)
: base(uc)
{
_positionStart = positionStart;
ref Storyboard storyboardStart = ref _storyboardStart;
object obj = ((FrameworkElement)_uc).FindName("p" + _positionStart);
storyboardStart = (Storyboard)((obj is Storyboard) ? obj : null);
reset();
}
public void reset()
{
if (_item != null)
{
_item.destroy();
}
item = null;
_isAnimating = false;
_isAnimatingBackwards = false;
_positionCurrent = (_positionDestination = _positionStart);
if (_storyboardPlaying != null)
{
((Timeline)_storyboardPlaying).remove_Completed((EventHandler)_storyboardOnCompleted);
_storyboardPlaying.Stop();
}
if (_isAnimating && _storyboardPlaying != null)
{
_storyboardPlaying.Seek(TimeSpan.Zero);
_storyboardPlaying.Stop();
}
_storyboardStart.Seek(TimeSpan.Zero);
_storyboardStart.Begin();
}
public void prev()
{
_positionDestination--;
_isAnimatingBackwards = true;
if (_positionDestination < 0)
{
_positionDestination += 7;
}
_play();
}
public void next()
{
_positionDestination++;
_isAnimatingBackwards = false;
if (_positionDestination > 6)
{
_positionDestination -= 7;
}
_play();
}
protected void _play()
{
if (_isAnimating)
{
return;
}
_isAnimating = true;
if (_positionCurrent == 3)
{
_item.animateOut();
}
int positionCurrent = _positionCurrent;
if (_isAnimatingBackwards)
{
_positionCurrent--;
if (_positionCurrent < 0)
{
_positionCurrent += 7;
}
}
else
{
_positionCurrent++;
if (_positionCurrent > 6)
{
_positionCurrent -= 7;
}
}
if (_item != null)
{
if (_positionCurrent == 3)
{
_item.select();
}
else
{
_item.deselect();
}
}
if (positionCurrent == 6 && _positionCurrent == 0)
{
if (this.PrevItemRequested != null)
{
this.PrevItemRequested(this, null);
}
}
else if (positionCurrent == 0 && _positionCurrent == 6 && this.NextItemRequested != null)
{
this.NextItemRequested(this, null);
}
ref Storyboard storyboardPlaying = ref _storyboardPlaying;
object obj = ((FrameworkElement)_uc).FindName("p" + positionCurrent + "_" + _positionCurrent);
storyboardPlaying = (Storyboard)((obj is Storyboard) ? obj : null);
((Timeline)_storyboardPlaying).add_Completed((EventHandler)_storyboardOnCompleted);
_storyboardPlaying.Begin();
}
private void _storyboardOnCompleted(object sender, EventArgs e)
{
((Timeline)((sender is Storyboard) ? sender : null)).remove_Completed((EventHandler)_storyboardOnCompleted);
if (sender == _storyboardPlaying)
{
_storyboardPlaying = null;
}
_isAnimating = false;
if (_positionCurrent == _positionDestination)
{
if (_positionCurrent == 3 && _item != null)
{
_item.animateIn();
}
if (this.Completed != null)
{
this.Completed(this, null);
}
}
else
{
_play();
}
}
}
}using System;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Xml.Linq;
using com.bigspaceship.display;
using com.bigspaceship.loading;
namespace com.victoriassecret.fashionshow.ui.widgets.carousel
{
public class CarouselItem : StandardButton
{
protected XElement _data;
protected int _index;
protected BigLoader _loader;
protected StandardButton _action;
protected Standard _photo;
protected CarouselTransition _transition;
protected bool _isVideo;
private bool _isLoaded;
public bool isVideo => _isVideo;
public XElement data => _data;
public string id => _data.Attribute("id").Value;
public int index => _index;
public CarouselTransition transition
{
get
{
return _transition;
}
set
{
if (_transition != null)
{
DependencyObject parent = ((FrameworkElement)_uc).get_Parent();
((PresentationFrameworkCollection<UIElement>)(object)((Panel)((parent is Canvas) ? parent : null)).get_Children()).Remove((UIElement)(object)_uc);
}
_transition = value;
if (_transition != null)
{
startLoad();
FrameworkElement obj = _transition._("item_uc.layoutroot");
Canvas val = (Canvas)(object)((obj is Canvas) ? obj : null);
((PresentationFrameworkCollection<UIElement>)(object)((Panel)val).get_Children()).Clear();
((PresentationFrameworkCollection<UIElement>)(object)((Panel)val).get_Children()).Add((UIElement)(object)_uc);
}
}
}
public event MouseButtonEventHandler ActionOnClick
{
[MethodImpl(MethodImplOptions.Synchronized)]
add
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.ActionOnClick = (MouseButtonEventHandler)Delegate.Combine((Delegate)(object)this.ActionOnClick, (Delegate)(object)value);
}
[MethodImpl(MethodImplOptions.Synchronized)]
remove
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
this.ActionOnClick = (MouseButtonEventHandler)Delegate.Remove((Delegate)(object)this.ActionOnClick, (Delegate)(object)value);
}
}
public event EventHandler ThumbnailLoadComplete;
public CarouselItem(UserControl uc, int index, XElement data)
: base(uc)
{
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
_data = data;
_index = index;
_selectAnimStartLabel = "rollout";
_isVideo = true;
((DependencyObject)_uc).SetValue(Canvas.LeftProperty, (object)((0.0 - ((FrameworkElement)_uc).get_Width()) * 0.5));
((DependencyObject)_uc).SetValue(Canvas.TopProperty, (object)((0.0 - ((FrameworkElement)_uc).get_Height()) * 0.5));
ref StandardButton action = ref _action;
FrameworkElement obj = _("action_uc");
action = new StandardButton((UserControl)(object)((obj is UserControl) ? obj : null));
_action.MouseClick += new MouseButtonEventHandler(_actionOnClick);
ref Standard photo = ref _photo;
FrameworkElement obj2 = _("content_canvas.photo_uc");
photo = new Standard((UserControl)(object)((obj2 is UserControl) ? obj2 : null));
_photo.gotoAndPlay("loading");
}
private void _actionOnClick(object sender, MouseButtonEventArgs e)
{
if (this.ActionOnClick != null)
{
this.ActionOnClick.Invoke((object)this, e);
}
}
public void startLoad()
{
if (!_isLoaded)
{
_loader = new BigLoader();
_loader.add(Model.instance.absoluteURL(_data.Attribute("silverlight_thumb_url").Value), "image", 1.0);
_loader.Completed += _loaderOnCompleted;
_loader.start();
}
}
private void _loaderOnCompleted(object sender, EventArgs e)
{
if (_loader != null)
{
FrameworkElement obj = _("content_canvas.photo_uc");
UserControl val = (UserControl)(object)((obj is UserControl) ? obj : null);
object obj2 = ((FrameworkElement)val).FindName("bmp");
? val2 = ((obj2 is Image) ? obj2 : null);
object asset = _loader.getAsset("image");
((Image)val2).set_Source((ImageSource)((asset is BitmapImage) ? asset : null));
_photo.gotoAndPlay("loaded");
_loader.Completed -= _loaderOnCompleted;
_loader.destroy();
_loader = null;
}
_isLoaded = true;
if (this.ThumbnailLoadComplete != null)
{
this.ThumbnailLoadComplete(this, null);
}
}
public void animateIn()
{
gotoAndPlay("_in");
}
public void animateOut()
{
gotoAndPlay("_out");
}
public override void destroy()
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
if (_loader != null)
{
_loader.Completed -= _loaderOnCompleted;
_loader.destroy();
_loader = null;
}
if (_action != null)
{
_action.MouseClick -= new MouseButtonEventHandler(_actionOnClick);
_action.destroy();
_action = null;
}
if (_photo != null)
{
_photo.destroy();
_photo = null;
}
transition = null;
base.destroy();
}
}
}using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Xml.Linq;
namespace com.victoriassecret.fashionshow.ui.widgets.carousel
{
public class PhotoItem : CarouselItem
{
public PhotoItem(UserControl uc, int index, XElement data)
: base(uc, index, data)
{
_isVideo = false;
FrameworkElement obj = _("content_canvas.tf");
((TextBlock)((obj is TextBlock) ? obj : null)).set_Text(_data.Descendants("title").First().Value);
if (_data.Attribute("silverlight_fullsize_url") == null || _data.Attribute("silverlight_fullsize_url").Value == "")
{
((UIElement)_action.uc).set_Visibility((Visibility)1);
}
}
public override void destroy()
{
base.destroy();
}
}
}Each slot is a CarouselTransition, bound to a UserControl named t0 through t6. Inside each of those is a resting Storyboard named for the slot it sits in:
_storyboardStart = _uc.FindName("p" + _positionStart) as Storyboard;
And a second set named for the hop, from the slot it’s leaving to the slot it’s arriving at:
_storyboardPlaying = _uc.FindName("p" + positionCurrent + "_" + _positionCurrent) as Storyboard;
So p2_3 is the move into the center. p3_4 is the move back out of it. Both directions had to exist, wrap included, so the XAML behind a slot carries a resting storyboard for each of the seven positions plus a transition for every adjacent hop each way. Twenty-one hand authored animations to make one arrow click look right. All the perspective, the scale, the easing, the way a panel tips as it slides toward center – none of that is in the code. The code just plays them.
prev() and next() decrement or increment a target index, wrap it mod 7, and let the timeline do the rest. If you click again mid-flight it doesn’t interrupt anything, it just moves the destination and keeps hopping one slot at a time until it gets there.
I don’t know why I didn’t make the center item 0. I wound up with code like this:
private void _nextOnClick(object sender, MouseButtonEventArgs e)
{
for (int i = 0; i < _transitions.Count(); i++)
_transitions[i].prev();
}
This is technically correct – moving the carousel forward means every slot moves backward! Looking at it now, I’m certain I confused myself for quite awhile during the build. I didn’t know how many photos any given gallery would have. To solve for that, I made sure we had cycled until we had enough photos:
int num2 = Math.Max(8, value.Count());
Then the last three get rotated to the front, so slot 3 starts holding the right picture instead of whatever happened to land there. Four photos, eight items, seven slots, and it spins forever without anyone noticing the repeat.
The videoplayer
One of the features we included was an embeddable video player so you didn’t need to be on the site to watch the stream – very fancy for 2009. In the interest of preservation, I’ve revived that embedded player using OpenSilver – it’s not a port, it’s the original code! It’s not the full site, but you can get a sense of the speed and styles we were able to pull off at the time.
The clip is Big Buck Bunny rather than anything from the show, for reasons I hope are obvious. Everything around it – the scrubber, the volume steps, the share overlay, the rollovers – is the 2009 code.
Some anecdotal results:
- The site drove millions of downloads for the Silverlight player, given the media attention.
- Microsoft highlighted it at their professional developer conference as an example of how Silverlight was powering tentpole streaming events online.
- The blog post about my experiences, which led to some fruitful discussion in the Flash community.
What I’m most proud of is what I overcame. Delivering something that many millions of people would see in a platform I’d never used and a language I’d never written is something I look back on with great fondness.