public ScreenContent Render(string content, IDisplay display)
        {
            //var parts = content.Split(' ');
            //var output = new ScreenContent();
            //var pos = 0;

            //foreach (var part in parts)
            //{
            //    // fit part on current line
            //    if (part.Length + pos < display.Columns)
            //    {
            //        output.AppendContent(part + " ");
            //        pos += part.Length + 1;

            //        continue;
            //    }

            //    // fit part on a whole line
            //    if 
            //}

            var output = new ScreenContent();

            if (string.IsNullOrEmpty(content))
                return output;

            var pos = 0;

            for (int row = 0; row < display.Rows; row++)
            {
                // stop if content is too short
                if (pos >= content.Length)
                    break;

                // skip empty space
                if (content[pos] == ' ')
                    pos++;

                var end = pos + display.Columns;

                output.AppendRow(
                    content.Substring(
                        pos, 
                        (end > content.Length 
                            ? content.Length - pos
                            : end - pos)));

                pos += display.Columns;
            }

            return output;
        }
        public static byte[] BuildSaveScreenResponse(ScreenContent ScreenContent)
        {
            var ra = new ByteArrayBuilder();

            // data stream header.
            {
                var buf = DataStreamHeader.Build(50, TerminalOpcode.SaveScreen, 0, 0);
                ra.Append(buf);
            }

            // restore screen workstation command.
            {
                var cmd = new RestoreScreenCommand();
                ra.Append(cmd.ToBytes());
            }

            // clear unit command.
            if (ScreenContent.ScreenDim.GetIsWideScreen( ) == true)
            {
                var cmd = new ClearUnitAlternateCommand(0x00);
                ra.Append(cmd.ToBytes());
            }
            else
            {
                var cmd = new ClearUnitCommand();
                ra.Append(cmd.ToBytes());
            }

            // WTD command.
            {
                var ordersByteStream = ScreenContent.BuildOrderStream( );
                var buf = WriteToDisplayCommand.Build(0x00, 0x18, ordersByteStream);
                ra.Append(buf);
            }

            // update length of response data stream.
            {
                var wk = new ByteArrayBuilder();
                wk.AppendBigEndianShort((short)ra.Length);
                ra.CopyToBuffer(wk.ToByteArray(), 0);
            }

            // IAC EOR
            {
                ra.Append(EOR_Command.Build());
            }

            return(ra.ToByteArray());
        }
        public static bool Match(this IScreenSection section, ScreenContent Content, string DebugInfo)
        {
            bool isMatch    = true;
            var  header     = section as ISectionHeader;
            var  sectionDim = section.CalcDim();

            IScreenLoc start = section.ScreenLoc;
            {
                start = start.NewInstance(start.RowNum, start.ColNum);
            }

            int  repeatIx  = 0;
            bool endOfRows = false;

            while (isMatch == true)
            {
                if ((repeatIx > 0) && (repeatIx >= section.RepeatCount))
                {
                    break;
                }
                repeatIx += 1;

                // section is a subfile. subfile row can be blank. If blank consider as
                // the end of rows of the subfile. So no need to match.
                bool rowIsBlank = false;
                if (section.PurposeCode == ScreenPurposeCode.ReportDetail)
                {
                    if (Content.RowIsBlank(start.RowNum) == true)
                    {
                        rowIsBlank = true;
                    }
                }

                // a blank row. no more rows to match.
                if (rowIsBlank == true)
                {
                    endOfRows = true;
                }

                if (endOfRows == false)
                {
                    isMatch = header.Match(start, Content, DebugInfo);
                }
                start.RowNum += 1;
            }

            return(isMatch);
        }
Example #4
0
        private IScreenDefn FindMatchingScreenDefn(
            ScreenContent Content, ScreenDefnList ScreenDefnList)
        {
            IScreenDefn matchDefn = null;

            foreach (var screenDefn in ScreenDefnList)
            {
                var isMatch = screenDefn.Match(Content);
                if (isMatch == true)
                {
                    matchDefn = screenDefn;
                    break;
                }
            }
            return(matchDefn);
        }
Example #5
0
 public bool TryParseMode(string mode, out object data)
 {
     if (string.Equals(mode, "total", StringComparison.CurrentCultureIgnoreCase))
     {
         data = new ScreenContent(true);
     }
     else if (string.Equals(mode, "each", StringComparison.CurrentCultureIgnoreCase))
     {
         data = new ScreenContent(false);
     }
     else
     {
         data = null;
     }
     return(data != null);
 }
Example #6
0
        public static ScreenItemInstance FindItem(
            this ISectionHeader section, IScreenLoc Start, IScreenLoc FindLoc, ScreenContent Content)
        {
            ScreenItemInstance findItem = null;

            // find the screenitem located at the find location.
            foreach (var item in section.Items)
            {
                findItem = item.FindItem(Start, FindLoc, Content);
                if (findItem != null)
                {
                    break;
                }
            }

            return(findItem);
        }
Example #7
0
        /// <summary>
        /// convert RowCol from whatever it is relative to to a value that is
        /// relative to the entire telnet screen.
        /// </summary>
        /// <param name="RowCol"></param>
        /// <param name="WindowContent"></param>
        /// <returns></returns>
        public static IRowCol ToParentRelative(
            this IRowCol RowCol, ScreenContent WindowContent)
        {
            if (RowCol.RowColRelative == RowColRelative.Parent)
            {
                return(RowCol);
            }

            // convert RowCol from local to window to absolute screen loc.
            else
            {
                var  rowNum = RowCol.RowNum + RowCol.ContentStart.Y;
                var  colNum = RowCol.ColNum + RowCol.ContentStart.X;
                bool forceParentRelative = true;
                return(RowCol.NewRowCol(rowNum, colNum, null, forceParentRelative));
            }
        }
Example #8
0
        private ScreenContent CreateNewScreenContent()
        {
            ScreenContent sc = new ScreenContent();

            sc.ScreenContentID     = 0;
            sc.AccountID           = 0;
            sc.ScreenContentTypeID = 0;
            sc.ScreenContentName   = String.Empty;
            sc.ScreenContentTitle  = String.Empty;
            sc.ThumbnailImageID    = 0;
            sc.CustomField1        = String.Empty;
            sc.CustomField2        = String.Empty;
            sc.CustomField3        = String.Empty;
            sc.CustomField4        = String.Empty;
            sc.IsActive            = true;

            return(sc);
        }
Example #9
0
        private void BuildAndSendResponseDataStream(
            AidKey AidKey, ScreenContent ScreenContent, TelnetLogList LogList = null)
        {
            // send response data stream up to the server.
            {
                var ra = BuildResponseByteStream(
                    ScreenContent,
                    AidKey, ScreenContent.CaretRowCol, ScreenContent.HowRead);
                ra = ra.Append(EOR_Command.Build());

                // send response stream back to server.
                TelnetConnection.WriteToHost(LogList, ra, this.Client.GetStream());

                // blank line in the log file.
                var logItem = new LogListItem(Direction.Read, "", true);
                this.LogList.AddItem(logItem);
            }
        }
Example #10
0
        /// <summary>
        /// determine if the ScreenDefn matches the screen content.
        /// </summary>
        /// <param name="Content"></param>
        /// <returns></returns>
        public static bool Match(this IScreenDefn Defn, ScreenContent Content)
        {
            bool isMatch = true;

            // BgnTemp
            // SpecialLogFile.AppendTextLines(this.ToColumnReport());
            // EndTemp

            // extract all ContentText on the screen. Add to FieldDict.
            Content.AddAllContentText();

            ISectionHeader sectionHeader = Defn as ISectionHeader;
            var            start         = new OneScreenLoc(1, 1);

            isMatch = sectionHeader.Match(start, Content, Defn.ScreenName);

            return(isMatch);
        }
Example #11
0
        /// <summary>
        /// capture the data of the screen to a DataTable class.
        /// </summary>
        /// <param name="Defn"></param>
        /// <param name="Content"></param>
        /// <returns></returns>
        public static EnhancedDataTable Capture(
            this IScreenDefn Defn, ScreenContent Content,
            ScreenItemInstance ItemInstance = null)
        {
            ISectionHeader sectionHeader = Defn as ISectionHeader;
            var            start         = new OneScreenLoc(1, 1);
            var            report        = sectionHeader.CaptureToReport(start, Content);
            var            table         = report.ToDataTable();

            // mark the selected datarow in the dataTable.
            int rownum = 0;

            if ((ItemInstance != null) && (ItemInstance.RepeatNum > 0))
            {
                rownum = ItemInstance.RepeatNum - 1;
            }
            table.MarkSelectedRow(rownum);

            return(table);
        }
Example #12
0
        private ScreenContent FillNulls(ScreenContent screencontent)
        {
            if (screencontent.CustomField1 == null)
            {
                screencontent.CustomField1 = String.Empty;
            }
            if (screencontent.CustomField2 == null)
            {
                screencontent.CustomField2 = String.Empty;
            }
            if (screencontent.CustomField3 == null)
            {
                screencontent.CustomField3 = String.Empty;
            }
            if (screencontent.CustomField4 == null)
            {
                screencontent.CustomField4 = String.Empty;
            }

            return(screencontent);
        }
Example #13
0
        public void Render(Window window, StringBuilder text, ref MySpriteDrawFrame frame)
        {
            ScreenContent content = window.GetData <ScreenContent>();

            if (Monitor.Updating || content == null)
            {
                return;
            }
            if (content.Total)
            {
                RenderTotal(window, content);
            }
            else
            {
                RenderAll(window, content);
            }
            frame.AddRange(content.StaticSprites);
            foreach (var pb in content.ProgressBars)
            {
                frame.AddRange(pb);
            }
        }
