Exemple #1
0
 private void mapControl_OnMapZoomChanged()
 {
     if (ZoomChanged != null)
     {
         ZoomChanged.Invoke(mapControl, EventArgs.Empty);
     }
 }
        private async Task OnZoomChanged()
        {
            ZoomChanged?.Invoke(this, new RoutedEventArgs());
            await UpdateZoom();

            TransportControls?.UpdateZoomButton();
        }
Exemple #3
0
 protected override void NewTitle(string title)
 {
     if (!String.IsNullOrEmpty(title))
     {
         double newLat, newLong, newZoom;
         // Incoming title should look like "6, (-27.15, 151.25)"
         // That is Zoom, then lat, long pair
         // We remove the brackets and split on the commas
         title = title.Replace("(", "");
         title = title.Replace(")", "");
         string[] parts = title.Split(new char[] { ',' });
         if (Double.TryParse(parts[0], out newZoom) && newZoom != _zoom)
         {
             _zoom = newZoom;
             if (ZoomChanged != null)
             {
                 ZoomChanged.Invoke(this, EventArgs.Empty);
             }
         }
         if (Double.TryParse(parts[1], out newLat) &&
             Double.TryParse(parts[2], out newLong) &&
             (newLat != _center.Latitude || newLong != Center.Longitude))
         {
             _center.Latitude  = newLat;
             _center.Longitude = newLong;
             if (PositionChanged != null)
             {
                 PositionChanged.Invoke(this, EventArgs.Empty);
             }
         }
     }
 }
Exemple #4
0
 private void vZoom_ValueChanged(object sender, EventArgs e)
 {
     if (ZoomChanged != null)
     {
         ZoomChanged.Invoke(this, EventArgs.Empty);
     }
 }
Exemple #5
0
 private void selectedIndexChanged(object sender, EventArgs e)
 {
     spriteGrid1.Zoom = zoom.SelectedIndex + 1;
     spriteGrid1.Size = new Size(spriteGrid1.MaximumSize.Width,
                                 spriteGrid1.MaximumSize.Height);
     AdaptSize();
     ZoomChanged?.Invoke();
 }
Exemple #6
0
        /// <summary>
        /// Apply the new animated _zoom value to the actual ScaleTransform and fire the ZoomChanged event.
        /// </summary>
        void OnZoomChanged()
        {
            _scale.ScaleX = _scale.ScaleY = _zoom;

            ZoomChanged?.Invoke(this, EventArgs.Empty);

            // focus rectangles may need to be repainted.
            _target.InvalidateVisual();
        }
Exemple #7
0
        public void Dispose()
        {
            editorFormatMap.FormatMappingChanged -= OnFormatItemsChanged;
            textView.BackgroundBrushChanged      -= OnBackgroundBrushChanged;
            textView.ZoomLevelChanged            -= OnZoomChanged;

            foreach (CommentsColorChangedHandler method in CommentsColorChanged.GetInvocationList())
            {
                CommentsColorChanged -= method;
            }
            foreach (ZoomChangedHandler method in ZoomChanged.GetInvocationList())
            {
                ZoomChanged -= method;
            }
        }
Exemple #8
0
 internal void SetZoom(int zoom, bool invoke = false)
 {
     if (scintilla.Margins[0].Width > 0)
     {
         scintilla.Margins[0].Width = Math.Max(20, 30 + 3 * zoom);
     }
     if (scintilla.Zoom != zoom)
     {
         scintilla.Zoom = zoom;
     }
     if (invoke)
     {
         ZoomChanged?.Invoke(this, scintilla.Zoom);
     }
 }
Exemple #9
0
 /// <summary>
 /// Internal handler for the zoom changed event.
 /// </summary>
 protected void OnZoomChanged()
 {
     if (ZoomChanged != null)
         ZoomChanged.Invoke(this);
  
     if (m_ZoomedSection == -1)
     {
         if (PanelUnZoomed != null)
             PanelUnZoomed.Invoke(this);
     }
     else
     {
         if (PanelZoomed != null)
             PanelZoomed.Invoke(this);
     }
 }
