238 lines
7.9 KiB
C#
238 lines
7.9 KiB
C#
/*********************************************************************************************
|
|
* Copyright 2004 - Volian Enterprises, Inc. All rights reserved.
|
|
* Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
|
* ------------------------------------------------------------------------------
|
|
* $Workfile: Properties.cs $ $Revision: 1 $
|
|
* $Author: Kathy $ $Date: 7/27/04 8:53a $
|
|
*
|
|
* $History: Properties.cs $
|
|
*
|
|
* ***************** Version 1 *****************
|
|
* User: Kathy Date: 7/27/04 Time: 8:53a
|
|
* Created in $/LibSource/VEObject
|
|
*********************************************************************************************/
|
|
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using System.Windows.Forms;
|
|
|
|
namespace VEObject
|
|
{
|
|
/// <summary>
|
|
/// This class provides the 'Properties' dialog box. It includes a property
|
|
/// grid which uses Property data from caller to list items in the grid.
|
|
/// </summary>
|
|
public class Properties : System.Windows.Forms.Form
|
|
{
|
|
/// <summary>
|
|
/// Required designer variable.
|
|
/// </summary>
|
|
private System.ComponentModel.Container components = null;
|
|
private System.Windows.Forms.PropertyGrid myPropertyGrid;
|
|
private System.Windows.Forms.Panel panel1;
|
|
private VEO_Base _ParentObj;
|
|
private VEO_Base _CurObj;
|
|
private System.Windows.Forms.Button btnCancel;
|
|
private System.Windows.Forms.Button btnSave;
|
|
private System.Windows.Forms.Button btnApply;
|
|
private bool isnew;
|
|
public GridItem CurrentGridItem;
|
|
private bool canedit;
|
|
|
|
public Properties(Object par, Object obj)
|
|
{
|
|
_ParentObj = (VEO_Base) par;
|
|
_CurObj = (VEO_Base) obj;
|
|
if(_CurObj.isNew)
|
|
isnew=true;
|
|
else
|
|
isnew=false;
|
|
|
|
//
|
|
// Required for Windows Form Designer support
|
|
//
|
|
InitializeComponent();
|
|
this.btnApply.Enabled=false;
|
|
if((_CurObj.canEdit()==false)&&!isnew)
|
|
this.myPropertyGrid.Enabled=false;
|
|
else
|
|
this.myPropertyGrid.Enabled=true;
|
|
|
|
this.myPropertyGrid.SelectedObject=obj;
|
|
canedit=this.myPropertyGrid.Enabled;
|
|
|
|
// make apply button visible if modify
|
|
this.btnApply.Visible = !isnew;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Clean up any resources being used.
|
|
/// </summary>
|
|
protected override void Dispose( bool disposing )
|
|
{
|
|
if( disposing )
|
|
{
|
|
if(components != null)
|
|
{
|
|
components.Dispose();
|
|
}
|
|
}
|
|
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()
|
|
{
|
|
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Properties));
|
|
this.myPropertyGrid = new System.Windows.Forms.PropertyGrid();
|
|
this.panel1 = new System.Windows.Forms.Panel();
|
|
this.btnApply = new System.Windows.Forms.Button();
|
|
this.btnCancel = new System.Windows.Forms.Button();
|
|
this.btnSave = new System.Windows.Forms.Button();
|
|
this.panel1.SuspendLayout();
|
|
this.SuspendLayout();
|
|
//
|
|
// myPropertyGrid
|
|
//
|
|
this.myPropertyGrid.CommandsVisibleIfAvailable = true;
|
|
this.myPropertyGrid.Dock = System.Windows.Forms.DockStyle.Top;
|
|
this.myPropertyGrid.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
|
|
this.myPropertyGrid.HelpVisible = false;
|
|
this.myPropertyGrid.LargeButtons = false;
|
|
this.myPropertyGrid.LineColor = System.Drawing.SystemColors.ScrollBar;
|
|
this.myPropertyGrid.Location = new System.Drawing.Point(0, 0);
|
|
this.myPropertyGrid.Name = "myPropertyGrid";
|
|
this.myPropertyGrid.PropertySort = System.Windows.Forms.PropertySort.Categorized;
|
|
this.myPropertyGrid.Size = new System.Drawing.Size(704, 416);
|
|
this.myPropertyGrid.TabIndex = 1;
|
|
this.myPropertyGrid.Text = "Properties";
|
|
this.myPropertyGrid.ToolbarVisible = false;
|
|
this.myPropertyGrid.ViewBackColor = System.Drawing.SystemColors.Window;
|
|
this.myPropertyGrid.ViewForeColor = System.Drawing.SystemColors.WindowText;
|
|
this.myPropertyGrid.Click += new System.EventHandler(this.myPropertyGrid_Click);
|
|
this.myPropertyGrid.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.myPropertyGrid_PropertyValueChanged);
|
|
this.myPropertyGrid.DoubleClick += new System.EventHandler(this.myPropertyGrid_Click);
|
|
//
|
|
// panel1
|
|
//
|
|
this.panel1.Controls.Add(this.btnApply);
|
|
this.panel1.Controls.Add(this.btnCancel);
|
|
this.panel1.Controls.Add(this.btnSave);
|
|
this.panel1.Location = new System.Drawing.Point(0, 128);
|
|
this.panel1.Name = "panel1";
|
|
this.panel1.Size = new System.Drawing.Size(704, 96);
|
|
this.panel1.TabIndex = 2;
|
|
//
|
|
// btnApply
|
|
//
|
|
this.btnApply.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
|
|
this.btnApply.Location = new System.Drawing.Point(200, 8);
|
|
this.btnApply.Name = "btnApply";
|
|
this.btnApply.Size = new System.Drawing.Size(64, 24);
|
|
this.btnApply.TabIndex = 2;
|
|
this.btnApply.Text = "Apply";
|
|
this.btnApply.Click += new System.EventHandler(this.btnApply_Click);
|
|
//
|
|
// btnCancel
|
|
//
|
|
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
|
this.btnCancel.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
|
|
this.btnCancel.Location = new System.Drawing.Point(112, 8);
|
|
this.btnCancel.Name = "btnCancel";
|
|
this.btnCancel.Size = new System.Drawing.Size(64, 24);
|
|
this.btnCancel.TabIndex = 1;
|
|
this.btnCancel.Text = "Cancel";
|
|
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
|
//
|
|
// btnSave
|
|
//
|
|
this.btnSave.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
|
|
this.btnSave.Location = new System.Drawing.Point(24, 8);
|
|
this.btnSave.Name = "btnSave";
|
|
this.btnSave.Size = new System.Drawing.Size(64, 24);
|
|
this.btnSave.TabIndex = 0;
|
|
this.btnSave.Text = "OK";
|
|
this.btnSave.Click += new System.EventHandler(this.btnOK_Click);
|
|
//
|
|
// Properties
|
|
//
|
|
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
|
this.ClientSize = new System.Drawing.Size(704, 190);
|
|
this.Controls.Add(this.panel1);
|
|
this.Controls.Add(this.myPropertyGrid);
|
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
|
this.Name = "Properties";
|
|
this.Text = "Properties";
|
|
this.panel1.ResumeLayout(false);
|
|
this.ResumeLayout(false);
|
|
|
|
}
|
|
#endregion
|
|
|
|
private void myPropertyGrid_Click(object sender, System.EventArgs e)
|
|
{
|
|
CurrentGridItem = this.myPropertyGrid.SelectedGridItem;
|
|
}
|
|
|
|
private void myPropertyGrid_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e)
|
|
{
|
|
btnApply.Enabled = true;
|
|
CurrentGridItem = this.myPropertyGrid.SelectedGridItem;
|
|
}
|
|
|
|
// save data for use by ok and apply button clicks
|
|
private bool saveclick()
|
|
{
|
|
bool success = true;
|
|
|
|
if (isnew)
|
|
{
|
|
if(_ParentObj==null)
|
|
{
|
|
DialogResult=DialogResult.Cancel;
|
|
return success;
|
|
}
|
|
success=_ParentObj.SaveChild(_CurObj);
|
|
}
|
|
else
|
|
{
|
|
success=_CurObj.Write();
|
|
}
|
|
return success;
|
|
}
|
|
|
|
// save was clicked, use the objects save methods.
|
|
private void btnOK_Click(object sender, System.EventArgs e)
|
|
{
|
|
bool success = true;
|
|
if (canedit) success = saveclick();
|
|
if (success==true)
|
|
{
|
|
DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
}
|
|
|
|
private void btnApply_Click(object sender, System.EventArgs e)
|
|
{
|
|
if(!canedit)return;
|
|
bool success = saveclick();
|
|
if(success==true)btnApply.Enabled=false;
|
|
this.myPropertyGrid.Refresh();
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, System.EventArgs e)
|
|
{
|
|
if(!canedit)return;
|
|
_CurObj.Restore();
|
|
}
|
|
|
|
}
|
|
}
|