コード例 #1
0
        /// <summary>
        /// Add custom tool.
        /// </summary>
        /// <param name="tool">Tool to add.</param>
        /// <param name="canActivateToolHandler">Handler for check activation.</param>
        private void _AddTool(IMapTool tool, CanActivateToolHandler canActivateToolHandler)
        {
            tool.Initialize(_mapctrl);
            _tools.Add(tool);
            _canActivateToolHandlers.Add(canActivateToolHandler);

            tool.EnabledChanged += new EventHandler(_ToolEnabledChanged);

            // Create tool button.
            ToggleButton button = new ToggleButton();

            button.ToolTip   = tool.TooltipText;
            button.Style     = (Style)App.Current.FindResource("MapToolButtonStyle");
            button.IsEnabled = false;
            button.Click    += new RoutedEventHandler(_ToolClick);

            BitmapImage bitmap = new BitmapImage(new Uri(tool.IconSource, UriKind.Relative));
            Image       img    = new Image();

            img.Source              = bitmap;
            img.Margin              = (Thickness)App.Current.FindResource("ToolButtonImageMargin");
            img.VerticalAlignment   = VerticalAlignment.Center;
            img.HorizontalAlignment = HorizontalAlignment.Center;
            button.Content          = img;

            _toolButtonsPanel.Children.Add(button);
        }
コード例 #2
0
        public void DefaultMapControlTools()
        {
            InitializeControls();

            // check for all default tools
            IMapTool mapTool = mapControl.SelectTool;

            Assert.IsNotNull(mapTool);
            SelectTool selectTool = mapTool as SelectTool;

            Assert.IsNotNull(selectTool);

            mapTool = mapControl.MoveTool;
            Assert.IsNotNull(mapTool);

            MoveTool moveTool = mapTool as MoveTool;

            Assert.IsNotNull(moveTool);
            Assert.AreEqual(FallOffPolicyRule.None, moveTool.FallOffPolicy);

            mapTool = mapControl.GetToolByName("CurvePoint");
            Assert.IsNotNull(mapTool);
            CurvePointTool curvePointTool = mapTool as CurvePointTool;

            Assert.IsNotNull(curvePointTool);
        }
コード例 #3
0
        /// <summary>
        /// Clear tools.
        /// </summary>
        internal void ClearTools()
        {
            Debug.Assert(_tools.Count == _toolButtonsPanel.Children.Count);

            int i = 0;

            while (i < _tools.Count)
            {
                IMapTool tool = _tools[i];
                _tools.RemoveAt(i);
                tool.EnabledChanged -= new EventHandler(_ToolEnabledChanged);
                tool.OnComplete     -= new EventHandler(_OnCompleteTool);

                _canActivateToolHandlers.RemoveAt(i);

                ToggleButton toggleButton = _toolButtonsPanel.Children[i] as ToggleButton;

                if (toggleButton != null)
                {
                    toggleButton.Click -= new RoutedEventHandler(_ToolClick);
                }
                else
                {
                    // Deleting of tool combobutton is not supported.
                    Debug.Assert(false);
                }

                _toolButtonsPanel.Children.RemoveAt(i);
            }
        }
コード例 #4
0
ファイル: AgileMapControll.cs プロジェクト: configare/hispeed
 public void SetCurrentMapTool(enumMapToolType standardToolType)
 {
     if (_mapTools.ContainsKey(standardToolType))
     {
         _currentMapTool = _mapTools[standardToolType];
     }
 }
