示例#1
0
        public IconHdr()
        {
            string[] arguments = Environment.GetCommandLineArgs();

            //MessageBox.Show(arguments.Concat);

            if (arguments.Length > 1)
            {
                if (arguments[1] == "RegisterRC")
                {
                    StartupHdr.RegisterRC();
                    notifyIcon.Visible = false;
                    //Application.Exit();
                    //MessageBox.Show("closing");
                    Environment.Exit(0);
                }
                else if (arguments[1] == "DeRegisterRC")
                {
                    StartupHdr.DeRegisterRC();
                    notifyIcon.Visible = false;
                    //Application.Exit();
                    //MessageBox.Show("closing");
                    Environment.Exit(0);
                }
                else
                {
                    StartupHdr.Startup(configWindow);

                    for (int i = 1; i < arguments.Count(); i++)
                    {
                        string path = arguments[i];
                        UploadHdr.Upload(path);
                    }
                    System.Media.SystemSounds.Hand.Play();
                    Environment.Exit(0);
                }
            }
            else
            {
                HotKeyHdr Hotkeys = new HotKeyHdr();


                MenuItem consoleMenuItem = new MenuItem("Console", new EventHandler(ShowConsole));
                MenuItem configMenuItem  = new MenuItem("Configuration", new EventHandler(ShowConfig));
                MenuItem exitMenuItem    = new MenuItem("Exit", new EventHandler(Exit));


                notifyIcon.Icon        = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);;
                notifyIcon.ContextMenu = new ContextMenu(new MenuItem[]
                                                         { consoleMenuItem, configMenuItem, exitMenuItem });
                notifyIcon.MouseClick += new MouseEventHandler(LeftClick);
                notifyIcon.Visible     = true;

                StartupHdr.Startup(configWindow);
            }
        }
示例#2
0
        static private bool commandLineStep()
        {
            Console.Write(">");
            string raw = Console.ReadLine();
            int    x   = 2;

            string[] rawArray = raw.Split(new char[] { ' ' }, x);
            string   command  = rawArray[0];

            List <string> args = new List <string>();

            if (rawArray.Length > 1)
            {
                string pattern = "[\"'](.*?)[\"']|([^ \"'\\s]+)";

                Regex rgx          = new Regex(pattern);
                int[] groupNumbers = rgx.GetGroupNumbers();

                Match m = rgx.Match(rawArray[1]);

                while (m.Success)
                {
                    for (int i = 1; i <= 2; i++)
                    {
                        Group             g  = m.Groups[i];
                        CaptureCollection cc = g.Captures;
                        if (cc.Count > 0)
                        {
                            args.Add(cc[0].Value);
                        }
                    }
                    m = m.NextMatch();
                }
            }

            switch (command)
            {
            case "damn":
            case "bye":
            case "kys":
            case "quit":
            case "close":
            case "exit":
                write("Bye!");
                System.Threading.Thread.Sleep(500);
                return(false);

                //FreeCons();
                break;

            case "upload":
                if (args.Count == 0)
                {
                    OpenFileDialog opf    = new OpenFileDialog();
                    DialogResult   result = opf.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        UploadHdr.Upload(opf.FileName);
                    }
                    else
                    {
                        writeE("There was an problem with:\n" + opf.FileName);
                    }
                }
                else
                {
                    foreach (string path in args)
                    {
                        UploadHdr.Upload(path);
                    }
                }
                break;

            case "logout":
                UploadHdr.Logout();
                Console.WriteLine("Please log back in");
                StartupHdr.ShowLogin();
                break;

            case "screenshot":

                Process proc = Process.Start("snippingtool", "/clip");

                proc.WaitForExit();

                if (Clipboard.ContainsImage())
                {
                    string path = Path.GetTempPath() + "screenshot_" + DateTime.Now.ToString("dd-MM-yy_HH.mm.ss") + ".png";
                    Image  img  = Clipboard.GetImage();
                    img.Save(path, System.Drawing.Imaging.ImageFormat.Png);
                    UploadHdr.Upload(path, "screenshots/", true);
                    File.Delete(path);
                }
                else
                {
                    writeE("Theres no picture!");
                }
                break;

            case "fullscreenshot":

                string ImgPath = Path.GetTempPath() + "screenshot_" + DateTime.Now.ToString("dd-MM-yy_HH.mm.ss") + ".png";
                Bitmap image   = HotKeyHdr.screenshot();
                image.Save(ImgPath, System.Drawing.Imaging.ImageFormat.Png);
                UploadHdr.Upload(ImgPath, "screenshots/", true);
                File.Delete(ImgPath);

                break;


            default:
                writeE("Unrecognized command: " + command);
                break;
            }

            return(true);
        }