Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Боев Андрей Олегович
ReadySetPrint
Commits
b04eed5c
Commit
b04eed5c
authored
6 months ago
by
Боев Андрей Олегович
Browse files
Options
Download
Patches
Plain Diff
add preparation for the photo processing process
parent
22e7b5c3
main
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ReadySetPrint/MainWindow.xaml
+6
-24
ReadySetPrint/MainWindow.xaml
ReadySetPrint/MainWindow.xaml.cs
+62
-3
ReadySetPrint/MainWindow.xaml.cs
with
68 additions
and
27 deletions
+68
-27
ReadySetPrint/MainWindow.xaml
+
6
−
24
View file @
b04eed5c
...
...
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ReadySetPrint"
mc:Ignorable="d"
Title="ReadySetPrint" Height="
4
00" Width="640" ResizeMode="NoResize" Icon="/logo.png">
Title="ReadySetPrint" Height="
5
00" Width="640" ResizeMode="NoResize" Icon="/logo.png">
<StackPanel HorizontalAlignment="Center">
<StackPanel Orientation="Horizontal">
<Button Content="Выбрать папку" Width="100" Margin="5" Name="BtnChooseFolder" Click="BtnChooseFolder_Click"></Button>
...
...
@@ -13,7 +13,7 @@
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Расположение:" VerticalAlignment="Center" Margin="5"></TextBlock>
<ComboBox Width="100" Margin="5" SelectedIndex="0" Name="CBPosition"
SelectionChanged="CBPosition_SelectionChanged"
>
<ComboBox Width="100" Margin="5" SelectedIndex="0" Name="CBPosition">
<ComboBoxItem Content="center"></ComboBoxItem>
<ComboBoxItem Content="top"></ComboBoxItem>
<ComboBoxItem Content="bottom"></ComboBoxItem>
...
...
@@ -26,34 +26,16 @@
<StackPanel Orientation="Horizontal">
<StackPanel>
<TextBlock Text="Исходные фото:" Margin="5 5 5 0"></TextBlock>
<ListView Margin="5" Width="300" Height="191" Name="LVOriginalPhotos">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Margin="5"></TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView Margin="5" Width="300" Height="291" Name="LVOriginalPhotos"></ListView>
</StackPanel>
<StackPanel Orientation="Vertical">
<TextBlock Text="Обработанные фото:" Margin="5 5 5 0"></TextBlock>
<ListView Margin="5" Width="300" Height="80">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Margin="5"></TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView Margin="5" Width="300" Height="130" Name="LVReadyPhotos"></ListView>
<TextBlock Text="Отбракованные фото:" Margin="5 5 5 0"></TextBlock>
<ListView Margin="5" Width="300" Height="80">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Margin="5"></TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView Margin="5" Width="300" Height="130" Name="LVDefectPhotos"></ListView>
</StackPanel>
</StackPanel>
<Button Content="Обработать изображения" Margin="5" Height="30"></Button>
<Button Content="Обработать изображения" Margin="5" Height="30"
Name="BtnStartProcess" Click="BtnStartProcess_Click"
></Button>
<ProgressBar Name="PBStatus" Margin="5" Height="20"></ProgressBar>
</StackPanel>
</Window>
This diff is collapsed.
Click to expand it.
ReadySetPrint/MainWindow.xaml.cs
+
62
−
3
View file @
b04eed5c
...
...
@@ -12,8 +12,8 @@ using System.Windows.Media;
using
System.Windows.Media.Imaging
;
using
System.Windows.Navigation
;
using
System.Windows.Shapes
;
using
System.Windows.Forms
;
using
System.Drawing
;
using
System.IO
;
//using ImageMagick;
namespace
ReadySetPrint
...
...
@@ -33,11 +33,25 @@ namespace ReadySetPrint
private
void
BtnChooseFolder_Click
(
object
sender
,
RoutedEventArgs
e
)
{
using
(
var
dlg
=
new
FolderBrowserDialog
())
using
(
var
dlg
=
new
System
.
Windows
.
Forms
.
FolderBrowserDialog
())
{
if
(
dlg
.
ShowDialog
()
==
System
.
Windows
.
Forms
.
DialogResult
.
OK
)
{
_folderPath
=
dlg
.
SelectedPath
;
var
images
=
Directory
.
GetFiles
(
_folderPath
,
"*.*"
)
.
Where
(
f
=>
f
.
EndsWith
(
".jpg"
)
||
f
.
EndsWith
(
".png"
))
.
ToList
();
if
(
images
.
Count
==
0
)
{
MessageBox
.
Show
(
"В папке отсутствуют фото в формате .png или .jpg"
,
"Ошибка"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Error
);
_folderPath
=
""
;
return
;
}
foreach
(
var
image
in
images
)
{
LVOriginalPhotos
.
Items
.
Add
(
image
.
Replace
(
_folderPath
+
"\\"
,
""
));
}
TBPath
.
Text
=
"Путь: "
+
dlg
.
SelectedPath
;
}
}
...
...
@@ -45,7 +59,7 @@ namespace ReadySetPrint
private
void
BtnChooseColor_Click
(
object
sender
,
RoutedEventArgs
e
)
{
using
(
ColorDialog
dlg
=
new
ColorDialog
())
using
(
var
dlg
=
new
System
.
Windows
.
Forms
.
ColorDialog
())
{
if
(
dlg
.
ShowDialog
()
==
System
.
Windows
.
Forms
.
DialogResult
.
OK
)
{
...
...
@@ -54,5 +68,50 @@ namespace ReadySetPrint
}
}
}
private
void
BtnStartProcess_Click
(
object
sender
,
RoutedEventArgs
e
)
{
if
(
_folderPath
==
""
)
{
MessageBox
.
Show
(
"Выберите папку с изображениями."
);
return
;
}
BtnChooseColor
.
IsEnabled
=
false
;
BtnChooseFolder
.
IsEnabled
=
false
;
BtnStartProcess
.
IsEnabled
=
false
;
PBStatus
.
Value
=
0
;
var
images
=
Directory
.
GetFiles
(
_folderPath
,
"*.*"
)
.
Where
(
f
=>
f
.
EndsWith
(
".jpg"
)
||
f
.
EndsWith
(
".png"
))
.
ToList
();
float
progress
=
100
/
images
.
Count
;
foreach
(
var
image
in
images
)
{
bool
result
=
ImageProcess
(
image
,
CBPosition
.
Text
);
if
(
result
)
LVReadyPhotos
.
Items
.
Add
(
image
.
Replace
(
_folderPath
+
"\\"
,
""
));
else
LVDefectPhotos
.
Items
.
Add
(
image
.
Replace
(
_folderPath
+
"\\"
,
""
));
PBStatus
.
Value
+=
progress
;
}
MessageBox
.
Show
(
"Обработка завершена."
,
"Информация"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Information
);
BtnChooseColor
.
IsEnabled
=
true
;
BtnChooseFolder
.
IsEnabled
=
true
;
BtnStartProcess
.
IsEnabled
=
true
;
}
private
bool
ImageProcess
(
string
path
,
string
position
)
{
try
{
return
true
;
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
Message
,
"Ошибка"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Error
);
return
false
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets