|
I need to know how to re-draw graphics on my forms when the forms are minimized or lose focus. I know there are an Update() and Invalidate() method but when I use them they don't work. I need to know where to put them actually.
I already know that the OnPaint() method is called when the form loses focus and graphics need to be drawn. The reason i don't want to go that route is because I am using a button control that when pressed, there are counters that will change the coordinates of the graphic shape. This means I would have to save the current state or coordinates after each time the button is pressed and it would be a hassle to pass all of this to the OnPaint() method, even though it could be done.
I just need a simple way to redraw my graphics in the forms.
|
|
|
|
|
save all the graphics in an ArrayList
make some class like Elipse , Arc.. etc
OnPaint()
foreach ( drawing in myDrawings )
{
drawing.Draw( e.Grahics ) ;
}
Lazar Mihai
Highschool student
|
|
|
|
|
I have a program that includes 2 splash screens. They both load correctly but the one that has a flash movie in it will just load and not play the movie. I think it is because I am using a Thread.Sleep(), that will just load the form but not execute any functions. If I load the flash form without threading the movie will play, so I know it is not an playback issue. This is a sample of the code in the Main() function.
LogoSplash logo=new LogoSplash(); //This works good
logo.Show();
Application.DoEvents();
Thread.Sleep(5000);
logo.Close();
FlashSplash flash=new SplashScreen(); //This is where i have issues
flash.Show();
Application.DoEvents();
Thread.Sleep(10000); //will execute, but not play movie
flash.Close();
Application.Run(new ParentForm());
I just want the flash splash form to load and play for 10 seconds, terminate and then load the main form.
If there is another route please, can anyone lead me in that direction.
|
|
|
|
|
You coud try not putting the thread to sleep .. and use a timer inside the flash splash screen..
and maybe do something like
Application.Run( new SpashScreen() );
// when the 10 seconds are up
inside the tick counter .. this.Close();
then the ParentForm() is going to appear ...
Lazar Mihai
Highschool student
|
|
|
|
|
Can any one help me out how to write the code for addin in C# which creates a button on command bar and on click of that button entire document data shuld be saved to database.(not only word but this should work for every office application ppt,xls,doc..it shuld be generic to office applications)
text selection shuld be hidden from user how?
how to add customdocument property of an office application thru C#? this can be done i VB.NET but it has some issues with C# plz help me out
|
|
|
|
|
use Extensiblity Projects - Shared Add-in to reach that.
|
|
|
|
|
hi
how can i load a mesh with items which are linked together and apply transormation to them using managed directx
thanks for help
|
|
|
|
|
Hi every body
I Wrote a calendar class that have a collection of holidays as an ArrayList. This
collection is a property of my custom control that I want Add some objects of
Holiday class to it at design time.I want to customize the .NET collection editor
to add my Holiday class instances instead of object type.Please help me.
My holiday class is very simple as follow :
public class Holiday
{
private int month;
private int day;
private string reason;
public Holiday(int month,int day,int reason)
{...}
//Properties
public int Month
{...}
public int Day
{...}
public string Reason
{...}
}
I read some articles is code project but they were very complicated.Please give
me one simple tutorial link if you can.
Xironix
|
|
|
|
|
Read this?
http://www.codeproject.com/csharp/DzCollectionEditor.asp
I'm in the high-fidelity first class traveling set.
And I think I need a Lear jet.
|
|
|
|
|
Thanx.Yes I read this. But I can't implement it ? I can customize the CollectionEditor for my HolidayObject but the auto generation code did not created ! Serializing could not work !
|
|
|
|
|
heavenamour wrote:
I Wrote a calendar class that have a collection of holidays as an ArrayList. This collection is a property of my custom control that I want Add some objects of Holiday class to it at design time.
You have to do three things:
1. Use a strongly typed Collection, derived from CollectionBase instead of an ArrayList or Array. This allows the CollectionEditor to work properly.
2. Create a custom TypeConverter for Holiday, which is capable of converting a Holiday instance to an InstanceDescriptor . This allows the code generator to generate code to instantiate Holiday objects.
3. Decorate the collection property of your custom control with the DesignerSerializationVisibility attribute. This tells the code generator to serialize the contents of your collection, rather than the collection itself.
To illustrate these points:
using System;
using System.Collections;
using System.ComponentModel;
using System.Globalization;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
namespace Holidays
{
public class YourControl
{
private readonly HolidayCollection holidays = new HolidayCollection();
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public HolidayCollection Holidays
{
get { return holidays; }
}
}
public class HolidayCollection : CollectionBase
{
public int Add(Holiday item)
{ return List.Add(item); }
public Holiday this[int index]
{
get { return (Holiday)List[index]; }
set { List[index] = value; }
}
}
[TypeConverter(typeof(HolidayConverter))]
public class Holiday
{
public Holiday()
{
this.month = -1;
this.day = -1;
this.reason = null;
}
public Holiday(int month, int day, string reason)
{
this.month = month;
this.day = day;
this.reason = reason;
}
private int month;
private int day;
private string reason;
public int Month
{
get { return month; }
set { month = value; }
}
public int Day
{
get { return day; }
set { day = value; }
}
public string Reason
{
get { return reason; }
set { reason = value; }
}
}
internal class HolidayConverter : ExpandableObjectConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
return true;
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
{
Holiday holiday = value as Holiday;
if (destinationType == typeof(InstanceDescriptor) && holiday != null)
{
Type[] argumentTypes = new Type[] { typeof(int), typeof(int), typeof(string) };
ConstructorInfo constructor = typeof(Holiday).GetConstructor(argumentTypes);
object[] arguments = new object[] { holiday.Month, holiday.Day, holiday.Reason };
if (constructor != null)
return new InstanceDescriptor(constructor, arguments, false);
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
}
HTH, Mark
Edit: I forgot one more thing. The CollectionEditor doesn't like non-default constructors, in fact, it can't instantiate objects without default constructors. So...
4. Add a default constructor to Holiday. The CollectionEditor has no way of specifiying constructor arguments.
|
|
|
|
|
Hi every body
I Wrote a calendar class that have a collection of holidays as an ArrayList. This
collection is a property of my custom control that I want Add some objects of
Holiday class to it at design time.I want to customize the .NET collection editor
to add my Holiday class instances instead of object type.Please help me.
My holiday class is very simple as follow :
public class Holiday
{
private int month;
private int day;
private string reason;
public Holiday(int month,int day,int reason)
{...}
//Properties
public int Month
{...}
public int Day
{...}
public string Reason
{...}
}
I read some articles is code project but they were very complicated.Please give
me one simple tutorial link if you can.
Xironix
|
|
|
|
|
Is this possible? Any code snippets are appreciated.
Brian
|
|
|
|
|
You can use the "Adobe Acrobat Browser Control Type Library" (PDF viewer) component.
<italic>Work hard, Work effectively.
|
|
|
|
|
ok.....where can I get it and can you provide any examples of how I can use it?
Sorry, I am new to this stuff.
Brian
|
|
|
|
|
Download page[^].
Use the method LoadFile to load the pdf file.
AcroPDF1.LoadFile ("c:\a.pdf") . Good luck.
<italic>Work hard, Work effectively.
|
|
|
|
|
|
Can someone please help me with correcting the following code. Everything is fine until you expand the window (the text gets all messed up).
Create a new windows form 300x300 and put the following code into the constructer after the InitializeComponent call. An run it, you will see my problem.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics dc = CreateGraphics();
// Set the bounds for redrawing, initial client size is 300x300
if (dc.ClipBounds.Top < 300 && dc.ClipBounds.Left < 300)
{
int screenHeight = Convert.ToInt32(ClientSize.Height);
int screenWidth = Convert.ToInt32(ClientSize.Width);
// Set up string.
string measureString = "This is just a test to see if this text will wrap the screen whilst also resizing with the window";
Font stringFont = new Font("Arial", 12);
// Set maximum layout size.
SizeF layoutSize = new SizeF(ClientSize.Width, ClientSize.Height);
// Measure string.
SizeF stringSize = new SizeF();
stringSize = dc.MeasureString(measureString, stringFont, layoutSize);
// Set the bounds for the text when drawn to screen
int quewidth = Convert.ToInt32(ClientSize.Width);
int queheight = Convert.ToInt32(stringSize.Height);
Rectangle questionRect = new Rectangle(0, 0, quewidth, queheight);
int screenheight = Convert.ToInt32(ClientSize.Height);
// Draw rectangle representing size of string.
dc.DrawRectangle(new Pen(Color.Red, 1), 0.0F, 0.0F, ClientSize.Width, stringSize.Height);
// Draw string to screen.
dc.DrawString(measureString, stringFont, Brushes.Black, questionRect);
dc.DrawString("quewidth = " + quewidth + "\n screenheight = " + screenheight + "\n", stringFont, Brushes.Black, new PointF(50, stringSize.Height+12.0F));
}
}
|
|
|
|
|
Had you set the ResizeRedraw property to true?
|
|
|
|
|
Where do i set that? I don't understand what you mean.
I managed to solve the messed up text by using dc.Clear(this.BackColor); at the start of the drawing loop.
It now works fine (be it not so smooth) but if you drag the window bigger width ways (redraws the text ok) , then drag the window smaller width ways nothing happens!!?? The text doesn't redraw until you minimize/maximize the form.
|
|
|
|
|
So you have to write in the Resize event of the form some code that makes the font smaller ,or just make the current size of the form is the minimum size so they can only maximize it or make it back to that size,but not smaller.
|
|
|
|
|
These two functions are not working in my forms. I want to close the 1st form when i open the 2nd one, that from a link on the first form(a button u understand). But i've tried all techniques dat my mind may hav told me 2 use, none of them are working. Tell me, please, how to use these two functions, as well as how to do wat i want to: close 1 form wen next opens(like in a game).
Please donot mind if i tell xtra things. This is my 1st message, and i dont frequent the net.
Jeea
|
|
|
|
|
Basically, it sounds like your trying to close a form that you can not close (unless you want your app to close that is). You haven't said what the forms are doing, so I'll have to take a guess...
Your startup form can't close, period. What you need to do is structure your app around a central form that manages your entire application. For instance, when newbies try to create a Splash screen for their application, they make the mistake of making the Splash screen the startup form. NO! Your main application must either startup from a custom Main or it must startup from your applications main form, not the Splash screen.
For some examples, search the articles for "splash screen".
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am having a problem with creating a file in c#. More specifically, a problem that happens to the file after creation.
First off, here is my code:
<br />
string strFileName = "c:\Test\file.log";<br />
if(!System.IO.File.Exists(strFileName))<br />
{<br />
System.IO.File.Create(strFileName); <br />
}<br />
The file is created just fine. The probelm is that the aspnet_wp process keeps the file locked after it has been created so I can not write to the file. I can't even open it or delete the file manually. I have to go into Task Manager and kill the process.
Is there some sort of cleanup I am missing here? Is it my code or the environment or...???
Thanks.
|
|
|
|
|