Exemplo n.º 1
0
        public void Do(Document doc)
        {
            Console.WriteLine(string.Format("Updating.  oldName={0}  newName={1}  newValue={2}", oldName, newName, newValue));

            SpriteDocument   sprite  = (SpriteDocument)doc;
            StringDictionary scripts = sprite.Metadata;

            if (!scripts.ContainsKey(oldName))
            {
                oldName = null;
            }

            if (scripts.ContainsKey(newName))
            {
                oldName = newName;
            }

            if (oldName != null)
            {
                oldValue = scripts[oldName];
            }
            scripts[newName] = newValue;

            if (oldName != null && oldName != newName)
            {
                scripts.Remove(oldName);
            }
            sprite.FireChanged();
        }
Exemplo n.º 2
0
        public void Undo(Document doc)
        {
            SpriteDocument sprite = (SpriteDocument)doc;

            sprite.Frames.RemoveAt(position);
            sprite.FireChanged();
        }
Exemplo n.º 3
0
        public void Undo(Document doc)
        {
            SpriteDocument sprite = (SpriteDocument)doc;

            sprite.Frames[position] = oldFrame;
            sprite.FireChanged();
        }
Exemplo n.º 4
0
        public void Undo(Document doc)
        {
            SpriteDocument sprite = (SpriteDocument)doc;

            sprite.Frames.Insert(position, oldFrame);
            sprite.FireChanged();
        }
Exemplo n.º 5
0
        public void Undo(Document doc)
        {
            SpriteDocument sprite = (SpriteDocument)doc;

            sprite.HotSpot = oldHotSpot;
            sprite.FireChanged();
        }
Exemplo n.º 6
0
        public void Do(Document doc)
        {
            SpriteDocument sprite = (SpriteDocument)doc;

            oldFrame = (Bitmap)sprite.Frames[position];
            sprite.Frames[position] = newFrame;
            sprite.FireChanged();
        }
Exemplo n.º 7
0
 void UpdateDialog(SpriteDocument sprite)
 {
     hotSpot            = sprite.HotSpot;
     editHotX.Text      = hotSpot.X.ToString();
     editHotY.Text      = hotSpot.Y.ToString();
     editHotWidth.Text  = hotSpot.Width.ToString();
     editHotHeight.Text = hotSpot.Height.ToString();
 }
Exemplo n.º 8
0
        public void Do(Document doc)
        {
            SpriteDocument sprite = (SpriteDocument)doc;

            oldHotSpot     = sprite.HotSpot;
            sprite.HotSpot = newHotSpot;
            sprite.FireChanged();
        }
Exemplo n.º 9
0
        public void Do(Document doc)
        {
            SpriteDocument sprite = (SpriteDocument)doc;

            Console.WriteLine(sprite.Size);

            sprite.Frames.Insert(position, bitmap);
            sprite.FireChanged();
        }
Exemplo n.º 10
0
        public void Undo(Document doc)
        {
            SpriteDocument sprite = (SpriteDocument)doc;

            ImageArray frames = (ImageArray)sprite.Frames;

            frames.Clear();
            frames.Resize(oldSize.Width, oldSize.Height);
            frames.AddRange(oldFrames);
            sprite.FireChanged();
        }
Exemplo n.º 11
0
        public void Undo(Document doc)
        {
            SpriteDocument   sprite  = (SpriteDocument)doc;
            StringDictionary scripts = sprite.Metadata;

            for (int i = 0; i < names.Length; i++)
            {
                scripts[names[i]] = oldValues[i];
            }
            sprite.FireChanged();
        }
Exemplo n.º 12
0
        public void Do(Document doc)
        {
            SpriteDocument   sprite  = (SpriteDocument)doc;
            StringDictionary scripts = sprite.Metadata;

            for (int i = 0; i < names.Length; i++)
            {
                oldValues[i] = scripts[names[i]];
                scripts.Remove(names[i]);
            }
            sprite.FireChanged();
        }
Exemplo n.º 13
0
        public void Undo(Document doc)
        {
            SpriteDocument   sprite  = (SpriteDocument)doc;
            StringDictionary scripts = sprite.Metadata;

            scripts.Remove(newName);
            if (oldName != null)
            {
                scripts[oldName] = oldValue;
            }
            sprite.FireChanged();
        }
Exemplo n.º 14
0
        public void Do(Document doc)
        {
            SpriteDocument sprite = (SpriteDocument)doc;

            oldSize = sprite.Size;

            oldFrames = new Bitmap[sprite.Frames.Count];
            for (int i = 0; i < sprite.Frames.Count; i++)
            {
                Bitmap frame = (Bitmap)sprite.Frames[i];
                oldFrames[i] = new Bitmap(frame);
            }

            sprite.Frames.Resize(newSize.Width, newSize.Height);
            sprite.FireChanged();
        }
