public NotificationForm(TaskbarApplication app, string label) : this(app)
        {
            if (string.IsNullOrWhiteSpace(label))
            {
                throw new ArgumentNullException(nameof(label));
            }

            this.Height = 40;

            this.CopyLinkButton.Visible = false;
            this.CopyLinkButton.Enabled = false;

            this.OpenLinkButton.Padding = new Padding(0);

            this.OpenLinkButton.Font = new Font(this.OpenLinkButton.Font.FontFamily, 11, FontStyle.Bold);

            this.OpenLinkButton.Text = label;

            this.OpenLinkButton.Dock      = DockStyle.Fill;
            this.OpenLinkButton.BackColor = Color.LightGray;
            this.OpenLinkButton.TextAlign = ContentAlignment.MiddleCenter;

            this.OpenLinkButton.FlatAppearance.BorderColor        = Color.Gray;
            this.OpenLinkButton.FlatAppearance.MouseDownBackColor = Color.LightGray;
            this.OpenLinkButton.FlatAppearance.MouseOverBackColor = Color.LightGray;

            int textWidth = TextRenderer.MeasureText(label, this.OpenLinkButton.Font).Width;
            if (textWidth > this.Width)
            {
                this.OpenLinkButton.Text = String.Concat(label.Substring(0, 40), "…");
            }
        }
예제 #2
0
        static void Main()
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using var app = new TaskbarApplication();

            Application.Run(app);
        }
        public NotificationForm(TaskbarApplication app)
        {
            this.InitializeComponent();

            this.App = app;

            this.fadeoutTimer = new Timer
            {
                Interval = 4000
            };
            this.fadeoutTimer.Tick += this.OnTimerTick;

            this.NotificationClosing = false;

            if (this.App != null)
            {
                this.App.CloseNotifications += this.OnParentCloseNotifications;
            }
        }
        public NotificationForm(TaskbarApplication app, QuickAction quickAction) : this(app)
        {
            if (quickAction == null)
            {
                throw new ArgumentNullException(nameof(quickAction));
            }

            this.OpenLinkButton.Text = quickAction.OpenLabel;

            if (quickAction.CanCopy)
            {
                this.CopyLinkButton.Text = String.Format(CultureInfo.CurrentCulture, "Copy link");
            }
            else
            {
                this.CopyLinkButton.Visible = false;
                this.CopyLinkButton.Enabled = false;
                this.OpenLinkButton.Dock    = DockStyle.Fill;
            }
        }