Пример #1
0
        /// <summary>
        /// Right mouse button action that  choses shape
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DrawCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            int count = 0;

            Point t = e.GetPosition((UIElement)sender);

            for (int i = 0; i < collection.Count; ++i)
            {
                HitTestResult result = VisualTreeHelper.HitTest(collection[i].shape, t);
                if (result != null)
                {
                    IsDraw = true;
                    count++;
                    MessageBox.Show("Found!");
                    //i.IsChosen = !i.IsChosen;
                    polygonCanvas.CurrentPolygon        = collection[i];
                    polygonCanvas.CurrentPolygon.Stroke = MyPolygon.FromBrush(Brushes.Red); break;
                }
                else
                {
                    polygonCanvas.CurrentPolygon = new MyPolygon();
                }
            }
            if (count == 0)
            {
                IsDraw = false;
            }
        }
Пример #2
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            int q = comboBox.SelectedIndex;

            switch (q)
            {
            case 0: testPolygon.Fill = MyPolygon.FromBrush(Brushes.Purple); break;

            case 1: testPolygon.Fill = MyPolygon.FromBrush(Brushes.Black); break;

            case 2: testPolygon.Fill = MyPolygon.FromBrush(Brushes.Red); break;

            case 3: testPolygon.Fill = MyPolygon.FromBrush(Brushes.Green); break;

            case 4: testPolygon.Fill = MyPolygon.FromBrush(Brushes.Pink); break;

            default:
                break;
            }
            this.Close();
        }
Пример #3
0
 public PolygonCanvas()
 {
     this.PolTemp        = new MyPolygon();
     this.PolTemp.Stroke = MyPolygon.FromBrush(Brushes.Green);
     this.PolTemp.shape.StrokeThickness = MyPolygon.DefaultStrokeThickness;
 }