|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Security.Permissions;
using System.Security;
namespace WindowTabifier
{
public partial class Main : Form
{
Properties.Settings set = new WindowTabifier.Properties.Settings();
About.AboutBox box = new About.AboutBox("Window Tabifier");
public Main()
{
InitializeComponent();
box.programname = "Window Tabifier";
box.StartPosition = FormStartPosition.CenterScreen;
box.BackColor = Color.SandyBrown;
}
private bool isstartup()
{
bool result = false;
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
result = key.GetValue("Window Tabifier") != null;
key.Close();
return result;
}
[RegistryPermissionAttribute(SecurityAction.LinkDemand, Write = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run")]
private void startup(bool add)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
if (add)
{
key.SetValue("Window Tabifier", "\"" + Application.ExecutablePath + "\"");
}
else
key.DeleteValue("Window Tabifier");
key.Close();
}
private void Exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void Form1_Load(object sender, EventArgs e)
{
if (!System.IO.File.Exists(Application.StartupPath + "\\Window Tabifier.exe.config"))
{
MessageBox.Show("Configuration file not found.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
Application.Exit();
}
System.IO.Directory.SetCurrentDirectory(Application.StartupPath);
winapi.statusbar = winapi.FindWindow("Shell_TrayWnd", "");
set.Startup = isstartup();
Tray.ShowBalloonTip(5);
this.Hide();
}
private void Tab_Click(object sender, EventArgs e)
{
WindowList wnd = new WindowList();
if (wnd.ShowDialog() == DialogResult.OK && wnd.SelectedWindows.Count>0)
{
Host hostform = new Host(wnd.SelectedWindows);
hostform.Show();
wnd.Dispose();
}
}
private void tabAll_Click(object sender, EventArgs e)
{
Host hostwindow = null;
if (Properties.Settings.Default.Ignore)
{
hostwindow = new Host(window.GetOpenWindows().FindAll(delegate(window wnd) { return wnd.Title.Length > 0 && wnd.GetExecutablePath() != Application.ExecutablePath; }));
}
else
{
hostwindow = new Host(window.GetOpenWindows().FindAll(delegate(window wnd) { return wnd.GetExecutablePath() != Application.ExecutablePath; }));
}
hostwindow.Show();
}
private void Tray_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (!this.Visible)
{
this.Show();
this.WindowState = FormWindowState.Normal;
}
}
private void Main_FormClosing(object sender, FormClosingEventArgs e)
{
if (startupCheck.Checked!=set.Startup)
{
startup(startupCheck.Checked);
}
set.Startup = startupCheck.Checked;
set.Ignore = ignoreCheck.Checked;
set.Save();
set.Reload();
if (e.CloseReason==CloseReason.UserClosing)
{
this.Hide();
e.Cancel = true;
}
}
private void About_Click(object sender, EventArgs e)
{
if (!box.Visible)
{
box.ShowDialog();
}
}
}
}
|
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.