Example #1
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            App.PublishVersion = GetPublishedVersion();
            if (Directory.Exists(Module.TravoxSentinel + "Exception"))
            {
                Array.ForEach(Directory.GetFiles(Module.TravoxSentinel + "Exception"), (string path) => { File.Delete(path); });
            }
            
            if (!Directory.Exists(Module.TravoxSentinel)) Directory.CreateDirectory(Module.TravoxSentinel);
            if (!Directory.Exists(Module.TravoxTemp)) Directory.CreateDirectory(Module.TravoxTemp);
            
            Mutex objMutex = new Mutex(false, Process.GetCurrentProcess().ProcessName);

            if (e.Args.Length > 0)
            {

            }
            else if (objMutex.WaitOne(0, false) == false)
            {
                MessageBox.Show("The Travox Sentinel is still running, Please try again in a moment.", "Travox Sentinel " + PublishVersion, MessageBoxButton.OK);
                Application.Current.Shutdown();
            }
            else
            {
                String LogCurrent = Module.TravoxSentinel + "log/" + DateTime.Now.ToString("yyyy-MM-dd") + Module.File_Log;
                if (File.Exists(LogCurrent)) File.Delete(LogCurrent);

                Log = new StringBuilder();
                TimeUp = new Stopwatch();
                BackgroundWorker InitWorker = new BackgroundWorker();

                WindowContext = new DialogContext();
                WindowInitialize = new DialogInitialize();
                NotifySentinal = new System.Windows.Forms.NotifyIcon();
                NotifySentinal.Visible = true;
                NotifySentinal.Text = "Travox Sentinel";
                NotifySentinal.Click += new EventHandler(Notify_OnClick);
                this.NotifyIcon(FindResource("NotifyOnStop"));

                InitWorker.DoWork += WorkSentinelServices;
                InitWorker.DoWork += WorkCrawlerCollection;
                InitWorker.ProgressChanged += WorkProgress;
                InitWorker.RunWorkerCompleted += WorkCompleted;
                InitWorker.WorkerSupportsCancellation = true;
                InitWorker.WorkerReportsProgress = true;

                App.ServerConnected = false;
                App.WebCrawlerConnected = false;
                App.WebCrawlerRestarted = true;
                App.CrawlerRunning = true;
                InitWorker.RunWorkerAsync();
                TimeUp.Start();
            }
        }
 private void btnAbout_Click(object sender, RoutedEventArgs e)
 {
     if (about == null || !about.IsShow)
     {
         about = new DialogInitialize(true);
         about.IsShow = true; 
         about.Show();
     }
     about.Topmost = true;
     about.Activate();
     about.Topmost = false;
 }