示例#1
0
        // Shows a text editor form and hide login form
        public static void ShowTextEditorForm(User user, LoginForm loginForm)
        {
            TextEditorForm TextEditorForm = new TextEditorForm(user);

            loginForm.Hide();
            TextEditorForm.Show();
        }
示例#2
0
 private void _openLogFileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (File.Exists(logFileName))
     {
         TextEditorForm textEditor = new TextEditorForm();
         textEditor.LoadContent(logFileName);
         textEditor.Show(this);
     }
     else
     {
         MessageBox.Show("Nie znaleziono pliku\n\n {0}", logFileName);
     }
 }
示例#3
0
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        /*
            Function name: openToolStripMenuItem_Click
            Version: 1
            Author: Christopher Sigouin
            Description: Open functionality to allow a user to open a previously saved file
            Inputs:
            Outputs:
            Return value: N/A
            Change History: 2015.12.04 Original version by CJS
        */
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TextEditorForm textEditor;
            string info;

            // Change the status strip text
            statusStripLabelParent.Text = "Opening...";

            try
            {
                // Get the result of the openFileDialog to check for "Open" or "Cancel"
                DialogResult openFileResult = openFileDialog1.ShowDialog();
                if (openFileResult == DialogResult.Cancel)
                {
                    // Change the status strip text
                    statusStripLabelParent.Text = "Done";
                }
                else
                {
                    using (StreamReader getInfo = new StreamReader(openFileDialog1.FileName))
                    {

                        // Create a new form
                        textEditor = new TextEditorForm();
                        textEditor.MdiParent = this;
                        textEditor.Text = textEditor.FileName = openFileDialog1.SafeFileName;
                        textEditor.SaveToolStripMenuItem.Text = "Save ( " + openFileDialog1.SafeFileName + " )";

                        // Better to use EOF when possible!!!
                        while ((info = getInfo.ReadLine()) != null)
                        {

                            textEditor.TextArea.Text += info;

                        } // END: WHILE
                    } // END : USING

                    // Get the data size for error checking
示例#4
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView2.SelectedItems.Count > 0)
            {
                ListViewItem        row   = listView2.SelectedItems[0];
                ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry)row.Tag;
                if (!entry.getAttrs().isDir())
                {
                    try
                    {
                        string resfile    = getCurrDir() + entry.getFilename();
                        string targetfile = MainForm.TEMP_DIR + string.Format("{0}.file", DateTime.Now.ToString("MMddHHmmss"));
                        targetfile = targetfile.Replace("\\", "/");

                        TextEditorForm editor = new TextEditorForm();
                        editor.Show(this);
                        editor.LoadRemoteFile(new ShellForm(this), resfile, targetfile);
                    }
                    catch { }
                }
            }
        }
示例#5
0
        private void OnFileNew(object sender, EventArgs eventArgs)
        {
            TextEditorForm textEditorForm = new TextEditorForm(this);
            textEditorForm.ToolTipText = $"{MainForm.NewFileName}{this.mNewFileNumber}";
            textEditorForm.Text = $"{MainForm.NewFileName}{this.mNewFileNumber}";
            textEditorForm.FileName = string.Empty;
            textEditorForm.TextEncoding = Encoding.UTF8;
            textEditorForm.Show(this.mDockPanel, DockState.Document);
            textEditorForm.SetEventHandlers();

            this.mStatusBarLabelEncoding.Text = Encoding.UTF8.EncodingName;

            ++this.mNewFileNumber;
        }
示例#6
0
        private void Open(string openFileName)
        {
            bool isFileAlreadyOpened = false;

            foreach (TextEditorForm textEditorForm in this.TextEditorForms) {
                if (textEditorForm.FileName == openFileName) {
                    isFileAlreadyOpened = true;
                    textEditorForm.Activate();
                    return;
                }
            }

            if (!isFileAlreadyOpened) {
                try {
                    byte[] bytes = File.ReadAllBytes(openFileName);
                    Encoding[] encodings = this.DetectEncodings(bytes, MainForm.DetectEncodingsCount);

                    string unicodeString = encodings[0].GetString(bytes);

                    TextEditorForm newTextEditorForm = new TextEditorForm(this);
                    newTextEditorForm.ToolTipText = openFileName;
                    newTextEditorForm.Text = $"{Path.GetFileName(openFileName)}";
                    newTextEditorForm.Scintilla.Text = unicodeString;
                    newTextEditorForm.Scintilla.EmptyUndoBuffer();
                    newTextEditorForm.Scintilla.SetSavePoint();
                    newTextEditorForm.FileName = openFileName;
                    newTextEditorForm.TextEncoding = encodings[0];
                    newTextEditorForm.Show(this.mDockPanel, DockState.Document);
                    newTextEditorForm.SetEventHandlers();

                    this.mStatusBarLabelEncoding.Text = encodings[0].EncodingName;
                } catch (Exception) {
                    MessageBox.Show(
                        $"\'{openFileName}\' を開く際にエラーが発生しました.",
                        Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }