コード例 #1
0
        /** Application ===============================================================================
         */
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // init directory
            PathCurrent     = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
            PathPrivoxy     = $@"{PathCurrent}\binary\privoxy";
            PathShadowsocks = $@"{PathCurrent}\binary\shadowsocks";
            PathCurl        = $@"{PathCurrent}\binary\curl";

            FilePreferenceXml = $@"{PathCurrent}\datas\Preference.xml";
            FileConfigXml     = $@"{PathCurrent}\datas\Config.xml";
            FileIPAddressXml  = $@"{PathCurrent}\datas\IPAddress.xml"; //china ip optimized
            FileUserAgentXml  = $@"{PathCurrent}\datas\UserAgent.xml";

            FileServerXml = $@"{PathCurrent}\datas\Servers.xml";
            FileCurlXml   = $@"{PathCurrent}\datas\Curl.xml";

            // init binaries
            PrivoxyManager.KillRunning();
            SSManager.KillRunning();
            CurlManager.KillRunning();
            if (!PrivoxyManager.Prepare() || !SSManager.Prepare() || !CurlManager.Prepare())
            {
                string app_name         = (string)FindResource("app_name");
                string app_error_binary = (string)FindResource("app_error_binary");
                new View.DialogPrompt(app_name, app_error_binary).ShowDialog();

                Shutdown();
                return;
            }

            // load data
            GlobalPreference = Preference.LoadFileOrDefault(FilePreferenceXml);
            GlobalConfig     = Config.LoadFileOrDefault(FileConfigXml);

            // notifyicon
            new View.TrayNotify.SystemTray();
            Exit += Application_Exit;
        }
コード例 #2
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (IsVisible)
            {
                e.Cancel = true;
                Hide();
                return;
            }

            /** if there were other proxy servers running they should set system proxy again
             */
            NativeMethods.DisableProxy();
            PrivoxyManager.Exit();
            SSManager.Exit();

            // Save window placement
            Preference preference = App.GlobalPreference;

            preference.WindowHome.X = Left;
            preference.WindowHome.Y = Top;
            preference.WindowHome.W = Width;
            preference.WindowHome.H = Height;
        }