Antenka 274 Posting Whiz

Hello,
the only approach I see is calculating the position by yourself, like here: C# Align User Interface.
Don't know, if there any better way to achieve that.

Antenka 274 Posting Whiz

Hi, Chris.
I've provided the solution, that would give the OP such functionality.

set the value property of the textbox to be initialised with that value i think . .

I don't think it's more handy approach. Because:
1. You have to show/hide/replace mask along user inputs text.
2. You still need to take control over user input (to validate the users input).

We have such a good control, MaskedTextBox. Yes, it's not almighty, so we sometimes need to help it to handle specific task. But still, there're a lot of pre-defined things, so there's no need to reinvent the wheel ;)

Antenka 274 Posting Whiz

Hello,
this example works without any errors:

double a = 1.2;
int c = 2;
double res = Math.Round((a * 100) / c);

Maybe you want somehow extend the problem definition ;)

Antenka 274 Posting Whiz

Ok, here was similar question: maskedTextBox works for hexadecimal input.

So, I've suggested you to see that link in my previous post. The solution might be like this:
1. Specify mask, that accepts all Alphanumeric characters. So you restrict the length and basic format (the second character always would be "x").
2. And then - listen to KeyPress event for further restrictions. You may choose re restriction from the first link I gave you (manually checking characters), or from the second (there's a link for a regular expression for the hexadecimal numbers), or make something your own.

Antenka 274 Posting Whiz

Hello,
as MSDN says,

Control.Bounds Property: Gets or sets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.

and

Control.Location Property: Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.

If you're ok with a Location, you probably should use it. If you need something more than upper corner coords - use Bounds :)

Antenka 274 Posting Whiz

As far as I know, the code in VB may be replaced with a similar code in C#. But, I doubt if playing with font size is a handy idea. Dunno about others, but I, personally, look cautious at web elements, who are living with their own life =) E.g. changing it's size or placement, so I need to wait till the "magic" would finish and then try continue to work.

It's just MHO .. and maybe in your case it's needed, but I decided to share my concerns :)

P.S. Here's what I've found in C#: C# Tutorial - Font Scaling

Antenka 274 Posting Whiz

Hello, rexdon.
Are you looking for something like this: C# Hex Mask for maskedtextbox input? ;)

Antenka 274 Posting Whiz

Hello, lemunk.
Take a look at this: How to: Execute a Stored Procedure that Returns Rows . And at DbDataAdapter.Fill Method (DataTable).

The DataAdapter uses SelectCommand property to retrieve a data from DataBase. Which is not specified in your code.

P.S. bumping, at least, is not appreciated ;)

Antenka 274 Posting Whiz

