Пример #1
0
        private async void _NewFile()
        {
            var immlDocument = new ImmlDocument();
            App.ViewModel.SelectedDocument = new ImmlDocumentViewModel(immlDocument);

            _ContextRenderer.Clear();

            var node = new ImmlDocumentSceneNode();
            node.Initialise(immlDocument, _DeviceManager);
            
            _ContextRenderer.Add(node);
        }
Пример #2
0
        private async void _OpenFile()
        {
            if (!ApplicationView.TryUnsnap())
            {
                //TODO: handle problem
            }

            var openPicker = new FileOpenPicker();
            openPicker.FileTypeFilter.Add(".imml");
            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;

            var file = await openPicker.PickSingleFileAsync();

            if (file != null)
            {
                var serialiser = new ImmlSerialiser();
                var immlDocument = await serialiser.Read<ImmlDocument>(file);

                App.ViewModel.SelectedDocument = new ImmlDocumentViewModel(immlDocument);

                _ContextRenderer.Clear();

                var node = new ImmlDocumentSceneNode();
                node.Initialise(immlDocument, _DeviceManager);

                _ContextRenderer.Add(node);

                //TODO: refactor this out somewhere
                var nestedElements = immlDocument.Elements.AsRecursiveEnumerable();

                foreach (var element in nestedElements)
                {
                    if (element is Primitive)
                    {
                        var nestedNode = new PrimitiveSceneNode();
                        nestedNode.Initialise(element, _DeviceManager);

                        _ContextRenderer.Add(nestedNode);
                    }
                }
            }
        }