Example #14
0
        private List <SelectListItem> BuildScreenScreenContentList(int screenid)
        {
            List <SelectListItem> items = new List <SelectListItem>();

            IScreenContentRepository              screp  = new EntityScreenContentRepository();
            IScreenContentTypeRepository          sctrep = new EntityScreenContentTypeRepository();
            IScreenScreenContentXrefRepository    sscrep = new EntityScreenScreenContentXrefRepository();
            IEnumerable <ScreenScreenContentXref> sscs   = sscrep.GetScreenScreenContentXrefs(screenid);

            foreach (ScreenScreenContentXref ssc in sscs)
            {
                ScreenContent     sc  = screp.GetScreenContent(ssc.ScreenContentID);
                ScreenContentType sct = sctrep.GetScreenContentType(sc.ScreenContentTypeID);

                SelectListItem item = new SelectListItem();
                item.Text  = sc.ScreenContentName + " (" + sct.ScreenContentTypeName + ")";
                item.Value = sc.ScreenContentID.ToString();
                items.Add(item);
            }

            return(items);
        }
Example #15
0
        private string ValidateInput(ScreenContent screencontent)
        {
            if (screencontent.AccountID == 0)
            {
                return("Account ID is not valid.");
            }

            if (String.IsNullOrEmpty(screencontent.ScreenContentName))
            {
                return("Screen Content Name is required.");
            }

            if (String.IsNullOrEmpty(screencontent.ScreenContentTitle))
            {
                return("Screen Content Title is required.");
            }

            if (screencontent.ScreenContentTypeID == 0)
            {
                return("You must select a Screen Content Type.");
            }

            if (String.IsNullOrEmpty(screencontent.ScreenContentName))
            {
                return("Screen Content Name is required.");
            }

            if (screencontent.ThumbnailImageID == 0)
            {
                return("You must select a Thumbnail Image.");
            }

            // Validate based on selected type


            return(String.Empty);
        }
Example #16
0
        public static DataItemReport CaptureToReport(
            this ISectionHeader section, IScreenLoc Start, ScreenContent Content)
        {
            var report = new DataItemReport();
            var row    = new DataItemList();

            // capture item data from each item of the section that is marked for capture.
            // ( by default, all ScreenField items are captured. )
            foreach (var item in section.Items)
            {
                var rv         = item.CaptureReport(Start, Content);
                var dataItem   = rv.Item1;
                var itemReport = rv.Item2;

                if (dataItem != null)
                {
                    report.Columns.Add(dataItem.ToColumnDefn());
                    row.Add(dataItem);
                }

                // this item is a section. The capture function returned a DataItemReport
                // contains the data of the report. Join that report with what has been
                // captured up to this point.
                if (itemReport != null)
                {
                    var comboReport = DataItemReport.CombineHorizontally(report, itemReport);
                    report = comboReport;
                }
            }

            if (row.Count > 0)
            {
                report.Rows.Add(row);
            }

            return(report);
        }
Example #17
0
        public static IEnumerable <string> ReportVisualItems(
            this ScreenContent ScreenContent, ItemCanvas TelnetCanvas)
        {
            var report = new List <string>();

            {
                var itemCanvas = ScreenContent.FindItemCanvas(TelnetCanvas);
                if (itemCanvas == null)
                {
                    throw new Exception("item canvas of screen content is not  found");
                }

                var subReport = ReportVisualItems_Actual(
                    ScreenContent, itemCanvas, "Telnet Canvas Visual Items");
                report.AddRange(subReport);
            }

            // report the visual items of each child screenContent. ( windows on the
            // canvas. )
            if (ScreenContent.Children != null)
            {
                foreach (var childContent in ScreenContent.Children)
                {
                    var itemCanvas = childContent.FindItemCanvas(TelnetCanvas);
                    if (itemCanvas == null)
                    {
                        throw new Exception("item canvas of screen content is not  found");
                    }

                    var subReport = ReportVisualItems_Actual(
                        childContent, itemCanvas, "Window Canvas Visual Items");
                    report.AddRange(subReport);
                }
            }

            return(report);
        }
Example #18
0
        public VisualItem VisualItemFactory(ScreenContent ScreenContent, ContentField contentField)
        {
            VisualItem visualItem = null;

            if (contentField is ContinuedContentField)
            {
                var contField = contentField as ContinuedContentField;
                if (contField.ContinuedFieldSegmentCode == ContinuedFieldSegmentCode.First)
                {
                    visualItem =
                        new VisualSpanner(ScreenContent, contField, this.CanvasDefn);
                }
            }
            else
            {
                visualItem = this.VisualItemFactory(
                    contentField.GetShowText(ScreenContent),
                    contentField.RowCol,
                    contentField.GetAttrByte(ScreenContent),
                    contentField.GetTailAttrByte(ScreenContent));
            }

            return(visualItem);
        }
