public void OpenProgram(string fullpath) { var openedProgram = OpenedDocuments.FirstOrDefault(op => op.ProgramFullPath == fullpath); if (openedProgram != null) { DocumentOpened?.Invoke(this, new DocumentOpenEventArgs(openedProgram)); return; } var programforOpening = RecentPrograms.FirstOrDefault(p => p.ProgramFullPath == fullpath); if (programforOpening == null) { programforOpening = ProgramViewModel.Create(fullpath, this, TvcStudioSettings); RecentPrograms.Add(programforOpening); } if (programforOpening.ProgramState == ProgramState.NotFound) { TraceEngine.TraceError($"{programforOpening.ProgramFullPath} beolvasása sikertelen, a file nem található!"); return; } openedProgram = programforOpening.GetDocumentViewModel(); openedProgram.DocumentClosedEvent += OnDocumentClose; OpenedDocuments.Add(openedProgram); programforOpening.ProgramState = ProgramState.Opened; DocumentOpened?.Invoke(this, new DocumentOpenEventArgs(openedProgram)); }
public MainViewModel() { m_OutPut = new StringBuilder(); CreateProgramCommand = new RelayCommand(CreateProgram); OpenProgramCommand = new RelayCommand(OpenProgram); SaveProgramCommand = new RelayCommand(SaveProgram, o => ActiveDocument != null && ActiveDocument.IsDirty); BuildProgramCommand = new RelayCommand(BuildProgram, o => SelectedProgram != null); ApplicationCloseCommand = new RelayCommand(ApplicationClose); HelpCommand = new RelayCommand(ShowHelp); AboutCommand = new RelayCommand(ShowAbout); OpenProgramFromRecentListCommand = new RelayCommand(OpenProgramFromRecentList); SettingsCommand = new RelayCommand(OpenSettings); FormatCodeCommand = new RelayCommand(FormatCode); FindAndReplaceCommand = new RelayCommand(Replace); ClearOutPutCommand = new RelayCommand(o => { m_OutPut.Clear(); OnPropertyChanged(nameof(OutPut)); }, o => m_OutPut.Length > 0); QuickSearchCommand = new RelayCommand(o => { ActiveDocument?.QuickSearchCommand.Execute(o); }); m_DocumentHandler = DocumentHandler.DeSerialize() ?? new DocumentHandler(); m_DocumentHandler.DocumentOpened += DocumentOpened; SelectedTheme = Themes[m_DocumentHandler.TvcStudioSettings.SelectedTheme]; TraceEngine.Subscribe(this); }
private void OpenLoaderFile(object obj) { if (!File.Exists(BuildSettings.LoaderPath)) { TraceEngine.TraceError($"A file {BuildSettings.LoaderPath} nem található!"); return; } DocumentHandler.OpenReadonlyDocument(BuildSettings.LoaderPath); }
public static DocumentHandler DeSerialize() { try { FileStream fs = new FileStream(SettingsPath, FileMode.Open); XmlSerializer xs = new XmlSerializer(typeof(DocumentHandler)); return((DocumentHandler)xs.Deserialize(fs)); } catch (Exception e) { TraceEngine.TraceError($"{SettingsPath} beolvasása sikertelen:{e.Message}"); return(null); } }
public static void Serialize(DocumentHandler settings) { try { if (!Directory.Exists(SettingsDirectory)) { Directory.CreateDirectory(SettingsDirectory); } FileStream fs = new FileStream(SettingsPath, FileMode.Create); XmlSerializer xs = new XmlSerializer(typeof(DocumentHandler)); xs.Serialize(fs, settings); } catch (Exception e) { TraceEngine.TraceError($"{SettingsPath} kimentése sikertelen:{e.Message}"); } }