Example #1
0
            public ViewModel(ICupSupportedObject cupObject)
            {
                CupObject = cupObject;

                var manager = (cupObject as AcObjectNew)?.GetManager();

                DisplayAlternativeIds = cupObject.CupUpdateInformation?.AlternativeIds?.Select(x => manager?.GetObjectById(x ?? "")?.DisplayName ?? x)
                                        .JoinToReadableString();
            }
Example #2
0
        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
                };
            }
        }
Example #3
0
        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)));
        }
Example #4
0
 public static void SetCupUpdate(DependencyObject obj, ICupSupportedObject value)
 {
     obj.SetValue(CupUpdateProperty, value);
 }
Example #5
0
 public static ContextMenu GetCupUpdateMenu([CanBeNull] FrameworkElement element, [NotNull] ICupSupportedObject obj)
 {
     return(CreateContextMenu(element, menu => ContextMenusProvider?.SetCupUpdateMenu(menu, obj)));
 }
Example #6
0
 public static void SetObject(DependencyObject obj, ICupSupportedObject value)
 {
     obj.SetValue(ObjectProperty, value);
 }