Exemple #1
0
 private void LoadScripts()
 {
     try
     {
         foreach (string filename in Directory.GetFiles(Folder)
                  .Where(fn =>
                         Path.GetExtension(fn).ToLower() == Extension
                         )
                  .OrderBy(s => s))
         {
             var extension = Path.GetExtension(filename);
             if (!Scripts.Any(s => s.FileName == filename))
             {
                 if (Logger != null)
                 {
                     Logger.Log(LogLevel.Debug, $"Adding {filename} to the list of known files");
                 }
                 var script = new ChangeScript();
                 script.Script   = Path.GetFileName(filename);
                 script.FileName = filename;
                 Scripts.Add(script);
             }
         }
     }
     catch (Exception ex)
     {
         if (Logger != null)
         {
             Logger.Log(LogLevel.Error, $"Error Cataloging Files: {ex.Message}");
         }
     }
 }
Exemple #2
0
        public void LoadAllScripts()
        {
            DirectoryInfo basePathInfo = new DirectoryInfo(BasePath);

            if (!basePathInfo.Exists)
            {
                basePathInfo.Create();
            }

            DirectoryInfo macroditorPathInfo = new DirectoryInfo(MacroditorPath);

            if (!macroditorPathInfo.Exists)
            {
                macroditorPathInfo.Create();
            }

            foreach (var manifestResourceName in typeof(MainViewModel).Assembly.GetManifestResourceNames())
            {
                Debug.WriteLine(manifestResourceName);
            }

            WriteResourceToFile(ReferencedAssembliesFile, "Macroditor.MacroditorScripsResources.ReferencedAssembliesFile", overrideExisting: false);
            WriteResourceToFile(GlobalUsingsFile, "Macroditor.MacroditorScripsResources.GlobalUsings", overrideExisting: false);

            IEnumerable <FileInfo> files = basePathInfo.GetFiles("*.csx").Concat(basePathInfo.GetFiles("*.cs"));

            Scripts.Clear();
            foreach (var file in files)
            {
                Scripts.Add(new Script(file.FullName, ReferencedAssembliesFile, GlobalUsingsFile));
            }
        }
        private void AddScriptCommandExecute()
        {
            var existingScriptsInfos = Scripts.Select(script => new DirectoryInfo(script.FilePath)).ToList();

            var browseWindow = new BrowseScriptsWindow(_parent);

            browseWindow.SetTopLevelFolder(TopLevelScriptsFolder);
            if (browseWindow.ShowDialog() == true)
            {
                var newDirectories = browseWindow
                                     .SelectedDirectories
                                     .Where(info => !existingScriptsInfos.Contains(info, new DirectoryInfoComparer()))
                                     .ToList();

                if (!newDirectories.Any())
                {
                    return;
                }

                foreach (var directoryInfo in newDirectories)
                {
                    Scripts.Add(new ScriptsFolderViewModel {
                        FilePath = directoryInfo.FullName.TrimEnd('\\'), IsChecked = true
                    });
                }

                var last = newDirectories.Last();
                TopLevelScriptsFolder = last.Parent != null ? last.Parent.FullName : last.FullName;
            }
        }
Exemple #4
0
        public DenizenIDEForm()
        {
            InitializeComponent();
            Timer t = new Timer()
            {
                Interval = 250
            };

            t.Tick += T_Tick;
            t.Start();
            Configure(richTextBox1);
            Rel    = this.Size - richTextBox1.Size;
            TabRel = this.Size - tabControl1.Size;
            LoadedScript initialScript = new LoadedScript()
            {
                FilePath = null, UnsavedName = tabPage1.Text
            };

            Scripts.Add(initialScript);
            Configure(tabPage1, 0);
            SetText(0, "");
            tabControl1.MouseClick += TabControl1_MouseClick;
            tabControl1.MouseClick += TabControl1_MouseClick2;
            this.MouseWheel        += Form1_MouseWheel;
            this.FormClosing       += Form1_FormClosing;
        }
        private static void Register(Type type)
        {
            //Log.WriteLine("Registering {0} as script", type.Name);
            try
            {
                var ctor = type.GetConstructor(new Type[] { });
                if (ctor == null)
                {
                    throw new Exception("Constructor not found");
                }

                var script = (Script)ctor.Invoke(new object[] { });
                if (script == null)
                {
                    throw new Exception("Unable to instantiate script");
                }

                Scripts.Add(script);
                OnScriptRegistered(script);
            }
            catch (Exception ex)
            {
                Log.WriteLine("Failed to compile: {0}", ex.Message);
            }
        }
