private void zoomin_btn_Click(object sender, RoutedEventArgs e) { //chnage the size of the image (with the ImageDecon2 class) and the size of the ellipse. images[image_number].zoom_number = images[image_number].zoom_number * 2; images[image_number].ell.Width = ball_sb.Value / images[image_number].resx * images[image_number].zoom_number; images[image_number].ell.Height = ball_sb.Value / images[image_number].resy * images[image_number].zoom_number; images[image_number].ell.Margin = new Thickness((canvas.Width - ball_sb.Value / images[image_number].resx * images[image_number].zoom_number) / 2, (canvas.Height - ball_sb.Value / images[image_number].resy * images[image_number].zoom_number) / 2, 0, 0); images[image_number].ell2.Width = cone_sb.Value / images[image_number].resx * images[image_number].zoom_number; images[image_number].ell2.Height = cone_sb.Value / images[image_number].resy * images[image_number].zoom_number; images[image_number].ell2.Margin = new Thickness((canvas.Width - cone_sb.Value / images[image_number].resx * images[image_number].zoom_number) / 2, (canvas.Height - cone_sb.Value / images[image_number].resy * images[image_number].zoom_number) / 2, 0, 0); ImageDecon2.ImageDecon2 id2 = new ImageDecon2.ImageDecon2(); images[image_number].bmp = id2.DrawImage(images[image_number].f, images[image_number].pixels, images[image_number].zoom_number); //BitmapSource bmp = id2.DrawImage(frame, pixels); field_img.Source = images[image_number].bmp; }
private void next_btn_Click(object sender, RoutedEventArgs e) { canvas.Children.Clear(); image_number++; //if the image number exceeds the maximum number count, return to the first iamge. image_numbermax = images.Count(); if (image_number >= image_numbermax) { image_number = 0; } canvas.Children.Add(images[image_number].ell); canvas.Children.Add(images[image_number].ell2); //draw the bitmap for the next image. ImageDecon2.ImageDecon2 id2 = new ImageDecon2.ImageDecon2(); images[image_number].bmp = id2.DrawImage(images[image_number].f, images[image_number].pixels, images[image_number].zoom_number); field_img.Source = images[image_number].bmp; }
private void previous_btn_Click(object sender, RoutedEventArgs e) { canvas.Children.Clear(); image_number--; image_numbermax = images.Count(); //reset to the last image if previous is pushed on the first image. if (image_number < 0) { image_number = image_numbermax - 1; } canvas.Children.Add(images[image_number].ell); canvas.Children.Add(images[image_number].ell2); //generate the bitmap for the previous image. ImageDecon2.ImageDecon2 id2 = new ImageDecon2.ImageDecon2(); images[image_number].bmp = id2.DrawImage(images[image_number].f, images[image_number].pixels, images[image_number].zoom_number);; field_img.Source = images[image_number].bmp; }
private void zoomout_btn_Click(object sender, RoutedEventArgs e) { images[image_number].zoom_number = images[image_number].zoom_number / 2; if (images[image_number].zoom_number < 1) { images[image_number].zoom_number = 1; } images[image_number].ell.Width = ball_sb.Value / images[image_number].resx * images[image_number].zoom_number; images[image_number].ell.Height = ball_sb.Value / images[image_number].resy * images[image_number].zoom_number; images[image_number].ell.Margin = new Thickness((canvas.Width - ball_sb.Value / images[image_number].resx * images[image_number].zoom_number) / 2, (canvas.Height - ball_sb.Value / images[image_number].resy * images[image_number].zoom_number) / 2, 0, 0); images[image_number].ell2.Width = cone_sb.Value / images[image_number].resx * images[image_number].zoom_number; images[image_number].ell2.Height = cone_sb.Value / images[image_number].resy * images[image_number].zoom_number; images[image_number].ell2.Margin = new Thickness((canvas.Width - cone_sb.Value / images[image_number].resx * images[image_number].zoom_number) / 2, (canvas.Height - cone_sb.Value / images[image_number].resy * images[image_number].zoom_number) / 2, 0, 0); ImageDecon2.ImageDecon2 id2 = new ImageDecon2.ImageDecon2(); images[image_number].bmp = id2.DrawImage(images[image_number].f, images[image_number].pixels, images[image_number].zoom_number); //BitmapSource bmp = id2.DrawImage(frame, pixels); field_img.Source = images[image_number].bmp; }
private void getImages_btn_Click(object sender, RoutedEventArgs e) { images.Clear(); int i_num = 0; int zoom_initial = 1; //get all the grids that make up all the fields. IEnumerable <Grid> grid_collections = Fields.Children.OfType <Grid>(); foreach (Grid gr in grid_collections) { //for each field, find the checkbox that denotes all the images. IEnumerable <CheckBox> cb_collections = gr.Children.OfType <CheckBox>(); int field_numb = Convert.ToInt16(gr.Name.Split('_').Last()); foreach (CheckBox sb in cb_collections) { //check if the checkbox for each of the images is checked, if so, create a WLImage in memory. if ((bool)sb.IsChecked) { images.Add(new WL_Image { image_id = i_num, WLfield = PD_AdvAnalysis.MainWindow.plan.Beams[field_numb], zoom_number = zoom_initial, f = PD_AdvAnalysis.MainWindow.plan.Beams[field_numb].PortalDoseImages.Where(j => j.Id == sb.Content.ToString()).First().Image.Frames[0], WLBeam = PD_AdvAnalysis.MainWindow.plan.Beams[field_numb].Beam, resx = PD_AdvAnalysis.MainWindow.plan.Beams[field_numb].PortalDoseImages.First(j => j.Id == sb.Content.ToString()).Image.Frames[0].XRes, resy = PD_AdvAnalysis.MainWindow.plan.Beams[field_numb].PortalDoseImages.First(j => j.Id == sb.Content.ToString()).Image.Frames[0].YRes }); images.Last().ell = new Ellipse { Width = ball_sb.Value / images.Last().resx *zoom_initial, Name = "ball_ell", Height = ball_sb.Value / images.Last().resy *zoom_initial, Stroke = System.Windows.Media.Brushes.Black, StrokeThickness = 3, Margin = new Thickness((canvas.Width - ball_sb.Value / images.Last().resx *zoom_initial) / 2, (canvas.Height - ball_sb.Value / images.Last().resy *zoom_initial) / 2, 0, 0), }; images.Last().ell2 = new Ellipse { Width = cone_sb.Value / images.Last().resx *zoom_initial, Name = "cone_ell", Height = cone_sb.Value / images.Last().resy *zoom_initial, Stroke = System.Windows.Media.Brushes.Green, StrokeThickness = 3, Margin = new Thickness((canvas.Width - cone_sb.Value / images.Last().resx *zoom_initial) / 2, (canvas.Height - cone_sb.Value / images.Last().resy *zoom_initial) / 2, 0, 0), }; //event handlers for moving the ellipse. images[i_num].ell.MouseDown += Ell_MouseDown; images[i_num].ell.MouseUp += Ell_MouseUp; images[i_num].ell.MouseMove += Ell_MouseMove; images[i_num].ell2.MouseDown += Ell_MouseDown; images[i_num].ell2.MouseUp += Ell_MouseUp; images[i_num].ell2.MouseMove += Ell_MouseMove; //get the pixels and the frame of the new image. images[i_num].pixels = new ushort[images[i_num].f.XSize, images[i_num].f.YSize]; images[i_num].f.GetVoxels(0, images[i_num].pixels); i_num++; } } } canvas.Children.Clear(); canvas.Children.Add(images[image_number].ell); canvas.Children.Add(images[image_number].ell2); //create the bitmap for the first field (image number is 0 until changed with the next or previous button. ImageDecon2.ImageDecon2 id2 = new ImageDecon2.ImageDecon2(); images[image_number].bmp = id2.DrawImage(images[image_number].f, images[image_number].pixels, images[image_number].zoom_number); //BitmapSource bmp = id2.DrawImage(frame, pixels); field_img.Source = images[image_number].bmp; }