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 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 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();
            }
        }