Example #1
0
 private void addImagesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     OpenFileDialog FileOpen = new OpenFileDialog();
     FileOpen.Title = "Open Image File";
     FileOpen.Multiselect = true;
     FileOpen.Filter = "All (*.*)|*.*|JPEG (*.jpg)|*.jpg|Bitmap (*.bmp)|*.bmp|TIFF (*.tiff)|*.tiff";
     DialogResult Result = FileOpen.ShowDialog();
     if (Result == DialogResult.OK)
     {
         foreach (String img in FileOpen.FileNames)
         {
             PictureBox p = new PictureBox();
             p.Image = Image.FromFile(img);
             if (images.Count > 0)
             {
                 if (p.Image.Height != images[0].Image.Height
                  || p.Image.Width != images[0].Image.Width)
                 {
                     MessageBox.Show(img + " posiada inne wymiary niz pierwszy wczytany obraz!");
                     FileOpen.Dispose();
                     UpdateImages();
                     return;
                 }
             }
             images.Add(p);
             p.Click += previevImageClick;
             p.SizeMode = PictureBoxSizeMode.Zoom;
         }
         UpdateImages();
     }
     else FileOpen.Dispose();
 }
Example #2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Create a dialog to ask the user for the full path of a file.
            OpenFileDialog dlg = new OpenFileDialog();

            // Initialize the dialog with some values before displaying it.
            dlg.Title = "Open File";
            dlg.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
            dlg.InitialDirectory =
                        Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            // Display the dialog.
            if (dlg.ShowDialog() == DialogResult.OK && dlg.FileName != string.Empty)
            {
                try
                {
                    // Open and display the file.
                    StreamReader reader = new StreamReader(dlg.FileName);
                    textBoxDocument.Text = reader.ReadToEnd();
                    reader.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            dlg.Dispose();
        }
Example #3
0
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            if (context == null || provider == null || context.Instance == null)
            {
                return(base.EditValue(provider, value));
            }

            string pathName = (value.ToString() != string.Empty) ? Path.Combine(Config.GetOption("WORKINGDIR"), value.ToString()) : Config.GetOption("WORKINGDIR");

            System.Windows.Forms.OpenFileDialog dialogFile = new System.Windows.Forms.OpenFileDialog();
            dialogFile.Title       = "Select a file";
            dialogFile.Filter      = "WAV files (*.wav)|*.wav|OGG files (*.ogg)|*.ogg|MP3 files (*.mp3)|*.mp3|All files (*.*)|*.*";
            dialogFile.FilterIndex = int.Parse(Config.GetOption("EXTFILTER", "4"));
            if (pathName != string.Empty)
            {
                dialogFile.InitialDirectory = Path.GetDirectoryName(pathName);
                dialogFile.FileName         = Path.GetFileName(pathName);
            }

            if (dialogFile.ShowDialog() == System.Windows.Forms.DialogResult.OK && dialogFile.FileName != System.String.Empty)
            {
                System.Uri uriRoot     = new System.Uri(Config.GetOption("WORKINGDIR"));
                System.Uri uriFile     = new System.Uri(dialogFile.FileName);
                System.Uri relativeUri = uriRoot.MakeRelativeUri(uriFile);
                value = relativeUri.ToString().Replace('\\', '/');

                Config.SetOption("EXTFILTER", dialogFile.FilterIndex.ToString());
            }

            dialogFile.Dispose();

            return(value);
        }
Example #4
0
        //THIS FUNCTION HANDLE USER INPUT. IGNORE THIS.
        static List <FileInfo> Get_filepath()
        {
            bool pathcheck = false;

            System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
            List <FileInfo> File = new List <FileInfo>();

            while (!pathcheck)
            {
                openFileDialog1.Multiselect      = true;
                openFileDialog1.InitialDirectory = @"C:\BatteryTest";
                openFileDialog1.DefaultExt       = "log";
                openFileDialog1.Title            = "Select ALL syslog-xxx files";
                openFileDialog1.CheckFileExists  = true;
                openFileDialog1.CheckPathExists  = true;
                openFileDialog1.Filter           = "ADC Log Files (syslog-xxxx)|";
                DialogResult result = openFileDialog1.ShowDialog();
                if (result == DialogResult.Cancel)
                {
                    break;
                }
                foreach (string filename in openFileDialog1.FileNames)
                {
                    if (filename.Length == 0)
                    {
                        break;
                    }
                    pathcheck = true;
                    File.Add(new FileInfo(filename));
                }
            }
            openFileDialog1.Dispose();
            return(File);
        }
Example #5
0
        public string AbrirGuardarImg(string LlaveImg, PictureBox Contenedor, string Ruta)
        {
            if (!(Contenedor.Image == null)) Contenedor.Image.Dispose();

            String Archivo = "";
            string NombreArchivo = "";

            var fdAttach = new OpenFileDialog();
            fdAttach.Filter = "Imagen|*.jpg;*.jpeg;*.gif;*.png;*.bmp;";
            //fdAttach.Filter = "Tipos de archivo|*.doc?;*.xls?;*.ppt?;*.pps?;*.pdf;*.txt;*.jpg;*.jpeg;*.gif;*.png;*.bmp;";
            fdAttach.Title = "Ruta del archivo a importar";
            if (fdAttach.ShowDialog() == DialogResult.OK)
                //if (fdAttach.ShowDialog(Principal.Instance) == DialogResult.OK)
                Archivo = fdAttach.FileName;
            fdAttach.Dispose();

            if (Archivo != "")
            {
                Bitmap Img;
                // string Ruta = RutaGlobal; //GlobalClass.ConfiguracionGlobal.pathImagenes;
                Ruta = Ruta + "\\(" + LlaveImg + ").jpg";
                var Cuadro = new System.Drawing.Size(130, 100);
                Img = (Bitmap)resizeImage(Image.FromFile(Archivo, true), Cuadro);
                saveJpeg(Ruta, Img, 150);
                NombreArchivo = fdAttach.FileName;
                NombreArchivo = NombreArchivo.Substring(NombreArchivo.LastIndexOf("\\") + 1).ToLower();
            }

            return NombreArchivo;
        }
Example #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            DbWorker dbWorker;
            OpenFileDialog ofdOpen = new OpenFileDialog();
           
                if (ofdOpen.ShowDialog() != DialogResult.OK)
                    return;
                dbWorker = new DbWorker("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ofdOpen.FileName);
                ofdOpen.Dispose();  
            
            try
            {
                dbWorker.OpenDB();
            }
            catch (TypeInitializationException error)
            {
                MessageBox.Show(error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            dbWorker.WriteLessonsDb(tableProcessor.ListLessons,1);
            dbWorker.CloseDB();
        
  
        }
 private void OnClickBrowse(object sender, EventArgs e)
 {
     OpenFileDialog dialog = new OpenFileDialog();
     dialog.Multiselect = false;
     string type = "txt";
     switch (comboBox1.SelectedIndex)
     {
         case 0: type = "txt";
             break;
         case 1: type = "uoa";
             break;
         case 2: type = "uoab";
             break;
         case 3: type = "wsc";
             break;
     }
     dialog.Title = String.Format("Choose {0} file to import", type);
     dialog.CheckFileExists = true;
     if (type == "uoab")
         dialog.Filter = "{0} file (*.uoa)|*.uoa";
     else
         dialog.Filter = String.Format("{0} file (*.{0})|*.{0}", type);
     if (dialog.ShowDialog() == DialogResult.OK)
         textBox1.Text = dialog.FileName;
     dialog.Dispose();
 }
        private void CloseInterfaces()
        {
            // Reset variables
            _mainDir            = null;
            _projectName        = null;
            _totalFrameNumber   = -1;
            _currentFrameNumber = 0;
            _istimeBarEnabled   = true;

            if (_openFileDialog != null)
            {
                _openFileDialog.Dispose();
                _openFileDialog = null;
            }

            if (_replayControl != null)
            {
                _replayControl.Dispose();
                _replayControl = null;
            }

            if (_dbReplayInfo != null)
            {
                _dbReplayInfo.DBDisconnect();
                _dbReplayInfo = null;
            }

            if (_replayInfo != null)
            {
                _replayInfo = null;
            }
        }
Example #9
0
        private void dateiÖffnenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            tWorkingInterval.Enabled = false;
            init();
            try
            {
                var FD = new System.Windows.Forms.OpenFileDialog();
                //FD.FileName = @""; //start in direction ...
                if (FD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    parser.setFilePath(FD.FileName);
                }
                enableButtons();
                FD.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            //set rom
            rom.setRom(parser.getRom());
            //view file in textbox
            showFile(parser.getTotalFile());
            selectLine();
        }
        private void btnLoadImage_Click(object sender, EventArgs e)
        {
            btnLoadImage.Enabled = false;
            
            OpenFileDialog dlg = new OpenFileDialog();
            _WhitePix = 0;
            _NonWhitePix = 0;

            dlg.Title = "Open Image";
            dlg.Filter = "JPG|*.jpg;*.jpeg|PNG|*.png|"
       + "All Graphics Types|*.jpg;*.jpeg;*.png;";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                _imagePath = dlg.FileName;
                imgSource.Image = Image.FromFile(dlg.FileName);
            }
            dlg.Dispose();

            DataTable dt = new DataTable();
            dt.Clear();
            dt.Columns.Add("Image_Source");
            dt.Rows.Add(new object []{_imagePath});
            GenerateSummary(dt, false);
            btnLoadImage.Enabled = true;
        }
Example #11
0
 /// <summary>
 /// Open a new file. Will ask for the file name in a dialog.
 /// </summary>
 public void OpenFile()
 {
     OpenFileDialog dlg = new OpenFileDialog ();
     if (dlg.ShowDialog () == DialogResult.OK)
         OpenFile (dlg.FileName);
     dlg.Dispose ();
 }
        private void buttonImport_Click(object sender, EventArgs e)
        {
            Equipment temp = new Equipment(equipment);
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "EquipmentFile (*.eqp)|*.eqp|All files (*.*)|*.*";
                ofd.FilterIndex = 1;

                if (ofd.ShowDialog() != DialogResult.OK)
                {
                    ofd.Dispose();
                    return;
                }

                byte[] fileData = File.ReadAllBytes(ofd.FileName);
                if (fileData.Length != Constants.SIZEOF_EQUIPMENT)
                {
                    MessageBox.Show("Invalid Equipment", "Error");
                    return;
                }

                this.equipment.EquipmentBytes = fileData;
                loadData();

                ofd.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Loading Error");
                this.equipment = temp;
            }
        }
