Пример #1
0
        static public void Remove(ListBox LB, ComboBox CB_Art, ref clsTaskManager.stcTaskManagerEx TaskManagerEx)
        {
            clsTaskManager TaskManager = new clsTaskManager();
            int            i           = LB.SelectedIndex;

            if (i == -1)
            {
                return;
            }
            if (((clsMTask)(LB.Items[i])).Grp == 1) //Удаляем целый ивент
            {
                do
                {
                    LB.Items.RemoveAt(i);
                    if (i >= LB.Items.Count)
                    {
                        break;
                    }
                } while (((clsMTask)(LB.Items[i])).Grp == 2);
            }
            else
            {
                LB.Items.RemoveAt(i);  //Удаляем всего один допинг
            }
            UpdateInfo(LB, CB_Art, ref TaskManagerEx);
        }
Пример #2
0
        static public void Save(ListBox LB, ComboBox CB_Art, ref clsTaskManager.stcTaskManagerEx TaskManagerEx, string FPath)
        {
            while (LB.Items.Count != 0 && ((clsMTask)(LB.Items[0])).Grp == 2)
            {
                LB.Items.RemoveAt(0);                                                               //Удаляем пустые ивенты без типа
            }
            FileStream FS = new FileStream(FPath, FileMode.Create);

            clsTaskManager.XmlSerializer.Serialize(FS, UpdateInfo(LB, CB_Art, ref TaskManagerEx));
            FS.Close();
        }
Пример #3
0
        static private clsTaskManager UpdateInfo(ListBox LB, ComboBox CB_Art, ref clsTaskManager.stcTaskManagerEx TaskManagerEx)
        {
            clsTaskManager TaskManager = TaskManagerExToTaskManager(TaskManagerEx); //Создаём исходное положение

            for (int i = TaskManager.Arts.Count() - 1; i < CB_Art.SelectedIndex; i++)
            {
                Array.Resize(ref TaskManager.Arts, TaskManager.Arts.Count() + 1);
                TaskManager.Arts[TaskManager.Arts.Count() - 1] = new clsTManagerArt {
                    Tasks = new clsMTask[0]
                };
            }
            clsMTask[] Tasks = new clsMTask[LB.Items.Count]; //Временный массив для хранения данных
            LB.Items.CopyTo(Tasks, 0);                       //Переносим данные во временный массив
            TaskManager.Arts[CB_Art.SelectedIndex] = new clsTManagerArt {
                Tasks = Tasks
            };                                                       //Перезаписываю установленные таски

            TaskManagerEx = TaskManagerToTaskmanagerEx(TaskManager); //Обновляю список
            return(TaskManager);
        }
Пример #4
0
        static private clsTaskManager TaskManagerExToTaskManager(clsTaskManager.stcTaskManagerEx TaskManagerEx)
        {
            if (TaskManagerEx.Arts == null)
            {
                return new clsTaskManager {
                           Arts = new clsTManagerArt[0]
                }
            }
            ;
            clsMTask[]     Task;
            clsTaskManager TaskManager = new clsTaskManager {
                Arts = new clsTManagerArt[TaskManagerEx.Arts.Count()]
            };

            for (int i = 0; i < TaskManagerEx.Arts.Count(); i++)
            {
                Task = new clsMTask[0];
                for (int k = 0; k < TaskManagerEx.Arts[i].Tasks.Count(); k++)
                {
                    Array.Resize(ref Task, Task.Count() + 1);
                    Task[Task.Count() - 1]      = new clsMTask();
                    Task[Task.Count() - 1].Grp  = 1;
                    Task[Task.Count() - 1].Item = (int)TaskManagerEx.Arts[i].Tasks[k].DoW;
                    Task[Task.Count() - 1].Text = "* " + Regex.Replace(CultureInfo.CreateSpecificCulture("ru-RU").DateTimeFormat.GetDayName(TaskManagerEx.Arts[i].Tasks[k].DoW), "^[\\w]", m => m.Value.ToUpper());

                    for (int x = 0; x < TaskManagerEx.Arts[i].Tasks[k].StartTS.Count(); x++)
                    {
                        Array.Resize(ref Task, Task.Count() + 1);
                        Task[Task.Count() - 1]      = new clsMTask();
                        Task[Task.Count() - 1].Grp  = 2;
                        Task[Task.Count() - 1].Item = (int)(TaskManagerEx.Arts[i].Tasks[k].StartTS[x] == new TimeSpan() && TaskManagerEx.Arts[i].Tasks[k].StopTS[x] == new TimeSpan() ? clsTaskManager.TaskEvent.NotToday : clsTaskManager.TaskEvent.Time);
                        Task[Task.Count() - 1].Text = "- " + (Task[Task.Count() - 1].Item == 0 ? "Не ходить" : "Участвовать с " + TaskManagerEx.Arts[i].Tasks[k].StartTS[x].ToString("%h\\:%m") + " до " + TaskManagerEx.Arts[i].Tasks[k].StopTS[x].ToString("%h\\:%m"));
                    }
                }
                TaskManager.Arts[i] = new clsTManagerArt {
                    Tasks = Task
                };
            }
            return(TaskManager);
        }
