private void 停止记录异常点ToolStripMenuItem_Click(object sender, EventArgs e) { 停止记录异常点ToolStripMenuItem.Enabled = false; 异常点记录ToolStripMenuItem.Enabled = true; RecordPoint.Abort(); timer2point写文件.Stop(); timer2point写文件.Enabled = false; }
/// <summary> /// 되돌리기로 뜻풀이가 변화될 때 다시 실행을 위해 현재 값을 기록(되돌리기 이전 실행) /// </summary> void RecordUndoDefinition(string searchText, string lastSearchText, WordDetailItem definition, int selectedIndex = -1, Visibility isMoreButtonVisible = Visibility.Collapsed) { RecordPoint record = new RecordPoint(RecordType.ClearDefinition, searchText, lastSearchText, null, definition, selectedIndex, isMoreButtonVisible); ForwardStack.AddLast(record); if (ForwardStack.Count > RECORD_LIMIT) { ForwardStack.RemoveFirst(); } }
/// <summary> /// 되돌리기 /// </summary> public void Undo(ref string searchText, ref string lastSearchText, ref ObservableCollection <SearchResultItem> searchResults, ref WordDetailItem definition, ref int selectedIndex, ref Visibility isMoreButtonVisible) { if (BackStack.Count == 0) { return; } RecordPoint previousRecord = BackStack.Last(); BackStack.RemoveLast(); if (previousRecord.Type == RecordType.ClearDefinition) { RecordUndoDefinition(searchText, lastSearchText, definition, selectedIndex, isMoreButtonVisible); searchText = previousRecord.SearchText; lastSearchText = previousRecord.LastSearchText; selectedIndex = previousRecord.SelectedIndex; if (previousRecord.Definition != null) { definition = previousRecord.Definition; } } else if (previousRecord.Type == RecordType.ClearAll) { RecordUndoAll(searchText, lastSearchText, searchResults, definition, selectedIndex, isMoreButtonVisible); searchText = previousRecord.SearchText; lastSearchText = previousRecord.LastSearchText; selectedIndex = previousRecord.SelectedIndex; if (previousRecord.SearchResults != null) { searchResults.Clear(); for (int i = 0; i < previousRecord.SearchResults.Count; i++) { searchResults.Add(previousRecord.SearchResults[i]); } } if (previousRecord.Definition != null) { definition = previousRecord.Definition; } isMoreButtonVisible = previousRecord.IsMoreButtonVisible; } else if (previousRecord.Type == RecordType.ClearSearchResult) { // 일어나지 않는 케이스 } }
/// <summary> /// 뜻풀이가 변화될 때 이전 값을 기록 /// </summary> public void RecordDefinition(string searchText, string lastSearchText, WordDetailItem definition, int selectedIndex = -1, bool isRedo = false, Visibility isMoreButtonVisible = Visibility.Collapsed) { RecordPoint record = new RecordPoint(RecordType.ClearDefinition, searchText, lastSearchText, null, definition, selectedIndex, isMoreButtonVisible); BackStack.AddLast(record); if (BackStack.Count > RECORD_LIMIT) { BackStack.RemoveFirst(); } if (!isRedo && ForwardStack.Count != 0) { ForwardStack.Clear(); } }
List <Plant> CreateData() { Random rnd = new Random(); List <Plant> plants = new List <Plant>(); DataTable Factorydt = new DataTable(); DataTable AreaDT = new DataTable(); DataTable TrainDt = new DataTable(); DataTable MachineDt = new DataTable(); DataTable PointDt = new DataTable(); int r = 0; try { Factorydt = DbClass.getdata(CommandType.Text, "select FACTORY_ID ,NAME,Description from factory_info "); AreaDT = DbClass.getdata(CommandType.Text, "select Area_ID,NAME,DESCRIPTION,FactoryID from area_info "); TrainDt = DbClass.getdata(CommandType.Text, "select Train_ID,NAME,Description ,Area_ID from train_info "); MachineDt = DbClass.getdata(CommandType.Text, "select Machine_ID ,NAME ,Description,TrainID from machine_info "); PointDt = DbClass.getdata(CommandType.Text, "SELECT Point_ID ,POINTNAME ,PointDesc,Machine_ID FROM POINT "); foreach (DataRow FactoryRow in Factorydt.Rows) { Plant plant = new Plant() { plantID = Convert.ToInt32(FactoryRow["FACTORY_ID"]), Name = Convert.ToString(FactoryRow["Name"]), Areas = new List <Area>() }; plants.Add(plant); foreach (DataRow AreaRow in AreaDT.Select("FactoryID = '" + Convert.ToString(FactoryRow["Factory_ID"]) + "'")) { Area area = new Area() { arID = Convert.ToInt32(AreaRow["Area_ID"]), Name = Convert.ToString(AreaRow["Name"]), Trains = new List <Train>() }; plant.Areas.Add(area); foreach (DataRow TrainRow in TrainDt.Select("Area_ID = '" + Convert.ToString(AreaRow["Area_ID"]) + "' ")) { Train Train = new Train() { trID = Convert.ToInt32(TrainRow["Train_ID"]), Name = Convert.ToString(TrainRow["name"]), Machines = new List <Machine>() }; area.Trains.Add(Train); foreach (DataRow MachineRow in MachineDt.Select("TrainID = '" + Convert.ToString(TrainRow["Train_ID"]) + "' ")) { Machine machine = new Machine() { macID = Convert.ToInt32(MachineRow["Machine_ID"]), Name = Convert.ToString(MachineRow["name"]), Points = new List <RecordPoint>() }; Train.Machines.Add(machine); foreach (DataRow PointRow in PointDt.Select(" Machine_ID = '" + Convert.ToString(MachineRow["Machine_ID"]) + "' ")) { RecordPoint point = new RecordPoint() { PointID = Convert.ToInt32(PointRow["Point_ID"]), Name = Convert.ToString(PointRow["POINTNAME"]), Points = new List <RecordPoint>() }; machine.Points.Add(point); } //foreach (DataRow PointRow in PointDt.Select(" Machine_ID = '" + Convert.ToString(MachineRow["Machine_ID"]) + "' ")) //{ // RecordPoint point = new RecordPoint() { Argument = "Argument" + pointCount, Value = rnd.Next(10) }; // machine.Points.Add(point); //} //foreach (int pointCount = 1; pointCount < 4; pointCount++) //{ // RecordPoint point = new RecordPoint() { Name = "Argument" + pointCount, PointID = rnd.Next(10) }; // machine.Points.Add(point); //} } } } } } catch { } return(plants); }
/// <summary> /// if ShpType == Polygon /// </summary> private void ParsePolygons() { List <Polygon> polygons = new List <Polygon>(); while (_br.CurrentIndex < _header.FileLength * 2) { //read some records RecordHeader recordHeader = new RecordHeader(); recordHeader.RecordNumber = _br.ReadInt(false); recordHeader.ContentLength = _br.ReadInt(false); RecordPolygon recordPolygon = new RecordPolygon(); int shpType = _br.ReadInt(true); recordPolygon.BoundingBoxMinX = _br.ReadDouble(true); recordPolygon.BoundingBoxMinY = _br.ReadDouble(true); recordPolygon.BoundingBoxMaxX = _br.ReadDouble(true); recordPolygon.BoundingBoxMaxY = _br.ReadDouble(true); recordPolygon.NumParts = _br.ReadInt(true); recordPolygon.NumPoints = _br.ReadInt(true); recordPolygon.Parts = new int[recordPolygon.NumParts]; recordPolygon.Points = new RecordPoint[recordPolygon.NumPoints]; for (int i = 0; i < recordPolygon.NumParts; i++) { recordPolygon.Parts[i] = _br.ReadInt(true); } List <RecordPoint> recordPoints = new List <RecordPoint>(); for (int i = 0; i < recordPolygon.NumPoints; i++) { RecordPoint recordPoint = new RecordPoint(); recordPoint.X = _br.ReadDouble(true); recordPoint.Y = _br.ReadDouble(true); recordPoints.Add(recordPoint); } //--split apart the parts into rings Polygon polygon = new Polygon(); if (recordPolygon.NumParts > 1) { for (int i = 0; i < recordPolygon.Parts.Length - 2; i++) { int startIndex = recordPolygon.Parts[i]; int endindex = recordPolygon.Parts[i + 1]; List <Point> ringPoints = new List <Point>(); for (int j = startIndex; j < endindex; j++) { RecordPoint p = recordPolygon.Points[j]; Point point = new Point(p.X, p.Y); ringPoints.Add(point); } polygon.LinearRings.Add(ringPoints); } } else { List <Point> ringPoints = new List <Point>(); foreach (var p in recordPoints) { Point point = new Point(p.X, p.Y); ringPoints.Add(point); } polygon.LinearRings.Add(ringPoints); } polygons.Add(polygon); } OutPolygons = polygons; int stop = 0; }