private void addModelButton_Click(object sender, EventArgs e) { ModelsData.Model newModel = new ModelsData.Model(); ManageModelForm addEditModelForm = new ManageModelForm(newModel, ManageModelForm.CallType.Add, -1); addEditModelForm.ShowDialog(); if (addEditModelForm.DialogResult == DialogResult.OK) { MainForm.modelsData.modelList.Add(addEditModelForm.GetModel()); MainForm.modelsJson.WriteModelsJson(); } }
private void EditModel() { if (modelsListBox.SelectedIndex >= 0) { //convert to json e deserialize to create a new fresh object string json = Newtonsoft.Json.JsonConvert.SerializeObject(MainForm.modelsData.modelList[modelsListBox.SelectedIndex]); ModelsData.Model editModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ModelsData.Model>(json); ManageModelForm addEditModelForm = new ManageModelForm(editModel, ManageModelForm.CallType.Edit, modelsListBox.SelectedIndex); addEditModelForm.ShowDialog(); if (addEditModelForm.DialogResult == DialogResult.OK) { MainForm.modelsData.modelList[modelsListBox.SelectedIndex] = addEditModelForm.GetModel(); MainForm.modelsJson.WriteModelsJson(); } } }
public string GenerateModel(ManageModelForm manageModelForm) { Logger.Trace(System.Reflection.MethodBase.GetCurrentMethod().Name); model = manageModelForm.GetModel(); string command = ""; // mkvmerge Path command += "\"||mkvmergePath||\" "; // --output command += "--output \"||outputFileFullPath||\" "; // work on track0 tracks command += GenerateTrackString(0); // work on other tracks bool done = false; int fileNumber = 0; while (!done) { fileNumber++; bool found = false; foreach (ModelsData.Model.Track track in model.trackList) { if (track.originalFileNumber == fileNumber) { found = true; break; } } if (found) { command += GenerateTrackString(fileNumber); } else { done = true; } } // --title if (model.customOutputFileArguments.emptyTitle) { command += "--title \"\" "; } // Add attachments if (model.customOutputFileArguments.addAttachments) { command += "||attachments|| "; } // Add chapters if (model.customOutputFileArguments.addChapters) { command += "||chapters|| "; } // add user defined custom output arguments if (!string.IsNullOrEmpty(model.customOutputFileArguments.text)) { command += model.customOutputFileArguments.text + " "; } // --track-order command += "--track-order "; int i = 0; foreach (ModelsData.Model.Track track in model.trackList) { if (i == 0) { command += track.originalFileNumber.ToString() + ':' + track.originalFileTrackPosition.ToString(); } else { command += "," + track.originalFileNumber.ToString() + ':' + track.originalFileTrackPosition.ToString(); } i++; } return(command); }
public bool CheckModel(ManageModelForm manageModelForm) { Logger.Trace(System.Reflection.MethodBase.GetCurrentMethod().Name); ModelsData.Model model = manageModelForm.GetModel(); Boolean result = true; errorList = ""; int errorIndex = 0; //model name must be specified if (String.IsNullOrEmpty(model.modelName)) { errorIndex += 1; AddError(Properties.Resources.ErrorLabel + " n." + errorIndex + ": " + Properties.Resources.DigitModelName); result = false; } for (int i = 0; i < MainForm.modelsData.modelList.Count; i++) { // if the model where are checking is already in model list if (MainForm.modelsData.modelList[i].modelName == model.modelName) { // if found but where are editing the same model, is ok if (manageModelForm.callType == ManageModelForm.CallType.Edit && i == manageModelForm.currentModelIndex) { } else { errorIndex += 1; AddError(Properties.Resources.ErrorLabel + " n." + errorIndex + ": " + Properties.Resources.UseDifferentModelName + " (" + model.modelName + ")"); result = false; } } } if (!model.customCommand) { // at least a track need to be inserted if (model.trackList.Count == 0) { errorIndex += 1; AddError(Properties.Resources.ErrorLabel + " n." + errorIndex + ": " + Properties.Resources.AddTrackOrUseCustomModel); result = false; } Boolean track0 = false; for (int i = 0; i < model.trackList.Count; i++) { if (model.trackList[i].originalFileNumber == 0) { track0 = true; } } // at least a track from file 0 need to be in track list if (!track0) { errorIndex += 1; AddError(Properties.Resources.ErrorLabel + " n." + errorIndex + ": " + Properties.Resources.AddTrackFromFileNumber0); result = false; } if (model.customInputFileArguments.noAttachments && model.customOutputFileArguments.addAttachments) { errorIndex += 1; AddError(Properties.Resources.ErrorLabel + " n." + errorIndex + ": " + Properties.Resources.UseOneAttachmentFlag); result = false; } } return(result); }