From 49190e4224e69484ceea46a4fa70e49900a5348c Mon Sep 17 00:00:00 2001 From: "swain.liu" Date: Sun, 25 May 2025 23:01:35 +0800 Subject: [PATCH 1/2] Update the theme mode, remove images and converters Add the `ThemeMode="System"` attribute in `App.xaml` and simplify the resource definition. Delete the `BooleanToImageConverter.cs` file and its content. Remove the `completed.png` and `incomplete.png` image files. Replace the image display logic with a `TextBlock` in `MainWindow.xaml`, and update the `TextBox` of `NewTodoItemTitle` to support instant updates. Remove the references to the deleted images in the project file while keeping other settings unchanged. --- samples/todoapp/TodoApp.WPF/App.xaml | 6 ++-- .../Converters/BooleanToImageConverter.cs | 32 ------------------ .../todoapp/TodoApp.WPF/Images/completed.png | Bin 1102 -> 0 bytes .../todoapp/TodoApp.WPF/Images/incomplete.png | Bin 297 -> 0 bytes samples/todoapp/TodoApp.WPF/MainWindow.xaml | 21 ++++++------ .../todoapp/TodoApp.WPF/TodoApp.WPF.csproj | 10 ------ 6 files changed, 13 insertions(+), 56 deletions(-) delete mode 100644 samples/todoapp/TodoApp.WPF/Converters/BooleanToImageConverter.cs delete mode 100644 samples/todoapp/TodoApp.WPF/Images/completed.png delete mode 100644 samples/todoapp/TodoApp.WPF/Images/incomplete.png diff --git a/samples/todoapp/TodoApp.WPF/App.xaml b/samples/todoapp/TodoApp.WPF/App.xaml index 1acf29e3..bda5cc8d 100644 --- a/samples/todoapp/TodoApp.WPF/App.xaml +++ b/samples/todoapp/TodoApp.WPF/App.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:TodoApp.WPF" - StartupUri="MainWindow.xaml"> - - + StartupUri="MainWindow.xaml" + ThemeMode="System"> + diff --git a/samples/todoapp/TodoApp.WPF/Converters/BooleanToImageConverter.cs b/samples/todoapp/TodoApp.WPF/Converters/BooleanToImageConverter.cs deleted file mode 100644 index 3931eaf3..00000000 --- a/samples/todoapp/TodoApp.WPF/Converters/BooleanToImageConverter.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Globalization; -using System.Windows.Data; -using System.Windows.Media.Imaging; - -namespace TodoApp.WPF.Converters; - -/// -/// A converter to convert the boolean for IsComplete into one of two images. -/// -public class BooleanToImageConverter : IValueConverter -{ - private const string baseUri = "pack://application:,,,/Images"; - - public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value is bool booleanValue) - { - return new BitmapImage(new Uri(booleanValue ? $"{baseUri}/completed.png" : $"{baseUri}/incomplete.png")); - } - - return null; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } -} diff --git a/samples/todoapp/TodoApp.WPF/Images/completed.png b/samples/todoapp/TodoApp.WPF/Images/completed.png deleted file mode 100644 index 8ac0e7f1a52185ce9b9c909c958f3ceeed3f4413..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1102 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCmUKs7M+SzC{oH>NS%G|oWRD45dJguM!v-tY$DUh!@P+6=(yLU`z6LcLCBs@Y8vBJ&@uo z@Q5sCVBk9f!i-b3`J@>bn6*7!978hhy`6d6FW6C}&0cW}o7CFQ2_}JhwTygU4@~t} zsAUtF=WxX%XG*q?9gB-V4Ric~!>v_|S(=Vz^ty2-tS~>?JyW*)+Puu~^K4VI-^}+> zm>c>3*Y!7+>l*cT{n%f4NZ6m>fGg%|y*|V92FBR`!aq3nu*Na?H$HbTe$A)B$bEqQ zfktBG`dsfw4tr)D#&*6#sg_q_jy@KOXWUmIpywT1T+Xw1*YX^uZw;vlQWDH;jdrnY zjfJt>7u~*9k#%c&_#7599X@-;%?|ZU`|1+7Zfq&Y%b0(!>R;zUPv#lV&wD*?vPqO=X z$n!bXby{WJ^y_JFdLgj?@Ub>+m*+=i{?(xI3B04D`Z(@ zZdB*}t9I{N>&`PqI~{h4xg>YRQZ>iscH&3Jm2I!qckhy2yH@vD>qEJdW}4w2jT#se z;;-}{Q{1oFGtF2){=viyWAWn$lM_wmPONBHb}$MVM>8i`zorvG3nP}q?qtLoFfbEVkZXx4{XazQfB6sqRjbBR4LnPs9|job~f zn(vbZX6Tu`yOGOTA=^Vsm@?Bnz9+;v)e({qy;YwqUUhcVaf_AU~ix_U~nlE&{9)^B)T*_bS; zwpjjOfAJ>i)h^{XKFo;!a`UsAPmbS4IOzQZLBO-2`TaTXJ96V>! z;@n`{Pd{tYWEFp%iMsHWeMS1U@&m?Kj9+{IYf8TcOvu+iO3yVh*KSUO_QmvAUQh^kMk%5tcu7QQFfpLhDk(IHfm65Twfq|8Q!S28BJWw>`=BH$)RpQog zYC+f+paw~h4Z-BuF?hQAxvXPx#<4Ht8R5(wqlQB|4K@5h!KSKo!o&e6FQd`mJ1w4e64Hb=*hu{LxP*H=PLr(w$ zHZqB`PoIFuFmIOaHko|+H=AD^o|e!M)B|ci=?%mrhgsn;?3D6R@ zIMMkpvrrQFg@neSo4^|xD@ts7C`P3 vGKZM`jptaTV)$9ByfsFKnRa%dlAXT*)faV<#&%Hq00000NkvXXu0mjf^V@n- diff --git a/samples/todoapp/TodoApp.WPF/MainWindow.xaml b/samples/todoapp/TodoApp.WPF/MainWindow.xaml index 4e006553..7445fc1f 100644 --- a/samples/todoapp/TodoApp.WPF/MainWindow.xaml +++ b/samples/todoapp/TodoApp.WPF/MainWindow.xaml @@ -4,15 +4,15 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:TodoApp.WPF" - xmlns:conv="clr-namespace:TodoApp.WPF.Converters" mc:Ignorable="d" Title="MainWindow" Height="420" Width="800" ResizeMode="CanMinimize"> - - - + + + + @@ -23,7 +23,7 @@ @@ -42,27 +42,26 @@ - - - +