コード例 #5
0
        /// <summary>
        /// React on tool enabled changed.
        /// </summary>
        /// <param name="sender">Tool.</param>
        /// <param name="e">Ignored.</param>
        private void _ToolEnabledChanged(object sender, EventArgs e)
        {
            IMapTool tool = (IMapTool)sender;

            int index = _tools.IndexOf(tool);

            if (index != -1)
            {
                if (tool == _currentTool && !tool.IsEnabled && _currentTool.IsActivated)
                {
                    _DeactivateTool();
                }

                ToggleButton toggleButton = _toolButtonsPanel.Children[index] as ToggleButton;
                if (toggleButton != null)
                {
                    toggleButton.IsEnabled = tool.IsEnabled;
                }
                else
                {
                    ToolComboButton toolComboButton = _toolButtonsPanel.Children[index] as ToolComboButton;
                    toolComboButton.Enable(tool.IsEnabled);
                }
            }
        }
コード例 #6
0
ファイル: AgileMapControll.cs プロジェクト: configare/hispeed
 public void SetCurrentMapTool(IMapTool mapTool)
 {
     if (mapTool != null)
     {
         _currentMapTool = mapTool;
     }
 }
コード例 #7
0
ファイル: Map.cs プロジェクト: MichealWen/sharpmapv2
        private void handleToolSelectedChanged(Object sender, EventArgs args)
        {
            IMapTool selected = sender as IMapTool;

            Assert.IsNotNull(selected);
            ActiveTool = selected;
        }
コード例 #8
0
ファイル: MapToolSet.cs プロジェクト: MichealWen/sharpmapv2
        protected virtual void OnToolRemoved(IMapTool tool)
        {
            EventHandler <MapToolSetChangedEventArgs> e = ToolAdded;

            if (e != null)
            {
                e(this, new MapToolSetChangedEventArgs(tool, MapToolSetChange.ToolRemoved));
            }
        }
コード例 #9
0
ファイル: AgileMapControll.cs プロジェクト: configare/hispeed
 private void InitMapTools()
 {
     _mapTools = new Dictionary <enumMapToolType, IMapTool>();
     _mapTools.Add(enumMapToolType.Pan, new MapPanTool());
     _mapTools.Add(enumMapToolType.Identify, new MapIdentifyTool());
     _mapTools.Add(enumMapToolType.ZoomIn, new MapZoomInTool());
     _mapTools.Add(enumMapToolType.ZoomOut, new MapZoomOutTool());
     _currentMapTool = _mapTools[enumMapToolType.Pan];
 }
コード例 #10
0
ファイル: MapToolSet.cs プロジェクト: MichealWen/sharpmapv2
        public void Insert(Int32 index, IMapTool item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            _tools.Insert(index, item);
            OnToolAdded(item);
        }
コード例 #11
0
ファイル: MapToolSet.cs プロジェクト: MichealWen/sharpmapv2
        public Boolean Remove(IMapTool item)
        {
            if (_tools.Remove(item))
            {
                OnToolRemoved(item);
                return(true);
            }

            return(false);
        }
コード例 #12
0
        public void Insert(Int32 index, IMapTool item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            _tools.Insert(index, item);
            OnToolAdded(item);
        }
コード例 #13
0
        /// <summary>
        /// Init header button view by tool.
        /// </summary>
        /// <param name="tool">Tool to assign with header button.</param>
        private void _InitHeaderButtonByTool(IMapTool tool)
        {
            // Set tool tip.
            _headerButton.ToolTip = tool.TooltipText;

            // Set image.
            Image       headerButtonImage = _headerButton.Content as Image;
            BitmapImage bitmap            = new BitmapImage(new Uri(tool.IconSource, UriKind.Relative));

            headerButtonImage.Source = bitmap;
        }
コード例 #14
0
        // TODO: this test is strange, there should be tests for tools, checking how many Tools exist in map control or state of default tools should be in MapControlTest class and not here
        public void CustomGeometryEditorTools()
        {
            InitializeControls();
            AddBranchLayerAndTool();

            IMapTool mapTool = mapControl.GetToolByName(branchLayer.Name);

            Assert.IsNotNull(mapTool);
            NewLineTool newLineTool = mapTool as NewLineTool;

            Assert.IsNotNull(newLineTool);
        }
