Ejemplo n.º 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();
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 3
0
 /// <inheritdoc/>
 public virtual bool InvokeEditor()
 {
     using (TextEditorForm form = new TextEditorForm(Report))
     {
         form.ExpressionText = Text;
         form.Brackets       = Brackets;
         if (form.ShowDialog() == DialogResult.OK)
         {
             Text = form.ExpressionText;
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 4
0
        // Shows a login form and hide text editor or registration form
        public static void ShowLoginForm(NewUserForm newUserForm = null, TextEditorForm textEditorForm = null)
        {
            LoginForm loginForm = new LoginForm();

            if (newUserForm != null)
            {
                newUserForm.Hide();
            }

            if (textEditorForm != null)
            {
                textEditorForm.Hide();
            }
            loginForm.Show();
        }
Ejemplo n.º 5
0
		/// <summary>
		/// Edits the specified object's value using the editor style indicated by <see cref="GetEditStyle"/>.
		/// </summary>
		/// <param name="context">An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.</param>
		/// <param name="provider">An <see cref="IServiceProvider"/> that this editor can use to obtain services.</param>
		/// <param name="value">The object to edit.</param>
		/// <returns>The new value of the object.</returns>
		public override object EditValue(ITypeDescriptorContext context,
			IServiceProvider provider, object value)
		{
			if (context != null && context.Instance != null)
			{
				TextEditorForm form = new TextEditorForm();
				form.Value = (string)value;
				DialogResult result = form.ShowDialog();

				if (result == DialogResult.OK)
					value = form.Value;
			}

			return value;
		}
Ejemplo n.º 6
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
Ejemplo n.º 7
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 { }
                }
            }
        }
Ejemplo n.º 8
0
        public async Task Run()
        {
            Env.Clear();
            Env.Notifier = _notifier;
            Env.App      = new App();
            Env.RandomNumberGenerator = GetRandomNumberGenerator();
            Env.CommandCollection     = new CommandCollection();
            Env.Cipher = new Cipher(await Env.Config.GetKeyAsync());
            Env.StateHandlerFactory = new JsonStateHandlerFactory();
            Env.Settings            = await GetSettingsAsync();

            Env.Parser             = new Parser();
            Env.ModeHook           = new ModeHook();
            Env.ForegroundListener = new ForegroundListener();
            Env.FlagManager        = await FlagManager.GetFlagManagerAsync();

            Env.Scheduler = await Scheduler.GetSchedulerAsync();

            Env.ProcessManager = new ProcessManager();
            Env.Injector       = new Injector();
            Env.PasswordMatrix = await PasswordMatrix.GetPasswordMatrixAsync();

            Env.AccountManager = await AccountManager.GetAccountManagerAsync();

            var comboHook   = new ComboHook();
            var comboRelay  = new ComboRelay(Env.ModeHook, comboHook);
            var inputHook   = new InputHook(comboRelay);
            var inputRelay  = new InputRelay(inputHook);
            var primaryHook = new PrimaryHook(inputRelay);
            var fileManager = await FileManager.GetFileManagerAsync();

            TextEditorForm = new TextEditorForm(fileManager);
            await Env.Config.Run();

            Env.App.TriggerRun();
        }
