public void PressGoodies(Goodies goodies) { _CurrentGoodies = goodies; Text desc = transform.FindChild("Down/Number").GetComponent <Text>(); desc.text = string.Format("数量:{0}", goodies.GetPrice()); }
public FileStatus(int status, string dwgPath) { this.status = status; this.dwgPath = dwgPath; if (status == 0) { db = Application.DocumentManager.MdiActiveDocument.Database; } else if (status == 1) { previousDwgPath = Application.DocumentManager.MdiActiveDocument.Name; Document doc = Goodies.GetDocumentFromDwgpath(dwgPath); db = doc.Database; Application.DocumentManager.MdiActiveDocument = doc; Application.DocumentManager.CurrentDocument = doc; //Application.DocumentManager.MdiActiveDocument = Application.DocumentManager.Open(dwgPath, false); //db = null; } else if (status == 2) { db.ReadDwgFile(dwgPath, FileOpenMode.OpenForReadAndAllShare, false, ""); } else if (status == 3) { db = null; } else { db = null; } }
public void PressToggle(bool isOn, GameObject toggle, int toggleNum) { _CurrentGoodies = null; Text desc = transform.FindChild("Down/Number").GetComponent <Text>(); desc.text = "数量:100"; SwitchToggle(toggleNum); }
/// <summary> /// ReadPNote is read Note in general, can be from database, can be from dwg depends on current situation. /// If dwgPNote is opened, is active or not, is modified or not (can't check whether or not it is modied), refer to read from DWG and updateDatabase. /// If dwgPNote is Not open check date, if if equals, read from database. /// Else: read from file + udpate todatabase. /// FK IT, JUST FOUND DOWN THE INTEROPT SHIT /// </summary> /// <param name="connection"></param> /// <returns></returns> public static NODEDWG ReadDataPNode(SQLiteConnection connection) { NODEDWG note = null; string notePath = GoodiesPath.GetNotePathFromADwgPath(Application.DocumentManager.MdiActiveDocument.Name, connection); if (!string.IsNullOrEmpty(notePath)) { if (Goodies.GetListOfDocumentOpening().Contains(notePath)) { Document doc = Goodies.GetDocumentFromDwgpath(notePath); if (doc == null) { Application.ShowAlertDialog("ReadDwgNoteFile -> There is no Document, weird!"); return(null); } AcadDocument acadDoct = (AcadDocument)doc.GetAcadDocument(); if (acadDoct.Saved && GoodiesPath.IsDateTheSame(notePath, connection)) { note = ReadFromDatabase(connection); } else { using (Database db = doc.Database) { note = GetData(db, connection); } } } else { Database db = new Database(); try { if (GoodiesPath.IsDateTheSame(notePath, connection)) { note = ReadFromDatabase(connection); } else { db.ReadDwgFile(notePath, FileOpenMode.OpenForReadAndAllShare, false, ""); note = GetData(db, connection); } }catch (Exception e) { MessageBox.Show(e.Message); } } } return(note); }
public void ReturnPreviousDocument() { if (status == 1) { Document doc = Goodies.GetDocumentFromDwgpath(previousDwgPath); using (doc.LockDocument()) { Application.DocumentManager.MdiActiveDocument = doc; Application.DocumentManager.CurrentDocument = doc; } } }
public TableData(BlockReference bref, Transaction tr, Database db) { model.handle = Goodies.ConvertHandleToString(bref.Handle); model.position = new Point3dModel(bref.Position.ToArray()); model.matrixTransform = new Matrix3dModel(bref.BlockTransform.ToArray()); model.ALIAS = XDataHelper.GetTableType(bref, tr, db); if (string.IsNullOrEmpty(model.ALIAS)) { model = null; return; } model.A_VALUE = ConstantName.invalidStr; }
public static void InsertFixtureUnit(FixtureDetails fd) { Goodies.AddBlockToActiveDrawing("C:\\Users\\dngo\\Desktop\\SAMPLES\\VERSION1.dwg", "FIX_26"); Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; Database db = doc.Database; BlockReference bref = null; Dictionary <ObjectId, ObjectId> blockToInsert = Goodies.InsertDynamicBlock("FIX_26", db, ref bref); using (doc.LockDocument()) { using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead); } } }
private void RefreshGoodies() { int count = 1; int beginGoodiesNumber = (_CurrentToggleNumber - 1) * 4; for (int i = beginGoodiesNumber; i < beginGoodiesNumber + 4 && i < _TotalNumberGoodies; i++, count++) { GameObject goodies = transform.FindChild(string.Format("Center/Goodies{0}", count)).gameObject; GoodiesData data = _GoodiesDatas[i]; Goodies goodiesComp = goodies.GetComponent <Goodies>(); goodies.SetActive(true); Button btn = goodies.transform.FindChild("Icon").GetComponent <Button>(); btn.onClick.AddListener(delegate() { this.PressGoodies(goodiesComp); }); ColorBlock colors = new ColorBlock(); colors.colorMultiplier = 1.0f; colors.normalColor = Color.white; colors.disabledColor = Color.gray; colors.pressedColor = new UnityEngine.Color(225.0f / 255.0f, 75.0f / 255.0f, 75.0f / 255.0f, 1.0f); colors.highlightedColor = new UnityEngine.Color(225.0f / 255.0f, 75.0f / 255.0f, 75.0f / 255.0f, 1.0f); btn.colors = colors; goodiesComp.Data = data; goodiesComp.SetName(data.Name); goodiesComp.SetPrice(data.Price); goodiesComp.SetIconPath(data.IconPath); } for (int i = count; i <= 4; i++) { GameObject goodies = transform.FindChild(string.Format("Center/Goodies{0}", i)).gameObject; goodies.SetActive(false); } }
private static NODEDWG GetData(Database db, SQLiteConnection connection) { NODEDWG note = new NODEDWG(); using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead); foreach (ObjectId id in btr) { DBObject obj = tr.GetObject(id, OpenMode.ForRead); if (obj is BlockReference) { BlockReference bref = (BlockReference)obj; if (Goodies.IsBlockInTheDrawing(bref)) { if (bref.IsDynamicBlock) { string brefName = Goodies.GetDynamicName(bref); if (brefName.Equals(ConstantName.FixtureInformationArea)) { FixtureBeingUsedArea dbA = new FixtureBeingUsedArea(bref); if (dbA.model != null) { note.FixtureBoxSet.Add(dbA); } } } else if (bref.Name == ConstantName.FixtureDetailsBox) { FixtureDetails FD = new FixtureDetails(bref, tr); if (FD.model != null) { note.FixtureDetailSet.Add(FD); } } else if (bref.Name == ConstantName.InsertPoint) { InsertPoint IP = new InsertPoint(bref, tr); if (IP.model != null) { note.InsertPointSet.Add(IP); } } else if (bref is Table) { TableData tb = new TableData(bref, tr, db); if (tb.model != null) { note.TableDataSet.Add(tb); } } } } } List <FixtureDetails> newFixs = new List <FixtureDetails>(); foreach (FixtureBeingUsedArea fba in note.FixtureBoxSet) { foreach (FixtureDetails fd in note.FixtureDetailSet) { if (fba.IsInsideTheBox(fd)) { newFixs.Add(fd); } } } note.FixtureDetailSet.Clear(); foreach (FixtureDetails fd in newFixs) { note.FixtureDetailSet.Add(fd); } } //Write to Database string currentdwgPath = db.Filename; string dbPath = GoodiesPath.GetDatabasePathFromDwgPath(currentdwgPath); if (string.IsNullOrEmpty(dbPath)) { MessageBox.Show("Could Not Find Database."); } note.file = DBDwgFile.GetPNote(connection); note.file.modifieddate = GoodiesPath.GetModifiedOfFile(GoodiesPath.GetFullPathFromRelativePath(note.file.relativePath, connection)).Ticks; if (note.file == null) { MessageBox.Show($"Can't find this {currentdwgPath} in databse."); return(null); } foreach (FixtureBeingUsedArea fixtureBox in note.FixtureBoxSet) { fixtureBox.model.file = note.file; } foreach (FixtureDetails fd in note.FixtureDetailSet) { fd.model.file = note.file; } foreach (InsertPoint ip in note.InsertPointSet) { ip.model.file = note.file; } foreach (TableData table in note.TableDataSet) { table.model.file = note.file; } DBDwgFile.DeleteRow(connection, note.file.relativePath); note.WriteToDataBase(connection); return(note); }
public static void WriteScheduleTableToNote(SQLiteConnection connection) { string dwgPath = Application.DocumentManager.MdiActiveDocument.Name; string notePathFull = GoodiesPath.GetNotePathFromADwgPath(dwgPath, connection); string notePath = GoodiesPath.MakeRelativePath(notePathFull); if (string.IsNullOrEmpty(notePath)) { MessageBox.Show("WriteScheduleTableToNote -> Can't find P_Note file."); return; } FileStatus fileStatus = Goodies.CanOpenToWrite(notePathFull); //Document doc = Goodies.CanOpenToWrite1(notePathFull); if (fileStatus == null || fileStatus.db == null) { return; } //if (doc == null) return; DwgFileModel fileModel = PlumbingDatabaseManager.GetNotePath(connection); if (notePath == fileModel.relativePath) { if (GoodiesPath.IsDateTheSame(notePathFull, connection)) { NODEDWG note = ReadPNote.ReadDataPNode(connection); InsertPoint ip = note.InsertPointSet.Where(insertpoint => insertpoint.model.alias == "FS").FirstOrDefault(); Table table = TableSchedule.CreateTable(note.FixtureDetailSet, ip); Document doc = Application.DocumentManager.GetDocument(fileStatus.db); using (doc.LockDocument()) { using (fileStatus.db) { TableSchedule.DeleteTableSchedule(fileStatus.db, XDataHelperName.tableSchedule); using (Transaction tr = fileStatus.db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(fileStatus.db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); Goodies.InsertTable(table, tr, btr); table.Layer = ConstantName.TABLE; XDataHelper.AddTableXData(ref table, tr, fileStatus.db); tr.Commit(); tr.Dispose(); TableData tableData = new TableData(table, tr, fileStatus.db); tableData.model.file = fileModel; tableData.model.WriteToDatabase(connection); } TableSchedule.AddBlockToTable(table, fileStatus.db, note.FixtureDetailSet); fileStatus.Save(); } } fileStatus.ReturnPreviousDocument(); } } }
public FixtureUnit(BlockReference bRef, Transaction tr) { model = new FixtureUnitModel(); model.position = new Point3dModel(bRef.Position.ToArray()); model.matrixTransform = new Matrix3dModel(bRef.BlockTransform.ToArray()); model.blockName = Goodies.GetDynamicName(bRef); model.fuS = FixtureUnitBlock.GetFixtureUnitStatus(model.blockName); Point3d v, m, r1; foreach (DynamicBlockReferenceProperty prop in bRef.DynamicBlockReferencePropertyCollection) { if (prop.PropertyName == FixtureUnitModelName.A1) { model.A1 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.A2) { model.A2 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.A3) { model.A3 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.D1) { model.D1 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.Y2) { model.Y2 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.X2) { model.X2 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.X2_2) { model.X2_2 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.V) { v = (Point3d)prop.Value; model.V = new Point3dModel(v.X, v.Y, v.Z); } else if (prop.PropertyName == FixtureUnitModelName.M) { m = (Point3d)prop.Value; model.M = new Point3dModel(m.X, m.Y, m.Z); } else if (prop.PropertyName == FixtureUnitModelName.R1) { r1 = (Point3d)prop.Value; model.R1 = new Point3dModel(r1.X, r1.Y, r1.Z); } } foreach (ObjectId id in bRef.AttributeCollection) { AttributeReference attRef = (AttributeReference)tr.GetObject(id, OpenMode.ForRead); if (attRef.Tag == FixtureUnitModelName.CWSFU) { model.CWSFU = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.WSFU) { model.WSFU = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.HWSFU) { model.HWSFU = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.VENT_DIA) { model.VENT_DIA = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.WASTE_DIA) { model.WASTE_DIA = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.STORM_DIA) { model.STORM_DIA = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.DFU) { model.DFU = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.HW_DIA) { model.HW_DIA = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.CW_DIA) { model.CW_DIA = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.INDEX) { model.INDEX = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.TAG) { throw new Exception("Check This Out."); } } }
public Stock GetStockFromCoordinates(Coordinates coordinates) { CheckCoordinates(coordinates); return(Goodies.FirstOrDefault(c => c.Key.Col == coordinates.Col && c.Key.Row == coordinates.Row).Value); }