示例#1
0
        public ExportParams(Object[,] data, String[] exportColumnFields)
            : this(exportColumnFields)
        {
            if (data == null) return;

            if (data.GetLength(1) != 2)
            {
                throw new ArgumentException("参数维度应为2");
            }

            for (int i = 0; i < data.GetLength(0); i++)
            {
                this.Parameters.Add(data[i, 0], data[i, 1]);
            }
        }
 public void WriteFromArray(Object[,] datasets)
 {
     var firstDimension = datasets.GetLength(0);
       var secondDimension = datasets.GetLength(1);
       range = worksheet.Range[worksheet.Cells[1, 1], worksheet.Cells[firstDimension, secondDimension]];
       range.Value2 = datasets;
 }
示例#3
0
        private SqlParameter[] transObjToParams(string[] str, Object[] obj)
        {
            SqlParameter[] param = new SqlParameter[obj.GetLength(0)];
            for (int i = 0; i < param.GetLength(0); i++) {
                if (obj[i] is Int32) {
                    param[i] = new SqlParameter("?" + str[i], SqlDbType.Int);
                    param[i].Value = Convert.ToInt32(obj[i]);
                }
                else if (obj[i] is Double) {
                    param[i] = new SqlParameter("?" + str[i], SqlDbType.Float);
                    param[i].Value = Convert.ToDouble(obj[i]);
                }
                else {
                    try {
                        Convert.ToDateTime(obj[i]);
                        param[i] = new SqlParameter("?" + str[i], SqlDbType.DateTime);
                        param[i].Value = Convert.ToString(obj[i]);
                    }
                    catch {
                        param[i] = new SqlParameter("?" + str[i], SqlDbType.VarChar);
                        param[i].Value = Convert.ToString(obj[i]);
                    }
                }

            }
            return param;
        }
示例#4
0
		/// <summary>
		/// Build a renderer from the given array of keys and their matching images
		/// </summary>
		/// <param name="keysAndImages">An array of key/image pairs</param>
		public MappedImageRenderer(Object[] keysAndImages)
			: this() {
			if ((keysAndImages.GetLength(0) % 2) != 0)
				throw new ArgumentException("Array must have key/image pairs");

			for (int i = 0; i < keysAndImages.GetLength(0); i += 2)
				this.Add(keysAndImages[i], keysAndImages[i + 1]);
		}
示例#5
0
        //Permet de générer un graphe à partir de la matrice des coûts
        public void generateGraph(Object[,] costM)
        {
            if (costM != null)
            {
                if (costM.GetLength(0) == costM.GetLength(1) - 1) // On vérifie que la matrice est carrée
                {
                    //Création des sommets
                    for (int i = 0; i < costM.GetLength(0); i++)
                        _nodes.Add(new Node(i, (String)costM[i,0]));

                    for (int i = 0; i < costM.GetLength(0); i++)
                    {
                        for (int j = 1; j < costM.GetLength(1); j++)
                        {
                            if (costM[i, j] != null)
                            {
                                if ((Int32)costM[i, j] != 0 && (Int32)costM[i, j] != int.MaxValue) //Si la valeur est de 0, c-à-d d'un sommet vers lui même avec un chemin de valeur 0, alors il n'y a pas d'arcs.
                                {
                                    Arc a = new Arc((Int32)costM[i, j], _nodes[i], _nodes[j - 1]);
                                    _nodes[i].addLinkedArc(a, false); //ajout d'un degré sortant au noeud d'origine de l'arc
                                    _nodes[j - 1].addLinkedArc(a, true);  //ajout d'un degré entrant au noeud d'extrémité de l'arc
                                    _arcs.Add(a);
                                }
                            }
                        }
                    }
                }
                else
                    Console.WriteLine("Erreur: La matrice n'est pas carrée.");
            }
        }
