bc... []

FloatPanel.cs ( File view )

  • By 2016-05-19
  • View(s):0
  • Download(s):0
  • Point(s): 1
			using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;

namespace FloatPanelDemo {

	public class FloatPanel {

		protected Popup panel = new Popup() {
 IsOpen = false 
};
		protected FrameworkElement Title = new TextBlock();

		public FloatPanel(double width, double height) {

			Application.Current.Host.Content.Resized += (sender, e) => {
 Resize(); 
};
			panel.Width = width;
			panel.MaxHeight = height;
			Resize();			
		
}
		public void Resize() {

			double positioningX = (Application.Current.Host.Content.ActualWidth / 2) - (panel.Width / 2);
			double positioningY = (Application.Current.Host.Content.ActualHeight / 2) - (panel.MaxHeight / 2);
			panel.VerticalOffset = positioningY;
			panel.HorizontalOffset = positioningX;
		
}
		public void Show() {
 panel.IsOpen = true;	
}
		public void Hide() {
 panel.IsOpen = false; 
}
		public void Close() {
 panel.IsOpen = false;	panel.Child = null;	
}
		public void SetContent(FrameworkElement content) {
 panel.Child = StandardVisualization(content); 
}
		public void SetTitle(object title) {

			if (title == null)
				return;
			Title = title is FrameworkElement ? title as FrameworkElement : new TextBlock() {
 Text = title.ToString(), TextWrapping = TextWrapping.Wrap 
};
			Title.VerticalAlignment = VerticalAlignment.Center;
			Title.HorizontalAlignment = HorizontalAlignment.Left;
		
}
		protected virtual FrameworkElement StandardVisualization(FrameworkElement content) {

			TextBlock tbExit = new TextBlock() {
 Text = "x", VerticalAlignment = VerticalAlignment.Center 
};
			Border bExit = new Border() {
 Child = tbExit, HorizontalAlignment = HorizontalAlignment.Right, Cursor = Cursors.Hand, BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(3), Padding = new Thickness(4, 0, 4, 0), Margin = new Thickness(2, 0, 0, 2) 
};
			bExit.MouseLeftButtonUp += (sender, e) => {
 Close(); 
};

			Border bTitle = new Border() {
 Child = Title, HorizontalAlignment = HorizontalAlignment.Stretch, BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(0, 0, 0, 1), CornerRadius = new CornerRadius(0), Padding = new Thickness(4, 0, 4, 0), Margin = new Thickness(0, 0, 0, 2) 
};

			Grid gMain = new Grid();
			gMain.RowDefinitions.Add(new RowDefinition() {
 Height = GridLength.Auto 
});
			gMain.RowDefinitions.Add(new RowDefinition() {
 Height = new GridLength(1, GridUnitType.Star) 
});
			gMain.ColumnDefinitions.Add(new ColumnDefinition() {
 Width = new GridLength(1, GridUnitType.Star) 
});
			gMain.ColumnDefinitions.Add(new ColumnDefinition() {
 Width = GridLength.Auto 
});
			gMain.Children.Add(bTitle);
			gMain.Children.Add(bExit);
			gMain.Children.Add(content);
			Grid.SetRow(bTitle, 0);
			Grid.SetColumn(bTitle, 0);
			Grid.SetRow(bExit, 0);
			Grid.SetColumn(bExit, 1);
			Grid.SetRow(content, 1);
			Grid.SetColumn(content, 0);
			Grid.SetColumnSpan(content, 2);

			Border b = new Border() {
 Background = new SolidColorBrush(Colors.White), BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(3), Padding = new Thickness(2) 
};
			b.Child = gMain;
			b.Width = panel.Width;
			b.MaxHeight = panel.MaxHeight;
			return b;
		
}
	
}

}
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
01.96 kB
democode.png15.50 kB2012-01-13 10:15
01.96 kB
FloatPanelDemo.sln2.38 kB2012-01-13 09:01
FloatPanelDemo.suo27.00 kB2012-01-13 10:29
01.96 kB
01.96 kB
FloatPanelDemo.xap5.55 kB2012-01-13 10:13
FloatPanelDemoTestPage.aspx2.87 kB2012-01-13 09:01
FloatPanelDemoTestPage.html2.81 kB2012-01-13 09:01
Silverlight.js7.50 kB2009-05-14 13:08
web.config312.00 B2012-01-13 09:01
App.xaml297.00 B2012-01-13 09:01
App.xaml.cs1.97 kB2012-01-13 09:01
01.96 kB
01.96 kB
AppManifest.xaml365.00 B2012-01-13 09:16
FloatPanelDemo.dll13.00 kB2012-01-13 10:13
FloatPanelDemo.pdb35.50 kB2012-01-13 10:13
FloatPanelDemo.xap5.55 kB2012-01-13 10:13
FloatPanelDemoTestPage.html2.78 kB2012-01-13 10:13
ContentDemo.xaml1.56 kB2012-01-13 10:11
ContentDemo.xaml.cs453.00 B2012-01-13 10:07
01.96 kB
FloatPanelDemo.csproj4.99 kB2012-01-13 10:10
FloatPanelDemo.csproj.user1.12 kB2012-01-13 10:10
FloatPanel.cs3.32 kB2012-01-13 10:29
MainPage.xaml477.00 B2012-01-13 09:01
MainPage.xaml.cs321.00 B2012-01-13 10:13
01.96 kB
01.96 kB
App.g.cs1.79 kB2012-01-13 09:01
App.g.i.cs1.79 kB2012-01-13 09:01
ContentDemo.g.cs1.98 kB2012-01-13 10:11
ContentDemo.g.i.cs1.98 kB2012-01-13 10:11
DesignTimeResolveAssemblyReferences.cache4.53 kB2012-01-13 10:11
DesignTimeResolveAssemblyReferencesInput.cache5.50 kB2012-01-13 10:13
FloatPanelDemo.csproj.FileListAbsolute.txt1.46 kB2012-01-13 10:10
FloatPanelDemo.dll13.00 kB2012-01-13 10:13
FloatPanelDemo.g.resources2.62 kB2012-01-13 10:11
FloatPanelDemo.pdb35.50 kB2012-01-13 10:13
MainPage.g.cs1.97 kB2012-01-13 09:01
MainPage.g.i.cs1.97 kB2012-01-13 09:01
SilverlightControl1.g.i.cs2.00 kB2012-01-13 10:06
01.96 kB
XapCacheFile.xml644.00 B2012-01-13 10:13
01.96 kB
AppManifest.xml207.00 B2012-01-13 09:01
AssemblyInfo.cs1.37 kB2012-01-13 09:01
overview.png28.22 kB2012-01-13 10:13
...

FloatPanel.cs (104.68 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D