public void ExportCHPackage() { string saveDirectory; if (FileExplorer.OpenFolderPanel(out saveDirectory)) { Song song = editor.currentSong; float songLength = editor.currentSongLength; saveDirectory = saveDirectory.Replace('\\', '/'); saveDirectory = Path.Combine(saveDirectory, FileExplorer.StripIllegalChars(song.name)); // Check if files exist at the current directory and ask user before overwriting. if (Directory.Exists(saveDirectory)) { NativeWindow window = ChartEditor.Instance.windowHandleManager.nativeWindow; NativeMessageBox.Result overwrite = NativeMessageBox.Show("Exported files exist. Overwrite?", "Warning", NativeMessageBox.Type.YesNo, window); if (overwrite != NativeMessageBox.Result.Yes) { return; } } StartCoroutine(ExportCHPackage(saveDirectory, song, songLength, exportOptions)); } }
public void ButtonClickAsyncTest() { // Arrenge dynamic main = _app.Type <Application>().Current.MainWindow; AppVar buttonCore = _app.Type <Button>()(); main._grid.Children.Add(buttonCore); dynamic checker = _app.Type <ButtonEventCheck>()(buttonCore, true); WindowControl windowControl = WindowControl.FromZTop(_app); WPFButtonBase ButtonBase = new WPFButtonBase(buttonCore); // Act Async async = new Async(); ButtonBase.EmulateClick(async); // Assert WindowControl messageBoxControl = windowControl.WaitForNextModal(); NativeMessageBox messageBox = new NativeMessageBox(messageBoxControl); Assert.AreEqual("TestMessageWindow", messageBox.Message); Assert.IsTrue((bool)checker.ButtonClickCalled); // Teardown messageBox.EmulateButtonClick("OK"); messageBoxControl.WaitForDestroy(); async.WaitForCompletion(); }
public string ButtonEntry_EmulateClickAndGetMessage() { Async async = new Async(); ButtonEntry.EmulateClick(async); var msgBox = new NativeMessageBox(Window.WaitForNextModal()); var msg = msgBox.Message; msgBox.EmulateButtonClick("OK"); async.WaitForCompletion(); return(msg); }
public void MessageBoxTest() { var async = new Async(); _messageBoxButton.EmulateClick(async); //メッセージボックスを取得 var main = new WindowControl(mainCore); var childWindow = main.WaitForNextModal(); var msg = new NativeMessageBox(childWindow); //メッセージを取得 Assert.AreEqual("msg", msg.Message); //テキストからボタンを検索して押す msg.EmulateButtonClick("OK"); //非同期処理の完了待ち async.WaitForCompletion(); }
IEnumerator AutosaveCheck() { yield return(null); if (System.IO.File.Exists(autosaveLocation)) { #if !UNITY_EDITOR string autosaveText = "An autosave was detected indicating that the program did not correctly shut down during the last session. \nWould you like to reload the autosave?"; string autosaveCaption = "Warning"; NativeMessageBox.Result result = NativeMessageBox.Show(autosaveText, autosaveCaption, NativeMessageBox.Type.YesNo, editor.windowHandleManager.nativeWindow); if (result == NativeMessageBox.Result.Yes) { yield return(StartCoroutine(editor._Load(autosaveLocation, false))); ChartEditor.isDirty = true; } #endif } }
bool EditCheck() { // Check for unsaved changes if (isDirty) { NativeMessageBox.Result result = NativeMessageBox.Show("Do you want to save unsaved changes?", "Warning", NativeMessageBox.Type.YesNoCancel, windowHandleManager.nativeWindow); if (result == NativeMessageBox.Result.Yes) { if (!_Save()) { return(false); } } else if (result == NativeMessageBox.Result.Cancel) { return(false); } } return(true); }
bool EditCheck() { // Check for unsaved changes if (isDirty) { if (quitting) { UnityEngine.Application.CancelQuit(); } #if !UNITY_EDITOR NativeMessageBox.Result result = NativeMessageBox.Show("Want to save unsaved changes?", "Warning", NativeMessageBox.Type.YesNoCancel); if (quitting) { UnityEngine.Application.CancelQuit(); } if (result == NativeMessageBox.Result.Yes) { if (!_Save()) { quitting = false; return(false); } } else if (result == NativeMessageBox.Result.Cancel) { quitting = false; return(false); } #endif if (quitting) { UnityEngine.Application.Quit(); } } return(true); }
public static Song ReadMidi(string path, ref CallbackState callBackState) { Song song = new Song(); string directory = System.IO.Path.GetDirectoryName(path); foreach (Song.AudioInstrument audio in EnumX <Song.AudioInstrument> .Values) { string filename = string.Empty; string[] locationOverrides = null; if (c_audioStreamLocationOverrideDict.TryGetValue(audio, out locationOverrides)) { foreach (string overrideFilename in locationOverrides) { string testFilepath = directory + "\\" + overrideFilename.ToLower() + ".ogg"; if (System.IO.File.Exists(testFilepath)) { filename = overrideFilename; break; } } } else { filename = audio.ToString(); } string audioFilepath = directory + "\\" + filename.ToLower() + ".ogg"; Debug.Log(audioFilepath); song.SetAudioLocation(audio, audioFilepath); } MidiFile midi; try { midi = new MidiFile(path); } catch (SystemException e) { throw new SystemException("Bad or corrupted midi file- " + e.Message); } song.resolution = (short)midi.DeltaTicksPerQuarterNote; // Read all bpm data in first. This will also allow song.TimeToTick to function properly. ReadSync(midi.Events[0], song); for (int i = 1; i < midi.Tracks; ++i) { var trackName = midi.Events[i][0] as TextEvent; if (trackName == null) { continue; } Debug.Log("Found midi track " + trackName.Text); string trackNameKey = trackName.Text.ToUpper(); if (trackNameKey == MidIOHelper.EVENTS_TRACK) { ReadSongGlobalEvents(midi.Events[i], song); } else if (!c_trackExcludesMap.ContainsKey(trackNameKey)) { bool importTrackAsVocalsEvents = trackNameKey == MidIOHelper.VOCALS_TRACK; #if !UNITY_EDITOR if (importTrackAsVocalsEvents) { callBackState = CallbackState.WaitingForExternalInformation; NativeMessageBox.Result result = NativeMessageBox.Show("A vocals track was found in the file. Would you like to import the text events as global lyrics events?", "Vocals Track Found", NativeMessageBox.Type.YesNo, null); callBackState = CallbackState.None; importTrackAsVocalsEvents = result == NativeMessageBox.Result.Yes; } #endif if (importTrackAsVocalsEvents) { Debug.Log("Loading lyrics from Vocals track"); ReadTextEventsIntoGlobalEventsAsLyrics(midi.Events[i], song); } else { Song.Instrument instrument; if (!c_trackNameToInstrumentMap.TryGetValue(trackNameKey, out instrument)) { instrument = Song.Instrument.Unrecognised; } Debug.LogFormat("Loading midi track {0}", instrument); ReadNotes(midi.Events[i], song, instrument); } } } return(song); }
public async Task Save(string msg, string fileName) { await Task.Run(async() => { try { //フォーカスしないようにする //ShowWindow(mainWindowHandle.ToInt32(), SW_HIDE); await Task.Delay(100); //再生完了待機 while (!saveButton.IsEnabled) { Console.WriteLine("saveBtn is not enabled"); await Task.Delay(100); } talkTextBox.EmulateChangeText(msg); var async = new Async(); saveButton.EmulateClick(async); //名前を付けて保存ダイアログ var saveFileWindow = uiTreeTop.WaitForNextModal(); var saveFileDialog = new NativeMessageBox(saveFileWindow); //ファイル名を入力 //右上の検索欄にも入力されてしまうが無視 var edits = saveFileDialog.Window.GetFromWindowClass("Edit"); foreach (var t in edits) { var edit = new NativeEdit(t); edit.EmulateChangeText(fileName); } saveFileDialog.EmulateButtonClick("保存(&S)"); //saveFileWindow.WaitForDestroy(); //出力状況を表示するダイアログの表示を待つ Console.WriteLine("waiting for showing progress window"); var progressWindow = uiTreeTop.WaitForNextModal(); if (progressWindow == null) { progressWindow = uiTreeTop.WaitForNextModal(); } Console.WriteLine("showed " + progressWindow.GetWindowText()); var tokenSource = new CancellationTokenSource(); var task = new TaskFactory().StartNew(() => { //完了通知ダイアログの表示を待つ Console.WriteLine("wationg for showing saving complete window"); var completeWindow = progressWindow.WaitForNextModal(); if (completeWindow != null) { Console.WriteLine("showed " + completeWindow.GetWindowText()); Console.WriteLine(DateTime.Now); try { var completeDialog = new NativeMessageBox(completeWindow); completeDialog.EmulateButtonClick("OK"); Console.WriteLine("wating for destroying"); completeWindow.WaitForDestroy(); Console.WriteLine("finish"); } catch (Exception e) { Console.WriteLine(e); } } }, tokenSource.Token); try { Console.WriteLine(DateTime.Now); if (!task.Wait(5000)) { tokenSource.Cancel(); Console.WriteLine("timeout"); Console.WriteLine(DateTime.Now); var windows = WindowControl.GetTopLevelWindows(uiTreeTop.App); foreach (var window in windows) { Console.WriteLine(window.GetWindowText()); var btnList = window.LogicalTree().ByType <Button>(); var count = btnList.Count; for (int i = 0; i < count; i++) { var btn = new WPFButtonBase(btnList[i]); var btnTxtList = btn.LogicalTree(TreeRunDirection.Descendants).ByType <TextBlock>(); if (btnTxtList.Count == 1) { var btnTxt = new WPFTextBlock(btnTxtList.Single()); Console.WriteLine(btnTxt.Text); if (btnTxt.Text.Equals("キャンセル")) { btn.EmulateClick(); } } } } var completeWindow = progressWindow.WaitForNextModal(); Console.WriteLine("showed2 " + completeWindow.GetWindowText()); Console.WriteLine("2" + DateTime.Now); var completeDialog = new NativeMessageBox(completeWindow); completeDialog.EmulateButtonClick("OK"); Console.WriteLine("wating for destroying2"); completeWindow.WaitForDestroy(); Console.WriteLine("finish2"); } } catch (AggregateException) { //タスクがキャンセルされた Console.WriteLine("task was canceled"); var completeWindow = WindowControl.FromZTop(uiTreeTop.App); Console.WriteLine("showed3 " + completeWindow.GetWindowText()); var completeDialog = new NativeMessageBox(completeWindow); completeDialog.EmulateButtonClick("OK"); Console.WriteLine("wating for destroying3"); completeWindow.WaitForDestroy(); Console.WriteLine("finish3"); } if (!async.IsCompleted) { try { Console.WriteLine("wating for async finish"); async.WaitForCompletion(); } catch (Exception e) { Console.WriteLine(e); } } } finally { //ShowWindow(mainWindowHandle.ToInt32(), SW_MINIMIZE); Console.WriteLine("complete saving"); } }); }
public MessageBoxDriver(WindowControl core) { _core = new NativeMessageBox(core); }