Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
AnswerRe: Image (Bitmap) Brightness/Contrast Pin
lexx_zone14-Jul-09 8:38
lexx_zone14-Jul-09 8:38 
QuestionBest method for syntax highlighting Pin
WebMaster14-Jul-09 6:36
WebMaster14-Jul-09 6:36 
AnswerRe: Best method for syntax highlighting Pin
Luc Pattyn14-Jul-09 7:31
sitebuilderLuc Pattyn14-Jul-09 7:31 
GeneralRe: Best method for syntax highlighting [modified] Pin
WebMaster14-Jul-09 8:45
WebMaster14-Jul-09 8:45 
GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn14-Jul-09 15:19
sitebuilderLuc Pattyn14-Jul-09 15:19 
GeneralRe: Best method for syntax highlighting Pin
WebMaster14-Jul-09 20:47
WebMaster14-Jul-09 20:47 
GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn15-Jul-09 0:03
sitebuilderLuc Pattyn15-Jul-09 0:03 
GeneralRe: Best method for syntax highlighting Pin
WebMaster15-Jul-09 1:24
WebMaster15-Jul-09 1:24 
You don't got some kind of instant messager? I'd be much easier for me.
Ehhh, I'm kinda stuck at the Caret thingy... How do I convert text locations to Points?

Code:
//*****************************************
//*      Storm.TextBox.Document.Caret     *
//*   Storm.TextBox.dll (c) Vestras 2009  *
//*                                       *
//*    Caret.cs - a class used for        *
//*    displaying a caret for the user.   *
//*                                       *
//* Copyright (c) Theodor Storm 2009      *
//*****************************************

namespace Storm.TextBox.Document
{
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    public class Caret : Control
    {
        #region Members
        // Timer for displaying the caret.
        private Timer caretTimer = new Timer();

        // Timer members.
        private int Interval = 50;

        // Display members.
        private string caretString = "|";
        private Font caretFont = new Font(new Font("Courier New", 9.25f), FontStyle.Bold);
        private Color caretColor = SystemColors.ControlText;
        private bool caretDisplay = true; // The member for showing and hiding the caret
                                          // every Interval miliseconds.

        // Caret position and size members
        private Point caretPos = new Point(-1, -1);
        private Size caretSize;
        #endregion

        #region Properties
        /// <summary>
        /// Gets or sets the font of the caret.
        /// </summary>
        public Font CaretFont
        {
            get { return caretFont; }
            set { caretFont = value; }
        }

        /// <summary>
        /// Gets or sets the string that the caret "contains".
        /// </summary>
        public string DisplayString
        {
            get { return caretString; }
            set { caretString = value; }
        }

        /// <summary>
        /// Gets or sets the interval of the timer that displays the caret.
        /// </summary>
        public int CaretInterval
        {
            get { return Interval; }
            set { Interval = value; }
        }
        #endregion

        #region Methods
        private void onTick(object sender, EventArgs e)
        {
            caretDisplay = !caretDisplay;
            Invalidate();
        }

        private void DrawCaret(Graphics g)
        {
            if (caretDisplay == true)
            {
                Rectangle r = new Rectangle(caretPos, caretSize);
                ControlPaint.DrawStringDisabled(g, caretString, caretFont, caretColor, r, TextFormatFlags.Default);
            }
        }

        private void onPaint(object sender, PaintEventArgs e)
        {
            DrawCaret(e.Graphics);
        }


        #endregion

        /// <summary>
        /// Initialize the caret.
        /// </summary>
        public Caret()
        {
            Paint += new PaintEventHandler(onPaint);

            caretTimer.Enabled = true;
            caretTimer.Tick += new EventHandler(onTick);
            caretTimer.Start();
        }
    }
}

GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn15-Jul-09 1:43
sitebuilderLuc Pattyn15-Jul-09 1:43 
GeneralRe: Best method for syntax highlighting Pin
WebMaster15-Jul-09 1:56
WebMaster15-Jul-09 1:56 
GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn15-Jul-09 2:03
sitebuilderLuc Pattyn15-Jul-09 2:03 
GeneralRe: Best method for syntax highlighting Pin
WebMaster15-Jul-09 2:33
WebMaster15-Jul-09 2:33 
GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn15-Jul-09 2:44
sitebuilderLuc Pattyn15-Jul-09 2:44 
GeneralRe: Best method for syntax highlighting Pin
WebMaster15-Jul-09 3:23
WebMaster15-Jul-09 3:23 
GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn15-Jul-09 3:29
sitebuilderLuc Pattyn15-Jul-09 3:29 
GeneralRe: Best method for syntax highlighting Pin
WebMaster15-Jul-09 4:05
WebMaster15-Jul-09 4:05 
GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn15-Jul-09 4:20
sitebuilderLuc Pattyn15-Jul-09 4:20 
GeneralRe: Best method for syntax highlighting Pin
WebMaster15-Jul-09 4:44
WebMaster15-Jul-09 4:44 
GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn15-Jul-09 5:16
sitebuilderLuc Pattyn15-Jul-09 5:16 
GeneralRe: Best method for syntax highlighting Pin
WebMaster15-Jul-09 6:11
WebMaster15-Jul-09 6:11 
GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn15-Jul-09 6:23
sitebuilderLuc Pattyn15-Jul-09 6:23 
GeneralRe: Best method for syntax highlighting Pin
WebMaster15-Jul-09 6:37
WebMaster15-Jul-09 6:37 
GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn15-Jul-09 6:43
sitebuilderLuc Pattyn15-Jul-09 6:43 
GeneralRe: Best method for syntax highlighting Pin
WebMaster15-Jul-09 8:34
WebMaster15-Jul-09 8:34 
GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn15-Jul-09 8:40
sitebuilderLuc Pattyn15-Jul-09 8:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.