コード例 #1
0
ファイル: ucImageEditor.cs プロジェクト: pj-martins/PaJaMa
        private void deserializeDrawObjects()
        {
            _drawObjects = new List <DrawObject>();

            if (string.IsNullOrEmpty(FileName))
            {
                return;
            }

            string path = Path.Combine(Path.GetDirectoryName(FileName), "drawObjects");

            if (!Directory.Exists(path))
            {
                return;
            }

            string fileName = Path.Combine(path, Path.GetFileName(FileName) + ".xml");

            if (!File.Exists(fileName))
            {
                return;
            }

            _drawObjects = SerializableDrawObject.GetDrawObjectsFromXML(_currGraphics, File.ReadAllText(fileName), _zoomMultiplier);

            if (_drawObjects == null)
            {
                _drawObjects = new List <DrawObject>();
            }

            if (_drawObjects.Any())
            {
                redraw(true);
            }
        }
コード例 #2
0
ファイル: DrawObject.cs プロジェクト: pj-martins/PaJaMa
 public void Undo(SerializableDrawObject sdo)
 {
     _startPoint = new Point(sdo.StartPoint.X, sdo.StartPoint.Y);
     _endPoint   = new Point(sdo.EndPoint.X, sdo.EndPoint.Y);
     _pen.Color  = Color.FromArgb(sdo.PenColor);
     _pen.Width  = sdo.PenWidth;
     reset();
 }
コード例 #3
0
ファイル: DrawObject.cs プロジェクト: pj-martins/PaJaMa
        public static DrawObject FromSerialized(Graphics graphics, SerializableDrawObject sdo, float zoomMultiplier)
        {
            //var drawObj = Activator.CreateInstance(typeof(DrawObject).Assembly.GetType(sdo.DrawObjectType), new object[] { sdo.ID, graphics,
            //		new Pen(Color.FromArgb(sdo.PenColor), sdo.PenWidth), new Point(sdo.StartX, sdo.StartY), sdo.Erase, sdo.Highlight }) as DrawObject;
            var drawObj = (DrawObject)CreateDrawObject(typeof(DrawObject).Assembly.GetType(sdo.DrawObjectType), sdo.ID, graphics,
                                                       new Pen(Color.FromArgb(sdo.PenColor), sdo.PenWidth), new Point(sdo.StartPoint.X, sdo.StartPoint.Y), zoomMultiplier);

            drawObj.Erase     = sdo.Erase;
            drawObj.Highlight = sdo.Highlight;
            drawObj._endPoint = new Point(sdo.EndPoint.X, sdo.EndPoint.Y);
            drawObj.ID        = sdo.ID;
            drawObj.SetCargo(sdo.Cargo);
            drawObj.OnDrawObjectCreated();
            return(drawObj);
        }
コード例 #4
0
ファイル: ucImageEditor.cs プロジェクト: pj-martins/PaJaMa
        private void serializeDrawObjects()
        {
            if (string.IsNullOrEmpty(FileName))
            {
                return;
            }

            string path = Path.Combine(Path.GetDirectoryName(FileName), "drawObjects");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            File.WriteAllText(Path.Combine(path, Path.GetFileName(FileName) + ".xml"),
                              SerializableDrawObject.GetXMLForDrawObjects(_drawObjects));
        }