public Popup(GuiComponent parent, string message) { var titled = new TitledWindow(parent, "About...") { BackGround = ConsoleColor.DarkBlue, Foreground = ConsoleColor.White }; var label = new TextLabel(titled, message, new Coord(4, 1)); titled.Dimensions = label.GetSize(); titled.Dimensions.Height.Pixels += 5; titled.Dimensions.Width.Pixels += 6; titled.Position = new Coord((State.MaxX - titled.Dimensions.Width.Pixels) / 2, ((State.MaxY - titled.Dimensions.Height.Pixels) / 2) - 1); label.AdjustWhenParentsReposition(); var screenCenter = new Coord(titled.Dimensions.Width.Pixels / 2, label.Height + 2); var ok = new Button(titled, "OK", () => { titled.RemoveMeAndChildren(); }, screenCenter) { BackGround = ConsoleColor.DarkGray, Foreground = ConsoleColor.Green }; ok.Focus(); }
public ConnectForm(GuiComponent parent, Coord position, int[] legalInput) { this.legalInput = legalInput; titled = new TitledWindow(parent, "Connect...") { Position = position }; new TextLabel(titled, "From object:", new Coord(0, 0)); from = new TextBox(titled, 5, new Coord(0, 1)) { OnUserEscape = titled.RemoveMeAndChildren }; new TextLabel(titled, "To object:", new Coord(0, 2)); to = new TextBox(titled, 5, new Coord(0, 3)) { OnUserEscape = titled.RemoveMeAndChildren, OnUserSubmit = Submit }; from.OnUserSubmit = to.Focus; validationErrors = new TextLabel(titled, "", new Coord(0, 4)) { BackGround = ConsoleColor.White, Foreground = ConsoleColor.Red }; }
public GuiComponent <T> Get(S id) { GuiComponent <T> component = null; m_Pairs.TryGetValue(id, out component); return(component); }
protected override void Initialize() { this._graphics.PreferredBackBufferWidth = 1920; this._graphics.PreferredBackBufferHeight = 1080; this._graphics.SynchronizeWithVerticalRetrace = false; this._graphics.ApplyChanges(); this.Window.AllowUserResizing = true; this.Window.AllowAltF4 = true; renderer = new DeferredRenderer(GraphicsDevice, new ContentManager(Content.ServiceProvider, Content.RootDirectory + "/gbuffer"), new GBufferInitParams()); scenes.Add(new VillageScene(GraphicsDevice, Content)); scenes.Add(new IcoScene(GraphicsDevice, Content)); scene = scenes[0]; LoadContent(); Window.ClientSizeChanged += (sender, e) => renderer.RebuildTargets(); Components.Add(new FramesPerSecondComponent(this)); Components.Add(new GameSettingsComponent(this)); var guiService = new GuiComponent(this); Components.Add(guiService); Services.AddService <IGuiService>(guiService); base.Initialize(); }
/** * Adds given componenet as a child of this component, returns added child * * @param child Component to add * @param hAlign Position to align componenet too, or null for no aligment * @param vAlign Position to align componenet too, or null for no aligment * @param fixedAlignment If true the component will try to keep the given alignment values as it's parent changes| * @param backDraw If true child will be drawn underneith the container * size. * * @returns The added child. */ public GuiComponent Add(GuiComponent child, int?hAlign = null, int?vAlign = null, bool fixedAlignment = false, bool backgroundDraw = false) { Invalidate(); if (Children.IndexOf(child) < 0) { Children.Add(child); PositionComponent(child, hAlign, vAlign); } child.Parent = this; if (backgroundDraw) { hasBackgroundChildren = true; child.Layer = -1; } if (fixedAlignment) { child.FixedAlignment.x = hAlign ?? 0; child.FixedAlignment.y = vAlign ?? 0; child.Align = GuiAlignment.Fixed; } return(child); }
/** Styles a component with a red tint suitable for warnings. */ public static void RedWarning(GuiComponent component) { Util.Assert(component != null, "Component must not be null."); component.ColorTransform = ColorTransform.BlackAndWhite; component.ColorTransform += ColorTransform.Multiply(1.2f, 1.2f, 1.2f); component.Color = new Color(1f, 0.4f, 0.3f); }
private void mi_Load_Click(object sender, RoutedEventArgs e) { //object obj = sender; if (tv_Elements.SelectedItem != null) { XmlElement root = tv_Elements.SelectedItem as XmlElement; //XmlElement rootCopy = root.Clone() as XmlElement; string id = root.GetAttribute("id"); GuiComponent cp = SAPAutomationHelper.Current.GetSAPComponentById <GuiComponent>(id); if (root.ChildNodes.Count == 1) { root.RemoveChild(root.FirstChild); } SAPAutomationHelper.Current.LoopSAPComponents <XmlElement>(cp, root, root.ChildNodes.Count, _maxCount, addNode); root = tv_Elements.SelectedItem as XmlElement; var lastNode = root.LastChild.Clone(); root.RemoveChild(root.LastChild); int count = lastNode.ChildNodes.Count; for (int i = 0; i < count; i++) { root.AppendChild(lastNode.ChildNodes[0]); } } }
override protected void SetDDContent(GuiComponent value) { if (value is GuiItem) { Character.GiveItem((value as GuiItem).ItemInstance); } }
public Button(GuiComponent parent, string buttonText, Action onClick, ConsoleColor backgroundColor = ConsoleColor.DarkGray, ConsoleColor foregroundColor = ConsoleColor.Green) : base(parent) { this.buttonText = buttonText; this.onClick = onClick; this.backgroundColor = backgroundColor; this.foregroundColor = foregroundColor; }
private void OnMouseLeaveFromMenuButton(GuiComponent button) { if (IsMouseFocused(button, panelCharacters)) { cursor.SubCursorIndex = 0; //Cursor Free } }
/** Make sure we can only accept items */ public override bool CanReceive(GuiComponent value) { if (DataLink == null) { return(true); } if (value == null) { return(false); } if (!Enabled) { return(false); } if (containsCursedItem() && DataLink.IsEquipSlot) { return(false); } if (value is GuiItem) { if ((value as GuiItem).ItemInstance == null) { return(true); } return(DataLink.CanAccept((value as GuiItem).ItemInstance)); } return(false); }
public LibraryState() : base("Library") { Util.Assert(CoM.AllDataLoaded, "Data must be loaded before LibraryState can be created."); MainWindow.Width = 600; MainWindow.Height = 480; // -------------------------------------- ItemsWindow = new LibraryItemsView(); MonstersWindow = new LibraryMonstersView(); RecordsWindow = new LibraryRecordsView(); // -------------------------------------- var buttonGroup = new GuiRadioButtonGroup(); buttonGroup.EnableBackground = true; buttonGroup.OnValueChanged += delegate { ItemsWindow.Visible = buttonGroup.SelectedIndex == 0; MonstersWindow.Visible = buttonGroup.SelectedIndex == 1; RecordsWindow.Visible = buttonGroup.SelectedIndex == 2; }; buttonGroup.AddItem("Items"); buttonGroup.AddItem("Monsters"); buttonGroup.AddItem("Records"); buttonGroup.ButtonSize = new Vector2(120, 28); buttonGroup.Height = 45; buttonGroup.Style = Engine.GetStyleCopy("Solid"); buttonGroup.Color = Color.black.Faded(0.5f); buttonGroup.Width = MainWindow.Width; buttonGroup.Height = 45; MainWindow.Add(buttonGroup); buttonGroup.SelectedIndex = 0; // -------------------------------------- var BodySection = new GuiContainer(MainWindow.Width, MainWindow.Height - buttonGroup.Height) { Y = buttonGroup.Height }; MainWindow.Add(BodySection); BodySection.Add(ItemsWindow); BodySection.Add(MonstersWindow); BodySection.Add(RecordsWindow); // -------------------------------------- RepositionControls(); MainWindow.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow"); MainWindow.Background.Color = new Color(0.4f, 0.42f, 0.62f); }
private void btn_Spy_Click(object sender, RoutedEventArgs e) { if (BeforeSpy != null) { BeforeSpy(this, new EventArgs()); } //App.Current.MainWindow.WindowState = WindowState.Minimized; _isExpand = true; SAPAutomationHelper.Current.SetVisualMode(true); SAPAutomationHelper.Current.Spy((c) => { displayData(c); GuiComponent cp = c; Stack <SAPCompoentBasicInfo> comps = new Stack <SAPCompoentBasicInfo>(); do { SAPCompoentBasicInfo info = new SAPCompoentBasicInfo(); info.Comp = cp; info.ChildrenCount = 0; if (cp is GuiVContainer) { info.ChildrenCount = (cp as GuiVContainer).Children.Count; } if (cp is GuiContainer) { info.ChildrenCount = (cp as GuiContainer).Children.Count; } comps.Push(info); cp = cp.Parent; }while ((cp is GuiConnection) == false); xDoc = new XmlDocument(); XmlElement root = xDoc.CreateElement("Node"); root.SetAttribute("name", "root"); var firstComp = comps.Pop(); XmlElement temp = addNode(firstComp.Comp, root, firstComp.ChildrenCount); while (comps.Count > 0) { var comp = comps.Pop(); temp = addNode(comp.Comp, temp, comp.ChildrenCount); } xDoc.AppendChild(root.FirstChild); tv_Elements.Dispatcher.BeginInvoke(new Action(() => { tv_Elements.DataContext = xDoc; SAPAutomationHelper.Current.SetVisualMode(false); if (AfterSpy != null) { AfterSpy(this, new EventArgs()); } //App.Current.MainWindow.WindowState = WindowState.Normal; })); }); }
public TextBox(GuiComponent parent, int width, Coord position) : base(parent, position) { Dimensions = new GuiDimensions(new Size(width), new Size(1)); Value = ""; BackGround = ConsoleColor.DarkCyan; Foreground = ConsoleColor.Yellow; OnUserEscape = () => { }; }
/** Places button at correct position. */ private void positionButton(GuiComponent component, int index) { int xlp = index % COLUMNS; int ylp = index / COLUMNS; PositionComponentToColumns(component, (index % COLUMNS) + 1, COLUMNS, 100); component.Y = 10 + ylp * 120; }
/** Accept items, and auto set the mode to sell on drag over. */ override public bool CanReceive(GuiComponent value) { if (value is GuiItem) { return(true); } return(false); }
private void OnMouseLeaveFromSkillButton(GuiComponent button) { if (IsMouseFocused(button, panelSkills)) { panelTooltip.Visibility = false; cursor.SubCursorIndex = 0; //Cursor Free } }
public PopupNoButton(GuiComponent parent, string message) : base(parent) { msglines = message.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); Dimensions.Height.Pixels = msglines.Length; Dimensions.Width.Pixels = msglines.Max(x => x.Length) + 6; Position = new Coord((State.MaxX - Dimensions.Width.Pixels) / 2, ((State.MaxY - Dimensions.Height.Pixels) / 2) - 1); this.Focus(); }
public static void HighLight(this GuiComponent comp) { GuiVComponent vComp = comp as GuiVComponent; if (vComp != null) { vComp.Visualize(true); } }
/** Removes given componenet as a child of this component */ public void Remove(GuiComponent child) { Invalidate(); if (Children.IndexOf(child) >= 0) { Children.Remove(child); } child._parent = null; }
/** Adds an open / close button to target and adds it to targets parent. */ public static GuiOpenCloseButton Create(GuiComponent target) { var button = new GuiOpenCloseButton(target); button.X = (int)target.Bounds.xMax + 5 - button.Width; button.Y = (int)target.Bounds.yMin - 5; target.Parent.Add(button); return(button); }
public MainMenuGuiButtonController(GuiComponent parent, Vector2 offset = new Vector2(), Point size = new Point()) : base(parent, offset, size) { CursorGuiImageComponent = new GuiImageComponent(this, ZeldaGraphics.RightPointFingerCursor, new Point(16, 16)) { LocationOverride = true, IsVisible = false }; _moveSoundEffect = _selectSoundEffect = ZeldaSfx.CursorMove; }
public GuiComponent FindById(string path) { GuiComponent component = null; try { component = session.FindById(path); } catch (Exception e) { throw new InvalidPathException(path); } return(component); }
/// <summary> /// A gui button class that should be used as a base for all buttons /// </summary> /// <param name="textBoxConfig">The text that should be shown with the button</param> /// <param name="size">The size of the button</param> /// <param name="parentOffset">The offset of the components parent</param> /// <param name="parent">The parent of this object</param> /// <param name="graphicToLoad">The graphic for this button</param> protected GuiButton(Point size, Vector2 parentOffset, GuiComponent parent, TextBoxConfig textBoxConfig = null, Enum graphicToLoad = null) : base(parentOffset, size, parent) { if (graphicToLoad != null) { _guiImageComponent = new GuiImageComponent(this, graphicToLoad, size, parentOffset); } if (textBoxConfig != null) { _buttonTextComponent = new GuiTextComponent(textBoxConfig, textBoxConfig.FontType); } }
public static void LegacyGetElement() { //1 By Id GuiComponent comp = SAPTestHelper.Current.SAPGuiSession.FindById("/app/con[0]/ses[0]/wnd[0]/tbar[0]/okcd"); (comp as GuiOkCodeField).Text = "SE16"; //2 By Name GuiComponent comp1 = SAPTestHelper.Current.MainWindow.FindByName("okcd", "GuiOkCodeField"); (comp as GuiOkCodeField).Text = "SE16"; }
public GuiOpenCloseButton(GuiComponent target) : base("", 35, 35) { Style = Engine.GetStyleCopy("SquareButton"); Target = target; Image = new GuiImage(0, 0); setMode(OpenCloseButtonMode.Close); OnMouseClicked += delegate { SwitchMode(); }; }
private void mi_Prop_Click(object sender, RoutedEventArgs e) { if (tv_Elements.SelectedItem != null) { XmlElement root = tv_Elements.SelectedItem as XmlElement; //XmlElement rootCopy = root.Clone() as XmlElement; string id = root.GetAttribute("id"); GuiComponent cp = SAPAutomationHelper.Current.GetSAPComponentById <GuiComponent>(id); displayData(cp); } }
/// <summary> /// To load guibuttons, this needs to be overridden /// </summary> /// <param name="buttonModel"></param> /// <param name="parent"></param> /// <returns></returns> public override GuiButton CreateButton(Button buttonModel, GuiComponent parent) { var buttonOffset = new Vector2(buttonModel.Location.X, buttonModel.Location.Y); var buttonSize = new Point(buttonModel.Size.X, buttonModel.Size.Y); var textConfig = PopulateTextConfig(buttonModel.TextComponent, parent); return(buttonModel.Type switch { 0 => new TitleScreenMainMenuButton(textConfig, buttonSize, buttonOffset, parent, buttonModel.Graphic), _ => null });
/** * Changes the currently displayed settings group */ private void setSettingsGroup(GuiComponent group) { generalGroup.Visible = false; advancedGroup.Visible = false; informationGroup.Visible = false; if (group == null) { return; } group.Visible = true; }
internal WinProvider GetProvider(GuiComponent component) { //**************************************** WinProvider MyProvider; //**************************************** if (_Providers.TryGetValue(component.Name, out MyProvider)) { return(MyProvider); } throw new GuiException("Provider is not registered"); }
private static CodeExpression getFindByIdCode(GuiComponent Component) { if (Component == null) return null; CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression( new CodeMethodReferenceExpression( new CodeVariableReferenceExpression("SAPTestHelper.Current.SAPGuiSession") , "FindById" , new CodeTypeReference(Component.GetDetailType())) , new CodePrimitiveExpression(formatId(Component.Id))); return expression; }
private static CodeExpression getFindByNameCode(GuiComponent Component) { if (Component == null) return null; try { Stack<SapCompInfo> comps = new Stack<SapCompInfo>(); do { SapCompInfo ci = new SapCompInfo(); ci.Id = Component.Id; ci.Name = Component.Name; ci.Type = Component.GetDetailType(); comps.Push(ci); Component = Component.Parent; } while ((Component is GuiSession) == false); SapCompInfo top = comps.Pop(); CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression( new CodeMethodReferenceExpression( new CodeVariableReferenceExpression("SAPTestHelper.Current.SAPGuiSession") , "FindById" , new CodeTypeReference(top.Type)) , new CodePrimitiveExpression(top.Name)); while (comps.Count > 0) { SapCompInfo temp = comps.Pop(); expression = new CodeMethodInvokeExpression( new CodeMethodReferenceExpression( expression , "FindByName" , new CodeTypeReference(temp.Type)) , new CodePrimitiveExpression(temp.Name)); } return expression; } catch { return null; } }
private void DrawChannel(uint id) { GuiComponent analyzerSingleFigure = null; foreach (var guiComponent in _channelList.Where(guiComponent => guiComponent.Header.Id == id)) { analyzerSingleFigure = guiComponent;} if (analyzerSingleFigure == null) _channelList.Add( analyzerSingleFigure = new GuiComponent(id, "", new GuiAnalyzerSingleFigure(id, Analyzer))); PlotGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto, MinHeight = 138, MaxHeight = 350}); PlotGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(3) }); analyzerSingleFigure.Initialize(0, 0, PlotGrid); Grid.SetRow(analyzerSingleFigure.UserControl, ((int)id - 1) * 2); GridSplitter newGridSplitter; PlotGrid.Children.Add(newGridSplitter = new GridSplitter { Height = 3, HorizontalAlignment = HorizontalAlignment.Stretch }); Grid.SetRow(newGridSplitter, ((int)id * 2) - 1); var userControl = (GuiAnalyzerSingleFigure)analyzerSingleFigure.UserControl; userControl.UpdateSizes(Height, Width); }