Esempio n. 1
0
        private PaletteColorData GetUndoData()
        {
            PaletteColorData undo = new PaletteColorData(k_nColors);

            RecordUndoData(ref undo);
            return(undo);
        }
Esempio n. 2
0
        public void ApplyUndoData(PaletteColorData undo)
        {
            m_data.currentColor = undo.currentColor;

            for (int i = 0; i < k_nColors; i++)
                UpdateColor(i, undo.cRed[i], undo.cGreen[i], undo.cBlue[i]);

            RecordSnapshot();
        }
Esempio n. 3
0
        public Palette256(Document doc, Palettes pals, string strName, int id, string strDesc)
            : base(doc, pals, strName, id, strDesc)
        {
            m_type = Palette.Type.Color256;

            m_data = new PaletteColorData(k_nColors);

            if (m_doc.Owner != null)
                m_winPalette = new Palette256Form(m_doc.Owner, this);
        }
Esempio n. 4
0
        public void ApplyUndoData(PaletteColorData undo)
        {
            m_data.currentColor = undo.currentColor;

            for (int i = 0; i < k_nColors; i++)
            {
                UpdateColor(i, undo.cRed[i], undo.cGreen[i], undo.cBlue[i]);
            }

            RecordSnapshot();
        }
Esempio n. 5
0
        private void RecordUndoData(ref PaletteColorData undo)
        {
            undo.currentColor = m_data.currentColor;

            for (int i = 0; i < k_nColors; i++)
            {
                undo.cRed[i]   = m_data.cRed[i];
                undo.cGreen[i] = m_data.cGreen[i];
                undo.cBlue[i]  = m_data.cBlue[i];
            }
        }
Esempio n. 6
0
        public void RecordUndoAction(string strDesc, UndoMgr undo)
        {
            if (undo == null)
            {
                return;
            }

            PaletteColorData            data   = GetUndoData();
            UndoAction_Subpalette16Edit action = new UndoAction_Subpalette16Edit(undo, this, m_snapshot, data, strDesc);
            bool fHandled = false;

            if (action.IsSelectionChange())
            {
                // Ignore selection changes
                fHandled = true;
            }
            else
            {
                // If the last undo action is also a PaletteEdit, try to merge them together
                UndoAction_Subpalette16Edit last_action = undo.GetCurrent() as UndoAction_Subpalette16Edit;
                if (last_action != null)
                {
                    // Merge 2 color changes (as long as they edit the same color)
                    int last_color, last_color_val1, last_color_val2;
                    int this_color, this_color_val1, this_color_val2;
                    if (last_action.IsColorChange(out last_color, out last_color_val1, out last_color_val2) &&
                        action.IsColorChange(out this_color, out this_color_val1, out this_color_val2)
                        )
                    {
                        if (last_color == this_color)
                        {
                            // If this color change takes it back to the original value, then
                            // delete the UndoAction.
                            if (last_color_val1 == this_color_val2)
                            {
                                undo.DeleteCurrent();
                            }
                            else
                            {
                                last_action.UpdateRedoData(data);
                            }
                            fHandled = true;
                        }
                    }
                }
            }
            if (!fHandled)
            {
                undo.Push(action);
            }

            // Update the snapshot for the next UndoAction
            RecordSnapshot();
        }
Esempio n. 7
0
        public Palette256(Document doc, Palettes pals, string strName, int id, string strDesc) :
            base(doc, pals, strName, id, strDesc)
        {
            m_type = Palette.Type.Color256;

            m_data = new PaletteColorData(k_nColors);

            if (m_doc.Owner != null)
            {
                m_winPalette = new Palette256Form(m_doc.Owner, this);
            }
        }
Esempio n. 8
0
 public PaletteColorData(PaletteColorData data)
 {
     numColors = data.numColors;
     currentColor = data.currentColor;
     cRed = new int[numColors];
     cGreen = new int[numColors];
     cBlue = new int[numColors];
     for (int i = 0; i < numColors; i++)
     {
         cRed[i] = data.cRed[i];
         cGreen[i] = data.cGreen[i];
         cBlue[i] = data.cBlue[i];
     }
 }
Esempio n. 9
0
 public PaletteColorData(PaletteColorData data)
 {
     numColors    = data.numColors;
     currentColor = data.currentColor;
     cRed         = new int[numColors];
     cGreen       = new int[numColors];
     cBlue        = new int[numColors];
     for (int i = 0; i < numColors; i++)
     {
         cRed[i]   = data.cRed[i];
         cGreen[i] = data.cGreen[i];
         cBlue[i]  = data.cBlue[i];
     }
 }
        public UndoAction_Subpalette16Edit(UndoMgr mgr, Subpalette subpalette, PaletteColorData before, PaletteColorData after, string strDesc)
        {
            m_mgr = mgr;
            m_subpalette = subpalette;
            m_before = new PaletteColorData(before);
            m_after = new PaletteColorData(after);

            int b = before.currentColor;
            int a = after.currentColor;
            Description = "Subpalette16Edit " + subpalette.SubpaletteID + "," + before.currentColor + " ("
                + before.cRed[b] + "," + before.cGreen[b] + "," + before.cBlue[b]
                + ") -> ("
                + after.cRed[a] + "," + after.cGreen[a] + "," + after.cBlue[a]
                + ")";
        }
Esempio n. 11
0
        private void Init(Document doc, Palette mgr, int nSubpaletteID, DefaultColorSet eDefaultColorSet)
        {
            m_doc           = doc;
            m_mgr           = mgr;
            m_nSubpaletteID = nSubpaletteID;

            m_data  = new PaletteColorData(k_nColors);
            m_Brush = new SolidBrush[k_nColors];

            // Default color = black (index 1)
            m_data.currentColor = 1;

            m_snapshot = new PaletteColorData(k_nColors);
            SetDefaultSubpaletteColors(eDefaultColorSet);
        }
Esempio n. 12
0
        PaletteColorData m_after;               // Redo

        public UndoAction_Subpalette16Edit(UndoMgr mgr, Subpalette subpalette, PaletteColorData before, PaletteColorData after, string strDesc)
        {
            m_mgr        = mgr;
            m_subpalette = subpalette;
            m_before     = new PaletteColorData(before);
            m_after      = new PaletteColorData(after);

            int b = before.currentColor;
            int a = after.currentColor;

            Description = "Subpalette16Edit " + subpalette.SubpaletteID + "," + before.currentColor + " ("
                          + before.cRed[b] + "," + before.cGreen[b] + "," + before.cBlue[b]
                          + ") -> ("
                          + after.cRed[a] + "," + after.cGreen[a] + "," + after.cBlue[a]
                          + ")";
        }
Esempio n. 13
0
        public bool Equals(PaletteColorData data)
        {
            if (currentColor != data.currentColor
                || numColors != data.numColors
                )
                return false;

            for (int i = 0; i < numColors; i++)
            {
                if (cRed[i] != data.cRed[i]
                    || cGreen[i] != data.cGreen[i]
                    || cBlue[i] != data.cBlue[i]
                    )
                    return false;
            }
            return true;
        }
Esempio n. 14
0
        public bool Equals(PaletteColorData data)
        {
            if (currentColor != data.currentColor ||
                numColors != data.numColors
                )
            {
                return(false);
            }

            for (int i = 0; i < numColors; i++)
            {
                if (cRed[i] != data.cRed[i] ||
                    cGreen[i] != data.cGreen[i] ||
                    cBlue[i] != data.cBlue[i]
                    )
                {
                    return(false);
                }
            }
            return(true);
        }
 /// <summary>
 /// Update the "after" UndoData. This is used when merging two UndoActions together.
 /// </summary>
 /// <param name="after"></param>
 public void UpdateRedoData(PaletteColorData after)
 {
     m_after = new PaletteColorData(after);
 }
Esempio n. 16
0
        private void RecordUndoData(ref PaletteColorData undo)
        {
            undo.currentColor = m_data.currentColor;

            for (int i = 0; i < k_nColors; i++)
            {
                undo.cRed[i] = m_data.cRed[i];
                undo.cGreen[i] = m_data.cGreen[i];
                undo.cBlue[i] = m_data.cBlue[i];
            }
        }
Esempio n. 17
0
        private void Init(Document doc, Palette mgr, int nSubpaletteID, DefaultColorSet eDefaultColorSet)
        {
            m_doc = doc;
            m_mgr = mgr;
            m_nSubpaletteID = nSubpaletteID;

            m_data = new PaletteColorData(k_nColors);
            m_Brush = new SolidBrush[k_nColors];

            // Default color = black (index 1)
            m_data.currentColor = 1;

            m_snapshot = new PaletteColorData(k_nColors);
            SetDefaultSubpaletteColors(eDefaultColorSet);
        }
Esempio n. 18
0
 private PaletteColorData GetUndoData()
 {
     PaletteColorData undo = new PaletteColorData(k_nColors);
     RecordUndoData(ref undo);
     return undo;
 }
Esempio n. 19
0
 /// <summary>
 /// Update the "after" UndoData. This is used when merging two UndoActions together.
 /// </summary>
 /// <param name="after"></param>
 public void UpdateRedoData(PaletteColorData after)
 {
     m_after = new PaletteColorData(after);
 }