using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using SftTreeLib70; using AxSftTreeLib70; using Softelvdm.OLEConvert; namespace ListFont { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private AxSftTreeLib70.AxSftTree axSftTree1; private System.Windows.Forms.Button closeButton; private System.Windows.Forms.Label label1; private Softelvdm.OCXHelper.SftHelperComponent sftHelperComponent1; private System.ComponentModel.IContainer components; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // 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.components = new System.ComponentModel.Container(); System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1)); this.axSftTree1 = new AxSftTreeLib70.AxSftTree(); this.closeButton = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.sftHelperComponent1 = new Softelvdm.OCXHelper.SftHelperComponent(this.components); ((System.ComponentModel.ISupportInitialize)(this.axSftTree1)).BeginInit(); this.SuspendLayout(); // // axSftTree1 // this.axSftTree1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right); this.axSftTree1.Location = new System.Drawing.Point(8, 8); this.axSftTree1.Name = "axSftTree1"; this.axSftTree1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axSftTree1.OcxState"))); this.axSftTree1.Size = new System.Drawing.Size(368, 328); this.axSftTree1.TabIndex = 0; this.axSftTree1.ItemDblClick += new AxSftTreeLib70._DSftTreeEvents_ItemDblClickEventHandler(this.axSftTree1_ItemDblClick); // // closeButton // this.closeButton.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); this.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.closeButton.FlatStyle = System.Windows.Forms.FlatStyle.System; this.closeButton.Location = new System.Drawing.Point(384, 8); this.closeButton.Name = "closeButton"; this.closeButton.Size = new System.Drawing.Size(88, 24); this.closeButton.TabIndex = 1; this.closeButton.Text = "Close"; this.closeButton.Click += new System.EventHandler(this.closeButton_Click); // // label1 // this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label1.Location = new System.Drawing.Point(384, 144); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(88, 152); this.label1.TabIndex = 2; this.label1.Text = "Click on the SftTree/OCX control and hit F1 to access online help for SftTree/OCX" + " 6.0"; this.label1.Visible = false; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.CancelButton = this.closeButton; this.ClientSize = new System.Drawing.Size(480, 342); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.label1, this.closeButton, this.axSftTree1}); this.Name = "Form1"; this.Text = "Softel vdm, Inc. - ListFont Sample"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.axSftTree1)).EndInit(); this.ResumeLayout(false); } #endregion /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } //--locate-marker-- private void closeButton_Click(object sender, System.EventArgs e) { Application.Exit(); } private void axSftTree1_ItemDblClick(object sender, AxSftTreeLib70._DSftTreeEvents_ItemDblClickEvent e) { if (e.areaType == (short) SftTreeAreaTypeConstants.constSftTreeColumnRes) { axSftTree1.get_Column(e.colIndex).MakeOptimal(); axSftTree1.Items.RecalcHorizontalExtent(); } } private void Form1_Load(object sender, System.EventArgs e) { axSftTree1.BulkUpdate = true; // Add all screen fonts to the tree control int ScreenIndex = axSftTree1.Items.Add("Fonts"); axSftTree1.get_Item(ScreenIndex).Level = 0; // display fonts int counter = 0; foreach (FontFamily ff in System.Drawing.FontFamily.Families) { // add font name Font newFont = null; try { newFont = new Font(ff.Name, 8); } catch { newFont = null; } if (newFont != null) { if (++counter > 50) // only add up to 50 break; int itemIndex = axSftTree1.Items.Add(ff.Name); axSftTree1.get_Item(itemIndex).Level = 1; // set the font axSftTree1.get_Cell(itemIndex, 0).Font = OLECvt.ToIFontDisp(newFont); // set the font name in column 1 axSftTree1.get_Cell(itemIndex, 1).Text = ff.Name; } } axSftTree1.BulkUpdate = false; // make column widths optimal axSftTree1.ColumnsObj.MakeOptimal(); // allow horizontal scrolling axSftTree1.Items.RecalcHorizontalExtent(); } } }