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);
            }
        }
Esempio n. 2
0
 public LogMessageBox()
 {
     InitializeComponent();
     textBoxLog.Text = LogMessageBuilder.GetLogMessages();
 }