当前位置: 首页>>代码示例>>C#>>正文


C# IController.CreateInstance方法代码示例

本文整理汇总了C#中IController.CreateInstance方法的典型用法代码示例。如果您正苦于以下问题:C# IController.CreateInstance方法的具体用法?C# IController.CreateInstance怎么用?C# IController.CreateInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IController的用法示例。


在下文中一共展示了IController.CreateInstance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: fMap

      //====================================================================================================
      // Constructor
      //====================================================================================================
      public fMap(IController controller, Process process, Config config) {
         m_controller = controller;
         m_config = config;
         
         //Initialize form
         m_config.Suspend();
         Editor = controller.Editors.Default;
         InitializeComponent();
         InitializeLanguage();

         //Add the supported editors to the mode list
         if (controller.Editors != null && controller.Editors.Count > 0) {
            //add supported editors to the mode selector
            foreach (IMapEditor editor in controller.Editors) {
               ToolStripItem item = new ToolStripMenuItem(editor.ToString());
               item.Tag = editor;
               ModeMenu.Items.Add(item);
            }
            miModeMenu.Visible = true;
         } else {
            currentEditor = new MapNavigator();
            miModeMenu.Visible = false;
         }

         //apply the configuration settings from the current profile
         ApplyConfig();
         m_config.Resume();

         //set the intial check state of the context menu toggles
         miOnTop.Checked = this.TopMost;
         miDraggable.Checked = this.Draggable;
         miResizable.Checked = this.Resizable;
         miClickThru.Checked = this.ClickThrough;

         //bind event handlers
         this.Paint += new PaintEventHandler(fMap_Paint);
         MapEngine.Updated += new GenericEvent(MapEngine_Updated);
         MapEngine.ClientRectangle = Bounds;

         MapMenu.Opening += new CancelEventHandler(MapMenu_Opening);
         miOnTop.CheckedChanged += new EventHandler(miOnTop_CheckedChanged);
         miDraggable.CheckedChanged += new EventHandler(miDraggable_CheckedChanged);
         miResizable.CheckedChanged += new EventHandler(miResizable_CheckedChanged);
         miClickThru.CheckedChanged += new EventHandler(miClickThru_CheckedChanged);

         //check the data path and inform the user if invalid
         bool dns = m_config.Get("DNS_MapPath", false);
         if(!dns && !Directory.Exists(MapEngine.Data.FilePath)) {
            int button = MessageBoxEx.Show(string.Format(Program.GetLang("msg_mappath_invalid_text"), MapEngine.Data.FilePath), Program.GetLang("msg_mappath_invalid_title"), new string[] { Program.GetLang("button_browse"), Program.GetLang("button_ignore") }, MessageBoxIcon.Warning, out dns);
            m_config["DNS_MapPath"] = dns;
            if(button == 0) {
               FolderBrowserDialog browse = new FolderBrowserDialog();
               if(browse.ShowDialog(this) == DialogResult.OK) {
                  MapEngine.Data.FilePath = browse.SelectedPath;
                  m_config["MapPath"] = MapEngine.Data.FilePath;
               }
            }
         }

         //check the map pack path and inform the user if invalid
         dns = m_config.Get("DNS_MapPackPath", false);
         if(!dns && !File.Exists(MapPackPath + Program.MapIniFile)) {
            int button = MessageBoxEx.Show(string.Format(Program.GetLang("msg_mappack_invalid_text"), MapPackPath), Program.GetLang("msg_mappack_invalid_title"), new string[] { Program.GetLang("button_download"), Program.GetLang("button_browse"), Program.GetLang("button_ignore") }, MessageBoxIcon.Warning, out dns);
            m_config["DNS_MapPackPath"] = dns;
            if(button == 0) {
               System.Diagnostics.Process.Start(Program.ResGlobal.GetString("config_mappack_url"));
               MessageBox.Show(Program.GetLang("msg_pack_afterdownload_text"), Program.GetLang("msg_pack_afterdownload_title"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            } else if(button == 1) {
               while(true) {
                  FolderBrowserDialog browse = new FolderBrowserDialog();
                  if(browse.ShowDialog(this) == DialogResult.OK) {
                     //if the user selected a path that does not contain the map.ini file then reject it and inform the user
                     if(!File.Exists(browse.SelectedPath + "\\" + Program.MapIniFile)) {
                        if(MessageBox.Show(string.Format(Program.GetLang("msg_mappack_badsel_text_alt"), browse.SelectedPath, Program.MapIniFile), Program.GetLang("msg_mappack_badsel_title"), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                           continue;
                        break;
                     }

                     //lock the new map pack in
                     MapPackPath = browse.SelectedPath;
                     m_config["MapPackPath"] = MapPackPath;
                  }
                  break;
               }
            }
         }

         try {
            //initialize the game instance with the map engine
            m_game = controller.CreateInstance(process, this);

            if (m_game.Valid)
            {
               MapTimer.Tick += new EventHandler(MapTimer_Tick);
               MapTimer.Enabled = true;
            }
         } catch (InstanceException fex) {
//.........这里部分代码省略.........
开发者ID:stsy,项目名称:mappy,代码行数:101,代码来源:fMap.cs


注:本文中的IController.CreateInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。