Beispiel #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);
        }
Beispiel #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.
        }
Beispiel #3
0
 private void FillBackgroundColorBox()
 {
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Black));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.White));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Blue));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Green));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Red));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Yellow));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Cyan));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Turquoise));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Teal));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.LightGray));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Pink));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.DeepPink));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Magenta));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.AliceBlue));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.BlanchedAlmond));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.LightGreen));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.DarkOrchid));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.DarkOrange));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.SteelBlue));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Violet));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Purple));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Thistle));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.Indigo));
     _lstBackgroundColor.Add(new ColorBox(this, Brushes.LimeGreen));
     PclsMainWindowModel.SetDefaultBackgroundColorBox(_lstBackgroundColor.First());
 }
Beispiel #4
0
 /// <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());
     }
 }
Beispiel #5
0
        /// <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();
        }
Beispiel #6
0
 /// <summary>
 /// Whenever Perwitt Edge Detection state is changed, this method will reset the settings and update image.
 /// </summary>
 private void UpdateImageControlOnPerwittEdgeDetectionStateChanged()
 {
     PclsMainWindowModel.SetFiltersToDefault();
     UpdateImageControlOnFilterApply(PclsMainWindowModel.HueValue, PclsMainWindowModel.SaturationFactor, PclsMainWindowModel.BrightnessValue, PclsMainWindowModel.BlurFactor, PclsMainWindowModel.LuminanceFactor, PclsMainWindowModel.ContrastFactor, PclsMainWindowModel.IsPerwittEdgeDetectionChecked);
 }
Beispiel #7
0
 /// <summary>
 /// Subscriber of the SizeChanged event of ImageCanvas UIElement.
 /// </summary>
 /// <param name="sender">ImageCanvas UIElement</param>
 /// <param name="e">SizeChangedEventArgument containing the previous size and the new size.</param>
 internal void OnImageCanvasSizeChanged(object sender, SizeChangedEventArgs e)
 {
     PclsMainWindowModel.OnImageCanvasSizeChanged(sender, e);
 }
Beispiel #8
0
 /// <summary>
 /// Called when user clicks on "Delete Selected Image" button.
 /// </summary>
 public void OnDeleteSelectedImage()
 {
     PclsMainWindowModel.OnDeleteSelectedImage();
 }