Exemple #1
0
        public TrafficStatsSuspensionForm(ShadowsocksController controller, TrafficStats stats)
        {
            this.controller   = controller;
            this.trafficStats = stats;
            InitializeComponent();

            this.trafficStats.OnDataChanged += TrafficStats_OnDataChanged;
        }
Exemple #2
0
        public TrafficStatsForm(TrafficStatsSuspensionForm pSub, TrafficStats stats)
        {
            this.tsSuspentionForm = pSub;

            InitializeComponent();

            Icon              = Icon.FromHandle(Resources.ssw128.GetHicon());
            this.SizeChanged += new EventHandler(this.TrafficStatsForm_SizeChanged);

            this.trafficStats = stats;
            this.trafficStats.OnDataChanged  += TrafficdStats_OnDataChanged;
            this.trafficStats.OnSpeedChanged += TrafficStats_OnSpeedChanged;

            StatsItem totalItem = Utils.ConvertToMiB(this.trafficStats.MonthTotal);

            this.textbox_total.Text = totalItem.Value.ToString();
            this.label_total.Text   = totalItem.Unit;
            StatsItem statsItem = Utils.ConvertToMiB(this.trafficStats.MonthUsed);

            this.textbox_used.Text = statsItem.Value.ToString();
            this.label_used.Text   = statsItem.Unit;

            this.UpdateTexts();
        }
Exemple #3
0
        public MenuViewController(ShadowsocksController controller)
        {
            this.controller = controller;

            this.trafficStats = new TrafficStats();
            this.trafficStats.Load();

            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();

            CheckStatsItem(statsItem.Checked);

            Configuration config = controller.GetConfigurationCopy();

            if (config.isDefault)
            {
                _isFirstRun = true;
                ShowConfigForm();
            }
            else if (config.autoCheckUpdate)
            {
                _isStartupChecking = true;
                updateChecker.CheckUpdate(config, 3000);
            }

            this.lastInboundCounter  = controller.InboundCounter;
            this.lastOutboundCounter = controller.OutboundCounter;

            //更新统计数据
            Task.Factory.StartNew(UpdateTrafficDataStats, (cts = new CancellationTokenSource()).Token,
                                  TaskCreationOptions.LongRunning, TaskScheduler.Current);

            //统计数据校正
            this.trafficStats.CalibrateTrafficDataStats();

            Application.ApplicationExit += Application_ApplicationExit;
        }
