当前位置:编程学习 > C#/ASP.NET >>

可访问性低???那位高手解决一下啊

错误 1 可访问性不一致: 参数类型“_3sdnMap1.ControlsSynchronizer”比方法“_3sdnMap1.OpenNewMapDocument.OpenNewMapDocument(_3sdnMap1.ControlsSynchronizer)”的可访问性低 F:\kkk\3sdnMap1\3sdnMap1\OpenNewMapDocument.cs 76 17 3sdnMap1



第一

 namespace _3sdnMap1
{
    /// <summary>
    /// Command that works in ArcMap/Map/PageLayout
    /// </summary>
    [Guid("e4df18b0-e9b2-4968-893a-37ad3719e7a8")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("_3sdnMap1.OpenNewMapDocument")]
    public sealed class OpenNewMapDocument : BaseCommand
    {


        private ControlsSynchronizer m_controlsSynchronizer = null;
        #region COM Registration Function(s)
        [ComRegisterFunction()]
        [ComVisible(false)]
      static void RegisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryRegistration(registerType);

            //
            // TODO: Add any COM registration code here
            //
        }

        [ComUnregisterFunction()]
        [ComVisible(false)]
          private IHookHelper m_hookHelper = null;
        public  OpenNewMapDocument(ControlsSynchronizer controlsSynchronizer)------------这里出错
        {
            //
            // TODO: Define values for the public properties
            //
            base.m_category = "Generic"; //localizable text
            base.m_caption = "Open";  //localizable text 
            base.m_message = "This should work in ArcMap/MapControl/PageLayoutControl";  //localizable text
            base.m_toolTip = "Open";  //localizable text
            base.m_name = "Generic_Open";   //unique id, non-localizable (e.g. "MyCategory_MyCommand")
           
            //初始化m_controlsSynchronizer
            m_controlsSynchronizer = controlsSynchronizer;

            try
            {
                //
                // TODO: change bitmap name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }


   第二ControlsSynchronizer类


namespace _3sdnMap1
{
    
   class ControlsSynchronizer
    {

        #region class members
        private IMapControl3 m_mapControl = null;
        private IPageLayoutControl2 m_pageLayoutControl = null;
        private ITool m_mapActiveTool = null;
        private ITool m_pageLayoutActiveTool = null;
        private bool m_IsMapCtrlactive = true;
        private ArrayList m_frameworkControls = null;


      
        public ControlsSynchronizer()
        {
            //初始化ArrayList
            m_frameworkControls = new ArrayList();
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mapControl"></param>
        /// <param name="pageLayoutControl"></param>
        public ControlsSynchronizer(IMapControl3 mapControl, IPageLayoutControl2 pageLayoutControl) : this()
        {
            //为类成员赋值
            m_mapControl = mapControl;
            m_pageLayoutControl = pageLayoutControl;
        }
        #endregion

        #region properties
        /// <summary>
        /// 取得或设置MapControl
        /// </summary>
        public IMapControl3 MapControl
        {
            get { return m_mapControl; }
            set { m_mapControl = value; }
        }

        /// <summary>
        /// 取得或设置PageLayoutControl
        /// </summary>
        public IPageLayoutControl2 PageLayoutControl
        {
            get { return m_pageLayoutControl; }
            set { m_pageLayoutControl = value; }
        }

        /// <summary>
        /// 取得当前ActiveView的类型
        /// </summary>
        public string ActiveViewType
        {
            get
            {
                if (m_IsMapCtrlactive)
                    return "MapControl";
                else
                    return "PageLayoutControl";
            }
        }

        /// <summary>
        /// 取得当前活动的Control
        /// </summary>
        public object ActiveControl
        {
            get
            {
                if (m_mapControl == null || m_pageLayoutControl == null)
                    throw new Exception("ControlsSynchronizer::ActiveControl:\r\nEither MapControl or PageLayoutControl are not initialized!");

                if (m_IsMapCtrlactive)
                    return m_mapControl.Object;
                else
                    return m_pageLayoutControl.Object;
            }
        }
        #endregion

        #region Methods
        /// <summary>
        /// 激活MapControl并解除the PagleLayoutControl
        /// </summary>
        public void ActivateMap()
        {
            try
            {
                if (m_pageLayoutControl == null || m_mapControl == null)
                    throw new Exception("ControlsSynchronizer::ActivateMap:\r\nEither MapControl or PageLayoutControl are not initialized!");

                //缓存当前PageLayout的CurrentTool
                if (m_pageLayoutControl.CurrentTool != null) m_pageLayoutActiveTool = m_pageLayoutControl.CurrentTool;

                //解除PagleLayout
                m_pageLayoutControl.ActiveView.Deactivate();

                //激活MapControl
                m_mapControl.ActiveView.Activate(m_mapControl.hWnd);

                //将之前MapControl最后使用的tool,作为活动的tool,赋给MapControl的CurrentTool
                if (m_mapActiveTool != null) m_mapControl.CurrentTool = m_mapActiveTool;

                m_IsMapCtrlactive = true;

                //为每一个的framework controls,设置Buddy control为MapControl
                this.SetBuddies(m_mapControl.Object);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("ControlsSynchronizer::ActivateMap:\r\n{0}", ex.Message));
            }
        }

        /// <summary>
        /// 激活PagleLayoutControl并减活MapCotrol
        /// </summary>
        public void ActivatePageLayout()
        {
            try
            {
                if (m_pageLayoutControl == null || m_mapControl == null)
                    throw new Exception("ControlsSynchronizer::ActivatePageLayout:\r\nEither MapControl or PageLayoutControl are not initialized!");

                //缓存当前MapControl的CurrentTool
                if (m_mapControl.CurrentTool != null) m_mapActiveTool = m_mapControl.CurrentTool;

                //解除MapControl
                m_mapControl.ActiveView.Deactivate();

                //激活PageLayoutControl
                m_pageLayoutControl.ActiveView.Activate(m_pageLayoutControl.hWnd);

                //将之前PageLayoutControl最后使用的tool,作为活动的tool,赋给PageLayoutControl的CurrentTool
                if (m_pageLayoutActiveTool != null) m_pageLayoutControl.CurrentTool = m_pageLayoutActiveTool;

                m_IsMapCtrlactive = false;

                //为每一个的framework controls,设置Buddy control为PageLayoutControl
                this.SetBuddies(m_pageLayoutControl.Object);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("ControlsSynchronizer::ActivatePageLayout:\r\n{0}", ex.Message));
            }
        }

        /// <summary>
        /// 给予一个地图, 置换PageLayoutControl和MapControl的focus map
        /// </summary>
        /// <param name="newMap"></param>
        public void ReplaceMap(IMap newMap)
        {
            if (newMap == null)
                throw new Exception("ControlsSynchronizer::ReplaceMap:\r\nNew map for replacement is not initialized!");

            if (m_pageLayoutControl == null || m_mapControl == null)
                throw new Exception("ControlsSynchronizer::ReplaceMap:\r\nEither MapControl or PageLayoutControl are not initialized!");

            //create a new instance of IMaps collection which is needed by the PageLayout
            //创建一个PageLayout需要用到的,新的IMaps collection的实例
            IMaps maps = new Maps();
            //add the new map to the Maps collection
            //把新的地图加到Maps collection里头去
            maps.Add(newMap);

            bool bIsMapActive = m_IsMapCtrlactive;

            //call replace map on the PageLayout in order to replace the focus map
            //we must call ActivatePageLayout, since it is the control we call 'ReplaceMaps'
            //调用PageLayout的replace map来置换focus map
            //我们必须调用ActivatePageLayout,因为它是那个我们可以调用"ReplaceMaps"的Control
            this.ActivatePageLayout();
            m_pageLayoutControl.PageLayout.ReplaceMaps(maps);

            //assign the new map to the MapControl
            //把新的地图赋给MapControl
            m_mapControl.Map = newMap;

            //reset the active tools
            //重设active tools
            m_pageLayoutActiveTool = null;
            m_mapActiveTool = null;

            //make sure that the last active control is activated
            //确认之前活动的control被激活
            if (bIsMapActive)
            {
                this.ActivateMap();
                m_mapControl.ActiveView.Refresh();
            }
            else
            {
                this.ActivatePageLayout();
                m_pageLayoutControl.ActiveView.Refresh();
            }
        }

                       

    }
}
那位高手指教一下
--------------------编程问答-------------------- 很明显嘛,将冲突的两个方法的访问修饰符改成一致就行了 --------------------编程问答-------------------- namespace _3sdnMap1
{
    
  public class ControlsSynchronizer
  {
  ... --------------------编程问答--------------------   class ControlsSynchronizer 这个没有加public

msdn:
如果在类的内部声明的类型没有访问修饰符,则该类型默认为 private。
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,