Exemple #10
0
        /// <summary>
        ///     Zoom to the given factor.
        /// </summary>
        /// <param name='zoom'>
        ///     A zoom factor, expressed as a double.
        /// </param>
        /// <param name='x'>
        ///     The point of the viewport around which to zoom.
        /// </param>
        /// <param name='y'>
        ///     The point of the viewport around which to zoom.
        /// </param>
        void DoZoom(double zoom, int x, int y)
        {
            Fit = zoom == MIN_ZOOM;

            if (zoom == this.zoom || Math.Abs(this.zoom - zoom) < Double.Epsilon)
            {
                // Don't recalculate if the zoom factor stays the same.
                return;
            }

            // Clamp the zoom factor within the [ MIN_ZOOM , MAX_ZOOM ] interval.
            zoom = Math.Max(Math.Min(zoom, MAX_ZOOM), MIN_ZOOM);

            this.zoom = zoom;

            int    x_offset = scaled_width < Allocation.Width ? (int)(Allocation.Width - scaled_width) / 2 : -XOffset;
            int    y_offset = scaled_height < Allocation.Height ? (int)(Allocation.Height - scaled_height) / 2 : -YOffset;
            double x_anchor = (double)(x - x_offset) / (double)scaled_width;
            double y_anchor = (double)(y - y_offset) / (double)scaled_height;

            ComputeScaledSize();

            AdjustmentsChanged -= ScrollToAdjustments;
            if (scaled_width < Allocation.Width)
            {
                Hadjustment.Value = XOffset = 0;
            }
            else
            {
                Hadjustment.Value = XOffset = Clamp((int)(x_anchor * scaled_width - x), 0, (int)(Hadjustment.Upper - Hadjustment.PageSize));
            }
            if (scaled_height < Allocation.Height)
            {
                Vadjustment.Value = YOffset = 0;
            }
            else
            {
                Vadjustment.Value = YOffset = Clamp((int)(y_anchor * scaled_height - y), 0, (int)(Vadjustment.Upper - Vadjustment.PageSize));
            }
            AdjustmentsChanged += ScrollToAdjustments;

            ZoomChanged?.Invoke(this, EventArgs.Empty);

            QueueDraw();
        }
Exemple #11
0
        private void UpdateMatrices()
        {
            zoom = Utils.Clamp(0.25f, 4.00f, zoom);

            if (Math.Abs(zoom - zoomLast) > 0.01f)
            {
                zoomLast = zoom;
                ZoomChanged?.Invoke(this, zoom);
            }

            transformation.Reset();
            transformation.Translate(translation.X, translation.Y);
            transformation.Scale(zoom, zoom);

            inverse_transformation.Reset();
            inverse_transformation.Scale(1.0f / zoom, 1.0f / zoom);
            inverse_transformation.Translate(-translation.X, -translation.Y);
        }
