|
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace DSODemo
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.Label lblStep1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label lblTitle;
private System.Windows.Forms.Label lblSubject;
private System.Windows.Forms.Label lblAuthor;
private System.Windows.Forms.Label lblCategory;
private System.Windows.Forms.Label lblKeywords;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtTitle;
private System.Windows.Forms.Button btnUpdate;
private DSOFile.OleDocumentPropertiesClass myDSOOleDocument = new DSOFile.OleDocumentPropertiesClass();
private System.Windows.Forms.TextBox txtSubject;
private System.Windows.Forms.TextBox txtAuthor;
private System.Windows.Forms.TextBox txtCategory;
private System.Windows.Forms.TextBox txtComment;
private System.Windows.Forms.TextBox txtKeyword;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
Application.EnableVisualStyles();
InitializeComponent();
Application.EnableVisualStyles();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <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()
{
this.button1 = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.lblStep1 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.lblTitle = new System.Windows.Forms.Label();
this.lblSubject = new System.Windows.Forms.Label();
this.lblAuthor = new System.Windows.Forms.Label();
this.lblCategory = new System.Windows.Forms.Label();
this.lblKeywords = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.txtTitle = new System.Windows.Forms.TextBox();
this.txtSubject = new System.Windows.Forms.TextBox();
this.txtAuthor = new System.Windows.Forms.TextBox();
this.txtCategory = new System.Windows.Forms.TextBox();
this.txtKeyword = new System.Windows.Forms.TextBox();
this.txtComment = new System.Windows.Forms.TextBox();
this.btnUpdate = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.button1.Location = new System.Drawing.Point(232, 8);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "Browse";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// lblStep1
//
this.lblStep1.Location = new System.Drawing.Point(8, 16);
this.lblStep1.Name = "lblStep1";
this.lblStep1.Size = new System.Drawing.Size(224, 16);
this.lblStep1.TabIndex = 0;
this.lblStep1.Text = "Step1: Click on browse button to locate file.";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnUpdate);
this.groupBox1.Controls.Add(this.txtTitle);
this.groupBox1.Controls.Add(this.lblTitle);
this.groupBox1.Controls.Add(this.lblSubject);
this.groupBox1.Controls.Add(this.lblAuthor);
this.groupBox1.Controls.Add(this.lblCategory);
this.groupBox1.Controls.Add(this.lblKeywords);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.txtSubject);
this.groupBox1.Controls.Add(this.txtAuthor);
this.groupBox1.Controls.Add(this.txtCategory);
this.groupBox1.Controls.Add(this.txtKeyword);
this.groupBox1.Controls.Add(this.txtComment);
this.groupBox1.Location = new System.Drawing.Point(8, 40);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(296, 320);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Step2: View/modify exiting file summary";
//
// lblTitle
//
this.lblTitle.Location = new System.Drawing.Point(16, 24);
this.lblTitle.Name = "lblTitle";
this.lblTitle.Size = new System.Drawing.Size(56, 16);
this.lblTitle.TabIndex = 0;
this.lblTitle.Text = "Title:";
//
// lblSubject
//
this.lblSubject.Location = new System.Drawing.Point(16, 56);
this.lblSubject.Name = "lblSubject";
this.lblSubject.Size = new System.Drawing.Size(56, 16);
this.lblSubject.TabIndex = 0;
this.lblSubject.Text = "Subject:";
//
// lblAuthor
//
this.lblAuthor.Location = new System.Drawing.Point(16, 88);
this.lblAuthor.Name = "lblAuthor";
this.lblAuthor.Size = new System.Drawing.Size(56, 16);
this.lblAuthor.TabIndex = 0;
this.lblAuthor.Text = "Author:";
//
// lblCategory
//
this.lblCategory.Location = new System.Drawing.Point(16, 120);
this.lblCategory.Name = "lblCategory";
this.lblCategory.Size = new System.Drawing.Size(56, 16);
this.lblCategory.TabIndex = 0;
this.lblCategory.Text = "Category:";
//
// lblKeywords
//
this.lblKeywords.Location = new System.Drawing.Point(16, 152);
this.lblKeywords.Name = "lblKeywords";
this.lblKeywords.Size = new System.Drawing.Size(56, 16);
this.lblKeywords.TabIndex = 0;
this.lblKeywords.Text = "Keywords:";
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 184);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Comments:";
//
// txtTitle
//
this.txtTitle.Location = new System.Drawing.Point(72, 24);
this.txtTitle.Name = "txtTitle";
this.txtTitle.Size = new System.Drawing.Size(200, 20);
this.txtTitle.TabIndex = 1;
this.txtTitle.Text = "[File not specified]";
//
// txtSubject
//
this.txtSubject.Location = new System.Drawing.Point(72, 56);
this.txtSubject.Name = "txtSubject";
this.txtSubject.Size = new System.Drawing.Size(200, 20);
this.txtSubject.TabIndex = 2;
this.txtSubject.Text = "[File not specified]";
//
// txtAuthor
//
this.txtAuthor.Location = new System.Drawing.Point(72, 88);
this.txtAuthor.Name = "txtAuthor";
this.txtAuthor.Size = new System.Drawing.Size(200, 20);
this.txtAuthor.TabIndex = 3;
this.txtAuthor.Text = "[File not specified]";
//
// txtCategory
//
this.txtCategory.Location = new System.Drawing.Point(72, 120);
this.txtCategory.Name = "txtCategory";
this.txtCategory.Size = new System.Drawing.Size(200, 20);
this.txtCategory.TabIndex = 4;
this.txtCategory.Text = "[File not specified]";
//
// txtKeyword
//
this.txtKeyword.Location = new System.Drawing.Point(72, 152);
this.txtKeyword.Name = "txtKeyword";
this.txtKeyword.Size = new System.Drawing.Size(200, 20);
this.txtKeyword.TabIndex = 5;
this.txtKeyword.Text = "[File not specified]";
//
// txtComment
//
this.txtComment.Location = new System.Drawing.Point(72, 184);
this.txtComment.Multiline = true;
this.txtComment.Name = "txtComment";
this.txtComment.Size = new System.Drawing.Size(200, 80);
this.txtComment.TabIndex = 6;
this.txtComment.Text = "[File not specified]";
//
// btnUpdate
//
this.btnUpdate.Enabled = false;
this.btnUpdate.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnUpdate.Location = new System.Drawing.Point(112, 280);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.TabIndex = 7;
this.btnUpdate.Text = "Update";
this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(328, 371);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.lblStep1);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(336, 504);
this.MinimumSize = new System.Drawing.Size(336, 400);
this.Name = "Form1";
this.Text = "DSO Demo";
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
/*****************************************************
* Opening file
* ***************************************************/
openFileDialog1.ShowDialog();
myDSOOleDocument.Open(openFileDialog1.FileName,false , DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess);
/*****************************************************
* Reading from file through DSO and writing values to form
* ***************************************************/
txtTitle.Text = myDSOOleDocument.SummaryProperties.Title;
txtSubject.Text = myDSOOleDocument.SummaryProperties.Subject;
txtAuthor.Text = myDSOOleDocument.SummaryProperties.Author;
txtCategory.Text = myDSOOleDocument.SummaryProperties.Category;
txtKeyword.Text = myDSOOleDocument.SummaryProperties.Keywords;
txtComment.Text = myDSOOleDocument.SummaryProperties.Comments ;
btnUpdate.Enabled = true;
}
private void btnUpdate_Click(object sender, System.EventArgs e)
{
/*****************************************************
* Reading from form and writing values to File summary through DSO
* ***************************************************/
myDSOOleDocument.SummaryProperties.Title = txtTitle.Text;
myDSOOleDocument.SummaryProperties.Subject = txtSubject.Text;
myDSOOleDocument.SummaryProperties.Author = txtAuthor.Text;
myDSOOleDocument.SummaryProperties.Category = txtCategory.Text;
myDSOOleDocument.SummaryProperties.Keywords = txtKeyword.Text;
myDSOOleDocument.SummaryProperties.Comments = txtComment.Text;
myDSOOleDocument.Save();
MessageBox.Show("Information updated successfully","DSO Demo");
Application.Exit();
}
}
}
|
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.