Пример #1
0
        private void txtPage_GotFocus(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.NeutralHighlight)
            {
                highlight     = Eclectic.GetSysColor(Eclectic.COLOR_HIGHLIGHT);
                highlightText = Eclectic.GetSysColor(Eclectic.COLOR_HIGHLIGHTTEXT);

                int[] elements = { Eclectic.COLOR_HIGHLIGHT, Eclectic.COLOR_HIGHLIGHTTEXT };
                int[] colors   = { 0, 0 };

                if (txtPage.ForeColor.R > 150 | txtPage.ForeColor.G > 150 | txtPage.ForeColor.B > 150)
                {
                    colors[0] = getWin32Color(txtPage.ForeColor, -100);
                }
                else
                {
                    colors[0] = getWin32Color(txtPage.ForeColor, 100);
                }

                colors[1] = System.Drawing.ColorTranslator.ToWin32(txtPage.ForeColor);

                Eclectic.SetSysColors(elements.Length, elements, colors);
            }

            blinkRate = Eclectic.GetCaretBlinkTime();
            Eclectic.SetCaretBlinkTime(Properties.Settings.Default.CaretBlinkRate);
        }
Пример #2
0
 private void btnLineDown_MouseDown(object sender, MouseEventArgs e)
 {
     ScrollAction      = (int)Eclectic.ScrollBarActions.SB_LINEDOWN;
     tmrScroll.Enabled = true;
     Eclectic.SendMessage(txtPage.Handle, Eclectic.WM_VSCROLL, (int)Eclectic.ScrollBarActions.SB_LINEDOWN, 0);
     txtPage.Focus();
 }
Пример #3
0
        private void DarkTextBox_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.Control)             // handle control key functions
            {
                if (FormattingEnabled) // handle formating keys if formatting enabled
                {
                    if (e.KeyCode == Keys.B)
                    {
                        if (this.SelectionFont.Bold)
                        {
                            this.SelectionFont = new Font(this.SelectionFont, FontStyle.Regular);
                        }
                        else
                        {
                            this.SelectionFont = new Font(this.SelectionFont, FontStyle.Bold);
                        }
                    }
                    else if (e.KeyCode == Keys.J)
                    {
                        Eclectic.SendMessage(Handle, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY);
                    }
                }
                else // supress formating if formatting disabled
                {
                    if (e.KeyCode == Keys.L || e.KeyCode == Keys.E || e.KeyCode == Keys.R || e.KeyCode == Keys.Oem2 || e.KeyCode == Keys.Oem1)
                    {
                        e.Handled = true;
                    }
                }
            }
            else // handle if control not pressed
            {
                // handle new line
                if (e.KeyCode == Keys.Enter)
                {
                    // handle autoindent
                    if (AutoIndent & SelectionStart != 0)
                    {
                        SelectedText = "\n" + findIndentLevel();
                        e.Handled    = true;
                    }
                }

                // handle tabs to spaces
                if (e.KeyCode == Keys.Tab)
                {
                    if (TabsToSpaces > 0)
                    {
                        SendKeys.Send("{BACKSPACE}");
                        for (int i = 0; i < TabsToSpaces; i++)
                        {
                            SendKeys.Send(" ");
                        }
                    }

                    tabCount++;
                }
            }
        }
Пример #4
0
 private void txtPage_MouseWheel(object sender, MouseEventArgs e)
 {
     if (e.Delta > 0)
     {
         Eclectic.SendMessage(txtPage.Handle, Eclectic.WM_VSCROLL, (int)Eclectic.ScrollBarActions.SB_LINEUP, 0);
     }
     else
     {
         Eclectic.SendMessage(txtPage.Handle, Eclectic.WM_VSCROLL, (int)Eclectic.ScrollBarActions.SB_LINEDOWN, 0);
     }
 }
Пример #5
0
        private void txtPage_LostFocus(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.NeutralHighlight)
            {
                int[] elements = { Eclectic.COLOR_HIGHLIGHT, Eclectic.COLOR_HIGHLIGHTTEXT };
                int[] colors   = { highlight, highlightText };

                Eclectic.SetSysColors(elements.Length, elements, colors);
            }

            Eclectic.SetCaretBlinkTime(blinkRate);
        }
Пример #6
0
        private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string latest = Eclectic.CheckForUpdate();

            if (latest == System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString())
            {
                MessageBox.Show("Your version of Dark Room W is up to date.", "Update", MessageBoxButtons.OK);
            }
            else
            {
                DialogResult response = MessageBox.Show("A new version (" + latest + ") of Dark Room W is available.\n\nWould you like to download it?", "New Version Available", MessageBoxButtons.YesNo);
                if (response == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(Properties.Settings.Default.DarkRoomURL);
                }
            }
        }
Пример #7
0
        private void Init()
        {
            Int32 lStyle;

            lStyle = (int)Eclectic.TextMode.TM_RICHTEXT | (int)Eclectic.TextMode.TM_MULTILEVELUNDO | (int)Eclectic.TextMode.TM_MULTICODEPAGE;
            Eclectic.SendMessage(txtPage.Handle, Eclectic.EM_SETTEXTMODE, lStyle, 0);

            Sync();

            switch (Properties.Settings.Default.DataRecoveryMode)
            {
            case (int)Eclectic.DataRecoveryModes.BUFFER:
                txtPage.Text = RecallCache();
                break;

            case (int)Eclectic.DataRecoveryModes.LAST_FILE:
                OpenFile(Properties.Settings.Default.LastFileName);
                break;
            }

            txtPage.Select(0, 0);
            txtPage.ContextMenuStrip = contextMenuPage;
            txtPage.DetectUrls       = txtPage.FormattingEnabled;
            txtPage.AutoIndent       = Properties.Settings.Default.AutoIndent;
            txtPage.TabsToSpaces     = Properties.Settings.Default.TabToSpaces;
            txtPage.ClearUndo();
            txtPage.Modified = false;

            dlgOpen.Filter = "Text Documents (*.txt)|*.txt|All files (*.*)|*.*";
            dlgSave.Filter = "Text Documents (*.txt)|*.txt";

            if (txtPage.FormattingEnabled)
            {
                dlgOpen.Filter = "Rich Text Format (*.rtf)|*.rtf|" + dlgOpen.Filter;
                dlgSave.Filter = "Rich Text Format (*.rtf)|*.rft|" + dlgSave.Filter;
            }

            dlgSave.AddExtension = true;
            preferencesToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+,";
            statisticsToolStripMenuItem.ShortcutKeyDisplayString  = "Ctrl+/";
        }
Пример #8
0
        private void tmrScroll_Tick(object sender, EventArgs e)
        {
            switch (ScrollAction)
            {
            case (int)Eclectic.ScrollBarActions.SB_LINEDOWN:
                Eclectic.SendMessage(txtPage.Handle, Eclectic.WM_VSCROLL, (int)Eclectic.ScrollBarActions.SB_LINEDOWN, 0);
                break;

            case (int)Eclectic.ScrollBarActions.SB_PAGEDOWN:
                Eclectic.SendMessage(txtPage.Handle, Eclectic.WM_VSCROLL, (int)Eclectic.ScrollBarActions.SB_PAGEDOWN, 0);
                break;

            case (int)Eclectic.ScrollBarActions.SB_LINEUP:
                Eclectic.SendMessage(txtPage.Handle, Eclectic.WM_VSCROLL, (int)Eclectic.ScrollBarActions.SB_LINEUP, 0);
                break;

            case (int)Eclectic.ScrollBarActions.SB_PAGEUP:
                Eclectic.SendMessage(txtPage.Handle, Eclectic.WM_VSCROLL, (int)Eclectic.ScrollBarActions.SB_PAGEUP, 0);
                break;
            }
        }
Пример #9
0
        private void prtDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Font  font = txtPage.Font;
            Int32 PrintAreaHeight, PrintAreaWidth, marginLeft, marginTop;

            PrintAreaHeight = prtDoc.DefaultPageSettings.PaperSize.Height - prtDoc.DefaultPageSettings.Margins.Top - prtDoc.DefaultPageSettings.Margins.Bottom;
            PrintAreaWidth  = prtDoc.DefaultPageSettings.PaperSize.Width - prtDoc.DefaultPageSettings.Margins.Left - prtDoc.DefaultPageSettings.Margins.Right;
            marginLeft      = prtDoc.DefaultPageSettings.Margins.Left;
            marginTop       = prtDoc.DefaultPageSettings.Margins.Top;

            if (prtDoc.DefaultPageSettings.Landscape)
            {
                Int32 intTemp;
                intTemp         = PrintAreaHeight;
                PrintAreaHeight = PrintAreaWidth;
                PrintAreaWidth  = intTemp;
            }

            Int32        intLineCount     = System.Convert.ToInt32(PrintAreaHeight / font.Height);
            RectangleF   rectPrintingArea = new RectangleF(marginLeft, marginTop, PrintAreaWidth, PrintAreaHeight);
            StringFormat fmt              = new StringFormat(StringFormatFlags.LineLimit);
            Int32        intLinesFilled;
            Int32        intCharsFitted;

            e.Graphics.MeasureString(Eclectic.Mid(txtPage.Text, intCurrentChar), font, new SizeF(PrintAreaWidth, PrintAreaHeight), fmt, out intCharsFitted, out intLinesFilled);
            e.Graphics.DrawString(Eclectic.Mid(txtPage.Text, intCurrentChar), font, Brushes.Black, rectPrintingArea, fmt);
            intCurrentChar += intCharsFitted;
            if (intCurrentChar < (txtPage.Text.Length - 1))
            {
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
                intCurrentChar = 0;
            }
        }
Пример #10
0
 private void btnPageDown_Click(object sender, EventArgs e)
 {
     ScrollAction = (int)Eclectic.ScrollBarActions.SB_PAGEDOWN;
     Eclectic.SendMessage(txtPage.Handle, Eclectic.WM_VSCROLL, (int)Eclectic.ScrollBarActions.SB_PAGEDOWN, 0);
     txtPage.Focus();
 }
Пример #11
0
 private void btnPageUp_Click(object sender, EventArgs e)
 {
     ScrollAction = (int)Eclectic.ScrollBarActions.SB_PAGEUP;
     Eclectic.SendMessage(txtPage.Handle, Eclectic.WM_VSCROLL, (int)Eclectic.ScrollBarActions.SB_PAGEUP, 0);
 }