Пример #1
0
 protected override void OnStyleChanged()
 {
     eDotNetBarStyle effectiveStyle = this.EffectiveStyle;
     if (effectiveStyle == eDotNetBarStyle.Office2010)
     {
         if (_WindowIcon == null)
         {
             _IconSeparator = new Separator("sys_caption_separator");
             _IconSeparator.SetSystemItem(true);
             _IconSeparator.DesignTimeVisible = false;
             _IconSeparator.CanCustomize = false;
             _CaptionContainer.SubItems._Add(_IconSeparator, 0);
             _WindowIcon = new SystemCaptionItem();
             _WindowIcon.Name = "sys_caption_icon";
             _WindowIcon.Enabled = false;
             _WindowIcon.Style = this.Style;
             _WindowIcon.IsSystemIcon = true;
             _WindowIcon.DesignTimeVisible = false;
             _WindowIcon.CanCustomize = false;
             _WindowIcon.QueryIconOnPaint = true;
             _WindowIcon.MouseDown += WindowIconMouseDown;
             _WindowIcon.DoubleClick += WindowIconDoubleClick;
             _CaptionContainer.SubItems._Add(_WindowIcon, 0);
         }
     }
     else if (effectiveStyle == eDotNetBarStyle.Windows7)
     {
         if (_WindowIcon == null)
         {
             _IconSeparator = new Separator("sys_caption_separator");
             _IconSeparator.FixedSize = new Size(3, 12);
             _IconSeparator.SetSystemItem(true);
             _IconSeparator.DesignTimeVisible = false;
             _IconSeparator.CanCustomize = false;
             _CaptionContainer.SubItems._Add(_IconSeparator, 0);
             _WindowIcon = new SystemCaptionItem();
             _WindowIcon.Name = "sys_caption_icon";
             _WindowIcon.Enabled = false;
             _WindowIcon.Style = this.Style;
             _WindowIcon.IsSystemIcon = true;
             _WindowIcon.QueryIconOnPaint = true;
             _WindowIcon.DesignTimeVisible = false;
             _WindowIcon.CanCustomize = false;
             _WindowIcon.MouseDown += WindowIconMouseDown;
             _CaptionContainer.SubItems._Add(_WindowIcon, 0);
         }
     }
     else if (effectiveStyle == eDotNetBarStyle.Metro)
     {
         if (_WindowIcon == null)
         {
             _IconSeparator = new Separator("sys_caption_separator");
             _IconSeparator.FixedSize = new Size(3, 14);
             _IconSeparator.SetSystemItem(true);
             _IconSeparator.DesignTimeVisible = false;
             _IconSeparator.CanCustomize = false;
             _CaptionContainer.SubItems._Add(_IconSeparator, 0);
             _WindowIcon = new SystemCaptionItem();
             _WindowIcon.Name = "sys_caption_icon";
             _WindowIcon.Enabled = false;
             _WindowIcon.Style = this.Style;
             _WindowIcon.IsSystemIcon = true;
             _WindowIcon.DesignTimeVisible = false;
             _WindowIcon.CanCustomize = false;
             _WindowIcon.QueryIconOnPaint = true;
             _WindowIcon.MouseDown += WindowIconMouseDown;
             _WindowIcon.DoubleClick += WindowIconDoubleClick;
             _CaptionContainer.SubItems._Add(_WindowIcon, 0);
         }
     }
     else if (_WindowIcon != null)
     {
         if (_CaptionContainer.SubItems.Contains(_WindowIcon))
             _CaptionContainer.SubItems._Remove(_WindowIcon);
         _WindowIcon.MouseDown -= WindowIconMouseDown;
         _WindowIcon.DoubleClick -= WindowIconDoubleClick;
         _WindowIcon.Dispose();
         _WindowIcon = null;
         if (_CaptionContainer.SubItems.Contains(_IconSeparator))
             _CaptionContainer.SubItems._Remove(_IconSeparator);
         _IconSeparator.Dispose();
         _IconSeparator = null;
     }
     base.OnStyleChanged();
 }