Exemple #6
0
        public void ReadScriptFile()
        {
            string[]      lines    = File.ReadAllLines(AbsolutePath);
            List <string> commands = new List <string>();

            Scripts.Clear();
            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].StartsWith("#begin "))
                {
                    string name = lines[i++].Substring("#begin ".Length);
                    commands.Clear();
                    for (int j = i; (i = j) < lines.Length; j++)
                    {
                        if (lines[j].StartsWith("#end"))
                        {
                            i++;
                            break;
                        }
                        commands.Add(lines[j]);
                    }
                    Scripts.Add(name, new Script(commands, this));
                }
            }
        }
Exemple #7
0
        public virtual void AddScript(DatabaseClass script, bool listViewOnly = false, bool selectNewItem = false)
        {
            ListView.AddObject(script);

            if (!listViewOnly)
            {
                Scripts.Add(script);
            }

            //CustomListViewItem lvi = new CustomListViewItem(GetListViewKeyValue(script));
            //lvi.Script = script;
            //lvi.Name = GetListViewKeyValue(script);

            //foreach (PropertyInfo propInfo in PropInfo.Where(p => !p.Name.Equals(GetListViewKey())))
            //{
            //    if (ExcludedProperties.Contains(propInfo.Name))
            //        continue;

            //    lvi.SubItems.Add(propInfo.GetValue(script).ToString());
            //}

            //if (!listViewOnly)
            //    Scripts.Add(script);

            //ListViewItem newItem = ListView.Items.Add(lvi);

            if (selectNewItem)
            {
                ListView.HideSelection = false;
                ListView.SelectObject(script);
                ListView.Select();
                ListView.Focus();
                ListView.EnsureModelVisible(script);
            }
        }
Exemple #8
0
        private void CreateNewScript(string name, string type)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }
            if (_dbContext.UserScripts.Any(x => x.Name == name))
            {
                _dialogService.ShowMessageAsync(this, "Script Already Exists", "A script with that name already exists.");
                return;
            }

            //If there are unsaved changes, prompt to save before making a new script
            HandleUnsavedChanges();

            //test text for uniqueness
            var script = new UserScript();

            script.Name = name;

            AddStandardAssemblies(script);

            script.Code = string.Format(type == "Order"
                ? OrderScriptBase
                : TradeScriptBase, name);

            _dbContext.UserScripts.Add(script);
            Scripts.Add(script);
            SelectedScript = script;
            Code           = SelectedScript.Code;
            SaveScripts();
        }
Exemple #9
0
        public void AddScriptInstance(CryScriptInstance instance, ScriptType scriptType)
        {
#if !(RELEASE && RELEASE_DISABLE_CHECKS)
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            if (!Enum.IsDefined(typeof(ScriptType), scriptType))
            {
                throw new ArgumentException(string.Format("scriptType: value {0} was not defined in the enum", scriptType));
            }
#endif

            var script = FindScript(scriptType, x => x.Type == instance.GetType());
            if (script == null)
            {
                if (CryScript.TryCreate(instance.GetType(), out script))
                {
                    Scripts.Add(script);
                }
                else
                {
                    return;
                }
            }

            AddScriptInstance(script, instance);
        }
Exemple #10
0
        public void AddScript()
        {
            var ret = new ScriptItemModel(Scripts);

            Scripts.Add(ret);
            Scripts.SelectedItem = ret;
        }
