|
Sorry, tried to post last night but CP kept timing out on me. Anyway, I won't be posting my sample task otherwise I'd have to come up with a new one - there's no point giving potential candidates too much of a head start.
|
|
|
|
|
How old are you? I'm 50 and been contracting a bit lately. Never once got a job when interviewed by someone in there 30's. Never once Not got the job when interviewed by someone over 40.
Age is definitely an issue, you won’t get around that.
As far as the sharpening goes, just get up to speed with the new technologies. Working for in-house development teams can leave your skillset stale due to the fact they tend to be conservative places and not early adopters of technology.
At a .NET level I’d say focus on Xaml(WPF/Silverlight/WP7/MVVM) WCF, Entity Framework and Unit testing if you don’t already have these skills. If you are a web developer MVC is a no brainer.
"You get that on the big jobs."
modified on Wednesday, June 1, 2011 8:23 PM
|
|
|
|
|
private void Action(int ust_id)
{
MySqlCommand cmd = new MySqlCommand("Select * From kategoriler_tablo Where UstKategoriId=" + ust_id.ToString(), c);
c.Open();
MySqlDataReader r = cmd.ExecuteReader();
while (r.Read()) {
if (ust_id != 0) {
treeView1.Nodes.Find(ust_id.ToString(), true)(0).Nodes.Add(r("id").ToString(), r("KategoriAdi").ToString());
} else {
treeView1.Nodes.Add(r("id").ToString(), r("KategoriAdi").ToString());
}
Action(Convert.ToInt32(r("id")));
}
r.Close();
c.Close()
}
private void Button1_Click(System.Object sender, System.EventArgs e)
{
if (c.State != ConnectionState.Open) {
}
TreeView1.Nodes.Clear();
TreeView1.Update();
c.close();
Action(0);
}
This code does not work. I could not understand where the fault is
http://www.imageupload.org/?d=2E926FEF1[^]
|
|
|
|
|
I guess an earlier operation didn't close the connection. Find out where, and also check the state before opening and closing.
You may want to put the close in a finally.
|
|
|
|
|
It'd be easier to create a new connection in the Action method and wrapping it in a using directive; that way it'll always use it's own connection and it'll always close it when done.
Bastard Programmer from Hell
|
|
|
|
|
Well as the error indicates the connection is still opened from a previous attempt or some other method.
Since you are not using any try/catch blocks the code could have failed at any point between the Open and Close calls thus leaving the connection open.
Make use of the using statement
using(SqlConnection conn = new SqlConnection("..."))
{
using(SqlCommand cmd = new SqlCommand("...", conn))
{
}
}
With this the connection and command will be disposed of regardless of whether a failure has occurred.
You should learn to program defensively also.
if(conn.State != ConnectionState.Open)
conn.Open();
And lastly, use parameterized queries rather than concatenate a string for the command.
I know the language. I've read a book. - _Madmatt
modified on Wednesday, June 1, 2011 9:34 AM
|
|
|
|
|
which should help me get the line?
|
|
|
|
|
What?????
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
which line is wrong in my code?
|
|
|
|
|
All of it. Please read the suggestions you have been given
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
Then we can't help you further
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
good one
|
|
|
|
|
As others have said, your connection is open already. You could wrap the line c.Open() with
if (c.ConnectionState != ConnectionState.Open)
c.Open();
|
|
|
|
|
|
We are here to help but you must also put forth some effort. Copy & Paste is not a valid coding technique. You need to understand the objects you are working with. This error is very easily corrected by simply using the Intellisence built in to Visual Studio.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
if (c.State != ConnectionState.Open)
c.Open(); ---- accept that this code ***** but "c.ConnectionState" wrong
|
|
|
|
|
For goodness sake, I just typed into the textbox here. I'm not opening things up in Visual Studio and creating a whole project just to test things for you.
|
|
|
|
|
trying to figure out a way to get it right...
1. items in a collection fall in one of the category parent or orphan
2. items in a collection may have one or more independent parent / one or more orphan
3. Both (Parent and Orphan) may or maynot have Individual behaviour
4. If a parent has one or null behaviour it should be applied to children. Individual behaviour of children item be hidden
5. If a orphan has one or null behaviour it should be applied to it
6. An item will have only one or null behaviour
trying to rephrase the following code...
private static void ApplyBehaviour(IEnumerator items, Behaviour behaviour = null)
{
while(items.MoveNext())
{
ItemModel item = (ItemModel)items.Current;
if(item.type = parent)
{
parentModel parentModel = (parentModel)item;
if(parentModel.HasBehaviour)
{
behaviour = parentModel.Behaviour;
}
ApplyBehaviour(parentModel.Children.GetEnumerator(), behaviour);
if(parentModel.HasBehaviour)
{
behaviour = null;
}
}
item.Behaviour = behaviour;
}
}
}
inital call will be ApplyBehaviour(items);
if two items with common parent and different behaviour, then the above code gets the
first item and children right...takes the parent behaviour but the second item retains its behaviour and applie it to children.
not sure whether i have explained in a way that someone can read and understand
- Regards - J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers
modified on Wednesday, June 1, 2011 8:37 AM
|
|
|
|
|
It looks like the problem is that once you finish the first sibling with custom behaviour, you reset the value of behaviour to null. In other words, the logic as coded starts ignoring the value passed in after discovering the first sibling with parentModel.HasBehaviour == true .
Changing the code as follows avoids this problem:
if(item.type = parent) {
ParentModel parentModel = (parentModel)item;
ApplyBehaviour(
parentModel.Children.GetEnumerator()
, parentModel.HasBehaviour ? parentModel.Behaviour : behaviour
);
}
|
|
|
|
|
What is the reason of memory consumption in the DrawRoi function leading to hundreds of Mb?
There is a Frame bitmap and its FrameWithRoi copy to assign to PictureBox.
On the mouse move event new ROI coords are estimated and DrawRoi() is called.
DrawRoi()
{
RectangleF roi = Roi;
RectangleF rect = new RectangleF()
{
X = (float)Frame.Width * roi.X,
Y = (float)Frame.Height * roi.Y,
Width = (float)Frame.Width * roi.Width,
Height = (float)Frame.Height * roi.Height
};
if (rect.Left > 0 || rect.Right < (float)FrameWithRoi.Width ||
rect.Top > 0 || rect.Bottom < (float)FrameWithRoi.Height)
{
Graphics g = Graphics.FromImage(FrameWithRoi);
g.DrawImage(Frame, 0, 0);
using (Bitmap region = new Bitmap(FrameWithRoi.Width, FrameWithRoi.Height, FrameWithRoi.PixelFormat))
{
Graphics roi_g = Graphics.FromImage(region);
roi_g.FillRectangle(new SolidBrush(Color.FromArgb(64, 0, 0, 0)), new Rectangle(0, 0, FrameWithRoi.Width, FrameWithRoi.Height));
roi_g.FillRectangle(new SolidBrush(Color.Red), rect);
region.MakeTransparent(Color.Red);
g.DrawImage(region, 0, 0);
}
}
this.framePictureBox.Image = FrameWithRoi;
}
Чесноков
|
|
|
|
|
Two things strike me immediately:
- you are not disposing of the graphics objects you obtain. This might actually be a resource leak.
- you create a new RectangleF every time (though I think this is a value type, so it shouldn't matter).
It's also possible that the bitmap doesn't get garbage collected immediately, even though it is being disposed of at the end of the using. But it should do.
|
|
|
|
|
Yes, disposing graphics objects solved the problem.
But why the drawing is very slow? The larger the image the slower update.
Чесноков
|
|
|
|
|
Graphics objects are expensive, and you should dispose them. Why not use a using statement, just like you did for the region Bitmap ?
And why would you need two Graphics instances, and a DrawImage() ? Couldn't you just use the Bitmap(Image) constructor, and have its Graphics , just the one?
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
I was looking for a way to darken non ROI region in the image.
You optimizations would be welcomed.
Why the picture box update is very slow if I keep drawing on every mouse move event?
Чесноков
|
|
|
|