|
For that you need to use the Scanner SDK to create your own scanning application. There are lots of 3rd party scannner SDKs available for you.
But if you need a simple application then this may help. .NET TWAIN image scanner[^]
Books are as useful to a stupid person as a mirror is useful to a blind person. - Chanakya
|
|
|
|
|
So I am trying to make a class that uses a constructor of a different class.
I use the code (Name of class) Class = new (Name of class(constructor variable))
But oddly the constructor variable won't appear. Could anyone please help?
|
|
|
|
|
Your question is not clear. Posting relevant code will help.
|
|
|
|
|
public class CharClasses
{
public int healthPoints = 0;
public int manaPoints = 0;
public int strength = 0;
public int dexterity = 0;
public int speed = 0;
public int intelligence = 0;
public CharClasses (string characterClass)
{
if (characterClass == "Warrior")
{
healthPoints = 100;
manaPoints = 10;
strength = 10;
dexterity = 5;
speed = 3;
intelligence = 0;
}
if (characterClass == "Archer")
{
healthPoints = 75;
manaPoints = 10;
strength = 3;
dexterity = 10;
speed = 5;
intelligence = 0;
}
if (characterClass == "Assassin")
{
healthPoints = 75;
manaPoints = 10;
strength = 5;
dexterity = 3;
speed = 10;
intelligence = 0;
}
if (characterClass == "Mage")
{
healthPoints = 50;
manaPoints = 50;
strength = 0;
dexterity = 5;
speed = 3;
intelligence = 10;
}
}
}
public class Leveling
{
public int level = 1;
public int experience = 0;
public Leveling()
{
if (experience == ((experience + 100) * 1.5))
{
level++;
}
}
}
I'm trying to take the constructor named "characterClass" from the class CharClasses and use it in the class Leveling.
CharClasses Class = new CharClasses(characterClass); I'm trying to make this code work but the characterClass part of it does not seem to work...
|
|
|
|
|
nik121 wrote: CharClasses Class = new CharClasses(characterClass); I'm trying to make this code work but the characterClass part of it does not seem to work...
Ok, Have you defined the variable characterClass in this scope? What is the error you are getting?
|
|
|
|
|
Yea characterClass was the string for the Constructor in the class CharClasses. But the characterClass says that it doesn't exist in the current context.
|
|
|
|
|
nik121 wrote: Yea characterClass was the string for the Constructor in the class CharClasses. But the characterClass says that it doesn't exist in the current context.
WOW! I am not sure how can I explain this to you. All you can do is to get a book and learn the basics.
When you write code like CharClasses Class = new CharClasses(characterClass) , compiler is expecting the variable characterClass to be presented in the scope. Here you don't have characterClass declared. You need to declare the variable first before using it. Something like
string characterClass = "Warrior";<br />
CharClasses Class = new CharClasses(characterClass);
|
|
|
|
|
If I understand your question, Leveling should inherit CharClasses and use the base constructor characterClass , as follows:
Leveling lvl = new Leveling("Warrior");
public class CharClasses
{
public int healthPoints = 0;
public int manaPoints = 0;
public int strength = 0;
public int dexterity = 0;
public int speed = 0;
public int intelligence = 0;
public CharClasses(string characterClass)
{
if(characterClass == "Warrior")
{
healthPoints = 100;
manaPoints = 10;
strength = 10;
dexterity = 5;
speed = 3;
intelligence = 0;
}
if(characterClass == "Archer")
{
healthPoints = 75;
manaPoints = 10;
strength = 3;
dexterity = 10;
speed = 5;
intelligence = 0;
}
if(characterClass == "Assassin")
{
healthPoints = 75;
manaPoints = 10;
strength = 5;
dexterity = 3;
speed = 10;
intelligence = 0;
}
if(characterClass == "Mage")
{
healthPoints = 50;
manaPoints = 50;
strength = 0;
dexterity = 5;
speed = 3;
intelligence = 10;
}
}
}
public class Leveling : CharClasses
{
public int level = 1;
public int experience = 0;
public Leveling(string characterClass)
: base(characterClass)
{
if(experience == ((experience + 100) * 1.5))
{
level++;
}
}
}
If you use inheritance, and don't need to instantiate CharClasses directly, you may want to change you your access modifiers from all public to protected , etc.
Regards,
Gary
|
|
|
|
|
Hello I am trying to read several different integers from a data file and then store each integer into a different variable.Does anyone know how to do this?
This is my program so far:
class Program
{
static void Main(string[] args)
{
string fileName, num;
int temp;
Console.Write("ENTer filename: ");
fileName = Console.ReadLine();
StreamReader inputFile = new StreamReader(fileName);
num = inputFile.ReadLine();
while (num != null)
{
temp= Convert.ToInt32(inputFile.Read());
Console.WriteLine(num);
num =inputFile.ReadLine();
}
Console.WriteLine("Press enter to end Program");
Console.ReadLine();
}
}
|
|
|
|
|
Use a List<int> and add the value each time in the loop.
|
|
|
|
|
Thank you.Where in the program am i suppose to place List<int>?
|
|
|
|
|
Hi, everyone, i am a new member of this website. i encounted a problem in my GUI.
Right now i want to create a progressbar with pencentage done status running beside it. Can someone give me a hand? i appreciate it.
Peishen
|
|
|
|
|
Welcome!
There is a progress bar control available. You have to calculate the progress percentage and set that to Value[^] property of progress bar.
|
|
|
|
|
|
Try searching the articles - there must be 6+ articles on PBs
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
We have an existing application (so I can't make wholescale changes) that has a number of user controls that are displayed as follows:
Call a method (MyUserControl.ShowVaseline(Control parentControl) which
1. Creates a bitmap from the parentControl.
2. 'Grayscales' the bitmap
3. Creates an empty usercontrol with this bitmap as the background
4. Docks this newly created user control within the parentControl (so it LOOKS as if the parent control is disabled, whereas in fact it is invisible, hidden behind the newly created control)
4. Positions MyUserControl centrally within this newly created user control
The effect is that MyUserControl is shown on top of the parent control, will move with the parent control, and the parent control is disabled and appears 'greyed out'
In most cases this is fine and dandy for its purposes - which is essentially a desire to be able to access some top-level controls on the parent form at all times, while maintaining workflow through apparent modality of dialogs).
But when shown like this it is not 'Modal' in the Windows sense of the word - ie the code following MyUserControl.ShowVaseline(parentControl) is executed without waiting for MyUserControl to complete.
So the 'closing' of the user control is handled by it events which are handled by the parent :
...
MyUserControl.Close += MyUserControlClosed;
MyUserControl.ShowVaseline(Control parentControl);
}
private void MyUserControlClosed(Dialogresult dialogResult)
{
if (DialogResult.OK)
{
SoSomeStuff();
}
}
I would dearly like the ability to treat the control just like a modal dialog form, in some cases - so the LOOK would be the same (centered on an apparently disabled background) but I could do something like
DialogResult dialogResult = MyControl.ShowVaselineModal(parentControl);
if (dialogresult == DialogResult.Ok)
{
DoSomeStuff();
}
I don't really understand, technically, how a dialog form 'works' so don't really know where to begin.
I can think of having my main program enter a loop, checking the user control for a modal result
MyControl.ShowVaselineModal(parentControl);
while (MyControl.DialogResult == DialogResult.None)
{
Application.ProcessMessages();
}
if (MyControl.Dialogresult == DialogResult.Ok)
{
DoSomeStuff();
}
But surely there's something clever I'm missing?
Incidentally, the reason I want to do this is for the occasional situation where, for example, I am iterating a collection, and want to open a 'dialog' for (possibly) several items in the collection - with a true dialog I can just put the code in the loop - but using the existing Vaseline stuff, I have to faff about keeping references to where I am in the collection and/or what has been handled so I can continually reprocess the collection until I have done. It's not so much hard as annoying.
All help gratefully appreciated.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Wow - what dogs breakfast to you have to go through to disable a form. Why not just walk the forms control tree and disable/grey the controls, you could even replace the vaseline (what a horrible name, brings back memo... oops) with a UC to do the disabling.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes - it is a dog's breakfast. But they didn't want the controls disabled because some of them became all but illegible in their default disabled state (due to particularly horrible colour schemes and the idiosyncrasies of the GUI (because some 3rd party controls look different when disabled to their windows counterparts, some user controls behaved differently etc.)
Initially all this faffing about was done using a series of helper classes (bizzarro world here, I tell you!) I at lewast put the functionality in the base class (so you can just say 'control.ShowVaseline' without worrying about what's going on behind). And you would still need some method of positioning the user control on top of the rest of the controls...
It actually looks quite nice - if you like that sort of thing.
The name stems from photography, where Vaseline is used to 'blur' an image, I believe, and not from any, ahem, medicinal usage, of which you appear to be over familiar
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
can't you do something like set a flag in the UC (dialogresult ) and make the main form wait till the flag is reset before allowing progress. or possibly have the parent subscribe to an event on the UC.
Can the UC be changed to a borderless form - and therefore a real dialogresult can be used.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
i am using IE objects. i am getting one IHTMLElement "textarea".
manually in browser if we click on this text area then some javascript code runs. and i get captch. if i see the page source then i am getting... likke this...
;
so what i have to do is, i have to click on textarea by IE automation using microsoft.mstml classes.
Thanks for reply.....
<div class="ForumSig">yogesh</div>
|
|
|
|
|
Hello,
here is a libary you searching for. I foud this some time ago. With this libary you have full control
of the internet explorer here is the link:
http://watin.sourceforge.net/[^]
i hope this helps you
|
|
|
|
|
I've been battling this for a few hours so now I need help!
I'm converting a 64bit fixed point timestamp (32bit integer part, 32bit fractional part) to a DateTime by converting it to a TimeSpan adding that to an epoch, as the timestamp represents the number of seconds since the epoch.
The problem is I'm losing precision (I assume because of the cast to/from double and UInt64 - see code), so converting back from DateTime to timestamp gets a different value.
Any ideas?
using System;
class Program
{
static void Main(string[] args)
{
UInt64 timestampA = 14844064336383267476;
Console.WriteLine("TimestampA: {0}", timestampA);
DateTime dateTime = NTPConversion.TimestampToDateTime(timestampA);
Console.WriteLine("DateTime: {0}", dateTime);
UInt64 timestampB = NTPConversion.DateTimeToTimestamp(dateTime);
Console.WriteLine("TimestampB: {0}", timestampB);
Console.WriteLine("Discrepancy: {0}", timestampB - timestampA);
Console.ReadKey();
}
}
public static class NTPConversion
{
public static readonly DateTime Epoch = new DateTime(1900, 1, 1);
public static DateTime TimestampToDateTime(UInt64 timestamp)
{
TimeSpan timeSpan = TimeSpan.FromSeconds((double)timestamp / 4294967296);
DateTime dateTime = Epoch + timeSpan;
return dateTime;
}
public static UInt64 DateTimeToTimestamp(DateTime dateTime)
{
TimeSpan timeSpan = dateTime - Epoch;
UInt64 timestamp = (UInt64)((timeSpan.TotalSeconds * 4294967296d));
return timestamp;
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Dave,
the problem is here: (double)timestamp
uint64 (aka long) has a 63-bit resolution, whereas double only has some 52 bits of mantissa, the remaining bits required to hold the exponent.
You'll have to smarten up your TimestampToDateTime() method by splitting the uint64 in two parts, and adding them separately to get the DateTime. Example:
long hipart=timestamp&0xFFFF0000;
long lopart=timestamp&0x0000FFFF;
DateTime dt=TimeSpan.FromSeconds(hipart*...);
dt.AddSeconds(lopart*...);
I strongly suggest you don''t use those magic numbers of yours either; they are incromprehensible; what I would do is write them as a formula, the compiler will multiply them for you, and better yet also make them named constants so their name indicates their meaning.
Cheers.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
Dave, I have just tried something for your TimestampToDateTime method and I got 09/07/2009 18:30:53 (dd/mm/yyyy), is that what you were hoping for?
If so I will post it for you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|