Beispiel #1
0
        /// <summary>
        /// Add Cell From Image
        /// </summary>
        /// <param name="img">Image</param>
        /// <param name="cell">Rectangle</param>
        public void AddCellFromImage(Image img, CELL cell)
        {
            Bitmap srcBmp = new Bitmap(img);
            //Rectangle srcRect = new Rectangle(cell.Rect.Left,cell.Rect.Top,(cell.Rect.Right-cell.Rect.Left)-1,(cell.Rect.Bottom-cell.Rect.Top)-1);
            Bitmap dstBmp = srcBmp.Clone(cell.Rect, srcBmp.PixelFormat);

            cell.Img = dstBmp;
            CellList.Add(cell);//追加
        }
Beispiel #2
0
        /// <summary>
        /// Add Cell from Cell.ImageID
        /// </summary>
        /// <param name="cell">Rectangle</param>
        public void AddCellFromID(CELL a)
        {
            if (a.ImageID > Info.Count)
            {
                Console.Out.WriteLine("[ImageID]OutofRange");
                return;
            }
            //Cellにイメージ格納
            Bitmap srcBmp = new Bitmap(Info[a.ImageID].ImageOrg);
            Bitmap dstBmp = srcBmp.Clone(a.Rect, srcBmp.PixelFormat);

            a.Img = dstBmp;
            CellList.Add(a);//追加
        }
Beispiel #3
0
        private void button_Cut_Click(object sender, EventArgs e)
        {
            //Start>End Swap
            int wrk = 0;

            if (mPosStart.X > mPosEnd.X)
            {
                wrk         = mPosStart.X;
                mPosStart.X = mPosEnd.X;
                mPosEnd.X   = wrk;
            }
            if (mPosStart.Y > mPosEnd.Y)
            {
                wrk         = mPosStart.Y;
                mPosStart.Y = mPosEnd.Y;
                mPosEnd.Y   = wrk;
            }
            //保護クリップ
            if (mPosStart.X < 0)
            {
                mPosStart.X = 0;
            }
            if (mPosStart.Y < 0)
            {
                mPosStart.Y = 0;
            }
            if (mPosEnd.X > mImage.Width)
            {
                mPosEnd.X = mImage.Width;
            }
            if (mPosEnd.Y > mImage.Height)
            {
                mPosEnd.Y = mImage.Height;
            }

            Size      wh = new Size((mPosEnd.X - mPosStart.X), (mPosEnd.Y - mPosStart.Y));
            Rectangle r  = new Rectangle(mPosStart, wh);
            CELL      c  = new CELL();

            c.Rect = r;
            ImageManager.AddCellFromImage(mImage, c);

            //
            panel_CellList.Height = (ImageManager.CellList.Count / (panel_CellList.Width / mThumsWidth)) * mThumsWidth;
            splitContainerBase.Panel2.Refresh();

            //this.DialogResult = DialogResult.OK;
        }
Beispiel #4
0
        public void AddElementsFromCEll(CELL work, int x, int y)
        {
            //アイテムの登録
            ELEMENTS elem = new ELEMENTS();

            elem.Atr        = new AttributeBase();
            elem.Atr.CellID = work.GetHashCode();
            elem.Atr.Width  = work.Img.Width;
            elem.Atr.Height = work.Img.Height;

            //画像サイズ半分シフトして画像中心をセンターに
            x -= elem.Atr.Width / 2;
            y -= elem.Atr.Height / 2;

            elem.Atr.Position = new Vector3(x, y, 0);
        }
Beispiel #5
0
        /// <summary>
        /// CellからElementを作成し追加
        /// </summary>
        /// <param name="work"></param>
        /// <param name="x">クリック座標(Cliant)</param>
        /// <param name="y">クリック座標(Cliant)</param>
        private void AddElements(CELL work, int x, int y)
        {
            //アイテムの登録
            ELEMENTS elem = new ELEMENTS();

            elem.Atr        = new AttributeBase();
            elem.Atr.CellID = work.GetHashCode();
            elem.Atr.Width  = work.Img.Width;
            elem.Atr.Height = work.Img.Height;
            elem.Tag        = elem.GetHashCode();

            //センターからの距離に変換
            x -= panel_PreView.Width / 2;
            y -= panel_PreView.Height / 2;
            //さらに画像サイズ半分シフトして画像中心をセンターに
            x -= elem.Atr.Width / 2;
            y -= elem.Atr.Height / 2;

            elem.Atr.Position = new Vector3(x, y, 0);
            elem.Name         = elem.GetHashCode().ToString("X8");//仮名

            //Show - Attribute
            mFormAttribute.SetAllParam(elem.Atr);

            TimeLine.EditFrame.AddElements(elem); //Elements登録
            TimeLine.Store();                     //
            // "Motion"固定決め打ちしてるのはあとでモーション名管理変数に置き換え

            //TreeNode selNode = treeView_Project.Nodes[mNowMotionName];
            TreeNode selNode = treeView_Project.Nodes["Motion"];

            selNode.Nodes.Add(elem.Name, elem.Name);
            selNode.Expand();
            selNode.Nodes[elem.Name].Tag                = elem.GetHashCode();
            selNode.Nodes[elem.Name].ImageIndex         = 4;
            selNode.Nodes[elem.Name].SelectedImageIndex = 3;

            //Control更新
            mFormControl.Refresh();
        }
Beispiel #6
0
        private void button_Divid_Click(object sender, EventArgs e)
        {
            //等間隔分割
            int dx = (int)numericUpDown_DivX.Value;
            int dy = (int)numericUpDown_DivY.Value;

            for (int cy = 0; cy < (mImage.Height / dy); cy++)
            {
                for (int cx = 0; cx < (mImage.Width / dx); cx++)
                {
                    Rectangle r = new Rectangle(cx * dx, cy * dy, dx, dy);
                    CELL      c = new CELL();
                    c.Rect = r;
                    c.Name = cy.ToString("0d") + ":" + cx.ToString("0d");
                    ImageManager.AddCellFromImage(mImage, c);
                }
            }
            //panel_CellList.Height = (ImageManager.CellList.Count / (panel_CellList.Width / mThumsWidth)) * mThumsWidth;
            splitContainerBase.Panel2.Refresh();
            mPosStart = new Point(0, 0);
            mPosEnd   = new Point(dx, dy);//仮
        }
Beispiel #7
0
 public CELL(CELL a)
 {
     ImageID = a.ImageID;
     Rect    = a.Rect;
 }
Beispiel #8
0
 public void AddCell(CELL c)
 {
     CellList.Add(c);
 }
Beispiel #9
0
        private void PanelPreView_DragDrop(object sender, DragEventArgs e)
        {
            float zoom = HScrollBar_ZoomLevel.Value / mParZOOM;
            Point sPos = panel_PreView.PointToClient(new Point(e.X, e.Y));

            //PNGファイル直受け入れ
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                //1画像 1CELL 1Element
                //File
                string[] AllPaths = (string[])e.Data.GetData(DataFormats.FileDrop);
                foreach (string str in AllPaths)
                {
                    string ext = System.IO.Path.GetExtension(str).ToLower();
                    if (ext == ".png")
                    {
                        CELL c = new CELL();
                        c.FromPngFile(str);
                        ImageMan.AddCell(c);
                        AddElements(c, sPos.X, sPos.Y);
                    }
                }
                e.Effect = DragDropEffects.Copy;
            }

            //ListViewItem受け入れ
            if (e.Data.GetDataPresent(typeof(ListViewItem)))
            {
                ListViewItem lvi = (ListViewItem)e.Data.GetData(typeof(ListViewItem));
                //Cellの登録 Image Item
                CELL work = new CELL();
                work.Img = (Bitmap)lvi.ImageList.Images[lvi.ImageIndex];
                //画像そのままならこれでいいが一部切り抜きとなると変更
                // !!!どうやらオリジナル画像でなくサムネらしい!!!
                work.Rect = new Rectangle(0, 0, work.Img.Width, work.Img.Height);
                ImageMan.AddCell(work);//画像登録

                AddElements(work, sPos.X, sPos.Y);
                e.Effect = DragDropEffects.Copy;
            }

            //CELL 受け入れ
            if (e.Data.GetType() == typeof(CELL))
            {
                //Store Cell Item
                CELL work = (CELL)e.Data.GetData(typeof(CELL));
                ImageMan.AddCell(work);//画像登録

                Point a = panel_PreView.PointToClient(new Point(e.X, e.Y));
                AddElements(work, a.X, a.Y);
                e.Effect = DragDropEffects.Copy;
            }
            if (e.Data.GetType() == typeof(ELEMENTS))
            {
                e.Effect = DragDropEffects.Copy;
            }
            if (e.Data.GetType() == typeof(Image))
            {
                e.Effect = DragDropEffects.Copy;
            }

            panel_PreView.Refresh();
        }
