Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public void ReleaseEventFrom(Model.Data.ServerItem server)
 {
     server.OnLog                 -= SendLog;
     server.OnPropertyChanged     -= SaveChanges;
     server.OnRequireMenuUpdate   -= InvokeEventOnRequireMenuUpdate;
     server.OnRequireDeleteServer -= DeleteServerHandler;
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 public void BindEventTo(Model.Data.ServerItem server)
 {
     server.OnLog                 += SendLog;
     server.OnPropertyChanged     += SaveChanges;
     server.OnRequireMenuUpdate   += InvokeEventOnRequireMenuUpdate;
     server.OnRequireDeleteServer += DeleteServerHandler;
 }
Esempio n. 5
0
 public ServerListItem(int index, Model.Data.ServerItem serverItem)
 {
     this.menu       = CreateMenu();
     this.serverItem = serverItem;
     SetIndex(index);
     InitializeComponent();
 }
Esempio n. 6
0
 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;
            }
        }
Esempio n. 8
0
        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;
        }
Esempio n. 9
0
 public void ReleaseEventsFrom(Model.Data.ServerItem server)
 {
     server.OnLog               -= OnSendLogHandler;
     server.OnPropertyChanged   -= ServerItemPropertyChangedHandler;
     server.OnRequireMenuUpdate -= InvokeEventOnRequireMenuUpdate;
 }
Esempio n. 10
0
 public void BindEventsTo(Model.Data.ServerItem server)
 {
     server.OnLog               += OnSendLogHandler;
     server.OnPropertyChanged   += ServerItemPropertyChangedHandler;
     server.OnRequireMenuUpdate += InvokeEventOnRequireMenuUpdate;
 }