//private string _longText;
        //public string LongText
        //{
        //    get { return _longText; }
        //    set
        //    {
        //        _longText = value;
        //        OnPropertyChanged();
        //    }
        //}

        public PDSVHipWay GetPanelType()
        {
            var newType = new PDSVHipWay();

            //newType.LongName = LongText;
            newType.Name = ShortText;
            return(newType);
        }
示例#2
0
        public void Initialize()
        {
            TextOFNewType = "Новый ПДСВ ход";
            MessageBus.Default.Subscribe("RebuildFirstPDSV", RebuildFirst);
            MessageBus.Default.Subscribe("RebuildLegSectionViewModel", Rebuild);
            CurrentPanelViewModelWaySelect = new PDSVVayTypePanelViewModel(this);
            OpenAddtWayCommand             = new DelegateCommand(() =>
            {
                ((PDSVVayTypePanelViewModel)CurrentPanelViewModelWaySelect).ClearPanel();
                ((PDSVVayTypePanelViewModel)CurrentPanelViewModelWaySelect).PanelOpened = true;
            });

            SavetWayCommand = new DelegateCommand(() =>
            {
                var newType = ((PDSVVayTypePanelViewModel)CurrentPanelViewModelWaySelect).GetPanelType();
                if (!string.IsNullOrWhiteSpace(newType.Name))
                {
                    ((PDSVVayTypePanelViewModel)CurrentPanelViewModelWaySelect).PanelOpened = false;

                    //Handled = false;

                    Data.PDSVHipWay.Add((newType));

                    Data.Complete();
                    PanelOpened           = true;
                    var DataSourceListbuf = PDSVWayType;
                    PDSVWayType           = new ObservableCollection <PDSVHipWay>();

                    foreach (var Scintific in Data.PDSVHipWay.GetAll)
                    {
                        PDSVWayType.Add(Scintific);
                    }

                    PDSVHipWay emptyWay1 = new PDSVHipWay();
                    emptyWay1.Name       = "";
                    PDSVWayType.Add(emptyWay1);
                    SelectedPDSVWayTypeId = PDSVWayType.IndexOf(newType);
                    // Controller.NavigateTo<BPVHipViewModel>();

                    PanelOpened = false;
                }
                else
                {
                    MessageBox.Show("Не все поля заполнены");
                }
            });
            RevertWayCommand = new DelegateCommand(() =>
            {
                ((PDSVVayTypePanelViewModel)CurrentPanelViewModelWaySelect).PanelOpened = false;
                PanelOpened = false;
            });
            SavePanelCommand = new DelegateCommand(() =>
            {
                var panel = CurrentPanelViewModel;
                if (!string.IsNullOrWhiteSpace(panel.Text1) || !string.IsNullOrWhiteSpace(panel.Text2))
                {
                    CurrentLegSide = CurrentLegSide;
                    if (IsStructEdited(CurrentPanelViewModel.LegPrt))
                    {
                        if ((LevelSelected != 0 && testOnUnique(CurrentPanelViewModel.LegPrt)) || (LevelSelected == 0 && testAdditionalStructOnUnique(CurrentPanelViewModel.LegPrt)))
                        {
                            var newStruct    = GetPanelStructure();
                            newStruct.Custom = false;
                            Data.PDSVHips.Add((PDSVHipStructure)newStruct);
                            Data.Complete();
                            _lastSender.StructureSource.Add(newStruct);
                            _lastSender.SelectedValue         = newStruct;
                            CurrentPanelViewModel.PanelOpened = false;
                            handled = false;
                        }
                    }
                    if (!IsStructEdited(CurrentPanelViewModel.LegPrt))
                    {
                        CurrentPanelViewModel.PanelOpened = false;
                        handled = false;
                    }
                }
                else
                {
                    MessageBox.Show("Не все поля заполнены");
                }

                //_lastSender.DeleteCustom();
            });
            SaveCommand = new DelegateCommand(
                () =>
            {
                if (LegSections[0].SelectedValue != null)
                {
                    bool isValid = Validate();
                    if (isValid)
                    {
                        IsEmpty = false;

                        List <int?> ids = new List <int?>();

                        foreach (var leg in LegSections)
                        {
                            //никогда так не делайте
                            if (leg.IsVisible == Visibility.Visible && leg.ListNumber != 1 && leg.SelectedValue != null && leg.SelectedValue.Id != 0)
                            {
                                ids.Add(leg.SelectedValue.Id);
                            }
                        }

                        var combo = Data.PDSVCombos.FindCombo(LegSections[0].SelectedValue.Id, ids);
                        //если комбо не нашлось - значит оно кастомное, мы его запомним и отправим в базу на радость будущим пользователям
                        if (combo == null)
                        {
                            var newCombo = new PDSVHipCombo();

                            commentSave = Comment; for (int i = 0; i < LegSections.Count; i++)
                            {
                                var currentStructure = LegSections[i].SelectedValue;
                                //ничего не было выбрано
                                if (currentStructure == null)
                                {
                                    continue;
                                }
                                //добавляем структуры, которые встретились впервые, чтобы потом добавить комбо
                                if (currentStructure.Id == 0
                                    //потому что переход к след.разделу в комбо добавлять не надо, это излишняя информация
                                    && !currentStructure.ToNextPart)
                                {
                                    //currentStructure.Level = i + 1;
                                    //Data.PDSVHips.Add((PDSVHipStructure)currentStructure);
                                    //Data.Complete();
                                    //((PDSVHipEntry)LegSections[i].CurrentEntry).Structure = (PDSVHipStructure)currentStructure;
                                    //(LegSections[i].CurrentEntry).StructureID = currentStructure.Id;
                                    //Data.PDSVHipEntries.Add((PDSVHipEntry)LegSections[i].CurrentEntry);
                                    //Data.Complete();
                                    //if (i == 0) newCombo.IdStr1 = currentStructure.Id;
                                    ////там гда раньше был ноль теперь будет актуальный айдишник
                                    //else ids[i - 2] = currentStructure.Id;
                                }
                            }

                            newCombo.IdStr1 = LegSections[0].SelectedValue.Id;
                            //заполняем комбо
                            Data.PDSVCombos.AddCombo(newCombo, ids);
                            Data.Complete();
                            MessageBus.Default.Call("RebuildFirstPDSV", this, LegSections[0]);
                            MessageBus.Default.Call("RebuildLegSectionViewModel", this, LegSections[0]);
                            MessageBus.Default.Call("RebuildLegSectionViewModel", this, LegSections[1]);
                            MessageBus.Default.Call("RebuildLegSectionViewModel", this, LegSections[2]);
                        }
                        MessageBus.Default.Call("LegDataSaved", this, this.GetType());
                        Controller.NavigateTo <ViewModelAddPhysical>();
                    }
                }
                else
                {
                    MessageBus.Default.Call("LegDataSaved", this, this.GetType());
                    Controller.NavigateTo <ViewModelAddPhysical>();
                }
            }
                );
            PDSVWayType = new ObservableCollection <PDSVHipWay>();
            foreach (var way in Data.PDSVHipWay.GetAll)
            {
                PDSVWayType.Add(way);
            }
            PDSVHipWay emptyWay = new PDSVHipWay();

            emptyWay.Name = "";
            PDSVWayType.Add(emptyWay);

            LevelCount          = 3;
            _sections           = new ObservableCollection <LegSectionViewModel>();
            AdditionalStructure = new PDSVAdditionalSectionViewModel(Controller, null, 0);
            for (int i = 0; i < LevelCount; i++)
            {
                if (i != 0)
                {
                    LegSections.Add(new PDSVSectionViewModel(Controller, _sections[i - 1], i + 1));
                }
                else
                {
                    LegSections.Add(new PDSVSectionViewModel(Controller, null, i + 1));
                }
            }
            _title = "Передняя добавочная сафенная вена";
        }
