File tree Expand file tree Collapse file tree 2 files changed +55
-5
lines changed Expand file tree Collapse file tree 2 files changed +55
-5
lines changed Original file line number Diff line number Diff line change 28
28
<GeometryModel3D .Material>
29
29
<DiffuseMaterial >
30
30
<DiffuseMaterial .Brush>
31
- <ImageBrush ImageSource =" LetterPaperTest.jpg" />
31
+ <ImageBrush x : Name = " MainImage " ImageSource =" LetterPaperTest.jpg" />
32
32
</DiffuseMaterial .Brush>
33
33
</DiffuseMaterial >
34
34
</GeometryModel3D .Material>
74
74
</Viewbox >
75
75
76
76
<Button
77
+ x : Name =" OpenButton"
77
78
Margin =" 20"
79
+ HorizontalAlignment =" Left"
80
+ VerticalAlignment =" Top"
81
+ Click =" OpenButton_Click"
82
+ Content =" Open Image" />
83
+
84
+ <StackPanel
78
85
HorizontalAlignment =" Right"
79
86
VerticalAlignment =" Bottom"
80
- Click =" SaveButton_Click"
81
- Content =" Save" />
87
+ Orientation =" Horizontal" >
88
+ <Button
89
+ x : Name =" OpenFolder"
90
+ Margin =" 5,20"
91
+ Click =" OpenFolder_Click"
92
+ Content =" Open Folder"
93
+ IsEnabled =" False" />
94
+
95
+ <Button
96
+ x : Name =" SaveButton"
97
+ Margin =" 5,20,20,20"
98
+ Click =" SaveButton_Click"
99
+ Content =" Save" />
100
+ </StackPanel >
82
101
</Grid >
83
102
84
103
</Window >
Original file line number Diff line number Diff line change 1
- using System ;
1
+ using Microsoft . Win32 ;
2
+ using System ;
3
+ using System . Diagnostics ;
2
4
using System . IO ;
3
5
using System . Windows ;
4
6
using System . Windows . Controls ;
@@ -205,13 +207,42 @@ public void SaveButton_Click(object sender, RoutedEventArgs e)
205
207
return ;
206
208
207
209
string imageFileName = $ "{ folder } \\ tempFile.png";
208
- button . Content = imageFileName ;
209
210
210
211
if ( File . Exists ( imageFileName ) )
211
212
File . Delete ( imageFileName ) ;
212
213
213
214
using FileStream fs = new ( imageFileName , FileMode . Create ) ;
214
215
encoder . Save ( fs ) ;
216
+ OpenFolder . IsEnabled = true ;
217
+ button . Content = "Saved as \" tempFile.png\" " ;
218
+ }
219
+
220
+ private void OpenButton_Click ( object sender , RoutedEventArgs e )
221
+ {
222
+ OpenFileDialog openFileDialog = new ( )
223
+ {
224
+ InitialDirectory = Environment . GetFolderPath ( Environment . SpecialFolder . MyPictures ) ,
225
+ Filter = "PNG Files(*.png)|*.png|JPEG Files(*.jpg;*.jpeg)|*.jpg;*.jpeg|All files (*.*)|*.*"
226
+ } ;
227
+
228
+ if ( openFileDialog . ShowDialog ( ) != true )
229
+ return ;
230
+
231
+ BitmapImage bitmap = new ( ) ;
232
+ bitmap . BeginInit ( ) ;
233
+ bitmap . UriSource = new ( openFileDialog . FileName ) ;
234
+ bitmap . EndInit ( ) ;
235
+ MainImage . ImageSource = bitmap ;
236
+ }
237
+
238
+ private void OpenFolder_Click ( object sender , RoutedEventArgs e )
239
+ {
240
+ string ? folder = Path . GetDirectoryName ( System . Reflection . Assembly . GetExecutingAssembly ( ) . Location ) ;
241
+
242
+ if ( folder is null )
243
+ return ;
244
+
245
+ Process . Start ( "explorer.exe" , folder ) ;
215
246
}
216
247
}
217
248
You can’t perform that action at this time.
0 commit comments