public async Task InsertTask(MacroTask task) { var collection = database.GetCollection <BsonDocument>("tasks"); BsonDocument document = task.ToBsonDocument(); await collection.InsertOneAsync(document); }
private void BindMacroTask(MacroTask macroTask, StudioViewModel viewModel) { switch (macroTask.MacroTaskType) { case EMacroTaskType.Text: ShowOnlyText(); TextBoxTaskText.Text = macroTask.Line; break; case EMacroTaskType.SpecialKey: ShowOnlyComboBox(); ComboBoxItems.ItemsSource = viewModel.SupportedSpecialKeys; SelectComboBoxItem(macroTask.SpecialKey.ToString()); break; case EMacroTaskType.Format: ShowAppropriateFormattingOptions(); break; case EMacroTaskType.Variable: ShowVariableOptions(); VariableEditor.SetInitialValues(viewModel.RegisteredVariables[macroTask.VarName]); break; default: break; } }
internal virtual void Produce() { // check for overlords, if (VBot.Bot.GetAvaibleSupplyPending() < 6 * Controller.GetCompletedCount(Units.ResourceCenters)) { if (VBot.Bot.GameInfo.PlayerInfo[VBot.Bot.PlayerId].RaceActual == SC2APIProtocol.Race.Zerg) { MacroTask.MakeUnit(Units.OVERLORD); } else { throw new System.Exception("impliment supply for t or p"); } } else { foreach (var step in ProduceList) { if (step.CheckQty()) { step.CreateTask(); } } } }
public MacroTaskEditControl(StudioViewModel viewModel) { InitializeComponent(); DisplayedTask = viewModel.MacroTaskInEdit; this.viewModel = viewModel; LabelTaskType.Content = DisplayedTask.MacroTaskType.GetFriendlyString(); BindMacroTask(DisplayedTask, viewModel); }
public void CreateTask() { if (UnitId != 0) { MacroTask.MakeUnit(UnitId); } if (UpgradeId != 0) { MacroTask.ResearchUpgrade(UpgradeId); } }
private async void btnSubmit_Click(object sender, RoutedEventArgs e) { try { string taskName = this.txtName.Text; string taskBaseUrl = "http://" + this.txtBaseUrl.Text; MacroTask taskToCreate = new MacroTask(taskName, taskBaseUrl); MainWindow window = (MainWindow)System.Windows.Application.Current.MainWindow; await window.Context.InsertTask(taskToCreate); ObjectId taskID = (await window.Context.GetTask(ObjectId.Empty, taskName)).ID; await window.ShowTaskDetails(taskID); this.Close(); } catch (Exception ex) { throw new Exception(); } }
public MacroTaskControl(MacroTask macroTask, StudioViewModel viewModel) { InitializeComponent(); this.macroTask = macroTask; this.viewModel = viewModel; this.DataContext = macroTask; this.AllowDrop = true; TaskTextTitle.Text = RtfEnumStringRetriever.GetFriendlyString(macroTask.MacroTaskType); switch (macroTask.MacroTaskType) { case EMacroTaskType.SpecialKey: TaskText.Text = macroTask.SpecialKey.ToString(); HideColorFontAndSize(); CanvasMain.Background = new SolidColorBrush(Colors.LightSeaGreen); break; case EMacroTaskType.Format: TaskText.Text = macroTask.FormatType.ToString(); SetupFormatType(); CanvasMain.Background = new SolidColorBrush(Colors.LightSteelBlue); break; case EMacroTaskType.Variable: TaskText.Text = macroTask.VarName; HideColorFontAndSize(); CanvasMain.Background = new SolidColorBrush(Colors.LightGoldenrodYellow); break; case EMacroTaskType.Undefined: case EMacroTaskType.Text: default: HideColorFontAndSize(); TaskText.Text = StudioViewModel.GetTextFromMacroTask(macroTask); CanvasMain.Background = new SolidColorBrush(Colors.LightPink); break; } }