Hello, drugoholic.
The first fast idea that came to me is:
1. Create a DataSource in your project and bind a grid to it (I'm not considering here custom cell renders, so we can focus on the approach).
2. Modify the DataSource (Including it's TableAdapter and DataSet) to return the given query. You can easily write your own sql-commands in SelectCommand (or other similar) property.
3. Voala! You have customized data displayed in your grid.

This is just a base idea. But, as for me, it's better to write the custom dataSource to achieve this (I guess, it would be more clean solution :)).

Antenka 274 Posting Whiz

Hello, dieucay555.
Well,this is what MSDN says:

Generic Static Method

C# allows you to define static methods that use generic type parameters. However, when invoking such a static method, you need to provide the concrete type for the containing class at the call site, such as in this example:

public class MyClass<T>
{

public static T SomeMethod(T t)

{...}
}
int number = MyClass<int>.SomeMethod(3);

Static methods can define method-specific generic type parameters and constraints, similar to instance methods. When calling such methods, you need to provide the method-specific types at the call site, either explicitly:

public class MyClass<T>
{
public static T SomeMethod<X>(T t,X x)
{..}
}
int number = MyClass<int>.SomeMethod<string>(3,"AAA");

Or rely on type inference when possible:

int number = MyClass<int>.SomeMethod(3,"AAA");

Generic static methods are subjected to all constraints imposed on the generic type parameter they use at the class level. As with instance method, you can provide constraints for generic type parameters defined by the static method:

public class MyClass
{
public static T SomeMethod<T>(T t) where T : IComparable<T>
{...}
}

And here's the actual page: An Introduction to C# Generics

Antenka 274 Posting Whiz

Hello.
How about using something like:

this.Controls[i].Enabled = !this.Controls[i].Enabled;

To change the state in both ways.

Antenka 274 Posting Whiz
Antenka 274 Posting Whiz

Hello, kavi4u.
The first solution that came up to me is playing a bit with a row background color and a Timer.
But I would suggest you better just highlight the row, rather than changing color. Cause blinking is pretty annoying (and imagine that in some cases the whole grid would be like a Christmas tree :D)

Antenka 274 Posting Whiz

> if the user does change this to C:\newpdflocation\
> the next time the user opens the app, the location will be C:\pdfs\ right?
Depends on how app determines the default path to save your pdf's.
If, you write this setting in a config-file, or a property-file when user changes the default path. And then you restore this setting on application start up. Then the new path would be loaded

Antenka 274 Posting Whiz

> i'm using so i know which index was selected, so the app knows which file to open..
ok, how about:

int index = listBox1.SelectedIndex;
if (index >= 0) {
}

SelectedIndex property is 0-based. So if user selects any item in list box, it would return the selected index. If nothing selected - it will return -1. IMO, this approach:
1. More readable.
2. Less complex.
3. More appropriate for this situation.
4. And, I suppose, has performance advantages (if not dig too deep: SelectedIndex - is a property, than returns a single value, stored in a listBox; IndexFromPoint - is a method that calculates a selected item index based on where user clicked. Sounds like it has more work to do ;)).

> will the path set by the user always reset to the original path, or will it be the path the user updates

Not sure, that I understand you correctly. But I'll take a shot :) You mean, if the Location of Documents would be changed?
If so - I suppose, you should treat your "My Documents" (in a folder browse dialog) as a shortcut. If user would change the folder, assigned to this shortcut - you'll see the contents of a newly-assigned folder.

If you need to remember the previous-opened location - sure, you can write it in a property-file. And then, for example, make a button "Recent Documents" to view it's content.

Antenka 274 Posting Whiz

Is this is that you're looking for: Microsoft HTML Help 1.4 SDK? :)

Antenka 274 Posting Whiz

Hello, walid86.
Firstly, try it out by yourself:
1. Find your local folder called "My Documents".
2. Right-click on it and go to tab "Location".
3. See what's in there ;)

Next, it would be great if you posted exception message (so I don't need to recreate all the behavior to reproduce your exception), cause Win32 Exception is too generalized term.

Ok, closer to your exception. I have a few questions:
1. Where do you get it? (exact line of code)
2. What data is in variables, on that line?
3. What's this for:

int index = this.listBox1.IndexFromPoint(e.Location);
if (index != System.Windows.Forms.ListBox.NoMatches)

it's look like it should be

if (listBox1.SelectedItem != null) {
}

or

if (listBox1.SelectedIndex >= 0) {
}

.. but that's just a thoughts in a loud .. maybe there's something that making you use IndexFromPoint .

Antenka 274 Posting Whiz

oh, c'mon! :) We'll get this to work, just put some effort (don't expect for a ready-made solution ;))

Antenka 274 Posting Whiz

So if you want it to execute after button click, why wont you put all this into a button click event, rather than in a numericUpDown1_ValueChanged? ;)

Antenka 274 Posting Whiz

Ok, we're one step closer! :)
Now, take a look at NumericUpDown Class and replace the "//THERE?????" with a value from your control.

Antenka 274 Posting Whiz

So what's the problem? I gave you a solution. You just need to pick up a number of times to repeat from your control and place your work at the certain place.

Antenka 274 Posting Whiz

Hello, lxXTaCoXxl.
Maybe this would help: C# Get user picture (Avatar)

Antenka 274 Posting Whiz

you mean, something like this?

for(int i = 0; i < REPEAT_TIMES; i++){
    //some work to repeat "REPEAT_TIMES" times 
}
Antenka 274 Posting Whiz

Hello, bbman.
What have you done so far? What's not working or what's giving you unexpected/undesired results?

Antenka 274 Posting Whiz

Hello, wcroome.
I've created a Test Application, and when I add Items to lBFirmware , rather than lBoxTest1 , I'm able to obtain the selected Index in the specified handler:

private void lBFirmware_SelectedIndexChanged(object sender, EventArgs e) {
     ListBox lb = sender as ListBox;
     int selectedIndex = lb.SelectedIndex; //all ok here ;)
}
Antenka 274 Posting Whiz

Hi, Johnrocks.
Take a look at this this project, maybe it would give you an idea on how to implement this functionality in WPF: Creating Custom Controls-Providing Design Time Support

Antenka 274 Posting Whiz

Hi, MORFIOUS.
As for a beginner, I would suggest you to take an easier project to learn from. The given project has variety things, that may be too complex and too confusing for a newbie. Start from "Hello world" and then build up things to it bit by bit .. that would make your education easy and comfortable ;)

Antenka 274 Posting Whiz

Hi, adobe71.
C# uses the backslash to escape characters, so "\\" is equal to \ literal, and "\" results in error, because you trying to escape the second quote and your string literal remains "unclosed".

You have 2 ways to go:
1. As you can see, double backslash results in a single one. So, to have \ ? you have to write \\ . 4 backslashes to result "\\" .. and so on.

2. You can use @ before your string literal, so the compiler won't try to get the control sequences from your string (based on the backslashes) and would treat your string same, as you write it (so the @"\" results into \ ).

ddanbe commented: Good advice! +14
Antenka 274 Posting Whiz

Mitja Bonca,
by unwrapping a part of loop, DaveTran lessen the cycle iterations in 2 times .. it's one of the known ways to optimize loops. It doesn't look too fancy, but it does optimize it.

Antenka 274 Posting Whiz

Hello, as a way of optimization, I'd suggest you to use static members. On every iteration of your cycle, you create again and again new instances of VertexFormat. You can create a static method in this class, so you could do something like that:

for (int i = 0; i < batchVertices.Length; ++i)
{
    batchVertices[i] = VertexFormat.getBatchVertices(vertices[i], normals[i], textureCoordinates[i]);
}

also taking the Length property out of the cycle:

uint len = batchVertices.Length;
for (int i = 0; i < len; ++i)
{
//...

Also I'd suggest you to try a descending loop (from i=len to 0). Especially, if you can test the time of it's execution (cause I don't have tools right now).

Ok, these probably the most influential .. I'll let you know, if I'd remember something else.

Antenka 274 Posting Whiz

Hi,
seems like it's the right time for recursion. There plenty of examples with it everywhere, so find it, take a shot to make something in your direction .. I'm here to help if you'll meet any dificulties :)

Antenka 274 Posting Whiz

Hi,
if you're talking about windows forms, then you might be interested in viewing this thread: How do i make MDI Parent & Child Forms in C#.NET as looks like as Master & Child Pages in ASP.NET?

Antenka 274 Posting Whiz

Momerath, thanks for correcting.
Probably, shouldn't multitask while posting :D

NewOrder commented: thanks for the help +0
Antenka 274 Posting Whiz

Hello, here's where your problem sits:
1. You define and array of interfaces

IchecherMove[ , ] checker

2. Then instantiate your array using Checker class

new Checker[9 , 9];

don't see the problem yet? :) ok, continuing ..

3. You're inserting some variables into it, including this:

checker[5, 8] = new King("BK");

So what the problem is .. when you define an array of interface type and instantiate it by derived class - everything is seems to be good (since the Chacker class is easily automatically can be converted to IchecherMove). But if you said, that your array would contain a King instance - it's arguing with you, since King can't be implicitly converted to Chacker (as you said at instantiation time).

this change might resolve the error:

IchecherMove[ , ] checker = new IchecherMove[9 , 9];

but you cannot instantiate interfaces. So we need some workaround .. as a way, I can suggest you to use List<T> :

//for 1-dimentional
List<ISomeInterface> list = new List<ISomeInterface>();

//and for 2-dimentional
List<List<ISomeInterface>> list = new List<List<ISomeInterface>>();

then to instantiate 1 row ..

list.Add(new List<ISomeInterface>());

and to add elements to this row ..

list[0].Add(new SomeClass());
//and
ist[0].Add(new SomeOtherClass());

where, ofcourse

class SomeClass:ISomeInterface{
}
	
class SomeOtherClass:ISomeInterface{
}

Good luck :)

Antenka 274 Posting Whiz

Exactly!
I was suggesting you to be a kinda photographer .. you're arranging the objects in some manner, then taking a shot, then making some permanent changes to your scene and making another shot. Good job! :)

Antenka 274 Posting Whiz

Hello,
yeah, static word might be confusing for some time. But it's not that hard .. Static members has a class level, rather then object one. To understand it better, let's look at example. Imagine a form for making cookies ..

Your form is your class. And your cookies are your objects.
If you change your form once, it would affect all the children .. so the line:

color = colorParam;

means "May all MyRectangle objects would have a given color" .. all the objects, no matter if they were created before or after this call (of course, this for the case, when the color variable is static).

Ok, and now, correct your code, knowing all this .. or ask if something left unclear :)

ddanbe commented: He! Nice explanation :) +8
kvprajapati commented: Helpful! +11
Antenka 274 Posting Whiz

> So is there a way to link from html into the database to display the image onto a page?
I don't know, if we're talking about same linking, but if you can have a template for an HTML-page and populate it with data from DataBase, when it's needed.

> Are you saying that i can prevent that somehow?
I wasn't doing this by my own, but I saw some time ago .. they people was looking the way to work with a PrintScreen button and image, that it makes (they were going to fill with a some color areas, which they want to hide .. or change the pic's). Anyway, that's a starting point for you - you may check it whenever you want at Google ;)

> You ended that sentence a little weird i dont know what you meant.
I just said that, cause you want to prevent all possible preventable ways of stealing image .. so I added my 2 cents to your list :)

Antenka 274 Posting Whiz

Can you attach your project, so I could take a look at it this evening?

Antenka 274 Posting Whiz

Ok, one more try .. my browser is playing tricks on me today, so pleas don't mark it solved till I finish my answer :D

Ok, one more source for the errors might be, if you haven't specified a namespace for your class. Here's an example for you, where similar thingy is used: Data Binding in WPF.

P.S. I may be wrong, cause I have no tools to test this .. so this is just a wild guess :)

Antenka 274 Posting Whiz

The one way I see is storing the images in a DataBase .. that would prevent average user from searching images locally.

P.S. FYI, one more way of stealing images is just making a PrintScreen in a biggest possible resolution .. so, you might want to consider and this case ;)

