Exemple #1
0
        /// <summary>
        /// runs when mouse is moved over the canvas
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void paper_MouseMove(object sender, MouseEventArgs e)
        {
            if (lmbDown) // only run if left mouse down
            {
                switch (CurrentTool)
                {
                case Tools.ToolType.CreateElement:
                    if (fe != null)
                    {
                        fe.X = e.GetPosition(paper).X;
                        fe.Y = e.GetPosition(paper).Y;

                        fe.RenderTransform = fe.GetTransform();
                    }
                    break;

                case Tools.ToolType.Move:
                    if (result != null)
                    {
                        fe.X = e.GetPosition(paper).X;
                        fe.Y = e.GetPosition(paper).Y;

                        fe.RenderTransform = fe.GetTransform();
                    }
                    break;

                case Tools.ToolType.Erase:
                    Point pt = e.GetPosition((UIElement)sender);

                    result = VisualTreeHelper.HitTest(paper, pt);

                    if (result != null)
                    {
                        if (result.VisualHit.GetType() != typeof(Canvas))
                        {
                            fe = (FestivalElement)result.VisualHit;
                            paper.Children.Remove(fe);
                        }
                    }
                    break;

                case Tools.ToolType.ColourPick:
                    break;

                case Tools.ToolType.ReColour:
                    break;

                case Tools.ToolType.Select:
                    break;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// updates the preview element
        /// </summary>
        void UpdatePreview()
        {
            canvasPreview.Children.Clear();
            FestivalElement previewFE = GetFEType(CurrentFEType, colour, 2, 2);

            previewFE.X = canvasPreview.ActualWidth / 2;
            previewFE.Y = canvasPreview.ActualHeight / 2;
            previewFE.RenderTransform = previewFE.GetTransform();
            previewFE.IsPreview       = true;

            canvasPreview.Children.Add(previewFE);
        }
Exemple #3
0
        // methods which run from mouse activity
        #region Mouse Methods
        private void paper_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            mWindow.Focus();
            Point pt = e.GetPosition((UIElement)sender);

            result = VisualTreeHelper.HitTest(paper, pt);
            // checks which tool is in use
            // tools do what they are called
            switch (CurrentTool)
            {
            case Tools.ToolType.CreateElement:
                fe = GetFEType(CurrentFEType, colour, origScaleX, origScaleY);

                fe.X     = e.GetPosition(paper).X;
                fe.Y     = e.GetPosition(paper).Y;
                fe.Angle = 0;

                fe.RenderTransform = fe.GetTransform();

                paper.Children.Add(fe);
                break;

            case Tools.ToolType.Move:


                if (result != null)
                {
                    if (result.VisualHit.GetType() != typeof(Canvas))
                    {
                        fe = (FestivalElement)result.VisualHit;
                    }
                }
                break;

            case Tools.ToolType.Erase:

                if (result != null)
                {
                    if (result.VisualHit.GetType() != typeof(Canvas))
                    {
                        fe = (FestivalElement)result.VisualHit;
                        paper.Children.Remove(fe);
                    }
                }
                break;

            case Tools.ToolType.ColourPick:
                if (result != null)
                {
                    if (result.VisualHit.GetType() != typeof(Canvas))
                    {
                        // will get element colour
                        fe = (FestivalElement)result.VisualHit;
                        Color c = (fe.BGBrush as SolidColorBrush).Color;
                        colourChange      = true;
                        sliderAlpha.Value = c.A;
                        sliderRed.Value   = c.R;
                        sliderGreen.Value = c.G;
                        sliderBlue.Value  = c.B;
                        colourChange      = false;
                        GetColourFromSlider();
                    }
                    else
                    {
                        // will get background colour
                        Color c = (paper.Background as SolidColorBrush).Color;
                        colourChange      = true;
                        sliderAlpha.Value = c.A;
                        sliderRed.Value   = c.R;
                        sliderGreen.Value = c.G;
                        sliderBlue.Value  = c.B;
                        colourChange      = false;
                        GetColourFromSlider();
                    }
                }
                break;

            case Tools.ToolType.ReColour:
                if (result != null)
                {
                    if (result.VisualHit.GetType() != typeof(Canvas))
                    {
                        fe         = (FestivalElement)result.VisualHit;
                        fe.BGBrush = colour;
                        fe.InvalidateVisual();
                    }
                    else
                    {
                        paper.Background = colour;
                    }
                }
                break;

            case Tools.ToolType.Select:
                if (result != null)
                {
                    if (result.VisualHit.GetType() != typeof(Canvas))
                    {
                        if (selectedFE != null)
                        {
                            selectedFE.OnDeSelection();
                        }
                        selectedFE = (FestivalElement)result.VisualHit;
                        selectedFE.OnSelection();
                        if (gridSelectionTools.Visibility != Visibility.Visible)
                        {
                            gridSelectionTools.Visibility = Visibility.Visible;
                            UpdateElementList();
                        }
                        GetSelectionData();
                    }
                }
                break;
            }

            lmbDown = true;
        }