Example #19
0
        void RenderAll(Window window, ScreenContent content)
        {
            int count = Monitor.Batteries.Count;

            if (content.StaticSprites.Length != 1 || content.ProgressBars.Length != count)
            {
                content.StaticSprites    = new MySprite[1];
                content.StaticSprites[0] = window.Surface.FitText("Battery Status", window.Area.SubRect(0.1f, 0.0f, 0.8f, 0.15f), "Debug", window.Surface.ScriptForegroundColor);
                content.ProgressBars     = new ProgressBar[count];
                int i = 0;
                foreach (var a in window.Surface.MakeTable(count, 2.0f, new Vector2(0.01f, 0.01f), new Vector2(0.01f, 0.01f), window.Area.SubRect(0.0f, 0.2f, 1.0f, 0.8f)))
                {
                    string fmt = Monitor.Batteries[i].Battery.IsSameConstructAs(Owner.PB.Me)
                        ? " {0:P1} " : "[{0:P1}]";
                    content.ProgressBars[i] = new ProgressBar(window.Surface, a,
                                                              window.Surface.ScriptForegroundColor, Color.Black, window.Surface.ScriptForegroundColor,
                                                              fmt);
                    i++;
                }
            }
            for (int i = 0; i < count; i++)
            {
                content.StaticSprites[0].Color = window.Surface.ScriptForegroundColor;
                float delta = Monitor.Batteries[i].Input.Current - Monitor.Batteries[i].Output.Current;
                if (Math.Abs(delta) > 0.1)
                {
                    content.ProgressBars[i].ForegroundColor = (delta > 0) ? Color.Green : Color.Red;
                }
                else
                {
                    content.ProgressBars[i].ForegroundColor = Color.Blue;
                }
                content.ProgressBars[i].PollColors();
                content.ProgressBars[i].Value = Monitor.Batteries[i].Charge.GetRatio();
            }
        }
Example #20
0
        public static IRowCol ToContentRelative(
            this IRowCol RowCol, ScreenContent ScreenContent)
        {
            if (RowCol.RowColRelative == ScreenContent.ContentRelative)
            {
                return(RowCol);
            }

            // convert RowCol to location relative to a window.
            else if (RowCol.RowColRelative == RowColRelative.Parent)
            {
                var rowNum = RowCol.RowNum - ScreenContent.StartRowCol.RowNum;
                var colNum = RowCol.ColNum - ScreenContent.StartRowCol.ColNum;
                return(RowCol.NewRowCol(rowNum, colNum, ScreenContent));
            }

            // convert RowCol from local to window to absolute screen loc.
            else
            {
                var rowNum = RowCol.RowNum + RowCol.ContentStart.Y;
                var colNum = RowCol.ColNum + RowCol.ContentStart.X;
                return(RowCol.NewRowCol(rowNum, colNum, ScreenContent));
            }
        }
Example #21
0
        static Tuple <ScreenContent, ScreenContent> ProcessClearUnit(
            this ScreenContent InBaseMaster, ScreenDim ScreenDim,
            PaintThread PaintThread)
        {
            var baseMaster = InBaseMaster;

            baseMaster = new ScreenContent(
                null, ScreenDim, baseMaster.ContentOdom);
            var master = baseMaster.GetWorkingContentBlock();

            // post ClearUnit message to paint thread.
            {
                var cu = new ClearUnitMessage(master.ContentNum);
                PaintThread.PostInputMessage(cu);
            }

            // mark the screenContent as having ClearUnit applied on it. When the SCB
            // is sent to the PaintThread code there will clear the TelnetCanvas and
            // dispose of any window item canvases.
            // todo: Send ClearUnitMessage to PaintThread. Get rid of DoClearUnit flag.
            baseMaster.DoClearUnit = true;

            return(new Tuple <ScreenContent, ScreenContent>(baseMaster, master));
        }
 public void UpdateScreenContent(ScreenContent screencontent)
 {
     db.Entry(screencontent).State = EntityState.Modified;
     db.SaveChanges();
 }
 public void CreateScreenContent(ScreenContent screencontent)
 {
     db.ScreenContents.Add(screencontent);
     db.SaveChanges();
 }
