using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Reflection;

using Softelvdm.SftTreeNET;
using Softelvdm.SftTabsNET;
using Softelvdm.Controls;

// This sample also requires SftTree/NET 2.0 to be compiled (in addition to SftTabs/NET 6.0)
// This sample also requires SftTree/NET 2.0 to be compiled (in addition to SftTabs/NET 6.0)
// This sample also requires SftTree/NET 2.0 to be compiled (in addition to SftTabs/NET 6.0)

namespace EventViewer {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            sftTreeList.ItemCollection.Clear();

            for (int i = 4 ; i < 14 ; ++i) {
                TabClass tab = sftTabs1.TabCollection.Add();
                tab.Text = "Tab " + i.ToString();
                tab.ToolTip = tab.Text;
                tab.TextPart.PartAlignment = PartAlignmentEnum.Center;
            }                

            sftTabs1.Current = 0;

            sftTabs1.AllowReordering = true;
            propertyGrid1.SelectedObject = sftTabs1;
        }

        private string strLastEvent = "";
        private bool fLastEventDup = false;

        // This is a small helper routine to show all properties and fields of an object
        private void DumpValues(string title, object o) {

            string s = "";

            if (strLastEvent == title) {
                if (!fLastEventDup) {
                    s = "Additional " + title + " events ... now suppressed";
                    fLastEventDup = true;
                } else
                    return;
            } else {
                strLastEvent = title;
                fLastEventDup = false;

                PropertyInfo[] api = o.GetType().GetProperties();
                foreach (PropertyInfo pi in api)
                    s += pi.Name + "=" + pi.GetValue(o, new object[] { }) + " ";
                FieldInfo[] afi = o.GetType().GetFields();
                foreach (FieldInfo fi in afi)
                    s += fi.Name + "=" + fi.GetValue(o) + " ";
            }

            ItemClass item = sftTreeList.ItemCollection.Add(new string[] { title, s });
            item.Selected = true;

            sftTreeList.Columns.MakeOptimal(50, true);
            sftTreeList.RecalcHorizontalExtent();
        }

        private void sftTabs1_ClientSizeChanged(object sender, EventArgs e) {
            DumpValues("ClientSizeChanged", e);
        }

        private void sftTabs1_CloseButtonClicked(object sender, EventArgs e) {
            DumpValues("CloseButtonClicked", e);
        }

        private void sftTabs1_DragDetected(object sender, Softelvdm.SftTabsNET.DragDetectedEventArgs e) {
            DumpValues("DragDetected", e);
        }

        private void sftTabs1_DragDrop(object sender, DragEventArgs e) {
            DumpValues("DragDrop", e);
        }

        private void sftTabs1_DragEnter(object sender, DragEventArgs e) {
            DumpValues("DragEnter", e);
        }

        private void sftTabs1_DragLeave(object sender, EventArgs e) {
            DumpValues("DragLeave", e);
        }

        private void sftTabs1_DragOver(object sender, DragEventArgs e) {
            DumpValues("DragOver", e);
        }

        private void sftTabs1_Enter(object sender, EventArgs e) {
            DumpValues("Enter", e);
        }

        private void sftTabs1_GiveFeedback(object sender, GiveFeedbackEventArgs e) {
            DumpValues("GiveFeedback", e);
        }

        private void sftTabs1_KeyDown(object sender, KeyEventArgs e) {
            DumpValues("KeyDown", e);
        }

        private void sftTabs1_KeyPress(object sender, KeyPressEventArgs e) {
            DumpValues("KeyPress", e);
        }

        private void sftTabs1_KeyUp(object sender, KeyEventArgs e) {
            DumpValues("KeyUp", e);
        }

        private void sftTabs1_Leave(object sender, EventArgs e) {
            DumpValues("Leave", e);
        }

        private void sftTabs1_MinimizeButtonClicked(object sender, EventArgs e) {
            DumpValues("MinimizeButtonClicked", e);
        }

        private void sftTabs1_MouseDown(object sender, MouseEventArgs e) {
            DumpValues("MouseDown", e);
        }

        private void sftTabs1_MouseEnter(object sender, EventArgs e) {
            DumpValues("MouseEnter", e);
        }

        private void sftTabs1_MouseHover(object sender, EventArgs e) {
            DumpValues("MouseHover", e);
        }

        private void sftTabs1_MouseLeave(object sender, EventArgs e) {
            DumpValues("MouseLeave", e);
        }

        private void sftTabs1_MouseMove(object sender, MouseEventArgs e) {
            DumpValues("MouseMove", e);
        }

        private void sftTabs1_MouseMoveHoverTimer(object sender, EventArgs e) {
            DumpValues("MouseMoveHoverTimer", e);
        }

        private void sftTabs1_MouseMoveTimer(object sender, EventArgs e) {
            DumpValues("MouseMoveTimer", e);
        }

        private void sftTabs1_MouseUp(object sender, MouseEventArgs e) {
            DumpValues("MouseUp", e);
        }

        private void sftTabs1_PartClicked(object sender, PartClickedEventArgs e) {
            DumpValues("PartClicked", e);
        }

        private void sftTabs1_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) {
            DumpValues("QueryContinueDrag", e);
        }

        private void sftTabs1_RestoreButtonClicked(object sender, EventArgs e) {
            DumpValues("RestoreButtonClicked", e);
        }

        private void sftTabs1_Scrolled(object sender, ScrolledEventArgs e) {
            DumpValues("Scrolled", e);
        }

        private void sftTabs1_Switched(object sender, EventArgs e) {
            DumpValues("Switched", e);
        }

        private void sftTabs1_Switching(object sender, SwitchingEventArgs e) {
            DumpValues("Switching", e);
        }

        private void sftTabs1_SwitchingDisabled(object sender, SwitchingEventArgs e) {
            DumpValues("SwitchingDisabled", e);
        }
    }
}