Ejemplo n.º 1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (null != TaskComboBox.SelectedValue && string.Empty != ((string)TaskComboBox.SelectedValue).Trim())
     {
         DayRegister.SortInactives();
         var list = DayRegister.InactiveControls.ToList();
         //list.Sort();
         var item = list.ElementAt(TaskComboBox.SelectedIndex);
         DayRegister.ActivateTask(item);
         this.Width            = 510;
         StopButton.Visibility = Visibility.Visible;
     }
 }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();
            this.Width            = 200;
            StopButton.Visibility = Visibility.Hidden;

            TaskComboBox.Visibility  = Visibility.Hidden;
            AddTaskButton.Visibility = Visibility.Hidden;

            /*
             * NewTaskClientNameTextBox.Visibility = Visibility.Hidden;
             * NewTaskNameTextBox.Visibility = Visibility.Hidden;
             * AddTaskByNameButton.Visibility = Visibility.Hidden;
             */
            TimersList.Visibility   = Visibility.Hidden;
            TimersScroll.Visibility = Visibility.Hidden;
            DayRegister.InactiveControls.CollectionChanged += (e, v) => ReloadComboBox();

            try
            {
                var tasks = ExcelHelper.GetTasks3(ProductProperties.InputFileName);
                timer.Interval = new TimeSpan(0, 0, 1);
                timer.Tick    += timer_Tick;
                timer.Start();


                foreach (var item in tasks)
                {
                    DayRegister.AddUnactiveTask(item[0], item[1], item[2], item[3], Convert.ToInt32(item[5]));
                }
            }
            catch (Exception ex)
            {
                Log.Fatal("Fatal error on loading tasks from excel\t" + ex.ToString());
                throw ex;
            }

            DayRegister.SortInactives();

            if (Helpers.ExcelHelper.DoFileExist(ProductProperties.LastSessionFileName))
            {
                try
                {
                    var lastSessionTasks = XMLHelper.ReadXML(Data.ProductProperties.LastSessionFileName);
                    foreach (var item in lastSessionTasks)
                    {
                        if (DayRegister.InactiveControls.Any(x => x.TaskName == item[0]))
                        {
                            DayRegister.ActivateTask(DayRegister.InactiveControls.Single(x => x.TaskName == item[0]));
                        }
                        else
                        {
                            var x = new TimeControl(item[0], item[1], item[2], item[3], Convert.ToInt32(item[4]));
                            DayRegister.InactiveControls.Add(x);
                            DayRegister.ActivateTask(x);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Fatal("Fatal error on loading last session from xml\t" + ex.ToString());
                    throw ex;
                }
            }

            foreach (var item in DayRegister.Controls)
            {
                item.Width = 0;
            }

            DayRegister.Controls.CollectionChanged += (e, v) => ReloadTimerList();
            DayRegister.Controls.CollectionChanged += (e, v) => ReloadComboBox();
            DayRegister.SortInactives();

            try
            {
                if (ExcelHelper.DoFileExist(ProductProperties.LastLoggedUserFile))
                {
                    UserNameTextBox.Text = XMLHelper.ReadXMLString(ProductProperties.LastLoggedUserFile);
                }
            }
            catch (Exception ex)
            {
                Log.Fatal("Fatal error on loading last logged user from xml\t" + ex.ToString());
                throw ex;
            }

            ReloadTimerList();
        }