zr

来源:互联网 发布:python telnet 编辑:程序博客网 时间:2024/06/03 07:10
 
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Drawing.Imaging;

namespace StudySampleCSharp
{
    
/// <summary>
    
/// Form2 の概要の説明です。
    
/// </summary>

    public class Form2 : System.Windows.Forms.Form
    
{
        
private System.Windows.Forms.Label label1;
        
private System.Windows.Forms.Label label2;
        
/// <summary>
        
/// 必要なデザイナ変数です。
        
/// </summary>

        private System.ComponentModel.Container components = null;
        
private System.Windows.Forms.Button btnForeColor;
        
private System.Windows.Forms.Button btnBackColor;        
        
private System.Windows.Forms.Button btnFonts;
        
private System.Windows.Forms.ComboBox cmbPosition;
        
private System.Windows.Forms.Button btnExcute;
        
private System.Windows.Forms.ListBox listBoxFile;
        
private System.Windows.Forms.Button btnSource;
        
private System.Windows.Forms.Button btnDestination;
        
private System.Windows.Forms.TextBox txtDestination;
        
private System.Windows.Forms.TextBox txtSource;
        
private System.Windows.Forms.Panel panelDemo;
        
private System.Windows.Forms.Label lblDemo;
        
private System.Windows.Forms.TextBox textBox1;
        
private System.Windows.Forms.TextBox textBox2;

        
//Custom
        private Font titleFont = new Font("MS UI Gothic",9);
        
private Color foreColor = Color.White;
        
private Color backColor = Color.Transparent;
        
private int iPanelLeft = 0;
        
private int iPanelTop = 0;        
        
private int iLeft = 0;
        
private int iTop = 0;
        
private int iWidth = 0;
        
private int iHeight = 0;
        
private int iDirection = 0;            
        
private bool isOnLbl = false;
        
private bool isOnSizing = false;
        
private int iLblInLeft = 0;
        
private System.Windows.Forms.TextBox txtDemo;
        
private int iLblInTop = 0;
        
private int iLblX = 0;
        
private int iLblY = 0;
        
private System.Windows.Forms.StatusBar statusBar1;
        
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
        
private System.Windows.Forms.CheckBox checkBox1;
        
private bool isBorder = false;


        
public Form2()
        
{
            
//
            
// Windows フォーム デザイナ サポートに必要です。
            
//
            InitializeComponent();

            
//
            
// TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
            
//
        }


        
/// <summary>
        
/// 使用されているリソースに後処理を実行します。
        
/// </summary>

        protected override void Dispose( bool disposing )
        
{
            
if( disposing )
            
{
                
if (components != null
                
{
                    components.Dispose();
                }

            }

            
base.Dispose( disposing );
        }


        
Windows フォーム デザイナで生成されたコード        

        
private void Form2_Load(object sender, System.EventArgs e)
        
{
            cmbPosition.Items.Add(
"TopLeft");
            cmbPosition.Items.Add(
"TopRight");
            cmbPosition.Items.Add(
"MiddleCenter");
            cmbPosition.Items.Add(
"BottomLeft");
            cmbPosition.Items.Add(
"BottomRight");
            cmbPosition.SelectedIndex 
= 3;
            lblDemo.Width 
= 100;
            lblDemo.Height 
= 20;
            txtDestination.Text 
= @"C:Documents and Settings84デスクトップpic";
            Demo();
            iPanelLeft 
= this.Left + (this.Width - this.ClientSize.Width) / 2 + panelDemo.Left + 2;
            iPanelTop 
= this.Top + (this.Height - this.ClientSize.Height - (this.Width - this.ClientSize.Width) / 2+ panelDemo.Top + 2;
            txtDemo.Visible 
= false;

        }


        
button Event

        
Demo

        
sonota Event

        
Panel Event

        
Label Event

        
private void lblDemo_LocationChanged(object sender, System.EventArgs e)
        
{
            textBox1.Text 
= lblDemo.Left.ToString();
            textBox2.Text 
= lblDemo.Top.ToString();
        }


        
private void textBox1_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        
{
            
string strLeft = textBox1.Text;
            
for (int ix = 0; ix < strLeft.Length; ix++)
            
{
                
if (Char.IsNumber(strLeft,ix) == false)
                
{
                    MessageBox.Show(
"Please input a integer!");
                    textBox1.Select();
                    
return;
                }

            }

            
int iLeft = Convert.ToInt32(strLeft);
            
if (iLeft < 0)
            
{
                iLeft 
= 0;
            }

            
if (iLeft > panelDemo.Width - lblDemo.Width)
            
{
                iLeft 
= panelDemo.Width - lblDemo.Width;
            }

            lblDemo.Left 
= iLeft;
        }


        
private void textBox2_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        
{
            
string strTop = textBox2.Text;
            
for (int ix = 0; ix < strTop.Length; ix++)
            
{
                
if (Char.IsNumber(strTop,ix) == false)
                
{
                    MessageBox.Show(
"Please input a integer!");
                    textBox2.Select();
                    
return;
                }

            }

            
int iTop = Convert.ToInt32(strTop);
            
if (iTop < 0)
            
{
                iTop 
= 0;
            }

            
if (iTop > panelDemo.Height - lblDemo.Height)
            
{
                iTop 
= panelDemo.Height - lblDemo.Height;
            }

            lblDemo.Top 
= iTop;
        }


        
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
        
{
            
if (checkBox1.Checked == true)
            
{
                btnBackColor.Enabled 
= false;
                backColor 
= Color.Transparent;
                Demo();
            }

            
else
            
{
                btnBackColor.Enabled 
= true;
            }


        }


        
        
    }

}

原创粉丝点击