WPF case (iv) simulating the WINDOWS7 desktop taskbar

Source: Internet
Author: User

Original: WPF case (iv) simulating WINDOWS7 desktop taskbar

This program is modeled as a Windows7 desktop taskbar, when you double-click a shortcut on the desktop, a new sub-interface opens, and a taskbar icon in the taskbar that links to this interface is created, and when you move the mouse to the icon on the taskbar, a real-time image thumbnail of the screen appears. When you click the taskbar icon, you can maximize or minimize the interface, as shown below, the source is downloaded from here

When you make this taskbar interface thumbnail, use VisualBrush to populate the real-time image of the sub-interface to Rectangle

1Rectangle Emptyrectangle= NewRectangle
2 {
3Width=250D,
4Height=130D,
5Fill= NewVisualBrush {Visual=Child },
6Margin= NewThickness (2)
7  };

Two border were used to Windows7 the corners of the taskbar thumbnail.

using rounded corners  //apply a fillet to the popup interface thumbnail of the taskbar
Border Visualborder= NewBorder
{
BorderBrush=Brushes.transparent,
BorderThickness= NewThickness (1),
Cornerradius= NewCornerradius (Ten),
Margin= NewThickness (Ten),
Height=150D,
Width=270D,
Child=Emptyrectangle,
HorizontalAlignment=HorizontalAlignment.Center,
VerticalAlignment=Verticalalignment.center,
Background=  This. FindResource ("TransparentColor")                      asLinearGradientBrush
};
//apply rounded corners to the background of the popup interface thumbnail of the taskbar
Border Host= NewBorder
{
BorderBrush=Brushes.transparent,
BorderThickness= NewThickness (1),
Cornerradius= NewCornerradius (8),
Child=Visualborder,
HorizontalAlignment=HorizontalAlignment.Center,
VerticalAlignment=Verticalalignment.center,
Background=  This. FindResource ("Thumbnailbackground")                           asImageBrush
};

Defines a tooltip used to host the interface of the thumbnail image

ToolTip  //add a ToolTip to host the child interface's thumb
ToolTip Visualtooltip= NewToolTip
{
Content=Host,
Background=Brushes.transparent,
BorderBrush=Brushes.transparent,
Placement=Placementmode.top,
Horizontalcontentalignment=HorizontalAlignment.Center,
Verticalcontentalignment=Verticalalignment.center,
Hasdropshadow= false,
Verticaloffset=3
};
//the popup delay time for the design tooltip is 20ms
tooltipservice.setinitialshowdelay (thumbnail, -);
Thumbnail. ToolTip=Visualtooltip;

Define the event, when the sub-interface is closed, remove the icon from the taskbar on the taskbar to maximize or minimize the interface when you click on the taskbar icon

Defining Events //You need to remove the icon from the taskbar on the taskbar when the sub-interface is turned off
Child . Closed+= Delegate
{
This. StatusBar.Children.Remove (Hostborder);
};
//Maximize or minimize sub-interfaces when you click the task icon on the taskbar
Hostborder.mouseleftbuttondown+= Delegate(Objectsender, MouseButtonEventArgs e)
{
if(E.clickcount== 1)
{
if(child. WindowState==windowstate.minimized)
{
//Normal display sub-interface
Child . WindowState=Windowstate.normal;
Child. Topmost= true;
}
Else
//minimizing sub-interfaces
Child . WindowState=windowstate.minimized;
}
};

This program is simple to implement, but it is important to note that when you add a sub-interface taskbar icon to the taskbar, you should add it from the top down order to avoid repeating the sub-leaf points of the Rendering logical tree.

WPF case (iv) simulating the WINDOWS7 desktop taskbar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.