コード例 #1
0
        //show tooltip when hovering over line in Variable plot
        void _hoverController_Hover_Var(object sender, EventArgs e)
        {
            if (!UsingKMeans)
            {
                int x = _hoverControllerVar.HoverScreenPosition.X;
                int y = _hoverControllerVar.HoverScreenPosition.Y;
                System.Drawing.Point mousePos = _hoverControllerVar.HoverPosition;

                //get country id
                int[] countryList = _pcPlotVariables.GetLineIndexesAtPosition(mousePos, 2).ToArray();
                //check if country is hidden
                int country = -1;
                if (countryList.Length > 0)
                {
                    for (int i = 0; i < countryList.Length; i++)
                    {
                        if (_pcPlotVariables.IndexVisibilityManager.GetVisibility(countryList[i]))
                        {
                            country = countryList[i];
                            break;
                        }
                    }
                }
                if (country > -1)
                {
                    //init tooltip
                    String tooltip = _mainWindow.DataHandler.RawDataProvider.NaNColumns[0][0][country].ToString();

                    // where to draw tooltip
                    //System.Drawing.Point atThisLocation = new System.Drawing.Point(_hoverControllerVar.HoverScreenPosition.X - 3, _hoverControllerVar.HoverScreenPosition.Y - 3);

                    //get current year
                    int year = _mainWindow.yearSlider.Value;
                    //loop over info to show in tooltip
                    for (int i = 0; i < _mainWindow.DataHandler.RawDataProvider.ColumnHeaders.Count; i++)
                    {
                        tooltip += "\n" + _mainWindow.DataHandler.RawDataProvider.ColumnHeaders[i];
                        tooltip += "   " + _mainWindow.DataHandler.getValueFromDataCube(i, country, year);
                    }
                    _gavToolTip.Text = tooltip;
                    _gavToolTip.Show(new System.Drawing.Point(x - 5, y - 5));
                }

                //tooltip for header names, funkar inte nu

                /*
                 * int header = _pcPlotVariables.AxisLayer.AxisAtPosition(new System.Drawing.Point(mousePos.X, mousePos.Y + 40), 5);
                 * if (header != -1)
                 * {
                 *  _gavToolTip.Text = _mainWindow.DataHandler.RawDataProvider.ColumnHeaders[header];
                 *  _gavToolTip.Show(new System.Drawing.Point(x,y));
                 * }
                 */
            }
        }
コード例 #2
0
 //show tooltip when hovering over line in Years plot
 void _hoverController_Hover_Year(object sender, EventArgs e)
 {
     if (!UsingKMeans)
     {
         //get country id
         int[] countryList = _pcPlotYears.GetLineIndexesAtPosition(_hoverControllerYear.HoverPosition, 2).ToArray();
         //check if country is hidden
         int country = -1;
         if (countryList.Length > 0)
         {
             for (int i = 0; i < countryList.Length; i++)
             {
                 if (_pcPlotYears.IndexVisibilityManager.GetVisibility(countryList[i]))
                 {
                     country = countryList[i];
                     break;
                 }
             }
         }
         if (country > -1)
         {
             //init tooltip
             String tooltip = _mainWindow.DataHandler.RawDataProvider.NaNColumns[0][0][country].ToString();
             // if no header has been selected set to zero
             int selectedHeader;
             if (_pcPlotVariables.HeaderLayer.SelectedHeadersList.Count > 0)
             {
                 selectedHeader = _pcPlotVariables.HeaderLayer.SelectedHeadersList[0];
             }
             else
             {
                 selectedHeader = 0;
             }
             // add header to tooltip
             tooltip += ":  " + _mainWindow.DataHandler.RawDataProvider.ColumnHeaders[selectedHeader];
             //loop over all years for the selected variable
             for (int year = 0; year < _mainWindow.DataHandler.RawDataProvider.GetDataCube().DataArray.GetLength(2); year++)
             {
                 tooltip += "\n" + (year + 1990) + "   " + _mainWindow.DataHandler.getValueFromDataCube(selectedHeader, country, year);
             }
             _gavToolTip.Text = tooltip;
             _gavToolTip.Show(_hoverControllerYear.HoverScreenPosition);
         }
     }
 }