private static void openUI()
        {
            _trayIcon.Visible = false;

            var ui = new BackgroundManagerUI.MainWindow();

            //*-------copy data--------*/
            ui.InitializeComponent();

            ui.Data        = Handle.data;
            ui.DataContext = ui.Data;

            ui.loadNonBindings();
            //*------------------------*/

            ui.ShowDialog();

            _trayIcon.Visible = true;

            if (ui.IsToClose)
            {
                WinFormApplication.Exit();
            }

            ui = null;
        }
        public void Completato(object o, AsyncCompletedEventArgs args)
        {
            log("Disinstallando la vecchia versione...[0%]");
            log("Disinstallata la vecchia verisone[40%]");

            MessageBox.Show("Disintallando la vecchia versione", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            string app_name = ApplicationForm.StartupPath + "\\" + ApplicationForm.ProductName + ".exe";
            string bat_name = app_name + ".bat";

            string bat =
                "@echo off\n"                                                                                          //CHECK BEFORE RELEASE
                + ":loop\n"
                + "del \"" + app_name + "\"\n"
                + "if Exist \"" + app_name + "\" GOTO loop\n"
                + "ren PercentualeAlunni_new.exe PercentualeAlunni.exe\n"
                + "del %0\n"
                + "start PercentualeAlunni.exe";

            StreamWriter file = new StreamWriter(bat_name);

            file.Write(bat);
            file.Close();

            Process bat_call = new Process();

            bat_call.StartInfo.FileName        = bat_name;
            bat_call.StartInfo.WindowStyle     = ProcessWindowStyle.Hidden;
            bat_call.StartInfo.UseShellExecute = true;
            bat_call.Start();

            log("Disinstallata la vecchia verisone[100%]");
            log("Download terminato.");

            ApplicationForm.Exit();
        }
 void OtherMachineNoClearnWarningWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (DialogResult != true)
     {
         Application.Exit();
     }
 }
Exemple #4
0
        private void OnExit(object sender, EventArgs e)
        {
            _core.EndService();

            _trayIcon.Visible = false;
            Self.Exit();
        }
        public TestContext()
            : base()
        {
            try
            {
                if (!SboApp.ApplicationConnected)
                {
                    throw new Exception("SboApp not Connected");
                }


                //Test_CopyTo();

                //Test_Form();
                //Test_MenuCreate();
                //Test_GetString();
                //Test_Setting();
                //Test_SettingAsk();
                //Test_FileDialogs();
                Test_SendMessage();
            }
            catch (Exception e)
            {
                MessageBox.Show($"Error: {e.Message}\nExiting...");
                Application.Exit();
            }
        }
Exemple #6
0
        private void messBox()
        {
            var message = "Voulez vous recommencer ?";
            var title   = "Hey!";
            var result  = MessageBox.Show(
                message,
                title,
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question);

            switch (result)
            {
            case DialogResult.Yes:
                iniform();
                Form1_Load();
                break;

            case DialogResult.No:
                Application.Exit();
                break;

            default:
                MessageBox.Show("What did you press?");
                break;
            }
        }
        private void BtnRetry_OnClick(object sender, RoutedEventArgs e)
        {
            IRestaurantService service = new RestaurantServiceImpl();
            var result = service.GetUnclearnPosInfo();

            if (!string.IsNullOrEmpty(result.Item1))
            {
                frmWarning.ShowWarning(result.Item1);
                return;
            }

            var noClearnMachineList = result.Item2;

            if (noClearnMachineList.Any()) //这里只需要判断有未清机的就不关闭窗口。
            {
                return;
            }

            string reinfo;

            if (!RestClient.OpenUp("", "", 0, out reinfo))//如果判断未开业则说明结业成功了。
            {
                Application.Exit();
            }

            DialogResult = true;
            Close();
        }
Exemple #8
0
 private void Exit()
 {
     trayIcon.Visible = false;
     muteForm.SaveSettings();
     muteForm.Close();
     WinFormsApplication.Exit();
 }
Exemple #9
0
        private async Task InitSession()
        {
            try
            {
                StatusText = "Inititializing session...";
                await osdbClient.InitSessionAsync();
            }
            catch (OSDbException e)
            {
                var result = MessageBox.Show(
                    $"Failed to initialize session: {e.Message}",
                    "Error",
                    MessageBoxButtons.RetryCancel,
                    MessageBoxIcon.Error);

                if (result == DialogResult.Retry)
                {
                    await InitSession();
                }
                else
                {
                    Application.Exit();
                }
            }

            StatusText = "Session initialized.";
        }
 private static void Main()
 {
     if (!IsAdministrator())
     {
         var info = new ProcessStartInfo(Assembly.GetExecutingAssembly().GetName().Name);
         info.Verb = "runas";
         Process.Start(info);
         Application.Exit();
     }
     else
     {
         AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         try
         {
             Application.Run(new MainForm());
         }
         catch (Exception ex)
         {
             TraceHelper.Tracer.WriteTrace(ex.ToString());
             MessageBox.Show(ex.ToString());
         }
     }
 }
Exemple #11
0
        private void ExitMenu_Click(object sender, EventArgs e)
        {
            Dispose();
            Startup.DisposeOutlookObjects();

            Application.Exit();
        }
        //关闭窗口前
        private void AutoUpdateFrm_FormClosing(object sender, FormClosingEventArgs e)
        {
            Process[] appProcess = Process.GetProcessesByName("在线投标工具");
            //防止多次调用主程序
            if (appProcess.Length <= 0)
            {
                //启动 调用更新程序
                string startExe = $@"{AppDomain.CurrentDomain.BaseDirectory}{mainexe}";
                if (File.Exists(startExe))
                {
                    ProcessStartInfo info = new ProcessStartInfo();
                    info.FileName    = startExe;
                    info.Arguments   = "";
                    info.WindowStyle = ProcessWindowStyle.Minimized;
                    Process.Start(info);
                }
            }

            Process[] process = Process.GetProcessesByName("online_bid_autoUpdate");
            foreach (Process prc in process)
            {
                prc.Kill();
                return;
            }
            Application.Exit();//退出应用程序
        }
Exemple #13
0
        private void InitializeTrayIcon()
        {
            _trayMenu = new ContextMenu();

            var item = new MenuItem("Auto Start");

            item.Checked = AutoStart();
            item.Click  += OnAutoStartClick;
            _trayMenu.MenuItems.Add(item);

            _trayMenu.MenuItems.Add("Reset", OnResetClickedOnClick);
            _trayMenu.MenuItems.Add("-");
            _trayMenu.MenuItems.Add("Exit", (sender, args) => Application.Exit());

            components = new Container();

            _trayIcon = new NotifyIcon(components)
            {
                Text        = "SoftU2F Daemon",
                ContextMenu = _trayMenu,
                Icon        = new Icon("tray.ico"),
                Visible     = true
            };

            _trayIcon.BalloonTipClicked += (sender, args) =>
            {
                _notificationOpen = false;
                _userPresenceCallback?.Invoke(true);
            };
            _trayIcon.BalloonTipShown  += (sender, args) => _notificationOpen = true;
            _trayIcon.BalloonTipClosed += (sender, args) => _notificationOpen = false;
        }
