Esempio n. 1
0
		protected override void Startup()
		{
			try
			{
				Util.Initialize("GoArrow", Host, Core, base.Path);
				System.Threading.Thread.CurrentThread.CurrentCulture
					= new System.Globalization.CultureInfo("en-US", false);

				mSettingsLoaded = false;
				mLoggedIn = false;
				mLoginCompleted = false;

				FileInfo locationsFile = new FileInfo(Util.FullPath("locations.xml"));
				if (locationsFile.Exists)
				{
					mLocDb = new LocationDatabase(locationsFile.FullName);
				}
				else
				{
					// Load from resource
					XmlDocument locDoc = new XmlDocument();
					locDoc.LoadXml(RouteFinding.Data.LocationsDatabase);
					mLocDb = new LocationDatabase(locDoc);
				}

				mLastSpellId = 0;
				mLastSpellTarget = 0;
				mRecallingToLSBind = RecallStep.NotRecalling;
				mRecallingToLSTie = RecallStep.NotRecalling;
				mRecallingToBindstone = RecallStep.NotRecalling;

				mHudManager = new HudManager(Host, Core, DefaultView, delegate() { return mDefaultViewActive; }, false);
				mHudManager.ExceptionHandler += new EventHandler<ExceptionEventArgs>(HudManager_ExceptionHandler);
				GraphicsReset += new EventHandler(mHudManager.GraphicsReset);
				WindowMessage += new EventHandler<WindowMessageEventArgs>(mHudManager.DispatchWindowMessage);
				RegionChange3D += new EventHandler<RegionChange3DEventArgs>(mHudManager.DispatchRegionChange3D);

				mDungeonHud = new DungeonHud(mHudManager);

				mMapHud = new MapHud(mHudManager, this, mLocDb);

				mArrowHud = new ArrowHud(mHudManager);
				mArrowHud.AsyncLoadComplete += new RunWorkerCompletedEventHandler(ArrowHud_AsyncLoadComplete);
				mArrowHud.DestinationChanged += new EventHandler<DestinationChangedEventArgs>(mMapHud.ArrowHud_DestinationChanged);

				mToolbar = new ToolbarHud(mHudManager);
				mMainViewToolButton = mToolbar.AddButton(new ToolbarButton(Icons.Toolbar.Settings, "Settings"));
				mArrowToolButton = mToolbar.AddButton(new ToolbarButton(Icons.Toolbar.GoArrow, "Arrow"));
				mDerethToolButton = mToolbar.AddButton(new ToolbarButton(Icons.Toolbar.Dereth, "Dereth"));
				mDungeonToolButton = mToolbar.AddButton(new ToolbarButton(Icons.Toolbar.Dungeon, "Dungeon"));
				mMainViewToolButton.Click += new EventHandler(MainViewToolButton_Click);
				mArrowToolButton.Click += new EventHandler(ArrowToolButton_Click);
				mDerethToolButton.Click += new EventHandler(DerethToolButton_Click);
				mDungeonToolButton.Click += new EventHandler(DungeonToolButton_Click);

				mStartLocations = new SortedDictionary<string, RouteStart>(StringComparer.OrdinalIgnoreCase);

				// Load portal devices
				// Try to load from file. If that fails, load from resource
				XmlDocument portalDevicesDoc = new XmlDocument();
				string portalDevicesPath = Util.FullPath("PortalDevices.xml");
				if (File.Exists(portalDevicesPath))
				{
					portalDevicesDoc.Load(portalDevicesPath);
				}
				else
				{
					portalDevicesDoc.LoadXml(RouteFinding.Data.PortalDevices);
				}

				mPortalDevices = new SortedDictionary<string, PortalDevice>(StringComparer.OrdinalIgnoreCase);
				foreach (XmlElement portalDeviceEle in portalDevicesDoc.DocumentElement.GetElementsByTagName("device"))
				{
					PortalDevice device;
					if (PortalDevice.TryLoadXmlDefinition(portalDeviceEle, out device))
					{
						mPortalDevices[device.Name] = device;
					}
				}

				InitMainViewBeforeSettings();

				mRecallTimeout = new WindowsTimer();
				mRecallTimeout.Tick += new EventHandler(RecallTimeout_Tick);

				mLoginTime = DateTime.Now;

#if USING_D3D_CONTAINER
				RouteStart.Initialize(110011, "Digero", 220022, "DaBug", "DebugAccount");
				LoadSettings();
				InitMainViewAfterSettings();

				mHudManager.StartHeartbeat();
#endif
			}
			catch (Exception ex) { Util.HandleException(ex); }
		}
Esempio n. 2
0
		protected override void Shutdown()
		{
			try
			{
				mLoggedIn = false;
				mLoginCompleted = false;

				SaveSettings();

				Util.Dispose();
				DisposeMainView();

				if (mHudManager != null)
				{
					GraphicsReset -= mHudManager.GraphicsReset;
					WindowMessage -= mHudManager.DispatchWindowMessage;
					RegionChange3D -= mHudManager.DispatchRegionChange3D;
					mHudManager.Dispose();
					mHudManager = null;
				}

				mArrowHud = null;
				mMapHud = null;
				mDungeonHud = null;

				if (mRecallTimeout != null)
				{
					mRecallTimeout.Dispose();
					mRecallTimeout = null;
				}

				if (mDatabaseReminderDelay != null)
				{
					mDatabaseReminderDelay.Dispose();
					mDatabaseReminderDelay = null;
				}

				if (Core.HotkeySystem != null)
				{
					Core.HotkeySystem.Hotkey -= HotkeySystem_Hotkey;
				}

				mLocDb.Dispose();
				mLocDb = null;
			}
			catch (Exception ex) { Util.HandleException(ex); }
		}