Example #1
0
        private formNotify(NotifyType t, int screen, Settings.ScreenAnchor anchor, Image image, bool dispose)
            : this(t, screen, anchor)
        {
            this.Controls.Clear();

            var b    = this.screen.Bounds;
            var ms   = new System.Drawing.Size(b.Width / 5, b.Height / 5);
            var size = Util.RectangleConstraint.Scale(image.Size, ms);

            var p = new PictureBox()
            {
                Location = new Point(2, 2),
                Size     = new Size(size.Width - 4, size.Height - 4),
                SizeMode = PictureBoxSizeMode.StretchImage,
                Image    = image,
            };

            if (dispose)
            {
                this.Disposed += delegate
                {
                    image.Dispose();
                };
            }

            this.Controls.Add(p);

            var _h = this.Handle; //force

            this.Size = size;

            Initialize(t);
        }
Example #2
0
        void radio_CheckedChanged(object sender, EventArgs e)
        {
            var r = (RadioButton)sender;

            if (r.Checked)
            {
                currentAnchor = (Settings.ScreenAnchor)r.Tag;
                OnScreenPositionChanged();
            }
        }
Example #3
0
 public static void Show(NotifyType t, int screen, Settings.ScreenAnchor anchor, Tools.BackgroundPatcher.DownloadProgressEventArgs pe)
 {
     Show(new formNotify(t, screen, anchor, new Tools.BackgroundPatcher.PatchEventArgs()
     {
         Build   = pe.build,
         Files   = pe.filesTotal + pe.manifestsTotal,
         Size    = pe.estimatedBytesRemaining + pe.contentBytesTotal,
         Elapsed = DateTime.UtcNow.Subtract(pe.startTime)
     }));
 }
Example #4
0
        private formNotify(NotifyType t, int screen, Settings.ScreenAnchor anchor, string text1, string text2)
            : this(t, screen, anchor)
        {
            var b = this.screen.WorkingArea;
            var ms = new System.Drawing.Size(b.Width / 4, b.Height / 4);
            int w, h;
            var spacing = labelBuildCaption.Top - labelTitle.Bottom;
            var xpad    = labelTitle.Left * 2;
            var ypad    = labelTitle.Top + this.Height - labelElapsedCaption.Bottom;

            labelTitle.MaximumSize         = ms;
            labelBuildCaption.MaximumSize  = ms;
            labelBuildCaption.AutoEllipsis = true;
            labelTitle.AutoEllipsis        = true;
            labelTitle.Text        = text1;
            labelBuildCaption.Text = text2;

            w = labelTitle.Width;
            h = labelTitle.Height;

            switch (t)
            {
            default:
            case NotifyType.Note:

                if (!string.IsNullOrEmpty(text2))
                {
                    labelBuildCaption.Top = labelTitle.Bottom + labelBuildCaption.Height / 2;
                    //labelBuild.Location = new Point(labelBuildCaption.Left, labelTitle.Bottom + labelBuild.Height / 2);
                    h += labelBuildCaption.Bottom - labelTitle.Bottom;
                    labelBuildCaption.Visible = true;
                    //labelBuildCaption.ForeColor = Color.FromArgb(115, 115, 115);

                    if (labelBuildCaption.Width > w)
                    {
                        w = labelBuildCaption.Width;
                    }
                }

                labelTitle.Visible = true;

                break;
            }

            if (w < this.Width)
            {
                w = this.Width;
            }

            var _h = this.Handle; //force

            this.Size = new Size(w + xpad, h + ypad);

            Initialize(t);
        }
Example #5
0
        //private string formatSize;

        private formNotify(NotifyType t, int screen, Settings.ScreenAnchor anchor)
        {
            InitializeComponents();

            notifyType = t;

            var screens = Screen.AllScreens;

            if (screens.Length <= screen)
            {
                this.screen = Screen.PrimaryScreen;
            }
            else
            {
                this.screen = screens[screen];
            }

            this.anchor = anchor;
        }
