Exemplo n.º 1
0
        /**
         * @brief 현재 그려져 있는 객체 중에서 해당 그룹에 해당하는 객체만 저장하기 위해 오버로딩된 메서드이다.
         * @details view에 있는 pictureBox를 들고 와서 pictureBox를 Bitmap형식으로 저장한 다음에 객체만 저장하기 위해서 객체의 크기로 자른다. 자른 후에 PNG형식으로 저장한다.
         * @author 김효상
         * @date 2017-07-31
         * @param fileName 저장할 파일 이름
         * @param groupName 저장할 그룹 이름
         */
        public String SavePNG(string fileName, string groupName)
        {
            FigureList copyList = (FigureList)drawnFigures.Clone();

            drawnFigures.Clear();
            foreach (Figure figure in copyList)
            {
                if (figure.groupName.Equals(groupName))
                {
                    drawnFigures.Add(figure);
                }
            }
            UpdateAllViews();

            PictureBox ptemp = ((View)viewList[1]).getPictureBox();

            int W = ptemp.Width;
            int H = ptemp.Height;

            Bitmap temp = new Bitmap(W, H);

            ptemp.DrawToBitmap(temp, new Rectangle(0, 0, W, H));
            temp.MakeTransparent(Color.White);
            temp.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
            innerNeedSave = false;

            drawnFigures = copyList;
            UpdateAllViews();
            return(fileName);
        }
Exemplo n.º 2
0
        /**
         * @brief 입력으로 받은 파일이름으로 입력받은 그룹에 해당하는 figure만 저장하기 위해 오버로딩된 메서드이다.
         * @details 도형이 잘리지 않도록 하기 위해서 View의 크기에 맞게 잘라서 저장된다. 저장하는 파일 경로가 각 객체의 groupName에 저장된다.
         * @author 김효상
         * @date 2017-07-31
         * @param fileName 저장하고자 하는 파일이름
         * @param groupName 저장하고자 하는 그룹의 이름
         */
        public String SaveDocument(string fileName, string groupName)
        {
            View ptemp = ((View)viewList[0]);
            int  W     = ptemp.Width;
            int  H     = ptemp.Height;

            this.fileName = fileName;
            Stream          streamWrite = File.Create(fileName);
            BinaryFormatter binaryWrite = new BinaryFormatter();
            FigureList      groupList   = new FigureList();

            foreach (Figure figure in drawnFigures)
            {
                if (figure.groupName.Equals(groupName))
                {
                    figure.groupName = Path.GetFullPath(fileName);
                    groupList.Add(figure);
                }
            }
            binaryWrite.Serialize(streamWrite, groupList);
            streamWrite.Close();
            innerNeedSave = false;

            return(fileName);
        }
Exemplo n.º 3
0
        /**
         * @brief FigureList 상대좌표계 복제
         * @author 김민규
         * @date 2017-2-7
         * @param magnificationRatio 확대 비율
         * @param screenPos 화면의 현재 위치
         * @return FigureList 똑같은 값을 가지는 새로운 FigureList를 생성해 반환한다.
         */
        public virtual FigureList RelativeClone(int magnificationRatio, Pos screenPos)
        {
            FigureList list = new FigureList();

            for (int i = 0; i < this.Count; i++)
            {
                list.Add((Figure)this[i].RelativeClone(magnificationRatio, screenPos));
            }
            return(list);
        }
Exemplo n.º 4
0
        /**
         * @brief FigureList 복제
         * @author 김민규
         * @date 2017-1-27
         * @return object 똑같은 값을 가지는 새로운 FigureList를 생성해 반환한다.
         */
        public virtual object Clone()
        {
            FigureList list = new FigureList();

            for (int i = 0; i < this.Count; i++)
            {
                list.Add((Figure)this[i].Clone());
            }
            return(list);
        }
Exemplo n.º 5
0
        /**
         * @brief 선택된 객체가 맨 앞으로 가지 않고 Z값을 준수하도록 더 앞 객체의 리스트를 불러온다.
         * @author 김민규
         * @date 2017-1-27
         * @param currentFigure 비교할 객체
         * @return FigureList 더 높은 Z값을 가지는 오브젝트의 리스트
         */
        public FigureList getHigherZFigures(Figure currentFigure)
        {
            FigureList higherZFigures     = new FigureList();
            int        currentFigureIndex = drawnFigures.IndexOf(currentFigure);

            for (int currentIndex = currentFigureIndex + 1; currentIndex < drawnFigures.Count; currentIndex++)
            {
                higherZFigures.Add(drawnFigures[currentIndex]);
            }
            return(higherZFigures);
        }
