public static void MessagePull(System.Windows.Controls.TextBox textBox) { textBox.AppendText("Your DMs:" + Environment.NewLine); MessagePuller puller = new MessagePuller(); List <String> messages = puller.PullMessages(); for (int i = 0; i < messages.Count; i++) { textBox.AppendText(Environment.NewLine + (i + 1) + ". " + messages[i]); } }
public static void Timeline(System.Windows.Controls.TextBox textBox) { textBox.Clear(); textBox.AppendText("BACS 387 - Team 2's Timeline:\n\n"); TimelinePuller puller = new TimelinePuller(); List <String> timelineTweets = puller.PullTimeline(); for (int i = 0; i < timelineTweets.Count; i++) { textBox.AppendText(timelineTweets[i] + "\n"); } }
public void NumberClick(TextBox textBox, int character) { if (_calculatorMethods.Operator.Equals('\0')) { _calculatorMethods.InitialParameter = character; textBox.AppendText(character.ToString()); } else { _calculatorMethods.SecondaryParameter = character; textBox.AppendText(character.ToString()); } }
public void Click(TextBox textBox, char character) { if (_calculatorMethods.Operator == ' ') { _calculatorMethods.InitialParameter = _calculatorMethods.InitialParameter * 10 + _calculatorMethods.InitialParameter; textBox.AppendText(character.ToString()); } else { _calculatorMethods.SecondaryParameter = (_calculatorMethods.SecondaryParameter * 10) + _calculatorMethods.InitialParameter; textBox.AppendText(character.ToString()); } }
public void SymbolClick(TextBox textBox, char symbol) { _calculatorMethods.Operator = symbol; if (_calculatorMethods.Operator == ' ') { _calculatorMethods.InitialParameter = _calculatorMethods.InitialParameter * 10 + _calculatorMethods.InitialParameter; textBox.AppendText(symbol.ToString()); } else { _calculatorMethods.SecondaryParameter = (_calculatorMethods.SecondaryParameter * 10) + _calculatorMethods.InitialParameter; textBox.AppendText(symbol.ToString()); } }
public static void write(String text) { Application.Current.Dispatcher.Invoke(() => { _buffer.AppendText(text + Environment.NewLine); }); _lbuffer += (text + Environment.NewLine); }
public override void Write(char value) { base.Write(value); textBox.Dispatcher.BeginInvoke(new Action(() => { textBox.AppendText(value.ToString()); })); }
public void EqualsClick(TextBox textBox, ICalculatorMethods parameters) { var result = parameters.Operation(textBox); textBox.MaxLength = 10; textBox.Text = " "; textBox.AppendText(result.ToString()); parameters.InitialParameter = result; parameters.Operator = '\0'; }
/// <summary> /// Writes the line. /// </summary> /// <param name = "str">The STR.</param> public override void WriteLine(string str) { /********************* .NET 4.0 (i.e. WPF) Specific Reference *********************/ if (outputBox.Dispatcher.CheckAccess()) { outputBox.AppendText(Thread.CurrentThread.Name + "•" + str + "\n"); outputBox.ScrollToEnd(); } else { outputBox.Dispatcher.Invoke( (ThreadStart) delegate { /*********************************************************************************/ outputBox.AppendText(Thread.CurrentThread.Name + "•" + str + "\n"); outputBox.ScrollToEnd(); } ); } }
public static void AppendAndScroll(this System.Windows.Controls.TextBox ctl, string text) { ctl.AppendText(text); ctl.ScrollToEnd(); }
private void bgwValidate_DoWork(object sender, DoWorkEventArgs e) { //Do the validation here DateTime begin = DateTime.Now; try { excelApp = new Application(); List <String> scodes = new List <string>(); int rowCount = 0, columnCount = 0, i, j = 1; Workbook courseWorkbook = excelApp.Workbooks.Open(fileName, 0, true, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); Worksheet courseWorksheet; Range courseWorksheetRange; isValid = true; tempProcessLog = ln + "Reading worksheet..." + ln + "Total sheets : " + courseWorkbook.Sheets.Count; foreach (Worksheet cws in courseWorkbook.Sheets) { if (!Medatabase.isPresentLike("course_master", "course_code", cws.Name)) { tempProcessLog += ln + "sheet with name \"" + cws.Name + "\" course code is not present in database"; isValid = false; invalidRows++; } else { tempProcessLog += ln + "======== reading sheet " + cws.Name + "========" + ln; courseWorksheet = cws; courseWorksheetRange = courseWorksheet.UsedRange; rowCount = courseWorksheetRange.Rows.Count; columnCount = courseWorksheetRange.Columns.Count; tempProcessLog += ln + "Rows " + rowCount + " | Columns " + columnCount + ln; if (rowCount <= 1) { tempProcessLog += ln + "in sheet \"" + cws.Name + "\" There are no records to validate..."; isValid = false; continue; //Move to next sheet } if (columnCount > 5 || columnCount < 5) { tempProcessLog += ln + "in sheet \"" + cws.Name + "\" Expecting columns to be 5, " + columnCount + " is present." + ln + "This excelsheet is not meeting the desired format."; isValid = false; continue; //Move to next sheet } tempProcessLog += ln + "Expecting first row to be column names. " + ln + "reading from 2nd row..."; for (i = 2; i <= rowCount; i++) { try { tempProcessLog += ln + ">> Sheet [" + cws.Name + "] > Processing Row: " + i + ln; /** CANT CHECK FOR DUPLICATE AS ELECTIVE LAB CAN HAVE DUPLICATE SUBJECT CODE :( **/ //Check for duplicate subject_code in database if (Medatabase.isPresent("subject_master", "sub_code", (string)courseWorksheet.Cells[i, 1].Value)) { tempProcessLog += ln + "duplicate subject_code '" + (string)courseWorksheet.Cells[i, 1].Value + "' already present in database in row " + i; isValid = false; invalidRows++; } //if not a lab subject if (String.Compare((string)courseWorksheet.Cells[i, 5].Value, "Lab", true) != 0) { //Check for duplicate subject_code in the same excel sheet if (scodes.IndexOf((string)courseWorksheet.Cells[i, 1].Value) != -1) { tempProcessLog += ln + "duplicate subject_code '" + (string)courseWorksheet.Cells[i, 1].Value + "' already present in the same excel sheet in row " + i; isValid = false; invalidRows++; } scodes.Add((string)courseWorksheet.Cells[i, 1].Value); } if (courseWorksheet.Cells[i, 1].Value == null) { tempProcessLog += ln + "Empty value given for subject_code in row " + i; isValid = false; invalidRows++; } if (courseWorksheet.Cells[i, 2].Value == null) { tempProcessLog += ln + "Empty value given for subject_name in row " + i; isValid = false; invalidRows++; } if ((int)courseWorksheet.Cells[i, 3].Value <= 0 || (int)courseWorksheet.Cells[i, 3].Value > Courses.getSemCount(cws.Name)) { tempProcessLog += ln + "Invalid semester number \"" + (int)courseWorksheet.Cells[i, 3].Value + "\" in row " + i; isValid = false; invalidRows++; } if ((int)courseWorksheet.Cells[i, 4].Value <= 0) { tempProcessLog += ln + "Subject credits cannot be less than or equal to 0 in row " + i; isValid = false; invalidRows++; } if (courseWorksheet.Cells[i, 5].Value == null) { tempProcessLog += ln + "Empty value given for subject type in row " + i; isValid = false; invalidRows++; } } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException be) { invalidRows++; isValid = false; tempProcessLog += ln + "In row [" + i + "] expecting int value, string given!"; LogWriter.WriteError("While validating subject details worksheet", be.Message); } //Update output textbox App.Current.Dispatcher.Invoke(new System.Action(() => { txtOutput.AppendText(tempProcessLog); txtOutput.ScrollToEnd(); })); bgwValidate.ReportProgress(Convert.ToInt16(((i * 100) / rowCount))); tempProcessLog = ""; } } bgwValidate.ReportProgress(Convert.ToInt16(((j * 100) / courseWorkbook.Sheets.Count))); j++; } } catch (System.IO.IOException ioe) { tempProcessLog += ln + "ERROR HANDLING FILE :(" + ln + "Please retry"; LogWriter.WriteError("While validating subject details worksheet", ioe.Message); isValid = false; return; } catch (databaseException) { tempProcessLog += ln + "ERROR OCCURED IN DATABASE OPERATION :(" + ln + "Please retry."; isValid = false; return; } catch (Exception ex) { tempProcessLog += ln + "UNEXPECTED ERROR OCCURED :(" + ln + "Please retry."; LogWriter.WriteError("While validating subject details worksheet", ex.Message); isValid = false; return; } finally { if (invalidRows > 0) { tempProcessLog += ln + ln + "There are total " + invalidRows + " errors."; } //Update output textbox tempProcessLog += ln + "Took " + String.Format("{0:0.00}", (DateTime.Now - begin).TotalSeconds) + " seconds"; App.Current.Dispatcher.Invoke(new System.Action(() => { txtOutput.AppendText(tempProcessLog); txtOutput.ScrollToEnd(); progress.Value = 100; })); excelApp.Workbooks.Close(); } }
} //명령어 구성!!! /// <summary> /// 명령창에 입력된 명령어 인식 및 처리. 명령창에서 스페이스를 누르면이 이 함수가 실행됨. /// 사용자가 입력한 명령 실행. 커멘드 창에서 space, enter를 누르면 실행됨. /// </summary> void GetCommand() { //명령창에서 사용자가 입력한 명령어 반환 string userInput = GetCommandTextFromCommandWindowText(); userInput = userInput.ToUpper(main.CultureInfo); //대문자로 변경 //사용자가 명령어 없이 스페이스만 누른 경우 처리 if (userInput.Length == 0) { if (lastCommand == null) { //WriteText("직전에 실행한 명령이 없습니다."); Enter(); NewLine(); return; } if (main.requestUserInput != null) { if (main.requestUserInput.IsOn) //이미 명령이 실행중인 경우 다시 실행 { if (requestedInputType == InputTypes.Points) { //Points를 요청하는 절점의 끝을 입력한 경우. Enter(); PutPoints_End(); //NewLine(); return; } else { Enter(); main.requestUserInput.DoAction(); return; } } } WriteText(lastCommand.name + " (last command)"); Enter(); ExecuteCommand(lastCommand); // 직전 명령 다시 실행 return; } //사용자가 입력한 command가 있는 경우 실행 Command cmd = FindCommandFromUserInput(userInput); if (cmd != null) { WriteText(" " + cmd.name); Enter(); ExecuteCommand(cmd); return; } //사용자가 입력한 값의 형식에 따라서 구분 InputTypes userInputType = GetTypeOfUserInput(userInput); switch (requestedInputType) { case InputTypes.Int: if (userInputType == requestedInputType) { if (actionAfterIntWithInt != null) { actionAfterIntWithInt(userInputInt); actionAfterIntWithInt = null; EndCommand(); } return; } break; case InputTypes.Ints: switch (userInputType) { case InputTypes.Int: userInputInts = new List <int>(); userInputInts.Add(userInputInt); actionAfterIntsWithInts(userInputInts); EndCommand(); return; case InputTypes.Ints: actionAfterIntsWithInts(userInputInts); NewLine(); EndCommand(); return; default: break; } break; case InputTypes.Double: break; case InputTypes.Point: break; case InputTypes.Vector: case InputTypes.VectorValue: switch (userInputType) { case InputTypes.Point: //상대좌표를 요청했는데 절대좌표가 입력된 경우. if (requestedInputType == InputTypes.VectorValue & !isMouseInput) { //VectorValue는 키보드로 절대좌표를 입력한 경우 입력값을 그대로 벡터로 반환함. userInputVector3D = userInputPoint3D - new Point3D(0, 0, 0); ActionAfterVecWithVec(); } else { PutVector_Point(userInputPoint3D); } return; case InputTypes.Vector: ActionAfterVecWithVec(); return; case InputTypes.Int: case InputTypes.Double: PutVector_MouseDirectionDist(userInputDouble); return; default: break; } //상대좌표를 요청했는데 입력되지 않은 경우. WriteText(" (상대좌표값이 아닙니다. 상대좌표를 입력하세요. ex: @0,1 or @0,1,0)"); Enter(); main.requestUserInput.DoAction(); return; case InputTypes.Dist: break; case InputTypes.Points: switch (userInputType) { case InputTypes.Point: PutPoints_Point(userInputPoint3D); return; case InputTypes.Vector: PutPoints_Direction(userInputVector3D); return; case InputTypes.Int: case InputTypes.Double: PutPoints_MouseDirectionDist(userInputDouble); break; default: break; } break; case InputTypes.None: break; default: break; } //명령어가 없는 경우. WriteText(" Unknown command."); Enter(); if (activeCommand == rootCommand) { textBox.AppendText(initialCmdMark + cmdMark); } else { WriteText(activeCommand.GetSubCmdQuaryString()); textBox.AppendText(cmdMark); } SetCursorLast(); return; }
private void bgwValidate_DoWork(object sender, DoWorkEventArgs e) { //Do the validation here DateTime begin = DateTime.Now; try { const int MAX_SEMS = 8; int sheetCount = 0; int rowCount = 0, columnCount = 0, i; int isem = 0, tsem = 0; string[] courseCodes; isValid = true; excelApp = new Application(); Workbook courseWorkbook = excelApp.Workbooks.Open(fileName, 0, true, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); Worksheet courseWorksheet = (Worksheet)courseWorkbook.Sheets.get_Item(1); Range courseWorksheetRange = courseWorksheet.UsedRange; sheetCount = courseWorkbook.Sheets.Count; tempProcessLog = ln + "Reading worksheet..." + ln + "Total sheets : " + sheetCount; tempProcessLog += ln + "Using Sheet1... "; rowCount = courseWorksheetRange.Rows.Count; columnCount = courseWorksheetRange.Columns.Count; courseCodes = new string[rowCount]; tempProcessLog += ln + "Rows " + rowCount + " | Columns " + columnCount + ln; if (rowCount <= 1) { tempProcessLog += ln + "There are no records to validate..."; App.Current.Dispatcher.Invoke(new System.Action(() => { txtOutput.AppendText(tempProcessLog); txtOutput.ScrollToEnd(); progress.Value = 100; })); isValid = false; return; } if (columnCount > 4 || columnCount < 4) { tempProcessLog += ln + "Expecting columns to be 4, " + columnCount + " is present." + ln + "This excelsheet is not meeting the desired format."; App.Current.Dispatcher.Invoke(new System.Action(() => { txtOutput.AppendText(tempProcessLog); txtOutput.ScrollToEnd(); progress.Value = 100; })); isValid = false; return; } tempProcessLog += ln + "Expecting first row to be column names. " + ln + "reading from 2nd row..."; List <String> tmpCourseCodes = new List <string>(); for (i = 2; i <= rowCount; i++) { try { tempProcessLog += ln + "> Processing Row: " + i + ln; if (courseWorksheet.Cells[i, 1].Value != null) { //Check for duplicate course_code in database if (Medatabase.isPresentLike("course_master", "course_code", (string)courseWorksheet.Cells[i, 1].Value)) { tempProcessLog += ln + "duplicate course_code '" + (string)courseWorksheet.Cells[i, 1].Value + "' already present in database..."; isValid = false; invalidRows++; } //Check for duplicate course_code in the same excel sheet if (tmpCourseCodes.IndexOf((string)courseWorksheet.Cells[i, 1].Value) != -1) { tempProcessLog += ln + "duplicate course_code '" + (string)courseWorksheet.Cells[i, 1].Value + "' already present in the same excel sheet..."; isValid = false; invalidRows++; } else //if not duplicate { tmpCourseCodes.Add((string)courseWorksheet.Cells[i, 1].Value); } } else { tempProcessLog += ln + "empty course_code given...'" + ln; isValid = false; invalidRows++; } if (courseWorksheet.Cells[i, 2].Value != null) { tsem = Convert.ToInt16(courseWorksheet.Cells[i, 2].Value); if (tsem > MAX_SEMS || tsem < 0) { tempProcessLog += ln + (string)courseWorksheet.Cells[i, 1].Value + " > total semesters must be between 0 and " + MAX_SEMS + ", " + tsem + " given"; isValid = false; invalidRows++; } } else { tempProcessLog += ln + "empty value given for total semesters...'" + ln; isValid = false; invalidRows++; } if (courseWorksheet.Cells[i, 3].Value != null) { isem = Convert.ToInt16(courseWorksheet.Cells[i, 3].Value); if (isem < 1) { tempProcessLog += ln + (string)courseWorksheet.Cells[i, 1].Value + " > in semesters must be between 0 and " + MAX_SEMS + ", " + isem + " given"; isValid = false; invalidRows++; } if (isem > tsem) { tempProcessLog += ln + (string)courseWorksheet.Cells[i, 1].Value + " > in semesters can't be > than total sems, " + isem + " given"; isValid = false; invalidRows++; } if (isem > MAX_SEMS) { tempProcessLog += ln + (string)courseWorksheet.Cells[i, 1].Value + " > max in semesters possible is " + MAX_SEMS + ", " + isem + " given"; isValid = false; invalidRows++; } } else { tempProcessLog += ln + "empty value given for in semesters...'" + ln; isValid = false; invalidRows++; } if (courseWorksheet.Cells[i, 4].Value != null) { if ((int)courseWorksheet.Cells[i, 4].Value < 1) { tempProcessLog += ln + "credits must be greater than 0"; isValid = false; invalidRows++; } } else { tempProcessLog += ln + "empty value given for total credits...'" + ln; isValid = false; invalidRows++; } } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException be) { invalidRows++; isValid = false; tempProcessLog += ln + "In row [" + i + "] expecting numeric value, string given!"; LogWriter.WriteError("During course excel sheet validation", be.Message); } //Update output textbox App.Current.Dispatcher.Invoke(new System.Action(() => { txtOutput.AppendText(tempProcessLog); txtOutput.ScrollToEnd(); })); bgwValidate.ReportProgress(Convert.ToInt16(((i * 100) / rowCount))); tempProcessLog = ""; } } catch (System.IO.IOException ioe) { tempProcessLog += ln + "ERROR HANDLING FILE :(" + ln + "Please retry"; LogWriter.WriteError("During course excel sheet validation", ioe.Message); isValid = false; return; } catch (databaseException) { tempProcessLog += ln + "ERROR OCCURED IN DATABASE OPERATION :(" + ln + "Please retry."; isValid = false; return; } catch (Exception ex) { tempProcessLog += ln + "UNEXPECTED ERROR OCCURED :(" + ln + "Please retry."; LogWriter.WriteError("During course excel sheet validation", ex.Message); isValid = false; return; } finally { if (invalidRows > 0) { tempProcessLog += ln + "There are total " + invalidRows + " errors."; tempProcessLog += ln + "Took " + String.Format("{0:0.00}", (DateTime.Now - begin).TotalSeconds) + " seconds"; App.Current.Dispatcher.Invoke(new System.Action(() => { txtOutput.AppendText(tempProcessLog); txtOutput.ScrollToEnd(); progress.Value = 100; })); } excelApp.Workbooks.Close(); } }
public static void WriteToNotificationWindow(string message) { System.Windows.Application.Current.Dispatcher.Invoke(() => m_TbNotification.AppendText(message + "\r\n")); System.Windows.Application.Current.Dispatcher.Invoke(() => m_TbNotification.ScrollToEnd()); }