
hi
how can move a rectangle over desktop area and taking picture.i want to be able to move the rectangle around pressing left mouse cursor and keep capturing pictures.
your help is greatly appreciated
abol







Hello
How to Get bound of full screen without taskbar c#
thanks





Rectangle r1 = Screen.PrimaryScreen.Bounds;
Rectangle r2 = Screen.PrimaryScreen.WorkingArea;
int tBarHeight = r1.Height  r2.Height; If the TaskBar is not autohidden then the r1.Height  r2.Height gives you the height of the TaskBar.
However, if your goal is to show a fullscreen Window, you should not really concern yourself with the TaskBar: see Raymond Chen's MS blog entry:[^].
Remember that the user may have docked the TaskBar to another side of the screen, and, that there could be multiple monitors in use.
"What Turing gave us for the first time (and without Turing you just couldn't do any of this) is he gave us a way of thinking about and taking seriously and thinking in a disciplined way about phenomena that have, as I like to say, trillions of moving parts.
Until the late 20th century, nobody knew how to take seriously a machine with a trillion moving parts. It's just mindboggling." Daniel C. Dennett






Hello would someone please help me with my program, I'm stuck all day with this thing. The program runs, but I think the problem is a logical error. The fraction 1/4 + 2 1/2 should be equal to 2 3/4 but the program's result is 2 3/8. Another thing is the expression 1/8 + 2 1/2 should be equals to 2 5/8. Please help me how to fix the codes. Thank you very much!
using System;
class FractionDemo
{
static void Main(string[] args)
{
Fraction firstfraction = new Fraction();
Fraction secondfraction = new Fraction();
firstfraction.Numerator = 1;
firstfraction.Denominator = 4;
secondfraction.Numerator = 1;
secondfraction.Denominator = 8;
secondfraction.WholeNumber = 2;
Fraction add = new Fraction();
add = firstfraction + secondfraction;
Console.Write("\n {0}/{1}", firstfraction.Numerator, firstfraction.Denominator);
Console.WriteLine(" + {0}/{1} = {2}/{3}", secondfraction.Numerator, secondfraction.Denominator, add.Numerator, add.Denominator);
Console.Write("\n {0}/{1}", firstfraction.Numerator, firstfraction.Denominator);
Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator,secondfraction.WholeNumber, add.WholeNumber, add.Numerator, add.Denominator);
Console.Write("\n {0}/{1}", firstfraction.Numerator, secondfraction.Denominator);
Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator, secondfraction.WholeNumber, add.WholeNumber, add.Numerator, add.Denominator);
Console.ReadLine();
}
public class Fraction
{
private int wholenumber;
private int numerator;
private int denominator;
public int WholeNumber
{
get
{
return wholenumber;
}
set
{
wholenumber = value;
}
}
public int Numerator
{
get
{
return numerator;
}
set
{
numerator = value;
}
}
public int Denominator
{
get
{
return denominator;
}
set
{
denominator = value;
if (denominator > 0)
{
denominator = value;
}
else
{
denominator = 1;
}
}
}
public Fraction(int wholenumber, int numerator, int denominator)
: this(numerator, denominator)
{
WholeNumber = wholenumber;
}
public Fraction(int numerator, int denominator)
{
WholeNumber = 0;
Numerator = numerator;
Denominator = denominator;
}
public Fraction()
{
WholeNumber = 0;
Numerator = 0;
Denominator = 1;
}
public int gcd()
{
int x = Numerator;
int y = Denominator;
int m;
if (x > y)
m = y;
else
m = x;
for (int i = m; i >= 1; i)
{
if (x % i == 0 && y % i == 0)
{
return i;
}
}
return 1;
}
public void Reduce()
{
int gcdNum = gcd();
if (gcdNum != 0)
{
Numerator = Numerator / gcdNum;
Denominator = Denominator / gcdNum;
}
if (Denominator < 0)
{
Denominator = Denominator * 1;
Numerator = Numerator * 1;
}
convertFraction();
}
public void convertFraction()
{
WholeNumber = Numerator / Denominator;
Numerator = Numerator % Denominator;
}
public static Fraction operator +(Fraction firstfraction, Fraction secondfraction)
{
int firstNum = (firstfraction.WholeNumber * firstfraction.Denominator) + firstfraction.Numerator;
int secondNum = (secondfraction.WholeNumber * secondfraction.Denominator) + secondfraction.Numerator;
Fraction Result = new Fraction();
Result.Numerator = firstNum * secondfraction.Denominator + firstfraction.Denominator * secondNum;
Result.Denominator = firstfraction.Denominator * secondfraction.Denominator;
Result.Reduce();
return Result;
}
}
}





Um.
No, it's your test code that is the problem:
Console.Write("\n {0}/{1}", firstfraction.Numerator, firstfraction.Denominator);
Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator, secondfraction.WholeNumber, add.WholeNumber, add.Numerator, add.Denominator);
Console.Write("\n {0}/{1}", firstfraction.Numerator, secondfraction.Denominator);
Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator, secondfraction.WholeNumber, add.WholeNumber, add.Numerator, add.Denominator);
Why are you printing the whole number in two places:
1/4 + 2 1/2 = 2 3/8
^
1/8 + 2 1/2 = 2 3/8
^
If you change the third parameter value to the Denominator:
Console.Write("\n {0}/{1}", firstfraction.Numerator, firstfraction.Denominator);
Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator, secondfraction.Denominator, add.WholeNumber, add.Numerator, add.Denominator);
Console.Write("\n {0}/{1}", firstfraction.Numerator, secondfraction.Denominator);
Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator, secondfraction.Denominator, add.WholeNumber, add.Numerator, add.Denominator);
Then the math is correct for the second line:
1/4 + 2 1/8 = 2 3/8
but still wrong for the third, since that isn't the sum you are doing!
1/8 + 2 1/8 = 2 3/8