Exemplo n.º 15
0
        public SpriteDetailPanel(SpriteDocument sprite)
        {
            editHotX.Enter      += new EventHandler(BeginEdit);
            editHotY.Enter      += new EventHandler(BeginEdit);
            editHotWidth.Enter  += new EventHandler(BeginEdit);
            editHotHeight.Enter += new EventHandler(BeginEdit);

            editHotX.Leave      += new EventHandler(ChangeHotX);
            editHotY.Leave      += new EventHandler(ChangeHotY);
            editHotWidth.Leave  += new EventHandler(ChangeHotWidth);
            editHotHeight.Leave += new EventHandler(ChangeHotHeight);

            splitter.Dock = DockStyle.Bottom;

            metaGrid.CaptionText = "Metadata";
            metaGrid.Dock        = DockStyle.Bottom;

            animGrid.CaptionText = "Animation scripts";
            animGrid.Values      = sprite.AnimScripts;

            animGrid.ValueAdded   += new DictionaryValueAddedHandler(OnAnimScriptAdded);
            animGrid.ValueChanged += new DictionaryValueChangeHandler(OnAnimScriptChanged);
            animGrid.ValueDeleted += new DictionaryValueDeleteHandler(OnAnimScriptsDeleted);

            metaGrid.ValueAdded   += new DictionaryValueAddedHandler(OnMetadataAdded);
            metaGrid.ValueChanged += new DictionaryValueChangeHandler(OnMetadataChanged);
            metaGrid.ValueDeleted += new DictionaryValueDeleteHandler(OnMetadataDeleted);

            Controls.AddRange(new Control[] {
                xLabel,
                editHotX,
                yLabel,
                editHotY,
                widthLabel,
                editHotWidth,
                heightLabel,
                editHotHeight,
                animGrid,
                splitter,
                metaGrid,
            }
                              );

            OnLayout(null);
            ClientSize = new System.Drawing.Size(animGrid.Right, animGrid.Bottom);
            UpdateDialog(sprite);
        }
Exemplo n.º 16
0
 public FramePanel(SpriteDocument doc)
 {
     document          = doc;
     backBuffer        = new Bitmap(Size.Width, Size.Height);
     document.Changed += new rho.Documents.ChangeEventHandler(OnSpriteChanged);
 }
Exemplo n.º 17
0
        public SpriteEditor(SpriteDocument doc)
        {
            document = doc;

            Splitter splitter = new Splitter();

            detailPanel = new SpriteDetailPanel(document);
            framePanel  = new FramePanel(doc);
            scrollPanel = new Panel();

            detailPanel.Dock               = DockStyle.Left;
            detailPanel.HotSpotChanged    += new SpriteHotSpotHandler(HotSpotChanged);
            detailPanel.AnimScriptChanged += new DataChangeHandler(AnimScriptChanged);
            detailPanel.AnimScriptDeleted += new DataDeletedHandler(AnimScriptsRemoved);
            detailPanel.MetadataChanged   += new DataChangeHandler(MetadataChanged);
            detailPanel.MetadataDeleted   += new DataDeletedHandler(MetadataRemoved);

            splitter.Dock          = DockStyle.Left;
            splitter.SplitPosition = 256;

            scrollPanel.BackColor  = Color.Black;
            scrollPanel.AutoScroll = true;

            scrollPanel.Controls.Add(framePanel);

            Controls.AddRange(new Control[] { splitter, detailPanel, scrollPanel });

            MinimumSize = new Size(detailPanel.Width, MinimumSize.Height);

            framePanel.FrameSelected     += new FrameEventHandler(FrameSelected);
            framePanel.FrameRightClicked += new FrameEventHandler(FrameRightClicked);
            framePanel.Location           = new Point(0, 0);

            contextMenu = new ContextMenu(
                new MenuItem[] {
                new MenuItem("Cut", new EventHandler(CutFrame)),
                new MenuItem("Copy", new EventHandler(CopyFrame)),
                new MenuItem("-"),
                new MenuItem("Paste Over", new EventHandler(PasteOverFrame)),
                new MenuItem("Insert and Paste", new EventHandler(InsertAndPasteFrame)),
            }
                );

            MenuItem fileMenu = new MenuItem("&File", new MenuItem[] {
                MenuBuilder.menu(2, "-"),
                MenuBuilder.menu(3, "&Save", new EventHandler(Save), Shortcut.CtrlS),
                MenuBuilder.menu(4, "Save &As...", new EventHandler(SaveAs), Shortcut.CtrlShiftS),
            }
                                             );

            fileMenu.MergeType  = MenuMerge.MergeItems;
            fileMenu.MergeOrder = 1;

            MenuItem editMenu = new MenuItem("&Edit", new MenuItem[] {
                MenuBuilder.menu("&Undo", new EventHandler(Undo), Shortcut.CtrlZ),
                MenuBuilder.menu("&Redo", new EventHandler(Redo), Shortcut.CtrlY),
                MenuBuilder.separator(),
                MenuBuilder.menu("Cu&t", new EventHandler(CutFrame), Shortcut.CtrlX),
                MenuBuilder.menu("&Copy", new EventHandler(CopyFrame), Shortcut.CtrlC),
                MenuBuilder.menu("&Paste over", new EventHandler(PasteOverFrame), Shortcut.CtrlShiftV),
                MenuBuilder.menu("Insert and p&aste", new EventHandler(InsertAndPasteFrame), Shortcut.CtrlV),
                MenuBuilder.separator(),
                MenuBuilder.menu("Re&size...", new EventHandler(SpriteResized)),
                MenuBuilder.menu("&Import frames from image...", new EventHandler(ImportFramesFromImage)),
            }
                                             );

            editMenu.MergeType  = MenuMerge.MergeItems;
            editMenu.MergeOrder = 2;

            Menu = new MainMenu(new MenuItem[] { fileMenu, editMenu });
        }
Exemplo n.º 18
0
        public DockContent OpenWindow(Document doc)
        {
            SpriteDocument sprite = (SpriteDocument)doc;

            return(new SpriteEditor(sprite));
        }