Exemple #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var ec           = ModelItemExtensions.GetEditingContext(ModelItem);
            var modelService = ec.Services.GetService <System.Activities.Presentation.Services.ModelService>();
            ModelItemCollection importsModelItem = modelService.Root.Properties["Imports"].Collection;
            var namespaces = new System.Collections.Generic.List <string>();

            foreach (ModelItem import in importsModelItem)
            {
                namespaces.Add(import.Properties["Namespace"].ComputedValue as string);
            }

            string script = ModelItem.GetValue <string>("Script");
            var    f      = new Editor(script, "AutoHotkey", null, namespaces.ToArray());

            f.highlightingComboBox.Visibility = Visibility.Hidden;
            f.ShowDialog();
            if (f.textEditor.Text != script)
            {
                ModelItem.Properties["Script"].SetValue(new InArgument <string>()
                {
                    Expression = new Literal <string>(f.textEditor.Text)
                });
            }
        }
Exemple #2
0
        private void ActivityDesigner_Loaded(object sender, RoutedEventArgs e)
        {
            var ec           = ModelItemExtensions.GetEditingContext(ModelItem);
            var modelService = ec.Services.GetService <System.Activities.Presentation.Services.ModelService>();
            ModelItemCollection importsModelItem = modelService.Root.Properties["Imports"].Collection;
            var namespaces = new List <string>();

            foreach (ModelItem import in importsModelItem)
            {
                namespaces.Add(import.Properties["Namespace"].ComputedValue as string);
            }
            if (!namespaces.Contains("System.Collections"))
            {
                namespaces.Add("System.Collections");
            }
            if (!namespaces.Contains("System.Collections.Generic"))
            {
                namespaces.Add("System.Collections.Generic");
            }

            string[] current = ModelItem.GetValue <string[]>("namespaces");
            if (current == null || namespaces.Count() != current.Count())
            {
                ModelItem.Properties["namespaces"].SetValue(namespaces.ToArray());
            }
        }
Exemple #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var ec           = ModelItemExtensions.GetEditingContext(ModelItem);
                var modelService = ec.Services.GetService <System.Activities.Presentation.Services.ModelService>();
                ModelItemCollection importsModelItem = modelService.Root.Properties["Imports"].Collection;
                var namespaces = new List <string>();
                foreach (ModelItem import in importsModelItem)
                {
                    namespaces.Add(import.Properties["Namespace"].ComputedValue as string);
                }
                if (!namespaces.Contains("System.Collections"))
                {
                    namespaces.Add("System.Collections");
                }
                if (!namespaces.Contains("System.Collections.Generic"))
                {
                    namespaces.Add("System.Collections.Generic");
                }

                var    vars     = FindVariablesInScope(ModelItem);
                string code     = ModelItem.GetValue <string>("Code");
                string language = ModelItem.GetValue <string>("Language");
                if (string.IsNullOrEmpty(language))
                {
                    language = "VB";
                }
                var f = new Editor(code, language, vars, namespaces.ToArray());
                f.textEditor.SyntaxHighlighting = f.Languages.Where(x => x.Name == language).FirstOrDefault();
                f.Owner = GenericTools.MainWindow;
                f.ShowDialog();
                if (f.textEditor.Text != code)
                {
                    ModelItem.Properties["Code"].SetValue(new InArgument <string>()
                    {
                        Expression = new Literal <string>(f.textEditor.Text)
                    });
                }
                if (f.textEditor.SyntaxHighlighting.Name != language)
                {
                    ModelItem.Properties["Language"].SetValue(new InArgument <string>()
                    {
                        Expression = new Literal <string>(f.textEditor.SyntaxHighlighting.Name)
                    });
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }