示例#1
0
 public void Initialize(Dictionary<string, object> appInfo, Dictionary<string, object> entryPointInformation)
 {
     try
     {
         VmcExecuteAddIn.entryPointInfo = entryPointInformation;
         object obj1;
         VmcExecuteAddIn.entryPointInfo.TryGetValue("Title", out obj1);
         VmcExecuteAddIn.ExecutionTitle = obj1 as string;
         object obj2;
         if (!VmcExecuteAddIn.entryPointInfo.TryGetValue("ImageUrl", out obj2))
             VmcExecuteAddIn.entryPointInfo.TryGetValue("ThumbnailUrl", out obj2);
         VmcExecuteAddIn.ExecutionImageUrl = obj2 as string;
         object obj3;
         if (!VmcExecuteAddIn.entryPointInfo.TryGetValue("Context", out obj3))
             throw new InvalidOperationException("Context not found.");
         this.executionInfo = (ExecutionInfo)new XmlSerializer(typeof(ExecutionInfo)).Deserialize((TextReader)new StringReader(((string)obj3).Trim()));
         if (this.executionInfo == null)
             throw new FormatException("Could not interpret context.");
         bool flag1 = !string.IsNullOrEmpty(this.executionInfo.FileName);
         bool flag2 = this.executionInfo.Media != null && this.executionInfo.Media.Count > 0;
         if (!flag1 && !flag2 && !this.executionInfo.Page.HasValue)
             throw new InvalidOperationException("No file name, page or media specified.");
         if (!flag1)
             return;
         this.executionInfo.FileName = System.Environment.ExpandEnvironmentVariables(this.executionInfo.FileName);
         object obj4;
         if (!this.executionInfo.RequiresDirectX && VmcExecuteAddIn.entryPointInfo.TryGetValue("CapabilitiesRequired", out obj4))
             this.executionInfo.RequiresDirectX = ((string)obj4).IndexOf("directx", StringComparison.InvariantCultureIgnoreCase) != -1;
         VmcExecuteAddIn.globalHook = new GlobalHook();
         VmcExecuteAddIn.ExecutionEngine = new ExecutionEngine(this.executionInfo, VmcExecuteAddIn.globalHook);
         VmcExecuteAddIn.ExecutionEngine.ExecutionFinished += (EventHandler)delegate
         {
             Application.DeferredInvoke(new DeferredHandler(this.ExecutionFinishedHandler));
         };
         VmcExecuteAddIn.ExecutionEngine.ExecutionError += (EventHandler<Advent.VmcExecute.ErrorEventArgs>)((sender, args) => Application.DeferredInvoke(new DeferredHandler(this.ExecutionErrorHandler), (object)args));
         if (string.IsNullOrEmpty(VmcExecuteAddIn.ExecutionTitle))
             VmcExecuteAddIn.ExecutionTitle = Path.GetFileNameWithoutExtension(this.executionInfo.FileName);
         VmcExecuteAddIn.messagePump = new Thread((ThreadStart)(() =>
         {
             try
             {
                 if (VmcExecuteAddIn.ExecutionEngine.RequiresKeyboardHook)
                     VmcExecuteAddIn.globalHook.Start(false, true);
                 System.Windows.Threading.Dispatcher.Run();
             }
             catch (ThreadAbortException)
             {
             }
         }));
         VmcExecuteAddIn.messagePump.SetApartmentState(ApartmentState.STA);
         VmcExecuteAddIn.messagePump.IsBackground = true;
         VmcExecuteAddIn.messagePump.Start();
     }
     catch (Exception ex)
     {
         VmcExecuteAddIn.LogError(ex.ToString());
         throw;
     }
 }
示例#2
0
 internal ExecutionEngine(ExecutionInfo info, GlobalHook globalHook)
 {
     this.execInfo = info;
     this.hook     = globalHook;
     this.psi      = new ProcessStartInfo()
     {
         FileName        = this.execInfo.FileName,
         Arguments       = this.execInfo.Arguments,
         UseShellExecute = true
     };
     if (this.psi.FileName == null)
     {
         throw new ArgumentException("A file to execute must be provided.");
     }
 }
