completo commit x rimozione gestione tray
This commit is contained in:
Generated
-18
@@ -45,8 +45,6 @@
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.FileTSMI = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mLoadConf = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
|
||||
this.trayMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.lblTopCent = new System.Windows.Forms.Label();
|
||||
this.lblTopDx = new System.Windows.Forms.Label();
|
||||
@@ -201,20 +199,6 @@
|
||||
this.mLoadConf.Text = "&LOAD CONF";
|
||||
this.mLoadConf.Click += new System.EventHandler(this.mLoadConf_Click);
|
||||
//
|
||||
// notifyIcon1
|
||||
//
|
||||
this.notifyIcon1.ContextMenuStrip = this.trayMenu;
|
||||
this.notifyIcon1.Text = "IOB-WIN";
|
||||
this.notifyIcon1.Visible = true;
|
||||
this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
|
||||
//
|
||||
// trayMenu
|
||||
//
|
||||
this.trayMenu.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.trayMenu.Name = "trayMenu";
|
||||
this.trayMenu.Size = new System.Drawing.Size(61, 4);
|
||||
this.trayMenu.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.trayMenu_ItemClicked);
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
@@ -591,8 +575,6 @@
|
||||
private System.Windows.Forms.Timer gather;
|
||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.NotifyIcon notifyIcon1;
|
||||
private System.Windows.Forms.ContextMenuStrip trayMenu;
|
||||
private System.Windows.Forms.ToolStripStatusLabel lblApp;
|
||||
private System.Windows.Forms.ToolStripStatusLabel lblVers;
|
||||
private System.Windows.Forms.ToolStripProgressBar MainProgrBar;
|
||||
|
||||
+1
-122
@@ -138,11 +138,6 @@ namespace IOB_WIN
|
||||
firstStart = DateTime.Now;
|
||||
lastStartTry = DateTime.Now;
|
||||
|
||||
// fix icon!
|
||||
notifyIcon1.Text = string.Format("IOB-WIN | {0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
|
||||
Icon = Icon.ExtractAssociatedIcon(utils.defIconFilePath);
|
||||
notifyIcon1.Icon = Icon.ExtractAssociatedIcon(utils.defIconFilePath);
|
||||
|
||||
// fix versione!
|
||||
lblApp.Text = string.Format("{0}", ConfigurationManager.AppSettings.Get("appName"));
|
||||
lblVers.Text = string.Format(" v.{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
|
||||
@@ -196,19 +191,7 @@ namespace IOB_WIN
|
||||
displTimer.Enabled = true;
|
||||
|
||||
displayTaskAndLog("Program Running");
|
||||
createTrayMenu();
|
||||
displayTaskAndLog("Tray Menu OK");
|
||||
|
||||
// avvio minimizzato se richiesto
|
||||
if (utils.CRB("startMinimized"))
|
||||
{
|
||||
// imposto minimized se necessario!
|
||||
if (WindowState != FormWindowState.Minimized)
|
||||
{
|
||||
WindowState = FormWindowState.Minimized;
|
||||
}
|
||||
displayTaskAndLog("Minimized");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// segnalo reboot (programma)...
|
||||
@@ -236,12 +219,6 @@ namespace IOB_WIN
|
||||
/// <param name="e"></param>
|
||||
private void MainForm_Shown(object sender, EventArgs e)
|
||||
{
|
||||
// avvio minimizzato se richiesto
|
||||
if (utils.CRB("startMinimized"))
|
||||
{
|
||||
// controllo e mando a tray...
|
||||
sendToTray();
|
||||
}
|
||||
displayTaskAndLog("Main Form SHOWN");
|
||||
}
|
||||
/// <summary>
|
||||
@@ -251,104 +228,6 @@ namespace IOB_WIN
|
||||
/// <param name="e"></param>
|
||||
private void MainForm_Resize(object sender, EventArgs e)
|
||||
{
|
||||
checkFormVisibility();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region gestione tray
|
||||
|
||||
/// <summary>
|
||||
/// crea menù tray x applicazione
|
||||
/// </summary>
|
||||
private void createTrayMenu()
|
||||
{
|
||||
// Fix testi menù tray...
|
||||
trayMenu.Items.Clear();
|
||||
// SE permessa massimizzazione...
|
||||
if (utils.CRB("windowCanMax"))
|
||||
{
|
||||
trayMenu.Items.Add("Show IOB-WIN");
|
||||
}
|
||||
// se è permesso tray close...
|
||||
if (utils.CRB("trayClose"))
|
||||
{
|
||||
trayMenu.Items.Add("Close IOB-WIN");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// doppio click su tray icon
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
// SOLO SE PERMESSO mostrare full...
|
||||
if (utils.CRB("windowCanMax"))
|
||||
{
|
||||
Show();
|
||||
WindowState = FormWindowState.Normal;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Verifica stato windows (minimized/normal) e visibilità con tray...
|
||||
/// </summary>
|
||||
private void checkFormVisibility()
|
||||
{
|
||||
// se non può massimizzare imposto COMUNQUE a minimized...
|
||||
if (!utils.CRB("windowCanMax"))
|
||||
{
|
||||
WindowState = FormWindowState.Minimized;
|
||||
}
|
||||
// controllo cosa devo mostrare...
|
||||
if (WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
notifyIcon1.Visible = false;
|
||||
sendToTray();
|
||||
}
|
||||
else
|
||||
{
|
||||
notifyIcon1.Visible = false;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Gestisce "andata nel tray" della form
|
||||
/// </summary>
|
||||
private void sendToTray()
|
||||
{
|
||||
if (!notifyIcon1.Visible)
|
||||
{
|
||||
notifyIcon1.BalloonTipTitle = utils.CRS("appName");
|
||||
notifyIcon1.BalloonTipText = string.Format("{0} running on tray", utils.CRS("appName"));
|
||||
notifyIcon1.Visible = true;
|
||||
notifyIcon1.ShowBalloonTip(100);
|
||||
}
|
||||
Hide();
|
||||
}
|
||||
/// <summary>
|
||||
/// click su menù contestuale in tray
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void trayMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
{
|
||||
if (e.ClickedItem.Text.StartsWith("Close"))
|
||||
{
|
||||
// stop adapter...
|
||||
closeAdapter();
|
||||
// chiudo!
|
||||
Close();
|
||||
}
|
||||
else if (e.ClickedItem.Text.StartsWith("Show"))
|
||||
{
|
||||
if (utils.CRB("windowCanMax"))
|
||||
{
|
||||
Show();
|
||||
WindowState = FormWindowState.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user