Exemplo n.º 1
0
        public FormDiscInfo(Disc disc)
        {
            InitializeComponent();

            _defaultJacketSizeMode = pictureBoxJacket.SizeMode;

            var fs = disc.FileSystem;
            var metadata = disc.Metadata;

            labelQuickSummary.Text = GenerateQuickSummary(metadata, fs);

            if (fs.Files.JacketImageSmall != null)
            {
                _hasSmallJacketImage = true;
                _smallJacketImagePath = fs.Files.JacketImageSmall.FullName;

                pictureBoxJacket.ImageLocation = _smallJacketImagePath;
                toolStripMenuItemJacketImagePath.Text = _smallJacketImagePath;
            }

            groupBoxJacket.Visible = _hasSmallJacketImage;

            discInfoMetadataPanel.SetDisc(disc);
            discInfoFeaturesPanel.SetDisc(disc);

            this.EnableSelectAll();
        }
Exemplo n.º 2
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 /// 
 /// <param name="image">The image to show.</param>
 /// <param name="imageWidth">The width of the image.</param>
 /// <param name="imageHeight">The height of the image.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// 
 public static DialogResult Show(double[] image, int imageWidth, int imageHeight,
     PictureBoxSizeMode sizeMode)
 {
     Bitmap bitmap;
     new ArrayToImage(imageWidth, imageHeight).Convert(image, out bitmap);
     return Show("Image", bitmap, sizeMode);
 }
Exemplo n.º 3
0
		public PictureBox()
		{
			sizeMode = PictureBoxSizeMode.Normal;
			TabStop = false;
			SetStyle(ControlStyles.SupportsTransparentBackColor, true);
			SetStyle(ControlStyles.Selectable, false);
		}
        public ImagePreviewForm(Image image, PictureBoxSizeMode sizeMode = PictureBoxSizeMode.StretchImage)
        {
            InitializeComponent();

            picImage.Image = image;
            picImage.SizeMode = sizeMode;
            // picImage.im
        }
Exemplo n.º 5
0
        public new void Load(string imageLoc)
        {
            SizeMode = PictureBoxSizeMode.AutoSize;
            base.Load(imageLoc);
            Size size = Image.Size;
            SizeMode = PictureBoxSizeMode.StretchImage;
            Size = size;

            this.KeyDown += new KeyEventHandler(OnKeyDown);
        }
Exemplo n.º 6
0
		public void SetUpFixture()
		{
			BitmapFileNamesRequested.Clear();
			CreatedComponents.Clear();
			WixProject project = WixBindingTestsHelper.CreateEmptyWixProject();
			WixDocument doc = new WixDocument(project, this);
			doc.LoadXml(GetWixXml());
			WixDialog wixDialog = doc.CreateWixDialog("WelcomeDialog", new MockTextFileReader());
			using (Form dialog = wixDialog.CreateDialog(this)) {
				PictureBox pictureBox = (PictureBox)dialog.Controls[0];
				hasImage = (pictureBox.Image != null);
				sizeMode = pictureBox.SizeMode;
			}
		}
