public AccountWorkflow(WebBrowser wb, Account account) { _WB = wb; _Macro = new Macro(wb); _Completed = false; _Account = account; }
private bool canBeMet(Macro goal, Macro[] foods, Macro current, int offset = 0) { if (offset == foods.Length) return goal.Equals(current); var nextFood = foods[offset]; var newCurrent = new Macro { C = nextFood.C + current.C, F = nextFood.F + current.F, P = nextFood.P + current.P }; return canBeMet(goal, foods, current, offset + 1) || canBeMet(goal, foods, newCurrent, offset + 1); }
public override Expression Call(Expression expr) { if (expr.Elements.Count < 4) throw new MistException("defmacro must have at least 3 arguments (symbol, parameters list, and a body)"); var symbol = expr.Elements.Second(); if (symbol.Token.Type != Tokens.SYMBOL) throw new MistException(string.Format("The first argument to defmacro does not evaluate to a symbol ({0})", symbol.Token)); var parameters = expr.Elements.Third() as ListExpression; if (parameters == null) throw new MistException("The second argument to defmacro must be a list"); var name = symbol.Token.Text; var macro = new Macro( symbol: name, formalParams: parameters, body: expr.Elements.Skip(3), environment: Environment); Environment.CurrentScope.AddBinding(symbol, macro); return macro; }
private void askForConfirmation(Macro item, Action<BaseObject> onAccept) { DialogHelper.ShowConfirmationDialog( "Veuillez confirmer", string.Format("Êtes-vous sûr de vouloir lancer la macro '{0}' ?", item.Name), item, this, onAccept ); }
internal MacroEditor(Macro macro) { InitializeComponent(); //FunctionList.Items.Add("Start"); this.macro = macro; FunctionList.ItemsSource = macro.Actions; Application.Current.Resources["MacroStorage"] = macro; }
/// <summary> /// Initializes a new instance of the <see cref="MacroWindowViewModel"/> class. /// </summary> public MacroWindowViewModel(Macro macro, IUIVisualizerService uiVisualizerService, IMessageService messageService) { Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageService); this.uiVisualizerService = uiVisualizerService; this.messageService = messageService; AddAction = new Command<string>(OnAddActionExecute); EditAction = new Command<ActionModel>(OnEditActionExecute); DeleteAction = new Command(OnDeleteActionExecute); Save = new Command(OnSaveExecute); //Save = new Command(OnSaveExecute); //Cancel = new Command(OnCancelExecute); MoveAction = new Command(OnMoveActionExecute); this.Macro = macro; //this.Actions.SubscribeToWeakCollectionChangedEvent(Actions, new System.Collections.Specialized.NotifyCollectionChangedEventHandler( OnEditActionExecute)); }
// Macro Run click private void Button_Click_36(object sender, RoutedEventArgs e) { this.MacroToGMMode = false; Macro m = (Macro)((Button)sender).DataContext; this.ImgErrs.Source = this._fine; this.ImgErrs.ToolTip = null; List <string> errs = new List <string>(); MacroActionExecuteMacro.NumExecutions = 0; m.Execute(errs); if (errs.Count > 0) { ToolTip tt = new ToolTip { Content = string.Join("\n", errs.ToArray()) }; this.ImgErrs.Source = this._errs; this.ImgErrs.ToolTip = tt; } this.ImgErrs.InvalidateVisual(); }
private void btnInsertMacro_Click(object sender, EventArgs e) { if (DataContext.Instance.SelectedMacroSet.Name == null) { MessageBox.Show("Select a Macro Set first."); return; } Macro newMacro = new Macro(); MacroForm form = new MacroForm(newMacro); var result = form.ShowDialog(); if (result == DialogResult.Cancel) { return; } //dito save new macro DataContext.Instance.SelectedMacroSet.InsertMacro(newMacro); DataContext.Instance.SaveData(); RefreshBindings(); Refresh_Datagrid(); }
public Input(Stack Stack = default, slice <@string> includes = default, bool beginningOfLine = default, slice <bool> ifdefStack = default, map <@string, ref Macro> macros = default, @string text = default, bool peek = default, ScanToken peekToken = default, @string peekText = default) { this.Stack = Stack; this.includes = includes; this.beginningOfLine = beginningOfLine; this.ifdefStack = ifdefStack; this.macros = macros; this.text = text; this.peek = peek; this.peekToken = peekToken; this.peekText = peekText; }
public override object Execute(Macro m, List <string> errors) => (int)Math.Ceiling((float)this.Params[0].Execute(m, errors));
IEnumerator WaitEndGame() { yield return(new WaitForSeconds(4.5f)); Macro.EndGame(); }
private TreeNode AddMacroNode(Macro M, TreeNode Parent) { TreeNode MacroNode = new TreeNode(M.Name, 4, 4); MacroNode.Tag = M; Parent.Nodes.Add(MacroNode); return MacroNode; }
public async Task <IndividualMacroResponse> CreateMacroAsync(Macro macro) { var body = new { macro }; return(await GenericPostAsync <IndividualMacroResponse>("macros.json", body)); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] != null) { createdPackage = cms.businesslogic.packager.CreatedPackage.GetById(int.Parse(Request.QueryString["id"])); pack = createdPackage.Data; /* CONTENT */ cp = new ContentPicker(); content.Controls.Add(cp); bt_submitButton.Attributes.Add("onClick", "window.location = 'submitpackage.aspx?id=" + pack.Id.ToString() + "'; return false;"); if (string.IsNullOrEmpty(pack.PackagePath) == false) { packageUmbFile.Text = " <a href='" + Page.ResolveClientUrl(pack.PackagePath) + "'>Download</a>"; if (cms.businesslogic.packager.repositories.Repository.getAll().Count > 0) { bt_submitButton.Visible = true; } } else { packageUmbFile.Text = "<em>This package is not published</em>"; } if (Page.IsPostBack == false) { ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree <loadPackages>().Tree.Alias) .SyncTree("-1,init," + loadPackages.PACKAGE_TREE_PREFIX + createdPackage.Data.Id, false); packageAuthorName.Text = pack.Author; packageAuthorUrl.Text = pack.AuthorUrl; packageLicenseName.Text = pack.License; packageLicenseUrl.Text = pack.LicenseUrl; packageName.Text = pack.Name; packageReadme.Text = pack.Readme; packageVersion.Text = pack.Version; packageUrl.Text = pack.Url; /*ACTIONS XML*/ tb_actions.Text = pack.Actions; cp.Value = pack.ContentNodeId.ToString(); //startNode.Value = pack.ContentNodeId.ToString(); packageContentSubdirs.Checked = pack.ContentLoadChildNodes; /*TEMPLATES */ Template[] umbTemplates = Template.GetAllAsList().ToArray(); foreach (Template tmp in umbTemplates) { ListItem li = new ListItem(tmp.Text, tmp.Id.ToString()); if (pack.Templates.Contains(tmp.Id.ToString())) { li.Selected = true; } templates.Items.Add(li); } /* DOC TYPES */ DocumentType[] docs = DocumentType.GetAllAsList().ToArray(); foreach (DocumentType dc in docs) { ListItem li = new ListItem(dc.Text, dc.Id.ToString()); if (pack.Documenttypes.Contains(dc.Id.ToString())) { li.Selected = true; } documentTypes.Items.Add(li); } /*Stylesheets */ StyleSheet[] sheets = StyleSheet.GetAll(); foreach (StyleSheet st in sheets) { ListItem li = new ListItem(st.Text, st.Id.ToString()); if (pack.Stylesheets.Contains(st.Id.ToString())) { li.Selected = true; } stylesheets.Items.Add(li); } /* MACROS */ Macro[] umbMacros = Macro.GetAll(); foreach (Macro m in umbMacros) { ListItem li = new ListItem(m.Name, m.Id.ToString()); if (pack.Macros.Contains(m.Id.ToString())) { li.Selected = true; } macros.Items.Add(li); } /*Langauges */ Language[] umbLanguages = Language.getAll; foreach (Language l in umbLanguages) { ListItem li = new ListItem(l.FriendlyName, l.id.ToString()); if (pack.Languages.Contains(l.id.ToString())) { li.Selected = true; } languages.Items.Add(li); } /*Dictionary Items*/ Dictionary.DictionaryItem[] umbDictionary = Dictionary.getTopMostItems; foreach (Dictionary.DictionaryItem d in umbDictionary) { string liName = d.key; if (d.hasChildren) { liName += " <small>(Including all child items)</small>"; } ListItem li = new ListItem(liName, d.id.ToString()); if (pack.DictionaryItems.Contains(d.id.ToString())) { li.Selected = true; } dictionary.Items.Add(li); } /*Data types */ cms.businesslogic.datatype.DataTypeDefinition[] umbDataType = cms.businesslogic.datatype.DataTypeDefinition.GetAll(); foreach (cms.businesslogic.datatype.DataTypeDefinition umbDtd in umbDataType) { ListItem li = new ListItem(umbDtd.Text, umbDtd.Id.ToString()); if (pack.DataTypes.Contains(umbDtd.Id.ToString())) { li.Selected = true; } cbl_datatypes.Items.Add(li); } /* FILES */ packageFilesRepeater.DataSource = pack.Files; packageFilesRepeater.DataBind(); packageControlPath.Text = pack.LoadControl; } else { ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree <loadPackages>().Tree.Alias) .SyncTree("-1,init," + loadPackages.PACKAGE_TREE_PREFIX + createdPackage.Data.Id, true); } } }
private IEnumerator StopGame() { yield return(new WaitForSeconds(2)); Macro.EndGame(); }
public static void Parse(List<string> files, ErrorCollection errors) { /* * #macro <identifier>[(<identifiers>)] * anything...#arg1...anything * * #endmacro * * #<identifier>(anything_but_comma, #anything_but_hash#) * * */ //Phase 1: locate all macros List<Macro> macros = new List<Macro>(); for (int i = 0; i < files.Count; i++) { string source = files[i]; Lexer lexer = new Lexer(new StringReader(source)); List<Token> tokens = new List<Token>(); Token token; while (!((token = lexer.Next()) is EOF)) { if (token is TWhiteSpace || token is TTraditionalComment || token is TDocumentationComment || token is TEndOfLineComment) continue; tokens.Add(token); } List<Util.Pair<TextPoint, TextPoint>> macroSpan = new List<Util.Pair<TextPoint, TextPoint>>(); for (int j = 0; j < tokens.Count - 1; j++) { int t = j; if (tokens[t] is TSharp && tokens[t + 1].Text == "macro") { Macro macro = new Macro(); Token sharp = tokens[t]; macro.token = sharp; TextPoint start = TextPoint.FromCompilerCoords(tokens[t]); t += 2; if (t >= tokens.Count || !(tokens[t] is TIdentifier)) { errors.Add(new ErrorCollection.Error(sharp, LocRM.GetString("ErrorText206"))); continue; } macro.Name = tokens[t].Text; //Find end TextPoint end = new TextPoint(-1, -1); for (int k = t; k < tokens.Count - 1; k++) { if (tokens[k] is TSharp) { if (tokens[k + 1].Text == "macro") { errors.Add(new ErrorCollection.Error(tokens[k], LocRM.GetString("ErrorText207"), false, new ErrorCollection.Error(sharp, LocRM.GetString("ErrorText208")))); } else if (tokens[k + 1].Text == "endmacro") { end = TextPoint.FromCompilerCoords(tokens[k]); break; } } } if (end.Line == -1) { errors.Add(new ErrorCollection.Error(sharp, LocRM.GetString("ErrorText209"))); continue; } //Check for parameters t++; TextPoint textStart; if (tokens[t] is TLParen) { macro.Method = true; bool needComma = false; while (true) { t++; if (tokens[t] is TRParen) break; if (tokens[t] is TComma) { if (!needComma) { errors.Add(new ErrorCollection.Error(tokens[t], LocRM.GetString("ErrorText210"))); break; } needComma = false; t++; } if (tokens[t] is TIdentifier) { if (needComma) { errors.Add(new ErrorCollection.Error(tokens[t], LocRM.GetString("ErrorText211"))); break; } macro.Parameters.Add(tokens[t].Text); needComma = true; continue; } if (needComma) errors.Add(new ErrorCollection.Error(tokens[t], LocRM.GetString("ErrorText211"))); else errors.Add(new ErrorCollection.Error(tokens[t], LocRM.GetString("ErrorText210"))); break; } textStart = TextPoint.FromCompilerCoords(tokens[t]); textStart.Pos++; t++; } else { textStart = TextPoint.FromCompilerCoords(tokens[t - 1]); textStart.Pos += macro.Name.Length; } macro.Text = GetText(source, textStart, end); macroSpan.Add(new Util.Pair<TextPoint, TextPoint>(start, end)); macros.Add(macro); j = t; } } //Remove macros List<string> lines = source.Split('\n').ToList(); for (int j = macroSpan.Count - 1; j >= 0; j--) { TextPoint start = macroSpan[j].First; TextPoint end = macroSpan[j].Second; lines[start.Line] = lines[start.Line].Substring(0, start.Pos - 1) + lines[end.Line].Substring(end.Pos + "#endmacro".Length - 1); for (int line = end.Line; line > start.Line; line--) { lines.RemoveAt(line); } } StringBuilder builder = new StringBuilder(); builder.Append(lines[0]); for (int j = 0; j < lines.Count; j++) { builder.Append("\n" + lines[j]); } source = builder.ToString(); files[i] = source; } //Check for dublicate macros for (int i = 0; i < macros.Count; i++) { List<Macro> conflicts = new List<Macro>(){macros[i]}; for (int j = i + 1; j < macros.Count; j++) { if (macros[i].Name == macros[j].Name && macros[i].Method == macros[j].Method && macros[i].Parameters.Count == macros[j].Parameters.Count) conflicts.Add(macros[j]); } if (conflicts.Count > 1) { List<ErrorCollection.Error> subErrors = new List<ErrorCollection.Error>(); foreach (Macro macro in conflicts) { subErrors.Add(new ErrorCollection.Error(macro.token, LocRM.GetString("ErrorText212"))); macros.Remove(macro); } errors.Add(new ErrorCollection.Error(conflicts[0].token, LocRM.GetString("ErrorText213"), false, subErrors.ToArray())); i--; } } //Search for macro invocations for (int i = 0; i < files.Count; i++) { string source = files[i]; ReplaceInvocations(ref source, macros, new List<Macro>(), errors); files[i] = source; } }
public override bool ExecuteMacro(Macro macro) { return true; }
/// <summary> /// Method to invoke when the MacroAdd command is executed. /// </summary> private void OnMacroAddExecute() { Macro m = new Macro(); Start s = new Start(); m.Name = "New Macro"; m.Actions.Add(s); Macroes.Add(m); }
/// <summary> /// Add a macro with <c>key</c> as its name and <c>obj</c> as its value. /// Throws an <see cref="L20nCore.Exceptions.ImportException"/> in case /// a macro is already added with <c>key</c> as its name. /// </summary> public void AddMacro(string key, Macro obj) { try { m_Macros.Add(key, obj); } catch (ArgumentException) { throw new Exceptions.ImportException( String.Format( "macro with key {0} can't be added, as key isn't unique", key)); } }
private void newButton_Click(object sender, EventArgs e) { Macro macro = new Macro(); string name = null; lock (RuntimeCore.Macros.SyncRoot) { int index = 1; while (RuntimeCore.Macros.ContainsKey("macro" + index.ToString())) index++; name = "macro" + index.ToString(); RuntimeCore.Macros.Add(name, macro); macrosList.Items[name].Selected = true; } }
private void DoNewMacro(TreeNode TN, bool Confirm) { Macro NewMacro = new Macro("New Macro"); (TN.Tag as MacroFolder).Macros.Add(NewMacro); this.tvMacroTree.SelectedNode = this.AddMacroNode(NewMacro, TN); this.tvMacroTree.SelectedNode.BeginEdit(); }
public static Macro MakeNew(string Name) { var macro = new Umbraco.Core.Models.Macro { Name = Name, Alias = Name.Replace(" ", String.Empty) }; ApplicationContext.Current.Services.MacroService.Save(macro); var newMacro = new Macro(macro); //fire new event var e = new NewEventArgs(); newMacro.OnNew(e); return newMacro; }
public override object Execute(Macro m, List <string> errors) => this._b;
protected void confirmUnInstall(object sender, EventArgs e) { bool refreshCache = false; //Uninstall Stylesheets foreach (ListItem li in stylesheets.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { StyleSheet s = new StyleSheet(nId); if (s != null) { s.delete(); pack.Data.Stylesheets.Remove(nId.ToString()); } } } } //Uninstall templates foreach (ListItem li in templates.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { Template s = new Template(nId); if (s != null) { s.RemoveAllReferences(); s.delete(); pack.Data.Templates.Remove(nId.ToString()); } } } } //Uninstall macros foreach (ListItem li in macros.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { Macro s = new Macro(nId); if (s != null && !String.IsNullOrEmpty(s.Name)) { // remove from cache runtimeMacro.GetMacro(s.Id).removeFromCache(); s.Delete(); } pack.Data.Macros.Remove(nId.ToString()); } } } //Remove Document types foreach (ListItem li in documentTypes.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { DocumentType s = new DocumentType(nId); if (s != null) { s.delete(); pack.Data.Documenttypes.Remove(nId.ToString()); // refresh content cache when document types are removed refreshCache = true; } } } } //Remove Dictionary items foreach (ListItem li in dictionaryItems.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { cms.businesslogic.Dictionary.DictionaryItem di = new global::umbraco.cms.businesslogic.Dictionary.DictionaryItem(nId); if (di != null) { di.delete(); pack.Data.DictionaryItems.Remove(nId.ToString()); } } } } //Remove Data types foreach (ListItem li in dataTypes.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { cms.businesslogic.datatype.DataTypeDefinition dtd = new global::umbraco.cms.businesslogic.datatype.DataTypeDefinition(nId); if (dtd != null) { dtd.delete(); pack.Data.DataTypes.Remove(nId.ToString()); } } } } pack.Save(); if (!isManifestEmpty()) { Response.Redirect(Request.RawUrl); } else { BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, "executing undo actions"); // uninstall actions try { System.Xml.XmlDocument actionsXml = new System.Xml.XmlDocument(); actionsXml.LoadXml("<Actions>" + pack.Data.Actions + "</Actions>"); BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, actionsXml.OuterXml); foreach (XmlNode n in actionsXml.DocumentElement.SelectNodes("//Action")) { try { cms.businesslogic.packager.PackageAction.UndoPackageAction(pack.Data.Name, n.Attributes["alias"].Value, n); } catch (Exception ex) { BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString()); } } } catch (Exception ex) { BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString()); } //moved remove of files here so custom package actions can still undo //Remove files foreach (ListItem li in files.Items) { if (li.Selected) { //here we need to try to find the file in question as most packages does not support the tilde char string file = IOHelper.FindFile(li.Value); string filePath = IOHelper.MapPath(file); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); pack.Data.Files.Remove(li.Value); } } } pack.Save(); pack.Delete(); packageUninstalled.Visible = true; installedPackagePanel.Visible = false; } // refresh cache if (refreshCache) { library.RefreshContent(); } //ensure that all tree's are refreshed after uninstall ClientTools.ClearClientTreeCache() .RefreshTree(); TreeDefinitionCollection.Instance.ReRegisterTrees(); BizLogicAction.ReRegisterActionsAndHandlers(); }
private static bool MacroHasProperty(Macro macroObject, string propertyAlias) { return(macroObject.Properties.Any(mp => mp.Alias.ToLower() == propertyAlias)); }
public void Record() { Mode = Modes.Recording; NewMacro = new Macro(); NewMacro.Recorded = DateTime.Now; }
public MacroRecorder() { commands = (Macro)new Macro().CreateSynchronized(); commands.ListCleared += new EventHandler(commands_ListCleared); }
protected override void OnActionVerbDisplayEnd() { Debug.Log("heleled"); Macro.StartGame(); }
public IndividualMacroResponse CreateMacro(Macro macro) { var body = new { macro }; return(GenericPost <IndividualMacroResponse>("macros.json", body)); }
private void ShowProperties(Macro M) { this.txtCommand1.Enabled = (M != null); this.txtCommand2.Enabled = (M != null); this.txtCommand3.Enabled = (M != null); this.txtCommand4.Enabled = (M != null); this.txtCommand5.Enabled = (M != null); this.txtCommand6.Enabled = (M != null); if (M == null) { this.txtCommand1.Clear(); this.txtCommand2.Clear(); this.txtCommand3.Clear(); this.txtCommand4.Clear(); this.txtCommand5.Clear(); this.txtCommand6.Clear(); } else { this.txtCommand1.Text = M.Commands[0]; this.txtCommand2.Text = M.Commands[1]; this.txtCommand3.Text = M.Commands[2]; this.txtCommand4.Text = M.Commands[3]; this.txtCommand5.Text = M.Commands[4]; this.txtCommand6.Text = M.Commands[5]; } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] != null) { pack = cms.businesslogic.packager.InstalledPackage.GetById(int.Parse(Request.QueryString["id"])); lt_packagename.Text = pack.Data.Name; lt_packageVersion.Text = pack.Data.Version; lt_packageAuthor.Text = pack.Data.Author; lt_readme.Text = library.ReplaceLineBreaks(pack.Data.Readme); bt_confirmUninstall.Attributes.Add("onClick", "jQuery('#buttons').hide(); jQuery('#loadingbar').show();; return true;"); if (!Page.IsPostBack) { //temp list to contain failing items... List <string> tempList = new List <string>(); foreach (string str in pack.Data.Documenttypes) { int tId = 0; if (int.TryParse(str, out tId)) { try { DocumentType dc = new DocumentType(tId); if (dc != null) { ListItem li = new ListItem(dc.Text, dc.Id.ToString()); li.Selected = true; documentTypes.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } } //removing failing documentTypes items from the uninstall manifest syncLists(pack.Data.Documenttypes, tempList); foreach (string str in pack.Data.Templates) { int tId = 0; if (int.TryParse(str, out tId)) { try { Template t = new Template(tId); if (t != null) { ListItem li = new ListItem(t.Text, t.Id.ToString()); li.Selected = true; templates.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } } //removing failing template items from the uninstall manifest syncLists(pack.Data.Templates, tempList); foreach (string str in pack.Data.Stylesheets) { int tId = 0; if (int.TryParse(str, out tId)) { try { StyleSheet s = new StyleSheet(tId); if (s != null) { ListItem li = new ListItem(s.Text, s.Id.ToString()); li.Selected = true; stylesheets.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } } //removing failing stylesheet items from the uninstall manifest syncLists(pack.Data.Stylesheets, tempList); foreach (string str in pack.Data.Macros) { int tId = 0; if (int.TryParse(str, out tId)) { try { Macro m = new Macro(tId); if (m != null && !string.IsNullOrEmpty(m.Name)) { //Macros need an extra check to see if they actually exists. For some reason the macro does not return null, if the id is not found... ListItem li = new ListItem(m.Name, m.Id.ToString()); li.Selected = true; macros.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } } //removing failing macros items from the uninstall manifest syncLists(pack.Data.Macros, tempList); foreach (string str in pack.Data.Files) { try { if (!String.IsNullOrEmpty(str) && System.IO.File.Exists(IOHelper.MapPath(str))) { ListItem li = new ListItem(str, str); li.Selected = true; files.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } //removing failing files from the uninstall manifest syncLists(pack.Data.Files, tempList); foreach (string str in pack.Data.DictionaryItems) { int tId = 0; if (int.TryParse(str, out tId)) { try { cms.businesslogic.Dictionary.DictionaryItem di = new global::umbraco.cms.businesslogic.Dictionary.DictionaryItem(tId); if (di != null) { ListItem li = new ListItem(di.key, di.id.ToString()); li.Selected = true; dictionaryItems.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } } //removing failing files from the uninstall manifest syncLists(pack.Data.DictionaryItems, tempList); foreach (string str in pack.Data.DataTypes) { int tId = 0; if (int.TryParse(str, out tId)) { try { cms.businesslogic.datatype.DataTypeDefinition dtd = new global::umbraco.cms.businesslogic.datatype.DataTypeDefinition(tId); if (dtd != null) { ListItem li = new ListItem(dtd.Text, dtd.Id.ToString()); li.Selected = true; dataTypes.Items.Add(li); } else { tempList.Add(str); } } catch { tempList.Add(str); } } } //removing failing files from the uninstall manifest syncLists(pack.Data.DataTypes, tempList); //save the install manifest, so even tho the user doesn't uninstall, it stays uptodate. pack.Save(); //Look for updates on packages. if (!String.IsNullOrEmpty(pack.Data.RepositoryGuid) && !String.IsNullOrEmpty(pack.Data.PackageGuid)) { try { repo = cms.businesslogic.packager.repositories.Repository.getByGuid(pack.Data.RepositoryGuid); if (repo != null) { hl_packageRepo.Text = repo.Name; hl_packageRepo.NavigateUrl = "BrowseRepository.aspx?repoGuid=" + repo.Guid; pp_repository.Visible = true; } cms.businesslogic.packager.repositories.Package repoPackage = repo.Webservice.PackageByGuid(pack.Data.PackageGuid); if (repoPackage != null) { if (repoPackage.HasUpgrade && repoPackage.UpgradeVersion != pack.Data.Version) { bt_update.Visible = true; bt_update.Text = "Update available: version: " + repoPackage.UpgradeVersion; lt_upgradeReadme.Text = repoPackage.UpgradeReadMe; bt_gotoUpgrade.OnClientClick = "window.location.href = 'browseRepository.aspx?url=" + repoPackage.Url + "'; return true;"; lt_noUpdate.Visible = false; } else { bt_update.Visible = false; lt_noUpdate.Visible = true; } if (!string.IsNullOrEmpty(repoPackage.Demo)) { lb_demoLink.OnClientClick = "openDemo(this, '" + pack.Data.PackageGuid + "'); return false;"; pp_documentation.Visible = true; } if (!string.IsNullOrEmpty(repoPackage.Documentation)) { hl_docLink.NavigateUrl = repoPackage.Documentation; hl_docLink.Target = "_blank"; pp_documentation.Visible = true; } } } catch { bt_update.Visible = false; lt_noUpdate.Visible = true; } } bool deletePackage = true; //sync the UI to match what is in the package if (macros.Items.Count == 0) { pp_macros.Visible = false; } else { deletePackage = false; } if (documentTypes.Items.Count == 0) { pp_docTypes.Visible = false; } else { deletePackage = false; } if (files.Items.Count == 0) { pp_files.Visible = false; } else { deletePackage = false; } if (templates.Items.Count == 0) { pp_templates.Visible = false; } else { deletePackage = false; } if (stylesheets.Items.Count == 0) { pp_css.Visible = false; } else { deletePackage = false; } if (dictionaryItems.Items.Count == 0) { pp_di.Visible = false; } else { deletePackage = false; } if (dataTypes.Items.Count == 0) { pp_dt.Visible = false; } else { deletePackage = false; } if (deletePackage) { pane_noItems.Visible = true; bt_uninstall.Visible = false; pane_uninstall.Visible = false; } } } }
public override bool ExecuteMacro(Macro macro) { try { Android.Util.Log.Info("HoMIDroid.Server.RealServer", string.Format("Executing macro '{0}'", macro.Name)); this.Server.RunMacro(this.ServerID, macro.Id); return true; } catch (Exception exc) { Android.Util.Log.Error("HoMIDroid.Server.RealServer", exc.ToString()); return false; } }
public override object Execute(Macro m, List <string> errors) => (float)this.Params[0].Execute(m, errors) > (float)this.Params[1].Execute(m, errors);
/// <summary>Create an effect from a file</summary> public Effect CreateEffectFromFile(Device device, string filename, Macro[] defines, Include includeFile, ShaderFlags flags, EffectPool effectPool, out string errors) { // No errors at first! errors = string.Empty; // Search the cache first foreach(CachedEffect ce in effectCache.Keys) { if ( (string.Compare(ce.Source, filename, true) == 0) && ce.Flags == flags) { // A match was found, return that return effectCache[ce] as Effect; } } // Nothing found in the cache Effect e = Effect.FromFile(device, filename, defines, includeFile, null, flags, effectPool, out errors); // Add this to the cache CachedEffect entry = new CachedEffect(); entry.Flags = flags; entry.Source = filename; effectCache.Add(entry, e); // Return the new effect return e; }
public void ShowVerb() { Macro.DisplayActionVerb("Fill it !"); }
/// <summary>Create an effect from a file</summary> public Effect CreateEffectFromFile(Device device, string filename, Macro[] defines, Include includeFile, ShaderFlags flags, EffectPool effectPool) { string temp; return CreateEffectFromFile(device, filename, defines, includeFile, flags, effectPool, out temp); }
protected override void OnGameStart() { Macro.StartTimer(5, false); OnGameStartEvent.Invoke(); Debug.Log("heleled"); }
public bool RunMacro(Macro macro) { foreach (X10CommandSet command in macro.Commands) { if (!this.SendCommand(command)) { return false; } } return true; }
public List <int> GetTransitionToIndicesReflexBehavior(Script script) { List <int> transitionToIndices = new List <int>(); for (int i = 0; i < script.scriptNodes.Count; i++) { ScriptNode node = script.scriptNodes[i]; ScriptNode nextNode = null; ScriptNode nextNextNode = null; if (i < script.scriptNodes.Count - 1) { nextNode = script.scriptNodes[i + 1]; } if (i < script.scriptNodes.Count - 2) { nextNextNode = script.scriptNodes[i + 2]; } if (node.nodeType == ScriptNode.NodeType.Procedure) { if (node.param >= Settings.s.aiTypes.procedureTable.Length) { //Debug.LogError("node.param is out of range of procedure table: "+node.param); continue; } string procedureType = Settings.s.aiTypes.procedureTable[node.param]; if (procedureType == "Proc_ChangeMyComportReflex" || procedureType == "_fn_p_stChangeMyComportReflexProcedure" || procedureType == "ChangeMyComportReflexProcedure") { Behavior transitionBehavior = MapLoader.Loader.FromOffset <Behavior>(nextNode.param_ptr); if (transitionBehavior != null && !transitionToIndices.Contains(transitionBehavior.index)) { transitionToIndices.Add(transitionBehavior.index); } } if (nextNextNode != null && (procedureType == "Proc_ChangeMyComportAndMyReflex" || procedureType == "_fn_p_stChangeMyComportIntelligenceAndReflexProcedure" || procedureType == "ChangeMyComportIntelligenceAndReflexProcedure")) { Behavior transitionBehavior = MapLoader.Loader.FromOffset <Behavior>(nextNextNode.param_ptr); if (transitionBehavior != null && !transitionToIndices.Contains(transitionBehavior.index)) { transitionToIndices.Add(transitionBehavior.index); } } } if (node.nodeType == ScriptNode.NodeType.SubRoutine) { Macro macro = MapLoader.Loader.FromOffset <Macro>(node.param_ptr); if (macro != null) { transitionToIndices.AddRange(GetTransitionToIndicesReflexBehavior(macro.script)); } else { Debug.LogWarning("No macro found after subroutine call"); } } } return(transitionToIndices); }
private static void ParseDefineDirective(Context ctx, string line) { Match symbolMatch = _RegexDefineSymbol.Match(line); Match macroMatch = _RegexMacro.Match(line); if ((symbolMatch.Success == false) && (macroMatch.Success == false)) throw new ArgumentException("no valid 'define' preprocessor directive"); if (macroMatch.Success) { // Define macro List<string> macroArgs = new List<string>(); if (macroMatch.Groups["Arg0"].Success) { macroArgs.Add(macroMatch.Groups["Arg0"].Value); foreach (Capture argsCapture in macroMatch.Groups["ArgN"].Captures) macroArgs.Add(argsCapture.Value); } Macro macro = new Macro(macroMatch.Groups["Symbol"].Value, macroArgs.ToArray(), macroMatch.Groups["Value"].Value); ctx.Macros[macro.Name] = macro; } else if (symbolMatch.Success ) { // Define symbol Symbol symbol = new Symbol(symbolMatch.Groups["Symbol"].Value, symbolMatch.Groups["Value"].Value); ctx.Symbols[symbol.Name] = symbol; } }
public void Macro_Not_Found_Constructor() { Macro target = new Macro(-1111); }
private void unWrapInner(FileData f) { LinkedList<String> tmp = new LinkedList<String>(); LinkedList<String> includes = new LinkedList<String>(); //go through the entire file, resolve #macros, and #includes etc. bool writingMacro = false; Macro currentMacro = null; foreach (String s in f.inst) { if (s.StartsWith("#macro")) { if (writingMacro) { throw new FormatException("Macro definition found inside of macro definition. Are you missing a '}'?: " + s); } else { writingMacro = true; currentMacro = new Macro(s); } continue; } else if (s.Equals("}") && writingMacro) { writingMacro = false; macros.Add(currentMacro.getName(), currentMacro); currentMacro = null; continue; } else if (writingMacro) { if (s.StartsWith("#")) { throw new FormatException("lines starting in '#' may not exist in macro definition: " + s); } currentMacro.addLine(s); continue; } //with macro writing out of the way, we can concentrate on getting all the include statements out of the way if (s.StartsWith("#include")) { String s2 = Util.cutStrBefore(s, " "); includes.AddLast(s2); continue; } //finally, put the remaining strings in the tmp linkedList tmp.AddLast(s); } //let f have the tmp file as the thing with the stuff f.inst = tmp; //go through f.data and remove all "allocate" entries tmp = new LinkedList<string>(); foreach (String s in f.data) { if (s.StartsWith("#allocate")) { String[] strs = s.Split(' '); if (strs.Length > 2) { throw new FormatException("Incorrect ammount of parameters in #allocate statement: " + s); } else { UInt16 a; if (Util.tryParseTo<UInt16>(strs[1], out a)) { for (int i = 0; i < a; ++i) { tmp.AddLast("0"); } } else { throw new FormatException("Not A Number or too large/small in: " + s); } } } else if (s.StartsWith("#stringw")) { String convert = s.Substring(s.IndexOf("\"") + 1); convert = convert.Substring(0, convert.LastIndexOf("\"")); convert = Util.fixEscapeChars(convert); Int32[] stringInts = Util.strToInt32(convert, false); foreach (Int32 i in stringInts) { tmp.AddLast(i.ToString()); } } else if (s.StartsWith("#string")) { String convert = s.Substring(s.IndexOf("\"") + 1); convert = convert.Substring(0, convert.LastIndexOf("\"")); convert = Util.fixEscapeChars(convert); Int32[] stringInts = Util.strToInt32(convert, true);//this is a bit of a hack, but w/e foreach (Int32 i in stringInts) { tmp.AddLast(i.ToString()); } } else { tmp.AddLast(s); } } f.data = tmp; //load all referenced files, and merge them with this one foreach (String s in includes) { if (!filesIncluded.Contains(s)) { filesIncluded.AddLast(s); FileData f2 = loadText(s); f.mergeWith(f2); } } }
public override object Execute(Macro m, List <string> errors) => AppState.Current.State.General.ProfficientAtSurvival;
/** * Adds a macro to the list of macros in the game * * @param macro * the macro to add */ public void addMacro(Macro macro) { macros.Add(macro); }
private void Load(KeyboardState keyboard, string file, params GroupType[] groups) { GroupType currentGroup = GroupType.None; Macro currentMacro = null; HashSet <Layer> currentLayers = new HashSet <Layer>(); string[] lines = File.ReadAllLines(file); for (int i = 0; i < lines.Length; i++) { string line = lines[i].Trim(); if (line.StartsWith("#")) { continue; } if (line.StartsWith("[")) { currentGroup = GroupType.None; currentLayers.Clear(); int endBrace = line.IndexOf(']'); if (endBrace > 1) { string fullGroupName = line.Substring(1, endBrace - 1).Trim(); string[] groupNames = null; string innerName = null; string[] innerNameSplitted = null; int openParenth = fullGroupName.IndexOf('('); int closeParenth = fullGroupName.IndexOf(')'); if (openParenth > 0 && closeParenth > openParenth) { innerName = fullGroupName.Substring(openParenth + 1, closeParenth - (openParenth + 1)); innerNameSplitted = innerName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); innerName = innerNameSplitted.Length > 0 ? innerNameSplitted[0] : null; for (int j = 0; j < innerNameSplitted.Length; j++) { innerNameSplitted[j] = innerNameSplitted[j].Trim(); } if (!string.IsNullOrEmpty(innerName)) { innerName = innerName.Trim(); } groupNames = new string[] { fullGroupName.Substring(0, openParenth).Trim() }; } else { // This is for layers (not macro / lighting) groupNames = fullGroupName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < groupNames.Length; j++) { groupNames[j] = groupNames[j].Trim(); } } foreach (string groupName in groupNames) { switch (groupName.ToLower()) { case "base": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Base, false)); } break; case "layer1": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Layer1, false)); } break; case "layer2": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Layer2, false)); } break; case "layer3": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Layer3, false)); } break; case "fnbase": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Base, true)); } break; case "fnlayer1": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Layer1, true)); } break; case "fnlayer2": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Layer2, true)); } break; case "fnlayer3": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Layer3, true)); } break; case "macro": if (groups.Contains(GroupType.Macro) && !string.IsNullOrEmpty(innerName)) { currentGroup = GroupType.Macro; currentMacro = new Macro(innerName); Macros[innerName] = currentMacro; if (innerNameSplitted.Length > 1) { ushort.TryParse(innerNameSplitted[1], out currentMacro.DefaultDelay); } if (innerNameSplitted.Length > 2) { if (!Enum.TryParse <MacroRepeatType>(innerNameSplitted[2], true, out currentMacro.RepeatType)) { currentMacro.RepeatType = MacroRepeatType.RepeatXTimes; } } if (innerNameSplitted.Length > 3) { byte.TryParse(innerNameSplitted[3], out currentMacro.RepeatCount); } if (innerNameSplitted.Length > 4) { bool.TryParse(innerNameSplitted[4], out currentMacro.UseTrailingDelay); } if (currentMacro.RepeatCount == 0) { // No point in having a macro which doesn't even run... currentMacro.RepeatCount = 1; } } break; case "lighting": if (groups.Contains(GroupType.Lighting) && !string.IsNullOrEmpty(innerName)) { currentGroup = GroupType.Lighting; LightingEffect lightingEffect = null; if (!LightingEffects.TryGetValue(innerName, out lightingEffect)) { lightingEffect = new LightingEffect(innerName); } if (lightingEffect.Load(keyboard)) { LightingEffects[innerName] = lightingEffect; for (int j = 1; j < innerNameSplitted.Length; j++) { KeyboardLayer layer; if (Enum.TryParse(innerNameSplitted[j], out layer)) { lightingEffect.Layers.Add(layer); } } } else { Program.Log("Failed to load lighting effect '" + innerName + "'"); } } break; case "nolighting": if (innerNameSplitted != null) { for (int j = 0; j < innerNameSplitted.Length; j++) { KeyboardLayer layer; if (Enum.TryParse(innerNameSplitted[j], out layer)) { NoLightingLayers.Add(layer); } } } else { NoLighting = true; } break; } } } } else { switch (currentGroup) { case GroupType.Layer: { string[] splitted = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (splitted.Length > 1) { string[] keysSplittedSrc = splitted[0].Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries); string[] keysSplittedDst = splitted[1].Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries); uint srcValue = 0; uint dstValue = 0; foreach (string str in keysSplittedSrc) { if (str.StartsWith("0x")) { uint.TryParse(str, NumberStyles.HexNumber, null, out srcValue); } else { DriverValue value; if (Enum.TryParse(str, out value)) { srcValue = (uint)value; } } } if (srcValue != 0) { foreach (string str in keysSplittedDst) { if (str.StartsWith("0x")) { uint.TryParse(str, NumberStyles.HexNumber, null, out dstValue); } else if (str.ToLower().StartsWith("macro")) { int openParenth = str.IndexOf('('); int closeParenth = str.IndexOf(')'); if (openParenth > 0 && closeParenth > openParenth) { string macroName = str.Substring(openParenth + 1, closeParenth - (openParenth + 1)); Macro macro = GetMacro(macroName); if (macro != null) { Debug.Assert(macro.Id >= 0 && macro.Id <= byte.MaxValue); dstValue = (uint)(0x0A010000 + macro.Id); } else { Program.Log("Failed to find macro '" + macroName + "' bound to key " + (DriverValue)srcValue); } } } else { DriverValue value; if (Enum.TryParse(str, out value)) { switch (KeyValues.GetKeyType((uint)value)) { case DriverValueType.Key: // TODO: Extra validation (this only makes sense for modifiers) dstValue |= (uint)value; break; default: dstValue = (uint)value; break; } } } } foreach (Layer currentLayer in currentLayers) { currentLayer.Keys[srcValue] = dstValue; } } } } break; case GroupType.Macro: { string[] splitted = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (splitted.Length > 1) { string[] keysSplitted = splitted[1].Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries); ushort delay = currentMacro.DefaultDelay; if (splitted.Length > 2) { if (!ushort.TryParse(splitted[2], out delay)) { delay = currentMacro.DefaultDelay; } } MacroKeyState[] states = null; switch (splitted[0].ToLower()) { case "press": states = new MacroKeyState[] { MacroKeyState.Down, MacroKeyState.Up }; break; case "down": states = new MacroKeyState[] { MacroKeyState.Down }; break; case "up": states = new MacroKeyState[] { MacroKeyState.Up }; break; } for (int j = 0; j < states.Length; j++) { MacroKeyState state = states[j]; for (int k = 0; k < keysSplitted.Length; k++) { string str = keysSplitted[k]; Macro.Action action = new Macro.Action(); action.State = state; if (j == states.Length - 1 && k == keysSplitted.Length - 1) { // Only set the delay on the last listed key for each macro line entry action.Delay = delay; } else { action.Delay = 0; } DriverValue value; if (Enum.TryParse(str, out value)) { switch (value) { case DriverValue.LCtrl: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.LCtrl; //action.KeyCode = (byte)DriverValueModifer.LCtrl; break; case DriverValue.LShift: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.LShift; //action.KeyCode = (byte)DriverValueModifer.LShift; break; case DriverValue.LAlt: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.LAlt; //action.KeyCode = (byte)DriverValueModifer.LAlt; break; case DriverValue.LWin: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.LWin; //action.KeyCode = (byte)DriverValueModifer.LWin; break; case DriverValue.RCtrl: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.RCtrl; //action.KeyCode = (byte)DriverValueModifer.RCtrl; break; case DriverValue.RShift: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.RShift; //action.KeyCode = (byte)DriverValueModifer.RShift; break; case DriverValue.RAlt: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.RAlt; //action.KeyCode = (byte)DriverValueModifer.RAlt; break; case DriverValue.RWin: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.RWin; //action.KeyCode = (byte)DriverValueModifer.RWin; break; case DriverValue.MouseLClick: action.Type = MacroKeyType.Mouse; action.KeyCode = (byte)DriverValueMouseButton.LButton; break; case DriverValue.MouseRClick: action.Type = MacroKeyType.Mouse; action.KeyCode = (byte)DriverValueMouseButton.RButton; break; case DriverValue.MouseMClick: action.Type = MacroKeyType.Mouse; action.KeyCode = (byte)DriverValueMouseButton.MButton; break; case DriverValue.MouseBack: action.Type = MacroKeyType.Mouse; action.KeyCode = (byte)DriverValueMouseButton.Back; break; case DriverValue.MouseAdvance: action.Type = MacroKeyType.Mouse; action.KeyCode = (byte)DriverValueMouseButton.Advance; break; default: action.Type = MacroKeyType.Key; action.KeyCode = (byte)KeyValues.GetShortDriverValue((uint)value); break; } } currentMacro.Actions.Add(action); } } } } break; } } } }
/// <summary> /// Initializes a new instance of the EvaluateExpandMacro class. /// </summary> /// <param name="expr">The expression to evaluate.</param> /// <param name="env">The evaluation environment</param> /// <param name="caller">The caller. Return to this when done.</param> /// <param name="fn">The macro to expand.</param> private EvaluateExpandMacro(SchemeObject expr, Environment env, Evaluator caller, Macro fn) : base(ExpandStep, expr, env, caller) { this.fn = fn; }
static void Main(string[] arg) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); SettingsManager.ImportOldConfig(); SettingsManager.InitUserSettings(); SettingsManager.RegisterManager(); #if (!DEBUG) try { #endif // check for macro file as first parameter string macroFilename = GetMacroParameter(arg); if (macroFilename != "") { bool dontAsk = false; bool edit = false; string directory = ""; // look for the /dontAsk or /edit switch foreach (string s in arg) { string para = s.Trim().ToLower(); if (para == "/dontask") { dontAsk = true; } else if (para == "/edit") { edit = true; } //else if (para.StartsWith("/dir=")) //TODO //{ // DirectoryInfo di = new DirectoryInfo(para.Substring(5)); // if (di.Exists) // directory = di.FullName; // else // directory = ""; //} } //MessageBox.Show(directory); if (edit) { Application.Run(new MainForm(macroFilename)); } else { Macro macro = Macros.OpenMacroFromFile(macroFilename); if (macro == null) { // file does not exist or is invalid MessageBox.Show("Cannot open the given macro file!", "PhotoTagStudio", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Application.Run(new StandAloneMacroExecutionForm(macro, GetStartingDirectory(arg), !dontAsk)); } return; // exit } // start pts the normal way Application.Run(new MainForm(GetStartingDirectory(arg))); #if (!DEBUG) } catch (Exception ex) { ErrorHandler.LogException(ex); } #endif }
/// <summary> /// Call an expand evaluator. /// This comes here with a macro (fn) and a set of macro arguments (args). /// The args are unevaluated. /// The macro is applied to the unevaluated arguments, yielding an expanded program. /// Then the result is evaluated as an expression. /// </summary> /// <param name="fn">The macro to expand.</param> /// <param name="args">The expression to evaluate.</param> /// <param name="env">The environment to make the expression in.</param> /// <param name="caller">The caller. Return to this when done.</param> /// <returns>The expand evaluator.</returns> internal static Evaluator Call(Macro fn, SchemeObject args, Environment env, Evaluator caller) { return new EvaluateExpandMacro(args, env, caller, fn); }
public virtual void DefineMacro(Macro fun, VCExpr vc) { throw new NotImplementedException(); }
/// <summary> /// Initializes a new instance of the <see cref="MacroViewModel"/> class. /// </summary> public MacroViewModel(Macro macro) { this.Macro = macro; }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] != null) { createdPackage = cms.businesslogic.packager.CreatedPackage.GetById(int.Parse(Request.QueryString["id"])); pack = createdPackage.Data; /* CONTENT */ cp = new ContentPicker(); content.Controls.Add(cp); if (string.IsNullOrEmpty(pack.PackagePath) == false) { packageUmbFile.Text = " <a href='" + Page.ResolveClientUrl(pack.PackagePath) + "'>Download</a>"; } else { packageUmbFile.Text = "<em>This package is not published</em>"; } if (Page.IsPostBack == false) { ClientTools .SetActiveTreeType(Constants.Trees.Packages) .SyncTree("-1,created," + createdPackage.Data.Id, false); packageAuthorName.Text = pack.Author; packageAuthorUrl.Text = pack.AuthorUrl; packageLicenseName.Text = pack.License; packageLicenseUrl.Text = pack.LicenseUrl; packageName.Text = pack.Name; packageReadme.Text = pack.Readme; packageVersion.Text = pack.Version; packageUrl.Text = pack.Url; iconUrl.Text = pack.IconUrl; umbracoVersion.Text = pack.UmbracoVersion != null?pack.UmbracoVersion.ToString(3) : string.Empty; /*ACTIONS XML*/ tb_actions.Text = pack.Actions; cp.Value = pack.ContentNodeId.ToString(); //startNode.Value = pack.ContentNodeId.ToString(); packageContentSubdirs.Checked = pack.ContentLoadChildNodes; /*TEMPLATES */ Template[] umbTemplates = Template.GetAllAsList().ToArray(); foreach (Template tmp in umbTemplates) { ListItem li = new ListItem(tmp.Text, tmp.Id.ToString()); if (pack.Templates.Contains(tmp.Id.ToString())) { li.Selected = true; } templates.Items.Add(li); } /* DOC TYPES */ DocumentType[] docs = DocumentType.GetAllAsList().ToArray(); foreach (DocumentType dc in docs) { ListItem li = new ListItem(dc.Text, dc.Id.ToString()); if (pack.Documenttypes.Contains(dc.Id.ToString())) { li.Selected = true; } documentTypes.Items.Add(li); } /*Stylesheets */ var sheets = Services.FileService.GetStylesheets(); foreach (var st in sheets) { if (string.IsNullOrEmpty(st.Name) == false) { var li = new ListItem(st.Alias, st.Name); if (pack.Stylesheets.Contains(st.Name)) { li.Selected = true; } stylesheets.Items.Add(li); } } /* MACROS */ Macro[] umbMacros = Macro.GetAll(); foreach (Macro m in umbMacros) { ListItem li = new ListItem(m.Name, m.Id.ToString()); if (pack.Macros.Contains(m.Id.ToString())) { li.Selected = true; } macros.Items.Add(li); } /*Langauges */ Language[] umbLanguages = Language.getAll; foreach (Language l in umbLanguages) { ListItem li = new ListItem(l.FriendlyName, l.id.ToString()); if (pack.Languages.Contains(l.id.ToString())) { li.Selected = true; } languages.Items.Add(li); } /*Dictionary Items*/ Dictionary.DictionaryItem[] umbDictionary = Dictionary.getTopMostItems; foreach (Dictionary.DictionaryItem d in umbDictionary) { string liName = d.key; if (d.hasChildren) { liName += " <small>(Including all child items)</small>"; } ListItem li = new ListItem(liName, d.id.ToString()); if (pack.DictionaryItems.Contains(d.id.ToString())) { li.Selected = true; } dictionary.Items.Add(li); } /*Data types */ cms.businesslogic.datatype.DataTypeDefinition[] umbDataType = cms.businesslogic.datatype.DataTypeDefinition.GetAll(); // sort array by name Array.Sort(umbDataType, delegate(cms.businesslogic.datatype.DataTypeDefinition umbDataType1, cms.businesslogic.datatype.DataTypeDefinition umbDataType2) { return(umbDataType1.Text.CompareTo(umbDataType2.Text)); }); foreach (cms.businesslogic.datatype.DataTypeDefinition umbDtd in umbDataType) { ListItem li = new ListItem(umbDtd.Text, umbDtd.Id.ToString()); if (pack.DataTypes.Contains(umbDtd.Id.ToString())) { li.Selected = true; } cbl_datatypes.Items.Add(li); } /* FILES */ packageFilesRepeater.DataSource = pack.Files; packageFilesRepeater.DataBind(); packageControlPath.Text = pack.LoadControl; } else { ClientTools .SetActiveTreeType(Constants.Trees.Packages) .SyncTree("-1,created," + createdPackage.Data.Id, true); } } }
public override object Execute(Macro m, List <string> errors) => Math.Abs((float)this.Params[0].Execute(m, errors) - (float)this.Params[1].Execute(m, errors)) <= float.Epsilon;
protected override void Dispose(bool disposing) { lock (syncRoot) { Stop(); commands = null; } base.Dispose(disposing); }
internal static void Rename(IParserInfo item, IDocument document, TabInfo cTab, List <TabInfo> tabs) { string newName; switch ((NameType)item.Type()) { case NameType.LVar: // local procedure variable Variable lvar = (Variable)item; newName = lvar.name; if (!ProcForm.CreateRenameForm(ref newName, "Local Variable") || newName == lvar.name) { return; } if (cTab.parseInfo.CheckExistsName(newName, NameType.LVar, lvar.fdeclared, lvar.d.declared)) { MessageBox.Show("The local variable this name already exists.", "Unable to rename"); return; } RenameVariable(lvar, newName, RegexOptions.IgnoreCase, document); // rename only via references break; case NameType.GVar: // script variable Variable gvar = (Variable)item; newName = gvar.name; if (!ProcForm.CreateRenameForm(ref newName, "Script Variable") || newName == gvar.name) { return; } if (cTab.parseInfo.CheckExistsName(newName, NameType.GVar)) { MessageBox.Show("The variable/procedure or declared macro this name already exists.", "Unable to rename"); return; } RenameVariable(gvar, newName, RegexOptions.IgnoreCase, document); // rename only via references break; case NameType.Proc: RenameProcedure((Procedure)item, document, cTab, tabs); return; case NameType.Macro: Macro macros = (Macro)item; bool isGlobal = ProgramInfo.macrosGlobal.ContainsKey(macros.token); newName = macros.token; if (!ProcForm.CreateRenameForm(ref newName, (isGlobal) ? "Global Macro" : "Local Macro") || newName == macros.token) { return; } if (cTab.parseInfo.CheckExistsName(newName, NameType.Macro)) { MessageBox.Show("The variable/procedure or declared macro this name already exists.", "Unable to rename"); return; } int diff = newName.Length - macros.token.Length; // Для глобальных требуется переименовать все макросы во всех открытых вкладках и во всех файлах проекта/мода if (isGlobal) { RenameGlobalMacros(macros, newName, cTab, tabs, diff); // обновить макросы GetMacros.GetGlobalMacros(Settings.pathHeadersFiles); return; } RenameMacros(macros.token, newName, RegexOptions.None, document); if (diff != 0) { DefineMacroAdjustSpaces(macros, document, diff); } break; } }
public MacroRecorder(Macro commands) { this.commands = commands; commands.ListCleared += new EventHandler(commands_ListCleared); }
private static void RenameGlobalMacros(Macro macros, string newName, TabInfo cTab, List <TabInfo> tabs, int diff) { Regex s_regex = new Regex(@"\b" + macros.token + @"\b", RegexOptions.None); // preview renamed macros open scripts Dictionary <string, List <PreviewMatch> > matchTabs = PreviewRenameGlobalMacros(s_regex, tabs); // file => mathes List <string> files = Directory.GetFiles(Settings.solutionProjectFolder, "*.ssl", SearchOption.AllDirectories).ToList(); files.AddRange(Directory.GetFiles(Settings.solutionProjectFolder, "*.h", SearchOption.AllDirectories).ToList()); // preview renamed macros open scripts Dictionary <string, List <PreviewMatch> > matchFiles = PreviewRenameGlobalMacros(s_regex, tabs, files); // выбор совпадений var previewForm = new PreviewRename(macros.defname, macros.defname.Replace(macros.token, newName)); previewForm.BuildTreeMatches(matchTabs, matchFiles); matchTabs.Clear(); matchFiles.Clear(); if (previewForm.ShowDialog() != DialogResult.OK) { return; } previewForm.GetSelectedMatches(ref matchTabs, ref matchFiles); previewForm.Dispose(); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int isAdjustSpaces = diff; cTab.DisableParseAndStatusChange = true; int replaceLen = macros.token.Length; foreach (var tabMatches in matchTabs) { TabInfo tab = null; int replace_count = 0; foreach (var matches in tabMatches.Value) { tab = matches.tab; Match match = matches.match; int offset = (diff * replace_count) + match.Index; tab.textEditor.Document.Replace(offset, replaceLen, newName); replace_count++; } if (tab != null) { var document = tab.textEditor.Document; if (isAdjustSpaces != 0 && string.Equals(tab.filepath, macros.fdeclared, StringComparison.OrdinalIgnoreCase)) { DefineMacroAdjustSpaces(macros, document, diff); isAdjustSpaces = 0; } document.UndoStack.ClearAll(); tab.SaveInternal(document.TextContent, tab.textEditor.Encoding); // сохранить изменения в файл } } if (matchFiles.Count == 0) { cTab.DisableParseAndStatusChange = false; return; } // замена в файлах проекта ProgressBarForm pf = (matchFiles.Count > 100) ? new ProgressBarForm(Form.ActiveForm, matchFiles.Count, "Идет замена в файлах проекта...") : null; int total = 0; foreach (var fileMatches in matchFiles) { string textContent = System.IO.File.ReadAllText(fileMatches.Key); total += fileMatches.Value.Count; int replace_count = 0; foreach (var matches in fileMatches.Value) { int offset = (diff * replace_count) + matches.match.Index; textContent = textContent.Remove(offset, matches.match.Length); textContent = textContent.Insert(offset, newName); replace_count++; } if (isAdjustSpaces != 0 && string.Equals(fileMatches.Key, macros.fdeclared, StringComparison.OrdinalIgnoreCase)) { DefineMacroAdjustSpaces(macros, newName, ref textContent, diff); isAdjustSpaces = 0; } if (replace_count > 0) { File.WriteAllText(fileMatches.Key, textContent, (Settings.saveScriptUTF8) ? new UTF8Encoding(false) : Encoding.Default); } if (pf != null) { pf.IncProgress(); } } if (pf != null) { pf.Dispose(); } //MessageBox.Show(String.Format("Произведено переименование {0} макросов, в {1} файлах.", total, previewFiles.Count)); cTab.DisableParseAndStatusChange = false; }
public async Task <IndividualMacroResponse> UpdateMacroAsync(Macro macro) { var body = new { macro }; return(await GenericPutAsync <IndividualMacroResponse>(string.Format("macros/{0}.json", macro.Id), body)); }
public override void startElement(string namespaceURI, string sName, string qName, Dictionary<string, string> attrs) { // If no element is being subparsed, check if we must subparse something if (subParsing == NONE) { //Parse eAdventure attributes if (qName.Equals("eAdventure")) { foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("adaptProfile")) { chapter.setAdaptationName(entry.Value.ToString()); } if (entry.Key.Equals("assessProfile")) { chapter.setAssessmentName(entry.Value.ToString()); } } } // Subparse scene else if (qName.Equals("scene")) { subParser = new SceneSubParser(chapter); subParsing = SCENE; } // Subparse slidescene else if (qName.Equals("slidescene") || qName.Equals("videoscene")) { subParser = new CutsceneSubParser(chapter); subParsing = CUTSCENE; } // Subparse book else if (qName.Equals("book")) { subParser = new BookSubParser(chapter); subParsing = BOOK; } // Subparse object else if (qName.Equals("object")) { subParser = new ItemSubParser(chapter); subParsing = OBJECT; } // Subparse player else if (qName.Equals("player")) { subParser = new PlayerSubParser(chapter); subParsing = PLAYER; } // Subparse character else if (qName.Equals("character")) { subParser = new CharacterSubParser(chapter); subParsing = CHARACTER; } // Subparse conversacion (tree conversation) else if (qName.Equals("tree-conversation")) { subParser = new TreeConversationSubParser(chapter); subParsing = CONVERSATION; } // Subparse conversation (graph conversation) else if (qName.Equals("graph-conversation")) { subParser = new GraphConversationSubParser(chapter); subParsing = CONVERSATION; } // Subparse timer else if (qName.Equals("timer")) { subParser = new TimerSubParser(chapter); subParsing = TIMER; } // Subparse global-state else if (qName.Equals("global-state")) { string id = null; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("id")) id = entry.Value.ToString(); } currentGlobalState = new GlobalState(id); currentString = string.Empty; chapter.addGlobalState(currentGlobalState); subParser = new ConditionSubParser(currentGlobalState, chapter); subParsing = GLOBAL_STATE; } // Subparse macro else if (qName.Equals("macro")) { string id = null; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("id")) id = entry.Value.ToString(); } currentMacro = new Macro(id); currentString = string.Empty; chapter.addMacro(currentMacro); subParser = new EffectSubParser(currentMacro, chapter); subParsing = MACRO; } // Subparse atrezzo object else if (qName.Equals("atrezzoobject")) { subParser = new AtrezzoSubParser(chapter); subParsing = ATREZZO; }// Subparse assessment profile else if (qName.Equals("assessment")) { subParser = new AssessmentSubParser(chapter); subParsing = ASSESSMENT; }// Subparse adaptation profile else if (qName.Equals("adaptation")) { subParser = new AdaptationSubParser(chapter); subParsing = ADAPTATION; } } // If an element is being subparsed, spread the call if (subParsing != NONE) { //try { subParser.startElement(namespaceURI, sName, qName, attrs); //} catch (Exception e) { Debug.LogError(e); }{ // System.out.println("Marihuanhell es muy malo pero hemos capturado la excepción"); //e.printStackTrace(); //} } }
public IndividualMacroResponse UpdateMacro(Macro macro) { var body = new { macro }; return(GenericPut <IndividualMacroResponse>(string.Format("macros/{0}.json", macro.Id), body)); }
public abstract bool ExecuteMacro(Macro macro);