Пример #1
0
        private void TextBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            TextBox  tb = (TextBox)sender;
            BoltUnit ci = (BoltUnit)tb.DataContext;

            this_dc.SelectedUnit = ci;
        }
Пример #2
0
        //Код для автоматического перехода на нужную строку в списке
        private void ComboBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            ComboBox cb = (ComboBox)sender;
            BoltUnit ci = (BoltUnit)cb.DataContext;

            this_dc.SelectedUnit = ci;
        }
Пример #3
0
 public void CopyItem()
 {
     if (SelectedUnit != null)
     {
         BoltUnit unit = (BoltUnit)SelectedUnit.Clone();
         unit.Number = UnitList.Count + 1;
         UnitList.Add(unit);
         SelectedUnit = unit;
     }
 }
Пример #4
0
        //Кнопки управления списком
        public void AddItem()
        {
            BoltUnit unit = new BoltUnit(BaseSet);

            unit.Number             = UnitList.Count + 1;
            unit.ConnectionTypes    = ConnectionTypes;
            unit.SelectedItemGammaC = ListGammaC[0];
            UnitList.Add(unit);
            SelectedUnit = unit;
        }
Пример #5
0
 public void ItemDown()
 {
     if (SelectedUnit != null)
     {
         int selectedIndex = UnitList.IndexOf(SelectedUnit);
         if (selectedIndex < UnitList.Count - 1)
         {
             BoltUnit tempItem = UnitList[selectedIndex];
             UnitList[selectedIndex]             = UnitList[selectedIndex + 1];
             UnitList[selectedIndex].Number     -= 1;
             UnitList[selectedIndex + 1]         = tempItem;
             UnitList[selectedIndex + 1].Number += 1;
             SelectedUnit = UnitList[selectedIndex + 1];
         }
     }
 }
Пример #6
0
 public void ItemUp()
 {
     if (SelectedUnit != null)
     {
         int selectedIndex = UnitList.IndexOf(SelectedUnit);
         if (selectedIndex > 0)
         {
             BoltUnit tempItem = UnitList[selectedIndex];
             UnitList[selectedIndex]             = UnitList[selectedIndex - 1];
             UnitList[selectedIndex].Number     += 1;
             UnitList[selectedIndex - 1]         = tempItem;
             UnitList[selectedIndex - 1].Number -= 1;
             SelectedUnit = UnitList[selectedIndex - 1];
         }
     }
 }
Пример #7
0
 public void RemoveItem()
 {
     if (SelectedUnit != null)
     {
         int selectedIndex = UnitList.IndexOf(SelectedUnit);
         UnitList.Remove(SelectedUnit);
         if (UnitList.Count >= selectedIndex + 1)
         {
             SelectedUnit = UnitList[selectedIndex];
             for (int i = selectedIndex; i < UnitList.Count; i++)
             {
                 UnitList[i].Number = i + 1;
             }
         }
         else if (UnitList.Count > 0)
         {
             SelectedUnit = UnitList[selectedIndex - 1];
         }
     }
 }
Пример #8
0
        //Код для поддержки копирования:
        public object Clone()
        {
            BoltUnit bu = (BoltUnit)this.MemberwiseClone();

            bu.BoltList          = new ObservableCollection <Bolt>(this.BoltList);
            bu.StrengthClassList = new ObservableCollection <StrengthClass>(this.StrengthClassList);
            bu.StandartList      = new ObservableCollection <string>(this.StandartList);
            bu.KitList           = new ObservableCollection <Kit>(KitList);
            bu.calc_list         = new List <ICalculation>();
            for (int i = 0; i < calc_list.Count; i++)
            {
                ICalculation calc = (ICalculation)calc_list[i].Clone();
                calc.ResultChangedEvent -= this.UpdateResultHandler;
                calc.ResultChangedEvent += bu.UpdateResultHandler;
                bu.calc_list.Add(calc);
            }
            bu.MyCalculation = bu.calc_list[calc_list.IndexOf(MyCalculation)];

            return(bu);
        }
Пример #9
0
 //Конструктор
 public MainWindowModel()
 {
     BaseSet = new DataSet[3];
     TablesLoad();
     ListGammaC = new ObservableCollection <ItemGammaC>();
     RefreshListGammaC();
     ConnectionTypes = new ObservableCollection <ConnectionType>()
     {
         new ConnectionType()
         {
             Name = "На срез", Description = "Соединение без контроллируемого натяжения болтов. Внешние усилия воспринимаются вследствие сопротивления болтов срезу и соединяемых элементов смятию."
         },
         new ConnectionType()
         {
             Name = "На растяжение", Description = "Соединение, в котором болты работают на растяжение (кроме фланцевых на высокопрочных болтах)"
         }
     };
     UnitList = new ObservableCollection <BoltUnit>();
     for (int i = 0; i < 1; i++)
     {
         AddItem();
     }
     SelectedUnit = UnitList[0];
 }