示例#6
0
        /// <summary>
        /// Asserts that two objects are not equal. If they are equal
        /// an <see cref="AssertionException"/> is thrown.
        /// </summary>
        /// <param name="expected">The expected object</param>
        /// <param name="actual">The actual object</param>
        /// <param name="message">The message to be displayed when the two objects are the same object.</param>
        /// <param name="args">Arguments to be used in formatting the message</param>
        public static void AreNotEqual(Object[] expected, Object[] actual, string message, params object[] args)
        {
            bool fail = false;

            if (expected != null && actual != null)
            {
                if (expected.GetLength(0) == actual.GetLength(0))
                {
                    fail = true;
                }

                if (!fail)
                {
                    int position = 0;
                    bool same = true;
                    foreach (object o in expected)
                    {
                        if (!o.Equals(actual.GetValue(position)))
                        {
                            same = false;
                        }
                        position++;
                    }

                    if (same)
                        fail = true;
                }
            }
            else
            {
                fail = true;
            }

            if (fail)
            {
                if (args != null)
                    Assert.FailSame(expected, actual, message, args);
                else
                    Assert.FailSame(expected, actual, message);
            }
        }
示例#7
0
	    public void testRemoteArraysDims23() {
		    log.info("testRemoteArraysDims23(");

            RemoteArrayTypes23 remote;
            remote = client.RemoteArrayTypes23;

            {
			    int[] arr1 = new int[3];
			    int[,] arr2 = new int[7,6];
			    int[,,] arr3 = new int[7,5,3];
			    int[,,,] arr4 = new int[3,4,6,7];
			
			    for (int i2 = 0; i2 < arr2.GetLength(0); i2++) 
				    for (int i1 = 0; i1 < arr2.GetLength(1); i1++)
					    arr2[i2,i1] = i2+i1;
			    for (int i3 = 0; i3 < arr3.GetLength(0); i3++) 
				    for (int i2 = 0; i2 < arr3.GetLength(1); i2++) 
					    for (int i1 = 0; i1 <arr3.GetLength(2); i1++)
						    arr3[i3,i2,i1] = i3+i2+i1;
			    for (int i4 = 0; i4 < arr4.GetLength(0); i4++) 
				    for (int i3 = 0; i3 < arr4.GetLength(1); i3++) 
					    for (int i2 = 0; i2 < arr4.GetLength(2); i2++) 
						    for (int i1 = 0; i1 < arr4.GetLength(3); i1++)
							    arr4[i4,i3,i2,i1] = i4+i3+i2+i1;
			
			    arr1[0] = arr2[1,1];
			    arr1[1] = arr3[1,1,1];
			    arr1[2] = arr4[1,1,1,1];
			
			    int[] arrR = remote.SendArraysInt(arr2, arr3, arr4);
			    TestUtils.assertEquals(log,  "int", arr1, arrR);
		    }
		
		    {
			    String[] arr1 = new String[3];
			    String[,] arr2 = new String[7,6];
			    String[,,] arr3 = new String[7,5,3];
			    String[,,,] arr4 = new String[3,4,6,7];
			
			    for (int i2 = 0; i2 < arr2.GetLength(0); i2++) 
				    for (int i1 = 0; i1 < arr2.GetLength(1); i1++)
					    arr2[i2,i1] = ""+i2+i1;
			    for (int i3 = 0; i3 < arr3.GetLength(0); i3++) 
				    for (int i2 = 0; i2 < arr3.GetLength(1); i2++) 
					    for (int i1 = 0; i1 <arr3.GetLength(2); i1++)
						    arr3[i3,i2,i1] = ""+i3+i2+i1;
			    for (int i4 = 0; i4 < arr4.GetLength(0); i4++) 
				    for (int i3 = 0; i3 < arr4.GetLength(1); i3++) 
					    for (int i2 = 0; i2 < arr4.GetLength(2); i2++) 
						    for (int i1 = 0; i1 < arr4.GetLength(3); i1++)
							    arr4[i4,i3,i2,i1] = ""+i4+i3+i2+i1;
			
			    arr1[0] = arr2[1,1];
			    arr1[1] = arr3[1,1,1];
			    arr1[2] = arr4[1,1,1,1];
			
			    String[] arrR = remote.SendArraysString(arr2, arr3, arr4);
			    TestUtils.assertEquals(log,  "String", arr1, arrR);
		    }

		    {
			    PrimitiveTypes[] arr1 = new PrimitiveTypes[3];
			    PrimitiveTypes[,] arr2 = new PrimitiveTypes[7,6];
			    PrimitiveTypes[,,] arr3 = new PrimitiveTypes[7,5,3];
			    PrimitiveTypes[,,,] arr4 = new PrimitiveTypes[3,4,6,7];
			
			    for (int i2 = 0; i2 < arr2.GetLength(0); i2++) 
				    for (int i1 = 0; i1 < arr2.GetLength(1); i1++)
					    arr2[i2,i1] = TestUtils.createObjectPrimitiveTypes();
			    for (int i3 = 0; i3 < arr3.GetLength(0); i3++) 
				    for (int i2 = 0; i2 < arr3.GetLength(1); i2++) 
					    for (int i1 = 0; i1 <arr3.GetLength(2); i1++)
						    arr3[i3,i2,i1] = TestUtils.createObjectPrimitiveTypes();
			    for (int i4 = 0; i4 < arr4.GetLength(0); i4++) 
				    for (int i3 = 0; i3 < arr4.GetLength(1); i3++) 
					    for (int i2 = 0; i2 < arr4.GetLength(2); i2++) 
						    for (int i1 = 0; i1 < arr4.GetLength(3); i1++)
							    arr4[i4,i3,i2,i1] = TestUtils.createObjectPrimitiveTypes();
			
			    arr1[0] = arr2[1,1];
			    arr1[1] = arr3[1,1,1];
			    arr1[2] = arr4[1,1,1,1];
		
			    PrimitiveTypes[] arrR = remote.SendArraysClass(arr2, arr3, arr4);
			    TestUtils.assertEquals(log,  "PrimitiveTypes", arr1, arrR);
		    }
	
		    {
			    Object[] arr1 = new Object[3];
			    Object[,] arr2 = new Object[7,6];
			    Object[,,] arr3 = new Object[7,5,3];
			    Object[,,,] arr4 = new Object[3,4,6,7];
			
			    for (int i2 = 0; i2 < arr2.GetLength(0); i2++) 
				    for (int i1 = 0; i1 < arr2.GetLength(1); i1++)
					    arr2[i2,i1] = TestUtils.createObjectPrimitiveTypes();
			    for (int i3 = 0; i3 < arr3.GetLength(0); i3++) 
				    for (int i2 = 0; i2 < arr3.GetLength(1); i2++) 
					    for (int i1 = 0; i1 <arr3.GetLength(2); i1++)
						    arr3[i3,i2,i1] = TestUtils.createObjectPrimitiveTypes();
			    for (int i4 = 0; i4 < arr4.GetLength(0); i4++) 
				    for (int i3 = 0; i3 < arr4.GetLength(1); i3++) 
					    for (int i2 = 0; i2 < arr4.GetLength(2); i2++) 
						    for (int i1 = 0; i1 < arr4.GetLength(3); i1++)
							    arr4[i4,i3,i2,i1] = TestUtils.createObjectPrimitiveTypes();
			
			    arr1[0] = arr2[1,1];
			    arr1[1] = arr3[1,1,1];
			    arr1[2] = arr4[1,1,1,1];
		
			    Object[] arrR = remote.SendArraysObject(arr2, arr3, arr4);
			    TestUtils.assertEquals(log,  "Object", arr1, arrR);
		    }
		
		    {
			    Point2D[] arr1 = new Point2D[3];
			    Point2D[,] arr2 = new Point2D[7,6];
			    Point2D[,,] arr3 = new Point2D[7,5,3];
			    Point2D[,,,] arr4 = new Point2D[3,4,6,7];
			
			    for (int i2 = 0; i2 < arr2.GetLength(0); i2++) 
				    for (int i1 = 0; i1 < arr2.GetLength(1); i1++)
					    arr2[i2,i1] = TestUtils.createPoint2D();
			    for (int i3 = 0; i3 < arr3.GetLength(0); i3++) 
				    for (int i2 = 0; i2 < arr3.GetLength(1); i2++) 
					    for (int i1 = 0; i1 <arr3.GetLength(2); i1++)
						    arr3[i3,i2,i1] = TestUtils.createPoint2D();
			    for (int i4 = 0; i4 < arr4.GetLength(0); i4++) 
				    for (int i3 = 0; i3 < arr4.GetLength(1); i3++) 
					    for (int i2 = 0; i2 < arr4.GetLength(2); i2++) 
						    for (int i1 = 0; i1 < arr4.GetLength(3); i1++)
							    arr4[i4,i3,i2,i1] = TestUtils.createPoint2D();
			
			    arr1[0] = arr2[1,1];
			    arr1[1] = arr3[1,1,1];
			    arr1[2] = arr4[1,1,1,1];
		
			    Point2D[] arrR = remote.SendArraysInline(arr2, arr3, arr4);
			    TestUtils.assertEquals(log,  "Point2D", arr1, arrR);
		    }
		
		    log.info(")testRemoteArraysDims23");
	    }
