Saturday, September 25, 2010

Visual Basic to create "five star" level control





Figure 1 "five-star" level control

This control looks great and provides a good graphical way to view the grade, but according to editorial experience, I find it especially cool. When the mouse hover over the bar when, Windows Media Player highlights one of the stars to show you the current float of its value on the bar, thus providing a good graphical feedback. In a variety of Web sites (including Netflix and Amazon), you can find the same type of user interface, and I think in their own applications have this feature, so I decided to create my own control. I'll use Windows Forms controls that the user interface elements to simulate the same time try to make it custom with sufficient capacity to be used in various environments.

Getting Started

The first step is to create a new Class Library project to hold the controls and empty Windows application to a test project. Although the Windows Control Library project template appears to be more appropriate, and it is well to work, but by default, the project includes user controls (user controls 鈹?General for composite control contains one or more controls for Windows Forms control), and I need is an empty class file. Next, you must present a new empty class inherits from the System.Windows.Forms.Control, which simply add a single class declaration can be achieved:

Public Class Ratings
Inherits System.Windows.Forms.Control End Class

If you try to use only IntelliSense? Add Inherits statement, will encounter a small problem: use Class Library template to start your project will not add a reference to the System.Windows.Forms assembly, so you need to manually add. At this point, be the first to add a reference to an System.Drawing.dll, because the final drawing to use custom controls. From now on, I generally follow the following steps to carry out all of the control development:

1. To add custom drawing control standards constructor, set the control style of all the necessary controls in order to correct the drawing and smooth as possible.

Public Sub New ()
Me.SetStyle (ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle (ControlStyles.DoubleBuffer, True)
Me.SetStyle (ControlStyles.ResizeRedraw, True)
Me.SetStyle (ControlStyles.UserPaint, True)
...''Add any additional initialization code here
End Sub

2. Paper record configuration control behavior and appearance may need to list the public properties.

3. All these attributes add to the private member variable (I prefer to use Hungarian notation in front of each variable to add the prefix "m_" to represent the internal variables), and includes the appropriate default values, as shown below.

Private m_FilledImage As Image
Private m_EmptyImage As Image
Private m_HoverImage As Image
Private m_ImageCount As Integer = 5
Private m_TopMargin As Integer = 2
Private m_LeftMargin As Integer = 4
Private m_BottomMargin As Integer = 2
Private m_RightMargin As Integer = 4
Private m_ImageSpacing As Integer = 8
Private m_ImageToDraw As Integer = 1
Private m_SelectedColor As Color = Color.Empty
Private m_HoverColor As Color = Color.Empty
Private m_EmptyColor As Color = Color.Empty
Private m_OutlineColor As Color = Color.Empty

Private m_selectedItem As Integer = 3
Private m_hoverItem As Integer = 1
Private m_hovering As Boolean = False

Private ItemAreas () As Rectangle

4. The properties of these variables into the process, although most of the process is fairly simple (get value, set value), but some of the process will require some additional code, I will discuss later.

5. Began to design and custom graphics code.

6. Finally, add a new event, such as clicking a specific control process or the requirements of the specific event.

The default value of properties with a specific routine

I want some of my properties

鈹?handling those attributes of color

鈹?reflect the control of other properties of the default values (such as ForeColor) and to reflect the user's system color of other values. For example, let us use only one of them can produce color HoverColor to see the default value of different methods.

The first is obvious, just in the variable declaration (or constructor) to set default values:

Private m_HoverColor As Color = _
Color.FromKnownColor (KnownColor.Highlight)

In most cases, this can work well, but there are two problems. The first question is, if the user running the application to change their system colors, how to do? After you restart the program, the control will reflect the correct color, but was not. The second question is, if the user to programmatically set the color to the default colors, how to do? There is no practical way to clear the color settings and set it to the appropriate system color. Users will naturally be set correctly for the appropriate system color, but then will return to first question. Another method is to color changes in the user's system when the traps, and the corresponding changes to your property value:

Protected Overrides Sub OnSystemColorsChanged (_
ByVal e As System.EventArgs)
Me.HoverColor = Color.FromKnownColor (KnownColor.Highlight)
Me.Invalidate ()







相关链接:



OGM to AVI



Art - Screen SAVERS Report



Photoshop plug-in filters



Strawberry Splendor



Bitter Start, the result of joy



ASF to MPG



DivX to IPod



ADO programming in the definition of the problem ENCOUNTERED by ATL



To Yushu in Qinghai Province earthquake in mourning the dead and injured



3DS MAX And Some Basic Materials And Practical Examples Of Parameters



My favorite Graphic Viewers



251 hospitals and Receive Paperless



Articles about Games Arcade



symantec will be extended to the Exchange platform



"Dream Zhu Xian," Common Sense To Make Money: What Equipment The Most Valuable?



Top E-Mail List Management



GGhost A Key Recovery 09.03.08



Thursday, September 16, 2010

The official version of Opera 10 September 1 showing the speed will increase 40%



August 28 News, Opera announced that desktop browser Opera 10 RC official version of the first edition in September 1 for download, the official version of Opera 9.6 with the new version of high-intensive processing resources, such as Gmail and Facebook pages, etc. , will be 40% faster.

Opera company said in response to an increasing number of mobile internet users disturbing network traffic congestion, Opera 10 launch of Opera Turbo function, the limited bandwidth can improve the website speed, so play site has a higher rate of family and play the net efficiency. In addition, the site developers can use the network to enjoy the font, RGBA / HSLA colors and SVG support.

In addition, Opera browser built-in mail software Opera Mail also features a substantial revision and improvement; Opera 10 improved the tabbed browsing feature that allows users to adjust the network to see page thumbnails, and adjusted according to personal preferences making the page size, up and down and left and right position.







Recommended links:



About Groovy and Grails



IME TOOL to input more obedient



E-cology in the Pan Micro Series 27



Popular technique - the production of waterlines banner



The "Page SETUP" Come Right menu



DDOS DDOS Tracking The Introduction And



Ps3 mov



Windows Media Player M4v



video format for ps3



Hot JAVA And JavaScript



"Batman Arkham asylum" after Playing a little bit of getting



youtube On xbox 360



My Favorite Printer



Big Rabbit - Yuan Colombia