CreateLabel() public method

public CreateLabel ( string text, int xLocation, int width = -1 ) : Label
text string
xLocation int
width int
return System.Windows.Forms.Label
Exemplo n.º 1
0
        private Panel CreatePanel(Window window)
        {
            var panel = new Panel();

            panel.SuspendLayout();
            panel.AutoSize  = false;
            panel.Location  = new Point(left, 0);
            panel.ForeColor = normalForegroundColor;
            panel.BackColor = normalBackgroundColor;

            var pictureBox = new PictureBox
            {
                Size     = new Size(this.bar.GetBarHeight(), this.bar.GetBarHeight()),
                SizeMode = PictureBoxSizeMode.CenterImage
            };

            pictureBox.Click += this.OnApplicationTabClick;
            panel.Controls.Add(pictureBox);

            Utilities.GetWindowSmallIconAsBitmap(window.hWnd, bitmap => pictureBox.Image = bitmap);

            var label = bar.CreateLabel(window.DisplayName, bar.GetBarHeight(), 0);

            label.Click += this.OnApplicationTabClick;
            panel.Controls.Add(label);

            panel.ResumeLayout();
            return(panel);
        }
Exemplo n.º 2
0
 void IWidget.InitializeWidget(Bar bar)
 {
     label           = bar.CreateLabel(separator, 0);
     label.BackColor = backgroundColor;
     label.ForeColor = foregroundColor;
     label.TextAlign = ContentAlignment.MiddleCenter;
 }
        void IWidget.InitializeWidget(Bar bar)
        {
            this.bar = bar;

            var powerStatus = SystemInformation.PowerStatus;
            label = bar.CreateLabel((powerStatus.PowerLineStatus == PowerLineStatus.Offline ?
                textForNotCharging : textForCharging) + prefix + (powerStatus.BatteryLifePercent * 100) + postfix, 0);
            label.BackColor = backgroundColor;
            label.ForeColor = foregroundColor;
            label.TextAlign = ContentAlignment.MiddleCenter;
            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;
                case BatteryChargeStatus.NoSystemBattery:
                    label.ForeColor = Color.Black;
                    label.Text = @"NO BAT";
                    return ;
            }

            bar.BarShown += () => updateTimer.Start();
            bar.BarHidden += () => updateTimer.Stop();
        }
Exemplo n.º 4
0
        void IWidget.InitializeWidget(Bar bar)
        {
            this.bar = bar;

            var powerStatus = SystemInformation.PowerStatus;

            label = bar.CreateLabel((powerStatus.PowerLineStatus == PowerLineStatus.Offline ?
                                     textForNotCharging : textForCharging) + prefix + (powerStatus.BatteryLifePercent * 100) + postfix, 0);
            label.BackColor = backgroundColor;
            label.ForeColor = foregroundColor;
            label.TextAlign = ContentAlignment.MiddleCenter;
            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;

            case BatteryChargeStatus.NoSystemBattery:
                label.ForeColor = Color.Black;
                label.Text      = @"NO BAT";
                return;
            }

            bar.BarShown  += () => updateTimer.Start();
            bar.BarHidden += () => updateTimer.Stop();
        }
Exemplo n.º 5
0
 void IWidget.InitializeWidget(Bar bar)
 {
     label = bar.CreateLabel(separator, 0);
     label.BackColor = backgroundColor;
     label.ForeColor = foregroundColor;
     label.TextAlign = ContentAlignment.MiddleCenter;
 }
Exemplo n.º 6
0
        void IWidget.InitializeWidget(Bar bar)
        {
            if (flashWorkspaces)
            {
                flashTimer.Tick            += OnTimerTick;
                OnWorkspaceFlashingStopped += SetWorkspaceLabelColor;
            }

            isShown = false;

            bar.BarShown  += OnBarShown;
            bar.BarHidden += OnBarHidden;

            workspaceLabels = new Label[windawesome.config.Workspaces.Length];

            Workspace.WorkspaceWindowAdded   += (ws, _) => SetWorkspaceLabelColor(ws);
            Workspace.WorkspaceWindowRemoved += (ws, _) => SetWorkspaceLabelColor(ws);

            Workspace.WorkspaceDeactivated += OnWorkspaceChangedFromTo;
            Workspace.WorkspaceActivated   += OnWorkspaceChangedFromTo;
            Workspace.WorkspaceShown       += OnWorkspaceChangedFromTo;
            Workspace.WorkspaceHidden      += OnWorkspaceChangedFromTo;

            for (var i = 0; i < windawesome.config.Workspaces.Length; i++)
            {
                var workspace = windawesome.config.Workspaces[i];
                var name      = (i + 1) + (workspace.name == "" ? "" : ":" + workspace.name);

                var label = bar.CreateLabel(" " + name + " ", 0);
                label.TextAlign    = ContentAlignment.MiddleCenter;
                label.Click       += OnWorkspaceLabelClick;
                workspaceLabels[i] = label;
                SetWorkspaceLabelColor(workspace);
            }
        }
