Ejemplo n.º 1
0
        public object GetHoverData(EnhancedDataTable itemTable)
        {
            var srcmbr    = itemTable.SelectedRow["MbrName"].ToString();
            var srcfName  = itemTable.SelectedRow["SrcfName"].ToString();
            var srcfLib   = itemTable.SelectedRow["SrcfLib"].ToString();
            var hoverData = SrcmbrScripts.GetSrcmbrLines(srcfName, srcfLib, srcmbr);

            return(hoverData);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// fill and make visible the hover window.
        /// Called by the DrawHoverBox method of ItemCanvas.
        /// </summary>
        /// <param name="Position"></param>
        /// <param name="CanvasRowCol"></param>
        /// <param name="MatchScreenDefn"></param>
        /// <param name="Content"></param>
        public void DrawHoverBox(
            Point Position, IScreenLoc CanvasRowCol, IScreenDefn MatchScreenDefn,
            ScreenContent Content)
        {
            // first remove any existing popup hover box.
            RemoveHoverBox();

            // hovering on a screen with a screen defn. Find the item on the screen
            // which is being hovered over.
            string             itemName   = "";
            string             itemValue  = "";
            int                itemRowNum = 0;
            ScreenItemInstance hoverItem  = null;

            if ((MatchScreenDefn != null) && (CanvasRowCol != null))
            {
                var foundItem = MatchScreenDefn.FindItem(CanvasRowCol, Content);
                if (foundItem != null)
                {
                    hoverItem  = foundItem;
                    itemName   = foundItem.GetItemName().EmptyIfNull();
                    itemValue  = foundItem.GetValue(Content);
                    itemRowNum = foundItem.RepeatNum;
                }
            }

            // capture the contents of the screen to a DataTable.
            EnhancedDataTable itemTable = null;
            Grid   srcmbrGrid           = null;
            object hoverData            = null;
            string hoverXaml            = null;
            string hoverCode            = null;

            if ((MatchScreenDefn != null) && (hoverItem != null))
            {
                itemTable = MatchScreenDefn.Capture(Content, hoverItem);
                {
                    hoverXaml = FindHoverXaml(hoverItem.Item);
                    hoverCode = FindHoverCode(hoverItem.Item);
                }

                if (hoverCode.IsNullOrEmpty( ) == false)
                {
                    hoverData = CompileAndRunHoverCode(hoverCode, itemTable);
                }

                if ((MatchScreenDefn.ScreenName == "wrkmbrpdm") && (hoverData == null))
                {
                    // BgnTemp
                    {
                        if (itemTable.Rows.Count == 0)
                        {
                            var rep = Content.ToColumnReport("Content report");
                            rep.DebugPrint();
                            itemTable = MatchScreenDefn.Capture(Content, hoverItem);
                        }
                    }
                    // EndTemp

                    var srcmbr      = itemTable.SelectedRow["MbrName"].ToString();
                    var srcfName    = itemTable.SelectedRow["SrcfName"].ToString();
                    var srcfLib     = itemTable.SelectedRow["SrcfLib"].ToString();
                    var sourceLines = SrcmbrScripts.GetSrcmbrLines(srcfName, srcfLib, srcmbr);
                    hoverData = new { srcmbr, srcfName, srcfLib, sourceLines };
                }
            }

            Grid grid = null;

            if (hoverData != null)
            {
                if (hoverXaml.IsNullOrEmpty( ) == false)
                {
                    var sr     = new StringReader(hoverXaml);
                    var xr     = XmlReader.Create(sr);
                    var uiElem = XamlReader.Load(xr);
                    grid             = uiElem as Grid;
                    grid.DataContext = hoverData;
                }
                else
                {
                    var uiElem = hoverData.ToUIElement();
                    grid = uiElem as Grid;
                }
            }
            else
            {
                // create the controls that make up the hover control.
                ListBox lb = null;
                System.Windows.Controls.Canvas canvas = null;

                if (srcmbrGrid != null)
                {
                    var rv = BuildSrcmbrHoverGrid(srcmbrGrid);
                    grid = rv.Item1;
                }
                else
                {
                    var rv = BuildFoundation();
                    grid   = rv.Item1;
                    lb     = rv.Item2;
                    canvas = rv.Item3;

                    lb.Items.Add("field name:" + itemName);
                    lb.Items.Add("RowCol:" + CanvasRowCol.ToText());
                    lb.Items.Add("Value:" + itemValue);
                    lb.Items.Add("Row number:" + itemRowNum);
                }
            }

            ShowHoverBox(grid, Position);
        }