-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
<Button Content="Hello World" /> | ||
<Button Content="Nice Popup" /> | ||
<Button Content="Goodbye" /> | ||
<Button Content="Version" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
<ListBoxItem Content="Hello World" /> | ||
<ListBoxItem Content="Nice Popup" /> | ||
<ListBoxItem Content="Goodbye" /> | ||
<ListBoxItem Content="Version" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()); | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
} |
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 | ||
|
||
|
There was a problem hiding this comment.
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.