Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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.
        }