Beispiel #1
0
        private async Task Initialize()
        {
            RegistryKey rk = Registry.CurrentUser.OpenSubKey
                                 ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            if (rk.GetValue("AnnouncementHelper") != null)
            {
                Program.StartupEnabled = true;
            }
            if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\AnnouncementHelper\\"))
            {
                Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\AnnouncementHelper\\");
            }

            string[] files = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\AnnouncementHelper\\");
            foreach (string s in files)
            {
                string filename = s.Split('\\').Last();
                if (filename.Contains("reminder"))
                {
                    string date = filename.Split('_')[1].Split('T')[0];
                    if (DateTime.ParseExact(date, "yyyy-MM-dd", CultureInfo.InvariantCulture) <= DateTime.Now.Date)
                    {
                        StringEdit.Out("Βρέθηκε ανακοίνωση για σήμερα!", ref richTextBox1, StringEdit.OutType.Success);
                        await Task.Delay(1000);

                        Announcement temp = AnnouncementConvert.FromBase64(File.ReadAllText(s));
                        File.Delete(s);
                        new Thread(() =>
                        {
                            AnnouncementForm f1 = new AnnouncementForm(temp);
                            f1.ShowDialog();
                        })
                        {
                            IsBackground = true
                        }.Start();
                    }
                }
            }
            // Το httpClient χρησιμοποιεί proxy σαν default που το κάνει αργό
            // οπότε το αφαιρούμε
            HttpClientHandler hch = new HttpClientHandler
            {
                Proxy    = null,
                UseProxy = false,
            };

            client = new HttpClient(hch);
        }
Beispiel #2
0
 public static void Show(WindowType windowType)
 {
     try
     {
         if (windowType.Equals(WindowType.About))
         {
             if (_aboutForm == null || _aboutForm.IsDisposed)
             {
                 _aboutForm  = new AboutWindow(_aboutPanel);
                 _aboutPanel = _aboutForm;
             }
             _aboutForm.Show(frmMain.Default.pnlDock);
         }
         else if (windowType.Equals(WindowType.ActiveDirectoryImport))
         {
             if (_adimportForm == null || _adimportForm.IsDisposed)
             {
                 _adimportForm  = new ActiveDirectoryImportWindow(_adimportPanel);
                 _adimportPanel = _adimportForm;
             }
             _adimportPanel.Show(frmMain.Default.pnlDock);
         }
         else if (windowType.Equals(WindowType.Options))
         {
             using (var optionsForm = new frmOptions())
             {
                 optionsForm.ShowDialog(frmMain.Default.pnlDock);
             }
         }
         else if (windowType.Equals(WindowType.SSHTransfer))
         {
             SshtransferForm   = new SSHTransferWindow(_sshtransferPanel);
             _sshtransferPanel = SshtransferForm;
             SshtransferForm.Show(frmMain.Default.pnlDock);
         }
         else if (windowType.Equals(WindowType.Update))
         {
             if (UpdateForm == null || UpdateForm.IsDisposed)
             {
                 UpdateForm  = new UpdateWindow(UpdatePanel);
                 UpdatePanel = UpdateForm;
             }
             UpdateForm.Show(frmMain.Default.pnlDock);
         }
         else if (windowType.Equals(WindowType.Help))
         {
             if (_helpForm == null || _helpForm.IsDisposed)
             {
                 _helpForm  = new HelpWindow(_helpPanel);
                 _helpPanel = _helpForm;
             }
             _helpForm.Show(frmMain.Default.pnlDock);
         }
         else if (windowType.Equals(WindowType.ExternalApps))
         {
             if (_externalappsForm == null || _externalappsForm.IsDisposed)
             {
                 _externalappsForm  = new ExternalToolsWindow(_externalappsPanel);
                 _externalappsPanel = _externalappsForm;
             }
             _externalappsForm.Show(frmMain.Default.pnlDock);
         }
         else if (windowType.Equals(WindowType.PortScan))
         {
             _portscanForm  = new PortScanWindow(_portscanPanel);
             _portscanPanel = _portscanForm;
             _portscanForm.Show(frmMain.Default.pnlDock);
         }
         else if (windowType.Equals(WindowType.UltraVNCSC))
         {
             if (_ultravncscForm == null || _ultravncscForm.IsDisposed)
             {
                 _ultravncscForm  = new UltraVNCWindow(_ultravncscPanel);
                 _ultravncscPanel = _ultravncscForm;
             }
             _ultravncscForm.Show(frmMain.Default.pnlDock);
         }
         else if (windowType.Equals(WindowType.ComponentsCheck))
         {
             if (_componentscheckForm == null || _componentscheckForm.IsDisposed)
             {
                 _componentscheckForm  = new ComponentsCheckWindow(_componentscheckPanel);
                 _componentscheckPanel = _componentscheckForm;
             }
             _componentscheckForm.Show(frmMain.Default.pnlDock);
         }
         else if (windowType.Equals(WindowType.Announcement))
         {
             if (AnnouncementForm == null || AnnouncementForm.IsDisposed)
             {
                 AnnouncementForm  = new AnnouncementWindow(AnnouncementPanel);
                 AnnouncementPanel = AnnouncementForm;
             }
             AnnouncementForm.Show(frmMain.Default.pnlDock);
         }
     }
     catch (Exception ex)
     {
         Runtime.MessageCollector.AddExceptionStackTrace("App.Runtime.Windows.Show() failed.", ex);
     }
 }