Exemplo n.º 7
0
 public void InitializeWidget(Bar bar)
 {
     this.bar             = bar;
     this.label           = bar.CreateLabel(this.prefix + DateTime.Now.ToString(str) + this.suffix, 0);
     this.label.TextAlign = ContentAlignment.MiddleCenter;
     this.label.BackColor = this.background_color;
     this.label.ForeColor = this.foreground_color;
     if (this.click != null)
     {
         this.label.Click += this.click;
     }
 }
Exemplo n.º 8
0
        void IWidget.InitializeWidget(Bar bar)
        {
            this.bar = bar;

            label = bar.CreateLabel("", 0);
            label.BackColor = backgroundColor;
            label.ForeColor = foregroundColor;
            label.TextAlign = ContentAlignment.MiddleCenter;

            bar.BarShown += () => updateTimer.Start();
            bar.BarHidden += () => updateTimer.Stop();
        }
Exemplo n.º 9
0
        void IWidget.InitializeWidget(Bar bar)
        {
            this.bar = bar;

            label           = bar.CreateLabel("", 0);
            label.BackColor = backgroundColor;
            label.ForeColor = foregroundColor;
            label.TextAlign = ContentAlignment.MiddleCenter;

            bar.BarShown  += () => updateTimer.Start();
            bar.BarHidden += () => updateTimer.Stop();
        }
Exemplo n.º 10
0
        void IWidget.InitializeWidget(Bar bar)
        {
            this.bar = bar;

            label           = bar.CreateLabel("", 0);
            label.BackColor = backgroundColor;
            label.ForeColor = foregroundColor;
            label.TextAlign = ContentAlignment.MiddleCenter;

            Workspace.WindowActivatedEvent += SetNewLanguage;
            InputLanguageChanged           += SetNewLanguage;
        }
Exemplo n.º 11
0
        void IWidget.InitializeWidget(Bar bar)
        {
            this.bar = bar;

            label           = bar.CreateLabel(prefix + counter.NextValue().ToString("00") + postfix, 0);
            label.BackColor = backgroundColor;
            label.ForeColor = foregroundColor;
            label.TextAlign = ContentAlignment.MiddleCenter;

            bar.BarShown  += () => updateTimer.Start();
            bar.BarHidden += () => updateTimer.Stop();
        }
Exemplo n.º 12
0
        void IWidget.InitializeWidget(Bar bar)
        {
            this.bar = bar;

            label = bar.CreateLabel(prefix + counter.NextValue().ToString("00") + postfix, 0);
            label.BackColor = backgroundColor;
            label.ForeColor = foregroundColor;
            label.TextAlign = ContentAlignment.MiddleCenter;

            bar.BarShown += () => updateTimer.Start();
            bar.BarHidden += () => updateTimer.Stop();
        }
Exemplo n.º 13
0
        void IWidget.InitializeWidget(Bar bar)
        {
            this.bar = bar;

            label = bar.CreateLabel("", 0);
            label.BackColor = backgroundColor;
            label.ForeColor = foregroundColor;
            label.TextAlign = ContentAlignment.MiddleCenter;

            Workspace.WindowActivatedEvent += SetNewLanguage;
            InputLanguageChanged += SetNewLanguage;
        }
