Exemplo n.º 1
0
        private void TapEmpty()
        {
            if (FocusedState == FocusState.Unfocus)
            {
                OnEmptyTapped?.Invoke();
            }
            else if (FocusedState == FocusState.Focus)
            {
                focusedNode.PopOutline();
                focusedNode.Highlight();
                int idx = focusedNode.Idx;
                focusedNode = null;

                FocusedState = FocusState.Unfocus;
                OnUnfocused?.Invoke();
            }
            else if (FocusedState == FocusState.SuperFocus)
            {
                FocusedState = FocusState.Focus;
                foreach (Node no in nodes)
                {
                    no.State = Node.PositionState.Stress;
                    no.SetNewParentKeepPos(yAxle);
                }
                foreach (Link li in links)
                {
                    li.Show(true);
                }
            }
        }
Exemplo n.º 2
0
 public ButtonNode(ButtonStructure structure, RectangleRenderElementStyle style, TextRenderElementStyle text_style)
 {
     Structure     = structure;
     BorderStyle   = style;
     TextStyle     = text_style;
     BorderElement = new RectangleRenderElement(Position, Width, Height, style.FillColor, style.BorderColor, style.BorderWidth);
     TextElement   = new TextRenderElement(Position, Text, TextColor, TextStyle.FontSize, TextStyle.FontStyle);
     TriggerAreas.Add(new RectangleHitbox(Position, Width, Height));
     ButtonAction  = Structure.ButtonAction;
     OnMouseClick += (object sender, EventArgs e) =>
     {
         ButtonAction.Invoke();
         OnUnfocused?.Invoke(this, new NodeEventArgs(this));
     };
 }
Exemplo n.º 3
0
        private void HandleKey(object sender, KeyPressEventArgs e)
        {
            char key = e.KeyChar;

            if (key == (char)8 && Text.Length > 0)
            {
                Text  = Text.Substring(0, Text.Length - 1);
                Width = Renderer.GetTextWidth(Text.Length);
            }
            else if (key == (char)13)
            {
                OnUnfocused?.Invoke(this, new NodeEventArgs(this));
            }
            else if (Char.IsWhiteSpace(key))
            {
                Text = Text.Insert(Text.Length, " ");
            }
            else
            {
                Text = Text.Insert(Text.Length, key.ToString());
            }
        }
Exemplo n.º 4
0
 public virtual void Unfocus()
 {
     Focused = false;
     OnUnfocused?.Invoke(this);
     Parent?.Unfocus();
 }