Exemplo n.º 1
0
        /// <summary>
        /// Set the background of the form to a selected image file.
        /// </summary>
        public void BackgroundImageSelect()
        {
            // Set to current image path if one is in use
            if (Games.CurrentSettings.BackgroundImageLoc != null)
            {
                string path = GetDirectoryString(TextBox1.Text);
                if (Directory.Exists(path))
                {
                    OpenImageFileDialog.InitialDirectory = path; // set initial path to currently used one where a file was selected in the past
                    if (File.Exists(TextBox1.Text))
                    {
                        OpenImageFileDialog.FileName = GetFileDisplayString(TextBox1.Text);
                    }
                    else
                    {
                        OpenImageFileDialog.FileName = "";
                    }
                }
            }

            if (OpenImageFileDialog.ShowDialog() == DialogResult.OK)
            {
                Games.CurrentSettings.BackgroundImageLoc = OpenImageFileDialog.FileName;
                SaveMySettings();
                BackgroundPicture = Image.FromFile(OpenImageFileDialog.FileName);
                RefreshBackgroundImage();
            }
        }
Exemplo n.º 2
0
 private void FileButton_Click(object sender, EventArgs e)
 {
     if (OpenImageFileDialog.ShowDialog(this) != DialogResult.OK)
     {
         return;
     }
     OpenImageFile(OpenImageFileDialog.FileName);
 }
Exemplo n.º 3
0
        private void OpenFileButton_Click(object sender, EventArgs e)
        {
            OpenImageFileDialog.Filter           = "JPEG Image|*.jpg;*.jpeg|PNG Image|*.png";
            OpenImageFileDialog.InitialDirectory = "c:\\";
            OpenImageFileDialog.Title            = "Select Image";

            if (OpenImageFileDialog.ShowDialog() == DialogResult.OK)
            {
                ItemPicFileNameTextBox.Text = OpenImageFileDialog.SafeFileName;
                ItemPicFilePathTextBox.Text = OpenImageFileDialog.FileName;
            }
        }
Exemplo n.º 4
0
        private void OpenIcon()
        {
            OpenImageFileDialog.Filter = "PNG Files(*.png;)|*.png;";
            if (OpenImageFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    var filePath = OpenImageFileDialog.FileName;

                    if (!Directory.Exists(FileUtils.IconsFolderPath))
                    {
                        Directory.CreateDirectory(FileUtils.IconsFolderPath);
                    }

                    File.Copy(filePath, FileUtils.GetIconPath(SelectedItem), true);
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Unable to open file " + exception.Message);
                }

                RenderEditItem();
            }
        }