Example #1
0
            /// <summary>
            /// 指定したインデックスのエネミーの位置を指定した分だけ移動させます。
            /// </summary>
            public void OffsetPosition(int index, Point scaledposoffset, Size scaledwndSize, ViewScale.ScaleRate scale)
            {
                var enemyPos  = this.Enemies[index].Position;
                var enemySize = this.Enemies[index].Size;

                ViewScale.ApplyRateToPoint(ref enemyPos, scale);
                ViewScale.ApplyRateToSize(ref enemySize, scale);
                var afterRange = new Rectangle(enemyPos.X + scaledposoffset.X, enemyPos.Y + scaledposoffset.Y, enemySize.Width, enemySize.Height);

                //拡大率を解除する
                var originalposoffset = scaledposoffset;
                var originalwndSize   = scaledwndSize;

                ViewScale.RestoreOriginalPoint(ref originalposoffset, scale);
                ViewScale.RestoreOriginalSize(ref originalwndSize, scale);

                //端点に範囲外になる場合は調整する
                var limit = (int)(limitPosition * ViewScale.GetRate(scale));

                if (afterRange.Right < limit)
                {
                    this.Enemies[index].Position = new Point(-this.Enemies[index].Size.Width + limitPosition, this.Enemies[index].Position.Y);
                }
                else if (afterRange.Bottom < limit)
                {
                    this.Enemies[index].Position = new Point(this.Enemies[index].Position.X, -this.Enemies[index].Size.Height + limitPosition);
                }
                else if (afterRange.Left > scaledwndSize.Width - limit)
                {
                    this.Enemies[index].Position = new Point(originalwndSize.Width - limitPosition, this.Enemies[index].Position.Y);
                }
                else if (afterRange.Top > scaledwndSize.Height - limit)
                {
                    this.Enemies[index].Position = new Point(this.Enemies[index].Position.X, originalwndSize.Height - limitPosition);
                }
                else
                {
                    //調整しなかった場合のみ差分移動する
                    this.Enemies[index].OffsetPosition(originalposoffset);
                }

                this.IsDirty = true;
            }
Example #2
0
        /// <summary>
        /// デザイナー:ドラッグ開始
        /// </summary>
        private void picPreview_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            var NotFound = true;

            //レイヤーはインデックスが後ろになるほど上に描画される構造であるため、逆から判定する
            for (var i = this.mgr.EdittingData.Enemies.Count - 1; i >= 0; i--)
            {
                //拡大率を適用する
                var enemyPos  = this.mgr.EdittingData.Enemies[i].Position;
                var enemySize = this.mgr.EdittingData.Enemies[i].Size;
                var pos       = new Point(e.X, e.Y);
                ViewScale.RestoreOriginalPoint(ref pos, this.mgr.Scale);
                ViewScale.ApplyRateToPoint(ref enemyPos, this.mgr.Scale);
                ViewScale.ApplyRateToSize(ref enemySize, this.mgr.Scale);

                //ドラッグ可能な領域である場合
                if (new Rectangle(enemyPos, enemySize).Contains(e.X, e.Y))
                {
                    this.drugObj = new DrugObject(i, new Point(e.X, e.Y));
                    this.ltvAnalyzer.SelectedIndices.Add(i);
                    NotFound = false;
                    break;
                }
            }

            if (NotFound)
            {
                this.drugObj = null;
                this.ltvAnalyzer.SelectedIndices.Clear();
                this.picPreview.Refresh();
            }
        }
Example #3
0
        /// <summary>
        /// 指定したグラフィック描画オブジェクトを用いてデザイナー用の描画を行います。
        /// </summary>
        public void DrawDesigner(Graphics g, Size scaledwndSize, int activeIndex)
        {
            Common.ApplyHighQualityDrawing(g);

            //背景描画
            if (this.backPicture != null)
            {
                g.DrawImage(this.backPicture, new Rectangle(Point.Empty, scaledwndSize));
            }

            //各エネミーを描画
            if (this.EdittingData != null)
            {
                for (var i = 0; i < this.EdittingData.Enemies.Count; i++)
                {
                    //現在の表示倍率に合わせる
                    var pos  = this.EdittingData.Enemies[i].Position;
                    var size = this.EdittingData.Enemies[i].Img?.Size ?? Size.Empty;
                    ViewScale.ApplyRateToPoint(ref pos, this.Scale);
                    ViewScale.ApplyRateToSize(ref size, this.Scale);

                    if (this.EdittingData.Enemies[i].Img != null)
                    {
                        g.FillRectangle(new SolidBrush(Color.FromArgb(100, (i == activeIndex) ? Color.Yellow : Color.White)), new Rectangle(pos, size));
                        g.DrawImage(this.EdittingData.Enemies[i].Img, new Rectangle(pos, size));
                        var strSize = g.MeasureString(this.EdittingData.Enemies[i].Name, Settings.Default.Text_Font);
                        g.DrawString(this.EdittingData.Enemies[i].Name, Settings.Default.Text_Font, Brushes.White, new Point(pos.X, pos.Y - (int)strSize.Height));
                    }
                }
            }

            //ガイド線描画
            g.DrawRectangle(new Pen(Color.LightGray, 3), 0, 0, scaledwndSize.Width, scaledwndSize.Height);
            g.DrawLine(Pens.LightGray, scaledwndSize.Width / 2, 0, scaledwndSize.Width / 2, scaledwndSize.Height);
            g.DrawLine(Pens.LightGray, 0, scaledwndSize.Height / 2, scaledwndSize.Width, scaledwndSize.Height / 2);
        }