public void AddEventToFolder(EventUC eventUC)
        {
            Cursor = Cursors.Wait;

            if (!DoImport(eventUC, false))
            {
                Cursor = Cursors.Arrow;
                return;
            }

            double _h = eventUC.ActualHeight / 10;

            for (int i = 10; i > 0; i--)
            {
                eventUC.Height = i * _h;
                DoEvents();
                Thread.Sleep(50);
            }

            VideosCount -= eventUC.VideosCount;
            PhotosCount -= eventUC.PhotosCount;

            Rt.RemoveFileChanges(eventUC.Event);

            m_eventUCs.Remove(eventUC);

            ShowInfor();

            m_currentDevice.Refresh();

            Cursor = Cursors.Arrow;
        }
        private void ShowEvents()
        {
            Cursor = Cursors.Wait;

            m_defaultEventNameCache = new List <string>();

            PhotosCount = 0;
            VideosCount = 0;

            m_eventUCs = new ObservableCollection <EventUC>();
            listBoxEvent.ItemsSource = m_eventUCs;

            GroupingEventInterval = m_sliderTicks.ToArray()[(int)sliderEvent.Value].Value;
            Rt.GroupingByEvent(GroupingEventInterval);

            Rt.Events.Reverse();

            foreach (List <FileChange> _event in Rt.Events)
            {
                EventUC _ctl = new EventUC
                {
                    Event = _event
                };

                _ctl.SetUI();

                PhotosCount += _ctl.PhotosCount;
                VideosCount += _ctl.VideosCount;

                _ctl.DescribeText = GetDefaultEventName(Rt.DateTimeCache[_event[0].taken_time]);

                m_eventUCs.Add(_ctl);
            }

            DoEvents();

            DataTemplate _dataTemplate = FindResource("SbPreviewTemplate") as DataTemplate;

            listBoxEvent.SetValue(ScrollingPreviewService.VerticalScrollingPreviewTemplateProperty, _dataTemplate);

            ShowInfor();

            GC.Collect();

            SetEventIntervalTypeText();
        }
        private bool DoImport(EventUC eventUC, bool all)
        {
            Cursor = Cursors.Wait;

            m_dispatcherTimer.Stop();

            sliderEvent.IsEnabled = false;

            PendingSort _pendingSort = new PendingSort
            {
                device_id = m_currentDevice.ID
            };

            if (all)
            {
                foreach (EventUC _item in listBoxEvent.Items)
                {
                    Event _event = new Event
                    {
                        type       = 1,
                        title      = _item.DescribeText,
                        time_start = Rt.DateTimeCache[_item.Event[0].taken_time].ToString("yyyy-MM-dd HH:mm:ss"),
                        time_end   = Rt.DateTimeCache[_item.Event[_item.Event.Count - 1].taken_time].ToString("yyyy-MM-dd HH:mm:ss")
                    };

                    foreach (FileChange _fileChange in _item.Event)
                    {
                        _event.files.Add(_fileChange.id);
                    }

                    _pendingSort.events.Add(_event);
                }
            }
            else
            {
                Event _event = new Event
                {
                    type       = 1,
                    title      = eventUC.DescribeText,
                    time_start = Rt.DateTimeCache[eventUC.Event[0].taken_time].ToString("yyyy-MM-dd HH:mm:ss"),
                    time_end   = Rt.DateTimeCache[eventUC.Event[eventUC.Event.Count - 1].taken_time].ToString("yyyy-MM-dd HH:mm:ss")
                };

                foreach (FileChange _fileChange in eventUC.Event)
                {
                    _event.files.Add(_fileChange.id);
                }

                _pendingSort.events.Add(_event);
            }

            string _how = string.Empty;

            try
            {
                _how = JsonConvert.SerializeObject(_pendingSort);
            }
            catch
            {
                return(false);
            }

            try
            {
                string _url = "http://127.0.0.1:14005" + "/pending/sort";

                string _parms = "how" + "=" + HttpUtility.UrlEncode(_how);

                WebPostHelper _webPos = new WebPostHelper();
                bool          _isOK   = _webPos.doPost(_url, _parms, null, 10000);

                if (!_isOK)
                {
                    return(false);
                }

                _webPos.getContent();
            }
            catch
            {
            }

            sliderEvent.IsEnabled = true;

            m_dispatcherTimer.Start();

            Cursor = Cursors.Arrow;

            return(true);
        }