コード例 #1
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 8 "..\..\..\WPFClass\VisualObject.xaml"
                ((LinqFunctions.WPFClass.VisualObject)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden

            #line 8 "..\..\..\WPFClass\VisualObject.xaml"
                ((LinqFunctions.WPFClass.VisualObject)(target)).MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Window_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 8 "..\..\..\WPFClass\VisualObject.xaml"
                ((LinqFunctions.WPFClass.VisualObject)(target)).MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Window_MouseRightButtonDown);

            #line default
            #line hidden
                return;

            case 2:
                this.MyPanel = ((LinqFunctions.WPFClass.MyPanel)(target));
                return;
            }
            this._contentLoaded = true;
        }
コード例 #2
0
        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point         clickpoint = e.GetPosition(this.MyPanel);
            DrawingVisual dv         = new DrawingVisual();

            this.drawRect(dv, clickpoint);
            MyPanel.AddChild(dv);
        }
コード例 #3
0
        private void Window_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point         clickpoint = e.GetPosition(this.MyPanel);
            DrawingVisual dv         = MyPanel.GetVisual(clickpoint);

            if (dv == null)
            {
                return;
            }
            MyPanel.RemoveChild(dv);
        }
コード例 #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DrawingVisual  dv    = new DrawingVisual();
            DrawingContext dc    = dv.RenderOpen();
            Brush          brush = Brushes.LightGreen;
            Pen            pen   = new Pen(Brushes.SteelBlue, 3);

            dc.DrawRectangle(brush, pen, new Rect(new Point(10, 10), new Size(50, 25)));
            dc.DrawEllipse(brush, pen, new Point(10, 60), 50, 25);
            dc.DrawLine(pen, new Point(10, 100), new Point(80, 120));
            dc.Close();
            MyPanel.AddChild(dv);
        }