image
 1: class Operation
 2: {
 3: public virtual double operation(int x, int y)
 4: {
 5: return x * y;
 6: }
 7: }
 8: class Addition : Operation
 9: {
 10: public override double operation(int x, int y)
 11: {
 12: return (x + y);
 13: }
 14: }
 15:  
 16: private void button1_Click(object sender, EventArgs e)
 17: {
 18: if (comboBox1.SelectedIndex == 0)
 19: {
 20: Operation multiplication = new Operation();
 21: txtResult.Text = multiplication.operation( Convert.ToInt32(txtNum1.Text.Trim()), Convert.ToInt32(txtNum2.Text.Trim() )).ToString();
 22: }
 23: else
 24: {
 25: Operation addition = new Addition();
 26: txtResult.Text = addition.operation(Convert.ToInt32(txtNum1.Text.Trim()), Convert.ToInt32(txtNum2.Text.Trim())).ToString();
 27: }

28: }

me1237guy 發表在 痞客邦 留言(0) 人氣()

image
Define an abstract class named Poly
 1: public abstract class Poly
 2: {
 3: private int r = 0;
 4: public int R
 5: {
 6: get
 7: {
 8: return r;
 9: }
 10: set
 11: {
 12: r = value;
 13: }
 14: }
 15: public abstract double Area();
 16: }

me1237guy 發表在 痞客邦 留言(0) 人氣()

image
相關文章:
C# Delegates with Anonymous Methods(匿名方法)and Named Methods(具名方法)
 
框架如下

me1237guy 發表在 痞客邦 留言(0) 人氣()

image

 1: class test
 2: {
 3: public override string ToString()
 4: {
 5: return "c# 真好用";
 6: }
 7: }

me1237guy 發表在 痞客邦 留言(0) 人氣()

FileStream –> object   OKFileStream->Stream   OKFileStream->string      NGFileStream->StreamReader  NG
 1: private void button1_Click(object sender, EventArgs e)
 2: {
 3: using (FileStream fs = new FileStream(@"c:\log.txt",System.IO.FileMode.Create))
 4: {
 5: object obj = fs as object;
 6: if (obj != null)
 7: {
 8: MessageBox.Show("轉換為Object成功!", "提示!");
 9: }
 10: else
 11: {
 12: MessageBox.Show("轉換為Object不成功!", "提示!");
 13: }
 14: Stream strm = obj as Stream;
 15: if (strm != null)
 16: {
 17: MessageBox.Show("轉換為Stream成功!", "提示!");
 18: }
 19: else
 20: {
 21: MessageBox.Show("轉換為Stream不成功!", "提示!");
 22: }
 23: string str = obj as string;
 24: if (str != null)
 25: {
 26: MessageBox.Show("轉換為string成功!", "提示!");
 27: }
 28: else
 29: {
 30: MessageBox.Show("轉換為string不成功!", "提示!");
 31: }
 32:  
 33: StreamReader f = obj as StreamReader;
 34: if (str != null)
 35: {
 36: MessageBox.Show("轉換為StreamReader成功!", "提示!");
 37: }
 38: else
 39: {
 40: MessageBox.Show("轉換為StreamReader不成功!", "提示!");
 41: }
 42:  
 43: }

44: }

me1237guy 發表在 痞客邦 留言(0) 人氣()

image
資料來源: 建置專案時出現了「在憑證存放區中找不到資訊清單簽署憑證」錯誤第一種解決方法 跟有憑證的人申請索取憑證第二種解決方法 將在專案屬性中的簽署頁籤內將簽署的checkbox勾選取消

me1237guy 發表在 痞客邦 留言(0) 人氣()

image

 1: using System;
 2: using System.Collections.Generic;
 3: using System.ComponentModel;
 4: using System.Data;
 5: using System.Drawing;
 6: using System.Linq;
 7: using System.Text;
 8: using System.Windows.Forms;
 9: using System;
 10: using System.Runtime.InteropServices;
 11:  
 12: namespace HideTaskBarEx
 13: {
 14:  
 15: public partial class Form1 : Form
 16: {
 17: [DllImport("user32.dll")]
 18: private static extern IntPtr FindWindow(String className, String windowText);
 19: [DllImport("user32.dll")]
 20: private static extern Int32 ShowWindow(IntPtr hwnd, Int32 command);
 21: private const Int32 HIDE = 0;
 22: private const Int32 SHOW = 1;
 23: public Form1()
 24: {
 25: InitializeComponent();
 26: }
 27:  
 28: private void button1_Click(object sender, EventArgs e)
 29: {
 30: IntPtr TaskBar = FindWindow("Shell_TrayWnd", "");
 31: ShowWindow(TaskBar, HIDE);
 32: }
 33:  
 34: private void button2_Click(object sender, System.EventArgs e)
 35: {
 36: IntPtr TaskBar = FindWindow("Shell_TrayWnd", "");
 37: ShowWindow(TaskBar, SHOW);
 38: }
 39: }
 40: }

