public void CreateQuest() { saveDialog.Filter = getFilter(); if (!String.IsNullOrEmpty(Settings.Default.LastExportDirectory)) { saveDialog.InitialDirectory = Settings.Default.LastExportDirectory; } DialogResult result = saveDialog.ShowDialog(); if (result == DialogResult.OK) { FileInfo fileInfo = new FileInfo(saveDialog.FileName); Settings.Default.LastExportDirectory = fileInfo.DirectoryName; Log.Info(String.Format(Resources.msgExportingQuest, saveDialog.FileName)); // make sure last edit is stored in dataset try { QuestDesignerMain.DesignerForm.Cursor = Cursors.WaitCursor; BackgroundWorker exportWorker = new BackgroundWorker(); exportWorker.DoWork += new DoWorkEventHandler(exportWorker_DoWork); exportWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(exportWorker_RunWorkerCompleted); exportWorker.RunWorkerAsync(); } catch (Exception e) { QuestDesignerMain.HandleException(e, Resources.msgExportError + ": " + e.Message); Cursor.Current = Cursors.Default; } } }
private static void backgroundWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { if (e.Error != null) { QuestDesignerMain.HandleException(e.Error, Resources.msgRegionError + ": " + e.Error.Message, global::DOL.Tools.QuestDesigner.Properties.Resources.error); } else { QuestDesignerMain.DesignerForm.DXControl.Invalidate(); Log.Info(Resources.msgRegionSuccess); } if (QuestDesignerMain.DesignerForm != null && !QuestDesignerMain.DesignerForm.StatusProgress.IsDisposed) { QuestDesignerMain.DesignerForm.StatusProgress.Value = QuestDesignerMain.DesignerForm.StatusProgress.Minimum; } }
public bool Compare(DataRow row) { if (!IsFiltered) { return(true); } if (Utils.EqualsIgnoreCase(DB.COL_REQUIREMENTTYPE_COMPARATOR, FilterParameter)) { try { object value = row[DB.COL_REQUIREMENTTYPE_COMPARATOR]; if (value != DBNull.Value) { eComparator comparatorRow = (eComparator)Enum.Parse(typeof(eComparator), Convert.ToString(value)); return(comparatorRow == (eComparator)FilterValue); } else { if ((eComparator)filterValue == eComparator.None) { return(true); } else { return(false); } } } catch (Exception e) { QuestDesignerMain.HandleException(e); return(false); } } else { return((string)FilterValue == (string)row[FilterParameter]); } }
public void InitDB() { if (m_database == null) { m_database = ObjectDatabase.GetObjectDatabase(dolConfig.DBType, dolConfig.DBConnectionString); try { //We will search our assemblies for DataTables by reflection so //it is not neccessary anymore to register new tables with the //server, it is done automatically! foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { // Walk through each type in the assembly foreach (Type type in assembly.GetTypes()) { // Pick up a class if (type.IsClass != true) { continue; } object[] attrib = type.GetCustomAttributes(typeof(DataTable), true); if (attrib.Length > 0) { //Log.Info("Registering table: " + type.FullName); m_database.RegisterDataObject(type); } } } } catch (DatabaseException e) { QuestDesignerMain.HandleException(e); return; } } }
public static bool LoadRegion(Region region) { if (region == null) { return(false); } if (m_OpenedRegion != null && region.ID == m_OpenedRegion.ID) { Log.Info(String.Format(Resources.msgRegionAlreadyLoaded, region.Name)); return(true); } // we are still loading a old region, cancel that operation if (backgroundWorker != null && backgroundWorker.IsBusy) { backgroundWorker.CancelAsync(); } UnloadRegion(); //Create "hitbox" Mesh hb = Mesh.Box(Common.Device, 256 * 256 * 16, 256 * 256 * 16, 0.0f); XMesh ms = new XMesh(hb); Texture tx = Textures.Generator(Color.Cyan); Model mdl = new Model(ms, tx); GeometryObj bj = new GeometryObj(null, mdl, DrawLevel.NonRender, DetailLevel.Nondetailed, 256 * 256 * 16 / 2, 256 * 256 * 16 / 2, 0.0f, 0.0f, 0.0f, 0.0f, new Vector3(1.0f, 1.0f, 1.0f), false, false); DXControl.GeoObjects.Add(bj); QuestDesignerMain.DesignerForm.DXControl.HBObject = bj; try { m_OpenedRegion = region; backgroundWorker = new BackgroundWorker(); backgroundWorker.WorkerSupportsCancellation = true; backgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(backgroundWorker_doWork); backgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted); backgroundWorker.RunWorkerAsync(); } catch (Exception e) { QuestDesignerMain.HandleException(e, Resources.msgRegionError + ": " + e.Message, global::DOL.Tools.QuestDesigner.Properties.Resources.databaseError); } //Scrollbars.. QuestDesignerMain.DesignerForm.DXControl.hScrollBar.Minimum = 0; QuestDesignerMain.DesignerForm.DXControl.hScrollBar.Maximum = 256 * 256 * 16; QuestDesignerMain.DesignerForm.DXControl.hScrollBar.SmallChange = 256; QuestDesignerMain.DesignerForm.DXControl.hScrollBar.LargeChange = 2560; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.Minimum = 0; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.Maximum = 256 * 256 * 16; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.SmallChange = 256; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.LargeChange = 2560; QuestDesignerMain.DesignerForm.DXControl.SetZoom(0.75F);; int maxSize = Math.Max(region.MaxHeight - region.MinHeight, region.MaxWidth - region.MinWidth); int zoomFactor = (QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Maximum - QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Minimum) / 16 * (maxSize / (256 * 256)); // restrcit zoomFactor zo Minimum-Maximum QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Value = Math.Min(QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Maximum, Math.Max(QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Minimum, zoomFactor)); QuestDesignerMain.DesignerForm.DXControl.hScrollBar.Enabled = true; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.Enabled = true; QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Enabled = true; QuestDesignerMain.DesignerForm.DXControl.CenterView(); ModulMgr.TriggerModules(ModulEvent.RegionLoad, region); // render newly added objects from Modules QuestDesignerMain.DesignerForm.DXControl.Invalidate(); return(true); }