|
I need form with shaded background.
One way, I can achieve it by making image of shaded color and set it as backgroundImage
Second way, I can use System.Drawing.Drawing2D.LinearGradientBrush class with Form paint event
My question is which one is good practice from the performance point of view ?
Thanks in advance
Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim
So Smile Please
|
|
|
|
|
The difference will be trivial.
If you're generating your background image from within your program, you should consider that GDI will probably have better algorithms than you for doing this. Also if your form is resized, you'll have to recalculate your background at every resize. If the form is only displayed once, you'll take a performance hit from going to an outside file, or paging in the resource you're using for the background. (bigger executable = larger loading time).
But again, this are trivial performance differences.. Since you're displaying a form, I suspect that you want some user interaction. The user won't notice the difference.
|
|
|
|
|
Hi,
Great fan of the codeproject and the people who contribute.
I want to provide the ability to change a jpeg brightness and contrast.
Peoplae have suggested that I want a Window/Level approach. However I am not an Image processing guru (and I mean that). I did what any thickie might do and banged the Window/Level into google. This seems to comeback with cxImage and vtk.
So far, vtk seems to play nicely with Windows Forms and I have not investigated cxImage.
I am not a MS guru either (I know it gets worse), but know enough to create application can call unmanaged C++.
Regards,
Iain
|
|
|
|
|
Hi,All:
I have a function, want to copy the image of pictureBox1 to clipboard .
then I can copy the image to anywhere when press the right mouse button and choose paste of the system's own
menu.
I just wnat to imitate copy function of win7's PhotoViewer.
My English is not so good,but hope you can understand and give me a hand;
my code is here ,but it doesnot work. the paste item of the system's menu is not clickable after i click my
copy item;
<pre>
private void copyCToolStripMenuItem_Click(object sender, EventArgs e)
{
Clipboard.SetImage(this.pictureBox1.Image);
}</pre>
|
|
|
|
|
Hi everyone, Could you please help me regarding coding this program. I am a beginner and need your help
===============================================================================
There are 4 fish species in the river, which you may catch:
Australian Bass (Macquaria novemaculeata) - commonly less than 4 Kg; excellent eating, when less
than 2.5 Kg.
Short Finned Eel (Anguilla australis)- commonly less than 3 Kg; a good eating fish.
Eel Tailed Catfish (Tandanus tandanus) - Up to 6.8 Kg; excellent eating, when less than 4 Kg.
Gippsland Perch (Macquaria colonorum)- commonly less then 10 Kg; excellent eating when up to
6 Kg.
You should assume that:
· The chances to catch a fish of each of these four species are equal.
· Weights of fishes of the same species are distributed evenly and range from 0 to the
Maximal Weight. The value of Maximal Weight for each of the species is given above.
You start fishing with an empty basket. If you catch a fish with weight less than 500 g or greater
than the recommended excellent eating maximum, you release it. Otherwise put it in the basket.
Stop fishing immediately as soon as the total weight of all the fishes in the basket exceeds 15 Kg.
To model the situation, you are supposed to use the Random class’ Next method.
Fishes of different species must be implemented as objects of different classes, each extending an
abstract class Fish.
Whenever the branching logic is required to handle fish objects of different species, you must do it
polymorphically.
All weights appearing in the program are given in grams, e.g. instead of 3 Kg we will use 3000g.
Therefore use int variables to represent them.
1. Abstract class Fish. The class should have:
· A field – protected int weight + corresponding property.
· Abstract read-only properties – Name, ScientificName, and Acceptable.
· The method - public override string ToString().
|
|
|
|
|
hi guys,its my code
==============================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace assignmnet1
{
public abstract class Fish
{
protected int weight; //fields definition
/* definition of class property in general
get { return fish_name};
set {fish_name = value}; */
// Abstract read-only properties
public abstract string Name
{
get;
}
public abstract string ScientificName
{
get;
}
public abstract string Acceptable
{
get;
}
//method - public override string ToString().
public override string ToString()
{
return base.ToString();
}
====================================================
the next question is
Classes AustralianBass, ShortFinnedEel, EelTailedCatfish, GippslandPerch.
Class AustralianBass should contain the following members:
· public const int MAX_WEGHT = 4000;
· The default constructor public AustralianBass() should create an instance of the class with
the weight taking its value randomly from 0 to MAX_WEIGHT.
· Implementations for the properties Name, ScientificName, and Acceptable.
· The method - public override string ToString().
how do I supposed to impelement this class?
|
|
|
|
|
That looks like a good start; what's the problem?
|
|
|
|
|
its the one I have done, so far; I mean part one and two
=========================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace assignmnet1
{
public abstract class Fish
{
protected int weight; //fields definition
/* definition of class property in general
get { return fish_name};
set {fish_name = value}; */
// Abstract read-only properties
public abstract string Name
{
get;
}
public abstract string ScientificName
{
get;
}
public abstract string Acceptable
{
get;
}
//method - public override string ToString().
public override string ToString()
{
return base.ToString();
}
public class AustralianBass : Fish
{
public AustralianBass()
{
Random random = new Random();
weight = random.Next(0, Max_Weight);
}
public const int Max_Weight = 4000;
public override string Name
{
get { throw new NotImplementedException(); }
}
public override string ScientificName
{
get { throw new NotImplementedException(); }
}
public override string Acceptable
{
get { throw new NotImplementedException(); }
}
}
public class ShortFinnedEel : Fish
{
public const int Max_Weight = 3000;
public override string Name
{
get { throw new NotImplementedException(); }
}
public override string ScientificName
{
get { throw new NotImplementedException(); }
}
public override string Acceptable
{
get { throw new NotImplementedException(); }
}
}
public class EelTailedCatfish : Fish
{
public const int Max_Weight = 6800;
public override string Name
{
get { throw new NotImplementedException(); }
}
public override string ScientificName
{
get { throw new NotImplementedException(); }
}
public override string Acceptable
{
get { throw new NotImplementedException(); }
}
}
public class GippslandPerch : Fish
{
public const int Max_Weight = 10000;
public override string Name
{
get { throw new NotImplementedException(); }
}
public override string ScientificName
{
get { throw new NotImplementedException(); }
}
public override string Acceptable
{
get { throw new NotImplementedException(); }
}
}
==================================================================================================
the next part is
Class Fishing. The class should have three methods:
· public static void Fishing() – The method imitates a fishing process. It randomly creates
fishes of different species with random weights, and if a fish is acceptable (i.e. is heavier
than 500 g and still edible) adds the fish in the basket, i.e. writes the fish object to the
basket.dat file . The process continues while the total weight of the fishes in the basket is
less than 15000 g. (15 Kg). To write fish objects to the file you should use Serialize()
method of the BinaryFormatter class (notice, that the Fish class should have [Serializable]
attribute).
public static void ReadBasket() – the method opens the basket.dat file, reads the objects
from the file and prints them in the terminal window.
its the problem, I don't know who to impelement it.
|
|
|
|
|
hello,
I need your help. is any one can help me,please?
|
|
|
|
|
<click>
I'm sorry, but the Western World is closed for the weekend, and will not be available to help you with your homework until tomorrow.
Please leave your name, number and a message describing the actual problem you are having after the tone, and we will try to get back to you when we return to the office on Monday.
<BEEP>
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
As far as I can ascertain, Name and ScientificName need to return a hardcoded string in implementing classes.
In your abstract Fish class, Acceptable should be a bool . To implement it you need to test the values you've been given for this species against the weight.
namespace Assignment1
{
public abstract class Fish
{
protected int weight;
public abstract bool Acceptable { get; }
public abstract string Name { get; }
public abstract string ScientificName { get; }
public int Weight
{
get { return weight; }
}
public override string ToString()
{
return Name;
}
}
}
using System;
namespace Assignment1
{
public class AustralianBass : Fish
{
public const int MAX_WEGHT = 4000;
public AustralianBass()
{
Random random = new Random();
weight = random.Next(0, MAX_WEGHT);
}
public override bool Acceptable
{
get { return weight >= 500 && weight < 2500; }
}
public override string Name
{
get { return "Australian Bass"; }
}
public override string ScientificName
{
get { return "Macquaria novemaculeata"; }
}
}
}
Do similar for the other classes and you will be good to go for the next parts.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Member 4674360 wrote: its the problem, I don't know who how to impelement it.
There's an example on MSDN that shows how to read a file[^].
Looks something like this;
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
I are Troll
|
|
|
|
|
thanks a lot for your help.
I implement the 3rd part but I faced with a problem. in part 3, I create a random number and random weight. I check them with mentioend values but the problem is how I should access to the properties of the class.
this is part3,
================================================
fishes of different species with random weights, and if a fish is acceptable (i.e. is heavier
than 500 g and still edible) adds the fish in the basket, i.e. writes the fish object to the
basket.dat file . The process continues while the total weight of the fishes in the basket is
less than 15000 g. (15 Kg). To write fish objects to the file you should use Serialize()
method of the BinaryFormatter class (notice, that the Fish class should have [Serializable]
attribute).
==================================================
this is my code
public class fisshing
{
public static void fishing()
{
int basket = 0;
Random rand = new Random(0,4);
Random weight = new Random.next(0,10000);
do
{
switch (rand)
{
case 1:
if (weight > 500 && weight < 2500)
{
basket = basket + weight;
}
case 2:
if (weight > 500 && weight < 3000)
{
basket = basket + weight;
}
case 3:
if (weight > 500 && weight < 4000)
{
basket = basket + weight;
}
case 4:
if (weight > 500 && weight < 6000)
{
basket = basket + weight;
}
}
} while basket => 15000;
}
}
|
|
|
|
|
hello,
is my code right regarding the requirement?
|
|
|
|
|
Member 4674360 wrote: is my code right regarding the requirement?
You're going in the right direction, just keep working at it
For starters, I modified your code so that it compiles;
int basket = 0;
Int32 rand = new Random().Next(0,4);
Int32 weight = new Random().Next(0,10000);
do
{
switch (rand)
{
case 1:
if (weight > 500 && weight < 2500)
basket = basket + weight;
break;
case 2:
if (weight > 500 && weight < 3000)
basket = basket + weight;
break;
case 3:
if (weight > 500 && weight < 4000)
basket = basket + weight;
break;
case 4:
if (weight > 500 && weight < 6000)
basket = basket + weight;
break;
}
} while (basket >= 15000);
- There's a
break statement at the end of each case
- Changed "rand" and "weight" to
int , assuming you want to work with the numbers
- Changed the order of the operators in the
while loop; >= works, => doesn't compile (would be interpreted as a lambda-statement).
As your requirements go; I don't see a fish-class, nor a BinaryFormatter[^]. How about something like this;
using System.Runtime.Serialization.Formatters.Binary;
[Serializable()]
public class MyFish
{
public int Weight { get; set; }
public MyFish()
{
Weight = new Random().Next(0,10000);
}
}
I are Troll
|
|
|
|
|
But why have four different case 's? They all do the same thing as long as the weight is more than 500 and less than 6000 (and that is - adds the weight to the basket ). Maybe I've missed something in the instruction, but I would write:
while (basket <= 15000)
{
basket += weight;
}
|
|
|
|
|
Calla wrote: But why have four different case's?
Dunno, it was in the original code - but you're right
I are Troll
|
|
|
|
|
I reckon there i a problem in part3, cause the condition include all. for instance if a fish is 1000g, it can be all four condition.
please read part3,
=======================
Part3:
The method imitates a fishing process. It randomly creates
fishes of different species with random weights, and if a fish is acceptable (i.e. is heavier
than 500 g and still edible) adds the fish in the basket, i.e. writes the fish object to the
basket.dat file . The process continues while the total weight of the fishes in the basket is
less than 15000 g. (15 Kg). To write fish objects to the file you should use Serialize()
method of the BinaryFormatter class (notice, that the Fish class should have [Serializable]
attribute).
|
|
|
|
|
Hi
i'm looking for good library or source code which implement send/receive sms via gsm modem. i found this article[^] and it's good, but unfortunately it does not support delivery event handler when sms deilvered. can anybody help me and provide better library or source code which support more events ?
thanks in advance
|
|
|
|
|
Do you want to use any thirdparty api / write your own?
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Hi
no, i don't want to use any third party controls, i want to create my own.
can u help me ?
|
|
|
|
|
Hi Friends,
I am working on a ERP windows Project c#, that should support both Oracle & Sql Server. Now I suppose to write procedures for both the databases. because we don't want inline queries in our codes. I feel this will cause maintanance issue in future as software size grows.
I heard, Entity Framework & Linq to DB will affect application performance when compare to stored Procedures.
Please advise me, what is the best solution. That should solve performance as well as SQL & Oracle support.
Thanks in Advance
Anand
|
|
|
|
|
The application should neither know nor care what database is in use. This is where the Data Access Layer shines -- it separates the application from the database. I prefer to have a database-agnostic framework (such as my DatabaseAccessor[^]) upon which to build the DAL. You can then build flexibility into your DAL to deal with the various flavors of SQL (which is a step I haven't bothered to take yet myself).
Given a proper DAL, the application developers won't know whether you are using stored procedures or not.
anand kumar m wrote: Now I suppose to write procedures for both the databases. ... I feel this will cause maintanance issue in future as software size grows.
Yes, it will. The queries have to go somewhere, and there are differences in how SQL is implemented by various vendors. For ease of maintenance, the multiple versions of a particular query should be kept close together, in one file if possible. This tends not to be the case when using stored procedures. It's one of the things I like least about stored procedures (I don't use stored procedures anymore).
anand kumar m wrote: Entity Framework & Linq to DB
Don't those only work with SQL Server? Either way, I avoid them.
The old ways are the best ways.
P.S. As to performance -- you still need to write good SQL and use Connections, Commands, and Parameters effectively.
Most "performance" problems are caused by poor understanding of the tools being used.
modified on Saturday, April 24, 2010 1:18 PM
|
|
|
|
|
hi bloggers,
I have been trying to visualize my gestures through MS chart graph, for instance using wiimote accelerometer to draw a shape of the number(0-9), when I try to make 0,6,8,9 the shape is not drawn completely rather the coordinates spreads on the other side.... currently Im calculating velocity and distance from the accelerometer values(x,y,z) and then plot distance values to MSCHART spline graph....
give me some suggestions or solutions how can I correct my code...
this is the snippet of the code which Im trying to plot on the graph
private void show()
{
for (int i=1; i<=size-1; i++)
{
VX[i] = VX[i - 1] + (XA[i] * RecordTimer.Interval * 10.0);
VY[i] = VY[i - 1] + (YA[i] * RecordTimer.Interval * 10.0);
VZ[i] = VZ[i - 1] + (ZA[i] * RecordTimer.Interval * 10.0);
}
for (int i=0; i< size-1; i++){
DX[i] = VX[i] * RecordTimer.Interval;
DY[i] = VY[i] * RecordTimer.Interval;
DZ[i] = VZ[i] * RecordTimer.Interval;
}
for (int i=1; i<=size-1; i++)
{
DisX.Text += string.Format("{0: 0.00000000}\n", Convert.ToInt32(DX[i]).ToString());
DisY.Text += string.Format("{0: 0.00000000}\n", Convert.ToInt32(DY[i]).ToString());
DisZ.Text += string.Format("{0: 0.00000000}\n", Convert.ToInt32(DZ[i]).ToString());
}
for (int i=1; i<=size-1; i++) {
double x = DX[i];
double y = DY[i];
double z = DZ[i];
CXZ.Series["XZ"].Points.AddXY(x, -z);
CXY.Series["XY"].Points.AddXY(x, -y);
CYZ.Series["YZ"].Points.AddXY(y,-z);
}
}
suggestions are anxiously required.....
modified on Saturday, April 24, 2010 9:42 AM
|
|
|
|
|
Hi,
if RecordTimer happens to be a System.Windows.Forms.Timer you are overly optimistic about its accuracy; I suggest you read Timer surprises, and how to avoid them[^] and switch to another timing mechanism (Multimedia timer, or Stopwatch).
PS: check the code snippet shown, it is unreadable, lacking formatting and the necessary HTML and smiley escaping.
|
|
|
|
|