private void ShowEdgeEnd(EdgeEndControl window, string type)
        {
            if (window == null)
            {
                MessageBox.Show($"{type} node family is not defined", "Error",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            window.Show();
        }
        public void FromEdgeFamily(EdgeFamily edgeFamily)
        {
            IdentifierPartRangeControl.FromRanges(edgeFamily.Ranges);
            validationTemplateBox.Text = edgeFamily.ValidationTemplate;
            FamilyName.Text            = edgeFamily.Name;

            SetNodeFamilies(edgeFamily.Target.NodeFamilyName, edgeFamily.Source.NodeFamilyName);
            _targetWindow = new EdgeEndControl(edgeFamily.Target);
            _sourceWindow = new EdgeEndControl(edgeFamily.Source);
            _targetWindow.EdgeEndIdParts.ForEach(x => Debug.WriteLine($"{x.IdPart}, {x.Template}"));

            var windows = new List <Window>();

            foreach (var conditionalProperty in edgeFamily.ConditionalProperties)
            {
                var window = new EdgeConditionalPropertyWindow();
                window.FromConditionalProperty(conditionalProperty);
                windows.Add(window);
            }

            PropertiesControl.SetNewWindows(windows);
        }
        public void SetRadioButtons(List <NodeFamilyWindow> nodeFamilyWindows)
        {
            foreach (var nodeWindow in nodeFamilyWindows)
            {
                var nodeName = nodeWindow.FamilyName.Text;
                if (_nodesToButtons.ContainsKey(nodeWindow))
                {
                    continue;
                }

                var targetRadioButton = new RadioButton {
                    Content = nodeName, GroupName = $"TargetNodes{GetHashCode()}"
                };
                targetRadioButton.Checked += (sender, args) =>
                {
                    _targetWindow =
                        new EdgeEndControl(
                            nodeWindow.IdentifierPartRangeControl.Ranges
                            .Where(id => !IsNullOrEmpty(id.Name)).Select(id => id.Name).ToList(), nodeName);
                };

                TargetPanel.Children.Add(targetRadioButton);
                var sourceRadioButton = new RadioButton {
                    Content = nodeName, GroupName = $"SourceNodes{GetHashCode()}"
                };
                sourceRadioButton.Checked += (sender, args) =>
                                             _sourceWindow =
                    new EdgeEndControl(
                        nodeWindow.IdentifierPartRangeControl.Ranges.Where(id => !IsNullOrEmpty(id.Name))
                        .Select(id => id.Name).ToList(), nodeName);

                nodeWindow.ok.Click += (sender, args) =>
                {
                    sourceRadioButton.Content = nodeWindow.FamilyName.Text;
                    targetRadioButton.Content = nodeWindow.FamilyName.Text;
                };

                SourcePanel.Children.Add(sourceRadioButton);
                _nodesToButtons.Add(nodeWindow,
                                    new Tuple <RadioButton, RadioButton>(targetRadioButton, sourceRadioButton));
            }

            var keysToRemove = _nodesToButtons.Keys.Where(w => !nodeFamilyWindows.Contains(w)).ToList();

            keysToRemove.ForEach(w =>
            {
                var targetRadioButton = _nodesToButtons[w].Item1;
                var sourceRadioButton = _nodesToButtons[w].Item2;
                if (targetRadioButton.IsChecked == true)
                {
                    _targetWindow = null;
                }

                if (sourceRadioButton.IsChecked == true)
                {
                    _sourceWindow = null;
                }
                TargetPanel.Children.Remove(targetRadioButton);
                SourcePanel.Children.Remove(sourceRadioButton);
                _nodesToButtons.Remove(w);
            });
        }