Exemplo n.º 14
0
        void IWidget.InitializeWidget(Bar bar)
        {
            this.bar = bar;

            Windawesome.WindowTitleOrIconChanged += WindawesomeOnWindowTitleOrIconChanged;

            var hWnd = NativeMethods.FindWindow(windowClassName, null);
            var text = NativeMethods.GetText(hWnd);
            label = bar.CreateLabel(text, 0);
            label.BackColor = backgroundColor;
            label.ForeColor = foregroundColor;
            label.TextAlign = ContentAlignment.MiddleCenter;
        }
Exemplo n.º 15
0
        void IWidget.InitializeWidget(Bar bar)
        {
            this.bar = bar;

            Windawesome.WindowTitleOrIconChanged += WindawesomeOnWindowTitleOrIconChanged;

            var hWnd = NativeMethods.FindWindow(windowClassName, null);
            var text = NativeMethods.GetText(hWnd);

            label           = bar.CreateLabel(text, 0);
            label.BackColor = backgroundColor;
            label.ForeColor = foregroundColor;
            label.TextAlign = ContentAlignment.MiddleCenter;
        }
Exemplo n.º 16
0
        void IWidget.InitializeWidget(Bar bar)
        {
            this.bar = bar;

            bar.BarShown += () => OnWorkspaceLayoutChanged(bar.Monitor.CurrentVisibleWorkspace);

            Workspace.LayoutUpdated          += () => OnWorkspaceLayoutChanged(bar.Monitor.CurrentVisibleWorkspace);
            Workspace.WorkspaceShown         += OnWorkspaceLayoutChanged;
            Workspace.WorkspaceLayoutChanged += (ws, _) => OnWorkspaceLayoutChanged(ws);

            layoutLabel           = bar.CreateLabel("", 0);
            layoutLabel.TextAlign = ContentAlignment.MiddleCenter;
            layoutLabel.BackColor = backgroundColor;
            layoutLabel.ForeColor = foregroundColor;
            if (onClick != null)
            {
                layoutLabel.Click += (unused1, unused2) => onClick();
            }
        }
Exemplo n.º 17
0
        void IWidget.InitializeWidget(Bar bar)
        {
            this.bar = bar;

            bar.BarShown += () => OnWorkspaceLayoutChanged(bar.Monitor.CurrentVisibleWorkspace);

            Workspace.LayoutUpdated += () => OnWorkspaceLayoutChanged(bar.Monitor.CurrentVisibleWorkspace);
            Workspace.WorkspaceShown += OnWorkspaceLayoutChanged;
            Workspace.WorkspaceLayoutChanged += (ws, _) => OnWorkspaceLayoutChanged(ws);

            layoutLabel = bar.CreateLabel("", 0);
            layoutLabel.TextAlign = ContentAlignment.MiddleCenter;
            layoutLabel.BackColor = backgroundColor;
            layoutLabel.ForeColor = foregroundColor;
            if (onClick != null)
            {
                layoutLabel.Click += (unused1, unused2) => onClick();
            }
        }
Exemplo n.º 18
0
        void IWidget.InitializeWidget(Bar bar)
        {
            if (flashWorkspaces)
            {
                flashTimer.Tick += OnTimerTick;
                OnWorkspaceFlashingStopped += SetWorkspaceLabelColor;
            }

            bar.BarShown += () => flashTimer.Start();
            bar.BarHidden += () => flashTimer.Stop();

            workspaceLabels = new Label[windawesome.config.Workspaces.Length];

            Workspace.WorkspaceWindowAdded += (ws, _) => SetWorkspaceLabelColor(ws);
            Workspace.WorkspaceWindowRemoved += (ws, _) => SetWorkspaceLabelColor(ws);

            Workspace.WorkspaceDeactivated += OnWorkspaceChangedFromTo;
            Workspace.WorkspaceActivated += OnWorkspaceChangedFromTo;
            Workspace.WorkspaceShown += OnWorkspaceChangedFromTo;
            Workspace.WorkspaceHidden += OnWorkspaceChangedFromTo;

            for (var i = 0; i < windawesome.config.Workspaces.Length; i++)
            {
                var workspace = windawesome.config.Workspaces[i];
                var name = workspace.name ?? (i + 1).ToString();

                var label = bar.CreateLabel(" " + name + " ", 0);
                label.TextAlign = ContentAlignment.MiddleCenter;
                label.Click += OnWorkspaceLabelClick;
                workspaceLabels[i] = label;
                SetWorkspaceLabelColor(workspace);
            }
        }