示例#1
0
        // 刷新所有控件
        public void refreshAll()
        {
            refreshListBoxImages();
            pictureBoxMain.Refresh();
            pictureBoxFrameList.Refresh();
            pictureBoxImagePreview.Refresh();
            textBoxScreenWidth.Text  = screenWidth.ToString();
            textBoxScreenHeight.Text = screenHeight.ToString();
            refreshListBoxCurrentFrame();
            if (selectedImageSituation != null)
            {
                textBoxAlpha.Text       = selectedImageSituation.getAlpha().ToString();
                textBoxRotate.Text      = selectedImageSituation.rotate.ToString();
                textBoxScaleX.Text      = selectedImageSituation.scaleX.ToString();
                textBoxScaleY.Text      = selectedImageSituation.scaleY.ToString();
                checkBoxIsScale.Checked = selectedImageSituation.isScale;
                checkBoxRotate.Checked  = selectedImageSituation.isRotate;
                checkBoxAlpha.Checked   = selectedImageSituation.isAlpha;
            }
            else
            {
                textBoxAlpha.Text       = "1.0";
                textBoxRotate.Text      = "0";
                textBoxScaleX.Text      = "1.0";
                textBoxScaleY.Text      = "1.0";
                checkBoxIsScale.Checked = false;
                checkBoxRotate.Checked  = false;
                checkBoxAlpha.Checked   = false;
            }

            textBoxFPS.Text = "30";

            if (isTimerRunning)
            {
                stopTimer();
            }

            currentFrameBasedEnable();
            groupBoxImageSituationEnable();
            buttonRunEnable();
            buttonBuildEnable();
        }
示例#2
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);
        }