Example #1
0
        void AddGadget(object sender, MouseButtonEventArgs e)
        {
            Ewav.ContextMenu.MenuItem thisMenuItem = sender as Ewav.ContextMenu.MenuItem;

            GadgetManager gm = new GadgetManager();
            UserControl   uc = gm.LoadGadget(thisMenuItem.ControlID);

            double mouseHorizontalPosition, mouseVerticalPosition;

            uc.Name = ControlNameGenerator(uc);

            mouseVerticalPosition   = contextMenuRightClickCoords.Y - 55;
            mouseHorizontalPosition = contextMenuRightClickCoords.X;

            if (uc is XYChartControl)
            {
                ((XYChartControl)uc).SetChartTitle(((Ewav.ContextMenu.MenuItem)(sender)).Text.Replace(" ", ""));
            }

            cmnClass.AddControlToCanvas(uc, mouseVerticalPosition, mouseHorizontalPosition, applicationViewModel.LayoutRoot);
            MenuPopup(this, new EventArgs());

            root.Children.Remove(popupMenu);
        }
Example #2
0
        /// <summary>
        /// Constructor that instantiats the contextMenu.
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="StrataList"></param>
        /// <param name="selectedGadget"></param>
        /// <param name="canvas"></param>
        /// <returns></returns>
        public Menu CreateContextMenu(string controlName, Point mouseButtonCoords,
                                      List <Grid> StrataList, IGadget selectedGadget, Canvas canvas,
                                      Grid LayoutRoot, GridCells gc, GadgetParameters gp)
        {
            contextMenuRightClickCoords = mouseButtonCoords;

            cmnClass              = new ClientCommon.Common();
            popupMenu             = new Menu();
            this.StrataGridList   = StrataList;
            this.SelectedGadget   = selectedGadget;
            this.Root             = canvas;
            this.DgRoot           = (DragCanvas)canvas;
            this.ControlName      = controlName;
            this.GridCells        = gc;
            this.Gadgetparameters = gp;

            Ewav.ContextMenu.MenuItem mnuCopy;
            Ewav.ContextMenu.MenuItem mnuSendDataToHTML;
            Ewav.ContextMenu.MenuItem mnuSendToBack;
            Ewav.ContextMenu.MenuItem mnuClose;

            switch (controlName.ToUpper())
            {
            case "FREQUENCYCONTROL":
            case "MEANSCONTROL":
            case "MXNTABLECONTROL":
            case "TWOXTWOTABLECONTROL":
                mnuCopy = new Ewav.ContextMenu.MenuItem("Copy data to clipboard", "Images/clipboard.png");
                mnuCopy.MouseLeftButtonDown           += new MouseButtonEventHandler(mnuCopy_MouseLeftButtonDown);
                mnuSendDataToHTML                      = new Ewav.ContextMenu.MenuItem("Send data to web browser", "Images/webexport.png");
                mnuSendDataToHTML.MouseLeftButtonDown += new MouseButtonEventHandler(mnuSendDataToHTML_MouseLeftButtonDown);
                mnuSendToBack = new Ewav.ContextMenu.MenuItem("Send gadget to back", "Images/sendback.png");
                mnuSendToBack.MouseLeftButtonDown += new MouseButtonEventHandler(mnuSendToBack_MouseLeftButtonDown);
                mnuClose = new Ewav.ContextMenu.MenuItem("Close this gadget", "Images/closegadget.png");
                mnuClose.MouseLeftButtonDown += new MouseButtonEventHandler(mnuClose_MouseLeftButtonDown);
                popupMenu.Items.Add(mnuCopy);
                popupMenu.Items.Add(mnuSendDataToHTML);
                popupMenu.Items.Add(mnuSendToBack);
                popupMenu.Items.Add(mnuClose);
                break;

            case "COMBINEDFREQUENCY":
                mnuSendDataToHTML = new Ewav.ContextMenu.MenuItem("Send data to web browser", "Images/webexport.png");
                mnuSendDataToHTML.MouseLeftButtonDown += new MouseButtonEventHandler(mnuSendDataToHTML_MouseLeftButtonDown);
                mnuSendToBack = new Ewav.ContextMenu.MenuItem("Send gadget to back", "Images/sendback.png");
                mnuSendToBack.MouseLeftButtonDown += new MouseButtonEventHandler(mnuSendToBack_MouseLeftButtonDown);
                mnuClose = new Ewav.ContextMenu.MenuItem("Close this gadget", "Images/closegadget.png");
                mnuClose.MouseLeftButtonDown += new MouseButtonEventHandler(mnuClose_MouseLeftButtonDown);
                popupMenu.Items.Add(mnuSendDataToHTML);
                popupMenu.Items.Add(mnuSendToBack);
                popupMenu.Items.Add(mnuClose);
                break;

            case "ABERRATIONCONTROL":
            case "STATCALC2X2":
            case "BINOMIAL":
            case "COHORT":
            case "POPULATION":
            case "UNMATCHED":
            case "CHISQUARE":
            case "POISSON":
            case "LINELIST":
            case "MAPCONTROL":
            case "LOGISTICREGRESSION":
            case "LINEARREGRESSION":
                mnuSendToBack = new Ewav.ContextMenu.MenuItem("Send gadget to back", "Images/sendback.png");
                mnuSendToBack.MouseLeftButtonDown += new MouseButtonEventHandler(mnuSendToBack_MouseLeftButtonDown);
                mnuClose = new Ewav.ContextMenu.MenuItem("Close this gadget", "Images/closegadget.png");
                mnuClose.MouseLeftButtonDown += new MouseButtonEventHandler(mnuClose_MouseLeftButtonDown);
                popupMenu.Items.Add(mnuSendToBack);
                popupMenu.Items.Add(mnuClose);
                break;

            case "TEXTCONTROL":
                Ewav.ContextMenu.MenuItem mnuCloseTextControl = new Ewav.ContextMenu.MenuItem("Close this gadget", "Images/closegadget.png");
                mnuCloseTextControl.MouseLeftButtonDown += new MouseButtonEventHandler(mnuClose_MouseLeftButtonDown);
                Ewav.ContextMenu.MenuItem mnuStopEdit = new Ewav.ContextMenu.MenuItem("Show/Hide Tool Bar", "");
                mnuStopEdit.MouseLeftButtonDown += new MouseButtonEventHandler(mnuStopEdit_MouseLeftButtonDown);
                popupMenu.Items.Add(mnuStopEdit);
                popupMenu.Items.Add(mnuCloseTextControl);
                break;

            case "EPICURVE":
            case "SCATTER":
            case "XYCHARTCONTROL":
                Ewav.ContextMenu.MenuItem mnuSetChartTitle = new ContextMenu.MenuItem("Set Diplay options", "Images/title.png");
                mnuSetChartTitle.MouseLeftButtonDown += new MouseButtonEventHandler(mnuSetChartTitle_MouseLeftButtonDown);
                Ewav.ContextMenu.MenuItem munSaveAsImage = new ContextMenu.MenuItem("Save as Image", "Images/save1.png");
                munSaveAsImage.MouseLeftButtonDown += new MouseButtonEventHandler(munSaveAsImage_MouseLeftButtonDown);
                mnuSendToBack = new Ewav.ContextMenu.MenuItem("Send gadget toback", "Images/sendback.png");
                mnuSendToBack.MouseLeftButtonDown += new MouseButtonEventHandler(mnuSendToBack_MouseLeftButtonDown);
                mnuClose = new Ewav.ContextMenu.MenuItem("Close this gadget", "Images/closegadget.png");
                mnuClose.MouseLeftButtonDown += new MouseButtonEventHandler(mnuClose_MouseLeftButtonDown);
                if (SelectedGadget is IChartControl)
                {
                    if (((IChartControl)SelectedGadget).GetChartTypeEnum() != ClientCommon.XYControlChartTypes.Pie)
                    {
                        popupMenu.Items.Add(mnuSetChartTitle);
                    }
                }
                popupMenu.Items.Add(munSaveAsImage);
                popupMenu.Items.Add(mnuSendToBack);
                popupMenu.Items.Add(mnuClose);
                break;

            default:

                Ewav.ContextMenu.MenuItem GadgetSel = new Ewav.ContextMenu.MenuItem("", "");
                GadgetSel.IsEnabled  = false;
                GadgetSel.FontSize   = 0.2;
                GadgetSel.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
                Ewav.ContextMenu.MenuItem Gadget = new Ewav.ContextMenu.MenuItem("Add Gadgets", "Images/gadget.png");
                Gadget.IsEnabled            = !DisplayWithOutDSSelected;
                Gadget.MouseLeftButtonDown += new MouseButtonEventHandler(MouseLeftButtonDown);
                Ewav.ContextMenu.MenuItem Chart = new Ewav.ContextMenu.MenuItem("Add Charts", "Images/chart.png");
                Chart.IsEnabled            = !DisplayWithOutDSSelected;;
                Chart.MouseLeftButtonDown += new MouseButtonEventHandler(MouseLeftButtonDown);

                Ewav.ContextMenu.MenuDivider MD       = new MenuDivider();
                Ewav.ContextMenu.MenuItem    StatCalc = new Ewav.ContextMenu.MenuItem("Add StatCalc Calculator", "Images/calculator.png");
                StatCalc.MouseLeftButtonDown += new MouseButtonEventHandler(MouseLeftButtonDown);

                Ewav.ContextMenu.Menu subMenuGadget   = new Ewav.ContextMenu.Menu();
                Ewav.ContextMenu.Menu subMenuChart    = new Ewav.ContextMenu.Menu();
                Ewav.ContextMenu.Menu subMenuStatCalc = new Ewav.ContextMenu.Menu();

                List <EwavContextMenuItem> listOfItems = new List <EwavContextMenuItem>();
                listOfItems = applicationViewModel.MefEwavContextMenuItems;
                if (applicationViewModel.MefOrderDictionary != null)
                {
                    listOfItems.Clear();
                    var sortedList = from q in applicationViewModel.MefOrderDictionary orderby q.Key ascending select q;
                    foreach (var item in sortedList)
                    {
                        listOfItems.Add(((EwavContextMenuItem)item.Value));
                    }
                }

                foreach (EwavContextMenuItem ewavMenuItem in listOfItems)
                {
                    Ewav.ContextMenu.MenuItem gadgetItem = new ContextMenu.MenuItem(ewavMenuItem);
                    gadgetItem.MouseLeftButtonDown += new MouseButtonEventHandler(AddGadget);

                    switch (ewavMenuItem.Type)
                    {
                    case "chart":
                        subMenuChart.Items.Add(gadgetItem);
                        break;

                    case "gadget":
                        subMenuGadget.Items.Add(gadgetItem);
                        break;

                    case "statcalc":
                        subMenuStatCalc.Items.Add(gadgetItem);
                        break;

                    default:
                        break;
                    }
                }

                Gadget.Content   = subMenuGadget;
                Chart.Content    = subMenuChart;
                StatCalc.Content = subMenuStatCalc;

                foreach (Ewav.ContextMenu.MenuItem item in popupMenu.Items)
                {
                    if (item.Text == "Add Gadgets")
                    {
                        popupMenu.Items.Remove(item);
                    }
                }

                popupMenu.Items.Add(GadgetSel);
                popupMenu.Items.Add(Gadget);
                popupMenu.Items.Add(Chart);
                popupMenu.Items.Add(MD);
                popupMenu.Items.Add(StatCalc);
                break;
            }

            PopupMenu = popupMenu;

            return(popupMenu);
        }