示例#1
0
        public TextWizard(string fontFileName)
        {
            String rootPath     = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            String fullFontPath = (rootPath + "\\" + fontFileName);

            Stream stream = null;

            try
            {
                stream = File.Open(fullFontPath, FileMode.Open);
                Type[] extraTypes = new Type[2] {
                    typeof(Frame), typeof(List <Frame>)
                };
                XmlSerializer  serializer   = new XmlSerializer(typeof(FrameStripData), extraTypes);
                FrameStripData incomingData = (FrameStripData)serializer.Deserialize(stream);

                mFontTemplate = new List <Frame>(incomingData.m_frames);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Font Load Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }
        }
示例#2
0
        public void load(string file, LoadMode LM)
        {
            Stream stream = null;

            try
            {
                stream = File.Open(file, FileMode.Open);
                Type[] extraTypes = new Type[2] {
                    typeof(Frame), typeof(List <Frame>)
                };
                XmlSerializer  serializer   = new XmlSerializer(typeof(FrameStripData), extraTypes);
                FrameStripData incomingData = (FrameStripData)serializer.Deserialize(stream);

                m_data.m_fps = incomingData.m_fps;

                if (LM == LoadMode.Replace)
                {
                    deleteAll();
                }

                Int32 selIndex = m_data.m_frames.Count;

                if (LM == LoadMode.Append || LM == LoadMode.Replace)
                {
                    foreach (Frame f in incomingData.m_frames)
                    {
                        addFrame(f, false);
                    }
                }
                else if (LM == LoadMode.Overlay ||
                         LM == LoadMode.OverlayAdditive ||
                         LM == LoadMode.OverlayCutoutFG ||
                         LM == LoadMode.OverlayCutoutBG)
                {
                    Int32 curSelIndex = getIndexForFrame(SelectedFrame);
                    Int32 maxIndex    = Math.Min(incomingData.m_frames.Count, m_data.m_frames.Count - curSelIndex);
                    maxIndex = Math.Max(maxIndex, 0);

                    for (Int32 i = 0; i < maxIndex; i++)
                    {
                        if (i >= m_data.m_frames.Count)
                        {
                            break;
                        }

                        Frame blendOut = new Frame();

                        if (LM == LoadMode.OverlayCutoutFG ||
                            LM == LoadMode.OverlayCutoutBG)
                        {
                            FrameTools.OverlayCutout(m_data.m_frames[curSelIndex + i], incomingData.m_frames[i], blendOut, (LM == LoadMode.OverlayCutoutFG));
                        }
                        else
                        {
                            FrameTools.Overlay(m_data.m_frames[curSelIndex + i], incomingData.m_frames[i], blendOut, (LM == LoadMode.OverlayAdditive));
                        }

                        blendOut.copyTo(m_data.m_frames[curSelIndex + i]);
                    }
                }

                if (m_data.m_frames.Count > selIndex)
                {
                    SelectedFrame = m_data.m_frames[selIndex];
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Load Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }
        }