public ViewModel(ICupSupportedObject cupObject) { CupObject = cupObject; var manager = (cupObject as AcObjectNew)?.GetManager(); DisplayAlternativeIds = cupObject.CupUpdateInformation?.AlternativeIds?.Select(x => manager?.GetObjectById(x ?? "")?.DisplayName ?? x) .JoinToReadableString(); }
public CupInformationDialog(ICupSupportedObject obj) { InitializeComponent(); DataContext = new ViewModel(obj); var client = CupClient.Instance; if (client != null) { Buttons = new[] { CreateCloseDialogButton("Update", true, false, MessageBoxResult.OK, new AsyncCommand(() => client.InstallUpdateAsync(obj.CupContentType, obj.Id))), CreateCloseDialogButton("Report update as broken", false, true, MessageBoxResult.No, new AsyncCommand(() => client.ReportUpdateAsync(obj.CupContentType, obj.Id))), CloseButton }; } }
public void SetCupUpdateMenu(ContextMenu menu, ICupSupportedObject obj) { var client = CupClient.Instance; var information = obj.CupUpdateInformation; if (client == null || information == null) { return; } if (information.IsToUpdateManually) { menu.AddItem("Download and install update", new AsyncCommand(() => client.InstallUpdateAsync(obj.CupContentType, obj.Id)), iconData: (Geometry)Icons["UpdateIconData"]); menu.AddItem("Download update", new AsyncCommand(async() => { WindowsHelper.ViewInBrowser(await client.GetUpdateUrlAsync(obj.CupContentType, obj.Id)); })); menu.AddSeparator(); } else { menu.AddItem("Get update", new AsyncCommand(async() => { WindowsHelper.ViewInBrowser(await client.GetUpdateUrlAsync(obj.CupContentType, obj.Id) ?? obj.CupUpdateInformation?.InformationUrl); })); menu.AddSeparator(); } menu.AddItem("View information", () => new CupInformationDialog(obj).ShowDialog()); if (!string.IsNullOrWhiteSpace(information.InformationUrl)) { menu.AddItem("Open information page", () => { WindowsHelper.ViewInBrowser(information.InformationUrl); }); } menu.AddSeparator() .AddItem("Ignore update", () => client.IgnoreUpdate(obj.CupContentType, obj.Id)) .AddItem("Ignore all updates", () => client.IgnoreAllUpdates(obj.CupContentType, obj.Id)) .AddItem("Report update as broken", new AsyncCommand(() => client.ReportUpdateAsync(obj.CupContentType, obj.Id))); }
public static void SetCupUpdate(DependencyObject obj, ICupSupportedObject value) { obj.SetValue(CupUpdateProperty, value); }
public static ContextMenu GetCupUpdateMenu([CanBeNull] FrameworkElement element, [NotNull] ICupSupportedObject obj) { return(CreateContextMenu(element, menu => ContextMenusProvider?.SetCupUpdateMenu(menu, obj))); }
public static void SetObject(DependencyObject obj, ICupSupportedObject value) { obj.SetValue(ObjectProperty, value); }