Example #6
0
        public formScreenPosition(NotificationType type, int screen, Settings.ScreenAnchor anchor)
        {
            InitializeComponents();

            this.type = type;

            switch (type)
            {
            case NotificationType.Patch:

                pe = new Tools.BackgroundPatcher.DownloadProgressEventArgs()
                {
                    build             = 12345,
                    filesTotal        = 123,
                    startTime         = DateTime.UtcNow,
                    contentBytesTotal = 12345
                };

                break;

            case NotificationType.Note:
                break;

            case NotificationType.Screenshot:

                break;
            }

            screens       = Screen.AllScreens;
            currentScreen = screen;

            if (currentScreen >= screens.Length)
            {
                currentScreen = 0;
            }

            if (screens.Length > 1)
            {
                arrowLeft.Visible  = true;
                arrowRight.Visible = true;
            }

            labelScreen.Text = (currentScreen + 1).ToString();

            radioBL.Tag = Settings.ScreenAnchor.BottomLeft;
            radioBR.Tag = Settings.ScreenAnchor.BottomRight;
            radioTL.Tag = Settings.ScreenAnchor.TopLeft;
            radioTR.Tag = Settings.ScreenAnchor.TopRight;

            radioBR.Checked = true;
            currentAnchor   = Settings.ScreenAnchor.BottomRight;

            foreach (Control c in this.Controls)
            {
                c.LostFocus += c_LostFocus;
                if (c is RadioButton)
                {
                    var r = (RadioButton)c;
                    if (r.Tag != null && (Settings.ScreenAnchor)r.Tag == anchor)
                    {
                        r.Checked     = true;
                        currentAnchor = anchor;
                    }
                    r.CheckedChanged += radio_CheckedChanged;
                }
            }
        }
Example #7
0
 public ScreenPositionChangedEventArgs(int screen, Settings.ScreenAnchor anchor)
 {
     this.Screen = screen;
     this.Anchor = anchor;
 }
Example #8
0
 public static void ShowImage(int screen, Settings.ScreenAnchor anchor, string text, Image image, bool dispose)
 {
     Show(new formNotify(NotifyType.Note, screen, anchor, image, dispose));
 }
Example #9
0
 public static void ShowNote(int screen, Settings.ScreenAnchor anchor, string text, string accountName)
 {
     Show(new formNotify(NotifyType.Note, screen, anchor, text, accountName));
 }
Example #10
0
 public static void Show(NotifyType t, int screen, Settings.ScreenAnchor anchor, Tools.BackgroundPatcher.PatchEventArgs pe)
 {
     Show(new formNotify(t, screen, anchor, pe));
 }
Example #11
0
        private formNotify(NotifyType t, int screen, Settings.ScreenAnchor anchor, Tools.BackgroundPatcher.PatchEventArgs pe)
            : this(t, screen, anchor)
        {
            labelBuild.Text = string.Format(labelBuild.Text, pe.Build);

            switch (t)
            {
            case NotifyType.PatchReady:

                var    elapsed = pe.Elapsed;
                string _elapsed;
                if (elapsed.TotalMinutes >= 1)
                {
                    int m = (int)elapsed.TotalMinutes;
                    _elapsed = m + "m";
                    if (elapsed.Seconds > 0)
                    {
                        _elapsed += " " + elapsed.Seconds + "s";
                    }
                }
                else
                {
                    _elapsed = elapsed.Seconds + "s";
                }

                labelTitle.Text   = "Patch ready";
                labelSize.Text    = string.Format(labelSize.Text, pe.Files, Util.Text.FormatBytes(pe.Size), pe.Files != 1 ? "files" : "file");
                labelElapsed.Text = string.Format(labelElapsed.Text, _elapsed);

                labelBuild.Visible          = true;
                labelBuildCaption.Visible   = true;
                labelElapsed.Visible        = true;
                labelElapsedCaption.Visible = true;
                labelSize.Visible           = true;
                labelSizeCaption.Visible    = true;
                labelTitle.Visible          = true;

                break;

            case NotifyType.DownloadingFiles:

                labelTitle.Text        = "Downloading";
                labelElapsed.Text      = "(estimated)";
                labelElapsed.ForeColor = Color.DimGray;
                labelSize.Text         = string.Format(labelSize.Text, pe.Files, Util.Text.FormatBytes(pe.Size), pe.Files != 1 ? "files" : "file");

                labelBuild.Visible        = true;
                labelBuildCaption.Visible = true;
                labelElapsed.Visible      = true;
                labelSize.Visible         = true;
                labelSizeCaption.Visible  = true;
                labelTitle.Visible        = true;

                break;

            case NotifyType.DownloadingManifests:

                labelTitle.Text    = "Downloading build " + labelBuild.Text;
                labelTitle.Visible = true;

                this.Height       = labelTitle.Location.Y * 2 + labelTitle.Height;
                this.SizeChanged += formNotify_SizeChanged;

                break;

            case NotifyType.Error:

                labelTitle.Text    = "Failed to download update";
                labelTitle.Visible = true;

                this.Height       = labelTitle.Location.Y * 2 + labelTitle.Height;
                this.SizeChanged += formNotify_SizeChanged;

                break;
            }

            Initialize(t);
        }