the Math works, but displaying the data is corrupt.
use function like:
public override string ToString()
{
if (wholenumber == 0) return String.Format("{0}/{1}", numerator, denominator);
return String.Format("{0} {1}/{2}", wholenumber, numerator, denominator);
}
In fraction class definition for standard displaying a fraction.
to calculate an other fraction, you have to change the calculation parameters like:
Fraction firstfraction = new Fraction(1,8);
Fraction secondfraction = new Fraction(2,1,4);
Fraction add = firstfraction + secondfraction;
Console.WriteLine(firstfraction.ToString() + " + " + secondfraction.ToString() +" = "+ add.ToString() );
firstfraction = new Fraction(3,8);
secondfraction = new Fraction(2,1,6);
add = firstfraction + secondfraction;
Console.WriteLine(firstfraction.ToString() + " + " + secondfraction.ToString() +" = "+ add.ToString() );
Console.ReadLine();





Hello
I know I can change mouse cursor like that
this.cursor=cursor.hand
I need change it when my application is minimized by notify Icon.





Just to be clear, you want to change the cursor when the mouse is OVER the notify icon, or you want to change the cursor for the system after your application minimizes to the notify icon?





I want change the cursor for the system after application minimized to finish some task and return mouse to default..
thanks in advance





Changing the System cursor is usually a very bad idea, but I assume you have some very special purpose in mind ... so, if you have to do it:
You are going to have define your own cursor file, and hack the registry: [^].
"What Turing gave us for the first time (and without Turing you just couldn't do any of this) is he gave us a way of thinking about and taking seriously and thinking in a disciplined way about phenomena that have, as I like to say, trillions of moving parts.
Until the late 20th century, nobody knew how to take seriously a machine with a trillion moving parts. It's just mindboggling." Daniel C. Dennett





thanks for answer
I know that and I do not want change cursor from register and restart PC, I need For instance make trick on form maximize it and change the cursor make the form opacity 0.
so that change the cursor but when I move mouse does not focus
another window because the main form cover all screen.
I hope you understand me.





This goes directly against the principles of a multitasking operating system. Locking the machine while your application does something is really bad practice. Why do you want to do this?





Hello
How I can Retrieve all the controls of any window with their types and value.
please urgent
thanks





delphix5 wrote: urgent No, it's not urgent. And you could answer questions like this far faster by doing Google searches[^].
Veni, vidi, abiit domum





I searched but all what I found
List<Control> TotalControles = new List<Control>();
foreach (Control c in this.Controls)
{
TotalControles.Add(c);
}
How I change this.Controls to forgroundwindow.Controls
thanks in advance





You have already been given a link in this answer[^] to find the active window. If you follow all these links you will find lots of information to help you.
Veni, vidi, abiit domum






Sorry, pasted a response to a different question. Looks like you figured it out.
Veni, vidi, abiit domum





Hi all,
using online converters, the C# snippet
{
this.listView.Items.Add(new ListViewItem(dc.Line)
{<pre>
SubItems = {dc.Sign},
Tag = (object) dc
});
gets converted to
Me.listView.Items.Add(New ListViewItem(dc.Line) With { _
Key .SubItems = {dc.Sign}, _
Key .Tag = DirectCast(dc, Object) _
})
Ok, it's obvious that "Key" results in a Syntax Error in VB (amazing why all the converters I tried still put it). But after removing this, I have another error saying "The property 'SubItems' is ReadOnly". Also, IntelliSense doesn't give it as an option in VB, while it does in C#...
My question now: Would it be possible that the property isn't ReadOnly in C#, while it is in VB? Or has it been converted errorous?
Thank you in advance,
Mick





Converters are not perfect, some are better than others and I find the online ones to be the worst.
Why? Because the best converters will compile the code first, get down to MSIL and then convert back up to whatever you want. Online converters typically don't take compiled code so they attempt to do conversions with text replacements. The one you found isn't bad, but it made up the Key part somewhere, your conversion should be:
Me.listView.Items.Add(New ListViewItem(dc.Line) With { _
.SubItems = dc.Sign _
.Tag = dc _
})
(The original code the scoping around dc.Sign is unnecessary as well as casting dc to object).
So if you change it, I'm sure you'll see SubItems come back up in Intellisense, as well as Tag. Key is not a property of ListViewItem so that's why nothing comes up in Intellisense.





Hi Ron,
thank you for your answer. It's funny, but during my own attempts for a working solution I had put it just that way... and of course I'm aware of what you wrote about converters.
Unfortunately there's still something wrong, the error message stays ("The property 'SubItems' is ReadOnly."). And by just opening a new Sub which contains the line
Dim mylv As ListViewItem = New ListViewItem(dc.Line) With {.s...." you can see that Intellisense doesn't show "SubItems" then.
Do you have any further hints? I was afraid that the curly brackets (".Subitems = {dc.Sign}") have to be converted in a different way – but I had no clue what C# uses them for...





Try SubItems.Add(dc.Line).
The collection is readonly (same in C#, so I'm not sure how they are getting away with it in the original code). You can't assign something directly to it, so it should not work in the C# code either.
In C#, the brackets are scoping characters, and in the code you posted, unnecessary for anything.




