Exemplo n.º 1
0
 public bool loadFromFile(string path)
 {
     try
     {
         CTwoDFigureFactory factory = CTwoDFigureFactory.GetFactory(0);
         if (factory != null)
         {
             CJSONparser parser = new CJSONparser(figuresLoader.TypesNames, figuresLoader.NamespacesNames,
                                                  figuresLoader.FiguresGroupType);
             string content = parser.ParseFile(path);
             if (content == null)
             {
                 throw new Exception();
             }
             var newPicture = new CPicture(currentPictureBackgroundColor, PictureBox, factory, PictureMode.pmEdit, figuresGroupManager, content);
             picture = newPicture;
             setStandartSettings();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         picture.Redraw();
         showErrorMessageBox(FAIL_TO_LOAD_MESSG);
         return(false);
     }
 }
Exemplo n.º 2
0
        private void btnFigure_Click(object sender, EventArgs e)
        {
            Button curBtn = (Button)sender;

            picture.currentFigure = CTwoDFigureFactory.GetFactory(figuresLoader.GetBtnNumber(curBtn.Name));
            setStandartColorForAllButtons();
            setPressedColorForButton(curBtn);
        }
Exemplo n.º 3
0
 private void tsmiNew_Click(object sender, EventArgs e)
 {
     if (projectManager.canContinue())
     {
         CTwoDFigureFactory factory = CTwoDFigureFactory.GetFactory(0);
         if (factory != null)
         {
             picture = new CPicture(currentPictureBackgroundColor, PictureBox, factory, PictureMode.pmEdit, figuresGroupManager);
             setStandartSettings();
             projectManager.resetProjectInfo();
             updateWindowCaption();
         }
     }
 }
Exemplo n.º 4
0
        public CPicture(Color canvColor, PictureBox pb, CTwoDFigureFactory factory, PictureMode startMode, CFiguresGroupManager groupManager, string filepath)
        {
            figures             = new List <CTwoDFigure>(loadPicture(filepath));
            points              = new List <Point>();
            figuresGroupManager = groupManager;

            currentColor    = Color.Black;
            BackgroundColor = canvColor;
            currentFigure   = factory;
            pointsAmo       = 0;
            mode            = startMode;

            curPicture = pb;
            buffer     = new Bitmap(curPicture.Width, curPicture.Height);
            gCanvas    = Graphics.FromImage(buffer);

            Redraw(gCanvas);
        }
Exemplo n.º 5
0
        public frmMain()
        {
            InitializeComponent();

            curBtnX   = 8;
            curBtnY   = 260;
            locationX = 0;
            locationY = 0;
            currentPictureBackgroundColor = STANDART_CANVAS_COLOR;

            figuresBtns    = new List <Button>();
            userInterface  = new CViewer(this);
            projectManager = new CProjectInfo(userInterface);
            figuresLoader  = new CFiguresLoader(userInterface);
            paramsXML      = new CParamsXML();

            figuresLoader.LoadFigures();
            CTwoDFigureFactory.LoadedFactories = figuresLoader.LoadedMethods;
            CTwoDFigure.KnownTypes             = figuresLoader.LoadedTypes;
            figuresGroupManager = new CFiguresGroupManager(userInterface, figuresLoader);

            CTwoDFigureFactory factory = CTwoDFigureFactory.GetFactory(0);

            if (factory != null)
            {
                picture = new CPicture(currentPictureBackgroundColor, PictureBox, factory, PictureMode.pmEdit, figuresGroupManager);
            }

            standartBtnColor = Color.White;
            pressedBtnColor  = Color.Bisque;
            prevMode         = PictureMode.pmEdit;
            this.SetStyle(ControlStyles.ResizeRedraw, true);

            setStandartSettings();
            updateWindowCaption();
        }