Example #13
0
        private void OpenFileDialogImplement()
        {
            var lDialog = new System.Windows.Forms.OpenFileDialog();

            lDialog.Title            = "Open worksheet";
            lDialog.CheckFileExists  = true;
            lDialog.Filter           = ("Xls/Xlsx/Xlsm (Excel)|*.xls;*.xlsx;*.xlsm|Xls (Excel 2003)|_*.xls | Xlsx / Xlsm / Xlsb(Excel 2007) | *.xlsx; *.xlsm; *.xlsb | Xml(Xml) | _*.xml | Html(Html) | *.html | Csv(Csv) | *.csv | All files | *.* ");
            lDialog.InitialDirectory = @"D:\";
            lDialog.Multiselect      = false;

            if (lDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                System.Windows.Forms.Application.DoEvents();
                try
                {
                    FileInfo File          = new FileInfo(lDialog.FileName);
                    var      fs            = new FileStream(lDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    var      globalPackage = new ExcelPackage(File);
                    //  globalPackage.Load(fs);

                    var globalFileName            = globalPackage.File.FullName;
                    var globalLastActiveWorksheet = globalPackage.Workbook.Worksheets.FirstOrDefault(f => f.View.TabSelected);
                    CreateDocument(globalLastActiveWorksheet);
                }
                finally
                {
                    lDialog.Dispose();
                }
            }
        }
Example #14
0
 public void Dispose()
 {
     if (ofd != null)
     {
         ofd.Dispose();
     }
 }
Example #15
0
 void mnuOpen_OnClick(object sender, EventArgs e)
 {
     var dlg = new OpenFileDialog {InitialDirectory = "C:\\", Filter = @"CSV|*.csv"};
     dlg.ShowDialog(this);
     OpenFile(dlg.FileName);
     dlg.Dispose();
 }
Example #16
0
        /// <summary>
        /// Creates a Open File Dialog box with inputs for filtering the file type and whether the multiple files can be selected.
        /// </summary>
        /// <param name="fileTypeFilter">A string that filters the file types to be selected.  Format should be as follows: display value|file type.  For example "Text (*.txt)|*.txt"</param>
        /// <param name="multiSelect">True allows multiple files to be selected, false allows only a single file.</param>
        /// <param name="reset">Resets the node so the dialog will reopen.</param>
        /// <returns name="File Path">A string of the file path.</returns>
        public static string[] FileOpen(
            [DefaultArgument("\"All Files (*.*)|*.*\"")] string fileTypeFilter,
            [DefaultArgument("true")] bool multiSelect,
            [DefaultArgument("true")] bool reset
            )
        {
            string[] fileNames = null;

            // Create an instance of the open file dialog box.
            winForms.OpenFileDialog openFileDialog1 = new winForms.OpenFileDialog();

            // Set filter options and filter index.
            openFileDialog1.Filter      = fileTypeFilter;
            openFileDialog1.FilterIndex = 1;

            openFileDialog1.Multiselect = multiSelect;

            // Call the ShowDialog method to show the dialog box.
            winForms.DialogResult userClickedOK = openFileDialog1.ShowDialog();
            // Process input if the user clicked OK.
            if (userClickedOK == winForms.DialogResult.OK)
            {
                fileNames = openFileDialog1.FileNames;
            }

            openFileDialog1.Dispose();

            return(fileNames);
        }
 private void button1_Click(object sender, EventArgs e)
 {
     OpenFileDialog ofd = new OpenFileDialog();
     ofd.Filter = "Application|*.exe";
     ofd.FilterIndex = 0;
     if (ofd.ShowDialog() == DialogResult.OK)
         txtApp.Text = ofd.FileName;
     ofd.Dispose();
 }
 public ITI loadITI()
 {
     OpenFileDialog OFD = new OpenFileDialog();
     OFD.Filter = "ITI|*.iti";
     OFD.ShowDialog();
     string bon = OFD.FileName;
     OFD.Dispose();
     return new ITI(bon);
 }
Example #19
0
        public static bool Parse()
        {
            if (Program.CommandLineFile == null)
            {
                // Before we try to parse, let's make sure CurrentList is in the Keywords
                // Dict. Someone could have deleted it in the editor!
                if (Program.Keys.KeywordDict.ContainsKey(Program.Keys.CurrentList) == false)
                {
                    MessageBox.Show("You must have deleted the Keyword List you was using in the editor! Please Refresh and try again.");
                    return false;
                }

                OpenFileDialog dialog = new OpenFileDialog();
                dialog.AddExtension = true;
                dialog.Filter = "Log files (*.log)|*.log|All files (*.*)|*.*";
                dialog.InitialDirectory = Program.opt.DefaultLogPath.ToString();
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    MessageBox.Show("Error Reading Log File or no Log File Selected!");
                    return false;
                }
                Program.CommandLineFile = dialog.FileName.ToString();
                dialog.Dispose();
            }

            StreamReader LogFile = File.OpenText(Program.CommandLineFile);
            LogParsed = Program.CommandLineFile;

            // LogLine is the text line read in
            // We use a StringBuilder here to build the output for the text window.
            string LogLine = "";

            // Let's reset these so they are clean! :)
            Results.Clear();

            while ((LogLine = LogFile.ReadLine()) != null)
            {
                foreach (string TheKeyword in Program.Keys.KeywordDict[Program.Keys.CurrentList])
                {
                    string NewLogLine = LogLine;
                    string NewKeyword = TheKeyword;
                    if (Program.opt.CaseParse)
                    {
                        NewLogLine = LogLine.ToLower();
                        NewKeyword = TheKeyword.ToLower();
                    }

                    if (NewLogLine.IndexOf(NewKeyword) != -1)
                    {
                        // We found a match!
                        AddMatch(TheKeyword, LogLine.ToString());
                    }
                }
            }
            LogFile.Close();
            return true;
        }
 private void buttonBrowseBgImage_Click(object sender, EventArgs e)
 {
     OpenFileDialog fd = new OpenFileDialog();
     if (fd.ShowDialog() == DialogResult.OK)
     {
         textBoxBgImage.Text = fd.FileName;
     }
     fd.Dispose();
 }
Example #21
0
 private void btnBuscarCsv_Click(object sender, EventArgs e)
 {
     var frmCsv = new OpenFileDialog();
     frmCsv.Filter = "(*.csv)|*.csv";
     frmCsv.Title = "Ruta del archivo Csv a importar";
     if (frmCsv.ShowDialog(Principal.Instance) == DialogResult.OK)
         this.txtRutaCsv.Text = frmCsv.FileName;
     frmCsv.Dispose();
 }
Example #22
0
 private void button2_Click(object sender, EventArgs e)
 {
     OpenFileDialog openfile = new OpenFileDialog();
     if (openfile.ShowDialog() == DialogResult.OK && (openfile.FileName != ""))
     {
         pictureBox1.ImageLocation = openfile.FileName;
         openfile.Dispose();
     }
 }
Example #23
0
 private void Button_OpenJava_Click(object sender, RoutedEventArgs e)
 {
     WinForm.OpenFileDialog dialog = new WinForm.OpenFileDialog();
     dialog.Filter = "javaw.exe|javaw.exe";
     dialog.Title  = "选择Java";
     dialog.ShowDialog();
     TextBox_JavaPath.Text = dialog.FileName;
     dialog.Dispose();
 }
Example #24
0
        /// <summary>
        /// Creates an Open File Dialog box with applicable parameters.
        /// </summary>
        /// <param name="fileExtension">The file extension to filter for.</param>
        /// <param name="typeName">The full name description of the file type.</param>
        /// <param name="initialDirectory">The initial directory to open to.</param>
        /// <returns>The String path to the file selected, or null on Cancel.</returns>
        public static string OpenFileDialogBox(String fileExtension, String typeName, String initialDirectory)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                DefaultExt = fileExtension,
                Filter = String.Format("{1} File(s) (*.{0})|*.{0}", fileExtension, typeName),
                InitialDirectory = initialDirectory
            };

            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                openFileDialog.Dispose();
                return null;
            }
            String filePath = openFileDialog.FileName;
            openFileDialog.Dispose();

            return filePath;
        }
Example #25
0
 private void btnBrowseChatSound_Click(object sender, EventArgs e)
 {
     OpenFileDialog ofd = new OpenFileDialog();
     ofd.Filter = "wav files (*.wav)|*.wav";
     if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         txtChatSoundLocation.Text = ofd.FileName;
     }
     ofd.Dispose();
 }
        private void browse_Click(object sender, EventArgs e)
        {
            openFile = new OpenFileDialog();
            openFile.Filter = "Text Files(*.txt)|*.txt||";

            if (openFile.ShowDialog() == DialogResult.OK)
                 _path = openFile.FileName;

            openFile.Dispose();
        }
