예제 #1
0
        /// <summary>
        /// Gets the calendars.
        /// </summary>
        /// <returns>List view model</returns>
        public virtual IList <EventCalendarViewModel> GetCalendars(IEventsFilter filter)
        {
            this.UICulture = filter.UICulture;
            var viewModel         = this.CreateListViewModel(null, 1);
            var manager           = (EventsManager)this.GetManager();
            var eventCalendarsIds = viewModel.Items.Select(i => i.DataItem as Event).Where(p => p != null)
                                    .GroupBy(p => p.Parent.Id).Select(p => p.Key);

            var eventCalendars = manager.GetCalendars().Where(p => eventCalendarsIds.Contains(p.Id));
            var calendars      = eventCalendars.Select(e => new EventCalendarViewModel(e, this.UICulture)).OrderBy(p => p.Title, StringComparer.Create(this.UICulture, true));

            return(calendars.ToList());
        }
예제 #2
0
        /// <summary>
        /// Gets the scheduler events.
        /// </summary>
        /// <returns>List view model</returns>
        public virtual IList <EventOccurrenceViewModel> GetEvents(IEventsFilter filter)
        {
            this.UICulture = filter.UICulture;
            var viewModel = this.CreateListViewModel(null, 1);
            var events    = viewModel.Items.Select(i => i.DataItem as Event);

            if (filter.CalendarList != null && filter.CalendarList.Length > 0)
            {
                events = events.Where(p => p.Parent != null && filter.CalendarList.Contains(p.Parent.Id));
            }

            var manager = (EventsManager)this.GetManager();

            // get event occurrences based on widget selected view
            var allOccurrences = manager.GetEventsOccurrences(events, filter.StartDate, filter.EndDate.AddDays(1)).AsQueryable <EventOccurrence>();

            // get filter expression used for events
            string filterExpression = this.CompileEventsOccurrencesFilterExpression();

            if (!string.IsNullOrWhiteSpace(filterExpression))
            {
                var eventEnd        = this.GetPropertyInfo <Event>(e => e.EventEnd);
                var occurrenceEnd   = this.GetPropertyInfo <EventOccurrence>(eo => eo.EndDate);
                var eventStart      = this.GetPropertyInfo <Event>(e => e.EventStart);
                var occurrenceStart = this.GetPropertyInfo <EventOccurrence>(eo => eo.StartDate);

                // replace Event properties with EventOccurrence properties in filter expression
                filterExpression = filterExpression.Replace(eventEnd.Name, occurrenceEnd.Name).Replace(eventStart.Name, occurrenceStart.Name);

                allOccurrences = allOccurrences.Where(filterExpression);
            }

            var eventOccurrences = allOccurrences.Select(e => new EventOccurrenceViewModel(e, this.UICulture));

            return(eventOccurrences.ToList());
        }
예제 #3
0
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> qiContent, out ITrackingSpan applicableToSpan)
        {
            this._eventsFilter?.Remove();
            this._eventsFilter = Helpers.DemandEventsFilterForCurrentNativeTextView();
            session.Dismissed += this.RemoveFilter;
            applicableToSpan   = null;

            var           buffer = session.TextView.TextBuffer;
            SnapshotPoint?point  = session.GetTriggerPoint(buffer.CurrentSnapshot);

            if (!point.HasValue)
            {
                return;
            }

            int position = point.Value.Position;
            var line     = point.Value.GetContainingLine();
            var span     = new SnapshotSpan(line.Start, line.Length);
            var tags     = this._classifier.GetClassificationSpans(span);

            foreach (var tag in tags.Where(t => t.Span.Contains(position)))
            {
                if (tag.ClassificationType.IsOfType(IgnoreClassificationTypes.PathNoMatch))
                {
                    string text = tag.Span.GetText();

                    // Only show error tooltips
                    if (!text.Contains("../") && !IgnorePackage.Options.ShowTooltip)
                    {
                        continue;
                    }

                    string tooltip = $"The path \"{text}\" does not point to any existing file";

                    if (text.StartsWith("../"))
                    {
                        tooltip = "The entry contains a relative path segment which is not allowed";
                    }

                    applicableToSpan = buffer.CurrentSnapshot.CreateTrackingSpan(tag.Span.Span, SpanTrackingMode.EdgeNegative);
                    qiContent.Add(tooltip);
                    break;
                }
                else if (tag.ClassificationType.IsOfType(IgnoreClassificationTypes.Path))
                {
                    if (!IgnorePackage.Options.ShowTooltip)
                    {
                        continue;
                    }

                    string     pattern = tag.Span.GetText().Trim();
                    IgnoreTree tree    = new IgnoreTree(this._root, pattern, () =>
                    {
                        try
                        {
                            session.Dismiss();
                        }
                        catch
                        {
                        }
                    });

                    //Resizing in quick info causes the position to change relative to the mouse's position relative to
                    //  the original launch point. Fix the size of the control when launching from QI
                    tree.Width  = tree.MaxWidth;
                    tree.Height = (tree.MaxHeight + tree.MinHeight) / 2;
                    qiContent.Add(tree);
                    applicableToSpan = buffer.CurrentSnapshot.CreateTrackingSpan(tag.Span.Span, SpanTrackingMode.EdgeNegative);

                    //var files = GetFiles(_root, pattern);
                    //qiContent.Add(string.Join(Environment.NewLine, files.Take(_maxFiles)));

                    //if (files.Count() > _maxFiles)
                    //{
                    //    qiContent.Add($"...and {files.Count() - _maxFiles} more");
                    //}
                    break;
                }
            }
        }
예제 #4
0
 private void RemoveFilter(object sender, EventArgs e)
 {
     this._eventsFilter.Remove();
     this._eventsFilter = null;
 }