Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display version to popup in the Demo App #3736

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
MDIXColorsVersion: ${{ inputs.mdix-colors-version }}
MDIXMahAppsVersion: ${{ inputs.mdix-mahapps-version }}

- name: Generate Version File
run: echo ${{ inputs.mdix-version }} > src/MainDemo.Wpf/version.txt

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels kinda hacky, but I unfortunately can't suggest a better way because I don't have much experience with pipelines.

- name: Test
timeout-minutes: 20
run: dotnet test ${{ env.solution }} --configuration ${{ inputs.build-configuration }} --no-build --blame-crash --logger GitHubActions
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/get_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Setup Versions

on:
workflow_call:
inputs:
inputs:
is-full-release:
required: false
type: boolean
Expand Down
1 change: 1 addition & 0 deletions src/MahMaterialDragablzMashUp/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<Button Content="Hello World" />
<Button Content="Nice Popup" />
<Button Content="Goodbye" />
<Button Content="Version" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this should also be a button since there is no functionality behind it, but I guess it's so this fits in with the rest of the items (Buttons) above

</StackPanel>
</wpf:PopupBox>
</controls:WindowCommands>
Expand Down
1 change: 1 addition & 0 deletions src/MainDemo.Wpf/ColorZones.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<ListBoxItem Content="Hello World" />
<ListBoxItem Content="Nice Popup" />
<ListBoxItem Content="Goodbye" />
<ListBoxItem Content="Version" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having something app-specific on a page which showcases a Material Design component is debatable, but I don't mind that much

</ListBox>
</materialDesign:PopupBox>

Expand Down
5 changes: 5 additions & 0 deletions src/MainDemo.Wpf/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@
<Separator />

<Button Click="MenuPopupButton_OnClick" Content="Goodbye" />

<Separator />

<TextBlock x:Name="VersionText" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10" />

</StackPanel>
</materialDesign:PopupBox>

Expand Down
24 changes: 23 additions & 1 deletion src/MainDemo.Wpf/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ public partial class MainWindow
public MainWindow()
{
InitializeComponent();
LoadVersion();


Task.Factory.StartNew(() => Thread.Sleep(2500)).ContinueWith(t =>
{
//note you can use the message queue from any thread, but just for the demo here we
//note you can use the message queue from any thread, but just for the demo here we
//need to get the message queue from the snackbar, so need to be on the dispatcher
MainSnackbar.MessageQueue?.Enqueue("Welcome to Material Design In XAML Toolkit");
}, TaskScheduler.FromCurrentSynchronizationContext());
Expand Down Expand Up @@ -114,4 +116,24 @@ private static void ModifyTheme(bool isDarkTheme)

private void OnSelectedItemChanged(object sender, DependencyPropertyChangedEventArgs e)
=> MainScrollViewer.ScrollToHome();
private void LoadVersion()
{
try
{
string versionFilePath = Path.Combine(Directory.GetCurrentDirectory(), "version.txt");
if (File.Exists(versionFilePath))
{
string version = File.ReadAllText(versionFilePath).Trim();
VersionText.Text = $"Version: {version}";
}
else
{
VersionText.Text = "Version file not found";
}
}
catch (Exception ex)
{
VersionText.Text = $"Error reading version: {ex.Message}";
}
}
Comment on lines +119 to +138
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though the demo app isn't there to showcase best practices/design patterns, I would argue being consistent and binding a Version property in a MVVM way, rather than having all that logic in the code behind, is preferred.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for comments, yoj mean that is preferable to have a class only to load the version and link it to the MVVM class? Did I understand correctly?

}
2 changes: 1 addition & 1 deletion src/MainDemo.Wpf/MaterialDesignDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
<PackageReference Include="ShowMeTheXAML.AvalonEdit" />
<PackageReference Include="ShowMeTheXAML.MSBuild" />
</ItemGroup>
</Project>
</Project>
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1