- xplorerbar_src.zip
- XPlorerBar_src
- XPlorerBar.DemoApp.sln
- XPlorerBar.DemoApp
- App.xaml
- App.xaml.cs
- Converters
- Extra_BindingMode
- Extra_ThemeManagement
- Images
- codeproject120x60.gif
- Computer16.png
- Copy16.png
- CreateFolder16.png
- Delete16.png
- MailFile16.png
- Move16.png
- MusicOnLine16.png
- MyComputer16.png
- MyDocuments16.png
- MyMusic32.png
- MyNetwork16.png
- MyPictures16.png
- MyPictures32.png
- MyPictures48.png
- NetworkFavorites16.png
- OrderPictures16.png
- PlayAll16.png
- PrintPictures16.png
- PublishFolder16.png
- Rename16.png
- SharedMusic16.png
- ShareFolder16.png
- SlideShow16.png
- MainWindow.xaml
- MainWindow.xaml.cs
- Properties
- Resources
- Images
- Folder16.png
- MyComputer16.png
- NetworkPlaces16.png
- PicturePrint16.png
- PictureTasks32.png
- PictureTasksMono48.png
- PrintsOnline16.png
- SlideShow16.png
- Skins
- XPlorerBar.DemoApp.csproj
- XPlorerBar.Documentation
- XPlorerBarDocumentationProject.shfb
- XPlorerBar.Library
- XPlorerBar.VisualStudio.Design
- xplorerbar_demo.zip
- XPlorerBar_demo
- ZonaTools.XPlorerBar.DemoApp.exe
- ZonaTools.XPlorerBar.dll
- ZonaTools.XPlorerBar.Documentation.chm
|
#region [ Copyright © 2008, Zona-Tools, all rights reserved. ]
/*
*
This source code is licensed under the Code Project Open License (CPOL).
Check out http://www.codeproject.com/info/cpol10.aspx for further details.
*
*/
#endregion
#region [ Using namespaces ]
using System;
using System.Windows;
using Microsoft.Windows.Design.Interaction;
using Microsoft.Windows.Design.Model;
#endregion
namespace ZonaTools.XPlorerBar.VisualStudio.Design
{
/// <summary>
/// Provides an adorner on any selected XPlorerBar object.
/// </summary>
public class XPlorerBarAdornerProvider : PrimarySelectionAdornerProvider
{
#region [ Fields ]
//ModelItem representation of the selected control
private ModelItem m_adornedControlModel;
//Adorner look and feel
private DesignTimeGlyph m_designTimeGlyph;
//Panel that holds design-time adorners
private AdornerPanel m_xplorerBarAdornerPanel;
#endregion
#region [ Properties ]
/// <summary>
/// Public accessor of the panel that holds the design-time adorners
/// </summary>
public AdornerPanel Panel
{
get
{
//If the panel does not exist
if (this.m_xplorerBarAdornerPanel == null)
{
//Creates it
m_xplorerBarAdornerPanel = new AdornerPanel();
m_xplorerBarAdornerPanel.Children.Add(m_designTimeGlyph);
//and adds it to the adorners collection
this.Adorners.Add(m_xplorerBarAdornerPanel);
}
return m_xplorerBarAdornerPanel;
}
}
#endregion
#region [ Constructor ]
//===========================================================================
/// <summary>
/// Default constructor.
/// </summary>
//===========================================================================
public XPlorerBarAdornerProvider()
{
//Creates a design-time glyph
m_designTimeGlyph = new DesignTimeGlyph();
}
#endregion
#region [ Creates and sets up the panel that holds the adorners ]
//===========================================================================
/// <summary>
/// Creates an <c>AdornerPanel</c> to host controls, which act as adorners
/// for the selected control, sets up the panel and attaches a
/// <c>ModelItem</c> to the adorned control.
/// </summary>
/// <param name="item">A <c>ModelItem</c> representing the adorned element.
/// </param>
/// <param name="view">An instance of the adorned element.</param>
//===========================================================================
protected override void Activate(ModelItem item, DependencyObject view)
{
//Saves the ModelItem (adorned element) and handles its changes
m_adornedControlModel = item;
m_adornedControlModel.PropertyChanged +=
new System.ComponentModel.PropertyChangedEventHandler(m_adornedControlModel_PropertyChanged);
//Gets the adorner panel
AdornerPanel adornerPanel = this.Panel;
//Sets the size of the design-time glyph
AdornerPanel.SetHorizontalStretch(m_designTimeGlyph, AdornerStretch.Scale);
AdornerPanel.SetVerticalStretch(m_designTimeGlyph, AdornerStretch.Scale);
//Sets the placement of the design-time glyph within the adorner panel
AdornerPlacementCollection placement = new AdornerPlacementCollection();
placement.SizeRelativeToAdornerDesiredWidth(1.0, 0.0);
placement.SizeRelativeToAdornerDesiredHeight(1.0, 0.0);
placement.PositionRelativeToAdornerHeight(-1.0, 0.0);
placement.PositionRelativeToContentWidth(1.0, -17.0);
AdornerPanel.SetPlacements(m_designTimeGlyph, placement);
base.Activate(item, view);
}
//===========================================================================
/// <summary>
/// Used to update the adorners each time the adorned element changed.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">A <c>PropertyChangedEventArgs</c> that contains the
/// event data.</param>
//===========================================================================
void m_adornedControlModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
//Not used here
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I have been developing and managing projects for real-time embedded softwares for eight years. Then, I moved from Paris to the south of France and began to lead a team who was developping Java applications.
My main occupation right now is to continue my journey in the WPF world.
You can check out my blog
here. [
^]