示例#1
0
文件: TimeLine.cs 项目: amamiex/hanim
 //init
 public TIMELINEbase()
 {
     EditFrame  = new FRAME();
     gmTimeLine = new List <FRAME>();
     gmTimeLine.Add(EditFrame);
     Top();
 }
示例#2
0
文件: TimeLine.cs 项目: amamiex/hanim
        //操作系関数

        /// <summary>
        /// Frameから前後を検出しフレーム補完したものを返す
        /// </summary>
        /// <param name="FrameNum"></param>
        public FRAME Completion(int FrameNum)
        {
            //A Bがないと補完しようがないのでCount=0時はそのまま null
            if (gmTimeLine.Count <= 1)
            {
                return(null);
            }

            int?frm_a = FindPosition(FrameNum);
            int?frm_b;

            FRAME ret = null;

            if (frm_a != null)
            {
                //最後尾チェック
                if (frm_a != gmTimeLine.Count - 1)
                {
                    frm_b = frm_a + 1;
                }
                else
                {//終端だとどうすべ・・
                }
            }
            else
            { //前フレーム不明 0を基準にする
                frm_a = 0;
                frm_b = 1;
            }

            return(ret);
        }
示例#3
0
文件: TimeLine.cs 项目: amamiex/hanim
 /// <summary>
 /// Index直前に挿入
 /// </summary>
 /// <param name="index"></param>
 /// <param name="f"></param>
 public void Insert(int index, FRAME f)
 {
     //現在のフレームを戻す
     //Store();
     gmTimeLine[mCurrentIndex] = EditFrame;
     gmTimeLine.Insert(index, f);
 }
示例#4
0
文件: TimeLine.cs 项目: amamiex/hanim
        /// <summary>
        /// フレームオブジェクトを追加(同フレームは上書き)
        /// カレントフレームを移動する
        /// </summary>
        /// <param name="f"></param>
        public void AddFrame(FRAME f)
        {
            //FrameIndexを確認
            int?res = FindIndex(f.FrameNum);

            //同じフレームは上書きする
            if (res != null)
            {
                //上書き
                gmTimeLine[(int)res] = f;
                mCurrentIndex        = (int)res;
            }
            else
            {
                //新規 該当フレームの挿入場所を探す
                //もしくは追加してからFlameNumで昇順ソートする?
                //0< f.FlameNum <Max(Last)
                int pos = FindPosition(f.FrameNum);
                if (pos + 1 >= gmTimeLine.Count)
                {
                    //未発見 最後尾追加
                    gmTimeLine.Add(f);
                    mCurrentIndex = gmTimeLine.Count - 1;
                }
                else
                {
                    //pos直前に追加
                    gmTimeLine.Insert((int)pos + 1, f);
                    mCurrentIndex = pos + 1;
                }
            }
        }
示例#5
0
文件: TimeLine.cs 项目: amamiex/hanim
        //Clone
        public FRAME Clone()
        {
            //参照以外のコピー
            FRAME f = new FRAME();

            //必要な参照を個別でコピーする
            for (int cnt = 0; cnt < this.mFrame.Count; cnt++)
            {
                f.mFrame.Add(this.mFrame[cnt].Clone());
            }
            //f.mFrame = this.mFrame.ToList();
            return(f);
        }
示例#6
0
文件: TimeLine.cs 项目: amamiex/hanim
 public FRAME(FRAME f)
 {
     mFrame      = new List <ELEMENTS>();
     ActiveIndex = f.ActiveIndex;
     Text        = f.Text;
     Type        = f.Type;
     FrameNum    = f.FrameNum;
     //FrameCopy
     for (int cnt = 0; cnt < f.ElementsCount; cnt++)
     {
         mFrame.Add(f.mFrame[cnt]);
     }
 }
示例#7
0
文件: TimeLine.cs 项目: amamiex/hanim
        /// <summary>
        /// フレームLinear補完
        /// </summary>
        /// <param name="rate">重み</param>
        /// <param name="Index1">対象1</param>
        /// <param name="Index2">対象2</param>
        /// <returns></returns>
        public FRAME FrameCompLinier(int Index1, int Index2, float rate)
        {
            //座標差分を取る?
            FRAME ret = gmTimeLine[Index1].Clone();

            for (int cnt = 0; cnt < gmTimeLine[Index1].ElementsCount; cnt++)
            {
                ELEMENTS ele1 = gmTimeLine[Index1].GetElement(cnt);
                ELEMENTS ele2 = gmTimeLine[Index2].GetElement(cnt);
                ELEMENTS rest = ret.GetElement(cnt);
                rest.Atr.Position = Vector3.Linear(ele1.Atr.Position, ele2.Atr.Position, rate);
            }
            return(ret);
        }
