Beispiel #1
0
        public bool Popup(string[] args)
        {
            GraphicsPath GP = new GraphicsPath();


            //string[] args = Environment.GetCommandLineArgs();

            if (confmode)
            {
                args = new string[] { "This will display the path that will be copied" };
            }

            //string[] args = new string[1] { "Hello World.pdf" };
            if (args.Length > 0)
            {
                if (string.IsNullOrEmpty(File))
                {
                    File = System.IO.Path.GetFullPath(args[0]);
                }
                else
                {
                    File += "\r\n" + args[0];
                }

                try {
                    Clipboard.SetText(File, TextDataFormat.Text);
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message, "Error");
                    return(false);
                }



                string display = "Copied " + args[0] + " To Clipboard.";//System.IO.Path.GetFileName(File);
                Size   TxtSize = TextRenderer.MeasureText(File, this.Font);
                if (TxtSize.Width > (Screen.PrimaryScreen.WorkingArea.Width / 2))
                {
                    TxtSize.Width = Screen.PrimaryScreen.WorkingArea.Width / 2;
                }
                Bitmap bmp = new Bitmap(TxtSize.Width + 10, 24);
                // Bitmap bmp = new Bitmap(TxtSize.Width - (TxtSize.Width / 2), 24);
                Rectangle bnds = new Rectangle(new Point(), bmp.Size);
                this.Size     = bnds.Size;
                this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Right - bnds.Width - 5, Screen.PrimaryScreen.WorkingArea.Bottom - bnds.Height - 5);
                GP.AddArc(new Rectangle(0, 0, 16, 16), 180, 90);
                GP.AddArc(new Rectangle(bnds.Right - 17, 0, 16, 16), 270, 90);
                GP.AddArc(new Rectangle(bnds.Right - 17, bnds.Bottom - 17, 16, 16), 0, 90);
                GP.AddArc(new Rectangle(0, bnds.Bottom - 17, 16, 16), 90, 90);
                GP.CloseFigure();

                Graphics            G   = Graphics.FromImage(bmp);
                LinearGradientBrush lbg = new LinearGradientBrush(bnds, this.GradientTopColor, this.GradientBottomColor, LinearGradientMode.Vertical);
                G.FillPath(lbg, GP);
                StringFormat SF = StringFormat.GenericTypographic;
                SF.Alignment     = StringAlignment.Center;
                SF.FormatFlags   = StringFormatFlags.NoWrap;
                SF.Trimming      = StringTrimming.EllipsisPath;
                SF.LineAlignment = StringAlignment.Center;
                bnds.X          += 5;
                bnds.Width      -= 10;
                SolidBrush TextBrush = new SolidBrush(this.TextColor);
                G.DrawString(display, this.Font, TextBrush, bnds, SF);
                Pen P = new Pen(this.OutlineColor, 1);
                TextBrush.Dispose();
                P.Alignment = PenAlignment.Inset;
                G.DrawPath(P, GP);
                G.Dispose();
                P.Dispose();
                this.BackgroundImage = bmp;
                ShowWindow(this.Handle, SW_SHOWNOACTIVATE);
                MakeAlwaysOnTop(true);
                if (!confmode)
                {
                    DelayFade.Start();
                }
                return(true);
            }
            else
            {
                this.Close();
            }
            return(false);
        }
Beispiel #2
0
 private void DelayFade_Tick(object sender, EventArgs e)
 {
     DelayFade.Stop();
     FadeOut.Start();
 }