Exemple #11
0
        /// <summary>
        /// Creates a new map with values.
        /// </summary>
        /// <param name="width">The width in tiles.</param>
        /// <param name="height">The height in tiles.</param>
        /// <param name="tileWidth">The tilewidth in pixels.</param>
        /// <param name="tileHeight">The tileheight in pixels.</param>
        /// <param name="tilesetPath">The path to the tileset.</param>
        public void CreateNew(short width, short height, short tileWidth, short tileHeight, string tilesetPath)
        {
            for (int i = 0; i < 9; ++i)
            {
                Scripts.Add("");
            }

            // create a base layer:
            Layer layer = new Layer();

            layer.CreateNew(width, height);
            Layers.Add(layer);

            // create a starting tile:
            Tileset = new Tileset();

            if (string.IsNullOrEmpty(tilesetPath))
            {
                Tileset.CreateNew(tileWidth, tileHeight);
            }
            else
            {
                Tileset    = Tileset.FromFile(tilesetPath);
                Scripts[0] = Path.GetFileName(tilesetPath);
            }
        }
Exemple #12
0
        public void NewTab()
        {
            TabPage tp = new TabPage("New Script " + (CPage++));

            Configure(tp, tabControl1.TabCount - 1);
            tabControl1.TabPages.Insert(tabControl1.TabCount - 1, tp);
            RichTextBox linertfb = new RichTextBox()
            {
                Location = LineReferenceBox.Location,
                Size     = LineReferenceBox.Size,
                Font     = LineReferenceBox.Font,
                ReadOnly = true,
                Anchor   = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left
            };

            tp.Controls.Add(linertfb);
            RichTextBox rtfb = new RichTextBox()
            {
                Location = ReferenceBox.Location,
                Size     = ReferenceBox.Size,
                Font     = ReferenceBox.Font
            };

            Configure(rtfb);
            tp.Controls.Add(rtfb);
            tabControl1.SelectTab(tabControl1.TabCount - 2);
            Scripts.Add(new LoadedScript()
            {
                FilePath = null, UnsavedName = tp.Text
            });
        }
Exemple #13
0
        public static void RegisterScript(this HtmlHelper html, string jsFile, string category)
        {
            bool inReverseOrder = false;

            string viewPath;

            inReverseOrder = (html.ViewDataContainer.RegisterReverseOrder(html.ViewContext.View, out viewPath));

            category = category ?? "";

            if (!Scripts.Any(v => v.ViewPath == viewPath))
            {
                if (inReverseOrder)
                {
                    Scripts.Insert(0, new ResourceGroup {
                        ViewPath = viewPath
                    });
                }
                else
                {
                    Scripts.Add(new ResourceGroup {
                        ViewPath = viewPath
                    });
                }
            }

            Scripts.First(s => s.ViewPath == viewPath).Items.Add(new ResourceWrapper
            {
                Category = category,
                Filename = jsFile
            });
        }
Exemple #14
0
        public void DefineEmptyScript()
        {
            var script = new AbcScript {
                Initializer = DefineEmptyMethod()
            };

            Scripts.Add(script);
        }
Exemple #15
0
        public void DefineScript(IEnumerable <AbcInstance> instances, Predicate <AbcInstance> filter)
        {
            var script = new AbcScript();

            Scripts.Add(script);
            script.DefineClassTraits(instances, filter);
            DefineScriptInit(script);
        }
Exemple #16
0
 public void AddScript(int level, string script)
 {
     if (!Scripts.ContainsKey(level))
     {
         Scripts.Add(level, new StringBuilder());
     }
     Scripts[level].AppendLine(script);
 }
Exemple #17
0
 public void AddScript(string scriptTag)
 {
     if (!Scripts.Contains(scriptTag))
     {
         Scripts.Add(scriptTag);
     }
     SetToRequest(this);
 }
Exemple #18
0
        private void AddScriptButton_Click(object sender, EventArgs e)
        {
            var dataSourceObject = new ScriptSourceObject();

            Scripts.Add(dataSourceObject);
            dataSourceObject.ScriptSource = new Script();
            GridViewScripts.RefreshData();
        }
Exemple #19
0
 private void ExecuteAddExpression()
 {
     Scripts.Add(new ScriptExpression
     {
         Expression  = "puts 40+2",
         IsRemovable = true
     });
 }
Exemple #20
0
        public void ImportScript(AbcScript from)
        {
            var script = new AbcScript();

            Scripts.Add(script);
            script.Initializer = ImportMethod(from.Initializer);
            ImportTraits(from, script);
        }
 private void UpdateScriptList()
 {
     Scripts.Clear();
     Scripts.Add(new ScriptViewModel());
     foreach (Script script in _scriptRegistry.Scripts)
     {
         Scripts.Add(new ScriptViewModel(script));
     }
 }