示例#8
0
        private void panel_Time_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //タイムライン上ダブルクリックは KeyFrame作成
            int pos = e.X / TIME_CELL_WIDTH;

            //フレーム範囲チェック
            if (pos >= numericUpDown_MaxFrame.Value)
            {
                return;
            }

            FRAME newframe = mTimeLine.EditFrame.Clone();

            newframe.FrameNum = pos;
            newframe.Type     = FRAME.TYPE.KeyFrame;
            mTimeLine.AddFrame(newframe);
            //表示更新
            panel_Time.Refresh();
            mFormMain.Refresh();
        }
示例#9
0
文件: TimeLine.cs 项目: amamiex/hanim
 /// <summary>
 /// インデックスでのフレーム移動
 /// </summary>
 /// <param name="x"></param>
 public void ToIndex(int x)
 {
     if (gmTimeLine == null)
     {
         return;
     }
     if (gmTimeLine.Count == 0)
     {
         return;
     }
     if (x < 0)
     {
         return;
     }
     if (x > gmTimeLine.Count)
     {
         return;
     }
     //Now -> Store
     //CurrentFrame -> EditFrame
     EditFrame     = new FRAME(gmTimeLine[x]);
     mCurrentIndex = x;
 }
示例#10
0
        private void panel_Time_Paint(object sender, PaintEventArgs e)
        {
            //TimeLine
            int inWidth = this.panel_Time.Width;
            int inHeight = this.panel_Time.Height;
            int inFrame = (int)this.numericUpDown_MaxFrame.Value;
            int CellWidth = TIME_CELL_WIDTH;
            int CellHeight = TIME_CELL_HEIGHT;
            int inCnt, inMax = 5;

            //全消去
            e.Graphics.Clear(Color.Black);

            //以下、横ライン描画処理

            //e.Graphics.DrawLine(Pens.Black, 0, CellHeight, inWidth - 1, CellHeight);

            if (mTimeLine == null)
            {
                return;
            }
            inMax = mTimeLine.EditFrame.ElementsCount;//現在フレームのElements数
            for (inCnt = 0; inCnt < inMax; inCnt++)
            {
                SolidBrush sb = new SolidBrush(Color.FromArgb(64, Color.Gray));
                //e.Graphics.DrawLine(Pens.Black, 0, inY, inWidth, inY);
                //選択中Elementsの背景強調
                ELEMENTS ele = mTimeLine.EditFrame.GetElement(inCnt);

                if ((inCnt % 2) != 0)
                {
                    e.Graphics.FillRectangle(sb, 0, inCnt * CellHeight, panel_Time.Width, CellHeight - 1);
                }
                if (ele.Select)
                {
                    sb = new SolidBrush(Color.FromArgb(64, Color.Green));
                    e.Graphics.FillRectangle(sb, 0, inCnt * CellHeight, panel_Time.Width, CellHeight - 1);
                }
            }

            //以下、縦ライン描画処理

            for (inCnt = 0; inCnt < inFrame; inCnt++)
            {
                var pen = Pens.CadetBlue;

                //5の倍数の時(グレイ)
                if (inCnt % 5 == 0)
                {
                    pen = Pens.DarkGreen;
                }
                //現在のフレームの時(赤)
                if (inCnt == numericUpDown_NowFlame.Value)
                {
                    SolidBrush sb = new SolidBrush(Color.FromArgb(64, Color.Red));
                    e.Graphics.FillRectangle(sb, inCnt * CellWidth, 0, CellWidth, inHeight - 1);
                }
                //標準(黒)
                e.Graphics.DrawLine(pen, inCnt * CellWidth, 0, inCnt * CellWidth, inHeight);

                //Draw FRAMEtype
                FRAME frm = mTimeLine.GetFrame(inCnt);
                if (frm != null)
                {
                    if (frm.Type == FRAME.TYPE.KeyFrame)
                    {
                        SolidBrush sb = new SolidBrush(Color.FromArgb(64, Color.Aquamarine));
                        e.Graphics.FillRectangle(sb, inCnt * CellWidth, 0, CellWidth, inHeight - 1);
                    }
                    if (frm.Type == FRAME.TYPE.Control)
                    {
                    }
                }
            }


            //DrawDragArea
            if (!mSelect_Pos_End.IsEmpty)
            {
                //選択範囲の網掛け
                SolidBrush sb = new SolidBrush(Color.FromArgb(128, 0, 0, 128));
                e.Graphics.FillRectangle(sb, mSelect_Pos_Start.X * TIME_CELL_WIDTH, 0, (mSelect_Pos_End.X - mSelect_Pos_Start.X) * TIME_CELL_WIDTH, inHeight - 1);
            }
        }
示例#11
0
文件: FormMain.cs 项目: amamiex/hanim
        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
            }
        }
示例#12
0
文件: TimeLine.cs 项目: amamiex/hanim
 public void LoadFromStream(Stream stm)
 {
     DataContractSerializer serializer = new DataContractSerializer(typeof(FRAME));
     FRAME a = (FRAME)serializer.ReadObject(stm);
 }