コード例 #15
0
        /// <summary>
        /// Activate tool.
        /// </summary>
        /// <param name="tool">Tool to activate.</param>
        private void _ActivateTool(IMapTool tool)
        {
            _currentTool = tool;

            tool.Activate();

            if (tool != _editingTool)
            {
                _overridedCursor    = _mapctrl.map.Cursor;
                _mapctrl.map.Cursor = tool.Cursor;
            }
        }
コード例 #16
0
ファイル: MapToolSet.cs プロジェクト: MichealWen/sharpmapv2
        public void RemoveAt(Int32 index)
        {
            if (index < 0 || index >= _tools.Count)
            {
                throw new ArgumentOutOfRangeException("index",
                                                      index,
                                                      "Index must be between 0 and Count.");
            }

            IMapTool tool = _tools[index];

            _tools.RemoveAt(index);
            OnToolRemoved(tool);
        }
コード例 #17
0
        /// <summary>
        /// Add tool.
        /// </summary>
        /// <param name="tool">Tool for adding.</param>
        /// <param name="canActivateToolHandler">Delegate to check can activated.</param>
        public void AddTool(IMapTool tool, CanActivateToolHandler canActivateToolHandler)
        {
            EditingTool editingTool = tool as EditingTool;

            if (editingTool != null)
            {
                _AddEditingTool(editingTool);
            }
            else
            {
                _AddTool(tool, canActivateToolHandler);
            }

            tool.OnComplete += new EventHandler(_OnCompleteTool);
        }
コード例 #18
0
        /// <summary>
        /// Add tool button.
        /// </summary>
        /// <param name="tool">Tool to assign with button.</param>
        private void _AddTool(IMapTool tool)
        {
            // Create bitmap image.
            BitmapImage bitmap = new BitmapImage(new Uri(tool.IconSource, UriKind.Relative));
            Image       img    = new Image();

            img.Source = bitmap;

            MenuItem item = new MenuItem();

            item.Header = tool.Title;
            item.Click += new RoutedEventHandler(_ItemClick);
            item.Icon   = img;
            _menu.Items.Add(item);
        }
コード例 #19
0
ファイル: FormMapBox.cs プロジェクト: yangyijie88/SharpMap
        private void btnTool_Click(object sender, EventArgs e)
        {
            var      btn  = (Button)sender;
            IMapTool tool = null;

            switch (btn.Name)
            {
            case "btnTool":
                tool = (mapBox1.CustomTool is SampleTool) ? null : new SampleTool(mapBox1);
                break;

            case "btnTool2":
                tool = (mapBox1.CustomTool is MagnifierTool) ? null : new MagnifierTool(mapBox1);
                break;
            }

            var oldCustomTool = mapBox1.CustomTool;

            if (oldCustomTool is SampleTool)
            {
                btnTool.Font = new Font(btn.Font, FontStyle.Regular);
            }
            if (oldCustomTool is MagnifierTool)
            {
                btnTool2.Font = new Font(btn.Font, FontStyle.Regular);
            }

            if (oldCustomTool is IDisposable)
            {
                ((IDisposable)oldCustomTool).Dispose();
            }

            mapBox1.CustomTool = tool;
            btn.Font           = new Font(btn.Font, tool == null ? FontStyle.Regular : FontStyle.Bold);
            if (tool == null)
            {
                mapBox1.ActiveTool = MapBox.Tools.Pan;
            }

            //if (mapBox1.CustomTool == null)
            //    mapBox1.CustomTool = new SampleTool(mapBox1);
            //else
            //{
            //    mapBox1.CustomTool = null;
            //    mapBox1.ActiveTool = MapBox.Tools.Pan;
            //}
        }
コード例 #20
0
 /// <summary>
 /// React on tool click.
 /// </summary>
 /// <param name="tool"></param>
 private void _OnToolClick(IMapTool tool)
 {
     if (tool == _currentTool)
     {
         // Deactivate current tool.
         _DeactivateTool();
     }
     else
     {
         // Deactivate current tool and activate chosen.
         if (_currentTool != null)
         {
             _DeactivateTool();
         }
         _ActivateTool(tool);
     }
 }
