コード例 #1
0
        public MenuViewController()
        {
            this.mainController = ViewManager.instance.MainController;
            this.mainForm       = ViewManager.instance.MainForm;
            this.user           = User.instance();
            this.siteConfig     = SiteConfig.instance();

            LoadMenu();

            this.mainController.EnableStatusChanged += controller_EnableStatusChanged;
            this.mainController.ConfigChanged       += controller_ConfigChanged;
            this.mainController.EnableGlobalChanged += controller_EnableGlobalChanged;
            this.mainController.Errored             += controller_Errored;
            this.mainController.TrafficChanged      += controller_TrafficChanged;

            this.notifyIcon = new NotifyIcon();

            UpdateTrayIcon();

            this.notifyIcon.Visible            = true;
            this.notifyIcon.ContextMenu        = contextMenu;
            this.notifyIcon.MouseDoubleClick  += notifyIcon_DoubleClick;
            this.notifyIcon.BalloonTipClicked += notifyIcon_BalloonTipClicked;
            this.notifyIcon.BalloonTipClosed  += notifyIcon_BalloonTipClosed;

            LoadCurrentConfiguration();

            Configuration config = this.mainController.GetConfigurationCopy();

            this.updateChecker = new UpdateChecker();
            this.updateChecker.CheckUpdateCompleted += updateChecker_CheckUpdateCompleted;
            this.updateChecker.CheckUpdate(config, 5000);
        }
コード例 #2
0
        private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
        {
            ShadowSocksController mainController = ViewManager.instance.MainController;

            switch (e.Mode)
            {
            case PowerModes.Resume:
                Logging.Info("os wake up");
                if (mainController != null)
                {
                    System.Timers.Timer timer = new System.Timers.Timer(10 * 1000);
                    timer.Elapsed  += Timer_Elapsed;
                    timer.AutoReset = false;
                    timer.Enabled   = true;
                    timer.Start();
                }
                break;

            case PowerModes.Suspend:
                if (mainController != null)
                {
                    mainController.Stop();
                    Logging.Info("main controller stopped");
                }
                Logging.Info("os suspend");
                break;
            }
        }
コード例 #3
0
ファイル: Hotkeys.cs プロジェクト: Soldie/greendot1
        public static void Init(ShadowSocksController controller)
        {
            _hotKeyManager             = new HotKeyManager();
            _hotKeyManager.KeyPressed += HotKeyManagerPressed;

            HotkeyCallbacks.InitInstance(controller);
        }
コード例 #4
0
ファイル: StrategyManager.cs プロジェクト: Soldie/greendot1
 public StrategyManager(ShadowSocksController controller)
 {
     _strategies = new List <IStrategy>();
     _strategies.Add(new BalancingStrategy(controller));
     _strategies.Add(new HighAvailabilityStrategy(controller));
     _strategies.Add(new StatisticsStrategy(controller));
     // TODO: load DLL plugins
 }
コード例 #5
0
 public void closeMainController()
 {
     if (mainController != null)
     {
         mainController.Stop();
         mainController = null;
     }
 }
コード例 #6
0
        public StatisticsStrategy(ShadowSocksController controller)
        {
            _controller = controller;
            var servers     = controller.GetCurrentConfiguration().configs;
            var randomIndex = new Random().Next() % servers.Count;

            _currentServer = servers[randomIndex];  //choose a server randomly at first
            _timer         = new Timer(ReloadStatisticsAndChooseAServer);
        }
コード例 #7
0
ファイル: HotkeyCallbacks.cs プロジェクト: Soldie/greendot1
        public static void InitInstance(ShadowSocksController controller)
        {
            if (Instance != null)
            {
                return;
            }

            Instance = new HotkeyCallbacks(controller);
        }
コード例 #8
0
ファイル: Log.cs プロジェクト: Soldie/greendot1
        public Log()
        {
            InitializeComponent();
            materialSkinManager = MaterialSkinManager.Instance;
            materialSkinManager.AddFormToManage(this);
            materialSkinManager.Theme       = MaterialSkinManager.Themes.LIGHT;
            materialSkinManager.ColorScheme = new ColorScheme(Primary.LightBlue500, Primary.LightBlue500, Primary.Amber900, Accent.Amber700, TextShade.WHITE);

            this.filename = Logging.LogFilePath;
            this.Icon     = Icon.FromHandle(Resources.logo.GetHicon());

            this.mainController = ViewManager.instance.MainController;
            this.mainController.TrafficChanged += controller_TrafficChanged;
        }
コード例 #9
0
ファイル: Main.cs プロジェクト: Soldie/greendot1
        public Main()
        {
            InitializeComponent();

            materialSkinManager = MaterialSkinManager.Instance;
            materialSkinManager.AddFormToManage(this);
            materialSkinManager.Theme       = MaterialSkinManager.Themes.LIGHT;
            materialSkinManager.ColorScheme = new ColorScheme(Primary.LightBlue500, Primary.LightBlue500, Primary.Amber900, Accent.Amber700, TextShade.WHITE);

            this.user           = User.instance();
            this.mainController = ViewManager.instance.MainController;
            this.mainController.ConfigChanged += controller_ConfigChanged;

            this.initLocation();
            this.loadConfiguration();
            this.loadServers();
            this.setUserChecker();

            CheckForIllegalCrossThreadCalls = false;
        }
コード例 #10
0
ファイル: Setting.cs プロジェクト: Soldie/greendot1
        public Setting()
        {
            InitializeComponent();

            materialSkinManager = MaterialSkinManager.Instance;
            materialSkinManager.AddFormToManage(this);
            materialSkinManager.Theme       = MaterialSkinManager.Themes.LIGHT;
            materialSkinManager.ColorScheme = new ColorScheme(Primary.LightBlue500, Primary.LightBlue500, Primary.Amber900, Accent.Amber700, TextShade.WHITE);

            this.menuController = ViewManager.instance.MenuController;
            this.mainController = ViewManager.instance.MainController;

            this.mainController.PACFileReadyToOpen            += controller_FileReadyToOpen;
            this.mainController.UpdatePACFromGFWListCompleted += controller_UpdatePACFromGFWListCompleted;
            this.mainController.UpdatePACFromGFWListError     += controller_UpdatePACFromGFWListError;

            this.siteConfig    = SiteConfig.instance();
            this.configuration = this.mainController.GetConfigurationCopy();

            this.updateChecker = new UpdateChecker();
            this.updateChecker.CheckUpdateCompleted += updateChecker_CheckUpdateCompleted;
        }
コード例 #11
0
ファイル: HotkeyCallbacks.cs プロジェクト: Soldie/greendot1
 private HotkeyCallbacks(ShadowSocksController controller)
 {
     _controller = controller;
 }
コード例 #12
0
 public HighAvailabilityStrategy(ShadowSocksController controller)
 {
     _controller   = controller;
     _random       = new Random();
     _serverStatus = new Dictionary <Server, ServerStatus>();
 }
コード例 #13
0
ファイル: BalancingStrategy.cs プロジェクト: Soldie/greendot1
 public BalancingStrategy(ShadowSocksController controller)
 {
     _controller = controller;
     _random     = new Random();
 }