private void tsmiNewScriptFile_Click(object sender, EventArgs e) { try { string newName = ""; var newNameForm = new frmInputBox("Enter the name of the new file without extension", "New File"); newNameForm.txtInput.Text = tvProject.SelectedNode.Name; newNameForm.ShowDialog(); if (newNameForm.DialogResult == DialogResult.OK) { newName = newNameForm.txtInput.Text; } else if (newNameForm.DialogResult == DialogResult.Cancel) { return; } if (newName.EndsWith(".json")) { throw new Exception("Invalid file name"); } string selectedNodePath = tvProject.SelectedNode.Tag.ToString(); string newFilePath = Path.Combine(selectedNodePath, newName + ".json"); UIListView newScriptActions = NewLstScriptActions(); List <ScriptVariable> newScripVariables = new List <ScriptVariable>(); List <ScriptElement> newScriptElements = new List <ScriptElement>(); var helloWorldCommand = new ShowMessageCommand(); helloWorldCommand.v_Message = "Hello World"; newScriptActions.Items.Insert(0, CreateScriptCommandListViewItem(helloWorldCommand)); if (!File.Exists(newFilePath)) { Script.SerializeScript(newScriptActions.Items, newScripVariables, newScriptElements, newFilePath); NewNode(tvProject.SelectedNode, newFilePath, "file"); OpenFile(newFilePath); } else { int count = 1; string newerFilePath = newFilePath; while (File.Exists(newerFilePath)) { string newDirectoryPath = Path.GetDirectoryName(newFilePath); string newFileNameWithoutExtension = Path.GetFileNameWithoutExtension(newFilePath); newerFilePath = Path.Combine(newDirectoryPath, $"{newFileNameWithoutExtension} ({count}).json"); count += 1; } Script.SerializeScript(newScriptActions.Items, newScripVariables, newScriptElements, newerFilePath); NewNode(tvProject.SelectedNode, newerFilePath, "file"); OpenFile(newerFilePath); } } catch (Exception ex) { Notify("An Error Occured: " + ex.Message, Color.Red); } }
public ViewAViewModel(IEventAggregator eventAggregator) { _eventAggregator = eventAggregator; ShowMessageCommand.Subscribe(() => { NotificationRequest.Raise(new Notification { Title = "sample", Content = "new message" }); }); ClosingCommand.Subscribe(OnClosing); NavigateToViewBCommand.Subscribe(NavigateToViewB); Thread.Sleep(500); }
private void CheckPatFreshness(string filePath) { int difference = PatComparedToToday(filePath); if (difference < 0) { ShowMessageCommand.Execute(new NotificationModel("Pat Config is up to date!", NotificationType.Information)); } else if (difference > 0) { ShowMessageCommand.Execute(new NotificationModel("PAT CONFIG EXPIRED!!!!", NotificationType.Error)); } else if (difference == 0) { ShowMessageCommand.Execute(new NotificationModel("Pat Config will expire tomorrow!", NotificationType.Error)); } }
private void tsmiNewScriptFile_Click(object sender, EventArgs e) { try { string selectedNodePath = tvProject.SelectedNode.Tag.ToString(); string newFilePath = Path.Combine(selectedNodePath, "New Script.json"); UIListView newScriptActions = NewLstScriptActions(); List <ScriptVariable> newScripVariables = new List <ScriptVariable>(); List <ScriptElement> newScriptElements = new List <ScriptElement>(); var helloWorldCommand = new ShowMessageCommand(); helloWorldCommand.v_Message = "Hello World"; newScriptActions.Items.Insert(0, CreateScriptCommandListViewItem(helloWorldCommand)); if (!File.Exists(newFilePath)) { Script.SerializeScript(newScriptActions.Items, newScripVariables, newScriptElements, newFilePath, _scriptProject.ProjectName); NewNode(tvProject.SelectedNode, newFilePath, "file"); OpenFile(newFilePath); } else { int count = 1; string newerFilePath = newFilePath; while (File.Exists(newerFilePath)) { string newDirectoryPath = Path.GetDirectoryName(newFilePath); string newFileNameWithoutExtension = Path.GetFileNameWithoutExtension(newFilePath); newerFilePath = Path.Combine(newDirectoryPath, $"{newFileNameWithoutExtension} ({count}).json"); count += 1; } Script.SerializeScript(newScriptActions.Items, newScripVariables, newScriptElements, newerFilePath, _scriptProject.ProjectName); NewNode(tvProject.SelectedNode, newerFilePath, "file"); OpenFile(newerFilePath); } } catch (Exception ex) { Notify("An Error Occured: " + ex.Message); } }
private void LockWorkItems() { OpenFileDialog openFileDialog = new(); openFileDialog.Filter = "JSON files (*.json)|*.json"; openFileDialog.Multiselect = true; openFileDialog.Title = "Select Configs which should lock workitems."; var result = openFileDialog.ShowDialog(); if (result != null && result == true) { //Get the path of specified file string[] filePaths = openFileDialog.FileNames; WitLockingService.Lock(filePaths); ShowMessageCommand.Execute(new NotificationModel("SUCCESS!!!!", NotificationType.Information)); } else { ShowMessageCommand.Execute(new NotificationModel("But why? :(", NotificationType.Error)); } }
public void ShowMessage(string messageText, string caption) { var command = new ShowMessageCommand(messageText, caption); this._onShowMessage.OnNext(command); }
private void CopyLocationToClipBoard() { Clipboard.SetText(Location); ShowMessageCommand.Execute(new NotificationModel("SUCCESS!!!!", NotificationType.Information)); }
public void AddProject() { tvProject.Nodes.Clear(); var projectBuilder = new frmProjectBuilder(); projectBuilder.ShowDialog(); //Close taskt if add project form is closed at startup if (projectBuilder.DialogResult == DialogResult.Cancel && _scriptProject == null) { Application.Exit(); return; } //Create new taskt project else if (projectBuilder.CreateProject == true) { DialogResult result = CheckForUnsavedScripts(); if (result == DialogResult.Cancel) { return; } uiScriptTabControl.TabPages.Clear(); _scriptProjectPath = projectBuilder.NewProjectPath; string mainScriptPath = Path.Combine(_scriptProjectPath, "Main.json"); string mainScriptName = Path.GetFileNameWithoutExtension(mainScriptPath); UIListView mainScriptActions = NewLstScriptActions(mainScriptName); List <ScriptVariable> mainScriptVariables = new List <ScriptVariable>(); List <ScriptElement> mainScriptElements = new List <ScriptElement>(); ShowMessageCommand helloWorldCommand = new ShowMessageCommand(); helloWorldCommand.v_Message = "Hello World"; mainScriptActions.Items.Insert(0, CreateScriptCommandListViewItem(helloWorldCommand)); //Begin saving as main.xml ClearSelectedListViewItems(); try { //Serialize main script var mainScript = Script.SerializeScript(mainScriptActions.Items, mainScriptVariables, mainScriptElements, mainScriptPath, projectBuilder.NewProjectName); //Create new project Project proj = new Project(projectBuilder.NewProjectName); _mainFileName = proj.Main; //Save new project proj.SaveProject(mainScriptPath, mainScript, _mainFileName); //Open new project _scriptProject = Project.OpenProject(mainScriptPath); //Open main script OpenFile(mainScriptPath); ScriptFilePath = mainScriptPath; //Show success dialog Notify("Project has been created successfully!"); } catch (Exception ex) { Notify("An Error Occured: " + ex.Message); } } //Open existing taskt project else if (projectBuilder.OpenProject == true) { DialogResult result = CheckForUnsavedScripts(); if (result == DialogResult.Cancel) { return; } try { //Open project _scriptProject = Project.OpenProject(projectBuilder.ExistingMainPath); _mainFileName = _scriptProject.Main; if (Path.GetFileName(projectBuilder.ExistingMainPath) != _mainFileName) { throw new Exception("Attempted to open project from a script that isn't Main"); } _scriptProjectPath = Path.GetDirectoryName(projectBuilder.ExistingMainPath); uiScriptTabControl.TabPages.Clear(); //Open Main OpenFile(projectBuilder.ExistingMainPath); //show success dialog Notify("Project has been opened successfully!"); } catch (Exception ex) { //show fail dialog Notify("An Error Occured: " + ex.Message); //Try adding project again AddProject(); return; } } DirectoryInfo projectDirectoryInfo = new DirectoryInfo(_scriptProjectPath); TreeNode projectNode = new TreeNode(projectDirectoryInfo.Name); projectNode.Text = projectDirectoryInfo.Name; projectNode.Tag = projectDirectoryInfo.FullName; projectNode.Nodes.Add("Empty"); projectNode.ContextMenuStrip = cmsProjectMainFolderActions; tvProject.Nodes.Add(projectNode); projectNode.Expand(); }
//float _timeInStage = 0; void Update() { // If we're not currently playing out a command.. if (!Command.playingQueue) { // If there's no commands in the queue, figure out what to do next?? if (Command.CommandQueue.Count == 0) { if (CurrentState == GameState.GameBeginPhase) { var gameBeginMsgCmd = new ShowMessageCommand("Game Begin", GlobalSettings.MessageStartTime); gameBeginMsgCmd.AddToQueue(); var changeStateCmd = new ChangeStateCommand(GameState.DrawPhase); changeStateCmd.AddToQueue(); } else if (CurrentState == GameState.DrawPhase) { TimeInStage += Time.deltaTime; if (TimeInStage > 5) { // Show a Tip to tap the deck } } else if (CurrentState == GameState.DrawTransitionPhase) { //(new MoveGameObjectCommand(drawnCard, player.inPlay.transform.position, 0.5f)).AddToQueue(); //(new MoveGameObjectCommand(oppDrawnCard, opponent.inPlay.transform.position, 0.5f)).AddToQueue(); (new MoveGameObjectCommand(new GameObject[] { player.CardOnTable, opponent.CardOnTable }, new Vector3[] { player.inPlay.transform.position, opponent.inPlay.transform.position }, GlobalSettings.CardMoveTime)).AddToQueue(); (new ChangeStateCommand(GameState.PlayPhase)).AddToQueue(); } else if (CurrentState == GameState.PlayPhase) { (new RevealCardsCommand(new GameObject[] { player.CardOnTable, opponent.CardOnTable })).AddToQueue(); (new DelayCommand(GlobalSettings.RevealDelayTime)).AddToQueue(); (new ChangeStateCommand(GameState.ResolvePhase)).AddToQueue(); (new ResolvePlayCommand(ref player, ref opponent)).AddToQueue(); } else if (CurrentState == GameState.WarPhase) { } else if (CurrentState == GameState.ResolvePhase) { } else if (CurrentState == GameState.EndPhase) { if (player.deck.cards.Count == 0) { if (player.discard.cards.Count == 0) { player.HasLost = true; } else { (new MoveDiscardToDeckCommand(ref player)).AddToQueue(); } } if (opponent.deck.cards.Count == 0) { if (opponent.discard.cards.Count == 0) { opponent.HasLost = true; } else { (new MoveDiscardToDeckCommand(ref opponent)).AddToQueue(); } } if (player.HasLost || opponent.HasLost) { (new ChangeStateCommand(GameState.GameOverPhase)).AddToQueue(); } else { (new ChangeStateCommand(GameState.DrawPhase)).AddToQueue(); } } else if (CurrentState == GameState.GameOverPhase) { Command.CommandQueue.Clear(); if (player.HasLost) { (new ShowMessageCommand("You Lose!", GlobalSettings.MessageGameEndTime)).AddToQueue(); } else { (new ShowMessageCommand("You Win!", GlobalSettings.MessageGameEndTime)).AddToQueue(); } (new ChangeStateCommand(GameState.NotPlaying)).AddToQueue(); } else if (CurrentState == GameState.NotPlaying) { if (!GameMenu.activeSelf) { GameMenu.SetActive(true); } } } //if (Command.CommandQueue.Count > 0 && !Command.playingQueue) if (Command.CommandQueue.Count > 0) { Command cmd = Command.CommandQueue.Dequeue(); cmd.StartCommandExecution(); } } }
public void AddProject() { tvProject.Nodes.Clear(); var projectBuilder = new frmProjectBuilder(); projectBuilder.ShowDialog(); //Close OpenBots if add project form is closed at startup if (projectBuilder.DialogResult == DialogResult.Cancel && ScriptProject == null) { Application.Exit(); return; } //Create new OpenBots project else if (projectBuilder.CreateProject == true) { DialogResult result = CheckForUnsavedScripts(); if (result == DialogResult.Cancel) { return; } uiScriptTabControl.TabPages.Clear(); ScriptProjectPath = projectBuilder.NewProjectPath; string configPath = Path.Combine(ScriptProjectPath, "project.config"); string mainScriptPath = Path.Combine(ScriptProjectPath, "Main.json"); string mainScriptName = Path.GetFileNameWithoutExtension(mainScriptPath); UIListView mainScriptActions = NewLstScriptActions(mainScriptName); List <ScriptVariable> mainScriptVariables = new List <ScriptVariable>(); List <ScriptElement> mainScriptElements = new List <ScriptElement>(); ShowMessageCommand helloWorldCommand = new ShowMessageCommand(); helloWorldCommand.v_Message = "Hello World"; mainScriptActions.Items.Insert(0, CreateScriptCommandListViewItem(helloWorldCommand)); //Begin saving as main.xml ClearSelectedListViewItems(); try { //Serialize main script var mainScript = Script.SerializeScript(mainScriptActions.Items, mainScriptVariables, mainScriptElements, mainScriptPath); //Create new project ScriptProject = new Project(projectBuilder.NewProjectName); _mainFileName = ScriptProject.Main; //create config file File.WriteAllText(configPath, JsonConvert.SerializeObject(ScriptProject)); OpenFile(mainScriptPath); ScriptFilePath = mainScriptPath; //Show success dialog Notify("Project has been created successfully!", Color.White); } catch (Exception ex) { Notify("An Error Occured: " + ex.Message, Color.Red); } } //Open existing OpenBots project else if (projectBuilder.OpenProject == true) { DialogResult result = CheckForUnsavedScripts(); if (result == DialogResult.Cancel) { return; } try { //Open project ScriptProject = Project.OpenProject(projectBuilder.ExistingConfigPath); _mainFileName = ScriptProject.Main; string mainFilePath = Directory.GetFiles(projectBuilder.ExistingProjectPath, _mainFileName, SearchOption.AllDirectories).FirstOrDefault(); if (mainFilePath == null) { throw new Exception("Main script not found"); } ScriptProjectPath = projectBuilder.ExistingProjectPath; uiScriptTabControl.TabPages.Clear(); //Open Main OpenFile(mainFilePath); //show success dialog Notify("Project has been opened successfully!", Color.White); } catch (Exception ex) { //show fail dialog Notify("An Error Occured: " + ex.Message, Color.Red); //Try adding project again AddProject(); return; } } DirectoryInfo projectDirectoryInfo = new DirectoryInfo(ScriptProjectPath); TreeNode projectNode = new TreeNode(projectDirectoryInfo.Name); projectNode.Text = projectDirectoryInfo.Name; projectNode.Tag = projectDirectoryInfo.FullName; projectNode.Nodes.Add("Empty"); projectNode.ContextMenuStrip = cmsProjectMainFolderActions; tvProject.Nodes.Add(projectNode); projectNode.Expand(); }