|
If you are looking for complete efficiency you should use DirectX to draw your own controls instead of GDI+.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Hey!
I have a form that uses some pretty heft painting, it draws a custom caption, close, minimize, maximize buttons and border.
It works really perfectly (lagless) when resizing the form, but when I move the form offscreen slightly and move it back in, it draws the bottom border (or the border that was moved off-screen) repeatedly onto the form's body.
My solution to this was to apply Invalidate() into the Form.Move event, but as you can imagine it lags the form heavily when you move the form now. It doesn't lag it to the point that it's slow as such, but it does apply quite a bit of memory (sometimes up to 11k memory whereas on resize it's only around 5k).
Is there any way that I could possibly prevent the form from drawing the borders repeatedly over the body (which looks ugly) without having to completely invalidate the form everytime the form is moved?
Thanks.
|
|
|
|
|
Invalidate region and create a custom region that is bigger than the form and slightly smaller.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Hm? I don't quite understand what you mean, could you elaborate a bit please?
Thanks
|
|
|
|
|
Sorry. Make one rectangle larger than your entire draw area, then make one slightly smaller. Combine them into a region that excludes the inside portion of the smaller rectangle and then call invalidate and pass in your region. The form will only draw the outer portion which will be very fast.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Mm that didn't help D:
Here's a screenshot of the problem:
Screenshot of the moving problem[^]
All I did was move the form below the taskbar/off the bottom of the screen so it draws the bottom border (which is custom drawn) onto the body repeatedly. Then when I do something to raise the OnPaint event again, the form is drawn properly. It's only when the actual form is being moved off the screen that it draws it like that.
I think it's because, when the client is moved off the screen the ClipRectangle in OnPaint is reduced to only the visible area on the screen, so the border is drawn where the end of the client is a the screen.
I might use a new Rectangle rather than ClipRectangle based on
new Rectangle(this.Left, this.Top, this.Width, this.Height); to obtain the full client region, rather than relying on ClipRectangle.
Thank you!
|
|
|
|
|
So you were using the clip rectangle as the size of the window? I expected something like that, because that would definitely explain why the border is drawn inside the window.
The clip rectangle is the area that the Paint event is expected to draw, and that can definitely be smaller than the window. If you for example have another window on top of your window, and your window has to be redrawn, you will get several calls to the Paint event. The visible window area is divided into rectangles, and the Paint event is called to draw each rectangle.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I have a generic class which I use to populate a BindingList which I then use as the DataSource of my DataGridView.
This class inherits from my LINQ table and adds some extra properties such as State etc...
The problem is that I have to creat a new class for every single LINQ table I choose to use this way, I need some way to make my inheritance generic.
This code works for that specific class (but it's not really generic since it only works for "myExampleTable"):
Please not that <<T>> is only written with double brackets because the correct syntax doesn't want to display in CP.
namespace BL.CustomLINQ {
public class StateTracker<<T>> : myExampleTable where T:class {
public enum ErrorState {
NoError = 0,
RowIsIncomplete = 1,
RowValidationFailed = 2
}
public int state{get;set;}
public ErrorState RowErrorState { get; set; }
public StateTracker() : base() { }
}
} But as I said, this code is useless for me!
This is what I really want to do, but I'm doing it wrong:
namespace BL.CustomLINQ {
public class StateTracker<<T>> : T where T:class {
public enum ErrorState {
NoError = 0,
RowIsIncomplete = 1,
RowValidationFailed = 2
}
public int state{get;set;}
public ErrorState RowErrorState { get; set; }
public StateTracker() : base() { }
}
} Note that I'm inheriting from the same class as the one I passed in as the generic.
The error I get (underlining T) is: Cannot derive from 'T' because it is a type parameter.
Is there any way to do this or should I try a different (less appealing ) approach?
|
|
|
|
|
I don't think this could work. Inheritance is handled at compile time while Generic type parameters are resolved at run time. There's no way for the compiler to know what the base class of of StateTracker<T> would be, and therefore what the functional interface to that base class would be. For example, in your default constructor you are explicitly calling the default constructor of the base class - but what if type T does not define a default constructor or the default constructor is hidden (private)? In my opinion you would be better off to create your StateTracker class to contain an element of Type T and interact with it in this manner even if C# did allow you to derive from a Generic type.
"We are men of action; lies do not become us."
|
|
|
|
|
You can't do that. Can you tell us why you need such a design?
|
|
|
|
|
I'm kinda struggeling with the DataGridView, this control has given me some grey hairs lately. It's my first time that I use it in this manner.
The reason I'm doing this StateTracker thing is to be able to add extra information to this list that I bind to the DataGridView which I use to label a row as new or edited etc.
I'm doing this because, when done editing, I submit only the affected rows to my Web Service (WCF) which then updates the rows appropiately.
Is there a better way?
|
|
|
|
|
I'm not sure about the necessity of using a StateTracker to track the state of a row, but notwithstanding that, why would you need to derive the StateTracker from a generic type? Based on your post, I am guessing that you want to actually derive the StateTracker from the List that is used as the GridView data source. Assuming you could do this, it really wouldn't be an effective inheritance model because A List is a logical grouping of objects, and a StateTracker is an object created for tracking the state of something. There really is no logical inheritance relation between the two. I think it would be more effective to use a model like this:
Say you have objects you are viewing in your GridView. We'll call them objects of type Widget. Now you want to populate your GridView with a data source. You're using a List<Widget> collection object as your data source. Great, except this doesn't have all the data you need. You want to track the state of the List<Widget>. So just create an overloaded class, call it WidgetCollection or something like that. This class will inherit from List<Widget> and also contain an instance of the StateTracker class (which is a base type - not derived from anything other than System.Object). This inner instance of StateTracker should be used to track the state of each WidgetCollection. Again I don't know if this would be the best solution because I don't fully know your situation, but something along these lines should meet your needs - You have a collection of objects that either tracks state on the collection level or the object level. If you are tracking on the collection level, then the collection contains a StateTracker to handle this. If you are tracking on the object level, then each Object contains a StateTracker to handle this. Hope that helps or gets you pointed in the right direction.
"We are men of action; lies do not become us."
|
|
|
|
|
Hi cor2879
Thank you for that!
cor2879 wrote: So just create an overloaded class, call it WidgetCollection or something like that. This class will inherit from List<widget> and also contain an instance of the StateTracker class
From this I understand that I cannot get away without creating a special class for every table in my LINQ model. Also, tell me what you think, but I think that it would work better to create a class, say, TrackedWidget which inherits from Widget, then my DataGridView's datasource is List<<TrackedWidget>>. This way I'll have object level tracking.
Another solution I've been working on, was to create a Dictionary<<int1, int2>> to record my object's state, where int1 is the value of the primary key column of that table and int2 is the state enumerator.
Thank you again for your help!
|
|
|
|
|
Hello,
I'm sure this is a simple question, but I can't find the answer.
When I call a child form within the parent form I can set the
text property of the parent form - but it is always appended with
the file name of the child form, so if I set the Text property
of the parent form to:
"Parent form heading"
what I get is
"Parent form heading" - [Childfilename]
How can I get around this ?
thanks
pcjd
|
|
|
|
|
What is your code?
I have this code and works fine for me:
private void ShowNewForm(object sender, EventArgs e)
{
Form childForm = new Form();
childForm.MdiParent = this;
this.Text = "Parent form heading";
childForm.Show();
}
Life is 5: 3 me, 1 you.
Trying to find the missing part is the meaning of Life.
And sadness is when you find that part!
|
|
|
|
|
Hello,
my code is similar to yours - but I still
get the child file name appended to the .Text string
this.Text = "Parent form heading";
ICP newMDIChild = new ICP();
newMDIChild.MdiParent = this;
newMDIChild.WindowState = FormWindowState.Maximized;
newMDIChild.Dock = DockStyle.Fill;
newMDIChild.Show();
// Result: Parent form heading = [Childfilename]
|
|
|
|
|
Hello again,
I put a typo in the last reply. The correct
test is
// Result: Parent form heading - [Childfilename]
ie without the = sign. Note the appended child file name
occurs for all of the child forms I use (about 12)
|
|
|
|
|
Sorry, I couldn't find any problem in your code. Just a question:
You wrote: child file name
What did you mean? What is a Child File Name?
Life is 5: 3 me, 1 you.
Trying to find the missing part is the meaning of Life.
And sadness is when you find that part!
|
|
|
|
|
Hello,
the child file name is just the name of the unit
eg. program.cs, so the string ' - [program]' is appended
to the parent text when this form is shown.
|
|
|
|
|
Oh, I got it. When you maximize your Child form, its Text goes in front of your Parent form, exactly what you wrote. Restore down your Child and your Parent's text will be "Parent form Header" as you expected. I don't know if there's any way to get rid of this issue, Sorry
Life is 5: 3 me, 1 you.
Trying to find the missing part is the meaning of Life.
And sadness is when you find that part!
|
|
|
|
|
Hi EveryOne,
I have a problem in enabling and Disabling the Controls in the WPF:DataGrid,
I am trying to Disable the TextBoxes in the DataGrid when the ComboBox in the same DataGrid gets the SelectedIndex as 0. The TextBoxes of the same row in which the ComboBox's SelectedIndex is 0 should be disabled.
For example, lets say there are 6 columns and 10 rows in a DataGrid,
ComboBox is in Column 3, rest are the TextBox Columns. If I set the ComboBox's SelectedIndex to 0(ZERO) of Row 3, then the TextBoxes in the Column 4 and 5 of the respective row(i.e., Row 3) has to be disabled,
Can Anybody please, help me out with this Issue????
Thank you in Advance.....
|
|
|
|
|
Hi.
I want to open a file... example... in an textbox. I just want to open the file, delete first 50 characters and then save the file and do this through the whole directory.
Any help?
PS: Files are BIG - 1MB to 250MB.
Thanks in front.
Regards,
Matjaž
|
|
|
|
|
|
I don't see why you need the text box. As previously said, you can use FileStream. I'd also suggest using System.IO.StreamReader and System.IO.StreamWriter in conjunction with the FileStream, especially if the file is not ASCII.
My LinkedIn Profile
|
|
|
|
|
Using VS2008/.Net 3.5...
I'm working on an app that has HUNDREDS of data entry forms. Here are some requirements:
0) The user must be able to open more than one form at any given time.
1) The opened forms will be constrained to a panel on a splitter container.
2) The user will be able to change the form display from free-floating windows to tabs (like the Visual Studio IDE can do).
At first blush, I think I'm going to have to make all of the forms modeless. Switching to a tabbed interface is kinda wonky though. How should I go about doing that?My first thought is to create a form that docks at the top of the panel and displays a tab for every currently opened form, and then make all of the data forms "maximized" within the panel.
Comments?
[EDIT]--------------
I created a sample app with a splitter container, and tried to add a mdi container as a child, and .Net puked on me (top-level control cannot be added to a control).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Friday, November 21, 2008 7:23 AM
|
|
|
|