コード例 #21
0
        void btn_Click(object sender, EventArgs e)
        {
            ToolStripButton      btn  = sender as ToolStripButton;
            MapToolExtensionNode node = btn.Tag as MapToolExtensionNode;

            if (currentTool != null)
            {
                currentTool.SetInactive();
            }

            currentTool = node.Tool;

            if (currentTool != null)
            {
                currentTool.SetActive(this, node.Tag);
            }
        }
コード例 #22
0
        public void ActivateTool(IMapTool tool)
        {
            if (tool == null || tool.IsActive)
            {
                return;
            }

            if (tool.AlwaysActive)
            {
                throw new InvalidOperationException("Tool is AlwaysActive, use IMapTool.Execute() to make it work");
            }

            // deactivate other tools
            foreach (var t in tools.Where(t => t.IsActive && !t.AlwaysActive))
            {
                t.IsActive = false;
            }

            tool.IsActive = true;
        }
コード例 #23
0
ファイル: Map.cs プロジェクト: MichealWen/sharpmapv2
        /// <summary>
        /// Creates a new instance of a Map with the given title.
        /// </summary>
        public Map(String title, IGeometryFactory geoFactory, ICoordinateTransformationFactory coordTransformFactory)
        {
            _geoFactory            = geoFactory;
            _coordTransformFactory = coordTransformFactory;
            _emptyPoint            = _geoFactory.CreatePoint();
            _layers              = new LayerCollection(this);
            _layers.ListChanged += handleLayersChanged;
            _featureDataSet      = new FeatureDataSet(title, geoFactory);

            // TODO: tool configuration should come from a config file and / or reflection
            IMapTool[] mapTools = new IMapTool[]
            {
                StandardMapView2DMapTools.Pan,
                StandardMapView2DMapTools.Query,
                StandardMapView2DMapTools.ZoomIn,
                StandardMapView2DMapTools.ZoomOut
            };

            // I18N_UNSAFE
            Tools = new MapToolSet("Standard Map View Tools", mapTools);
        }
コード例 #24
0
        /// <summary>
        /// Add tools.
        /// </summary>
        /// <param name="tools">Tools for adding.</param>
        /// <param name="canActivateToolHandler">Callback for checking is tool can be activated.</param>
        private void _AddTools(IMapTool[] tools, CanActivateToolHandler canActivateToolHandler)
        {
            foreach (IMapTool tool in tools)
            {
                tool.Initialize(_mapctrl);
            }

            IMapTool toolOnPanel = tools[0];

            toolOnPanel.OnComplete     += new EventHandler(_OnCompleteTool);
            toolOnPanel.EnabledChanged += new EventHandler(_ToolEnabledChanged);
            _tools.Add(toolOnPanel);

            _canActivateToolHandlers.Add(canActivateToolHandler);

            ToolComboButton button = new ToolComboButton();

            button.ToolActivated += new EventHandler(_OnToolActivated);
            button.Init(tools);

            _toolButtonsPanel.Children.Add(button);
        }
コード例 #25
0
ファイル: MapControl.xaml.cs プロジェクト: configare/hispeed
        private void SetMapToolByCurrentType()
        {
            IMapCommand cmd = MapToolFactory.GetMapTool(_currentToolType);

            if (!(cmd is IMapTool))
            {
                return;
            }
            if (_currentMapTool != null)
            {
                (_currentMapTool as IMapToolInternal).Deactive();
            }
            _currentMapTool = cmd as IMapTool;
            if (_currentMapTool == null)
            {
                _currentToolType = enumMapTools.None;
            }
            else
            {
                (_currentMapTool as IMapToolInternal).Active();
            }
        }
