private void Confirm_Click(object sender, EventArgs e) { if (SubName.Text == null || SubName.Text.Length == 0) { MessageBox.Show("Заполните поле назвние вещества!"); return; } if (Formula.Text == null || Formula.Text.Length == 0) { MessageBox.Show("Заполните поле формулы вещества!"); return; } if (isAddition) { Archive.Add <Substance>(new Substance(SubName.Text, Formula.Text)); } else { Archive.Update <Substance>(new Substance(SubName.Text, Formula.Text, Updated.ID)); } MessageBox.Show(isAddition ? "Вещество добавлено" : "Вещество обновлено", "Готово!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
/// <summary> /// Save a move in the archive /// </summary> /// <param name="isWhite"></param> /// <param name="Board"></param> /// <param name="lastPlay"></param> public void AddArchive() { // Depth copy int[,] BoardCopy = new int[COLUMN, ROW]; for (int x = 0; x < COLUMN; ++x) { for (int y = 0; y < ROW; ++y) { BoardCopy[x, y] = Board[x, y]; } } // Archive copy Archive.Add(new Tuple <bool, int[, ], Tuple <int, int> >(CurrentPlayerTurn, BoardCopy, LastMovePosition)); }
private void MoveToArchive(TransmittalVM trans) { var file = trans.File; file.MoveTo(ArchivePath(file)); _ui.Send(x => Archive.Add(file.Name), null); if (Archive.Count > MAX_ARCHIVE) { _ui.Send(x => Archive.RemoveAt(0), null); } //OnGoing.Remove(trans); _ui.Send(x => OnGoing.Remove(trans), null); //Pending.Remove(file); _ui.Send(x => Pending.Remove(file), null); }
private void ArchiveInput(Key member) { //Grab the Input we want moved OpenTextInput input = Groups[member.Group].Members[member.Member]; { //Check if this is in favorites string str = $"{member.Group}-{member.Member}"; if (FavoriteMembers.Contains(str)) { FavoriteMembers.Remove(str); } } //Remove it from its old location Groups[member.Group].Members.RemoveAt(member.Member); input.Index = Archive.Count; Archive.Add(input); }
private void Confirm_Click(object sender, EventArgs e) { if (NameDisc.Text == null || NameDisc.Text.Length == 0) { MessageBox.Show("Заполните поле имени первооткрывателя!"); return; } if (isAddition) { Archive.Add <Discoverer>(new Discoverer(NameDisc.Text.ToString())); } else { Archive.Update <Discoverer>(new Discoverer(NameDisc.Text.ToString(), Updated.ID)); } MessageBox.Show(isAddition ? "Первооткрыватель добавлен" : "Первооткрыватель обновлен", "Готово!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
private void Confirm_Click(object sender, EventArgs e) { if (AsterName.Text == null || AsterName.Text.Length == 0) { MessageBox.Show("Заполните поле имени созвездия!"); return; } if (isAddition) { Archive.Add <Asterism>(new Asterism(AsterName.Text, Convert.ToDouble(Square.Value))); } else { Archive.Update <Asterism>(new Asterism(AsterName.Text, Convert.ToDouble(Square.Value), Updated.ID)); } MessageBox.Show(isAddition ? "Созвездие добавлено" : "Созвездие обновлено", "Готово!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
public IActionResult ExecuteTests() { var nunit = new HW5T1.MyNUnit($"{environment.WebRootPath}/Temp"); nunit.Execute(); var results = nunit.GetAllData(); var assemblyReport = new AssemblyReportModel(); var idPart = DateTime.Now; foreach (var test in results) { var currentReport = new TestReportModel(); currentReport.Name = test.Name; currentReport.Time = test.TimeOfExecution; currentReport.WhyIgnored = test.WhyIgnored; currentReport.Id = idPart.ToString() + '%' + test.Name; if (test.Result == "Success") { currentReport.Passed = true; assemblyReport.Passed++; } else if (test.Result == "Failed") { currentReport.Passed = false; assemblyReport.Failed++; } else { currentReport.Passed = null; assemblyReport.Ignored++; } infoContainer.TestReports.Add(currentReport); archive.Add(currentReport); archive.SaveChanges(); assemblyReport.TestReports.Add(currentReport); } this.currentAssembly = assemblyReport; currentState.AssemblyReports.Add(assemblyReport); return(View("Index", infoContainer.TestReports)); }
/// <summary> /// Remove the selected Notebook /// </summary> /// <param name="dataContext"></param> public static bool Remove(BangumiNotebook notebook) { int index = Archive.ToList().FindIndex(cur => cur == notebook); // Add new notebook if this is the last one if (Archive.Count <= 1) { Archive.Add(new BangumiNotebook("New Notebook")); } Archive.RemoveAt(index); if (index == ArcIndex) { ArcIndex = 0; ResetAll(); return(true); } else if (index < ArcIndex) { ArcIndex -= 1; } return(false); }
public void FinishCourse(string courseName, params int[] marks) { if (!String.IsNullOrEmpty(courseName)) { foreach (var item in Course) { if (item.CourseName == courseName) { if (marks.Length != item.StudentID.Count) { throw new ArgumentException("You must mark all students"); } for (int i = 0; i < item.StudentID.Count; i++) { item.Mark[i] = marks[i]; } // archive Archive.Add(item); Course.Remove(item); break; } } } }
private void Confirm_Click(object sender, EventArgs e) { if (SubstanceSelects.Sum(S => S.NUM.Value) != 1) { MessageBox.Show("Сумма долей веществ должна равнятся 1!"); return; } if (ObjName.Text == null || ObjName.Text.Length == 0) { MessageBox.Show("Заполните поле названия звезды!"); return; } if (isAddition) { List <string> IDS = Archive.Add <Star>(new Star( ObjName.Text, DateKnown.Checked ? (int?)Date.Value : null, ObjectDiscoverer.SelectedIndex == 0 ? null : ObjectDiscoverer.SelectedItem as Discoverer, AsterismSelect.Items.Count == 0 ? null : AsterismSelect.SelectedItem as Asterism, Convert.ToDouble(Distance.Value), MassKnown.Checked ? (double?)Mass.Value : null, Convert.ToDouble(TMin.Value), Convert.ToDouble(TMax.Value), ColorVars )); int id = Convert.ToInt32(IDS[0]); foreach (SubstanceInput SI in SubstanceSelects) // добавлние данных о веществах в звезде в БД { Archive.Add <Star_Substance>(new Star_Substance(id, (SI.CB.SelectedItem as Substance).ID, (double)SI.NUM.Value)); } Star ST = Archive.Stars.Single(S => S.ID == id); foreach (SubstanceInput SI in SubstanceSelects) // добавлние данных о веществах в модель { ST.SubstancesPercentage.Add(SI.CB.SelectedItem as Substance, (double)SI.NUM.Value); } } else { List <Star_Substance> Substances = Archive.StarSubstances.Where(S => S.StarId == Updated.ID).ToList(); foreach (Star_Substance SSP in Substances) //удаление из БД всех данных о веществах в этой звезде { Archive.Delete <Star_Substance>(SSP); } foreach (SubstanceInput SI in SubstanceSelects) //добавление в БД новых данных о веществах в этой звезде { Archive.Add <Star_Substance>(new Star_Substance(Updated.ID, (SI.CB.SelectedItem as Substance).ID, (double)SI.NUM.Value)); } Archive.Update <Star>(new Star( ObjName.Text, DateKnown.Checked ? (int?)Date.Value : null, ObjectDiscoverer.SelectedIndex == 0 || ObjectDiscoverer.SelectedIndex == 0 ? null : ObjectDiscoverer.SelectedItem as Discoverer, AsterismSelect.Items.Count == 0 ? null : AsterismSelect.SelectedItem as Asterism, Convert.ToDouble(Distance.Value), MassKnown.Checked ? (double?)Mass.Value : null, Convert.ToDouble(TMin.Value), Convert.ToDouble(TMax.Value), ColorVars, SubstanceSelects.ToDictionary(S => (Substance)S.CB.SelectedItem, S => (double)S.NUM.Value), Updated.ID )); Star ST = Archive.Stars.Single(S => S.ID == Updated.ID); ST.SubstancesPercentage.Clear(); //удаление из модели(состояния соответствующего объекта зведзы) всех данных о веществах в этой звезде foreach (SubstanceInput SI in SubstanceSelects) //добавлние в модель всех данных о веществах в этой звезде { ST.SubstancesPercentage.Add(SI.CB.SelectedItem as Substance, (double)SI.NUM.Value); } } MessageBox.Show(isAddition ? "Звезда добавлена" : "Звезда обновлена", "Готово!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
//Метод перемещания преступника в архив public void MoveToArchive(Criminal criminal) { Criminals.Remove(criminal); Archive.Add(criminal); }
/// <summary> /// Add a new Notebook /// </summary> /// <param name="name"></param> public static void Add(string name) { Archive.Add(new BangumiNotebook(name)); Change(Archive.Count - 1); }
public IEnumerator SaveGameAsync(string title, string outputFileName, GameSaveOptions gameSaveOptions) { if (string.IsNullOrEmpty(outputFileName)) { throw new ArgumentException("outputFileName"); } string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(outputFileName); string fileNameExtension = System.IO.Path.GetExtension(outputFileName); string path = System.IO.Path.GetDirectoryName(outputFileName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if ((gameSaveOptions & GameSaveOptions.QuickSave) == GameSaveOptions.QuickSave) { title = "%QuickSaveFileName"; fileNameWithoutExtension = "QuickSave"; } if ((gameSaveOptions & GameSaveOptions.AutoSave) == GameSaveOptions.AutoSave) { title = "%AutoSaveFileName"; fileNameWithoutExtension = "AutoSave"; if (global::GameManager.maximumNumberOfAutoSaveFiles == 0) { yield break; } if ((gameSaveOptions & GameSaveOptions.Incremental) == GameSaveOptions.Incremental) { int number = this.ProcessIncremental(path, fileNameWithoutExtension); fileNameWithoutExtension = string.Format("{0} {1}", fileNameWithoutExtension, number); } } outputFileName = System.IO.Path.Combine(path, string.Format("{0}{1}", fileNameWithoutExtension, fileNameExtension)); MemoryStream stream = new MemoryStream(); try { this.SaveGame(stream); ISessionService sessionService = Services.GetService <ISessionService>(); Diagnostics.Assert(sessionService != null); Diagnostics.Assert(sessionService.Session != null); if (this.GameSaveDescriptor == null) { this.GameSaveDescriptor = new GameSaveDescriptor(); using (WorldGenerator worldGenerator = new WorldGenerator()) { this.GameSaveDescriptor.SourceFileName = worldGenerator.GetOuputPath(); if (File.Exists(this.GameSaveDescriptor.SourceFileName)) { this.GameSaveDescriptor.Source = File.ReadAllBytes(this.GameSaveDescriptor.SourceFileName); } } Diagnostics.Assert(this.Game is global::Game); Diagnostics.Assert(sessionService.Session != null); global::Game game = this.Game as global::Game; int turn = Math.Max(0, game.Turn - 1); this.GameSaveDescriptor.GameSaveSessionDescriptor.TrackUserPresence(game, sessionService.Session, turn); this.GameSaveDescriptor.GUID = Guid.NewGuid(); } this.GameSaveDescriptor.DateTime = DateTime.Now; this.GameSaveDescriptor.Title = title; this.GameSaveDescriptor.Version = Amplitude.Unity.Framework.Application.Version; this.GameSaveDescriptor.Turn = (this.Game as global::Game).Turn; if ((gameSaveOptions & GameSaveOptions.Closed) == GameSaveOptions.Closed) { this.GameSaveDescriptor.Closed = true; } IRuntimeService runtimeService = Services.GetService <IRuntimeService>(); if (runtimeService != null && runtimeService.Runtime != null) { Diagnostics.Assert(runtimeService.Runtime.RuntimeModules != null); this.GameSaveDescriptor.RuntimeModules = (from runtimeModule in runtimeService.Runtime.RuntimeModules select runtimeModule.Name).ToArray <string>(); } this.GameSaveDescriptor.GameSaveSessionDescriptor.SessionMode = sessionService.Session.SessionMode; this.GameSaveDescriptor.GameSaveSessionDescriptor.SetLobbyData(sessionService.Session); outputFileName = System.IO.Path.ChangeExtension(outputFileName, "sav"); if (File.Exists(this.GameSaveDescriptor.SourceFileName)) { try { if (outputFileName != this.GameSaveDescriptor.SourceFileName) { File.Copy(this.GameSaveDescriptor.SourceFileName, outputFileName, true); } } catch (Exception ex) { Exception exception = ex; if (!(exception is IOException)) { throw; } if (!File.Exists(outputFileName)) { throw; } } } else { if (this.GameSaveDescriptor.Source == null) { throw new FileNotFoundException("The source file is missing; it may have been deleted?", this.GameSaveDescriptor.SourceFileName); } try { Diagnostics.LogWarning("Using binary source to restore the game archive..."); File.WriteAllBytes(outputFileName, this.GameSaveDescriptor.Source); } catch { throw; } } using (Archive archive = Archive.Open(outputFileName, ArchiveMode.OpenOrCreate)) { archive.Add(global::GameManager.GameFileName, stream, CompressionMethod.Compressed); stream.Seek(0L, SeekOrigin.Begin); stream.SetLength(0L); this.SaveGameDescriptor(stream); if (stream.Length > 0L) { archive.Add(global::GameManager.GameSaveDescriptorFileName, stream, CompressionMethod.Compressed); } if (this.GameSaving != null) { this.GameSaving(this, new GameSavingEventArgs(archive)); } } this.GameSaveDescriptor.SourceFileName = outputFileName; } catch { throw; } if (stream != null) { stream.Close(); stream = null; } yield break; }