Ejemplo n.º 9
0
        public FindDialog(MainForm mainForm, FindDialogType findDialogType)
        {
            // TODO: フォームが2つ以上生成されないようにする

            this.InitializeComponent();

            this.mMainForm = mainForm;
            this.mCurrentTextEditorForm = this.mMainForm.GetCurrentTextEditorForm();
            this.OnDockPanelActiveDocumentChanged(this, EventArgs.Empty);

            // タブの選択(デフォルトでは検索を選択)
            this.mTabControl.SelectedTab =
                findDialogType == FindDialogType.Find ? this.mTabPageFind :
                findDialogType == FindDialogType.Replace ? this.mTabPageReplace :
                this.mTabPageFind;

            this.OnTabControlSelectedIndexChanged(this, EventArgs.Empty);

            // 検索文字列
            this.mRecentFindTextList =
                Properties.Settings.Default.RecentFindTextList?.Cast<string>().ToList() ??
                new List<string>();
            this.mComboBoxFindText.Items.AddRange(this.mRecentFindTextList.ToArray<object>());

            // 置換文字列
            this.mRecentReplaceTextList =
                Properties.Settings.Default.RecentReplaceTextList?.Cast<string>().ToList() ??
                new List<string>();
            this.mComboBoxReplaceText.Items.AddRange(this.mRecentReplaceTextList.ToArray<object>());

            // 検索対象
            this.mComboBoxSearchScope.SelectedItem =
                this.mComboBoxSearchScope.Items.Cast<string>()
                    .FirstOrDefault(item => item == this.mSearchScopeDictionary[SearchScope.CurrentDocument]);

            // 検索オプション
            FindOptions findOptions = (FindOptions)Properties.Settings.Default.FindOptions;
            this.mCheckBoxWholeWord.Checked = findOptions.HasFlag(FindOptions.MatchWholeWordOnly);
            this.mCheckBoxMatchCase.Checked = findOptions.HasFlag(FindOptions.MatchCase);
            this.mCheckBoxWrapAround.Checked = findOptions.HasFlag(FindOptions.WrapAround);

            // 検索モード
            FindMode findMode = (FindMode)Properties.Settings.Default.FindMode;

            switch (findMode) {
                case FindMode.Normal:
                    this.mRadioButtonFindModeNormal.Checked = true;
                    break;
                case FindMode.EscapeSequence:
                    this.mRadioButtonFindModeEscapeSequence.Checked = true;
                    break;
                case FindMode.RegularExpression:
                    this.mRadioButtonFindModeRegularExpression.Checked = true;
                    break;
                default:
                    this.mRadioButtonFindModeNormal.Checked = true;
                    break;
            }

            // 検索方向
            FindDirection findDirection = (FindDirection)Properties.Settings.Default.FindDirection;
            switch (findDirection) {
                case FindDirection.Up:
                    this.mRadioButtonFindDirectionUp.Checked = true;
                    break;
                case FindDirection.Down:
                    this.mRadioButtonFindDirectionDown.Checked = true;
                    break;
                default:
                    this.mRadioButtonFindDirectionDown.Checked = true;
                    break;
            }

            // ウィンドウの透明化
            this.mCheckBoxTransparent.Checked = Properties.Settings.Default.FindDialogTransparent;
            this.OnCheckBoxTransparentCheckedChanged(this, EventArgs.Empty);

            FindDialogTransparentMode transparentMode =
                    (FindDialogTransparentMode)Properties.Settings.Default.FindDialogTransparentMode;

            switch (transparentMode) {
                case FindDialogTransparentMode.OnLosingFocus:
                    this.mRadioButtonTransparentOnLosingFocus.Checked = true;
                    break;
                case FindDialogTransparentMode.Always:
                    this.mRadioButtonTransparentAlways.Checked = true;
                    break;
                default:
                    this.mRadioButtonTransparentOnLosingFocus.Checked = true;
                    break;
            }

            this.mTrackBarTransparency.Value =
                Math.Min(100, Math.Max(5, Properties.Settings.Default.FindDialogOpacity));

            // イベント ハンドラー
            this.mMainForm.DockPanel.ActiveDocumentChanged += this.OnDockPanelActiveDocumentChanged;

            this.Activated += this.OnFormActivated;
            this.Deactivate += this.OnFormDeactivate;

            this.mTabControl.SelectedIndexChanged += this.OnTabControlSelectedIndexChanged;

            this.mComboBoxFindText.TextChanged += this.OnComboBoxFindTextChanged;

            this.mComboBoxSearchScope.DropDown += this.OnComboBoxSearchScopeDropDown;

            this.mButtonFindNext.Click += this.OnButtonFindNextClick;
            this.mButtonCount.Click += this.OnButtonCountClick;
            this.mButtonFindAll.Click += this.OnButtonFindAllClick;
            this.mButtonFindAllDocuments.Click += this.OnButtonFindAllDocumentsClick;
            this.mButtonClose.Click += this.OnButtonCloseClick;

            this.mButtonReplace.Click += this.OnButtonReplaceClick;
            this.mButtonReplaceAll.Click += this.OnButtonReplaceAllClick;
            this.mButtonReplaceAllDocuments.Click += this.OnButtonReplaceAllDocumentsClick;

            // 検索オプション
            this.mCheckBoxWholeWord.CheckedChanged += this.OnCheckBoxWholeWordCheckedChanged;
            this.mCheckBoxMatchCase.CheckedChanged += this.OnCheckBoxMatchCaseCheckedChanged;
            this.mCheckBoxWrapAround.CheckedChanged += this.OnCheckBoxWrapAroundCheckedChanged;

            // 検索モード
            this.mRadioButtonFindModeNormal.CheckedChanged += this.OnRadioButtonFindModeNormalCheckedChanged;
            this.mRadioButtonFindModeEscapeSequence.CheckedChanged += this.OnRadioButtonFindModeEscapeSequenceCheckedChanged;
            this.mRadioButtonFindModeRegularExpression.CheckedChanged += this.OnRadioButtonFindModeRegularExpressionCheckedChanged;

            // 検索方向
            this.mRadioButtonFindDirectionUp.CheckedChanged += this.OnRadioButtonFindDirectionUpCheckedChanged;
            this.mRadioButtonFindDirectionDown.CheckedChanged += this.OnRadioButtonFindDirectionDownCheckedChanged;

            // ウィンドウの透明化
            this.mCheckBoxTransparent.CheckedChanged += this.OnCheckBoxTransparentCheckedChanged;
            this.mRadioButtonTransparentOnLosingFocus.CheckedChanged += this.OnRadioButtonTransparentOnLosingFocusCheckedChanged;
            this.mRadioButtonTransparentAlways.CheckedChanged += this.OnRadioButtonTransparentAlwaysCheckedChanged;
            this.mTrackBarTransparency.ValueChanged += this.OnTrackBarTransparencyValueChanged;
        }
