Esempio n. 1
0
        /// <summary>
        /// Loads files from a filestream or zipstream and
        /// outputs the text to the textbox
        /// </summary>
        /// <param name="file"></param>
        internal void LoadAnyFile(string file)
        {
            string ifc;

            if (file.ToLower().EndsWith("ifczip") || file.ToLower().EndsWith("cobiezip"))
            {
                //Load zip file
                using (var zip = ZipFile.OpenRead(file))
                {
                    using (var sr = new StreamReader(zip.Entries[0].Open()))
                    {
                        ifc = sr.ReadToEnd();
                        sr.Close();
                    }
                    CompressedSize.Text   = (zip.Entries[0].CompressedLength / 1000) + "Kb";
                    UncompressedSize.Text = (zip.Entries[0].Length / 1000) + "Kb";
                    zip.Dispose();
                }
            }
            else
            {
                //Load uncompressed files.
                ifc = File.ReadAllText(file);
                IfcReader.Document    = null;
                CompressedSize.Text   = "n/a";
                UncompressedSize.Text = "n/a";
            }

            Title = DefaultTitle + " - " + Path.GetFileName(file);
            IfcReader.Document = new TextDocument {
                UndoStack = { SizeLimit = 0 }
            };

            //Output the loaded text to the window
            IfcReader.Document = new TextDocument(ifc);
            IfcReader.Padding  = new Thickness(10, 0, 0, 0);

            NumberOfLines.Text     = IfcReader.GetNumberOfLines().ToString();
            NumberOfInstances.Text = IfcReader.GetNumberOfInstances().ToString();

            //Populate the tree view browser
            using (var store = IfcStore.Open(file))
            {
                var containment = TreeViewBuilder.ContainmentView(store.ReferencingModel);
                SpatialTree.ItemsSource = containment;
            }
        }
Esempio n. 2
0
        private void SetTheme(bool isDarkMode)
        {
            using (new OverrideCursor(Cursors.Wait))
            {
                IfcReader.SetTheme(isDarkMode);

                var text       = (SolidColorBrush)Application.Current.Resources[isDarkMode ? "LightText" : "DarkText"];
                var readerText =
                    (SolidColorBrush)Application.Current.Resources[isDarkMode ? "LightTextReader" : "DarkText"];
                var readerBackground =
                    (SolidColorBrush)Application.Current.Resources[isDarkMode ? "DarkBackground" : "LightBackground"];
                var panelsBackground =
                    (SolidColorBrush)Application.Current.Resources[
                        isDarkMode ? "DarkPanelsBackground" : "LightPanelsBackground"];
                var border = (SolidColorBrush)Application.Current.Resources[isDarkMode ? "BorderDark" : "BorderLight"];

                BrowserHeading.Foreground = text;
                BrowserUnderline.Fill     = text;
                SpatialTree.Foreground    = text;
                IfcReader.Foreground      = readerText;
                StatusBar.Foreground      = text;
                SearchText.Foreground     = readerText;
                FontSizeLabel.Foreground  = text;
                //Backgrounds
                Background             = panelsBackground;
                RightPanel.Background  = panelsBackground;
                StatusBar.Background   = panelsBackground;
                SideBar.Background     = panelsBackground;
                ToolBar.Background     = panelsBackground;
                IfcReader.Background   = readerBackground;
                SearchText.Background  = readerBackground;
                SearchPanel.Background = panelsBackground;
                //Buttons
                OpenButton.Foreground        = text;
                ThemeSwitchButton.Foreground = text;
                //Borders
                GridSplitter.BorderBrush = border;
                ToolbarBorder.Stroke     = border;
                StatusBar.BorderBrush    = border;
                SearchText.BorderBrush   = border;
            }
        }
Esempio n. 3
0
 private void SpatialTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
 {
     IfcReader.SelectLine(((CustomXbimViewModel)SpatialTree.SelectedItem).EntityLabel.ToString());
 }