Exemple #12
0
        /// <summary>
        /// Internal handler for the zoom changed event.
        /// </summary>
        protected void OnZoomChanged()
        {
            if (ZoomChanged != null)
            {
                ZoomChanged.Invoke(this, EventArgs.Empty);
            }

            if (m_ZoomedSection == -1)
            {
                if (PanelUnZoomed != null)
                {
                    PanelUnZoomed.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                if (PanelZoomed != null)
                {
                    PanelZoomed.Invoke(this, EventArgs.Empty);
                }
            }
        }
Exemple #13
0
        protected override void OnSizeAllocated(Gdk.Rectangle allocation)
        {
            min_zoom = ComputeMinZoom(upscale);

            if (Fit || zoom < MIN_ZOOM)
            {
                zoom = MIN_ZOOM;
            }
            // Since this affects the zoom_scale we should alert it
            ZoomChanged?.Invoke(this, EventArgs.Empty);

            ComputeScaledSize();

            OnSizeAllocatedChildren();

            if (IsRealized)
            {
                GdkWindow.MoveResize(allocation.X, allocation.Y, allocation.Width, allocation.Height);
            }

            if (XOffset > Hadjustment.Upper - Hadjustment.PageSize)
            {
                ScrollTo((int)(Hadjustment.Upper - Hadjustment.PageSize), YOffset, false);
            }
            if (YOffset > Vadjustment.Upper - Vadjustment.PageSize)
            {
                ScrollTo(XOffset, (int)(Vadjustment.Upper - Vadjustment.PageSize), false);
            }

            base.OnSizeAllocated(allocation);

            if (Fit)
            {
                ZoomFit(upscale);
            }
        }
        /// <summary>
        /// Enable Zoom and Pan Controls.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="selectionChanged">Selection changed callabck. Triggered when user select a point with selec tool.</param>
        /// <param name="cursorMoved">Cursor moved callabck. Triggered when user move the mouse in chart area.</param>
        /// <param name="zoomChanged">Callback triggered when chart has 
        /// zoomed in or out (and on first painting of the chart).</param>
        /// <param name="option">Additional user options</param>
        /// <remarks>
        /// <para>Callback are optional (pass in null to ignore).</para>
        /// <para>WARNING: Add or Remove Chart Area or Chart Series after enabled zoom and pan controls may cause unexpected behavior.</para>
        /// <para>Recommended to enable the zoom and pan controls after configure the <see cref="ChartArea"/> and <see cref="Series"/>.</para>
        /// </remarks>
        public static void EnableZoomAndPanControls(this Chart sender,
            CursorPositionChanged selectionChanged,
            CursorPositionChanged cursorMoved,
            ZoomChanged zoomChanged = null, ChartOption option = null)
        {
            if (!ChartTool.ContainsKey(sender))
            {
                ChartTool[sender] = new ChartData(sender);
                ChartData ptrChartData = ChartTool[sender];
                ptrChartData.Option = (option == null) ? new ChartOption() : option;
                ptrChartData.Backup();
                ptrChartData.PositionChangedCallback = selectionChanged;
                ptrChartData.CursorMovedCallback = cursorMoved;
                ptrChartData.ZoomChangedCallback = zoomChanged;

                //Scan through series to identify valid ChartArea
                Chart ptrChart = sender;
                foreach (ChartArea cArea in ptrChart.ChartAreas)
                {
                    IEnumerable<Series> chartSeries = ptrChart.Series.Where(n => n.ChartArea == cArea.Name);
                    if (chartSeries.Count() == 0)
                    {
                        Debug.WriteLine(string.Format("WARNING: Chart Area [{0}] does not contains any series.", cArea.Name));
                    }
                    else if (chartSeries.Where(n => UnsupportedChartType.Contains(n.ChartType)).Count() > 0)
                    {
                        Debug.WriteLine(string.Format("WARNING: Chart Area [{0}] contains unsupported series.", cArea.Name));
                    }
                    else ptrChartData.SupportedChartArea.Add(cArea);
                }

                //Populate Context menu
                if (ptrChart.ContextMenuStrip == null)
                {
                    //Context menu is empty, use ChartContextMenuStrip directly
                    ptrChart.ContextMenuStrip = new ContextMenuStrip();
                    ptrChart.ContextMenuStrip.Items.AddRange(ChartTool[ptrChart].MenuItems.ToArray());
                }
                else
                {
                    //User assigned context menu to chart. Merge current menu with ChartContextMenuStrip.
                    ContextMenuStrip newMenu = new ContextMenuStrip();
                    newMenu.Items.AddRange(ChartTool[sender].MenuItems.ToArray());

                    foreach (object ptrItem in ChartTool[sender].ContextMenuStrip.Items)
                    {
                        if (ptrItem is ToolStripMenuItem) newMenu.Items.Add(((ToolStripMenuItem)ptrItem).Clone());
                        else if (ptrItem is ToolStripSeparator) newMenu.Items.Add(new ToolStripSeparator());
                    }
                    ptrChart.ContextMenuStrip = newMenu;
                    ptrChart.ContextMenuStrip.AddHandlers(ChartTool[sender].ContextMenuStrip);
                }
                ptrChart.ContextMenuStrip.Opening += ChartContext_Opening;
                ptrChart.ContextMenuStrip.ItemClicked += ChartContext_ItemClicked;
                ptrChart.MouseWheel += ChartControl_MouseWheel;
                ptrChart.MouseDown += ChartControl_MouseDown;
                ptrChart.MouseMove += ChartControl_MouseMove;
                ptrChart.MouseUp += ChartControl_MouseUp;

                //Override settings.
                foreach (ChartArea ptrChartArea in ptrChart.ChartAreas)
                {
                    ptrChartArea.CursorX.AutoScroll = false;
                    ptrChartArea.CursorX.Interval = 1e-06;
                    ptrChartArea.CursorY.AutoScroll = false;
                    ptrChartArea.CursorY.Interval = 1e-06;

                    ptrChartArea.AxisX.ScrollBar.Enabled = false;
                    ptrChartArea.AxisX2.ScrollBar.Enabled = false;
                    ptrChartArea.AxisY.ScrollBar.Enabled = false;
                    ptrChartArea.AxisY2.ScrollBar.Enabled = false;
                }
                SetChartControlState(sender, MSChartExtensionToolState.Select);
            }
        }
Exemple #15
0
 /// <summary>
 /// Raises the ZoomChanged event when the zoom factor changed.
 /// </summary>
 protected virtual void OnZoomChanged(EventArgs e)
 {
     ZoomChanged?.Invoke(this, e);
 }
Exemple #16
0
 private void zoomSelectedIndexChanged(object sender, EventArgs e)
 {
     ZoomChanged?.Invoke(zoom.SelectedIndex + 1);
 }
 void HandleStaticZoomChanged(object sender, EventArgs e)
 {
     DisposeFont();
     ZoomChanged?.Invoke(this, EventArgs.Empty);
     OnChanged(EventArgs.Empty);
 }
Exemple #18
0
 private void OnZoomChanged(object sender, ZoomLevelChangedEventArgs args)
 {
     ZoomChanged?.Invoke((IWpfTextView)sender, args.NewZoomLevel);
 }
        /// <summary>
        /// Enable Zoom and Pan Controls.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="selectionChanged">Selection changed callabck. Triggered when user select a point with selec tool.</param>
        /// <param name="cursorMoved">Cursor moved callabck. Triggered when user move the mouse in chart area.</param>
        /// <param name="zoomChanged">Callback triggered when chart has 
        /// zoomed in or out (and on first painting of the chart).</param>
        /// <remarks>Callback are optional (pass in null to ignore).</remarks>
        public static void EnableZoomAndPanControls(this Chart sender,
            CursorPositionChanged selectionChanged,
            CursorPositionChanged cursorMoved,
            ZoomChanged zoomChanged = null)
        {
            if (!ChartTool.ContainsKey(sender))
            {
                ChartTool[sender] = new ChartData(sender);
                ChartData ptrChartData = ChartTool[sender];
                ptrChartData.Backup();
                ptrChartData.SelectionChangedCallback = selectionChanged;
                ptrChartData.CursorMovedCallback = cursorMoved;
                ptrChartData.ZoomChangedCallback = zoomChanged;

                //Populate Context menu
                Chart ptrChart = sender;
                if (ptrChart.ContextMenuStrip == null)
                {
                    //Context menu is empty, use ChartContextMenuStrip directly
                    ptrChart.ContextMenuStrip = new ContextMenuStrip();
                    ptrChart.ContextMenuStrip.Items.AddRange(ChartTool[ptrChart].MenuItems.ToArray());
                }
                else
                {
                    //User assigned context menu to chart. Merge current menu with ChartContextMenuStrip.
                    ContextMenuStrip newMenu = new ContextMenuStrip();
                    newMenu.Items.AddRange(ChartTool[sender].MenuItems.ToArray());

                    foreach (object ptrItem in ChartTool[sender].ContextMenuStrip.Items)
                    {
                        if (ptrItem is ToolStripMenuItem) newMenu.Items.Add(((ToolStripMenuItem)ptrItem).Clone());
                        else if (ptrItem is ToolStripSeparator) newMenu.Items.Add(new ToolStripSeparator());
                    }
                    newMenu.Items.Add(new ToolStripSeparator());
                    ptrChart.ContextMenuStrip = newMenu;
                    ptrChart.ContextMenuStrip.AddHandlers(ChartTool[sender].ContextMenuStrip);
                }
                ptrChart.ContextMenuStrip.Opening += ChartContext_Opening;
                ptrChart.ContextMenuStrip.ItemClicked += ChartContext_ItemClicked;
                ptrChart.MouseDown += ChartControl_MouseDown;
                ptrChart.MouseMove += ChartControl_MouseMove;
                ptrChart.MouseUp += ChartControl_MouseUp;
                ptrChart.PostPaint += ChartOnPostPaint; // Necessary to kickstart ZoomChanged callback

                // The following is for testing out the built-in events.
                //  They don't seem to be as reliable as just handling mouse up/move/down
                //ptrChart.CursorPositionChanging += (sender1, e) =>
                //    {
                //        // Changed event isn't triggered with any zoom or select operations! From looking at the Cursor.cs code, it seems to be a bug.
                //        // Changing event is raised twice, once for each cursor (X, Y)
                //        var axis = e.Axis;
                //    };
                //ptrChart.SelectionRangeChanging += (o, args) =>
                //    {
                //        // Changed event isn't triggered with any zoom or select operations!
                //        // Neither is changed event... odd
                //        Console.WriteLine("SelectionRangeChanging raised " + args.ToString());
                //        var axis = args.Axis;
                //        var chartArea = args.ChartArea;
                //    };

                //Override settings.
                ChartArea ptrChartArea = ptrChart.ChartAreas[0];
                ptrChartArea.CursorX.AutoScroll = false;
                ptrChartArea.CursorX.Interval = 1e-06;
                ptrChartArea.CursorY.AutoScroll = false;
                ptrChartArea.CursorY.Interval = 1e-06;

                ptrChartArea.AxisX.ScrollBar.Enabled = false;
                ptrChartArea.AxisX2.ScrollBar.Enabled = false;
                ptrChartArea.AxisY.ScrollBar.Enabled = false;
                ptrChartArea.AxisY2.ScrollBar.Enabled = false;

                SetChartControlState(sender, MSChartExtensionToolState.Select);
            }
        }
Exemple #20
0
 private void RaiseZoomChanged()
 {
     ZoomChanged?.Invoke(this, new EventArgs());
 }
Exemple #21
0
 private void OnZoomChanged(EventArgs e)
 {
     ZoomChanged?.Invoke(this, e);
 }
        /// <summary>
        /// Enable Zoom and Pan Controls.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="selectionChanged">Selection changed callabck. Triggered when user select a point with selec tool.</param>
        /// <param name="cursorMoved">Cursor moved callabck. Triggered when user move the mouse in chart area.</param>
        /// <param name="zoomChanged">Callback triggered when chart has
        /// zoomed in or out (and on first painting of the chart).</param>
        /// <remarks>Callback are optional (pass in null to ignore).</remarks>
        public static void EnableZoomAndPanControls(this Chart sender,
                                                    CursorPositionChanged selectionChanged,
                                                    CursorPositionChanged cursorMoved,
                                                    ZoomChanged zoomChanged = null)
        {
            if (!ChartTool.ContainsKey(sender))
            {
                ChartTool[sender] = new ChartData(sender);
                ChartData ptrChartData = ChartTool[sender];
                ptrChartData.Backup();
                ptrChartData.SelectionChangedCallback = selectionChanged;
                ptrChartData.CursorMovedCallback      = cursorMoved;
                ptrChartData.ZoomChangedCallback      = zoomChanged;

                //Populate Context menu
                Chart ptrChart = sender;
                if (ptrChart.ContextMenuStrip == null)
                {
                    //Context menu is empty, use ChartContextMenuStrip directly
                    ptrChart.ContextMenuStrip = new ContextMenuStrip();
                    ptrChart.ContextMenuStrip.Items.AddRange(ChartTool[ptrChart].MenuItems.ToArray());
                }
                else
                {
                    //User assigned context menu to chart. Merge current menu with ChartContextMenuStrip.
                    ContextMenuStrip newMenu = new ContextMenuStrip();
                    newMenu.Items.AddRange(ChartTool[sender].MenuItems.ToArray());

                    foreach (object ptrItem in ChartTool[sender].ContextMenuStrip.Items)
                    {
                        if (ptrItem is ToolStripMenuItem)
                        {
                            newMenu.Items.Add(((ToolStripMenuItem)ptrItem).Clone());
                        }
                        else if (ptrItem is ToolStripSeparator)
                        {
                            newMenu.Items.Add(new ToolStripSeparator());
                        }
                    }
                    newMenu.Items.Add(new ToolStripSeparator());
                    ptrChart.ContextMenuStrip = newMenu;
                    ptrChart.ContextMenuStrip.AddHandlers(ChartTool[sender].ContextMenuStrip);
                }
                ptrChart.ContextMenuStrip.Opening     += ChartContext_Opening;
                ptrChart.ContextMenuStrip.ItemClicked += ChartContext_ItemClicked;
                ptrChart.MouseDown += ChartControl_MouseDown;
                ptrChart.MouseMove += ChartControl_MouseMove;
                ptrChart.MouseUp   += ChartControl_MouseUp;
                ptrChart.PostPaint += ChartOnPostPaint; // Necessary to kickstart ZoomChanged callback

                // The following is for testing out the built-in events.
                //  They don't seem to be as reliable as just handling mouse up/move/down
                //ptrChart.CursorPositionChanging += (sender1, e) =>
                //    {
                //        // Changed event isn't triggered with any zoom or select operations! From looking at the Cursor.cs code, it seems to be a bug.
                //        // Changing event is raised twice, once for each cursor (X, Y)
                //        var axis = e.Axis;
                //    };
                //ptrChart.SelectionRangeChanging += (o, args) =>
                //    {
                //        // Changed event isn't triggered with any zoom or select operations!
                //        // Neither is changed event... odd
                //        Console.WriteLine("SelectionRangeChanging raised " + args.ToString());
                //        var axis = args.Axis;
                //        var chartArea = args.ChartArea;
                //    };


                //Override settings.
                ChartArea ptrChartArea = ptrChart.ChartAreas[0];
                ptrChartArea.CursorX.AutoScroll = false;
                ptrChartArea.CursorX.Interval   = 1e-06;
                ptrChartArea.CursorY.AutoScroll = false;
                ptrChartArea.CursorY.Interval   = 1e-06;

                ptrChartArea.AxisX.ScrollBar.Enabled  = false;
                ptrChartArea.AxisX2.ScrollBar.Enabled = false;
                ptrChartArea.AxisY.ScrollBar.Enabled  = false;
                ptrChartArea.AxisY2.ScrollBar.Enabled = false;

                SetChartControlState(sender, MSChartExtensionToolState.Select);
            }
        }
Exemple #23
0
 private void SetZoom(float value)
 {
     _zoom = Max(0f, value);
     RefreshImage();
     ZoomChanged?.Invoke(this, new EventArgs());
 }
Exemple #24
0
 protected virtual void OnZoomChanged(object sender, EventArgs e)
 {
     float.TryParse(txtZoom.Text, out _zoom);
     _eventArgs.Zoom = _zoom;
     ZoomChanged?.Invoke(this, _eventArgs);
 }
Exemple #25
0
 private void txtExpression_ZoomChanged(object sender, EventArgs e)
 {
     ZoomChanged?.Invoke(this, txtExpression.Zoom);
 }
 public void SetZoom(double newZoom)
 {
     Zoom = newZoom;
     ZoomChanged?.Invoke();
     Refresh();
 }
Exemple #27
0
 private void OnZoomChanged()
 {
     ZoomChanged?.Invoke(this, new CanvasZoomChangedEventArgs(zoomFactor));
 }
 private void DecreaseZoomButton_Click(object sender, EventArgs e)
 {
     ZoomChanged.Invoke(-1);
 }
Exemple #29
0
 void OnZoomChanged()
 {
     ZoomChanged?.Invoke(this, EventArgs.Empty);
 }
Exemple #30
0
 protected virtual void OnZoomChanged()
 {
     ZoomChanged?.Invoke(this, EventArgs.Empty);
 }