示例#3
0
 public EntryPointPresenter(Advent.MediaCenter.StartMenu.OEM.EntryPoint entryPoint)
 {
     this.isImageAutoGenerated = true;
     this.isInactiveImageAutoGenerated = true;
     this.entryPoint = entryPoint;
     this.entryPoint.IsDirtyChanged += (EventHandler)delegate
     {
         this.OnPropertyChanged("IsDirty");
     };
     this.entryPoint.Saving += new EventHandler(this.EntryPointSaving);
     List<EntryPointCapabilityPresenter> list = new List<EntryPointCapabilityPresenter>();
     this.CapabilitiesRequired = (IEnumerable<EntryPointCapabilityPresenter>)list;
     foreach (EntryPointCapabilities capability in EntryPointPresenter.PossibleCapabilities)
         list.Add(new EntryPointCapabilityPresenter(this, capability));
     if (entryPoint.AddIn != null)
     {
         System.Type type = (System.Type)null;
         try
         {
             type = System.Type.GetType(entryPoint.AddIn, false, false);
         }
         catch (Exception ex)
         {
             Trace.TraceError(((object)ex).ToString());
         }
         if (type == typeof(VmcExecuteAddIn))
         {
             this.ExecutionType = EntryPointType.VmcExecute;
             this.vmcExecuteInfo = !string.IsNullOrEmpty(this.entryPoint.Context) ? (ExecutionInfo)new XmlSerializer(typeof(ExecutionInfo)).Deserialize((TextReader)new StringReader(this.entryPoint.Context)) : new ExecutionInfo();
             if (this.vmcExecuteInfo.CloseKeys == null)
                 this.vmcExecuteInfo.CloseKeys = new List<Keys>();
             if (this.vmcExecuteInfo.KillKeys == null)
                 this.vmcExecuteInfo.KillKeys = new List<Keys>();
             ObservableCollection<Keys> observableCollection1 = new ObservableCollection<Keys>(this.vmcExecuteInfo.CloseKeys);
             observableCollection1.CollectionChanged += (NotifyCollectionChangedEventHandler)delegate
             {
                 this.Model.MarkAsDirty();
             };
             CollectionUtilities.StartReplicatingChangesTo<Keys>((INotifyCollectionChanged)observableCollection1, (ICollection<Keys>)this.vmcExecuteInfo.CloseKeys);
             ObservableCollection<Keys> observableCollection2 = new ObservableCollection<Keys>(this.vmcExecuteInfo.KillKeys);
             observableCollection2.CollectionChanged += (NotifyCollectionChangedEventHandler)delegate
             {
                 this.Model.MarkAsDirty();
             };
             CollectionUtilities.StartReplicatingChangesTo<Keys>((INotifyCollectionChanged)observableCollection2, (ICollection<Keys>)this.vmcExecuteInfo.KillKeys);
             this.CloseKeys = (IList<Keys>)observableCollection1;
             this.KillKeys = (IList<Keys>)observableCollection2;
             if (this.vmcExecuteInfo.Media == null)
                 this.vmcExecuteInfo.Media = new List<MediaInfo>();
             ObservableCollection<MediaInfoPresenter> observableCollection3 = new ObservableCollection<MediaInfoPresenter>(Enumerable.Select<MediaInfo, MediaInfoPresenter>((IEnumerable<MediaInfo>)this.vmcExecuteInfo.Media, (Func<MediaInfo, MediaInfoPresenter>)(o => MediaInfoPresenter.Create(o))));
             observableCollection3.CollectionChanged += (NotifyCollectionChangedEventHandler)delegate
             {
                 this.Model.MarkAsDirty();
             };
             CollectionUtilities.StartReplicatingChangesTo<MediaInfo>((INotifyCollectionChanged)observableCollection3, (ICollection<MediaInfo>)this.vmcExecuteInfo.Media, true, (Func<object, MediaInfo>)(o => ((MediaInfoPresenter)o).MediaInfo));
             this.Media = observableCollection3;
         }
         else
             this.ExecutionType = EntryPointType.AddIn;
     }
     else if (entryPoint.Run != null)
     {
         this.ExecutionType = EntryPointType.Exe;
     }
     else
     {
         if (entryPoint.Url == null)
             return;
         this.ExecutionType = EntryPointType.Url;
     }
 }
 private void NewGameExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     OemManager oemManager = this.m_startMenu.StartMenuManager.OemManager;
     Game game = (Game)e.Parameter;
     Advent.MediaCenter.StartMenu.OEM.EntryPoint entryPoint = new Advent.MediaCenter.StartMenu.OEM.EntryPoint();
     entryPoint.ID = "{" + Guid.NewGuid() + "}";
     entryPoint.Title = game.Name;
     entryPoint.RawDescription = game.Description;
     entryPoint.CapabilitiesRequired = (EntryPointCapabilities.DirectX | EntryPointCapabilities.IntensiveRendering);
     entryPoint.NowPlayingDirective = "stop";
     entryPoint.ImageOverride = game.Image;
     string fileName="";
     string arguments="";
     if (VmcStudioUtil.IsShortcut(game.PlayTasks[0]))
     {
         WshShell shell = new WshShell();
         IWshShortcut wshShortcut = (IWshShortcut)shell.CreateShortcut(game.PlayTasks[0]);
         fileName = wshShortcut.TargetPath;
         arguments = wshShortcut.Arguments;
     }
     else
     {
         fileName = game.PlayTasks[0];
         arguments = null;
     }
     entryPoint.AddIn = typeof(VmcExecuteAddIn).AssemblyQualifiedName;
     ExecutionInfo executionInfo = new ExecutionInfo();
     executionInfo.FileName = fileName;
     executionInfo.Arguments = arguments;
     executionInfo.CloseKeys = new List<Keys>
     {
         Keys.BrowserBack
     };
     XmlSerializer xmlSerializer = new XmlSerializer(typeof(ExecutionInfo));
     StringBuilder stringBuilder = new StringBuilder();
     xmlSerializer.Serialize(new StringWriter(stringBuilder), executionInfo);
     entryPoint.Context = stringBuilder.ToString();
     Advent.MediaCenter.StartMenu.OEM.Application application = oemManager.Applications[game.GameID];
     if (application == null)
     {
         application = new Advent.MediaCenter.StartMenu.OEM.Application();
         application.ID = "{" + Guid.NewGuid() + "}";
         application.Title = entryPoint.Title;
         oemManager.Applications.Add(application);
     }
     entryPoint.Manager = oemManager;
     entryPoint.Application = application;
     oemManager.EntryPoints.Add(entryPoint);
     OemQuickLink oemQuickLink = new OemQuickLink(oemManager);
     oemQuickLink.BeginInit();
     oemQuickLink.Application = application;
     oemQuickLink.EntryPoint = entryPoint;
     oemQuickLink.EndInit();
     oemManager.Categories["Services\\Games"].QuickLinks.Add(oemQuickLink);
     EntryPointDocumentView.OpenDocument(entryPoint);
     e.Handled = true;
 }
