/// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        /// https://stackoverflow.com/questions/1052147/how-do-i-extend-a-winforms-dispose-method
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                // Dispose stuff here
                if (Browser != null)
                {
                    Browser.Dispose();
                    Browser = null;
                }
                if (PreviewPicture != null)
                {
                    PreviewPicture.Dispose();
                    PreviewPicture = null;
                }
                for (int i = 0; i < this.Controls.Count; i++)
                {
                    if (Controls[i] != null)
                    {
                        Controls[i].Dispose();
                    }
                }
                this.Controls.Clear();
            }

            base.Dispose(disposing);
        }
Esempio n. 2
0
        //sets the window title to reflect the new picture, and
        //begine the async process of loading the new picture
        public void DisplayMedia(Media m)
        {
            if (PreviewPicture != null)
            {
                PreviewPicture.Image = null;
            }
            if (Medias.Count == 0)
            {
                return;
            }
            if (m.URL.Equals(""))
            {
                return;
            }
            if (Controls.Contains(PreviewPicture))
            {
                Controls.Remove(PreviewPicture);
                PreviewPicture.Dispose();
                PreviewPicture = null;
            }
            if (Controls.Contains(Browser))
            {
                Controls.Remove(Browser);
                Browser.Dispose();
                Browser = null;
            }
            if (Controls.Contains(player))
            {
                Controls.Remove(player);
                player.Dispose();
                player = null;
            }
            if (Controls.Contains(ErrorLabel))
            {
                Controls.Remove(ErrorLabel);
                ErrorLabel.Dispose();
                ErrorLabel = null;
            }
            //calculate the new component size
            //width is from the top left of previous to the top right of next
            //height is PreviewComponentLocation (12) Y to location of top left of preview - 6
            int picturewidth  = (NextPicButton.Location.X + NextPicButton.Size.Width) - PreviousPicButton.Location.X;
            int pictureHeight = PreviousPicButton.Location.Y - 6 - PreviewComponentLocation.Y;

            PreviewComponentSize = new Size(picturewidth, pictureHeight);
            switch (m.MediaType)
            {
            case MediaType.Picture:
                PreviewPicture = new PictureBox()
                {
                    Size      = PreviewComponentSize,
                    BackColor = PreviewComponentBackColor,
                    Location  = PreviewComponentLocation,
                    SizeMode  = PictureBoxSizeMode.Zoom,
                    Anchor    = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left)
                };
                PreviewPicture.Click += PreviewPicture_Click;
                Controls.Add(PreviewPicture);
                PreviewPicture.Image = Settings.GetLoadingImage();
                PreviewPicture.LoadAsync(m.URL);
                Text = DBO.NameFormatted + " - " + CurrentlySelected;
                Logging.Manager("Preview: started loading of picture '" + DBO.NameFormatted + "' at URL '" + m.URL + "'");
                break;

            case MediaType.Webpage:
                //NOTE: needs to be fixed
                Browser = new WebBrowser()
                {
                    Size     = PreviewComponentSize,
                    Location = PreviewComponentLocation,
                    ScriptErrorsSuppressed = true,
                    Anchor = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left)
                };
                Controls.Add(Browser);
                Browser.Navigate(m.URL);
                Text = DBO.NameFormatted + " - " + CurrentlySelected;
                Logging.Manager("Preview: started loading of webpage '" + DBO.NameFormatted + "' at URL '" + m.URL + "'");
                break;

            case MediaType.MediaFile:
                try
                {
                    player = new RelhaxMediaPlayer()
                    {
                        Size     = PreviewComponentSize,
                        Location = PreviewComponentLocation,
                        //BackColor = PreviewComponentBackColor,
                        MediaURL = m.URL,
                        Anchor   = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left)
                    };
                    Controls.Add(player);
                    Text = DBO.NameFormatted + " - " + CurrentlySelected;
                    Logging.Manager("Preview: started loading of direct media '" + DBO.NameFormatted + "' at URL '" + m.URL + "'");
                }
                catch (Exception e)
                {
                    Utils.ExceptionLog(e);
                    ErrorLabel = new Label()
                    {
                        Text     = "ERROR",
                        AutoSize = false,
                        Size     = PreviewComponentSize
                    };
                    Controls.Add(ErrorLabel);
                    Text = DBO.NameFormatted + " - " + CurrentlySelected;
                }
                break;

            case MediaType.HTML:
                Browser = new WebBrowser()
                {
                    Size     = PreviewComponentSize,
                    Location = PreviewComponentLocation,
                    ScriptErrorsSuppressed = true,
                    Anchor = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left)
                };
                Controls.Add(Browser);
                Browser.DocumentText = m.URL;
                Text = DBO.NameFormatted + " - " + CurrentlySelected;
                Logging.Manager("Preview: started loading of HTML '" + DBO.NameFormatted + "' at HTML '" + m.URL + "'");
                break;

            default:
                Logging.Manager("WARNING: Unknown mediaType: " + m.MediaType);
                break;
            }
        }
Esempio n. 3
0
        public static void CustomizeControl(PreviewPicture previewPicture, EditFormMode mode)
        {
            CheckHelper.ArgumentNotNull(previewPicture, "previewPicture");

            previewPicture.Enabled = mode != EditFormMode.View;
        }