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); }
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; } }
public static void Init(ShadowSocksController controller) { _hotKeyManager = new HotKeyManager(); _hotKeyManager.KeyPressed += HotKeyManagerPressed; HotkeyCallbacks.InitInstance(controller); }
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 }
public void closeMainController() { if (mainController != null) { mainController.Stop(); mainController = null; } }
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); }
public static void InitInstance(ShadowSocksController controller) { if (Instance != null) { return; } Instance = new HotkeyCallbacks(controller); }
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; }
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; }
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; }
private HotkeyCallbacks(ShadowSocksController controller) { _controller = controller; }
public HighAvailabilityStrategy(ShadowSocksController controller) { _controller = controller; _random = new Random(); _serverStatus = new Dictionary <Server, ServerStatus>(); }
public BalancingStrategy(ShadowSocksController controller) { _controller = controller; _random = new Random(); }