コード例 #26
0
        /// <summary>
        /// React on button click.
        /// </summary>
        /// <param name="sender">Clicked button.</param>
        /// <param name="e">Ignored.</param>
        private void _ItemClick(object sender, RoutedEventArgs e)
        {
            MenuItem button = sender as MenuItem;

            if (button.Tag != _headerButton)
            {
                // If hided tool selected from popup - init header button by selected tool.
                int index = _menu.Items.IndexOf((MenuItem)sender);
                if (SelectedTool != _tools[index])
                {
                    SelectedTool = _tools[index];
                    _InitHeaderButtonByTool(SelectedTool);
                }

                button.IsChecked = false;
            }

            // Activate selected tool.
            if (ToolActivated != null)
            {
                ToolActivated(this, EventArgs.Empty);
            }
        }
コード例 #27
0
        public void ActivateTool(IMapTool tool)
        {
            if (tool.IsActive)
            {
                // tool already active
                return;
            }

            if (tool.AlwaysActive)
            {
                throw new InvalidOperationException("Tool is AlwaysActive, use IMapTool.Execute() to make it work");
            }

            // deactivate other tools
            foreach (IMapTool t in tools)
            {
                if (t.IsActive && !t.AlwaysActive)
                {
                    t.IsActive = false;
                }
            }

            tool.IsActive = true;
        }
コード例 #28
0
        /// <summary>
        /// Control template apply.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            IsEnabled = false;

            _headerButton = this.GetTemplateChild("PART_HeaderButton") as ToggleButton;

            _menu = this.GetTemplateChild("PART_Menu") as ContextMenu;
            _menu.PlacementTarget = _headerButton;
            _menu.Closed         += new RoutedEventHandler(_MenuClosed);
            _menu.MouseMove      += new MouseEventHandler(_MenuMouseMove);

            MouseEnter += new MouseEventHandler(_MouseEnter);


            SelectedTool = _tools[0];

            _headerButton.Style     = (Style)App.Current.FindResource("MapToolButtonStyle");
            _headerButton.IsEnabled = false;
            _headerButton.Click    += new RoutedEventHandler(_headerButton_Click);

            Image imgHeaderButton = new Image();

            imgHeaderButton.Margin              = (Thickness)App.Current.FindResource("ToolButtonImageMargin");
            imgHeaderButton.VerticalAlignment   = VerticalAlignment.Center;
            imgHeaderButton.HorizontalAlignment = HorizontalAlignment.Center;
            _headerButton.Content = imgHeaderButton;

            for (int i = 0; i < _tools.Count; i++)
            {
                _AddTool(_tools[i]);
            }

            _InitHeaderButtonByTool(SelectedTool);
        }
コード例 #29
0
 public MapToolPresenter(Map map, IMapTool mapTool, IMapToolView view)
     : base(map, view)
 {
     _mapTool = mapTool;
 }
コード例 #30
0
ファイル: MapTool.cs プロジェクト: lishxi/_SharpMap
 public virtual void ActiveToolChanged(IMapTool newTool)
 {
 }
コード例 #31
0
 public void ActiveToolChanged(IMapTool newTool)
 {
 }
コード例 #32
0
 /// <summary>
 /// Add tools.
 /// </summary>
 /// <param name="tools">Tools for adding.</param>
 /// <param name="canActivateToolHandler">Callback for checking is tool can be activated.</param>
 public void AddTools(IMapTool[] tools, CanActivateToolHandler canActivateToolHandler)
 {
     _tools.AddTools(tools,  canActivateToolHandler);
 }
コード例 #33
0
ファイル: NewPolygonTool.cs プロジェクト: lishxi/_SharpMap
 public override void ActiveToolChanged(IMapTool newTool)
 {
     newObjectIndex = -1;
 }
コード例 #34
0
        protected virtual void OnToolRemoved(IMapTool tool)
        {
            EventHandler<MapToolSetChangedEventArgs> e = ToolAdded;

            if (e != null)
            {
                e(this, new MapToolSetChangedEventArgs(tool, MapToolSetChange.ToolRemoved));
            }
        }
