From 0cdc4d1dd5bd95283bfa93b83ca4d2cbd75ed809 Mon Sep 17 00:00:00 2001 From: Ashok Gelal Date: Thu, 16 Mar 2017 16:49:25 -0600 Subject: [PATCH] Can add/override a custom resource for a window. Also updated sample app to show how. --- src/Magpie/Magpie.Example/MainWindow.xaml.cs | 18 ++++++- src/Magpie/Magpie/Views/MainWindow.xaml | 3 +- src/Magpie/Magpie/Views/MainWindow.xaml.cs | 53 +++++++++++++------- 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/src/Magpie/Magpie.Example/MainWindow.xaml.cs b/src/Magpie/Magpie.Example/MainWindow.xaml.cs index 7cb057d..8406b1e 100644 --- a/src/Magpie/Magpie.Example/MainWindow.xaml.cs +++ b/src/Magpie/Magpie.Example/MainWindow.xaml.cs @@ -1,6 +1,8 @@ using System.Reflection; using System.Windows; +using MagpieUpdater.Interfaces; using MagpieUpdater.Services; +using MagpieUpdater.Views; namespace MagpieExample { @@ -24,7 +26,7 @@ public MainWindow() InitializeComponent(); CurrentVersion.Content = "Current version: " + Assembly.GetEntryAssembly().GetName().Version; SelectedChannel = 1; - _magpie = new Magpie(MakeAppInfo(SelectedChannel)); + _magpie = new ExampleMagpie(MakeAppInfo(SelectedChannel)); _magpie.CheckInBackground(); } @@ -64,4 +66,18 @@ private void DailyBuildChannel_OnClick(object sender, RoutedEventArgs e) _magpie.SwitchSubscribedChannel(SelectedChannel); } } + + public class ExampleMagpie : Magpie + { + public ExampleMagpie(AppInfo appInfo, IDebuggingInfoLogger debuggingInfoLogger = null, IAnalyticsLogger analyticsLogger = null) + : base(appInfo, debuggingInfoLogger, analyticsLogger) + { + } + + protected override void SetOwner(Window window) + { + base.SetOwner(window); + window.AddCustomResource("_downloadNow", "What?"); + } + } } \ No newline at end of file diff --git a/src/Magpie/Magpie/Views/MainWindow.xaml b/src/Magpie/Magpie/Views/MainWindow.xaml index b420dad..455e195 100644 --- a/src/Magpie/Magpie/Views/MainWindow.xaml +++ b/src/Magpie/Magpie/Views/MainWindow.xaml @@ -99,7 +99,8 @@ Margin="10" HorizontalAlignment="Stretch" LastChildFill="False"> -