Example #24
0
        /// <summary>
        /// apply the commands of the workstation command list to the screen content
        /// block.
        /// </summary>
        /// <param name="applyMaster"></param>
        /// <param name="CmdList"></param>
        /// <param name="ToThread"></param>
        /// <param name="LogList"></param>
        /// <returns></returns>
        public static Tuple <bool, ScreenContent> Apply(
            this ScreenContent InBaseMaster,
            WorkstationCommandList CmdList,
            ToThread ToThread, PaintThread PaintThread, TelnetLogList LogList)
        {
            bool wtdApplied = false;
            var  baseMaster = InBaseMaster;
            var  master     = baseMaster.GetWorkingContentBlock();

            foreach (var cmdBase in CmdList)
            {
                if (cmdBase is ClearUnitCommand)
                {
                    var rv = ProcessClearUnit(baseMaster, baseMaster.ScreenDim, PaintThread);
                    baseMaster = rv.Item1;
                    master     = rv.Item2;
                }

                // same as ClearUnit. Only signals that a wide screen to be used.
                else if (cmdBase is ClearUnitAlternateCommand)
                {
                    var cua = cmdBase as ClearUnitAlternateCommand;

                    // screen size.
                    ScreenDim screenDim;
                    if (cua.RequestByte == 0x00)
                    {
                        screenDim = new ScreenDim(27, 132);
                    }
                    else
                    {
                        screenDim = new ScreenDim(24, 80);
                    }

                    var rv = ProcessClearUnit(baseMaster, screenDim, PaintThread);
                    baseMaster = rv.Item1;
                    master     = rv.Item2;
                }

                // apply the orders of the WriteToDisplay command.
                else if (cmdBase is WriteToDisplayCommand)
                {
                    var curMaster = master.Apply(cmdBase as WriteToDisplayCommand);
                    master     = curMaster;
                    wtdApplied = true;
                }

                else if (cmdBase is ReadMdtFieldsCommand)
                {
                    master.HowRead = HowReadScreen.ReadMdt;
                }

                // save screen command. Build response, send back to server.
                else if (cmdBase is SaveScreenCommand)
                {
                    var msg = new SaveScreenMessage(master.Copy());
                    ToThread.PostInputMessage(msg);
                }

                // read screen command. Build response, send back to server.
                else if (cmdBase is ReadScreenCommand)
                {
                    var msg = new ReadScreenMessage(master.Copy());
                    ToThread.PostInputMessage(msg);
                }

                else if (cmdBase is WriteStructuredFieldCommand)
                {
                    var wsfCmd = cmdBase as WriteStructuredFieldCommand;
                    if (wsfCmd.RequestCode == WSF_RequestCode.Query5250)
                    {
                        var msg = new Query5250ResponseMessage();
                        ToThread.PostInputMessage(msg);
                    }
                }
                else if (cmdBase is WriteSingleStructuredFieldCommand)
                {
                }
            }
            return(new Tuple <bool, ScreenContent>(wtdApplied, baseMaster));
        }
        private ScreenContent CreateExampleScreenContent(int accountid, string screencontentname, string screencontenttitle, int screencontenttypeid, int thumbnailimageid, string customfield1)
        {
            try
            {
                IScreenContentRepository screencontentrep = new EntityScreenContentRepository();
                ScreenContent content = new ScreenContent();
                content.AccountID = accountid;
                content.ScreenContentName = screencontentname;
                content.ScreenContentTitle = screencontenttitle;
                content.ScreenContentTypeID = screencontenttypeid;
                content.ThumbnailImageID = thumbnailimageid;
                content.CustomField1 = customfield1;
                content.CustomField2 = String.Empty;
                content.CustomField3 = String.Empty;
                content.CustomField4 = String.Empty;
                content.IsActive = true;
                screencontentrep.CreateScreenContent(content);

                return content;
            }
            catch { return null; }
        }
Example #26
0
        /// <summary>
        /// paint the text and fields of the screen content block onto the item canvas.
        /// </summary>
        /// <param name="ScreenContent"></param>
        /// <param name="ItemCanvas"></param>
        /// <param name="Window"></param>
        public static void PaintScreenContent(this ScreenContent ScreenContent,
                                              ItemCanvas ItemCanvas)
        {
            // use ContentNum to match ScreenContent with the ItemCanvas.
            ItemCanvas.ContentNum = ScreenContent.ContentNum;

            // apply the clear unit command to the itemcanvas.
            if (ScreenContent.DoClearUnit == true)
            {
                ItemCanvas.EraseScreen();
                ScreenContent.DoClearUnit = false;
            }

            else
            {
                // add ContentText items to the ContentDict of the SCB.
                ScreenContent.AddAllContentText();
            }

            // Remove all items on the ItemCanvas that are not in the SCB.
            // todo: need to clear the caret position if field removed from the screen
            //       contains the caret.
            var visualItems = ItemCanvas.VisualItems;

            foreach (var itemCursor in visualItems.ItemList())
            {
                var             vi          = itemCursor.GetVisualItem();
                var             rowCol      = vi.ItemRowCol;
                ContentItemBase contentItem = null;
                var             rc          = ScreenContent.FieldDict.TryGetValue(rowCol, out contentItem);
                if (rc == false)
                {
                    visualItems.RemoveItem(itemCursor, ItemCanvas);
                }
            }

            // loop for each item within the content array.
            foreach (var contentItem in ScreenContent.ContentItems())
            {
                if (contentItem is ContentText)
                {
                    var contentText = contentItem as ContentText;
                    var visualItem  = ItemCanvas.VisualItemFactory(
                        contentText.GetShowText(ScreenContent),
                        contentText.RowCol, contentText.GetAttrByte(ScreenContent),
                        contentText.GetTailAttrByte(ScreenContent));

                    var iMore = visualItem as IVisualItemMore;
                    var node  = iMore.InsertIntoVisualItemsList(ItemCanvas.VisualItems);
                    iMore.AddToCanvas(ItemCanvas);
                    iMore.SetupUnderline();
                }

                else if (contentItem is ContentField)
                {
                    var contentField = contentItem as ContentField;
                    var visualItem   =
                        ItemCanvas.VisualItemFactory(ScreenContent, contentField);

                    if (visualItem != null)
                    {
                        var iMore = visualItem as IVisualItemMore;
                        var node  = iMore.InsertIntoVisualItemsList(ItemCanvas.VisualItems);
                        iMore.AddToCanvas(ItemCanvas);
                        iMore.SetupUnderline();
                        iMore.SetupFieldItem(
                            ScreenContent, contentField,
                            ItemCanvas.CanvasDefn.CharBoxDim, ItemCanvas.CanvasDefn.KernDim);
                    }
                }
            }

            // position the caret.
            ItemCanvas.PositionCaret(ScreenContent.CaretRowCol);
            ItemCanvas.SetFocus();
        }
Example #27
0
        /// <summary>
        /// apply the orders of the WriteToDisplay command to the screen content
        /// block.
        /// </summary>
        /// <param name="ApplyMaster"></param>
        /// <param name="wtdCmd"></param>
        /// <returns></returns>
        public static ScreenContent Apply(
            this ScreenContent ApplyMaster, WriteToDisplayCommand wtdCmd)
        {
            IRowCol curRowCol = new ZeroRowCol(0, 0, ApplyMaster);
            var     master    = ApplyMaster;

            foreach (var order in wtdCmd.OrderList)
            {
                if (order is SetBufferAddressOrder)
                {
                    var sba = order as SetBufferAddressOrder;
                    curRowCol = sba.GetRowCol(master.ScreenDim).ToZeroRowCol().ToContentRelative(master);
                }

                // screen position is out of bounds. Do not place text or field onto the
                // screen at an invalid position.
                else if (curRowCol.ColNum >= master.ScreenDim.Width)
                {
                }

                else if (order is StartFieldOrder)
                {
                    var sfo          = order as StartFieldOrder;
                    var contentField = master.ApplyStartFieldOrder(curRowCol, sfo);
                    curRowCol = curRowCol.Advance(1);
                }

                else if (order is RepeatToAddressOrder)
                {
                    var rao       = order as RepeatToAddressOrder;
                    var lx        = rao.RepeatLength((ZeroRowCol)curRowCol.ToParentRelative(master));
                    var textBytes = rao.GetRepeatTextBytes(lx);
                    master.ApplyTextBytes(curRowCol, textBytes);
                    curRowCol = curRowCol.Advance(lx);
                }

                else if (order is TextDataOrder)
                {
                    var tdo = order as TextDataOrder;
                    master.ApplyTextBytes(curRowCol, tdo.RawBytes);
                    curRowCol = tdo.Advance(curRowCol);
                }

                else if (order is InsertCursorOrder)
                {
                    var ico = order as InsertCursorOrder;
                    master.CaretRowCol = ico.RowCol;
                }

                else if (order is EraseToAddressOrder)
                {
                    var eao       = order as EraseToAddressOrder;
                    var lx        = eao.EraseLength((ZeroRowCol)curRowCol.ToParentRelative(master));
                    var textBytes = ((byte)0x00).Repeat(lx);
                    master.ApplyTextBytes(curRowCol, textBytes);
                    curRowCol = curRowCol.Advance(lx);
                }

                // WriteStructuredField order. used to create a window ScreenContent
                // within the main screenContent.
                else if (order is CreateWindowStructuredField)
                {
                    var sfo = order as CreateWindowStructuredField;

                    // create the window as a ScreenContent block onto itself. All future
                    // WTD orders are applied to the window screen content.
                    var windowMaster = new WindowScreenContent(
                        master,
                        sfo.WindowDim, (ZeroRowCol)curRowCol);

                    // store the index of this new child window as the index of the
                    // "current window" SCB within the parent SCB.
                    master.CurrentChildIndex = master.Children.Length - 1;

                    // the window is now the current SCB.
                    master = windowMaster;

                    // reset the current rowCol to position 0,0 within the window.
                    curRowCol = new ZeroRowCol(0, 0, master);
                }
            }

            return(master);
        }
