|
using System;
using System.Drawing;
using System.Drawing.Text;
using System.ComponentModel;
using System.Windows.Forms;
using ErkerTech.DeltaScope.App.Models;
using ErkerTech.DeltaScope.View;
namespace ErkerTech.DeltaScope.App.Views
{
public class MainForm : Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private readonly FontDialog _FontDlg;
private IContainer components;
private MainMenu mainMenu1;
private MenuItem mnuFont;
private MenuItem mnuExit;
private MenuItem mnuWordWrap;
private MenuItem mnuFile;
private MenuItem mnuView;
private MenuItem mnuOptions;
private MenuItem menuItem2;
private MenuItem mnuShowSwirlRegionBoundry;
private MenuItem menuItem3;
private MenuItem mnuFontSmoothing;
private MenuItem mnuFontSmoothing_AntiAlias;
private MenuItem mnuFontSmoothing_AntiAlias_GridFit;
private MenuItem mnuFontSmoothing_ClearType_GridFit;
private MenuItem mnuFontSmoothing_SingleBitPerPixel;
private MenuItem mnuFontSmoothing_SingleBitPerPixel_GridFit;
private MenuItem mnuFontSmoothing_SystemDefault;
private MenuItem mnuOpenFiles;
private MenuItem menuItem5;
public TabControl tabDeltaViews;
private ContextMenu TabMenu;
private MenuItem mnuCloseTab;
public StatusBar statusBar1;
private MenuItem mnuHelp;
private MenuItem mnuAbout;
private bool idleHooked;
private StatusBarPanel statusBarPanel1;
private Point ptPopupLocation = Point.Empty;
public MainForm()
{
InitializeComponent();
_FontDlg = new FontDialog();
}
private static TabPage GetTabPageByTab(Point pt, TabControl TC)
{
TabPage tp = null;
//Loop over the tab pages, using GetTabRect() to determine
//if that pages Tab contains the point we passed in.
for(var i = 0; i < TC.TabPages.Count; i++)
{
if (!TC.GetTabRect(i).Contains(pt)) continue;
//We found the tab page, no need to go on...
tp = TC.TabPages[i];
break;
}
return tp;
}
#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();
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
this.mnuFile = new System.Windows.Forms.MenuItem();
this.mnuOpenFiles = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.mnuExit = new System.Windows.Forms.MenuItem();
this.mnuView = new System.Windows.Forms.MenuItem();
this.mnuFont = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.mnuOptions = new System.Windows.Forms.MenuItem();
this.mnuFontSmoothing = new System.Windows.Forms.MenuItem();
this.mnuFontSmoothing_AntiAlias = new System.Windows.Forms.MenuItem();
this.mnuFontSmoothing_AntiAlias_GridFit = new System.Windows.Forms.MenuItem();
this.mnuFontSmoothing_ClearType_GridFit = new System.Windows.Forms.MenuItem();
this.mnuFontSmoothing_SingleBitPerPixel = new System.Windows.Forms.MenuItem();
this.mnuFontSmoothing_SingleBitPerPixel_GridFit = new System.Windows.Forms.MenuItem();
this.mnuFontSmoothing_SystemDefault = new System.Windows.Forms.MenuItem();
this.mnuShowSwirlRegionBoundry = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.mnuWordWrap = new System.Windows.Forms.MenuItem();
this.mnuHelp = new System.Windows.Forms.MenuItem();
this.mnuAbout = new System.Windows.Forms.MenuItem();
this.tabDeltaViews = new System.Windows.Forms.TabControl();
this.TabMenu = new System.Windows.Forms.ContextMenu();
this.mnuCloseTab = new System.Windows.Forms.MenuItem();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
this.SuspendLayout();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuFile,
this.mnuView,
this.mnuHelp});
//
// mnuFile
//
this.mnuFile.Index = 0;
this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuOpenFiles,
this.menuItem5,
this.mnuExit});
this.mnuFile.Text = "File";
//
// mnuOpenFiles
//
this.mnuOpenFiles.Index = 0;
this.mnuOpenFiles.Text = "Open Files";
this.mnuOpenFiles.Click += new System.EventHandler(this.mnuOpenFiles_Click);
//
// menuItem5
//
this.menuItem5.Index = 1;
this.menuItem5.Text = "-";
//
// mnuExit
//
this.mnuExit.Index = 2;
this.mnuExit.Text = "Exit";
this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click);
//
// mnuView
//
this.mnuView.Index = 1;
this.mnuView.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuFont,
this.menuItem2,
this.mnuOptions,
this.menuItem3,
this.mnuWordWrap});
this.mnuView.Text = "View";
//
// mnuFont
//
this.mnuFont.Index = 0;
this.mnuFont.Text = "Font";
this.mnuFont.Click += new System.EventHandler(this.mnuFont_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.Text = "-";
//
// mnuOptions
//
this.mnuOptions.Index = 2;
this.mnuOptions.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuFontSmoothing,
this.mnuShowSwirlRegionBoundry});
this.mnuOptions.Text = "Options";
//
// mnuFontSmoothing
//
this.mnuFontSmoothing.Index = 0;
this.mnuFontSmoothing.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuFontSmoothing_AntiAlias,
this.mnuFontSmoothing_AntiAlias_GridFit,
this.mnuFontSmoothing_ClearType_GridFit,
this.mnuFontSmoothing_SingleBitPerPixel,
this.mnuFontSmoothing_SingleBitPerPixel_GridFit,
this.mnuFontSmoothing_SystemDefault});
this.mnuFontSmoothing.Text = "Font Smoothing";
//
// mnuFontSmoothing_AntiAlias
//
this.mnuFontSmoothing_AntiAlias.Index = 0;
this.mnuFontSmoothing_AntiAlias.RadioCheck = true;
this.mnuFontSmoothing_AntiAlias.Text = "AntiAlias";
this.mnuFontSmoothing_AntiAlias.Click += new System.EventHandler(this.mnuFontSmoothing_AntiAlias_Click);
//
// mnuFontSmoothing_AntiAlias_GridFit
//
this.mnuFontSmoothing_AntiAlias_GridFit.Index = 1;
this.mnuFontSmoothing_AntiAlias_GridFit.RadioCheck = true;
this.mnuFontSmoothing_AntiAlias_GridFit.Text = "AntiAlias GridFit ";
this.mnuFontSmoothing_AntiAlias_GridFit.Click += new System.EventHandler(this.mnuFontSmoothing_AntiAlias_GridFit_Click);
//
// mnuFontSmoothing_ClearType_GridFit
//
this.mnuFontSmoothing_ClearType_GridFit.Index = 2;
this.mnuFontSmoothing_ClearType_GridFit.RadioCheck = true;
this.mnuFontSmoothing_ClearType_GridFit.Text = "ClearType GridFit ";
this.mnuFontSmoothing_ClearType_GridFit.Click += new System.EventHandler(this.mnuFontSmoothing_ClearType_GridFit_Click);
//
// mnuFontSmoothing_SingleBitPerPixel
//
this.mnuFontSmoothing_SingleBitPerPixel.Index = 3;
this.mnuFontSmoothing_SingleBitPerPixel.RadioCheck = true;
this.mnuFontSmoothing_SingleBitPerPixel.Text = "Single Bit Per Pixel ";
this.mnuFontSmoothing_SingleBitPerPixel.Click += new System.EventHandler(this.mnuFontSmoothing_SingleBitPerPixel_Click);
//
// mnuFontSmoothing_SingleBitPerPixel_GridFit
//
this.mnuFontSmoothing_SingleBitPerPixel_GridFit.Index = 4;
this.mnuFontSmoothing_SingleBitPerPixel_GridFit.RadioCheck = true;
this.mnuFontSmoothing_SingleBitPerPixel_GridFit.Text = "Single Bit Per Pixel GridFit";
this.mnuFontSmoothing_SingleBitPerPixel_GridFit.Click += new System.EventHandler(this.mnuFontSmoothing_SingleBitPerPixel_GridFit_Click);
//
// mnuFontSmoothing_SystemDefault
//
this.mnuFontSmoothing_SystemDefault.Checked = true;
this.mnuFontSmoothing_SystemDefault.DefaultItem = true;
this.mnuFontSmoothing_SystemDefault.Index = 5;
this.mnuFontSmoothing_SystemDefault.RadioCheck = true;
this.mnuFontSmoothing_SystemDefault.Text = "System Default ";
this.mnuFontSmoothing_SystemDefault.Click += new System.EventHandler(this.mnuFontSmoothing_SystemDefault_Click);
//
// mnuShowSwirlRegionBoundry
//
this.mnuShowSwirlRegionBoundry.Index = 1;
this.mnuShowSwirlRegionBoundry.Text = "Show Swirl Region Boundry";
this.mnuShowSwirlRegionBoundry.Click += new System.EventHandler(this.mnuShowSwirlRegionBoundry_Click);
//
// menuItem3
//
this.menuItem3.Index = 3;
this.menuItem3.Text = "-";
//
// mnuWordWrap
//
this.mnuWordWrap.Index = 4;
this.mnuWordWrap.Text = "Word Wrap";
this.mnuWordWrap.Click += new System.EventHandler(this.mnuWordWrap_Click);
//
// mnuHelp
//
this.mnuHelp.Index = 2;
this.mnuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuAbout});
this.mnuHelp.Text = "Help";
//
// mnuAbout
//
this.mnuAbout.Index = 0;
this.mnuAbout.Text = "About DeltaScope";
this.mnuAbout.Click += new System.EventHandler(this.mnuAbout_Click);
//
// tabDeltaViews
//
this.tabDeltaViews.Appearance = System.Windows.Forms.TabAppearance.FlatButtons;
this.tabDeltaViews.ContextMenu = this.TabMenu;
this.tabDeltaViews.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabDeltaViews.Location = new System.Drawing.Point(0, 0);
this.tabDeltaViews.Name = "tabDeltaViews";
this.tabDeltaViews.SelectedIndex = 0;
this.tabDeltaViews.ShowToolTips = true;
this.tabDeltaViews.Size = new System.Drawing.Size(536, 321);
this.tabDeltaViews.TabIndex = 7;
//
// TabMenu
//
this.TabMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuCloseTab});
this.TabMenu.Popup += new System.EventHandler(this.TabMenu_Popup);
//
// mnuCloseTab
//
this.mnuCloseTab.Index = 0;
this.mnuCloseTab.Text = "Close Tab";
this.mnuCloseTab.Click += new System.EventHandler(this.mnuCloseTab_Click);
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 321);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusBarPanel1});
this.statusBar1.ShowPanels = true;
this.statusBar1.Size = new System.Drawing.Size(536, 16);
this.statusBar1.TabIndex = 6;
//
// statusBarPanel1
//
this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
this.statusBarPanel1.Name = "statusBarPanel1";
this.statusBarPanel1.Width = 519;
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(536, 337);
this.Controls.Add(this.tabDeltaViews);
this.Controls.Add(this.statusBar1);
this.Menu = this.mainMenu1;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "DeltaScope v 0.6";
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
this.ResumeLayout(false);
}
#endregion
#region Generic .NET code
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
components.Dispose();
}
base.Dispose( disposing );
}
#endregion
#region Event Trigger overrides
protected override void OnResize(EventArgs e)
{
if ((Site != null) && Site.DesignMode)
base.OnResize(e);
else
{
if (OwnedForms.Length > 0)
{
var loForm = (DropDownForm)OwnedForms[0];
loForm.SetLocation();
}
if (!idleHooked)
{
Application.Idle += OnIdle;
idleHooked = true;
}
}
}
private void OnIdle(object sender, EventArgs e)
{
Invalidate();
PerformLayout();
if (!idleHooked) return;
Application.Idle -= OnIdle;
idleHooked = false;
}
#endregion
#region GUI Event-handler Methods
private void mnuWordWrap_Click(object sender, EventArgs e)
{
mnuWordWrap.Checked = !(mnuWordWrap.Checked);
DeltaScopeApp.WordWrap = mnuWordWrap.Checked;
}
private void mnuExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void mnuFont_Click(object sender, EventArgs e)
{
_FontDlg.ShowEffects = true;
_FontDlg.FontMustExist = true;
_FontDlg.Font = DeltaScopeApp.SwirlFont;
_FontDlg.ShowDialog(this);
DeltaScopeApp.SwirlFont = _FontDlg.Font;
}
private void mnuShowSwirlRegionBoundry_Click(object sender, EventArgs e)
{
mnuShowSwirlRegionBoundry.Checked = !mnuShowSwirlRegionBoundry.Checked;
DeltaScopeApp.SwirlRegionVisible = mnuShowSwirlRegionBoundry.Checked;
}
private void _setFontSmoothing(MenuItem toFontMenu, TextRenderingHint toHint)
{
if (toFontMenu.Checked) return;
mnuFontSmoothing_AntiAlias.Checked = false;
mnuFontSmoothing_AntiAlias_GridFit.Checked = false;
mnuFontSmoothing_ClearType_GridFit.Checked = false;
mnuFontSmoothing_SingleBitPerPixel.Checked = false;
mnuFontSmoothing_SingleBitPerPixel_GridFit.Checked = false;
mnuFontSmoothing_SystemDefault.Checked = false;
toFontMenu.Checked = true;
// _SwirlController.TextRenderingHint = toHint;
// SwirlDisplay1.OnRedraw();
}
private void mnuFontSmoothing_AntiAlias_Click(object sender, EventArgs e)
{
_setFontSmoothing(mnuFontSmoothing_AntiAlias, TextRenderingHint.AntiAlias);
}
private void mnuFontSmoothing_AntiAlias_GridFit_Click(object sender, EventArgs e)
{
_setFontSmoothing(mnuFontSmoothing_AntiAlias_GridFit, TextRenderingHint.AntiAliasGridFit);
}
private void mnuFontSmoothing_ClearType_GridFit_Click(object sender, EventArgs e)
{
_setFontSmoothing(mnuFontSmoothing_ClearType_GridFit, TextRenderingHint.ClearTypeGridFit);
}
private void mnuFontSmoothing_SingleBitPerPixel_Click(object sender, EventArgs e)
{
_setFontSmoothing(mnuFontSmoothing_SingleBitPerPixel, TextRenderingHint.SingleBitPerPixel);
}
private void mnuFontSmoothing_SingleBitPerPixel_GridFit_Click(object sender, EventArgs e)
{
_setFontSmoothing(mnuFontSmoothing_SingleBitPerPixel_GridFit, TextRenderingHint.SingleBitPerPixelGridFit);
}
private void mnuFontSmoothing_SystemDefault_Click(object sender, EventArgs e)
{
_setFontSmoothing(mnuFontSmoothing_SystemDefault, TextRenderingHint.SystemDefault);
}
private void mnuOpenFiles_Click(object sender, EventArgs e)
{
OpenFilesDialog loForm = new OpenFilesDialog(true);
AddOwnedForm(loForm);
loForm.Show();
}
#endregion
private void TabMenu_Popup(object sender, EventArgs e)
{
ptPopupLocation = PointToClient(MousePosition);
}
private void mnuCloseTab_Click(object sender, EventArgs e)
{
if (ptPopupLocation != Point.Empty)
{
var loHoveringPage = GetTabPageByTab(ptPopupLocation, tabDeltaViews);
if (loHoveringPage != null) tabDeltaViews.TabPages.Remove(loHoveringPage);
}
ptPopupLocation = Point.Empty;
if (tabDeltaViews.TabPages.Count == 0)
tabDeltaViews.Appearance = TabAppearance.FlatButtons;
}
private void mnuAbout_Click(object sender, EventArgs e)
{
MessageBox.Show(Application.ProductName.Trim() + "\r\n" + Application.ProductVersion.Trim());
}
}
}
|
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.