namespace Business.OutputMap
{
[Guid("068df737-4a05-4d23-b906-e96693bfabe5")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("OutputMap.SaveMapMxdCommand")]
public sealed class SaveMapMxdCommand : BaseCommand, IBarButtonItem, IShortCut
{
#endregion
private IHookHelper m_hookHelper;
//private IMapControl3 m_MapControl = null;
private IMapDocument m_PageLayoutDocument = null;
private IPageLayoutControl2 m_PageLayoutControl = null;
public SaveMapMxdCommand(IMapDocument mxdDoc)
{
}
#region Overriden Class Methods
/// <summary>
/// 勾子,命令创建的时候触发
/// </summary>
/// <param name="hook">Instance of the application</param>
public override void OnCreate(object hook)
{
if (hook == null)
return;
if (m_hookHelper == null)
m_hookHelper = new HookHelperClass();
m_hookHelper.Hook = hook;
// TODO: Add other initialization code
object hookMap = null;
if (m_hookHelper.Hook is IToolbarControl2)
hookMap = (m_hookHelper.Hook as IToolbarControl2).Buddy;
else
hookMap = m_hookHelper.Hook;
if (hookMap is IPageLayoutControl2)
this.m_PageLayoutControl = hookMap as IPageLayoutControl2;
//if (hookMap is IMapControl3)
// m_MapControl = hookMap as IMapControl3;
}
/// <summary>
/// Occurs when this command is clicked
/// </summary>
public override void OnClick()
{
//IObjectCopy lip_ObjCopy = new ObjectCopyClass();
//IMxdContents pMxdContents = ((IMap)lip_ObjCopy.Copy(this.m_hookHelper.ActiveView.FocusMap)) as IMxdContents;
//m_PageLayoutDocument.ReplaceContents(pMxdContents);
//m_PageLayoutDocument.Save(m_PageLayoutDocument.UsesRelativePaths, false);
m_PageLayoutDocument.ReplaceContents((IMxdContents)m_PageLayoutControl.Object);
m_PageLayoutDocument.SetActiveView(m_PageLayoutControl.ActiveView);
m_PageLayoutDocument.Save(m_PageLayoutDocument.UsesRelativePaths, true);
}
public override bool Enabled
{
}
#endregion
}
}