From 45bef542e08f2f31745cd4e1dd9244a6e0afca10 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 20 Dec 2017 12:36:48 +0100 Subject: [PATCH] completo commit x rimozione gestione tray --- IOB-WIN/AdapterForm.Designer.cs | 18 ----- IOB-WIN/AdapterForm.cs | 123 +------------------------------- 2 files changed, 1 insertion(+), 140 deletions(-) diff --git a/IOB-WIN/AdapterForm.Designer.cs b/IOB-WIN/AdapterForm.Designer.cs index f60f9ebd..dab14a4e 100644 --- a/IOB-WIN/AdapterForm.Designer.cs +++ b/IOB-WIN/AdapterForm.Designer.cs @@ -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; diff --git a/IOB-WIN/AdapterForm.cs b/IOB-WIN/AdapterForm.cs index 773073e9..8c8bd892 100644 --- a/IOB-WIN/AdapterForm.cs +++ b/IOB-WIN/AdapterForm.cs @@ -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 /// 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"); } /// @@ -251,104 +228,6 @@ namespace IOB_WIN /// private void MainForm_Resize(object sender, EventArgs e) { - checkFormVisibility(); - } - - #endregion - - #region gestione tray - - /// - /// crea menù tray x applicazione - /// - 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"); - } - } - - /// - /// doppio click su tray icon - /// - /// - /// - private void notifyIcon1_DoubleClick(object sender, EventArgs e) - { - // SOLO SE PERMESSO mostrare full... - if (utils.CRB("windowCanMax")) - { - Show(); - WindowState = FormWindowState.Normal; - } - } - /// - /// Verifica stato windows (minimized/normal) e visibilità con tray... - /// - 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; - } - - } - /// - /// Gestisce "andata nel tray" della form - /// - 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(); - } - /// - /// click su menù contestuale in tray - /// - /// - /// - 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