|
[挑战自我] 欢迎任何C#疑难杂症(编写完整软件除外)
[复制链接]
|
|

楼主 |
发表于 9-2-2011 05:17 PM
|
显示全部楼层
想问一下。。。 为什么要写 _bitmap ,而不要直接写 bitmap ? 还有m_shouldPaint 而不要mshouldPaint?? ...
麟 发表于 9-2-2011 04:48 PM 
为什么不直接写bitmap
1)有一天,你project 超过10,000lines , 你要找某字眼(ctrl+shift+f) 的时候,你就知道痛苦是什么。。。
2)跟标准就没错。 |
|
|
|
|
|
|
|
发表于 9-2-2011 05:20 PM
|
显示全部楼层
本帖最后由 麟 于 9-2-2011 05:22 PM 编辑
结论是,现在不用放underscore也不要紧,是吗?当然放了比较好!!
如何换特别的cursor? 如何加特别的cursor进去 visual C# 2005??? |
|
|
|
|
|
|
|

楼主 |
发表于 9-2-2011 05:22 PM
|
显示全部楼层
结论是,现在不用放underscore也不要紧,是吗?
如何换特别的cursor? 如何加特别的cursor进去 visual C# ...
麟 发表于 9-2-2011 05:20 PM 
visual C#(VS IDE)支持unicode,你要打中文都可以
- private int 加法(int 分数1,int 分数2)
- {
- return 分数1+分数2;
- }
复制代码 |
|
|
|
|
|
|
|

楼主 |
发表于 9-2-2011 05:24 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 9-2-2011 05:26 PM
|
显示全部楼层
visual C#(VS IDE)支持unicode,你要打中文都可以
chrizyuen2 发表于 9-2-2011 05:22 PM 
cursor 哦?老鼠的箭头喔? |
|
|
|
|
|
|
|

楼主 |
发表于 9-2-2011 05:30 PM
|
显示全部楼层
回复 85# 麟
不能还得了?
- // hourglass cursor
- Cursor.Current = Cursors.WaitCursor;
- try
- {
- Thread.Sleep(5000); // wait for a while
- }
- finally
- {
- Cursor.Current = Cursors.Default;
- }
复制代码 |
|
|
|
|
|
|
|
发表于 9-2-2011 05:41 PM
|
显示全部楼层
这些是本来就有了的,我是说我们是否可以放自己画的图画为箭头?
因为,我写的painter里(好像是你写比较多),我加了一个“橡皮擦”,
我是否可以做成像 ms paint 里的“橡皮擦”?
“橡皮擦”模式时,箭头在白纸上是一个四方格。还可以加减“四方格”(箭头)的size。“橡皮擦”越大,“四方格”就越大。可能吗? |
|
|
|
|
|
|
|