示例#8
0
        public void setValueAt(Object[,] mat, int val, int row, int col)
        {
            if (row < 0 || row >= mat.GetLength(0))
            {
                Console.WriteLine("Row out of bounds");
                return;  //invalide
            }
            if (col < 0 || col >= mat.GetLength(1))
            {
                Console.WriteLine("Col out of boundslol");
                return;  //invalide
            }

            mat[row, col] = val;
        }
        /// <summary>
        /// Method to accept paramaters andcreate sql command
        /// </summary>        
        public static SqlCommand GenerateSQLCommand(String sql, CommandType cmdType, Object[,] sqlParams)
        {
            try
            {
                myCommand = new SqlCommand(sql, myConnection);
                myCommand.CommandType = cmdType;
                if (sqlParams != null)
                {
                    for (int i = 0; i < sqlParams.GetLength(0); ++i)
                    {
                        Object pr = null;
                        //occurs if sqlparams itself is declared null
                        if (sqlParams[i, 1] == null)
                            continue;
                        else if (sqlParams[i, 1] == "-1")
                            pr = DBNull.Value;
                        else if (sqlParams[i, 1] == "")
                            pr = DBNull.Value;
                        else
                            pr = sqlParams[i, 1];

                        myCommand.Parameters.AddWithValue(sqlParams[i, 0].ToString(), pr);
                    }
                }
                return myCommand;
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw ex;
            }
        }
