예제 #1
0
 private void btn_AddBoundingBbox_Click(object sender, RoutedEventArgs e)
 {
     //Draw Rectangle aka BoundaryBox
     //MyRectangleGeometry = new RectangleGeometry(TtfObject.BoundaryBox);
     //DrawThisGeometry(MyRectangleGeometry);
     //PathGeometry tmp = Converter.CloseAllPathGeometries(globalPathGeometry);
     DrawThisGeometry(FillTool.GetMaximumRect(TtfObject.TextAsPathGeometry));
 }
예제 #2
0
        public string UploadFile()
        {
            HttpPostedFileBase file = Request.Files["myfile"];


            FillTool fillTool = new FillTool();


            string date = fillTool.getNowDate();

            int type = fillTool.getFileType(file.FileName);

            //文件名添加guid防止文件名重复
            var gu = Guid.NewGuid();


            var fileName = file.FileName;
            var filePath = Server.MapPath("~/Temp/" + "username");
            int size     = file.ContentLength;



            //根据用户名创建文件夹
            if (System.IO.Directory.Exists(Server.MapPath("~/Temp/" + "username")) == false)//如果不存在就创建file文件夹
            {
                System.IO.Directory.CreateDirectory(Server.MapPath("~/Temp/" + "username"));
            }

            if (System.IO.File.Exists(filePath + "/" + fileName))
            {
                return("已存在");
            }


            file.SaveAs(Path.Combine(filePath, fileName));

            //decimal size = fillTool.getDirectorySize(filePath + "/" + fileName, "MB");

            //文件实体类
            API.Model.fileOne fileOne = new API.Model.fileOne();
            fileOne.tb_int         = gu;
            fileOne.tb_name_before = file.FileName;
            fileOne.tb_name_now    = fileName;
            fileOne.tb_date        = date;
            fileOne.tb_size        = size;
            fileOne.tb_username    = "******";
            fileOne.tb_userid      = 1;
            fileOne.tb_type        = type;
            fileOne.tb_address     = filePath;
            fileOne.tb_projectid   = 2;
            fileOne.tb_project     = "b";


            fone.AddB(fileOne);


            return("上传成功");
        }
예제 #3
0
 public DrawTools(MainWin window, PictureBox pic)
 {
     this.mainWindow  = window;
     this.mainPicture = pic;
     this.pointerTool = new PointerTool(mainWindow, mainPicture);
     this.lineTool    = new LineTool(mainWindow, mainPicture);
     this.rectTool    = new RectTool(mainWindow, mainPicture);
     this.polyTool    = new PolyTool(mainWindow, mainPicture);
     this.circleTool  = new CircleTool(mainWindow, mainPicture);
     this.curveTool   = new CurveTool(mainWindow, mainPicture);
     this.fillTool    = new FillTool(mainWindow, mainPicture);
     this.resizeTool  = new ResizeTool(mainWindow, mainPicture);
     this.cutTool     = new CutTool(mainWindow, mainPicture);
 }
예제 #4
0
    private void GlobalInputHack()
    {
        Event e = Event.current;

        if (e.type == EventType.KeyDown)
        {
            if (e.keyCode == KeyCode.D)
            {
                DrawTool.GetBrush().Rotate();
                Parent.Repaint();
                Repaint();
            }
            if (e.keyCode == KeyCode.Alpha1)
            {
                DrawTool = new PaintTool(this, DrawTool.GetBrush());
                Repaint();
            }
            if (e.keyCode == KeyCode.Alpha2)
            {
                DrawTool = new FillTool(this, DrawTool.GetBrush() as NormalBrush);
                Repaint();
            }
            if (e.keyCode == KeyCode.Alpha3)
            {
                DrawTool = new ReplaceTool(this, DrawTool.GetBrush() as NormalBrush);
                Repaint();
            }

            var brush = DrawTool.GetBrush();

            if (DrawTool is PaintTool && brush is NormalBrush)
            {
                if (e.keyCode == KeyCode.A)
                {
                    //_brushWindow.BrushSizeAdd(-1);
                }

                if (e.keyCode == KeyCode.S)
                {
                    //_brushWindow.BrushSizeAdd(1);
                }
            }

            if (e.keyCode == KeyCode.Alpha3)
            {
                _drawTileSetWindow.SetBrush(-1);
            }
        }
    }
