public void Test() { const int IMAGE_WIDTH = 4000; const int IMAGE_HEIGHT = 3000; Object[,] imageArray = new Object[IMAGE_WIDTH, IMAGE_HEIGHT]; for (int i = 0; i < IMAGE_WIDTH; i++) { for (int j = 0; j < IMAGE_HEIGHT; j++) { imageArray[i, j] = (Byte)((i * j) % 256); } } Stopwatch sw = Stopwatch.StartNew(); byte[] bytes = imageArray.ToByteArray(1, 0, 0, AlpacaErrors.AlpacaNoError, ""); output.WriteLine($"Time to create byte array: {sw.Elapsed.TotalMilliseconds:0.0}"); ArrayMetadataV1 metadata = bytes.GetMetadataV1(); Assert.True(metadata.TransmissionElementType == ImageArrayElementTypes.Byte); sw.Restart(); Object[,] responseArray = (Object[, ])bytes.ToImageArray(); output.WriteLine($"Time to create return array: {sw.Elapsed.TotalMilliseconds:0.0}"); Assert.True(TestSupport.CompareArrays(imageArray, responseArray, false, output)); }
private static void ArrayCasting() { // Create a 2-dim FileStream array FileStream[,] fs2dim = new FileStream[5, 10]; // Implicit cast to a 2-dim Object array Object[,] o2dim = fs2dim; // Can't cast from 2-dim array to 1-dim array // Compiler error CS0030: Cannot convert type 'object[*,*]' to 'System.IO.Stream[]' //Stream[] s1dim = (Stream[]) o2dim; // Explicit cast to 2-dim Stream array Stream[,] s2dim = (Stream[, ])o2dim; // Explicit cast to 2-dim Type array // Compiles but throws InvalidCastException at runtime try { Type[,] t2dim = (Type[, ])o2dim; } catch (InvalidCastException) { } // Create a 1-dim Int32 array (value types) Int32[] i1dim = new Int32[5]; // Can't cast from array of value types to anything else // Compiler error CS0030: Cannot convert type 'int[]' to 'object[]' // Object[] o1dim = (Object[]) i1dim; // However, Array.Copy knows how to coerce an array // of value types to an array of boxed references Object[] o1dim = new Object[i1dim.Length]; Array.Copy(i1dim, o1dim, 0); }
public SqlQuery(string sql, DbParameter[] parameters) { this.Sql = sql; this.parameters = parameters; this.dataArray = null; this.dataMap = null; }
public SqlQuery(string sql, IDictionary <String, Object> parameters) { this.Sql = sql; this.parameters = null; this.dataMap = parameters; this.dataArray = null; }
public SqlQuery(string sql, Object[,] data) { this.Sql = sql; this.parameters = null; this.dataMap = null; this.dataArray = data; }
public DataTable Convert2DArraytoDatatable(Object[,] numbers) { DataTable dt = new DataTable(); int colCount = numbers.GetLength(1); int rowCount = numbers.GetLength(0); dt = new DataTable(); int noofrow = 1; for (int c = 1; c <= colCount; c++) { dt.Columns.Add("Column" + (c)); noofrow = 1; } for (int i = noofrow; i <= rowCount; i++) { DataRow dr = dt.NewRow(); for (int j = 1; j <= colCount; j++) { dr[j - 1] = numbers[i, j]; } dt.Rows.Add(dr); } return(dt); }
public Maze(int numberOfRows, int numberOfColumns, int startingRow, int startingColumn, int destinationRow, int destinationColumn, Object[,] mazeObjects) { objects = mazeObjects; cells = new Cell[numberOfRows, numberOfColumns]; if (startingRow > -1 && startingRow < numberOfRows) { currentRowIndex = startingRow; InitialRowIndex = startingRow; } else { throw new ArgumentOutOfRangeException("Starting Row Index is not within the range of the board"); } if (startingColumn > -1 && startingColumn < numberOfColumns) { currentColumnIndex = startingColumn; InitialColumnIndex = startingColumn; } else { throw new ArgumentOutOfRangeException("Starting Column Index is not within the range of the board"); } if (destinationColumn > -1 && destinationColumn < numberOfColumns) { FinalRowIndex = destinationColumn; } else { throw new ArgumentOutOfRangeException("Destination Column Index is not within the range of the board"); } if (destinationRow > -1 && destinationRow < numberOfColumns) { FinalColumnIndex = destinationRow; } else { throw new ArgumentOutOfRangeException("Destination Row Index is not within the range of the board"); } for (int i = 0; i < numberOfRows * 2 + 1; i++) { for (int j = 0; j < numberOfColumns * 2 + 1; j++) { if (objects[i, j] is Space || objects[i, j] == null) { cells[i / 2, j / 2] = new Cell( northWall: (Wall)objects[i - 1, j], eastWall: (Wall)objects[i, j + 1], southWall: (Wall)objects[i + 1, j], westWall: (Wall)objects[i, j - 1]); } } } }
PopulateSourceColumnsCheckedListBox() { AssertValid(); System.Windows.Forms.ListBox.ObjectCollection oItems = clbSourceColumns.Items; oItems.Clear(); // Attempt to get the non-empty range of the active worksheet of the // selected source workbook. Range oNonEmptyRange; if (!TryGetSourceWorkbookNonEmptyRange(out oNonEmptyRange)) { return; } Boolean bSourceColumnsHaveHeaders = cbxSourceColumnsHaveHeaders.Checked; // Get the first row and column of the non-empty range. Range oFirstRow = oNonEmptyRange.get_Resize(1, Missing.Value); Range oColumn = oNonEmptyRange.get_Resize(Missing.Value, 1); Object [,] oFirstRowValues = ExcelUtil.GetRangeValues(oFirstRow); // Loop through the columns. Int32 iNonEmptyColumns = oNonEmptyRange.Columns.Count; Int32 iColumnOneBased = oColumn.Column; for (Int32 i = 1; i <= iNonEmptyColumns; i++, iColumnOneBased++) { String sColumnLetter = ExcelUtil.GetColumnLetter( ExcelUtil.GetRangeAddress((Range)oColumn.Cells[1, 1])); // Get the value of the column's first cell, if there is one. String sFirstCellValue; if (!ExcelUtil.TryGetNonEmptyStringFromCell(oFirstRowValues, 1, i, out sFirstCellValue)) { sFirstCellValue = null; } String sItemText = GetSourceColumnItemText(sFirstCellValue, sColumnLetter, bSourceColumnsHaveHeaders); oItems.Add(new ObjectWithText(iColumnOneBased, sItemText)); // Move to the next column. oColumn = oColumn.get_Offset(0, 1); } }
public SqlQuery(string sql) { this.Sql = sql; this.parameters = new DbParameter[0] { }; this.dataArray = null; this.dataMap = null; }
public Form_construct(From_menu from_menu) { InitializeComponent(); this.from_menu = from_menu; this.pen = Type.Road; this.map = new Object[13, 13]; this.penDown = false; }
public Level(string name, Object[,] map, string[] map_array, Goal[,] goalsMap, Dictionary <char, string> colorOfObject) { Name = name; Map = map; Map_array = map_array; GoalsMap = goalsMap; ColorOfObject = colorOfObject; }
ReadEdgeTable ( ListObject oEdgeTable, HashSet <String> oUniqueVertexNames ) { Debug.Assert(oEdgeTable != null); Debug.Assert(oUniqueVertexNames != null); Debug.Assert(oUniqueVertexNames.Count == 0); AssertValid(); // Get the vertex name column ranges. Range oVertex1NameRange, oVertex2NameRange; if (!ExcelTableUtil.TryGetTableColumnData(oEdgeTable, EdgeTableColumnNames.Vertex1Name, out oVertex1NameRange) || !ExcelTableUtil.TryGetTableColumnData(oEdgeTable, EdgeTableColumnNames.Vertex2Name, out oVertex2NameRange) ) { return; } Int32 iRows = oVertex1NameRange.Rows.Count; Debug.Assert(oVertex2NameRange.Rows.Count == iRows); // Read the vertex names all at once. Object [,] aoVertex1NameValues = ExcelUtil.GetRangeValues(oVertex1NameRange); Object [,] aoVertex2NameValues = ExcelUtil.GetRangeValues(oVertex2NameRange); // Loop through the edges. for (Int32 iRowOneBased = 1; iRowOneBased <= iRows; iRowOneBased++) { // Get the vertex names and add them to the HashSet. String sVertex1Name, sVertex2Name; if (ExcelUtil.TryGetNonEmptyStringFromCell(aoVertex1NameValues, iRowOneBased, 1, out sVertex1Name)) { oUniqueVertexNames.Add(sVertex1Name); } if (ExcelUtil.TryGetNonEmptyStringFromCell(aoVertex2NameValues, iRowOneBased, 1, out sVertex2Name)) { oUniqueVertexNames.Add(sVertex2Name); } } }
public virtual void SendArraysObject(Object[,] arr2, Object[,,] arr3, Object[,,,] arr4, BAsyncResult <Object[]> asyncResult) { BRequest_RemoteArrayTypes23_sendArraysObject req = new BRequest_RemoteArrayTypes23_sendArraysObject(); req.arr2Value = arr2; req.arr3Value = arr3; req.arr4Value = arr4; transport.sendMethod(req, asyncResult); }
/// <summary> /// Perform a SELECT query. /// </summary> /// /// <example> /// DataTable dt = Query("select * from STAFF where id = @id", new Object[,] { { "@id", 1 } }) /// </example> /// /// <param name="query">The SELECT statement, all params need to be prefixed with an @</param> /// <param name="paramList">An array of size (n x 2), each row describes a param (name, value)</param> /// /// <returns>A DataTable containing the results of the given SELECT</returns> public DataTable Query(String query, Object[,] paramList) { SqlCommand cmd = buildCommand(query, paramList); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable ans = new DataTable(); da.Fill(ans); return(ans); }
public List <string> Get_Cul(int ID) { var cel = ws.UsedRange; Object[,] cel1 = (Object[, ])cel.Value; var q = cel1[0, 1]; return(null); }
public Grid() { matrix = new Object[7, 7]; for (int i = 0; i < 49; i++) { SetValueAt(i, 0); } }
public ObjectGrid(string id, Object parent, char[,] grid, int tileWidth, int tileHeight) : base(id, parent) { _collums = grid.GetLength(0); _rows = grid.GetLength(1); _tileWidth = tileWidth; _tileHeight = tileHeight; _grid = new Object[_collums, _rows]; ReadTiles(grid); }
//Create empty ObjectGrid public ObjectGrid(string id, Object parent, int collums, int rows, int tileWidth, int tileHeight) : base(id, parent) { _collums = collums; _rows = rows; _tileWidth = tileWidth; _tileHeight = tileHeight; _grid = new Object[collums, rows]; BoundingBox = new Rectangle((int)Position.X, (int)Position.Y, collums * tileWidth, rows * tileHeight); }
WriteAllSettings() { AssertValid(); Debug.Assert(m_oSettings != null); ListObject oPerWorkbookSettingsTable; if (!TryGetPerWorkbookSettingsTable(out oPerWorkbookSettingsTable)) { return; } // Clear the table. ExcelUtil.ClearTable(oPerWorkbookSettingsTable); // Attempt to get the optional table columns that contain the settings. Range oNameColumnData, oValueColumnData; if ( !ExcelUtil.TryGetTableColumnData(oPerWorkbookSettingsTable, PerWorkbookSettingsTableColumnNames.Name, out oNameColumnData) || !ExcelUtil.TryGetTableColumnData(oPerWorkbookSettingsTable, PerWorkbookSettingsTableColumnNames.Value, out oValueColumnData) ) { return; } // Copy the settings to arrays. Int32 iSettings = m_oSettings.Count; Object [,] aoNameColumnValues = ExcelUtil.GetSingleColumn2DArray(iSettings); Object [,] aoValueColumnValues = ExcelUtil.GetSingleColumn2DArray(iSettings); Int32 i = 1; foreach (KeyValuePair <String, Object> oKeyValuePair in m_oSettings) { aoNameColumnValues[i, 1] = oKeyValuePair.Key; aoValueColumnValues[i, 1] = oKeyValuePair.Value; i++; } // Write the arrays to the columns. ExcelUtil.SetRangeValues(oNameColumnData, aoNameColumnValues); ExcelUtil.SetRangeValues(oValueColumnData, aoValueColumnValues); }
public virtual void ImportXls(DataTable dt) { int rowcnt = 1; string keyfield = dt.Columns[0].Caption; Object[,] data = readCell(1, ++rowcnt, dt.Columns.Count); string tmp = ""; while (data[1, 1] != null) { tmp += data[1, 1].ToString() + "{}"; DataRow[] dr = dt.Select(keyfield + "='" + data[1, 1].ToString() + "'"); if (dr != null && dr.Length > 0 && (!data[1, 1].ToString().Equals("-1"))) { dr[0].BeginEdit(); for (int i = 0; i < data.GetUpperBound(1); i++) { if (data[1, i + 1] != null) { dr[0][i] = data[1, i + 1]; } } dr[0].EndEdit(); } else { DataRow r = dt.NewRow(); r.BeginEdit(); for (int i = 0; i < data.GetUpperBound(1); i++) { if (data[1, i + 1] != null) { if (dt.Columns[i].DataType == typeof(DateTime)) { DateTime dati; String s = data[1, i + 1].ToString(); // MessageBox.Show(s); if (DateTime.TryParse(s, out dati)) { r[i] = dati; } } else { r[i] = data[1, i + 1]; } } } r.EndEdit(); dt.Rows.Add(r); } data = readCell(1, ++rowcnt, dt.Columns.Count); } }
private SqlCommand buildCommand(String query, Object[,] paramList) { SqlCommand cmd = new SqlCommand(query, connection); for (int i = 0; i < paramList.GetLength(0); ++i) { cmd.Parameters.AddWithValue(paramList[i, 0].ToString(), paramList[i, 1]); } return(cmd); }
private string GetCellValue(Object[,] arry, int row, int col) { object o = arry.GetValue(row, col); if (o == null || o is DBNull || o.Equals("")) { return(""); } return(o.ToString()); }
/// <summary> /// 엑셀에 시간표를 입력한다. /// </summary> /// <param name="timeTable">시간표 정보</param> public void WriteOnExcel(Object[,] timeTable) { Excel.Application excelApp = null; Excel.Workbook wb = null; Excel.Worksheet ws = null; Object path = new Object(); path = @"C: \User\gjwls\Desktop\MyTimeTableSub"; //int row = 23,column = 6; try { excelApp = new Excel.Application(); wb = excelApp.Workbooks.Open(@"C:\Users\gjwls\Desktop\MyTimeTable"); // 엑셀파일을 엽니다. // ExcelPath 대신 문자열도 가능합니다 // 예. Open(@"D:\test\test.xlsx"); ws = wb.Worksheets.get_Item(1) as Excel.Worksheet; // 첫번째 Worksheet를 선택합니다. Excel.Range rng = ws.Range["A1", "F26"]; //ws.Range[ws.Cells[1, 1], ws.Cells[row, column]]; // 해당 Worksheet에서 저장할 범위를 정합니다. // 지금은 저장할 행렬의 크기만큼 지정합니다. // 다른 예시 Excel.Range rng = ws.Range["B2", "G8"]; Object[,] data = timeTable; // 저장할 때 사용할 object 행렬 // for문이 아니더라도 object[,] 형으로 저장된다면 저장이 가능합니다. rng.Value = data; // data를 불러온 엑셀파일에 적용시킵니다. 아직 완료 X if (path != null) { // path는 새로 저장될 엑셀파일의 경로입니다. // 따로 지정해준다면, "다른이름으로 저장" 의 역할을 합니다. // 상대경로도 가능합니다. (예. "secondExcel.xlsx") wb.SaveCopyAs(path); } else { // 따로 저장하지 않는다면 지금 파일에 그대로 저장합니다. wb.Save(); } wb.Close(); excelApp.Quit(); } catch (SystemException e) { Console.WriteLine(e.Message); } }
public DataTable Convert2DArraytoDatatable(Object[,] numbers) { DataTable dt = new DataTable(); int colCount = numbers.GetLength(1); int rowCount = numbers.GetLength(0); dt = new DataTable(); if (true == IsHeader) { DataRow dr = null; for (int i = 1; i <= rowCount; i++) { if (1 != i) { dr = dt.NewRow(); } for (int j = 1; j <= colCount; j++) { if (1 == i) { dt.Columns.Add(numbers[i, j].ToString()); } else { dr[j - 1] = numbers[i, j]; } } if (1 != i) { dt.Rows.Add(dr); } } } else { for (int c = 1; c <= colCount; c++) { dt.Columns.Add("Column" + (c)); } for (int i = 1; i <= rowCount; i++) { DataRow dr = dt.NewRow(); for (int j = 1; j <= colCount; j++) { dr[j - 1] = numbers[i, j]; } dt.Rows.Add(dr); } } return(dt); }
private (bool success, string error) ParseInitialState(List <string> rows) { if (rows.Count <= 2) { return(false, "Invalid state definition."); } var levelWidth = rows.Max(r => r.Length); var levelHeight = rows.Count; var rowIndex = 0; map = new Object[levelHeight, levelWidth]; agentOccured = new Dictionary <char, bool>(); boxOccurences = new Dictionary <char, int>(); foreach (var row in rows) { for (int i = 0; i < row.Length; i++) { var symbol = row[i]; if (!IsSymbol(symbol)) { return(false, $"Unexpected symbol '{symbol}'."); } if ((IsBox(symbol) || IsAgent(symbol)) && !colors.ContainsKey(symbol)) { return(false, $"The object {symbol} does not have a color specified."); } map[rowIndex, i] = ToObject(symbol); if (IsBox(symbol)) { boxOccurences.TryGetValue(symbol, out var occurences); boxOccurences[symbol] = occurences + 1; } if (IsAgent(symbol)) { if (agentOccured.ContainsKey(symbol)) { return(false, $"The agent '{symbol}' already occured on the map."); } agentOccured[symbol] = true; } } rowIndex++; } return(true, null); }
GetRowCount ( Object [,] aoColumnValues ) { Debug.Assert(aoColumnValues != null); AssertValid(); return(aoColumnValues.GetUpperBound(0) - aoColumnValues.GetLowerBound(0) + 1); }
public Boolean DeleteProvider(out String Message, provider objProvider) { Message = String.Empty; par = new Object[,] { { "@ID", objProvider.providerId }, { "@TxnType", TransactionType.DELETE } }; return Delete(par, SP_Insert_Update_Delete, out Message); }
MarkRowsForDeletion ( ListObject oEdgeTable, Object [,] aoVertex1NameValues, Object [,] aoVertex2NameValues, Object [,] aoThirdColumnValues, Boolean bGraphIsDirected, out ListColumn oDeleteIfEmptyColumn, out Range oDeleteIfEmptyData, out Object [,] aoDeleteIfEmptyValues ) { Debug.Assert(oEdgeTable != null); Debug.Assert(aoVertex1NameValues != null); Debug.Assert(aoVertex2NameValues != null); AssertValid(); HashSet <String> oUniqueEdgeKeys = new HashSet <String>(); if (!ExcelTableUtil.TryGetOrAddTableColumn(oEdgeTable, DeleteIfEmptyColumnName, ExcelTableUtil.AutoColumnWidth, null, out oDeleteIfEmptyColumn, out oDeleteIfEmptyData, out aoDeleteIfEmptyValues)) { throw new InvalidOperationException( "Can't add marked for deletion column."); } Int32 iRows = GetRowCount(aoVertex1NameValues); for (Int32 iRowOneBased = 1; iRowOneBased <= iRows; iRowOneBased++) { String sEdgeKey; Object oDeleteIfEmpty = 1; if ( TryGetEdgeKey(iRowOneBased, aoVertex1NameValues, aoVertex2NameValues, aoThirdColumnValues, bGraphIsDirected, out sEdgeKey) && !oUniqueEdgeKeys.Add(sEdgeKey) ) { // This is a duplicate that is not the first instance. It // should be deleted. oDeleteIfEmpty = null; } aoDeleteIfEmptyValues[iRowOneBased, 1] = oDeleteIfEmpty; } oDeleteIfEmptyData.set_Value(Missing.Value, aoDeleteIfEmptyValues); }
public CMapLockContainer(Int32 width, Int32 height) { _locks = new Object[width, height]; for (var x = 0; x < width; ++x) { for (var y = 0; y < height; y++) { _locks[x, y] = new Object(); } } }
public Grid(Grid gd) { matrix = new Object[7, 7]; for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { this.matrix[i, j] = gd.matrix[i, j]; } } }
public Grid(Object[,] obj) { matrix = new Object[7, 7]; for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { this.matrix[i, j] = obj[i, j]; } } }
public void generateMatrix(Graph g) { int dim = g.getNodeList().Count(); Object[,] matrixC = new Object[dim, dim + 1]; //+1 <=> colonne ajoutée pour les noms //On ajoute les noms de noeuds à la matrice for (int i = 0; i < dim; i++) matrixC[i, 0] = g.getNodeAt(i).getName(); //On remplit les cases connues foreach (Node n in g.getNodeList()) { foreach (Arc a in n.getEgressArc()) { int x = a.getOrigin().getIndex(); int y = a.getEdge().getIndex(); setValueAt(matrixC, a.getCost(), x, y+1); } } //On remplie les cases inconnues for (int i = 0; i < dim; i++) { for (int j = 1; j < dim + 1; j++) { if(matrixC[i, j]==null) { if (i + 1 == j) matrixC[i, j] = 0; else matrixC[i, j] = int.MaxValue; } } } this.costMatrix = matrixC; refreshCalcM(); }
//Construye un nodo a partir de su valor y lo agrega a la lista de nodos public CVertice AgregarVertice(string valor) { nodos = (Object[,])ResizeArray(nodos, cantNodos + 1); CVertice nodo = new CVertice(valor); nodos[cantNodos, 0] = nodo; for (int x = 1; x <= cantNodos; x++) { nodos[cantNodos, x] = -1; nodos[x, cantNodos] = -1; } nodos[0, cantNodos] = nodo; cantNodos++; return nodo; }
/** @brief Metodo que se encarga de llenar el comboBox con los proyectos que hay en la base de datos. */ private void llena_proyectos_disponibles() { DataTable tabla_proyectos = m_controladora_pdp.solicitar_proyectos_disponibles(); m_tamano_tabla_pdp = tabla_proyectos.Rows.Count; m_tabla_proyectos_disponibles = new Object[m_tamano_tabla_pdp, 2]; for (int i = 0; i < m_tamano_tabla_pdp; ++i) { m_tabla_proyectos_disponibles[i, 0] = Convert.ToInt32(tabla_proyectos.Rows[i]["id_proyecto"]); m_tabla_proyectos_disponibles[i, 1] = tabla_proyectos.Rows[i]["nombre_proyecto"].ToString(); ListItem item_proyecto = new ListItem(); item_proyecto.Text = Convert.ToString(m_tabla_proyectos_disponibles[i, 1]); item_proyecto.Value = Convert.ToString(m_tabla_proyectos_disponibles[i, 0]); drop_proyecto_asociado.Items.Add(item_proyecto); } }
//读取数据 private void btRead_Click(object sender, EventArgs e) { int MAXLINE = 5000; int i = 0, j = 0, k = 0, m = 0;//m为总行数 int fileCount = lvFile.Items.Count; string DataTag; int eCount = 0;//有效工作簿数 int sCount = 0;//当前表中工作簿数 Point point; Object missing = Type.Missing; int iCount = lbContent.Items.Count; //重点区域,范围型读取单元格区域 RangeSelector mainRange = new RangeSelector(tbMainRange.Text); //预判断块读取还是固定位置读取,初始化总数组大小 if (mainRange.getWidth() > 0) myArray = new String[MAXLINE, mainRange.getWidth() + iCount + 1];//最多千行 else myArray = new String[MAXLINE, iCount + 1];//最多千行 //開啟一個新的應用程式 myExcel = new Excel.Application(); for (i = 0; i < fileCount; i++) { //停用警告訊息 myExcel.DisplayAlerts = false; //讓Excel文件可見 myExcel.Visible = true; //引用第一個活頁簿 myBook = myExcel.Workbooks.Open(lvFile.Items[i].SubItems[2].Text, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing); //設定活頁簿焦點 myBook.Activate(); //判断所有工作簿 sCount = myBook.Worksheets.Count; for (k = 1; k <= sCount; k++) { //大表判断条件 if (cbSheetSelect.Text != "全部" && Int16.Parse(cbSheetSelect.Text) != k) continue; //选择当前表 mySheet = (Worksheet)myBook.Worksheets[k]; //設工作表焦點 mySheet.Activate(); //特征值判断 if (tbSheetPos.Text != "") { point = pointPos(tbSheetPos.Text); if (mySheet.Cells[point.Y, point.X].Value != tbSheetCont.Text) continue; } eCount++; //备注列判断 if (tbDataTag.Text == "") DataTag = lvFile.Items[i].SubItems[0].Text; //未设置备注默认使用文件名 else { Point tagpos = pointPos(tbDataTag.Text); DataTag = Convert.ToString(mySheet.Cells[tagpos.Y, tagpos.X].Value); } string mainStart = tbMainStart.Text; string mainEnd = tbMainEnd.Text; //判断选择哪种模式 if (mainRange.Count() > 1) { mainRange = new RangeSelector(tbMainRange.Text);//重新恢复原区域值 //重点区域起始位置判断 Point nowPos = mainRange.getCurPos(); for (j = 0; j < mainRange.Count(); j++) { string myCell = Convert.ToString(mySheet.Cells[nowPos.Y, nowPos.X].Value); if (mainStart == "") break; if (myCell == mainStart) break; mainRange.acc(); } //mainRange.lineacc(); //移到关键字下一行 mainRange.SetStartVal(mainRange.getCurPos()); //读取内容 while (m < MAXLINE) //最大读取行数上限估计 { nowPos = mainRange.getCurPos(); string lineFirstCell = Convert.ToString(mySheet.Cells[nowPos.Y, nowPos.X].Value); if (lineFirstCell == null|| lineFirstCell=="") break; //首字为空 if (lineFirstCell == tbMainEnd.Text) break; //符合结束字符串 if (mainRange.pos > mainRange.Count()) break;//读取完了就退出 for (j = 0; j < mainRange.getWidth(); j++)//读取一行 { point = mainRange.getCurPos(); myArray[m, j] = Convert.ToString(mySheet.Cells[point.Y, point.X].Value); //不管什么类型都转为字符串 mainRange.acc(); } myArray[m, j] = DataTag; m++; } } else { //准备读取单元格相关信息,固定位置读取单元格 if (iCount >= 1) { List<Array> ListOfLine = new List<Array>(); //所有的读取行集合 String[] myLine = new String[iCount]; //单行对象 RangeSelector[] rsContentA = new RangeSelector[iCount]; for (j = 0; j < iCount; j++) { rsContentA[j] = new RangeSelector(lbContent.Items[j].ToString()); } j = 0; foreach (RangeSelector cont in rsContentA) { cont.acc(); point = cont.getCurPos(); myArray[m, j] = Convert.ToString(mySheet.Cells[point.Y, point.X].Value); //不管什么类型都转为字符串 j++; if (j > iCount) break;//xxxxxxx } myArray[m, j - 1] = DataTag; m++; } } } //关闭当前活页簿 myBook.Close(); System.Windows.Forms.Application.DoEvents(); } myExcel.Quit(); }
//************************************************************************* // Method: GetRows() // /// <summary> /// Enumerates the rows in the table. /// </summary> /// /// <returns> /// An enumerable that enumerates the rows in the table. /// </returns> /// /// <remarks> /// Filtered rows are automatically skipped. /// </remarks> //************************************************************************* public IEnumerable<ExcelTableRow> GetRows() { AssertValid(); // Get the visible range. If the table is filtered, the range may // contain multiple areas. Range oVisibleTableRange; if ( !ExcelUtil.TryGetVisibleTableRange(m_oTable, out oVisibleTableRange) ) { yield break; } // Loop through the areas, and split each area into subranges if the // area contains too many rows. ExcelTableRow oExcelTableRow = new ExcelTableRow(this); foreach ( Range oSubrange in ExcelRangeSplitter.SplitRange(oVisibleTableRange) ) { m_oCurrentSubrange = oSubrange; m_aoCurrentSubrangeValues = ExcelUtil.GetRangeValues( m_oCurrentSubrange); Int32 iRows = m_oCurrentSubrange.Rows.Count; for (m_iCurrentRowOneBased = 1; m_iCurrentRowOneBased <= iRows; m_iCurrentRowOneBased++) { // Note that the same ExcelTableRow object is always returned, // and the object doesn't know anything about the current row. // The current row information is maintained by this class, not // by ExcelTableRow, and ExcelTableRow forwards all its method // calls to this class. yield return (oExcelTableRow); } } m_oCurrentSubrange = null; m_aoCurrentSubrangeValues = null; m_iCurrentRowOneBased = Int32.MinValue; }
//************************************************************************* // Constructor: ExcelTableReader() // /// <summary> /// Initializes a new instance of the <see cref="ExcelTableReader" /> /// class. /// </summary> /// /// <param name="table"> /// The table to read. The table must have no hidden columns. /// </param> /// /// <remarks> /// If <paramref name="table" /> has hidden columns, an exception is /// thrown. Use the <see cref="ExcelColumnHider" /> class to temporarily /// show all hidden columns if necessary. /// </remarks> //************************************************************************* public ExcelTableReader( ListObject table ) { Debug.Assert(table != null); m_oTable = table; m_oColumnIndexesOneBased = new Dictionary<String, Int32>(); ListColumns oColumns = table.ListColumns; Int32 iColumns = oColumns.Count; for (Int32 i = 1; i <= iColumns; i++) { String sColumnName = oColumns[i].Name; if ( !String.IsNullOrEmpty(sColumnName) ) { m_oColumnIndexesOneBased.Add(sColumnName, i); } } m_oCurrentSubrange = null; m_aoCurrentSubrangeValues = null; m_iCurrentRowOneBased = Int32.MinValue; AssertValid(); }
/** @brief Se encarga de llenar la tabla de proyectos de pruebas que contiene a todos los proyectos, dentro de la base de datos. **/ private void llena_proyectos_de_pruebas() { DataTable tabla_de_datos; if (m_es_administrador) tabla_de_datos = m_controladora_pdp.solicitar_proyectos_disponibles(); else tabla_de_datos = m_controladora_pdp.consultar_mi_proyecto(Context.User.Identity.Name); m_tamano_tabla_pdp = tabla_de_datos.Rows.Count; m_tabla_proyectos_disponibles = new Object[m_tamano_tabla_pdp, 2]; crea_encabezado_tabla_proyectos(); for (int i = (m_tamano_tabla_pdp - 1); i >= 0; --i) { TableRow fila = new TableRow(); TableCell celda_boton = new TableCell(); TableCell celda_estado = new TableCell(); TableCell celda_oficina = new TableCell(); TableCell celda_encargado = new TableCell(); Button btn = new Button(); string[,] info_oficina = new string[1, 2]; //la oficina y el representante de la oficina asociada al proyecto m_tabla_proyectos_disponibles[i, 0] = Convert.ToInt32(tabla_de_datos.Rows[i]["id_proyecto"]); m_tabla_proyectos_disponibles[i, 1] = Convert.ToString(tabla_de_datos.Rows[i]["nombre_proyecto"]); //Crea el boton btn.ID = Convert.ToString(m_tabla_proyectos_disponibles[i, 0]); btn.Text = Convert.ToString(m_tabla_proyectos_disponibles[i, 1]); btn.CssClass = "btn btn-link"; btn.Click += new EventHandler(btn_lista_pdp_click); celda_boton.Controls.AddAt(0, btn); fila.Cells.AddAt(0, celda_boton); celda_estado.Text = Convert.ToString(tabla_de_datos.Rows[i]["estado"]); fila.Cells.AddAt(1, celda_estado); info_oficina = busca_info_oficina(Convert.ToInt32(tabla_de_datos.Rows[i]["id_oficina"])); celda_oficina.Text = info_oficina[0, 0]; fila.Cells.AddAt(2, celda_oficina); celda_encargado.Text = info_oficina[0, 1]; fila.Cells.AddAt(3, celda_encargado); tabla_proyectos_de_pruebas.Rows.Add(fila); } }
/** @brief Metodo que se encarga de llenar el dropbox con las oficinas disponibles. */ private void llena_oficinas_disponibles() { DataTable tabla_oficinas = m_controladora_pdp.solicitar_oficinas_disponibles(); m_tamano_tabla_oficinas = tabla_oficinas.Rows.Count; m_tabla_oficinas_disponibles = new Object[m_tamano_tabla_oficinas, 3]; for (int i = 0; i < m_tamano_tabla_oficinas; ++i) { m_tabla_oficinas_disponibles[i, 0] = Convert.ToInt32(tabla_oficinas.Rows[i]["id_oficina"]); m_tabla_oficinas_disponibles[i, 1] = Convert.ToString(tabla_oficinas.Rows[i]["nombre_oficina"]); m_tabla_oficinas_disponibles[i, 2] = Convert.ToString(tabla_oficinas.Rows[i]["nom_representante"]); ListItem item_oficina = new ListItem(); item_oficina.Text = Convert.ToString(m_tabla_oficinas_disponibles[i, 1]); item_oficina.Value = Convert.ToString(m_tabla_oficinas_disponibles[i, 0]); drop_oficina_asociada.Items.Add(item_oficina); } }
//将所有内容读取保存到myarray private void btReadWord_Click(object sender, EventArgs e) { int fileCount = lvFile.Items.Count; WordReader reader = new WordReader(); reader.ResetData(); for (int i = 0; i < fileCount; i++) { reader.ReadOne(lvFile.Items[i].SubItems[2].Text); reader.dataArray[i, reader.colCount] = lvFile.Items[i].SubItems[0].Text; } myArray = reader.dataArray; MessageBox.Show("读取完毕"); }
public CGrafo(string valor) { nodos = new Object[cantNodos, cantNodos]; AgregarVertice(valor); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { // RestfullModel.test(); // RestfullMAnswersodel.setParameters(new List<Parameter>() { new Parameter("lv", new List<string>() { "a", "b" }), new Parameter("de", new List<string>() { "a" }) }); Answers = new List<int>(); cmdTryAgain = new RelayCommand(()=> { ResultsVisible = Visibility.Hidden; QuestionVisible = Visibility.Visible; }); cmdYes = new RelayCommand(() => { _Response = true; ProgressBar++; RaisePropertyChanged(() => ProgressBar); }); cmdNo = new RelayCommand(() => { _Response = false; ProgressBar++; RaisePropertyChanged(() => ProgressBar); }); questionList = new List<Question>(); answeredList = new List<Question>(); _numberOfQuestions = 20; _questionsAnswered = 0; //List<Param> Params= new List<Param>() //{ // new Param(){Question = "Are you looking for a Masters Education?", ParamName = "lv", Params = new List<string>(){}) // }} //}; questions = new Object[,] { { "Are you looking for a Masters Education?", new Parameter("lv", new List<string>{"master"}), new Parameter("lv", new List<string>{"bachelor", "Phd", "short"}) }, { "Do you want a full time study ?", new Parameter("de", new List<string>{"fulltime"}), new Parameter("de", new List<string>{"parttime"}) }, { "Are you looking for exact science?", new Parameter("di", new List<string>{"7", "10" , "11" , "12", "24","117", "258" }), new Parameter("di", new List<string>{"6", "9", "13", "23", "54", "58", "64", "289" }) } }; for (int i = 0; i < 3 ; i++) { List<Parameter> args = new List<Parameter>(); //args.Add(questions[i, 1]); //args.Add(questions[i, 2]); questionList.Add(new Question(i, questions[i,0].ToString(), i, false, args)); } QuestionToDisplay = questionList[_questionsAnswered].question; RaisePropertyChanged(() => QuestionToDisplay); ResultsVisible=Visibility.Hidden; }
//Création de la matrice à partir d'une matrice existante public Matrix(Object[,] m) { this.costMatrix = m; refreshCalcM(); }
public Boolean SaveProvider(out String Message, providerList providerlist, provider objProvider) { Message = String.Empty; //Check if duplicate records exists in the category list if (providerlist.Select(element => element.providerName = objProvider.providerName).Count() > 1) { Message = CustomMessages.DUPLICATE("Provider", "Name"); return false; } else { par = new Object[,] { { "@ID", objProvider.providerId } , { "@Name", objProvider.providerName } , { "@Order", objProvider.providerOrder } , { "@Status", objProvider.providerStatus } , { "@CreatedBy", HttpContext.Current.Session["UserID"] } , { "@ModifiedBy", HttpContext.Current.Session["UserID"] } , { "@TxnType", (objProvider.providerId>0 ? TransactionType.UPDATE: TransactionType.INSERT) } }; return Save(par, SP_Insert_Update_Delete, out Message); } }
private Image imgBuffer_CB = null;//剪贴板图形 private void copyRectSelect() { if ((this.editMode != EDITMOD_RECT_SELECT && this.editMode != EDITMOD_STRAW) || currentMap == null) { return; } if (frameX_0 < 0 || frameY_0 < 0 || frameX_1 < 0 || frameY_1 < 0) { return; } //计算参数 int xMin = Math.Min(frameX_0, frameX_1); int yMin = Math.Min(frameY_0, frameY_1); int xMax = Math.Max(frameX_0, frameX_1); int yMax = Math.Max(frameY_0, frameY_1); copyedW = xMax - xMin + 1; copyedH = yMax - yMin + 1; //重设缓存大小 clipBoard = new Object[copyedW, copyedH]; //复制数据 for (int i = 0; i < copyedW; i++) { for (int j = 0; j < copyedH; j++) { clipBoard[i, j] = currentMap.getTileClone(xMin + i, yMin + j, Consts.currentLevel, currentStageID); } } copyedLevel = Consts.currentLevel; generateCBImage(); }
//从容器复制一块区域并且粘贴 private void copyFromGfxSelect() { if (currentMap == null || (Consts.currentLevel != Consts.LEVEL_TILE_BG && Consts.currentLevel != Consts.LEVEL_TILE_SUR)) { return; } if (this.editMode != EDITMOD_STRAW) { setEditMode(EDITMOD_STRAW); } TileGfxElement tile_Gfx0 = (TileGfxElement)currentGfxContainer[idStart]; TileGfxElement tile_Gfx1 = (TileGfxElement)currentGfxContainer[idEnd]; int rowCount = pictureBox_Gfx.Width/currentMap.getTileW(); int xMin = Math.Min(tile_Gfx0.GetID() % rowCount, tile_Gfx1.GetID() % rowCount); int yMin = Math.Min(tile_Gfx0.GetID() / rowCount, tile_Gfx1.GetID() / rowCount); int xMax = Math.Max(tile_Gfx0.GetID() % rowCount, tile_Gfx1.GetID() % rowCount); int yMax = Math.Max(tile_Gfx0.GetID() / rowCount, tile_Gfx1.GetID() / rowCount); int width_Fox = xMax - xMin; int height_Fox = yMax - yMin; copyedW = xMax - xMin + 1; copyedH = yMax - yMin + 1; //重设缓存大小 clipBoard = new Object[copyedW, copyedH]; //复制数据 for (int i = 0; i < copyedW; i++) { for (int j = 0; j < copyedH; j++) { int index = xMin + (j+yMin) * rowCount + i; clipBoard[i, j] = new TransTileGfxElement((TileGfxElement)currentGfxContainer[index],0); } } copyedLevel = Consts.currentLevel; //准备剪贴板缓冲 int bufferWidth = copyedW * TileW; int bufferHeight = copyedH * TileH; if (imgBuffer_CB == null || imgBuffer_CB.Width < bufferWidth || imgBuffer_CB.Height < bufferHeight) { imgBuffer_CB = new Bitmap(bufferWidth, bufferHeight); } Graphics g = Graphics.FromImage(imgBuffer_CB); g.Clear(Color.Transparent); int zoomLevel = 1; for (int i = 0; i < copyedW; i++) { for (int j = 0; j < copyedH; j++) { if (clipBoard[i, j] == null) { continue; } TransTileGfxElement gfxElement = (TransTileGfxElement)clipBoard[i, j]; byte flag=gfxElement.tileGfxElement.getTansFlag(); flag = Consts.getTransFlag(flag, gfxElement.transFlag); gfxElement.tileGfxElement.display(g, i * TileW, j * TileH, zoomLevel, flag, null); } } g.Dispose(); g = null; }
/// <summary> /// Supprime un noeud /// </summary> /// <param name="nIndex"></param> public void removeNode(int nIndex) { int nbRow = costMatrix.GetLength(0); int nbCol = costMatrix.GetLength(1); if (nIndex < 0 || nIndex >= nbRow) return; //pas valide Object[,] matrixC = new Object[nbRow-1, nbCol-1]; //nouvelle matrice int i2 = 0, j2 = 0; for (int i = 0; i < nbRow; i++) { j2 = 0; if (i != nIndex) { for (int j = 0; j < nbCol; j++) { if (j != nIndex + 1) { matrixC[i2, j2] = costMatrix[i, j]; j2++; } } i2++; } } this.costMatrix=matrixC; refreshCalcM(); }
private Object[,] costMatrix; //Matrice de cout avec le nom des sommets #endregion Fields #region Constructors public Matrix() { this.costMatrix = new Object[0, 0]; this.calcMatrix = new int[0, 0]; }
//public String NewReg_IsValidEmail(String Email, String ActivationCode) //{ // String Message = String.Empty; // if (Email != String.Empty && ActivationCode != String.Empty) // { // if (_.IsValidString(Email)) // { // par = new Object[,] // { // { "@Email", Email }, // { "@Code", ActivationCode } // }; // myDataSet = ExecuteDataSet(SP_Activate_Account, par, CommandType.StoredProcedure); // if (myDataSet != null && myDataSet.Tables.Count > 0 && myDataSet.Tables[0].Rows.Count > 0) // { // switch (myDataSet.Tables[0].Rows[0]["Status"].ToString()) // { // case "ACTIVATION_LINK_STATUS_ACTIVE": // Message = CustomMessage.ACTIVATION_LINK_STATUS_ACTIVE; // break; // case "Deleted": // Message = CustomMessage.Deleted; // break; // case "InActive": // Message = CustomMessage.InActive; // break; // case "SUCCESS": // Message = CustomMessage.SUCCESS; // break; // case "ACTIVATION_LINK_INVALID": // Message = CustomMessage.ACTIVATION_LINK_INVALID; // break; // case "USER_DOESNOT_EXIST": // Message = CustomMessage.USER_DOESNOT_EXIST; // break; // default: // Message = CustomMessage.INVALID_SERVICE_REQUEST; // break; // } // } // else // Message = CustomMessage.INVALID_SERVICE_REQUEST; // } // else // Message = CustomMessage.INVALID_CHARS; // } // else // Message = CustomMessage.MANDATORY_FIELDS; // return Message; //} //public String NewReg_IsValidEmail(String Email) //{ // String Message = String.Empty; // if (Email != String.Empty) // { // if (IsValidString(Email)) // { // par = new Object[,] // { // { "@Email", Email } // }; // myDataSet = ExecuteDataSet(SP_Is_New_Email_Valid, par, CommandType.StoredProcedure); // if (myDataSet != null && myDataSet.Tables.Count > 0 && myDataSet.Tables[0].Rows.Count > 0 && // myDataSet.Tables[0].Rows[0]["Status"].ToString().ToUpper() != "SUCCESS") // Message = CustomMessage.USER_ALREADY_EXISTS(Email); // else // Message = CustomMessage.SUCCESS; // } // else // Message = CustomMessage.INVALID_CHARS; // } // else // Message = CustomMessage.MANDATORY_FIELDS; // return Message; //} public String Authenticate(String Username, String Password, String IPAddress) { String Message = String.Empty; if (Username.Trim() != String.Empty && Password.Trim() != String.Empty) { if (_.IsValidString(Username)) { Username = Username.Trim().ToString().ToLower(); ////Satya hack to check jquery with wcf //if (Username == "satya" && Decrypt(Password) == "satya") //{ // Message = "Success"; //} //else // Message = "Failed"; //return Message; par = new Object[,] { { "@Username", Username }, { "@Password", Password }, { "@LoginIP", IPAddress } }; myDataSet = ExecuteDataSet(SP_ValidateUser, par, CommandType.StoredProcedure); if (myDataSet != null && myDataSet.Tables.Count > 0 && myDataSet.Tables[0].Rows.Count > 0) { //Occurs if user is invalid if (myDataSet.Tables[0].Rows[0]["ERROR"] != null || myDataSet.Tables[0].Rows[0]["ERROR"].ToString() != String.Empty) { switch (myDataSet.Tables[0].Rows[0]["ERROR"].ToString().ToUpper()) { case "USER_CRED_INCORRECT": Message = CustomMessages.USER_CRED_INCORRECT; break; case "USER_DOESNOT_EXIST": Message = CustomMessages.USER_DOESNOT_EXIST; break; default: Message = CustomMessages.INVALID_SERVICE_REQUEST; break; } } else { if ((Status)int.Parse(myDataSet.Tables[0].Rows[0]["User_Status"].ToString()) == Status.Active) { //if (ActiveUser.ActiveUserList.Count == 0) //{ // CurrentUser clsCurrentUser = new CurrentUser(); // clsCurrentUser.Remove(); //} //objActiveUser = new ActiveUser(); //System.Web.HttpContext.Current.Session["UserID"] = objActiveUser.ID = Int32.Parse(myDataSet.Tables[0].Rows[0]["ID"].ToString()); //objActiveUser.Username = myDataSet.Tables[0].Rows[0]["UserName"].ToString(); //objActiveUser.Password = myDataSet.Tables[0].Rows[0]["Password"].ToString(); //objActiveUser.Role = (Role)int.Parse(myDataSet.Tables[0].Rows[0]["User_Role"].ToString()); //if (ActiveUser.ActiveUserList.SingleOrDefault(p => p.ID == objActiveUser.ID) == null) // ActiveUser.ActiveUserList.Add(objActiveUser); //else // System.Web.HttpContext.Current.Session["UserID"] = objActiveUser.ID; //throw new Exception("A User has already logged in with this account. Details<br/>" + // " <b>IP Address- </b>" + System.Web.HttpContext.Current.Request.ServerVariables["remote_addr"] + "<br/>" + // " <b>Name - </b>" + System.Web.HttpContext.Current.Request.LogonUserIdentity.Name); //DBTransaction.Income = tempIN.ToString().Remove(tempIN.ToString().Split('.')[0].Length + 2, 2); } else { switch ((Status)int.Parse(myDataSet.Tables[0].Rows[0]["User_Status"].ToString())) { case Status.Deleted: Message = CustomMessages.Deleted; break; case Status.InActive: Message = CustomMessages.InActive; break; default: Message = CustomMessages.INVALID_SERVICE_REQUEST; break; } } } } } else Message = CustomMessages.INVALID_CHARS; } else Message = CustomMessages.MANDATORY_FIELDS; return Message; }
//Agrega un nodo a la lista de nodos del grafo public void AgregarVertice(CVertice nuevonodo) { nodos = (Object[,])ResizeArray(nodos, cantNodos + 1); nodos[cantNodos, 0] = nuevonodo; for (int x = 1; x <= cantNodos; x++) { nodos[cantNodos, x] = -1; nodos[x, cantNodos] = -1; } nodos[0, cantNodos] = nuevonodo; cantNodos++; }
public frmShowChart(Object[,] data,int length) { InitializeComponent(); this.m_data = data; m_legendLength = length; }
// Constructor public CGrafo() { //nodos = new List<CVertice>(); nodos = new Object[cantNodos, cantNodos]; }