|
Somewhere in the Microsoft guidelines it sure is stated one should not use properties to return changing data; properties should be pretty constant, such as Environment.NewLine . One of the wildest but acceptable exceptions being DateTime.Now .
When real data is to be offered, a method should be used; that is why Directory.GetFiles() and Random.Next() are methods and not properties.
|
|
|
|
|
Luc Pattyn wrote: Somewhere in the Microsoft guidelines it sure is stated one should not use properties to return changing data; properties should be pretty constant,
Yes, that's CA rule #1024[^].
I used a property for ease of understanding. It could of course be replaced by the method .Value() .
/ravi
|
|
|
|
|
You don't need ToString with WriteLine.
|
|
|
|
|
Imho, it's good practice to use ToString() for at least 2 reasons: (1) it provides deterministic formatting and (2) it takes advantage of a custom object's display format. (1) makes it easier to perform regression testing and (2) allows meaningful information to be displayed vs. just the object's fully qualified type name.
/ravi
|
|
|
|
|
What do you think WriteLine will do if you leave it off?
|
|
|
|
|
You're right in saying you don't need to ToString() an int (and many other types) because WriteLine() will display an acceptable form of the type without it.
But you seem to have missed the point I was trying to make.
/ravi
|
|
|
|
|
You may have missed the point <i>I</i> was trying to make...
Ravi Bhavnani wrote:
WriteLine() will display an acceptable form of the type without it.
... by calling ToString.
|
|
|
|
|
Yes, you are correct. As I said in my previous post.
/ravi
|
|
|
|
|
hi everyone, When debugger works, it comes to a procedure, enters in, runs a few lines of code and goes out without completing whole procedure and finishes debugging without any error. Your valuable comments are welcomed, thanks
|
|
|
|
|
Is it an OnPaint or something like that? There are sneaky hidden try/catches around some the of WinForms methods that "eat" your exceptions before you see them (you can work around that a bit by putting a try/catch around the code and put a breakpoint in the catch)
|
|
|
|
|
|
If you're debugging a multithreaded app, this could happen.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I have a custom control containing a movable Thumb (similar to ScrollBar Thumb), drawn using a System.Drawing.Rectangle which can be clicked and dragged etc
As I am showing ToolTips for other controls within this custom control, I would like to be able to show a similar style ToolTip for the Thumb (and other similar pseudo controls) .
My understanding is that as the Thumb is not based on Control, the ToolTip class cannot be used to do this.
Do I need to make my Thumb a Thumb class based on Control, to attach ToolTips?
Is there a way to attach a ToolTip to Rectangles etc in another fashion?
Thanks for any help or suggestions.
AussieLew
PS.. I have done a fair bit of searching on this and have found nothing helpful even though I thought it would be a common question.
|
|
|
|
|
When developing your application you need to keep aware of what occurs in other applications you use. The scroll bar (or Thumb as you call it) is just a slider within another containment object. A tooltip is useful for the data container but really useless for the scrollbar. If you do need a tooltip for that, then the users have NO PC experience what-so-ever and the problem should be address via training instead of an improper use of tooltips.
|
|
|
|
|
The custom scrollbar(not based on Scrollbar for various reasons) is being used on a control in a situation where the user may view it as a position indicator only. As I have provided ToolTips for all other controls (ToolButtons, TextBoxes etc) within this control, in the interests of consistency, I thought it proper to also provide a ToolTip for non-control based items that can provide actions.
All this aside though, provision of a ToolTip for non-control based items must be a common need surely.
Examples that spring to mind are:
.. A drawing or cad situation where you could provide instant feedback of line & shape properties.
.. Flowcharting and Statistical charts etc where hovering over a particular area would provide additional detail.
.. Breaking up a graphic eg a Map, to provide additional info for various segments, States or legends etc.
.. Inline Text within a document, where intellisense type information could be provided on mousehover.
|
|
|
|
|
How can I have a page folding (page turning) effect in WinFom so it wil be an image at the button which use will click the it will be an effect like page is turning?
|
|
|
|
|
|
Hello everyone,
I have a C# application that allows users to write some plugins. I have an app that I have written in C++ and OpenGL and I want to write a plugin that encapsulates that app.
So, what I wanted to do was create an unmanaged C++ DLL which I could load from my C# plugin and have methods to initialize OpenGL and handle all the drawing etc.
I have an exported method init_gl that seems to work. All it does is initialize OpenGL and creates and enables the rendering context.
How do I handle all the paint events etc.? Normally, in a pure C++/OpenGL app, I would have a message loop that would call the animation code.
My question is how can I delegate the resize, paint events or any other message that might be of interest to the DLL from my C# app. Also, is it a good way to do this? My C++/OpenGL app is quite complex and rewriting it all in C# is not really an option.
So, at the moment, I create my winform and the host control and pass its handle to the DLL and call OpenGL methods on it.
Would really appreciate any help.
Thanks,
keith
|
|
|
|
|
Keith,
Your wrapper would hold the responsibility of providing all of that functionality...but as you probably are aware of...it will take some work.
First you should define all of the methods that you want exposed (such as Resize) and the parameters that are required.
Then implement each of those methods in your wrapper and have those methods call into your C++ DLL. Your wrapper basically becomes a means of marshalling the C# calls into the C++ applications.
Once you are done with it consuming it would be just like consuming any C# library.
|
|
|
|
|
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?
|
|
|
|