Exemplo n.º 1
0
        private async void uiBrowseIconButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png, *gif) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png; *.gif";
            dialog.Title  = "Constabulary Icon";
            DialogResult dr = dialog.ShowDialog();

            if (dr != DialogResult.OK)
            {
                return;
            }

            string path = dialog.FileName;

            try
            {
                string base64 = await Task.Run(() => OsirtHelper.ResizeConstabLogo(path));

                uiConstabularyIconPictureBox.Image = base64.Base64ToImage();
                settings.ConstabIcon = base64;
                settings.Save();
            }
            catch
            {
                MessageBox.Show("Unable to save icon", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }