Пример #1
0
        private void saveFileCtrlSToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (nazwapliku != null)
            {
                try
                {
                    Encoding enc = Encoding.GetEncoding(kodowanie);
                    System.IO.File.WriteAllText(get_nazwa_pliku(), richTextBox1.Text, enc);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("bleError: Could not save file to disk. Original error: " + ex.Message);
                }

            }
            else if (nazwapliku == null)
            {
                SaveFileDialogWithEncoding saveFileDialog2 = new SaveFileDialogWithEncoding();
                saveFileDialog2.Filter = "Text files|*.txt|All files|*.*";
                if (saveFileDialog2.ShowDialog() == DialogResult.OK)
                {
                    string kodowanie;
                    if (saveFileDialog2.EncodingType == EncodingType.UTF8)
                    {
                        kodowanie = "UTF-8";
                    }
                    else if (saveFileDialog2.EncodingType == EncodingType.WIN)
                    {
                        kodowanie = "Windows-1250";
                    }
                    else if (saveFileDialog2.EncodingType == EncodingType.UNICODE)
                    {
                        kodowanie = "UNICODE";
                    }
                    else
                    {
                        kodowanie = "ASCII";
                    }

                    try
                    {
                        Encoding enc = Encoding.GetEncoding(kodowanie);
                        System.IO.File.WriteAllText(saveFileDialog2.FileName, richTextBox1.Text, enc);

                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: Could not save file to disk. Original error: " + ex.Message);
                    }
                    set_nazwa_pliku(saveFileDialog2.FileName);
                    set_nazwa_w_formularzu(saveFileDialog2.FileName);

                }
            }
        }
Пример #2
0
 private void menuSaveProj_Click(object sender, System.EventArgs e)
 {
     SaveFileDialogWithEncoding ofd = new SaveFileDialogWithEncoding();
     ofd.DefaultExt = "xml";
     ofd.EncodingType = EncodingType.UTF8;
     ofd.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
     if (ofd.ShowDialog((IntPtr)this.Handle, Screen.FromControl(this), "UTF-8") == DialogResult.OK) {
         SaveProject(ofd.FileName);
     }
 }
Пример #3
0
 private void menuSaveEffectsFile_Click(object sender, System.EventArgs e)
 {
     SaveFileDialogWithEncoding ofd=new SaveFileDialogWithEncoding();
     ofd.DefaultExt="exml";
     ofd.EncodingType=EncodingType.ANSI;
     ofd.Filter="XML effect files (*.exml)|*.exml|All files (*.*)|*.*";
     if (ofd.ShowDialog((IntPtr)this.Handle,Screen.FromControl(this))==DialogResult.OK) {
         Form1.SaveEffectsFile(ofd.FileName,tColl);
     }
 }
Пример #4
0
        private void menuSaveAs_Click(object sender, System.EventArgs e)
        {
            SaveFileDialogWithEncoding ofd = new SaveFileDialogWithEncoding();
            ofd.DefaultExt = "ass";
            ofd.EncodingType = EncodingType.Unicode;
            ofd.Filter = "SSA/ASS files (*.ass;*.ssa)|*.ass;*.ssa|All files (*.*)|*.*";
            if (ofd.ShowDialog((IntPtr)this.Handle, Screen.FromControl(this), enc == null ? string.Empty : enc.ToString()) == DialogResult.OK) {
                enc = SaveFileDialogWithEncoding.stringToEncodingType(ofd.EncodingType.ToString());
                SaveFile(ofd.FileName);

            }
        }