Esempio n. 1
0
        // Displays the provided status and message
        public void SetStatusMessage(BitmapEditorStatus status, string message)
        {
            string iconPath = "";
            Color  msgColor = DefaultForeColor;

            if (status == BitmapEditorStatus.OK)
            {
                iconPath = ICON_OK;
                msgColor = COLOR_OK;
            }
            else if (status == BitmapEditorStatus.WARNING)
            {
                iconPath = ICON_WARNING;
                msgColor = COLOR_WARNING;
            }

            // Displaying the icon
            StreamReader streamReader = new StreamReader(iconPath);

            picMessageIcon.Image = (Bitmap)Bitmap.FromStream(streamReader.BaseStream);

            // Changing the status text color and content
            lbMessage.ForeColor = msgColor;
            lbMessage.Text      = message;
        }
        // Checks the editor's current state and transfers data to the view (controls activation, status and message)
        public void CheckEditorState()
        {
            BitmapEditorStatus status  = BitmapEditorStatus.OK;
            string             message = "";
            bool controlsEnabled       = true;

            if (!HasImage())
            {
                // No image was chosen
                status          = BitmapEditorStatus.WARNING;
                message         = "No image chosen";
                controlsEnabled = false;
            }

            else
            {
                // If we have an image,controls are enabled
                controlsEnabled = true;

                bool hasPixelFilter = HasPixelFilter();
                bool hasEdgeFilter  = HasEdgeFilter();

                // Warning if no filter was selected
                if (!hasPixelFilter && !hasEdgeFilter)
                {
                    status  = BitmapEditorStatus.WARNING;
                    message = "No filter applied";
                }

                else
                {
                    if (!hasEdgeFilter)
                    {
                        // Warning if no edge detection filter was applied
                        status  = BitmapEditorStatus.WARNING;
                        message = "No edge detection\nfilter applied";
                    }

                    else
                    {
                        // OK status confirming everything needed was configured/set
                        status  = BitmapEditorStatus.OK;
                        message = "Edge detection\napplied. Ready to save.";
                    }
                }
            }

            // Updating the view
            view.SetControlsEnabled(controlsEnabled);
            view.SetStatusMessage(status, message);
        }