Example #1
0
        public int Compare(object x, object y)
        {
            StoredRegion a = x as StoredRegion;
            StoredRegion b = y as StoredRegion;

            if (a == null || b == null)
            {
                return(-1); //this is wrong, but anyway
            }
            return(a.Name.CompareTo(b.Name));
        }
        /// <summary>
        /// Gets an array of stored regions.
        /// </summary>
        private StoredRegion[] GetStoredRegions()
        {
            if (Settings.Default.SavedRegions == null || Settings.Default.SavedRegions.Count == 0)
            {
                return(null);
            }

            StoredRegion[] ret = new StoredRegion[Settings.Default.SavedRegions.Count];
            Settings.Default.SavedRegions.CopyTo(ret);

            Array.Sort <StoredRegion>(ret, (a, b) => {
                return(a.Name.CompareTo(b.Name));
            });

            return(ret);
        }
        private void PopulateRegionsDropdown(ToolStripMenuItem parent, WindowHandle parentHandle, StoredRegion[] regions)
        {
            parent.DropDownItems.Clear();

            //No region
            var nullRegionItem = new ToolStripMenuItem(Strings.MenuWindowsWholeRegion);
            nullRegionItem.Tag = parentHandle;
            nullRegionItem.Image = Resources.regions;
            nullRegionItem.Click += MenuWindowClickHandler;
            parent.DropDownItems.Add(nullRegionItem);

            //Video detector
            /*var detectorItem = new ToolStripMenuItem("Autodetect plugin");
            detectorItem.Tag = parentHandle;
            detectorItem.Click += MenuVideoCropperClickHandler;
            parent.DropDownItems.Add(detectorItem);*/

            //Regions (if any)
            if (regions == null || regions.Length == 0)
                return;

            parent.DropDownItems.Add(new ToolStripSeparator());

            foreach (StoredRegion region in regions) {
                var regionItem = new ToolStripMenuItem(region.Name);
                regionItem.Tag = new Tuple<WindowHandle, StoredRegion>(parentHandle, region);
                regionItem.Click += MenuRegionWindowClickHandler;

                parent.DropDownItems.Add(regionItem);
            }
        }
        /// <summary>
        /// Gets an array of stored regions.
        /// </summary>
        private StoredRegion[] GetStoredRegions()
        {
            if (Settings.Default.SavedRegions == null || Settings.Default.SavedRegions.Count == 0)
                return null;

            StoredRegion[] ret = new StoredRegion[Settings.Default.SavedRegions.Count];
            Settings.Default.SavedRegions.CopyTo(ret);

            Array.Sort<StoredRegion>(ret, (a, b) => {
                return a.Name.CompareTo(b.Name);
            });

            return ret;
        }
        private static IEnumerable<StoredRegion> GetRegions()
        {
            if (Settings.Default.SavedRegions == null || Settings.Default.SavedRegions.Count == 0)
                return null;

            StoredRegion[] regions = new StoredRegion[Settings.Default.SavedRegions.Count];
            Settings.Default.SavedRegions.CopyTo(regions);

            Array.Sort<StoredRegion>(regions, new Comparison<StoredRegion>((a, b) => {
                return a.Name.CompareTo(b.Name);
            }));

            return regions;
        }