0
私はこの「面白い」問題に直面しました。 wpfウィンドウにボタンがあり、それを押すと、長方形が表示され、メインウィンドウのサイズに拡大されます。次に、そのテキストを中央に配置するために四角形内に保持します。この後、スクリプトからWebから画像をダウンロードして実行を開始します。しかし...私はボタンを押すと、私の長方形は見えにならず、その代わりにexeファイルが画像のダウンロードを開始します...私はコードが順番に実行されなければならないと思った...目的のスクリプトの前にイメージをダウンロードして実行中
On button_1 press(blah blah){
expander1.IsExpanded = false; //just an expander i use to hide a few elements
pleasewait.Visibility = Visibility.Visible; //pleasewait - rectangle
plswait_label.Visibility = Visibility.Visible; // plswait_lable - label
pleasewait.Height = window_main.Height;
pleasewait.Width = window_main.Width;
plswait_label.HorizontalAlignment = HorizontalAlignment.Center;
plswait_label.VerticalAlignment = VerticalAlignment.Center;
image1.Source = null; // dumping previous image before downloading a new one
//This is the script to download the image and do some other stuff..
string path = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
Uri urlUri = new Uri(address.Text);
var request = WebRequest.CreateDefault(urlUri);
byte[] buffer = new byte[4096];
using (var target = new FileStream(path + @"\Temp\br_temp.png", FileMode.Create, FileAccess.Write))
{
using (var response = request.GetResponse())
{
using (var stream = response.GetResponseStream())
{
int read;
while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
{
target.Write(buffer, 0, read);
}
}
}
}
Bitmap resizedImage;
System.Drawing.Size newSize = new System.Drawing.Size(266, 150);
using (System.Drawing.Image originalImage = System.Drawing.Image.FromFile(path + @"\Temp\br_temp.png"))
resizedImage = new System.Drawing.Bitmap(originalImage, newSize);
resizedImage.Save(path + @"\Temp\temp.png", System.Drawing.Imaging.ImageFormat.Jpeg);
resizedImage.Dispose();
BitmapImage MainImage = new BitmapImage();
MainImage.BeginInit();
MainImage.UriSource = new Uri(path + @"\Temp\temp.png");
MainImage.DecodePixelWidth = 266;
MainImage.DecodePixelHeight = 150;
MainImage.EndInit();
image1.Source = MainImage;
}
十分おかしいです、ダウンロードしたコードを削除すると、矩形が実際に何をしたいのですか。