Example #1
0
        /// <summary>
        /// Updates a special menu item, the data item, with the currently available plot names. The active plot is marked with a
        /// check.
        /// </summary>
        public void UpdateDataPopup()
        {
            if (null == this.m_MenuDataPopup)
            {
                return;                 // as long there is no menu, we cannot do it
            }
            // first delete old menuitems
            this.m_MenuDataPopup.MenuItems.Clear();


            // check there is at least one layer
            if (m_Graph.Layers.Count == 0)
            {
                return;                 // there is no layer, we can not have items in the data menu
            }
            // now it is save to get the active layer
            int         actLayerNum = this.CurrentLayerNumber;
            XYPlotLayer actLayer    = this.Layers[actLayerNum];

            // then append the plot associations of the actual layer

            int actPA = CurrentPlotNumber;
            int len   = actLayer.PlotItems.Flattened.Length;

            for (int i = 0; i < len; i++)
            {
                IGPlotItem   pa = actLayer.PlotItems.Flattened[i];
                DataMenuItem mi = new DataMenuItem(pa.ToString(), new EventHandler(EhMenuData_Data));
                mi.Checked        = (i == actPA);
                mi.PlotItemNumber = i;
                this.m_MenuDataPopup.MenuItems.Add(mi);
            }
        }
Example #2
0
        public IEnumerable <object> BuildItems(Codon codon, object owner)
        {
            var ctrl = Current.Workbench.ActiveViewContent as Altaxo.Gui.Graph.Gdi.Viewing.GraphController;

            if (null == ctrl)
            {
                return(null);
            }
            var activeLayer = ctrl.ActiveLayer as XYPlotLayer;

            if (null == activeLayer)
            {
                return(null);
            }

            int actPA = ctrl.CurrentPlotNumber;
            int len   = activeLayer.PlotItems.Flattened.Length;
            var items = new List <object>();

            for (int i = 0; i < len; i++)
            {
                IGPlotItem pa   = activeLayer.PlotItems.Flattened[i];
                var        item = new System.Windows.Controls.MenuItem()
                {
                    Header = pa.ToString()
                };
                item.Click    += EhWpfMenuItem_Clicked;
                item.IsChecked = (i == actPA);
                item.Tag       = i;
                items.Add(item);
            }

            return(items);
        }
Example #3
0
        /// <summary>
        /// Handles the double click event onto a plot item.
        /// </summary>
        /// <param name="hit">Object containing information about the double clicked object.</param>
        /// <returns>True if the object should be deleted, false otherwise.</returns>
        protected static bool EhEditPlotItem(IHitTestObject hit)
        {
            XYPlotLayer actLayer = hit.ParentLayer;
            IGPlotItem  pa       = (IGPlotItem)hit.HittedObject;


            // get plot group
            PlotGroupStyleCollection plotGroup = pa.ParentCollection.GroupStyles;

            Current.Gui.ShowDialog(new object[] { pa }, string.Format("#{0}: {1}", pa.Name, pa.ToString()), true);

            return(false);
        }
Example #4
0
        /// <summary>
        /// Handler for all submenu items of the data popup.".
        /// </summary>
        /// <param name="sender">The menuitem, must be of type <see cref="DataMenuItem"/>.</param>
        /// <param name="e">Not used.</param>
        /// <remarks>The handler either checks the menuitem, if it was unchecked. If it was already checked,
        /// it shows the LineScatterPlotStyleControl into a dialog box.
        /// </remarks>
        private void EhMenuData_Data(object sender, System.EventArgs e)
        {
            DataMenuItem dmi = (DataMenuItem)sender;

            if (!dmi.Checked)
            {
                // if the menu item was not checked before, check it now
                // by making the plot association shown by the menu item
                // the actual plot association
                int         actLayerNum = this.CurrentLayerNumber;
                XYPlotLayer actLayer    = this.Layers[actLayerNum];
                if (null != actLayer && dmi.PlotItemNumber < actLayer.PlotItems.Flattened.Length)
                {
                    dmi.Checked       = true;
                    CurrentPlotNumber = dmi.PlotItemNumber;
                }
            }
            else
            {
                // if it was checked before, then bring up the plot style dialog
                // of the plot association represented by this menu item
                int         actLayerNum = this.CurrentLayerNumber;
                XYPlotLayer actLayer    = this.Layers[actLayerNum];
                IGPlotItem  pa          = actLayer.PlotItems.Flattened[CurrentPlotNumber];

                Current.Gui.ShowDialog(new object[] { pa }, string.Format("#{0}: {1}", pa.Name, pa.ToString()), true);
            }
        }
Example #5
0
        private void EhWpfMenuItem_Clicked(object sender, System.Windows.RoutedEventArgs e)
        {
            var dmi            = (System.Windows.Controls.MenuItem)sender;
            int plotItemNumber = (int)dmi.Tag;

            var ctrl = Current.Workbench.ActiveViewContent as Altaxo.Gui.Graph.Gdi.Viewing.GraphController;

            if (null == ctrl)
            {
                return;
            }
            var activeLayer = ctrl.ActiveLayer as XYPlotLayer;

            if (null == activeLayer)
            {
                return;
            }

            if (!dmi.IsChecked)
            {
                // if the menu item was not checked before, check it now
                // by making the plot association shown by the menu item
                // the actual plot association
                if (null != activeLayer && plotItemNumber < activeLayer.PlotItems.Flattened.Length)
                {
                    dmi.IsChecked          = true;
                    ctrl.CurrentPlotNumber = plotItemNumber;
                }
            }
            else
            {
                IGPlotItem pa = activeLayer.PlotItems.Flattened[plotItemNumber];
                Current.Gui.ShowDialog(new object[] { pa }, string.Format("#{0}: {1}", pa.Name, pa.ToString()), true);
            }
        }