Exemple #14
0
        private static void ShowCrashDialog(Exception ex)
        {
            string msg    = ex == null ? "Unexpected error" : $"An error occurred: {ex.Message}";
            string detail = ex == null ? "" : ex.ToString();

            MessageBox.Show(text: $"{msg}\n\nPlease report this error at {ProgramInfo.GithubUrl}\n\nError details:\n\n{detail}", caption: "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            WinFormsApplication.Exit();
        }
        public void Shutdown()
        {
            var outStream = Encoding.Unicode.GetBytes("\0CLIMSG\0exit");

            _serverStream.Write(outStream, 0, outStream.Length);
            _serverStream.Close(1000);
            Application.Exit();
            Environment.Exit(0);
        }
        /// <summary>
        /// Downloading and installing latest update from GitHub.
        /// </summary>
        public async void DownloadAndInstallUpdate()
        {
            if (latestRelease == null)
            {
                return; // Probably shouldn't happen, but just in case
            }
            // Check whether the application is installed or used as a portable app
            int fileType = Application.StartupPath.EndsWith("Roaming\\CustomRP") ? 0 : 1; // 0 is exe, 1 is zip

            var wc   = new WebClient();
            var exec = Path.GetTempPath() + latestRelease.Assets[fileType].Name;

            wc.DownloadProgressChanged += DownloadProgress;

            while (true)
            {
                try
                {
                    if (!File.Exists(exec))
                    {
                        await wc.DownloadFileTaskAsync(latestRelease.Assets[fileType].BrowserDownloadUrl, exec);
                    }

                    if (fileType == 1) // Open up app's folder for ease of manual update
                    {
                        Process.Start(Application.StartupPath);
                    }
                    Process.Start(exec);

                    Application.Exit();
                    break;
                }
                catch
                {
                    if (File.Exists(exec))
                    {
                        File.Delete(exec);
                    }

                    var result = MessageBox.Show(this, Strings.errorUpdateFailed, Strings.error, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);

                    if (result == DialogResult.Yes)
                    {
                        continue;
                    }
                    else if (result == DialogResult.No)
                    {
                        Process.Start(latestRelease.Assets[fileType].BrowserDownloadUrl);
                    }

                    downloadUpdateToolStripMenuItem.Enabled = true;
                    downloadUpdateToolStripMenuItem.Text    = res.GetString("downloadUpdateToolStripMenuItem.Text");

                    break;
                }
            }
        }
        // Called when you click File -> Quit or right-click on the tray icon and choose Quit
        private void Quit(object sender, EventArgs e)
        {
            if (client != null)
            {
                client.Dispose();
            }

            settings.Save();
            Application.Exit();
        }
Exemple #18
0
        private void exit_Click(object sender, EventArgs e)
        {
            notifyIcon1.Dispose();
            needAbort = true;
            Logger.Close();
            _photoShopLisener.Stop();
            _saiLisener.Stop();

            Application.Exit();
        }
Exemple #19
0
        private void openDoc2(string path, out Word.Document document)
        {
            if (!File.Exists(path))
            {
                MessageBox.Show("File cannot found");
                Application.Exit();
            }

            document = wordApp.Documents.Open(path);
        }
Exemple #20
0
        /// <summary>
        /// Called when the application is shutdown.
        /// </summary>
        protected override void OnShutdown()
        {
            InvokeOnUi(() =>
            {
                FormsApplication.Exit();

                FormsApplication.ThreadException           -= new ThreadExceptionEventHandler(Forms_UiUnhandledException);
                AppDomain.CurrentDomain.UnhandledException -= new UnhandledExceptionEventHandler(Forms_UnhandledException);
            });
        }
        /// <summary>
        /// Called when you click File -> Quit or right-click on the tray icon and choose Quit.
        /// </summary>
        private void Quit(object sender, EventArgs e)
        {
            if (client != null)
            {
                client.Dispose();
            }

            if (Utils.SaveSettings())
            {
                Application.Exit();
            }
        }
Exemple #22
0
        private void ExitMenu_Click(object sender, EventArgs e)
        {
            Dispose();

            Startup.OutlookExplorer.Close();
            Startup.OutlookExplorer  = null;
            Startup.OutlookFolder    = null;
            Startup.OutlookNameSpace = null;
            Startup.OutlookApp       = null;

            Application.Exit();
        }
Exemple #23
0
        private void openSheet2(string path, out Excel.Workbook workbook, out Excel.Worksheet worksheet, string sheetName)
        {
            if (!File.Exists(path))
            {
                MessageBox.Show("File cannot found");
                Application.Exit();
            }

            workbook = excelApp.Workbooks.Open(path);

            worksheet = workbook.Worksheets[sheetName];
        }
Exemple #24
0
        private static void Startup(string[] args)
        {
            bool startMinimized = args.Any(a => a.Equals("/background", StringComparison.OrdinalIgnoreCase));
            var  ctx            = MuteAppContext.Create(startMinimized);

            if (ctx != null)
            {
                WinFormsApplication.Run(ctx);
            }
            else
            {
                WinFormsApplication.Exit();
            }
        }
Exemple #25
0
        private void Web_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            System.Threading.Thread.Sleep(2000);
            string pth = Path.Combine(Application.StartupPath, "ZOKUpdater.exe");

            if (!File.Exists(pth))
            {
                Main.ShowError("Güncelleme aracı bulunamadı.");
                File.Delete(pth);
            }
            System.Diagnostics.Process.Start(pth);
            web.Dispose();
            Application.Exit();
        }
