How to utilize Winforms Paint Event in creating graphics - accessing from another class (simple plasma effect) I'm beginner in C# programming and I'm trying to create some graphics effects utilizing Winforms. I've tried to generate simple &quot;plasma effect&quot;, however utilization of Paint Event is really frustrating (or I'm just stupid). In my example I have two classes (Form1 and Plasmadraw). In Form1 I have following setup: namespace Plasma_effect { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.Width = 1920; this.Height = 1200; FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; this.DoubleBuffered = true; }     private void Form1_Paint(object sender, PaintEventArgs e)     {         Plasmadraw plasma = new Plasmadraw();          plasma.Draw(e.Graphics);          Invalidate();     }      private void Form1_Load(object sender, EventArgs e)     {         // Why I can't create instance of Plasmadraw class once here , I have to do it in Paint event ??     }      private void Form1_MouseClick(object sender, MouseEventArgs e)     {         this.Close();     }  And in the Plasmadraw class I have following setup: namespace Plasma_effect { class Plasmadraw {     int y;     int x;     double i;          double pii = 3.1415;      public void Draw(Graphics gfx)     {         // Should I use For loop here in creating the plasma, I managed to create full screen plasma with it, but no animation ?            x = x + 10; // this should increase the value, however the value is not increased         i = i + 1;          if (x == 1920)         {             x = 0;             y = y + 10;         }          if (y == 1200)         {             y = 0;         }              double v = Math.Sin((x * 0.5) + i * 0.001);             double c = v * pii;             double d = c + (2 * pii / 3);             double f = c + (6 * pii / 3);             double r = 255 * Math.Abs(Math.Sin(c));             double g = 255 * Math.Abs(Math.Sin(d));             double b = 255 * Math.Abs(Math.Sin(f));              int r1 = (int)r;             int g1 = (int)g;             int b1 = (int)b;              Color e = Color.FromArgb(r1, g1, b1);              SolidBrush brush = new SolidBrush(e);             Rectangle rect = new Rectangle(x, y, 10, 10);             gfx.FillRectangle(brush, rect);             } }  } Basically I'm trying to create continuous loop where I would have the effect running. The problem is that the program creates just one rectangle and stops after that. What I should do to make it run continuously ? Before I've managed to create some moving effects by basically creating a list of objects (for example sprites) and then using foreach in Paint event to draw them &amp; invalidate(). However I'd like to learn to use some other approach than always using the same (copied) way.
Simple animation in WinForms Imagine you want to animate some object on a WinForm. You setup a timer to update the state or model, and override the paint event of the Form. But from there, what's the best way to continually repaint the Form for the animation?   Invalidate the Form as soon as you are done drawing? Setup a second timer and invalidate the form on a regular interval? Perhaps there is a common pattern for this thing? Are there any useful .NET classes to help out?   Each time I need to do this I discover a new method with a new drawback. What are the experiences and recommendations from the SO community?
I have B1/B2 Visa. Can I travel for Business trip to US with this Visa? After the therapy, eight children (43%) became able to crawl/move on their back.   Or should I use "on their backs"?   Singular because each child only has one back, or plural because we're dealing with eight backs? Now that  is in effect, people who have visited Iraq, Syria, Iran, or Sudan since 2011 are banned from entering the US under the Visa Waiver Program. However it's unclear to me how could the US officials prove one has set foot in those countries, unless:   There's a stamp in one's passport indicating so, which can be side-stepped by getting a fresh passport One mentions the fact on the ESTA application form, which is obviously easy to avoid   Is there any other way the US might be able to identify such individuals?  NB: I'm not eligible for the VWP myself and don't plan to travel to the four countries above, so it's a purely theorethical question While doing some flagging (yes, I'm a little bit addicted) I stumbled upon the user . At first the case seemed clear, Spammer, but...and that's a big one, he seems to be a productive member of SU and SO (his account on SF isn't there anymore, but it's still in the Data-Dump of the explorer, not sure what happened).  He does never seem to link against StarWind-Software, except with his name and profile. He also  that he's a developer there...so...at what am I looking here? I can't really place him somewhere. Is ArcSDE no longer needed at ArcGIS 10.1? Missing processing menu in QGIS? I'm sure there is a really simple explanation to this but haven't found any pointers on this forum or elsewhere. I seem to have lost the 'processing' menu from QGIS and can't figure out how/why!? Any ideas what I might have done to make this happen?  I'm running QGIS 2.8 built against GDAL 1.10 on Ubuntu 14.04. Is it possible to recover an email that has been clicked "delete forever" in the trash folder? Cancel misclicked flags I'm wondering (since it just happened to me), is it possible to "cancel" ("undo", "delete", "retract", whatever) a flag I just raised if I misclicked it, so the mods won't waste time?  I looked everywhere, but I can't find such a feature. Manually calculated $R^2$ doesn't match up with randomForest() $R^2$ for testing new data I know this is a fairly specific R question, but I may be thinking about proportion variance explained, $R^2$, incorrectly. Here goes.  I'm trying to use the R package randomForest. I have some training data and testing data. When I fit a random forest model, the randomForest function allows you to input new testing data to test. It then tells you the percentage of variance explained in this new data. When I look at this, I get one number.  When I use the predict() function to predict the outcome value of the testing data based on the model fit from the training data, and I take the squared correlation coefficient between these values and the actual outcome values for the testing data, I get a different number. These values don't match up.   Here's some R code to demonstrate the problem.  # use the built in iris data data(iris)  #load the randomForest library library(randomForest)  # split the data into training and testing sets index &lt;- 1:nrow(iris) trainindex &lt;- sample(index, trunc(length(index)/2)) trainset &lt;- iris[trainindex, ] testset &lt;- iris[-trainindex, ]  # fit a model to the training set (column 1, Sepal.Length, will be the outcome) set.seed(42) model &lt;- randomForest(x=trainset[ ,-1],y=trainset[ ,1])  # predict values for the testing set (the first column is the outcome, leave it out) predicted &lt;- predict(model, testset[ ,-1])  # what's the squared correlation coefficient between predicted and actual values? cor(predicted, testset[, 1])^2  # now, refit the model using built-in x.test and y.test set.seed(42) randomForest(x=trainset[ ,-1], y=trainset[ ,1], xtest=testset[ ,-1], ytest=testset[ ,1]) Limit of $\lim_{(x,y)\rightarrow(0,0)}\frac{x^2y^2}{x^3+y^3}$ I want to know whether $\lim_{(x,y)\to (0,0)}\dfrac{x^2y^2}{x^3+y^3}$ exists or not. I tried to approximate to (0,0) from different "paths" and the result was always 0. For example,  $f(x,mx^2) = \dfrac{m^2x^3}{1+m^3x^3}$  But that doesn't show that the limit is 0. Introduction to AdS/CFT Is there a free site to play Yu-Gi-Oh? Proof Verification: Converse of Intermediate Value Theorem I looked "$\divideontimes$" up on Google and now I know that it's Unicode U+22c7 but when would it be used?  I am guessing that $5 \divideontimes 5 = 25$ and $1$...? I'm level 16 which makes battling many Draugr Wrights hard. My defense is just way too low, and I don't have enough time or strong enough magic to take them out.   My one-handed skill is at 62 and my strongest weapon does 33+10 enchanted damage. Are there any ways to level up easily? Imagine I have tons of RAM. Let's say 64GB. That's a lot for even gaming PCs. Now the default location of a pagefile in Windows is on the main OS drive, be it HDD or SSD, which are faster in general, but still not as fast as RAM.  Something tells me that disabling the pagefile on the hard drive or creating a virtual RAM drive and letting the pagefile be there could make Windows move all its virtual memory to RAM, and so increase the system's performance, but I'm not very knowledgeable in that area, so that might not be true at all.  I tried both, but I couldn't analyze the results to reach a definite conclusion with my knowledge level in memory things.  Would this work? If not, why? Krull dimension of this local ring I want to know what the Krull dimension of this ring $\mathbb C[x,y]_p/(y^2-x^7,y^5-x^3)$ is, where $p\neq (0,0)$. I know the dimension of it in the origin point, but I don't know other cases. How to make beveled 90 degree corners on a curve better? Understanding reference counting with Cocoa and Objective-C I'm just beginning to have a look at Objective-C and Cocoa with a view to playing with the iPhone SDK. I'm reasonably comfortable with C's malloc and free concept, but Cocoa's references counting scheme has me rather confused. I'm told it's very elegant once you understand it, but I'm just not over the hump yet.  How do release, retain and autorelease work and what are the conventions about their use?  (Or failing that, what did you read which helped you get it?) Is it possible to adjust desktop monitor brightness like on laptops? Yes all desktop monitors have separate menu for it. But is it possible to change this to something like Winkey+(F1..F12)?    Monitor is connected via VGA or DVI cable.   OS: Ubuntu 14.04 Desktop monitors