示例#1
0
        // 这里需要对已经存在的imageSituation进行判定, 如果已经存在的话需要进行重命名.
        // 可以简单的使用一个int变量解决这个问题.
        public void addImageSituation(string _imageName, float _x, float _y,
                                      bool _isScale, bool _isRotate, bool _isAlpha,
                                      float _scaleX, float _scaleY, float _rotate, float _alpha)
        {
            // 进行重复性检测
            // 如果未发生重复, name即为imageName.
            // 如果已经发生重复, name = imageName + renameId++;
            bool   __isRepeat = false;
            string __newName  = _imageName;

            for (int i = 0; i < imageSituations.Count; i++)
            {
                string __targetName = ((ImageSituation)imageSituations[i]).name;
                __isRepeat = true;
                break;
            }
            if (__isRepeat)
            {
                // 已经发生重复
                __newName = _imageName + "_" + renameId++;
            }

            ImageSituation __newImageSituation = new ImageSituation(__newName, _imageName, _x, _y,
                                                                    _isScale, _isRotate, _isAlpha,
                                                                    _scaleX, _scaleY, _rotate, _alpha);

            imageSituations.Add(__newImageSituation);
        }
示例#2
0
 // 更改当前帧要刷新帧预览中的图像
 private void changeCurrentFrameIndex(int _newIndex)
 {
     currentFrameIndex = _newIndex;
     pictureBoxMain.Refresh();
     pictureBoxFrameList.Refresh();
     selectedImageSituation = null;
     refreshListBoxCurrentFrame();
 }
示例#3
0
        // 清理所有的数据
        public void clearAll()
        {
            previewImage           = null;
            images                 = null;
            keyFrames              = new Dictionary <int, FrameData>();
            allFrames              = null;
            selectedImageSituation = null;

            refreshAll();
        }
示例#4
0
 public void imageSituationMoveDown(int _index)
 {
     if (imageSituations != null)
     {
         if (_index >= 0 && _index < imageSituations.Count - 1)
         {
             ImageSituation __currentImageSituation = (ImageSituation)imageSituations[_index];
             imageSituations.RemoveAt(_index);
             imageSituations.Insert(_index + 1, __currentImageSituation);
         }
     }
 }
示例#5
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     if (listBoxCurrentFrame.SelectedItem != null && keyFrames.ContainsKey(currentFrameIndex))
     {
         FrameData __currentFrame = keyFrames[currentFrameIndex];
         __currentFrame.removeImageSituation(listBoxCurrentFrame.SelectedIndex);
         selectedImageSituation = null;
         refreshListBoxCurrentFrame();
         if (listBoxCurrentFrame.Items.Count > 0)
         {
             listBoxCurrentFrame.SelectedIndex = 0;
         }
         pictureBoxMain.Refresh();
     }
 }
示例#6
0
 // 选择关键帧中的图片
 private void listBoxCurrentFrame_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (keyFrames.ContainsKey(currentFrameIndex) && listBoxCurrentFrame.SelectedItem != null)
     {
         FrameData __currentFrame = keyFrames[currentFrameIndex];
         selectedImageSituation = __currentFrame.getImageSituation(listBoxCurrentFrame.SelectedIndex);
         pictureBoxMain.Refresh();
     }
     else
     {
         selectedImageSituation = null;
     }
     // refresh ImageStuation Edit
     groupBoxImageSituationEnable();
 }
