コード例 #1
0
        void vectorTimer_Tick(object sender, EventArgs e)
        {
            // get a vector enumerator
            VectorEnumerator enumerator = tempest.GetVectorEnumerator();

            if (enumerator != null)
            {
                int index = 0;
                for (; ;)
                {
                    // get the vector
                    Int16 startX16, startY16, endX16, endY16;
                    byte  r, g, b;
                    if (!enumerator.GetNextVector(out startX16, out startY16, out endX16, out endY16, out r, out g, out b))
                    {
                        break;
                    }

                    // switch to longer than 16 bits
                    int startX = startX16;
                    int startY = startY16;
                    int endX   = endX16;
                    int endY   = endY16;

                    Line line;
                    if (index >= lines.Count)
                    {
                        line = new Line();
                        lines.Add(line);
                        canvas.Children.Add(line);
                    }
                    else
                    {
                        line = lines[index];
                    }

                    int strokeThickness = 100;

                    // if we have a zero length line we need to fudge it... this is how
                    // Tempest draws points
                    if (endX == startX && endY == startY)
                    {
                        endX   += strokeThickness / 2;
                        startX += strokeThickness / 2;
                        endY   -= strokeThickness / 2;
                        startY += strokeThickness / 2;
                    }

                    line.Stroke          = new SolidColorBrush(Color.FromRgb(r, g, b));
                    line.X1              = canvas.ActualWidth / 2 + startX;
                    line.X2              = canvas.ActualWidth / 2 + endX;
                    line.Y1              = canvas.ActualHeight / 2 - startY;
                    line.Y2              = canvas.ActualHeight / 2 - endY;
                    line.StrokeThickness = 100;
                    line.Visibility      = System.Windows.Visibility.Visible;

                    ++index;
                }

                while (index < lines.Count)
                {
                    lines[index++].Visibility = System.Windows.Visibility.Hidden;
                }
            }
        }
コード例 #2
0
        void VectorTimer_Tick(object sender, object e)
        {
            if (vectorGameManager == null)
            {
                return;
            }

            // get a vector enumerator
            VectorEnumerator enumerator = vectorGameManager.GetVectorEnumerator();

            if (enumerator != null)
            {
                int index = 0;
                for (; ;)
                {
                    // get the vector
                    Vector vector = enumerator.GetNextVector();
                    if (!vector.valid)
                    {
                        break;
                    }

                    // switch to longer than 16 bits
                    int startX = vector.startX;
                    int startY = vector.startY;
                    int endX   = vector.endX;
                    int endY   = vector.endY;


                    Line line;
                    if (index >= lines.Count)
                    {
                        line = new Line();
                        lines.Add(line);
                        canvas.Children.Add(line);
                    }
                    else
                    {
                        line = lines[index];
                    }

                    int strokeThickness = 100;

                    // if we have a zero length line we need to fudge it... this is how
                    // Tempest draws points
                    if (endX == startX && endY == startY)
                    {
                        endX   += strokeThickness / 2;
                        startX += strokeThickness / 2;
                        endY   -= strokeThickness / 2;
                        startY += strokeThickness / 2;
                    }

                    line.Stroke          = new SolidColorBrush(Color.FromArgb(255, vector.r, vector.g, vector.b));
                    line.X1              = canvas.ActualWidth / 2 + startX;
                    line.X2              = canvas.ActualWidth / 2 + endX;
                    line.Y1              = canvas.ActualHeight / 2 - startY;
                    line.Y2              = canvas.ActualHeight / 2 - endY;
                    line.StrokeThickness = 100;
                    line.Visibility      = Visibility.Visible;

                    ++index;
                }

                while (index < lines.Count)
                {
                    lines[index++].Visibility = Visibility.Collapsed;
                }
            }
        }