static void Main(string[] args) { Random los = new Random(); int wylosowana; Console.WriteLine("Podaj pierwszy parametr"); int a = int.Parse(Console.ReadLine()); Console.WriteLine("Podaj drugi parametr"); int b = int.Parse(Console.ReadLine()); Console.WriteLine("Podaj wielkość tablicy"); int n = int.Parse(Console.ReadLine()); int[,] tab1 = new int[n, n]; Boolean[,] tab2 = new Boolean[n, n]; for (int i = 0; i < tab2.GetLength(0); i++) { for (int j = 0; j < tab2.GetLength(1); j++) { wylosowana = los.Next(0, 2); if (wylosowana == 1) { tab2[i, j] = true; } else { tab2[i, j] = false; } } } Console.WriteLine(Funkcja(tab1, tab2, a, b)); }
public void GenerateLakeRoad() { Boolean[,] RoadMap = new Boolean[IslandMap.lk.GetLength(0), IslandMap.lk.GetLength(1)]; List <Point> PointList = new List <Point>(); for (int i = 0; i < StructureList.Count; i++) { Vector dir = new Vector(StructureList[i].Position.X - CenterPosition.X, StructureList[i].Position.Z - CenterPosition.Y); dir.Normalize(); Point MidPoint = MathUtil.MathUtil.RotatePoint(new Point(0, StructureList[i].WX), StructureList[i].Angle); PointList.Add(new Point(StructureList[i].Position.X + dir.X * 2 + MidPoint.X, StructureList[i].Position.Z + dir.Y * 2 + MidPoint.Y)); } RoadMap = MapUtil.FillShape(PointList, RoadMap); for (int i = 0; i < RoadMap.GetLength(0); i++) { for (int j = 0; j < RoadMap.GetLength(1); j++) { if (RoadMap[i, j]) { if (!IslandMap.lk[i, j] && !IslandMap.r[i, j]) { IslandMap.ma[i, j] = 129; IslandMap.rd[i, j] = true; } else if (IslandMap.lk[i, j] && MapUtil.HasSurrounding(i, j, IslandMap.l, 1)) { IslandMap.ma[i, j] = 129; IslandMap.rd[i, j] = true; } } } } }
public static Boolean[,] FillShape(List <Point> PointList, Boolean[,] ShadeMap) { Point Center = new Point(); for (int i = 0; i < PointList.Count; i++) { Center.X += PointList[i].X; Center.Y += PointList[i].Y; } Center.X /= PointList.Count; Center.Y /= PointList.Count; List <Point> SortedList = PointList; SortedList.Sort((a, b) => MathUtil.MathUtil.GetAngle(Center, a).CompareTo(MathUtil.MathUtil.GetAngle(Center, b))); SortedList.Add(SortedList[0]); for (int i = 0; i < SortedList.Count - 1; i++) { RayTrace(SortedList[i], SortedList[i + 1], ShadeMap); } Boolean[,] FillMap = basicFill(ShadeMap); Boolean[,] NewMap = new Boolean[FillMap.GetLength(0), FillMap.GetLength(1)]; for (int i = 0; i < NewMap.GetLength(0); i++) { for (int j = 0; j < NewMap.GetLength(1); j++) { NewMap[i, j] = !FillMap[i, j]; } } return(NewMap); }
public void generateMountains() { //top x,bottom x //left y,right y int tx = wy / 2 + wy / 4 * (sy % sx) / sx; int bx = wy / 2 - wy / 4 * (sy % sx) / sy; int ly = wy / 2 + wy / 4 * (sy % sx) / sx; int ry = wy / 2 - wy / 4 * (sy % sx) / sy; int waveNumX = sx % 10 + 3; int waveNumY = sy % 10 + 3; int waveWidthX = wx / 32; Boolean[,] mountainMap = new Boolean[wx, wy]; int px = Math.Max(tx, bx); int px2 = Math.Min(tx, bx); int py = Math.Max(ly, ry); int py2 = Math.Max(ly, ry); if (sx % 2 == 0) { mountainMap = MapUtil.generateSineWave(mountainMap, new Point(0, px), new Point(wx, px2), waveNumX, waveWidthX, sx, wx); } else { mountainMap = MapUtil.generateSineWave(mountainMap, new Point(px, 0), new Point(px, wy), waveNumX, waveWidthX, sx, wx); } int waterDistance = 4; for (int i = waterDistance; i < mountainMap.GetLength(0) - waterDistance; i++) { for (int j = waterDistance; j < mountainMap.GetLength(0) - waterDistance; j++) { if (IslandMap.l[i, j] && mountainMap[i, j]) { Boolean hasWater = false; for (int countX = -waterDistance; countX < waterDistance; countX++) { for (int countY = -waterDistance; countY < waterDistance; countY++) { if (IslandMap.o[i + countX, j + countY] || IslandMap.lk[i + countX, j + countY]) { hasWater = true; goto completedSearch; } } } completedSearch: if (!hasWater) { IslandMap.m[i, j] = true; } } } } }
private Boolean[,] simplify() { Boolean[,] detail = new Boolean[(int)numericUpDown1.Value, (int)numericUpDown2.Value]; for (int i = 0; i < detail.GetLength(0); i++) { for (int j = 0; j < detail.GetLength(1); j++) { detail[i, j] = BW[i * detail.GetLength(0) / 2, j *detail.GetLength(1) / 2]; } } return(detail); }
public void generateMainLand() { int[] Points = MathUtil.MathUtil.generateFibonocciNumbers(sx, sy, (ipc + 1) * 2, (int)Math.Log10(wx)); List <Point> mainLandPoints = new List <Point>(); for (int i = 0; i < Points.GetLength(0); i += 2) { mainLandPoints.Add(new Point(buffer + Points[i] % (useRegion / 2), buffer + Points[i + 1] % (useRegion / 2))); } mainLandPoints.Sort((p1, p2) => MathUtil.MathUtil.distance(p2, new Point(wx / 2, wy / 2)).CompareTo(MathUtil.MathUtil.distance(p1, new Point(wx / 2, wy / 2)))); IslandMap.MainLandPoints = mainLandPoints; List <Point> p = new List <Point>(); for (int i = 0; i < ipc; i++) { Point pos = mainLandPoints[i]; int[] sectionPoints = MathUtil.MathUtil.generateFibonocciNumbers(sx + i + 10, sy + i + 10, ((sx + i + sy) % 40) * 2, (int)Math.Log10(wx)); for (int j = 0; j < sectionPoints.GetLength(0); j += 2) { Point sectionPointPos = new Point(sectionPoints[j] % (useRegion / 8), sectionPoints[j + 1] % (useRegion / 8)); p.Add(new Point(buffer + ((pos.X + sectionPointPos.X) % useRegion), buffer + ((pos.Y + sectionPointPos.Y) % useRegion))); } } p.Add(p[0]); Boolean[,] map = new Boolean[(wx + 1), (wy + 1)]; for (int i = 0; i < p.Count - 1; i++) { map = MapUtil.createCurve(map, p[i], p[i + 1], 1); } Boolean[,] shadeMap = MapUtil.basicFill(map); for (int i = 0; i < map.GetLength(0); i++) { for (int j = 0; j < map.GetLength(1); j++) { if (shadeMap[i, j]) { IslandMap.o[i, j] = shadeMap[i, j]; } } } for (int i = 0; i < map.GetLength(0); i++) { for (int j = 0; j < map.GetLength(1); j++) { IslandMap.l[i, j] = !shadeMap[i, j]; } } }
public bool IsWildCardMatch(string s, string p) { var T = new Boolean[s.Length + 1, p.Length + 1]; T[0, 0] = true; for (int i = 1; i < T.GetLength(0); i++) { T[i, 0] = false; } // Handle empty case for (int j = 1; j < T.GetLength(1); j++) { if (p.Length > 0 && p[j - 1] == '*') { T[0, j] = T[0, j - 2]; } } for (int i = 0; i < s.Length; i++) { for (int j = 0; j < p.Length; j++) { int tRIndex = i + 1; int tCIndex = j + 1; if (s[i] == p[j] || p[j] == '.') { T[tRIndex, tCIndex] = T[tRIndex - 1, tCIndex - 1]; } if (p[j] == '*') { if (T[tRIndex, tCIndex - 2] == true || ((s[i] == p[j - 1] || p[j - 1] == '.') && T[tRIndex - 1, tCIndex] == true)) { T[tRIndex, tCIndex] = true; } } } } return(T[s.Length, p.Length]); }
// кнопка для расчетов исходной защищенности protected void ButtonIshodZaschita_Click(object sender, EventArgs e) { int index = RadioButtonListTerritory.SelectedIndex; if ((RadioButtonListTerritory.SelectedIndex == -1) || (RadioButtonListObschieSety.SelectedIndex == -1) || (RadioButtonListLegalOperation.SelectedIndex == -1) || (RadioButtonListRazgrDostup.SelectedIndex == -1) || (RadioButtonListSoedinInBD.SelectedIndex == -1) || (RadioButtonListBezlich.SelectedIndex == -1) || (RadioButtonListObiem.SelectedIndex == -1)) { LabelErrorIshodHarakteristik.Text = "Не указана одна из характеристик для исходной защищенности"; } else { //*** удаление записей с связной таблице исходной защищенности string conn = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString; SqlDataSource sds = new SqlDataSource(); sds.ConnectionString = conn; sds.DeleteParameters.Add(new Parameter("ParamISPDnID", TypeCode.Int32, DetailsViewISPDnIshodZachita.Rows[0].Cells[1].Text)); sds.DeleteCommand = "DELETE FROM MnogieHarakteristikiIshod WHERE (ISPDnOperatorID = @ParamISPDnID)"; sds.Delete(); sds.Dispose(); /* РАСЧИТЫВАЕМ ИСХОДНУЮ ЗАЩИЩЕННОСТЬ * ****************************************************/ Boolean[,] ModelArray = new Boolean[22, 3]; // по территориальному размещению ModelArray[0, 2] = RadioButtonListTerritory.Items[0].Selected; //распределенная ИСПДн, которая охватывает несколько областей, краев, округов или государство в целом; ModelArray[1, 2] = RadioButtonListTerritory.Items[1].Selected; //городская ИСПДн, охватывающая не более одного населенного пункта [города, поселка]; ModelArray[2, 1] = RadioButtonListTerritory.Items[2].Selected; //корпоративная распределенная ИСПДн, охватывающая многие подразделения одной организации; ModelArray[3, 1] = RadioButtonListTerritory.Items[3].Selected; //окальная [кампусная] ИСПДн, развернутая в пределах нескольких близко расположенных зданий; ModelArray[4, 0] = RadioButtonListTerritory.Items[4].Selected; //локальная ИСПДн, развернутая в пределах одного здания // по наличию соединений с сетями общего пользования ModelArray[5, 2] = RadioButtonListObschieSety.Items[0].Selected; //ИСПДн, имеющая многоточечный выход в сеть общего пользования; ModelArray[6, 1] = RadioButtonListObschieSety.Items[1].Selected; //ИСПДн, имеющая одноточечный выход в сеть общего пользования; ModelArray[7, 0] = RadioButtonListObschieSety.Items[2].Selected; //ИСПДн, физически отделенная от сети общего пользования // По легальным операциям ModelArray[8, 0] = RadioButtonListLegalOperation.Items[0].Selected; // чтение, поиск; ModelArray[9, 1] = RadioButtonListLegalOperation.Items[1].Selected; //запись, удаление, сортировка; ModelArray[10, 2] = RadioButtonListLegalOperation.Items[2].Selected; //модификация, передача // По разграничению доступа ModelArray[11, 1] = RadioButtonListRazgrDostup.Items[0].Selected; //ИСПДн, к которой имеют доступ определенные переченем сотрудники организации, являющейся владельцем ИСПДн, либо субъект ПДн; ModelArray[12, 2] = RadioButtonListRazgrDostup.Items[1].Selected; //ИСПДн, к которой имеют доступ все сотрудники организации, являющейся владельцем ИСПДн; ModelArray[13, 2] = RadioButtonListRazgrDostup.Items[2].Selected; //ИСПДн с открытым доступом //По наличию соединения с другими базами ИСПДн ModelArray[14, 2] = RadioButtonListSoedinInBD.Items[0].Selected; //интегрированная ИСПДн [организация использует несколько баз ПДн ИСПДн, при этом организация не является владельцем всех используемых баз ПДн]; ModelArray[15, 0] = RadioButtonListSoedinInBD.Items[1].Selected; //ИСПДн, в которой используется одна база ПДн, принадлежащая организации – владельцу данной ИСПДн //По уровню обобщения [обезличивания] ПДн ModelArray[16, 0] = RadioButtonListBezlich.Items[0].Selected; //ИСПДн, в которой предоставляемые пользователю данные являются обезличенными [на уровне организации, отрасли, области, региона и т.д.]; ModelArray[17, 1] = RadioButtonListBezlich.Items[1].Selected; //ИСПДн, в которой данные обезличиваются только при передаче в другие организации и не обезличены при предоставлении пользователю в организации; ModelArray[18, 2] = RadioButtonListBezlich.Items[2].Selected; //ИСПДн, в которой предоставляемые пользователю данные не являются обезличенными [т.е. присутствует информация, позволяющая идентифицировать субъекта ПДн] // по объему ПДн, которые предостовляются другим ModelArray[19, 2] = RadioButtonListObiem.Items[0].Selected; //ИСПДн, предоставляющая всю базу данных с ПДн; ModelArray[20, 1] = RadioButtonListObiem.Items[1].Selected; //ИСПДн, предоставляющая часть ПДн; ModelArray[21, 0] = RadioButtonListObiem.Items[2].Selected; //ИСПДн, не предоставляющая никакой информации. /// добовляем данные в зависимости от условия SqlDataSource sdsIn = new SqlDataSource(); sdsIn.ConnectionString = conn; sdsIn.InsertCommand = "INSERT INTO MnogieHarakteristikiIshod (ISPDnHarakteristikIshodID, ISPDnOperatorID) VALUES (@ParamHarakteristikIshod,@ParamISPDnID)"; sdsIn.InsertParameters.Add(new Parameter("ParamHarakteristikIshod", TypeCode.Int32)); sdsIn.InsertParameters.Add(new Parameter("ParamISPDnID", TypeCode.Int32, DetailsViewISPDnIshodZachita.Rows[0].Cells[1].Text)); // Добавление записей в связные таблицы исходной защищенности if (ModelArray[5, 2] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "1"; sdsIn.Insert(); } if (ModelArray[1, 2] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "2"; sdsIn.Insert(); } if (ModelArray[2, 1] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "3"; sdsIn.Insert(); } if (ModelArray[3, 1] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "4"; sdsIn.Insert(); } if (ModelArray[4, 0] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "5"; sdsIn.Insert(); } if (ModelArray[5, 2] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "6"; sdsIn.Insert(); } if (ModelArray[6, 1] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "7"; sdsIn.Insert(); } if (ModelArray[7, 0] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "8"; sdsIn.Insert(); } if (ModelArray[8, 0] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "9"; sdsIn.Insert(); } if (ModelArray[9, 1] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "10"; sdsIn.Insert(); } if (ModelArray[10, 2] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "11"; sdsIn.Insert(); } if (ModelArray[11, 1] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "12"; sdsIn.Insert(); } if (ModelArray[12, 2] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "13"; sdsIn.Insert(); } if (ModelArray[13, 2] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "14"; sdsIn.Insert(); } if (ModelArray[14, 2] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "15"; sdsIn.Insert(); } if (ModelArray[15, 0] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "16"; sdsIn.Insert(); } if (ModelArray[16, 0] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "17"; sdsIn.Insert(); } if (ModelArray[17, 1] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "18"; sdsIn.Insert(); } if (ModelArray[18, 2] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "19"; sdsIn.Insert(); } if (ModelArray[19, 2] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "20"; sdsIn.Insert(); } if (ModelArray[20, 1] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "21"; sdsIn.Insert(); } if (ModelArray[21, 0] == true) { sdsIn.InsertParameters["ParamHarakteristikIshod"].DefaultValue = "22"; sdsIn.Insert(); } sdsIn.Dispose(); int SumV; // переменная для сбоора количества положительных решений Выс уровень int SumS; //' переменная для сбоора количества положительных решений Средний уровень int SumN; //' переменная для сбоора количества положительных решений Низкий уровень SumV = 0; SumS = 0; SumN = 0; // СЧИТАЕМ ПОЛОЖИТ РЕШЕНИЯ ПО ВЫСОКОМУ УРОВНЮ for (int v = 0; v < ModelArray.GetLength(0); v++) { if (ModelArray[v, 0] == true) { SumV = SumV + 1; } } //СЧИТАЕМ ПОЛОЖИТ РЕШЕНИЯ ПО СРЕДНЕМУ УРОВНЮ for (int s = 0; s < ModelArray.GetLength(0); s++) { if (ModelArray[s, 1] == true) { SumS = SumS + 1; } } // СЧИТАЕМ ПОЛОЖИТ РЕШЕНИЯ ПО НИЗКОМУ УРОВНЮ for (int n = 0; n < ModelArray.GetLength(0); n++) { if (ModelArray[n, 2] == true) { SumN = SumN + 1; } } // КАКОЙ УРОВЕНЬ ЗАЩИЩЕНОСТИ ИМЕЕТ ИСПДН В ИТОГЕ //int koofIshod; // коэфициэнт уровня защищенности //' коофициэнты исходной защищенности double VurovenZachit = (7.0 * 70) / 100; //' высчитываем сколько характеристик будет состовлять 70 процентов от общего числа решений // а если к отношение к числу положительных решений а не к орбщему то VurovenZachit = 6 / 100 * 70 = 4,2 решения //UPDATE ISPDnOperator SET ISPDnIshodZashitaID = @ParamIshodZahita WHERE (ISPDnOperatorID = @ParamISPDnID) SqlDataSource sdsUp = new SqlDataSource(); sdsUp.ConnectionString = conn; sdsUp.UpdateCommand = "UPDATE ISPDnOperator SET ISPDnIshodZashitaID = @ParamIshodZahita WHERE (ISPDnOperatorID = @ParamISPDnID)"; sdsUp.UpdateParameters.Add(new Parameter("ParamIshodZahita", TypeCode.Int32)); sdsUp.UpdateParameters.Add(new Parameter("ParamISPDnID", TypeCode.Int32, DetailsViewISPDnIshodZachita.Rows[0].Cells[1].Text)); //проверка условия на процент положит высокой защиты if ((SumV >= VurovenZachit) && (SumN == 0)) { sdsUp.UpdateParameters["ParamIshodZahita"].DefaultValue = "1"; sdsUp.Update(); LabelErrorIshodHarakteristik.Text = "ИСПДН имеет ВЫСОКИЙ уровень исходной защищености"; } else if ((((SumV >= VurovenZachit) && (SumN == 0)) == false) && ((SumV + SumS) >= VurovenZachit)) { sdsUp.UpdateParameters["ParamIshodZahita"].DefaultValue = "2"; sdsUp.Update(); LabelErrorIshodHarakteristik.Text = "ИСПДН имеет СРЕДНИЙ уровень исходной защищености"; } else { sdsUp.UpdateParameters["ParamIshodZahita"].DefaultValue = "3"; sdsUp.Update(); LabelErrorIshodHarakteristik.Text = "ИСПДН имеет НИЗКИЙ уровень исходной защищености"; } sdsUp.Dispose(); } }
public Boolean runTest() { Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; String strLoc = "Loc_000oo"; String strBaseLoc; short[] in2Arr = new Int16[10]; int[] in4Arr = new Int32[5]; long[] in8Arr = new Int64[0]; String[] strArr = new String[6]; Boolean[] boArr = new Boolean[3]; Double[] dblArr = new Double[2]; Single[] snglArr = new Single[32000]; Char[] chArr = new Char[10000]; int rank; try { LABEL_860_GENERAL: do { strLoc = "Loc_819yt"; rank = -1; in2Arr = new Int16[5]; iCountTestcases++; try { in2Arr.GetLength(rank); iCountErrors++; Console.WriteLine(s_strTFAbbrev + "Err_499ws! , GetLength==" + in2Arr.Length); } catch (IndexOutOfRangeException ioorExc) {} catch (Exception exc) { iCountErrors++; Console.WriteLine(s_strTFAbbrev + "Err_758! exc==" + exc); } strLoc = "Loc_819ee"; rank = 1; in2Arr = new Int16[5]; iCountTestcases++; try { in2Arr.GetLength(rank); iCountErrors++; Console.WriteLine(s_strTFAbbrev + "Err_500ws! , GetLength==" + in2Arr.Length); } catch (IndexOutOfRangeException ioorExc) {} catch (Exception exc) { iCountErrors++; Console.WriteLine(s_strTFAbbrev + "Err_750! exc==" + exc); } strLoc = "Loc_482wu"; rank = 0; in2Arr = new Int16[10]; iCountTestcases++; if (in2Arr.GetLength(rank) != 10) { iCountErrors++; Console.WriteLine(s_strTFAbbrev + "Err_481ua! , GetLength==" + in2Arr.Length); } strLoc = "Loc_471ay"; in4Arr = new Int32[5]; iCountTestcases++; if (in4Arr.GetLength(rank) != 5) { iCountErrors++; Console.WriteLine(s_strTFAbbrev + "Err_29qaq! , GetLength==" + in4Arr.Length); } strLoc = "Loc_982uq"; in8Arr = new Int64[0]; iCountTestcases++; if (in8Arr.GetLength(rank) != 0) { iCountErrors++; Console.WriteLine(s_strTFAbbrev + "Err_237sy! , GetLength==" + in8Arr.Length); } strLoc = "Loc_172ms"; boArr = new Boolean[3]; iCountTestcases++; if (boArr.GetLength(rank) != 3) { iCountErrors++; Console.WriteLine(s_strTFAbbrev + "Err_382! , GetLength==" + boArr.Length); } strLoc = "Loc_49su"; dblArr = new Double[2]; iCountTestcases++; if (dblArr.GetLength(rank) != 2) { iCountErrors++; Console.WriteLine(s_strTFAbbrev + "Err_200su! , GetLength==" + dblArr.Length); } strLoc = "Loc_371su"; snglArr = new Single[32000]; iCountTestcases++; if (snglArr.GetLength(rank) != 32000) { iCountErrors++; Console.WriteLine(s_strTFAbbrev + "Err_319aw! , GetLength==" + snglArr.Length); } strLoc = "Loc_129wi"; strArr = new String[5]; strArr[2] = null; iCountTestcases++; if (strArr.GetLength(rank) != 5) { iCountErrors++; Console.WriteLine(s_strTFAbbrev + "Err_71ahw! , GetLength==" + strArr.Length); } } while (false); } catch (Exception exc_general) { ++iCountErrors; Console.WriteLine(s_strTFAbbrev + " Error Err_8888yyy! strLoc==" + strLoc + ", exc_general==" + exc_general); } if (iCountErrors == 0) { return(true); } else { return(false); } }
static void Main(string[] args) { // Initialize string currentPath = Directory.GetCurrentDirectory(); if (File.Exists(string.Format(@"{0}\\output.txt", currentPath))) { File.Delete(string.Format(@"{0}\\output.txt", currentPath)); } int draw = 10000; Console.Write("How many times you want to draw the lottery (Default: 10000):"); string read = Console.ReadLine(); if (read.Length != 0) { draw = int.Parse(read); } try { int[,] lottery = new int[draw, 6]; string[] sequences = new string[draw]; int occurrence = 0; Boolean[] result = new Boolean[draw]; for (int i = 0; i < result.GetLength(0); i++) { result[i] = false; } // Generate the lottery Console.Write("\n[{0:d/M/yyyy HH:mm:ss.fff}] ", DateTime.Now); Console.WriteLine("Generate and sort random numbers, search consecutive pairs..."); for (int i = 0; i < lottery.GetLength(0); i++) { // Generate the reference array int[] reference = new int[46]; // Ignore the 0 element. for (int j = 0; j < reference.GetLength(0); j++) { reference[j] = j; } int length = 0; while (length != lottery.GetLength(1)) { int pointer = generate(); if (reference[pointer] != 0) { reference[pointer] = 0; lottery[i, length] = pointer; length++; } } // Ascending Sorting ascendingSort(lottery, i); // Searching consecutive pairs for (int j = 0; j < lottery.GetLength(1) - 1; j++) { if (lottery[i, j] == lottery[i, j + 1] - 1) { result[i] = true; occurrence++; break; } } } /*for (int i = 0; i < lottery.GetLength(0); i++) { * Console.Write("#{0}\t", i); * for (int j = 0; j < lottery.GetLength(1); j++) { * Console.Write("{0} ", lottery[i, j]); * } * Console.WriteLine(); * }*/ for (int i = 0; i < sequences.GetLength(0); i++) { sequences[i] = string.Format("{0},{1},{2},{3},{4},{5}", lottery[i, 0], lottery[i, 1], lottery[i, 2], lottery[i, 3], lottery[i, 4], lottery[i, 5]); } /*foreach (string i in sequences) { * Console.WriteLine(i); * }*/ // Save to file using (System.IO.StreamWriter file = new System.IO.StreamWriter(string.Format(@"{0}\\output.txt", currentPath), true)) { file.WriteLine("===RESULTS IN {0} TIMES DRAW===", draw); for (int i = 0; i < result.GetLength(0); i++) { if (result[i] == false) { file.WriteLine("#{0}\tFALSE\t{1}", i, sequences[i]); //Console.WriteLine("#{0}\tFALSE\t{1}", i, sequences[i]); } else { file.WriteLine("#{0}\tTRUE\t{1}", i, sequences[i]); //Console.WriteLine("#{0}\tTRUE\t{1}", i, sequences[i]); } } file.WriteLine("==========RESULT END=========="); Console.Write("\n[{0:d/M/yyyy HH:mm:ss.fff}] ", DateTime.Now); Console.WriteLine("Mission accomplished."); Console.WriteLine("There are {0} consecutive pairs out of {1} draws. \nRatio: {2}%", occurrence, draw, (double)(occurrence) / (double)(draw) * 100); file.WriteLine("There are {0} consecutive pairs out of {1} draws. \nRatio: {2}%", occurrence, draw, (double)(occurrence) / (double)(draw) * 100); Console.Write("\n[{0:d/M/yyyy HH:mm:ss.fff}] ", DateTime.Now); Console.WriteLine("The result text file is saved to {0}\\output.txt", currentPath); } } catch (OutOfMemoryException) { // Exception handle Console.WriteLine("\nThis program does not support this amount of draw. The possible reasons are:"); Console.WriteLine(" 1. A significant huge number."); Console.WriteLine(" 2. Your current computer does not have enough RAM or you are under 32-bit environment."); Environment.Exit(1); } }
private void buttonIshodZashita_Click(object sender, EventArgs e) { // Проверяем все ли чекбоксы параметров исходной защищенности отмечены if (RadioButtonTerGosudarstvo.Checked == false && RadioButtonTerGorod.Checked == false && RadioButtonTerKorparation.Checked == false && RadioButtonTerLocal.Checked == false && RadioButtonTerRadioButtonTerLocalZdanie.Checked == false) { MessageBox.Show("Определите параметры по терр размещению ИСПДн"); goto konec; } else if (RadioButtonSInetMnogotochie.Checked == false && RadioButtonSInetOdnotochie.Checked == false && RadioButtonSInetOtdelno.Checked == false) { MessageBox.Show("Определите параметры по наличию соединений с др. Сетями"); goto konec; } else if (RadioButtonLegalChtenie.Checked == false && RadioButtonLegalZapis.Checked == false && RadioButtonLegalPeredacha.Checked == false) { MessageBox.Show("Определите параметры По встроенным(Легальным) операциям с базами ПД"); goto konec; } else if (RadioButtonDostupPerechen.Checked == false && RadioButtonDostupVseSotrud.Checked == false && RadioButtonDostupOtkrit.Checked == false) { MessageBox.Show("Определите параметры По разграничению доступа к ПД"); goto konec; } else if (RadioButtonDrugieBDInteger.Checked == false && RadioButtonDrugieOdnaBD.Checked == false) { MessageBox.Show("Определите параметры По наличию с другими БД иных ИСПДн"); goto konec; } else if (RadioButtonBezlicRegion.Checked == false && RadioButtonBezlicOrganization.Checked == false && RadioButtonBezlicNo.Checked == false) { MessageBox.Show("Определите параметры По уровню обобщения (обезличивания)"); goto konec; } else if (RadioButtonObyemAll.Checked == false && RadioButtonObyemChastPD.Checked == false && RadioButtonObyemNo.Checked == false) { MessageBox.Show("Определите параметры По объему предостовляемых ПД другими лицами"); goto konec; } else { int ispdnID; ispdnID = 0; DataTable tableIspdn = iSPDnBDDataSet.Tables["ISPDnOperator"]; if (tableIspdn.Rows.Count == 0) { MessageBox.Show("Нет ИСПДн для определения исходной защищенности"); goto konec; } else { foreach (DataRow dataRow in tableIspdn.Rows) { string forName; forName = dataRow["ISPDnOperatorName"].ToString(); string forISPDnID; forISPDnID = dataRow["ISPDnOperatorID"].ToString(); if (this.comboBoxISPDnIshod.Text == forName) // Если Имя Поля названиеИС равно имени в Базе { ispdnID = Convert.ToInt32(forISPDnID); } } // для начала очищаем связную таблицу this.mnogieHarakteristikiIshodTableAdapter.DeleteQueryMnogieISPDnIshod(ispdnID); Boolean[,] ModelArray = new Boolean[22, 3]; // по территориальному размещению ModelArray[0, 2] = RadioButtonTerGosudarstvo.Checked; //распределенная ИСПДн, которая охватывает несколько областей, краев, округов или государство в целом; ModelArray[1, 2] = RadioButtonTerGorod.Checked; //городская ИСПДн, охватывающая не более одного населенного пункта [города, поселка]; ModelArray[2, 1] = RadioButtonTerKorparation.Checked; //корпоративная распределенная ИСПДн, охватывающая многие подразделения одной организации; ModelArray[3, 1] = RadioButtonTerLocal.Checked; //окальная [кампусная] ИСПДн, развернутая в пределах нескольких близко расположенных зданий; ModelArray[4, 0] = RadioButtonTerRadioButtonTerLocalZdanie.Checked; //локальная ИСПДн, развернутая в пределах одного здания // по наличию соединений с сетями общего пользования ModelArray[5, 2] = RadioButtonSInetMnogotochie.Checked; //ИСПДн, имеющая многоточечный выход в сеть общего пользования; ModelArray[6, 1] = RadioButtonSInetOdnotochie.Checked; //ИСПДн, имеющая одноточечный выход в сеть общего пользования; ModelArray[7, 0] = RadioButtonSInetOtdelno.Checked; //ИСПДн, физически отделенная от сети общего пользования // По легальным операциям ModelArray[8, 0] = RadioButtonLegalChtenie.Checked; // чтение, поиск; ModelArray[9, 1] = RadioButtonLegalZapis.Checked; //запись, удаление, сортировка; ModelArray[10, 2] = RadioButtonLegalPeredacha.Checked; //модификация, передача // По разграничению доступа ModelArray[11, 1] = RadioButtonDostupPerechen.Checked; //ИСПДн, к которой имеют доступ определенные переченем сотрудники организации, являющейся владельцем ИСПДн, либо субъект ПДн; ModelArray[12, 2] = RadioButtonDostupVseSotrud.Checked; //ИСПДн, к которой имеют доступ все сотрудники организации, являющейся владельцем ИСПДн; ModelArray[13, 2] = RadioButtonDostupOtkrit.Checked; //ИСПДн с открытым доступом //По наличию соединения с другими базами ИСПДн ModelArray[14, 2] = RadioButtonDrugieBDInteger.Checked; //интегрированная ИСПДн [организация использует несколько баз ПДн ИСПДн, при этом организация не является владельцем всех используемых баз ПДн]; ModelArray[15, 0] = RadioButtonDrugieOdnaBD.Checked; //ИСПДн, в которой используется одна база ПДн, принадлежащая организации – владельцу данной ИСПДн //По уровню обобщения [обезличивания] ПДн ModelArray[16, 0] = RadioButtonBezlicRegion.Checked; //ИСПДн, в которой предоставляемые пользователю данные являются обезличенными [на уровне организации, отрасли, области, региона и т.д.]; ModelArray[17, 1] = RadioButtonBezlicOrganization.Checked; //ИСПДн, в которой данные обезличиваются только при передаче в другие организации и не обезличены при предоставлении пользователю в организации; ModelArray[18, 2] = RadioButtonBezlicNo.Checked; //ИСПДн, в которой предоставляемые пользователю данные не являются обезличенными [т.е. присутствует информация, позволяющая идентифицировать субъекта ПДн] // по объему ПДн, которые предостовляются другим ModelArray[19, 2] = RadioButtonObyemAll.Checked; //ИСПДн, предоставляющая всю базу данных с ПДн; ModelArray[20, 1] = RadioButtonObyemChastPD.Checked; //ИСПДн, предоставляющая часть ПДн; ModelArray[21, 0] = RadioButtonObyemNo.Checked; //ИСПДн, не предоставляющая никакой информации. if (ModelArray[5, 2] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(1, ispdnID); } if (ModelArray[1, 2] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(2, ispdnID); } if (ModelArray[2, 1] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(3, ispdnID); } if (ModelArray[3, 1] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(4, ispdnID); } if (ModelArray[4, 0] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(5, ispdnID); } if (ModelArray[5, 2] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(6, ispdnID); } if (ModelArray[6, 1] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(7, ispdnID); } if (ModelArray[7, 0] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(8, ispdnID); } if (ModelArray[8, 0] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(9, ispdnID); } if (ModelArray[9, 1] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(10, ispdnID); } if (ModelArray[10, 2] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(11, ispdnID); } if (ModelArray[11, 1] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(12, ispdnID); } if (ModelArray[12, 2] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(13, ispdnID); } if (ModelArray[13, 2] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(14, ispdnID); } if (ModelArray[14, 2] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(15, ispdnID); } if (ModelArray[15, 0] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(16, ispdnID); } if (ModelArray[16, 0] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(17, ispdnID); } if (ModelArray[17, 1] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(18, ispdnID); } if (ModelArray[18, 2] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(19, ispdnID); } if (ModelArray[19, 2] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(20, ispdnID); } if (ModelArray[20, 1] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(21, ispdnID); } if (ModelArray[21, 0] == true) { mnogieHarakteristikiIshodTableAdapter.InsertHarakteristicISPDnIshod(22, ispdnID); } int SumV; // переменная для сбоора количества положительных решений Выс уровень int SumS; //' переменная для сбоора количества положительных решений Средний уровень int SumN; //' переменная для сбоора количества положительных решений Низкий уровень SumV = 0; SumS = 0; SumN = 0; // СЧИТАЕМ ПОЛОЖИТ РЕШЕНИЯ ПО ВЫСОКОМУ УРОВНЮ for (int v = 0; v < ModelArray.GetLength(0); v++) { if (ModelArray[v, 0] == true) { SumV = SumV + 1; } } //СЧИТАЕМ ПОЛОЖИТ РЕШЕНИЯ ПО СРЕДНЕМУ УРОВНЮ for (int s = 0; s < ModelArray.GetLength(0); s++) { if (ModelArray[s, 1] == true) { SumS = SumS + 1; } } // СЧИТАЕМ ПОЛОЖИТ РЕШЕНИЯ ПО НИЗКОМУ УРОВНЮ for (int n = 0; n < ModelArray.GetLength(0); n++) { if (ModelArray[n, 2] == true) { SumN = SumN + 1; } } // КАКОЙ УРОВЕНЬ ЗАЩИЩЕНОСТИ ИМЕЕТ ИСПДН В ИТОГЕ //int koofIshod; // коэфициэнт уровня защищенности //' коофициэнты исходной защищенности double VurovenZachit = (7.0 * 70) / 100; //' высчитываем сколько характеристик будет состовлять 70 процентов от общего числа решений // а если к отношение к числу положительных решений а не к орбщему то VurovenZachit = 6 / 100 * 70 = 4,2 решения //проверка условия на процент положит высокой защиты if ((SumV >= VurovenZachit) && (SumN == 0)) { MessageBox.Show("ИСПДН имеет ВЫСОКИЙ уровень исходной защищености"); ispDnOperatorTableAdapter.UpdateIshZachita(1, ispdnID, ClassGlobalVar.OrgID); } else if ((((SumV >= VurovenZachit) && (SumN == 0)) == false) && ((SumV + SumS) >= VurovenZachit)) { MessageBox.Show("ИСПДН имеет СРЕДНИЙ уровень исходной защищености"); ispDnOperatorTableAdapter.UpdateIshZachita(2, ispdnID, ClassGlobalVar.OrgID); } else { MessageBox.Show("ИСПДН имеет НИЗКИЙ уровень исходной защищености"); ispDnOperatorTableAdapter.UpdateIshZachita(3, ispdnID, ClassGlobalVar.OrgID); } } } konec :; // переход от проверки все ли параметры отмечены к выходу из программы }
static void Main(string[] args) { // Initialize string currentPath = Directory.GetCurrentDirectory(); if (File.Exists(string.Format(@"{0}\\output.txt", currentPath))) { File.Delete(string.Format(@"{0}\\output.txt", currentPath)); } Stick simulation; string read; int amount = 1000000; int occurrence = 0; Console.Write("The circumferrence of triangle (Default: 100): "); read = Console.ReadLine(); if (read.Length == 0) { simulation = new Stick(); } else { simulation = new Stick(int.Parse(read)); } Console.Write("The amount of simulations (Default: {0}): ", amount); read = Console.ReadLine(); if (read.Length != 0) { amount = int.Parse(read); } try { // Generate the broken sticks Console.WriteLine("Generating stick simulations..."); int[,] draw = new int[amount, 3]; Boolean[] result = new Boolean[amount]; for (int i = 0; i < result.Length; i++) { result[i] = false; } for (int i = 0; i < draw.GetLength(0); i++) { int[] tmp = simulation.separate(); for (int j = 0; j < draw.GetLength(1); j++) { draw[i, j] = tmp[j]; } } Console.WriteLine("Examining the possibility of build triangle..."); for (int i = 0; i < draw.GetLength(0); i++) { if (draw[i, 0] + draw[i, 1] > draw[i, 2]) { //Console.WriteLine("TRUE {0}, {1}, {2}", draw[i, 0], draw[i, 1], draw[i, 2]); result[i] = true; occurrence++; } else { //Console.WriteLine("FALSE {0}, {1}, {2}", draw[i, 0], draw[i, 1], draw[i, 2]); result[i] = false; } } Console.WriteLine("There are {0} sticks can be built to triangle out of {1} sticks.", occurrence, amount); Console.WriteLine("Ratio: {0}%", (double)(occurrence) / (double)(amount) * 100); using (System.IO.StreamWriter file = new System.IO.StreamWriter(string.Format(@"{0}\\output.txt", currentPath), true)) { file.WriteLine("====RESULTS IN {0} STICKS====", amount); for (int i = 0; i < result.GetLength(0); i++) { if (result[i] == false) { file.WriteLine("#{0}\tFALSE\t{1}, {2}, {3}", i, draw[i, 0], draw[i, 1], draw[i, 2]); } else { file.WriteLine("#{0}\tTRUE\t{1}, {2}, {3}", i, draw[i, 0], draw[i, 1], draw[i, 2]); } } file.WriteLine("==========RESULT END=========="); file.WriteLine("There are {0} sticks can be built to triangle out of {1} sticks.", occurrence, amount); file.WriteLine("Ratio: {0}%", (double)(occurrence) / (double)(amount) * 100); } // Test /*for (int i = 0; i < draw.GetLength(0); i++) { * for (int j = 0; j < draw.GetLength(1); j++) { * Console.Write("{0} ", draw[i, j]); * } * Console.WriteLine(); * } * Console.WriteLine(simulation.Circumferrence);*/ } catch (OutOfMemoryException) { // Exception handle Console.WriteLine("Out of memory!"); Environment.Exit(1); } }
public Boolean runTest() { Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; String strLoc = "Loc_000oo"; String strBaseLoc; short[] in2Arr = new Int16[10]; int[] in4Arr = new Int32[5]; long[] in8Arr = new Int64[0]; String[] strArr = new String[6]; Boolean[] boArr = new Boolean[3]; Double[] dblArr = new Double[2]; Single[] snglArr = new Single[32000]; Char[] chArr = new Char[10000]; int rank; try { LABEL_860_GENERAL: do { strLoc = "Loc_819yt"; rank = -1; in2Arr = new Int16[5]; iCountTestcases++; try { in2Arr.GetLength(rank); iCountErrors++; Console.WriteLine( s_strTFAbbrev+ "Err_499ws! , GetLength=="+in2Arr.Length); } catch (IndexOutOfRangeException ioorExc) {} catch (Exception exc) { iCountErrors++; Console.WriteLine( s_strTFAbbrev+ "Err_758! exc=="+exc); } strLoc = "Loc_819ee"; rank = 1; in2Arr = new Int16[5]; iCountTestcases++; try { in2Arr.GetLength(rank); iCountErrors++; Console.WriteLine( s_strTFAbbrev+ "Err_500ws! , GetLength=="+in2Arr.Length); } catch (IndexOutOfRangeException ioorExc) {} catch (Exception exc) { iCountErrors++; Console.WriteLine( s_strTFAbbrev+ "Err_750! exc=="+exc); } strLoc = "Loc_482wu"; rank = 0; in2Arr = new Int16[10]; iCountTestcases++; if(in2Arr.GetLength(rank) != 10) { iCountErrors++; Console.WriteLine( s_strTFAbbrev+ "Err_481ua! , GetLength=="+in2Arr.Length); } strLoc = "Loc_471ay"; in4Arr = new Int32[5]; iCountTestcases++; if(in4Arr.GetLength(rank) != 5) { iCountErrors++; Console.WriteLine( s_strTFAbbrev+ "Err_29qaq! , GetLength=="+in4Arr.Length); } strLoc = "Loc_982uq"; in8Arr = new Int64[0]; iCountTestcases++; if(in8Arr.GetLength(rank) != 0) { iCountErrors++; Console.WriteLine( s_strTFAbbrev+ "Err_237sy! , GetLength=="+in8Arr.Length); } strLoc = "Loc_172ms"; boArr = new Boolean[3]; iCountTestcases++; if(boArr.GetLength(rank) != 3) { iCountErrors++; Console.WriteLine( s_strTFAbbrev+ "Err_382! , GetLength=="+boArr.Length); } strLoc = "Loc_49su"; dblArr = new Double[2]; iCountTestcases++; if(dblArr.GetLength(rank) != 2) { iCountErrors++; Console.WriteLine( s_strTFAbbrev+ "Err_200su! , GetLength=="+dblArr.Length); } strLoc = "Loc_371su"; snglArr = new Single[32000]; iCountTestcases++; if(snglArr.GetLength(rank) != 32000) { iCountErrors++; Console.WriteLine( s_strTFAbbrev+ "Err_319aw! , GetLength=="+snglArr.Length); } strLoc = "Loc_129wi"; strArr = new String[5]; strArr[2] = null; iCountTestcases++; if(strArr.GetLength(rank) != 5) { iCountErrors++; Console.WriteLine( s_strTFAbbrev+ "Err_71ahw! , GetLength=="+strArr.Length); } } while (false); } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine(s_strTFAbbrev +" Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general); } if ( iCountErrors == 0 ) { return true; } else { return false;} }
public ReportSettings GetReportSettings(IWin32Window owner, string[] experimentStatColumns, string[] itemStatColumns, DataServer dServer, bool forStreaming) { ReportSettings settings; bool [] markerColumnFlags, itemColumnFlags; object[] selectedAnnotationTypeObjects; Identifiable[] selectedAnnotationTypes; MyOKFlag = false; MyForStreaming = forStreaming; MyMarkerColumnsForm = new CheckedListForm(); MyItemColumnsForm = new CheckedListForm(); MyAnnotationTypesForm = new CheckedListForm(); //Prepare column selection forms. MyMarkerColumnsForm.LoadItems(experimentStatColumns); MyItemColumnsForm.LoadItems(itemStatColumns); MyAnnotationTypesForm.LoadItems(this.GetAnnotationTypes(dServer)); //Check all columns. MyMarkerColumnsForm.SetAllCheckState(true); MyItemColumnsForm.SetAllCheckState(true); MyAnnotationTypesForm.SetAllCheckState(true); //Uncheck item success rate over nonfailed experiments, because should not be in the report by default. MyItemColumnsForm.SetItemChecked(2, false); PathTextBox.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer); this.SetEnabledStatus(); this.ShowDialog(owner); settings = new ReportSettings(); //Set included sections. settings.Set(ReportSettings.Bools.IncludeAnnotations, MarkerAnnotationsCheckBox.Checked); settings.Set(ReportSettings.Bools.IncludeControlItemStat, ControlItemStatisticsCheckBox.Checked); settings.Set(ReportSettings.Bools.IncludeExperimentStat, ExperimentStatisticsCheckBox.Checked); settings.Set(ReportSettings.Bools.IncludeItemStat, ItemStatisticsCheckBox.Checked); settings.Set(ReportSettings.Bools.IncludeSourceInfo, SourceInfoCheckBox.Checked); settings.Set(ReportSettings.Bools.IncludeResults, ResultsCheckBox.Checked); settings.Set(ReportSettings.Bools.IncludeSelectedPlates, SelectionPlatesCheckBox.Checked); settings.Set(ReportSettings.Bools.IncludeSelectedGroups, SelectionGroupsCheckBox.Checked); settings.Set(ReportSettings.Bools.IncludeSelectedDetailedFilter, SelectionDetailedFilterCheckBox.Checked); //Set empty result string. settings.Set(ReportSettings.Strings.EmptyResultString, NoResultTextBox.Text); //Set report type. settings.Set(ReportSettings.Strings.ReportType, (TextFileRadioButton.Checked ? ReportSettings.ReportTypeText : ReportSettings.ReportTypeXML)); if (TableExperimentRowRadioButton.Checked) { settings.Set(ReportSettings.Strings.ResultTableType, ReportSettings.ResultTableTypeExpmRows); } else if (TableExperimentColumnRadioButton.Checked) { settings.Set(ReportSettings.Strings.ResultTableType, ReportSettings.ResultTableTypeExpmCol); } else if (PairwiseAllRadioButton.Checked) { settings.Set(ReportSettings.Strings.ResultTableType, ReportSettings.ResultTableTypePairAll); } else if (PairwiseApprovedRadioButton.Checked) { settings.Set(ReportSettings.Strings.ResultTableType, ReportSettings.ResultTableTypePairApp); } //Set selected columns for experiments. markerColumnFlags = new Boolean[MyMarkerColumnsForm.GetItems().GetLength(0)]; for (int i = 0; i < markerColumnFlags.GetLength(0); i++) { markerColumnFlags[i] = MyMarkerColumnsForm.GetItemChecked(i); } settings.Set(ReportSettings.BoolArrays.ExperimentStatFlags, markerColumnFlags); //Set selected columns for items. itemColumnFlags = new Boolean[MyItemColumnsForm.GetItems().GetLength(0)]; for (int i = 0; i < itemColumnFlags.GetLength(0); i++) { itemColumnFlags[i] = MyItemColumnsForm.GetItemChecked(i); } settings.Set(ReportSettings.BoolArrays.ItemStatFlags, itemColumnFlags); //Set selected columns for annotations. selectedAnnotationTypeObjects = MyAnnotationTypesForm.GetCheckedItems(); selectedAnnotationTypes = new Identifiable[selectedAnnotationTypeObjects.GetLength(0)]; for (int i = 0; i < selectedAnnotationTypeObjects.GetLength(0); i++) { selectedAnnotationTypes[i] = (Identifiable)selectedAnnotationTypeObjects[i]; } settings.Set(ReportSettings.Identifiables.AnnotationTypes, selectedAnnotationTypes); //Set split file flag. settings.Set(ReportSettings.Bools.SplitFile, SplitFileCheckBox.Checked); //Set file path. settings.Set(ReportSettings.Strings.FilePath, MyFilePath); //Set destination file name. settings.Set(ReportSettings.Strings.FileName, MyFileName); return(MyOKFlag ? settings : null); }
public static Boolean[,] basicFill(Boolean[,] PointMap) { Boolean[,] shadeMap = new Boolean[PointMap.GetLength(1), PointMap.GetLength(1)]; //j++; for (int i = 0; i < shadeMap.GetLength(1); i++) { for (int j = 0; j < shadeMap.GetLength(1); j++) { if (PointMap[i, j]) { break; } shadeMap[i, j] = true; } } //j--; for (int i = 0; i < shadeMap.GetLength(1); i++) { for (int j = shadeMap.GetLength(1) - 1; j >= 0; j--) { if (PointMap[i, j]) { break; } shadeMap[i, j] = true; } } //i++; for (int i = 0; i < shadeMap.GetLength(0); i++) { for (int j = 0; j < shadeMap.GetLength(1); j++) { if (PointMap[i, j]) { break; } shadeMap[i, j] = true; } } //i--; for (int j = 0; j < shadeMap.GetLength(1); j++) { for (int i = shadeMap.GetLength(0) - 1; i >= 0; i--) { if (PointMap[i, j]) { break; } shadeMap[i, j] = true; } } Boolean hasMove = true; while (hasMove) { hasMove = false; for (int i = 1; i < PointMap.GetLength(0) - 1; i++) { for (int j = 1; j < PointMap.GetLength(1) - 1; j++) { if (shadeMap[i, j]) { if (!PointMap[i - 1, j] && !shadeMap[i - 1, j]) { shadeMap[i - 1, j] = true; hasMove = true; } if (!PointMap[i + 1, j] && !shadeMap[i + 1, j]) { shadeMap[i + 1, j] = true; hasMove = true; } if (!PointMap[i, j - 1] && !shadeMap[i, j - 1]) { shadeMap[i, j - 1] = true; hasMove = true; } if (!PointMap[i, j + 1] && !shadeMap[i, j + 1]) { shadeMap[i, j + 1] = true; hasMove = true; } } } } } return(shadeMap); }
public void generateLake() { int lakeCount = sx % 5 + 1; int lakeRange = 12; int px = sx; int py = sy; int attempt = 0; int CurrentLakeCount = 0; while (attempt < 100 && CurrentLakeCount < 1) { Point Position = new Point(buffer + (px % (useRegion)), buffer + (py % (useRegion))); double Oceandistance = MapUtil.GetDist((int)Position.X, (int)Position.Y, IslandMap.o, wx / 2); //Debug.WriteLine("Center: " + Position); if (Oceandistance > lakeRange * 2 || Oceandistance == -1) { IslandMap.LakePoints.Add(Position); int[] LakePoints = MathUtil.MathUtil.generateFibonocciNumbers(sx + px + 12, sy + py + 13, 20, 2); List <Point> P = new List <Point>(); for (int j = 0; j < LakePoints.GetLength(0) / 2; j++) { //Debug.WriteLine(new Point(Position.X + ((LakePoints[j] % lakeRange) - lakeRange / 2), Position.Y + ((LakePoints[j + 1] % lakeRange) - lakeRange / 2))); Point newPoint = new Point(Position.X + ((LakePoints[j] % lakeRange) - lakeRange / 2), Position.Y + ((LakePoints[j + 1] % lakeRange) - lakeRange / 2)); P.Add(newPoint); } //add 5 points P.Add(P[0]); Boolean[,] Map = new Boolean[(wx + 1), (wy + 1)]; for (int j = 0; j < P.Count - 1; j++) { Map = MapUtil.createCurve(Map, P[j], P[j + 1], 2); } Boolean[,] shadeMap = MapUtil.basicFill(Map); for (int countX = 0; countX < Map.GetLength(0); countX++) { for (int countY = 0; countY < Map.GetLength(1); countY++) { if (!IslandMap.lk[countX, countY]) { IslandMap.lk[countX, countY] = !shadeMap[countX, countY]; } } } Boolean[,] RiverMap = new Boolean[(wx + 1), (wy + 1)]; Point OceanPoint = MapUtil.getClosest((int)Position.X, (int)Position.Y, IslandMap.o, wx / 4); Point RiverPoint = MapUtil.getClosest((int)Position.X, (int)Position.Y, IslandMap.r, wx / 4); Point ClosestPoint = MathUtil.MathUtil.distance(Position, OceanPoint) < MathUtil.MathUtil.distance(Position, RiverPoint) ? OceanPoint : RiverPoint; IslandMap.DeltaPoints.Add(ClosestPoint); MapUtil.createCurve(RiverMap, Position, ClosestPoint, 2); for (int countX = 0; countX < Map.GetLength(0); countX++) { for (int countY = 0; countY < Map.GetLength(1); countY++) { if (!IslandMap.r[countX, countY] && RiverMap[countX, countY]) { IslandMap.r[countX, countY] = RiverMap[countX, countY]; } } } CurrentLakeCount++; } attempt++; int tx = px; px += py + 1; px %= wx; py = (tx) % wx; } for (int i = 0; i < IslandMap.r.GetLength(0); i++) { for (int j = 0; j < IslandMap.r.GetLength(1); j++) { if (IslandMap.r[i, j]) { IslandMap.l[i, j] = false; } if (IslandMap.lk[i, j]) { IslandMap.l[i, j] = false; } } } //Debug.WriteLine("Attempts: " + attempt); }