Example #27
0
 private void Select_Picrture_Click(object sender, EventArgs e)
 {
     OpenFileDialog openfile = new OpenFileDialog();
     if (openfile.ShowDialog() == DialogResult.OK)
     {
         pictureBox1.ImageLocation = openfile.FileName;
         PicturePath.Text = openfile.FileName;
     }
     openfile.Dispose();
 }
Example #28
0
 /// <summary>
 /// uses a OpenFileDialog to return a file
 /// </summary>
 /// <param name="F">File-Filter</param>
 /// <returns>string path</returns>
 public static string FGet(string F)
 {
     string relay = string.Empty;
     OpenFileDialog of = new OpenFileDialog();
     of.Filter = F;
     if (of.ShowDialog() == DialogResult.OK) relay = of.FileName;
     of.Dispose();
     of = null;
     return relay;
 }
Example #29
0
 /// <summary>
 /// Handle Disposing of the the OpenFileDialog behind this class
 /// </summary>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (ofd != null)
         {
             ofd.Dispose();
         }
     }
 }
Example #30
0
 private void Button3Click(object sender, EventArgs e)
 {
     var ofdDetect = new OpenFileDialog {FileName = "", InitialDirectory = Program.AppPath + @"sounds\"};
     ofdDetect.ShowDialog(this);
     if (ofdDetect.FileName != "")
     {
         txtExecute.Text = ofdDetect.FileName;
     }
     ofdDetect.Dispose();
 }
Example #31
0
        private void button2_Click(object sender, EventArgs e)
        {
            var fd = new OpenFileDialog();
            if (fd.ShowDialog() == DialogResult.OK)
                this.textBox1.Text = fd.FileName;

            fd.Dispose();

            Initfile(this.textBox1.Text);
        }
Example #32
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (concreteOpenFileDialog != null)
         {
             concreteOpenFileDialog.Dispose();
             concreteOpenFileDialog = null;
         }
     }
 }
Example #33
0
 private void loadEncryptedTagFileButton_Click(object sender, EventArgs e)
 {
     OpenFileDialog fd = new OpenFileDialog();
     fd.Title = "Select Encrypted File";
     //fd.Filter = "bin files (*.bin)|*.bin";
     if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         encryptedFileTextBox.Text = fd.FileName;
     }
     fd.Dispose();
 }
        private void processFileButton_click(object sender, EventArgs e)
        {
            Stream myStream = null;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FilterIndex = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            //Clean up old file runs
                            File.Delete(FileManager.CreateOutputFileName(openFileDialog1.FileName));

                            //Create Streamreader with file stream
                            StreamReader reader = new StreamReader(myStream);

                            //Read file line by line for search terms
                            string searchCommand = "";
                            while ((searchCommand = reader.ReadLine()) != null)
                            {
                                //If empty line skip and warn
                                if (searchCommand != String.Empty)
                                {
                                    //translate search command
                                    Navigator navigationPath = new Navigator(searchCommand);

                                    //append translation to output file
                                    FileManager.WriteStringToFile(openFileDialog1.FileName, navigationPath.NavigationPath);
                                }
                                else
                                {
                                    MessageBox.Show("Search Command is empty");
                                }
                            }
                            //Release file resource
                            openFileDialog1.Dispose();
                        }
                    }
                }
                catch (Exception ex)
                {
                    //Should only be reached in the event that a file with invalid characters is used, allows program to continue and process next file selection
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
Example #35
0
 private void playlistOpen_Click(object sender, RoutedEventArgs e)
 {
     Forms.OpenFileDialog OFD = new Forms.OpenFileDialog();
     OFD.Multiselect = true;
     OFD.Filter      = "播放列表文件|*.XML";
     if (OFD.ShowDialog() == Forms.DialogResult.OK)
     {
         LoadPlayList(OFD.FileName);
     }
     OFD.Dispose();
 }
Example #36
0
 // open new file with image
 private void MenuFile_Open_Click(object sender, EventArgs e)
 {
     OpenFileDialog FileOpen = new OpenFileDialog();
     FileOpen.Title = "Open Image File";
     FileOpen.Filter = "JPEG (*.jpg)|*.jpg|Bitmap (*.bmp)|*.bmp|TIFF (*.tiff)|*.tiff|All (*.*)|*.*";
     DialogResult Result = FileOpen.ShowDialog();
     if (Result == DialogResult.OK)
     {
         ImageWindow img = new ImageWindow(this, FileOpen.FileName);
     }
     else FileOpen.Dispose();
 }
        private void FileOpen( object p_Sender, System.EventArgs p_Args )
        {
            OpenFileDialog FileDialog = new OpenFileDialog( );

            FileDialog.Filter = "Blood Bullet file (*.blood)|*.blood";
            if( FileDialog.ShowDialog( this ) == System.Windows.Forms.DialogResult.OK )
            {
                m_FileName = FileDialog.FileName;
            }

            FileDialog.Dispose( );
        }
Example #38
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                checkFile = true;
                fileName = openFile.SafeFileName.ToString();
                textBox1.Text = fileName;
                openFile.Dispose();
            }
        }
Example #39
0
 private void button2_Click(object sender, EventArgs e)
 {
     OpenFileDialog ofdOpen = new OpenFileDialog() { Filter = "Книга Excel 97-2003|*.xls|Книга Excel|*.xlsx|Все файлы|*.*" };
     
         if (ofdOpen.ShowDialog() != DialogResult.OK)
             return;
         EdPlanProcessor = new EducationalPlanProcessor();
         EdPlanProcessor.OpenExcelDoc(ofdOpen.FileName);
     ofdOpen.Dispose();
     EdPlanProcessor.CreateEducationalPlan();
     EdPlanProcessor.CloseExcelDoc();
 }
Example #40
0
        private void metroButton2_Click(object sender, EventArgs e)
        {
            this.openFileDialog1        = new OpenFileDialog();
            this.openFileDialog1.Filter = "*.txt|*.TXT";

            if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                this.metroTextBox3.Text = this.openFileDialog1.FileName;
            }

            openFileDialog1.Dispose();
        }
Example #41
0
		public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e)
		{
			Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y));
			OpenFileDialog ofd = new OpenFileDialog();
			ofd.Title = "Select an Image to insert into map";
			ofd.Filter = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|Fireworks (*.png)|*.png|GIF (*.gif)|*.gif|Icon (*.ico)|*.ico|All files|*.*";
			ofd.InitialDirectory = Environment.SpecialFolder.MyPictures.ToString();
			int al = drawArea.TheLayers.ActiveLayerIndex;
			if (ofd.ShowDialog() == DialogResult.OK)
				((DrawImage)drawArea.TheLayers[al].Graphics[0]).TheImage = (Bitmap)Bitmap.FromFile(ofd.FileName);
			ofd.Dispose();
			base.OnMouseUp(drawArea, e);
		}
Example #42
0
 private string[] File_Open(string filter, bool multiselect)
 {
     string[]             files = null;
     Forms.OpenFileDialog OFD   = new Forms.OpenFileDialog();
     OFD.Multiselect = multiselect;
     OFD.Filter      = filter;
     if (OFD.ShowDialog() == Forms.DialogResult.OK)
     {
         files = OFD.FileNames;
     }
     OFD.Dispose();
     return(files);
 }
Example #43
0
 private void adcionar_Click(object sender, EventArgs e)
 {
     OpenFileDialog openFileDialog = new OpenFileDialog();
     //openFileDialog.InitialDirectory = currentPatch;
     openFileDialog.Filter = "Grf Files (*.grf)|*.grf|All Files (*.*)|*.*";
     if (openFileDialog.ShowDialog(this) == DialogResult.OK)
     {
         listGrf.Items.Add(openFileDialog.FileName);
         confModified = true;
     }
     openFileDialog.Dispose();
     openFileDialog = null;
 }
Example #44
0
        public static bool OpenFileDialog(string title, string filter, string initialDirectory, string[] allowedExtensions, out string fullName)
        {
            fullName = String.Empty;
            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
            try
            {
                dialog.Title  = title;
                dialog.Filter = filter;
                if (!String.IsNullOrEmpty(initialDirectory))
                {
                    dialog.InitialDirectory = initialDirectory;
                }
                dialog.FilterIndex = 1; //The index value of the first filter entry is 1.
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    fullName = dialog.FileName;
                    if (String.IsNullOrEmpty(fullName))
                    {
                        fullName = String.Empty;
                    }
                    else
                    {
                        System.IO.FileInfo fi = new System.IO.FileInfo(fullName);

                        if (!allowedExtensions.Contains(fi.Extension.ToLowerInvariant()))
                        {
                            fullName = String.Empty;
                        }
                    }
                }

                if (String.IsNullOrEmpty(fullName))
                {
                    return(false);
                }

                return(true);
            }
            catch
            {
                fullName = String.Empty;
                return(false);
            }
            finally
            {
                dialog.Dispose();
            }
        }
Example #45
0
        private void Upload_Click(object sender, RoutedEventArgs e)
        {
            Forms.OpenFileDialog fileDialog = new Forms.OpenFileDialog();
            string filepath = null;

            if (fileDialog.ShowDialog() == Forms.DialogResult.OK)
            {
                filepath = fileDialog.FileName;
                if (File.Exists(filepath))
                {
                    FileInfo fileInfo = new FileInfo(filepath);
                    fileName.Text = fileInfo.Name;
                }
            }
            fileDialog.Dispose();
        }
Example #46
0
        private bool _disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                    if (ofd != null)
                    {
                        ofd.Dispose();
                    }
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.
                _disposedValue = true;
            }
        }
        private void menuItem2_Click(object sender, System.EventArgs e)                 //Opens openfile dialog to select a DXF file
        {
            //Form1 f = new Form1();
            //f.Show();
            //f.Activate();
            //f.Focus();
            inputFileTxt = "";

            openFileDialog1.InitialDirectory = "c:\\";                              //sets the initial directory of the openfile dialog

            openFileDialog1.Filter = "dxf files (*.dxf)|*.dxf|All files (*.*)|*.*"; //filters the visible files...

            openFileDialog1.FilterIndex = 1;


            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) //open file dialog is shown here...if "cancel" button is clicked then nothing will be done...
            {
                inputFileTxt = openFileDialog1.FileName;                              //filename is taken (file path is also included to this name example: c:\windows\system\blabla.dxf

                int ino = inputFileTxt.LastIndexOf("\\");                             //index no of the last "\" (that is before the filename) is found here


                newCanvas = new Canvas();                                                               //a new canvas is created...

                newCanvas.MdiParent = this;                                                             //...its mdiparent is set...

                newCanvas.Text        = inputFileTxt.Substring(ino + 1, inputFileTxt.Length - ino - 1); //...filename is extracted from the text...(blabla.dxf)...
                newCanvas.MinimumSize = new Size(500, 400);                                             //...canvas minimum size is set...


                if (inputFileTxt.Length > 0)
                {
                    newCanvas.ReadFromFile(inputFileTxt);                               //the filename is sent to the method for data extraction and interpretation...
                }



                newCanvas.Show();                                                                       //the canvas is displayed...
                newCanvas.Activate();
                newCanvas.Focus();
            }

            openFileDialog1.Dispose();
        }
Example #48
0
        private void btnSelect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var dialog = new System.Windows.Forms.OpenFileDialog();
                dialog.Filter          = "FF14版本文件 (ffxivgame.ver)|ffxivgame.ver|FF14可执行文件 (ffxiv.exe)|ffxiv.exe|FF14_DX11可执行文件(ffxiv.exe)|ffxiv_dx11.exe";
                dialog.CheckFileExists = true;
                dialog.CheckPathExists = true;
                dialog.ValidateNames   = true;
                dialog.ShowHelp        = true;
                dialog.Title           = "请选择\"你的安装目录/最终幻想XIV/game/ffxivgame.ver\"或ffxiv.exe";
                void _(Object _sender, EventArgs _e)
                {
                    MessageBox.Show("请选择\"你的安装目录/最终幻想XIV/game/ffxivgame.ver\"或ffxiv.exe");
                }
                dialog.HelpRequest += new EventHandler(_);

                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    logger.Info($"Game file path selected: {dialog.FileName}");
                    pathSelect.Text = dialog.FileName;
                    string GamePath    = System.IO.Directory.GetParent(pathSelect.Text).ToString();
                    var    versionFile = new System.IO.StreamReader(GamePath + @"/ffxivgame.ver");
                    gameVersion = versionFile.ReadToEnd();
                    if (gameVersion.Length == 20)
                    {
                        txtVersion.Text = gameVersion;
                    }
                    else
                    {
                        txtVersion.Text = "ERROR";
                        logger.Error($"Incorrect game version file detected");
                    }
                    versionFile.Dispose();
                }
                dialog.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
                logger.Error(error.Message);
                this.Close();
            }
        }
Example #49
0
 private void ButtonAdd_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog
     {
         Multiselect     = true,
         CheckPathExists = true,
         CheckFileExists = true,
         Filter          = "Image Files(*.jpg;*.jpeg;*.bmp;*.png)|*.BMP;*.JPG;*.JPEG,*.PNG"
     };
     if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         string[] tempDragFileNames = openFileDialog.FileNames;
         int      fileCount         = FilesListLoad(tempDragFileNames);
         labelfileCount.Content = "添加 " + fileCount.ToString() + " 个文件,合计 " + Fileslist.SrcName.Count.ToString();
         FileInfoRefresh();
         ListRefresh();
     }
     openFileDialog.Dispose();
 }
Example #50
0
        private void OnFileOpen(object sender, EventArgs e)
        {
            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();

            dlg.Filter = "All files (*.*)|*.*";

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this._ProcImage.Destroy();

                PsImage.ImageReader.ReadImage(dlg.FileName, this._ImageData);

                this.UpdateViewImage(this._ImageData);

                this.UpdateView();
            }

            dlg.Dispose();
        }
        private void Import_Click(object sender, RoutedEventArgs e)
        {
            int r = 0;

            //文件选择窗口
            wf.OpenFileDialog opd = new wf.OpenFileDialog();
            opd.Title = "选择文件";
            //第一个参数是名称,随意取,第二个是模式匹配, 多个也是用“|”分割
            opd.Filter = "EXCEL文件|*.xls*";

            if (opd.ShowDialog() == wf.DialogResult.OK)
            {
                string result = new FileHelper().ImportExcelToDatabase(opd.FileName);
                if (result == null)
                {
                    r = (int)_service.AuditProductiveTaskList(this.DP2.SelectedDate.Value);
                }

                this.AuditText.Text = "已审核";
                MessageBox.Show($"成功 {r} 条");
            }
            opd.Dispose();
        }
Example #52
0
 public void Dispose()
 {
     _dialog.Dispose();
 }
Example #53
0
 public void Dispose()
 {
     fileDialog.Dispose();
     folderDialog.Dispose();
 }
Example #54
0
 //clicked on from file browser, clicking cancel wil return from the showDialog
 private void BrowserSelection(object sender, System.ComponentModel.CancelEventArgs e)
 {
     file.Text = openFileDialog.FileName;
     openFileDialog.Dispose();
     LoadDoc();
 }
Example #55
0
 public void Dispose()
 {
     _openFileDialog.Dispose();
 }
Example #56
0
        /*public static void mapDecypher(System.IO.BinaryReader br, int headerOffset, int id)
         * {
         *  /*
         *  09 1115 used in $C0/591A (DC2D84,((00:1115 & 0x3F (6 bits)) * 4) + DC/2E24)                 First  [4bpp 8x8] Graphics load
         *  .. .... used in $C0/596A (DC2D84,(Invert_Bytes((00:1115..16 & 0FC0) * 4) * 4) + DC/2E24)    Second [4bpp 8x8] Graphics load
         *  0A 1116 used in $C0/59D7 (DC2D84,((00:1116..7 & 03F0)/4) + DC/2E24)                         Third  [4bpp 8x8] Graphics load
         *  0B 1117 used in $C0/5A45 (DC0000,((00:1117 & #$FC) / 2) + DC/0024)                                 [2bpp 8x8] Graphics load
         *
         *  0C 1118 used in $C0/5877 (CB0000,(((00:1118 & 0x03FF) - 1) * 2) + CB...CC.../0000???)              [unheaded Type02] (I.e. CC/344B) -> Bytemap decompressed in 7F:0000
         *  0D 1119 used in $C0/588D (if (((00:1119 & 0x0FFC) / 4) - 1) == 0xFFFF => 0-> 7F0000:7F0FFF)        [unheaded Type02] -> Bytemap ???? decompressed in 7F:1000 ????
         *  0E 111A used in $C0/58B6 (CB0000,(((00:111A & 0x3FF0)/16) - 1) * 2) + CB...CC.../0000???)          [unheaded Type02] (I.e. CC/344B) -> Bytemap ???? decompressed in 7F:2000 ????
         *  0F 111B "
         *
         *  16 1122 Used in $C0/58DB (Sent 0x100 bytes C3BB00,([17] * 0x0100 [16]) (i.e. C3:C400) -> to 00:0C00 [Palette])
         *  //
         *
         *  int offset = 0;
         *  br.BaseStream.Position = 0x0E9C00 + headerOffset + (id * 0x1A);
         *  List<Byte> mapDescriptors = br.ReadBytes(0x1A).ToList();
         *
         *
         *
         *  br.BaseStream.Position = 0x03BB00 + headerOffset + (mapDescriptors[0x16] + mapDescriptors[0x17] * 0x0100);
         *  Byte[]  bytePal = br.ReadBytes(0x0100);
         *  Color[] palette = new Color[0x0100];
         *  for (int i = 0; i < 0x0100; i += 2)
         *  {
         *      int color = bytePal[i] + bytePal[i + 1] * 0x0100;
         *      int r = ((color /    1) % 32) * 8;
         *      int g = ((color /   32) % 32) * 8;
         *      int b = ((color / 1024) % 32) * 8;
         *      r = r + r / 32;
         *      g = g + g / 32;
         *      b = b + b / 32;
         *
         *      palette[i] = Color.FromArgb(r, g, b);
         *  }
         *
         *  br.BaseStream.Position = 0x1C2D84 + headerOffset + ((mapDescriptors[0x09] & 0x3F) * 4);
         *  offset = br.ReadByte() + (br.ReadByte() * 0x0100) + (br.ReadByte() * 0x010000) + 0x1C2E24 + headerOffset;
         *  br.BaseStream.Position = offset;
         *  Bitmap firstBitmap = Transformations.transform4b(br.ReadBytes(0x2000).ToList(), 0, 0x2000);
         *  ManageBMP.exportBPM("firstBitmap.png", firstBitmap, palette);
         *
         *  br.BaseStream.Position = 0x1C2D84 + headerOffset + ((((mapDescriptors[0x09] & 0xC0) / 4)  + (mapDescriptors[0x0A] & 0x0F)) * 4);
         *  offset = br.ReadByte() + (br.ReadByte() * 0x0100) + (br.ReadByte() * 0x010000) + 0x1C2E24 + headerOffset;
         *  br.BaseStream.Position = offset;
         *  Bitmap secondBitmap = Transformations.transform4b(br.ReadBytes(0x2000).ToList(), 0, 0x2000);
         *  ManageBMP.exportBPM("secondBitmap.png", secondBitmap, palette);
         *
         *  br.BaseStream.Position = 0x1C2D84 + headerOffset + (((mapDescriptors[0x0A] + (mapDescriptors[0x0B] * 0x0100)) & 0x03F0) / 4);
         *  offset = br.ReadByte() + (br.ReadByte() * 0x0100) + (br.ReadByte() * 0x010000) + 0x1C2E24 + headerOffset;
         *  br.BaseStream.Position = offset;
         *  Bitmap thirdBitmap = Transformations.transform4b(br.ReadBytes(0x2000).ToList(), 0, 0x2000);
         *  ManageBMP.exportBPM("thirdBitmap.png", thirdBitmap, palette);
         *
         *  br.BaseStream.Position = 0x1C0000 + headerOffset + ((mapDescriptors[0x0B] & 0xFC) / 2);
         *  offset = br.ReadByte() + (br.ReadByte() * 0x0100) + 0x1C0024 + headerOffset;
         *  br.BaseStream.Position = offset;
         *  Bitmap forthBitmap = Transformations.transform2bpp(br.ReadBytes(0x2000).ToList(), 0, 0x1000);
         *  ManageBMP.exportBPM("forthBitmap.png", forthBitmap, Palettes.palette2b);
         * }
         */



        public static void editSRM()
        {
            System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
            openFileDialog.Filter = "SRM File|*.srm";
            openFileDialog.Title  = "Choose a file";

            /* Show the Dialog */
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (openFileDialog.FileName != "")
                {
                    System.IO.FileStream   fs = new System.IO.FileStream(openFileDialog.FileName, System.IO.FileMode.Open);
                    System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs, new UnicodeEncoding());
                    System.IO.BinaryReader br = new System.IO.BinaryReader(fs, new UnicodeEncoding());

                    // Compare checksum
                    int accumulator = 0;
                    //int currrentChecksum = 0;

                    // Edit items
                    bw.BaseStream.Position = 0x0140;
                    for (int i = 0; i < 0x100; i++)
                    {
                        bw.BaseStream.WriteByte(BitConverter.GetBytes(i)[0]);
                    }
                    for (int i = 0; i < 0x100; i++)
                    {
                        bw.BaseStream.WriteByte(0x08);
                    }

                    br.BaseStream.Position = 0x0000;

                    for (int i = 0; i < 0x300; i++)
                    {
                        accumulator += br.ReadByte() + br.ReadByte() * 0x0100;
                        if (accumulator > 0xFFFF)
                        {
                            accumulator -= 0xFFFF;                       // or(0x010000)
                        }
                    }

                    /*
                     * FFVI
                     *
                     * for(int i = 0 ; i < 0x09FE ; i++) {
                     *      accumulator += br.ReadByte() + br.ReadByte() * 0x0100;
                     *      if (accumulator > 0xFFFF) accumulator -= 0xFFFF; // or(0x010000)
                     * }
                     *
                     * bw.BaseStream.Position = 0x09FE;
                     * bw.BaseStream.WriteByte(BitConverter.GetBytes(accumulator)[0]);
                     * bw.BaseStream.WriteByte(BitConverter.GetBytes(accumulator)[1]);
                     */

                    bw.BaseStream.Position = 0x1FF0;
                    //currrentChecksum = br.ReadByte() + br.ReadByte() * 0x0100;
                    //System.Windows.Forms.MessageBox.Show(currrentChecksum.ToString("X4"), accumulator.ToString("X4"));
                    bw.BaseStream.WriteByte(BitConverter.GetBytes(accumulator)[0]);
                    bw.BaseStream.WriteByte(BitConverter.GetBytes(accumulator)[1]);

                    bw.Close();
                    bw.Dispose();
                    br.Close();
                    br.Dispose();
                    fs.Close();
                    fs.Dispose();
                }
            }

            openFileDialog.Dispose();
            openFileDialog = null;
        }
    private void Button2_Click(System.Object sender, System.EventArgs e)
    {
        //Dim m_strConnection As String = "server='Server_Name';Initial Catalog='Database_Name';Trusted_Connection=True;"

        //Catch ex As Exception
        //    MessageBox.Show(ex.ToString())
        //End Try

        //Dim objDataset1 As DataSet()
        //Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        //Dim da As OdbcDataAdapter
        System.Windows.Forms.OpenFileDialog OpenFile = new System.Windows.Forms.OpenFileDialog();
        // Does something w/ the OpenFileDialog
        string  strFullPath = null;
        string  strFileName = null;
        TextBox tbFile      = new TextBox();

        // Sets some OpenFileDialog box options
        OpenFile.Filter = "CSV Files (*.csv)|*.csv|All files (*.*)|*.*";
        // Shows only .csv files
        OpenFile.Title = "Browse to file:";
        // Title at the top of the dialog box

        // Makes the open file dialog box show up
        if (OpenFile.ShowDialog() == DialogResult.OK)
        {
            strFullPath = OpenFile.FileName;
            // Assigns variable
            strFileName = Path.GetFileName(strFullPath);

            // Checks to see if they've picked a file
            if (OpenFile.FileNames.Length > 0)
            {
                tbFile.Text = strFullPath;
                // Puts the filename in the textbox

                // The connection string for reading into data connection form
                string connStr = null;
                connStr = "Driver={Microsoft Text Driver (*.txt; *.csv)}; Dbq=" + Path.GetDirectoryName(strFullPath) + "; Extensions=csv,txt ";

                // Sets up the data set and gets stuff from .csv file
                OdbcConnection  Conn        = new OdbcConnection(connStr);
                DataSet         ds          = default(DataSet);
                OdbcDataAdapter DataAdapter = new OdbcDataAdapter("SELECT * FROM [" + strFileName + "]", Conn);
                ds = new DataSet();

                try {
                    DataAdapter.Fill(ds, strFileName);
                    // Fills data grid..
                    DataGridView1.DataSource = ds.Tables(strFileName);
                    // ..according to data source

                    // Catch and display database errors
                } catch (OdbcException ex) {
                    OdbcError odbcError = default(OdbcError);
                    foreach (odbcError in ex.Errors)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                // Cleanup
                OpenFile.Dispose();
                Conn.Dispose();
                DataAdapter.Dispose();
                ds.Dispose();
            }
        }
    }
        public static string CargarImagenPictureBox(PictureBox pb)
        {
            string image = "";

            try
            {
                using (System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog())
                {
                    dlg.Title  = "Abrir imagen";
                    dlg.Filter = "Imágenes (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png";

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        string ruta_origen = dlg.FileName;

                        string ruta_destino = Global.DIRECTORIO_IMAGENES + @"\" + dlg.SafeFileName;

                        Bitmap bm = new Bitmap(ruta_origen);
                        pb.Image = bm;

                        if (!File.Exists(ruta_destino))
                        {
                            //File.Copy(dlg.FileName, ruta_destino);
                            SaveJpeg(ruta_destino, bm, 50);
                        }
                        else
                        {
                            if (!FileCompare(ruta_origen, ruta_destino))
                            {
                                int    counter        = 0;
                                string filenameNoPath = Path.GetFileNameWithoutExtension(ruta_destino);
                                string temppath       = Path.GetDirectoryName(ruta_destino);
                                string extension      = Path.GetExtension(ruta_destino);
                                string path           = "";

                                do
                                {
                                    counter++; // we're here, so lets count files with same name
                                    path = temppath + "\\" + filenameNoPath + "(" + counter.ToString() + ")" + extension;
                                } while (File.Exists(path));

                                ruta_destino = path;

                                //File.Copy(dlg.FileName, path);
                                SaveJpeg(path, bm, 50);
                            }
                        }

                        image = ruta_destino;
                        dlg.Dispose();
                    }
                    else
                    {
                        return("");
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Imágen no válida!");
            }

            return(image);
        }
        private void ButtonLicenseFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog();

            if (!Directory.Exists(ConstDef.APP_DATA_CONFIG_DIR))
            {
                fileDialog.InitialDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            }
            else
            {
                fileDialog.InitialDirectory = ConstDef.APP_DATA_CONFIG_DIR;
            }
            fileDialog.DefaultExt                   = "ini";
            fileDialog.RestoreDirectory             = true;
            fileDialog.Filter                       = "WeDo License 파일|*.ini";
            fileDialog.SupportMultiDottedExtensions = true;

            if (Utils.STAShowDialog(fileDialog) == DialogResult.OK)
            {
                Initialize();
                LabelLicenseFile.Text = fileDialog.FileName;
                FileInfo       info    = new FileInfo(LabelLicenseFile.Text);
                LicenseHandler handler = new LicenseHandler(info);
                handler.LogWriteHandler += OnStatusWrite;

                handler.ReadLicense();

                companyCd           = handler.CompanyCode;
                companyName         = handler.CompanyName;
                LabelCompanyCd.Text = string.Format("{0}({1})", companyName, companyCd);

                if (ctrl.NeedDbReinstall(handler.CompanyCode))
                {
                    ButtonDBReinstall.Enabled = true;
                    SetLicenseCheck(false);
                    LabelWarning.Text = string.Format("라이센스파일의 회사코드[{0}]가 기존 회사코드[{1}]와 다릅니다.\n"
                                                      + " 새로운 회사코드를 쓰려면 DB를 재설치해야 합니다."
                                                      , handler.CompanyCode, ctrl.CompanyCd);
                }
                else
                {
                    ButtonDBReinstall.Enabled = false;

                    if (handler.ValidLicense())
                    {
                        SetLicenseCheck(true);
                        LabelWarning.Text = "라이센스파일이 유효합니다.";
                    }
                    else
                    {
                        SetLicenseCheck(false);

                        LabelWarning.Text = "라이센스파일 검증에 실패했습니다. 파일유효성을 확인하세요.\n";

                        int resultCode = Convert.ToInt16(handler.ResultMessage.Split('&')[0]);
                        if (resultCode == (int)LicenseResult.ERR_EXPIRED)
                        {
                            LabelWarning.Text += "License 만료일자 지남.";
                        }
                        else if (resultCode == (int)LicenseResult.ERR_INVALID_FILE)
                        {
                            LabelWarning.Text += "잘못된 등록일자, 회사코드/명 또는 라이센스키.";
                        }
                        else if (resultCode == (int)LicenseResult.ERR_MAC_ADDR)
                        {
                            LabelWarning.Text += string.Format("License file 잘못된 mac address값.실제 mac address[{0}]", handler.MacAddress);
                        }
                    }
                }
            }
            fileDialog.Dispose();
        }
        /// <summary>
        /// Invokes the action.
        /// </summary>
        /// <param name="parameter">The parameter to the action; but not used.</param>
        protected override void Invoke(object parameter)
        {
            WinForms.OpenFileDialog dialog = null;

            try
            {
                dialog = new WinForms.OpenFileDialog();

                dialog.AddExtension       = this.AddExtension;
                dialog.AutoUpgradeEnabled = this.AutoUpgradeEnabled;
                dialog.CheckFileExists    = this.CheckFileExists;
                dialog.CheckPathExists    = this.CheckPathExists;
                dialog.DefaultExt         = this.DefaultExt;
                dialog.DereferenceLinks   = this.DereferenceLinks;
                dialog.FileName           = this.FileName;
                dialog.Filter             = this.Filter;
                dialog.FilterIndex        = this.FilterIndex;
                dialog.InitialDirectory   = this.InitialDirectory;
                dialog.Multiselect        = this.Multiselect;
                dialog.ReadOnlyChecked    = this.ReadOnlyChecked;
                dialog.RestoreDirectory   = this.RestoreDirectory;
                dialog.ShowHelp           = this.ShowHelp;
                dialog.ShowReadOnly       = this.ShowReadOnly;
                dialog.Site = this.Site;
                dialog.SupportMultiDottedExtensions = this.SupportMultiDottedExtensions;
                dialog.Tag           = this.Tag;
                dialog.Title         = this.Title;
                dialog.ValidateNames = this.ValidateNames;

                var dialogResult = dialog.ShowDialog(new Win32Window(this.Owner));

                switch (dialogResult)
                {
                case WinForms.DialogResult.OK:
                    if (this.OkCommand != null)
                    {
                        var result = new OpenFileDialogActionResult(dialog.FileName, dialog.FileNames);
                        if (this.OkCommand.CanExecute(result))
                        {
                            this.OkCommand.Execute(result);
                        }
                    }

                    break;

                case WinForms.DialogResult.Cancel:
                    if (this.CancelCommand != null)
                    {
                        if (this.CancelCommand.CanExecute(null))
                        {
                            this.CancelCommand.Execute(null);
                        }
                    }

                    break;

                default:
                    throw new NotImplementedException("Should not reach here.");
                }
            }
            finally
            {
                dialog.Dispose();
            }
        }