Ejemplo n.º 1
0
 private void LoadCurrentConfiguration()
 {
     _modifiedConfiguration          = controller.GetConfigurationCopy().proxy;
     UseProxyCheckBox.Checked        = _modifiedConfiguration.useProxy;
     ProxyServerTextBox.Text         = _modifiedConfiguration.proxyServer;
     ProxyPortTextBox.Text           = _modifiedConfiguration.proxyPort.ToString();
     ProxyTimeoutTextBox.Text        = _modifiedConfiguration.proxyTimeout.ToString();
     ProxyTypeComboBox.SelectedIndex = _modifiedConfiguration.proxyType;
 }
Ejemplo n.º 2
0
 private void LoadCurrentConfiguration()
 {
     _modifiedConfiguration = controller.GetConfigurationCopy();
     LoadConfiguration(_modifiedConfiguration);
     _lastSelectedIndex = _modifiedConfiguration.index;
     if (_lastSelectedIndex < 0 || _lastSelectedIndex >= ServersListBox.Items.Count)
     {
         _lastSelectedIndex = 0;
     }
     ServersListBox.SelectedIndex = _lastSelectedIndex;
     UpdateMoveUpAndDownButton();
     LoadSelectedServer();
 }
Ejemplo n.º 3
0
        public MenuViewController(PhotonController controller)
        {
            this.controller = controller;

            LoadMenu();

            controller.EnableStatusChanged         += controller_EnableStatusChanged;
            controller.ConfigChanged               += controller_ConfigChanged;
            controller.PACFileReadyToOpen          += controller_FileReadyToOpen;
            controller.UserRuleFileReadyToOpen     += controller_FileReadyToOpen;
            controller.ShareOverLANStatusChanged   += controller_ShareOverLANStatusChanged;
            controller.VerboseLoggingStatusChanged += controller_VerboseLoggingStatusChanged;
            controller.EnableGlobalChanged         += controller_EnableGlobalChanged;
            controller.Errored += controller_Errored;
            controller.UpdatePACFromGFWListCompleted += controller_UpdatePACFromGFWListCompleted;
            controller.UpdatePACFromGFWListError     += controller_UpdatePACFromGFWListError;

            _notifyIcon = new NotifyIcon();
            UpdateTrayIcon();
            _notifyIcon.Visible            = true;
            _notifyIcon.ContextMenu        = contextMenu1;
            _notifyIcon.BalloonTipClicked += notifyIcon1_BalloonTipClicked;
            _notifyIcon.MouseClick        += notifyIcon1_Click;
            _notifyIcon.MouseDoubleClick  += notifyIcon1_DoubleClick;
            _notifyIcon.BalloonTipClosed  += _notifyIcon_BalloonTipClosed;
            controller.TrafficChanged     += controller_TrafficChanged;

            this.updateChecker = new UpdateChecker();
            updateChecker.CheckUpdateCompleted += updateChecker_CheckUpdateCompleted;

            LoadCurrentConfiguration();

            Configuration config = controller.GetConfigurationCopy();

            if (config.isDefault)
            {
                _isFirstRun = true;
                ShowConfigForm();
            }
            else if (config.autoCheckUpdate)
            {
                _isStartupChecking = true;
                updateChecker.CheckUpdate(config, 3000);
            }
        }
Ejemplo n.º 4
0
        public LogForm(PhotonController controller, string filename)
        {
            this.controller = controller;
            this.filename   = filename;
            InitializeComponent();
            Icon = Icon.FromHandle(Resources.ssw128.GetHicon());

            LogViewerConfig config = controller.GetConfigurationCopy().logViewer;

            topMostTrigger              = config.topMost;
            wrapTextTrigger             = config.wrapText;
            toolbarTrigger              = config.toolbarShown;
            LogMessageTextBox.BackColor = config.BackgroundColor;
            LogMessageTextBox.ForeColor = config.TextColor;
            LogMessageTextBox.Font      = config.Font;

            controller.TrafficChanged += controller_TrafficChanged;

            UpdateTexts();
        }
Ejemplo n.º 5
0
        private void SwitchSystemProxyCallback()
        {
            bool enabled = _controller.GetConfigurationCopy().enabled;

            _controller.ToggleEnable(!enabled);
        }
Ejemplo n.º 6
0
 private void LoadCurrentConfiguration()
 {
     _modifiedConfig = _controller.GetConfigurationCopy().hotkey;
     LoadConfiguration(_modifiedConfig);
 }
Ejemplo n.º 7
0
        private void UpdateTrayIcon()
        {
            int      dpi;
            Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);

            dpi = (int)graphics.DpiX;
            graphics.Dispose();
            icon_baseBitmap = null;
            if (dpi < 97)
            {
                // dpi = 96;    任务栏小图标
                icon_baseBitmap = Resources.Photon2;
            }
            else if (dpi < 121)
            {
                // dpi = 120;
                //icon_baseBitmap = Resources.ss20;
            }
            else
            {
                //icon_baseBitmap = Resources.ss24;
            }
            Configuration config  = controller.GetConfigurationCopy();
            bool          enabled = config.enabled;
            bool          global  = config.global;

            icon_baseBitmap = getTrayIconByState(icon_baseBitmap, enabled, global);

            icon_base  = Icon.FromHandle(icon_baseBitmap.GetHicon());
            targetIcon = icon_base;
            icon_in    = Icon.FromHandle(AddBitmapOverlay(icon_baseBitmap, Resources.Photon1).GetHicon());
            //icon_out = Icon.FromHandle(AddBitmapOverlay(icon_baseBitmap, Resources.ssOut24).GetHicon());下载小图标(将图片放在Resoutces文件夹即可引用,修改ssOut24即可)
            //icon_both = Icon.FromHandle(AddBitmapOverlay(icon_baseBitmap, Resources.Photon1, Resources.ssOut24).GetHicon());配合上面使用
            icon_both        = Icon.FromHandle(AddBitmapOverlay(icon_baseBitmap, Resources.Photon1).GetHicon());
            _notifyIcon.Icon = targetIcon;

            string serverInfo = null;

            if (controller.GetCurrentStrategy() != null)
            {
                serverInfo = controller.GetCurrentStrategy().Name;
            }
            else
            {
                serverInfo = config.GetCurrentServer().FriendlyName();
            }
            // show more info by hacking the P/Invoke declaration for NOTIFYICONDATA inside Windows Forms
            string text = I18N.GetString("Photon") + " " + UpdateChecker.Version + "\n" +
                          (enabled ?
                           I18N.GetString("System Proxy On: ") + (global ? I18N.GetString("Global") : I18N.GetString("PAC")) :
                           String.Format(I18N.GetString("Running: Port {0}"), config.localPort))     // this feedback is very important because they need to know Shadowsocks is running
                          + "\n" + serverInfo;

            ViewUtils.SetNotifyIconText(_notifyIcon, text);
        }