private void UpdateConnectorList(bool rebuild)
        {
            string prevSelectedID = ConnectorComboBox.ComboBox.SelectedValue as string;

            using (FlagManager.UseFlag("UpdateConnectorList"))
            {
                if (rebuild)
                {
                    Connections.Clear();
                }

                if (CurrentProject != null)
                {
                    var studConnectors = CurrentProject.GetAllElements <PartConnection>(x =>
                                                                                        x.ConnectorType == LDD.Primitives.Connectors.ConnectorType.Custom2DField);

                    if (rebuild)
                    {
                        Connections.AddRange(studConnectors);
                    }
                    else
                    {
                        Connections.SyncItems(studConnectors);
                    }
                }
            }

            string currentSelectedID = ConnectorComboBox.ComboBox.SelectedValue as string;

            if (prevSelectedID != currentSelectedID)
            {
                FillSelectedConnector(false);
            }
        }
Beispiel #2
0
        private void UpdateElementList(bool rebuild)
        {
            string prevSelectedID = ElementsComboBox.ComboBox.SelectedValue as string;

            using (FlagManager.UseFlag(nameof(UpdateElementList)))
            {
                if (rebuild || CurrentProject == null)
                {
                    Connections.Clear();
                }

                if (CurrentProject != null)
                {
                    var studConnectors = CurrentProject.GetAllElements <PartConnection>();

                    if (rebuild)
                    {
                        Connections.AddRange(studConnectors);
                    }
                    else
                    {
                        Connections.SyncItems(studConnectors);
                    }
                }
            }

            string currentSelectedID = ElementsComboBox.ComboBox.SelectedValue as string;

            if (prevSelectedID != currentSelectedID)
            {
                SetCurrentObject(ElementsComboBox.SelectedItem as PartConnection, false);
            }
        }
Beispiel #3
0
        private void UpdateStudConnectorList()
        {
            if (CurrentProject == null)
            {
                ConnectorList.Clear();
            }
            else
            {
                var studConnections = CurrentProject.GetAllElements <PartConnection>()
                                      .Where(x => x.ConnectorType == ConnectorType.Custom2DField).ToList();

                foreach (var studConn in studConnections)
                {
                    if (string.IsNullOrEmpty(studConn.ID))
                    {
                        continue;
                    }

                    var comboItem = ConnectorList.FirstOrDefault(x => x.ID == studConn.ID);
                    if (comboItem == null)
                    {
                        comboItem = new ConnectorComboItem(studConn);
                        comboItem.ConnTypeText = studConn.SubType == 22 ? BottomStudsLabel.Text : TopStudsLabel.Text;
                        ConnectorList.Add(comboItem);
                    }
                }

                var validConnectionIDs = studConnections.Select(x => x.ID).ToList();
                var usedConnectionIDs  = CurrentProject.GetAllElements <StudReference>()
                                         .Select(x => x.ConnectionID).Distinct().ToList();

                foreach (var comboItem in ConnectorList.ToArray())
                {
                    if (!validConnectionIDs.Contains(comboItem.ID) &&
                        !usedConnectionIDs.Contains(comboItem.ID))
                    {
                        ConnectorList.Remove(comboItem);
                    }
                }
            }
        }