|
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace CardfileCE
{
/// <summary>
/// Summary description for Contact.
/// </summary>
public class frmContact : System.Windows.Forms.Form
{
private ContactPanel pnlContact;
private System.Windows.Forms.Button cmdCancel;
private System.Windows.Forms.Button cmdOK;
private System.Windows.Forms.TextBox tbCardName;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel pnlSubstrate;
private System.Windows.Forms.VScrollBar vScrollBar;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.Label label2;
public frmContact()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
// Set up the scrollable edit panel
pnlContact = new ContactPanel();
pnlSubstrate.Controls.Add(this.pnlContact);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cmdCancel = new System.Windows.Forms.Button();
this.cmdOK = new System.Windows.Forms.Button();
this.tbCardName = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.pnlSubstrate = new System.Windows.Forms.Panel();
this.vScrollBar = new System.Windows.Forms.VScrollBar();
this.label2 = new System.Windows.Forms.Label();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
//
// cmdCancel
//
this.cmdCancel.Location = new System.Drawing.Point(80, 241);
this.cmdCancel.Text = "Cancel";
this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
//
// cmdOK
//
this.cmdOK.Location = new System.Drawing.Point(160, 241);
this.cmdOK.Text = "OK";
this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
//
// tbCardName
//
this.tbCardName.Location = new System.Drawing.Point(96, 9);
this.tbCardName.Size = new System.Drawing.Size(136, 26);
this.tbCardName.Text = "";
this.tbCardName.TextChanged += new System.EventHandler(this.tbCardName_TextChanged);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 9);
this.label1.Size = new System.Drawing.Size(96, 20);
this.label1.Text = "Card name:";
//
// pnlSubstrate
//
this.pnlSubstrate.Controls.Add(this.vScrollBar);
this.pnlSubstrate.Location = new System.Drawing.Point(8, 64);
this.pnlSubstrate.Size = new System.Drawing.Size(224, 168);
//
// vScrollBar
//
this.vScrollBar.Location = new System.Drawing.Point(208, 0);
this.vScrollBar.Maximum = 91;
this.vScrollBar.Size = new System.Drawing.Size(13, 168);
this.vScrollBar.ValueChanged += new System.EventHandler(this.vScrollBar_ValueChanged);
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 40);
this.label2.Text = "Contact:";
//
// frmContact
//
this.Controls.Add(this.label2);
this.Controls.Add(this.pnlSubstrate);
this.Controls.Add(this.cmdCancel);
this.Controls.Add(this.cmdOK);
this.Controls.Add(this.tbCardName);
this.Controls.Add(this.label1);
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.MinimizeBox = false;
this.Text = "Contact";
}
#endregion
public string CardName
{
get { return tbCardName.Text; }
set
{
// Save the card name
tbCardName.Text = value;
// Retitle the form
this.Text = value;
}
}
public CardTypeBodyContact ContactInfo
{
get { return pnlContact.ContactInfo; }
set { pnlContact.ContactInfo = value; }
}
private void tbCardName_TextChanged(object sender, System.EventArgs e)
{
// The note name is changing, so update form title
this.Text = tbCardName.Text;
}
private void cmdOK_Click(object sender, System.EventArgs e)
{
// Just quit...
this.DialogResult = DialogResult.OK;
this.Close();
}
private void cmdCancel_Click(object sender, System.EventArgs e)
{
// Just quit...
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private void vScrollBar_ValueChanged(object sender, System.EventArgs e)
{
// Scroll the contact panel
Double pct = Convert.ToDouble(vScrollBar.Value) / Convert.ToDouble(vScrollBar.Maximum); // how far have we scrolled (percentage)
Double rng = Convert.ToDouble(pnlContact.Height) - Convert.ToDouble(pnlSubstrate.Height) + 1; // how far can we scroll the panel?
Int32 loc = Convert.ToInt32(pct * rng); // convert to pixels
pnlContact.Top = loc > 0 ? -loc : 0; // move
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.