Beispiel #1
0
        // Change module icon
        private void ModuleIconImage_MouseDown(object sender, RoutedEventArgs e)
        {
            var dlg = new Microsoft.Win32.OpenFileDialog
            {
                Filter = "Image Files(*.BMP;*.JPG;*.GIF,*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.* "
            };

            if (dlg.ShowDialog() == true)
            {
                const int newX = 100;

                System.Drawing.Bitmap resizedImage;
                using (System.Drawing.Image originalImage = System.Drawing.Image.FromFile(dlg.FileName))
                {
                    double x     = originalImage.Width;
                    double y     = originalImage.Height;
                    double newYd = newX * (y / x);
                    int    newY  = Convert.ToInt32(newYd);
                    resizedImage = new System.Drawing.Bitmap(originalImage, newX, newY);
                }

                TileButton.IconTile = AdministrationClass.BitmapToBitmapImage(resizedImage);
            }
        }