コード例 #35
0
 public void CopyTo(IMapTool[] array, Int32 arrayIndex)
 {
     _tools.CopyTo(array, arrayIndex);
 }
コード例 #36
0
 public void Add(IMapTool item)
 {
     _tools.Add(item);
     OnToolAdded(item);
 }
コード例 #37
0
ファイル: Main.cs プロジェクト: eropple/sharplike
        void btn_Click(object sender, EventArgs e)
        {
            ToolStripButton btn = sender as ToolStripButton;
            MapToolExtensionNode node = btn.Tag as MapToolExtensionNode;

            if (currentTool != null)
                currentTool.SetInactive();

            currentTool = node.Tool;

            if (currentTool != null)
                currentTool.SetActive(this, node.Tag);
        }
コード例 #38
0
        /// <summary>
        /// Init header button view by tool.
        /// </summary>
        /// <param name="tool">Tool to assign with header button.</param>
        private void _InitHeaderButtonByTool(IMapTool tool)
        {
            // Set tool tip.
            _headerButton.ToolTip = tool.TooltipText;

            // Set image.
            Image headerButtonImage = _headerButton.Content as Image;
            BitmapImage bitmap = new BitmapImage(new Uri(tool.IconSource, UriKind.Relative));
            headerButtonImage.Source = bitmap;
        }
コード例 #39
0
        /// <summary>
        /// React on button click.
        /// </summary>
        /// <param name="sender">Clicked button.</param>
        /// <param name="e">Ignored.</param>
        private void _ItemClick(object sender, RoutedEventArgs e)
        {
            MenuItem button = sender as MenuItem;
            if (button.Tag != _headerButton)
            {
                // If hided tool selected from popup - init header button by selected tool.
                int index = _menu.Items.IndexOf((MenuItem)sender);
                if (SelectedTool != _tools[index])
                {
                    SelectedTool = _tools[index];
                    _InitHeaderButtonByTool(SelectedTool);
                }

                button.IsChecked = false;
            }

            // Activate selected tool.
            if (ToolActivated != null)
                ToolActivated(this, EventArgs.Empty);
        }
コード例 #40
0
 /// <summary>
 /// Init button.
 /// </summary>
 /// <param name="tools">Tools which can be selected.</param>
 public void Init(IMapTool[] tools)
 {
     _tools = new List<IMapTool>(tools);
 }
コード例 #41
0
 public MapToolSetChangedEventArgs(IMapTool tool, MapToolSetChange change)
 {
     _tool = tool;
     _change = change;
 }
コード例 #42
0
ファイル: NewLineTool.cs プロジェクト: lishxi/_SharpMap
 public override void ActiveToolChanged(IMapTool newTool)
 {
     adding = false;
 }
