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