示例#3
0
        private void RebuildFirst(object sender, object data)
        {
            if (((LegPartViewModel)Controller.CurrentViewModel.Controller.LegViewModel).CurrentLegSide != this.CurrentLegSide)
            {
                return;
            }
            var   bufSaveLegSection           = new List <int?>();
            float savedValue                  = -1;
            int   bufSaveLegAdditionalSection = -1;

            if (AdditionalStructure.SelectedValue != null)
            {
                bufSaveLegAdditionalSection = AdditionalStructure.SelectedValue.Id;
                if (AdditionalStructure.CurrentEntry != null)
                {
                    savedValue = AdditionalStructure.CurrentEntry.Size;
                }
            }
            AdditionalStructure = new PDSVAdditionalSectionViewModel(Controller, null, 0);
            if (bufSaveLegAdditionalSection != -1)
            {
                for (int j = 0; j < AdditionalStructure.StructureSource.Count; ++j)
                {
                    if (AdditionalStructure.StructureSource[j].Id == bufSaveLegAdditionalSection && AdditionalStructure.StructureSource[j].Text1 != "Свой вариант ответа")
                    {
                        bufSaveLegAdditionalSection = j;
                        break;
                    }
                }

                //   if (bufSaveLegAdditionalSection != -1)
                AdditionalStructure.SelectedValue = AdditionalStructure.StructureSource[bufSaveLegAdditionalSection];
                if (savedValue != -1)
                {
                    AdditionalStructure.CurrentEntry.Size = savedValue;
                }
            }
            foreach (var x in LegSections)
            {
                if (x.SelectedValue != null)
                {
                    bufSaveLegSection.Add(x.SelectedValue.Id);
                }
                else
                {
                    bufSaveLegSection.Add(null);
                }
            }

            for (int i = 0; i < LegSections.Count; ++i)
            {
                var bufSave = new ObservableCollection <LegPartDbStructure>();
                bufSave = LegSections[i].StructureSource;

                LegSections[i].StructureSource = new ObservableCollection <LegPartDbStructure>(Data.PDSVHips.LevelStructures(i + 1).ToList());

                int selectedIndex = -1;
                if (bufSaveLegSection[i] != null)
                {
                    for (int j = 0; j < LegSections[i].StructureSource.Count; ++j)
                    {
                        if (LegSections[i].StructureSource[j].Id == bufSaveLegSection[i])
                        {
                            selectedIndex = j;
                        }
                    }
                }



                if (selectedIndex != -1)
                {
                    LegSections[i].SelectedValue = LegSections[i].StructureSource[selectedIndex];
                }


                foreach (var variant in bufSave)
                {
                    if (variant.Text1 == "Свой вариант ответа" || variant.Text1 == "Переход к следующему разделу")
                    {
                        if (variant.Text1 == "Переход к следующему разделу" && i == 0)
                        {
                        }
                        else
                        {
                            LegSections[i].StructureSource.Add(variant);
                        }
                    }
                    else if (variant.Text1 == "" && variant.Text2 == "")
                    {
                        LegSections[i].StructureSource.Add(variant);
                    }
                }
                foreach (var structure in LegSections[i].StructureSource)
                {
                    structure.Metrics = Data.Metrics.GetStr(structure.Size);
                }
            }

            MessageBus.Default.Call("LegDataSaved", this, this.GetType());
            FF_lengthSave       = FF_length;
            SelectedWayTypeSave = SelectedWayType;
            LegSectionsSaved    = new List <LegSectionViewModel>();
            for (int i = 0; i < LevelCount; i++)
            {
                if (i != 0)
                {
                    LegSectionsSaved.Add(new PDSVSectionViewModel(Controller, _sections[i - 1], i + 1));
                }
                else
                {
                    LegSectionsSaved.Add(new PDSVSectionViewModel(Controller, null, i + 1));
                }
            }

            commentSave = Comment; for (int i = 0; i < LegSections.Count; i++)
            {
                LegSectionsSaved[i].Comment       = LegSections[i].Comment;
                LegSectionsSaved[i].Size          = LegSections[i].Size;
                LegSectionsSaved[i].Size2         = LegSections[i].Size2;
                LegSectionsSaved[i].Text1         = LegSections[i].Text1;
                LegSectionsSaved[i].Text2         = LegSections[i].Text2;
                LegSectionsSaved[i].SelectedValue = LegSections[i].SelectedValue;
                LegSectionsSaved[i].CurrentEntry  = LegSections[i].CurrentEntry;
            }
            PDSVWayType = new ObservableCollection <PDSVHipWay>();

            foreach (var Scintific in Data.PDSVHipWay.GetAll)
            {
                PDSVWayType.Add(Scintific);
            }

            PDSVHipWay emptyWay = new PDSVHipWay();

            emptyWay.Name = "";
            PDSVWayType.Add(emptyWay);
            SelectedWayType = SelectedWayTypeSave;
        }