Пример #5
0
        static private clsTaskManager.stcTaskManagerEx TaskManagerToTaskmanagerEx(clsTaskManager TaskManager)
        {
            clsTaskManager.stcTaskEx[]      TaskEx;
            clsTaskManager.stcTaskManagerEx TaskManagerEx = new clsTaskManager.stcTaskManagerEx {
                Arts = new clsTaskManager.stcArtsEx[TaskManager.Arts.Count()]
            };

            for (int i = 0; i < TaskManager.Arts.Count(); i++)
            {
                TaskEx = new clsTaskManager.stcTaskEx[0];
                for (int k = 0; k < TaskManager.Arts[i].Tasks.Count(); k++)
                {
                    switch (TaskManager.Arts[i].Tasks[k].Grp)
                    {
                    case 1:     //Event
                    {
                        Array.Resize(ref TaskEx, TaskEx.Count() + 1);
                        TaskEx[TaskEx.Count() - 1].DoW     = (DayOfWeek)TaskManager.Arts[i].Tasks[k].Item;
                        TaskEx[TaskEx.Count() - 1].StartTS = new TimeSpan[0];
                        TaskEx[TaskEx.Count() - 1].StopTS  = new TimeSpan[0];
                    }
                    break;

                    case 2:     //Item
                    {
                        Array.Resize <TimeSpan>(ref TaskEx[TaskEx.Count() - 1].StartTS, TaskEx[TaskEx.Count() - 1].StartTS.Count() + 1);
                        Array.Resize <TimeSpan>(ref TaskEx[TaskEx.Count() - 1].StopTS, TaskEx[TaskEx.Count() - 1].StopTS.Count() + 1);
                        Match match = Regex.Match(TaskManager.Arts[i].Tasks[k].Text, "Участвовать с (?<From>([0-9:])+) до (?<Till>([0-9:])+)");
                        TaskEx[TaskEx.Count() - 1].StartTS[TaskEx[TaskEx.Count() - 1].StartTS.Count() - 1] = (clsTaskManager.TaskEvent)TaskManager.Arts[i].Tasks[k].Item == clsTaskManager.TaskEvent.NotToday ? new TimeSpan() : TimeSpan.Parse(match.Groups["From"].Value);
                        TaskEx[TaskEx.Count() - 1].StopTS[TaskEx[TaskEx.Count() - 1].StopTS.Count() - 1]   = (clsTaskManager.TaskEvent)TaskManager.Arts[i].Tasks[k].Item == clsTaskManager.TaskEvent.NotToday ? new TimeSpan() : TimeSpan.Parse(match.Groups["Till"].Value);
                        break;
                    }
                    }
                }
                TaskManagerEx.Arts[i].Tasks = TaskEx;
            }
            return(TaskManagerEx);
        }
Пример #6
0
        static public bool Load(ListBox LB, ComboBox CB_Event, ComboBox CB_Item, ComboBox CB_Art, ref clsTaskManager.stcTaskManagerEx TaskManagerEx, string FPath)
        {
            bool bRet = true;

            if (File.Exists(FPath))
            {
                FileStream     FS          = new FileStream(FPath, FileMode.Open);
                clsTaskManager TaskManager = (clsTaskManager)clsTaskManager.XmlSerializer.Deserialize(FS);
                FS.Close();

                #region Стираю прошлые допинги перед обновлением списка (обязательно после выбора типа допингов)
                LB.Items.Clear();
                #endregion
                if (TaskManager.Arts.Count() >= CB_Art.SelectedIndex && TaskManager.Arts[CB_Art.SelectedIndex].Tasks != null) //Есть допинг?
                {
                    LB.Items.AddRange(TaskManager.Arts[CB_Art.SelectedIndex].Tasks);
                }
                TaskManagerEx = TaskManagerToTaskmanagerEx(TaskManager);
            }
            return(bRet);
        }