首页 > 代码库 > 当各种语言集中到一个人,脑子有些乱套 1

当各种语言集中到一个人,脑子有些乱套 1

   // Call this function AFTER operation.

        public void NewState(GraphicsList graphicsList)

        {

            // Keep objects state after operation.

            listAfter = new List<DrawObject>();

            afterZoomRate = new List<PointF>();

            DrawObject newO = null;

            bool bValid = false;

            foreach (DrawObject o in graphicsList.graphicsList)

            {

                if(!bValid)

                {

                    //afterZoomRate.X = o.ObjectZoomRate.X;

                    //afterZoomRate.Y = o.ObjectZoomRate.Y;

                    afterZoomRate.Add(new PointF(o.ObjectZoomRate.X, o.ObjectZoomRate.Y));

                    bValid = true;

 

                }

                if (o.ObjectType == (int)DrawArea.DrawToolType.Line)

                {

                    listAfter.Add(o.Clone());

                }

                else if (o.ObjectType == (int)DrawArea.DrawToolType.PolyLine)

                {

 

                    newO = new DrawPolyLine(((DrawPolyLine)o).pointArray[0].X, ((DrawPolyLine)o).pointArray[0].Y);

                    int num = 0;

 

                    foreach (PointF point in ((DrawPolyLine)o).pointArray.ToArray())

                    {

                        if (num >= 1)

                        {

                            ((DrawPolyLine)newO).AddPoint(point);

                        }

                        num++;

                    }

 

                    newO.ID = o.ID;

                    newO.ObjectType = o.ObjectType;

                    //记?录?缩?放¤?及??拖a?拽á?ì

                    newO.ObjectZoomRate = o.ObjectZoomRate;

                    newO.ObjectDragOffset = o.ObjectDragOffset;

 

                    //当ì?à多¨¤段?线?时o?à,List<T>指?向¨°内¨2存?? 当ì?à内¨2存??发¤?é生|¨2变à?化?¥则¨°跟¨2随?之?变à?化?¥ 导ì?致?无T法¤?§撤?¤销¨2恢?复??上|?一°?个?状á??态??

                    listAfter.Add(newO);

                }

            }

 

        }

 

        public override void Undo(GraphicsList list)

        {

            list.Clear();

            foreach (DrawObject o in listBefore )

            {

                list.Add(o.Clone());// o   /o.Clone()

            }

            

            //UndoObjects(list);

            list.UpdateZoomRate(beforeZoomRate[0],true);

        }

 

        public override void Redo(GraphicsList list)

        {

            list.Clear();

            foreach (DrawObject o in listAfter)

            {

                list.Add(o.Clone());//o.Clone()  o

            }

          

            //RedoObjects(list);

            list.UpdateZoomRate(afterZoomRate[0],false);

        }

 

        // Replace objects in graphicsList with objects from list

        private void UndoObjects(GraphicsList graphicsList)

        {

            for (int i = 0; i < graphicsList.Count; i++)

            {

                DrawObject replacement = null;

 

                foreach (DrawObject o in listBefore)

                {

                    if (o.ID == graphicsList[i].ID)

                    {

                        replacement = o;

                        //缩?放¤?比ਨ例¤y

                        graphicsList.Replace(i, replacement);

 

                    }

                   /* else

                    {

                        o.Resize(beforeZoomRate, o.ObjectZoomRate.X);

                    }*/

                }

        

            }

        }

 

        // Replace objects in graphicsList with objects from list

        private void RedoObjects(GraphicsList graphicsList)

        {

            for (int i = 0; i < graphicsList.Count; i++)

            {

                DrawObject replacement = null;

 

                foreach (DrawObject o in listAfter)

                {

                    if (o.ID == graphicsList[i].ID)

                    {

                        replacement = o;

                        //缩?放¤?比ਨ例¤y

                        graphicsList.Replace(i, replacement);

 

                    }

                   /* else

                    {

                        o.Resize(afterZoomRate, o.ObjectZoomRate.X);

                    }*/

                }

 

            }

        }

 

 

 

    }

}

 

 

======================================================================================================================================================================================================================================================

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

 

namespace CSharp

{

    public partial class AdminForm : Form

    {

        MainForm parentform = new MainForm();

        public AdminForm(MainForm parent)

        {

            InitializeComponent();

            parentform = parent;

        }

 

        public float GetMergeDis()

        {

           return (float)(Convert.ToDouble(mergeDistextBox.Text));

        }

 

        public float GetSplitDis()

        {

            return(float)((Convert.ToDouble(splitDistextBox.Text))*parentform.drawArea.pxwidth);

        }

 

       

    }

}

 

 

 

==================================================================================

当各种语言集中到一个人,脑子有些乱套 1