コード例 #1
0
        public static Grid SrcmbrHoverHandler(DataTable ContentTable, ScreenItemInstance Instance)
        {
            string srcmbr, srcfName, srcfLib;
            ObservableCollection <string> Lines = new ObservableCollection <string>();

            {
                var rv = GetSrcmbrName(ContentTable, Instance);
                srcfName = rv.Item1;
                srcfLib  = rv.Item2;
                srcmbr   = rv.Item3;
            }

            SrcmbrModel model = new SrcmbrModel()
            {
                Lines    = Lines,
                SrcfName = srcfName,
                Srcmbr   = srcmbr
            };

            var lines = GetSrcmbrLines(srcfName, srcfLib, srcmbr);

            foreach (var line in lines)
            {
                Lines.Add(line);
            }

            var grid = BuildControls(model);

            return(grid);
        }
コード例 #2
0
        private static Tuple <string, string, string> GetSrcmbrName(
            DataTable contentTable, ScreenItemInstance instance)
        {
            // get the row of the table.
            int rownum = instance.RepeatNum;

            if (rownum == 0)
            {
                rownum = 1;
            }

            var row      = contentTable.Rows[rownum - 1];
            var srcmbr   = row["MbrName"] as string;
            var srcfName = row["SrcfName"] as string;
            var srcfLib  = row["SrcfLib"] as string;

            return(new Tuple <string, string, string>(srcfName, srcfLib, srcmbr));
        }
コード例 #3
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);
        }