Antenka 274 Posting Whiz

Ooops .. too late :)

Antenka 274 Posting Whiz

...

Antenka 274 Posting Whiz

Oh, sorry for answering a wrong question :D Ok, how to deal with duplicates .. Ok, just a few thoughts ..
After getting the 2nd file name (the 1st has the same name), you may check if File.Exists.

Then you may want to include some difference into these files... here, I can suggest you 2 ways:
1. If you have plenty of files, you could append the files with " - Duplicate<N>" thingy as Windows does when copying a file in the same directory.
2. If you have not really much files, you may want to reorganize them .. e.g. putting them all together and moving to folders only those, who has duplicates. Here's an example.

Suppose, you have 2 jobs: JOB_001 and JOB_002. The first job has 3 files: File1.txt, File2.txt, File2.txt. The second one has 1 file, called File1.txt. So, in this case you may have this file structure:

C:
|--MyFolder
| |--JOB_001.File1.txt
| |--JOB_001.File2.txt
| | |--1
| | |--2
| |--JOB_002.File1.txt

Notice, that the "JOB_001.File1.txt" is a file, and the "JOB_001.File2.txt" is a folder.

Antenka 274 Posting Whiz

Ok, beforehand a small question: can't you take a control over filename generating and eliminate the insertion of illegal symbols into it's future name?

As a way to centralize your name converting, I would suggest to look at how they do the 8.3 format: How Windows Generates 8.3 File Names from Long File Names. That's just a start point to get your own method.

That's just a few tips to get into your problem .. tell me if it solves it, or what's wrong with it.

Antenka 274 Posting Whiz

Ok, in your case, you can't call the Login form as equipollent view as a view for a logged user. Let me provide you with an example .. there're could be views, if you'd telling about (strongly) different functionality for a few groups of users. E.g. like a customers and sellers, who're using same software for different purposes. So, we can talk about the views as a different sides of one medal.

In your case it's rather states, than views. User is making some steps to get somewhere .. in your case he's logging in to get e.g. to it's control panel.

Assuming that, it would have more sence in making a form for a logged user as a fully-functional view, and the login form as a, say "supporting tool". You can make it as a popup window, or a smoothing panel above the main view .. there plenty of different variants, just look at web logging mechanisms (it provides more different examples, rather than desktop software), and decide, what you want to have in your prog.

Antenka 274 Posting Whiz

There's an ASP.NET Forum, for ASP .NET questions. You have more chances to get the answer, when posting on a proper forum.

Antenka 274 Posting Whiz

What if you'd have 1 pannel for logged user and a separate popup window for a user to log in? Can the 'non-logged' user somehow interact with your system (except entering his/her login data)?

Antenka 274 Posting Whiz

Hello.
Please describe what your program should do (the basic algorythm/-s).

Just thing, I would like to notice is that the Program.cs usually contains code for application running, finishing: What common routines do you put in your Program.cs for C#.

And in the Form.cs - you have the code, supporting you form (and it's components) look and act ..

Antenka 274 Posting Whiz

Hello,
I might help if you would follow these forum rules, as "We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well."

So, tell me, please what you've already tried, what you can't understand or what troubles are you facing while coding this task?

Lusiphur commented: Good Post! +1
Antenka 274 Posting Whiz