private void CmbCycleItems_Loaded(object sender, RoutedEventArgs e)
 {
     CurrentItem      = ExpProgram.CycleItems[CmbCycleItems.SelectedIndex];
     TxtDuration.Text = CurrentItem.CycleDuration.ToString();
     TxtOnTime.Text   = CurrentItem.OnTime.ToString();
     TxtOffTime.Text  = CurrentItem.OffTime.ToString();
 }
 private void CmbCycleItems_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if ((CmbCycleItems.SelectedIndex >= 0) && (CmbCycleItems.SelectedIndex <= ExpProgram.Count()))
     {
         CurrentItem      = ExpProgram.CycleItems[CmbCycleItems.SelectedIndex];
         TxtDuration.Text = CurrentItem.CycleDuration.ToString();
         TxtOnTime.Text   = CurrentItem.OnTime.ToString();
         TxtOffTime.Text  = CurrentItem.OffTime.ToString();
     }
 }
 private void BtnAdd_Click(object sender, RoutedEventArgs e)
 {
     if (ExpProgram.CycleItems.Count < 10)
     {
         ExpProgram.CycleItems.Add(new CycleItem(5, 5, 60));
         CmbCycleItems.Items.Add(String.Format($"Step {(ExpProgram.Count() - 1).ToString()}"));
         CmbCycleItems.SelectedIndex = ExpProgram.Count() - 1;
         CurrentItem = ExpProgram.CycleItems[ExpProgram.Count() - 1];
         ShowData();
     }
 }
Пример #4
0
        public virtual void BindingShouldSuppressCycle()
        {
            var cycleItem1  = new CycleItem();
            var cycleItem2  = new CycleItem();
            var dataBinding = CreateDataBinding(
                new BindingSourceAccessor(new SinglePathObserver(cycleItem1, new BindingPath("Property"), true, false, true, false),
                                          DataContext.Empty, true),
                new BindingSourceAccessor(new SinglePathObserver(cycleItem2, new BindingPath("Property"), true, false, true, false),
                                          DataContext.Empty, false));

            dataBinding.Behaviors.Add(new TwoWayBindingMode());
            cycleItem2.Property = 10;

            Tracer.Warn("Item1: {0}, Item2: {1}", cycleItem1.Property, cycleItem2.Property);
        }
 private void BtnRemove_Click(object sender, RoutedEventArgs e)
 {
     if (ExpProgram.CycleItems.Count > 1)
     {
         ExpProgram.CycleItems.Remove(CurrentItem);
         CmbCycleItems.Items.Remove(CmbCycleItems.SelectedItem);
         for (int i = 0; i < ExpProgram.Count(); i++)
         {
             CmbCycleItems.Items[i] = "Step " + i.ToString();
         }
         CurrentItem = ExpProgram.CycleItems[ExpProgram.Count() - 1];
         CmbCycleItems.SelectedItem = CmbCycleItems.Items[ExpProgram.Count() - 1];
         ShowData();
     }
 }
        private void CycleInitialisation(ref Cycle InitialProgram)
        {
            String[] args = App.Args;
            if (args == null)
            {
                InitialProgram.CycleNumber = 1;

                InitialProgram.CycleItems.Add(new CycleItem(5, 5, 60));

                TxtCycleNumber.Text = InitialProgram.CycleNumber.ToString();
                CmbCycleItems.Items.Clear();
                for (int i = 0; i < InitialProgram.Count(); i++)
                {
                    CmbCycleItems.Items.Add(String.Format($"Step {i}"));
                }
                CmbCycleItems.SelectedIndex = 0;
                ShowData();
            }
            else
            {
                try
                {
                    ExpProgram  = Cycle.Load(args[0]);
                    CurrentItem = ExpProgram.CycleItems[0];
                    CmbCycleItems.Items.Clear();
                    for (int i = 0; i < ExpProgram.Count(); i++)
                    {
                        CmbCycleItems.Items.Add(String.Format($"Step {i}"));
                    }
                    CmbCycleItems.SelectedIndex = 0;
                    TxtCycleNumber.Text         = ExpProgram.CycleNumber.ToString();
                    TxtDuration.Text            = CurrentItem.CycleDuration.ToString();
                    TxtOnTime.Text  = CurrentItem.OnTime.ToString();
                    TxtOffTime.Text = CurrentItem.OffTime.ToString();
                    ShowData();
                }
                catch
                {
                    MessageBox.Show("File load error");
                    App.Args = null;
                    CycleInitialisation(ref InitialProgram);
                }
            }
        }
        private void MenuNew_Click(object sender, RoutedEventArgs e)
        {
            ExpProgram = new Cycle();
            // CycleInitialisation(ref ExpProgram);
            ExpProgram.CycleNumber = 1;

            ExpProgram.CycleItems.Add(new CycleItem(5, 5, 60));

            CurrentItem = ExpProgram.CycleItems[0];

            TxtCycleNumber.Text = ExpProgram.CycleNumber.ToString();
            CmbCycleItems.Items.Clear();
            for (int i = 0; i < ExpProgram.Count(); i++)
            {
                CmbCycleItems.Items.Add(String.Format($"Step {i}"));
            }
            CmbCycleItems.SelectedIndex = 0;
            ShowData();
        }
        private void MenuOpen_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ExpOpen = new OpenFileDialog();

            ExpOpen.Filter = "Experiment files(*exprmnt)|*.exprmnt";
            if (ExpOpen.ShowDialog() == true)
            {
                ExpProgram  = Cycle.Load(ExpOpen.FileName);
                CurrentItem = ExpProgram.CycleItems[0];
                CmbCycleItems.Items.Clear();
                for (int i = 0; i < ExpProgram.Count(); i++)
                {
                    CmbCycleItems.Items.Add(String.Format($"Step {i}"));
                }
                CmbCycleItems.SelectedIndex = 0;
                TxtCycleNumber.Text         = ExpProgram.CycleNumber.ToString();
                TxtDuration.Text            = CurrentItem.CycleDuration.ToString();
                TxtOnTime.Text  = CurrentItem.OnTime.ToString();
                TxtOffTime.Text = CurrentItem.OffTime.ToString();
                ShowData();
            }
        }
        public virtual void BindingShouldSuppressCycle()
        {
            var cycleItem1 = new CycleItem();
            var cycleItem2 = new CycleItem();
            var dataBinding = CreateDataBinding(
                new BindingSourceAccessor(
                    new BindingSource(new SinglePathObserver(cycleItem1, BindingPath.Create("Property"), true)),
                    DataContext.Empty, true),
                new BindingSourceAccessor(
                    new BindingSource(new SinglePathObserver(cycleItem2, BindingPath.Create("Property"), true)),
                    DataContext.Empty, false));
            dataBinding.Behaviors.Add(new TwoWayBindingMode());
            cycleItem2.Property = 10;

            Tracer.Warn("Item1: {0}, Item2: {1}", cycleItem1.Property, cycleItem2.Property);
        }