├── .gitattributes ├── .gitignore ├── README-en.md ├── README.md ├── Resources ├── AlertDemo.png ├── ButtonsDemo.gif ├── CheckBoxDemo.png ├── ComboBoxDemo.png ├── ContextMenuDemo.png ├── FieldDemo.png ├── HelloWeUiSharp.png ├── IconButtonDemo.gif ├── Localization.png ├── MessageBoxDemo.png ├── Overview.png ├── PathButtonDemo.gif ├── ToastDemo.png ├── ToggleButtonDemo.gif ├── WeChatLoginDemo.png ├── WeUiSharp.ico ├── WeUiSharpLogo.png ├── WeUiSharpLogo.psd └── 公众号.jpg └── Src ├── WeUiSharp.Demo ├── App.xaml ├── App.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ ├── Settings.settings │ ├── Strings.Designer.cs │ ├── Strings.en.Designer.cs │ ├── Strings.en.resx │ ├── Strings.resx │ ├── Strings.zh-CN.Designer.cs │ ├── Strings.zh-CN.resx │ ├── Strings.zh-Hant.Designer.cs │ └── Strings.zh-Hant.resx ├── Resources │ ├── Chat.png │ ├── Chat_MouseOver.png │ ├── Chat_Pressed.png │ ├── Overview.png │ ├── WeUiSharp.ico │ ├── WeUiSharp.png │ └── 公众号.jpg ├── Utilities │ └── RegionNames.cs ├── ViewModels │ ├── DemoItemListViewModel.cs │ ├── DemoItemViewModel.cs │ ├── MainWindowViewModel.cs │ ├── MyCustomDetailViewModel.cs │ ├── MyCustomListViewModel.cs │ ├── OverviewViewModel.cs │ ├── SettingsWindowViewModel.cs │ ├── WeChatLoginViewModel.cs │ ├── WeChatLoginWindowViewModel.cs │ └── YourCustomViewModel.cs ├── Views │ ├── DemoItemListView.xaml │ ├── DemoItemListView.xaml.cs │ ├── DemoItemView.xaml │ ├── DemoItemView.xaml.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── MyCustomDetailView.xaml │ ├── MyCustomDetailView.xaml.cs │ ├── MyCustomListView.xaml │ ├── MyCustomListView.xaml.cs │ ├── OverviewView.xaml │ ├── OverviewView.xaml.cs │ ├── SettingsWindow.xaml │ ├── SettingsWindow.xaml.cs │ ├── WeChatLoginView.xaml │ ├── WeChatLoginView.xaml.cs │ ├── WeChatLoginWindow.xaml │ ├── WeChatLoginWindow.xaml.cs │ ├── YourCustomView.xaml │ └── YourCustomView.xaml.cs ├── WeUiSharp.Demo.csproj └── WeUiSharp.ico ├── WeUiSharp.HelloWorld ├── App.config ├── App.xaml ├── App.xaml.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── WeUiSharp.HelloWorld.csproj └── packages.config ├── WeUiSharp.HelloWorldWithPrism ├── App.xaml ├── App.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── ViewModels │ └── MainWindowViewModel.cs ├── Views │ ├── MainWindow.xaml │ └── MainWindow.xaml.cs └── WeUiSharp.HelloWorldWithPrism.csproj ├── WeUiSharp.sln └── WeUiSharp ├── .editorconfig ├── Common └── TypedEventHandler.cs ├── Controls ├── AddButton.xaml ├── AddButton.xaml.cs ├── Badge.cs ├── Button.cs ├── ClippingBorder.cs ├── ComboBox.cs ├── Field.cs ├── HamburgerMenuItemBase.cs ├── IconButton.cs ├── MenuItemSeparator.cs ├── MessageBox.xaml ├── MessageBox.xaml.cs ├── PathButton.cs ├── Primitives │ ├── ControlHelper.cs │ └── DelegateHelper.cs ├── SearchBar.xaml ├── SearchBar.xaml.cs ├── TabControl.cs ├── Toast.xaml ├── Toast.xaml.cs └── WheelSpeedScrollViewer.cs ├── ControlsResources.xaml ├── Converters ├── EqualToVisibilityConverter.cs ├── InverseBooleanConverter.cs └── InvertBoolToVisibilityConverter.cs ├── DesignTime ├── Design.cs ├── DesignTimeResources.xaml ├── IntellisenseResources.cs ├── IntellisenseResourcesBase.cs ├── ResourceKeys.xaml └── SystemColors.xaml ├── Enums ├── ButtonGreenType.cs ├── MessageBoxButton.cs └── MessageBoxResult.cs ├── Helpers ├── ColorsHelper.cs ├── DesignMode.cs ├── MergedDictionariesHelper.cs ├── PackUriHelper.cs └── ThemeResourceHelper.cs ├── Interfaces ├── ICloseWindow.cs └── ISortedView.cs ├── Localization ├── Translation.cs └── TranslationSource.cs ├── Markup ├── DynamicColorExtension.cs ├── KeyTimeExtension.cs ├── LocExtension.cs ├── StaticColorExtension.cs ├── StaticResourceExtension.cs └── ThemeResourceExtension.cs ├── Models └── ContextMenuCommandItem.cs ├── Properties ├── AssemblyInfo-DESKTOP-SJ8KJP4.cs ├── AssemblyInfo.cs ├── Settings.Designer.cs ├── Settings.settings ├── Strings.Designer.cs ├── Strings.en.Designer.cs ├── Strings.en.resx ├── Strings.resx ├── Strings.zh-CN.Designer.cs ├── Strings.zh-CN.resx ├── Strings.zh-Hant.Designer.cs └── Strings.zh-Hant.resx ├── ResourceDictionaryEx.cs ├── Resources ├── Geometries.xaml ├── Icons │ ├── Plugin.png │ ├── Plugin_Checked.png │ └── Plugin_MouseOver.png ├── WeUiSharp.ico └── WeUiSharp.png ├── Styles ├── BadgeStyle.xaml ├── ButtonBaseStyle.xaml ├── ButtonStyle.xaml ├── CheckBoxStyle.xaml ├── ClippingBorder.xaml ├── ComboBoxStyle.xaml ├── ContextMenuStyle.xaml ├── DocumentBaseStyle.xaml ├── FieldStyle.xaml ├── HamburgerMenuItemBaseStyle.xaml ├── IconButtonStyle.xaml ├── MenuItemSeparatorStyle.xaml ├── MenuItemStyle.xaml ├── MessageBox.xaml ├── MoreStyle.xaml ├── PathButtonStyle.xaml ├── ScrollBarStyle.xaml ├── TabControlStyle.xaml ├── ToggleButtonStyle.xaml └── WindowStyle.xaml ├── ThemeDictionary.cs ├── ThemeManager.cs ├── ThemeResources.cs ├── ThemeResources ├── Dark.xaml └── Light.xaml ├── Themes └── Generic.xaml ├── Utilities ├── PopupEx.cs ├── ScrollBarEx.cs ├── StackPanelRegionAdapter.cs └── WindowCloser.cs ├── WeUiSharp.csproj ├── WeUiSharp.ico ├── WeUiSharp.nuspec ├── WeUiSharp.png ├── Windows ├── AlertWindow.xaml ├── AlertWindow.xaml.cs ├── DocumentBase.cs ├── MessageBox.cs ├── MessageBoxWrapper.xaml ├── MessageBoxWrapper.xaml.cs └── Window.cs ├── app.config └── packages.config /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /Resources/AlertDemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/AlertDemo.png -------------------------------------------------------------------------------- /Resources/ButtonsDemo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/ButtonsDemo.gif -------------------------------------------------------------------------------- /Resources/CheckBoxDemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/CheckBoxDemo.png -------------------------------------------------------------------------------- /Resources/ComboBoxDemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/ComboBoxDemo.png -------------------------------------------------------------------------------- /Resources/ContextMenuDemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/ContextMenuDemo.png -------------------------------------------------------------------------------- /Resources/FieldDemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/FieldDemo.png -------------------------------------------------------------------------------- /Resources/HelloWeUiSharp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/HelloWeUiSharp.png -------------------------------------------------------------------------------- /Resources/IconButtonDemo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/IconButtonDemo.gif -------------------------------------------------------------------------------- /Resources/Localization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/Localization.png -------------------------------------------------------------------------------- /Resources/MessageBoxDemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/MessageBoxDemo.png -------------------------------------------------------------------------------- /Resources/Overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/Overview.png -------------------------------------------------------------------------------- /Resources/PathButtonDemo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/PathButtonDemo.gif -------------------------------------------------------------------------------- /Resources/ToastDemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/ToastDemo.png -------------------------------------------------------------------------------- /Resources/ToggleButtonDemo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/ToggleButtonDemo.gif -------------------------------------------------------------------------------- /Resources/WeChatLoginDemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/WeChatLoginDemo.png -------------------------------------------------------------------------------- /Resources/WeUiSharp.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/WeUiSharp.ico -------------------------------------------------------------------------------- /Resources/WeUiSharpLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/WeUiSharpLogo.png -------------------------------------------------------------------------------- /Resources/WeUiSharpLogo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/WeUiSharpLogo.psd -------------------------------------------------------------------------------- /Resources/公众号.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Resources/公众号.jpg -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using WeUiSharp.Demo.Views; 2 | using Prism.Ioc; 3 | using Prism.Modularity; 4 | using System.Windows; 5 | using Prism.Regions; 6 | using WeUiSharp.Demo.Utilities; 7 | using WeUiSharp.Demo.ViewModels; 8 | using WeUiSharp.Localization; 9 | 10 | namespace WeUiSharp.Demo 11 | { 12 | /// 13 | /// Interaction logic for App.xaml 14 | /// 15 | public partial class App 16 | { 17 | protected override Window CreateShell() 18 | { 19 | 20 | var ttt = SystemColors.GrayTextBrush.Color; // #FF6D6D6D 21 | return Container.Resolve(); 22 | } 23 | 24 | protected override void RegisterTypes(IContainerRegistry containerRegistry) 25 | { 26 | 27 | } 28 | protected override void Initialize() 29 | { 30 | base.Initialize(); 31 | 32 | // --------------------------- 确定默认语言 --------------------------------------- 33 | string cultureName = System.Globalization.CultureInfo.CurrentCulture.Name; 34 | 35 | // zh-CN 0x0804 中文(中国) zh-Hans 0x0004 中文(简体) zh-SG 0x1004 中文(新加坡) 36 | if (cultureName.Equals("zh-CN") || cultureName.Equals("zh-Hans") || cultureName.Equals("zh-SG")) 37 | { 38 | TranslationSource.Instance.Language = "zh-CN"; 39 | } 40 | // zh-Hant 中文(繁体) zh-TW 中文(台湾)zh-HK 中文(香港特别行政区,中国)zh-MO 中文(澳门特别行政区) 41 | else if (cultureName.Equals("zh-Hant") || cultureName.Equals("zh-TW") || cultureName.Equals("zh-MO")) 42 | { 43 | TranslationSource.Instance.Language = "zh-Hant"; 44 | } 45 | else 46 | { 47 | // 非中文系统全部按英文系统处理 48 | TranslationSource.Instance.Language = "en"; 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("WeUiSharp.Demo")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("WeUiSharp.Demo")] 15 | [assembly: AssemblyCopyright("Copyright © 2017")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WeUiSharp.Demo.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WeUiSharp.Demo.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WeUiSharp.Demo.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Properties/Strings.en.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp.Demo/Properties/Strings.en.Designer.cs -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Properties/Strings.zh-CN.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp.Demo/Properties/Strings.zh-CN.Designer.cs -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Properties/Strings.zh-Hant.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp.Demo/Properties/Strings.zh-Hant.Designer.cs -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Resources/Chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp.Demo/Resources/Chat.png -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Resources/Chat_MouseOver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp.Demo/Resources/Chat_MouseOver.png -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Resources/Chat_Pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp.Demo/Resources/Chat_Pressed.png -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Resources/Overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp.Demo/Resources/Overview.png -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Resources/WeUiSharp.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp.Demo/Resources/WeUiSharp.ico -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Resources/WeUiSharp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp.Demo/Resources/WeUiSharp.png -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Resources/公众号.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp.Demo/Resources/公众号.jpg -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Utilities/RegionNames.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace WeUiSharp.Demo.Utilities 8 | { 9 | public class RegionNames 10 | { 11 | public static string ListRegion { get => "ListRegion"; } 12 | 13 | public static string DetailRegion { get => "DetailRegion"; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/ViewModels/DemoItemListViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism; 2 | using Prism.Commands; 3 | using Prism.Ioc; 4 | using Prism.Mvvm; 5 | using Prism.Regions; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Collections.ObjectModel; 9 | using System.Linq; 10 | using WeUiSharp.Demo.Utilities; 11 | using WeUiSharp.Demo.Views; 12 | 13 | namespace WeUiSharp.Demo.ViewModels 14 | { 15 | public class DemoItemListViewModel : BindableBase 16 | { 17 | #region [Fields] 18 | private ObservableCollection _DemoItems; 19 | private int _SelectedIndex; 20 | private IRegionManager _RegionManager; 21 | private IContainerProvider _ContainerProvider; 22 | #endregion 23 | 24 | #region [Properties] 25 | public ObservableCollection DemoItems 26 | { 27 | get 28 | { 29 | return _DemoItems; 30 | } 31 | set 32 | { 33 | SetProperty(ref _DemoItems, value); 34 | } 35 | } 36 | public int SelectedIndex 37 | { 38 | get 39 | { 40 | return _SelectedIndex; 41 | } 42 | set 43 | { 44 | SetProperty(ref _SelectedIndex, value); 45 | UpdateDetailView(); 46 | } 47 | } 48 | #endregion 49 | 50 | public DemoItemListViewModel(IRegionManager regionManager, IContainerProvider containerProvider) 51 | { 52 | _RegionManager = regionManager; 53 | _ContainerProvider = containerProvider; 54 | 55 | _DemoItems = new ObservableCollection(); 56 | _DemoItems.Add(new DemoItemViewModel() { Title = "Overview", Icon="../Resources/Overview.png" }); 57 | _DemoItems.Add(new DemoItemViewModel() { Title = "WeChatLogin", Icon = "../Resources/Overview.png" }); 58 | 59 | _SelectedIndex = 0; 60 | IRegion detailRegion = _RegionManager.Regions[RegionNames.DetailRegion]; 61 | OverviewView overviewView = _ContainerProvider.Resolve(); 62 | detailRegion.Add(overviewView, nameof(OverviewView)); 63 | detailRegion.Activate(overviewView); 64 | } 65 | 66 | public void UpdateDetailView() 67 | { 68 | IRegion detailRegion = _RegionManager.Regions[RegionNames.DetailRegion]; 69 | if (_SelectedIndex == 0) 70 | { 71 | var view = detailRegion.GetView(nameof(OverviewView)); 72 | if (view == null) 73 | { 74 | OverviewView newView = _ContainerProvider.Resolve(); 75 | detailRegion.Add(newView, nameof(OverviewView)); 76 | detailRegion.Activate(newView); 77 | } 78 | else 79 | { 80 | detailRegion.Activate(view); 81 | } 82 | } 83 | else if (_SelectedIndex == 1) 84 | { 85 | var view = detailRegion.GetView(nameof(WeChatLoginView)); 86 | if (view == null) 87 | { 88 | WeChatLoginView newView = _ContainerProvider.Resolve(); 89 | detailRegion.Add(newView, nameof(WeChatLoginView)); 90 | detailRegion.Activate(newView); 91 | } 92 | else 93 | { 94 | detailRegion.Activate(view); 95 | } 96 | } 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/ViewModels/DemoItemViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | using Prism.Mvvm; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace WeUiSharp.Demo.ViewModels 8 | { 9 | public class DemoItemViewModel : BindableBase 10 | { 11 | #region [Properties] 12 | public string Title { get; set; } 13 | public string Icon { get; set; } 14 | #endregion 15 | public DemoItemViewModel() 16 | { 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/ViewModels/MyCustomDetailViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | using Prism.Mvvm; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace WeUiSharp.Demo.ViewModels 8 | { 9 | public class MyCustomDetailViewModel : BindableBase 10 | { 11 | public MyCustomDetailViewModel() 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/ViewModels/MyCustomListViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | using Prism.Mvvm; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace WeUiSharp.Demo.ViewModels 8 | { 9 | public class MyCustomListViewModel : BindableBase 10 | { 11 | public MyCustomListViewModel() 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/ViewModels/OverviewViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | using Prism.Mvvm; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Windows.Controls; 7 | using System.Windows.Input; 8 | using WeUiSharp.Localization; 9 | using WeUiSharp.Models; 10 | using WeUiSharp.Windows; 11 | 12 | namespace WeUiSharp.Demo.ViewModels 13 | { 14 | public class OverviewViewModel : BindableBase 15 | { 16 | #region [Fields] 17 | private List _MenuItems; 18 | private ICommand _MenuItemCommand; 19 | private int _LanguageIndex; 20 | #endregion 21 | #region [Properties] 22 | public List MenuItems { get => _MenuItems; } 23 | 24 | public int LanguageIndex 25 | { 26 | get 27 | { 28 | return _LanguageIndex; 29 | } 30 | set 31 | { 32 | SetProperty(ref _LanguageIndex, value); 33 | if (value == 0) 34 | { 35 | TranslationSource.Instance.Language = "zh-CN"; 36 | } 37 | else if (value == 1) 38 | { 39 | TranslationSource.Instance.Language = "en"; 40 | } 41 | else if (value == 2) 42 | { 43 | TranslationSource.Instance.Language = "zh-Hant"; 44 | } 45 | } 46 | } 47 | #endregion 48 | 49 | public OverviewViewModel() 50 | { 51 | InitContextMenu(); 52 | InitLanguage(); 53 | } 54 | 55 | private void OnClickMenuItem(object obj) 56 | { 57 | if (obj is MenuItem menuItem) 58 | { 59 | MessageBox.Show("You clicked " + menuItem.Header, "ContextMenu"); 60 | } 61 | } 62 | 63 | private void InitContextMenu() 64 | { 65 | _MenuItemCommand = new DelegateCommand(OnClickMenuItem); 66 | _MenuItems = new List(); 67 | var menuItem1 = new MenuItem() 68 | { 69 | Header = "Item1", 70 | Command = _MenuItemCommand 71 | }; 72 | menuItem1.CommandParameter = menuItem1; 73 | var menuItem2 = new MenuItem() 74 | { 75 | Header = "Item2", 76 | Command = _MenuItemCommand 77 | }; 78 | menuItem2.CommandParameter = menuItem2; 79 | var menuItem3 = new MenuItem() 80 | { 81 | Header = "Item3", 82 | 83 | Command = _MenuItemCommand 84 | }; 85 | menuItem3.CommandParameter = menuItem3; 86 | var menuItem4 = new MenuItem() 87 | { 88 | Header = "Item4", 89 | IsEnabled = false, 90 | Command = _MenuItemCommand 91 | }; 92 | menuItem4.CommandParameter = menuItem4; 93 | _MenuItems.Add(menuItem1); 94 | _MenuItems.Add(menuItem2); 95 | _MenuItems.Add(null); // 分割线 MenuItemSeparator 96 | _MenuItems.Add(menuItem3); 97 | _MenuItems.Add(menuItem4); 98 | } 99 | 100 | private void InitLanguage() 101 | { 102 | if (TranslationSource.Instance.Language == "zh-CN") 103 | { 104 | _LanguageIndex = 0; 105 | } 106 | else if (TranslationSource.Instance.Language == "en") 107 | { 108 | _LanguageIndex = 1; 109 | } 110 | else if (TranslationSource.Instance.Language == "zh-Hant") 111 | { 112 | _LanguageIndex = 1; 113 | } 114 | else 115 | { 116 | _LanguageIndex = 0; 117 | } 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/ViewModels/SettingsWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | using Prism.Mvvm; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using WeUiSharp.Localization; 7 | 8 | namespace WeUiSharp.Demo.ViewModels 9 | { 10 | public class SettingsWindowViewModel : BindableBase 11 | { 12 | #region [Fields] 13 | private int _LanguageIndex; 14 | #endregion 15 | 16 | #region [Properties] 17 | public int LanguageIndex 18 | { 19 | get 20 | { 21 | return _LanguageIndex; 22 | } 23 | set 24 | { 25 | SetProperty(ref _LanguageIndex, value); 26 | if (value == 0) 27 | { 28 | TranslationSource.Instance.Language = "zh-CN"; 29 | } 30 | else if (value == 1) 31 | { 32 | TranslationSource.Instance.Language = "en"; 33 | } 34 | else if (value == 2) 35 | { 36 | TranslationSource.Instance.Language = "zh-Hant"; 37 | } 38 | } 39 | } 40 | #endregion 41 | public SettingsWindowViewModel() 42 | { 43 | InitLanguage(); 44 | } 45 | 46 | private void InitLanguage() 47 | { 48 | if (TranslationSource.Instance.Language == "zh-CN") 49 | { 50 | _LanguageIndex = 0; 51 | } 52 | else if (TranslationSource.Instance.Language == "en") 53 | { 54 | _LanguageIndex = 1; 55 | } 56 | else if (TranslationSource.Instance.Language == "zh-Hant") 57 | { 58 | _LanguageIndex = 1; 59 | } 60 | else 61 | { 62 | _LanguageIndex = 0; 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/ViewModels/WeChatLoginViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | using Prism.Mvvm; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace WeUiSharp.Demo.ViewModels 8 | { 9 | public class WeChatLoginViewModel : BindableBase 10 | { 11 | public WeChatLoginViewModel() 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/ViewModels/WeChatLoginWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | using Prism.Mvvm; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace WeUiSharp.Demo.ViewModels 8 | { 9 | public class WeChatLoginWindowViewModel : BindableBase 10 | { 11 | public WeChatLoginWindowViewModel() 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/ViewModels/YourCustomViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | using Prism.Mvvm; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace WeUiSharp.Demo.ViewModels 8 | { 9 | public class YourCustomViewModel : BindableBase 10 | { 11 | public YourCustomViewModel() 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/DemoItemListView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace WeUiSharp.Demo.Views 4 | { 5 | /// 6 | /// Interaction logic for DemoItemListView 7 | /// 8 | public partial class DemoItemListView : UserControl 9 | { 10 | public DemoItemListView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/DemoItemView.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/DemoItemView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace WeUiSharp.Demo.Views 4 | { 5 | /// 6 | /// Interaction logic for DemoItemView 7 | /// 8 | public partial class DemoItemView : UserControl 9 | { 10 | public DemoItemView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using Prism.Ioc; 2 | using Prism.Regions; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Controls.Primitives; 8 | using System.Windows.Input; 9 | using WeUiSharp.Controls; 10 | 11 | namespace WeUiSharp.Demo.Views 12 | { 13 | /// 14 | /// Interaction logic for MainWindow.xaml 15 | /// 16 | public partial class MainWindow 17 | { 18 | #region [Fields] 19 | ToggleButton _PreToggleButton; 20 | #endregion 21 | 22 | 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | } 27 | 28 | private void Window_Loaded(object sender, RoutedEventArgs e) 29 | { 30 | _PreToggleButton = ComponentMenuItem; 31 | MoreBtnContextMenu.Placement = PlacementMode.Custom; 32 | MoreBtnContextMenu.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(PlaceMoreBtnContextMenu); 33 | } 34 | 35 | // 实现拖拽左侧汉堡菜单移动主窗体 36 | private void MainMenu_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) 37 | { 38 | if (!(e.Source is Grid)) 39 | { 40 | return; 41 | } 42 | 43 | if (e.ChangedButton == MouseButton.Left) 44 | { 45 | this.DragMove(); 46 | } 47 | } 48 | 49 | // 实现菜单项的单选 50 | private void OnMenuItemPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) 51 | { 52 | if (sender is ToggleButton toggleButton) 53 | { 54 | if (toggleButton.IsChecked.HasValue && toggleButton.IsChecked.Value) 55 | { 56 | e.Handled = true; 57 | return; 58 | } 59 | if (_PreToggleButton != null && _PreToggleButton.IsChecked.HasValue && _PreToggleButton.IsChecked.Value) 60 | { 61 | _PreToggleButton.IsChecked = false; 62 | } 63 | _PreToggleButton = toggleButton; 64 | } 65 | } 66 | #region [MoreButton related] 67 | public CustomPopupPlacement[] PlaceMoreBtnContextMenu(Size popupSize, Size targetSize, Point offset) 68 | { 69 | // 针对显示设置成不同DPI情况下 70 | // https://stackoverflow.com/a/44692724 71 | double dpiFactor = System.Windows.PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice.M11; // dpiFactor范围:1.0 - 2.5 72 | 73 | CustomPopupPlacement[] ttplaces = new CustomPopupPlacement[] { new CustomPopupPlacement() }; 74 | Point relevantPoint = MoreButton.TranslatePoint(new Point(0, 0), HamburgerMenuGrid); 75 | double xOffset = targetSize.Width; 76 | if (dpiFactor != 1) 77 | { 78 | xOffset -= 1; 79 | } 80 | double yOffset = relevantPoint.Y * dpiFactor + MoreButton.ActualHeight * dpiFactor - popupSize.Height + 5 * dpiFactor; 81 | 82 | ttplaces[0].Point = new Point(xOffset, yOffset); 83 | ttplaces[0].PrimaryAxis = PopupPrimaryAxis.Horizontal; 84 | return ttplaces; 85 | } 86 | 87 | private void MoreButton_MouseUp(object sender, MouseButtonEventArgs e) 88 | { 89 | if (e.ChangedButton == MouseButton.Right) 90 | { 91 | e.Handled = true; 92 | } 93 | } 94 | 95 | private void MoreButton_Click(object sender, RoutedEventArgs e) 96 | { 97 | if (sender is PathButton pathButton) 98 | { 99 | ContextMenu menu = pathButton.ContextMenu; 100 | menu.PlacementTarget = HamburgerMenuGrid; 101 | menu.IsOpen = !menu.IsOpen; 102 | } 103 | } 104 | #endregion 105 | 106 | 107 | private void Avatar_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) 108 | { 109 | Process.Start(new ProcessStartInfo("https://github.com/IUpdatable/WeUiSharp")); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/MyCustomDetailView.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | Custom my detail view 8 | 9 | 10 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/MyCustomDetailView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace WeUiSharp.Demo.Views 4 | { 5 | /// 6 | /// Interaction logic for MyCustomDetailView 7 | /// 8 | public partial class MyCustomDetailView : UserControl 9 | { 10 | public MyCustomDetailView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/MyCustomListView.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | Custom my list view 8 | 9 | 10 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/MyCustomListView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace WeUiSharp.Demo.Views 4 | { 5 | /// 6 | /// Interaction logic for MyCustomListView 7 | /// 8 | public partial class MyCustomListView : UserControl 9 | { 10 | public MyCustomListView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/OverviewView.xaml.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | using System; 3 | using System.Threading; 4 | using System.Windows.Controls; 5 | using System.Windows.Input; 6 | using WeUiSharp.Controls; 7 | using WeUiSharp.Demo.Properties; 8 | using WeUiSharp.Windows; 9 | 10 | namespace WeUiSharp.Demo.Views 11 | { 12 | 13 | /// 14 | /// Interaction logic for OverviewView 15 | /// 16 | public partial class OverviewView : UserControl 17 | { 18 | #region [Fields] 19 | 20 | #endregion 21 | 22 | public OverviewView() 23 | { 24 | InitializeComponent(); 25 | } 26 | 27 | private void MessageBox0_Click(object sender, System.Windows.RoutedEventArgs e) 28 | { 29 | MessageBox.Show("This is a MessageBox!", "Title"); 30 | } 31 | 32 | private void MessageBox1_Click(object sender, System.Windows.RoutedEventArgs e) 33 | { 34 | MessageBoxResult dialogResult = MessageBox.Show("This is a MessageBox!", "Title", MessageBoxButton.YesNo); 35 | if (dialogResult == MessageBoxResult.Yes) 36 | { 37 | MessageBox.Show("You clicked Yes"); 38 | } 39 | else if (dialogResult == MessageBoxResult.No) 40 | { 41 | MessageBox.Show("You clicked No"); 42 | } 43 | } 44 | 45 | private void MessageBox2_Click(object sender, System.Windows.RoutedEventArgs e) 46 | { 47 | MessageBoxResult dialogResult = MessageBox.Show("This is a MessageBox!", "Title", MessageBoxButton.OKCancel); 48 | if (dialogResult == MessageBoxResult.OK) 49 | { 50 | MessageBox.Show("You clicked Ok"); 51 | } 52 | else if (dialogResult == MessageBoxResult.Cancel) 53 | { 54 | MessageBox.Show("You clicked Cancel"); 55 | } 56 | } 57 | 58 | private void Toast_Click(object sender, System.Windows.RoutedEventArgs e) 59 | { 60 | Toast.Show("Tis is a Toast!", 1); 61 | } 62 | 63 | private void OnTriggerAlert(object sender, System.Windows.RoutedEventArgs e) 64 | { 65 | string alertMessage = Strings.ResourceManager.GetString(nameof(Strings.TextAlertMessage), Thread.CurrentThread.CurrentUICulture); 66 | (System.Windows.Application.Current.MainWindow as WeUiSharp.Windows.Window).TriggerAlertCommand.Execute(alertMessage); 67 | } 68 | 69 | private void OnCancelTriggerAlert(object sender, System.Windows.RoutedEventArgs e) 70 | { 71 | var window = System.Windows.Application.Current.MainWindow as WeUiSharp.Windows.Window; 72 | if (window.IsAlertTriggered) 73 | { 74 | window.CancelAlertCommand.Execute(null); 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/SettingsWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Documents; 5 | using WeUiSharp.Controls; 6 | 7 | namespace WeUiSharp.Demo.Views 8 | { 9 | /// 10 | /// Interaction logic for SettingsWindow.xaml 11 | /// 12 | public partial class SettingsWindow 13 | { 14 | public SettingsWindow() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | private void TextBlock_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) 20 | { 21 | if (sender is TextBlock textBlock) 22 | { 23 | Clipboard.SetText(textBlock.Text); 24 | Toast.Show(this, "Copied", 1); 25 | } 26 | } 27 | 28 | private void Hyperlink_Click(object sender, RoutedEventArgs e) 29 | { 30 | if (sender is Hyperlink hyperlink) 31 | { 32 | Process.Start(new ProcessStartInfo(hyperlink.NavigateUri.ToString())); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/WeChatLoginView.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/WeChatLoginView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace WeUiSharp.Demo.Views 4 | { 5 | /// 6 | /// Interaction logic for WeChatLoginView 7 | /// 8 | public partial class WeChatLoginView : UserControl 9 | { 10 | public WeChatLoginView() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void Button_Click(object sender, System.Windows.RoutedEventArgs e) 16 | { 17 | WeChatLoginWindow weChatLoginWindow = new WeChatLoginWindow(); 18 | weChatLoginWindow.ShowDialog(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/WeChatLoginWindow.xaml: -------------------------------------------------------------------------------- 1 |  13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/WeChatLoginWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace WeUiSharp.Demo.Views 4 | { 5 | /// 6 | /// Interaction logic for WeChatLoginWindow.xaml 7 | /// 8 | public partial class WeChatLoginWindow 9 | { 10 | public WeChatLoginWindow() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/YourCustomView.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | Custom your view 8 | 9 | 10 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/Views/YourCustomView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace WeUiSharp.Demo.Views 4 | { 5 | /// 6 | /// Interaction logic for YourCustomView 7 | /// 8 | public partial class YourCustomView : UserControl 9 | { 10 | public YourCustomView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/WeUiSharp.Demo/WeUiSharp.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp.Demo/WeUiSharp.ico -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorld/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorld/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorld/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WeUiSharp.HelloWorld 10 | { 11 | /// 12 | /// App.xaml 的交互逻辑 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorld/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorld/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WeUiSharp.HelloWorld 17 | { 18 | /// 19 | /// MainWindow.xaml 的交互逻辑 20 | /// 21 | public partial class MainWindow 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorld/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // 有关程序集的一般信息由以下 8 | // 控制。更改这些特性值可修改 9 | // 与程序集关联的信息。 10 | [assembly: AssemblyTitle("WeUiSharp.HelloWorld")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("WeUiSharp.HelloWorld")] 15 | [assembly: AssemblyCopyright("Copyright © 2021")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // 将 ComVisible 设置为 false 会使此程序集中的类型 20 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 21 | //请将此类型的 ComVisible 特性设置为 true。 22 | [assembly: ComVisible(false)] 23 | 24 | //若要开始生成可本地化的应用程序,请设置 25 | //.csproj 文件中的 CultureYouAreCodingWith 26 | //例如,如果您在源文件中使用的是美国英语, 27 | //使用的是美国英语,请将 设置为 en-US。 然后取消 28 | //对以下 NeutralResourceLanguage 特性的注释。 更新 29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置 36 | //(未在页面中找到资源时使用, 37 | //或应用程序资源字典中找到时使用) 38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 39 | //(未在页面中找到资源时使用, 40 | //、应用程序或任何主题专用资源字典中找到时使用) 41 | )] 42 | 43 | 44 | // 程序集的版本信息由下列四个值组成: 45 | // 46 | // 主版本 47 | // 次版本 48 | // 生成号 49 | // 修订号 50 | // 51 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 52 | //通过使用 "*",如下所示: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorld/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本: 4.0.30319.42000 5 | // 6 | // 对此文件的更改可能导致不正确的行为,如果 7 | // 重新生成代码,则所做更改将丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | 12 | namespace WeUiSharp.HelloWorld.Properties 13 | { 14 | /// 15 | /// 强类型资源类,用于查找本地化字符串等。 16 | /// 17 | // 此类是由 StronglyTypedResourceBuilder 18 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 19 | // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen 20 | // (以 /str 作为命令选项),或重新生成 VS 项目。 21 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 22 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 23 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 24 | internal class Resources 25 | { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() 33 | { 34 | } 35 | 36 | /// 37 | /// 返回此类使用的缓存 ResourceManager 实例。 38 | /// 39 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 40 | internal static global::System.Resources.ResourceManager ResourceManager 41 | { 42 | get 43 | { 44 | if ((resourceMan == null)) 45 | { 46 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WeUiSharp.HelloWorld.Properties.Resources", typeof(Resources).Assembly); 47 | resourceMan = temp; 48 | } 49 | return resourceMan; 50 | } 51 | } 52 | 53 | /// 54 | /// 重写当前线程的 CurrentUICulture 属性,对 55 | /// 使用此强类型资源类的所有资源查找执行重写。 56 | /// 57 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 58 | internal static global::System.Globalization.CultureInfo Culture 59 | { 60 | get 61 | { 62 | return resourceCulture; 63 | } 64 | set 65 | { 66 | resourceCulture = value; 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorld/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | 12 | namespace WeUiSharp.HelloWorld.Properties 13 | { 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 17 | { 18 | 19 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 20 | 21 | public static Settings Default 22 | { 23 | get 24 | { 25 | return defaultInstance; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorld/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorld/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorldWithPrism/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorldWithPrism/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using WeUiSharp.HelloWorldWithPrism.Views; 2 | using Prism.Ioc; 3 | using Prism.Modularity; 4 | using System.Windows; 5 | 6 | namespace WeUiSharp.HelloWorldWithPrism 7 | { 8 | /// 9 | /// Interaction logic for App.xaml 10 | /// 11 | public partial class App 12 | { 13 | protected override Window CreateShell() 14 | { 15 | return Container.Resolve(); 16 | } 17 | 18 | protected override void RegisterTypes(IContainerRegistry containerRegistry) 19 | { 20 | 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorldWithPrism/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("WeUiSharp.HelloWorldWithPrism")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("WeUiSharp.HelloWorldWithPrism")] 15 | [assembly: AssemblyCopyright("Copyright © 2017")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorldWithPrism/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WeUiSharp.HelloWorldWithPrism.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WeUiSharp.HelloWorldWithPrism.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorldWithPrism/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WeUiSharp.HelloWorldWithPrism.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorldWithPrism/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorldWithPrism/ViewModels/MainWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Mvvm; 2 | 3 | namespace WeUiSharp.HelloWorldWithPrism.ViewModels 4 | { 5 | public class MainWindowViewModel : BindableBase 6 | { 7 | private string _title = "Hello WeUiSharp"; 8 | public string Title 9 | { 10 | get { return _title; } 11 | set { SetProperty(ref _title, value); } 12 | } 13 | 14 | public MainWindowViewModel() 15 | { 16 | 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorldWithPrism/Views/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorldWithPrism/Views/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace WeUiSharp.HelloWorldWithPrism.Views 4 | { 5 | /// 6 | /// Interaction logic for MainWindow.xaml 7 | /// 8 | public partial class MainWindow 9 | { 10 | public MainWindow() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/WeUiSharp.HelloWorldWithPrism/WeUiSharp.HelloWorldWithPrism.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {5BE9979B-566D-4597-84F4-B4A6EB075AE8} 8 | WinExe 9 | Properties 10 | WeUiSharp.HelloWorldWithPrism 11 | WeUiSharp.HelloWorldWithPrism 12 | v4.7.2 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | true 17 | PackageReference 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 4.0 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | MSBuild:Compile 57 | Designer 58 | 59 | 60 | MSBuild:Compile 61 | Designer 62 | 63 | 64 | App.xaml 65 | Code 66 | 67 | 68 | 69 | MainWindow.xaml 70 | Code 71 | 72 | 73 | 74 | 75 | Code 76 | 77 | 78 | True 79 | True 80 | Resources.resx 81 | 82 | 83 | True 84 | Settings.settings 85 | True 86 | 87 | 88 | ResXFileCodeGenerator 89 | Resources.Designer.cs 90 | 91 | 92 | SettingsSingleFileGenerator 93 | Settings.Designer.cs 94 | 95 | 96 | 97 | 98 | 99 | 1.0.10 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /Src/WeUiSharp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29324.140 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeUiSharp", "WeUiSharp\WeUiSharp.csproj", "{843053B2-DD54-40C3-B87D-148BD0F9C0AC}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Src", "Src", "{B8B80348-EA27-4382-AA6D-959D699D6BA1}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{80012983-AD42-446D-AC37-461B456EBB21}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0F2E81CD-3743-4011-B282-260FD5D06D39}" 13 | ProjectSection(SolutionItems) = preProject 14 | ..\README-en.md = ..\README-en.md 15 | ..\README.md = ..\README.md 16 | EndProjectSection 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeUiSharp.Demo", "WeUiSharp.Demo\WeUiSharp.Demo.csproj", "{87062573-667A-4596-BD08-C1854385E383}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeUiSharp.HelloWorld", "WeUiSharp.HelloWorld\WeUiSharp.HelloWorld.csproj", "{CA26E528-5BA6-45B5-975A-6D823496D33B}" 21 | EndProject 22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeUiSharp.HelloWorldWithPrism", "WeUiSharp.HelloWorldWithPrism\WeUiSharp.HelloWorldWithPrism.csproj", "{5BE9979B-566D-4597-84F4-B4A6EB075AE8}" 23 | EndProject 24 | Global 25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 26 | Debug|Any CPU = Debug|Any CPU 27 | Release|Any CPU = Release|Any CPU 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {843053B2-DD54-40C3-B87D-148BD0F9C0AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {843053B2-DD54-40C3-B87D-148BD0F9C0AC}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {843053B2-DD54-40C3-B87D-148BD0F9C0AC}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {843053B2-DD54-40C3-B87D-148BD0F9C0AC}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {87062573-667A-4596-BD08-C1854385E383}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {87062573-667A-4596-BD08-C1854385E383}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {87062573-667A-4596-BD08-C1854385E383}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {87062573-667A-4596-BD08-C1854385E383}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {CA26E528-5BA6-45B5-975A-6D823496D33B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {CA26E528-5BA6-45B5-975A-6D823496D33B}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {CA26E528-5BA6-45B5-975A-6D823496D33B}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {CA26E528-5BA6-45B5-975A-6D823496D33B}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {5BE9979B-566D-4597-84F4-B4A6EB075AE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {5BE9979B-566D-4597-84F4-B4A6EB075AE8}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {5BE9979B-566D-4597-84F4-B4A6EB075AE8}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {5BE9979B-566D-4597-84F4-B4A6EB075AE8}.Release|Any CPU.Build.0 = Release|Any CPU 46 | EndGlobalSection 47 | GlobalSection(SolutionProperties) = preSolution 48 | HideSolutionNode = FALSE 49 | EndGlobalSection 50 | GlobalSection(NestedProjects) = preSolution 51 | {843053B2-DD54-40C3-B87D-148BD0F9C0AC} = {B8B80348-EA27-4382-AA6D-959D699D6BA1} 52 | {80012983-AD42-446D-AC37-461B456EBB21} = {B8B80348-EA27-4382-AA6D-959D699D6BA1} 53 | {87062573-667A-4596-BD08-C1854385E383} = {80012983-AD42-446D-AC37-461B456EBB21} 54 | {CA26E528-5BA6-45B5-975A-6D823496D33B} = {80012983-AD42-446D-AC37-461B456EBB21} 55 | {5BE9979B-566D-4597-84F4-B4A6EB075AE8} = {80012983-AD42-446D-AC37-461B456EBB21} 56 | EndGlobalSection 57 | GlobalSection(ExtensibilityGlobals) = postSolution 58 | SolutionGuid = {C6EB1CBC-7678-403D-BFF2-35ABEC40A682} 59 | EndGlobalSection 60 | EndGlobal 61 | -------------------------------------------------------------------------------- /Src/WeUiSharp/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # CA1063: Implement IDisposable Correctly 4 | dotnet_diagnostic.CA1063.severity = none 5 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Common/TypedEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace WeUiSharp 2 | { 3 | /// 4 | /// Represents a method that handles general events. 5 | /// 6 | /// 7 | /// 8 | /// The event source. 9 | /// The event data. If there is no event data, this parameter will be null. 10 | public delegate void TypedEventHandler(TSender sender, TResult args); 11 | } 12 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/AddButton.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/AddButton.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WeUiSharp.Controls 17 | { 18 | /// 19 | /// AddButton.xaml 的交互逻辑 20 | /// 21 | public partial class AddButton: WeUiSharp.Controls.Button 22 | { 23 | public AddButton() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/Badge.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WeUiSharp.Controls 10 | { 11 | public class Badge: System.Windows.Controls.ContentControl 12 | { 13 | static Badge() 14 | { 15 | DefaultStyleKeyProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(typeof(Badge))); 16 | } 17 | 18 | #region [Value] 19 | /// 20 | /// Value: 只支持int类型数字(Only supports int type) 21 | /// 22 | public int Value 23 | { 24 | get { return (int)GetValue(ValueProperty); } 25 | set { SetValue(ValueProperty, value); } 26 | } 27 | /// 28 | /// 只支持int类型数字(Only supports int type) 29 | /// 30 | public static readonly DependencyProperty ValueProperty = 31 | DependencyProperty.Register(nameof(Value), typeof(int), typeof(Badge), 32 | new PropertyMetadata(-1, new PropertyChangedCallback(OnNumberChanged))); 33 | 34 | public static void OnNumberChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 35 | { 36 | int value = int.Parse(e.NewValue.ToString()); 37 | 38 | if (value <= 0) 39 | { 40 | d.SetValue(IsEnabledProperty, false); 41 | } 42 | else 43 | { 44 | d.SetValue(IsEnabledProperty, true); 45 | } 46 | if (value > 0 && value.ToString().Length == 1) 47 | { 48 | d.SetValue(ValueLengthProperty, 1); 49 | d.SetValue(TextProperty, value.ToString()); 50 | } 51 | else if (value > 0 && value.ToString().Length == 2) 52 | { 53 | d.SetValue(ValueLengthProperty, 2); 54 | d.SetValue(TextProperty, value.ToString()); 55 | } 56 | else if (value > 0 && value.ToString().Length == 3) 57 | { 58 | d.SetValue(ValueLengthProperty, 3); 59 | d.SetValue(TextProperty, "..."); 60 | } 61 | else 62 | { 63 | d.SetValue(IsEnabledProperty, false); 64 | } 65 | 66 | } 67 | #endregion 68 | 69 | #region [Text] 70 | internal string Text 71 | { 72 | get { return (string)GetValue(TextProperty); } 73 | set { SetValue(TextProperty, value); } 74 | } 75 | internal static readonly DependencyProperty TextProperty = 76 | DependencyProperty.Register(nameof(Text), typeof(string), typeof(Badge), 77 | new PropertyMetadata(string.Empty)); 78 | 79 | #endregion 80 | 81 | #region [IsValueVisible] 82 | public bool IsValueVisible 83 | { 84 | get { return (bool)GetValue(IsValueVisibleProperty); } 85 | set 86 | { 87 | if (!value) 88 | { 89 | SetValue(ValueLengthProperty, 0); 90 | } 91 | SetValue(IsValueVisibleProperty, value); 92 | } 93 | } 94 | public static readonly DependencyProperty IsValueVisibleProperty = 95 | DependencyProperty.Register(nameof(IsValueVisible), typeof(bool), typeof(Badge), new PropertyMetadata(false)); 96 | #endregion 97 | 98 | #region [ValueLength] 99 | /// 100 | /// ValueLength: 0, 1, 2, 3 101 | /// 102 | internal int ValueLength 103 | { 104 | get { return (int)GetValue(ValueLengthProperty); } 105 | private set { SetValue(ValueLengthProperty, value); } 106 | } 107 | 108 | internal static readonly DependencyProperty ValueLengthProperty = 109 | DependencyProperty.Register(nameof(ValueLength), typeof(int), typeof(Badge), new PropertyMetadata(0)); 110 | #endregion 111 | 112 | #region [CornerRadius] 113 | public CornerRadius CornerRadius 114 | { 115 | get { return (CornerRadius)GetValue(CornerRadiusProperty); } 116 | set { SetValue(CornerRadiusProperty, value); } 117 | } 118 | public static readonly DependencyProperty CornerRadiusProperty = 119 | DependencyProperty.Register(nameof(CornerRadius), typeof(CornerRadius), typeof(Badge), new PropertyMetadata(new System.Windows.CornerRadius(0))); 120 | #endregion 121 | 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/Button.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using WeUiSharp.Enums; 8 | using WeUiSharp.Windows; 9 | 10 | namespace WeUiSharp.Controls 11 | { 12 | public class Button: System.Windows.Controls.Button 13 | { 14 | static Button() 15 | { 16 | DefaultStyleKeyProperty.OverrideMetadata(typeof(Button), new FrameworkPropertyMetadata(typeof(Button))); 17 | } 18 | 19 | 20 | 21 | public ButtonGreenType GreenType 22 | { 23 | get { return (ButtonGreenType)GetValue(GreenTypeProperty); } 24 | set { SetValue(GreenTypeProperty, value); } 25 | } 26 | 27 | // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc... 28 | public static readonly DependencyProperty GreenTypeProperty = 29 | DependencyProperty.Register(nameof(GreenType), typeof(ButtonGreenType), typeof(Button), 30 | new PropertyMetadata(ButtonGreenType.None)); 31 | 32 | 33 | 34 | public CornerRadius CornerRadius 35 | { 36 | get { return (CornerRadius)GetValue(CornerRadiusProperty); } 37 | set { SetValue(CornerRadiusProperty, value); } 38 | } 39 | public static readonly DependencyProperty CornerRadiusProperty = 40 | DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(Button), new PropertyMetadata(new CornerRadius(0))); 41 | 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/ComboBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace WeUiSharp.Controls 9 | { 10 | public class ComboBox: System.Windows.Controls.ComboBox 11 | { 12 | static ComboBox() 13 | { 14 | DefaultStyleKeyProperty.OverrideMetadata(typeof(ComboBox), new FrameworkPropertyMetadata(typeof(ComboBox))); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/HamburgerMenuItemBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Media; 9 | using System.Windows.Media.Imaging; 10 | using WeUiSharp.Interfaces; 11 | 12 | namespace WeUiSharp.Controls 13 | { 14 | public abstract class HamburgerMenuItemBase : RadioButton, ISortedView 15 | { 16 | #region [Properties] 17 | 18 | public abstract int Index { get; set; } 19 | 20 | /// 21 | /// 正常情况下,背景图的ImageSource 22 | /// 23 | public ImageSource MenuItemImgSrc 24 | { 25 | get { return (ImageSource)GetValue(MenuItemImgSrcProperty); } 26 | set { SetValue(MenuItemImgSrcProperty, value); } 27 | } 28 | public static readonly DependencyProperty MenuItemImgSrcProperty = 29 | DependencyProperty.Register("MenuItemImgSrc", typeof(ImageSource), typeof(HamburgerMenuItemBase), new PropertyMetadata(null)); 30 | 31 | /// 32 | /// 鼠标停靠时,背景图的ImageSource 33 | /// 34 | public ImageSource MenuItemMouseOverImgSrc 35 | { 36 | get { return (ImageSource)GetValue(MenuItemMouseOverImgSrcProperty); } 37 | set { SetValue(MenuItemMouseOverImgSrcProperty, value); } 38 | } 39 | public static readonly DependencyProperty MenuItemMouseOverImgSrcProperty = 40 | DependencyProperty.Register("MenuItemMouseOverImgSrc", typeof(ImageSource), typeof(HamburgerMenuItemBase), new PropertyMetadata(null)); 41 | 42 | /// 43 | /// 选中时,背景图的ImageSource 44 | /// 45 | public ImageSource MenuItemCheckedImgSrc 46 | { 47 | get { return (ImageSource)GetValue(MenuItemCheckedImgSrcProperty); } 48 | set { SetValue(MenuItemCheckedImgSrcProperty, value); } 49 | } 50 | public static readonly DependencyProperty MenuItemCheckedImgSrcProperty = 51 | DependencyProperty.Register("MenuItemCheckedImgSrc", typeof(ImageSource), typeof(HamburgerMenuItemBase), new PropertyMetadata(null)); 52 | 53 | #endregion 54 | 55 | public HamburgerMenuItemBase() 56 | { 57 | MenuItemImgSrc = new BitmapImage(new Uri("pack://application:,,,/WeUiSharp;component/Resources/Icons/Plugin.png")); 58 | MenuItemMouseOverImgSrc = new BitmapImage(new Uri("pack://application:,,,/WeUiSharp;component/Resources/Icons/Plugin_MouseOver.png")); 59 | MenuItemCheckedImgSrc = new BitmapImage(new Uri("pack://application:,,,/WeUiSharp;component/Resources/Icons/Plugin_Checked.png")); 60 | this.Style = Application.Current.FindResource("HamburgerMenuItemBaseStyle") as Style; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/IconButton.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Media; 3 | 4 | namespace WeUiSharp.Controls 5 | { 6 | public class IconButton: System.Windows.Controls.Button 7 | { 8 | static IconButton() 9 | { 10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(IconButton), new FrameworkPropertyMetadata(typeof(IconButton))); 11 | } 12 | 13 | #region [StaticIcon] 14 | public ImageSource StaticIcon 15 | { 16 | get { return (ImageSource)GetValue(StaticIconProperty); } 17 | set { SetValue(StaticIconProperty, value); } 18 | } 19 | public static readonly DependencyProperty StaticIconProperty = 20 | DependencyProperty.Register("StaticIcon", typeof(ImageSource), typeof(IconButton), new PropertyMetadata(null)); 21 | #endregion 22 | 23 | #region [MouseOverIcon] 24 | public ImageSource MouseOverIcon 25 | { 26 | get { return (ImageSource)GetValue(MouseOverIconProperty); } 27 | set { SetValue(MouseOverIconProperty, value); } 28 | } 29 | public static readonly DependencyProperty MouseOverIconProperty = 30 | DependencyProperty.Register("MouseOverIcon", typeof(ImageSource), typeof(IconButton), new PropertyMetadata(null)); 31 | #endregion 32 | 33 | #region [PressedIcon] 34 | public ImageSource PressedIcon 35 | { 36 | get { return (ImageSource)GetValue(PressedIconProperty); } 37 | set { SetValue(PressedIconProperty, value); } 38 | } 39 | public static readonly DependencyProperty PressedIconProperty = 40 | DependencyProperty.Register("PressedIcon", typeof(ImageSource), typeof(IconButton), new PropertyMetadata(null)); 41 | #endregion 42 | 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/MenuItemSeparator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace WeUiSharp.Controls 9 | { 10 | public class MenuItemSeparator: System.Windows.Controls.Separator 11 | { 12 | static MenuItemSeparator() 13 | { 14 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MenuItemSeparator), new FrameworkPropertyMetadata(typeof(MenuItemSeparator))); 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/MessageBox.xaml: -------------------------------------------------------------------------------- 1 |  21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/MessageBox.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WeUiSharp.Controls 17 | { 18 | /// 19 | /// MessageBox.xaml 的交互逻辑 20 | /// 21 | public partial class MessageBox : WeUiSharp.Windows.Window 22 | { 23 | public string Message { get; set; } 24 | private MessageBoxResult _Result; 25 | 26 | public MessageBoxResult Result 27 | { 28 | get 29 | { 30 | return _Result; 31 | } 32 | } 33 | 34 | public MessageBox() 35 | { 36 | InitializeComponent(); 37 | this.DataContext = this; 38 | _Result = MessageBoxResult.Cancel; 39 | } 40 | 41 | 42 | 43 | public static MessageBoxResult Show(string messageBoxText, string caption = "") 44 | { 45 | MessageBoxResult result = MessageBoxResult.Cancel; 46 | using (MessageBox messageBox = new MessageBox()) 47 | { 48 | messageBox.Title = caption; 49 | messageBox.Message = messageBoxText; 50 | messageBox.WindowStartupLocation = WindowStartupLocation.CenterOwner; 51 | messageBox.Owner = Application.Current.MainWindow; 52 | messageBox.ShowDialog(); 53 | result = messageBox.Result; 54 | } 55 | return result; 56 | } 57 | 58 | private void CancelButton_Click(object sender, RoutedEventArgs e) 59 | { 60 | _Result = MessageBoxResult.Cancel; 61 | this.Close(); 62 | } 63 | 64 | private void YesButton_Click(object sender, RoutedEventArgs e) 65 | { 66 | _Result = MessageBoxResult.OK; 67 | this.Close(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/PathButton.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Media; 9 | using System.Windows.Shapes; 10 | 11 | namespace WeUiSharp.Controls 12 | { 13 | public class PathButton : Button 14 | { 15 | static PathButton() 16 | { 17 | DefaultStyleKeyProperty.OverrideMetadata(typeof(PathButton), new FrameworkPropertyMetadata(typeof(PathButton))); 18 | } 19 | 20 | public Brush DefaultBackground 21 | { 22 | get { return (Brush)GetValue(DefaultBackgroundProperty); } 23 | set { SetValue(DefaultBackgroundProperty, value); } 24 | } 25 | 26 | public static readonly DependencyProperty DefaultBackgroundProperty = 27 | DependencyProperty.Register(nameof(DefaultBackground), typeof(Brush), typeof(PathButton), new PropertyMetadata(null)); 28 | 29 | public Brush DefaultForeground 30 | { 31 | get { return (Brush)GetValue(DefaultForegroundProperty); } 32 | set { SetValue(DefaultForegroundProperty, value); } 33 | } 34 | 35 | public static readonly DependencyProperty DefaultForegroundProperty = 36 | DependencyProperty.Register(nameof(DefaultForeground), typeof(Brush), typeof(PathButton), new PropertyMetadata(null)); 37 | 38 | public Brush MouseOverBackground 39 | { 40 | get { return (Brush)GetValue(MouseOverBackgroundProperty); } 41 | set { SetValue(MouseOverBackgroundProperty, value); } 42 | } 43 | 44 | public static readonly DependencyProperty MouseOverBackgroundProperty = 45 | DependencyProperty.Register(nameof(MouseOverBackground), typeof(Brush), typeof(PathButton), new PropertyMetadata(null)); 46 | 47 | public Brush MouseOverForeground 48 | { 49 | get { return (Brush)GetValue(MouseOverForegroundProperty); } 50 | set { SetValue(MouseOverForegroundProperty, value); } 51 | } 52 | 53 | public static readonly DependencyProperty MouseOverForegroundProperty = 54 | DependencyProperty.Register(nameof(MouseOverForeground), typeof(Brush), typeof(PathButton), new PropertyMetadata(null)); 55 | 56 | public Brush PressedBackground 57 | { 58 | get { return (Brush)GetValue(PressedBackgroundProperty); } 59 | set { SetValue(PressedBackgroundProperty, value); } 60 | } 61 | public static readonly DependencyProperty PressedBackgroundProperty = 62 | DependencyProperty.Register(nameof(PressedBackground), typeof(Brush), typeof(PathButton), new PropertyMetadata(null)); 63 | 64 | public Brush PressedForeground 65 | { 66 | get { return (Brush)GetValue(PressedForegroundProperty); } 67 | set { SetValue(PressedForegroundProperty, value); } 68 | } 69 | public static readonly DependencyProperty PressedForegroundProperty = 70 | DependencyProperty.Register(nameof(PressedForeground), typeof(Brush), typeof(PathButton), new PropertyMetadata(null)); 71 | 72 | public Path Path 73 | { 74 | get { return (Path)GetValue(PathProperty); } 75 | set { SetValue(PathProperty, value); } 76 | } 77 | public static readonly DependencyProperty PathProperty = 78 | DependencyProperty.Register(nameof(Path), typeof(Path), typeof(PathButton), new PropertyMetadata(null)); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/Primitives/DelegateHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace WeUiSharp 5 | { 6 | internal static class DelegateHelper 7 | { 8 | public static T CreateDelegate(MethodInfo method) where T : Delegate 9 | { 10 | return (T)Delegate.CreateDelegate(typeof(T), method); 11 | } 12 | 13 | public static T CreateDelegate(object firstArgument, MethodInfo method) where T : Delegate 14 | { 15 | return (T)Delegate.CreateDelegate(typeof(T), firstArgument, method); 16 | } 17 | 18 | public static T CreateDelegate(Type target, string method, BindingFlags bindingAttr = DefaultLookup) where T : Delegate 19 | { 20 | if (bindingAttr != DefaultLookup) 21 | { 22 | var methodInfo = target.GetMethod(method, bindingAttr); 23 | if (methodInfo != null) 24 | { 25 | return CreateDelegate(methodInfo); 26 | } 27 | return null; 28 | } 29 | else 30 | { 31 | return (T)Delegate.CreateDelegate(typeof(T), target, method); 32 | } 33 | } 34 | 35 | public static T CreateDelegate(object target, string method, BindingFlags bindingAttr = DefaultLookup) where T : Delegate 36 | { 37 | if (bindingAttr != DefaultLookup) 38 | { 39 | var methodInfo = target.GetType().GetMethod(method, bindingAttr); 40 | if (methodInfo != null) 41 | { 42 | return CreateDelegate(target, methodInfo); 43 | } 44 | return null; 45 | } 46 | else 47 | { 48 | return (T)Delegate.CreateDelegate(typeof(T), target, method); 49 | } 50 | } 51 | 52 | public static Func CreatePropertyGetter(string name, BindingFlags bindingAttr = DefaultLookup, bool nonPublic = false) 53 | { 54 | var property = typeof(TType).GetProperty(name, bindingAttr); 55 | if (property != null) 56 | { 57 | var getMethod = property.GetGetMethod(nonPublic); 58 | if (getMethod != null) 59 | { 60 | return CreateDelegate>(getMethod); 61 | } 62 | } 63 | return null; 64 | } 65 | 66 | public static Action CreatePropertySetter(string name, BindingFlags bindingAttr = DefaultLookup, bool nonPublic = false) 67 | { 68 | var property = typeof(TType).GetProperty(name, bindingAttr); 69 | if (property != null) 70 | { 71 | var setMethod = property.GetSetMethod(nonPublic); 72 | if (setMethod != null) 73 | { 74 | return CreateDelegate>(setMethod); 75 | } 76 | } 77 | return null; 78 | } 79 | 80 | private const BindingFlags DefaultLookup = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/SearchBar.xaml: -------------------------------------------------------------------------------- 1 |  15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 37 | 38 | 39 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/SearchBar.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | 5 | namespace WeUiSharp.Controls 6 | { 7 | /// 8 | /// SearchBar.xaml 的交互逻辑 9 | /// 10 | public partial class SearchBar : UserControl 11 | { 12 | public SearchBar() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | private void SearchTextBox_GotFocus(object sender, RoutedEventArgs e) 18 | { 19 | TextBox textBox = sender as TextBox; 20 | textBox.Text = string.Empty; 21 | textBox.SetResourceReference(ForegroundProperty, "SearchBar.Focus.Foreground"); 22 | SearchCloseBtn.Visibility = Visibility.Visible; 23 | MainBoarder.SetResourceReference(BackgroundProperty, "SearchBar.Focus.Background"); 24 | MainBoarder.SetResourceReference(BorderBrushProperty, "SearchBar.Focus.Border"); 25 | MainBoarder.BorderThickness = new Thickness(1); 26 | } 27 | 28 | private void SearchTextBox_LostFocus(object sender, RoutedEventArgs e) 29 | { 30 | TextBox textBox = sender as TextBox; 31 | textBox.Text = Properties.Strings.ResourceManager.GetString("SearchBarText", Thread.CurrentThread.CurrentUICulture); 32 | textBox.SetResourceReference(ForegroundProperty, "SearchBar.Static.Foreground"); 33 | SearchCloseBtn.Visibility = Visibility.Collapsed; 34 | MainBoarder.SetResourceReference(BackgroundProperty, "SearchBar.Static.Background"); 35 | MainBoarder.BorderThickness = new Thickness(0); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/TabControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using Dragablz; 8 | 9 | namespace WeUiSharp.Controls 10 | { 11 | public class TabControl : TabablzControl 12 | { 13 | public TabControl() 14 | { 15 | Style style = Application.Current.FindResource("newTabablzControlStyle") as Style; 16 | base.Style = style; 17 | } 18 | 19 | static TabControl() 20 | { 21 | DefaultStyleKeyProperty.OverrideMetadata(typeof(TabControl), new FrameworkPropertyMetadata(typeof(TabControl))); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/Toast.xaml: -------------------------------------------------------------------------------- 1 |  14 | 15 | 16 | 17 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/Toast.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Timers; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Navigation; 15 | using System.Windows.Shapes; 16 | 17 | namespace WeUiSharp.Controls 18 | { 19 | /// 20 | /// Toast.xaml 的交互逻辑 21 | /// 22 | public partial class Toast : System.Windows.Window, IDisposable 23 | { 24 | public string Message { get; set; } 25 | public double Duration { get; set; } 26 | 27 | public Toast() 28 | { 29 | InitializeComponent(); 30 | this.DataContext = this; 31 | 32 | Task.Factory.StartNew(() => 33 | { 34 | System.Timers.Timer timer = new System.Timers.Timer(); 35 | double duration = Duration * 1000; 36 | timer.Interval = duration <= 0 ? 3500 : duration; 37 | timer.Elapsed += (sender, args) => 38 | { 39 | timer.Stop(); 40 | this.Dispatcher.Invoke(new Action(()=> 41 | { 42 | this.DialogResult = true; 43 | })); 44 | }; 45 | timer.Start(); 46 | }); 47 | } 48 | /// 49 | /// Toast消息提示 50 | /// 51 | /// 调用者 52 | /// 消息内容 53 | /// 消息展示的时间,单位:秒 54 | public static void Show(string message, double durationSec = 3.5) 55 | { 56 | using (Toast toast = new Toast()) 57 | { 58 | toast.Message = message; 59 | toast.Duration = durationSec; 60 | toast.Topmost = true; 61 | toast.Owner = Application.Current.MainWindow; 62 | toast.ShowDialog(); 63 | } 64 | } 65 | 66 | public static void Show(Window owner, string message, double durationSec = 3.5) 67 | { 68 | using (Toast toast = new Toast()) 69 | { 70 | toast.Message = message; 71 | toast.Duration = durationSec; 72 | toast.Topmost = true; 73 | toast.Owner = owner; 74 | toast.ShowDialog(); 75 | } 76 | } 77 | 78 | public void Dispose() 79 | { 80 | this.Close(); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Controls/WheelSpeedScrollViewer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Input; 9 | 10 | namespace WeUiSharp.Controls 11 | { 12 | public class WheelSpeedScrollViewer: ScrollViewer 13 | { 14 | public static readonly DependencyProperty SpeedFactorProperty = 15 | DependencyProperty.Register(nameof(SpeedFactor), 16 | typeof(Double), 17 | typeof(WheelSpeedScrollViewer), 18 | new PropertyMetadata(1.0)); 19 | 20 | public Double SpeedFactor 21 | { 22 | get { return (Double)GetValue(SpeedFactorProperty); } 23 | set { SetValue(SpeedFactorProperty, value); } 24 | } 25 | 26 | protected override void OnPreviewMouseWheel(MouseWheelEventArgs e) 27 | { 28 | if (!e.Handled && 29 | ScrollInfo is ScrollContentPresenter scp && 30 | ComputedVerticalScrollBarVisibility == System.Windows.Visibility.Visible) 31 | { 32 | scp.SetVerticalOffset(VerticalOffset - e.Delta * SpeedFactor); 33 | e.Handled = true; 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Src/WeUiSharp/ControlsResources.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 14 33 | 12 34 | 10 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Converters/EqualToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace WeUiSharp.Converters 7 | { 8 | public class EqualToVisibilityConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | if (value.Equals(parameter)) 13 | { 14 | return Visibility.Visible; 15 | } 16 | else 17 | { 18 | return Visibility.Collapsed; 19 | } 20 | } 21 | 22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 23 | { 24 | return null; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Converters/InverseBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Data; 8 | 9 | namespace WeUiSharp.Converters 10 | { 11 | [ValueConversion(typeof(bool), typeof(bool))] 12 | public class InverseBooleanConverter : IValueConverter 13 | { 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | if (targetType != typeof(bool)) 17 | { 18 | throw new InvalidOperationException("The target must be a boolean"); 19 | } 20 | return !(bool)value; 21 | } 22 | 23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Converters/InvertBoolToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Data; 9 | 10 | namespace WeUiSharp.Converters 11 | { 12 | public class InvertBoolToVisibilityConverter : IValueConverter 13 | { 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | if ((bool)value) 17 | { 18 | return Visibility.Collapsed; 19 | } 20 | else 21 | { 22 | return Visibility.Visible; 23 | } 24 | } 25 | 26 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 27 | { 28 | if ((Visibility)value == Visibility.Visible) 29 | { 30 | return false; 31 | } 32 | else 33 | { 34 | return true; 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Src/WeUiSharp/DesignTime/Design.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Windows; 3 | 4 | namespace WeUiSharp.DesignTime 5 | { 6 | public static class Design 7 | { 8 | #region RequestedTheme 9 | 10 | public static ElementTheme GetRequestedTheme(FrameworkElement element) 11 | { 12 | return (ElementTheme)element.GetValue(RequestedThemeProperty); 13 | } 14 | 15 | public static void SetRequestedTheme(FrameworkElement element, ElementTheme value) 16 | { 17 | element.SetValue(RequestedThemeProperty, value); 18 | } 19 | 20 | public static readonly DependencyProperty RequestedThemeProperty = DependencyProperty.RegisterAttached( 21 | "RequestedTheme", 22 | typeof(ElementTheme), 23 | typeof(Design), 24 | new PropertyMetadata(ElementTheme.Default, OnRequestedThemeChanged)); 25 | 26 | private static void OnRequestedThemeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 27 | { 28 | if (DesignerProperties.GetIsInDesignMode(d)) 29 | { 30 | var element = (FrameworkElement)d; 31 | ThemeManager.SetRequestedTheme(element, (ElementTheme)e.NewValue); 32 | } 33 | } 34 | 35 | #endregion 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Src/WeUiSharp/DesignTime/DesignTimeResources.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Src/WeUiSharp/DesignTime/IntellisenseResources.cs: -------------------------------------------------------------------------------- 1 | namespace WeUiSharp.DesignTime 2 | { 3 | public class IntellisenseResources : IntellisenseResourcesBase 4 | { 5 | public IntellisenseResources() 6 | { 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Src/WeUiSharp/DesignTime/IntellisenseResourcesBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Windows; 4 | 5 | namespace WeUiSharp.DesignTime 6 | { 7 | public abstract class IntellisenseResourcesBase : ResourceDictionary, ISupportInitialize 8 | { 9 | protected IntellisenseResourcesBase() 10 | { 11 | } 12 | 13 | public new Uri Source 14 | { 15 | get => base.Source; 16 | set 17 | { 18 | if (DesignMode.DesignModeEnabled) 19 | { 20 | base.Source = value; 21 | } 22 | } 23 | } 24 | 25 | public new void EndInit() 26 | { 27 | Clear(); 28 | MergedDictionaries.Clear(); 29 | base.EndInit(); 30 | } 31 | 32 | void ISupportInitialize.EndInit() 33 | { 34 | EndInit(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Src/WeUiSharp/DesignTime/ResourceKeys.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Src/WeUiSharp/DesignTime/SystemColors.xaml: -------------------------------------------------------------------------------- 1 |  4 | #FF0078D7 5 | #FF005A9E 6 | #FF004275 7 | #FF002642 8 | #FF429CE3 9 | #FF76B9ED 10 | #FFA6D8FF 11 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Enums/ButtonGreenType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace WeUiSharp.Enums 8 | { 9 | public enum ButtonGreenType 10 | { 11 | /// 12 | /// 默认值,正常按钮,无绿色(Default, normal button, NO green) 13 | /// 14 | None = 0, 15 | /// 16 | /// 绿色文字按钮(Foreground is green) 17 | /// 18 | Foreground = 10, 19 | /// 20 | /// 仅当鼠标悬停时呈现绿色(Green only when the mouse is hovered) 21 | /// 22 | Hover = 20, 23 | /// 24 | /// 完全呈现绿色(Completely green) 25 | /// 26 | All = 30 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Enums/MessageBoxButton.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace WeUiSharp.Windows 8 | { 9 | public enum MessageBoxButton 10 | { 11 | /// 12 | /// 该消息框显示 确定 按钮。 13 | /// 14 | OK = 0, 15 | /// 16 | /// 该消息框显示 确定 和 取消 按钮。 17 | /// 18 | OKCancel = 1, 19 | /// 20 | /// 该消息框显示 是, ,否, ,和 取消 按钮。 21 | /// 22 | YesNoCancel = 3, 23 | /// 24 | /// 该消息框显示 是 和 否 按钮。 25 | /// 26 | YesNo = 4, 27 | /// 28 | /// 该消息框显示 我知道了 按钮。 29 | /// 30 | GotIt = 5, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Enums/MessageBoxResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace WeUiSharp.Windows 8 | { 9 | public enum MessageBoxResult 10 | { 11 | /// 12 | /// 消息框中不返回任何结果。 13 | /// 14 | None = 0, 15 | /// 16 | /// 消息框中不返回任何结果。 17 | /// 18 | OK = 1, 19 | /// 20 | /// 消息框的结果值 取消。 21 | /// 22 | Cancel = 2, 23 | /// 24 | /// 消息框的结果值 是。 25 | /// 26 | Yes = 6, 27 | /// 28 | /// 消息框的结果值 否。 29 | /// 30 | No = 7, 31 | /// 32 | /// 消息框的结果值 我知道了。 33 | /// 34 | GotIt = 5, 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Helpers/ColorsHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Windows; 4 | using System.Windows.Media; 5 | using System.Windows.Threading; 6 | using WeUiSharp.Helpers; 7 | 8 | namespace WeUiSharp 9 | { 10 | internal class ColorsHelper : DispatcherObject 11 | { 12 | private readonly ResourceDictionary _colors = new ResourceDictionary(); 13 | 14 | private Color _SystemBackground; 15 | 16 | private ColorsHelper() 17 | { 18 | } 19 | 20 | public static ColorsHelper Current { get; } = new ColorsHelper(); 21 | 22 | public ResourceDictionary Colors => _colors; 23 | 24 | public ApplicationTheme? SystemTheme { get; private set; } 25 | 26 | public event EventHandler SystemThemeChanged; 27 | 28 | public void UpdateBrushes(ResourceDictionary themeDictionary) 29 | { 30 | UpdateBrushes(themeDictionary, _colors); 31 | } 32 | 33 | public static void UpdateBrushes(ResourceDictionary themeDictionary, ResourceDictionary colors) 34 | { 35 | foreach (DictionaryEntry entry in themeDictionary) 36 | { 37 | if (entry.Value is SolidColorBrush brush && !brush.IsFrozen) 38 | { 39 | object colorKey = ThemeResourceHelper.GetColorKey(brush); 40 | if (colorKey != null && colors.Contains(colorKey)) 41 | { 42 | brush.SetCurrentValue(SolidColorBrush.ColorProperty, (Color)colors[colorKey]); 43 | } 44 | } 45 | } 46 | } 47 | 48 | private void UpdateSystemAppTheme() 49 | { 50 | SystemTheme = IsDarkBackground(_SystemBackground) ? ApplicationTheme.Dark : ApplicationTheme.Light; 51 | } 52 | 53 | private static bool IsDarkBackground(Color color) 54 | { 55 | return color.R + color.G + color.B < (255 * 3 - color.R - color.G - color.B); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Helpers/DesignMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Windows; 4 | 5 | namespace WeUiSharp 6 | { 7 | /// 8 | /// Enables you to detect whether your app is in design mode in a visual designer. 9 | /// 10 | internal static class DesignMode 11 | { 12 | private static readonly Lazy _designModeEnabled = 13 | new Lazy(() => DesignerProperties.GetIsInDesignMode(new DependencyObject())); 14 | 15 | /// 16 | /// Gets a value that indicates whether the process is running in design mode. 17 | /// 18 | /// **True** if the process is running in design mode; otherwise **false**. 19 | public static bool DesignModeEnabled => _designModeEnabled.Value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Helpers/MergedDictionariesHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.ObjectModel; 3 | using System.Windows; 4 | 5 | namespace WeUiSharp 6 | { 7 | internal static class MergedDictionariesHelper 8 | { 9 | public static void AddIfNotNull(this Collection mergedDictionaries, ResourceDictionary item) 10 | { 11 | if (item != null) 12 | { 13 | mergedDictionaries.Add(item); 14 | } 15 | } 16 | 17 | public static void RemoveIfNotNull(this Collection mergedDictionaries, ResourceDictionary item) 18 | { 19 | if (item != null) 20 | { 21 | mergedDictionaries.Remove(item); 22 | } 23 | } 24 | 25 | public static void InsertOrReplace(this Collection mergedDictionaries, int index, ResourceDictionary item) 26 | { 27 | if (mergedDictionaries.Count > index) 28 | { 29 | mergedDictionaries[index] = item; 30 | } 31 | else 32 | { 33 | mergedDictionaries.Insert(index, item); 34 | } 35 | } 36 | 37 | public static void RemoveAll(this Collection mergedDictionaries) where T : ResourceDictionary 38 | { 39 | for (int i = mergedDictionaries.Count - 1; i >= 0; i--) 40 | { 41 | if (mergedDictionaries[i] is T) 42 | { 43 | mergedDictionaries.RemoveAt(i); 44 | } 45 | } 46 | } 47 | 48 | public static void InsertIfNotExists(this Collection mergedDictionaries, int index, ResourceDictionary item) 49 | { 50 | if (!mergedDictionaries.Contains(item)) 51 | { 52 | mergedDictionaries.Insert(index, item); 53 | } 54 | } 55 | 56 | public static void Swap(this Collection mergedDictionaries, int index1, int index2) 57 | { 58 | if (index1 == index2) 59 | { 60 | return; 61 | } 62 | 63 | var smallIndex = Math.Min(index1, index2); 64 | var largeIndex = Math.Max(index1, index2); 65 | var tmp = mergedDictionaries[smallIndex]; 66 | mergedDictionaries.RemoveAt(smallIndex); 67 | mergedDictionaries.Insert(largeIndex, tmp); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Helpers/PackUriHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WeUiSharp 4 | { 5 | internal static class PackUriHelper 6 | { 7 | public static Uri GetAbsoluteUri(string path) 8 | { 9 | return new Uri($"pack://application:,,,/WeUiSharp;component/{path}"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Helpers/ThemeResourceHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Media; 3 | 4 | namespace WeUiSharp.Helpers 5 | { 6 | internal static class ThemeResourceHelper 7 | { 8 | private static readonly DependencyProperty ColorKeyProperty = 9 | DependencyProperty.RegisterAttached( 10 | "ColorKey", 11 | typeof(object), 12 | typeof(ThemeResourceHelper)); 13 | 14 | internal static object GetColorKey(SolidColorBrush element) 15 | { 16 | return element.GetValue(ColorKeyProperty); 17 | } 18 | 19 | internal static void SetColorKey(SolidColorBrush element, object value) 20 | { 21 | element.SetValue(ColorKeyProperty, value); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Interfaces/ICloseWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Windows; 4 | 5 | namespace WeUiSharp.Interfaces 6 | { 7 | public interface ICloseWindow 8 | { 9 | Action Close { get; set; } 10 | bool CanClose { get; set; } 11 | 12 | void OnClosing(Window window); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Interfaces/ISortedView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace WeUiSharp.Interfaces 8 | { 9 | public interface ISortedView 10 | { 11 | int Index { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Localization/Translation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Resources; 3 | using System.Windows; 4 | 5 | namespace WeUiSharp.Localization 6 | { 7 | public class Translation 8 | { 9 | public static readonly DependencyProperty ResourceManagerProperty = 10 | DependencyProperty.RegisterAttached("ResourceManager", typeof(ResourceManager), typeof(Translation)); 11 | 12 | public static ResourceManager GetResourceManager(DependencyObject dependencyObject) 13 | { 14 | return (ResourceManager)dependencyObject.GetValue(ResourceManagerProperty); 15 | } 16 | 17 | public static void SetResourceManager(DependencyObject dependencyObject, ResourceManager value) 18 | { 19 | dependencyObject.SetValue(ResourceManagerProperty, value); 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Localization/TranslationSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Globalization; 5 | using System.Resources; 6 | using System.Threading; 7 | 8 | namespace WeUiSharp.Localization 9 | { 10 | public class TranslationSource : INotifyPropertyChanged 11 | { 12 | public static TranslationSource Instance { get; } = new TranslationSource(); 13 | 14 | private readonly Dictionary resourceManagerDictionary = new Dictionary() 15 | { 16 | // 默认添加的 ResourceManager 17 | {"WeUiSharp.Properties.Strings", Properties.Strings.ResourceManager} 18 | }; 19 | 20 | public List ResourceManagerList { get; set; } = new List() 21 | { 22 | // 默认添加的 ResourceManager 23 | Properties.Strings.ResourceManager 24 | }; 25 | public string this[string key] 26 | { 27 | get 28 | { 29 | Tuple tuple = SplitName(key); 30 | string translation = null; 31 | if (resourceManagerDictionary.ContainsKey(tuple.Item1)) 32 | translation = resourceManagerDictionary[tuple.Item1].GetString(tuple.Item2, Thread.CurrentThread.CurrentUICulture); 33 | return translation ?? key; 34 | } 35 | } 36 | 37 | private string language = Thread.CurrentThread.CurrentUICulture.Name; 38 | public string Language 39 | { 40 | get { return language; } 41 | set 42 | { 43 | if (language != null) 44 | { 45 | language = value; 46 | 47 | var cultureInfo = new CultureInfo(value); 48 | Thread.CurrentThread.CurrentUICulture = cultureInfo; 49 | Thread.CurrentThread.CurrentCulture = cultureInfo; 50 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(string.Empty)); 51 | } 52 | } 53 | } 54 | 55 | // WPF bindings register PropertyChanged event if the object supports it and update themselves when it is raised 56 | public event PropertyChangedEventHandler PropertyChanged; 57 | 58 | public void AddResourceManager(ResourceManager resourceManager) 59 | { 60 | if (!resourceManagerDictionary.ContainsKey(resourceManager.BaseName)) 61 | { 62 | resourceManagerDictionary.Add(resourceManager.BaseName, resourceManager); 63 | ResourceManagerList.Add(resourceManager); 64 | } 65 | } 66 | 67 | public static Tuple SplitName(string local) 68 | { 69 | int idx = local.ToString().LastIndexOf("."); 70 | var tuple = new Tuple(local.Substring(0, idx), local.Substring(idx + 1)); 71 | return tuple; 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Markup/DynamicColorExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.ComponentModel.Design.Serialization; 4 | using System.Globalization; 5 | using System.Windows; 6 | using System.Windows.Markup; 7 | using System.Windows.Media; 8 | using WeUiSharp.Helpers; 9 | 10 | namespace WeUiSharp.Markup 11 | { 12 | [TypeConverter(typeof(DynamicColorExtensionConverter))] 13 | public class DynamicColorExtension : DynamicResourceExtension 14 | { 15 | public DynamicColorExtension() 16 | { 17 | } 18 | 19 | public DynamicColorExtension(object resourceKey) : base(resourceKey) 20 | { 21 | } 22 | 23 | public override object ProvideValue(IServiceProvider serviceProvider) 24 | { 25 | object value = base.ProvideValue(serviceProvider); 26 | 27 | if (serviceProvider?.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget provideValueTarget) 28 | { 29 | if (provideValueTarget.TargetObject is SolidColorBrush solidColorBrush) 30 | { 31 | ThemeResourceHelper.SetColorKey(solidColorBrush, ResourceKey); 32 | } 33 | } 34 | 35 | return value; 36 | } 37 | } 38 | 39 | public class DynamicColorExtensionConverter : TypeConverter 40 | { 41 | public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) 42 | { 43 | if (destinationType == typeof(InstanceDescriptor)) 44 | { 45 | return true; 46 | } 47 | return base.CanConvertTo(context, destinationType); 48 | } 49 | 50 | public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) 51 | { 52 | if (destinationType == typeof(InstanceDescriptor)) 53 | { 54 | if (value == null) 55 | throw new ArgumentNullException(nameof(value)); 56 | 57 | DynamicColorExtension dynamicResource = value as DynamicColorExtension; 58 | 59 | if (dynamicResource == null) 60 | 61 | throw new ArgumentException($"{value} must be of type {nameof(DynamicColorExtension)}", nameof(value)); 62 | 63 | return new InstanceDescriptor(typeof(DynamicColorExtension).GetConstructor(new Type[] { typeof(object) }), 64 | new object[] { dynamicResource.ResourceKey }); 65 | } 66 | return base.ConvertTo(context, culture, value, destinationType); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Markup/KeyTimeExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Markup; 3 | using System.Windows.Media.Animation; 4 | 5 | namespace WeUiSharp.Markup 6 | { 7 | [MarkupExtensionReturnType(typeof(KeyTime))] 8 | public class KeyTimeExtension : MarkupExtension 9 | { 10 | public KeyTimeExtension() 11 | { 12 | } 13 | 14 | public TimeSpan TimeSpan { get; set; } = TimeSpan.Zero; 15 | 16 | public override object ProvideValue(IServiceProvider serviceProvider) 17 | { 18 | return KeyTime.FromTimeSpan(TimeSpan); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Markup/LocExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Resources; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | using System.Windows.Markup; 6 | using System.Xaml; 7 | using WeUiSharp.Localization; 8 | 9 | namespace WeUiSharp.Markup 10 | { 11 | public class LocExtension : MarkupExtension 12 | { 13 | public string StringName { get; } 14 | public LocExtension(string stringName) 15 | { 16 | StringName = stringName; 17 | } 18 | 19 | private ResourceManager GetResourceManager(object control) 20 | { 21 | if (control is DependencyObject dependencyObject) 22 | { 23 | object localValue = dependencyObject.ReadLocalValue(Translation.ResourceManagerProperty); 24 | 25 | // does this control have a "Translation.ResourceManager" attached property with a set value? 26 | if (localValue != DependencyProperty.UnsetValue) 27 | { 28 | if (localValue is ResourceManager resourceManager) 29 | { 30 | TranslationSource.Instance.AddResourceManager(resourceManager); 31 | 32 | return resourceManager; 33 | } 34 | } 35 | } 36 | else 37 | { 38 | foreach (var resourceManager in TranslationSource.Instance.ResourceManagerList) 39 | { 40 | var result = resourceManager.GetString(StringName); 41 | if (!string.IsNullOrEmpty(result)) 42 | { 43 | return resourceManager; 44 | } 45 | } 46 | } 47 | return null; 48 | } 49 | 50 | public override object ProvideValue(IServiceProvider serviceProvider) 51 | { 52 | // targetObject is the control that is using the LocExtension 53 | object targetObject = (serviceProvider as IProvideValueTarget)?.TargetObject; 54 | 55 | if (targetObject?.GetType().Name == "SharedDp") // is extension used in a control template? 56 | return targetObject; // required for template re-binding 57 | 58 | string baseName = GetResourceManager(targetObject)?.BaseName ?? string.Empty; 59 | 60 | if (string.IsNullOrEmpty(baseName)) 61 | { 62 | // rootObject is the root control of the visual tree (the top parent of targetObject) 63 | object rootObject = (serviceProvider as IRootObjectProvider)?.RootObject; 64 | baseName = GetResourceManager(rootObject)?.BaseName ?? string.Empty; 65 | } 66 | 67 | if (string.IsNullOrEmpty(baseName)) // template re-binding 68 | { 69 | if (targetObject is FrameworkElement frameworkElement) 70 | { 71 | baseName = GetResourceManager(frameworkElement.TemplatedParent)?.BaseName ?? string.Empty; 72 | } 73 | } 74 | Binding binding = new Binding 75 | { 76 | Mode = BindingMode.OneWay, 77 | Path = new PropertyPath($"[{baseName}.{StringName}]"), 78 | Source = TranslationSource.Instance, 79 | FallbackValue = StringName 80 | }; 81 | 82 | return binding.ProvideValue(serviceProvider); 83 | } 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Markup/StaticColorExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Markup; 3 | using System.Windows.Media; 4 | using WeUiSharp.Helpers; 5 | 6 | namespace WeUiSharp.Markup 7 | { 8 | public class StaticColorExtension : System.Windows.StaticResourceExtension 9 | { 10 | public StaticColorExtension() 11 | { 12 | } 13 | 14 | public StaticColorExtension(object resourceKey) : base(resourceKey) 15 | { 16 | } 17 | 18 | public override object ProvideValue(IServiceProvider serviceProvider) 19 | { 20 | object value = base.ProvideValue(serviceProvider); 21 | 22 | if (serviceProvider?.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget provideValueTarget) 23 | { 24 | if (provideValueTarget.TargetObject is SolidColorBrush solidColorBrush) 25 | { 26 | ThemeResourceHelper.SetColorKey(solidColorBrush, ResourceKey); 27 | } 28 | } 29 | 30 | return value; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Markup/StaticResourceExtension.cs: -------------------------------------------------------------------------------- 1 | namespace WeUiSharp.Markup 2 | { 3 | public class StaticResourceExtension : System.Windows.StaticResourceExtension 4 | { 5 | public StaticResourceExtension() 6 | { 7 | } 8 | 9 | public StaticResourceExtension(object resourceKey) : base(resourceKey) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Markup/ThemeResourceExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.ComponentModel.Design.Serialization; 4 | using System.Globalization; 5 | using System.Windows; 6 | using System.Windows.Data; 7 | using System.Windows.Media; 8 | 9 | namespace WeUiSharp.Markup 10 | { 11 | [TypeConverter(typeof(ThemeResouceExtensionConverter))] 12 | public class ThemeResourceExtension : DynamicResourceExtension 13 | { 14 | public ThemeResourceExtension() 15 | { 16 | } 17 | 18 | public ThemeResourceExtension(object resourceKey) : base(resourceKey) 19 | { 20 | } 21 | 22 | public override object ProvideValue(IServiceProvider serviceProvider) 23 | { 24 | if (ResourceKey is string key && key.StartsWith("SystemColor", StringComparison.Ordinal)) 25 | { 26 | var binding = new Binding(key) { Source = SystemColorsSource.Current }; 27 | return binding.ProvideValue(serviceProvider); 28 | } 29 | 30 | return base.ProvideValue(serviceProvider); 31 | } 32 | 33 | private class SystemColorsSource : INotifyPropertyChanged 34 | { 35 | private SystemColorsSource() 36 | { 37 | SystemParameters.StaticPropertyChanged += OnSystemParametersPropertyChanged; 38 | } 39 | 40 | public static SystemColorsSource Current { get; } = new SystemColorsSource(); 41 | 42 | public Color SystemColorButtonFaceColor => SystemColors.ControlColor; 43 | public Color SystemColorButtonTextColor => SystemColors.ControlTextColor; 44 | public Color SystemColorGrayTextColor => SystemColors.GrayTextColor; 45 | public Color SystemColorHighlightColor => SystemColors.HighlightColor; 46 | public Color SystemColorHighlightTextColor => SystemColors.HighlightTextColor; 47 | public Color SystemColorHotlightColor => SystemColors.HotTrackColor; 48 | public Color SystemColorWindowColor => SystemColors.WindowColor; 49 | public Color SystemColorWindowTextColor => SystemColors.WindowTextColor; 50 | public Color SystemColorActiveCaptionColor => SystemColors.ActiveCaptionColor; 51 | public Color SystemColorInactiveCaptionTextColor => SystemColors.InactiveCaptionTextColor; 52 | 53 | public event PropertyChangedEventHandler PropertyChanged; 54 | 55 | private void OnSystemParametersPropertyChanged(object sender, PropertyChangedEventArgs e) 56 | { 57 | if (e.PropertyName == nameof(SystemParameters.HighContrast) && SystemParameters.HighContrast) 58 | { 59 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(null)); 60 | } 61 | } 62 | } 63 | } 64 | 65 | public class ThemeResouceExtensionConverter : TypeConverter 66 | { 67 | public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) 68 | { 69 | if (destinationType == typeof(InstanceDescriptor)) 70 | { 71 | return true; 72 | } 73 | return base.CanConvertTo(context, destinationType); 74 | } 75 | 76 | public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) 77 | { 78 | if (destinationType == typeof(InstanceDescriptor)) 79 | { 80 | if (value == null) 81 | throw new ArgumentNullException(nameof(value)); 82 | 83 | ThemeResourceExtension dynamicResource = value as ThemeResourceExtension; 84 | 85 | if (dynamicResource == null) 86 | 87 | throw new ArgumentException($"{value} must be of type {nameof(ThemeResourceExtension)}", nameof(value)); 88 | 89 | return new InstanceDescriptor(typeof(ThemeResourceExtension).GetConstructor(new Type[] { typeof(object) }), 90 | new object[] { dynamicResource.ResourceKey }); 91 | } 92 | return base.ConvertTo(context, culture, value, destinationType); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Models/ContextMenuCommandItem.cs: -------------------------------------------------------------------------------- 1 | using Prism.Mvvm; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Input; 9 | 10 | namespace WeUiSharp.Models 11 | { 12 | public class ContextMenuCommandItem: BindableBase 13 | { 14 | #region [Fields] 15 | private string _Header; 16 | private Visibility _Visibility; 17 | private ICommand _Command; 18 | #endregion 19 | 20 | public string Header 21 | { 22 | get 23 | { 24 | return _Header; 25 | } 26 | set 27 | { 28 | SetProperty(ref _Header, value); 29 | } 30 | } 31 | public ICommand Command 32 | { 33 | get 34 | { 35 | return _Command; 36 | } 37 | set 38 | { 39 | SetProperty(ref _Command, value); 40 | _Command.CanExecuteChanged += Command_CanExecuteChanged; 41 | } 42 | } 43 | 44 | private void Command_CanExecuteChanged(object sender, EventArgs e) 45 | { 46 | 47 | if (_Command.CanExecute(null)) 48 | { 49 | _Visibility = Visibility.Visible; 50 | RaisePropertyChanged(nameof(Visibility)); 51 | } 52 | else 53 | { 54 | _Visibility = Visibility.Collapsed; 55 | RaisePropertyChanged(nameof(Visibility)); 56 | } 57 | } 58 | 59 | public Visibility Visibility 60 | { 61 | get 62 | { 63 | return _Visibility; 64 | } 65 | set 66 | { 67 | SetProperty(ref _Visibility, value); 68 | } 69 | } 70 | 71 | public ContextMenuCommandItem() 72 | { 73 | _Visibility = Visibility.Visible; 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Properties/AssemblyInfo-DESKTOP-SJ8KJP4.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using System.Windows.Markup; 5 | 6 | // 有关程序集的一般信息由以下 7 | // 控制。更改这些特性值可修改 8 | // 与程序集关联的信息。 9 | [assembly: AssemblyTitle("WeUiSharp")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("IUpdatable")] 13 | [assembly: AssemblyProduct("WeUiSharp")] 14 | [assembly: AssemblyCopyright("Copyright © IUpdatable 2021")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // 将 ComVisible 设置为 false 会使此程序集中的类型 19 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 20 | //请将此类型的 ComVisible 特性设置为 true。 21 | [assembly: ComVisible(false)] 22 | 23 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 24 | [assembly: Guid("843053b2-dd54-40c3-b87d-148bd0f9c0ac")] 25 | 26 | // 程序集的版本信息由下列四个值组成: 27 | // 28 | // 主版本 29 | // 次版本 30 | // 生成号 31 | // 修订号 32 | // 33 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 34 | //通过使用 "*",如下所示: 35 | // [assembly: AssemblyVersion("1.0.*")] 36 | [assembly: AssemblyVersion("1.0.0.0")] 37 | [assembly: AssemblyFileVersion("1.0.0.0")] 38 | 39 | [assembly: XmlnsPrefix("https://github.com/IUpdatable/WeUiSharp", "weui")] 40 | [assembly: XmlnsDefinition("https://github.com/IUpdatable/WeUiSharp", "WeUiSharp")] 41 | [assembly: XmlnsDefinition("https://github.com/IUpdatable/WeUiSharp", "WeUiSharp.Windows")] 42 | [assembly: XmlnsDefinition("https://github.com/IUpdatable/WeUiSharp", "WeUiSharp.Controls")] 43 | 44 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using System.Windows.Markup; 5 | 6 | // 有关程序集的一般信息由以下 7 | // 控制。更改这些特性值可修改 8 | // 与程序集关联的信息。 9 | [assembly: AssemblyTitle("WeUiSharp")] 10 | [assembly: AssemblyDescription("基于 WPF 实现的仿 Windows 桌面版微信 UI 界面库(An unofficial UI library for Windows WeChat based on WPF implementation)")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("IUpdatable")] 13 | [assembly: AssemblyProduct("WeUiSharp")] 14 | [assembly: AssemblyCopyright("Copyright © IUpdatable")] 15 | [assembly: AssemblyTrademark("WeUiSharp")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // 将 ComVisible 设置为 false 会使此程序集中的类型 19 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 20 | //请将此类型的 ComVisible 特性设置为 true。 21 | [assembly: ComVisible(false)] 22 | 23 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 24 | [assembly: Guid("843053b2-dd54-40c3-b87d-148bd0f9c0ac")] 25 | 26 | // 程序集的版本信息由下列四个值组成: 27 | // 28 | // 主版本 29 | // 次版本 30 | // 生成号 31 | // 修订号 32 | // 33 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 34 | //通过使用 "*",如下所示: 35 | // [assembly: AssemblyVersion("1.0.*")] 36 | [assembly: AssemblyVersion("1.0.10.0")] 37 | [assembly: AssemblyFileVersion("1.0.10.0")] 38 | 39 | [assembly: XmlnsPrefix("https://github.com/IUpdatable/WeUiSharp", "weui")] 40 | [assembly: XmlnsDefinition("https://github.com/IUpdatable/WeUiSharp", "WeUiSharp")] 41 | [assembly: XmlnsDefinition("https://github.com/IUpdatable/WeUiSharp", "WeUiSharp.Windows")] 42 | [assembly: XmlnsDefinition("https://github.com/IUpdatable/WeUiSharp", "WeUiSharp.Controls")] 43 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WeUiSharp.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Properties/Strings.en.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp/Properties/Strings.en.Designer.cs -------------------------------------------------------------------------------- /Src/WeUiSharp/Properties/Strings.zh-CN.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp/Properties/Strings.zh-CN.Designer.cs -------------------------------------------------------------------------------- /Src/WeUiSharp/Properties/Strings.zh-Hant.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp/Properties/Strings.zh-Hant.Designer.cs -------------------------------------------------------------------------------- /Src/WeUiSharp/ResourceDictionaryEx.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | 4 | namespace WeUiSharp 5 | { 6 | public class ResourceDictionaryEx : ResourceDictionary 7 | { 8 | private ResourceDictionary _mergedThemeDictionary; 9 | 10 | /// 11 | /// Gets a collection of merged resource dictionaries that are specifically keyed 12 | /// and composed to address theme scenarios, for example supplying theme values for 13 | /// "HighContrast". 14 | /// 15 | /// 16 | /// A dictionary of ResourceDictionary theme dictionaries. Each must be keyed with 17 | /// **x:Key**. 18 | /// 19 | public Dictionary ThemeDictionaries { get; } = new Dictionary(); 20 | 21 | internal ResourceDictionary MergedAppThemeDictionary { get; set; } 22 | 23 | internal void Update(string themeKey) 24 | { 25 | if (ThemeDictionaries.TryGetValue(themeKey, out ResourceDictionary themeDictionary)) 26 | { 27 | if (_mergedThemeDictionary != null) 28 | { 29 | if (_mergedThemeDictionary == themeDictionary) 30 | { 31 | return; 32 | } 33 | else 34 | { 35 | int targetIndex = MergedDictionaries.IndexOf(_mergedThemeDictionary); 36 | MergedDictionaries[targetIndex] = themeDictionary; 37 | _mergedThemeDictionary = themeDictionary; 38 | } 39 | } 40 | else 41 | { 42 | int targetIndex; 43 | 44 | if (MergedAppThemeDictionary != null) 45 | { 46 | targetIndex = MergedDictionaries.IndexOf(MergedAppThemeDictionary) + 1; 47 | } 48 | else 49 | { 50 | targetIndex = 0; 51 | } 52 | 53 | MergedDictionaries.Insert(targetIndex, themeDictionary); 54 | _mergedThemeDictionary = themeDictionary; 55 | } 56 | } 57 | else 58 | { 59 | if (_mergedThemeDictionary != null) 60 | { 61 | MergedDictionaries.Remove(_mergedThemeDictionary); 62 | _mergedThemeDictionary = null; 63 | } 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Resources/Icons/Plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp/Resources/Icons/Plugin.png -------------------------------------------------------------------------------- /Src/WeUiSharp/Resources/Icons/Plugin_Checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp/Resources/Icons/Plugin_Checked.png -------------------------------------------------------------------------------- /Src/WeUiSharp/Resources/Icons/Plugin_MouseOver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp/Resources/Icons/Plugin_MouseOver.png -------------------------------------------------------------------------------- /Src/WeUiSharp/Resources/WeUiSharp.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp/Resources/WeUiSharp.ico -------------------------------------------------------------------------------- /Src/WeUiSharp/Resources/WeUiSharp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp/Resources/WeUiSharp.png -------------------------------------------------------------------------------- /Src/WeUiSharp/Styles/ButtonBaseStyle.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Styles/CheckBoxStyle.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | 59 | 60 | 60 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Styles/ContextMenuStyle.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 40 | 41 | 44 | 45 | 9 | 10 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Styles/HamburgerMenuItemBaseStyle.xaml: -------------------------------------------------------------------------------- 1 |  5 | 37 | 49 | 50 | 23 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Styles/MessageBox.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | 10 | 11 | 23 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Styles/MoreStyle.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 33 | -------------------------------------------------------------------------------- /Src/WeUiSharp/ThemeDictionary.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace WeUiSharp 4 | { 5 | public static class ThemeDictionary 6 | { 7 | public static void SetKey(ResourceDictionary themeDictionary, string key) 8 | { 9 | var baseThemeDictionary = GetBaseThemeDictionary(key); 10 | themeDictionary.MergedDictionaries.Insert(0, baseThemeDictionary); 11 | } 12 | 13 | private static ResourceDictionary GetBaseThemeDictionary(string key) 14 | { 15 | ResourceDictionary themeDictionary = ThemeResources.Current?.TryGetThemeDictionary(key); 16 | return themeDictionary ?? ThemeManager.GetDefaultThemeDictionary(key); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Utilities/PopupEx.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp/Utilities/PopupEx.cs -------------------------------------------------------------------------------- /Src/WeUiSharp/Utilities/ScrollBarEx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Controls.Primitives; 9 | using System.Windows.Media; 10 | 11 | namespace WeUiSharp.Utilities 12 | { 13 | public class ScrollBarEx: DependencyObject 14 | { 15 | 16 | 17 | public static double GetVerticalScrollBarWidth(ScrollViewer obj) 18 | { 19 | return (double)obj.GetValue(VerticalScrollBarWidthProperty); 20 | } 21 | 22 | public static void SetVerticalScrollBarWidth(ScrollViewer obj, double value) 23 | { 24 | obj.SetValue(VerticalScrollBarWidthProperty, value); 25 | obj.ApplyTemplate(); 26 | ScrollBar scrollBar = obj.Template.FindName("PART_VerticalScrollBar", obj) as ScrollBar; 27 | scrollBar.SetValue(Border.WidthProperty, value); 28 | 29 | // 修改圆角 30 | //Style thumbStyle = obj.FindResource("ScrollBarThumb") as Style; 31 | //foreach (Setter setter in thumbStyle.Setters) 32 | //{ 33 | // if (setter.Property.PropertyType == typeof(ControlTemplate)) 34 | // { 35 | // ControlTemplate template = setter.Value as ControlTemplate; 36 | // Border border = template.LoadContent() as Border; 37 | 38 | // Task.Run(async () => 39 | // { 40 | // await Application.Current.Dispatcher.InvokeAsync(() => 41 | // { 42 | // border.SetValue(Border.CornerRadiusProperty, new CornerRadius(value)); 43 | // border.UpdateLayout(); 44 | // }); 45 | // }); 46 | // } 47 | //} 48 | 49 | } 50 | 51 | public static readonly DependencyProperty VerticalScrollBarWidthProperty = 52 | DependencyProperty.RegisterAttached("VerticalScrollBarWidth", typeof(double), typeof(ScrollViewer), new PropertyMetadata(7.0)); 53 | 54 | 55 | } 56 | 57 | public static class DependencyObjectExtension 58 | { 59 | public static T GetChildOfType(this DependencyObject depObj) where T : DependencyObject 60 | { 61 | if (depObj == null) return null; 62 | 63 | for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++) 64 | { 65 | var child = VisualTreeHelper.GetChild(depObj, i); 66 | 67 | var result = (child as T) ?? GetChildOfType(child); 68 | if (result != null) return result; 69 | } 70 | return null; 71 | } 72 | 73 | public static T GetParentOfType(this DependencyObject depObj) where T : DependencyObject 74 | { 75 | if (depObj == null) return null; 76 | var parentObj = VisualTreeHelper.GetParent(depObj); 77 | var parent = parentObj as T; 78 | if (parent != null) 79 | { 80 | return parent; 81 | } 82 | else 83 | { 84 | return GetParentOfType(parentObj); 85 | } 86 | 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Utilities/StackPanelRegionAdapter.cs: -------------------------------------------------------------------------------- 1 | using Prism.Regions; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using WeUiSharp.Interfaces; 10 | 11 | namespace WeUiSharp.Utilities 12 | { 13 | /// 14 | /// 15 | /// Reference: 16 | /// Custome StackPanel Prism RegionAdapter to support Ordering 17 | /// https://stackoverflow.com/a/17638330 18 | /// 19 | public class StackPanelRegionAdapter: RegionAdapterBase 20 | { 21 | private readonly List _IndexList; 22 | 23 | public StackPanelRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory) 24 | : base(regionBehaviorFactory) 25 | { 26 | _IndexList = new List(); 27 | } 28 | 29 | protected override void Adapt(IRegion region, StackPanel regionTarget) 30 | { 31 | region.Views.CollectionChanged += (s, e) => 32 | { 33 | //Add 34 | if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) 35 | { 36 | foreach (FrameworkElement element in e.NewItems) 37 | { 38 | // Get index for view 39 | var sortedView = element as ISortedView; 40 | if (sortedView != null) 41 | { 42 | var viewIndex = sortedView.Index; 43 | // This method needs to iterate through the views in the region and determine 44 | // where a view with the specified index needs to be inserted 45 | var insertionIndex = GetInsertionIndex(viewIndex); 46 | regionTarget.Children.Insert(insertionIndex, (UIElement)sortedView); 47 | } 48 | else 49 | { 50 | // Add at the end of the StackPanel or reject adding the view to the region 51 | regionTarget.Children.Add(element); 52 | } 53 | 54 | } 55 | } 56 | //Remove 57 | if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove) 58 | { 59 | foreach (FrameworkElement element in e.OldItems) 60 | { 61 | regionTarget.Children.Remove(element); 62 | } 63 | } 64 | }; 65 | } 66 | 67 | private int GetInsertionIndex(in int viewIndex) 68 | { 69 | // Add the viewIndex to the index list if not already there 70 | if (_IndexList.Contains(viewIndex) == false) 71 | { 72 | _IndexList.Add(viewIndex); 73 | _IndexList.Sort(); 74 | } 75 | 76 | // Return the list index of the viewIndex 77 | for (var i = 0; i < _IndexList.Count; i++) 78 | { 79 | if (_IndexList[i].Equals(viewIndex)) 80 | { 81 | return i; 82 | } 83 | } 84 | 85 | return 0; 86 | } 87 | protected override IRegion CreateRegion() 88 | { 89 | return new AllActiveRegion(); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Utilities/WindowCloser.cs: -------------------------------------------------------------------------------- 1 | using WeUiSharp.Interfaces; 2 | using System.Windows; 3 | 4 | namespace WeUiSharp.Utilities 5 | { 6 | public class WindowCloser 7 | { 8 | 9 | public static bool? GetEnableWindowClosing(DependencyObject obj) 10 | { 11 | return (bool?)obj.GetValue(EnableWindowClosingProperty); 12 | } 13 | 14 | public static void SetEnableWindowClosing(DependencyObject obj, bool? value) 15 | { 16 | obj.SetValue(EnableWindowClosingProperty, value); 17 | } 18 | 19 | public static readonly DependencyProperty EnableWindowClosingProperty = 20 | DependencyProperty.RegisterAttached("EnableWindowClosing", typeof(bool?), typeof(WindowCloser), new PropertyMetadata(null, OnEnableWindowClosingChanged)); 21 | 22 | private static void OnEnableWindowClosingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 23 | { 24 | if (d is Window window) 25 | { 26 | window.Loaded += (s1, e1) => 27 | { 28 | if (window.DataContext is ICloseWindow vm) 29 | { 30 | vm.Close += () => 31 | { 32 | window.Close(); 33 | }; 34 | window.Closing += (s2, e2) => 35 | { 36 | vm.OnClosing(window); 37 | e2.Cancel = !vm.CanClose; 38 | }; 39 | } 40 | }; 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Src/WeUiSharp/WeUiSharp.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp/WeUiSharp.ico -------------------------------------------------------------------------------- /Src/WeUiSharp/WeUiSharp.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WeUiSharp 5 | 1.0.10 6 | WeUiSharp 7 | IUpdatable 8 | false 9 | MIT 10 | https://licenses.nuget.org/MIT 11 | Resources\WeUiSharp.png 12 | https://github.com/IUpdatable/WeUiSharp 13 | 基于 WPF 实现的仿 Windows 桌面版微信 UI 界面库(An unofficial UI library for Windows WeChat based on WPF implementation) 14 | 15 | $copyright$ 16 | WPF WeUI WeChat UI 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Src/WeUiSharp/WeUiSharp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IUpdatable/WeUiSharp/974b51e63e33131b45fa6f5f47de7c7d15f495da/Src/WeUiSharp/WeUiSharp.png -------------------------------------------------------------------------------- /Src/WeUiSharp/Windows/AlertWindow.xaml: -------------------------------------------------------------------------------- 1 |  17 | 18 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Windows/AlertWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WeUiSharp.Windows 17 | { 18 | /// 19 | /// AlertWindow.xaml 的交互逻辑 20 | /// 21 | public partial class AlertWindow : System.Windows.Window 22 | { 23 | public string Message { get; set; } 24 | 25 | public AlertWindow() 26 | { 27 | InitializeComponent(); 28 | this.DataContext = this; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Windows/DocumentBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Media; 9 | 10 | namespace WeUiSharp.Windows 11 | { 12 | public class DocumentBase : UserControl 13 | { 14 | #region [Properties] 15 | 16 | public string Title 17 | { 18 | get { return (string)GetValue(TitleProperty); } 19 | set { SetValue(TitleProperty, value); } 20 | } 21 | 22 | public static readonly DependencyProperty TitleProperty = 23 | DependencyProperty.Register("Title", typeof(string), typeof(DocumentBase), new PropertyMetadata("This is Title")); 24 | 25 | #endregion 26 | 27 | 28 | 29 | //static DocumentBase() 30 | //{ 31 | // DefaultStyleKeyProperty.OverrideMetadata(typeof(DocumentBase), new FrameworkPropertyMetadata(typeof(DocumentBase))); 32 | //} 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Windows/MessageBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace WeUiSharp.Windows 9 | { 10 | public class MessageBox 11 | { 12 | public MessageBox() 13 | { 14 | 15 | } 16 | public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button) 17 | { 18 | MessageBoxResult result = MessageBoxResult.Cancel; 19 | using (MessageBoxWrapper messageBox = new MessageBoxWrapper()) 20 | { 21 | messageBox.Title = caption; 22 | messageBox.Message = messageBoxText; 23 | messageBox.MessageBoxButton = button; 24 | messageBox.WindowStartupLocation = WindowStartupLocation.CenterOwner; 25 | messageBox.Owner = Application.Current.MainWindow; 26 | messageBox.ShowDialog(); 27 | result = messageBox.Result; 28 | } 29 | return result; 30 | } 31 | public static MessageBoxResult Show(string messageBoxText, string caption) 32 | { 33 | return Show(messageBoxText, caption, MessageBoxButton.OK); 34 | } 35 | 36 | public static MessageBoxResult Show(string messageBoxText) 37 | { 38 | return Show(messageBoxText, "", MessageBoxButton.OK); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Src/WeUiSharp/Windows/MessageBoxWrapper.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Data; 11 | using System.Windows.Documents; 12 | using System.Windows.Input; 13 | using System.Windows.Media; 14 | using System.Windows.Media.Imaging; 15 | using System.Windows.Navigation; 16 | using System.Windows.Shapes; 17 | 18 | namespace WeUiSharp.Windows 19 | { 20 | /// 21 | /// MessageBox.xaml 的交互逻辑 Wrapper 22 | /// 23 | internal partial class MessageBoxWrapper: Windows.Window 24 | { 25 | #region [Fields] 26 | private WeUiSharp.Windows.MessageBoxResult _Result; 27 | #endregion 28 | 29 | #region [Properties] 30 | 31 | #region Message 32 | internal string Message 33 | { 34 | get { return (string)GetValue(MessageProperty); } 35 | set { SetValue(MessageProperty, value); } 36 | } 37 | 38 | internal static readonly DependencyProperty MessageProperty = 39 | DependencyProperty.Register(nameof(Message), typeof(string), typeof(MessageBoxWrapper), new PropertyMetadata(string.Empty)); 40 | #endregion 41 | 42 | #region Result 43 | internal MessageBoxResult Result 44 | { 45 | get 46 | { 47 | return _Result; 48 | } 49 | } 50 | #endregion 51 | 52 | 53 | #region MessageBoxButton 54 | public MessageBoxButton MessageBoxButton 55 | { 56 | get { return (MessageBoxButton)GetValue(MessageBoxButtonProperty); } 57 | set { SetValue(MessageBoxButtonProperty, value); } 58 | } 59 | 60 | // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc... 61 | public static readonly DependencyProperty MessageBoxButtonProperty = 62 | DependencyProperty.Register(nameof(MessageBoxButton), typeof(MessageBoxButton), typeof(MessageBoxWrapper), 63 | new PropertyMetadata(MessageBoxButton.OK)); 64 | #endregion 65 | 66 | #endregion 67 | 68 | 69 | 70 | 71 | internal MessageBoxWrapper() 72 | { 73 | InitializeComponent(); 74 | this.DataContext = this; 75 | _Result = WeUiSharp.Windows.MessageBoxResult.Cancel; 76 | } 77 | 78 | private void CancelButton_Click(object sender, RoutedEventArgs e) 79 | { 80 | _Result = WeUiSharp.Windows.MessageBoxResult.Cancel; 81 | this.Close(); 82 | } 83 | 84 | private void YesButton_Click(object sender, RoutedEventArgs e) 85 | { 86 | _Result = WeUiSharp.Windows.MessageBoxResult.Yes; 87 | this.Close(); 88 | } 89 | 90 | private void GotItButton_Click(object sender, RoutedEventArgs e) 91 | { 92 | _Result = WeUiSharp.Windows.MessageBoxResult.GotIt; 93 | this.Close(); 94 | } 95 | 96 | private void NoButton_Click(object sender, RoutedEventArgs e) 97 | { 98 | _Result = WeUiSharp.Windows.MessageBoxResult.No; 99 | this.Close(); 100 | } 101 | 102 | private void OKButton_Click(object sender, RoutedEventArgs e) 103 | { 104 | _Result = WeUiSharp.Windows.MessageBoxResult.OK; 105 | this.Close(); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Src/WeUiSharp/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Src/WeUiSharp/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | --------------------------------------------------------------------------------