DoFixedWidthWidgetWidthChanged() public method

public DoFixedWidthWidgetWidthChanged ( IFixedWidthWidget widget ) : void
widget IFixedWidthWidget
return void
Esempio n. 1
0
        private void OnTimerTick(object sender, System.EventArgs e)
        {
            var powerStatus = SystemInformation.PowerStatus;

            switch (powerStatus.BatteryChargeStatus)
            {
            case BatteryChargeStatus.Critical:
                label.ForeColor = Color.Red;
                break;

            case BatteryChargeStatus.High:
                label.ForeColor = Color.Green;
                break;

            case BatteryChargeStatus.Low:
                label.ForeColor = Color.Orange;
                break;
            }

            var oldLeft  = label.Left;
            var oldRight = label.Right;
            var oldWidth = label.Width;

            label.Text = (powerStatus.PowerLineStatus == PowerLineStatus.Offline ?
                          textForNotCharging : textForCharging) + prefix + (powerStatus.BatteryLifePercent * 100) + postfix;

            label.Width = TextRenderer.MeasureText(label.Text, label.Font).Width;
            if (oldWidth != label.Width)
            {
                this.RepositionControls(oldLeft, oldRight);
                bar.DoFixedWidthWidgetWidthChanged(this);
            }
        }
        private void OnTimerTick(object sender, EventArgs e)
        {
            var oldLeft  = label.Left;
            var oldRight = label.Right;

            var curReceived = networkInterface.GetIPv4Statistics().BytesReceived;
            var downSpeed   = ((float)(curReceived - oldReceived)) / updateDuration * 1000 / 1024;
            var curSent     = networkInterface.GetIPv4Statistics().BytesSent;
            var upSpeed     = ((float)(curSent - oldSent)) / updateDuration * 1000 / 1024;

            var oldWidth = label.Width;

            label.Text = string.Format("\u2193{0}{1} \u2191{2}{3}", ((downSpeed > 999) ? downSpeed / 1024 : downSpeed).ToString("0.0"),
                                       ((downSpeed > 999) ? "M" : "k"), ((upSpeed > 999) ? upSpeed / 1024 : upSpeed).ToString("0.0"), ((upSpeed > 999) ? "M" : "k"));
            var newWidth = TextRenderer.MeasureText(label.Text, label.Font).Width;

            label.Width = newWidth;

            if (oldWidth != newWidth)
            {
                this.RepositionControls(oldLeft, oldRight);
                bar.DoFixedWidthWidgetWidthChanged(this);
            }

            oldSent     = curSent;
            oldReceived = curReceived;
        }
Esempio n. 3
0
        private void OnTimerTick(object sender, EventArgs e)
        {
            var oldLeft   = label.Left;
            var oldRight  = label.Right;
            var nextValue = counter.NextValue();

            label.Text = prefix + nextValue.ToString("00") + postfix;

            if (Math.Abs(nextValue - 100) < 0.00001)
            {
                this.RepositionControls(oldLeft, oldRight);
                bar.DoFixedWidthWidgetWidthChanged(this);
            }
        }
Esempio n. 4
0
 private void OnWorkspaceLayoutChanged(Workspace workspace)
 {
     if (workspace.Monitor == bar.Monitor && workspace.IsWorkspaceVisible)
     {
         var oldLeft  = layoutLabel.Left;
         var oldRight = layoutLabel.Right;
         var oldWidth = layoutLabel.Width;
         layoutLabel.Text  = workspace.Layout.LayoutSymbol();
         layoutLabel.Width = TextRenderer.MeasureText(layoutLabel.Text, layoutLabel.Font).Width;
         if (layoutLabel.Width != oldWidth)
         {
             this.RepositionControls(oldLeft, oldRight);
             bar.DoFixedWidthWidgetWidthChanged(this);
         }
     }
 }
Esempio n. 5
0
        private void SetNewLanguage(string language)
        {
            if (language != label.Text)
            {
                var oldLeft  = label.Left;
                var oldRight = label.Right;
                var oldWidth = label.Width;
                label.Text = language;

                label.Width = TextRenderer.MeasureText(label.Text, label.Font).Width;
                if (oldWidth != label.Width)
                {
                    this.RepositionControls(oldLeft, oldRight);
                    bar.DoFixedWidthWidgetWidthChanged(this);
                }
            }
        }
Esempio n. 6
0
        private void WindawesomeOnWindowTitleOrIconChanged(Workspace workspace, Window window, string newText, Bitmap newIcon)
        {
            if (window.className == windowClassName)
            {
                var oldLeft  = label.Left;
                var oldRight = label.Right;

                var oldWidth = label.Width;
                var newWidth = TextRenderer.MeasureText(newText, label.Font).Width;

                label.Text  = newText;
                label.Width = newWidth;

                if (oldWidth != newWidth)
                {
                    this.RepositionControls(oldLeft, oldRight);
                    bar.DoFixedWidthWidgetWidthChanged(this);
                }
            }
        }