コード例 #43
0
ファイル: Main.cs プロジェクト: eropple/sharplike
        void Main_Load(object sender, EventArgs e)
        {
            Game.Initialize();
            Game.SetRenderSystem("OpenTK");

            String glyphPath = Game.PathTo("curses_640x300.png");
            using (Stream imgstream = File.OpenRead(glyphPath))
            {
                GlyphPalette pal = new GlyphPalette(imgstream, 16, 16);

                window = Game.RenderSystem.CreateWindow(SharplikeView.Size, pal, SharplikeView);
            }

            SharplikeView.Controls[0].MouseDown += new MouseEventHandler(SharplikeView_MouseDown);
            SharplikeView.Controls[0].MouseUp += new MouseEventHandler(SharplikeView_MouseUp);
            SharplikeView.Controls[0].MouseMove += new MouseEventHandler(SharplikeView_MouseMove);

            EntityList.ItemDrag += new ItemDragEventHandler(EntityList_ItemDrag);
            SharplikeView.Controls[0].AllowDrop = true;
            SharplikeView.Controls[0].DragDrop += new DragEventHandler(Main_DragDrop);
            SharplikeView.Controls[0].DragOver += new DragEventHandler(Main_DragOver);
            SharplikeView.Controls[0].DragEnter += new DragEventHandler(Main_DragEnter);
            SharplikeView.Controls[0].DragLeave += new EventHandler(Main_DragLeave);

            //Game.SetInputSystem("OpenTK");

            window.Clear();

            ReplaceMap(new MapStack(window.Size, 20, 15, "EditorMap"));
            Map.ViewFrom(new Vector3(0, 0, 0), true);

            Bitmap glyphs = Game.RenderSystem.Window.GlyphPalette.SourceBitmap;
            ImageList il = new ImageList();
            Size glyphSize = Game.RenderSystem.Window.GlyphPalette.GlyphDimensions;

            for (int y = 0; y < Game.RenderSystem.Window.GlyphPalette.RowCount; ++y)
            {
                for (int x = 0; x < Game.RenderSystem.Window.GlyphPalette.ColumnCount; ++x)
                {
                    Rectangle area = new Rectangle(x * glyphSize.Width, y * glyphSize.Height,
                        glyphSize.Width, glyphSize.Height);
                    Bitmap b = new Bitmap(glyphSize.Width, glyphSize.Height, glyphs.PixelFormat);
                    using (Graphics bg = Graphics.FromImage(b))
                    {
                        bg.Clear(Color.Black);
                        bg.DrawImageUnscaled(glyphs.Clone(area, glyphs.PixelFormat), new Point(0, 0));
                    }
                    il.Images.Add(b);
                }
            }
            EntityList.LargeImageList = il;
            EntityList.SmallImageList = il;

            SquareList.LargeImageList = il;
            SquareList.SmallImageList = il;

            foreach (EditorExtensionNode node in AddinManager.GetExtensionNodes("/Sharplike/Entities"))
            {
                ListViewItem i = new ListViewItem();
                i.Text = node.Id;
                i.ToolTipText = node.TooltipText;
                i.Tag = node;
                i.ImageIndex = node.GlyphID;

                EntityList.Items.Add(i);
            }

            foreach (EditorExtensionNode node in AddinManager.GetExtensionNodes("/Sharplike/Squares"))
            {
                ListViewItem i = new ListViewItem();
                i.Text = node.Id;
                i.ToolTipText = node.TooltipText;
                i.Tag = node;
                i.ImageIndex = node.GlyphID;

                SquareList.Items.Add(i);
            }

            foreach (ToolGroupExtensionNode node in AddinManager.GetExtensionNodes("/Sharplike/Editlike/Tools"))
            {
                foreach (ExtensionNode mapnode in node.ChildNodes)
                {
                    if (mapnode.GetType() == typeof(MapToolExtensionNode))
                    {
                        ToolStripButton btn = new ToolStripButton();
                        BuildButton(mapnode as MapToolExtensionNode, btn);
                        EditorTools.Items.Add(btn);
                    }
                    else
                    {
                        ToolStripDropDownButton ddbtn = new ToolStripDropDownButton();
                        ddbtn.DropDown.Width = 200;
                        foreach (MapToolExtensionNode mnode in mapnode.ChildNodes)
                        {

                            ToolStripButton btn = new ToolStripButton();
                            BuildButton(mnode, btn);
                            if (btn.DisplayStyle == ToolStripItemDisplayStyle.Image)
                                btn.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;

                            Image i = mnode.Icon;
                            btn.Click += delegate(object send, EventArgs ea)
                            {
                                ddbtn.Image = i;
                                ddbtn.Tag = btn;
                            };

                            ddbtn.DropDownItems.Add(btn);

                            if (ddbtn.Tag == null)
                            {
                                ddbtn.Tag = btn;
                                ddbtn.Image = mnode.Icon;
                            }
                        }

                        ddbtn.Click += delegate(object send, EventArgs ea)
                        {
                            btn_Click(ddbtn.Tag, ea);
                        };

                        EditorTools.Items.Add(ddbtn);
                    }
                }
                EditorTools.Items.Add(new ToolStripSeparator());
            }

            viewTool = new ViewportTool();
            viewTool.SetActive(this, "");

            Game.Run();
        }