Example #28
0
 public ReadScreenMessage(ScreenContent ScreenContent)
 {
     this.ScreenContent = ScreenContent;
 }
Example #29
0
 public ScreenModel LoadScreen(ScreenContent name)
 {
     return(GameRoot.Instance.Content.Load <ScreenModel>("Screen/" + name));
 }
 public SaveScreenMessage(ScreenContent ScreenContent)
 {
     this.ScreenContent = ScreenContent;
 }
 public GenericScreen(IEnumerable<string> rows)
 {
     _content = new ScreenContent(rows);
 }
 public GenericScreen(ScreenContent content)
 {
     _content = content;
 }
Example #33
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);
        }
Example #34
0
 public MatchScreenDefnMessage(IScreenDefn ScreenDefn, ScreenContent ScreenContent)
 {
     this.ScreenDefn    = ScreenDefn;
     this.ScreenContent = ScreenContent;
 }
Example #35
0
        private byte[] BuildResponseByteStream(
            ScreenContent ScreenContent,
            AidKey AidKey, OneRowCol CaretRowCol, HowReadScreen?HowRead = null)
        {
            var ba = new ByteArrayBuilder();

            // what to read from the screen.
            HowReadScreen howRead = HowReadScreen.ReadAllInput;

            if (HowRead != null)
            {
                howRead = HowRead.Value;
            }

            {
                var buf = DataStreamHeader.Build(99, TerminalOpcode.PutGet);
                ba.Append(buf);
            }

            // location of caret on the canvas.
            {
                var rowCol = CaretRowCol.ToParentRelative(ScreenContent);
                var buf    = ResponseHeader.Build(rowCol as OneRowCol, AidKey);
                ba.Append(buf);
            }

            foreach (var dictItem in ScreenContent.FieldDict)
            {
                ContentField responseField = null;
                var          contentItem   = dictItem.Value;

                // process only ContentField.
                if (contentItem is ContentField)
                {
                    var contentField = contentItem as ContentField;
                    responseField = contentField;
                }

                // only process the first of a continued entry field.
                if ((responseField != null) && (responseField is ContinuedContentField))
                {
                    var contContentField = responseField as ContinuedContentField;
                    if (contContentField.ContinuedFieldSegmentCode != ContinuedFieldSegmentCode.First)
                    {
                        responseField = null;
                    }
                }

                if ((howRead == HowReadScreen.ReadMdt) &&
                    (responseField != null) && (responseField.GetModifiedFlag(ScreenContent) == false))
                {
                    responseField = null;
                }

                if (responseField != null)
                {
                    IRowCol rowCol = responseField.RowCol.ToOneRowCol().AdvanceRight();
                    {
                        rowCol = rowCol.ToParentRelative(ScreenContent);
                        var buf = SetBufferAddressOrder.Build(rowCol as OneRowCol);
                        ba.Append(buf);
                    }
                    {
                        var buf = TextDataOrder.Build(responseField.GetFieldShowText(ScreenContent));
                        ba.Append(buf);
                    }
                }
            }

            // update length of response data stream.
            var ra = ba.ToByteArray();

            {
                var wk = new ByteArrayBuilder();
                wk.AppendBigEndianShort((short)ra.Length);
                Array.Copy(wk.ToByteArray(), ra, 2);
            }

            return(ra);
        }
