Exemple #1
0
        static int Main(string[] args)
        {
            if ((args.Length == 4) && args[0].Equals("install", StringComparison.OrdinalIgnoreCase))
                return (int)ShellExtension.Install(args[1] == "1", args[2] == "1", args[3], true);

            if (args.Length == 1 && args[0].Equals("uninstall", StringComparison.OrdinalIgnoreCase))
                return (int)ShellExtension.Uninstall(true);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            TiX.ExternalLibrary.Resolver.Init(typeof(Properties.Resources));
            CrashReport.Init();

            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            #if !DEBUG
            System.Net.HttpWebRequest.DefaultWebProxy = null;
            #endif
            System.Net.HttpWebRequest.DefaultCachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
            System.Net.ServicePointManager.MaxServicePoints = 20;

            Settings.Load();
            TiXMain.Twitter.UserToken  = Settings.UToken;
            TiXMain.Twitter.UserSecret = Settings.USecret;

            int i;

            if (args.Length >= 1 && args[0].Equals("stasis", StringComparison.OrdinalIgnoreCase))
            {
                Image cropedImage;
                using (var stasisForm = new Stasisfield())
                {
                    Application.Run(stasisForm);
                    cropedImage = stasisForm.CropedImage;
                }

                if (cropedImage != null)
                {
                    if (args.Length == 3)
                        TweetModerator.Tweet(cropedImage, false, "캡처 화면 전송중", args[1], args[2]);
                    else
                        TweetModerator.Tweet(cropedImage, false, "캡처 화면 전송중");
                }

                return 0;
            }
            else if (args.Length >= 1)
            {
                var data = new ImageCollection();
                bool autoStart = args.Any(e => e.Equals("--notext", StringComparison.OrdinalIgnoreCase));

                var lst = new List<string>(args.Length);

                if (args.Any(e => e.Equals("--pipe", StringComparison.OrdinalIgnoreCase)))
                {
                    var reader = new StreamReader(Console.OpenStandardInput(), Encoding.UTF8);
                    string path;
                    while (true)
                    {
                        path = reader.ReadLine();
                        if (string.IsNullOrEmpty(path)) break;

                        if (CheckFile(path))
                            lst.Add(path);
                    }
                }
                else
                {
                    for (i = 0; i < args.Length; ++i)
                        if (CheckFile(args[i]))
                            lst.Add(args[i]);
                }

                if (lst.Count == 0) return 0;

                data.Add(lst);

                Application.Run(new frmUpload(data, true) { AutoStart = autoStart });
                return 0;
            }

            Form frm;
            using (var instance = new InstanceHelper(InstanceName))
            {
                if (instance.Check())
                {
                    if (String.IsNullOrEmpty(Settings.UToken) | String.IsNullOrEmpty(Settings.USecret))
                    {
                        using (frm = new frmPin())
                        {
                            Application.Run(instance.MainWindow = frm);

                            if (frm.DialogResult != DialogResult.OK)
                                return 0;
                        }
                    }

                    frm = new frmMain();
                    Application.Run(instance.MainWindow = frm);
                }
            }

            return 0;
        }
Exemple #2
0
        private void GenerateStasisField()
        {
            this.Opacity = 0;
            this.ShowInTaskbar = false;

            Image cropedImage;
            using (var stasis = new Stasisfield())
            {
                stasis.ShowDialog();
                cropedImage   = stasis.CropedImage;
            }

            this.ShowInTaskbar = true;
            this.Opacity = 255;

            if (cropedImage != null)
                TweetModerator.Tweet(cropedImage, false, "캡처 화면 전송중");
        }