예제 #5
0
        public FormMain()
        {
            InitializeComponent();
            //WindowState = FormWindowState.Maximized;
            openImageDialog.Title = "Открыть изображение";
            saveImageDialog.Title = "Сохранить изображение";

            templateShown = false;
            isTemplateOn  = false;

            BackgroundImage                = null; //is it correct way to clear BackgroundImage of the form?
            templatePanel.Enabled          = false;
            templatePanel.Visible          = false;
            templatePanelMinimized.Enabled = false;
            templatePanelMinimized.Visible = false;

            isImageSaved = false;

            snapshot = new Bitmap(mainPictureBox.Width, mainPictureBox.Height);
            backPic  = new Bitmap(mainImagePanel.Width, mainImagePanel.Height);
            loadPic  = null;

            mouseDown              = false;
            clearFlag              = false;
            loadPicFlag            = false;
            activeToolControlName  = null;
            activeColorControlName = null;
            width = lineThicknessTrackBar.Value;

            eraser  = new EraserTool(width);
            pencil  = new PencilTool(width);
            rect    = new RectangleTool(width);
            line    = new LineTool(width);
            ellipse = new EllipseTool(width);
            fill    = new FillTool();

            toolsList = new Dictionary <string, ITool>();
            toolsList.Add("labelPencil", pencil);
            toolsList.Add("labelEraser", eraser);
            toolsList.Add("labelRect", rect);
            toolsList.Add("labelLine", line);
            toolsList.Add("labelEllipse", ellipse);
            toolsList.Add("labelFill", fill);

            loadTemplate = new FormLoadTemplate();
        }
예제 #6
0
파일: PaintCore.cs 프로젝트: robmikh/paint
        public void SwitchToFillTool()
        {
            var tool = new FillTool(_device, _currentColor);

            SwitchTool(tool);
        }
예제 #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Bundle extras = Intent.Extras;

            spriteName = extras.GetString(GetString(Resource.String.bundle_sprite_name));
            int[] dimensions = extras.GetIntArray(
                GetString(Resource.String.bundle_sprite_dimensions));

            w = dimensions[0];
            h = dimensions[1];

            //SetContentView(Resource.Layout.make_sprite);

            SetContentView(Resource.Layout.activity_make_sprite); // Drawer layout

            drawButton = FindViewById <Button>(Resource.Id.drawButton);
            drawButton.GetLocationOnScreen(buttonLocs);
            drawButton.Touch += OnbuttonPush;
            //// Setup Drawer
            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_make_sprite);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, null,
                                                                     Resource.String.navigation_drawer_open,
                                                                     Resource.String.navigation_drawer_close);

            drawerLayout.AddDrawerListener(toggle);
            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view_create_sprite);

            navigationView.SetNavigationItemSelectedListener(this);

            canvasView = FindViewById <ImageView>(Resource.Id.imageView);
            cursorView = FindViewById <ImageView>(Resource.Id.cursorView);

            SetUpImage(ref this.canvas, ref this.mainSpriteDisplay, ref this.sourceBitmap, canvasView, w, h);

            commandHistory = new CommandHistory();
            //Seems redundant for now
            tools       = new Tool[4];
            tools[0]    = new PencilTool(commandHistory, sourceBitmap);
            tools[1]    = new EraserTool(commandHistory, sourceBitmap);
            tools[2]    = new FillTool(commandHistory, sourceBitmap);
            tools[3]    = new ColorPickerTool(commandHistory, sourceBitmap);
            currentTool = tools[0];

            FrameLayout spriteMainLayout = FindViewById <FrameLayout>(Resource.Id.make_sprite_main_layout);

            spriteMainLayout.Touch += OnSpriteCanvasTouched;

            SetupSideImageViews(Resource.Id.imageViewLeft, sourceBitmap);
            SetupSideImageViews(Resource.Id.imageViewTop, sourceBitmap);
            SetupSideImageViews(Resource.Id.imageViewRight, sourceBitmap);
            SetupSideImageViews(Resource.Id.imageViewBottom, sourceBitmap);

            canvas.DrawARGB(255, 255, 0, 255);

            curX = cursorView.GetX();
            curY = cursorView.GetY();


            SetupButtons();
        }