Example #36
0
        //
        // GET: /Screen/

        public ActionResult Index()
        {
            try
            {
                if (Session["UserAccountID"] == null)
                {
                    return(RedirectToAction("Validate", "Login"));
                }
                User user = (User)Session["User"];
                ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"]));
                if (user.IsAdmin)
                {
                    ViewData["txtIsAdmin"] = "true";
                }
                else
                {
                    ViewData["txtIsAdmin"] = "false";
                }

                // Initialize or get the page state using session
                ScreenPageState pagestate = GetPageState();

                // Get the account id
                int accountid = 0;
                if (Session["UserAccountID"] != null)
                {
                    accountid = Convert.ToInt32(Session["UserAccountID"]);
                }

                // Set and save the page state to the submitted form values if any values are passed
                if (Request.Form["lstAscDesc"] != null)
                {
                    pagestate.AccountID   = accountid;
                    pagestate.ScreenName  = Request.Form["txtScreenName"].ToString().Trim();
                    pagestate.Description = Request.Form["txtDescription"].ToString().Trim();
                    if (Request.Form["chkIncludeInactive"].ToLower().StartsWith("true"))
                    {
                        pagestate.IncludeInactive = true;
                    }
                    else
                    {
                        pagestate.IncludeInactive = false;
                    }
                    pagestate.SortBy     = Request.Form["lstSortBy"].ToString().Trim();
                    pagestate.AscDesc    = Request.Form["lstAscDesc"].ToString().Trim();
                    pagestate.PageNumber = Convert.ToInt32(Request.Form["txtPageNumber"].ToString().Trim());
                    SavePageState(pagestate);
                }

                // Add the session values to the view data so they can be populated in the form
                ViewData["AccountID"]       = pagestate.AccountID;
                ViewData["ScreenName"]      = pagestate.ScreenName;
                ViewData["Description"]     = pagestate.Description;
                ViewData["IncludeInactive"] = pagestate.IncludeInactive;
                ViewData["SortBy"]          = pagestate.SortBy;
                ViewData["SortByList"]      = new SelectList(BuildSortByList(), "Value", "Text", pagestate.SortBy);
                ViewData["AscDescList"]     = new SelectList(BuildAscDescList(), "Value", "Text", pagestate.AscDesc);

                // Determine asc/desc
                bool isdescending = false;
                if (pagestate.AscDesc.ToLower().StartsWith("d"))
                {
                    isdescending = true;
                }

                // Get a Count of all filtered records
                int recordcount = repository.GetScreenRecordCount(pagestate.AccountID, pagestate.ScreenName, pagestate.Description, pagestate.IncludeInactive);

                // Determine the page count
                int pagecount = 1;
                if (recordcount > 0)
                {
                    pagecount = recordcount / Constants.PageSize;
                    if (recordcount % Constants.PageSize != 0) // Add a page if there are more records
                    {
                        pagecount = pagecount + 1;
                    }
                }

                // Make sure the current page is not greater than the page count
                if (pagestate.PageNumber > pagecount)
                {
                    pagestate.PageNumber = pagecount;
                    SavePageState(pagestate);
                }

                // Set the page number and account in viewdata
                ViewData["PageNumber"]  = Convert.ToString(pagestate.PageNumber);
                ViewData["PageCount"]   = Convert.ToString(pagecount);
                ViewData["RecordCount"] = Convert.ToString(recordcount);

                // We need to add the Main Feature Type and Name, and the Screen Content Names
                IEnumerable <Screen>               screens           = repository.GetScreenPage(pagestate.AccountID, pagestate.ScreenName, pagestate.Description, pagestate.IncludeInactive, pagestate.SortBy, isdescending, pagestate.PageNumber, pagecount);
                List <ScreenWizardView>            screenwizardviews = new List <ScreenWizardView>();
                ISlideShowRepository               ssrep             = new EntitySlideShowRepository();
                IPlayListRepository                plrep             = new EntityPlayListRepository();
                ITimelineRepository                tlrep             = new EntityTimelineRepository();
                IScreenScreenContentXrefRepository sscxrep           = new EntityScreenScreenContentXrefRepository();
                IScreenContentRepository           screp             = new EntityScreenContentRepository();
                IScreenContentTypeRepository       sctrep            = new EntityScreenContentTypeRepository();
                foreach (Screen screen in screens)
                {
                    ScreenWizardView swv = new ScreenWizardView();
                    swv.ScreenID          = screen.ScreenID;
                    swv.AccountID         = screen.AccountID;
                    swv.ScreenName        = screen.ScreenName;
                    swv.ScreenDescription = screen.ScreenDescription;
                    if (screen.SlideShowID > 0)
                    {
                        swv.MainFeatureType = "Slide Show";
                        swv.MainFeatureName = ssrep.GetSlideShow(screen.SlideShowID).SlideShowName;
                    }
                    else if (screen.PlayListID > 0)
                    {
                        swv.MainFeatureType = "Play List";
                        swv.MainFeatureName = plrep.GetPlayList(screen.PlayListID).PlayListName;
                    }
                    else if (screen.TimelineID > 0)
                    {
                        swv.MainFeatureType = "Media Timeline";
                        swv.MainFeatureName = tlrep.GetTimeline(screen.TimelineID).TimelineName;
                    }
                    if (screen.IsInteractive)
                    {
                        IEnumerable <ScreenScreenContentXref> sscxs = sscxrep.GetScreenScreenContentXrefs(screen.ScreenID);
                        foreach (ScreenScreenContentXref sscx in sscxs)
                        {
                            string contentinfo = String.Empty;

                            ScreenContent sc = screp.GetScreenContent(sscx.ScreenContentID);
                            contentinfo = "'" + sc.ScreenContentName + "'";

                            ScreenContentType sctype = sctrep.GetScreenContentType(sc.ScreenContentTypeID);
                            contentinfo += " (" + sctype.ScreenContentTypeName + ")";

                            if (!String.IsNullOrEmpty(swv.InteractiveContent))
                            {
                                swv.InteractiveContent += ", ";
                            }
                            swv.InteractiveContent += contentinfo;
                        }
                    }
                    swv.IsActive = screen.IsActive;

                    screenwizardviews.Add(swv);
                }

                ViewResult result = View(screenwizardviews);
                result.ViewName = "Index";
                return(result);
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("Screen", "Index", ex.Message);
                return(RedirectToAction("Index", "ApplicationError"));
            }
        }