Пример #1
0
 public PathArrowButton(Func <string, bool> openPath, string path = null) : base()
 {
     this.path      = path;
     this.openPath  = openPath;
     MinMaxHeight   = 20;
     Presenter      = new PathButtonPresenter();
     base.Presenter = Presenter;
     if (path == null)
     {
         Updating += (float delta) => {
             var prevState = State;
             if (Expanded)
             {
                 State = PathBarButtonState.Press;
             }
             else
             {
                 if (IsMouseOverThisOrDescendant())
                 {
                     if (WasClicked())
                     {
                         State = PathBarButtonState.Press;
                     }
                     else
                     {
                         State = PathBarButtonState.Hover;
                     }
                 }
                 else
                 {
                     State = PathBarButtonState.Normal;
                 }
             }
             if (prevState != State)
             {
                 Presenter.SetState(State);
             }
         };
     }
     Gestures.Add(new ClickGesture(0, FlipState));
     Layout         = new HBoxLayout();
     MinMaxSize     = new Vector2(11, 20);
     Nodes.Add(icon = new Image {
         LayoutCell = new LayoutCell {
             Alignment = new Alignment {
                 X = HAlignment.Center, Y = VAlignment.Center
             }
         },
         MinMaxSize = new Vector2(11, 6),
         Texture    = IconPool.GetTexture("Filesystem.PathSeparatorCollapsed")
     });
     Expanded = false;
 }
Пример #2
0
        public PathFolderButton(Func <string, bool> openPath, string path) : base()
        {
            Text           = GetName(path);
            Presenter      = new PathButtonPresenter();
            base.Presenter = Presenter;
            MinMaxHeight   = 20;
            MinMaxWidth    = FontPool.Instance.DefaultFont.MeasureTextLine(Text, Theme.Metrics.TextHeight, 0).X + 7;
            Clicked       += () => openPath(path);
#if WIN
            UpdateHandler showContextMenu = null;
            showContextMenu = delta => {
                Updating -= showContextMenu;
                SystemShellContextMenu.Instance.Show(path);
            };
            // TODO: Immediate showing context menu causes weird crash in GestureManager
            Gestures.Add(new ClickGesture(1, () => Updating += showContextMenu));
#endif // WIN
        }