Exemplo n.º 1
0
        private void OpenTagReferenceRequested(object sender, TagReferenceEventArgs e)
        {
            //Get file name
            string fileName = Path.Combine(RegistrySettings.WorkspaceDirectory, "tags", e.TagReference);

            try
            {
                //Load
                AbideTagGroupFile tagGroupFile = new AbideTagGroupFile();
                using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    tagGroupFile.Load(stream);

                //Create
                TagFileModel tagGroupFileViewModel = new TagFileModel(fileName, tagGroupFile);
                tagGroupFileViewModel.CloseCallback              = File_Close;
                tagGroupFileViewModel.OpenTagReferenceRequested += OpenTagReferenceRequested;
                Files.Add(tagGroupFileViewModel);

                //Set
                SelectedFile = tagGroupFileViewModel;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to open the specified file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                throw ex;
            }
        }
Exemplo n.º 2
0
        private void NewFile()
        {
            //Create and show
            NewTagViewModel newTagViewModel = new NewTagViewModel();
            NewFileDialog   newFileDialog   = new NewFileDialog()
            {
                Owner = Owner, DataContext = newTagViewModel
            };

            if (newFileDialog.ShowDialog() ?? false)
            {
                //Get tag group
                Group tagGroup = TagLookup.CreateTagGroup(newTagViewModel.SelectedTagDefinition.GroupTag);

                //Create file
                TagFileModel newTagFileModel = new TagFileModel($"new_{tagGroup.GroupName}.{tagGroup.GroupName}", new AbideTagGroupFile()
                {
                    TagGroup = tagGroup
                })
                {
                    IsDirty = true, CloseCallback = File_Close
                };
                newTagFileModel.OpenTagReferenceRequested += OpenTagReferenceRequested;
                Files.Add(newTagFileModel);

                //Set
                SelectedFile = newTagFileModel;
            }
        }
Exemplo n.º 3
0
        private void OpenFile()
        {
            //Prepare
            string tagsDirectory = Path.Combine(RegistrySettings.WorkspaceDirectory, "tags");

            //Create
            OpenFileDialog openDlg = new OpenFileDialog
            {
                InitialDirectory = tagsDirectory,
                Filter           = "All Files (*.*)|*.*"
            };

            //Add custom place
            openDlg.CustomPlaces.Add(new FileDialogCustomPlace(tagsDirectory));

            //Show
            if (openDlg.ShowDialog() ?? false)
            {
                if (!Files.Any(f => f.FileName == openDlg.FileName))
                {
                    try
                    {
                        //Load
                        AbideTagGroupFile tagGroupFile = new AbideTagGroupFile();
                        using (var stream = openDlg.OpenFile())
                            tagGroupFile.Load(stream);

                        //Create
                        TagFileModel tagGroupFileViewModel = new TagFileModel(openDlg.FileName, tagGroupFile);
                        tagGroupFileViewModel.CloseCallback              = File_Close;
                        tagGroupFileViewModel.OpenTagReferenceRequested += OpenTagReferenceRequested;
                        Files.Add(tagGroupFileViewModel);

                        //Set
                        SelectedFile = tagGroupFileViewModel;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Unable to open the specified file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        throw ex;
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void LoadTagGroupFile(TagFileModel tagGroupFile)
        {
            //Prepare
            TagBlockControl tagBlockControl = null;
            TagBlockModel   tagBlockModel   = null;

            //Load tag blocks
            foreach (var tagBlock in tagGroupFile.TagGroup)
            {
                //Initialize
                tagBlockModel = new TagBlockModel()
                {
                    Owner = TagFile, TagBlock = tagBlock
                };
                tagBlockControl = new TagBlockControl()
                {
                    DataContext = tagBlockModel
                };

                //Add
                mainStackPanel.Children.Add(tagBlockControl);
            }
        }