me1237guy 發表在 痞客邦 留言(0) 人氣()

image

資源檔案加入一張圖片請先下載Icon: http://findicons.com/icon/583421/forms程式碼:
 1: public partial class Form1 : Form
 2: {
 3: NotifyIcon notifyIcon;
 4:  
 5: private void Initial()
 6: {
 7: notifyIcon = new NotifyIcon();
 8: notifyIcon.BalloonTipText = "Program is Running..."; //設定通知欄提示的文字
 9: notifyIcon.Text = "NotifyIcon Sample"; //設定通知欄在滑鼠移至Icon上的要顯示的文字
 10: notifyIcon.Icon = (System.Drawing.Icon)Properties.Resources.forms; //決定一個Logo
 11: notifyIcon.Click += (sender, e) => //設定按下Icon的事件
 12: {
 13: notifyIcon.Visible = false;
 14: this.ShowInTaskbar = true;
 15: this.Show();
 16: };
 17:  
 18: //設定右鍵選單
 19: ContextMenu contextMenu = new ContextMenu();
 20: MenuItem menuItem = new MenuItem();
 21: menuItem.Checked = true;
 22: menuItem.Index = 1;
 23: menuItem.Text = "顯示";
 24: menuItem.Click += (sender, e) => //設定按下事件
 25: {
 26: MessageBox.Show("開始...");
 27: };
 28: contextMenu.MenuItems.Add(menuItem);
 29: notifyIcon.ContextMenu = contextMenu;
 30: }
 31: public Form1()
 32: {
 33: InitializeComponent();
 34: Initial();
 35: }
 36:  
 37: private void button1_Click(object sender, EventArgs e)
 38: {
 39: this.ShowInTaskbar = false;
 40: this.Hide();
 41: notifyIcon.Visible = true;
 42: notifyIcon.ShowBalloonTip(1, "測試", "測試內容", ToolTipIcon.Info);
 43: }

44: }

me1237guy 發表在 痞客邦 留言(0) 人氣()

image

 1: private void button1_Click(object sender, EventArgs e)
 2: {
 3: listBox1.Items.Clear();
 4: foreach (var screen in Screen.AllScreens)
 5: {
 6: listBox1.Items.Add("Device nAME: " + screen.DeviceName);
 7: listBox1.Items.Add("Bounds: " + screen.Bounds.ToString());
 8: listBox1.Items.Add("Type: " + screen.GetType().ToString());
 9: listBox1.Items.Add("Working Area: " + screen.WorkingArea.ToString());
 10: listBox1.Items.Add("Primary Screen: " + screen.Primary.ToString());
 11: listBox1.Items.Add("=================================================");
 12: }
 13: }

me1237guy 發表在 痞客邦 留言(0) 人氣()

image
原本只想在DataGridView加入ComboBox的功能, 結果網路一查之下, 發現這也是一門學問,.NET已經將一些常用的如DataGridView + ComboBoxDataGridView + CheckBox DataGridView + ButtonDataGridView + Image等諸如此類的元件都已經整合在一起, 真是棒!但是有些還是得自己手動加入DataGridView + NumericUpDownDataGridView + RadioButton網路上的MSDN範例又臭又長,實在難以下嚥,

me1237guy 發表在 痞客邦 留言(2) 人氣()

image
今天在寫一個簡單的<開始><暫停><停止>同一個thread, 發現thread一旦被suspended, 則必須透過          try
          {
              gProcThread.Abort();
          }

me1237guy 發表在 痞客邦 留言(0) 人氣()

今天開機發現馬達參數跑掉, 導致無法運行, 研究發現ADLINK 8164 Motion Card初始化會載入一組參數檔案備份檔案 C:\Users\GTVision\AppData\Local\VirtualStore\Windows\8164MC.ini
實際讀取 C:\windows\8164MC.ini此要確認C:\windows\8164MC.ini的檔案沒有被覆蓋, 或是自行指定路徑

me1237guy 發表在 痞客邦 留言(0) 人氣()

Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。