楼主 |
发表于 9-2-2011 05:48 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 9-2-2011 06:06 PM
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 9-2-2011 06:17 PM
|
显示全部楼层
懂了!!
你很神
麟 发表于 9-2-2011 06:06 PM 
你问的东西还很基本。。。 |
|
|
|
|
|
|
|
发表于 9-2-2011 07:41 PM
|
显示全部楼层
本帖最后由 麟 于 9-2-2011 07:53 PM 编辑
- namespace WindowsApplication1
- {
- public struct IconInfo
- {
- public bool fIcon;
- public int xHotspot;
- public int yHotspot;
- public IntPtr hbmMask;
- public IntPtr hbmColor;
- }
-
- public partial class Form2 : Form
- {
- [DllImport("user32.dll")]
- public static extern IntPtr CreateIconIndirect(ref IconInfo icon);
-
- [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool GetIconInfo(IntPtr hIcon, ref IconInfo pIconInfo);
-
- public static Cursor CreateCursor(Bitmap bmp, int xHotSpot, int yHotSpot)
- {
- IconInfo tmp = new IconInfo();
- GetIconInfo(bmp.GetHicon(), ref tmp);
- tmp.xHotspot = xHotSpot;
- tmp.yHotspot = yHotSpot;
- tmp.fIcon = false;
- return new Cursor(CreateIconIndirect(ref tmp));
- }
- private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
- {
- this.Text = "Cursor Test";
- Bitmap E_bitmap = new Bitmap(140, 25);
- Graphics g = Graphics.FromImage(E_bitmap);
- using (Font f = new Font(FontFamily.GenericSansSerif, 20))
- g.DrawString("[]", f, Brushes.Green, 0, 0);
- this.Cursor = CreateCursor(E_bitmap, 5, 5);
-
- E_bitmap.Dispose();
- }
- }
- }
复制代码
我想在pictureBOX1里用那特别的cursor“[]”而已。
1。想问在 E_bitmap.Dispose() 过后,为什么cursor 不会换回去default cursor?
2。根据我的code,cursor不是应该只在pictureBOX1里用那特别的cursor“[]” 吗?
可是现在我的cursor一直都是“[]”,在pictureBOX1外也一样。 |
|
|
|
|
|
|
|
发表于 9-2-2011 08:03 PM
|
显示全部楼层
我忘了换- pictureBox1.Cursor = CreateCursor(E_bitmap, 5, 5);
复制代码 谢了,能了!! |
|
|
|
|
|
|
|
发表于 21-3-2011 04:55 PM
|
显示全部楼层
如何 create 一个 icon 在 deskstop 直接 run program?不用一直开c# ..谢! |
|
|
|
|
|
|
|

楼主 |
发表于 21-3-2011 06:25 PM
|
显示全部楼层
回复 93# 麟
汗。。。我劝你去找visual studio书看看。
1)Right click Project->Properties
2) Application -> Icons:
3) Rebuild target -> Release.
4) Project Folder\Bin\Release |
|
|
|
|
|
|
|
发表于 31-3-2011 04:25 PM
|
显示全部楼层
本帖最后由 木村拓栽 于 31-3-2011 04:37 PM 编辑
还有user enter date的部分也不会work(问题应该出现在application的 37)
麻烦你们了
application
- import javax.swing.JOptionPane;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- public class WorkerApp
- {
- public static void main(String args[])
- {
- DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
-
- //hourly worker and salesman object
-
-
- Salesman s=new Salesman();
- //declaration
- String name,id,hdate;
- double basicpay=0;
- double monthsale=0;
- double commission=0.0;
- String answer;
- double total=0.0;
- do{
- //input the worker information
- id=JOptionPane.showInputDialog("Enter worker ID:");
- name=JOptionPane.showInputDialog("Enter worker name:");
-
-
- do{
- hdate=JOptionPane.showInputDialog("Enter hire date:");
-
-
- if(!df.format(df).equals(hdate))
- {
- JOptionPane.showMessageDialog(null, " Input invalid\nPlease enter a positive integer.","Error input",JOptionPane.ERROR_MESSAGE);
- }
-
-
- }while(!df.format(df).equals(hdate));
-
-
- //input the hourly worker information
- basicpay=Double.parseDouble(JOptionPane.showInputDialog("Enter basic pay :"));
- monthsale=Double.parseDouble(JOptionPane.showInputDialog("Enter total sales:"));
- commission=Double.parseDouble(JOptionPane.showInputDialog("Enter commission :"));
-
-
-
- s.setMonthsale(monthsale);
- s.setBasicpay(basicpay);
- s.setCommission(commission);
- s.setId(id);
- s.setHdate(hdate);
- s.setName(name);
- total=s.CalculateSalary();//calculate hourly worker salary
-
- //if the user choose salesman object
-
-
- //display the worker id, name, and salary.
-
- JOptionPane.showMessageDialog(null,"Employee Name: "+s.getName()+
- "\nEmployee ID: "+s.getId()+
- "\nEmployee Hired Date: "+s.getHdate()+
- "\nBasic Salary: "+s.getBasicpay()+
- "\nCommission rate: "+s.getCommission()+
- "\nMonthly Sales: "+s.getMonthsale()+
-
- "\n\nNet Salary: "+total);
- //ask the user whether continue or not
- answer=JOptionPane.showInputDialog("Do you want to continue?(yes/no)");
- }while(answer.equals("yes"));//Whether the user decide when to stop
-
- }}
复制代码
class
- public class Salesman extends Worker
- {
- //declaration
- private double basicpay;
- private double monthsale;
- public double commission;
-
- //two overloaded constructors
- public Salesman()
- {
-
- basicpay=0.0;
- monthsale=0.0;
- commission=0.0;
- }
- public Salesman(String i,String n,String d,double basicpay,double monthsale,double commission)
- {
-
- this.basicpay=basicpay;
- this.monthsale=monthsale;
- this.commission=commission;
- }
- //mutator method
- public void setBasicpay(double b)
- {
- basicpay=b;
- }
- public void setMonthsale(double s)
- {
- monthsale=s;
- }
- public void setCommission(double c)
- {
- commission=c;
- }
- //accessor method
- public double getBasicpay()
- {
- return basicpay;
- }
- public double getMonthsale()
- {
- return monthsale;
- }
- public double getCommission()
- {
- return commission;
- }
- //implementation of abstract method
- //The salary for a salesman is calculated as the basic pay plus commission.
- //The commission is calculated based on the rate given for the sales made.
- public double CalculateSalary()
- {
- return basicpay+(monthsale*(commission/100.0));
- }
-
- }//end class Salesman
复制代码
subclass
- public abstract class Worker
- {
- //declaration
- protected String name;
- protected String id;
- protected double basicpay;
- protected String hdate;
-
-
- //two overloaded constructors
- protected Worker()
- {
- name=null;
- hdate=null;
- id=null;
- basicpay=0.0;
- }
- public Worker(String name,String hdate,String id,double basicpay)
- {
- this.name=name;
- this.hdate=hdate;
- this.id=id;
- this.basicpay=basicpay;
- }//end three-argument Worker constructor
- //mutator method
- public void setName(String n)
- {
- name=n;
- }
- public void setHdate(String d)
- {
- hdate=d;
- }
- public void setBasicpay(int s)
- {
- basicpay=s;
- }
- public void setId(String i)
- {
- id=i;
- }
- //accessor method
- public String getName()
- {
- return name;
- }
- public String getHdate()
- {
- return hdate;
- }
- public double getBasicpay()
- {
- return basicpay;
- }
- public String getId()
- {
- return id;
- }
- //abstract method
- public abstract double CalculateSalary();
- }//end class worker
复制代码 |
|
|
|
|
|
|
|

楼主 |
发表于 31-3-2011 04:38 PM
|
显示全部楼层
本帖最后由 chrizyuen2 于 31-3-2011 04:40 PM 编辑
尝试给个 namespace.
也加入classpath.
PS: 我随便说的,等我回家才用java testing. |
|
|
|
|
|
|
|

楼主 |
发表于 1-4-2011 07:16 PM
|
显示全部楼层
本帖最后由 chrizyuen2 于 1-4-2011 07:18 PM 编辑
回复 95# 木村拓栽
好不容易才install了eclipse.
下次java别post来这里, 我很难下台
public static boolean isValidDateStr(String date, String format) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(format); sdf.setLenient(false); sdf.parse(date);
} catch (ParseException e) { return false; }
catch (IllegalArgumentException e) { return false; }
return true;
}
http://www.rgagnon.com/javadetails/java-0099.html |
|
|
|
|
|
|
|
发表于 1-4-2011 09:47 PM
|
显示全部楼层
回复 木村拓栽
好不容易才install了eclipse.
下次java别post来这里, 我很难下台
publi ...
chrizyuen2 发表于 1-4-2011 07:16 PM 
忘了回复你,我成功了。。。。
功课今天就是due date了
不过还是要谢谢你。。 |
|
|
|
|
|
|
|
发表于 14-4-2011 03:12 AM
|
显示全部楼层
i wan put the value into radio button (value is in array)
请问要怎样放进radiobutton?? |
|
|
|
|
|
|
|

楼主 |
发表于 14-4-2011 09:22 AM
|
显示全部楼层
i wan put the value into radio button (value is in array)
请问要怎样放进radiobutton??
Iandhim 发表于 14-4-2011 03:12 AM 
一组的radiobutton, 其中只有一个可以被选择。 所以,大家都是用enum,从来不用array我觉得你是说checkbox吧。
loop你的array, 一个个set, 那样而已。
对了,那是怎样的array? int[]? string[], list<string>? |
|
|
|
|
|
|
| |
本周最热论坛帖子
|