Ejemplo n.º 10
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;
        }
Ejemplo n.º 11
0
        private TextEditorForm GetNextTextEditorForm(TextEditorForm currentForm)
        {
            if (currentForm == null || currentForm.IsDisposed) {
                return null;
            }

            int foundDockPaneIndex = Int32.MinValue;
            int foundDockContentIndex = Int32.MinValue;

            for (int dockPaneIndex = 0;
                dockPaneIndex < this.DockPanel.Panes.Count; dockPaneIndex++) {
                DockPane dockPane = this.DockPanel.Panes[dockPaneIndex];

                for (int dockContentIndex = 0;
                    dockContentIndex < dockPane.Contents.Count; dockContentIndex++) {
                    IDockContent dockContent = dockPane.Contents[dockContentIndex];

                    TextEditorForm textEditorForm = dockContent as TextEditorForm;
                    if (textEditorForm == null || currentForm.IsDisposed) {
                        continue;
                    }

                    if (textEditorForm == currentForm) {
                        foundDockPaneIndex = dockPaneIndex;
                        foundDockContentIndex = dockContentIndex;

                        goto CurrentFormFound;
                    }
                }
            }

            return null;

            CurrentFormFound:

            TextEditorForm resultForm = null;

            for (int dockPaneIndex = foundDockPaneIndex;
                dockPaneIndex < this.DockPanel.Panes.Count; dockPaneIndex++) {
                DockPane dockPane = this.DockPanel.Panes[dockPaneIndex];

                for (int dockContentIndex = foundDockContentIndex + 1;
                    dockContentIndex < dockPane.Contents.Count; dockContentIndex++) {
                    IDockContent dockContent = dockPane.Contents[dockContentIndex];

                    TextEditorForm textEditorForm = dockContent as TextEditorForm;

                    if (textEditorForm != null) {
                        resultForm = textEditorForm;
                        goto ResultFormFound;
                    }
                }
            }

            for (int dockPaneIndex = 0;
                dockPaneIndex < foundDockPaneIndex + 1; dockPaneIndex++) {
                DockPane dockPane = this.DockPanel.Panes[dockPaneIndex];

                for (int dockContentIndex = 0;
                    dockContentIndex < foundDockContentIndex; dockContentIndex++) {
                    IDockContent dockContent = dockPane.Contents[dockContentIndex];

                    TextEditorForm textEditorForm = dockContent as TextEditorForm;

                    if (textEditorForm != null) {
                        resultForm = textEditorForm;
                        goto ResultFormFound;
                    }
                }
            }

            return null;

            ResultFormFound:
            return resultForm;
        }
