Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
GregaMohorko committed Apr 12, 2021
2 parents 5f1fc65 + f78a948 commit 9f9148f
Show file tree
Hide file tree
Showing 29 changed files with 907 additions and 236 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Gregor Mohorko
Copyright (c) 2021 Gregor Mohorko

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ You can read the documentation and how-to's under the [Wiki](https://github.com/
- [StartPage](src/GM.WPF/GM.WPF/Controls/StartPage.xaml.cs)
- [TimeControl](src/GM.WPF/GM.WPF/Controls/TimeControl.xaml.cs)
- [TimePicker](src/GM.WPF/GM.WPF/Controls/TimePicker.xaml.cs)
- [WatermarkTextBox](src/GM.WPF/GM.WPF/Controls/WatermarkTextBox.xaml.cs)

**Dialogs**:
- [DialogPanel](src/GM.WPF/GM.WPF/Controls/Dialogs/DialogPanel.xaml.cs)
Expand Down Expand Up @@ -51,14 +52,17 @@ You can read the documentation and how-to's under the [Wiki](https://github.com/
- [FrameworkElement](src/GM.WPF/GM.WPF/Behaviors/FrameworkElementBehavior.cs)
- [Panel](src/GM.WPF/GM.WPF/Behaviors/PanelBehavior.cs)
- [TabItem](src/GM.WPF/GM.WPF/Behaviors/TabItemBehavior.cs)
- [TabControl](src/GM.WPF/GM.WPF/Behaviors/TabControlBehavior.cs)
- [TextBlock](src/GM.WPF/GM.WPF/Behaviors/TextBlockBehavior.cs)

**Converters**:
- [BoolToBool](src/GM.WPF/GM.WPF/Converters/BoolToBoolConverter.cs)
- [BoolToScrollBarVisibility](src/GM.WPF/GM.WPF/Converters/BoolToScrollBarVisibilityConverter.cs)
- [BoolToVisibility](src/GM.WPF/GM.WPF/Converters/BoolToVisibilityConverter.cs)
- [EnumToCollectionConverter](src/GM.WPF/GM.WPF/Converters/EnumToCollectionConverter.cs)
- [FunctionToString](src/GM.WPF/GM.WPF/Converters/FunctionToStringConverter.cs)
- [ICollectionToBool](src/GM.WPF/GM.WPF/Converters/ICollectionToBoolConverter.cs)
- [ICollectionToCountConverter](src/GM.WPF/GM.WPF/Converters/ICollectionToCountConverter.cs)
- [ICollectionToVisibility](src/GM.WPF/GM.WPF/Converters/ICollectionToVisibilityConverter.cs)
- [IListToIList](src/GM.WPF/GM.WPF/Converters/IListToIListConverter.cs)
- [IntToVisibility](src/GM.WPF/GM.WPF/Converters/IntToVisibilityConverter.cs)
Expand Down
2 changes: 1 addition & 1 deletion src/GM.WPF/GM.WPF.Test/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Author: Grega Mohorko
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="GM.Utility" publicKeyToken="a1ae152199607549" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
<bindingRedirect oldVersion="0.0.0.0-1.3.1.0" newVersion="1.3.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
20 changes: 20 additions & 0 deletions src/GM.WPF/GM.WPF.Test/FodyWeavers.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the IsChanged property feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EventInvokerNames" type="xs:string">
<xs:annotation>
<xs:documentation>Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.</xs:documentation>
Expand All @@ -31,6 +41,16 @@
<xs:documentation>Used to control if equality checks should use the static Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
Expand Down
42 changes: 11 additions & 31 deletions src/GM.WPF/GM.WPF.Test/GM.WPF.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\PropertyChanged.Fody.3.2.8\build\PropertyChanged.Fody.props" Condition="Exists('..\packages\PropertyChanged.Fody.3.2.8\build\PropertyChanged.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -38,29 +37,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommonServiceLocator, Version=2.0.5.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
<HintPath>..\packages\CommonServiceLocator.2.0.5\lib\net47\CommonServiceLocator.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight, Version=5.4.1.0, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Extras, Version=5.4.1.0, Culture=neutral, PublicKeyToken=669f0b5e8f868abf, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Platform, Version=5.4.1.0, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference>
<Reference Include="GM.Utility, Version=1.3.0.0, Culture=neutral, PublicKeyToken=a1ae152199607549, processorArchitecture=MSIL">
<HintPath>..\packages\GM.Utility.1.3.0\lib\netstandard2.0\GM.Utility.dll</HintPath>
</Reference>
<Reference Include="PropertyChanged, Version=3.2.8.0, Culture=neutral, PublicKeyToken=ee3ee20bcf148ddd, processorArchitecture=MSIL">
<HintPath>..\packages\PropertyChanged.Fody.3.2.8\lib\net40\PropertyChanged.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -167,7 +145,6 @@
<None Include="..\GM.WPF\GM.WPF.licenseheader">
<Link>GM.WPF.licenseheader</Link>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand All @@ -185,13 +162,16 @@
<ItemGroup>
<None Include="FodyWeavers.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="GM.Utility">
<Version>1.3.2</Version>
</PackageReference>
<PackageReference Include="MvvmLightLibs">
<Version>5.4.1.1</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.3.3</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.6.2.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.2.0\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\PropertyChanged.Fody.3.2.8\build\PropertyChanged.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\PropertyChanged.Fody.3.2.8\build\PropertyChanged.Fody.props'))" />
</Target>
<Import Project="..\packages\Fody.6.2.0\build\Fody.targets" Condition="Exists('..\packages\Fody.6.2.0\build\Fody.targets')" />
</Project>
2 changes: 1 addition & 1 deletion src/GM.WPF/GM.WPF.Test/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Author: Grega Mohorko
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="_Dialogs">
<MenuItem Header="_Progress" IsCheckable="True" IsChecked="{Binding IsDialogProgressShown,Mode=OneWayToSource}" />
<MenuItem Header="_Progress" Click="MenuItem_Dialogs_Progress_Click" />
<MenuItem Header="_Message">
<MenuItem Header="_Normal" Click="MenuItem_Dialogs_Message_Normal_Click" />
<MenuItem Header="_Warning" Click="MenuItem_Dialogs_Message_Warning_Click" />
Expand Down
43 changes: 24 additions & 19 deletions src/GM.WPF/GM.WPF.Test/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -55,7 +56,6 @@ public MainWindow()
InitializeComponent();

var vm = new MainWindowViewModel();
vm.PropertyChanged += Vm_PropertyChanged;
ViewModel = vm;
}

Expand All @@ -66,25 +66,27 @@ public void Dispose()
IsDisposed = true;
}

private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
var vm = (MainWindowViewModel)ViewModel;

switch(e.PropertyName) {
case nameof(MainWindowViewModel.IsDialogProgressShown):
if(vm.IsDialogProgressShown) {
var r = new Random();
_ProgressDialog.Show("Title content.", "Message content.", r.NextDouble() * 130);
} else {
_ProgressDialog.Hide();
}
break;
}
}

#region MAINMENU

#region DIALOGS
private async void MenuItem_Dialogs_Progress_Click(object sender, RoutedEventArgs e)
{
const int msTime = 3000;
_ProgressDialog.Show($"Showing for {msTime} milliseconds", null, 0);
ProgressUpdater progressUpdater = _ProgressDialog.Updater;
await Task.Run(async delegate
{
int progressSteps = 100;
int msStep = (int)Math.Round(msTime / (double)progressSteps);
progressUpdater.StartNewLoop(progressSteps);
for(int i = 0; i < progressSteps; ++i) {
progressUpdater.SetForLoop(i, true);
await Task.Delay(msStep);
}
});
_ProgressDialog.Hide();
}

private async void MenuItem_Dialogs_Message_Normal_Click(object sender, RoutedEventArgs e)
{
// using the DialogPanel
Expand Down Expand Up @@ -211,16 +213,19 @@ private async void MenuItem_Dialogs_Search_Single_Click(object sender, RoutedEve

private Random rand = new Random();

private async Task<List<string>> SearchDialogLoadingFunction(string searchText)
private async Task<List<string>> SearchDialogLoadingFunction(string searchText, CancellationToken ct, ProgressUpdater progressUpdater)
{
// simulate one second of loading
await Task.Delay(1000);
await Task.Delay(1000, ct);

// generate some random items
int count = rand.Next(2, 30);
var items = new List<string>(count);
progressUpdater?.StartNewLoop(count);
for(int i = count - 1; i >= 0; --i) {
progressUpdater?.SetForLoop(i);
items.Add($"{rand.Next(100)}-{searchText}");
ct.ThrowIfCancellationRequested();
}
return items;
}
Expand Down
2 changes: 1 addition & 1 deletion src/GM.WPF/GM.WPF.Test/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ namespace GM.WPF.Test
{
class MainWindowViewModel : ViewModel
{
public bool IsDialogProgressShown { get; set; }

}
}
35 changes: 0 additions & 35 deletions src/GM.WPF/GM.WPF.Test/packages.config

This file was deleted.

3 changes: 1 addition & 2 deletions src/GM.WPF/GM.WPF/Behaviors/FrameworkElementBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ private static void NullifyDataContext(FrameworkElement frameworkElement, TabIte
break;
}
}
FrameworkElement parent = dataContextSource.GetParent() as FrameworkElement;
if(parent == null) {
if(!(dataContextSource.GetParent() is FrameworkElement parent)) {
// there currently is no binding on DataContext
if(!dataContextSource.IsLoaded && tabItem != null) {
// this was probably called from a UserControl, from constructor, from InitializeComponent()
Expand Down
Loading

0 comments on commit 9f9148f

Please sign in to comment.