Esempio n. 1
0
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            //clean up notifyicon (would otherwise stay open until application finishes)
            MainNotifyIcon.Dispose();

            base.OnClosing(e);
        }
Esempio n. 2
0
        public FormMain(System.Diagnostics.Process process)
        {
            InitializeComponent();
            if (process != null)//重复打开对应事件
            {
                MainNotifyIcon.Visible = false;

                this.Visible       = false;
                this.ShowInTaskbar = false;
                this.ShowIcon      = false;
                this.Hide();

                MainNotifyIcon.ShowBalloonTip(10, "程序已运行", "后台已运行动态壁纸", ToolTipIcon.Info);
                //弹出系统通知
                Win32.ShowWindow(process.MainWindowHandle, 10);
                //将已打开程序前置
                //this.Dispose();
                this.Close();
                //Application.ExitThread();
                //自我关闭
            }
            SetDefaultPictureMain();
            MainNotifyIcon.Visible = true;
            if (SetFile.Default.IsFristStatUp == true)
            {
                //SetFile.Default.IsFristStatUp = false;
                //SetFile.Default.Save();
            }
        }
Esempio n. 3
0
        private void RefreshPrimeNotifyIcon(string InputNotifyMessageStr)
        {
            string MessageNotifyIconText = "◆◆◆";

            //MainNotifyIcon.Text = MessageNotifyIconText + InputNotifyMessageStr;
            MainNotifyIcon.BalloonTipTitle = MessageNotifyIconText;
            MainNotifyIcon.BalloonTipText  = InputNotifyMessageStr;
            MainNotifyIcon.ShowBalloonTip(100);
        }
Esempio n. 4
0
        private void ShowBalloon()
        {
            string title = "Happy Team";
            string text  = "I'll be right here!";

            MainNotifyIcon.ShowBalloonTip(title, text, Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info);

            Thread.Sleep(4000);
            MainNotifyIcon.HideBalloonTip();
        }
Esempio n. 5
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                e.Cancel    = true;
                WindowState = FormWindowState.Minimized;
                Hide();
            }
            else
            {
                MainNotifyIcon.Dispose( );

                base.OnFormClosing(e);
            }
        }
Esempio n. 6
0
 //Action on window resizing
 private void MainWindow_Resize(object sender, EventArgs e)
 {
     if (this.WindowState == FormWindowState.Minimized)
     {
         MainNotifyIcon.Visible = true;
         if (!MinimizedToolTipShown)
         {
             MainNotifyIcon.ShowBalloonTip(500);
             MinimizedToolTipShown = true;
         }
         this.Hide();
         _IsHidden = true;
     }
     else if (this.WindowState == FormWindowState.Normal)
     {
         MainNotifyIcon.Visible = false;
         _IsHidden = false;
     }
 }
Esempio n. 7
0
        /// <summary>
        /// Click Update Setting Item
        /// </summary>
        /// <param name="sender">ToolStripMenuItem</param>
        /// <param name="args">Empty EventArgs</param>
        private void Click_UpdateToolStripMenuItem(object sender, EventArgs args)
        {
            var item    = sender as ToolStripMenuItem;
            var setting = item.Tag as Common.WinIPChangerSettingDetail;
            var adapter = new Network.NetworkAdapter()
            {
                Name           = setting.NetworkAdapterName,
                IsDhcpEnabled  = setting.IsDhcpEnabled,
                IPAddress      = (string.IsNullOrWhiteSpace(setting.IPAddress) ? null : IPAddress.Parse(setting.IPAddress)),
                SubnetMask     = (string.IsNullOrWhiteSpace(setting.SubnetMask) ? null : IPAddress.Parse(setting.SubnetMask)),
                DefaultGateway = (string.IsNullOrWhiteSpace(setting.DefaultGateway) ? null : IPAddress.Parse(setting.DefaultGateway))
            };

            foreach (var dns in setting.DnsServers)
            {
                adapter.DnsServers.Add(IPAddress.Parse(dns));
            }
            var result = Network.NetworkAdapterUtility.SetAdapterConfig(adapter, false);

            switch (result)
            {
            case Network.Results.Success:
                MainNotifyIcon.ShowBalloonTip(10, "Success!", "Update Network Info.", ToolTipIcon.Info);
                break;

            case Network.Results.SuccessRebootRequired:
                MainNotifyIcon.ShowBalloonTip(10, "Success!", "Update Network Info. But, Reboot Required!", ToolTipIcon.Warning);
                break;

            case Network.Results.ApiFailedError:
                MainNotifyIcon.ShowBalloonTip(10, "Error!", string.Format("API Error! Error Code: {0}.", Network.NetworkAdapterUtility.LastApiErrorCode), ToolTipIcon.Error);
                break;

            case Network.Results.TargetIsNotEnableIPError:
                MainNotifyIcon.ShowBalloonTip(10, "Error!", "Target Network Adapter is not enable IP.", ToolTipIcon.Error);
                break;

            case Network.Results.TargetNotFoundError:
                MainNotifyIcon.ShowBalloonTip(10, "Error!", "Target Network Adapter is not found.", ToolTipIcon.Error);
                break;
            }
        }
        private void DoFetch(bool showToastIfNoResult = false)
        {
            if (IsLocked)
            {
                return;
            }

            lock (this)
            {
                try
                {
                    var fetcher     = new GitFetcher();
                    var fetchResult = fetcher.Fetch();
                    if (fetchResult.AnyChanges)
                    {
                        var message = "Changes fetched in:";

                        message += String.Format
                                       ("{0}{0}{1}",
                                       Environment.NewLine,
                                       String.Join(Environment.NewLine, fetchResult.RelevantBranches));

                        var fetchInfo = new FetchInformation(message);
                        MainNotifyIcon.ShowCustomBalloon(fetchInfo, PopupAnimation.Fade, 10 * 60 * 1000);
                    }
                    else if (showToastIfNoResult)
                    {
                        var fetchInfo = new FetchInformation("No changes fetched");
                        MainNotifyIcon.ShowCustomBalloon(fetchInfo, PopupAnimation.Fade, 60 * 1000);
                    }
                }
                catch
                {
                    SystemSounds.Exclamation.Play();
                    MainNotifyIcon.ShowBalloonTip("Git Notifier", "An error has occured", BalloonIcon.Error);
                }
            }
        }