Exemple #26
0
        // Method to Check if a new updated version does exist.
        public static void check()
        {
            Form1     f      = new Form1();                                                 // To get access to Form1 (my main Form)
            WebClient client = new WebClient();                                             // WebClient to get latest version number from Server

            try
            {
                Stream       stream = client.OpenRead("http://127.0.0.1/path/to/version.txt"); // Replace URL with your server. End must be version.txt, otherwise
                StreamReader reader = new StreamReader(stream);                                // update the code to your changes
                content = reader.ReadToEnd();
            }
            catch (Exception ex)
            {
                Clipboard.SetText(ex.Message);                                              // If any errors happen, it copies the error message to clipboard
                MessageBox.Show("Unable to get Version number", "error");
            }

            if (content == System.Windows.Forms.Application.ProductVersion)
            {
                // Do nothing because you are already on the newest version
            }
            else
            {
                // Here you could add DialogResult to let the user choose to update or not.
                // Currently it just shows a message for testing purposes. Just delete this line if you dont need it or comment
                // it out
                MessageBox.Show("A New update was found", "info");

                try
                {
                    // This downloads the update.exe and saves it to the applications startup path.
                    // update.exe is a SFX WinRAR Archive using Override Existing files etc...
                    client.DownloadFile("http://127.0.0.1/path/to/update.exe", Application.StartupPath + "\\update.exe");

                    // If downloaded Update file exists, execute update file and close itself
                    // (close itself because of overwriting issues if keeps running)
                    if (File.Exists(Application.StartupPath + "\\update.exe"))
                    {
                        Process.Start(Application.StartupPath + "\\update.exe");
                        Application.Exit();
                    }
                }
                catch (Exception ex1)
                {
                    Clipboard.SetText(ex1.Message);
                    MessageBox.Show("Could not download update", "error");
                }
            }
        }
Exemple #27
0
        public void genForm(int rowNum = 0)
        {
            string path = workPath + dataFileName;

            if (!File.Exists(path))
            {
                MessageBox.Show("File cannot found");
                Application.Exit();
            }

            thisWorkBook = excelApp.Workbooks.Open(path);

            nameWorkSheet  = thisWorkBook.Worksheets["Name"];
            classWorkSheet = thisWorkBook.Worksheets["Class"];

            Excel.Range nameRange  = nameWorkSheet.UsedRange;
            Excel.Range classRange = classWorkSheet.UsedRange;

            List <string> nameList  = new List <string>();
            List <string> classList = new List <string>();

            try
            {
                for (int i = startNum; i <= nameRange.Rows.Count; i++)
                {
                    nameList.Add(nameRange.Cells[i, 1].Text);
                }

                for (int i = startNum; i <= classRange.Rows.Count; i++)
                {
                    classList.Add(classRange.Cells[i, 1].Text);
                }

                for (int i = 0; i < nameList.Count; i++)
                {
                    WriteLine(nameList[i]);
                }

                for (int i = 0; i < classList.Count; i++)
                {
                    WriteLine(classList[i]);
                }
            }
            finally
            {
                thisWorkBook.Close(false);
                excelApp.Quit();
            }
        }
Exemple #28
0
 //应用程序关闭
 private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     //DialogResult result = MessageBox.Show("是否关闭应用程序?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
     //if (DialogResult.Yes == result)
     //{
     //    e.Cancel = false;
     m_mainThread?.Abort();
     t_change?.Abort();
     Application.Exit();
     //}
     //else
     //{
     //    e.Cancel = true;
     //}
 }
        private void OnApplicationExit(Object sender = null, EventArgs e = null)
        {
            if (_isTerminated == true)
            {
                return;
            }

            _notifyIcon.Visible = false;

            CloseConsole();

            Application.Exit();
            Application.ExitThread();

            _isTerminated = true;
        }
Exemple #30
0
        private void InitializeBackgroundDaemon()
        {
            var daemon = _serviceProvider.GetService <IU2FBackgroundTask>();

            if (!daemon.OpenDevice())
            {
                MessageBox.Show("Failed to load driver. Maybe installation was unsuccessful\nExiting", "Driver Error");
                if (Application.MessageLoop)
                {
                    Application.Exit();
                }
                Environment.Exit(1);
                return;
            }
            (new Thread(() => { daemon.StartIoLoop(_cancellation.Token); })).Start();
            UserPresence.Sender = this;
        }