示例#5
0
 public void Initialize(Dictionary <string, object> appInfo, Dictionary <string, object> entryPointInformation)
 {
     try
     {
         VmcExecuteAddIn.entryPointInfo = entryPointInformation;
         object obj1;
         VmcExecuteAddIn.entryPointInfo.TryGetValue("Title", out obj1);
         VmcExecuteAddIn.ExecutionTitle = obj1 as string;
         object obj2;
         if (!VmcExecuteAddIn.entryPointInfo.TryGetValue("ImageUrl", out obj2))
         {
             VmcExecuteAddIn.entryPointInfo.TryGetValue("ThumbnailUrl", out obj2);
         }
         VmcExecuteAddIn.ExecutionImageUrl = obj2 as string;
         object obj3;
         if (!VmcExecuteAddIn.entryPointInfo.TryGetValue("Context", out obj3))
         {
             throw new InvalidOperationException("Context not found.");
         }
         this.executionInfo = (ExecutionInfo) new XmlSerializer(typeof(ExecutionInfo)).Deserialize((TextReader) new StringReader(((string)obj3).Trim()));
         if (this.executionInfo == null)
         {
             throw new FormatException("Could not interpret context.");
         }
         bool flag1 = !string.IsNullOrEmpty(this.executionInfo.FileName);
         bool flag2 = this.executionInfo.Media != null && this.executionInfo.Media.Count > 0;
         if (!flag1 && !flag2 && !this.executionInfo.Page.HasValue)
         {
             throw new InvalidOperationException("No file name, page or media specified.");
         }
         if (!flag1)
         {
             return;
         }
         this.executionInfo.FileName = System.Environment.ExpandEnvironmentVariables(this.executionInfo.FileName);
         object obj4;
         if (!this.executionInfo.RequiresDirectX && VmcExecuteAddIn.entryPointInfo.TryGetValue("CapabilitiesRequired", out obj4))
         {
             this.executionInfo.RequiresDirectX = ((string)obj4).IndexOf("directx", StringComparison.InvariantCultureIgnoreCase) != -1;
         }
         VmcExecuteAddIn.globalHook      = new GlobalHook();
         VmcExecuteAddIn.ExecutionEngine = new ExecutionEngine(this.executionInfo, VmcExecuteAddIn.globalHook);
         VmcExecuteAddIn.ExecutionEngine.ExecutionFinished += (EventHandler) delegate
         {
             Application.DeferredInvoke(new DeferredHandler(this.ExecutionFinishedHandler));
         };
         VmcExecuteAddIn.ExecutionEngine.ExecutionError += (EventHandler <Advent.VmcExecute.ErrorEventArgs>)((sender, args) => Application.DeferredInvoke(new DeferredHandler(this.ExecutionErrorHandler), (object)args));
         if (string.IsNullOrEmpty(VmcExecuteAddIn.ExecutionTitle))
         {
             VmcExecuteAddIn.ExecutionTitle = Path.GetFileNameWithoutExtension(this.executionInfo.FileName);
         }
         VmcExecuteAddIn.messagePump = new Thread((ThreadStart)(() =>
         {
             try
             {
                 if (VmcExecuteAddIn.ExecutionEngine.RequiresKeyboardHook)
                 {
                     VmcExecuteAddIn.globalHook.Start(false, true);
                 }
                 System.Windows.Threading.Dispatcher.Run();
             }
             catch (ThreadAbortException)
             {
             }
         }));
         VmcExecuteAddIn.messagePump.SetApartmentState(ApartmentState.STA);
         VmcExecuteAddIn.messagePump.IsBackground = true;
         VmcExecuteAddIn.messagePump.Start();
     }
     catch (Exception ex)
     {
         VmcExecuteAddIn.LogError(ex.ToString());
         throw;
     }
 }