Exemplo n.º 7
0
        protected ImageSettings(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            SerializationInfoEnumerator infoEnum = info.GetEnumerator();
            while (infoEnum.MoveNext())
            {
                switch (infoEnum.Name)
                {
                    case "SizeMode":
                        _sizeMode = (PictureBoxSizeMode)info.GetValue("SizeMode", typeof(PictureBoxSizeMode));
                        break;

                    case "BackgroundColor":
                        _backgroundColor = (Color)info.GetValue("BackgroundColor", typeof(Color));
                        break;
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 /// 
 /// <param name="title">The text to display in the title bar of the image box.</param>
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// 
 public static DialogResult Show(string title, UnmanagedImage image,
     PictureBoxSizeMode sizeMode)
 {
     return Show(title, image, sizeMode, 0, 0);
 }
Exemplo n.º 9
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 /// 
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// 
 public static DialogResult Show(UnmanagedImage image, PictureBoxSizeMode sizeMode)
 {
     return Show("Image", image, sizeMode, 0, 0);
 }
 public void LoadImage(Image img, PictureBoxSizeMode sizeMode = PictureBoxSizeMode.Zoom)
 {
     pbMain.SizeMode = sizeMode;
     pbMain.Image    = (Image)img.Clone();
     isReady         = true;
 }
Exemplo n.º 11
0
        private void ChangeCameraSizeMode(PictureBoxSizeMode sizeMode)
        {
            pbxRender.SizeMode = sizeMode;

            foreach (ToolStripMenuItem Item in sizeModeToolStripMenuItem.DropDownItems)
            {
                Item.Checked = false;
            }
        }
Exemplo n.º 12
0
        protected async void onMouseDown(object o, MouseEventArgs e)
        {
            Label tb = (Label) Controls.Find("console", true)[0];

            switch (((Control) o).Name)
            {

                case "optionInput_Help":

                    Form helpForm = new Form();
                    helpForm.AutoSize = true;
                    helpForm.Location = tempUsername.Location;

                    FancyLabel help = new FancyLabel();
                    help.Text = "WCN Quick Help";
                    help.Font = loginUsername.Font;
                    help.AutoSize = true;
                    helpForm.Controls.Add(help);

                    FancyLabel message = new FancyLabel();
                    message.Text = "Hello. Welcome to WCN File Manager by David (Hugs).";
                    message.Text += "\nYou can drag a background image onto the program to replace the default one.";
                    message.Text += "\nSometimes large images will make scrolling laggier.";
                    message.Text += "\nYou can scroll through images using the bottom bar.";
                    message.Text += "\nClicking closer to the left will move left, and clicking closer to the right will move right.";
                    message.Text += "\nYou can change how hovering over images behaves with the hover mode option.";
                    message.Text += "\nThe bg style option cycles through background image size modes.";
                    message.Text += "\nIt may take awhile for all images to load when scrolling. Once loaded it will be smooth.";
                    message.Text += "\nDownloaded images can be viewed by using the open folder option.";
                    message.Text += "\nYou can add music to the music folder and it will cycle through playing them. You can use the next button as well.";
                    message.Text += "\nThis program remembers every setting you choose and stores in %appdata%.";
                    message.Text += "\nThank you for trying WCN File Manager BETA.";
                    message.Font = tb.Font;
                    message.Location = new Point(help.Location.X, help.Location.Y + 5 + help.Height);
                    message.AutoSize = true;
                    helpForm.Controls.Add(message);

                    helpForm.Visible = true;

                break;

                case "optionInput_HoverMode":

                    if (!globalSettings.ContainsKey("HoverMode"))
                    {
                        globalSettings["HoverMode"] = "No";
                    }
                    else
                    {
                        string hover = globalSettings["HoverMode"];
                        globalSettings["HoverMode"] = hover.Equals("Yes") ? "No" : "Yes";
                    }

                    tb.Text += "\n[ -> ] hover preview set to " + globalSettings["HoverMode"];

                break;

                case "optionInput_PlayMusic": case "ControlPlay":

                    if ((int) wmp.playState != (int) WMPLib.WMPPlayState.wmppsPlaying)
                    {
                        if (wmp.URL.Equals("") || wmp.URL == null)
                        {
                            wmp = new WindowsMediaPlayer();
                            wmp.PlayStateChange += new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(playStateChange);
                            string[] filez = Directory.GetFiles(filePath + "/Music/", "*.*");
                            if (filez.Length == 0)
                            {
                                wmp.URL = "http://f.worldscolli.de/mlpas.mp3";
                            }
                            else
                            {
                                wmp.URL = filez[new Random().Next(filez.Length)];
                            }
                        }

                        wmp.controls.play();
                        globalSettings["PlayMusic"] = "Yes";
                        naturalEnding = true;
                        tb.Text += "\n[ -> ] playing " + wmp.currentMedia.name;
                    }

                break;

                case "optionInput_ShittyComputerMode":
                    
                    if (shittyComputerMode)
                    {
                        globalSettings["ShittyComputerMode"] = "No";
                    }
                    else
                    {
                        globalSettings["ShittyComputerMode"] = "Yes";
                    }

                    MessageBox.Show("The program needs to restart in order for this to take effect.\nYou will have to manually open it again.");
                    Application.Exit();

                break;

                case "optionInput_MultiSelect":

                    if (!globalSettings.ContainsKey("MultiSelect"))
                    {
                        globalSettings["MultiSelect"] = "No";
                    }

                    string value = globalSettings["MultiSelect"];
                    globalSettings["MultiSelect"] = value.Equals("Yes") ? "No" : "Yes";

                    if (globalSettings["MultiSelect"].Equals("Yes"))
                    {
                        ((Control)o).BackColor = Color.Purple;
                    }
                    else
                    {
                         ((Control)o).BackColor = Color.Transparent;
                    }

                break;

                case "optionInput_ResetBackground":

                    backgroundBack.Load(loggedIn ? "http://i.imgur.com/78jicHm.jpg" : "http://i.imgur.com/LvoiQw6.gif");
                    bgChanged = false;
                    globalSettings.Remove("BGPath");
                    backgroundBack.SizeMode = PictureBoxSizeMode.StretchImage;
                    currentBG = (Bitmap)backgroundBack.Image.Clone();
                    tb.Text += "\n[ -> ] background reset to default";

                break;

                case "ControlPause":

                    wmp.controls.pause();
                    globalSettings["PlayMusic"] = "No";
                    tb.Text += "\n[ -> ] paused " + wmp.currentMedia.name;

                break;

                case "ControlStop":

                    naturalEnding = false;
                    wmp.controls.stop();
                    globalSettings["PlayMusic"] = "No";
                    tb.Text += "\n[ -> ] stopped " + wmp.currentMedia.name;

                break;

                case "ControlNext":

                    naturalEnding = false;
                    wmp.controls.stop();
                    wmp = new WindowsMediaPlayer();
                    wmp.PlayStateChange += new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(playStateChange);
                    string[] files = Directory.GetFiles(filePath + "/Music/", "*.*");
                    if (files.Length == 0)
                    {
                        wmp.URL = "http://f.worldscolli.de/mlpas.mp3";
                    }
                    else
                    {
                        wmp.URL = files[new Random().Next(files.Length)];
                    }

                    naturalEnding = true;
                    tb.Text += "\n[ -> ] playing " + wmp.currentMedia.name;

                break;

                case "optionInput_BGStyle":

                    PictureBoxSizeMode[] pb = new PictureBoxSizeMode[] { PictureBoxSizeMode.CenterImage, PictureBoxSizeMode.Normal, PictureBoxSizeMode.StretchImage, PictureBoxSizeMode.Zoom };
                    string currSetting = globalSettings["BGStyle"];

                    for (int i = 0; i < pb.Length; i++)
                    {
                        if (pb[i].ToString().Replace(" ", "").Equals(currSetting))
                        {
                            int x = i + 1;
                            if (x >= pb.Length)
                            {
                                x = 0;
                            }
                            globalSettings["BGStyle"] = pb[x].ToString().Replace(" ", "");
                            backgroundBack.SizeMode = pb[x];
                            break;
                        }
                    }

                    tb.Text += "\n[ -> ] changing bg style to " + backgroundBack.SizeMode.ToString();

                break;

                case "PictureOptionCopy to Clipboard":

                    Clipboard.SetText(clickedImage.Name);
                    tb.Text += "\n[ -> ] copied to clipboard";

                break;

                case "PictureOptionSet as Desktop":

                    if (clickedImage.Text.Equals(""))
                    {
                        BackgroundWorker bw = new BackgroundWorker();
                        bw.DoWork += (b, w) =>
                        {
                            Wallpaper.Set(clickedImage.Name, Wallpaper.Style.Fill);
                        };

                        bw.RunWorkerAsync();

                        tb.Text += "\n[ -> ] changing wallpaper";
                    }
                    else
                    {
                        tb.Text += "\n[ -> ] error setting wallpaper";
                    }

                    ((Control)o).Enabled = false;

                break;

                case "PictureOptionDownload":

                    if (multi.Count() == 0)
                    {
                        multi.Add(clickedImage);
                    }

                    foreach (FancyLabel dl in multi)
                    {
                        string[] nameSplit = dl.Name.Split('/');
                        WebClient client = new WebClient();
                        client.DownloadFileAsync(new Uri(dl.Name), filePath + "/Download/" + nameSplit[nameSplit.Length - 1]);
                        ((Control)o).Enabled = false;

                        client.DownloadFileCompleted += (a, b) =>
                        {
                            tb.Text += "\n[ -> ] download of " + nameSplit[nameSplit.Length - 1] + " complete";
                            ((Control)o).Text = "Download";
                        };

                        client.DownloadProgressChanged += (a, b) =>
                        {
                            tb.Text += "\n[ -> ] downloading: " + b.ProgressPercentage + "%";
                            ((Control)o).Text = nameSplit[nameSplit.Length - 1] + ": " + b.ProgressPercentage + "%";
                        };
                    }

                break;

                case "PictureOptionOpen":

                    if (multi.Count() == 0)
                    {
                        multi.Add(clickedImage);
                    }

                    foreach (FancyLabel l in multi)
                    {
                        System.Diagnostics.Process.Start(l.Name);
                    }

                break;

                case "PictureOptionDelete":

                    if (multi.Count() == 0)
                    {
                        multi.Add(clickedImage);
                    }

                    foreach (FancyLabel l in multi)
                    {
                        string apiUrl = "http://files.worldscolli.de/api/remove";
                        var client = new HttpClient();
                        var values = new Dictionary<string, string>()
                        {
                            {"client_id", globalSettings["ClientID"]},
                            {"path", l.Name.Replace(@"http://f.worldscolli.de/", "")}
                        };

                        var content = new FormUrlEncodedContent(values);

                        try
                        {
                            var response = await client.PostAsync(apiUrl, content);
                            response.EnsureSuccessStatusCode();
                        }
                        catch (Exception botchedPost) {
                            MessageBox.Show(botchedPost.Message);
                        }

                        //string apiUrl = "http://files.worldscolli.de/api/remove?client_id=" + globalSettings["ClientID"] + "&path=" + l.Name.Replace(@"f.worldscolli.de/", "");
                       // HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl);

                        fullImages.Remove(l.Name);
                        thumbs.Remove(l.Name);
                        backgroundBack.Controls.Remove(l);
                    }

                    int xAmt = 0;
                    int yAmt = 0;
                    int yRows = 0;

                    foreach (string pic in thumbs.Keys)
                    {
                        FancyLabel leb = (FancyLabel) Controls.Find(pic, true)[0];
                        leb.Location = new Point(10 + xAmt, tempUsername.Location.Y - 80 + yAmt);
                        yAmt += 40 + leb.Height;
                        yRows++;

                        if (yRows == 3)
                        {
                            yAmt = 0;
                            yRows = 0;
                            xAmt += 40 + leb.Width;
                        }
                    }

                    multi.Clear();
                    onMouseDown(Controls.Find("PictureOptionCancel", true)[0], e);

                break;

                case "PictureOptionCancel":

                    viewingImage = false;
                    FancyLabel black = (FancyLabel)Controls.Find("black", true)[0];

                    foreach (string s in new string[] { "Copy to Clipboard", "Open", "Download", "Set as Desktop", "Delete", "Cancel" })
                    {
                        Controls.Find("PictureOption" + s, true)[0].Visible = false;
                        Controls.Find("PictureOption" + s, true)[0].Enabled = false;
                    }

                    backgroundBack.Image = currentBG;

                    foreach (Control c in previousVisible)
                    {
                        c.Visible = true;
                        c.Enabled = true;
                    }

                    clickedImage.BorderStyle = BorderStyle.None;
                    previousVisible.Clear();

                    for (int i = 200; i >= 0; i -= 10)
                    {
                        black.BackColor = Color.FromArgb(i, 0, 0, 0);
                        if (!shittyComputerMode)
                        {
                            await Task.Delay(10);
                        }
                    }

                    black.Visible = false;

                    foreach (FancyLabel l in multi)
                    {
                        l.BorderStyle = BorderStyle.None;
                    }

                    multi = new List<FancyLabel>();

                break;

                default:

                    try
                    {
                        ((FancyLabel)o).Select();
                        ((FancyLabel)o).Text = "";
                        if (((FancyLabel)o).Name.Equals("loginPassword"))
                        {
                            password = "";
                        }
                    }
                    catch (Exception ee) { }

                break;

                case "optionInput_LobbyMusicURL":

                    OpenFileDialog file = new OpenFileDialog();
                    file.InitialDirectory = (filePath).Replace("/", "\\");
                    file.RestoreDirectory = true;
                    file.AutoUpgradeEnabled = true;
                    file.Title = "WCN File Manager";
                    file.ShowDialog();

                break;
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// A window that lets the user wiew an image.
 /// </summary>
 /// <param name="i">The image</param>
 /// <param name="m">The resize mode</param>
 public ImageViewer(Image i, PictureBoxSizeMode m)
 {
     InitializeComponent();
     Image = i;
     Mode  = m;
 }
Exemplo n.º 14
0
        /// <summary>
        /// 初期化
        /// </summary>
        /// <param name="image"></param>
        /// <param name="sizeMode"></param>
#else
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="image"></param>
        /// <param name="sizeMode"></param>
#endif
        public CvWindowEx(IplImage image, PictureBoxSizeMode sizeMode)
            : this()
        {
            Image = image;
            _pictureBox.SizeMode = sizeMode;
        }
Exemplo n.º 15
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 ///
 /// <param name="title">The text to display in the title bar of the image box.</param>
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// <param name="width">The width of the image box.</param>
 /// <param name="height">The height of the image box.</param>
 /// <param name="backColor">The background color to use in the window.
 ///   Default is <see cref="Color.Black"/>.</param>
 ///
 public static DialogResult Show(string title, UnmanagedImage image,
                                 PictureBoxSizeMode sizeMode, int width, int height, Color backColor)
 {
     return(Show(title, image.ToManagedImage(), sizeMode, width, height, backColor));
 }
Exemplo n.º 16
0
        public void UpdatePixelData(int xPos, int yPos, Bitmap bmp, Rectangle displayRect, Rectangle bmpRect, PictureBoxSizeMode sizeMode)
        {
            // Determine (x, y) position within image
            int x = 0, y = 0;

            switch (sizeMode)
            {
            case PictureBoxSizeMode.AutoSize:
            case PictureBoxSizeMode.CenterImage:
                throw new NotSupportedException("The AutoSize and CenterImage size modes are not supported at this time.");

            case PictureBoxSizeMode.Normal:
                // Rectangle coords are image coords
                if (xPos >= bmp.Width || yPos >= bmp.Height)
                {
                    return;     // position outside image
                }
                x = xPos - bmpRect.X;
                y = yPos - bmpRect.Y;
                break;

            case PictureBoxSizeMode.StretchImage:
                // Translate rect coords to image
                x = xPos * bmp.Width / displayRect.Width;
                y = yPos * bmp.Height / displayRect.Height;
                break;

            case PictureBoxSizeMode.Zoom:
                // Determine image rectangle
                Rectangle r2 = ImageUtility.ScaleToFit(bmp, displayRect);

                if (!r2.Contains(xPos, yPos))
                {
                    return;     // position outside image
                }
                x = (xPos - r2.Left) * bmp.Width / r2.Width;
                y = (yPos - r2.Top) * bmp.Height / r2.Height;
                break;
            }

            // Extract color at calculated position
            Color c = bmp.GetPixel(x, y);

            // Update dialog values
            SetPixelData(x, y, c.R, c.G, c.B);
        }
Exemplo n.º 17
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 ///
 /// <param name="title">The text to display in the title bar of the image box.</param>
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// <param name="width">The width of the image box.</param>
 /// <param name="height">The height of the image box.</param>
 ///
 public static ImageBox Show(string title, UnmanagedImage image,
                             PictureBoxSizeMode sizeMode, int width, int height)
 {
     return(Show(title, image, sizeMode, width, height, Color.Black));
 }
Exemplo n.º 18
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 ///
 /// <param name="title">The text to display in the title bar of the image box.</param>
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 ///
 public static ImageBox Show(string title, Image image, PictureBoxSizeMode sizeMode)
 {
     return(Show(title, image, sizeMode, 0, 0));
 }
Exemplo n.º 19
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 ///
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// <param name="backColor">The background color to use in the window.
 ///   Default is <see cref="Color.Black"/>.</param>
 ///
 public static ImageBox Show(Image image, PictureBoxSizeMode sizeMode, Color backColor)
 {
     return(show("Image", image, sizeMode, 0, 0, backColor));
 }
Exemplo n.º 20
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 ///
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 ///
 public static ImageBox Show(Image image, PictureBoxSizeMode sizeMode)
 {
     return(Show("Image", image, sizeMode, 0, 0));
 }
Exemplo n.º 21
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 ///
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// <param name="width">The width of the image box.</param>
 /// <param name="height">The height of the image box.</param>
 ///
 public static ImageBox Show(Image image, PictureBoxSizeMode sizeMode, int width, int height)
 {
     return(show("Image", image, sizeMode, width, height, Color.Black));
 }
Exemplo n.º 22
0
        /// <summary>
        ///   Displays an image on the screen.
        /// </summary>
        /// 
        /// <param name="title">The text to display in the title bar of the image box.</param>
        /// <param name="image">The image to show.</param>
        /// <param name="sizeMode">How to display the image inside the image box.</param>
        /// <param name="width">The width of the image box.</param>
        /// <param name="height">The height of the image box.</param>
        /// <param name="backColor">The background color to use in the window. 
        ///   Default is <see cref="Color.Black"/>.</param>
        /// 
        public static DialogResult Show(string title, Image image,
            PictureBoxSizeMode sizeMode, int width, int height, Color backColor)
        {
            if (image == null)
                throw new ArgumentNullException("image");

            DialogResult result;

            if (width == 0 && height == 0)
            {
                switch (sizeMode)
                {
                    case PictureBoxSizeMode.AutoSize:
                        width = image.Width;
                        height = image.Height;
                        break;

                    case PictureBoxSizeMode.CenterImage:
                    case PictureBoxSizeMode.Normal:
                    case PictureBoxSizeMode.StretchImage:
                    case PictureBoxSizeMode.Zoom:
                        width = 320;
                        height = 240;
                        break;
                }
            }

            using (ImageBox box = new ImageBox())
            {
                box.SuspendLayout();
                box.Text = title;
                box.BackColor = backColor;
                box.ClientSize = new Size(width, height);
                box.pictureBox.SizeMode = sizeMode;
                box.pictureBox.Image = image;
                box.ResumeLayout(false);

                result = box.ShowDialog();
            }

            return result;
        }
Exemplo n.º 23
0
 internal void SetImageMode(PictureBoxSizeMode i)
 {
     clickthroughPictureBox1.SizeMode = i;
 }
Exemplo n.º 24
0
 private void uiPicture_Click(object sender, EventArgs e)
 {
     _pbSize            = (PictureBoxSizeMode)((1 + (int)_pbSize) % 5);
     uiPicture.SizeMode = _pbSize;
     log($"sizemode= {_pbSize}");
 }
Exemplo n.º 25
0
        private Rectangle ImageRectangleFromSizeMode(PictureBoxSizeMode mode)
        {
            Rectangle result = LayoutUtils.DeflateRect(ClientRectangle, Padding);

            if (image != null) {
                switch (mode) {
                  case PictureBoxSizeMode.Normal:
                  case PictureBoxSizeMode.AutoSize:
                      // Use image's size rather than client size.
                      result.Size = image.Size;
                      break;

                  case PictureBoxSizeMode.StretchImage:
                      // Do nothing, was initialized to the available dimensions.
                      break;

                  case PictureBoxSizeMode.CenterImage:
                      // Center within the available space.
                      result.X += (result.Width - image.Width) / 2;
                      result.Y += (result.Height - image.Height) / 2;
                      result.Size = image.Size;
                      break;
                  
                  case PictureBoxSizeMode.Zoom:
                    Size imageSize = image.Size;
                    float ratio = Math.Min((float)ClientRectangle.Width / (float)imageSize.Width, (float)ClientRectangle.Height / (float)imageSize.Height);
                    result.Width = (int)(imageSize.Width * ratio);
                    result.Height = (int) (imageSize.Height * ratio);
                    result.X = (ClientRectangle.Width - result.Width) /2;
                    result.Y = (ClientRectangle.Height - result.Height) /2;
                    break;

                  default:
                      Debug.Fail("Unsupported PictureBoxSizeMode value: " + mode);
                      break;
                }
            }

            return result;
        }
Exemplo n.º 26
0
        /// <summary>
        ///   Displays an image on the screen.
        /// </summary>
        /// 
        /// <param name="title">The text to display in the title bar of the image box.</param>
        /// <param name="image">The image to show.</param>
        /// <param name="sizeMode">How to display the image inside the image box.</param>
        /// <param name="width">The width of the image box.</param>
        /// <param name="height">The height of the image box.</param>
        /// <param name="backColor">The background color to use in the window. 
        ///   Default is <see cref="Color.Black"/>.</param>
        /// 
        public static DialogResult Show(string title, UnmanagedImage image, PictureBoxSizeMode sizeMode, int width, int height, Color backColor)
        {
            if (image == null)
                throw new ArgumentNullException("image");

            DialogResult result;

            using (ImageBox box = new ImageBox())
            {
                box.Text = title;
                box.pictureBox.Width = width;
                box.pictureBox.Height = height;
                box.pictureBox.SizeMode = sizeMode;
                box.pictureBox.Image = image.ToManagedImage();
                box.BackColor = backColor;
                result = box.ShowDialog();
            }

            return result;
        }
Exemplo n.º 27
0
 /// <summary>
 /// A window that lets the user wiew an image.
 /// </summary>
 /// <param name="i">The image</param>
 public ImageViewer(Image i)
 {
     InitializeComponent();
     Image = i;
     Mode  = PictureBoxSizeMode.Zoom;
 }
Exemplo n.º 28
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 /// 
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// 
 public static DialogResult Show(double[,] image, PictureBoxSizeMode sizeMode)
 {
     Bitmap bitmap;
     new MatrixToImage().Convert(image, out bitmap);
     return Show("Image", bitmap, sizeMode);
 }
        private Rectangle ImageRectangleFromSizeMode(PictureBoxSizeMode mode)
        {
            Rectangle rectangle = LayoutUtils.DeflateRect(base.ClientRectangle, base.Padding);
            if (this.image != null)
            {
                switch (mode)
                {
                    case PictureBoxSizeMode.Normal:
                    case PictureBoxSizeMode.AutoSize:
                        rectangle.Size = this.image.Size;
                        return rectangle;

                    case PictureBoxSizeMode.StretchImage:
                        return rectangle;

                    case PictureBoxSizeMode.CenterImage:
                        rectangle.X += (rectangle.Width - this.image.Width) / 2;
                        rectangle.Y += (rectangle.Height - this.image.Height) / 2;
                        rectangle.Size = this.image.Size;
                        return rectangle;

                    case PictureBoxSizeMode.Zoom:
                    {
                        Size size = this.image.Size;
                        float num = Math.Min((float) (((float) base.ClientRectangle.Width) / ((float) size.Width)), (float) (((float) base.ClientRectangle.Height) / ((float) size.Height)));
                        rectangle.Width = (int) (size.Width * num);
                        rectangle.Height = (int) (size.Height * num);
                        rectangle.X = (base.ClientRectangle.Width - rectangle.Width) / 2;
                        rectangle.Y = (base.ClientRectangle.Height - rectangle.Height) / 2;
                        return rectangle;
                    }
                }
            }
            return rectangle;
        }
Exemplo n.º 30
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 /// 
 /// <param name="title">The text to display in the title bar of the image box.</param>
 /// <param name="image">The image to show.</param>
 /// <param name="width">The width of the image box.</param>
 /// <param name="height">The height of the image box.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// 
 public static DialogResult Show(String title, double[,] image,
     PictureBoxSizeMode sizeMode, int width, int height)
 {
     Bitmap bitmap;
     new MatrixToImage().Convert(image, out bitmap);
     return Show(title, bitmap, sizeMode, width, height);
 }
Exemplo n.º 31
0
        private void ChangeOutputSizeMode(PictureBoxSizeMode sizeMode)
        {
            ibxPanorama.SizeMode = sizeMode;

            foreach (ToolStripMenuItem Item in mnuOutput.Items)
            {
                Item.Checked = false;
            }
        }
Exemplo n.º 32
0
 void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     string val = comboBox1.SelectedItem as string; // 获取选中的内容
     PictureBoxSizeMode sizeMode = (PictureBoxSizeMode)Enum.Parse(typeof(PictureBoxSizeMode),val);
     pictureBox1.SizeMode = sizeMode;
 }
Exemplo n.º 33
0
 protected override void Initialize()
 {
     SizeMode = PictureBoxSizeMode.Normal;
     base.Initialize();
 }
Exemplo n.º 34
0
        public PictureWrapper(string i_PictureURL, int i_Width = 100, int i_Height = 100, PictureBoxSizeMode i_PictureBoxSizeMode = PictureBoxSizeMode.StretchImage)
        {
            PictureBox = new PictureBox {
                Width = i_Width, Height = i_Height
            };

            if (!string.IsNullOrEmpty(i_PictureURL))
            {
                try
                {
                    PictureBox.Load(i_PictureURL);
                }
                catch (Exception ex)
                {
                    throw new FacebookApiLimitException(string.Format("Couldnt load picture- {0}", ex.Message));
                }

                PictureBox.SizeMode = i_PictureBoxSizeMode;
            }
            else
            {
                createEmptyPhoto();
            }
        }
Exemplo n.º 35
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 /// 
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// 
 public static DialogResult Show(UnmanagedImage image, PictureBoxSizeMode sizeMode)
 {
     if (image == null) throw new ArgumentNullException("image");
     return Show("Image", image, sizeMode, image.Width, image.Height);
 }
Exemplo n.º 36
0
 /// <inheritdoc/>
 public override void RestoreState()
 {
     base.RestoreState();
     // avoid UpdateAutoSize call, use sizeModeInternal
     sizeModeInternal = saveSizeMode;
 }
Exemplo n.º 37
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 /// 
 /// <param name="image">The image to show.</param>
 /// <param name="width">The width of the image box.</param>
 /// <param name="height">The height of the image box.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// 
 public static DialogResult Show(double[,] image,
     PictureBoxSizeMode sizeMode, int width, int height)
 {
     return Show("Image", image, sizeMode, width, height);
 }
Exemplo n.º 38
0
 /// <inheritdoc/>
 public override void SaveState()
 {
     base.SaveState();
     saveSizeMode = SizeMode;
 }
Exemplo n.º 39
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 /// 
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// <param name="width">The width of the image box.</param>
 /// <param name="height">The height of the image box.</param>
 /// 
 public static DialogResult Show(Image image, PictureBoxSizeMode sizeMode, int width, int height)
 {
     return Show("Image", image, sizeMode, width, height, Color.Black);
 }
Exemplo n.º 40
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 ///
 /// <param name="image">The image to show.</param>
 /// <param name="width">The width of the image box.</param>
 /// <param name="height">The height of the image box.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 ///
 public static DialogResult Show(double[,] image,
                                 PictureBoxSizeMode sizeMode, int width, int height)
 {
     return(Show("Image", image, sizeMode, width, height));
 }
Exemplo n.º 41
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 /// 
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// <param name="backColor">The background color to use in the window. 
 ///   Default is <see cref="Color.Black"/>.</param>
 ///   
 public static DialogResult Show(Image image, PictureBoxSizeMode sizeMode, Color backColor)
 {
     return Show("Image", image, sizeMode, 0, 0, backColor);
 }
Exemplo n.º 42
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 ///
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 ///
 public static DialogResult Show(UnmanagedImage image, PictureBoxSizeMode sizeMode)
 {
     return(Show("Image", image, sizeMode, 0, 0));
 }
Exemplo n.º 43
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 /// 
 /// <param name="title">The text to display in the title bar of the image box.</param>
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// <param name="width">The width of the image box.</param>
 /// <param name="height">The height of the image box.</param>
 /// 
 public static DialogResult Show(string title, UnmanagedImage image,
     PictureBoxSizeMode sizeMode, int width, int height)
 {
     return Show(title, image, sizeMode, width, height, Color.Black);
 }
Exemplo n.º 44
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 ///
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// <param name="backColor">The background color to use in the window.
 ///   Default is <see cref="Color.Black"/>.</param>
 ///
 public static DialogResult Show(Image image, PictureBoxSizeMode sizeMode, Color backColor)
 {
     return(Show("Image", image, sizeMode, 0, 0, backColor));
 }
Exemplo n.º 45
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 /// 
 /// <param name="title">The text to display in the title bar of the image box.</param>
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// <param name="width">The width of the image box.</param>
 /// <param name="height">The height of the image box.</param>
 /// <param name="backColor">The background color to use in the window. 
 ///   Default is <see cref="Color.Black"/>.</param>
 /// 
 public static DialogResult Show(string title, UnmanagedImage image,
     PictureBoxSizeMode sizeMode, int width, int height, Color backColor)
 {
     return Show(title, image.ToManagedImage(), sizeMode, width, height, backColor);
 }
Exemplo n.º 46
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 ///
 /// <param name="title">The text to display in the title bar of the image box.</param>
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 ///
 public static DialogResult Show(string title, UnmanagedImage image, PictureBoxSizeMode sizeMode)
 {
     return(Show(title, image, sizeMode, 0, 0));
 }
Exemplo n.º 47
0
        /// <summary>
        /// 初期化
        /// </summary>
        /// <param name="sizeMode"></param>
#else
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sizeMode"></param>
#endif
        public CvWindowEx(PictureBoxSizeMode sizeMode)
            : this()
        {
            _pictureBox.SizeMode = sizeMode;
        }
Exemplo n.º 48
0
 /// <summary>
 ///   Displays an image on the screen.
 /// </summary>
 ///
 /// <param name="title">The text to display in the title bar of the image box.</param>
 /// <param name="image">The image to show.</param>
 /// <param name="sizeMode">How to display the image inside the image box.</param>
 /// <param name="width">The width of the image box.</param>
 /// <param name="height">The height of the image box.</param>
 ///
 public static DialogResult Show(string title, Image image, PictureBoxSizeMode sizeMode, int width, int height)
 {
     return(Show(title, image, sizeMode, width, height, Color.Black));
 }
Exemplo n.º 49
0
        // Set size mode for picture box
        private void SetPictureBoxSizeMode( PictureBoxSizeMode sizeMode )
        {
            if ( sizeMode == PictureBoxSizeMode.AutoSize )
            {
                pictureBox.Dock = DockStyle.None;
                pictureBox.Location = new System.Drawing.Point( 0, 0 );
                splitContainer2.Panel1.AutoScroll = true;
            }
            else
            {
                pictureBox.Dock = DockStyle.Fill;
                splitContainer2.Panel1.AutoScroll = false;
            }

            pictureBox.SizeMode = sizeMode;
        }
Exemplo n.º 50
0
 private void normalToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Mode = PictureBoxSizeMode.CenterImage;
 }
Exemplo n.º 51
0
        /// <summary>
        /// Scale picture box to fit to current control size and image size
        /// </summary>
		private void ScalePictureBoxToFit()
		{
            if (this.Picture == null)
            {
                this.pictureBox.Width = this.ClientSize.Width;
                this.pictureBox.Height = this.ClientSize.Height;
                this.pictureBox.Left = 0;
                this.pictureBox.Top = 0;
                this.AutoScroll = false;
                this.CurrentScalePercent = GetMinScalePercent();
                this.pictureBoxSizeMode = PictureBoxSizeMode.Zoom;
            }
            else if (this.pictureBoxSizeMode == PictureBoxSizeMode.Zoom ||
                    (this.Picture.Width <= this.ClientSize.Width && this.Picture.Height <= this.ClientSize.Height))
            {
                this.pictureBox.Width = Math.Min(this.ClientSize.Width, this.Picture.Width);
                this.pictureBox.Height = Math.Min(this.ClientSize.Height, this.Picture.Height);
                this.pictureBox.Top = (this.ClientSize.Height - this.pictureBox.Height) / 2;
                this.pictureBox.Left = (this.ClientSize.Width - this.pictureBox.Width) / 2;
                this.AutoScroll = false;
                this.CurrentScalePercent = GetMinScalePercent();
                this.pictureBoxSizeMode = PictureBoxSizeMode.Zoom;
            }
            else
            {
                this.pictureBox.Width = Math.Max(this.Picture.Width * this.CurrentScalePercent / 100, this.ClientSize.Width);
                this.pictureBox.Height = Math.Max(this.Picture.Height * this.CurrentScalePercent / 100, this.ClientSize.Height);

                // Centering picture box control
                int top = (this.ClientSize.Height - this.pictureBox.Height) / 2;
                int left = (this.ClientSize.Width - this.pictureBox.Width) / 2;

                if (top < 0)
                {
                    top = this.AutoScrollPosition.Y;
                }
                if (left < 0)
                {
                    left = this.AutoScrollPosition.X;
                }
                this.pictureBox.Left = left;
                this.pictureBox.Top = top;
                this.AutoScroll = true;
            }

            // set cursor for picture box
            SetCursor4PictureBox();
            this.pictureBox.Invalidate();

            // Raise zoom rate changed event
            if (ZoomRateChangedEvent != null)
            {
                bool isFullPictureShown = this.pictureBox.Width <= this.ClientSize.Width &&
                                          this.pictureBox.Height <= this.ClientSize.Height;
                ZoomRateChangedEvent(this.CurrentScalePercent, isFullPictureShown);
            }
        }
Exemplo n.º 52
0
        public static void DrawImage(Control control, Graphics graphics, Image image, Rectangle bounds, PictureBoxSizeMode sizeMode)
        {
            switch (sizeMode)
            {
            case PictureBoxSizeMode.Normal:
                graphics.DrawImageUnscaled(image, bounds);
                break;

            case PictureBoxSizeMode.StretchImage:
                graphics.DrawImage(image, bounds);
                break;

            case PictureBoxSizeMode.AutoSize:
                control.Size = image.Size;
                graphics.DrawImageUnscaled(image, bounds);
                break;

            case PictureBoxSizeMode.CenterImage:
                var centeredRectangle = new Rectangle(Half(control.Width) - Half(image.Width),
                                                      Half(control.Height) - Half(image.Height),
                                                      image.Width, image.Height);
                graphics.DrawImageUnscaled(image, centeredRectangle);
                break;

            case PictureBoxSizeMode.Zoom:
                DrawImageZoomMode(graphics, image, bounds);
                break;
            }
        }