Exemple #1
0
 /* Open file */
 private void Open_TSMI_Click(object sender, EventArgs e)
 {
     try
     {
         if (OpenFD.ShowDialog() == DialogResult.OK)
         {
             _filename = OpenFD.FileName;
             if (OpenFD.FileName.EndsWith(".rtf"))
             {
                 rtb.LoadFile(_filename, RichTextBoxStreamType.RichText);
             }
             else
             {
                 rtb.LoadFile(_filename, RichTextBoxStreamType.PlainText);
             }
             Text        = _filename + CAPTURE_RIGHT_SIDE;
             isFileOpen  = true;
             isFileSaved = true;
         }
     }
     catch (Exception ex)
     {
         isFileOpen = false;
         Text       = DEFAULT_FILE_NAME + CAPTURE_RIGHT_SIDE;
         MessageBox.Show(ex.Message);
     }
 }
Exemple #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFD.Title            = "Select a Script";
                OpenFD.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                OpenFD.FileName         = "";
                OpenFD.Filter           = "SQL|*.sql";
                OpenFD.Multiselect      = true;

                if (OpenFD.ShowDialog() == DialogResult.OK)
                {
                    listBox1.Items.Clear();
                    string[] chosenFile = OpenFD.FileNames;
                    foreach (var itemList in chosenFile)
                    {
                        string files = Path.GetFileName(itemList);
                        listBox1.Items.Add(files);
                    }
                    listBox1.SelectionMode = SelectionMode.MultiExtended;

                    textBox1.Text = GetPath(OpenFD.FileName);
                }
            }
            catch (System.Exception excpt)
            {
                Console.WriteLine(excpt.Message);
            }
        }
 private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (OpenFD.ShowDialog() == DialogResult.Cancel)
     {
         return;
     }
     world.p.Sprite.Dispose();
     world.p.Sprite = new Bitmap(OpenFD.FileName);
 }
Exemple #4
0
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (OpenFD.ShowDialog() == DialogResult.OK)
     {
         TheGraph = Graph.FileToGraph(File.ReadAllLines(OpenFD.FileName));
         TheGraph.GetColors();
         DPanel.CreateGraphics().DrawImage(TheGraph.DrawGraph(DPanel.Width, DPanel.Height), new Point(0, 0));
     }
 }
        private void LoadFile(string filter, int first_row, char separator, int column_count, string temp_table, string transfer_proc)
        {
            int count = 0;

            FileBar.Maximum    = 1000;
            FileBar.Visible    = true;
            OpenFD.Title       = "Открытие файла данных IKEA";
            OpenFD.FileName    = "";
            OpenFD.Filter      = filter;
            OpenFD.Multiselect = true;
            if (OpenFD.ShowDialog() != DialogResult.Cancel)
            {
                foreach (string file in OpenFD.FileNames)
                {
                    try
                    {
                        galaxy.Database.ExecuteSqlCommand($"delete from {temp_table}");
                        StreamReader SR  = new StreamReader(file);
                        string       str = "";
                        for (int i = 0; i < first_row - 1; i++)
                        {
                            SR.ReadLine();
                        }
                        while (!SR.EndOfStream)
                        {
                            str = SR.ReadLine().Trim(separator);
                            //Структурирование строки из файла под SQL insert
                            str += new string(separator, column_count - 1 - str.Count(x => x == separator));
                            str  = str.Replace(separator.ToString(), "', '");
                            galaxy.Database.ExecuteSqlCommand($"insert into {temp_table} values ('{str}', '{file}')");
                            count++;
                            if (count % 50 == 0)
                            {
                                if (count == FileBar.Maximum)
                                {
                                    count = FileBar.Value = 0;
                                }
                                else
                                {
                                    FileBar.Value = count;
                                }
                            }
                        }
                        galaxy.Database.ExecuteSqlCommand($"begin {transfer_proc}; end;");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Ошибка чтения файла или сохранения данных!\n\n" + ex, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                MessageBox.Show("Файл(ы) успешно загружен(ы)!", "Успешно", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            FileBar.Visible = false;
        }
Exemple #6
0
        private void bLogFilePath_Click(object sender, EventArgs e)
        {
            string sFile = "";

            OpenFD.Title            = "Choose a Log File";
            OpenFD.InitialDirectory = "C:";
            //OpenFD.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            OpenFD.Filter = "Log Files|*.txt";
            OpenFD.ShowDialog();

            sFile = OpenFD.FileName;
            tbLogFilePath.Text = sFile;
        }
Exemple #7
0
        private void ButLoad_Click(object sender, EventArgs e)
        {
            object[] loadVehicle;
            bool     IsDecompressed = false;

            if (OpenFD.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            string filePath = OpenFD.FileName;

            try
            {
                if (GetSer(filePath) == null)
                {
                    if (DecompressFile(ref filePath) == false)
                    {
                        MessageBox.Show("Не загружен файл для разархивации.");
                        return;
                    }
                    else
                    {
                        IsDecompressed = true;
                    }
                }

                ISer ser = GetSer(filePath);
                if (ser == null)
                {
                    MessageBox.Show("Десериализация не удалась!");
                    return;
                }

                loadVehicle = ser.Deserialize(filePath);
                foreach (Vehicle vehicle in loadVehicle)
                {
                    Vehicles.Add(vehicle);
                }
                RefreshVehicleList();

                if (IsDecompressed)
                {
                    File.Delete(filePath);
                    IsDecompressed = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #8
0
        private void button9_Click(object sender, EventArgs e)
        {
            OpenFD.Title    = "Select Files";
            OpenFD.Filter   = "Jpg|*.jpg|Jpge|*.jpge";
            OpenFD.FileName = null;
            string fileName;

            if (OpenFD.ShowDialog() != DialogResult.Cancel)
            {
                fileName = OpenFD.FileName;
                Object refmissing = System.Reflection.Missing.Value;
                try
                {
                    // show it to picturebox

                    // Here get_image is a function and Big is the byte[] type

                    string conn = ConfigurationManager.ConnectionStrings["UCS_Starter.Properties.Settings.UCSConn"].ToString();



                    SqlConnection connection = new SqlConnection(conn);


                    SqlCommand command = new SqlCommand();
                    command.Connection  = connection;
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "Add_img";



                    SqlParameter retval = command.Parameters.Add("@cot", SqlDbType.VarChar, 15);
                    retval.Direction = ParameterDirection.Output;

                    connection.Open();
                    command.ExecuteNonQuery();
                    textBox12.Text = "UCS-IT-IMG-" + (string)command.Parameters["@cot"].Value + ".jpg";
                    connection.Close();

                    get_image(fileName, "UCS-IT-IMG-" + (string)command.Parameters["@cot"].Value);

                    string path = data_folder + @"\Item_300x300_tumb\" + "UCS-IT-IMG-" + (string)command.Parameters["@cot"].Value + ".jpg";
                    pictureBox1.Load(path);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error" + ex.Message.ToString());
                }
            }
        }
Exemple #9
0
        private void button3_Click(object sender, EventArgs e)
        {
            //load patient's picture from the system
            string picFile = "";

            OpenFD.InitialDirectory = "C:";
            OpenFD.Title            = "Load Patient Picture";
            OpenFD.Filter           = "Jpeg Files|*.jpg|GIF Images|*.gif";
            OpenFD.FileName         = "";

            if (OpenFD.ShowDialog() == DialogResult.OK)
            {
                picFile              = OpenFD.FileName;
                txtPatImage.Text     = picFile;
                pbPatientImage.Image = Image.FromFile(picFile);
            }
        }