|
thank u very much for helping me to find myself!!!
i really believe i find the answere in MSDN but first i got to have it!
Thanx
|
|
|
|
|
hi,
i want to know how can i make a fixed digits conversion like below C printf() function in c#?
CString a;
a.format("%02d, %02d, %02d", 1, 12, 123);
thanks,
jim
|
|
|
|
|
|
Hi everyone, does anyone know how to rotate a UserControl? Or, if there is no method to do this, is there any other way to rotate whatever is inside the UserControl (perhaps by rotating the region or something).
thanks in advance,
Lisa
|
|
|
|
|
You can't rotate the control itself, but you can rotate its contents using Graphics.Transform.Rotate() .
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hi, jdunlap,
I want to find some example of rotating image as well.
I have an image drawn by Graphics.drawImage(), and now want to rotate it at 90, 180 , 270.
I use graphic.DrawImage(img, p) where p is the position of image.
how can I rotate it to 90 ?
Or, do you have any example of this?
Thank you
|
|
|
|
|
Point[] destinationPoints = {
new Point(200, 20), // destination for upper-left point of
// original
new Point(110, 100), // destination for upper-right point of
// original
new Point(250, 30)}; // destination for lower-left point of
// original
Image image = new Bitmap(YOUR_IMAGE_NAME);
// Draw the image unaltered with its upper-left corner at (0, 0).
e.Graphics.DrawImage(image, 0, 0);
// Draw the image mapped to the parallelogram.
e.Graphics.DrawImage(image, destinationPoints);
You'll have to make calculations of destination poins for different angles.
|
|
|
|
|
Oh... great. Thank you very much WiB,
I'm now understand how to do. I have tried to use Point array as destinationPoints before, but I don't know the 3 points are the original corner of the image. ^_^..
THank you very much.
|
|
|
|
|
|
I am designing a user control. There is one property that I would like to hide from the Property box at design time. Is there a way to do this? I would like to use the convenience of the property set method so it is easy to set during runtime, but prevent setting it to anything at design time.
Updated: Of course I found the answer just after posting, set an attribute above the property's code:
[Browsable(false)]
|
|
|
|
|
I have been experiencing some interesting side effects with user controls and transparency, this particular problem is creating havoc in an application I am developing in C#.NET. If there is anyone who knows of a way around the problem (other that not over lapping controls), I would be very grateful.
Steps to create the problem.
1) Insert two controls onto a form a button and a label.
2) Set the background of the form to have an image (any image, this is simply to make the issue more visible).
3) Set the background color of the label to Transparent.
4) Drag the label over the Button and when the transparent portion moves over the button, you will see the background image and not the button.
Maybe the Transparent color is miss-named and it should be called the XRay Color
Am I doing something wrong or is it too much to expect that a transparency should only show the control under the transparent section rather than look straight through all the controls down to the background.
This[^] picture shows the effect of this.
Cheers,
Simon
"Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
animation mechanics in SVG (my first abstract photo)
|
|
|
|
|
Hi Everyone,
Lets say I have a collection class (MyClassCollection ) that holds instances of another class I've defined (MyClass ). If I serialize the collection class (using a BinaryFormatter ) and then deserialize it later will I get back the exact same information? For example if I had the following line:
MyClassCollection[0] = new MyClass ("Hello"); If I then serialize and deserialize the MyClassCollection will this work as expected (assuming Name is a member of MyClass that gets it's value from the constructor):
string str = MyClassCollection[0].Name;
- monrobot13
|
|
|
|
|
Serialization and deserialization of MyClassCollection (and the instances of MyClass that it holds) will work properly so long as you apply SerializableAttribute to both MyClassCollection and MyClass . If either class is not marked with SerializableAttribute you will receive a SerializationException when you try to call BinaryFormatter.Serialize .
The following demonstrates the serialization of your classes:
using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
[Serializable()]
public class MyClass {
public MyClass(string name) {
_Name = name;
}
public string Name {
get { return _Name; }
}
private string _Name;
}
[Serializable()]
class MyClassCollection {
public MyClassCollection() {
_Items = new MyClass[4];
}
public MyClass this[int index] {
get { return _Items[index]; }
set { _Items[index] = value; }
}
public override string ToString() {
string result = "MyClassCollection {";
for (int i = 0; i < _Items.Length; i++)
result += (i != 0 ? ", " : "") + (_Items[i] != null ? _Items[i].Name : "[null]");
result += "}";
return result;
}
private MyClass[] _Items;
[STAThread]
static void Main(string[] args) {
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream stream = new MemoryStream();
MyClassCollection col = new MyClassCollection();
col[0] = new MyClass("Item #1");
col[2] = new MyClass("Item #2");
Console.WriteLine(col);
formatter.Serialize(stream, col);
col = null;
stream.Seek(0, SeekOrigin.Begin);
col = (MyClassCollection)formatter.Deserialize(stream);
stream.Close();
Console.WriteLine(col);
Console.Read();
}
}
Output:
MyClassCollection {Item #1, [null], Item #2, [null]}
MyClassCollection {Item #1, [null], Item #2, [null]}
Hope this helps.
|
|
|
|
|
Kastro wrote:
Hope this helps
That helps a lot. Thanks for the help.
- monrobot13
|
|
|
|
|
I get a StackOverFlowException when I try to assign values in an array to properties in a struct. Not sure what is going on, any one have any ideas? Here is the code:
//Main Class
public class BloombergEq
{
TradeData td = new TradeData();
public BloombergEq()
{
}
public ArrayList ExecuteTradeData()
{
string fileName = @"D:\CSharp\file2.txt";
ArrayList rows = new ArrayList();
try
{
FileStream bbFile = new FileStream(fileName, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(bbFile);
//Move the file cursor down 4 lines to get to start of data
sr.ReadLine();
sr.ReadLine();
sr.ReadLine();
sr.ReadLine();
while (sr.Read() != -1)
{
object[] tokens = new object[12];
int tokenIndex = 0;
string row = sr.ReadLine();
Regex r = new Regex("\\s(?=([^\"]*\"[^\"]*\")*(?![^\"]*\"))"); //matches all white space characters
//splits line at every white space
//disregards whitespaces & saves non-whitespace char
for (int i=0; i<=r.Split(row).Length-1;i++)
{
if(r.Split(row).GetValue(i).Equals(""))
{
continue;
}
else
{
tokens[tokenIndex] = r.Split(row).GetValue(i);
tokenIndex++;
}
} // for
Console.WriteLine(tokens[0]);
THIS IS WHERE THE ERROR IS THROWN
td.orderTime = tokens[0];
td.transactionType = (string)tokens[1];
td.ticker = (string)tokens[3];
td.price = (float)tokens[4];
td.fillQ = (float) tokens[6];
td.account = (string)tokens[7];
td.broker = (string)tokens[8];
td.status = (string) tokens[9];
rows.Add(td);
} //while
}
catch (Exception e)
{
Console.WriteLine(e);
}
return rows;
} //ExecuteTradeData
public static void Main(string[] args)
{
BloombergEq eq = new BloombergEq();
eq.ExecuteTradeData();
}
} //BloombergEq
//struct
public struct TradeData
{
public object orderTime
{
get
{
return orderTime;
}
set
{
orderTime = value;
}
}
public string transactionType
{
get
{
return transactionType;
}
set
{
transactionType = value;
}
}
public string ticker
{
get
{
return ticker;
}
set
{
ticker = value;
}
}
public float price
{
get
{
return price;
}
set
{
price = Convert.ToSingle(value);
}
}
public float fillQ
{
get
{
return fillQ;
}
set
{
fillQ = Convert.ToSingle(value);
}
}
public string account
{
get
{
return account;
}
set
{
account = value;
}
}
public string broker
{
get
{
return broker;
}
set
{
broker = value;
}
}
public string status
{
get
{
return status;
}
set
{
status = value;
}
}
} //struct
|
|
|
|
|
your problem is the way you wrote the properties.
//struct
public struct TradeData
{
public object orderTime
{
get
{
return orderTime;
}
set
{
orderTime = value;
}
}
this is a c# translation of the resulting IL created for that:
public Object get_orderTime() {
return get_orderTime();
}
public set_orderTime(Object value) {
set_orderTime(value);
}
both of these will obviously recurse until you stackoverflow.
either make those properties into fields, or provide internal storage for the public property.
|
|
|
|
|
|
Thanks for the response Andy. What do you mean by providing internal storage for public property? Thanks again.
|
|
|
|
|
something like this:
public struct TradeData {
public object OrderTime {
get {
return orderTime;
}
set {
orderTime = value;
}
}
private Object orderTime;
}
|
|
|
|
|
I'm creating a windows application.
Trough my main menu I want to toggle between diferent views using only one frame..
How can I do this using forms??
Please help!!
|
|
|
|
|
You could try using Panel s. Panel s are just container controls that host other controls. You would make a panel and populate it with the buttons, listboxes, etc for the first view. Then make a panel for the second view, populate that and so on. Then using your menus you can make each panel visible or invisible depending on the menu item clicked.
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
We are working on creating two new newsgroups to discuss the ECMA/ISO standards for C# and the CLI. The first step in doing so is submitting a request for discussion, to see if there is interest in a group. If there is sufficient interest, a vote will be held later.
If you would like to have these groups, please respond to the posts in the news.groups newsgroups. You can also do this through google at:
C#
http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&oe=UTF-8&group=news.groups&selm=1057623961.29376%40isc.org
CLI
http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=1057624363.29389%40isc.org&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26group%3Dnews.groups
Thanks
Eric
EricGu@microsoft.com
|
|
|
|
|
|
Hello,
I have a problem that I'm still stuck on. I have a form with a pair of user controls. The first user control is displayed when the program runs. When a button is clicked, I want the first user control to remove itself from the form, and the second user control to appear.
However, when I write the code for the button, all I can do is get the first UC to disappear; the second UC never draws itself.
Someone earlier told me to instantiate an instance of the second user control in the form's constructor, and add this line into the form:
this.Parent.Controls.Add(newUserControl);
However, this still doesn't solve the issue of the first user control not knowing about the second user control. Can someone point me in the right direction?
|
|
|
|
|
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
this.button1.Location = new System.Drawing.Point(64, 112);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
this.button2.Location = new System.Drawing.Point(160, 112);
this.button2.Name = "button2";
this.button2.TabIndex = 1;
this.button2.Text = "button2";
this.button2.Visible = false;
this.button2.Click += new System.EventHandler(this.button2_Click);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button2,
this.button1});
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
private void button1_Click(object sender, System.EventArgs e)
{
button2.Visible = true;
button1.Visible = false;
}
private void button2_Click(object sender, System.EventArgs e)
{
button2.Visible = false;
button1.Visible = true;
}
}
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|