示例#7
0
        // 首先要检查有没有相同的image, 然后计算这些image的差
        // length 传入的是起始关键帧和结束关键帧为界的开区间的长
        public FrameData[] generateFrom2KeyFrames(FrameData _startKeyFrame, FrameData _endKeyFrame, int length)
        {
            if (length > 0)
            {
                // 检查相同的image
                ArrayList __sameImageSituationNames = new ArrayList();
                for (int i = 0; i < _startKeyFrame.imageSituations.Count; i++)
                {
                    if (_endKeyFrame.containsImageSituation(_startKeyFrame.getImageSituation(i).name))
                    {
                        __sameImageSituationNames.Add(_startKeyFrame.getImageSituation(i).name);
                    }
                }
                // 计算image之间的差
                Dictionary <string, float> __deltaXs      = new Dictionary <string, float>();
                Dictionary <string, float> __deltaYs      = new Dictionary <string, float>();
                Dictionary <string, float> __deltaScaleXs = new Dictionary <string, float>();
                Dictionary <string, float> __deltaScaleYs = new Dictionary <string, float>();
                Dictionary <string, float> __deltaRotates = new Dictionary <string, float>();
                Dictionary <string, float> __deltaAlphas  = new Dictionary <string, float>();

                Dictionary <string, float> __startXs      = new Dictionary <string, float>();
                Dictionary <string, float> __startYs      = new Dictionary <string, float>();
                Dictionary <string, float> __startScaleXs = new Dictionary <string, float>();
                Dictionary <string, float> __startScaleYs = new Dictionary <string, float>();
                Dictionary <string, float> __startRotates = new Dictionary <string, float>();
                Dictionary <string, float> __startAlphas  = new Dictionary <string, float>();

                for (int i = 0; i < __sameImageSituationNames.Count; i++)
                {
                    string __name = (string)__sameImageSituationNames[i];

                    float __startX      = _startKeyFrame.getImageSituation(__name).x;
                    float __startY      = _startKeyFrame.getImageSituation(__name).y;
                    float __startScaleX = _startKeyFrame.getImageSituation(__name).scaleX;
                    float __startScaleY = _startKeyFrame.getImageSituation(__name).scaleY;
                    float __startRotate = _startKeyFrame.getImageSituation(__name).rotate;
                    float __startAlpha  = _startKeyFrame.getImageSituation(__name).getAlpha();

                    float __deltaX      = (_endKeyFrame.getImageSituation(__name).x - __startX) / (length + 1);
                    float __deltaY      = (_endKeyFrame.getImageSituation(__name).y - __startY) / (length + 1);
                    float __deltaScaleX = (_endKeyFrame.getImageSituation(__name).scaleX - __startScaleX) / (length + 1);
                    float __deltaScaleY = (_endKeyFrame.getImageSituation(__name).scaleY - __startScaleY) / (length + 1);
                    float __deltaRotate = (_endKeyFrame.getImageSituation(__name).rotate - __startRotate) / (length + 1);
                    float __deltaAlpha  = (_endKeyFrame.getImageSituation(__name).getAlpha() - __startAlpha) / (length + 1);

                    __startXs.Add(__name, __startX);
                    __startYs.Add(__name, __startY);
                    __startScaleXs.Add(__name, __startScaleX);
                    __startScaleYs.Add(__name, __startScaleY);
                    __startRotates.Add(__name, __startRotate);
                    __startAlphas.Add(__name, __startAlpha);

                    __deltaXs.Add(__name, __deltaX);
                    __deltaYs.Add(__name, __deltaY);
                    __deltaScaleXs.Add(__name, __deltaScaleX);
                    __deltaScaleYs.Add(__name, __deltaScaleY);
                    __deltaRotates.Add(__name, __deltaRotate);
                    __deltaAlphas.Add(__name, __deltaAlpha);
                }

                // 对每一对相同的image建立期间的imageSituations
                FrameData[] __result = new FrameData[length];
                for (int i = 0; i < __result.Length; i++)
                {
                    __result[i] = new FrameData();
                    for (int j = 0; j < __sameImageSituationNames.Count; j++)
                    {
                        string         __tempSitName   = (string)__sameImageSituationNames[j];
                        ImageSituation __tempSit       = _startKeyFrame.getImageSituation(__tempSitName);
                        string         __tempImageName = __tempSit.imageName;
                        float          __tempX         = __tempSit.x + __deltaXs[__tempSitName] * (i + 1);
                        float          __tempY         = __tempSit.y + __deltaYs[__tempSitName] * (i + 1);
                        bool           __tempIsScale   = __tempSit.isScale;
                        bool           __tempIsRotate  = __tempSit.isRotate;
                        bool           __tempIsAlpha   = __tempSit.isAlpha;
                        float          __tempScaleX    = __tempSit.scaleX + __deltaScaleXs[__tempSitName] * (i + 1);
                        float          __tempScaleY    = __tempSit.scaleY + __deltaScaleYs[__tempSitName] * (i + 1);
                        float          __tempRotate    = __tempSit.rotate + __deltaRotates[__tempSitName] * (i + 1);
                        float          __tempAlpha     = __tempSit.getAlpha() + __deltaAlphas[__tempSitName] * (i + 1);
                        __result[i].addImageSituation(__tempImageName, __tempX, __tempY, __tempIsScale, __tempIsRotate,
                                                      __tempIsAlpha, __tempScaleX, __tempScaleY, __tempRotate, __tempAlpha);
                    }
                }
                return(__result);
            }

            return(null);
        }
示例#8
0
 public void addImageSituation(ImageSituation _newSit)
 {
     this.imageSituations.Add(_newSit);
 }