private void ProgressChanged(Progress_Bar progress) { _ProgressBar.Progress = progress.Progress; _ProgressBar.Status = progress.Status; _ProgressBar.Visible = progress.Visible; Thread.Sleep(25); }
public ExelData(string fName) { Progress_Bar progress = new Progress_Bar { Visible = true, Progress = 0, Status = "Extracr data forom file" }; Microsoft.Office.Interop.Excel.Application excel_app = new Microsoft.Office.Interop.Excel.Application(); string[] partsPath = fName.Split('\\'); foreach (string s in partsPath) { Console.WriteLine(s); } Console.WriteLine("\n" + partsPath.Length.ToString()); string res = ""; for (int i = 0; i < partsPath.Length - 1; i++) { res += partsPath[i] + "\\"; } res += partsPath[partsPath.Length - 1]; string file_name = res; Workbook work_book = excel_app.Workbooks.Open(file_name, Type.Missing); Worksheet work_shet = (Worksheet)work_book.Worksheets[1]; Range excelRange = work_shet.UsedRange; object[,] vallueArray = (object[, ])excelRange.get_Value(XlRangeValueDataType.xlRangeValueDefault); excelWorksheetRow = work_shet.UsedRange.Rows.Count; excelWorksheetCol = 15; // excelWorksheetCol = work_shet.UsedRange.Columns.Count; data = new string[excelWorksheetRow, excelWorksheetCol]; for (int row = 1; row <= excelWorksheetRow; ++row) { progress.Progress = (row * 100 / excelWorksheetRow); for (int col = 1; col <= excelWorksheetCol; ++col) { try { if (vallueArray[row, col] == null) { data[row - 1, col - 1] = "empty"; } else { data[row - 1, col - 1] = vallueArray[row, col].ToString(); } } catch { data[row - 1, col - 1] = "none"; } } } }
public frmUsuariosPermissoes() { InitializeComponent(); // Instacias Inicias prog = new Progress_Bar(); // Chamadas dos Botões btnNovo.Click += new EventHandler(BtnNovo_TextChangedAsync); btnGuardadr.Click += new EventHandler(BtnGuardadr_TextChanged); btnApagar.Click += new EventHandler(BtnApagar_Click); PermissoesIdTextEdit.TextChanged += new EventHandler(TxtCodigo_TextChanged); brnRefresk.Click += delegate { ListGeral(); }; #region Validações Rapidas dos Campos PermissoesIdTextEdit.TextChanged += delegate { if (!PermissoesIdTextEdit.Text.Equals("Selecione o Grupo de Administrador a que pertence!...")) { errorProvider1.Clear(); } else { errorProvider1.SetError(PermissoesIdTextEdit, "Atenção Este campo tem que ter valores"); } }; #endregion ListGeral(); dataLayoutControl1.Changed += DataLayoutControl1_Changed; btnNovos.Click += BtnNovos_Click; }
public ViewModel() { cFExRepository = new CFExRepository(); cFExRepository.progressChanged += ProgressChanged; visitorCollection = new ObservableCollection <Visitor>(); displaySettingCollection = cFExRepository.DisplaySettingCollection; dsColumnSettingCollection = cFExRepository.DsColumnSettingCollection; selectedSetting = displaySettingCollection.Where(s => s.IsSelected == true).FirstOrDefault(); selectedCollumnSetting = dsColumnSettingCollection.Where(s => s.IsSelected == true).FirstOrDefault(); addDataFromFileToDatabase = new RelayCommand(c => { OpenFileDialog openFileDialog = new OpenFileDialog(); _ProgressBar = new Progress_Bar { Visible = true, Progress = 10, Status = "Start" }; if (openFileDialog.ShowDialog() == true) { Task.Factory.StartNew(() => { cFExRepository.initRepositoryFromFile(openFileDialog.FileName); visitorCollection = cFExRepository.VisitorCollection; _ProgressBar.Status = "All data added to database"; _ProgressBar.Progress = 0; Thread.Sleep(3000); _ProgressBar.Visible = false; }); } }); }
public void importSatausToCollectionWithId(List <Status> statusCollection, Action <Progress_Bar> progressChanged_) { for (int row = 0; row < excelWorksheetRow; row++) { Progress_Bar progress = new Progress_Bar { Visible = true, Progress = 0, Status = "import Exel data to database" }; Status status = new Status(); progress.Progress = row * 100 / excelWorksheetRow; progressChanged_(progress); try { status.Id = int.Parse(data[row, 0]); } catch { status.Id = 0; } status.Name = data[row, 1]; status.ActionTime = data[row, 2]; try { status.UserId = int.Parse(data[row, 3]); } catch { status.UserId = 0; } try { status.VisitorId = int.Parse(data[row, 4]); } catch { status.VisitorId = 0; } statusCollection.Add(status); } }
void Update() { //Debug.Log( Width); if (IsActive) { if (!IsUsing) { ActualValue -= (float)Time.deltaTime; } else { if (usingCooldownCounter == 0 && ActualNumberOfSegments > 0) { ActualValue -= Model.maxTimeInSec / Model.numberOfSegments; } usingCooldownCounter += Time.deltaTime; } if (usingCooldownCounter > Model.usingCooldownInSec) { usingCooldownCounter = 0; IsUsing = false; } } if (!IsActivated) { _foregroundSpriteRenderer.material.color = new Color(1f, 1f, 1f, opacityDeactivatedSlot); } Progress_Bar.ChangeLocalPosition(offsetProgressBar); //Debug.Log(Power.ToString() + ": " + usingCooldownCounter + " | ActualNumberOfSegments: " + ActualNumberOfSegments); }
void ExtractDirectory(DiscDirectoryInfo Dinfo, string RootPath, string PathinISO) { if (!string.IsNullOrWhiteSpace(PathinISO)) { PathinISO += "\\" + Dinfo.Name; } RootPath += "\\" + Dinfo.Name; AppendDirectory(RootPath); foreach (DiscDirectoryInfo dinfo in Dinfo.GetDirectories()) { ExtractDirectory(dinfo, RootPath, PathinISO); } var test = Dinfo.GetFiles(); foreach (DiscFileInfo finfo in test) { using (Stream FileStr = finfo.OpenRead()) { using (FileStream Fs = File.Create(RootPath + "\\" + finfo.Name)) { Progress_Bar.Increment(1 / test.Length); Progress_Number.Text = Progress_Bar.Value.ToString() + " %"; Progress_Number.Refresh(); FileStr.CopyTo(Fs, 8 * 1024); } } } }
/* RIGHT_OR_WRONG * BUTTON EVENT HANDLER * * Note: This method is meant to cover the functionality of the two * (2) unique methods attached to the Correct/Fail buttons. It * was observed that the only instructional difference between * the two was incrementing "totalRight" only when the Correct * button was clicked. So I included some basic error-checking, * typecasted the incoming "object" as a Button, and asked if * it were equal to "Correct_Button". * * Anytime you find yourself repeating more than 2-3 lines of * code in more than one place, consider building a separate * method to reduce source code length _and_ improve debugging * practices later. ********************************************************************/ private void RightOrWrong(object sender, EventArgs e) { // Error Case: Incoming null object if (sender == null) { return; } Button alpha = sender as Button; // Error Case: Failed Typecast if (alpha == null) { return; } // Increment totalRight, only if the "Correct_Button" was clicked if (alpha == Correct_Button) { totalRight++; } total++; asked[index] = true; Progress_Bar.PerformStep(); Percentage_Box.Text = String.Format("{0: 0.00%}", ((float)totalRight / total)); int newRed = (int)((((float)total - totalRight) / total) * 215); int newGreen = (int)(((float)totalRight / total) * 200); Percentage_Box.BackColor = Color.FromArgb(255, newRed + 60, newGreen, 0); NextFlashCard(); //newArithmeticExpression(); }
public void setDataToCollection(DbSet <Visitor> visitorCollection, Action <Progress_Bar> progressChanged_) { Progress_Bar progress = new Progress_Bar { Visible = true, Progress = 0, Status = "Add Exel data to database" }; for (int row = 0; row < excelWorksheetRow; row++) { Visitor visitor = new Visitor(); progress.Progress = row * 100 / excelWorksheetRow; progressChanged_(progress); if (data[row, 0] != null) { visitor.Column1 = data[row, 0]; } else { visitor.Column1 = "none"; } if (data[row, 1] != null) { visitor.Column2 = data[row, 1]; } else { visitor.Column2 = "none"; } if (data[row, 2] != null) { visitor.Column3 = data[row, 2]; } else { visitor.Column3 = "none"; } if (data[row, 3] != null) { visitor.Column4 = data[row, 3]; } else { visitor.Column4 = "none"; } if (data[row, 4] != null) { visitor.Column5 = data[row, 4]; } else { visitor.Column5 = "none"; } if (data[row, 5] != null) { visitor.Column6 = data[row, 5]; } else { visitor.Column6 = "none"; } if (data[row, 6] != null) { visitor.Column7 = data[row, 6]; } else { visitor.Column7 = "none"; } if (data[row, 7] != null) { visitor.Column8 = data[row, 7]; } else { visitor.Column8 = "none"; } if (data[row, 8] != null) { visitor.Column9 = data[row, 8]; } else { visitor.Column9 = "none"; } if (data[row, 9] != null) { visitor.Column10 = data[row, 9]; } else { visitor.Column10 = "none"; } if (data[row, 10] != null) { visitor.Column11 = data[row, 10]; } else { visitor.Column11 = "none"; } if (data[row, 11] != null) { visitor.Column12 = data[row, 11]; } else { visitor.Column12 = "none"; } if (data[row, 12] != null) { visitor.Column13 = data[row, 12]; } else { visitor.Column13 = "none"; } if (data[row, 13] != null) { visitor.Column14 = data[row, 13]; } else { visitor.Column14 = "none"; } if (data[row, 14] != null) { visitor.Column15 = data[row, 14]; } else { visitor.Column15 = "none"; } visitorCollection.Add(visitor); } }
public CFExRepository() { progress = new Progress_Bar(); displaySettingCollection = new ObservableCollection <DisplaySetting>(); dsColumnSettingCollection = new ObservableCollection <DSCollumnSetting>(); visitorCollection = new ObservableCollection <Visitor>(); context = new ExContext(); var d = context.DisplaySettings.ToList(); if (d.Count() == 0) { //create default setting DisplaySetting defaultSetting = new DisplaySetting { Name = "default", IsSelected = true }; context.DisplaySettings.Add(defaultSetting); context.SaveChanges(); //find setting in database wich contain parameter Id var defaulSetting = context.DisplaySettings.Where(s => s.Name == "default").FirstOrDefault(); //add setting to repository displaySettingCollection.Add(defaulSetting); //find value Id for DisplaySettingId in DSCollumnSetting var defaulSettingId = defaulSetting.Id; //create collumn for default setting //add collumn in database context.DSCollumnSettings.Add(new DSCollumnSetting { Name = "Id", Alias = "№", Width = 100, Visible = true, IsSelected = true, DisplaySettingId = defaulSettingId }); context.DSCollumnSettings.Add(new DSCollumnSetting { Name = "FirstName", Alias = "Имя", Width = 100, Visible = true, IsSelected = false, DisplaySettingId = defaulSettingId }); context.DSCollumnSettings.Add(new DSCollumnSetting { Name = "LastName", Alias = "Фамилия", Width = 100, Visible = true, IsSelected = false, DisplaySettingId = defaulSettingId }); context.DSCollumnSettings.Add(new DSCollumnSetting { Name = "Сompany", Alias = "Компания", Width = 100, Visible = true, IsSelected = false, DisplaySettingId = defaulSettingId }); context.DSCollumnSettings.Add(new DSCollumnSetting { Name = "Jobtitle", Alias = "Должность", Width = 100, Visible = true, IsSelected = false, DisplaySettingId = defaulSettingId }); context.SaveChanges(); //extract collumns from database which contain parameter Id and add its into the perository var _dsCollumnSettings = context.DSCollumnSettings; foreach (var c in _dsCollumnSettings) { dsColumnSettingCollection.Add(c); } } else { //find settings in database var _displaySettingCollection = context.DisplaySettings; //add setting to repository foreach (var c in _displaySettingCollection) { displaySettingCollection.Add(c); } //extract collumns from database which contain parameter Id and add its into the perository var _dsCollumnSettings = context.DSCollumnSettings; foreach (var c in _dsCollumnSettings) { dsColumnSettingCollection.Add(c); } } }
private void Inicializar(string Titulim) { Text = Titulim; txtNomeCompleto.TextChanged += TxtNomeCompleto_TextChanged; // Instacias Inicias prog = new Progress_Bar(); this.FormClosing += new FormClosingEventHandler(FrmModelos_FormClosing); // Chamadas dos Botões btnNovo.Click += new EventHandler(BtnNovo_TextChangedAsync); btnGuardadr.Click += new EventHandler(BtnGuardadr_TextChanged); btnApagar.Click += new EventHandler(BtnApagar_Click); txtCodigo.TextChanged += new EventHandler(TxtCodigo_TextChanged); this.Load += frmModern__LoadAsync; brnRefresk.Click += delegate { Listar_Tudo(); }; txtCodigo.ButtonClick += delegate { try { Cursor = Cursors.WaitCursor; dataGridView1.Rows.Clear(); foreach (var item in UsuariosInstaciaList) { dataGridView1.Rows.Add(item.UsuariosId, item.UsuarioNomeCompleto); } flyoutPanel1.ShowBeakForm(); txtPesquisa_Flag.Focus(); } catch (System.Exception exception) { MessageBox.Show("Erro " + exception, "Erro de SQL", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor = Cursors.Default; } }; dataGridView1.MouseDoubleClick += delegate { if (dataGridView1.Rows.Count > 0) { txtCodigo.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); flyoutPanel1.HidePopup(); Edit(Convert.ToInt32(txtCodigo.Text), ""); } ; }; txtPesquisa_Flag.TextChanged += TxtPesquisa_Flag_TextChanged; #region Validações Rapidas dos Campos txtGrupos.TextChanged += delegate { if (!txtGrupos.Text.Equals(string.Empty)) { errorProvider1.Clear(); } else { errorProvider1.SetError(txtGrupos, "Atenção Este campo tem que ter valores"); } }; txtNomeCompleto.TextChanged += delegate { if (!txtNomeCompleto.Text.Equals(string.Empty)) { errorProvider1.Clear(); } else { errorProvider1.SetError(txtNomeCompleto, "Atenção Este campo tem que ter valores"); } }; txtApelido.TextChanged += delegate { if (!txtApelido.Text.Equals(string.Empty)) { errorProvider1.Clear(); } else { errorProvider1.SetError(txtApelido, "Atenção Este campo tem que ter valores"); } }; txtLogin.TextChanged += delegate { if (!txtLogin.Text.Equals(string.Empty)) { errorProvider1.Clear(); } else { errorProvider1.SetError(txtLogin, "Atenção Este campo tem que ter valores"); } }; txtSenha.TextChanged += delegate { if (!txtSenha.Text.Equals(string.Empty)) { errorProvider1.Clear(); } else { errorProvider1.SetError(txtSenha, "Atenção Este campo tem que ter valores"); } }; txtRepetir_Senha.TextChanged += delegate { if (!txtRepetir_Senha.Text.Equals(string.Empty)) { errorProvider1.Clear(); } else { errorProvider1.SetError(txtRepetir_Senha, "Atenção Este campo tem que ter valores"); } }; txtPIN.TextChanged += delegate { if (!txtPIN.Text.Equals(string.Empty)) { errorProvider1.Clear(); } else { errorProvider1.SetError(txtPIN, "Atenção Este campo tem que ter valores"); } }; #endregion //txtSenha.Validating += delegate { // OnValidatePassword(new object(), // new ValidatePasswordEventArgs("", txtSenha.Text, true)); //}; txtEmail.Validating += TxtEmail_Validating; // Validações dos Valores da PAssword 1 txtSenha.GotFocus += delegate { if (string.IsNullOrWhiteSpace(UserPassword)) { isNew = true; } else { txtSenha.Text = string.Empty; } }; txtSenha.LostFocus += delegate { if (string.IsNullOrWhiteSpace(UserPassword)) { return; } else if (!string.IsNullOrWhiteSpace(UserPassword) && string.IsNullOrWhiteSpace(txtSenha.Text)) { txtSenha.Text = UserPassword; isNew = false; } else { isNew = true; } }; // Validações dos Valores da PAssword 2 txtRepetir_Senha.GotFocus += delegate { if (string.IsNullOrWhiteSpace(UserPassword)) { isNew = true; } else { txtRepetir_Senha.Text = string.Empty; } }; txtRepetir_Senha.LostFocus += delegate { if (string.IsNullOrWhiteSpace(UserPassword)) { return; } else if (!string.IsNullOrWhiteSpace(UserPassword) && string.IsNullOrWhiteSpace(txtRepetir_Senha.Text)) { txtRepetir_Senha.Text = UserPassword; isNew = false; } else { isNew = true; } }; // Validações dos Valores da PIN txtPIN.GotFocus += delegate { if (string.IsNullOrWhiteSpace(UserPassword)) { isNew = true; } else { txtPIN.Text = string.Empty; } }; txtPIN.LostFocus += delegate { if (string.IsNullOrWhiteSpace(UserPassword)) { return; } else if (!string.IsNullOrWhiteSpace(UserPassword) && string.IsNullOrWhiteSpace(txtPIN.Text)) { txtPIN.Text = UserPassword; isNew = false; } else { isNew = true; } }; txtPIN.TextChanged += delegate { #region Validar //string actualdata = string.Empty; //char[] entereddata = txtPIN.Text.ToCharArray(); //foreach (char aChar in entereddata.AsEnumerable()) //{ // if (Char.IsDigit(aChar)) // { // actualdata = actualdata + aChar; // // MessageBox.Show(aChar.ToString()); // } // else // { // MessageBox.Show(aChar + " is not numeric"); // actualdata.Replace(aChar, ' '); // actualdata.Trim(); // } //} //txtPIN.Text = actualdata; #endregion }; txtPIN.KeyPress += (sender, e) => { #region Validar // Text string text = ((Control)sender).Text; // Is Negative Number? if (e.KeyChar == '-' && text.Length == 0) { e.Handled = false; return; } // Is Float Number? if (e.KeyChar == '.' && text.Length > 0 && !text.Contains(".")) { e.Handled = false; return; } // Is Digit? e.Handled = (!char.IsDigit(e.KeyChar)); #endregion }; txtPIN.Validating += (sender, e) => { var t = Encriptar.GetMD5Hash(txtEmail.Text); var result = UsuariosInstaciaList.Where(x => x.Pin == t && x.GrupoId == (int)txtGrupos.EditValue) .FirstOrDefault(); if (result != null) { if (!string.IsNullOrWhiteSpace(txtCodigo.Text) || !txtCodigo.Text.Equals("0")) { if (result.UsuariosId != int.Parse(txtCodigo.Text)) { XtraMessageBox.Show("Lamentamos mais este PIN Esta Indisponivel!...", "PIN Indisponivel", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Focus(); } } else { XtraMessageBox.Show("Lamentamos mais este PIN Esta Indisponivel!...", "PIN Indisponivel", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Focus(); } } }; txtNomeCompleto.KeyDown += TxtNomeCompleto_KeyDown1; ListGeral(); }
public void importVisitorsToCollectionWithId(List <Visitor> visitorCollection, Action <Progress_Bar> progressChanged_) { for (int row = 0; row < excelWorksheetRow; row++) { Progress_Bar progress = new Progress_Bar { Visible = true, Progress = 0, Status = "import Exel data to database" }; Visitor visitor = new Visitor(); progress.Progress = row * 100 / excelWorksheetRow; progressChanged_(progress); try { visitor.Id = int.Parse(data[row, 0]); } catch { visitor.Id = 0; } if (data[row, 1] != null) { visitor.Column1 = data[row, 1]; } else { visitor.Column1 = "none"; } if (data[row, 2] != null) { visitor.Column2 = data[row, 2]; } else { visitor.Column2 = "none"; } if (data[row, 3] != null) { visitor.Column3 = data[row, 3]; } else { visitor.Column3 = "none"; } if (data[row, 4] != null) { visitor.Column4 = data[row, 4]; } else { visitor.Column4 = "none"; } if (data[row, 5] != null) { visitor.Column5 = data[row, 5]; } else { visitor.Column5 = "none"; } if (data[row, 6] != null) { visitor.Column6 = data[row, 6]; } else { visitor.Column6 = "none"; } if (data[row, 7] != null) { visitor.Column7 = data[row, 7]; } else { visitor.Column7 = "none"; } if (data[row, 8] != null) { visitor.Column8 = data[row, 8]; } else { visitor.Column8 = "none"; } if (data[row, 9] != null) { visitor.Column9 = data[row, 9]; } else { visitor.Column9 = "none"; } if (data[row, 10] != null) { visitor.Column10 = data[row, 10]; } else { visitor.Column10 = "none"; } if (data[row, 11] != null) { visitor.Column11 = data[row, 11]; } else { visitor.Column11 = "none"; } if (data[row, 12] != null) { visitor.Column12 = data[row, 12]; } else { visitor.Column12 = "none"; } if (data[row, 13] != null) { visitor.Column13 = data[row, 13]; } else { visitor.Column13 = "none"; } if (data[row, 14] != null) { visitor.Column14 = data[row, 14]; } else { visitor.Column14 = "none"; } if (data[row, 15] != null) { visitor.Column15 = data[row, 15]; } else { visitor.Column15 = "none"; } if (data[row, 16] != null) { visitor.CurrentStatus = data[row, 16]; } else { visitor.CurrentStatus = "none"; } visitorCollection.Add(visitor); } }
public VisitorRepository() { context = new EContext(); progress = new Progress_Bar(); }
static void Main() { try { #region Interno Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!Get45PlusFromRegistry()) { Application.Exit(); } Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("pt-BR"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("pt-BR"); BonusSkins.Register(); SkinManager.EnableFormSkins(); UserLookAndFeel.Default.SetSkinStyle( ObjectoUserSetings.Default.DefaultAppSkin, ObjectoUserSetings.Default.DefaultPalette); WindowsFormsSettings.TouchUIMode = ObjectoUserSetings.Default.TouchUI == true ? TouchUIMode.True : TouchUIMode.False; WindowsFormsSettings.DefaultFont = ObjectoUserSetings.Default.DefaultAppFont; WindowsFormsSettings.DefaultPrintFont = ObjectoUserSetings.Default.DefaultAppFont; #endregion Mutex mt = new Mutex(true, name: "{26070B7C-21EC-4998-AB16-FE2BA4E25E10}"); try { if (mt.WaitOne(TimeSpan.Zero, true)) { // Leitura do Splash using (var f = new Progress_Bar()) { f.Mostrar_Splash(); { //#region Executar como Adminstrador //// Executar como adminstrador //if (!GetAdminstrador()) //{ // XtraMessageBox.Show("Você precisa executar a aplicação usando a opção 'run as administrator'", "É preciso ser uma administrador", MessageBoxButtons.OK, MessageBoxIcon.Warning); // Application.Exit(); //} //#endregion #region Validar Conexao do Sistema; try { ValidarConexao(); } catch (Exception exException) { f.Dispose(); XtraMessageBox.Show("Lamentamos mais verifique o seu Servidor: O SQLSERVER não esta Indisponivel ou não foi instalado neste computador\n " + exException.Message + "\n\nDetalhes: \n" + exException.Message, "Erro do Servidor SQLServer 2014 ou 2016!...", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion } } Application.Run(frmLogin.GetInstancia()); } else { XtraMessageBox.Show("Desculpe mais a sua Aplicação Já esta em Execução\nTente fecha-la e volte a abrir novamente", "Aplicação já em Execução", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { mt.ReleaseMutex(); } } catch { return; } }
public StatusRepository() { context = new EContext(); progress = new Progress_Bar(); }