EsriLogoControl.xaml.cs
上传用户:huazai0421
上传日期:2008-05-30
资源大小:405k
文件大小:2k
源码类别:

SilverLight

开发平台:

C#

  1. using System;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Media;
  5. using System.Windows.Media.Animation;
  6. namespace ESRI.ArcGIS.Samples
  7. {
  8. /// <summary>
  9. /// ESRI logo
  10. /// </summary>
  11. public partial class EsriLogo : UserControl
  12. {
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="EsriLogo"/> class.
  15. /// </summary>
  16. public EsriLogo()
  17. {
  18. // Required to initialize variables
  19. InitializeComponent();
  20. this.SizeChanged += new SizeChangedEventHandler(EsriLogo_SizeChanged);
  21. }
  22. private void EsriLogo_SizeChanged(object sender, SizeChangedEventArgs e)
  23. {
  24. //this.RenderTransformOrigin = new Point(0.5, 0.5);
  25. double scale = Math.Min(e.NewSize.Width / 400, e.NewSize.Height / 475);
  26. this.Logo.RenderTransform = new ScaleTransform()
  27. ScaleX = scale,
  28. ScaleY = scale
  29. };
  30. }
  31. /// <summary>
  32. /// Begins the show animation.
  33. /// </summary>
  34. public void BeginShowAnimation()
  35. {
  36. Storyboard show = this.Resources["ShowKey"] as Storyboard;
  37. show.Begin();
  38. show.Completed += new EventHandler(show_Completed);
  39. }
  40. /// <summary>
  41. /// Begins the hide animation.
  42. /// </summary>
  43. public void BeginHideAnimation()
  44. {
  45. Storyboard show = this.Resources["HideKey"] as Storyboard;
  46. show.Begin();
  47. show.Completed += new EventHandler(hide_Completed);
  48. }
  49. private void show_Completed(object sender, EventArgs e)
  50. {
  51. if (ShowCompleted != null) ShowCompleted(this, new EventArgs());
  52. }
  53. private void hide_Completed(object sender, EventArgs e)
  54. {
  55. if (HideCompleted != null) HideCompleted(this, new EventArgs());
  56. }
  57. /// <summary>
  58. /// Occurs when the show animation has completed.
  59. /// </summary>
  60. public event EventHandler ShowCompleted;
  61. /// <summary>
  62. /// Occurs when the hide animation has completed.
  63. /// </summary>
  64. public event EventHandler HideCompleted;
  65. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  66. {
  67. BeginShowAnimation();
  68. }
  69. }
  70. }