示例#10
0
    public void BuildReport(Excel.Range dsRange) {
       var ownerRptDef = this.Owner.Owner.Owner.RptDefinition;
      this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : Старт...");

      this.GRTTmplDef = new CXLRTemplateDef(dsRange);
      this.FLeftColOffset = dsRange.Column;
      this.FTopRowOffset = dsRange.Row;
      try {
        this.FHeaderFormatsCount = this.GRTTmplDef.HeaderFormats.Count;
        this.FIsGroupDefined = this.FHeaderFormatsCount > 0;
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : this.insertRows(" + this.RowsCount + ")...");
        Boolean additionalRowInserted = (this.RowsCount == 1);
        this.insertRows(additionalRowInserted ? 2 : this.RowsCount);
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : this.insertRows(" + this.RowsCount + ") - OK.");
        //return;
        Object[,] vBuffer = new Object[this.RowsCount, this.ColDefs.Count];
        this.FCurBufferRowIndex = -1;
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : FillBuffer...");
        this.FillBuffer(dsRange.Worksheet, vBuffer);
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : FillBuffer - OK.");
        //throw new Exception("Test!!!");
        Excel.Range vInsRng = ExcelSrv.getRange(this.GRTTmplDef.DetailsRng.Worksheet,
                              this.GRTTmplDef.DetailsRng.Cells[1, 1],
                              this.GRTTmplDef.DetailsRng.Cells[this.GRTTmplDef.DetailsRng.Rows.Count, this.GRTTmplDef.DetailsRng.Columns.Count]);
        if (ownerRptDef.DebugIsOn) {
          this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : saveBufferToTxt...");
          this.saveBufferToTxt(vBuffer, false);
          this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : saveBufferToTxt - OK.");
        }
        try {
          String insRngCoord = vInsRng.Address;
          this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : vInsRng["+insRngCoord+"].Formula = vBuffer...");
          //vInsRng.CopyFromRecordset(vBuffer);

          if (ownerRptDef.DebugIsOn) {
            this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : saveGroupTree...");
            this.RootGroup.GetXmlDoc().Save(ownerRptDef.LogPath + ownerRptDef.ShortCode + ".DS_DATA." + this.FOwner.Owner.Cfg.rangeName + "_pre.xml");
            this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : saveGroupTree - OK.");
          }

          vInsRng.FormulaLocal = vBuffer;
          if (this.Owner.PrepareDataError != null) {
            Excel.Range vInsErrRng = ExcelSrv.getRange(this.GRTTmplDef.DetailsRng.Worksheet,
                                  this.GRTTmplDef.DetailsRng.Cells[this.GRTTmplDef.DetailsRng.Rows.Count+1, 1],
                                  this.GRTTmplDef.DetailsRng.Cells[this.GRTTmplDef.DetailsRng.Rows.Count+1, 1]);
            vInsErrRng.FormulaLocal = this.Owner.PrepareDataError.Message;
            vInsErrRng.Font.Color = ConsoleColor.Red;
          }
          this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : vInsRng.Formula = vBuffer - OK.");
        } catch (Exception ex) {
          if (!ownerRptDef.DebugIsOn) 
            this.saveBufferToTxt(vBuffer, true);
          throw new EBioException("Ошибка при вставке буфера. vInsRng.Length:(" + vInsRng.Rows.Count + "," + vInsRng.Columns.Count + "); vBuffer.Length:(" + vBuffer.GetLength(0) + "," + vBuffer.GetLength(1) + "); msg:" + ex.ToString(), ex);
        }
        Excel.Range vDelLast = (Excel.Range)this.GRTTmplDef.DetailsRng.Rows[this.GRTTmplDef.DetailsRng.Rows.Count, Type.Missing];
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : refreshFormulaCols...");
        this.refreshFormulaCols(vDelLast);
        this.RefreshTTLFormula(dsRange);
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : refreshFormulaCols - OK.");

        vDelLast.Delete(Type.Missing);
        if (additionalRowInserted) {
          vDelLast = (Excel.Range)this.GRTTmplDef.DetailsRng.Rows[this.GRTTmplDef.DetailsRng.Rows.Count, Type.Missing];
          vDelLast.Delete(Type.Missing);
        }
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : AppliayFormat...");
        this.AppliayFormat(dsRange);

        if (this.FIsGroupDefined)
          this.GroupChild(dsRange.Worksheet);
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : AppliayFormat - OK.");

      } finally {
        this.GRTTmplDef.Dispose();
        this.GRTTmplDef = null;
      }
    }