Beispiel #10
0
        private void DrawParts(object sender, Graphics g)
        {
            //なんだか遅いなぁ・・ちらつくなぁ・・
            //表示の仕方も悩む 親もマーク表示するか 等
            //StageInfomation
            float zoom = HScrollBar_ZoomLevel.Value / mParZOOM;

            if (zoom < 0.2)
            {
                zoom = 0.2f;
            }
            int vcx = mScreenScroll.X + panel_PreView.Width / 2;  //ViewCenter X
            int vcy = mScreenScroll.Y + panel_PreView.Height / 2; //ViewCenter Y

            FRAME frm = TimeLine.EditFrame;

            for (int cnt = 0; cnt < frm.ElementsCount; cnt++)
            {
                ELEMENTS      e      = frm.GetElement(cnt);
                AttributeBase atr    = e.Atr;
                Matrix        Back   = g.Transform;
                Matrix        MatObj = new Matrix();

                float vsx = atr.Width * atr.Scale.X;  //* zoom;//SizeX
                float vsy = atr.Height * atr.Scale.Y; // * zoom;//SizeY

                CELL c = ImageMan.GetCellFromHash(atr.CellID);
                if (c == null)
                {
                    Console.WriteLine("Image:null"); return;
                }

                //原点を部品中心に
                //g.TranslateTransform(   vcx + (atr.Position.X + atr.Width/2)  * atr.Scale.X *zoom,
                //                        vcy + (atr.Position.Y + atr.Height/2) * atr.Scale.Y *zoom);//部品中心座標か?


                //平行移動
                g.TranslateTransform(vcx + (atr.Position.X * atr.Scale.X), vcy + (atr.Position.Y * atr.Scale.Y));
                //回転角指定
                g.RotateTransform(atr.Radius.X);
                //スケーリング調
                g.ScaleTransform(atr.Scale.X, atr.Scale.X);
                //g.TranslateTransform(vcx + (atr.Position.X * atr.Scale.X), vcy + (atr.Position.Y * atr.Scale.Y));

                //MatObj.Translate(-(vcx + atr.Position.X +(atr.Width /2))*atr.Scale.X,-(vcy + atr.Position.Y +(atr.Height/2))*atr.Scale.Y,MatrixOrder.Append);
                //MatObj.Translate(0, 0);
                //MatObj.Scale(atr.Scale.X,atr.Scale.Y,MatrixOrder.Append);
                //MatObj.Rotate(atr.Radius.X,MatrixOrder.Append);
                //MatObj.Translate((vcx + atr.Position.X + (atr.Width / 2)) * atr.Scale.Y, (vcy + atr.Position.Y + (atr.Height / 2)) * atr.Scale.Y,MatrixOrder.Append);

                //g.TranslateTransform(vcx, vcy);
                //描画

                /*
                 * g.DrawImage(c.Img,
                 *  -(atr.Width  * atr.Scale.X * zoom )/2,
                 *  -(atr.Height * atr.Scale.Y * zoom )/2,
                 *  vsx,vsy);*/
                //g.DrawImage(c.Img,vcx+ (now.Position.X*zoom)-(vsx/2),vcy+ (now.Position.Y*zoom)-(vsy/2),vsx,vsy);
                //g.Transform = MatObj;

                //Draw
                g.DrawImage(c.Img, -(atr.Width * atr.Scale.X) / 2, -(atr.Height * atr.Scale.Y) / 2, vsx, vsy);

                //Selected DrawBounds
                if (e.Select)
                {
                    g.DrawRectangle(Pens.DarkCyan, -(atr.Width * atr.Scale.X) / 2, -(atr.Height * atr.Scale.Y) / 2, vsx - 1, vsy - 1);
                }

                //test Hit範囲をボックス描画

                /*
                 * g.DrawRectangle(Pens.Aqua,  (-(atr.Width *atr.Scale.X)/2 * atr.Scale.X),
                 *                          (-(atr.Height *atr.Scale.Y)/2 * atr.Scale.Y),
                 *                          vsx - 1, vsy - 1);
                 */

                g.Transform = Back;//restore Matrix

                //Cuurent Draw Grip
            }
        }