|
hi
i draw a rectangle in picterebox and i want to rotate it around it's center and i want enable doublebuffering for prevent flicker and get highest quality
for my animation but it doesn't work
the ather problem is when i call g.Dispose(); in timer1_Tick event my app is crash .where does my problem and how to animate my rectangle with
doublebuffering and highest quality without flicker my animation ???
my code here :
Graphics g;
Pen m_pen;
Matrix mat;
int angle;
bool _doBuffer;
public Form1()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer ,true);
this.UpdateStyles();
m_pen = new Pen(Color.Violet,3);
bm = new Bitmap(src);
mat = new Matrix();
angle = 1;
_doBuffer = true;
}
private void button1_Click(object sender, System.EventArgs e)
{
g = pictureBox1.CreateGraphics();
g.DrawImage(bm,20,20,100,100);
timer1.Enabled = true;
timer1.Start();
Invalidate();
}
private Bitmap _backBuffer;
private void timer1_Tick(object sender, System.EventArgs e)
{
if(_backBuffer==null)
{
_backBuffer=new Bitmap(pictureBox1.ClientSize.Width,this.ClientSize.Height);
}
Graphics g=null;
if(_doBuffer)
g=Graphics.FromImage(_backBuffer);
else
g=pictureBox1.CreateGraphics();
g.Clear(Color.White);
g.SmoothingMode = SmoothingMode.AntiAlias;
p = new Point(70,70);
mat.RotateAt(angle,p);
g.Transform = mat;
g.DrawImage(bm,10,10,100,100);
//g.Dispose();
g.DrawImageUnscaled(_backBuffer,10,10,100,100);
Invalidate();
}
|
|
|
|
|
hdv212 wrote: g = pictureBox1.CreateGraphics();
You approach is wrong. Only handle painting in the OnPaint event, you can however do the rest where you have them now.
-- modified at 1:16 Friday 31st March, 2006
|
|
|
|
|
Hi,
Can someone show me how to put together a C# method to read the time of a remote PC, please. Thanks so much.
.NET Beginner
|
|
|
|
|
An easy way to get a remote PC's current time would be to use the "NET TIME" console command. This will only work if your PC and the Remote PC are at least NT4. Also, this isn't the greatest method if you need to parse out the date time from the console output.
System.Diagnostics.Process proc = new System.Diagnostics.Process();<br />
proc.StartInfo.UseShellExecute = false;<br />
proc.StartInfo.CreateNoWindow = true;<br />
proc.StartInfo.RedirectStandardOutput = true;<br />
proc.StartInfo.FileName = "net";<br />
proc.StartInfo.Arguments = "time \\\\MyRemotePC";<br />
proc.Start();<br />
MessageBox.Show(proc.StandardOutput.ReadToEnd());<br />
proc.WaitForExit();<br />
proc.Dispose();
-- modified at 20:35 Thursday 30th March, 2006
|
|
|
|
|
Hi Joshua,
Thanks for your help. I tried it and it worked. Is there a way to get the time with miliseconds also because I will also need the miliseconds?
.NET Beginner
|
|
|
|
|
I'm sorry. I don't know how to get the milliseconds.
|
|
|
|
|
If you're allowed to install your own app onto the remote PC, then you could use .NET Remoting (via TCP/IP) to get the date time in any format that you want. It would take a lot more doing on your part, but it would be the most powerful because you could provide all the info that your client app needs.
|
|
|
|
|
as a part of my project i hv to design a text editor i want to know how to make the normal options like cut , copy and paste
and above all how to print the document and see it in the print preview
thank u
abdelhameed81
|
|
|
|
|
|
Hi everybody,
I have a solution with 2 projects: a ASP.NET Project and a class library.I added App.config file to the class library but I can't access it.The class library uses the Web.config of the Web project. Does anyone know how to solve this problem?Thanks!!!
Stefano
|
|
|
|
|
anything that you want in an App.config file in the webserver must be added in the web.config OR you have to manually read/access it.
|
|
|
|
|
Hi,
I have an application that changes some properties of app.config file in some cases. But if you want your changes have effects, you have to restart the application. Is there any way my changes have effects without restarting?
Thanks.!!
|
|
|
|
|
I never need to restart the app, I just read the settings from the config again.
Are you referring to web app?
-- modified at 22:12 Thursday 30th March, 2006
|
|
|
|
|
Even i am facing the same problem in a desktop application created in C#
If you have any solution please
send it to me too..
Thanks,
Pramod
|
|
|
|
|
Not really a 'solution', I always read the keys from file when I need them, so I always get the latest values from the config.
Maybe you can tell us in more specific why you need to restart the application when you have made changes to the config file.
|
|
|
|
|
I have added the connection string for the database in the
app.config file when the application starts for the first time.
But when i add and later try to access the connection string from
the file it returns null, i debugged the whole application,
The file is modified but the object through which i read the file does not
displays the newly added value.
How have u done it?
can u tell me the procedure to do that.
I want to add a connection string value to the app.config file
when the application is started.
and then read this value later in the application without restarting it.
Thanks,
Pramod
|
|
|
|
|
As I wanted to change the key values in my apps during execution and reload the key values as needed, I use a custom class to read and write to the config file.
You can do a search on CP, there are a few of these custom classes, and see which one is more suitable for your needs.
|
|
|
|
|
I'm referring to a desktop application.
|
|
|
|
|
I needed to access an assembly, which I did by loading it into another AppDomain.
Next, I unload the AppDomain. Now when I try to open up that dll for writing it tells me that the file is being used by another process. I thought that the file got unloaded once the AppDomain was unloaded. That is the only reason I loaded the dll into another AppDomain, so that I could unload it and allow it to be overwritten afterward.
Here is my code. The dll is in the directory that the main executable is running in. This is the only way I got the domain to load the assembly. Once the domain loads the assembly a FileStream cannot be opened for writing on that file. It makes no sense because I unload the domain :
AppDomainSetup aps = new AppDomainSetup();<br />
<br />
aps.ApplicationBase=@"myapplocation";<br />
AppDomain domain = AppDomain.CreateDomain("My New Domain",null,aps);<br />
string apploc = @"myexecuting assembly location";<br />
domain.ExecuteAssembly(apploc);<br />
<br />
Assembly ass = domain.Load("AdCenter");<br />
<br />
AppDomain.Unload(domain);<br />
<br />
FileStream fs = new FileStream("AdCenter.dll", FileMode.Open, FileAccess.ReadWrite);
Thanks
-- modified at 15:59 Thursday 30th March, 2006
|
|
|
|
|
I don't think that there's any guarantee that the domain has been unloaded because the GC could still retain a reference to it.
Or then again maybe I'm confusing it with something else, although it's still worth checking up on.
Ed
|
|
|
|
|
Check the VS.NET output window, when the 'apploc' assembly loads. What is happening most likely that one of the Types in AdCenter.dll is crossing the domain boundry and effectively locking it. If that is the case, you will have to be a bit more clever how you execute the additional appdomain, it will depend on what your code does, so I cant help you with that.
|
|
|
|
|
AppDomain.Load will load the assembly BOTH in the target domain AND current domain. AppDomain.Load is for calls through COM from unmanaged code only.
Use AppDomain.CreateInstanceAndUnwrap to create an instance of a MarshalByRef class in your main assembly in the target domain. That class then can use Assembly.Load to load additional assemblies that should be active only in the target AppDomain.
|
|
|
|
|
I'm not sure I understand what you're saying. First off, AppDomain.CreateInstanceAndUnwrap loads the assembly into the both domains just as AppDomain.Load does. Also I don't get how I would be able to use that class to call Assembly.Load since the class that is returned is the class object that I instantiated.
|
|
|
|
|
Ok, I get what you're saying, if my class inherits MarshalByRefObjectthen I can load the assembly inside of that class. Since my class inherits MarshalByRefObject it get returned as a proxy.
|
|
|
|
|
Hello
I have what I hope will be a simple question...I'm trying to build an application in which I have a tree control on the left side of my form that will control swap which form is shown on the right (basically I'm hoping to reproduce the tab control using a tree as it's selection method). I've tried just hiding and showing the controls but this is not a valid solution as i add more options to the tree...I've also moved panels around but ran into the same extendibility problem. I'm sure there is a way to create separate forms and simply overlay them on the currently displayed form but I can't figure it out...please help.
Thanks
Kev
|
|
|
|