Skip to content

Commit 726dc4e

Browse files
authored
return the focus to the input field after printing and new marketing (#41)
add marketing shutdown message add returning the focus to the input field after printing #36 closes #36
1 parent eac899b commit 726dc4e

File tree

6 files changed

+33
-15
lines changed

6 files changed

+33
-15
lines changed

PrinterApp/App.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ private void MainWindowClosing(object? sender, System.ComponentModel.CancelEvent
8787
return;
8888
}
8989

90+
Marketing.ManualShutdown();
9091
_printerModel.SocketsClose();
9192
_autoUpdater.StopTimer();
9293
Current.Shutdown();

PrinterApp/MainWindow.xaml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ResizeMode="NoResize"
1313
Topmost="True"
1414
ShowInTaskbar="False"
15-
d:DataContext="{d:DesignInstance local:PrinterViewModel}">
15+
d:DataContext="{d:DesignInstance local:PrinterViewModel}" Focusable="False">
1616
<Viewbox Stretch="Fill" KeyDown="UIElement_OnKeyDown">
1717
<Canvas x:Name="RootCanvas" Background="{DynamicResource App.Background}" Height="900" Width="1600">
1818
<Canvas Height="900" Width="1600" Visibility="{Binding FlakesVisibility}">
@@ -43,11 +43,12 @@
4343
</Canvas>
4444
<Image Width="212" Height="212" Source="{Binding PrintQr}" HorizontalAlignment="Left"
4545
VerticalAlignment="Top" Canvas.Left="219" Canvas.Top="485"
46-
Visibility="{Binding PrintQrVisibility}" />
46+
Visibility="{Binding PrintQrVisibility}" Focusable="False" />
4747
<Rectangle Width="3" Height="590" Canvas.Left="684" Canvas.Top="155"
48-
Fill="{DynamicResource Labels.Foreground}" />
48+
Fill="{DynamicResource Labels.Foreground}" Focusable="False" />
4949
<TextBlock FontSize="24" Width="641" Height="449" Canvas.Left="814" Canvas.Top="57" TextWrapping="Wrap"
50-
Foreground="{DynamicResource Labels.Foreground}" FontFamily="Roboto" FontWeight="Bold">
50+
Foreground="{DynamicResource Labels.Foreground}" FontFamily="Roboto" FontWeight="Bold"
51+
Focusable="False">
5152
<Run
5253
Text="0) Подключись со своего устройства к интернету. Можно воспользоваться сетями Wi-Fi в холле ЦФА или гостевым Wi-Fi PKFF_Free. " />
5354
<LineBreak />
@@ -59,24 +60,25 @@
5960
</TextBlock>
6061
<TextBlock Text="Приложение Твой ФФ!" FontSize="24" Width="256" Height="28" Canvas.Left="854"
6162
Canvas.Top="540" TextWrapping="Wrap" Foreground="{DynamicResource Labels.Foreground}"
62-
FontWeight="Bold" />
63+
FontWeight="Bold" Focusable="False" />
6364
<TextBlock Text="Бот принтера ВК" FontSize="24" Width="189" Height="28" Canvas.Left="1208"
6465
Canvas.Top="540"
65-
TextWrapping="Wrap" Foreground="{DynamicResource Labels.Foreground}" FontWeight="Bold" />
66+
TextWrapping="Wrap" Foreground="{DynamicResource Labels.Foreground}" FontWeight="Bold"
67+
Focusable="False" />
6668
<TextBlock Text="app.profcomff.com" FontSize="24" Width="209" Height="28" Canvas.Left="878"
6769
Canvas.Top="815" TextWrapping="Wrap" Foreground="{DynamicResource Labels.Foreground}"
68-
FontWeight="Bold" />
70+
FontWeight="Bold" Focusable="False" />
6971
<TextBlock Text="vk.me/profcomff_print_bot" FontSize="24" Width="290" Height="28" Canvas.Left="1158"
7072
Canvas.Top="815" TextWrapping="Wrap" Foreground="{DynamicResource Labels.Foreground}"
71-
FontWeight="Bold" HorizontalAlignment="Left" VerticalAlignment="Center" />
73+
FontWeight="Bold" HorizontalAlignment="Left" VerticalAlignment="Center" Focusable="False" />
7274
<Rectangle Width="212" Height="212" Fill="{DynamicResource Qr.AppProfcomffCom}" Canvas.Left="876"
73-
Canvas.Top="591" HorizontalAlignment="Center" VerticalAlignment="Top" />
75+
Canvas.Top="591" HorizontalAlignment="Center" VerticalAlignment="Top" Focusable="False" />
7476
<Rectangle Width="212" Height="212" Fill="{DynamicResource Qr.ProfcomffPrint}" Canvas.Left="1197"
75-
Canvas.Top="591" HorizontalAlignment="Left" VerticalAlignment="Center" />
77+
Canvas.Top="591" HorizontalAlignment="Left" VerticalAlignment="Center" Focusable="False" />
7678
<TextBlock Text="{Binding Compliment}" TextWrapping="Wrap"
7779
Foreground="{DynamicResource Labels.Foreground}" FontFamily="Roboto" FontWeight="Bold"
7880
FontSize="24" Canvas.Left="120" Canvas.Top="485" Height="152" Width="410"
79-
HorizontalAlignment="Left" VerticalAlignment="Top" />
81+
HorizontalAlignment="Left" VerticalAlignment="Top" Focusable="False" />
8082
<Grid Canvas.Left="120" Canvas.Top="263" Width="410">
8183
<TextBlock Text="Код документа для печати" FontSize="24" TextWrapping="Wrap"
8284
Foreground="{DynamicResource Labels.Foreground}" FontWeight="Bold" Margin="0,0,104,158" />
@@ -88,7 +90,7 @@
8890
IsEnabled="{Binding DownloadNotInProgress}"
8991
TextAlignment="Center" Style="{DynamicResource MyTextBoxStyle1}"
9092
VerticalContentAlignment="Center"
91-
HorizontalContentAlignment="Center" Margin="0,29,0,105" />
93+
HorizontalContentAlignment="Center" Margin="0,29,0,105" TabIndex="1" />
9294
<TextBlock IsHitTestVisible="False" Text="Введите код здесь" VerticalAlignment="Top"
9395
HorizontalAlignment="Center" Margin="0,41,0,0" Foreground="DarkGray" FontSize="24">
9496
<TextBlock.Style>
@@ -107,9 +109,9 @@
107109
Background="Red" Foreground="White"
108110
Content="{Binding ErrorTextBlockText, FallbackValue=123}"
109111
Padding="0,0,0,0" Margin="0,157,0,0" Visibility="{Binding ErrorTextBlockVisibility}" />
110-
<Button Content="Распечатать сразу" Click="Print_OnClick"
112+
<Button x:Name="ButtonPrint" Content="Распечатать сразу" Click="Print_OnClick"
111113
Style="{DynamicResource MyButtonStyle}" FontSize="20"
112-
IsEnabled="{Binding DownloadNotInProgress}" Margin="0,92,0,42" />
114+
IsEnabled="{Binding DownloadNotInProgress}" Margin="0,92,0,42" Focusable="True" TabIndex="2" />
113115
</Grid>
114116
</Canvas>
115117
</Viewbox>

PrinterApp/MainWindow.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public MainWindow(PrinterModel printerModel)
9999
Topmost = false;
100100
ShowInTaskbar = true;
101101
#endif
102+
_printerModel.PrintAsyncCompleteEvent += () => { CodeBox.Focus(); };
102103
Marketing.MainWindowLoaded();
103104
}
104105

