/// <summary> /// Sets the current <see cref="DrawingMode"/> of the editor. /// </summary> /// <param name="mode">A <see cref="DrawingMode"/>.</param> public async ValueTask SetDrawingModeAsync(DrawingMode mode) { if (_disposed) { throw new ObjectDisposedException(nameof(ImageEditorService)); } var module = await _moduleTask.Value.ConfigureAwait(false); await module.InvokeVoidAsync("setDrawingMode", (int)mode) .ConfigureAwait(false); }
// On rectangle button click private void rectangleButton_Click(object sender, EventArgs e) { DrawingMode currentMode = defineRegionsControl.DrawingMode; // change current mode currentMode = (currentMode == DrawingMode.Rectangular) ? DrawingMode.None : DrawingMode.Rectangular; // update current mode defineRegionsControl.DrawingMode = currentMode; // change button status rectangleButton.Checked = (currentMode == DrawingMode.Rectangular); }
public Geometry(float[] vertices, uint[] indices, Shader shader, DrawingMode mode = DrawingMode.Fill) { Indices = indices; Vertices = vertices; _mode = mode; _shader = shader; setup(); }
public void clearShapes() { ShapeModels.Clear(); ClearColor(ref temporaryTexture); RenderShapes(ref targetTexture); lineCount = 0; DrawingMode temp = this.CurrentDrawingMode; this.CurrentDrawingMode = DrawingMode.Line; this.CurrentDrawingMode = temp; }
private static MapModeImplementation createNewMode(DrawingMode mode) { switch (mode) { case DrawingMode.Line: return new MapLineMode(); case DrawingMode.Image: return new MapImageMode(); case DrawingMode.Video: return new MapVideoMode(); default: return new MapNoneMode(); } }
public void rectButton_Click(object sender, RoutedEventArgs e) { inkCanvas.Cursor = Cursors.Pen; inkCanvas.EditingMode = InkCanvasEditingMode.Ink; inkCanvas.DefaultDrawingAttributes.IsHighlighter = false; inkCanvas.DefaultDrawingAttributes.FitToCurve = true; setBrushSize(); resetAllToolBackgrounds(); rectButton.Style = (Style)FindResource("highlightedButtonStyle"); mode = DrawingMode.RECT; }
void ImageMouseUp(MouseEventArgs e) { //lets the program know that mouse is no longer clicked down mouseClickedDown = false; layers[currentLayer].imageDrawings[layers[currentLayer].imageDrawings.Count - 1].SetEndPoint(new PointF(e.X, e.Y)); //sets the draw mode back to mouse drawType = DrawingMode.Mouse; InvalidateAll(); }
public static Path CreatePath(DrawingMode mode) { if (mode == DrawingMode.GdiPlus) { return((Path) new GdiPath()); } if (mode == DrawingMode.Direct2D) { return((Path)null); } return((Path)null); }
void ToggleDrawingMode_Click(object sender, RoutedEventArgs e) { if (mode == DrawingMode.Solid) { border1.ChangeDrawingMode(DrawingMode.StyulusPoints); mode = DrawingMode.StyulusPoints; } else { border1.ChangeDrawingMode(DrawingMode.Solid); mode = DrawingMode.Solid; } }
public void Modify(DrawingMode mode, short startX, short startY, short endX, short endY) { if (_mode != mode) { _mode = mode; UpdateColor(); } _x1 = (int)startX; _y1 = (int)startY; _x2 = (int)endX; _y2 = (int)endY; }
public void MoveAbsolute(int x, int y, DrawingMode mode) { // // Take coordinates as an 11-bit quantity (0-2048) even though we may not be displaying the full resolution. // if (mode != DrawingMode.Off) { AddNewVector(mode, _x, _y, x, y); } _x = x; _y = y; }
public Vector(DrawingMode mode, float intensity, bool blink, uint startX, uint startY, uint endX, uint endY) { _mode = mode; _intensity = intensity; _blink = blink; _x1 = (int)startX; _y1 = (int)startY; _x2 = (int)endX; _y2 = (int)endY; UpdateColor(); }
public void WriteLogsToService() { String s = ""; for (int a = 0; a < 2; a++) { FractalType fractalType = (FractalType)a; for (int b = 0; b < 3; b++) { DrawingMode drawingMode = (DrawingMode)b; int count = 0; ulong totalIterations = 0; ulong totalTicks = 0; foreach (var entry in entries) { if (entry.drawingMode == drawingMode && entry.fractalType == fractalType) { // pomin pierwszy rekord GPU if (drawingMode == DrawingMode.Gpu && count == 0) { count++; continue; } totalIterations += (ulong)entry.totalIterations; totalTicks += (ulong)entry.timeTicks; count++; } } if (drawingMode == DrawingMode.Gpu) { count--; } if (count > 0) { double performance = (double)totalIterations / totalTicks; s += $"Fraktal: {fractalType}, Tryb: {drawingMode}, Współczynnik wydajności: {performance}#"; } } } if (s != "") { mainWindow.SendMessageToClient(1, s); } }
// Initialization void Start() { LibPlacenote.Instance.RegisterListener(this); mLocalizationThumbnailContainer.gameObject.SetActive(false); // Set up the localization thumbnail texture event. LocalizationThumbnailSelector.Instance.TextureEvent += (thumbnailTexture) => { if (mLocalizationThumbnail == null) { return; } // set the width and height of the thumbnail based on the texture obtained RectTransform rectTransform = mLocalizationThumbnailContainer.rectTransform; if (thumbnailTexture.width != (int)rectTransform.rect.width) { rectTransform.SetSizeWithCurrentAnchors( RectTransform.Axis.Horizontal, thumbnailTexture.width * 2); rectTransform.SetSizeWithCurrentAnchors( RectTransform.Axis.Vertical, thumbnailTexture.height * 2); rectTransform.ForceUpdateRectTransforms(); } // set the texture mLocalizationThumbnail.texture = thumbnailTexture; }; // Make sure panels match the defaults startPanel.SetActive(true); mainButtonPanel.SetActive(true); modePanel.SetActive(false); paintPanel.SetActive(false); colorPalette.SetActive(false); brushTipObject.SetActive(false); snapToSurfaceBrushTipObject.SetActive(false); snapToSurfaceEnabled = false; setActiveLayerPanel.SetActive(false); showHideLayerPanel.SetActive(false); saveLoadLayerPanel.SetActive(false); // Make sure this child is active for when its parent is active buttonPanel = paintPanel.transform.Find("ButtonPanel").gameObject; buttonPanel.SetActive(true); currentDrawingMode = DrawingMode.normal; }
// Toggle the normal drawing mode private void ToggleModeNormal(bool modeNormalOn) { if (modeNormalOn) { // Turn on currentDrawingMode = DrawingMode.normal; textLabel.text = "Press the Screen to Paint"; } else { // Turn off currentDrawingMode = DrawingMode.none; } }
private void OnMouseLeftButtonClick(MouseState mouseState) { mouseClick = true; if (Text.DrawClickText(5, 5, "Layer: " + layerName, mouseState.X, mouseState.Y, mouseClick)) { currentLayer = (currentLayer + 1) % 3; } if (Text.DrawClickText(5, 25, "draw: " + layerName, mouseX, mouseY, mouseClick)) { drawingMode = (DrawingMode)((int)(drawingMode + 1) % 3); } if (drawingMode == DrawingMode.Ledges) { for (int i = 0; i < 16; i++) { var y = (int)ledgePaletteLocation[i].Y; if (Text.DrawClickText(paletteOffsetX, y, "ledge " + i.ToString(), mouseX, mouseY, mouseClick)) { currentLedge = i; } if (Text.DrawClickText(768, y, "f" + map.Ledges[i].Flags.ToString(), mouseX, mouseY, mouseClick)) { map.Ledges[i].Flags = (map.Ledges[i].Flags + 1) % 2; } } } if (Text.DrawClickText(5, 45, map.Path, mouseX, mouseY, mouseClick)) { editingMode = EditingMode.Path; } if (DrawButton(5, 65, 3, mouseX, mouseY, mouseClick)) { map.Save(); } if (DrawButton(40, 65, 4, mouseX, mouseY, mouseClick)) { map.Load(); } Console.WriteLine("X = {0}, Y = {1}", mouseState.X, mouseState.Y); }
/// <summary> /// Copies the pixel values to the output image. See <see cref="Converter{T}.AddToOutput(KeyValuePair{char, PixelMatrix}, Point, PixelMatrix)"/> for more information. /// </summary> /// <param name="character">The character to be drawn.</param> /// <param name="point">A point that represents the coordinates of the upper left corner to be drawn.</param> /// <param name="tile">The PixelMatrix representing a tile of the source image.</param> protected override void AddToOutput(KeyValuePair <char, PixelMatrix> character, Point point, PixelMatrix tile) { for (int y = point.Y; y < point.Y + RenderOptions.TileSize.Height; y++) { for (int x = point.X * Utils.BytesPerPixel; x < (point.X + RenderOptions.TileSize.Width) * Utils.BytesPerPixel; x += Utils.BytesPerPixel) { int index = y * _size.Width * Utils.BytesPerPixel; System.Drawing.Color c = DrawingMode.CalculateColor(character.Value.GetPixel(x - Utils.BytesPerPixel * point.X, y - point.Y), tile.GetPixel(x - Utils.BytesPerPixel * point.X, y - point.Y)); _pixels[index + x] = c.B; // b _pixels[index + x + 1] = c.G; // g _pixels[index + x + 2] = c.R; // r _pixels[index + x + 3] = c.A; // a } } }
public DrawEventArgs(DrawingMode drawingMode, List <PointLatLng> drawingPoints, Pen stroke, Brush fill) { DrawingMode = drawingMode; if (drawingMode == DrawingMode.Polygon) { Polygon = new GMapDrawPolygon(drawingPoints, drawingMode.ToString()); if (fill != null) { Polygon.Fill = (Brush)fill.Clone(); } if (stroke != null) { Polygon.Stroke = (Pen)stroke.Clone(); } Polygon.IsHitTestVisible = true; } else if (drawingMode == DrawingMode.Rectangle) { Rectangle = new GMapDrawRectangle(drawingPoints, drawingMode.ToString()); if (fill != null) { Rectangle.Fill = (Brush)fill.Clone(); } if (stroke != null) { Rectangle.Stroke = (Pen)stroke.Clone(); } Rectangle.IsHitTestVisible = true; } else if (drawingMode == DrawingMode.Route) { Route = new GMapDrawRoute(drawingPoints, drawingMode.ToString()); if (stroke != null) { Route.Stroke = (Pen)stroke.Clone(); } Route.IsHitTestVisible = true; } else if (drawingMode == DrawingMode.Line) { Line = new GMapDrawLine(drawingPoints, drawingMode.ToString()); if (stroke != null) { Line.Stroke = (Pen)stroke.Clone(); } Line.IsHitTestVisible = true; } }
public void Modify(DrawingMode mode, float intensity, bool blink, short startX, short startY, short endX, short endY) { if (_mode != mode) { _mode = mode; } _intensity = intensity; _blink = blink; _x1 = (int)(startX + Perturbation()); _y1 = (int)(startY + Perturbation()); _x2 = (int)(endX + Perturbation()); _y2 = (int)(endY + Perturbation()); UpdateColor(); }
private static void DrawingModePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DrawingMode drawingMode = (DrawingMode)e.NewValue; var drawingBoard = d as DrawingBoard; // 绘制规则图形 if (drawingMode != DrawingMode.Pen) { drawingBoard.inkCanvas.EditingMode = InkCanvasEditingMode.None; } else { // 设置绘画模式 drawingBoard.inkCanvas.EditingMode = InkCanvasEditingMode.Ink; } }
private void setDrawingMode(DrawingMode mode) { switch (mode) { case DrawingMode.Wireframe: OpenGL.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_LINE); break; case DrawingMode.Fill: OpenGL.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL); break; default: throw new ArgumentException($"Unknown DrawingMode: {mode}"); } }
/// <summary> /// Method to get drawing modes with color value /// </summary> /// <param name="strokes">strokes array</param> /// <returns>Array of DrawingMode</returns> public static DrawingMode[] GetDrawingModes(this StrokeCollection strokes) { DrawingMode[] drawingModeArray = new DrawingMode[strokes.Count]; for (int i = 0; i < strokes.Count; i++) { DrawingMode drawingMode; string color = strokes[i].DrawingAttributes.Color.ToString(); switch (color.ToLower()) { case "#ff000000": drawingMode = DrawingMode.BlackPen; break; case "#ff0000ff": drawingMode = DrawingMode.BluePen; break; case "#ffff0000": drawingMode = DrawingMode.RedPen; break; case "#ff008000": drawingMode = DrawingMode.GreenPen; break; case "#ffffff00": drawingMode = DrawingMode.YellowHighlighter; break; case "#ffffc0cb": drawingMode = DrawingMode.PinkHighlighter; break; default: drawingMode = DrawingMode.BlackPen; break; } drawingModeArray[i] = drawingMode; } return(drawingModeArray); }
public void SetCurrentDrawingMode(string drawingMode) { switch (drawingMode.ToLower()) { case "line": this.CurrentDrawingMode = DrawingMode.Line; break; case "triangle": this.CurrentDrawingMode = DrawingMode.Triangle; break; case "rectangle": this.CurrentDrawingMode = DrawingMode.Rectangle; break; } }
public void ChangeDrawingMode(DrawingMode mode) { if (myInkPresenter.Strokes.Count == 0) { return; } if (!(myInkPresenter.Strokes[0] is CustomRenderedStroke)) { return; } foreach (CustomRenderedStroke s in myInkPresenter.Strokes) { s.Mode = mode; } }
private void DrawGraph() { _debuggerOperations.ClearOutput(); _drawingMode = DrawingMode.Redrawing; ThreadHelper.ThrowIfNotOnUIThread(); if (_config == null || _debuggerOperations?.IsActive != true) { _drawingMode = DrawingMode.NotChanged; return; } var stopWatch = new Stopwatch(); stopWatch.Start(); var graph = _graphRenderer.RenderGraph(_config); stopWatch.Stop(); var ts = stopWatch.Elapsed; var elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds / 10:00}"; Debug.WriteLine($"total time {elapsedTime}"); if (graph == null) { return; } GViewer viewer = new GViewer { Graph = graph, Dock = DockStyle.Fill }; CreateForm(); _form.SuspendLayout(); _form.Controls.Clear(); _form.Controls.Add(viewer); _form.ResumeLayout(); if (!_form.Visible) { _form.Show(); } //_form.Focused = false; _dispatcherTimer?.Stop(); _drawingMode = DrawingMode.NotChanged; }
private async void ConvertToHtml() { VisualStateManager.GoToElementState(GridMain, "HtmlShown", false); DrawingMode mode = GetDrawingMode(); HtmlConverter converter = new HtmlConverter(CreateOptions(), mode); try { Progress <double> progress = new Progress <double>(UpdateProgress); WvAscii.NavigateToString(await converter.ConvertAsync(_source, progress)); } catch (Exception e) { MessageBox.Show(e.Message, "Operation failed!"); } }
private async void ConvertToImage() { VisualStateManager.GoToElementState(GridMain, "ImageShown", false); DrawingMode mode = GetDrawingMode(); BitmapSourceConverter converter = new BitmapSourceConverter(CreateOptions(), mode); try { Progress <double> progress = new Progress <double>(UpdateProgress); ImgAscii.Source = await converter.ConvertAsync(_source, progress); } catch (Exception e) { MessageBox.Show(e.Message, "Operation failed!"); } }
public MainForm() { InitializeComponent(); controlCanvas = pbCanvas.CreateGraphics(); bitmap = new Bitmap(pbCanvas.Width, pbCanvas.Height); bitmapCanvas = Graphics.FromImage(bitmap); points = new List <Point>(); _shapes = new List <Shape>(); mousePreviousPosition = new Point(); drawingMode = DrawingMode.FreeDrawing; isDrawing = false; penSize = 1f; penColor = Color.Black; backGroundColor = Color.White; cbColor.SelectedIndex = 0; cbBgColor.SelectedIndex = 0; }
//lets the user choose an image to add to the drawing void CreateImageDrawing() { //makes the user open a project OpenFileDialog opener = new OpenFileDialog(); if (opener.ShowDialog() == DialogResult.OK) { //makes sure that the right type of file was entered if (opener.FileName.ToLower().Contains(".png") || opener.FileName.ToLower().Contains(".jpg")) { //sets up an image with the chosen path layers[currentLayer].imageDrawings.Add(new ImageDrawing(opener.FileName, this)); layers[currentLayer].drawOrder.Add(Layer.DrawingMode.Image); drawType = DrawingMode.Image; } } }
public void Modify(DrawingMode mode, float intensity, bool blink, short startX, short startY, short endX, short endY) { if (_mode != mode) { _mode = mode; } if (blink) { Console.WriteLine("blink {0},{1}-{2},{3}", startX, startY, endX, endY); } _intensity = intensity; _blink = blink; _x1 = (int)startX; _y1 = (int)startY; _x2 = (int)endX; _y2 = (int)endY; UpdateColor(); }
private void AddNewVector(DrawingMode mode, int startX, int startY, int endX, int endY) { // // Scale the vector to the current scaling factor. // The Imlac specifies 11 bits of resolution (2048 points in X and Y) // which corresponds to a _scaleFactor of 1.0. // startX = (int)(startX * _scaleFactor + _xOffset); startY = (int)(startY * _scaleFactor - _yOffset); endX = (int)(endX * _scaleFactor + _xOffset); endY = (int)(endY * _scaleFactor - _yOffset); _lock.EnterWriteLock(); Vector newVector = _displayList[_displayListIndex]; newVector.Modify(mode, _intensity, _blink, (short)startX, (short)(_yResolution - startY), (short)endX, (short)(_yResolution - endY)); _displayListIndex++; _lock.ExitWriteLock(); }
public void SetDrawingModeSwitcherEnabled(DrawingMode drawingMode, bool isEnabled) { this.DrawingModeSwitchers.Where(s => (DrawingMode)s.Tag == drawingMode).First().Enabled = isEnabled; }
private void drawALineButton_Click(object sender, RoutedEventArgs e) { if (this.CurrentMode == DrawingMode.Line) { /* When in drawing mode */ this.CurrentMode = DrawingMode.None; } else { /* Turn on drawing line mode */ this.CurrentMode = DrawingMode.Line; } }
// On mouse up protected override void OnMouseUp( MouseEventArgs e ) { // check drawing and dragging mode if ( ( drawingMode == DrawingMode.Rectangular ) && ( dragging == true ) ) { // stop dragging mode dragging = false; this.Capture = false; // reset drawing mode drawingMode = DrawingMode.None; this.Cursor = Cursors.Default; // erase selection rectangle DrawSelectionRectangle( ); // get normalized points NormalizePoints( ref startPoint, ref endPoint ); // check that points are inside of the control CheckPointsInClient( ref startPoint ); CheckPointsInClient( ref endPoint ); // add rectangle to collection Rectangle rect = new Rectangle( startPoint.X - 1, startPoint.Y - 1, endPoint.X - startPoint.X + 1, endPoint.Y - startPoint.Y + 1 ); rectangles.Add( rect ); // notify clients about new available rectangle if ( OnNewRectangle != null ) { OnNewRectangle( this, rect ); } // redraw the control this.Invalidate( ); } }
void DrawLines(IGraphics g, List<PointF> points, DrawingMode mode) { const int count = 5; const float offsetY = 40; if (points != null) { using (Pen pen = new Pen(_signalColor, 0.0f)) { switch (mode) { case DrawingMode.DrawLines: { var pointsArray = points.ToArray(); for (int j = 0; j < count; j++) { g.TranslateTransform(0, offsetY); g.DrawLines(pen, pointsArray); } } break; case DrawingMode.GdiPlusDrawLine: { var gdip = ((GDIGraphics)g).Graphics; for (int j = 0; j < count; j++) { g.TranslateTransform(0, offsetY); for (int i = 1; i < points.Count; i++) gdip.DrawLine(pen, points[i - 1], points[i]); } } break; case DrawingMode.Gdi32: { var gdip = ((GDIGraphics)g).Graphics; for (int j = 0; j < count; j++) { g.TranslateTransform(0, offsetY); gdip.DrawLinesGdi32(pen, points); } } break; default: break; } } } }
/// <summary> /// /// </summary> private void DrawText() { string layerName = "map"; switch (currentLayer) { case 0: layerName = "back"; break; case 1: layerName = "mid"; break; case 2: layerName = "fore"; break; } if (text.DrawClickText(5, 5, "layer " + layerName, mouseX, mouseY, mouseClick)) currentLayer = (currentLayer + 1) % 3; // this will handle whether it's the segment or collision map that we're looking at switch (drawType) { case DrawingMode.SegmentSelection: layerName = "select"; break; case DrawingMode.CollisionMap: layerName = "col"; break; } if (text.DrawClickText(5, 25, "draw " + layerName, mouseX, mouseY, mouseClick)) drawType = (DrawingMode)((int)(drawType + 1) % 2); mouseClick = false; // reset the mosue }
private void Mode_MouseUp(object sender, MouseButtonEventArgs e) { if (ModeMouseDown[(int)GetModeByButton(sender)]) { GetButtonByMode(Mode).Selected = false; Mode = GetModeByButton(sender); ((SecondMenuButton)sender).Selected = true; ModeMouseDown[(int)Mode] = false; } }
private SecondMenuButton GetButtonByMode(DrawingMode byMode) { switch (byMode) { case DrawingMode.Draw: return modeDraw; case DrawingMode.Erase: return modeErase; } return modeDraw; }
private void modeCheckedChanged(int which) { if (ignoreModeChange) return; try { ignoreModeChange = true; for (int i = 0; i < PAIR_BUTTONS.GetLength(0); i++) { if (PAIR_BUTTONS[i, which].Checked) { PAIR_BUTTONS[i, 1 - which].Checked = PAIR_BUTTONS[i, which].Checked; drawingMode = (DrawingMode)i; if (i == 0) { mainNote.ContextMenuStrip = noteContextMenu; } else { mainNote.ContextMenuStrip = null; } } } } finally { ignoreModeChange = false; } }
public ToothChartWrapper() { drawMode=DrawingMode.Simple2D; tcData=new ToothChartData(); InitializeComponent(); ResetControls(); }
private void frmDrawing_DrawingModeChanged(DrawingMode drawingMode) { if ( drawingMode == DrawingMode.Editing ) { sbpStatus.Text = "Editing"; } else { sbpStatus.Text = "Sketching"; } }
private void putAVideo_Click(object sender, RoutedEventArgs e) { this.CurrentMode = DrawingMode.Video; }
protected override void Update(GameTime gameTime) { //MouseState mState = Mouse.GetState (); previousMouseState = currentMouseState; currentMouseState = Mouse.GetState(); //pMosX = mosX; //pMosY = mosY; mosX = currentMouseState.X; mosY = currentMouseState.Y; /*if (mapEd.HoverOver (mosX, mosY, currentLayer) != -1 && !mouseDrag) { mapSegIndex = mapEd.HoverOver (mosX, mosY, currentLayer); mouseDrag= true; Console.WriteLine("Chosen!!"); }*/ if((currentMouseState.LeftButton == ButtonState.Released && previousMouseState.LeftButton == ButtonState.Pressed) )//&& clickAbleText.Ishovering(mosX, mosY)) { if (clickAbleText.Ishovering (mosX, mosY)) { switch (layerName) { case "back": layerName = "mid"; currentLayer = .5f; break; case "mid": layerName = "front"; currentLayer = 1f; break; case "front": layerName = "back"; currentLayer = 0f; break; } clickAbleText.Str = "layer: " + layerName; } else if(drawTypeButton.Ishovering(mosX, mosY)) { switch (selectName){ case "col": selectName = "select"; drawType = DrawingMode.SegmentSelection; break; case "select": selectName = "col"; drawType = DrawingMode.CollisionMap; break; } drawTypeButton.Str = "draw: " +selectName ; } //Console.WriteLine(string.Format(layerName +": {0:0.0}", currentLayer)); } else if (!(currentMouseState.LeftButton == ButtonState.Released) && previousMouseState.LeftButton == ButtonState.Pressed) { //Console.WriteLine ("Drag!!"); if (drawType == DrawingMode.SegmentSelection) { if (drawMapSeg.getIndexOfPalletSegment (mosX, mosY) != -1 && !mouseDrag) { segIndex = drawMapSeg.getIndexOfPalletSegment (mosX, mosY); //Console.Write("Pallet Seg Index:"); //Console.WriteLine (segIndex); } } else if (mapEd.HoverOver (mosX, mosY, currentLayer) != -1 && !mouseDrag) { mapSegIndex = mapEd.HoverOver (mosX, mosY, currentLayer); mouseDrag= true; Console.WriteLine("Chosen!!"); }else if (mapSegIndex != -1 && mouseDrag) { mapEd.GetMapSegment (mapSegIndex, currentLayer).location.X = mosX; mapEd.GetMapSegment (mapSegIndex, currentLayer).location.Y = mosY; //Console.Write ("Map Seg Index :"); //Console.WriteLine (mapSegIndex); } } else { if (segIndex != -1) { //change the layer mapEd.AddSeg (currentLayer, segIndex, mosX, mosY); segIndex = -1; } mapSegIndex = -1; mouseDrag = false; } base.Update (gameTime); }
public UndoRedo(Int32 newX, Int32 newY, DrawingMode newMode) { X = newX; Y = newY; Mode = newMode; }
void Draw(IGraphics g, DrawingMode mode) { g.SmoothingMode = checkBoxAntialiasing.Checked ? SmoothingMode.HighQuality : SmoothingMode.None; g.Clear(Color.White); DrawMillimeterGridInPixels(g, tabControl1.SelectedTab.Controls[0].ClientRectangle); g.PageUnit = GraphicsUnit.Millimeter; var points = _noisePoints; DrawLines(g, points, mode); g.ResetTransform(); var path = CreateRoundedRectanglePath(new RectangleF(10, 10, 100, 40), 10); g.FillPath(new SolidBrush(Color.FromArgb(120, Color.LightSlateGray)), path); g.DrawPath(new Pen(Color.LightSlateGray, 0.0f), path); g.FillPie(new SolidBrush(Color.FromArgb(120, Color.CadetBlue)), new Rectangle(30, 20, 100, 100), 45.0f, 90.0f); g.DrawPie(new Pen(Color.CadetBlue, 0.0f), new Rectangle(30, 20, 100, 100), 45.0f, 90.0f); //GLGraphics gl = g as GLGraphics; //if (gl != null) // gl.FillTextBackground = gl.FillTextBackground_glReadPixels; g.PageUnit = GraphicsUnit.Pixel; RectangleF rect = new RectangleF(30.0f, 15.0f, _testImage.Width, _testImage.Height); g.DrawImage(_testImage, rect); g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height); g.PageUnit = GraphicsUnit.Millimeter; g.HintTextBackgroundAction((gdi, textLocation, textRect) => { _millimeterGridBrush.ResetTransform(); _millimeterGridBrush.TranslateTransform(-textLocation.X, -textLocation.Y); gdi.FillRectangle(_millimeterGridBrush, textRect); }); g.DrawString("Testovací řetězec pro odzkoušení správné implementace IGraphics - metody DrawString.", new Font("Arial", 12.0f), Brushes.Black, new PointF(100.0f, 58.0f)); }
protected override void Initialize() { // TODO: Add your initialization logic here mapEd = new Map (); drawMapSeg = new DrawMapSegment (mapEd.SegmentDefinitions, 500, 30, 50, 30, 40); segIndex = -1; mapSegIndex = -1; currentLayer = 0f; layer = new string[]{ "back", "mid", "front" }; selectType = new string[]{"col","select" }; layerName = layer[0]; selectName = selectType [1]; mouseClick = false; dropSegment = false; holdSegment = false; mouseDrag = false; drawType = DrawingMode.SegmentSelection; //Components.Add (new CollisionRectangle (this)); base.Initialize (); }
private void putAnImage_Click(object sender, RoutedEventArgs e) { this.CurrentMode = DrawingMode.Image; }
private void DrawText() { var layerName = "map"; switch (_curLayer) { case 0: layerName = "back"; break; case 1: layerName = "mid"; break; case 2: layerName = "fore"; break; } if (_text.DrawClickText(5, 5, "layer: " + layerName, _mosX, _mosY, _mouseClick)) _curLayer = (_curLayer + 1) % 3; switch (_drawType) { case DrawingMode.SegmentSelection: layerName = "select"; break; case DrawingMode.CollisionMap: layerName = "col"; break; case DrawingMode.Ledges: layerName = "ledge"; break; case DrawingMode.Script: layerName = "script"; break; } if (_text.DrawClickText(5, 25, "draw: " + layerName, _mosX, _mosY, _mouseClick)) _drawType = (DrawingMode)(((int)_drawType + 1) % 4); if (_drawType == DrawingMode.Script) { _spriteBatch.Begin(); _spriteBatch.Draw(_nullTex, new Rectangle(400, 20, 400, 565), new Color(new Vector4(0f, 0f, 0f, .62f))); _spriteBatch.End(); for (var i = _scriptScroll; i < _scriptScroll + 28; i++) { if (_selScript == i) { _text.Color = Color.White; _text.DrawText(405, 25 + (i - _scriptScroll) * 20, i + ": " + _map.Scripts[i] + "*"); } else { if (_text.DrawClickText(405, 25 + (i - _scriptScroll) * 20, i + ": " + _map.Scripts[i], _mosX, _mosY, _mouseClick)) { _selScript = i; _editMode = EditingMode.Script; } } if (_map.Scripts[i].Length > 0) { var split = _map.Scripts[i].Split(' '); var c = GetCommandColor(split[0]); if (c > ColorNone) { switch (c) { case ColorGreen: _text.Color = Color.Lime; break; case ColorYellow: _text.Color = Color.Yellow; break; } _text.DrawText(405, 25 + (i - _scriptScroll) * 20, i + ": " + split[0]); } } _text.Color = Color.White; _text.DrawText(405, 25 + (i - _scriptScroll) * 20, i + ": "); } var mouseDown = (Mouse.GetState().LeftButton == ButtonState.Pressed); if (DrawButton(770, 20, 1, _mosX, _mosY, mouseDown) && _scriptScroll > 0) _scriptScroll--; if (DrawButton(770, 550, 2, _mosX, _mosY, mouseDown) && _scriptScroll < _map.Scripts.Length - 28) _scriptScroll++; } _text.Color = Color.White; if (_editMode == EditingMode.Path) _text.DrawText(5, 45, _map.Path + "*"); else { if (_text.DrawClickText(5, 45, _map.Path, _mosX, _mosY, _mouseClick)) _editMode = EditingMode.Path; } _mouseClick = false; }
private void MoveSymbol(object sender, RoutedEventArgs e) { if (Undo.Count == 0 || Undo.First().Count > 0) Undo.Push(new Stack<UndoRedo>()); Redo.Clear(); DrawingMode old = Mode; if (((SecondMenuButton)sender).Title == "←") { for (int i = 0; i < Symbol.Height; ++i) { for (int j = 0; j < Symbol.Width - 1; ++j) { Mode = Symbol.Map[i][j + 1] ? DrawingMode.Draw : DrawingMode.Erase; DrawPixel(j, i); } } Mode = DrawingMode.Erase; for (int i = 0; i < Symbol.Height; ++i) DrawPixel(Symbol.Width - 1, i); } else if (((SecondMenuButton)sender).Title == "↑") { for (int i = 0; i < Symbol.Height - 1; ++i) { for (int j = 0; j < Symbol.Width; ++j) { Mode = Symbol.Map[i + 1][j] ? DrawingMode.Draw : DrawingMode.Erase; DrawPixel(j, i); } } Mode = DrawingMode.Erase; for (int j = 0; j < Symbol.Width; ++j) DrawPixel(j, Symbol.Height - 1); } else if (((SecondMenuButton)sender).Title == "→") { for (int i = 0; i < Symbol.Height; ++i) { for (int j = Symbol.Width - 1; j > 0; --j) { Mode = Symbol.Map[i][j - 1] ? DrawingMode.Draw : DrawingMode.Erase; DrawPixel(j, i); } } Mode = DrawingMode.Erase; for (int i = 0; i < Symbol.Height; ++i) DrawPixel(0, i); } else { for (int i = Symbol.Height - 1; i > 0; --i) { for (int j = 0; j < Symbol.Width; ++j) { Mode = Symbol.Map[i - 1][j] ? DrawingMode.Draw : DrawingMode.Erase; DrawPixel(j, i); } } Mode = DrawingMode.Erase; for (int j = 0; j < Symbol.Width; ++j) DrawPixel(j, 0); } Mode = old; }
private void RedoClick(object sender, RoutedEventArgs e) { if (Redo.Count > 0) { undoredo = true; Stack<UndoRedo> tmpRedo = Redo.Pop(); Undo.Push(new Stack<UndoRedo>()); Stack<UndoRedo> tmpUndo = Undo.First(); UndoRedo tmpUndoRedo; DrawingMode oldMode = Mode; while (tmpRedo.Count > 0) { tmpUndoRedo = tmpRedo.Pop(); Mode = tmpUndoRedo.Mode; DrawPixel(tmpUndoRedo.X, tmpUndoRedo.Y); tmpUndoRedo.InvertMode(); tmpUndo.Push(tmpUndoRedo); } Mode = oldMode; undoredo = false; } }
public DrawingModeSwitcherClickEventArgs(DrawingMode drawingMode) { this.DrawingMode = drawingMode; }
// Draws the clickable Text in the upper left corner private void DrawText() { // Layerbutton string layerName = "map"; switch (currentLayer) { case 0: layerName = "back"; break; case 1: layerName = "mid"; break; case 2: layerName = "fore"; break; default: break; } if (text.DrawClickText(5, 5, "layer: " + layerName, mouseX, mouseY, mouseClick)) currentLayer = (currentLayer + 1) % 3; // DrawingMode Button switch (drawingMode) { case DrawingMode.SegmentSelection: layerName = "select"; break; case DrawingMode.CollisionMap: layerName = "collision"; break; case DrawingMode.Ledges: layerName = "ledges"; break; case DrawingMode.Script: layerName = "script"; break; default: break; } if (text.DrawClickText(5, 25, "draw: " + layerName, mouseX, mouseY, mouseClick)) drawingMode = (DrawingMode)((int)(drawingMode + 1) % 4); text.color = Color.White; if (editmode == EditingMode.Path) text.DrawText(5, 45, map.Path + "*"); else { if (text.DrawClickText(5, 45, map.Path, mouseX, mouseY, mouseClick)) editmode = EditingMode.Path; } mouseClick = false; }
public void InvertMode() { if (Mode == DrawingMode.Draw) Mode = DrawingMode.Erase; else Mode = DrawingMode.Draw; }