Exemple #4
0
    // Token: 0x06005367 RID: 21351 RVA: 0x001CBAF0 File Offset: 0x001C9EF0
    public void DrawBandwidthWindow()
    {
        GUILayout.BeginVertical(new GUILayoutOption[0]);
        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
        if (PhotonNetwork.isMasterClient)
        {
            GUILayout.Label("Mstr", this.textStyle, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
        }
        GUILayout.Label("Ps: " + ((PhotonNetwork.room == null) ? "1" : PhotonNetwork.room.PlayerCount.ToString()), this.textStyle, new GUILayoutOption[0]);
        GUILayout.FlexibleSpace();
        GUILayout.Label("Dly: " + VRC.Network.SimulationDelay(VRC.Network.LocalPlayer).ToString(), this.textStyle, new GUILayoutOption[0]);
        GUILayout.FlexibleSpace();
        GUILayout.Label("Rt: " + PhotonNetwork.sendRateOnSerialize.ToString(), this.textStyle, new GUILayoutOption[0]);
        GUILayout.EndHorizontal();
        TrafficStats trafficStatsIncoming = PhotonNetwork.networkingPeer.TrafficStatsIncoming;
        TrafficStats trafficStatsOutgoing = PhotonNetwork.networkingPeer.TrafficStatsOutgoing;
        int          totalWidth           = 5;
        float        num = 1f / ((float)PhotonNetwork.networkingPeer.TrafficStatsElapsedMs / 1000f);

        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
        GUILayout.FlexibleSpace();
        GUILayout.Label("In", this.textStyle, new GUILayoutOption[0]);
        GUILayout.FlexibleSpace();
        GUILayout.Label(string.Concat(new string[]
        {
            "Cmd: ",
            trafficStatsIncoming.TotalCommandCount.ToString().PadLeft(totalWidth, ' '),
            "/",
            ((float)trafficStatsIncoming.TotalCommandCount * num).ToString("n1").PadRight(totalWidth, ' '),
            " ",
            trafficStatsIncoming.TotalCommandBytes.ToString().PadLeft(totalWidth, ' '),
            "/",
            ((float)trafficStatsIncoming.TotalCommandBytes * num).ToString("n1").PadRight(totalWidth, ' ')
        }), this.textStyle, new GUILayoutOption[0]);
        GUILayout.FlexibleSpace();
        GUILayout.Label("Ttl: " + trafficStatsIncoming.TotalPacketBytes.ToString().PadLeft(totalWidth, ' ') + "/" + ((float)trafficStatsIncoming.TotalPacketBytes * num).ToString("n1").PadRight(totalWidth, ' '), this.textStyle, new GUILayoutOption[0]);
        GUILayout.FlexibleSpace();
        GUILayout.Label("Out", this.textStyle, new GUILayoutOption[0]);
        GUILayout.FlexibleSpace();
        GUILayout.Label(string.Concat(new string[]
        {
            "Cmd: ",
            trafficStatsOutgoing.TotalCommandCount.ToString().PadLeft(totalWidth, ' '),
            "/",
            ((float)trafficStatsOutgoing.TotalCommandCount * num).ToString("n1").PadRight(totalWidth, ' '),
            " ",
            trafficStatsOutgoing.TotalCommandBytes.ToString().PadLeft(totalWidth, ' '),
            "/",
            ((float)trafficStatsOutgoing.TotalCommandBytes * num).ToString("n1").PadRight(totalWidth, ' ')
        }), this.textStyle, new GUILayoutOption[0]);
        GUILayout.FlexibleSpace();
        GUILayout.Label("Ttl: " + trafficStatsOutgoing.TotalPacketBytes.ToString().PadLeft(totalWidth, ' ') + "/" + ((float)trafficStatsOutgoing.TotalPacketBytes * num).ToString("n1").PadRight(totalWidth, ' '), this.textStyle, new GUILayoutOption[0]);
        GUILayout.EndHorizontal();
        GUILayout.Space(10f);
        GUILayout.EndVertical();
        if (this.frame == 0)
        {
            return;
        }
        IEnumerable <KeyValuePair <string, PhotonBandwidthGui.UsageTotal> > usage = (from s in this.playerSerializationTotals
                                                                                     orderby s.Key
                                                                                     select s).Reverse <KeyValuePair <string, PhotonBandwidthGui.UsageTotal> >();
        IEnumerable <KeyValuePair <string, PhotonBandwidthGui.UsageTotal> > usage2 = (from s in this.objectSerializationTotals
                                                                                      orderby s.Value.total
                                                                                      select s).Reverse <KeyValuePair <string, PhotonBandwidthGui.UsageTotal> >();
        IEnumerable <KeyValuePair <string, PhotonBandwidthGui.UsageTotal> > usage3 = (from s in this.valueSerializationTotals
                                                                                      orderby s.Value.total
                                                                                      select s).Reverse <KeyValuePair <string, PhotonBandwidthGui.UsageTotal> >();
        IEnumerable <KeyValuePair <string, PhotonBandwidthGui.UsageTotal> > usage4 = (from s in this.rpcSerializationTotals
                                                                                      orderby s.Value.total
                                                                                      select s).Reverse <KeyValuePair <string, PhotonBandwidthGui.UsageTotal> >();
        IEnumerable <KeyValuePair <string, PhotonBandwidthGui.UsageTotal> > usage5 = (from s in this.eventSerializationTotals
                                                                                      orderby s.Value.total
                                                                                      select s).Reverse <KeyValuePair <string, PhotonBandwidthGui.UsageTotal> >();

        GUILayout.BeginArea(new Rect(10f, 40f, this.windowRect.width - 20f, this.windowRect.height - 50f));
        this.serializationScrollPosition = GUILayout.BeginScrollView(this.serializationScrollPosition, new GUILayoutOption[0]);
        this.DrawHeader();
        object obj = this.usageFrames;

        lock (obj)
        {
            GUILayout.Label("Players", this.textStyle, new GUILayoutOption[0]);
            this.DrawUsageList(usage, this.usageFrames, PhotonBandwidthGui.UsageType.Player);
            GUILayout.Space(10f);
            GUILayout.Label("Objects", this.textStyle, new GUILayoutOption[0]);
            this.DrawUsageList(usage2, this.usageFrames, PhotonBandwidthGui.UsageType.Object);
            GUILayout.Space(10f);
            GUILayout.Label("RPCs", this.textStyle, new GUILayoutOption[0]);
            this.DrawUsageList(usage4, this.usageFrames, PhotonBandwidthGui.UsageType.RPC);
            GUILayout.Space(10f);
            GUILayout.Label("Events", this.textStyle, new GUILayoutOption[0]);
            this.DrawUsageList(usage5, this.usageFrames, PhotonBandwidthGui.UsageType.Event);
            GUILayout.Space(10f);
            GUILayout.Label("Types", this.textStyle, new GUILayoutOption[0]);
            this.DrawUsageList(usage3, this.usageFrames, PhotonBandwidthGui.UsageType.Value);
        }
        GUILayout.EndScrollView();
        GUILayout.EndArea();
    }