private void SaveSetProc(object o) { // Ask for a file name string fileName = ""; WindowsUI.RunWindowDialog(() => { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = StringsFunctions.ResourceString("resConfigFileType"); saveFileDialog.InitialDirectory = Environment.CurrentDirectory; if (saveFileDialog.ShowDialog() == true) { fileName = saveFileDialog.FileName; } } ); if (String.IsNullOrEmpty(fileName)) { return; } // Save string jsonStr = JsonConvert.SerializeObject(Model.BaseModel); File.WriteAllText(fileName, jsonStr); }
/// <summary> /// /// </summary> public static void Init() { // Set Error catching & handling AppDomain.CurrentDomain.UnhandledException += (s, eventArgs) => { // TODO: All data to File by NLog. // Final message to user // In some cases (broken styles) message box cannot be displayed WindowsUI.RunWindowDialog(() => { MessageBox.Show( eventArgs.ExceptionObject.ToString(), "Error Stack Trace", MessageBoxButton.OK, MessageBoxImage.Error ); } ); // Possible //Application.Current.Shutdown(); }; }
private void LoginCommandProc(object o) { // PasswordBox is MVVM violation if (o == null || !(o is PasswordBox)) { return; } // PasswordBox is MVVM violation bool result = UserFunctions.ValidateUsernameAndPassword(Model.Username, ((PasswordBox)o).SecurePassword); // OMG! MVVM Violation! If fact mostly we need it in case of failed validation ((PasswordBox)o).Clear(); if (!result) { WindowsUI.RunWindowDialog(() => { MessageBox.Show( StringsFunctions.ResourceString("resLoginFailed"), StringsFunctions.ResourceString("resError"), MessageBoxButton.OK, MessageBoxImage.Hand ); } ); return; } CloseAsOkEvent(); }
private void DeleteItemCommandProc(Object selectedItems) { ItemType selectedItem = (ItemType)((ObservableCollection <object>)selectedItems).FirstOrDefault(); if (selectedItem == null) { return; } bool result = true; WindowsUI.RunWindowDialog(() => { if (MessageBox.Show( String.Format(StringsFunctions.ResourceString("resDeleteConfirmation"), selectedItem.FirstName, selectedItem.Surname), StringsFunctions.ResourceString("resConfirmationRequired"), MessageBoxButton.YesNo) != MessageBoxResult.Yes) { result = false; } } ); if (!result) { return; } TestItems.Remove((ItemTypeExtended)selectedItem); }
private void LoadSetProc(object o) { // Ask for a file name string fileName = ""; WindowsUI.RunWindowDialog(() => { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = StringsFunctions.ResourceString("resConfigFileType"); openFileDialog.InitialDirectory = Environment.CurrentDirectory; if (openFileDialog.ShowDialog() == true) { fileName = openFileDialog.FileName; } } ); if (String.IsNullOrEmpty(fileName)) { return; } // Load string jsonString = File.ReadAllText(fileName); Model.BaseModel = JsonConvert.DeserializeObject <MainWindowBaseModel>(jsonString); }
public ReversedTicTacToe() { m_UI = new WindowsUI(k_WindowTitle, new PositiveRange(k_MinBoardSize, k_MaxBoardSize)); m_GamePlayers = GamePlayers.CreateFromGameType(m_UI.InitialParams.GameType, m_UI.InitialParams.PlayerNames); m_UI.RegisterOnInput(this.windowsUI_BoardCellChosen); m_UI.InitWindow(m_GamePlayers); startNewGame(); }
private void AboutProc(object o) { WindowsUI.RunWindowDialog(() => { MessageBox.Show( "SQL OVER EXCEL" + Environment.NewLine + "RIGA, LATVIA", StringsFunctions.ResourceString("resInfo"), MessageBoxButton.OK, MessageBoxImage.Information ); } ); }
public void ShowDataValidationWarning() { WindowsUI.RunWindowDialog(() => { MessageBox.Show( StringsFunctions.ResourceString("resItemValidationGeneral"), StringsFunctions.ResourceString("resInformation"), MessageBoxButton.OK, MessageBoxImage.Information ); }); }
private void SelectFileProc(object o) { WindowsUI.RunWindowDialog(() => { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = StringsFunctions.ResourceString("resFileTypes"); openFileDialog.InitialDirectory = Environment.CurrentDirectory; if (openFileDialog.ShowDialog() == true) { Model.BaseModel.ExcelFileName = openFileDialog.FileName; } } ); }
private void RunSqlQueryProc(object o) { try { using (new WaitCursor()) { Task runQuery = new Task(() => { using (ExcelCore excelIn = new ExcelCore(Model.BaseModel.ExcelFileName, AppDataCore.Settings.AceVersion, Model.BaseModel.HDR)) { DataTable queryResult = new DataTable(); // Run query excelIn.RunSql(Model.BaseModel.SqlQuery, ref queryResult); // Populate result Model.QueryResult = queryResult; } }); runQuery.Start(); runQuery.Wait(); } WindowsUI.RunWindowDialog(() => { MessageBox.Show( StringsFunctions.ResourceString("resQueryCompleted"), StringsFunctions.ResourceString("resInfo"), MessageBoxButton.OK, MessageBoxImage.Information ); } ); } catch (Exception ex) { WindowsUI.RunWindowDialog(() => { MessageBox.Show( StringsFunctions.ResourceString("resErrorDuringExecution") + Environment.NewLine + Environment.NewLine + ex.InnerException.Message, StringsFunctions.ResourceString("resError"), MessageBoxButton.OK, MessageBoxImage.Hand ); } ); } }
private void NewItemCommandProc(Object o) { NewItemWindow newItemWindow = WindowsUI.ShowWindowDialogEx <NewItemWindow>(); if (newItemWindow.DialogResult == true) { ItemTypeExtended newItem = ItemTypeExtended.GetItemTypeAsItemClassExtended( ((NewItemVM)(newItemWindow.DataContext)).Model.NewItem ); // Update item TestItems.Add( newItem ); } }
private void RunAnalyticsProc(object o) { try { using (new WaitCursor()) { using (ExcelCore excelIn = new ExcelCore(Model.BaseModel.ExcelFileName, AppDataCore.Settings.AceVersion, Model.BaseModel.HDR)) { List <string> worksheets = excelIn.GetWorksheets(); Model.WorksheetItems.Clear(); foreach (String name in worksheets) { WorksheetItemType worksheetItem = new WorksheetItemType(); worksheetItem.WorksheetName = name; ExcelObject.Worksheet worksheet = excelIn.GetWorksheet(name); worksheetItem.RowCount = excelIn.GetCountOfRows(worksheet); worksheetItem.ColCount = excelIn.GetCountOfCols(worksheet); Model.WorksheetItems.Add(worksheetItem); } } } } catch (Exception ex) { WindowsUI.RunWindowDialog(() => { MessageBox.Show( String.Format(StringsFunctions.ResourceString("resErrorDuringOpening"), Model.BaseModel.ExcelFileName) + Environment.NewLine + Environment.NewLine + ex.Message, StringsFunctions.ResourceString("resError"), MessageBoxButton.OK, MessageBoxImage.Hand ); } ); } }
private void ModifyItemCommandProc(Object selectedItems) { ItemTypeExtended selectedItem = (ItemTypeExtended)((ObservableCollection <object>)selectedItems).FirstOrDefault(); if (selectedItem == null) { return; } // Show window EditItemWindow editItemWindow = WindowsUI.ShowWindowDialogEx <EditItemWindow>(selectedItem); if (editItemWindow.DialogResult == true) { ItemTypeExtended currentItem = ItemTypeExtended.GetItemTypeAsItemClassExtended( ((EditItemVM)(editItemWindow.DataContext)).Model.CurrentItem ); // Update item TestItems.Update(selectedItem, currentItem); } }
/// <summary> /// Save query result to new (prompted) Excel file /// </summary> /// <param name="o"></param> private void SaveQueryResultProc(object o) { // Ask for a file name string fileName = ""; WindowsUI.RunWindowDialog(() => { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = StringsFunctions.ResourceString("resFileTypes"); saveFileDialog.InitialDirectory = Environment.CurrentDirectory; if (saveFileDialog.ShowDialog() == true) { fileName = saveFileDialog.FileName; } } ); if (String.IsNullOrEmpty(fileName)) { return; } // Save using (new WaitCursor()) { new ExcelCore().SaveResultToExcelFile(fileName, Model.QueryResult); } WindowsUI.RunWindowDialog(() => { MessageBox.Show( String.Format(StringsFunctions.ResourceString("resResultSaved"), fileName), StringsFunctions.ResourceString("resInfo"), MessageBoxButton.OK, MessageBoxImage.Information ); } ); }
public static void Main() { WindowsUI windowsUI = new WindowsUI(); windowsUI.StartGame(); }
/// <summary> /// Show About window /// </summary> private void CmdAboutProc(object o) { WindowsUI.ProceedWindow <AboutWindow>(true); }
private void CmdShowAwlProc(object o) { WindowsUI.ProceedWindow <AwlRulesWindow>(true); }