Esempio n. 1
0
        private void ListCollectionData_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (DbSelectedItems.Count() > 1 || DbSelectedItems.Count() == 0)
            {
                ItemsDocPreview.ItemsSource  = null;
                BorderDocPreview.Visibility  = Visibility.Collapsed;
                BorderFilePreview.Visibility = Visibility.Collapsed;
                return;
            }


            BorderDocPreview.Visibility = Visibility.Visible;
            var document = DbSelectedItems.First();
            var controls = new List <DocumentFieldData>();

            for (int i = 0; i < document.LiteDocument.Keys.Count; i++)
            {
                var key       = document.LiteDocument.Keys.ElementAt(i);
                var valueEdit = BsonValueEditor.GetBsonValueEditor(string.Format("[{0}]", key), document.LiteDocument[key], document.LiteDocument, true);
                controls.Add(new DocumentFieldData(key, valueEdit));
            }

            ItemsDocPreview.ItemsSource = controls;

            if (document.Collection is FileCollectionReference)
            {
                var fileInfo = (document.Collection as FileCollectionReference).GetFileObject(document);
                FilePreview.LoadFile(fileInfo);
                BorderFilePreview.Visibility = Visibility.Visible;
            }
            else
            {
                BorderFilePreview.Visibility = Visibility.Collapsed;
            }
        }
Esempio n. 2
0
        private void Initialize()
        {
            Store.Current.SelectedDatabaseChange += (sender, args) =>
            {
                var databaseReference = args.Data;
                Title = databaseReference == null ? $"LiteDB Explorer {Versions.CurrentVersion}" : $"{databaseReference.Name} - LiteDB Explorer {Versions.CurrentVersion}";
            };

            Store.Current.SelectedCollectionChange += (sender, args) =>
            {
                BorderFilePreview.Visibility = Visibility.Collapsed;
            };

            Store.Current.SelectedDocumentChange += (sender, args) =>
            {
                var document = args.Data;

                BorderFilePreview.Visibility = Visibility.Collapsed;

                if (document != null && document.Collection is FileCollectionReference reference)
                {
                    var fileInfo = reference.GetFileObject(document);
                    FilePreview.LoadFile(fileInfo);
                    BorderFilePreview.Visibility = Visibility.Visible;
                }
            };
        }
Esempio n. 3
0
        private void ListCollectionData_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (DbSelectedItems.Count() > 1 || !DbSelectedItems.Any())
            {
                // ItemsDocPreview.ItemsSource = null;
                BorderDocPreview.Visibility  = Visibility.Collapsed;
                BorderFilePreview.Visibility = Visibility.Collapsed;
                return;
            }


            BorderDocPreview.Visibility = Visibility.Visible;
            var document = DbSelectedItems.First();

            /*var controls = new List<DocumentFieldData>();
             *
             * for (int i = 0; i < document.LiteDocument.Keys.Count; i++)
             * {
             *  var key = document.LiteDocument.Keys.ElementAt(i);
             *  var valueEdit = BsonValueEditor.GetBsonValueEditor(
             *      expandMode: BsonEditorExpandMode.Inline,
             *      bindingPath: $"[{key}]",
             *      bindingValue: document.LiteDocument[key],
             *      bindingSource: document.LiteDocument,
             *      readOnly: true,
             *      keyName: key
             *  );
             *  controls.Add(new DocumentFieldData(key, valueEdit));
             * }
             *
             * ItemsDocPreview.ItemsSource = controls;*/

            DocumentTreeView.ItemsSource = new DocumentTreeItemsSource(document);

            if (document.Collection is FileCollectionReference reference)
            {
                var fileInfo = reference.GetFileObject(document);
                FilePreview.LoadFile(fileInfo);
                BorderFilePreview.Visibility = Visibility.Visible;
            }
            else
            {
                BorderFilePreview.Visibility = Visibility.Collapsed;
            }
        }