public TemplateManager(IFileViewModel settings) { m_settings = settings; m_settings.ContentChanged += SettingsOnContentChanged; m_root = new CollectionTreeViewModel(); UpdateSettings(); }
public SchemaManager(IFileViewModel settings) { m_settings = settings; m_settings.FileChangedOnDisk += SettingsOnFileChangedOnDisk; AddLockedSchema(new Schema(Properties.Resources.schema_schema, this)); AddLockedSchema(new Schema(Properties.Resources.quickschema_schema, this)); UpdateSettings(); }
private void CloseFile(IFileViewModel vm) { if (vm.Close()) { SelectedItem = null; openFilesList.Remove(vm); } }
public IFileViewModel MakeFile(string path) { IFileViewModel fileViewModel = IoC.Get <IFileViewModel>(); fileViewModel.Model = new File(path); return(fileViewModel); }
public FileSaveAsData(IModuleFileSave moduleFileSave, IFileViewModel fileViewModel) { this.ModuleFileSave = moduleFileSave; this.FileViewModel = fileViewModel; this.ModuleName = ModuleFileSave.GetType().Name; this.FileName = Path.GetFileName(fileViewModel.Filename); }
public Template(IFileViewModel fileViewModel) { m_fileViewModel = fileViewModel; fileViewModel.ContentChanged += FileViewModelOnContentChanged; m_templatePath = Path.GetDirectoryName(fileViewModel.Path) + "\\"; JsonNode jsonNode = (JsonNode)JsonHelperFunctions.Parse(FileViewModel.GetContent<string>()); if (jsonNode == null) return; Name = jsonNode.GetObjectOrDefault("name", "no name"); }
public EditorManager(IFileViewModel setting, MainViewModel mainViewModel) { m_editorsWithSettings = new FilteredObservableCollection<IEditor>(m_baseEditors, editor => editor.Settings != null); m_setting = setting; m_mainViewModel = mainViewModel; m_imageViewerViewModel = new ImageViewerViewModel(); m_jsonEditorViewModel = new JsonEditorViewModel(mainViewModel); m_simpleEditor = new BaseTextEditorViewModel(mainViewModel); m_findInFilesViewModel = new FindInFilesViewModel(mainViewModel); UpdateSettings(); m_setting.ContentChanged += SettingOnContentChanged; }
internal void MenuFileSave2(FileSaveData fileSaveData) { IFileViewModel fileViewModel = fileSaveData.FileViewModel; var moduleFileSave = fileSaveData.ModuleFileSave; if (fileViewModel.Filename == null || !System.IO.Path.IsPathRooted(fileViewModel.Filename)) { MenuFileSaveAs(); } else { moduleFileSave.FileSave(fileViewModel); } }
internal void MenuFileSaveAs2(FileSaveAsData fileSaveAsData) { IFileViewModel fileViewModel = fileSaveAsData.FileViewModel; var moduleFileSave = fileSaveAsData.ModuleFileSave; string filename = Path.GetFileName(fileViewModel.Filename); var initialDirectory = Path.GetDirectoryName(fileViewModel.Filename); // Get active moduleFile var moduleFile = moduleFileSave as IModuleFileSaveAs; IEnumerable <FileExtension> fileExtensions = moduleFile.FileExtensions; List <string> extensions = new List <string>(); foreach (var fileExtension in fileExtensions) { extensions.Add(fileExtension.ToString()); } extensions.Add("All files (*.*)|*.*"); string filter = string.Join("|", extensions); Win32.SaveFileDialog sfd = new Win32.SaveFileDialog(); sfd.Filter = filter; sfd.FilterIndex = 1; sfd.AddExtension = true; sfd.FileName = filename; sfd.InitialDirectory = initialDirectory; if (sfd.ShowDialog() != true) { return; } var fdFilenameResult = sfd.FileName; moduleFile.FileSaveAs(fileViewModel, fdFilenameResult); RegisterRecentFile(fdFilenameResult); return; }
public void Save(IFileViewModel fileViewModel) { try { fileViewModel.Save(); } catch (Exception e) { m_dialogHelper.ShowMessageBox("Save failed!", "Could not save:\r\n" + e.Message); } }
private void FileViewModelOnContentChanged(IFileViewModel fileViewModel) { JsonNode jsonNode = (JsonNode)JsonHelperFunctions.Parse(FileViewModel.GetContent<string>()); if (jsonNode == null) return; Name = jsonNode.GetObjectOrDefault("name", "no name"); }
private void SettingsOnFileChangedOnDisk(IFileViewModel fileViewModel) { UpdateSettings(); }
private void CloseFile(IFileViewModel file) { if (file == null) return; if (!LayoutManager.LayoutElements.Any(layout => layout.OpenFiles.Contains(file))) return; if (file.HasUnsavedChanges) { DialogHelper.ShowMessageBox(SaveOnCloseMessageBoxReply, new object[] { file }, "Has unsaved data", "Save unsaved data?", MessageBoxButton.YesNoCancel); } else SaveOnCloseMessageBoxReply(MessageBoxResult.No, new object[] { file }); }
private void FileOnPropertyChanged(IFileViewModel file) { if (m_file.GetContent<string>() != m_text) { string text = m_file.GetContent<string>(); if (m_convertTabsToSpaces) text = text.Replace("\t", m_indentString); FileChangedExternaley(text); m_textDocument.Text = text; } }
public void OpenFile(IFileViewModel file, LayoutElementViewModel layoutElement = null, bool select = true) { if (file == null) return; if (layoutElement == null) layoutElement = m_layoutManager.LayoutElements.FirstOrDefault(n => n.OpenFiles.Contains(file)) ?? LayoutManager.ActiveLayoutElement; if (file.Path == null || !layoutElement.OpenFiles.Any(n => n.Path == file.Path)) { file.FileChangedOnDisk += FileOnFileChangedOnDisk; layoutElement.OpenFiles.Add(file); } if (select) layoutElement.SelectedFile = file; }
private void FileOnFileChangedOnDisk(IFileViewModel sender) { if (!m_view.Dispatcher.CheckAccess()) { m_view.Dispatcher.BeginInvoke(new Action(() => FileOnFileChangedOnDisk(sender))); return; } if (!sender.IsBasedOnCurrentFile()) { m_reloadFilesDialogViewModel.AddFile(sender); if (!m_reloadFilesDialogViewModel.IsShown) m_dialogHelper.ShowDialog(m_reloadFilesDialogViewModel); } }
private void FileViewModelOnFileChangedOnDisk(IFileViewModel fileViewModel) { Dictionary<string, List<string>> dictionary = fileViewModel.GetTag("AutoComplete") as Dictionary<string, List<string>>; if (dictionary != null) { foreach (KeyValuePair<string, List<string>> keyValuePair in dictionary) { m_collections[keyValuePair.Key].Remove(keyValuePair.Value); } dictionary.Clear(); } Regex scheamRegex = new Regex(@"""\$schema""\s*\:\s*""(.*)""", RegexOptions.IgnoreCase); Match match = scheamRegex.Match(fileViewModel.GetContent<string>()); Schema schema = match.Success ? m_schemaManager.GetSchema(match.Groups[1].ToString()) : null; if (schema != null) { JsonException jsonException; JsonNode jsonNode = (JsonNode)JsonHelperFunctions.Parse(fileViewModel.GetContent<string>(), out jsonException); if (jsonException == null) m_tasks.Add(Task.Factory.StartNew(() => BuildCollection(fileViewModel, jsonNode, schema, new List<string>(), null))); } }
private void BuildCollection(IFileViewModel fileViewModel, JsonNode jsonNode, Schema schema, List<string> path, CancellationToken? token) { if (token.HasValue && token.Value.IsCancellationRequested) return; foreach (JsonElement jsonElement in jsonNode) { path.Add(jsonElement.Key); SchemaObject schemaObject = schema.GetSchemaObject(path); if (schemaObject != null) { if (schemaObject.AutoCompleteTargetKey != null) { string prefix = schemaObject.Prefix; AddParameters(ref prefix, fileViewModel); if (jsonElement.Value is JsonNode) AddRange(schemaObject.AutoCompleteTargetKey, ((JsonNode)jsonElement.Value).Keys, prefix, fileViewModel); else Add(schemaObject.AutoCompleteTargetKey, jsonElement.Value.ToString(), prefix,fileViewModel); } JsonNode node = jsonElement.Value as JsonNode; if (node != null) BuildCollection(fileViewModel, node, schema, path, token); else { JsonArray array = jsonElement.Value as JsonArray; if (array != null) BuildCollection(fileViewModel, array, schema, path, token); } } path.RemoveAt(path.Count - 1); } }
protected IHttpActionResult FileResult(IFileViewModel fileViewModel, RangeContentInfo rangeContentInfo) { return(new FileResult(fileViewModel, rangeContentInfo)); }
private void AddRange(string key, IEnumerable<object> value, string prefix, IFileViewModel fileViewModel) { Dictionary<string, List<string>> dictionary = fileViewModel.GetTag("AutoComplete") as Dictionary<string, List<string>>; if (dictionary == null) { dictionary = new Dictionary<string, List<string>>(); fileViewModel.SetTag("AutoComplete", dictionary); } List<string> list; dictionary.TryGetValue(key, out list); if (list == null) { list = new List<string>(); lock (m_collections) { if (!m_collections.ContainsKey(key)) m_collections.Add(key, new List<List<string>>()); m_collections[key].Add(list); dictionary.Add(key, list); } } lock (list) { list.AddRange(value.Select(n => prefix + n.ToString())); } }
public ReloadFileViewModel(IFileViewModel file) { m_file = file; }
private void BuildCollection(IFileViewModel fileViewModel, JsonArray jsonArray, Schema schema, List<string> path, CancellationToken? token) { foreach (object obj in jsonArray) { path.Add("[0]"); SchemaObject schemaObject = schema.GetSchemaObject(path); if (schemaObject == null) continue; if (schemaObject.AutoCompleteTargetKey != null) { string prefix = schemaObject.Prefix; AddParameters(ref prefix, fileViewModel); Add(schemaObject.AutoCompleteTargetKey, obj.ToString(), prefix, fileViewModel); } JsonNode node = obj as JsonNode; if (node != null) BuildCollection(fileViewModel, node, schema, path, token); JsonArray array = obj as JsonArray; if (array != null) BuildCollection(fileViewModel, array, schema, path, token); path.RemoveAt(path.Count - 1); } }
public static string GetExtension(this IFileViewModel fileViewModel) { return(Path.GetExtension(fileViewModel.FileName)); }
private void SettingsOnContentChanged(IFileViewModel fileViewModel) { UpdateSettings(); }
public void AddFile(IFileViewModel file) { Files.Add(new ReloadFileViewModel(file)); }
public FileResult(IFileViewModel fileViewModel, RangeContentInfo rangeContentInfo) { _fileViewModel = fileViewModel; _rangeContentInfo = rangeContentInfo; }
private void FileOnContentChanged(IFileViewModel fileViewModel) { UpdateImage(); }