private Layer DrawingToolToLayer(DrawingTools drawingTool) { switch (drawingTool) { case DrawingTools.Select: return(Layer.Selection); case DrawingTools.Terrain: return(Layer.Terrain); case DrawingTools.GmIcons: return(Layer.GmIcon); case DrawingTools.PlayerIcons: return(Layer.PlayerIcon); case DrawingTools.River: return(Layer.River); case DrawingTools.Road: return(Layer.Road); case DrawingTools.FogOfWar: return(Layer.FogOfWar); default: throw new ArgumentOutOfRangeException(nameof(drawingTool), drawingTool, null); } }
/*------------------------------------------------------------------*\ |* PRIVATE METHODES \*------------------------------------------------------------------*/ private void CreatePopup(float quantity, CollectibleType type) { var text = $"+ {quantity} {type.ToString()}"; var position = Helpers.SetY(entity.Position, Random.Range(2, 12)); DrawingTools.TextPopup(text, position, 4f, 2f, 34, Colors.Primary); }
public MainForm() { InitializeComponent(); SetAppearance(); queue = new Queue <double[]>(); InitConnection(); c1 = new Consumer(queue, lockObj, ws); comThread = new Thread(c1.consume); comThread.Start(); int scaleFactor = 2; int a = 85 * scaleFactor; int b = 85 * scaleFactor; double xMax = (a + b) * scaleFactor; g = panel1.CreateGraphics(); pen = new Pen(Color.Gray, 5); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; pen.StartCap = pen.EndCap = System.Drawing.Drawing2D.LineCap.Round; DT = new DrawingTools(a, b); DT.Init(); }
/// <summary> /// Initializes a new instance of the <see cref="ComponentType"/> class. /// </summary> /// <param name="components">The components that will be offered.</param> public ComponentType(IEnumerable <ComponentInfo> components) { InitializeComponent(); foreach (var component in components) { //display all ocmponents var componentType = component.ComponentType; var item = new ListBoxItem(); var text = DrawingTools.GetText(componentType.TypeName); item.Content = text; item.BorderThickness = new Thickness(1); item.Padding = new Thickness(10); item.BorderBrush = Brushes.Gray; item.FontSize = 15; var assemblyText = DrawingTools.GetHeadingText("Assembly", component.DefiningAssembly.ToString()); DrawingTools.SetToolTip(item, assemblyText); item.Selected += (s, e) => { SelectedComponent = componentType; DialogResult = true; }; ComponentTypes.Items.Add(item); } }
private void EnterCommander(DrawingTools mode, DrawingAction act) { if (mode == DrawingTools.Pencil) { _commander.Execute(new PencilCommand(this, act)); } }
/// <summary> /// Draws a rectangle. /// </summary> /// <param name="sb">Sb.</param> /// <param name="position">Position.</param> /// <param name="size">Size.</param> /// <param name="c">C.</param> /// <param name="layer">Layer.</param> public static void DrawRectangle(SpriteBatch sb, Vector2 position, Vector2 size, Color c, float layer) { Rectangle r = new Rectangle((int)position.X, (int)position.Y, // position (int)size.X, (int)size.Y); DrawingTools.DrawRectangle(sb, r, c, layer); }
private void Form1_Load(object sender, EventArgs e) { ChosenTool = DrawingTools.Pen; PenColor = Color.Black; PenWidth = 1; OpenedForms = 0; }
protected virtual void ChangeDrawingToolCursor(DrawingTools tool) { switch (tool) { case DrawingTools.PaintBucket: this.Cursor = this._paintBucketCursor; break; case DrawingTools.Pencil: this.Cursor = this._pencilCursor; break; case DrawingTools.Pan: this.Cursor = this._panCursor; break; case DrawingTools.Line: this.Cursor = Cursors.Cross; break; default: this.Cursor = this.DefaultCursor; break; } }
public DrawingAction(DrawingTools mode, Point leftTop, Point rightBottom, WriteableBitmap bitmap = null) { LeftTop = leftTop; RightBottom = rightBottom; Bitmap = bitmap; Mode = mode; }
private void RadioButton_CheckedChanged(object sender, System.EventArgs e) { var radioButton = (RadioButton)sender; if (sender == rbSelect && radioButton.Checked) { _currentDrawingTool = DrawingTools.Select; } else { if (sender == rbTerrain && radioButton.Checked) { _currentDrawingTool = DrawingTools.Terrain; } else if (sender == rbIcons && radioButton.Checked) { _currentDrawingTool = DrawingTools.GmIcons; //If any of the layers aren't set as we want them for GM icons, set them as we want them for GM icons if (!chk100GmIcons.Checked || chk50PlayerIcons.Checked || chk100PlayerIcons.Checked) { _drawingDisabled = true; chk100GmIcons.Checked = true; chk50PlayerIcons.Checked = false; chk100PlayerIcons.Checked = false; _drawingDisabled = false; DrawMap(); } } else if (sender == rbPlayerIcon && radioButton.Checked) { _currentDrawingTool = DrawingTools.PlayerIcons; //If any of the layers aren't set as we want them for Player icons, set them as we want them for Player icons if (!chk50GmIcons.Checked || !chk100PlayerIcons.Checked) { _drawingDisabled = true; chk50GmIcons.Checked = true; chk100PlayerIcons.Checked = true; _drawingDisabled = false; DrawMap(); } } else if (sender == rbRiver && radioButton.Checked) { _currentDrawingTool = DrawingTools.River; } else if (sender == rbRoad && radioButton.Checked) { _currentDrawingTool = DrawingTools.Road; } else if (sender == rbFogOfWar && radioButton.Checked) { _currentDrawingTool = DrawingTools.FogOfWar; } } }
public void Cleanup() { DrawingTools.ToList().All(t => { RemoveTool(t); return(true); }); }
public static void DrawRange(Entity entity) { var color = (entity.Interaction.Target && entity.Interaction.TargetInRange()) ? Color.red : Color.yellow; DrawingTools.Circle(entity.Position, entity.Interaction.Range, color); }
protected override void Dispose(bool disposing) { DrawingTools.All(t => { (t as IDisposable).Dispose(); return(true); }); }
public static void DrawTarget(Entity entity) { var origin = entity.Position; var destination = entity.Interaction.Target.Position; origin.y += 1f; destination.y += 1f; DrawingTools.Line(origin, destination, Selection.Instance.TargetColor); }
private DrawingAction MakeAction(DrawingTools mode, Point leftTop, Point rightBottom) { DrawingAction act = new DrawingAction(DrawingTools.None, _firstPoint, _finalPoint); if (mode == DrawingTools.Pencil) { act = new DrawingAction(mode, leftTop, rightBottom); } return(act); }
private void RemoveTool(DrawingTool tool) { tool.OnRemove(); DrawingTools.Remove(tool); Rectangle lRect = tool.Tracker.SurroundingRect; InvalidateRect(lRect); IsDirty = true; }
void OnBringToFront(object sender, EventArgs args) { OnBringTo(tools => { // move SelectedTool next to last overlapped tool int lIndex = tools.Max(t => DrawingTools.IndexOf(t)); return(lIndex + 1); }); }
void OnBringToBack(object sender, EventArgs args) { OnBringTo(tools => { // move SelectedTool prior to first overlapped tool int lIndex = tools.Min(t => DrawingTools.IndexOf(t)); return(lIndex); }); }
public void IncrementTimeScale() { increment = Input.GetKey(KeyCode.LeftControl) ? faster : normal; timeScale += increment; if (timeScale >= maxValue) { timeScale = maxValue; DrawingTools.TextPopupMouse("Max TimeScale.", timeScale); } }
public void Draw(SpriteBatch sb) { if (Enabled) { DrawingTools.DrawRectangle(sb, new Rectangle(0, 0, (int)Util.Resolution.VirtualViewport.Length(), _height), new Color(0, 0, 0, 0.75f), LayerDepths.POST_FRONT); _input.Draw(sb); } }
public virtual void DrawCursor(SpriteBatch sb) { CharInfo info = StringHelper.GetCharInfoFrom(_font, Value, _cursor, Position + new Vector2(5, 5), 1f); if (info == CharInfo.Empty) { info = StringHelper.GetCharInfoFrom(_font, " ", 0, Position + new Vector2(5, 5), 1f); } DrawingTools.DrawRectangle(sb, info.area, new Color(0, 0, 0, 0.5f), LayerDepths.FRONT); }
/// <summary> /// Draws a rectangle without filling the middle. /// </summary> /// <param name="sb">The SpriteBatch used for this rectangle draw.</param> /// <param name="pos">The position, top-left, of the rectangle.</param> /// <param name="size">The size of the rectangle.</param> /// <param name="c">The color of the rectangle.</param> /// <param name="layer">The layer on which to draw the rectangle.</param> public static void DrawEmptyRectangle(SpriteBatch sb, Vector2 pos, Vector2 size, Color c, float layer) { Vector2 topLeft = pos; Vector2 topRight = new Vector2(pos.X + size.X, pos.Y); Vector2 bottomRight = new Vector2(pos.X + size.X, pos.Y + size.Y); Vector2 bottomLeft = new Vector2(pos.X, pos.Y + size.Y); DrawingTools.DrawLine(sb, topLeft, topRight, c, layer); DrawingTools.DrawLine(sb, topRight, bottomRight, c, layer); DrawingTools.DrawLine(sb, bottomRight, bottomLeft, c, layer); DrawingTools.DrawLine(sb, bottomLeft, topLeft, c, layer); }
public void DecrementTimeScale() { increment = Input.GetKey(KeyCode.LeftControl) ? faster : normal; timeScale -= increment; if (timeScale <= 0.001f) { timeScale = 0.001f; DrawingTools.TextPopupMouse("Min TimeScale.", timeScale); } }
private void OnBringTo(Func <IEnumerable <DrawingTool>, int> getPositionfunc) { var overlappedTools = GetOverlappedTools(SelectedTool); if (overlappedTools.Count() > 0) { DrawingTools.Remove(SelectedTool); DrawingTools.Insert(getPositionfunc(overlappedTools), SelectedTool); Invalidate(); IsDirty = true; } }
public static void DrawDestination(Entity entity) { var origin = entity.Position; var destination = (Vector3)entity.Movable.Destination; DrawingTools.CircleWithLine( origin, destination, .3f, Selection.Instance.DestinationColor ); }
private void RenderBorder() { IntPtr hdc = NativeUser32Api.GetWindowDC(this.Handle); RECTAPI s = new RECTAPI(); NativeUser32Api.GetWindowRect(this.Handle, ref s); using (Graphics g = Graphics.FromHdc(hdc)) { DrawingTools.DrawBorder((ControlBorderStyle)(int)this.BorderStyle, this.BorderColor, g, new Rectangle(0, 0, s.Width, s.Height)); } NativeUser32Api.ReleaseDC(this.Handle, hdc); }
protected override void OnLoadModel(DesignerModel model) { base.OnLoadModel(model); DrawingTools.All(tool => { Point pt = tool.Location; pt.Offset(Offset); tool.Location = pt; return(true); }); }
private void CreatePopup(float quantity) { if (collectedType == CollectibleType.Structure) { return; } var sign = quantity > 0 ? "+" : "-"; var color = quantity > 0 ? Colors.Primary : Colors.Secondary; var text = $"{sign} {Math.Abs(quantity)} {collectedType.ToString()}"; var position = Helpers.SetY(entity.Position, 2f); DrawingTools.TextPopup(text, position, 2f, 1f, color: color); }
private void RenderBorder() { IntPtr hdc = NativeMethods.GetWindowDC(this.Handle); APIRect s = new APIRect(); NativeMethods.GetWindowRect(this.Handle, ref s); using (Graphics g = Graphics.FromHdc(hdc)) { DrawingTools.DrawBorder((BorderStyle2)(int)this.BorderStyle, this.BorderColor, g, new Rectangle(0, 0, s.Width, s.Height)); } NativeMethods.ReleaseDC(this.Handle, hdc); }
private void toolStripButton_Click(object sender, EventArgs e) { ToolStripButton btn = (ToolStripButton)sender; DrawingTools tool = (DrawingTools)(int.Parse(btn.Tag.ToString())); graphUI1.Tool = tool; foreach (ToolStripButton item in toolStrip1.Items) { item.Checked = false; } btn.Checked = true; }
// First method called when loading main form public MainFormPixelLion() { // Show Splashscreen frmSplash splash = new frmSplash(Properties.Resources.AlternateSplashScreen); splash.Show(); MainFormPixelLion variable = Parent as MainFormPixelLion; // Initialize controls splash.ChangeStatus("Initialisation de Pixel Lion"); InitializeComponent(); DisableMapEditing(); // Object creations splash.ChangeStatus("Initialisation d'XNA"); PresentationParameters pp = new PresentationParameters() { BackBufferHeight = PN_Map.Height, BackBufferWidth = PN_Map.Width, DeviceWindowHandle = PN_Map.Handle, IsFullScreen = false }; XNADevices.graphicsdevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, pp); splash.ChangeStatus("Création des objets cartes"); CurrentMap = new Map(); CurrentTool = DrawingTools.Pen; CurrentLayer = 0; CurrentTileIndex = new Point(); MapBatch = new SpriteBatch(XNADevices.graphicsdevice); // Loading user preferences splash.ChangeStatus("Chargement des préférences"); GlobalPreferences.Prefs = UserPreferences.LoadFromFile(UserPreferences.DefaultFileName); Prefs = GlobalPreferences.Prefs; PN_Tileset.BackColor = Prefs.TileSet.BackgroundColor; // Variable initialization splash.ChangeStatus("Initialisation des variables"); Rand = new Random(); MapSize = new SizeI(); LastOpenedMapFile = ""; MultiSelectionClicked = false; MapIsOpened = false; Bubbles = new Bubble[60].Select(x => Bubble.Create(PN_Map.Size, Rand)).ToList(); CurrentTile = new Rectangle(-Prefs.Map.TileSize.Width, -Prefs.Map.TileSize.Height, 0, 0); utils = new XNAUtils(); XNADevices.EvMarkers = new Texture2D[] { utils.ConvertToTexture(Properties.Resources.EvMarker1), utils.ConvertToTexture(Properties.Resources.EvMarker2), utils.ConvertToTexture(Properties.Resources.EvMarker3) }; // Buffering a number of map states for history management splash.ChangeStatus("Mise en mémoire tampon de l'historique"); History = new MapStateHistory(Prefs.Memory.HistoryCount); // Creating a map buffer to be drawn on Map Panel splash.ChangeStatus("Création d'une image tampon"); // Project Creation splash.ChangeStatus("Création d'un projet"); Project = new PLProject(); // This block tries to open the last opened project // If not found, will simply continue loading the rest of the form try { splash.ChangeStatus("Vérification du dernier projet ouvert"); if (File.Exists("LastProjectPath.plcfg")) { String proj = File.ReadAllText("LastProjectPath.plcfg").Trim(); if (File.Exists(proj)) { splash.ChangeStatus("Ouverture du dernier projet"); // If a project was found, try opening it try { OpenProject(proj); } catch (Exception) { splash.ChangeStatus("Impossible d'ouvrir le dernier projet"); ShowPopup("Projet invalide", "Impossible d'ouvrir le dernier projet ouvert. Celui-ci est peut-être introuvable ou est corrompu.", PopupReason.Error); } } else { ShowPopup("Projet introuvable", "Le dernier projet est introuvable. Il est possible que le fichier aie changé d'emplacement ou qu'il aie été supprimé.", PopupReason.Warning); } } } catch (ArgumentException) { } catch (IOException) { } catch (InvalidOperationException) { } // Locating Welcome Screen WelcomeScreenPopup.Location = new System.Drawing.Point(this.Width / 2 - WelcomeScreenPopup.Width / 2, this.Height / 2 - WelcomeScreenPopup.Height / 2); WelcomeScreenPopup.Visible = Project.Name != String.Empty; // Deletion of temporary files like songs preview splash.ChangeStatus("Destruction des fichers temporaires"); if (Directory.Exists("temps")) Directory.Delete("temp", true); // Recreation of a folder meant to contain teporary files splash.ChangeStatus("Création des dossiers temporaires"); Directory.CreateDirectory("temp"); ShowPopup("Dossier temporaire créé", "Le dossier temporaire contenant les fichiers de sons et autres a été créé avec succès"); // Check user preferences for if user wants to use double buffering if (Prefs.Video.DoubleBuffering) { try { // Turn on double buffering on main Map Panel splash.ChangeStatus("Chargement de l'optimisation graphique"); this.SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); Thread.Sleep(10); ShowPopup("Optimisation graphique", "La mise en mémoire tampon double (Double Buffering) a été activé avec succès et est bien géré par votre carte vidéo."); } catch (Exception) { ShowPopup("Optimisation graphique", "La mise en mémoire tampon double (Double Buffering) ne peut être activée. Peut-être que votre carte vidéo ne peut prendre en charge cette fonctionnalité.", PopupReason.Warning); } } // Will browse project folder for maps to add in the quick load menu splash.ChangeStatus("Chargement des cartes rapides"); // Initialization of the pEvent tooltip peventtip = new HoverTooltip(); peventtip.Visible = false; peventtip.MouseEnter += new EventHandler(peventtip_MouseEnter); PN_Map.Controls.Add(peventtip); // End of loading splash.Close(); }
public DrawingToolSelectedEventArgs(DrawingTools selectedTool) { this.SelectedTool = selectedTool; }
/// <summary> /// This method will change the <see cref="SelectedTool"/> to <see cref="DrawingTools.None"/>. /// </summary> /// <remarks> /// Use this if the user's current activity makes them ineligible to use a tool (e.g., the image has been closed). /// </remarks> public void CloseSelectedTool() { this.SelectedTool = DrawingTools.None; ToggleCheckBoxes(null); }
private void btnTool_Click(object sender, EventArgs e) { Control cb = sender as Control; switch (cb.Name) { case "btnPanTool": this.SelectedTool = DrawingTools.Pan; break; case "btnPencilTool": this.SelectedTool = DrawingTools.Pencil; break; case "btnPaintBucketTool": this.SelectedTool = DrawingTools.PaintBucket; break; case "btnLineTool": this.SelectedTool = DrawingTools.Line; break; case "btnSelectRectangleTool": this.SelectedTool = DrawingTools.SelectRectangle; break; case "btnResizeImageTool": if (ImageToEdit != null && this.ResizeImageDelegate != null) { var oldTool = this.SelectedTool; this.SelectedTool = DrawingTools.ResizeImage; using (ResizeImageDialog dlg = new ResizeImageDialog(ImageToEdit.Width, ImageToEdit.Height)) { if (dlg.ShowDialog() == DialogResult.OK) { ResizeImageDelegate(dlg.NewWidth, dlg.NewHeight, dlg.MaintainAspectRatio); } } } break; default: this.SelectedTool = DrawingTools.None; break; } ToggleCheckBoxes(sender); }
public DrawingToolbox() { InitializeComponent(); this._selectedTool = DrawingTools.None; }
private void BTN_PEN_Multi_Click(object sender, EventArgs e) { CurrentTool = DrawingTools.Multi; BTN_PEN_Draw.Enabled = true; BTN_PEN_Multi.Enabled = false; BTN_PEN_Eraser.Enabled = true; BTN_PEN_Fill.Enabled = true; BTN_PEN_Event.Enabled = true; }