private void radioBttnRoomHost_Checked(object sender, RoutedEventArgs e)
 {
     if (null != toolSettings)
     {
         bool islinkedRoom = (bool)radioBttnRoomLink.IsChecked;
         treeViewRoom.ItemsSource = null;
         treeViewRoom.ItemsSource = TreeviewModel.SetTreeView(roomDictionary, islinkedRoom);
     }
 }
        private bool DisplayRooms()
        {
            bool result = false;

            try
            {
                Dictionary <int /*roomId*/, RoomElevationProperties> roomsStored = ElevationCreatorDataStorageUtil.GetRoomElevationProperties(m_doc, linkedDocuments);
                roomDictionary = GetRoomsProperties(roomsStored);

                treeViewRoom.ItemsSource = TreeviewModel.SetTreeView(roomDictionary, toolSettings.IsLinkedRoom);
                result = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to display rooms.\n" + ex.Message, "Elevation Creator: DisplayRooms", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(result);
        }
예제 #3
0
        public static List <TreeviewModel> SetTreeView(Dictionary <int, RoomElevationProperties> dictionary, bool isLinkedRoom)
        {
            List <TreeviewModel> treeView = new List <TreeviewModel>();

            try
            {
                foreach (RoomElevationProperties rep in dictionary.Values)
                {
                    if (rep.IsLinked == isLinkedRoom)
                    {
                        TreeviewModel roomItem = new TreeviewModel(rep);
                        treeView.Add(roomItem);

                        List <TreeviewModel> childrenList = new List <TreeviewModel>();
                        foreach (int markId in rep.ElevationViews.Keys)
                        {
                            foreach (ElevationViewProperties evp in rep.ElevationViews[markId].Values)
                            {
                                TreeviewModel viewItem = new TreeviewModel(evp);
                                childrenList.Add(viewItem);
                            }
                        }

                        childrenList      = childrenList.OrderBy(child => child.name).ToList();
                        roomItem.Children = childrenList;
                        roomItem.Initialize();
                    }
                }
                treeView = treeView.OrderBy(item => item.Name).ToList();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to create the tree view for the rooms.\n" + ex.Message, "Room Elevation Creator", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(treeView);
        }
        private void buttonCreateByList_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (SetToolSettings())
                {
                    List <RoomElevationProperties> selectedRooms = new List <RoomElevationProperties>();

                    List <TreeviewModel> treeviewModels = treeViewRoom.ItemsSource as List <TreeviewModel>;
                    foreach (TreeviewModel roomNode in treeviewModels)
                    {
                        if (roomNode.IsChecked == true)
                        {
                            if (null != roomNode.RoomProperties)
                            {
                                RoomElevationProperties rep = roomNode.RoomProperties;
                                selectedRooms.Add(rep);
                            }
                        }
                    }

                    if (selectedRooms.Count > 0)
                    {
                        progressBar.Visibility = System.Windows.Visibility.Visible;
                        statusLable.Visibility = System.Windows.Visibility.Visible;
                        statusLable.Text       = "Creating Elevation Views . . .";

                        progressBar.Minimum = 0;
                        progressBar.Maximum = selectedRooms.Count;
                        progressBar.Value   = 0;

                        double value = 0;
                        UpdateProgressBarDelegate updatePdDelegate = new UpdateProgressBarDelegate(progressBar.SetValue);

                        foreach (RoomElevationProperties rep in selectedRooms)
                        {
                            ElevationCreator creator = new ElevationCreator(m_app, rep, toolSettings, linkedDocuments);
                            if (creator.CheckExisting())
                            {
                                if (creator.CreateElevationByList())
                                {
                                    RoomElevationProperties roomProperties = new RoomElevationProperties(creator.RoomProperties);
                                    if (roomDictionary.ContainsKey(roomProperties.RoomId))
                                    {
                                        roomDictionary.Remove(roomProperties.RoomId);
                                    }
                                    roomDictionary.Add(roomProperties.RoomId, roomProperties);
                                }
                            }

                            value += 1;
                            Dispatcher.Invoke(updatePdDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, value });
                        }

                        statusLable.Text       = "Ready";
                        progressBar.Visibility = System.Windows.Visibility.Hidden;

                        treeViewRoom.ItemsSource = null;
                        treeViewRoom.ItemsSource = TreeviewModel.SetTreeView(roomDictionary, toolSettings.IsLinkedRoom);

                        if (LogMessageBuilder.GetLogMessages().Length > 0)
                        {
                            LogMessageBox logMessageBox = new LogMessageBox();
                            logMessageBox.Show();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to start creating elevation views by rooms lists.\n" + ex.Message, "Elevation Creator: CreateByRoomList", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }