Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit553a19a

Browse files
committed
Populate hostname text from code
1 parent611938e commit553a19a

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

‎App/TrayWindow.xaml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,16 @@
104104
Canvas.Top="3" />
105105
</Canvas>
106106

107-
<!-- Thisneeds to nothave any whitespace at all to avoid adding spaces between theruns-->
107+
<!-- Thiscannothave any whitespace at all to avoid adding spaces between theelements, so it's populated from code instead-->
108108
<!-- TODO: I couldn't get ellipsis to work without hardcoding a width here-->
109109
<TextBlock
110+
Loaded="{x:Bind AgentHostnameText_OnLoaded}"
110111
VerticalAlignment="Center"
111112
HorizontalAlignment="Stretch"
112113
HorizontalTextAlignment="Left"
113114
TextTrimming="CharacterEllipsis"
114115
TextWrapping="NoWrap"
115-
Width="180"
116-
xml:space="preserve"><!--
117-
118-
--><Run
119-
Text="{x:Bind Hostname}"
120-
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}" /><!--
121-
--><Run
122-
Text="{x:Bind Suffix}"
123-
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" /><!--
124-
--></TextBlock>
116+
Width="180" />
125117
</StackPanel>
126118
</HyperlinkButton>
127119

‎App/TrayWindow.xaml.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
usingMicrosoft.UI.Xaml;
1616
usingMicrosoft.UI.Xaml.Controls;
1717
usingMicrosoft.UI.Xaml.Controls.Primitives;
18+
usingMicrosoft.UI.Xaml.Documents;
1819
usingMicrosoft.UI.Xaml.Media;
1920
usingWinRT.Interop;
2021
usingWindowActivatedEventArgs=Microsoft.UI.Xaml.WindowActivatedEventArgs;
@@ -30,8 +31,8 @@ public enum AgentStatus
3031

3132
publicpartialclassAgent
3233
{
33-
publicstringHostname{get;set;}// without suffix
34-
publicstringSuffix{get;set;}
34+
publicrequiredstringHostname{get;set;}// without suffix
35+
publicrequiredstringSuffix{get;set;}
3536
publicAgentStatusStatus{get;set;}
3637

3738
publicBrushStatusColor=>Statusswitch
@@ -82,6 +83,26 @@ private void AgentHostnameCopyButton_Click(object parameter)
8283
FlyoutBase.SetAttachedFlyout(frameworkElement,flyout);
8384
FlyoutBase.ShowAttachedFlyout(frameworkElement);
8485
}
86+
87+
publicvoidAgentHostnameText_OnLoaded(objectsender,RoutedEventArgse)
88+
{
89+
if(senderis notTextBlocktextBlock)return;
90+
textBlock.Inlines.Clear();
91+
textBlock.Inlines.Add(newRun
92+
{
93+
Text=Hostname,
94+
Foreground=
95+
(SolidColorBrush)Application.Current.Resources.ThemeDictionaries[
96+
"DefaultTextForegroundThemeBrush"],
97+
});
98+
textBlock.Inlines.Add(newRun
99+
{
100+
Text=Suffix,
101+
Foreground=
102+
(SolidColorBrush)Application.Current.Resources.ThemeDictionaries[
103+
"SystemControlForegroundBaseMediumBrush"],
104+
});
105+
}
85106
}
86107

87108
publicsealedpartialclassTrayWindow:Window

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp