private static void SetControlLocation(Control c, MainFrameDriverWindow MFDW) { if (!c.Tag.GetType().ToString().Contains("XMLScreenField")) { return; } XMLScreenField Xldf = ((XMLScreenField)c.Tag); c.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; c.VerticalAlignment = System.Windows.VerticalAlignment.Top; c.Margin = new Thickness(MFDW.WidthPerCharachter * Xldf.Location.left, MFDW.HeightPerRow * Xldf.Location.top, 0, 0); if (c.GetType() == typeof(TextBox)) { ((TextBox)c).FontSize = 20; } else if (c.GetType() == typeof(PasswordBox)) { ((PasswordBox)c).FontSize = 20; } else if (c.GetType() == typeof(Label)) { ((Label)c).FontSize = 20; } }
public override void RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var terminalObject = (OpenEmulator)v_InstanceName.GetAppInstance(engine); if (terminalObject.TN3270 == null || !terminalObject.TN3270.IsConnected) { throw new Exception($"Terminal Instance {v_InstanceName} is not connected."); } XMLScreenField field = null; List <XMLScreenField> fields = terminalObject.TN3270.CurrentScreenXML.Fields.ToList(); if (v_Option == "Row/Col Position") { var mouseX = int.Parse(v_XMousePosition.ConvertUserVariableToString(engine)); var mouseY = int.Parse(v_YMousePosition.ConvertUserVariableToString(engine)); field = fields.Where(f => (mouseY * 80 + mouseX) >= f.Location.position && (mouseY * 80 + mouseX) < f.Location.position + f.Location.length).FirstOrDefault(); } else { var fieldText = v_FieldText.ConvertUserVariableToString(engine); field = fields.Where(f => f.Text != null && f.Text.ToLower().Contains(fieldText.ToLower())).FirstOrDefault(); } int fieldIndex = -1; if (field != null) { fieldIndex = Array.IndexOf(terminalObject.TN3270.CurrentScreenXML.Fields, field); } fieldIndex.StoreInUserVariable(engine, v_OutputUserVariableName, nameof(v_OutputUserVariableName), this); }
private static void ConfigureControl(Control c, XMLScreenField x, Canvas ConsoleCanvas, MainFrameDriverWindow MFDW) { c.Tag = x; SetControlLocation(c, MFDW); ConsoleCanvas.Children.Add(c); c.GotFocus += Control_GotFocus; c.MouseEnter += Control_GotFocus; }
private static Label AddLabel(XMLScreenField x) { Label l = new Label() { Content = x.Text }; l.BorderThickness = new Thickness(1); l.BorderBrush = Brushes.White; l.FontFamily = new FontFamily("Courier New"); l.Background = Brushes.Black; return(l); }
private static TextBox AddTextBox(XMLScreenField x) { TextBox TB = new TextBox(); if (!String.IsNullOrEmpty(x.Text)) { TB.Text = x.Text; } TB.MaxLength = x.Location.length; TB.LostFocus += Control_LostFocus; TB.BorderBrush = Brushes.YellowGreen; TB.Background = Brushes.Black; return(TB); }
private static PasswordBox AddPasswordBox(XMLScreenField x) { PasswordBox PWB = new PasswordBox(); if (!String.IsNullOrEmpty(x.Text)) { PWB.Password = x.Text; } ; PWB.MaxLength = x.Location.length; PWB.LostFocus += Control_LostFocus; PWB.BorderThickness = new Thickness(1, 1, 1, 1); PWB.BorderBrush = Brushes.Green; PWB.Background = Brushes.Black; return(PWB); }
private static void Control_GotFocus(object sender, RoutedEventArgs e) { try { Control C = (Control)sender; XMLScreenField XF = (XMLScreenField)C.Tag; MainFrameDriverWindow MFDW = (MainFrameDriverWindow)Window.GetWindow(C); if (MFDW == null) { return; } MFDW.CaretXY.Text = XF.Location.left + "/" + XF.Location.top; MFDW.CaretIndex.Text = XF.Location.position.ToString(); } finally { } }
private static Control GetControlFromScreenField(XMLScreenField XF) { Console.WriteLine(XF.Location.length); Console.WriteLine(XF.Text); if (XF.Attributes.Protected && (XF.Attributes.FieldType == "Hidden" || XF.Location.length == 0)) { return(null); } if (XF.Attributes.Protected && !String.IsNullOrEmpty(XF.Text)) { return((Control)AddLabel(XF)); } else if (XF.Attributes.FieldType == "Hidden") { return((Control)AddPasswordBox(XF)); } else { return((Control)AddTextBox(XF)); } }
public async override Task RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var terminalObject = (OpenEmulator)((OBAppInstance)await v_InstanceName.EvaluateCode(engine)).Value; if (terminalObject.TN3270 == null || !terminalObject.TN3270.IsConnected) { throw new Exception($"Terminal Instance {v_InstanceName} is not connected."); } XMLScreenField field = null; List <XMLScreenField> fields = terminalObject.TN3270.CurrentScreenXML.Fields.ToList(); if (v_Option == "Row/Col Position") { var mouseX = (int)await v_XMousePosition.EvaluateCode(engine); var mouseY = (int)await v_YMousePosition.EvaluateCode(engine); field = fields.Where(f => (mouseY * 80 + mouseX) >= f.Location.position && (mouseY * 80 + mouseX) < f.Location.position + f.Location.length).FirstOrDefault(); } else { var fieldText = (string)await v_FieldText.EvaluateCode(engine); field = fields.Where(f => f.Text != null && f.Text.ToLower().Contains(fieldText.ToLower())).FirstOrDefault(); } int fieldIndex = -1; if (field != null) { fieldIndex = Array.IndexOf(terminalObject.TN3270.CurrentScreenXML.Fields, field); } fieldIndex.SetVariableValue(engine, v_OutputUserVariableName); }
public void Refresh() { try { XMLScreen XMLS = mDriver.MFE.GetScreenAsXML(); MainFrameUIHelper.RefreshCamvasComponents(mDriver, this, ConsoleCanvas, XMLS, null); } catch (Exception mfe) { XMLScreen XMLS = new XMLScreen(); XMLScreenField XF = new XMLScreenField(); XF.Text = "Mainframe not Connected " + mfe.Message; XF.Attributes = new XMLScreenAttributes(); XF.Attributes.Protected = true; XF.Location = new XMLScreenLocation(); XF.Location.position = 0; XF.Location.top = 0; XF.Location.left = 0; XF.Location.length = XF.Text.Length; MainFrameUIHelper.RefreshCamvasComponents(mDriver, this, ConsoleCanvas, XMLS, XF); } }
public static void RefreshCamvasComponents(MainFrameDriver MF, MainFrameDriverWindow MFDW, Canvas ConsoleCanvas, XMLScreen ScreenElements, XMLScreenField MXF = null) { DefaultBursh = Brushes.Cyan; ConsoleCanvas.Children.Clear(); if (MFDW.HeightPerRow == 00 || MFDW.WidthPerCharachter == 00 || Double.IsInfinity(MFDW.WidthPerCharachter) || Double.IsInfinity(MFDW.HeightPerRow) || Double.IsNaN(MFDW.WidthPerCharachter) || Double.IsNaN(MFDW.HeightPerRow)) { SetupMainframeDriverComponents(MF, MFDW, ConsoleCanvas); } if (MXF != null) { Control C = GetControlFromScreenField(MXF); Brush Brsh = CalculateBrush(MXF); ConfigureControl(C, MXF, ConsoleCanvas, MFDW); C.Foreground = Brsh; SetControlLocation(C, MFDW); return; } if (ScreenElements.Fields == null || ScreenElements == null) { return; } foreach (XMLScreenField XF in ScreenElements.Fields) { Control C = GetControlFromScreenField(XF); if (C == null) { continue; } Brush Brsh = CalculateBrush(XF); ConfigureControl(C, XF, ConsoleCanvas, MFDW); C.Foreground = Brsh; SetControlLocation(C, MFDW); } }
private static void SetTextoMainframe(object sender) { MainFrameDriver mdriver = null; XMLScreenField XF = null; string Command = null; MainFrameDriverWindow MDW = null; bool IsFeildPassword = false; if (sender.GetType() == typeof(TextBox)) { TextBox TB = (TextBox)sender; XF = (XMLScreenField)TB.Tag; MDW = (MainFrameDriverWindow)Window.GetWindow(TB); if (MDW == null) { return; } mdriver = MDW.mDriver; Command = TB.Text; } else if (sender.GetType() == typeof(PasswordBox)) { IsFeildPassword = true; PasswordBox PWB = (PasswordBox)sender; XF = (XMLScreenField)PWB.Tag; MDW = (MainFrameDriverWindow)Window.GetWindow(PWB); mdriver = MDW.mDriver; Command = PWB.Password; } else { return; } if (XF == null || String.IsNullOrEmpty(Command) || mdriver == null) { } else { mdriver.SetTextAtPosition(Command, XF.Location.left, XF.Location.top, false); if (MDW.RecordBtn.IsChecked == true) { try { ActMainframeSetText AMFST = new ActMainframeSetText(); AMFST.LocateBy = eLocateBy.ByCaretPosition; AMFST.LocateValue = XF.Location.position.ToString(); AMFST.Value = Command; if (mdriver.mBusinessFlow == null) { return; } if (IsFeildPassword) { AMFST.Description = "Set Password "; } else { AMFST.Description = "Set Text: " + Command; } mdriver.mBusinessFlow.CurrentActivity.Acts.Add((Actions.Act)AMFST); } finally { } } } }
private static Brush CalculateBrush(XMLScreenField XF) { if (XF == null || XF.Attributes == null) { return(DefaultBursh); } if (XF.Attributes.Foreground != null) { switch (XF.Attributes.Foreground) { case "neutralBlack": return(new SolidColorBrush(Colors.Black)); case "blue": return(new SolidColorBrush(Colors.SkyBlue)); case "red": return(new SolidColorBrush(Colors.Red)); case "pink": return(new SolidColorBrush(Colors.Pink)); case "green": return(new SolidColorBrush(Colors.Green)); case "turquoise": return(new SolidColorBrush(Colors.Turquoise)); case "yellow": return(new SolidColorBrush(Colors.Yellow)); case "neutralWhite": return(new SolidColorBrush(Colors.WhiteSmoke)); case "black": return(new SolidColorBrush(Colors.Black)); case "deepBlue": return(new SolidColorBrush(Colors.DeepSkyBlue)); case "orange": return(new SolidColorBrush(Colors.Orange)); case "purple": return(new SolidColorBrush(Colors.Purple)); case "paleGreen": return(new SolidColorBrush(Colors.PaleGreen)); case "paleTurquoise": return(new SolidColorBrush(Colors.PaleTurquoise)); case "grey": return(new SolidColorBrush(Colors.Gray)); case "white": default: return(new SolidColorBrush(Colors.White)); } } else { if (XF.Attributes.FieldType == "High") { return(Brushes.Red); } return(DefaultBursh); } }