/// <summary> /// EventHandler for when the this.GameLocationTextbox (for the game's executable location) /// text is changed. /// </summary> private void GameLocationTextbox_TextChanged(object sender, EventArgs e) { if (this.GameInstance.IsDOSBoxUsed(Program.UserDataAccessorInstance.GetUserData()) == false || this.DontUseDOSBoxCheckBox.Checked) { return; } //if a location for the game's executable has been entered if (StringExt.IsNullOrWhiteSpace(this.GameLocationTextbox.Text) == false) { //then the directory mounted has C: TextBox, BrowseButton, and Labeled are disabled //(because DOSBox already mounts the executable's directory path as C: ) this.GameDirectoryTextbox.Enabled = false; this.GameDirectoryBrowseButton.Enabled = false; this.GameDirectoryLabel.Enabled = false; } else { //if not, they are enabled this.GameDirectoryTextbox.Enabled = true; this.GameDirectoryBrowseButton.Enabled = true; this.GameDirectoryLabel.Enabled = true; } //if the entered executable does exist if (StringExt.IsNullOrWhiteSpace(this.GameLocationTextbox.Text) == false) { //the directory mounted has C: is displayed : it is the game's executable full directory path if (File.Exists(this.GameLocationTextbox.Text)) { //(even if the GameDirectory controls are not enabled : it's just to inform the user) this.GameDirectoryTextbox.Text = Path.GetDirectoryName(this.GameLocationTextbox.Text); } } }
public ActionResult CarregarRespostasPorQuestao(string codigo, string codQuestao) { if (!StringExt.IsNullOrWhiteSpace(codigo, codQuestao)) { AvalAcademica acad = AvalAcademica.ListarPorCodigoAvaliacao(codigo); int codQuestaoTemp = int.Parse(codQuestao); var retorno = from questao in acad.Avaliacao.PessoaResposta orderby questao.PessoaFisica.Nome where questao.CodQuestao == codQuestaoTemp && questao.AvalTemaQuestao.QuestaoTema.Questao.CodTipoQuestao == TipoQuestao.DISCURSIVA select new { alunoMatricula = acad.AlunosRealizaram.FirstOrDefault(a => a.Usuario.CodPessoaFisica == questao.CodPessoaFisica).Usuario.Matricula, alunoNome = questao.PessoaFisica.Nome, codQuestao = questao.CodQuestao, questaoEnunciado = questao.AvalTemaQuestao.QuestaoTema.Questao.Enunciado, questaoChaveResposta = questao.AvalTemaQuestao.QuestaoTema.Questao.ChaveDeResposta, alunoResposta = questao.RespDiscursiva, notaObtida = questao.RespNota.HasValue ? questao.RespNota.Value.ToValueHtml() : "", correcaoComentario = questao.ProfObservacao != null ? questao.ProfObservacao : "", flagCorrigida = questao.RespNota != null ? true : false }; return(Json(retorno)); } return(Json(null)); }
/// <summary> Returns the absolute the path to the user data file (AmpShell.xml). </summary> /// <returns> The absolute path to the user data file. </returns> internal string GetDataFilePath() { var appDataFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "AmpShell\\AmpShell.xml"); if (StringExt.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("AmpShellDebug")) == false) { return(appDataFile); } if (FileFinder.HasWriteAccessToAssemblyLocationFolder() == false) { var appDataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "AmpShell"); if (Directory.Exists(appDataDir) == false) { Directory.CreateDirectory(appDataDir); } return(appDataFile); } else { var portableAppDataFile = Path.Combine(PathFinder.GetStartupPath(), "AmpShell.xml"); if (File.Exists(portableAppDataFile)) { return(portableAppDataFile); } else { return(appDataFile); } } }
/// <summary> EventHandler to choose the game .conf (config) file. </summary> private void GameCustomConfigurationBrowseButton_Click(object sender, EventArgs e) { using (var customConfigFileDialog = new OpenFileDialog()) { if (Program.UserDataAccessorInstance.GetUserData().PortableMode == true) { customConfigFileDialog.InitialDirectory = Application.StartupPath; } else if (StringExt.IsNullOrWhiteSpace(this.GameCustomConfigurationTextbox.Text) == false && Directory.Exists(Path.GetDirectoryName(this.GameCustomConfigurationTextbox.Text))) { customConfigFileDialog.InitialDirectory = Path.GetDirectoryName(this.GameCustomConfigurationTextbox.Text); } else { customConfigFileDialog.InitialDirectory = this.GetFileDialogStartDirectory(); } customConfigFileDialog.Title = this.GameCustomConfigurationLabel.Text; customConfigFileDialog.Filter = "DOSBox configuration file (*.conf)|*.conf;*.CONF"; if (customConfigFileDialog.ShowDialog(this) == DialogResult.OK) { this.GameCustomConfigurationTextbox.Text = customConfigFileDialog.FileName; } } }
/// <summary> Starts DOSBox, and returns its <see cref="Process" />. </summary> /// <returns> The DOSBox <see cref="Process" />. </returns> private Process StartGame(string args) { if (this._game.IsDOSBoxUsed(_userData) == false) { var targetAndArguments = this._game.SplitTargetAndArguments(); var nativeLaunchPsi = new ProcessStartInfo(targetAndArguments[0], targetAndArguments[1]) { UseShellExecute = true, WorkingDirectory = Path.GetDirectoryName(this._game.DOSEXEPath) }; return(StartProcess(nativeLaunchPsi)); } var psi = new ProcessStartInfo(this._game.GetDOSBoxPath(_userData)) { UseShellExecute = true }; psi.WorkingDirectory = this._game.GetDOSBoxWorkingDirectory(psi.WorkingDirectory, _userData); if (StringExt.IsNullOrWhiteSpace(args) == false) { psi.Arguments = args; } return(StartProcess(psi)); }
public static bool CorrigirQuestaoAluno(string codAvaliacao, string matrAluno, int codQuestao, double notaObtida, string profObservacao) { if (!StringExt.IsNullOrWhiteSpace(codAvaliacao, matrAluno) && codQuestao != 0) { AvalAcadReposicao aval = ListarPorCodigoAvaliacao(codAvaliacao); Aluno aluno = Aluno.ListarPorMatricula(matrAluno); int codPessoaFisica = aluno.Usuario.PessoaFisica.CodPessoa; AvalQuesPessoaResposta resposta = aval.Avaliacao.PessoaResposta.FirstOrDefault(pr => pr.CodQuestao == codQuestao && pr.CodPessoaFisica == codPessoaFisica); resposta.RespNota = notaObtida; resposta.ProfObservacao = profObservacao; aval.Avaliacao.AvalPessoaResultado .Single(r => r.CodPessoaFisica == codPessoaFisica) .Nota = aval.Avaliacao.PessoaResposta .Where(pr => pr.CodPessoaFisica == codPessoaFisica) .Average(pr => pr.RespNota); contexto.SaveChanges(); return(true); } return(false); }
public ActionResult EsqueceuSenha(CandidatoEsqueceuSenhaViewModel model) { if (!StringExt.IsNullOrWhiteSpace(model.Cpf, model.Email) && Valida.CPF(model.Cpf) && Valida.Email(model.Email)) { Candidato c = Candidato.ListarPorCPF(Formate.DeCPF(model.Cpf)); if (c != null && c.Email.ToLower() == model.Email.ToLower()) { string token = Candidato.GerarTokenParaAlterarSenha(c); string url = Url.Action("AlterarSenha", "Candidato", new { codigo = token }, Request.Url.Scheme); EnviarEmail.SolicitarSenha(c.Email, c.Nome, url); TempData["EsqueceuSenhaMensagem"] = $"Um email com instruções foi enviado para {c.Email}."; return(RedirectToAction("EsqueceuSenha")); } else { model.Mensagem = "Não foi encontrado nenhum candidato para os dados informados."; } } else { model.Mensagem = "Todos os campos devem serem preenchidos com valores válidos."; } return(View(model)); }
public static Image GetImageFromFile(string filePath) { if (StringExt.IsNullOrWhiteSpace(filePath) || File.Exists(filePath) == false) { return(null); } if (FileExtensionIsExe(filePath)) { try { return(Icon.ExtractAssociatedIcon(filePath)?.ToBitmap()); } catch { } } try { return(Image.FromFile(filePath)); } catch { } return(null); }
private static void RunCli(CliOptions options) { if (StringExt.IsNullOrWhiteSpace(options.Game.Value)) { Console.WriteLine($"Empty game specified. Exiting..."); } var userDataAccessor = new UserDataAccessor(); var game = userDataAccessor.GetFirstGameWithName(options.Game.Value); if (StringExt.IsNullOrWhiteSpace(game.DOSEXEPath)) { game = userDataAccessor.GetGameWithMainExecutable(options.Game.Value); } if (options.Setup.IsProvided) { if (options.Verbose.IsProvided) { Console.WriteLine($"Running '{game.Name}''s setup executable: {game.SetupEXEPath}..."); } game.RunSetup(userDataAccessor.GetUserData()); } else { if (options.Verbose.IsProvided) { Console.WriteLine($"Running the game named '{game.Name}' via the main executable at {game.DOSEXEPath}..."); } game.Run(userDataAccessor.GetUserData()); } }
public ActionResult CarregarRespostasDiscursivas(string codigo, string matrAluno) { if (!StringExt.IsNullOrWhiteSpace(codigo, matrAluno)) { AvalAcadReposicao aval = AvalAcadReposicao.ListarPorCodigoAvaliacao(codigo); Aluno aluno = Aluno.ListarPorMatricula(matrAluno); int codPessoaFisica = aluno.Usuario.PessoaFisica.CodPessoa; var retorno = from alunoResposta in aval.Avaliacao.PessoaResposta orderby alunoResposta.CodQuestao where alunoResposta.CodPessoaFisica == codPessoaFisica && alunoResposta.AvalTemaQuestao.QuestaoTema.Questao.CodTipoQuestao == TipoQuestao.DISCURSIVA select new { codQuestao = alunoResposta.CodQuestao, questaoEnunciado = alunoResposta.AvalTemaQuestao.QuestaoTema.Questao.Enunciado, questaoChaveResposta = alunoResposta.AvalTemaQuestao.QuestaoTema.Questao.ChaveDeResposta, alunoResposta = alunoResposta.RespDiscursiva, notaObtida = alunoResposta.RespNota.HasValue ? alunoResposta.RespNota.Value.ToValueHtml() : "", correcaoComentario = alunoResposta.ProfObservacao != null ? alunoResposta.ProfObservacao : "", flagCorrigida = alunoResposta.RespNota != null ? true : false }; return(Json(retorno)); } return(Json(null)); }
public ActionResult AtualizarSenha(string senhaAtual, string senhaNova, string senhaConfirmacao) { string mensagem = "Ocorreu um erro ao tentar alterar a senha."; if (!StringExt.IsNullOrWhiteSpace(senhaAtual, senhaNova, senhaConfirmacao)) { Candidato c = Sessao.Candidato; if (Criptografia.ChecarSenha(senhaAtual, c.Senha)) { if (senhaNova == senhaConfirmacao) { c.Senha = Criptografia.RetornarHash(senhaNova); Repositorio.Commit(); mensagem = "Senha alterada com sucesso."; } else { mensagem = "A confirmação da senha deve ser igual a senha nova."; } } else { mensagem = "A senha atual informada está incorreta."; } } else { mensagem = "Todos os campos são necessários para alterar a senha."; } TempData["Mensagem"] = mensagem; return(RedirectToAction("Perfil")); }
private string AddCustomConfigFile() { string gameConfigFilePath = string.Empty; //if the "do not use any config file at all" has not been checked if (this._game.NoConfig == false) { //use at first the game's custom config file if (StringExt.IsNullOrWhiteSpace(this._game.DBConfPath) == false) { gameConfigFilePath = this._game.DBConfPath; } //if not, use the default dosbox.conf file else if (StringExt.IsNullOrWhiteSpace(_userData.DBDefaultConfFilePath) == false && _userData.DBDefaultConfFilePath != "No configuration file (*.conf) found in AmpShell's directory.") { gameConfigFilePath = _userData.DBDefaultConfFilePath; } } string dosboxArgs = string.Empty; if (StringExt.IsNullOrWhiteSpace(gameConfigFilePath) == false) { dosboxArgs += $"-conf \"{gameConfigFilePath}\""; } return(dosboxArgs); }
public static T Deserialize <T>(string xmlPath) where T : new() { if (StringExt.IsNullOrWhiteSpace(xmlPath)) { throw new ArgumentNullException(nameof(xmlPath)); } Directory.CreateDirectory(Path.GetDirectoryName(xmlPath)); XmlReaderSettings settings = new XmlReaderSettings() { XmlResolver = null }; using (var reader = XmlReader.Create(xmlPath, settings)) { var serializer = new XmlSerializer(new T().GetType()); try { return((T)serializer.Deserialize(reader)); } catch (InvalidOperationException) { return(new T()); } } }
/// <summary> EventHandler to choose the Game's executable location. </summary> private void GameLocationBrowseButton_Click(object sender, EventArgs e) { using (var gameExeFileDialog = new OpenFileDialog()) { if (Program.UserDataAccessorInstance.GetUserData().PortableMode == true) { gameExeFileDialog.InitialDirectory = Application.StartupPath; } else if (StringExt.IsNullOrWhiteSpace(this.GameLocationTextbox.Text) == false && Directory.Exists(Path.GetDirectoryName(this.GameLocationTextbox.Text))) { gameExeFileDialog.InitialDirectory = Path.GetDirectoryName(this.GameLocationTextbox.Text); } else { gameExeFileDialog.InitialDirectory = this.GetFileDialogStartDirectory(); } gameExeFileDialog.Title = this.GameLocationLabel.Text; gameExeFileDialog.Filter = "Executable file (*.bat;*.cmd;*.com;*.exe)|*.bat;*.cmd;*.com;*.exe;*.BAT;*.CMD;*.COM;*.EXE"; if (gameExeFileDialog.ShowDialog(this) == DialogResult.OK) { this.GameLocationTextbox.Text = gameExeFileDialog.FileName; } if (StringExt.IsNullOrWhiteSpace(this.GameInstance.Icon)) { var bitmapIcon = WinShell.FileIconLoader.GetImageFromFile(this.GameLocationTextbox.Text); if (!(bitmapIcon is null)) { this.GameIconPictureBox.Image = bitmapIcon; this.GameIconPictureBox.Tag = this.GameLocationTextbox.Text; } } } }
/// <summary> EventHandler to choose the game's CD image file. </summary> private void GameCDPathBrowseButton_Click(object sender, EventArgs e) { using (var cdImageFileDialog = new OpenFileDialog()) { cdImageFileDialog.Title = this.GameCDPathLabel.Text; cdImageFileDialog.Filter = "DOSBox compatible CD or Floppy image files (*.bin;*.cue;*.iso;*.img;*.ima)|*.bin;*.cue;*.iso;*.img;*.ima;*.BIN;*.CUE;*.ISO;*.IMG;*.IMA"; if (Program.UserDataAccessorInstance.GetUserData().PortableMode == true) { cdImageFileDialog.InitialDirectory = Application.StartupPath; } else if (StringExt.IsNullOrWhiteSpace(Program.UserDataAccessorInstance.GetUserData().CDsDefaultDir) == false && Directory.Exists(Program.UserDataAccessorInstance.GetUserData().CDsDefaultDir)) { cdImageFileDialog.InitialDirectory = Program.UserDataAccessorInstance.GetUserData().CDsDefaultDir; } else { cdImageFileDialog.InitialDirectory = this.GetFileDialogStartDirectory(); } if (cdImageFileDialog.ShowDialog(this) == DialogResult.OK) { this.GameCDPathTextBox.Text = cdImageFileDialog.FileName; } } }
private void AlternateDOSBoxLocationBrowsSearchButton_Click(object sender, EventArgs e) { using (var alternateDOSBoxExeFileDialog = new OpenFileDialog()) { if (Program.UserDataAccessorInstance.GetUserData().PortableMode == true) { alternateDOSBoxExeFileDialog.InitialDirectory = Application.StartupPath; } else if (StringExt.IsNullOrWhiteSpace(this.AlternateDOSBoxLocationTextbox.Text) == false && Directory.Exists(Path.GetDirectoryName(this.AlternateDOSBoxLocationTextbox.Text))) { alternateDOSBoxExeFileDialog.InitialDirectory = Path.GetDirectoryName(this.AlternateDOSBoxLocationTextbox.Text); } else if (StringExt.IsNullOrWhiteSpace(Program.UserDataAccessorInstance.GetUserData().DBPath) == false && Directory.Exists(Path.GetDirectoryName(Program.UserDataAccessorInstance.GetUserData().DBPath))) { alternateDOSBoxExeFileDialog.InitialDirectory = Program.UserDataAccessorInstance.GetUserData().DBPath; } else { alternateDOSBoxExeFileDialog.InitialDirectory = this.GetFileDialogStartDirectory(); } alternateDOSBoxExeFileDialog.Title = this.AlternateDOSBoxLocationLabel.Text; alternateDOSBoxExeFileDialog.Filter = "DOSBox executable file (*.exe)|*.exe;*.EXE"; if (alternateDOSBoxExeFileDialog.ShowDialog(this) == DialogResult.OK) { this.AlternateDOSBoxLocationTextbox.Text = alternateDOSBoxExeFileDialog.FileName; } } }
public ActionResult Gerar(FormCollection form) { if (!StringExt.IsNullOrWhiteSpace(form["txtTitulo"], form["txtObjetivo"])) { var avi = new AvalAvi(); /* Chave */ avi.Avaliacao = new Avaliacao(); DateTime hoje = DateTime.Now; avi.Avaliacao.TipoAvaliacao = TipoAvaliacao.ListarPorCodigo(TipoAvaliacao.AVI); avi.Avaliacao.Ano = hoje.Year; avi.Avaliacao.Semestre = hoje.SemestreAtual(); avi.Avaliacao.NumIdentificador = Avaliacao.ObterNumIdentificador(TipoAvaliacao.AVI); avi.Avaliacao.DtCadastro = hoje; avi.Avaliacao.FlagLiberada = false; /* AVI */ avi.Titulo = form["txtTitulo"]; avi.Objetivo = form["txtObjetivo"]; /* Colaborador */ Colaborador colaborador = Colaborador.ListarPorMatricula(Sessao.UsuarioMatricula); avi.CodColabCoordenador = colaborador.CodColaborador; avi.Colaborador = colaborador; AvalAvi.Inserir(avi); Lembrete.AdicionarNotificacao($"Avaliação Institucional cadastrada com sucesso.", Lembrete.POSITIVO); return(RedirectToAction("Questionario", new { codigo = avi.Avaliacao.CodAvaliacao })); } return(RedirectToAction("Gerar")); }
public static string GetStartupPath() { if (StringExt.IsNullOrWhiteSpace(startupPath)) { startupPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); } return(startupPath); }
public string GetConfigEditorPath() { if (PlatformDetector.IsWindows() && StringExt.IsNullOrWhiteSpace(_userData.ConfigEditorPath) == false && Path.Combine(Path.GetDirectoryName(Environment.GetFolderPath(Environment.SpecialFolder.System)), "NOTEPAD.EXE").ToUpperInvariant() == _userData.ConfigEditorPath.ToUpperInvariant()) { return(Path.GetFileName(_userData.ConfigEditorPath).ToLowerInvariant()); } return(_userData.ConfigEditorPath); }
public void Empty_value() { string value = ""; Assert.IsTrue(StringExt.IsNullOrWhiteSpace(value), "Test 1"); value = string.Empty; Assert.IsTrue(StringExt.IsNullOrWhiteSpace(value), "Test 2"); }
public static bool FileExtensionIsExe(string filePath) { var extension = Path.GetExtension(filePath); if (StringExt.IsNullOrWhiteSpace(extension)) { return(false); } return(extension.ToUpperInvariant() == ".EXE"); }
private void DeserializeUserData() { _userData = new Preferences(); string dataFilePath = GetDataFilePath(); if (File.Exists(dataFilePath)) { _userData = ObjectSerializer.Deserialize <Preferences>(dataFilePath); } if (_userData.PortableMode) { for (int i = 0; i < _userData.ListChildren.Count; i++) { Category concernedCategory = (Category)_userData.ListChildren[i]; for (int j = 0; j < concernedCategory.ListChildren.Count; j++) { Game concernedGame = (Game)concernedCategory.ListChildren[j]; concernedGame.DOSEXEPath = concernedGame.DOSEXEPath.Replace(AppPathPlaceHolder, PathFinder.GetStartupPath()); concernedGame.DBConfPath = concernedGame.DBConfPath.Replace(AppPathPlaceHolder, PathFinder.GetStartupPath()); concernedGame.AdditionalCommands = concernedGame.AdditionalCommands.Replace(AppPathPlaceHolder, PathFinder.GetStartupPath()); concernedGame.Directory = concernedGame.Directory.Replace(AppPathPlaceHolder, PathFinder.GetStartupPath()); concernedGame.CDPath = concernedGame.CDPath.Replace(AppPathPlaceHolder, PathFinder.GetStartupPath()); concernedGame.SetupEXEPath = concernedGame.SetupEXEPath.Replace(AppPathPlaceHolder, PathFinder.GetStartupPath()); concernedGame.Icon = concernedGame.Icon.Replace(AppPathPlaceHolder, PathFinder.GetStartupPath()); } } _userData.DBDefaultConfFilePath = _userData.DBDefaultConfFilePath.Replace(AppPathPlaceHolder, PathFinder.GetStartupPath()); _userData.DBDefaultLangFilePath = _userData.DBDefaultLangFilePath.Replace(AppPathPlaceHolder, PathFinder.GetStartupPath()); _userData.DBPath = _userData.DBPath.Replace(AppPathPlaceHolder, PathFinder.GetStartupPath()); _userData.ConfigEditorPath = _userData.ConfigEditorPath.Replace(AppPathPlaceHolder, PathFinder.GetStartupPath()); _userData.ConfigEditorAdditionalParameters = _userData.ConfigEditorAdditionalParameters.Replace(AppPathPlaceHolder, PathFinder.GetStartupPath()); } var fileFinder = new FileFinder(_userData); if (StringExt.IsNullOrWhiteSpace(_userData.DBPath) || File.Exists(_userData.DBPath) == false) { _userData.DBPath = fileFinder.SearchDOSBox(dataFilePath); } if (StringExt.IsNullOrWhiteSpace(_userData.ConfigEditorPath) || File.Exists(_userData.ConfigEditorPath) == false) { _userData.ConfigEditorPath = FileFinder.SearchCommonTextEditor(); } if (StringExt.IsNullOrWhiteSpace(_userData.DBDefaultConfFilePath) || File.Exists(_userData.DBDefaultConfFilePath) == false) { _userData.DBDefaultConfFilePath = FileFinder.SearchDOSBoxConf(dataFilePath, _userData.DBPath); } if (StringExt.IsNullOrWhiteSpace(_userData.DBDefaultLangFilePath) || File.Exists(_userData.DBDefaultLangFilePath) == false) { _userData.DBDefaultLangFilePath = FileFinder.SearchDOSBoxLanguageFile(dataFilePath, _userData.DBPath); } }
private string GetFileDialogStartDirectory() { var initialDirectory = this.GetInitialDirectoryFromView(); if (StringExt.IsNullOrWhiteSpace(initialDirectory)) { initialDirectory = this.GameInstance.GetFileDialogInitialDirectoryFromModel(Program.UserDataAccessorInstance.GetUserData()); } return(initialDirectory); }
public ActionResult Cadastrar(CandidatoCadastrarViewModel model) { if (!StringExt.IsNullOrWhiteSpace(model.Nome, model.Cpf, model.Email, model.Senha, model.SenhaConfirmacao)) { if (model.SenhaConfirmacao == model.Senha) { if (Valida.Email(model.Email)) { model.Cpf = Formate.DeCPF(model.Cpf); if (Candidato.ListarPorCPF(model.Cpf) == null) { if (model.Cpf.Length == 11 && Valida.CPF(model.Cpf)) { var c = new Candidato() { Nome = model.Nome, Cpf = model.Cpf, Email = model.Email, Senha = Criptografia.RetornarHash(model.Senha) }; Candidato.Inserir(c); Sessao.Inserir("SimuladoCandidato", c); EnviarEmail.Cadastro(c.Email, c.Nome); return(RedirectToAction("Perfil")); } else { model.Mensagem = "Informe um CPF válido."; } } else { model.Mensagem = "Este CPF já está cadastrado."; } } else { model.Mensagem = "Informe um email válido."; } } else { model.Mensagem = "Senha de Confirmação diferente da Senha informada."; } } else { model.Mensagem = "Todos os campos são obrigatórios."; } return(View(model)); }
public ActionResult CorrigirQuestaoAluno(string codigo, string matrAluno, int codQuestao, string notaObtida, string profObservacao) { if (!StringExt.IsNullOrWhiteSpace(codigo, matrAluno) && codQuestao > 0) { double nota = Double.Parse(notaObtida.Replace('.', ',')); bool retorno = AvalAcadReposicao.CorrigirQuestaoAluno(codigo, matrAluno, codQuestao, nota, profObservacao); return(Json(retorno)); } return(Json(false)); }
//------------------------------------------------------------------------------------------------------------ public static OBJData LoadOBJ(Stream lStream) { m_OBJData = new OBJData(); m_CurrentMaterial = null; m_CurrentGroup = null; StreamReader lLineStreamReader = new StreamReader(lStream); Action <string> lAction = null; string lCurrentLine = null; string[] lFields = null; string lKeyword = null; string lData = null; while (!lLineStreamReader.EndOfStream) { lCurrentLine = lLineStreamReader.ReadLine(); if (StringExt.IsNullOrWhiteSpace(lCurrentLine) || lCurrentLine[0] == '#') { continue; } lFields = lCurrentLine.Trim().Split(null, 2); if (lFields.Length < 2) { continue; } lKeyword = lFields[0].Trim(); lData = lFields[1].Trim(); lAction = null; m_ParseOBJActionDictionary.TryGetValue(lKeyword.ToLowerInvariant(), out lAction); if (lAction != null) { lAction(lData); } } Debug.Log("reached"); var lOBJData = m_OBJData; m_OBJData = null; return(lOBJData); }
public ActionResult CadastrarModulo(FormCollection form) { if (!StringExt.IsNullOrWhiteSpace(form["txtTitulo"], form["txtObjetivo"])) { var modulo = new AviModulo(); modulo.Descricao = form["txtTitulo"]; modulo.Objetivo = form["txtObjetivo"]; modulo.Observacao = String.IsNullOrWhiteSpace(form["txtObservacao"]) ? null : form["txtObservacao"]; AviModulo.Inserir(modulo); Lembrete.AdicionarNotificacao($"Módulo <b>{modulo.Descricao}</b> cadastrado com sucesso.", Lembrete.POSITIVO); } return(RedirectToAction("Configuracao")); }
/// <summary> EventHandler for when the user has clicked on "OK". </summary> private void OK_Click(object sender, EventArgs e) { if (StringExt.IsNullOrWhiteSpace(this.GameNameTextbox.Text) == true) { MessageBox.Show(this, "You must enter the game's name.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } this.GameInstance.DOSBoxWorkingDirectory = this.DOSBoxWorkingDirTextBox.Text; this.GameInstance.DOSEXEPath = this.GameLocationTextbox.Text; this.GameInstance.DBConfPath = this.GameCustomConfigurationTextbox.Text; this.GameInstance.NoConfig = this.NoConfigCheckBox.Checked; this.GameInstance.AdditionalCommands = this.GameAdditionalCommandsTextBox.Text; this.GameInstance.NoConsole = this.NoConsoleCheckBox.Checked; this.GameInstance.InFullScreen = this.FullscreenCheckBox.Checked; this.GameInstance.QuitOnExit = this.QuitOnExitCheckBox.Checked; this.GameInstance.Directory = this.GameDirectoryTextbox.Text; this.GameInstance.Name = this.GameNameTextbox.Text; this.GameInstance.ReleaseDate = this.GameReleaseDatePicker.Value; this.GameInstance.CDPath = this.GameCDPathTextBox.Text; this.GameInstance.CDLabel = this.DiscLabelTextBox.Text; this.GameInstance.SetupEXEPath = this.GameSetupTextBox.Text; this.GameInstance.AlternateDOSBoxExePath = this.AlternateDOSBoxLocationTextbox.Text; if (StringExt.IsNullOrWhiteSpace(this.GameIconPictureBox.ImageLocation) == false) { this.GameInstance.Icon = this.GameIconPictureBox.ImageLocation; } else if (WinShell.FileIconLoader.GetImageFromFile(this.GameInstance.DOSEXEPath) != null) { this.GameInstance.Icon = this.GameInstance.DOSEXEPath; } this.GameInstance.UseIOCTL = this.UseIOCTLRadioButton.Checked; this.GameInstance.MountAsFloppy = this.IsAFloppyDiskRadioButton.Checked; if (StringExt.IsNullOrWhiteSpace(this.GameCDPathTextBox.Text) == false) { if (File.Exists(this.GameCDPathTextBox.Text)) { this.GameInstance.CDIsAnImage = true; } else { this.GameInstance.CDIsAnImage = false; } } this.GameInstance.Notes = this.NotesRichTextBox.Text; this.GameInstance.UsesDOSBox = !this.DontUseDOSBoxCheckBox.Checked; this.DialogResult = DialogResult.OK; this.Close(); }
public Game GetFirstGameWithName(string name) { if (StringExt.IsNullOrWhiteSpace(name)) { return(new Game()); } var game = _userData.ListChildren.Cast <Category>().SelectMany(x => x.ListChildren.Cast <Game>()).FirstOrDefault(x => StringExt.IsNullOrWhiteSpace(x.Name) == false && x.Name.Trim().ToUpperInvariant() == name.Trim().ToUpperInvariant()); if (game is null) { return(new Game()); } return(game); }
/// <summary> EventHandler for when the this.GameDirectoryTextbox's this.Text has changed. </summary> private void GameDirectoryTextbox_TextChanged(object sender, EventArgs e) { if (this.GameInstance.IsDOSBoxUsed(Program.UserDataAccessorInstance.GetUserData()) == false || this.DontUseDOSBoxCheckBox.Checked) { return; } //if the textBox is not empty if (StringExt.IsNullOrWhiteSpace(this.GameDirectoryTextbox.Text) == false) { //if the game location textbox is not empty if (StringExt.IsNullOrWhiteSpace(this.GameLocationTextbox.Text) == false) { //and if the specified directory does not equals to the game executable's directory if (Path.GetDirectoryName(this.GameLocationTextbox.Text) != this.GameDirectoryTextbox.Text) { //then this textbox has been entered first by the user //so the controls for the game's executable location will be made empty and disabled //because DOSBox cannot mount a directory as C: and have an executable specified. //(it's one or the other) this.GameLocationTextbox.Text = string.Empty; this.GameLocationTextbox.Enabled = false; this.GameLocationBrowseButton.Enabled = false; this.GameLocationLabel.Enabled = false; } //if this textbox is empty else { //make the controls for the game's executable location available this.GameLocationTextbox.Enabled = true; this.GameLocationBrowseButton.Enabled = true; this.GameLocationLabel.Enabled = true; } } else { this.GameLocationTextbox.Text = string.Empty; this.GameLocationTextbox.Enabled = false; this.GameLocationBrowseButton.Enabled = false; this.GameLocationLabel.Enabled = false; } } else { this.GameLocationTextbox.Enabled = true; this.GameLocationBrowseButton.Enabled = true; this.GameLocationLabel.Enabled = true; } }