private void InitializeComponent() { AvaloniaXamlLoader.Load(this); DataContext = new AtlasViewModel() { Close = this.Close }; }
/// <summary> /// Opens a file and returns the corresponding MDViewModel /// </summary> /// <param name="info">The string location of the file</param> /// <returns>The <see cref="MDViewModel"/> for the file.</returns> public ContentViewModel OpenContent(object info, object param) { var location = info as string; if (location != null) { AtlasModel model = null; AtlasViewModel vm = VEFModule.UnityContainer.Resolve(typeof(AtlasViewModel), "") as AtlasViewModel; var view = VEFModule.UnityContainer.Resolve(typeof(AtlasView), "") as AtlasView; try { IAtlasService AtlasService = VEFModule.UnityContainer.Resolve(typeof(IAtlasService), "") as IAtlasService; IProjectTreeService pfExplorerService = VEFModule.UnityContainer.Resolve(typeof(IProjectTreeService), "") as IProjectTreeService; // string[] split = Regex.Split(info.ToString(), ":##:"); //if (split.Count() == 2) //{ // string identifier = split[0]; // string ID = split[1]; // if (identifier == "AtlasID") // { var Atlas = AtlasService.Atlass.Where(x => x.ContentID == info.ToString()); if (Atlas.Any()) { AtlasService.SelectedAtlas = Atlas.First(); AtlasService.SelectedAtlas.Open(info); } else //new Atlas { // AtlasModel newAtlas = new AtlasModel() { Name = "Atlas NEW", ContentID = "AtlasID:##:" }; // newAtlas.Parent = parent; if (pfExplorerService.SelectedItem is AtlasModel) { // pfExplorerService.SelectedItem.Items.Add(newAtlas); var newAtlas = pfExplorerService.SelectedItem as AtlasModel; if (newAtlas != null) { AtlasService.Atlass.Add(newAtlas); // AtlasService.SelectedAtlas = newAtlas; newAtlas.Open(-1); model = newAtlas; } } } //Model details if (model == null) { model = VEFModule.UnityContainer.Resolve(typeof(AtlasModel), "") as AtlasModel; } model.SetLocation(info); // model.SetLocation("AuftragID:##:" + info + ""); // model.Document.Text = File.ReadAllText(location); model.SetDirty(true); // } } catch (Exception exception) { _loggerService.Log(exception.Message, LogCategory.Exception, LogPriority.High); _loggerService.Log(exception.StackTrace, LogCategory.Exception, LogPriority.High); return(null); } //Clear the undo stack // model.Document.UndoStack.ClearAll(); //Set the model and view vm.SetModel(model); vm.SetView(view); vm.Title = "AtlasViewer";//model.nae // Path.GetFileName("Atlas gefunden"); (vm.View as UserControl).DataContext = model; return(vm); } return(null); }