|
You forgot an opening curly brace at line 215, causing a cascade of "scopes that were closed too early"
213:
214: bahrain_smartcard_error = bahrain_smartcard_data.ReadIDCard(BahrainAPI.BahrainData.Fields.EnglishName, ref bahrain_smartcard_Name);
215: if (bahrain_smartcard_error != 0) <big>{</big> MessageBox.Show(bahrain_smartcard_error.ToString()); }
Or remove the useless closing brace at the end of that line.
|
|
|
|
|
Hi,
I'm not going to download anything.
My advice is: concentrate on the first error. It tells me you probably opened a namespace, and provided some data members or methods, while not having opened a class/struct/whatever yet.
|
|
|
|
|
Other than comments, looks like you have removed some code from the following section -
catch (Exception exp)
{
MessageBox.Show("Error updating smartcard data!!" + Environment.NewLine + exp.Message + Environment.NewLine + "Please try again or enter data manually", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
public_var.create_event("System", "Error updating smartcard data!!", exp, EventLogEntryType.Error, 1000, true);
return;
}
finally
{
if (sql_reader != null) sql_reader.Close();
if (sql_connection != null)
{
if (sql_connection.State == ConnectionState.Open)
sql_connection.Close();
}
}
lblReadSmartCard.Visible = false;
lblReadSmartCard.Refresh();
progressReadSmartCard.Visible = false;
progressReadSmartCard.Refresh();
My signature "sucks" today
|
|
|
|
|
Hey
My application uses directshow to playback videos. If a video is playing and the user minimizes and then brings the window back on screen the video disapears. Does anyone have any idea of what could be causing this?
Thanks
|
|
|
|
|
Does this happen on all machines?
I ran into an issue with no-name nVidia cards that didn't have the updated drivers. Updating the drivers got the video to work.
|
|
|
|
|
Your render device may be lost. Try catching the render device's DeviceResizing, DeviceReset and DeviceLost events.
|
|
|
|
|
Hi All.
I have been developing my own OwnerDrawn TabControl so I can have a close button on the right hand side of the tab. All was going well thanks to some of the articles on CP and now it has stopped working in Design mode. When the control is used in the test form when the app is running, everything works as expected. In design mode I cannot switch tabs to add controls to them. Any ideas?
public class ClosableTabCtrl : TabControl
{
#region Private Members
private System.Windows.Forms.ImageList buttonImageList;
private bool showCloseButton = true;
private bool hideCloseButtonWhenOnlyOneTab;
private const string tabText = " ";
private int buttonImageIndex;
#endregion
public ClosableTabCtrl() : base()
{
buttonImageList = new ImageList();
buttonImageList.Images.Add((Image)new Bitmap(Resources.InactiveCross));
buttonImageList.Images.Add((Image)new Bitmap(Resources.ActiveCross));
buttonImageList.Images.Add((Image)new Bitmap(Resources.ClickedCross));
this.DrawMode = TabDrawMode.OwnerDrawFixed;
this.DrawItem += new DrawItemEventHandler(ClosableTabCtrl_DrawItem);
this.MouseMove += new MouseEventHandler(ClosableTabCtrl_MouseMove);
this.MouseLeave += new EventHandler(ClosableTabCtrl_MouseLeave);
this.MouseClick += new MouseEventHandler(ClosableTabCtrl_MouseClick);
this.MouseDown += new MouseEventHandler(ClosableTabCtrl_MouseDown);
this.MouseUp += new MouseEventHandler(ClosableTabCtrl_MouseUp);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
}
void ClosableTabCtrl_MouseUp(object sender, MouseEventArgs e)
{
if (MouseIsOverButton(e) && buttonImageIndex != 1)
{
buttonImageIndex = 1;
this.Invalidate();
}
}
void ClosableTabCtrl_MouseDown(object sender, MouseEventArgs e)
{
if (MouseIsOverButton(e) && buttonImageIndex != 2)
{
buttonImageIndex = 2;
this.Invalidate();
}
}
void ClosableTabCtrl_MouseClick(object sender, MouseEventArgs e)
{
if (MouseIsOverButton(e))
{
}
}
void ClosableTabCtrl_MouseLeave(object sender, EventArgs e)
{
if (buttonImageIndex != 0)
{
buttonImageIndex = 0;
this.Invalidate();
}
}
void ClosableTabCtrl_MouseMove(object sender, MouseEventArgs e)
{
if (MouseIsOverButton(e))
{
if (buttonImageIndex != 1)
{
buttonImageIndex = 1;
this.Invalidate();
}
}
else
{
if (buttonImageIndex != 0)
{
buttonImageIndex = 0;
this.Invalidate();
}
}
}
public bool ShowCloseButton
{
get { return showCloseButton; }
set { showCloseButton = value; }
}
public bool HideCloseButtonWhenOnlyOneTab
{
get { return hideCloseButtonWhenOnlyOneTab; }
set { hideCloseButtonWhenOnlyOneTab = value; }
}
bool MouseIsOverButton(MouseEventArgs e)
{
Rectangle r = this.GetTabRect(this.SelectedIndex);
r.Offset(2, 2);
Rectangle b = new Rectangle(new Point(r.X + (this.GetTabRect(this.SelectedIndex).Width - 20), this.GetTabRect(this.SelectedIndex).Height / 2 - 7),
new Size(17, 17));
if (b.Contains(e.Location))
{
return true;
}
else
{
return false;
}
}
void ClosableTabCtrl_DrawItem(object sender, DrawItemEventArgs e)
{
Rectangle r = this.GetTabRect(e.Index);
string title = String.Empty;
r.Offset(2, 2);
Brush TitleBrush = new SolidBrush(Color.Black);
Font f = this.Font;
if (e.State == DrawItemState.Selected)
{
if (!this.TabPages[e.Index].Text.EndsWith(tabText))
{
this.TabPages[e.Index].Text += tabText;
}
title = this.TabPages[e.Index].Text + tabText;
if (showCloseButton)
{
if (!(this.hideCloseButtonWhenOnlyOneTab && this.TabPages.Count == 1))
{
e.Graphics.DrawImage(buttonImageList.Images[buttonImageIndex],
new Point(r.X + (this.GetTabRect(e.Index).Width - 20),
this.GetTabRect(e.Index).Height / 2 - 7));
}
}
}
else
{
if (this.TabPages[e.Index].Text.EndsWith(tabText))
{
this.TabPages[e.Index].Text = this.TabPages[e.Index].Text.Replace(tabText, string.Empty);
}
title = this.TabPages[e.Index].Text + tabText;
}
e.Graphics.DrawString(title, f, TitleBrush, new PointF(r.X, (r.Height - f.Height) / 2 + 1));
TitleBrush.Dispose();
}
}
Thanks in advance.
The FoZ
modified on Wednesday, June 16, 2010 11:46 AM
|
|
|
|
|
I did something similar some time ago (although I don't think I actually inherited from tabControl), and implementing the design time functionality was a little problematic.
You can try to have a look at the souce to my Scroll Selector here:
ScrollSelector[^]
That might give you some pointers...
Good luck
|
|
|
|
|
Thanks Johnny J
I've had a look through and to be honest I'm not sure how it all works together. I'm having trouble getting it to work in 2008.
I'm going to try and build it again from scratch by pasting in the code bit by bit and testing along the way. I was able to select the different tabs in design mode before lunch. I wonder what has happened. If I find out I will post it here.
Cheers
The FoZ
|
|
|
|
|
I rebuilt it from scratch and here is what I found.
In the DrawItem method, the design mode does not like it when I change the text of the tab. The line I found to cause the trouble is
this.TabPages[e.Index].Text = this.TabPages[e.Index].Text.Replace(tabText, string.Empty);
Looks like I am going to have to actively calculate the size of the tab which is probably the best way to go about it.
If anyone can shed some light on the reason for this so I know why I shouldn't do it my original way, I would be grateful.
Cheers
The FoZ
|
|
|
|
|
Hello expert
I need the x symbol when click on the checkbox inside the datagridview. when i click on checkbox dot symbol are displayed instead on dot symbol i need the x symbol.
Please help me.
|
|
|
|
|
Hi Experts,
I'm trying to serialize a collection
using (System.IO.MemoryStream saveStream = new System.IO.MemoryStream())
{
System.Xml.Serialization.XmlSerializer saveSerializer = new System.Xml.Serialization.XmlSerializer(typeof(MyFineCollection));
saveSerializer.Serialize(saveStream, _manyObjects);
} The collection contains objects of following types
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace Test_Xml
{
public class MyFantasticBaseClass
{
private int _id = 0;
public MyFantasticBaseClass(int id)
{
this._id = id;
}
public int Id
{
get { return (_id); }
}
}
public class FirstDerivedClass : MyFantasticBaseClass
{
private bool _isReallyUseful = true;
public bool IsReallyUseful
{
get { return (_isReallyUseful); }
set { _isReallyUseful = value; }
}
}
public class SecondDerivedClass : MyFantasticBaseClass
{
private double _zoom = 1.0;
private MyFantasticBaseClass _linkedElement = null;
public double Zoom
{
get { return (_zoom); }
set { _zoom = value; }
}
public MyFantasticBaseClass LinkedElement
{
get { return (_linkedElement); }
set { _linkedElement = value; }
}
}
public class MyFineCollection:ICollection<MyFantasticBaseClass>
{
List<MyFantasticBaseClass> _innerList = new List<MyFantasticBaseClass>();
}
} Now, when collection contains an instance of one of the child classes, the line marked with "/*Ex*/" throws an InvalidOperationException with inner NullReferenceException.
How can I serialize the collection including all objects derived from MyFantasticBaseClass?
Ciao,
luker
|
|
|
|
|
Don't you need to mark the classes as Serializable?
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
lukeer wrote: How can I serialize the collection including all objects derived from MyFantasticBaseClass?
By marking them all as Serializable , or implementing the ISerializable interface.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Unfortunately, simply adding the [Serializable] attribute doesn't do the trick.
And as far as my tests show, the attribute isn't even necessary for serialization with System.Xml.Serialization.XmlSerializer.
The problem at hand is not serializing a class. That part works flawlessly, at least if _manyObjects contains nothing but instances of MyFantasticBaseClass.
Things get ugly when _manyObjects contains instances of children of MyFantasticBaseClass.
How can I get this to work?
Ciao,
luker
|
|
|
|
|
public class SecondDerivedClass : MyFantasticBaseClass
{
private double _zoom = 1.0;
private MyFantasticBaseClass _linkedElement = null;
public double Zoom
{
get { return (_zoom); }
set { _zoom = value; }
}
public MyFantasticBaseClass LinkedElement
{
get { return (_linkedElement); }
set { _linkedElement = value; }
}
}
This is a problem. the contained instance of MyFantasticBaseClassis initialized to null, and will throw the exception on serialization. Try initializing to a new MyFantasticBaseClass.
|
|
|
|
|
Hello To All,
I have found very diffrence between Text Printing and Text Using Image Printing
Case 1.
void PaintH(PaintEventArgs e)
{
System.Drawing.Bitmap bmp = new Bitmap(100,100);
Graphics G = Graphics.FromImage(bmp);
G.Clear(Color.White);
G.DrawString("Hello Everybody",this.font,this.col,this.rectangle1);
G.Dispose();
e.Graphics.DrawImage(bmp, 0, 0, bmp.width, bmp.height);
}
Case 2:
void PaintH(PaintEventArgs e)
{
G.DrawString("Hello Everybody",this.font,this.col,this.rectangle1);
}
Case 1 Printing quality is very bad. Case 2 Shows the real Printing Quality.
But I want to Print With the use of Case 1.
So Please Help.
Thanks
If you can think then I Can.
|
|
|
|
|
That happens because you use the default image resolution for your bitmap.
Add the next line right after the creation of your bitmap in order to set the proper resolution:
bmp.SetResolution(e.Graphics.DpiX, e.Graphics.DpiY);
|
|
|
|
|
but there is not same quality of both printing after applying this formula.
If you can think then I Can.
|
|
|
|
|
Yes, Nuri got it right. By default, a new bitmap takes the resolution of your primary monitor; printer resolutions may be quite different, which also means your bitmap may need quite a different size, hence 100,100 may not be enough depending on the printer you select!
|
|
|
|
|
Hi all,
I have some doubt, and it will be be help full if some one explain/elaborate on this. some variables which i am using. Whats my concern is where should i define them?
Approach 1, define with in function and modifying.
Class A
{
void CallingFunction()
{
string data = "";
DataTable dttemp = new DataTable();
bool isValid = false;
checkValue(ref data,ref isValid, ref dttemp);
}
private void checkValue(ref string msg, ref bool valid, ref DataTable dttemp)
{
msg += "Hello";
valid = false;
DataRow dr = dttemp.NewRow();
dr["cID"] = "2";
dttemp.Rows.Add(dr);
}
}
Approach 2, define at class level.
Class A
{
DataTable dttemp;
string data = "";
bool isValid = false;
void CallingFunction()
{
dttemp = new DataTable();
checkValue();
data = "";isValid = false; dttemp.Dispose();
}
private void checkValue()
{
data += "Some data";
isValid = true;
DataRow dr = dttemp.NewRow();
dr["cID"] = "2";
dttemp.Rows.Add(dr);
}
}
Whats the diffrence?
and when to use which?
|
|
|
|
|
First you have to ask youself if you have more than one DataTables.
In my oppinion you should use Approach 2 to solve you problem, Approach 1 is only wise if you have more than one instances of you objects and variables to check.
Well, i don't unterstand the intention of this code complete, maybe i can help more if you explain what are you planning to do
|
|
|
|
|
I am iterating in foreach loop, looking for some validation and then adding that to dttemp table;
foreach(Datatable dt in ds)
{
switch(dt.TableName)
{
case A:
foreach(DataRow dr in dt.Rows)
{
}
break;
.
.
.
case Z:
break;
}
}
Hope i make myself clear?
which is better way with reference to original post?
|
|
|
|
|
IMO, if you have just one datatable, the first approach is fine.
Why do you want to declare class level modules when you are using them only within a method.
My signature "sucks" today
|
|
|
|
|
Hum Dum wrote: Whats the diffrence?
Scope
Hum Dum wrote: and when to use which?
Use the second approach if the variables represent object-state, local variables and parameters if they don't. The hard part in that sentence would be defining "object state".
Let's take a Person class as an example. Now, if we introduce a variable for the age of the Person-object, then we're adding something that describes the state that the person is in. It contributes to the state of the object as a whole.
Next, if you want to iterate all arms that a person has, than you'd use a variable as a counter. That would be a local variable. If that variable were to be used to denote the amount of arms implemented, it would become a property.
I are Troll
|
|
|
|