Example #1
0
        void DrawLine()
        {
            Stick newStick = new Stick(this.StickArea.ActualWidth, this.StickArea.ActualHeight);

            this.Dispatcher.Invoke(() =>
            {
                Line canvasLine = new Line();
                canvasLine      = newStick.CreateLine();
                this.StickArea.Children.Add(canvasLine);
                lineList.Add(canvasLine);      //LineList keeps track of all Lines added to the Canvas
            });
        }
Example #2
0
        //[STAThread]
        void btnStart_Click(object sender, RoutedEventArgs e)
        {
            if (runState)
            {
                linesMove = true;
                runState  = true;

                //Thread t1 = new Thread(new ThreadStart(DrawLine));
                ThreadStart tStart = new ThreadStart(Go);
                Thread      t1     = new Thread(new ThreadStart(tStart));
                t1.SetApartmentState(ApartmentState.STA);
                t1.Start();

                Stick newStick   = new Stick(this.StickArea.ActualWidth, this.StickArea.ActualHeight);
                Line  canvasLine = new Line();
                canvasLine = newStick.CreateLine();
                this.StickArea.Children.Add(canvasLine);

                LineMover(canvasLine);


                //Thread move = new Thread(new ParameterizedThreadStart(newStick.MoveLine));
                ////move.Start(canvasLine);
                //LineMover(canvasLine);


                //lineList.Add(canvasLine);      //LineList keeps track of all Lines added to the Canvas
                //threadList.Add(t1); //threadList keeps track of all the started threads
                ////Thread.Sleep(10);

                //Line canvasLine = new Line();
                //canvasLine = newStick.CreateLine(x1, x2, y1, y2);
                //this.StickArea.Children.Add(canvasLine);
                //lineList.Add(canvasLine);      //LineList keeps track of all Lines added to the Canvas

                //Thread move = new Thread(new ParameterizedThreadStart(LineMover));
            }
        }