/// <summary>
        /// Initializes a new instance of the <see cref="ListViewItemSorter"/> class
        /// that uses the specified comparers to sort columns
        /// and attaches the new instance to the specified ListView.
        /// </summary>
        /// <param name="listView">The ListView that should be sorted and monitored for column click events.</param>
        /// <param name="itemComparers">An array of objects that implement IListViewItemComparer.
        /// The index of the comparer in the array corresponds to the index of the list view column that it sorts.
        /// If an element is <c>null</c>, the corresponding column cannot be sorted.
        /// If this parameter is <c>null</c>, all columns can be sorted by their text content.</param>
        /// <remarks>
        /// Note that the ListViewItemSorter constructor adds two bitmaps to the
        /// SmallImageList of the ListView (an empty ImageList will be created
        /// first if none is assigned).
        /// </remarks>
        public ListViewItemSorter(ListView listView, IListViewItemComparer[] itemComparers)
        {
            if (listView == null)
            {
                throw new ArgumentNullException("listView");
            }
            this.listView = listView;

            if (itemComparers == null)
            {
                IListViewItemComparer defaultComparer = new ListViewTextColumnComparer();
                this.itemComparers = new IListViewItemComparer[this.ListView.Columns.Count];
                for (int i = 0; i < this.itemComparers.Length; i++)
                {
                    this.itemComparers[i] = defaultComparer;
                }
            }
            else
            {
                this.itemComparers = itemComparers;
            }

            if (this.ListView.SmallImageList == null)
            {
                this.ListView.SmallImageList = new ImageList();
            }
            this.ListView.SmallImageList.Images.Add("SortAscending", BitmapResources.GetBitmap("Icons.16x16.SortAscending.png"));
            this.ListView.SmallImageList.Images.Add("SortDescending", BitmapResources.GetBitmap("Icons.16x16.SortDescending.png"));

            this.ListView.ColumnClick       += this.ListViewColumnClick;
            this.ListView.ListViewItemSorter = this;
        }
 public DraggingLayer()
 {
     this.Style = new ImageStyle
     {
         BitmapId    = BitmapResources.GetBitmapIdForEmbeddedResourceRelative(ImagePath),
         SymbolScale = Scale
     };
 }
Esempio n. 3
0
 public AttractorDraggingFeature(AttractorObject attractor) : base(attractor)
 {
     Geometry = attractor.Position;
     Styles.Add(new ImageStyle
     {
         BitmapId    = BitmapResources.GetBitmapIdForEmbeddedResourceRelative("Dragging.png"),
         SymbolScale = 0.8f
     });
 }
        private void OnPreviewRightMouseDown(object sender, MouseButtonEventArgs e)
        {
            Point mouseScreenPoint = e.GetPosition(mapControl).ToMapsui();
            var   draggingFeature  = GetFeaturesAtScreenPoint(mouseScreenPoint).OfType <DraggingFeature>().FirstOrDefault();

            if (draggingFeature != null && editedObject.Vertices.Count > editedObject.MinimumVertices)
            {
                // Preventing editing end
                e.Handled = true;

                var contextMenu = new ContextMenu();
                var deleteItem  = new MenuItem {
                    Header = "Удалить вершину",
                    Icon   = BitmapResources.LoadImage("Delete.png")
                };
                deleteItem.Click += (_s, _e) => RemoveVertex(draggingFeature.Vertex);
                contextMenu.Items.Add(deleteItem);
                contextMenu.IsOpen = true;
            }
        }
Esempio n. 5
0
 internal static nanoFramework.UI.Bitmap GetBitmap(BitmapResources id)
 {
     return((nanoFramework.UI.Bitmap)(nanoFramework.Runtime.Native.ResourceUtility.GetObject(ResourceManager, id)));
 }
        private ContextMenu CreateMapObjectContextMenu(IMapObject iMapObject)
        {
            var contextMenu = new ContextMenu();

            contextMenu.Items.Add(CreateModifyItem());
            contextMenu.Items.Add(CreateRemoveItem());
            if (iMapObject is MapObject mapObj && !(iMapObject is BoundingAreaPolygon))
            {
                contextMenu.Items.Add(CreateConvertItem(mapObj));
            }
            return(contextMenu);

            ///////// BUTTONS CREATION LOCAL FUNCS
            MenuItem CreateModifyItem()
            {
                var item = new MenuItem
                {
                    Header = "Редактировать",
                    Icon   = BitmapResources.LoadImage("EditPolygon.png")
                };

                item.Click += (s, e) =>
                {
                    UnhighlightAllMapObjects();
                    EndAllTools();
                    StartMapObjectEditing(iMapObject);
                };
                return(item);
            }

            MenuItem CreateRemoveItem()
            {
                var item = new MenuItem
                {
                    Header = "Удалить",
                    Icon   = BitmapResources.LoadImage("Delete.png")
                };

                item.Click += (s, e) =>
                {
                    if (iMapObject is MapObject mapObject)
                    {
                        if (iMapObject == boundingAreaTool.BoundingArea)
                        {
                            boundingAreaTool.Remove();
                            RefreshButtons();
                        }
                        else
                        {
                            mapObjectLayer.TryRemove(mapObject);
                        }
                    }
                    else if (iMapObject is AttractorObject attractor)
                    {
                        attractorLayer.TryRemove(attractor);
                        RefreshButtons();
                    }
                    RefreshLayers();
                };
                return(item);
            }

            MenuItem CreateConvertItem(MapObject mapObject)
            {
                var parent = new MenuItem
                {
                    Header = "Преобразовать в..."
                };
                var convertOptions = AreaTypes.All
                                     .Where(x => x.GeometryType == mapObject.AreaType.GeometryType);

                foreach (var areaType in convertOptions)
                {
                    var item = new MenuItem
                    {
                        Header = areaType.DisplayedName
                    };
                    item.Click += (s, e) =>
                    {
                        mapObject.AreaType = areaType;
                        RefreshLayers();
                    };
                    parent.Items.Add(item);
                }
                return(parent);
            }

            ///////// END BUTTONS CREATION LOCAL FUNCS
        }
Esempio n. 7
0
 internal static System.Drawing.Bitmap GetBitmap(BitmapResources id)
 {
     return((System.Drawing.Bitmap)ResourceManager.GetObject((short)id));
 }