Exemple #1
0
        public MainForm(CopyDataTransport dataTransport)
        {
            instance = this;
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            lang = Language.GetInstance();
            IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);

            // Make sure all hotkeys pass this window!
            HotkeyControl.RegisterHotkeyHWND(this.Handle);
            RegisterHotkeys();

            tooltip = new ToolTip();

            UpdateUI();
            InitializeQuickSettingsMenu();

            captureForm = new CaptureForm();

            // Load all the plugins
            PluginHelper.instance.LoadPlugins(this, captureForm);
            SoundHelper.Initialize();

            // Enable the Greenshot icon to be visible, this prevents Problems with the context menu
            notifyIcon.Visible = true;

            // Create a new instance of the class: copyData = new CopyData();
            copyData = new CopyData();

            // Assign the handle:
            copyData.AssignHandle(this.Handle);
            // Create the channel to send on:
            copyData.Channels.Add("Greenshot");
            // Hook up received event:
            copyData.CopyDataReceived += new CopyDataReceivedEventHandler(CopyDataDataReceived);

            if (dataTransport != null)
            {
                HandleDataTransport(dataTransport);
            }
            ClipboardHelper.RegisterClipboardViewer(this.Handle);
        }
Exemple #2
0
 private static void Main(string[] args)
 {
     if (!Directory.Exists(Path.GetDirectoryName(SettingsPath)))
     {
         Directory.CreateDirectory(Path.GetDirectoryName(SettingsPath));
     }
     Environment.ExitCode = 0;
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     if ((args.Length == 4) && (args[0] == "-automated"))
     {
         string path  = args[1].ToString();
         string str2  = args[2].ToString();
         bool   flag  = args[3].ToString().ToUpper().IndexOf("C") >= 0;
         bool   flag2 = args[3].ToString().ToUpper().IndexOf("S") >= 0;
         if (!System.IO.File.Exists(path))
         {
             Environment.ExitCode = 11;
             Application.Exit();
         }
         else if (!Directory.Exists(str2))
         {
             Environment.ExitCode = 12;
             Application.Exit();
         }
         else if (!flag && !flag2)
         {
             Environment.ExitCode = 13;
             Application.Exit();
         }
         else
         {
             ULManager          = new UpdateListManager();
             DLManager          = new DownloadManager();
             WindowsUpdateAgent = new Supremus.Environment.WindowsUpdates.WindowsUpdateAgent();
             ULManager.Load(path);
             if (flag)
             {
                 for (int i = 0; i < ULManager.Updates.Count; i++)
                 {
                     if (ULManager.Updates[i].Category == 1)
                     {
                         DLManager.Queue.Add(i);
                     }
                 }
             }
             if (flag2)
             {
                 for (int j = 0; j < ULManager.Updates.Count; j++)
                 {
                     if (ULManager.Updates[j].Category == 2)
                     {
                         DLManager.Queue.Add(j);
                     }
                 }
             }
             foreach (string str3 in Directory.GetFiles(str2))
             {
                 bool flag3 = false;
                 for (int k = 0; k < ULManager.Updates.Count; k++)
                 {
                     if (ULManager.Updates[k].Filename.ToUpper() == Path.GetFileName(str3).ToUpper())
                     {
                         flag3 = true;
                         int?nullable = null;
                         for (int m = 0; m < DLManager.Queue.Count; m++)
                         {
                             if (DLManager.Queue[m] == k)
                             {
                                 nullable = new int?(m);
                             }
                         }
                         if (nullable.HasValue)
                         {
                             DLManager.Queue.RemoveAt(nullable.Value);
                         }
                     }
                 }
                 if (!flag3)
                 {
                     System.IO.File.Delete(str3);
                 }
             }
             DLManager.DownloadPath  = str2;
             DLManager.UseSubFolders = false;
             Settings settings = new Settings(SettingsPath, "Settings");
             if (settings.ReadBool("Proxy", "Enabled", false))
             {
                 try
                 {
                     DLManager.Proxy = new WebProxy(settings.ReadString("Proxy", "Address", ""), settings.ReadInt("Proxy", "Port", 0x1f90));
                 }
                 catch (FormatException)
                 {
                     Environment.ExitCode = 14;
                     Application.Exit();
                     return;
                 }
                 if (settings.ReadBool("Proxy", "Authentication", false))
                 {
                     DLManager.Proxy.Credentials = new NetworkCredential(settings.ReadString("Proxy", "Username", ""), Supremus.Encryption.Encryption.Decrypt(settings.ReadString("Proxy", "Password", "")));
                 }
             }
             settings = null;
             formMain mainForm = new formMain {
                 mode = OperatingMode.Automated
             };
             Application.Run(mainForm);
             mainForm.Dispose();
         }
     }
     else if ((args.Length > 0) && (args[0] == "-install"))
     {
         UpdateListManager.InstallCompressedUL(args[1], Path.GetDirectoryName(SettingsPath));
         CopyData data = new CopyData();
         data.AssignHandle(Process.GetCurrentProcess().Handle);
         data.Channels.Add("WUD");
         data.Channels["WUD"].Send("Refresh");
         MessageBox.Show("Compressed UL file installed.", "Windows Updates Downloader", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
     else
     {
         ULManager          = new UpdateListManager(Path.GetDirectoryName(SettingsPath));
         DLManager          = new DownloadManager();
         WindowsUpdateAgent = new Supremus.Environment.WindowsUpdates.WindowsUpdateAgent();
         formMain main2 = new formMain {
             mode = OperatingMode.User
         };
         Application.Run(main2);
         main2.Dispose();
         if (WindowsUpdateAgent != null)
         {
             WindowsUpdateAgent.Dispose();
         }
     }
 }
Exemple #3
0
        private void frmMain_Load(object sender, System.EventArgs e)
        {
            try
            {
                Global.m_DataDirectory = Environment.GetEnvironmentVariable("appdata") + @"\nomp\";
                if (Global.m_DataDirectory == @"\nomp\") throw new ArgumentNullException();
            }
            catch
            {
                Global.m_DataDirectory = Global.m_CurrentDirectory;
            }
            Global.m_CacheDirectory = Global.m_DataDirectory + @"\Cache\";

            try
            {
                RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders");
                string str = (string)rk.GetValue("Personal");
                if (str == null ) throw new ArgumentNullException();
                Global.m_DownloadDirectory = str + @"\download\";
            }
            catch
            {
                Global.m_DownloadDirectory = Global.m_CurrentDirectory + @"\download\";
            }

            Global.ConnectionLog = new CEventLogEngine( Global.m_DataDirectory + "connection.log");
            Global.ConnectionLog.Enabled = false; // Set to true to have all NNTP trafic logged to connection.log

            if( !System.IO.Directory.Exists( Global.m_CacheDirectory))
                System.IO.Directory.CreateDirectory( Global.m_CacheDirectory);

            if( !System.IO.Directory.Exists( Global.m_DownloadDirectory))
                System.IO.Directory.CreateDirectory( Global.m_DownloadDirectory);

            Decoder.DecodeQueue = new ArrayQueue();
            Decoder.DecoderThread = new System.Threading.Thread( new System.Threading.ThreadStart( Decoder.Decode));
            Decoder.DecoderThread.Priority = System.Threading.ThreadPriority.Lowest;
            Decoder.DecoderThread.Name = "Decoder";
            Decoder.DecoderThread.Start();

            Global.m_Options = new OptionValues(false, true, 15, false, true, 5, true, 6, false, false, "", "", false, false, Global.m_CurrentDirectory, false);
            if(!LoadOptions(Global.m_DataDirectory + "options.xml"))
            {
            if(!LoadOptions(Global.m_CurrentDirectory + "options.xml"))
                frmMain.LogWriteError(Global.m_CurrentDirectory + "options.xml failed to load");

            }
            m_ServerManager = new ServerManager();
            if(!m_ServerManager.LoadServers(Global.m_DataDirectory + "servers.xml"))
            {
            if(!m_ServerManager.LoadServers(Global.m_CurrentDirectory + "servers.xml"))
                frmMain.LogWriteError(Global.m_CurrentDirectory + "servers.xml failed to load");

            }
            if(System.IO.File.Exists(Global.m_DataDirectory + "nzb-o-matic.xml"))
                ImportNZB(Global.m_DataDirectory + "nzb-o-matic.xml");

            if( Global.m_Options.ConnectOnStart)
            {
                frmMain.LogWriteInfo("Connect on startup enabled.");
                Connect();
            }

            foreach(string str in Global.Args)
            {
                frmMain.LogWriteInfo("Startup parameter: " + str);
                if(str == "/start")
                {
                    frmMain.LogWriteInfo("Connect on startup switch detected.");
                    Connect();
                }
                if(str == "/exit")
                {
                    frmMain.LogWriteInfo("Exit on completion switch detected.");
                    Global.m_ExitComplete = true;
                    Menu_Main_Options_Exit.Checked = true;
                }
                if(str.EndsWith(".nzb"))
                {
                    ImportNZB(str);
                }
            }

            copydata = new CopyData();
            copydata.AssignHandle(this.Handle);
            copydata.Channels.Add("NZBImport");
            copydata.DataReceived += new DataReceivedEventHandler(copydata_DataReceived);

            UpdateServers();

            frmMain.LogWriteInfo(Global.Name + " succesfully started.");
            frmMain.LogWriteInfo("Version: " + Global.Version);
        }
Exemple #4
0
        public MainForm(CopyDataTransport dataTransport)
        {
            instance = this;

            // Make sure we never capture the mainform
            WindowDetails.RegisterIgnoreHandle(this.Handle);
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();

            IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);

            tooltip = new ToolTip();

            UpdateUI();

            // Do loading on a different Thread to shorten the startup
            Thread pluginInitThread = new Thread(delegate()
            {
                // Load all the plugins
                PluginHelper.instance.LoadPlugins(this);

                // Check destinations, remove all that don't exist
                foreach (string destination in conf.OutputDestinations.ToArray())
                {
                    if (DestinationHelper.GetDestination(destination) == null)
                    {
                        conf.OutputDestinations.Remove(destination);
                    }
                }

                // we should have at least one!
                if (conf.OutputDestinations.Count == 0)
                {
                    conf.OutputDestinations.Add(Destinations.EditorDestination.DESIGNATION);
                }
                BeginInvoke((MethodInvoker) delegate
                {
                    // Do after all plugins & finding the destination, otherwise they are missing!
                    InitializeQuickSettingsMenu();
                });
            });

            pluginInitThread.Name         = "Initialize plug-ins";
            pluginInitThread.IsBackground = true;
            pluginInitThread.Start();

            SoundHelper.Initialize();

            // Create a new instance of the class: copyData = new CopyData();
            copyData = new CopyData();

            // Assign the handle:
            copyData.AssignHandle(this.Handle);
            // Create the channel to send on:
            copyData.Channels.Add("Greenshot");
            // Hook up received event:
            copyData.CopyDataReceived += new CopyDataReceivedEventHandler(CopyDataDataReceived);

            if (dataTransport != null)
            {
                HandleDataTransport(dataTransport);
            }
        }
Exemple #5
0
        private void frmMain_Load(object sender, System.EventArgs e)
        {
            Global.ConnectionLog = new CEventLogEngine( Global.m_CurrentDirectory + "connection.log");
            Global.ConnectionLog.Enabled = false; // Set to true to have all NNTP trafic logged to connection.log

            if( !System.IO.Directory.Exists( Global.m_CurrentDirectory + "Cache"))
                System.IO.Directory.CreateDirectory( Global.m_CurrentDirectory + "Cache");

            if( !System.IO.Directory.Exists( Global.m_CurrentDirectory + "Download"))
                System.IO.Directory.CreateDirectory( Global.m_CurrentDirectory + "Download");

            Decoder.DecodeQueue = new ArrayQueue();
            Decoder.DecoderThread = new System.Threading.Thread( new System.Threading.ThreadStart( Decoder.Decode));
            Decoder.DecoderThread.Priority = System.Threading.ThreadPriority.Lowest;
            Decoder.DecoderThread.Name = "Decoder";
            Decoder.DecoderThread.Start();

            Global.m_Options = new OptionValues(false, true, 15, false, true, 5, true, 6, false, false, "", "", false, false, Global.m_CurrentDirectory);
            if(!LoadOptions(Global.m_CurrentDirectory + "options.xml"))
                frmMain.LogWriteError(Global.m_CurrentDirectory + "options.xml failed to load");

            m_ServerManager = new ServerManager();
            if(!m_ServerManager.LoadServers(Global.m_CurrentDirectory + "servers.xml"))
                frmMain.LogWriteError(Global.m_CurrentDirectory + "servers.xml failed to load");

            if(System.IO.File.Exists(Global.m_CurrentDirectory + "nzb-o-matic.xml"))
                ImportNZB(Global.m_CurrentDirectory + "nzb-o-matic.xml");

            if( Global.m_Options.ConnectOnStart)
            {
                frmMain.LogWriteInfo("Connect on startup enabled.");
                Connect();
            }

            foreach(string str in Global.Args)
            {
                frmMain.LogWriteInfo("Startup parameter: " + str);
                if(str == "/start")
                {
                    frmMain.LogWriteInfo("Connect on startup switch detected.");
                    Connect();
                }
                if(str == "/exit")
                {
                    frmMain.LogWriteInfo("Exit on completion switch detected.");
                    Global.m_ExitComplete = true;
                    Menu_Main_Options_Exit.Checked = true;
                }
                if(str.EndsWith(".nzb"))
                {
                    ImportNZB(str);
                }
            }

            copydata = new CopyData();
            copydata.AssignHandle(this.Handle);
            copydata.Channels.Add("NZBImport");
            copydata.DataReceived += new DataReceivedEventHandler(copydata_DataReceived);

            UpdateServers();

            frmMain.LogWriteInfo(Global.Name + " succesfully started.");
            frmMain.LogWriteInfo("Version: " + Global.Version);
        }