Esempio n. 9
0
        public MainForm()
        {
            InitializeComponent();
            try
            {
                XInputObj = new XInputManager();
                vJoyObj   = new vJoyManager();
                RefreshDeviceList();

                Application.ApplicationExit += new EventHandler(delegate(Object o, EventArgs a)
                {
                    StopThread();

                    // Bug or something but the notify icon lingers after exiting unless we explicitely dispose it
                    if (MainNotifyIcon != null)
                    {
                        MainNotifyIcon.Icon = null;
                        MainNotifyIcon.Dispose();
                        MainNotifyIcon = null;
                    }
                });

                string[] cmds = Environment.GetCommandLineArgs();
                HandleArguments(cmds);
            }
            catch (System.IO.FileNotFoundException e)
            {
                MessageBox.Show("FileNotFoundException: " + e.FileName + ". This may occur because of missing DLLs. Make sure to include everything! Application will exit..", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(-1);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error: " + e.Message + ". This may occur because of missing DLLs. Make sure to include everything! Application will exit..", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(-1);
            }
        }
Esempio n. 10
0
 private void RefreshPrimeNotifyIcon2(string MessageNotifyTipTitle, string MessageTipText)
 {
     MainNotifyIcon.BalloonTipTitle = MessageNotifyTipTitle;
     MainNotifyIcon.BalloonTipText  = MessageTipText;
     MainNotifyIcon.ShowBalloonTip(100);
 }
Esempio n. 11
0
 public MainController()
 {
     _tray = new MainNotifyIcon(_container, _coreInvoker);
 }
Esempio n. 12
0
        private void UpdateDrives()
        {
            int ok       = 0;
            int warning  = 0;
            int critical = 0;

            Grid.Rows.Clear();

            foreach (DriveInfo drive in DriveInfo.GetAllDrives().OrderBy(d => d.Name))
            {
                DataGridViewRow row = new DataGridViewRow();

                DataGridViewTextBoxCell cellName = new DataGridViewTextBoxCell();
                cellName.Value = drive.Name;
                row.Cells.Add(cellName);

                DataGridViewTextBoxCell cellFreeSpace = new DataGridViewTextBoxCell();
                cellFreeSpace.Value           = drive.FreeSpace.ToString("#,###,###,###,###");
                cellFreeSpace.Value           = drive.FreeSpace.GetAsNiceByteSize();
                cellFreeSpace.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                row.Cells.Add(cellFreeSpace);

                DataGridViewTextBoxCell cellSize = new DataGridViewTextBoxCell();
                cellSize.Value           = drive.TotalSpace.ToString("#,###,###,###,###");
                cellSize.Value           = drive.TotalSpace.GetAsNiceByteSize();
                cellSize.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                row.Cells.Add(cellSize);

                DataGridViewTextBoxCell percentFree = new DataGridViewTextBoxCell();
                percentFree.Value           = drive.PercentFree.ToString() + "%";
                percentFree.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                row.Cells.Add(percentFree);

                DataGridViewTextBoxCell status = new DataGridViewTextBoxCell();
                status.Value           = drive.Criticality.ToString();
                status.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                row.Cells.Add(status);

                Grid.Rows.Add(row);
                Application.DoEvents();

                if (drive.Criticality == DriveInfoStatuses.OK)
                {
                    ok++;
                }
                else if (drive.Criticality == DriveInfoStatuses.Warning)
                {
                    warning++;
                }
                else if (drive.Criticality == DriveInfoStatuses.Critical)
                {
                    critical++;
                }

                MainNotifyIcon.Text = string.Format("Windows Drive Information: {0} ok, {1} warning, {2} critical", ok, warning, critical);
                if (critical > 0)
                {
                    MainNotifyIcon.ShowBalloonTip(10000, "Freespace CRITICAL!", "There are drives with a critical amount of freespace", ToolTipIcon.Error);
                    this.Focus();
                }
                else if (warning > 0)
                {
                    MainNotifyIcon.ShowBalloonTip(10000, "Freespace warning", "There are drives with a reduced amount of freespace", ToolTipIcon.Warning);
                }
            }
        }