/// <summary> /// When user clicks on Delete selected Image button, call comes here. /// </summary> private void OnDeleteSelectedImage() { //Start- Remove the ImageControl being deleted from View, Pathdictionary, ImagecontrolControllerList, its state from model. PclsMainWindowView.ImageCanvas.Children.Remove(ActiveImageControlController.GetView()); _dctImagePaths.Remove(ActiveImageControlController.GetHashCode()); ImageControlControllerList.Remove(ActiveImageControlController); PclsMainWindowModel.DeleteFilterStateFromDataTable(ActiveImageControlController.GetHashCode()); //End- Remove the ImageControl being deleted from View, Pathdictionary, ImagecontrolControllerList //Start- Destroy the object. ActiveImageControlController.ClearData(); ActiveImageControlController = null; //End- Destroy the object. //Start- Set any other image control controller as selected or reset everything to default. if (ImageControlControllerList.Count > 0) { _activeImageControlController = ImageControlControllerList.Last(); _activeImageControlController.RegisterImageControlEvents(); _activeImageControlController.Notify("UpdateImageControlStyle", null); _activeImageControlController.SetSelectedState(emSelectedState.Selected); PclsMainWindowView.FileNameTextBox.Text = _dctImagePaths[ActiveImageControlController.GetHashCode()]; PclsMainWindowModel.ImportFilterStateToModel(ActiveImageControlController.GetHashCode()); } else { PclsMainWindowModel.SetDefaultModelState(); PclsMainWindowView.FileNameTextBox.Text = ""; PclsMainWindowViewModel.OnPropertyChange("IsImageOperationsPanelEnabled"); PclsMainWindowViewModel.OnPropertyChange("IsDeleteButtonEnabled"); } //End- Set any other image control controller as selected or reset everything to default. }
/// <summary> /// Called from BrowseButtonClick method to pass the info that the image has been selected and ok is pressed. /// </summary> /// <param name="imagePath">Path of the selected image.</param> public void OnImageLoad(string imagePath) { //Start- Remove the style of previous imagecontrol and export its state. also set the model to default values. if (_activeImageControlController != null) { _activeImageControlController.RemoveStyle(); PclsMainWindowModel.ExportFilterStateToDataTable(_activeImageControlController.GetHashCode()); _activeImageControlController.UnRegisterImageControlEvents(); } PclsMainWindowModel.SetDefaultModelState(); //End- Remove the style of previous imagecontrol and export its state. also set the model to default values. //Start- Create new ImageControl and add it to Imagecontrolcontrollerlist, its view to canvas, add its path, and its state to model. _activeImageControlController = new ImageControlController(this); _lstImageControlController.Add(_activeImageControlController); _dctImagePaths.Add(_activeImageControlController.GetHashCode(), imagePath); PclsMainWindowModel.ExportFilterStateToDataTable(_activeImageControlController.GetHashCode()); PclsMainWindowView.ImageCanvas.Children.Add(ActiveImageControlController.GetView()); //End- Create new ImageControl and add it to Imagecontrolcontrollerlist, its view to canvas, add its path, and its state to model. //Render the image and set its canvas position. ActiveImageControlController.RenderImage(imagePath); //Update window states and image style. PclsMainWindowViewModel.OnPropertyChange("IsImageOperationsPanelEnabled"); PclsMainWindowViewModel.OnPropertyChange("IsDeleteButtonEnabled"); _activeImageControlController.Notify("UpdateImageControlStyle", null); }
/// <summary> /// When image selection is changed, this method is called from ImageControlController. /// </summary> /// <param name="imagecontrol">The current Imagecontrol being selected.</param> public void OnImageSelected(INotifier imagecontrol) { if (imagecontrol.GetHashCode() != ActiveImageControlController.GetHashCode()) { ActiveImageControlController.RemoveStyle(); ActiveImageControlController.UnRegisterImageControlEvents(); PclsMainWindowModel.ExportFilterStateToDataTable(ActiveImageControlController.GetHashCode()); ActiveImageControlController = imagecontrol as ImageControlController; ActiveImageControlController.RegisterImageControlEvents(); ActiveImageControlController.Notify("UpdateImageControlStyle", null); PclsMainWindowView.FileNameTextBox.Text = _dctImagePaths[ActiveImageControlController.GetHashCode()]; PclsMainWindowModel.ImportFilterStateToModel(ActiveImageControlController.GetHashCode()); } }
/// <summary> /// Called on application exit to clear all the references. /// </summary> public override void ClearData() { foreach (ImageControlController obj in ImageControlControllerList) { obj.ClearData(); } ImageControlControllerList.Clear(); _dctImagePaths.Clear(); _activeImageControlController = null; PclsMainWindowView.ClearData(); PclsMainWindowViewModel.ClearData(); PclsMainWindowModel.ClearData(); base.ClearData(); }
public ImageControlModel(ImageControlController _parent) : base(_parent) { SetDefaultModelState(); }