PrinterApp/Marketing.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@ public static void ManualReboot()
153153
pathTo: "");
154154
}
155155

156+
public static void ManualShutdown()
157+
{
158+
Post(
159+
action: "print terminal manual shutdown",
160+
status: "ok",
161+
pathFrom: "",
162+
pathTo: "");
163+
}
164+
156165
public static void SocketException(string status)
157166
{
158167
Post(

PrinterApp/PrinterApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Title>PrinterApp</Title>
1212
<Description>gui fo work https://app.profcomff.com/print/docs</Description>
1313
<Authors>Dyakov EI</Authors>
14-
<Version>2.1.3.0</Version>
14+
<Version>2.1.4.0</Version>
1515
<Company>dyakov.space</Company>
1616
<Copyright>dyakov.space @ 2022</Copyright>
1717
</PropertyGroup>

PrinterApp/PrinterModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public class PrinterModel
4949

5050
public event RebootHandler? Reboot;
5151

52+
public delegate void PrintAsyncCompleteHandler();
53+
54+
public event PrintAsyncCompleteHandler? PrintAsyncCompleteEvent;
55+
5256
public PrinterModel(ConfigFile configFile, AutoUpdater autoUpdater)
5357
{
5458
_configFile = configFile;
@@ -191,6 +195,7 @@ await _httpClient.GetStreamAsync(
191195
PrinterViewModel.DownloadNotInProgress = true;
192196
Log.Debug(
193197
$"{GetType().Name} {MethodBase.GetCurrentMethod()?.Name}: End response code {PrinterViewModel.CodeTextBoxText}");
198+
PrintAsyncCompleteEvent?.Invoke();
194199
}
195200

196201
public bool WrongExitCode()

0 commit comments

Comments
 (0)