Ejemplo n.º 12
0
        public void SaveAs(TextEditorForm textEditorForm)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.AddExtension = false; // DEBUG
            saveFileDialog.AutoUpgradeEnabled = false;
            saveFileDialog.CheckFileExists = false;
            saveFileDialog.CheckPathExists = false;
            saveFileDialog.CreatePrompt = false;
            saveFileDialog.DefaultExt = "hsp";
            saveFileDialog.FileName = string.Empty;
            saveFileDialog.Filter =
                /* "HSP ソース ファイル (*.hsp)|*.hsp|" +
                "HSP ヘッダー ファイル (*.as)|*.as|" +
                "テキスト ファイル (*.txt)|*.txt|" + */
                "すべてのファイル (*.*)|*.*";
            saveFileDialog.FilterIndex = 0;
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            saveFileDialog.OverwritePrompt = true;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.SupportMultiDottedExtensions = true;
            saveFileDialog.Title = "名前を付けて保存";
            saveFileDialog.ValidateNames = true;

            DialogResult dialogResult = saveFileDialog.ShowDialog(this);

            if (dialogResult != DialogResult.OK) {
                return;
            }

            try {
                File.WriteAllText(saveFileDialog.FileName,
                    textEditorForm.Scintilla.Text, textEditorForm.TextEncoding);
                textEditorForm.ToolTipText = saveFileDialog.FileName;
                textEditorForm.Text = $"{Path.GetFileName(saveFileDialog.FileName)}";
                textEditorForm.Scintilla.SetSavePoint();
                textEditorForm.FileName = saveFileDialog.FileName;
            } catch (Exception) {
                MessageBox.Show(
                    $"\'{saveFileDialog.FileName}\' に書きこむ際にエラーが発生しました.",
                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 13
0
 public void Save(TextEditorForm textEditorForm)
 {
     if (File.Exists(textEditorForm.FileName)) {
         try {
             File.WriteAllText(textEditorForm.FileName,
                 textEditorForm.Scintilla.Text, textEditorForm.TextEncoding);
             textEditorForm.Scintilla.SetSavePoint();
         } catch (Exception) {
             MessageBox.Show(
                 $"\'{textEditorForm.FileName}\' に書きこむ際にエラーが発生しました.",
                 Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     } else {
         this.SaveAs(textEditorForm);
     }
 }
Ejemplo n.º 14
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);
                }
            }
        }
Ejemplo n.º 15
0
        public DateTimePickerForm(TextEditorForm textEditor)
        {
			// Instance of the focused textEditor
            this.textEditor = textEditor;
            InitializeComponent();
        }
Ejemplo n.º 16
0
 private string RunTextEditor(string value)
 {
     try
       {
     TextEditorForm frm = new TextEditorForm();
     frm.RichTextBox.Text = value;
     DialogResult res = frm.ShowDialog();
     switch (res)
     {
       case DialogResult.Cancel:
     break;
       default:
     value = frm.RichTextBox.Text;
     break;
     }
       }
       catch (Exception)
       {
       }
       return value;
 }
Ejemplo n.º 17
0
        protected override void OnClosing(CancelEventArgs eventArgs)
        {
            // Win32Exception例外の防止
            this.Deactivate -= this.OnFormDeactivate;
            this.mMainForm.DockPanel.ActiveDocumentChanged -= this.OnDockPanelActiveDocumentChanged;

            if (this.mCurrentTextEditorForm != null) {
                this.mCurrentTextEditorForm.Scintilla.TextChanged -= this.OnScintillaTextChanged;
                this.mCurrentTextEditorForm.Scintilla.UpdateUI -= this.OnScintillaUpdateUI;
                this.mCurrentTextEditorForm = null;
            }

            base.OnClosing(eventArgs);
        }
Ejemplo n.º 18
0
        private void OnDockPanelActiveDocumentChanged(object sender, EventArgs eventArgs)
        {
            TextEditorForm backupTextEditorForm = this.mCurrentTextEditorForm;
            this.mCurrentTextEditorForm = this.mMainForm.GetCurrentTextEditorForm();

            this.mSearchTargetStart = FindReplace.InvalidPosition;
            this.mFound = false;
            this.mLastFound = false;
            this.UpdateComboBoxSearchScope();

            if (backupTextEditorForm != null) {
                backupTextEditorForm.Scintilla.TextChanged -= this.OnScintillaTextChanged;
                backupTextEditorForm.Scintilla.UpdateUI -= this.OnScintillaUpdateUI;
            }

            if (this.mCurrentTextEditorForm != null) {
                this.mCurrentTextEditorForm.Scintilla.TextChanged += this.OnScintillaTextChanged;
                this.mCurrentTextEditorForm.Scintilla.UpdateUI += this.OnScintillaUpdateUI;
            }
        }