Exemple #22
0
 public Variables Add(Variables item)
 {
     return(new Variables
     {
         Styles = Styles != null?Styles.Add(item?.Styles) : item?.Styles?.Add(null),
                      Scripts = Scripts != null?Scripts.Add(item?.Scripts) : item?.Scripts?.Add(null),
                                    Data = Data != null?Data.Add(item?.Data) : item?.Data?.Add(null),
     });
 }
Exemple #23
0
 //_____________________________________________________________________________________________________________________________________________________________
 private void AddScript(string name)
 {
     if (!File.Exists(name) || Scripts.Contains(name))
     {
         return;
     }
     Scripts.Add(name);
     File.WriteAllLines(fullProjectFileName, Scripts.ToArray());
 }
Exemple #24
0
        public void AddScript(string scriptText)
        {
            if (Scripts == null)
            {
                Scripts = new List <string>();
            }

            Scripts.Add(scriptText);
        }
        public DeckViewModel(Models.Deck deckModel)
        {
            _deckModel = deckModel;

            // Load available input languages
            foreach (var lang in InputLanguageManager.Current.AvailableInputLanguages ?? new List <object>())
            {
                Languages.Add(CultureInfo.CreateSpecificCulture(lang.ToString()));
            }

            // Load system default language
            var defaultLang = InputLanguageManager.Current.CurrentInputLanguage;

            // TODO: Remove hard-coded initialization
            // Initialize scripts
            var defaultScript = new NoneScript("None");

            Scripts.Add(defaultScript);
            Scripts.Add(new MirrorScript("Clone"));
            Scripts.Add(new FuriganaScript(MyQuery, "Furigana"));
            Scripts.Add(new DictionaryFormScript(MyQuery, "Dictionary Form"));
            Scripts.Add(new NotesScript(MyQuery, "Notes"));


            // Initialize deck settings
            DeckSettings = new DeckSettings(defaultLang, defaultScript);

            foreach (var noteModel in deckModel.note_models)
            {
                DeckSettings.AddFieldSettings(noteModel);
            }

            // Create dictionary of noteModels
            foreach (var noteModel in deckModel.note_models)
            {
                _noteModels.Add(noteModel.crowdanki_uuid, noteModel);
                NoteModels.Add(noteModel);
            }

            SelectedNoteModel = NoteModels.First();

            foreach (var note in deckModel.notes)
            {
                // Add notes where note model exists
                if (_noteModels.TryGetValue(note.note_model_uuid, out var noteModel))
                {
                    NoteViewModels.Add(new NoteViewModel(note, noteModel, this));
                }
                else
                {
                    // TODO Error handling
                }
            }

            Sort();
        }
Exemple #26
0
 public Property(Property b)
 {
     Name  = b.Name;
     Type  = b.Type;
     Value = b.Value;
     foreach (var i in b.Scripts)
     {
         Scripts.Add(new Script(i));
     }
 }
Exemple #27
0
        /// <summary>
        /// Load scripts to solve multi-browser compatibility issues.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            EnableScriptGlobalization = true;
            EnablePartialRendering    = true;
            ScriptMode           = ScriptMode.Release;
            AsyncPostBackTimeout = 595;
            Scripts.Add(new ScriptReference(WebKitHack));
        }
Exemple #28
0
        public void Handle(ScriptDocumentAddedEvent message)
        {
            var script = Scripts.FirstOrDefault(s => s.ContentId == message.Document.ContentId);

            if (script == null)
            {
                script = message.Document;
                Scripts.Add(script);
            }

            script.IsActive = true;
        }
        private void AddScripts(IEnumerable <Script> scriptsToAdd)
        {
            if (scriptsToAdd == null)
            {
                return;
            }

            foreach (Script script in scriptsToAdd)
            {
                Scripts.Add(new ScriptWrapper(script));
            }
        }
        private void AddScript_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (_sqlFileDialog.ShowDialog() != true)
            {
                return;
            }

            foreach (string file in _sqlFileDialog.FileNames)
            {
                Scripts.Add(new ScriptWrapper(new SqlScript(new DiskScriptResource(file), DefaultDatabaseConnection)));
            }
        }