コード例 #1
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter           = "Image files (.jpg, .jpeg, .bmp, .gif, .png)|*.jpg;*.jpeg;*.bmp;*.gif;*.png";
            dlg.Multiselect      = false;
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                lblFileName.Text = Path.GetFileName(dlg.FileName);
                IOSupport.CopyFile(dlg.FileName, Globals.SettingsResourceDir + lblFileName.Text);

                UpdateAndNotify();
            }
        }
コード例 #2
0
        private void lnkChooseNewLogo_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter           = "Image files (.jpg, .jpeg, .bmp, .gif, .png)|*.jpg;*.jpeg;*.bmp;*.gif;*.png";
            dlg.Multiselect      = false;
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                LogoSettings.Instance.FileName = Path.GetFileName(dlg.FileName);
                IOSupport.CopyFile(dlg.FileName, Globals.SettingsResourceDir + LogoSettings.Instance.FileName);

                SaveAndUpdate();
            }
        }
コード例 #3
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Multiselect      = false;
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            dlg.Filter           = "Icons (*.ico)|*.ico|PNG Portable Network Graphics Format (*.png)|*.png|GIF Graphics Interchange Format (*.gif)|*.gif|JPEG file interchange format (*.jpg)|*.jpg|Device Independent Bitmap (*.bmp)|*.bmp";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string destFile = Globals.SettingsResourceDir + Path.GetFileName(dlg.FileName);
                if (String.IsNullOrEmpty(txtIconFile.Text))
                {
                    // Copy new file to resource folder
                    txtIconFile.Text = Path.GetFileName(dlg.FileName);
                    bool assigned = false;
                    if (File.Exists(destFile))
                    {
                        // get the name of shop to which this icon is assigned
                        foreach (Shop shop in ShopManager.Shops)
                        {
                            if (shop.IconName == txtIconFile.Text)
                            {
                                MessageBox.Show(String.Format("Icon with name {0} already assigned to shop {1}.", txtIconFile.Text, shop.Name), "Icon...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                assigned = true;
                                break;
                            }
                        }
                    }

                    if (assigned == false)
                    {
                        IOSupport.CopyFile(dlg.FileName, destFile, true);
                    }
                }
                else
                {
                    //1. Delete old file
                    string oldFile = Globals.SettingsResourceDir + txtIconFile.Text;
                    IOSupport.DeleteFile(oldFile);
                    //2. copy new file
                    IOSupport.CopyFile(dlg.FileName, destFile);
                }
            }
        }
コード例 #4
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            HotSpotImageForm imageForm = new HotSpotImageForm();
            string           resFile   = string.Empty;

            if (imageForm.ShowDialog() == DialogResult.OK)
            {
                if (imageForm.ResourceImageSelected && imageForm.SelectedImage != null)
                {
                    resFile = Globals.SettingsResourceDir + imageForm.SelectedResourceImageFileName + ".png";
                    imageForm.SelectedImage.Save(resFile);
                }
                else if (imageForm.ResourceImageSelected == false && String.IsNullOrEmpty(imageForm.SelectedFile) == false)
                {
                    resFile = Globals.SettingsResourceDir + Path.GetFileName(imageForm.SelectedFile);
                    IOSupport.CopyFile(imageForm.SelectedFile, resFile);
                }

                pbImagePreview.Image = ImageLoader.GetImageFromFile(resFile, pbImagePreview.Width, pbImagePreview.Height);

                hotSpot.ImageName = Path.GetFileName(resFile);
                HotspotManager.Save();
            }
        }