示例#11
0
		private void saveBufferToTxt(Object[,] pBuffer, bool pForce){
      if(this.FOwner.Owner.Owner.RptDefinition.DebugIsOn || pForce) {
        String vSaveBufferPath = this.Owner.Owner.Owner.RptDefinition.LogPath+this.Owner.Owner.Owner.RptDefinition.ShortCode+"_insBuffer_"+this.Owner.Owner.Cfg.rangeName+".txt"; 
        if(File.Exists(vSaveBufferPath))
          File.Delete(vSaveBufferPath);
        for(int i=0; i<pBuffer.GetLength(0); i++){
          String vLine = null;
          for(int k=0; k<pBuffer.GetLength(1); k++)
            Bio.Helpers.Common.Utl.AddObjToLine(ref vLine, "\t", pBuffer[i, k]);
          Bio.Helpers.Common.Utl.AppendStringToFile(vSaveBufferPath, vLine, null);
        }
      }
		}
 public static StatProps GetRowNum(Object[,] mSelection, int pRowNum = 1, DataOrientation pDataOrientation = DataOrientation.InRows)
 {
     if (pRowNum <= mSelection.GetLength(0))
     {
         var mStatProps = new StatProps(pDataOrientation);
         for (int mColNum = 1, mNumCols = mSelection.GetLength(1); mColNum <= mNumCols; mColNum++)
         {
             mStatProps.Add(mColNum, Table.GetNullOrString(mSelection[pRowNum, mColNum]));
         }
         return mStatProps;
     }
     else
     {
         return null;
     }
 }
        public static StatProps GetColNum(Object[,] mSelection, int pColNum = 1, DataOrientation pDataOrientation = DataOrientation.InColumns)
        {
            if (pColNum <= mSelection.GetLength(1))
            {
                var mStatProps = new StatProps(pDataOrientation);
                for (int mRowNum = 1, mNumRows = mSelection.GetLength(0); mRowNum <= mNumRows; mRowNum++)
                {
                    mStatProps.AddValue(mRowNum, Table.GetNullOrString(mSelection[mRowNum, pColNum]));
                }
                return mStatProps;
            }
            else
            {
                return null;
            }

        }
