public DrawingToolsVM(Window parent, CanvasControlVM canvasControl, double fps) { var pencilTool = new PencilTool(_control.DrawingPanel, (x) => _window.GetDrawingColor(x), ChangeLine, fps); var lineTool = new LineTool(_control.DrawingPanel, (x) => _window.GetDrawingColor(x), () => pencilTool.Thickness, ChangeLine); var pickerTool = new PickerTool(_control.DrawingPanel, canvasControl.View, (x, y) => _window.SetDrawingColor(x, y)); _control.DrawingPanel.Children.Add(canvasControl.View); _control.Loaded += (s, e) => Control_Loaded(pencilTool, lineTool, pickerTool, parent); }
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(); }
public void SwitchToPencilTool() { var tool = new PencilTool(_device, new Vector2(1, 1), _currentColor); SwitchTool(tool); }
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(); }
private void OnEnable() { _target = (PencilTool)target; }