public bool AddServer(string config, bool quiet = false) { // duplicate if (IsServerItemExist(config)) { return(false); } var newServer = new Model.Data.ServerItem() { config = config, }; lock (serverListWriteLock) { serverList.Add(newServer); } newServer.parent = this; BindEventsTo(newServer); if (!quiet) { newServer.UpdateSummaryThen(() => { InvokeEventOnRequireMenuUpdate(this, EventArgs.Empty); InvokeEventOnRequireFlyPanelUpdate(this, EventArgs.Empty); }); } LazyGC(); LazySaveServerList(); return(true); }
public void ReleaseEventFrom(Model.Data.ServerItem server) { server.OnLog -= SendLog; server.OnPropertyChanged -= SaveChanges; server.OnRequireMenuUpdate -= InvokeEventOnRequireMenuUpdate; server.OnRequireDeleteServer -= DeleteServerHandler; }
public bool AddServer(string config, bool quiet = false) { var newServer = new Model.Data.ServerItem() { config = config, }; lock (writeLock) { foreach (var server in this) { if (server.config == config) { // duplicate return(false); } } this.Add(newServer); } BindEventTo(newServer); if (!quiet) { newServer.UpdateSummaryThen(() => { InvokeEventOnRequireMenuUpdate(this, EventArgs.Empty); InvokeEventOnRequireFlyPanelUpdate(this, EventArgs.Empty); }); } return(true); }
public void BindEventTo(Model.Data.ServerItem server) { server.OnLog += SendLog; server.OnPropertyChanged += SaveChanges; server.OnRequireMenuUpdate += InvokeEventOnRequireMenuUpdate; server.OnRequireDeleteServer += DeleteServerHandler; }
public ServerListItem(int index, Model.Data.ServerItem serverItem) { this.menu = CreateMenu(); this.serverItem = serverItem; SetIndex(index); InitializeComponent(); }
public ServerListItem(Model.Data.ServerItem serverItem) { this.serverItem = serverItem; InitializeComponent(); this.orgHeight = this.Height; this.minHeight = this.btnStart.Top; isRunning = !serverItem.isServerOn; this.Height = this.serverItem.isCollapse ? this.minHeight : this.orgHeight; }
void ModifyServerSetting( ref Model.Data.ServerItem server, int newMode, string newIP, int newPort, string newMark, int newAutorun, int newImport, int newSkipCN) { if (newSkipCN >= 0) { server.isInjectSkipCNSite = newSkipCN == 0; } if (newAutorun >= 0) { server.isAutoRun = newAutorun == 0; } if (newImport >= 0) { server.isInjectImport = newImport == 0; } if (newMode >= 0) { server.overwriteInboundType = newMode; } if (newIP != null) { server.inboundIP = newIP; } if (newPort >= 0) { server.inboundPort = newPort; } if (newMark != null) { server.mark = newMark; } }
public FormSingleServerLog(Model.Data.ServerItem serverItem) { maxNumberLines = Service.Setting.Instance.maxLogLines; this.serverItem = serverItem; InitializeComponent(); this.FormClosed += (s, e) => { serverItem.OnLog -= OnLogHandler; }; #if DEBUG this.Icon = Properties.Resources.icon_light; #endif this.Show(); this.Text = I18N("Log") + " - " + serverItem.summary; rtBoxLogger.Text = serverItem.logCache; serverItem.OnLog += OnLogHandler; }
public void ReleaseEventsFrom(Model.Data.ServerItem server) { server.OnLog -= OnSendLogHandler; server.OnPropertyChanged -= ServerItemPropertyChangedHandler; server.OnRequireMenuUpdate -= InvokeEventOnRequireMenuUpdate; }
public void BindEventsTo(Model.Data.ServerItem server) { server.OnLog += OnSendLogHandler; server.OnPropertyChanged += ServerItemPropertyChangedHandler; server.OnRequireMenuUpdate += InvokeEventOnRequireMenuUpdate; }