示例#14
0
        public Object[] ZickZackScan(Object[,] InputByteArray)
        {
            var ymax = InputByteArray.GetLength(0);
            var xmax = InputByteArray.GetLength(1);
            var x = 0;
            var y = 0;
            var indexMax = ymax * xmax;
            Object[] returnArray = new Object[indexMax];
            var index = 0;
            var zustand = 0;
            var kpold = 0;
            var kp = 0;

            returnArray[index] = InputByteArray[y,x];
            while (index < indexMax)
            {
                kp = kpold;
                if (zustand == 0)
                {
                    if (y == 0)
                    {
                        x++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        kpold = kp + 1;
                        while (kp >= 0)
                        {
                            x--;
                            y++;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }

                    }
                    else if (x == 0)
                    {
                        y++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        kpold = kp + 1;
                        while (kp >= 0)
                        {
                            x++;
                            y--;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }
                    }
                    if (ymax == y)
                    {
                        zustand = 1;
                    }
                    else if (xmax == x)
                    {
                        zustand = 1;
                    }
                    else if (x + 1 == xmax && y == 0)
                    {
                        x++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        kpold++;
                        kp = kpold;
                        zustand++;
                        while (kp > 0)
                        {
                            x--;
                            y++;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }
                    }
                    else if (y + 1 == ymax && x == 0)
                    {
                        y++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        kpold++;
                        kp = kpold;
                        zustand++;
                        while (kp > 0)
                        {
                            y--;
                            x++;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }
                    }
                }
                else if (zustand == 1 && xmax > ymax)
                {
                    if (xmax == x)
                    {
                        zustand = 2;
                    }
                    else if (x + 1 == xmax && y == 0)
                    {
                        x++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        zustand++;
                    }
                    else if (y + 1 == ymax && x == 0)
                    {
                        y++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        zustand++;
                    }
                    else if (x == 0)
                    {
                        x++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        while (kp > 0)
                        {
                            y--;
                            x++;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }
                    }
                    else if (y == 0)
                    {
                        x++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        while (kp > 0)
                        {
                            y++;
                            x--;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }
                    }
                    else if (x == xmax)
                    {
                        x++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        while (kp > 0)
                        {
                            y++;
                            x--;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }
                    }
                    else if (y == ymax)
                    {
                        x++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        while (kp > 0)
                        {
                            y--;
                            x++;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }
                    }
                }
                else if (zustand == 1 && xmax < ymax)
                {
                    if (ymax == y)
                    {
                        zustand = 2;
                    }
                    else if (x + 1 == xmax && y == 0)
                    {
                        x++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        zustand++;
                    }
                    else if (y + 1 == ymax && x == 0)
                    {
                        y++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        zustand++;
                    }
                    else if (x == 0)
                    {
                        y++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        while (kp > 0)
                        {
                            y--;
                            x++;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }
                    }
                    else if (y == 0)
                    {
                        y++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        while (kp > 0)
                        {
                            y++;
                            x--;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }
                    }
                    else if (x == xmax)
                    {
                        y++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        while (kp > 0)
                        {
                            y++;
                            x--;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }
                    }
                    else if (y == ymax)
                    {
                        y++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        while (kp > 0)
                        {
                            y--;
                            x++;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }
                    }
                }
                else if (zustand == 2)
                {
                    if (x == xmax && y == 0 && (xmax % 2) != 1)
                    {
                        y++;
                        returnArray[index] = InputByteArray[y, x];
                        kp--;
                        kpold--;
                        index++;
                    }
                    else if (y == ymax && x == 0 && (ymax % 2) == 1)
                    {
                        x++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        kp--;
                        kpold--;
                    }
                    if (x == xmax)
                    {
                        while (kp > 0)
                        {
                            y++;
                            x--;
                            returnArray[index] = InputByteArray[y, x];
                            kp--;
                            index++;
                        }
                        x++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        kpold = kpold - 1;
                    }
                    else if (y == ymax)
                    {
                        while (kp > 0)
                        {
                            y--;
                            x++;
                            returnArray[index] = InputByteArray[y, x];
                            index++;
                            kp--;
                        }
                        y++;
                        returnArray[index] = InputByteArray[y, x];
                        index++;
                        kpold = kpold - 1;
                    }

                }
            }
            return (returnArray);
        }