public Form1()
 {
     InitializeComponent();
     DoubleBuffered = true;
     dragger        = new DragBehavior(pic);
     dragger.Attach();
 }
示例#2
0
        public Window(string name,
                      IGuiSize size,
                      IGuiPosition position,
                      IGuiManager manager,
                      KeyValuePair <IGuiFrame, IGuiPosition> mainFrame,
                      KeyValuePair <IGuiFrame, IGuiPosition> headerFrame,
                      DragBehavior isDraggable,
                      IGuiStyle style)
            : base(name, size, position, manager, mainFrame, style)
        {
            mLogger      = manager.Logger;
            mDraggable   = isDraggable;
            mHeaderFrame = headerFrame;
            if (mHeaderFrame.Key != null)
            {
                mHeaderFrame.Key.Parent = this;
            }

            if (mHeaderFrame.Value == null)
            {
                mHeaderFrame = new KeyValuePair <IGuiFrame, IGuiPosition>
                               (
                    mHeaderFrame.Key,
                    new HeaderFrameSizePosition()
                               );
            }
        }
示例#3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        DragBehavior drag = other.gameObject.GetComponent <DragBehavior>();

        if (drag.invert)
        {
        }
    }
示例#4
0
 public Window(string name,
               IGuiSize size,
               IGuiManager manager,
               KeyValuePair <IGuiFrame, IGuiPosition> mainFrame,
               KeyValuePair <IGuiFrame, IGuiPosition> headerFrame,
               DragBehavior isDraggable,
               IGuiStyle style)
     : this(name, size, new FixedPosition(new Vector2(Screen.width * 0.5f, Screen.height * 0.5f)), manager, mainFrame, headerFrame, isDraggable, style)
 {
 }
        public void Initialize(DragBehavior dragBehavior, GameAPI api, IEnumerable <ItemObject> pickedItems,
                               Action <bool> backpackClicked)
        {
            _api = api;
            _api.ItemRemoved.AddListener(OnItemRemoved);
            _backpackClicked = backpackClicked;

            _dragBehavior = dragBehavior;
            _dragBehavior.ItemPushedToBag = OnItemPushedToBag;

            if (pickedItems == null)
            {
                return;
            }

            _pickedItems.AddRange(pickedItems);

            for (var i = 0; i < _pickedItems.Count; i++)
            {
                PlaceItemToHolder(_pickedItems[i]);
            }
        }
示例#6
0
        protected virtual Window BuildWindow(XmlNode windowNode)
        {
            string   name = BuildName(windowNode);
            IGuiSize size = BuildSize(windowNode);

            IGuiFrame    mainFrame         = null;
            IGuiPosition mainFramePosition = null;
            XmlNode      mainFrameNode     = windowNode.SelectSingleNode("MainFrame");

            if (mainFrameNode != null)
            {
                mainFramePosition = BuildPosition(mainFrameNode);
                mainFrame         = BuildFrame(mainFrameNode);
                if (mainFrame == null)
                {
                    throw new GuiConstructionException("Found MainFrame node in Window (" + name + "), but was unable to construct it.");
                }
            }

            IGuiFrame    headerFrame         = null;
            IGuiPosition headerFramePosition = null;
            XmlNode      headerFrameNode     = windowNode.SelectSingleNode("HeaderFrame");

            if (headerFrameNode != null)
            {
                headerFramePosition = BuildPosition(headerFrameNode);
                headerFrame         = BuildFrame(headerFrameNode);
                if (headerFrame == null)
                {
                    throw new GuiConstructionException("Found HeaderFrame node in Window (" + name + "), but was unable to construct it.");
                }
            }

            DragBehavior dragBehavior = BuildDragBehavior(windowNode);

            IGuiStyle style = GetStyle(windowNode, typeof(Window));

            if (windowNode.Attributes["position"] != null)
            {
                IGuiPosition position = BuildPosition(windowNode);
                return(new Window
                       (
                           name,
                           size,
                           position,
                           mManager,
                           new KeyValuePair <IGuiFrame, IGuiPosition>(
                               mainFrame,
                               mainFramePosition
                               ),
                           new KeyValuePair <IGuiFrame, IGuiPosition>(
                               headerFrame,
                               headerFramePosition
                               ),
                           dragBehavior,
                           style
                       ));
            }
            else
            {
                return(new Window
                       (
                           name,
                           size,
                           mManager,
                           new KeyValuePair <IGuiFrame, IGuiPosition>
                           (
                               mainFrame,
                               mainFramePosition
                           ),
                           new KeyValuePair <IGuiFrame, IGuiPosition>
                           (
                               headerFrame,
                               headerFramePosition
                           ),
                           dragBehavior,
                           style
                       ));
            }
        }