// Выбор приложения private void SelectApplication_Click(object sender, EventArgs e) { if (OFDialog.ShowDialog() == DialogResult.OK) { FileApplication.Text = OFDialog.FileName; } }
// Загрузка из файла реестра private void LoadRegFile_Click(object sender, EventArgs e) { // Контроль if (OFDialog.ShowDialog() != DialogResult.OK) { return; } // Загрузка uint res = rebm[BasesCombo.SelectedIndex].LoadRegistryFile(OFDialog.FileName); MessageBox.Show(Localization.GetText("EntriesAdded", al) + res.ToString(), ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); // Обновление таблицы int row = 0; if (MainTable.SelectedRows.Count > 0) { row = MainTable.SelectedRows[0].Index; } UpdateTable(); if (MainTable.SelectedRows.Count > 0) { MainTable.CurrentCell = MainTable.Rows[row].Cells[0]; } }
private void BtnLoad_Click(object sender, EventArgs e) { string strFilePath = string.Empty; OFDialog.InitialDirectory = Application.StartupPath; //프로그램 실행파일 위치 OFDialog.FileName = "*.txt"; OFDialog.Filter = "txt files (*.txt)|*.txt|All file (*.*)|*.*"; StringBuilder sb = new StringBuilder(); if (OFDialog.ShowDialog() == DialogResult.OK) { strFilePath = OFDialog.FileName; //StreamReader srOFDialog = new StreamReader(strFilePath, Encoding.UTF8, true); //while(srOFDialog.EndOfStream==false) //{ // sb.Append(srOFDialog.ReadLine()); // sb.Append("\r\n"); //} sb.Append(File.ReadAllText(strFilePath)); tboxConfigData.Text = sb.ToString(); } }
private void btnLoad_Click(object sender, EventArgs e) { string strFilePath = ""; StringBuilder sb = new StringBuilder(); OFDialog.InitialDirectory = Application.StartupPath; //프로그램 실행 파일 위치. OFDialog.FileName = "*.txt"; // file save dialog에서 파일명 OFDialog.Filter = "text files (*.txt)|*.txt|All Files(*.*)|*.*"; //파일 형식 if (OFDialog.ShowDialog() == DialogResult.OK) { strFilePath = OFDialog.FileName; using (StreamReader sr = new StreamReader(strFilePath, Encoding.UTF8, true)) { //파일 끝인지 확인..... while (sr.EndOfStream == false) { sb.Append(sr.ReadLine() + Environment.NewLine); } } tboxConfigData.Text = sb.ToString(); // sb.Append( File.ReadAllText(strFilePath) ); _data.Clear(); _data = _xml.Xml_Reader(strFilePath); } }
private void BAddFile_Click(object sender, EventArgs e) { if (OFDialog.ShowDialog() == DialogResult.OK) { var lastPt = OFDialog.FileName.Split('\\').Last(); File.Copy(OFDialog.FileName, Path.Combine(_user.UserDirectory.Path, lastPt), true); } ButtonsBind(); }
private void btnMP3_Click(object sender, EventArgs e) { //string strFilePath = string.Empty; //OFDialog.InitialDirectory = Application.StartupPath; //OFDialog.FileName = "*.mp3"; //OFDialog.Filter = "mp3 files(*.mp3)|*.mp3|All files(*.*)|*.*"; //if (OFDialog.ShowDialog() == DialogResult.OK) //{ // if (_mediaPlayer == null) // { // _mediaPlayer = new MediaPlayer.MediaPlayerClass(); // } // _mediaPlayer.FileName = OFDialog.FileName; // _mediaPlayer.Stop(); // changeStaus(EnumStatus.stop); // lblFileName.Text = OFDialog.FileName; // //처음 // tbarVolume.Value = TrackbarToVolumn(-1200, 0 , _mediaPlayer.Volume); // lblVolume.Text = tbarVolume.Value.ToString(); // //Timer // _tm.Interval = 500; // _tm.Tick += _tm_Tick; //} string strFilePath = string.Empty; OFDialog.InitialDirectory = Application.StartupPath; OFDialog.FileName = "*.mp3"; OFDialog.Filter = "mp3 files(*.mp3)|*.mp3|All files(*.*)|*.*"; if (OFDialog.ShowDialog() == DialogResult.OK) { if (_mediaPlayer == null) { _mediaPlayer = new MediaPlayer.MediaPlayerClass(); } _mediaPlayer.FileName = OFDialog.FileName; _mediaPlayer.Stop(); changeStaus(EnumStatus.stop); lblFileName.Text = OFDialog.FileName; //처음 tbarVolume.Value = TrackbarToVolumn(-1200, 0, _mediaPlayer.Volume); lblVolume.Text = tbarVolume.Value.ToString(); //Timer _tm.Interval = 500; _tm.Tick += _tm_Tick; } }
private void btnWAV_Click_1(object sender, EventArgs ex) { string strFilePath = string.Empty; OFDialog.InitialDirectory = Application.StartupPath; OFDialog.FileName = "*.wav"; OFDialog.Filter = "wav files(*.wav)|*.wav|All files(*.*)|*.*"; if (OFDialog.ShowDialog() == DialogResult.OK) { PlayWaverFile(OFDialog.FileName, true); } }
private void btnDBLoad_Click(object sender, EventArgs e) { string strFilePath = string.Empty; OFDialog.InitialDirectory = Application.StartupPath; OFDialog.FileName = "*.mdb"; OFDialog.Filter = "db files(*.mdb)|*.mdb|All files(*.*)|*.*"; if (OFDialog.ShowDialog() == DialogResult.OK) { tboxPath.Text = OFDialog.FileName; DBConnect(tboxPath.Text); } }
private void BtnBrowse_Click(object sender, EventArgs e) { try { OFDialog.Filter = "Image Files((*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png"; if (OFDialog.ShowDialog() == DialogResult.OK) { PbClient.Image = Image.FromFile(OFDialog.FileName); } } catch (Exception ex) { MessageBox.Show("Image Not Upload" + ex.ToString(), "Error de Carga", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (OFDialog.ShowDialog() == DialogResult.OK) { EditingMSF = new MSF(OFDialog.FileName); StreamListBox.Items.Clear(); StreamListBox.Items.Add(EditingMSF.EntireFile); foreach (var stream in EditingMSF.EntireFile.Streams) { StreamListBox.Items.Add(stream); } StreamListBox.SelectedIndex = 0; } }
/// <summary> /// Loads tower icon for shop /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void BLoadTowerIcon_Click(object sender, EventArgs e) { OFDialog.Filter = "Bitmap|*.bmp|Png picture|*.png"; if (OFDialog.ShowDialog() == DialogResult.OK) { try { TowerConfig.Icon = new Bitmap(OFDialog.FileName); PBTowerIcon.Image = TowerConfig.Icon; } catch (Exception exp) { MessageBox.Show("Picture loading error: " + exp.Message); } } }
private void BrowseButton_Click(object sender, EventArgs e) { { try { if (OFDialog.ShowDialog() != System.Windows.Forms.DialogResult.Cancel) { PicBox.Image = Image.FromFile(OFDialog.FileName); PicBox.SizeMode = PictureBoxSizeMode.StretchImage; val = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// Loads tower picture for rendering on the map /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void BLoadTowerBitmap_Click(object sender, EventArgs e) { OFDialog.Filter = "Bitmap|*.bmp|Png picture|*.png"; if (OFDialog.ShowDialog() == DialogResult.OK) { try { sMainTowerParam Tmp = TowerConfig.UpgradeParams[0]; Tmp.Picture = new Bitmap(OFDialog.FileName); TowerConfig.UpgradeParams[0] = Tmp; PBTowerBitmap.Size = TowerConfig.UpgradeParams[0].Picture.Size; PBTowerBitmap.Image = TowerConfig.UpgradeParams[0].Picture; } catch (Exception exp) { MessageBox.Show("Picture loading error: " + exp.Message); } } }
/// <summary> /// Tower configuration loading /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void BLoad_Click(object sender, EventArgs e) { OFDialog.FileName = "*.tdtc"; OFDialog.Filter = "Tower configuration|*.tdtc"; if (OFDialog.ShowDialog() == DialogResult.OK) { using (FileStream TowerConfLoadStream = new FileStream(OFDialog.FileName, FileMode.Open, FileAccess.Read)) { try { IFormatter Formatter = new BinaryFormatter(); TowerConfig = (TowerParam)Formatter.Deserialize(TowerConfLoadStream); SetParams(); } catch (Exception Exc) { MessageBox.Show("Tower configuration loading error: \n" + Exc.Message); } } } }
// Выбор файла private void SelectFile_Click(object sender, System.EventArgs e) { OFDialog.ShowDialog(); }
private void IconsExtractor_Load(object sender, EventArgs e) { // Запрос исполняемого файла if (OFDialog.ShowDialog() != DialogResult.OK) { this.Close(); return; } // Проверка на наличие иконок IntPtr bigIcon = IntPtr.Zero, smallIcon = IntPtr.Zero; iconsCount = ExtractIconExA(OFDialog.FileName, -1, ref bigIcon, ref smallIcon, 1); if (iconsCount == 0) { MessageBox.Show(string.Format(Localization.GetText("IconsNotFound", al), OFDialog.FileName), ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); return; } // Извлечение иконок List <Bitmap> icons = new List <Bitmap> (); for (UInt32 i = 0; i < iconsCount; i++) { ExtractIconExA(OFDialog.FileName, (Int32)i, ref bigIcon, ref smallIcon, 1); icons.Add(Icon.FromHandle(bigIcon).ToBitmap()); // Если делать проще, теряется альфа-канал } // Сборка изображения iconsView = new Bitmap((int)(iconPositionWidth * iconsHorizontalCount), (int)((decimal)iconPositionHeight * Math.Ceiling((decimal)iconsCount / (decimal)iconsHorizontalCount)), PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(iconsView); Brush b = new SolidBrush(Color.FromArgb(0, 0, 0)); Font f = new Font("Arial", 10); SizeF sz; for (int i = 0; i < icons.Count; i++) { g.DrawImage(icons[i], iconPositionWidth * (i % iconsHorizontalCount), iconPositionHeight * (i / iconsHorizontalCount)); sz = g.MeasureString(i.ToString(), f); g.DrawString(i.ToString(), f, b, iconPositionWidth * (i % iconsHorizontalCount) + (iconPositionWidth - sz.Width) / 2, iconPositionHeight * (i / iconsHorizontalCount) + iconHeight); icons[i].Dispose(); } // Завершение b.Dispose(); g.Dispose(); f.Dispose(); icons.Clear(); // Отображение MainPicture.BackgroundImage = (Bitmap)iconsView.Clone(); PageNumber.Maximum = Math.Ceiling((decimal)iconsCount / ((decimal)iconsVerticalCount * (decimal)iconsHorizontalCount)); TotalLabel.Text = Localization.GetText("IE_TotalLabelText", al) + iconsCount.ToString(); allowExit = false; this.Activate(); }
/* * Файл -> Открыть */ private void TSMI_Menu_File_Open_Click(object sender, EventArgs e) { // если файл не сохранен if (!IsFileSaved) { var askSaveFileDialogResult = MessageBox.Show( $"Сохранить изменения в файле \"{FileName}\"?", APP_NAME, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (askSaveFileDialogResult) { case DialogResult.Yes: { var safeDialogResult = SFDialog.ShowDialog(); if (safeDialogResult == DialogResult.OK) { WriteToFile(SFDialog.FileName); } IsFileSaved = true; var openDialogResult = OFDialog.ShowDialog(); if (openDialogResult == DialogResult.OK) { ReadFile(OFDialog.FileName); } break; } case DialogResult.No: { var openDialogResult = OFDialog.ShowDialog(); if (openDialogResult == DialogResult.OK) { ReadFile(OFDialog.FileName); } break; } case DialogResult.Cancel: { return; } } } else { var openDialogResult = OFDialog.ShowDialog(); if (openDialogResult == DialogResult.OK) { foreach (var form in MdiChildren) { form.Close(); } ReadFile(OFDialog.FileName); } } }
// Добавление файлов в обработку private void AddFiles_Click(object sender, EventArgs e) { OFDialog.ShowDialog(); }