public Panel() { rasterizerState = new RasterizerState() { ScissorTestEnable = true }; horizontalScrollbar = new HorizontalScrollbar(); verticalScrollbar = new VerticalScrollbar(); }
public override void Dispose() { Panel.Dispose(); if (HorizontalScrollbar != null) { HorizontalScrollbar.Dispose(); } if (VerticalScrollbar != null) { VerticalScrollbar.Dispose(); } }
public override void AttachTo(IColossalControl control) { control.AttachControl(Panel); if (HorizontalScrollbar != null) { HorizontalScrollbar.AttachTo(control); } if (VerticalScrollbar != null) { VerticalScrollbar.AttachTo(control); } }
public override void AttachTo(GameObject gameObject) { Panel.GameObject.transform.parent = gameObject.transform; if (HorizontalScrollbar != null) { HorizontalScrollbar.AttachTo(gameObject); } if (VerticalScrollbar != null) { VerticalScrollbar.AttachTo(gameObject); } }
private void RemoveVerticalScrollbar() { Panel.HorizontalScrollbar = null; if (VerticalScrollbar != null) { Panel.Height += VerticalScrollbar.Width; VerticalScrollbar.Dispose(); GameObject.DestroyImmediate(VerticalScrollbar.Control.GameObject); VerticalScrollbar = null; } }
protected virtual void OnEnable() { Utility.RegisterWindow(this); Utility.RestoreIcon(this); Metrics.UseTool(23); // NGSpolight this.scrollbar = new VerticalScrollbar(0F, 0F, this.position.height); this.scrollbar.interceiptEvent = true; this.wantsMouseMove = true; this.RefreshResult(); this.UpdateAvailableFilters(); List <EntryHardRef> refs = (List <EntryHardRef>)Utility.LoadEditorPref(null, typeof(List <EntryHardRef>), NGSpotlightWindow.Title + ".lastUsed"); if (refs != null) { NGSpotlightWindow.lastUsed.Clear(); for (int i = 0; i < refs.Count; i++) { List <IDrawableElement> list; if (NGSpotlightWindow.entries.TryGetValue(refs[i].key, out list) == true) { for (int j = 0; j < list.Count; j++) { if (list[j].RawContent == refs[i].content) { NGSpotlightWindow.lastUsed.Add(new EntryRef() { key = refs[i].key, i = j }); break; } } } } } }
public override void Init() { base.Init(); buffer = ConsoleRenderer.ActiveBuffer; textBox = new TextBox(controlManager) { Width = 34, Height = 13, Text = "Hello there", Attributes = CharAttribute.ForegroundWhite | CharAttribute.BackgroundDarkRed, WordBreak = WordBreak.Hard, TextAlign = TextAlign.Left }; textBox.Text = lorem; textBox.MousePressed += TextBox_MousePressed; textBox.Visible = false; //textBox.MouseReleased += TextBox_MouseReleased; dataBox = new TextBox(controlManager) { Width = 20, Height = 2, Name = "hello", Text = textBox.Rectangle.Size.ToString(), Attributes = CharAttribute.ForegroundGreen }; dataBox.Width = dataBox.Text.Length; dataBox.Visible = false; vs = new VerticalScrollbar(controlManager) { Height = 5, Left = 20, Top = 4 }; hs = new HorizontalScrollbar(controlManager) { Width = 10, Left = 3, Top = Height - 1 }; new ScrollableTextBox(controlManager) { Width = 20, Height = 5 }; colorfulString = new ColorfulString { Value = new string(Enumerable.Repeat('A', Enum.GetValues(typeof(CharAttribute)).Length - 0).ToArray()), ColorThing = ColorSelectMode.Repeat, Attributes = (CharAttribute[])Enum.GetValues(typeof(CharAttribute)) }; strings = new string[] { "Haha", "Console", "Go", "Brrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr" }.NormalizeLengths() .PadAround(2); int ratioX = 2; int ratioY = 1; int scale = 2; int spacingX = ratioX * scale; int spacingY = ratioY * scale; int pieceWidth = 2; int pieceHeight = 1; int tileWidth = pieceWidth + spacingX * 2; int tileHeight = pieceHeight + spacingY * 2; square = new CharInfo[8 * tileHeight, 8 * tileWidth]; for (int y = 0; y < square.GetLength(0); y++) { for (int x = 0; x < square.GetLength(1); x++) { square[y, x].Attributes |= ((x / tileWidth + y / tileHeight) % 2 == 0 ? CharAttribute.BackgroundGrey | CharAttribute.ForegroundBlack : CharAttribute.BackgroundBlack | CharAttribute.ForegroundWhite); } } for (int y = 0; y < square.GetLength(0); y++) { for (int x = 0; x < square.GetLength(1); x++) { if (x % tileWidth == 0 && y % tileHeight == 0) { int px = x + spacingX; int py = y + spacingY; square[py, px].UnicodeChar = '♕'; square[py, px].Attributes |= CharAttribute.LeadingByte; var yellow = CharAttribute.BackgroundYellow | CharAttribute.ForegroundBlack; var marker = new CharInfo { UnicodeChar = ShadingCharacter.Light, Attributes = yellow }; } } } backface = new BufferArea(square.GetLength(1) + 4, square.GetLength(0) + 2); CharInfo backChar = new CharInfo { UnicodeChar = ShadingCharacter.Dark, Attributes = CharAttribute.BackgroundDarkGrey }; backface.Fill(backChar); //Draw(); ConsoleInput.KeyPressed += ConsoleInput_KeyPressed; ConsoleInput.KeyHeld += ConsoleInput_KeyPressed; ConsoleInput.MouseReleased += TextBox_MouseReleased; ConsoleInput.MouseDragged += ConsoleInput_MouseDragged; ConsoleInput.Resized += ConsoleInput_Resized; //ConsoleInput.Resized += delegate //{ // Draw(); //}; Draw(); }
protected override void OnLayoutBuild() { { // int index = 0; // foreach (GUIStyle VARIABLE in GUI.skin) // { // Button b = EuiCore.CreateElement<Button>(); // b.Style = VARIABLE; // b.SetAnchor(AnchorType.LeftTop); // b.Pivot = new Vector2(0, 0); // b.Size = new Vector2(30, 30); // b.AnchoredPosition = new Vector2(index % 30 * 35, index / 30 * 35); // b.OnClickEvt += () => // { // Debug.Log(VARIABLE); // Selection.activeObject = GUI.skin; // }; // // index++; // } TimeAxis ta = EuiCore.CreateElement <TimeAxis>(); //return; VerticalScrollRect verticalScrollRect = EuiCore.CreateElement <VerticalScrollRect>(); verticalScrollRect.AnchoredPosition = new Vector2(0, 0); verticalScrollRect.Size = new Vector2(400, 500); StackLayout sl = EuiCore.CreateElement <StackLayout>(); verticalScrollRect.SetContent(sl); ta.SetParent(sl); Button btn = EuiCore.CreateElement <Button>(); btn.Text = "测试按钮"; btn.Size = new Vector2(60, 20); btn.OnClickEvt += () => { Debug.Log("点击"); }; btn.SetParent(sl); btn = EuiCore.CreateElement <Button>(); btn.Text = "测试按钮"; btn.Size = new Vector2(60, 180); btn.OnClickEvt += () => { Debug.Log("点击"); }; btn.SetParent(sl); Label lab = EuiCore.CreateElement <Label>(); lab.Text = " 测试"; lab.AnchoredPosition = new Vector2(100, 100); lab.Size = new Vector2(60, 20); lab.SetParent(sl); Toggle toggle = EuiCore.CreateElement <Toggle>(); toggle.Text = "测试"; toggle.AnchoredPosition = new Vector2(0, 100); toggle.Size = new Vector2(60, 20); toggle.SetParent(sl); InputField ifd = EuiCore.CreateElement <InputField>(); ifd.SetParent(sl); ifd.Text = "测试"; // ifd.SetAnchor(AnchorType.LeftTop); ifd.AnchoredPosition = new Vector2(0, 0); // ifd.Pivot = new Vector2(0,0); ifd.Size = new Vector2(100, 20); Image im = EuiCore.CreateElement <Image>(); im.MainTexture = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/demo.aseprite"); // im.AnchordPosition = new Vector2(-200, 0); //设置裁剪 im.SetActiveClip(true); //设置父对象 ifd.SetParent(im); VerticalScrollbar sr = EuiCore.CreateElement <VerticalScrollbar>(); sr.SetAnchor(AnchorType.RightStretch); sr.Pivot = new Vector2(1, 0.5f); sr.OnValueChanged += (x) => { Debug.Log(x); }; sr.SetSliderHeightRelative(0.5f); //sr.SetParent(im); sr.SetValue(1); } }