예제 #8
0
        public void SwitchTool(ToolType toolType)
        {
            if (toolType != ToolType.Move && ToolWhileMoveTool != null && ToolWhileMoveTool.GetToolType() == toolType)
            {
                ToolCurrent       = ToolWhileMoveTool;
                ToolWhileMoveTool = null;
                return;
            }
            ToolWhileMoveTool = null;

            if (ToolCurrent != null)
            {
                ToolCurrent.ResetUsedElements();
            }

            switch (toolType)
            {
            case ToolType.Brush:
                ToolCurrent = new BrushTool();
                break;

            case ToolType.Crop:
                ToolCurrent = new CropTool();
                break;

            case ToolType.Cursor:
                ToolCurrent = new CursorTool();
                break;

            case ToolType.Fill:
                ToolCurrent = new FillTool();
                break;

            case ToolType.Ellipse:
                ToolCurrent = new EllipseTool();
                break;

            case ToolType.Eraser:
                ToolCurrent = new EraserTool();
                break;

            case ToolType.ImportPng:
                ToolCurrent = new ImportTool();
                break;

            case ToolType.Flip:
                ToolCurrent = new FlipTool();
                break;

            case ToolType.Line:
                ToolCurrent = new LineTool();
                break;

            case ToolType.Zoom:
                ToolCurrent = new MoveZoomTool();
                break;

            case ToolType.Move:
                ToolWhileMoveTool = ToolCurrent;
                ToolCurrent       = new MoveZoomTool(false);
                break;

            case ToolType.Pipette:
                ToolCurrent = new PipetteTool();
                break;

            case ToolType.Rotate:
                ToolCurrent = new RotateTool();
                break;

            case ToolType.Rect:
                ToolCurrent = new RectangleTool();
                break;

            case ToolType.Stamp:
                ToolCurrent = new StampTool();
                break;

            default:
                break;
            }
        }
