Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            w               = pictureBox1.Width;
            h               = pictureBox1.Height;
            bmp             = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            g               = Graphics.FromImage(bmp);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.Clear(Color.White);
            gravity.x = 0;
            gravity.y = 0.2;
            vector2D vel = new vector2D();


            balls = new Ball[N];
            for (int i = 0; i < N; i++)
            {
                int diam = rnd.Next(10, 40);
                vel.x    = rnd.Next(-10, 10);
                vel.y    = rnd.Next(-10, 10);
                balls[i] = new Ball(rnd.Next(w), rnd.Next(h) - diam, diam, vel);
                balls[i].show();
            }
            ;
            pictureBox1.Image = bmp;
        }
Пример #2
0
 public Ball(double x, double y, int diameter, vector2D vel)
 {
     this.pos.x    = x;
     this.pos.y    = y;
     this.diameter = diameter;
     this.radius   = diameter / 2.0;
     this.vel      = vel;
 }
Пример #3
0
 public FingerPos()
 {
     Pos[0] = new vector2D(20, 50);
     Pos[1] = new vector2D(49, 20);
     Pos[2] = new vector2D(88, 15);
     Pos[3] = new vector2D(130, 27);
     Pos[4] = new vector2D(163, 92);
     Pos[5] = new vector2D(197, 93);
     Pos[6] = new vector2D(234, 28);
     Pos[7] = new vector2D(274, 14);
     Pos[8] = new vector2D(313, 26);
     Pos[9] = new vector2D(340, 51);
 }
Пример #4
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            #region 接受页面传值
            IDictionary<string, string> para = this.NavigationContext.QueryString;
            if (para.Count > 0)
            {
                gameClass = (para["gameClass"]).ToString().Trim();
                imgUri = (para["imgUri"]).ToString().Trim();
            }
            #endregion

            #region 处理墓碑错误
            if (app.str_Uri != null)
            {
                NavigationService.Navigate(new Uri("/ChoosePictures.xaml?gameClass=" + gameClass, UriKind.Relative));
            }
            app.str_Uri = null;
            #endregion

            #region 处理表格和图片相关初始值
            switch (gameClass)
            {
                case "5And5":
                    InitializeAboutGameClass(5,5,75,75,25);//5*5
                    break;
                case "4And4":
                    InitializeAboutGameClass(4,4,90,90,16);//4*4
                    break;
                case "3And3":
                    InitializeAboutGameClass(3,3,120,120,9);//3*3
                    break;
                default: break;
            }
            #endregion

            #region 创建方格和加载图片
            ImageBrush berriesBrush = new ImageBrush();
            berriesBrush.ImageSource =
                new BitmapImage(
                    new Uri(@"bg_InGame.jpg", UriKind.Relative)
                );
            Carrier.Background = berriesBrush;
            //Image Map = new Image();
            //Map.Width = 480;
            //Map.Height = 800;
            //Map.Source = new BitmapImage((new Uri(@"bg_InGame.jpg", UriKind.Relative)));
            //Carrier.Children.Add(Map);
            //Map.SetValue(Canvas.ZIndexProperty, -1);//ZIndexProperty附加属性,这样它就相当于地图背景的作用

            Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);

            Table t = new Table(tableColumn, tableRow, smallSquareWidth, smallSquareHeight);
            g = t.CreateTable();
            Carrier.Children.Add(g);

            littleImages = new MyImages(smallSquareWidth, smallSquareHeight);
            List<Image> listImages = littleImages.CreateImages(imgsCount,imgUri);
            try
            {
                foreach (var u in listImages)
                {
                    Carrier.Children.Add(u);
                }
            }
            catch
            { }

            tableVectors = new vector2D[tableRow + 1, tableColumn + 1];
            vector2D a = new vector2D();
            for (int i = 0; i < tableRow + 1; i++)
            {
                for (int j = 0; j < tableColumn + 1; j++)
                {
                    a.x = j * t.SmallSquareWidth + (480 - t.Column * t.SmallSquareWidth) / 2;
                    a.y = i * t.SmallSquareHeight;
                    tableVectors[i, j] = a;
                }
            }

            #region 原图

            originalImage.Name = "originalImage";
            #region 从存储过程中读取原图
            IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
            if (!isf.DirectoryExists(imgUri))
                isf.CreateDirectory(imgUri);
            string[] imgsNames = isf.GetFileNames(imgUri + "/originalImage*.jpg");
            try
            {
                using (IsolatedStorageFileStream isfStream = isf.OpenFile(imgUri + "/" + imgsNames[0], FileMode.Open, FileAccess.Read))
                {
                    BitmapImage bmpImg = new BitmapImage();
                    bmpImg.SetSource(isfStream);
                    originalImage.Source = bmpImg;
                }
            }
            catch
            { }
            #endregion
            //originalImage.Source = new BitmapImage(new Uri("img/5And5/1/originalImage.jpg", UriKind.Relative));
            originalImage.Width = g.Width;
            originalImage.Height = g.Height;
            Thickness gMargin = (Thickness)g.GetValue(MarginProperty);
            Canvas.SetLeft(originalImage, gMargin.Left);
            Canvas.SetTop(originalImage, gMargin.Top);

            Canvas.SetZIndex(originalImage, -1);
            try {
                Carrier.Children.Add(originalImage);
            }
            catch
            {

            }
            originalImage.Visibility = Visibility.Collapsed;

            #endregion

            #endregion

            #region 读取独立存储空间

            //switch (MusicName)
            //{
            //    case "Set Fire To The Rain": ReadIsolatedStorageFile(highPointCount[0], 1);//读取独立存储空间的歌曲高潮点文件,highPointCount[]歌曲名,1文件名
            //        break;
            //    case "What Doesn't Kill You": ReadIsolatedStorageFile(highPointCount[1], 2);//读取独立存储空间的歌曲高潮点文件
            //        break;
            //    default: break;
            //}
            #endregion
        }
Пример #5
0
 public void add(vector2D v)
 {
     this.x += v.x;
     this.y += v.y;
 }