protected override void OnQuickLinkChanged(OemQuickLink oldValue, OemQuickLink newValue) { if (this.IsInitInProgress) { return; } if (oldValue != null) { this.category.QuickLinks.Remove((IQuickLink)oldValue); } if (newValue != null) { ObservableCollection <IQuickLink> quickLinks = this.category.QuickLinks; if (!quickLinks.Contains((IQuickLink)newValue)) { quickLinks.Add((IQuickLink)newValue); } } OemQuickLink bestQuickLink = this.GetBestQuickLink(); if (bestQuickLink == newValue) { return; } this.OemQuickLink = bestQuickLink; }
protected override void Load() { base.Load(); this.launchElement = (XmlElement)Enumerable.First <XmlElement>(Enumerable.OfType <XmlElement>((IEnumerable)this.LinkElement.ChildNodes), (Func <XmlElement, bool>)(o => o.Name == "Command")).FirstChild; string attribute1 = this.launchElement.GetAttribute("AppId"); string attribute2 = this.launchElement.GetAttribute("EntryPointId"); if (string.IsNullOrEmpty(attribute2)) { return; } EntryPoint entryPoint = this.Manager.OemManager.EntryPoints[attribute2]; if (entryPoint != null) { OemQuickLink oemQuickLink = new OemQuickLink(this.Manager.OemManager); oemQuickLink.BeginInit(); oemQuickLink.ApplicationID = attribute1; oemQuickLink.EntryPoint = entryPoint; oemQuickLink.EndInit(); this.OemQuickLink = oemQuickLink; } else { Trace.TraceWarning("Entry point " + attribute2 + " not found."); } }
internal override void Save(IResourceLibrary ehres) { if (this.OemQuickLink != null) { OemQuickLink oemQuickLink = this.OemQuickLink; this.launchElement.SetAttribute("AppId", oemQuickLink.ApplicationID); this.launchElement.SetAttribute("EntryPointId", oemQuickLink.EntryPointID); this.LinkElement.SetAttribute("Description", this.OemQuickLink.Title); this.LinkElement.SetAttribute("EntryPointId", oemQuickLink.EntryPointID); XmlElement xmlElement = (XmlElement)Enumerable.First <XmlElement>(Enumerable.OfType <XmlElement>((IEnumerable)this.LinkElement), (Func <XmlElement, bool>)(o => o.Name == "Image")).FirstChild.FirstChild; Enumerable.First <XmlElement>(Enumerable.OfType <XmlElement>((IEnumerable)xmlElement.ChildNodes), (Func <XmlElement, bool>)(o => o.GetAttribute("Name") == "Focus")).SetAttribute("Source", Windows7PartnerQuickLink.GetFileUrl(oemQuickLink.EntryPoint.ImageUrl)); Enumerable.First <XmlElement>(Enumerable.OfType <XmlElement>((IEnumerable)xmlElement.ChildNodes), (Func <XmlElement, bool>)(o => o.GetAttribute("Name") == "Default")).SetAttribute("Source", Windows7PartnerQuickLink.GetFileUrl(oemQuickLink.EntryPoint.InactiveImageUrl ?? oemQuickLink.EntryPoint.ImageUrl)); } base.Save(ehres); }
protected override void OnQuickLinkChanged(OemQuickLink oldValue, OemQuickLink newValue) { if (this.IsInitInProgress) return; if (oldValue != null) this.category.QuickLinks.Remove((IQuickLink)oldValue); if (newValue != null) { ObservableCollection<IQuickLink> quickLinks = this.category.QuickLinks; if (!quickLinks.Contains((IQuickLink)newValue)) quickLinks.Add((IQuickLink)newValue); } OemQuickLink bestQuickLink = this.GetBestQuickLink(); if (bestQuickLink == newValue) return; this.OemQuickLink = bestQuickLink; }
protected override void InsertItem(int index, IQuickLink item) { if (!this.inInit) { IPartnerQuickLink partnerQuickLink1 = item as IPartnerQuickLink; OemQuickLink oemQuickLink = partnerQuickLink1 == null ? item as OemQuickLink : partnerQuickLink1.OemQuickLink; if (oemQuickLink != null) { IPartnerQuickLink partnerQuickLink2 = this.GetFreePartnerQuickLink(); if (partnerQuickLink2 != null) { partnerQuickLink2.OemQuickLink = oemQuickLink; int oldIndex = this.IndexOf((IQuickLink)partnerQuickLink2); this.Move(oldIndex, oldIndex < index ? index - 1 : index); } } else { base.InsertItem(index, item); } XmlQuickLink xmlQuickLink = item as XmlQuickLink; if (xmlQuickLink == null || xmlQuickLink.XmlElement.OwnerDocument == this.strip.xml || xmlQuickLink is IPartnerQuickLink) { return; } if (xmlQuickLink.XmlElement.ParentNode != null) { XmlElement documentElement = this.strip.MenuStripDocument.DocumentElement; foreach (XmlAttribute xmlAttribute in (XmlNamedNodeMap)xmlQuickLink.XmlElement.OwnerDocument.DocumentElement.Attributes) { XmlAttribute attributeNode = documentElement.GetAttributeNode(xmlAttribute.Name); if (xmlAttribute.Name.StartsWith("xmlns:") && attributeNode == null) { documentElement.SetAttribute(xmlAttribute.Name, xmlAttribute.Value); } } xmlQuickLink.XmlElement.ParentNode.RemoveChild((XmlNode)xmlQuickLink.XmlElement); } xmlQuickLink.XmlElement = (XmlElement)this.strip.xml.ImportNode((XmlNode)xmlQuickLink.XmlElement, true); } else { base.InsertItem(index, item); } }
private void OnDrag(object sender, BeginDragEventArgs e) { OemQuickLink link = new OemQuickLink(this.OemEntryPoint.Manager); link.BeginInit(); link.Application = this.OemEntryPoint.Application; link.EntryPoint = this.OemEntryPoint; link.EndInit(); IDataObject dataObject = Advent.Common.Interop.DataObject.CreateDataObject(); VmcStudioUtil.DragDropObject = new QuickLinkDrag(link); try { dataObject.DoDragDrop(this, e.DragPoint, DragDropEffects.Move); } finally { VmcStudioUtil.DragDropObject = null; } }
public List <OemQuickLink> GetPartnerQuickLinks() { List <OemQuickLink> list = new List <OemQuickLink>(); foreach (IQuickLink quickLink in (Collection <IQuickLink>) this) { IPartnerQuickLink partnerQuickLink = quickLink as IPartnerQuickLink; if (partnerQuickLink != null && partnerQuickLink.OemQuickLink != null) { OemQuickLink oemQuickLink = partnerQuickLink.OemQuickLink; if (oemQuickLink != null) { list.Add(oemQuickLink); } } } return(list); }
private void NewApplicationExecuted(object sender, ExecutedRoutedEventArgs e) { OemManager oemManager = this.m_startMenu.StartMenuManager.OemManager; Advent.MediaCenter.StartMenu.OEM.EntryPoint ep = new Advent.MediaCenter.StartMenu.OEM.EntryPoint(); ep.Manager = oemManager; ep.ID = "{" + Guid.NewGuid() + "}"; ep.Title = "New Entry Point"; ep.RawImageUrl = string.Empty; ep.AddIn = typeof(VmcExecuteAddIn).AssemblyQualifiedName; bool isSaved = false; OemCategory category = oemManager.Categories["More Programs"]; ep.Saving += delegate { if (!isSaved) { Advent.MediaCenter.StartMenu.OEM.Application application = new Advent.MediaCenter.StartMenu.OEM.Application(); application.ID = "{" + Guid.NewGuid() + "}"; application.Title = ep.Title; oemManager.Applications.Add(application); ep.Application = application; oemManager.EntryPoints.Add(ep); OemQuickLink oemQuickLink = new OemQuickLink(oemManager); oemQuickLink.BeginInit(); oemQuickLink.Application = application; oemQuickLink.EntryPoint = ep; oemQuickLink.EndInit(); category.QuickLinks.Add(oemQuickLink); } }; ep.Saved += delegate { if (!isSaved) { category.Save(); } isSaved = true; }; EntryPointDocumentView.OpenDocument(ep); e.Handled = true; }
protected override void Load() { base.Load(); this.launchElement = (XmlElement)Enumerable.First<XmlElement>(Enumerable.OfType<XmlElement>((IEnumerable)this.LinkElement.ChildNodes), (Func<XmlElement, bool>)(o => o.Name == "Command")).FirstChild; string attribute1 = this.launchElement.GetAttribute("AppId"); string attribute2 = this.launchElement.GetAttribute("EntryPointId"); if (string.IsNullOrEmpty(attribute2)) return; EntryPoint entryPoint = this.Manager.OemManager.EntryPoints[attribute2]; if (entryPoint != null) { OemQuickLink oemQuickLink = new OemQuickLink(this.Manager.OemManager); oemQuickLink.BeginInit(); oemQuickLink.ApplicationID = attribute1; oemQuickLink.EntryPoint = entryPoint; oemQuickLink.EndInit(); this.OemQuickLink = oemQuickLink; } else Trace.TraceWarning("Entry point " + attribute2 + " not found."); }
protected override IPartnerQuickLink GetFreePartnerQuickLink(OemQuickLink oemLink) { IPartnerQuickLink partnerQuickLink = base.GetFreePartnerQuickLink(oemLink); if (partnerQuickLink == null) { XmlElement element = this.MenuStripDocument.CreateElement("home", "DefaultPartnerQuicklink", this.MenuStripDocument.DocumentElement.GetAttribute("xmlns:home")); element.SetAttribute("ExtensibilityCategory", string.Format("{0}\\Category {{{1}}}", (object)this.Manager.CustomInternalCategory, (object)Guid.NewGuid())); int num = 100; element.SetAttribute("Priority", num.ToString()); partnerQuickLink = (IPartnerQuickLink) new FijiPartnerQuickLink(this.Manager, element, true); partnerQuickLink.BeginInit(); partnerQuickLink.Priority = num; XmlMenuStrip.XmlQuickLinkCollection quickLinkCollection = (XmlMenuStrip.XmlQuickLinkCollection) this.QuickLinks; quickLinkCollection.BeginInit(); quickLinkCollection.Add((IQuickLink)partnerQuickLink); quickLinkCollection.EndInit(); partnerQuickLink.EndInit(); } return(partnerQuickLink); }
protected override IPartnerQuickLink GetFreePartnerQuickLink(OemQuickLink oemLink) { IPartnerQuickLink partnerQuickLink = base.GetFreePartnerQuickLink(oemLink); if (partnerQuickLink == null) { string attribute1 = this.MenuStripDocument.DocumentElement.GetAttribute("xmlns"); string attribute2 = this.MenuStripDocument.DocumentElement.GetAttribute("xmlns:home"); XmlElement element1 = this.MenuStripDocument.CreateElement("home", "CommandQuickLink", attribute2); element1.SetAttribute("SqmTrackingId", "-1"); element1.SetAttribute("ViewTemplate", "@res://Microsoft.MediaCenter.Shell!StartMenuQuickLink.mcml#PartnerQuickLinkContent"); XmlElement element2 = this.MenuStripDocument.CreateElement("Image", attribute1); element1.AppendChild((XmlNode)element2); XmlElement element3 = this.MenuStripDocument.CreateElement("shll", "ImageSet", this.MenuStripDocument.DocumentElement.GetAttribute("xmlns:shll")); element3.SetAttribute("DefaultImageName", "Default"); element2.AppendChild((XmlNode)element3); XmlElement element4 = this.MenuStripDocument.CreateElement("Values", attribute1); element3.AppendChild((XmlNode)element4); XmlElement element5 = this.MenuStripDocument.CreateElement("Image", attribute1); element5.SetAttribute("Name", "Default"); element4.AppendChild((XmlNode)element5); XmlElement element6 = this.MenuStripDocument.CreateElement("Image", attribute1); element6.SetAttribute("Name", "Focus"); element4.AppendChild((XmlNode)element6); XmlElement element7 = this.MenuStripDocument.CreateElement("Command", attribute1); element1.AppendChild((XmlNode)element7); XmlElement element8 = this.MenuStripDocument.CreateElement("home", "LaunchExtensibilityEntryPointCommand", attribute2); element7.AppendChild((XmlNode)element8); partnerQuickLink = (IPartnerQuickLink) new Windows7PartnerQuickLink(this.Manager, element1); partnerQuickLink.BeginInit(); partnerQuickLink.Priority = int.MaxValue; XmlMenuStrip.XmlQuickLinkCollection quickLinkCollection = (XmlMenuStrip.XmlQuickLinkCollection) this.QuickLinks; quickLinkCollection.BeginInit(); quickLinkCollection.Add((IQuickLink)partnerQuickLink); quickLinkCollection.EndInit(); partnerQuickLink.EndInit(); } return(partnerQuickLink); }
public bool CanAddQuickLink(IQuickLink link) { OemQuickLink link1 = link as OemQuickLink; if (link1 == null) { IPartnerQuickLink partnerQuickLink = link as IPartnerQuickLink; if (partnerQuickLink != null) { link1 = partnerQuickLink.OemQuickLink; } } if (link1 != null) { if (!this.quickLinks.GetPartnerQuickLinks().Contains(link1)) { return(this.GetFreePartnerQuickLink(link1) != null); } else { return(true); } } else { if (!(link is XmlQuickLink)) { return(false); } if (link.OriginalStrip != null && link.OriginalStrip != this) { return(this.Manager.Strips.IndexOf((IMenuStrip)this) > this.Manager.Strips.IndexOf(link.OriginalStrip)); } else { return(true); } } }
protected override void InsertItem(int index, IQuickLink item) { if (this.Count == 0) { if (!(item is PartnerQuickLink)) throw new ArgumentException(); this.singleLink = (PartnerQuickLink)item; base.InsertItem(index, item); } else { OemQuickLink oemQuickLink = item as OemQuickLink; if (oemQuickLink == null) { PartnerQuickLink partnerQuickLink = item as PartnerQuickLink; if (partnerQuickLink != null) oemQuickLink = partnerQuickLink.OemQuickLink; } if (oemQuickLink == null) return; this.singleLink.OemQuickLink = oemQuickLink; } }
protected override IPartnerQuickLink GetFreePartnerQuickLink(OemQuickLink oemLink) { IPartnerQuickLink partnerQuickLink = base.GetFreePartnerQuickLink(oemLink); if (partnerQuickLink == null) { XmlElement element = this.MenuStripDocument.CreateElement("home", "DefaultPartnerQuicklink", this.MenuStripDocument.DocumentElement.GetAttribute("xmlns:home")); element.SetAttribute("ExtensibilityCategory", string.Format("{0}\\Category {{{1}}}", (object)this.Manager.CustomInternalCategory, (object)Guid.NewGuid())); int num = 100; element.SetAttribute("Priority", num.ToString()); partnerQuickLink = (IPartnerQuickLink)new FijiPartnerQuickLink(this.Manager, element, true); partnerQuickLink.BeginInit(); partnerQuickLink.Priority = num; XmlMenuStrip.XmlQuickLinkCollection quickLinkCollection = (XmlMenuStrip.XmlQuickLinkCollection)this.QuickLinks; quickLinkCollection.BeginInit(); quickLinkCollection.Add((IQuickLink)partnerQuickLink); quickLinkCollection.EndInit(); partnerQuickLink.EndInit(); } return partnerQuickLink; }
protected virtual IPartnerQuickLink GetFreePartnerQuickLink(OemQuickLink link) { return(this.quickLinks.GetFreePartnerQuickLink()); }
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; }
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; }
protected virtual void OnQuickLinkChanged(OemQuickLink oldValue, OemQuickLink newValue) { }
protected override IPartnerQuickLink GetFreePartnerQuickLink(OemQuickLink oemLink) { IPartnerQuickLink partnerQuickLink = base.GetFreePartnerQuickLink(oemLink); if (partnerQuickLink == null) { string attribute1 = this.MenuStripDocument.DocumentElement.GetAttribute("xmlns"); string attribute2 = this.MenuStripDocument.DocumentElement.GetAttribute("xmlns:home"); XmlElement element1 = this.MenuStripDocument.CreateElement("home", "CommandQuickLink", attribute2); element1.SetAttribute("SqmTrackingId", "-1"); element1.SetAttribute("ViewTemplate", "@res://Microsoft.MediaCenter.Shell!StartMenuQuickLink.mcml#PartnerQuickLinkContent"); XmlElement element2 = this.MenuStripDocument.CreateElement("Image", attribute1); element1.AppendChild((XmlNode)element2); XmlElement element3 = this.MenuStripDocument.CreateElement("shll", "ImageSet", this.MenuStripDocument.DocumentElement.GetAttribute("xmlns:shll")); element3.SetAttribute("DefaultImageName", "Default"); element2.AppendChild((XmlNode)element3); XmlElement element4 = this.MenuStripDocument.CreateElement("Values", attribute1); element3.AppendChild((XmlNode)element4); XmlElement element5 = this.MenuStripDocument.CreateElement("Image", attribute1); element5.SetAttribute("Name", "Default"); element4.AppendChild((XmlNode)element5); XmlElement element6 = this.MenuStripDocument.CreateElement("Image", attribute1); element6.SetAttribute("Name", "Focus"); element4.AppendChild((XmlNode)element6); XmlElement element7 = this.MenuStripDocument.CreateElement("Command", attribute1); element1.AppendChild((XmlNode)element7); XmlElement element8 = this.MenuStripDocument.CreateElement("home", "LaunchExtensibilityEntryPointCommand", attribute2); element7.AppendChild((XmlNode)element8); partnerQuickLink = (IPartnerQuickLink)new Windows7PartnerQuickLink(this.Manager, element1); partnerQuickLink.BeginInit(); partnerQuickLink.Priority = int.MaxValue; XmlMenuStrip.XmlQuickLinkCollection quickLinkCollection = (XmlMenuStrip.XmlQuickLinkCollection)this.QuickLinks; quickLinkCollection.BeginInit(); quickLinkCollection.Add((IQuickLink)partnerQuickLink); quickLinkCollection.EndInit(); partnerQuickLink.EndInit(); } return partnerQuickLink; }