예제 #9
0
    public override void ToolBar()
    {
        base.ToolBar();

        GUILayout.Box("Misc", EditorStyles.toolbarDropDown);
        Rect miscRect = GUILayoutUtility.GetLastRect();

        if (MyGUI.ButtonMouseDown(miscRect))
        {
            var misc = PopupWindow.ShowAtPosition <MiscPopup>(new Rect(miscRect.x, miscRect.y + miscRect.height, 120f, 60));
            misc.Setup(TilerMap);
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        GUI.enabled = TilerMapEditFunctions.Undo.IsUndo();
        if (GUILayout.Button("<", EditorStyles.toolbarButton))
        {
            TilerMapEditFunctions.Undo.PerformUndo();
            Repaint();
        }
        GUI.enabled = TilerMapEditFunctions.Undo.IsRedo();
        if (GUILayout.Button(">", EditorStyles.toolbarButton))
        {
            TilerMapEditFunctions.Undo.PerformRedo();
            Repaint();
        }
        GUI.enabled = true;

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (MyGUI.HasToggledPositive(DrawTool is PaintTool, "P", EditorStyles.toolbarButton))
        {
            DrawTool = new PaintTool(this, DrawTool.GetBrush() as NormalBrush);
            Repaint();
        }
        if (MyGUI.HasToggledPositive(DrawTool is FillTool, "F", EditorStyles.toolbarButton))
        {
            DrawTool = new FillTool(this, DrawTool.GetBrush() as NormalBrush);
            Repaint();
        }
        if (MyGUI.HasToggledPositive(DrawTool is ReplaceTool, "R", EditorStyles.toolbarButton))
        {
            DrawTool = new ReplaceTool(this, DrawTool.GetBrush() as NormalBrush);
            Repaint();
        }

        EditorGUILayout.Space();

        if (GUILayout.Button("O", EditorStyles.toolbarButton))
        {
            var p = _camera.transform.position;
            p.x = 0;
            p.z = 0;
            _camera.transform.position = p;
        }

        EditorGUILayout.Space();

        //var currentIndex = _mapIndex;
        //_mapIndex = EditorGUILayout.Popup(_mapIndex, _mapNames, EditorStyles.toolbarPopup);

        //options = new[] { "CanJump", "CanShoot", "CanSwim" };
        //flags = EditorGUILayout.MaskField("Layers", 1, options, EditorStyles.toolbarPopup);

        GUILayout.Box("Layers", EditorStyles.toolbarDropDown);
        Rect last = GUILayoutUtility.GetLastRect();

        if (MyGUI.ButtonMouseDown(last))
        {
            var height = 20 * _tilerMaps.Count + 20;// +25;

            var lp = PopupWindow.ShowAtPosition <LayerPopup>(new Rect(last.x, last.y + last.height, 150f, height));
            lp.Setup(_mapIndex, _mapMask, _tilerMaps, SetMapChange, SetMapMask, Save);
            GUIUtility.ExitGUI();
        }

        /*if (currentIndex != _mapIndex)
         * {
         *  Save();
         *  SetMap(_mapIndex);
         * }*/
    }
예제 #10
0
        void AddFilling()
        {
            PathGeometry pGeometry = TtfObject.TextAsPathGeometry;

            DrawThisGeometry(FillTool.GetFillingLines(pGeometry, Convert.ToInt32(tb_desity.Text), Convert.ToInt32(tb_degree.Text)));
        }
예제 #11
0
        private void SetTool()
        {
            //
            // Toolbar
            //
            ToolBar = new Toolbar();
            ToolBar.SetActiveCanvas(DrawingCanvas);
            ToolBar.AddSeparator();
            ToolBar.ItemClicked += new ToolStripItemClickedEventHandler(Toolbar_ItemClicked);

            OutlineColorChooser OColorChooser = new OutlineColorChooser();

            ToolBar.AddTool(OColorChooser);
            ToolBar.AddSeparator();

            FillColorChooser IColorChooser = new FillColorChooser();

            ToolBar.AddTool(IColorChooser);
            ToolBar.AddSeparator();

            this.Controls.Add(ToolBar);
            //
            // Toolbox
            //
            ToolBox = new Toolbox();
            ToolBox.SetActiveCanvas(DrawingCanvas);

            LineTool LineToolStrip = new LineTool();

            LineToolStrip.Click += new EventHandler(Toolbox_ItemClicked);
            LineToolStrip.SubscribeLine(OColorChooser);
            ToolBox.AddTool(LineToolStrip);

            EllipseTool EllipseToolStrip = new EllipseTool();

            EllipseToolStrip.Click += new EventHandler(Toolbox_ItemClicked);
            EllipseToolStrip.SubscribeFill(IColorChooser);
            EllipseToolStrip.SubscribeLine(OColorChooser);
            ToolBox.AddTool(EllipseToolStrip);

            RectangleTool RectangleToolStrip = new RectangleTool();

            RectangleToolStrip.Click += new EventHandler(Toolbox_ItemClicked);
            RectangleToolStrip.SubscribeFill(IColorChooser);
            RectangleToolStrip.SubscribeLine(OColorChooser);
            ToolBox.AddTool(RectangleToolStrip);
            ToolBox.AddSeparator();

            SelectionTool SelectionToolStrip = new SelectionTool();

            SelectionToolStrip.Click += new EventHandler(Toolbox_ItemClicked);
            ToolBox.AddTool(SelectionToolStrip);
            ToolBox.AddSeparator();

            LineFillTool LineFillToolStrip = new LineFillTool();

            LineFillToolStrip.Click += new EventHandler(Toolbox_ItemClicked);
            LineFillToolStrip.SubscribeLine(OColorChooser);
            ToolBox.AddTool(LineFillToolStrip);

            FillTool FillToolStrip = new FillTool();

            FillToolStrip.Click += new EventHandler(Toolbox_ItemClicked);
            FillToolStrip.SubscribeFill(IColorChooser);
            ToolBox.AddTool(FillToolStrip);

            this.Controls.Add(ToolBox);
        }