Пример #1
0
        private Rectangle boxBlank ;    // 空き位置

        /// <summary>
        /// 初期化ボタン
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clickInit(object sender, EventArgs e)
        {
            var cols = new List<Color>()
            {
                Color.Red,
                Color.Navy,
                Color.Yellow,
                Color.Pink,
                Color.Purple,
            };
            var rnd = new Random();

            // キャンバスに Box を25個並べる
            boxes = new List<BoxViewEx>();
            for (int i = 0; i < 25; i++) {
                var box = new BoxViewEx();
                boxes.Add(box);
                canvas.Children.Add(box);
                int w = 60;
                int h = 60;

                int x = (i % 5) * (w + 10) + 30;
                int y = (i / 5) * (h + 10) + 30;

                var rect = new Rectangle(new Point(x, y), new Size(w, h));
                box.LayoutTo(rect);
                box.BackgroundColor = cols[ rnd.Next(cols.Count)];
                box.ManipulationDelta += Box_ManipulationDelta;
                box.ManipulationCompleted += Box_ManipulationCompleted;
                box.ManipulationStarted += Box_ManipulationStarted;
            }
        }
Пример #2
0
        private Rectangle boxBlank;     // 空き位置

        /// <summary>
        /// 初期化ボタン
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clickInit(object sender, EventArgs e)
        {
            var cols = new List <Color>()
            {
                Color.Red,
                Color.Navy,
                Color.Yellow,
                Color.Pink,
                Color.Purple,
            };
            var rnd = new Random();

            // キャンバスに Box を25個並べる
            boxes = new List <BoxViewEx>();
            for (int i = 0; i < 25; i++)
            {
                var box = new BoxViewEx();
                boxes.Add(box);
                canvas.Children.Add(box);
                int w = 60;
                int h = 60;

                int x = (i % 5) * (w + 10) + 30;
                int y = (i / 5) * (h + 10) + 30;

                var rect = new Rectangle(new Point(x, y), new Size(w, h));
                box.LayoutTo(rect);
                box.BackgroundColor        = cols[rnd.Next(cols.Count)];
                box.ManipulationDelta     += Box_ManipulationDelta;
                box.ManipulationCompleted += Box_ManipulationCompleted;
                box.ManipulationStarted   += Box_ManipulationStarted;
            }
        }