コード例 #44
0
        /// <summary>
        /// Add tool button.
        /// </summary>
        /// <param name="tool">Tool to assign with button.</param>
        private void _AddTool(IMapTool tool)
        {
            // Create bitmap image.
            BitmapImage bitmap = new BitmapImage(new Uri(tool.IconSource, UriKind.Relative));
            Image img = new Image();
            img.Source = bitmap;

            MenuItem item = new MenuItem();
            item.Header = tool.Title;
            item.Click += new RoutedEventHandler(_ItemClick);
            item.Icon = img;
            _menu.Items.Add(item);
        }
コード例 #45
0
 public Boolean Contains(IMapTool item)
 {
     return _tools.Contains(item);
 }
コード例 #46
0
ファイル: MeasureTool.cs プロジェクト: lishxi/_SharpMap
 public override void ActiveToolChanged(IMapTool newTool)
 {
     // TODO: It seems this is never called, so it is also cleared when the IsActive property is (re)set
     Clear();
     base.ActiveToolChanged(newTool);
 }
コード例 #47
0
        public Boolean Remove(IMapTool item)
        {
            if (_tools.Remove(item))
            {
                OnToolRemoved(item);
                return true;
            }

            return false;
        }
コード例 #48
0
 /// <summary>
 /// Add tool.
 /// </summary>
 /// <param name="tool">Tool for adding.</param>
 /// <param name="canActivateToolHandler">Callback for checking is tool can be activated.</param>
 public void AddTool(IMapTool tool, CanActivateToolHandler canActivateToolHandler)
 {
     _tools.AddTool(tool, canActivateToolHandler);
 }
コード例 #49
0
 public Int32 IndexOf(IMapTool item)
 {
     return _tools.IndexOf(item);
 }
コード例 #50
0
 /// <summary>
 /// Creates a new instance of a <see cref="ToolChangeRequestedEventArgs"/>
 /// with the given <see cref="IMapTool"/>.
 /// </summary>
 /// <param name="requestedTool">
 /// The <see cref="IMapTool"/> to request change to.
 /// </param>
 public ToolChangeRequestedEventArgs(IMapTool requestedTool)
 {
     _requestedTool = requestedTool;
 }
コード例 #51
0
 public override void ActiveToolChanged(IMapTool newTool)
 {
     newObjectIndex = -1;
 }
コード例 #52
0
        /// <summary>
        /// Control template apply.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            IsEnabled = false;

            _headerButton = this.GetTemplateChild("PART_HeaderButton") as ToggleButton;

            _menu = this.GetTemplateChild("PART_Menu") as ContextMenu;
            _menu.PlacementTarget = _headerButton;
            _menu.Closed += new RoutedEventHandler(_MenuClosed);
            _menu.MouseMove += new MouseEventHandler(_MenuMouseMove);

            MouseEnter += new MouseEventHandler(_MouseEnter);

            SelectedTool = _tools[0];

            _headerButton.Style = (Style)App.Current.FindResource("MapToolButtonStyle");
            _headerButton.IsEnabled = false;
            _headerButton.Click += new RoutedEventHandler(_headerButton_Click);

            Image imgHeaderButton = new Image();
            imgHeaderButton.Margin = (Thickness)App.Current.FindResource("ToolButtonImageMargin");
            imgHeaderButton.VerticalAlignment = VerticalAlignment.Center;
            imgHeaderButton.HorizontalAlignment = HorizontalAlignment.Center;
            _headerButton.Content = imgHeaderButton;

            for (int i = 0; i < _tools.Count; i++)
            {
                _AddTool(_tools[i]);
            }

            _InitHeaderButtonByTool(SelectedTool);
        }