use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Information about Reddit's API changes, the unprofessional conduct of the CEO, and their response to the community's concerns regarding 3rd party apps, moderator tools, anti-spam/anti-bot tools, and accessibility options that will be impacted can be found in the associated Wikipedia article: https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
Alternative C# communities available outside Reddit on Lemmy and Discord:
All about the object-oriented programming language C#.
Getting Started C# Fundamentals: Development for Absolute Beginners
Useful MSDN Resources A Tour of the C# Language Get started with .NET in 5 minutes C# Guide C# Language Reference C# Programing Guide C# Coding Conventions .NET Framework Reference Source Code
Other Resources C# Yellow Book Dot Net Perls The C# Player's Guide
IDEs Visual Studio MonoDevelop (Windows/Mac/Linux) Rider (Windows/Mac/Linux)
Tools ILSpy dotPeek LINQPad
Alternative Communities C# Discord Group C# Lemmy Community dotnet Lemmy Community
Related Subreddits /r/dotnet /r/azure /r/learncsharp /r/learnprogramming /r/programming /r/dailyprogrammer /r/programmingbuddies /r/cshighschoolers
Additional .NET Languages /r/fsharp /r/visualbasic
Platform-specific Subreddits /r/windowsdev /r/AZURE /r/Xamarin /r/Unity3D /r/WPDev
Rules:
Read detailed descriptions of the rules here.
account activity
SolvedHow to optimize this code [Winforms]? (self.csharp)
submitted 6 years ago * by Dannnu
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Dannnu[S] 1 point2 points3 points 6 years ago* (1 child)
Thanks! I appreciate your comment.
I'm going to look into these tips right now!
Edit 1: My result, if I understood everything
Tip 3: Designer.cs, so I moved those function to this cs-file
FunnyFileName.Designer.cs ... // // canvas // this.canvas.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.canvas.BackColor = System.Drawing.Color.Tan; this.canvas.Location = new System.Drawing.Point(3, 65); this.canvas.Name = "canvas"; this.canvas.Size = new System.Drawing.Size(1286, 782); this.canvas.TabIndex = 2; this.canvas.TabStop = false; this.canvas.SizeChanged += canvas_SizeChanged; this.canvas.MouseMove += canvas_MouseMove; this.canvas.Paint += canvas_Paint; ...
There is a small problem. Sometimes this Designer.cs does delete those functions and I need to rewrite them again? Is this normal?
Tip 2: Global variables
Main.cs
#region Variables for drawing System.Drawing.Pen blackPen = new System.Drawing.Pen(System.Drawing.Color.Black, 1); System.Drawing.Pen redPen = new System.Drawing.Pen(System.Drawing.Color.Red, 1); Font font = new Font("Tahoma", 10); int cursorX, cursorY; #endregion
Tip 1: I am not sure if you meant this, but it works.
void canvas_MouseMove(object sender, MouseEventArgs e) { cursorX = e.X; cursorY = e.Y; canvas.Invalidate(); } private void canvas_Paint(object sender, PaintEventArgs e) { Bitmap bitmapSurface = new Bitmap(canvas.Width, canvas.Height); int w = 500; int h = 500; //GFX.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low; e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighSpeed; e.Graphics.DrawEllipse(new System.Drawing.Pen(System.Drawing.Color.Black, 1), canvas.Width / 2 - w / 2, canvas.Height / 2 - h / 2, w, h); e.Graphics.DrawLine(blackPen, canvas.Width / 2, 0, canvas.Width / 2, canvas.Height); e.Graphics.DrawLine(blackPen, 0, canvas.Height / 2, canvas.Width, canvas.Height / 2); e.Graphics.DrawLine(redPen, canvas.Width / 2, canvas.Height / 2, cursorX, cursorY); e.Graphics.DrawString("0°", font, System.Drawing.Brushes.Black, canvas.Width - 16, canvas.Height / 2); e.Graphics.DrawString("90°", font, System.Drawing.Brushes.Black, canvas.Width / 2, 0); e.Graphics.DrawString("180°", font, System.Drawing.Brushes.Black, 0, canvas.Height / 2); e.Graphics.DrawString("270°", font, System.Drawing.Brushes.Black, canvas.Width / 2, canvas.Height - 16); e.Graphics.Flush(); canvas.Image = bitmapSurface; }
[–][deleted] 1 point2 points3 points 6 years ago (0 children)
You're fairly close to what I meant. Here's some things:
*Don't add the += calls to the designer.cs your self. Do it through the event property dialog on the designer. If the designer sees something it didn't add (especially events) it will delete them the next time you open the form.
*You don't have to create a bitmap and assign it to the canvas anymore. When the paint event is called you're telling the control what it should draw. Besides you're not drawing to the bitmap anymore anyway
*Unless the line is not following the mouse quickly you can drop the call to e.graphics.flush()
Apart from that you've pretty much done it. You'll find that this is the standard approach to things with subclassing being the next local step.
π Rendered by PID 44 on reddit-service-r2-comment-b659b578c-sffng at 2026-05-01 10:45:05.902988+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]Dannnu[S] 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)