Esempio n. 1
0
        public MainPage()
        {
            this.InitializeComponent();
            _model                   = new Model();
            _presentationModel       = new PresentationModel.PresentationModel(_model, _canvas);
            _buttonControl           = new ButtonControl();
            _canvas.PointerPressed  += HandleCanvasPressed;
            _canvas.PointerReleased += HandleCanvasReleased;
            _canvas.PointerMoved    += HandleCanvasMoved;

            _circleButton.Click    += HandleCircleButtonClick;
            _rectangleButton.Click += HandleRectangleButtonClick;
            _smileButton.Click     += HandleSmileButtonClick;
            _undoButton.Click      += HandleUndoButtonClick;
            _redoButton.Click      += HandleRedoButtonClick;
            _deleteButton.Click    += HandleDeleteButtonClick;
            _clearButton.Click     += HandleClearButtonClick;
            _saveButton.Click      += HandleSaveButtonClick;
            _colorButton.Click     += HandleChangeColorButtonClick;
            _exitButton.Click      += HandleExitButtonClick;
            _model._modelChanged   += HandleModelChanged;

            Color color = Color.FromArgb((byte)_colors[ALPHA], (byte)_colors[0], (byte)_colors[1], (byte)_colors[BLUE]);

            _showColorBorder.Background = new SolidColorBrush(color);
            _redTextBox.Text            = _colors[0].ToString();
            _greenTextBox.Text          = _colors[1].ToString();
            _blueTextBox.Text           = _colors[BLUE].ToString();

            _redTextBox.LostFocus   += ChangeColor;
            _greenTextBox.LostFocus += ChangeColor;
            _blueTextBox.LostFocus  += ChangeColor;

            _model.ChangeShape(CIRCLE_TYPE);
            _model.ChangeColor(_colors);
            RefreshButton();
        }
Esempio n. 2
0
        public DrawingForm()
        {
            InitializeComponent();
            // prepare canvas
            _canvas.Dock       = DockStyle.Fill;
            _canvas.BackColor  = System.Drawing.Color.White;
            _canvas.MouseDown += HandleCanvasPressed;
            _canvas.MouseUp   += HandleCanvasReleased;
            _canvas.MouseMove += HandleCanvasMoved;
            _canvas.Paint     += HandleCanvasPaint;
            Controls.Add(_canvas);
            // event handler
            _circleToolStripButton.Click        += HandleCircleButtonClick;
            _rectangleToolStripButton.Click     += HandleRectangleButtonClick;
            _smileToolStripButton.Click         += HandleSmileButtonClick;
            _redoToolStripButton.Click          += HandleRedoButtonClick;
            _undoToolStripButton.Click          += HandleUndoButtonClick;
            _deleteToolStripButton.Click        += HandleDeleteButtonClick;
            _clearToolStripButton.Click         += HandleClearButtonClick;
            _saveToolStripButton.Click          += HandleSaveButtonClick;
            _colorToolStripButton.Click         += HandleChangeColorButtonClick;
            _showColorToolStripButton.BackColor  = Color.FromArgb(_colors[3], _colors[0], _colors[1], _colors[2]);
            _saveToDriveToolStripMenuItem.Click += HandleSaveButtonClick;
            _exitToolStripMenuItem.Click        += HandleExitButtonClick;
            // prepare presentation model and model
            _model                = new Model();
            _presentationModel    = new PresentationModel.PresentationModel(_model);
            _buttonControl        = new ButtonControl();
            _model._modelChanged += HandleModelChanged;
            _model.ChangeShape(CIRCLE_TYPE);
            _model.ChangeColor(_colors);

            Graphics graphic = Graphics.FromHwnd(this.Handle);

            _presentationModel.GetFileFromDrive(graphic);
            HandleModelChanged();
        }