/// <summary> /// Creates a new MwiChild and places it in the Children collection /// </summary> public void CreateNewMwiChild() { AnalysisChild child = new AnalysisChild(); double offset = 14; double limit = Math.Floor(((this.ActualWidth - child.MinSize.Width) / offset) - 2); if (Math.Floor(((this.ActualHeight - child.MinSize.Height) / offset) - 2) < limit) { limit = Math.Floor((this.ActualHeight / offset) - 2); } child.Width = this.ActualWidth - (((this.Children.Count % limit) + 1) * offset); child.Height = this.ActualHeight - (((this.Children.Count % limit) + 1) * offset); child.Background = new SolidColorBrush(Colors.Blue); child.BorderBrush = new SolidColorBrush(Colors.Black); child.Icon = new BitmapImage(new Uri("pack://application:,,,/Resources/app.ico")); child.Title = String.Format("My{0}Computer Test 1234567890", zindex); Canvas.SetLeft(child, (((this.Children.Count % limit)) * offset)); Canvas.SetTop(child, (((this.Children.Count % limit)) * offset)); Children.Add(child); }
public void LogChild() { AnalysisChild child = null; getWindow("LogWindow", ref child); System.Windows.Controls.TextBox logTextBox = new System.Windows.Controls.TextBox(); child.Title = @"Log Window"; child.Name = @"LogWindow"; child.AnalysisGrid.Children.Add(logTextBox); }
public void ParameterChild() { AnalysisChild child = null; getWindow("ParameterWindow", ref child); gParameterControl = new ParameterControl(); child.Title = @"Parameter Window"; child.Name = @"ParameterWindow"; child.AnalysisGrid.Children.Add(gParameterControl); }
/// <summary> /// Creates a new MwiChild and places it in the Children collection /// </summary> /// public void getWindow(string name, ref AnalysisChild child) { child = null; // find a imagewindow foreach (AnalysisChild cwin in Children) { if (cwin.Name == name) { child = cwin; return; } } if (child == null) { child = new AnalysisChild(); double offset = 14; Loaded += delegate { this.gwidth = this.ActualWidth; this.gheight = this.ActualHeight; }; if (this.gwidth == 0 && this.gheight == 0) { this.gheight = 1024; this.gwidth = 1284; } double limit = Math.Floor(((gwidth - child.MinSize.Width) / offset) - 2); if (Math.Floor(((gheight - child.MinSize.Height) / offset) - 2) < limit) { limit = Math.Floor((gheight / offset) - 2); } child.Width = gwidth - (((this.Children.Count % limit) + 1) * offset); child.Height = gheight - (((this.Children.Count % limit) + 1) * offset); child.Background = new SolidColorBrush(Colors.Gray); child.BorderBrush = new SolidColorBrush(Colors.Black); child.Icon = new BitmapImage(new Uri("pack://application:,,,/Resources/app.ico")); child.Name = name; Canvas.SetLeft(child, (((this.Children.Count % limit)) * offset)); Canvas.SetTop(child, (((this.Children.Count % limit)) * offset)); Children.Add(child); } }
/// <summary> /// Promotes the child to top-most in the MwiWindow /// </summary> /// <param name="child"></param> public void PromoteChildToFront(AnalysisChild child) { int zindex = Canvas.GetZIndex(child); foreach (AnalysisChild _child in AttachedChildren) //Children) { _child.IsSelected = _child.Equals(child); int _zindex = Canvas.GetZIndex(_child); Canvas.SetZIndex(_child, _child.Equals(child) ? AnalysisWindow.zindex - 1 : _zindex < zindex ? _zindex : _zindex - 1); } if (child.IsSelected && child.IsMinimized) { child.Minimize(true); } this.SelectedChild = child; }
/// <summary> /// Detaches or attaches a child to the MwiWindow /// </summary> /// <param name="child"></param> /// <param name="reverse"></param> public void DetachChild(AnalysisChild child, bool reverse) { if (!reverse) { if (Children.Remove(child)) { DetachedChildren.Add(child); } } else { if (DetachedChildren.Remove(child)) { Children.Add(child); } } }
/// <summary> /// Minimizes a child in the MwiWindow /// </summary> /// <param name="child"></param> /// <param name="reverse"></param> public void MinimizeChild(AnalysisChild child, bool reverse) { if (!reverse) { if (Children.Remove(child)) { MinChildren.Add(child); } } else { if (MinChildren.Remove(child)) { Children.Add(child); } } }
public void SquareToCircleAnalysisChild() { if (_imageanalysis.FringesImage == null) { return; } AnalysisChild child = null; var img = new System.Windows.Controls.Image(); foreach (AnalysisChild cwin in Children) { if (cwin.Title == "SquareWindow") { child = cwin; break; } } if (child == null) { child = new AnalysisChild(); getWindow("SquareWindow", ref child); //System.Windows.Controls.Image img = new System.Windows.Controls.Image(); img.Name = @"ImageViewer"; child.AnalysisGrid.Children.Add(img); } BitmapSource processImage; processImage = _imageanalysis.SquareToCycle(); //processImage = _imageanalysis.CutEdge(_imageanalysis.FringesImage, 0, ref ledge, ref redge, ref tedge, ref bedge); img = new System.Windows.Controls.Image(); foreach (var element in child.AnalysisGrid.Children) { if (element.GetType() == typeof(System.Windows.Controls.Image)) { img = (System.Windows.Controls.Image)element; } } img.Source = processImage; }
/// <summary> /// Creates a new MwiChild and places it in the Children collection /// </summary> public void OpenImageAnalysisChild(string title) { OpenFileDialog op = new OpenFileDialog(); op.Title = "Select a picture"; op.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" + "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" + "Portable Network Graphic (*.png)|*.png"; BitmapSource bitmapsrc; //Bitmap bitmap; if (op.ShowDialog() == DialogResult.OK) { bitmapsrc = new BitmapImage(new Uri(op.FileName)); // read bmp file and convert to gray image. if (bitmapsrc.Format != PixelFormats.Gray8) { bitmapsrc = new FormatConvertedBitmap(bitmapsrc, PixelFormats.Gray8, null, 0); } AnalysisChild child = null; // find a imagewindow foreach (AnalysisChild cwin in Children) { if (cwin.Title == "ImageWindow") { child = cwin; break; } } if (child == null) { child = new AnalysisChild(); double offset = 14; double limit = Math.Floor(((this.ActualWidth - child.MinSize.Width) / offset) - 2); if (Math.Floor(((this.ActualHeight - child.MinSize.Height) / offset) - 2) < limit) { limit = Math.Floor((this.ActualHeight / offset) - 2); } child.Width = this.ActualWidth - (((this.Children.Count % limit) + 1) * offset); child.Height = this.ActualHeight - (((this.Children.Count % limit) + 1) * offset); child.Background = new SolidColorBrush(Colors.Gray); child.BorderBrush = new SolidColorBrush(Colors.Black); //child.Icon = new BitmapImage(new Uri(op.FileName)); child.Icon = bitmapsrc; child.Title = title; System.Windows.Controls.Image img = new System.Windows.Controls.Image(); img.Name = @"ImageViewer"; img.Source = bitmapsrc; child.AnalysisGrid.Children.Add(img); Canvas.SetLeft(child, (((this.Children.Count % limit)) * offset)); Canvas.SetTop(child, (((this.Children.Count % limit)) * offset)); Children.Add(child); } else { var img = new System.Windows.Controls.Image(); foreach (var element in child.AnalysisGrid.Children) { if (element.GetType() == typeof(System.Windows.Controls.Image)) { img = (System.Windows.Controls.Image)element; } } img.Source = bitmapsrc; } if (_imageanalysis == null) { _imageanalysis = new ImageAnalysis(); } _imageanalysis.FringesImage = bitmapsrc; } }