Exemplo n.º 6
0
        /**
         * @brief Equals의 재정의 메서드
         * @details FigureList 내부의 인스턴스들을 전부 비교해서 확인한다.
         * @author 김민규
         * @date 2017-1-27
         * @param rawrhs 같은 지 비교할 객체
         */
        public override bool Equals(object rawrhs)
        {
            if (rawrhs == null || GetType() != rawrhs.GetType())
            {
                return(false);
            }

            FigureList rhs = (FigureList)rawrhs;

            for (int i = 0; i < this.Count; i++)
            {
                if (!this[i].Equals(rhs[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 7
0
        /**
         * @brief 복제
         * @author 불명(김민규 담당)
         * @date 불명(2017-1-17 확인)
         * @return object 똑같은 값을 가지는 새로운 Figure를 생성해 반환한다. 사실상 팩토리 역할을 한다.
         */
        public virtual object Clone()
        {
            Figure figure = null;

            if (this.GetType() == typeof(LineFigure))
            {
                figure = new LineFigure();
            }
            else if (this.GetType() == typeof(PolyLineFigure))
            {
                figure = new PolyLineFigure();
            }
            else if (this.GetType() == typeof(FreeLineFigure))
            {
                figure = new FreeLineFigure();
            }
            else if (this.GetType() == typeof(RectFigure))
            {
                figure = new RectFigure();
            }
            else if (this.GetType() == typeof(OvalFigure))
            {
                figure = new OvalFigure();
            }
            else if (this.GetType() == typeof(ImageFigure))
            {
                figure = new ImageFigure(((ImageFigure)this).getImage());
            }
            else if (this.GetType() == typeof(MergedFigure))
            {
                FigureList figureListToClone = ((MergedFigure)this).getFigList();
                figure = new MergedFigure((FigureList)figureListToClone.Clone());
            }
            else
            {
                throw new System.NotImplementedException();
            }

            figure.coordinates = (RectList)this.coordinates.Clone();
            figure.filledColor = this.filledColor;
            figure.bFilled     = this.bFilled;
            figure.groupName   = this.groupName;
            return(figure);
        }
Exemplo n.º 8
0
        /**
         * @brief 복제 뒤 상대좌표 반영
         * @author 김민규
         * @date 2017-02-07
         * @param magnificationRatio 확대 비율
         * @param screenPos 화면의 현재 위치
         */
        public virtual Figure RelativeClone(int magnificationRatio, Pos screenPos)
        {
            Figure figure = null;

            if (this.GetType() == typeof(LineFigure))
            {
                figure = new LineFigure();
            }
            else if (this.GetType() == typeof(PolyLineFigure))
            {
                figure = new PolyLineFigure();
            }
            else if (this.GetType() == typeof(FreeLineFigure))
            {
                figure = new FreeLineFigure();
            }
            else if (this.GetType() == typeof(RectFigure))
            {
                figure = new RectFigure();
            }
            else if (this.GetType() == typeof(OvalFigure))
            {
                figure = new OvalFigure();
            }
            else if (this.GetType() == typeof(ImageFigure))
            {
                figure = new ImageFigure(((ImageFigure)this).getImage());
            }
            else if (this.GetType() == typeof(MergedFigure))
            {
                FigureList figureListToClone = ((MergedFigure)this).getFigList();
                figure = new MergedFigure((FigureList)figureListToClone.RelativeClone(magnificationRatio, screenPos));
            }
            else
            {
                throw new System.NotImplementedException();
            }

            figure.coordinates = (RectList)this.coordinates.RelativeClone(magnificationRatio, screenPos);
            figure.filledColor = this.filledColor;
            return(figure);
        }
Exemplo n.º 9
0
 /**
  * @brief mergedFigure를 unmerge된 상태의 Figure들로 분리한다.
  */
 public void unmergeFigure()
 {
     if (drawingFigures.Count > 0)
     {
         foreach (Figure f in drawingFigures)
         {
             if (f is MergedFigure)
             {
                 MergedFigure mf          = f as MergedFigure;
                 string       motherGName = f.groupName;
                 mf.deselect();
                 FigureList unmerge = mf.getFigList();
                 foreach (Figure temp in unmerge)
                 {
                     temp.groupName = motherGName;
                 }
                 drawnFigures.Remove(mf);
                 drawnFigures.AddRange(unmerge);
             }
         }
     }
 }
Exemplo n.º 10
0
 /**
  * @brief stack에 들어있던 objList를 Document객체의 objList에 넣는다.
  */
 public void restoreToLastSnapshot()
 {
     drawnFigures = undoSnapshot.Pop();
     UpdateAllViews();
 }