Click here to Skip to main content
15,895,462 members
Articles / Desktop Programming / Windows Forms

Photoshop-Style Angle and Altitude Selectors

Rate me:
Please Sign up or sign in to vote.
4.97/5 (25 votes)
26 Apr 2008CPOL6 min read 59.1K   1.7K   63  
C# custom controls with the look and functionaliy of Photoshop's angle selectors.
//Downloaded from
//Visual C# Kicks - http://vckicks.110mb.com
//The Code Project - http://www.codeproject.com

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TestApp
{
    public partial class RunForm : Form
    {
        public RunForm()
        {
            InitializeComponent();
        }

        //Angle Selector
        private void angleSelector1_AngleChanged()
        {
            txtAngle1.Text = angleSelector1.Angle.ToString();
        }

        private void txtAngle1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "\\d+"))
                e.Handled = true;                
        }

        private void txtAngle1_KeyUp(object sender, KeyEventArgs e)
        {
            angleSelector1.Angle = int.Parse(txtAngle1.Text);
        }

        //Angle and Altitude Selector
        private void angleAltitudeSelector1_AngleChanged()
        {
            txtAngle2.Text = angleAltitudeSelector1.Angle.ToString();
        }

        private void angleAltitudeSelector1_AltitudeChanged()
        {
            txtAltitude.Text = angleAltitudeSelector1.Altitude.ToString();
        }       

        private void txtAngle2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "\\d+"))
                e.Handled = true;                
        }

        private void txtAltitude_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "\\d+"))
                e.Handled = true;                
        }

        private void txtAngle2_KeyUp(object sender, KeyEventArgs e)
        {
            angleAltitudeSelector1.Angle = int.Parse(txtAngle2.Text);
        }

        private void txtAltitude_KeyUp(object sender, KeyEventArgs e)
        {
            angleAltitudeSelector1.Altitude = int.Parse(txtAltitude.Text);
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.codeproject.com");
        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://vckicks.110mb.com");
        }                
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
Visit Visual C# Kicks for more free C#.NET articles, resources, and downloads at
http://www.vcskicks.com

Comments and Discussions