コード例 #1
0
        public void StartServer()
        {
            var port = Config.Instance.Proxy.Port;

            if (this.m_server?.Port == port)
            {
                return;
            }

            try
            {
                this.m_invoker.Invoke(new Action(() =>
                {
                    try
                    {
                        this.m_scripPort.ForeColor = Color.Red;
                        this.m_scripPort.Text      = string.Format(Lang.MainContext__m_scripPort__Text, "");
                    }
                    catch
                    {
                    }
                }));
            }
            catch
            {
            }

            try
            {
                this.m_server?.Dispose();
                this.m_server = null;
            }
            catch (Exception ex)
            {
                SentrySdk.CaptureException(ex);
            }

            try
            {
                this.m_server = new RespiratorServer(port);

                this.m_invoker.Invoke(new Action(() =>
                {
                    try
                    {
                        this.m_scripPort.ForeColor = SystemColors.ControlText;
                        this.m_scripPort.Text      = string.Format(Lang.MainContext__m_scripPort__Text, port);
                    }
                    catch
                    {
                    }
                }));
            }
            catch (Exception ex)
            {
                SentrySdk.CaptureException(ex);

                this.m_invoker.Invoke(new Action(() => MessageBox.Show(Lang.StartError, Lang.Name, MessageBoxButtons.OK, MessageBoxIcon.Information)));
            }
        }
コード例 #2
0
        static void Main()
        {
            using (var mut = new Mutex(true, MutexName, out bool createdNew))
            {
                if (!createdNew)
                {
                    return;
                }

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

                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

                WebRequest.DefaultCachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
#if !DEBUG
                System.Net.WebRequest.DefaultWebProxy = null;
#endif

                CrashReport.Init();

                if (Assembly.GetExecutingAssembly().GetName().Version.ToString() != "0.0.0.0" && !CheckUpdate())
                {
                    return;
                }

                if (!Certificates.InstallCACertificates())
                {
                    MessageBox.Show(Lang.CertificateError, Lang.Name, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                RespiratorServer server;
                try
                {
                    server = new RespiratorServer();
                }
                catch (Exception ex)
                {
                    SentrySdk.CaptureException(ex);

                    MessageBox.Show(Lang.StartError, Lang.Name, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                using (server)
                {
                    Application.Run(new MainContext(server));
                    Config.Save();
                }
            }
        }
コード例 #3
0
        public MainContext(RespiratorServer server)
        {
            this.m_invoker = new Control();
            this.m_invoker.CreateControl();

            this.m_server = server;

            TwitterClientFactory.ClientUpdated += this.TwitterClientFactory_ClientUpdated;

            this.InitializeComponent();
            Lang.ApplyLang(this);

            if (TwitterClientFactory.AccountCount == 0)
            {
                this.m_notifyIcon.ShowBalloonTip(10000, Lang.Name, Lang.MainContext_NoAccount, ToolTipIcon.Info);
            }
            else
            {
                foreach (var user in Config.Instance.Accounts)
                {
                    this.m_clients.Add(user.Id, this.NewClientToolStripItems(user.Id, user.ScreenName));
                }
            }
        }