Exemple #1
0
    private void ProcesThunder(ClickType clickType = ClickType.CT_IGNITE)
    {
        Ray mouseRay = this._mainCamera.ScreenPointToRay(Input.mousePosition);
        RaycastHit rayHit = new RaycastHit();
        if (Physics.Raycast(mouseRay, out rayHit))
        {

            Vector3 rot = Vector3.zero;
            rot.x = 270.0f;
            Quaternion quat = Quaternion.identity;
            quat.eulerAngles = rot;

            Cell tmpCell = rayHit.collider.GetComponent<Cell>();
            if(tmpCell != null)
            {
                switch(clickType)
                {
                    case ClickType.CT_IGNITE:
                        GameObject go = (GameObject)Instantiate(this._thunder, rayHit.point, quat);
                        Destroy(go, 1.5f);
                        tmpCell.Ignite();
                        break;
                    case ClickType.CT_INFO:
                        tmpCell.PrintStatus();
                        break;
                }
            }
        }
    }
Exemple #2
0
 public ActionEntry(int x, int y, string text, int interval, ClickType type)
 {
     this.x = x;
     this.y = y;
     this.text = text;
     this.interval = interval;
     this.type = type;
 }
Exemple #3
0
 public override void ReciveInput(int x, int y, ClickType type)
 {
     //   int size=(int)toolVal;
     if (type == ClickType.Down)
     {
         if (data != null)
         {
             Loom.RunAsync(() =>
             {
                 printer.MosaicTexture(x, y, data.area, data.mosaicval);
                 //  printer.MosaicTexture(x, y,data.mosaicval);
             });
         }
     }
 }
 public override void WriteXml(XmlWriter writer)
 {
     base.WriteXml(writer);
     writer.WriteElementString("KnobImage", KnobImage);
     writer.WriteElementString("RotationStep", RotationStep.ToString(CultureInfo.InvariantCulture));
     writer.WriteElementString("StepValue", StepValue.ToString(CultureInfo.InvariantCulture));
     writer.WriteElementString("InitialRotation", InitialRotation.ToString(CultureInfo.InvariantCulture));
     writer.WriteStartElement("ClickType");
     writer.WriteElementString("Type", ClickType.ToString());
     if (ClickType == Controls.ClickType.Swipe)
     {
         writer.WriteElementString("Sensitivity", SwipeSensitivity.ToString(CultureInfo.InvariantCulture));
     }
     writer.WriteEndElement();
 }
Exemple #5
0
        public UIElementClickAndValidateEditPage(ActUIElement Act, PlatformInfoBase mPlatform)
        {
            mAct = Act;
            InitializeComponent();

            //TODO: Binding of all UI elements
            ClickType.Init(mAct.GetOrCreateInputParam(ActUIElement.Fields.ClickType), mPlatform.GetPlatformUIClickTypeList(), false, null);
            xValidationType.Init(mAct.GetOrCreateInputParam(ActUIElement.Fields.ValidationType), mPlatform.GetPlatformUIValidationTypesList(), false, null);
            xValidationElementTypeComboBox.Init(mAct.GetOrCreateInputParam(ActUIElement.Fields.ValidationElement), mPlatform.GetPlatformUIElementsType(), false, null);
            xValidationElementLocateByComboBox.Init(mAct.GetOrCreateInputParam(ActUIElement.Fields.ValidationElementLocateBy), mPlatform.GetPlatformUIElementLocatorsList(), false, null);
            SetLocateValueFrame();
            GingerCore.General.ActInputValueBinding(LoopThroughClicks, CheckBox.IsCheckedProperty, mAct.GetOrCreateInputParam(ActUIElement.Fields.LoopThroughClicks, "False"));

            xValidationElementLocateByComboBox.ComboBox.SelectionChanged += ElementLocateByComboBox_SelectionChanged;
        }
Exemple #6
0
        public SunButton CreateOperateButton(ClickType clickType)
        {
            float fontSize    = 9F;
            int   leftPadding = 0;

            var fontStyle = FontStyle.Regular;

            SunButton sunButton = new SunButton()
            {
            };

            sunButton.AutoSize = true;
            sunButton.Cursor   = System.Windows.Forms.Cursors.Hand;
            sunButton.FlatAppearance.BorderSize = 0;
            sunButton.FlatStyle               = System.Windows.Forms.FlatStyle.Flat;
            sunButton.Font                    = new System.Drawing.Font(familyName, fontSize, fontStyle);
            sunButton.Location                = new System.Drawing.Point(0, 0);
            sunButton.Margin                  = new System.Windows.Forms.Padding(0);
            sunButton.Name                    = MenuHelper.CreateName("btn");
            sunButton.Padding                 = new System.Windows.Forms.Padding(leftPadding, 0, 0, 0);
            sunButton.RightToLeft             = System.Windows.Forms.RightToLeft.No;
            sunButton.Size                    = new System.Drawing.Size(0, height);
            sunButton.Text                    = MenuHelper.GetNameByClickType(clickType);
            sunButton.TextAlign               = System.Drawing.ContentAlignment.MiddleCenter;
            sunButton.UseVisualStyleBackColor = true;

            switch (clickType)
            {
            case ClickType.Ignore:
                sunButton.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(191)))), ((int)(((byte)(102)))));
                break;

            case ClickType.AbsentMark:
                sunButton.ForeColor = System.Drawing.ColorTranslator.FromHtml("#4B9AFF");
                break;

            default:
                sunButton.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(102)))), ((int)(((byte)(102)))));
                break;
            }
            sunButton.Click += new System.EventHandler((object sender, EventArgs e) =>
            {
                var button = (SunButton)sender;
                //针对 菜单的点击事件
                this.ClickHandler?.Invoke(clickType, this.Param);
            });
            return(sunButton);
        }
Exemple #7
0
        private void Second(Button button, string content)
        {
            int index = ButtonList.IndexOf(button);

            if (gameplay.ValidSecondClick(PrevIndex, index))
            {
                if (PlayerOne)
                {
                    ReversePrev(PrevIndex);
                    button.Background    = Brushes.Red;
                    button.Content       = "X";
                    Cows.X               = Cows.X - 1;
                    positionValue[index] = PlayerMark.Red;

                    gameplay.ValueBind(positionValue);
                    if (gameplay.IsItCapture(index))
                    {
                        click = ClickType.Capture;
                    }
                    else
                    {
                        click     = ClickType.First;
                        PlayerOne = false;
                        mark      = "O";
                    }
                }
                else
                {
                    ReversePrev(PrevIndex);
                    button.Background    = Brushes.Blue;
                    button.Content       = "O";
                    Cows.Y               = Cows.Y - 1;
                    positionValue[index] = PlayerMark.Blue;

                    gameplay.ValueBind(positionValue);
                    if (gameplay.IsItCapture(index))
                    {
                        click = ClickType.Capture;
                    }
                    else
                    {
                        click     = ClickType.First;
                        PlayerOne = true;
                        mark      = "X";
                    }
                }
            }
        }
Exemple #8
0
    /// <summary>
    /// Clicks the unlockButton if the input field is selected and the unlock button is interactable
    /// </summary>
    /// <param name="clickType"> The enter button ClickType </param>
    public void EnterButtonPressed(ClickType clickType)
    {
        if (clickType != ClickType.Down)
        {
            return;
        }

        if (unlockButton.interactable && !walletPasswordVerification.VerifyingPassword)
        {
            unlockButton.Press();
        }
        else if (!walletPasswordVerification.VerifyingPassword)
        {
            passwordField.InputFieldBase.SelectSelectable();
        }
    }
Exemple #9
0
    /// <summary>
    /// Loads the wallet if the button is enabled.
    /// </summary>
    /// <param name="clickType"> The enter button ClickType </param>
    public void EnterButtonPressed(ClickType clickType)
    {
        if (clickType != ClickType.Down || checkingWallet)
        {
            return;
        }

        if (InputFieldUtils.GetActiveInputField() == LastSelectableField && nextButton.interactable)
        {
            nextButton.Press();
        }
        else
        {
            SelectableFields.MoveToNextSelectable();
        }
    }
Exemple #10
0
 /// <summary>
 /// Returns bit flags required to simulate mouse button release for specified button.
 /// </summary>
 /// <param name="ct">Mouse button.</param>
 /// <returns></returns>
 public static int MouseClickUpDwFlags(ClickType ct)
 {
     if (ct == ClickType.LeftClick)
     {
         return(MOUSEEVENTF_LEFTUP);
     }
     if (ct == ClickType.MiddleClick)
     {
         return(MOUSEEVENTF_MIDDLEUP);
     }
     if (ct == ClickType.RightClick)
     {
         return(MOUSEEVENTF_RIGHTUP);
     }
     return(0x0000);
 }
Exemple #11
0
    /// <summary>
    /// Clicks the send button if on the last input field
    /// </summary>
    /// <param name="clickType"> The enter button ClickType </param>
    public void EnterButtonPressed(ClickType clickType)
    {
        if (clickType != ClickType.Down)
        {
            return;
        }

        if (invalidTokenSection.activeInHierarchy && InputFieldUtils.GetActiveInputField() == decimalsField.InputFieldBase && okButton.interactable)
        {
            okButton.Press();
        }
        else if (invalidTokenSection.activeInHierarchy)
        {
            selectableFields.MoveToNextSelectable();
        }
    }
Exemple #12
0
    void ChangeBarValueByBtn(ClickType clickType)
    {
        progress = TargetScrollBar.value;

        if (clickType == ClickType.Long)
        {
            progress += Speed * dir * Time.deltaTime;
        }
        else if (clickType == ClickType.Once)
        {
            progress += ScrollViewHeight / progressLength * dir;
        }

        progress = Mathf.Clamp01(progress);
        TargetScrollBar.value = progress;
    }
    /// <summary>
    /// Moves to the next input field
    /// </summary>
    /// <param name="clickType"> The tab button ClickType </param>
    public void EnterButtonPressed(ClickType clickType)
    {
        if (clickType != ClickType.Down)
        {
            return;
        }

        if (InputFieldUtils.GetActiveInputField() == password2Field.InputFieldBase && nextButton.interactable)
        {
            nextButton.Press();
        }
        else
        {
            SelectableExtensions.MoveToNextSelectable(inputFields);
        }
    }
        public static string GetString(this ClickType clickType, GameSettings gameSettings)
        {
            switch (clickType)
            {
            case ClickType.Select:
                return(gameSettings.SelectText);

            case ClickType.Deselect:
                return(gameSettings.DeselectText);

            case ClickType.MoveTo:
                return(gameSettings.MoveToText);

            case ClickType.Rest:
                return(gameSettings.RestText);

            case ClickType.Attack:
                return(gameSettings.AttackText);

            case ClickType.Heal:
                return(gameSettings.HealText);

            case ClickType.Recruit:
                return(gameSettings.RecruitText);

            case ClickType.ConfirmMoveTo:
                return(gameSettings.ConfirmMoveToText);

            case ClickType.ConfirmRest:
                return(gameSettings.ConfirmRestText);

            case ClickType.ConfirmAttack:
                return(gameSettings.ConfirmAttackText);

            case ClickType.ConfirmRecruit:
                return(gameSettings.ConfirmRecruitText);

            case ClickType.ConfirmHeal:
                return(gameSettings.ConfirmHealText);

            case ClickType.None:
                return(gameSettings.NoneText);

            default:
                throw new ArgumentOutOfRangeException(nameof(clickType), clickType, null);
            }
        }
        private async Task EventHandler(IDialogContext context, Activity activity)
        {
            JObject          json = activity.Value as JObject;
            List <InputData> data = getReplyData(json);

            //have mandatory info
            if (data.Count >= 2)
            {
                //json structure is correct
                if (data[0].attribute == REPLY_ATR && data[1].attribute == DIALOG_ATR)
                {
                    ClickType  event_click  = getClickType(data[0].value);
                    DialogType event_dialog = getDialogType(data[1].value);

                    //process in this dialog
                    if (event_dialog == DialogType.WISHLIST &&
                        event_click != ClickType.NONE)
                    {
                        switch (event_click)
                        {
                        case ClickType.PAGINATION:
                            await StartAsync(context);

                            break;

                        case ClickType.ADD_PRODUCT:
                            var dialog = new FilterDialog(FilterDialog.State.INIT);
                            context.Call(dialog, ResumeAfterDialogCall);
                            break;
                        }
                    }
                    //process in parent dialog
                    else
                    {
                        context.Done(new CODE(DIALOG_CODE.PROCESS_EVENT, activity, event_dialog));
                    }
                }
                else
                {
                    context.Done(new CODE(DIALOG_CODE.DONE));
                }
            }
            else
            {
                context.Done(new CODE(DIALOG_CODE.DONE));
            }
        }
    /// <summary>
    /// Checks the popup buttons and closes them if none of them are hovered.
    /// </summary>
    /// <param name="clickType"> The ClickType that was pressed. </param>
    private void CheckPopupButtons(ClickType clickType)
    {
        if (clickType != ClickType.Down)
        {
            return;
        }

        if (observables.Count == 0 || observables.Where(observable => observable.PointerEntered).Count() > 0)
        {
            return;
        }

        observables.Where(button => button.PopupObject != null).ToList().SafeForEach(obj => Object.Destroy(obj.PopupObject));
        observables.Clear();

        onObjectsDestroyed?.Invoke();
    }
        private void MappingProperties_PropertyClicked(PropertyPage props, ClickType click, int propIdx, int rowIdx, int colIdx)
        {
            if (click == ClickType.Button && (propIdx == 2 || propIdx == 3))
            {
                var keys = new bool[MidiFileReader.MidiDrumKeyNames.Length];

                if (propIdx == 2)
                {
                    for (int i = 0; i < keys.Length; i++)
                    {
                        keys[i] = true;
                    }
                }

                props.UpdateCheckBoxList(1, keys);
            }
        }
Exemple #18
0
    /// <summary>
    /// Closes the active popup if one is open, if not, calls the back button on the active menu.
    /// </summary>
    /// <param name="clickType"> The ClickType of the escape button press. </param>
    public void EscapeButtonPressed(ClickType clickType)
    {
        if (clickType != ClickType.Down)
        {
            return;
        }

        if (popupManager.ActivePopupType != typeof(HopeUpdatePopup) && (popupManager.AnimatingPopup || popupManager.CloseActivePopup(typeof(LoadingPopup), typeof(TooltipPopup)) || popupManager.ActivePopupExists))
        {
            return;
        }

        if (closingMenu?.Animator.Animating != true)
        {
            menus.Peek().GoBack();
        }
    }
Exemple #19
0
 public BaseBuilderMVP()
 {
     turnNumber      = 0;
     lastTurn        = 0;
     nextTurn        = Time.time + timePerTurn;
     currentIsland   = new bbIsland(this);
     playerAgents    = new List <bbAgent>();
     playerResources = new Dictionary <ItemType, int> {
         { ItemType.ITEM_FOOD, STARTING_FOOD }, { ItemType.ITEM_GOLD, STARTING_GOLD }
     };
     playerJobQueue   = new List <List <bbJob> >();
     availableActions = new List <ClickType> {
         ClickType.BUILD_FARM, ClickType.BUILD_MINE, ClickType.BUILD_HOUSE
     };
     currentClickType = availableActions[0];
     InitializeSetup();
 }
Exemple #20
0
 public override void WriteXml(XmlWriter writer)
 {
     base.WriteXml(writer);
     writer.WriteElementString("SwitchType", SwitchType.ToString());
     writer.WriteElementString("Orientation", Orientation.ToString());
     writer.WriteElementString("ClickType", ClickType.ToString());
     writer.WriteElementString("PositionOneImage", PositionOneImage);
     writer.WriteElementString("PositionTwoImage", PositionTwoImage);
     if (HasIndicator)
     {
         writer.WriteStartElement("Indicator");
         writer.WriteElementString("PositionOneImage", PositionOneIndicatorOnImage);
         writer.WriteElementString("PositionTwoImage", PositionTwoIndicatorOnImage);
         writer.WriteEndElement();
     }
     writer.WriteElementString("DefaultPosition", DefaultPosition.ToString());
 }
Exemple #21
0
 public ActionMouse(
     long timeDelayMS,
     ClickType clickType,
     CoordinateMode mode,
     MouseButton button,
     int xButtonId,
     int moveX,
     int moveY) : base(timeDelayMS)
 {
     this.clickType = clickType;
     this.mode      = mode;
     this.button    = button;
     this.xMove     = moveX;
     this.yMove     = moveY;
     this.xButtonId = xButtonId;
     this.Type      = ActionType.Mouse;
 }
Exemple #22
0
 public override void WriteXml(System.Xml.XmlWriter writer)
 {
     base.WriteXml(writer);
     writer.WriteElementString("SwitchType", SwitchType.ToString());
     writer.WriteElementString("Orientation", Orientation.ToString());
     writer.WriteElementString("ClickType", ClickType.ToString());
     writer.WriteStartElement("GuardUp");
     writer.WriteElementString("PositionOneImage", PositionOneGuardUpImage);
     writer.WriteElementString("PositionTwoImage", PositionTwoGuardDownImage);// writing this value just for compatibility with old profiles
     writer.WriteEndElement();
     writer.WriteStartElement("GuardDown");
     writer.WriteElementString("PositionOneImage", PositionOneGuardUpImage);// writing this value just for compatibility with old profiles
     writer.WriteElementString("PositionTwoImage", PositionTwoGuardDownImage);
     writer.WriteEndElement();
     writer.WriteElementString("DefaultPosition", "Two"); // writing this value just for compatibility with old profiles
     writer.WriteElementString("DefaultGuardPosition", DefaultGuardPosition.ToString());
 }
Exemple #23
0
 public override void WriteXml(System.Xml.XmlWriter writer)
 {
     base.WriteXml(writer);
     writer.WriteElementString("SwitchType", SwitchType.ToString());
     writer.WriteElementString("Orientation", Orientation.ToString());
     writer.WriteElementString("ClickType", ClickType.ToString());
     writer.WriteStartElement("GuardUp");
     writer.WriteElementString("PositionOneImage", PositionOneGuardUpImage);
     writer.WriteElementString("PositionTwoImage", PositionTwoGuardUpImage);
     writer.WriteEndElement();
     writer.WriteStartElement("GuardDown");
     writer.WriteElementString("PositionOneImage", PositionOneGuardDownImage);
     writer.WriteElementString("PositionTwoImage", PositionTwoGuardDownImage);
     writer.WriteEndElement();
     writer.WriteElementString("DefaultPosition", DefaultPosition.ToString());
     writer.WriteElementString("DefaultGuardPosition", DefaultGuardPosition.ToString());
 }
Exemple #24
0
 public static int GetCommandForClick(ClickType click)
 {
     int command = MouseCommand.none;
     switch (click)
     {
         case ClickType.Click:
             command = Settings.Default.Click;
             break;
         case ClickType.MidClick:
             command = Settings.Default.MidClick;
             break;
         case ClickType.RightClick:
             command = Settings.Default.RightClick;
             break;
     }
     return command;
 }
Exemple #25
0
    /// <summary>
    /// This initializes this instance, for intializaing internal objects
    /// before Awake() is called.
    /// </summary>
    public virtual void Init()
    {
        clickStatus = ClickType.NoClick;

        _connectedLocations = new List <Location>();
        _connectedPaths     = new Dictionary <int, Path>();
        _locID = NetworkManager.GetNextLocID();

        if (upperText != null)
        {
            upperText.text = "";
        }

        if (lowerText != null)
        {
            lowerText.text = "";
        }
    }
    public void EnterButtonPressed(ClickType clickType)
    {
        if (clickType != ClickType.Down)
        {
            return;
        }

        Button button = confirmButton.gameObject.activeInHierarchy ? confirmButton : addContactButton;

        if (InputFieldUtils.GetActiveInputField() == inputFields[1] && button.interactable)
        {
            button.Press();
        }
        else
        {
            inputFields.MoveToNextSelectable();
        }
    }
Exemple #27
0
        public async Task EventHandler(IDialogContext context, Activity activity)
        {
            JObject          json = activity.Value as JObject;
            List <InputData> data = getReplyData(json);

            //have mandatory info
            if (data.Count >= 2)
            {
                //json structure is correct
                if (data[0].attribute == REPLY_ATR && data[1].attribute == DIALOG_ATR)
                {
                    ClickType  event_click  = getClickType(data[0].value);
                    DialogType event_dialog = getDialogType(data[1].value);

                    if (event_dialog == DialogType.RECOMMENDATION &&
                        event_click != ClickType.NONE)
                    {
                        switch (event_click)
                        {
                        case ClickType.PAGINATION:
                        {
                            page++;
                            state = State.INIT;
                            await ShowRecommendations(context, null);

                            break;
                        }
                        }
                    }
                    else
                    {
                        context.Done(new CODE(DIALOG_CODE.PROCESS_EVENT, activity, event_dialog));
                    }
                }
                else
                {
                    context.Done(new CODE(DIALOG_CODE.DONE));
                }
            }
            else
            {
                context.Done(new CODE(DIALOG_CODE.DONE));
            }
        }
Exemple #28
0
        public static void Press(ClickType type)
        {
            switch (type)
            {
            case ClickType.None:
                break;

            case ClickType.Left:
                Api.mouse_event(MouseClickType.LeftDown, 259, 334, 0, UIntPtr.Zero);
                break;

            case ClickType.Right:
                Api.mouse_event(MouseClickType.RightDown, 259, 334, 0, UIntPtr.Zero);
                break;

            default:
                throw new ArgumentOutOfRangeException("type");
            }
        }
Exemple #29
0
        public override void WriteXml(XmlWriter writer)
        {
            TypeConverter colorConverter = TypeDescriptor.GetConverter(typeof(Color));

            base.WriteXml(writer);
            writer.WriteElementString("KnobImage", KnobImage);
            writer.WriteStartElement("Positions");
            foreach (RotarySwitchPosition position in Positions)
            {
                writer.WriteStartElement("Position");
                writer.WriteAttributeString("Name", position.Name);
                writer.WriteAttributeString("Rotation", position.Rotation.ToString(CultureInfo.InvariantCulture));
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
            writer.WriteElementString("DefaultPosition", DefaultPosition.ToString(CultureInfo.InvariantCulture));
            if (DrawLines)
            {
                writer.WriteStartElement("Lines");
                writer.WriteElementString("Thickness", LineThickness.ToString(CultureInfo.InvariantCulture));
                writer.WriteElementString("Length", LineLength.ToString(CultureInfo.InvariantCulture));
                writer.WriteElementString("Color", colorConverter.ConvertToInvariantString(LineColor));
                writer.WriteEndElement();
            }
            if (DrawLabels)
            {
                writer.WriteStartElement("Labels");
                writer.WriteElementString("Color", colorConverter.ConvertToInvariantString(LabelColor));
                writer.WriteElementString("MaxWidth", MaxLabelWidth.ToString(CultureInfo.InvariantCulture));
                writer.WriteElementString("MaxHeight", MaxLabelHeight.ToString(CultureInfo.InvariantCulture));
                writer.WriteElementString("Distance", LabelDistance.ToString(CultureInfo.InvariantCulture));
                LabelFormat.WriteXml(writer);
                writer.WriteEndElement();
            }
            writer.WriteStartElement("ClickType");
            writer.WriteElementString("Type", ClickType.ToString());
            if (ClickType == Controls.ClickType.Swipe)
            {
                writer.WriteElementString("Sensitivity", SwipeSensitivity.ToString(CultureInfo.InvariantCulture));
            }
            writer.WriteEndElement();
            writer.WriteElementString("MouseWheel", MouseWheelAction.ToString(CultureInfo.InvariantCulture));
        }
Exemple #30
0
        private static void InitializeSettings()
        {
            // Gather app settings using a user form.
            using (var form = new SettingsForm())
            {
                form.StartPosition = FormStartPosition.CenterScreen;
                form.ShowDialog();

                if (!form.Confirmed)
                {
                    // The user canceled the application.
                    Environment.Exit(0);
                }

                mWaitMinutes      = Convert.ToDouble(form.WaitMinutes);
                mClickCoordinates = form.ClickLocation;
                mClickType        = form.ClickType;
            }
        }
        public static async Task RightClick(ClickType click)
        {
            Input mouseDownInput = new Input();

            mouseDownInput.Data.Mouse.dwFlags = MouseEventFlags.RIGHTDOWN;
            Input mouseUpInput = new Input();

            mouseUpInput.Data.Mouse.dwFlags = MouseEventFlags.RIGHTUP;
            Input[] inputs = new Input[] { mouseDownInput, mouseUpInput };

            SendInput(inputs.Length, inputs, Input.Size);

            if (click == ClickType.Double)
            {
                await Task.Delay(5);

                SendInput(inputs.Length, inputs, Input.Size);
            }
        }
Exemple #32
0
        private static void Release(ClickType clickType)
        {
            switch (clickType)
            {
            case ClickType.None:
                break;

            case ClickType.Left:
                Api.mouse_event(MouseClickType.LeftUp, 259, 334, 0, UIntPtr.Zero);
                break;

            case ClickType.Right:
                Api.mouse_event(MouseClickType.RightUp, 259, 334, 0, UIntPtr.Zero);
                break;

            default:
                throw new ArgumentOutOfRangeException("type");
            }
        }
Exemple #33
0
    public override void ReciveInput(int x, int y, ClickType type)
    {
        if (isDraw)
        {
            if (type == ClickType.Down)
            {
                drawRectangle.Draw();
            }
        }
        // if(ty)
        if (type == ClickType.Up)
        {
            if (isDrag)
            {
                isDrag = false;
                drawRectangle.SetNotDrag();
            }
            if (isDraw)
            {
                EventSys.GetInstance().ChooseAreaEnd();

                drawRectangle.LockArea();
                isDraw = false;
                drawRectangle.GetArea();
            }
        }
        if (type == ClickType.Down)
        {
            if (!isDraw)
            {
                if (drawRectangle.IsInArea())
                {
                    isDrag = true;
                    drawRectangle.SetDrag();
                }
            }
        }
        if (isDrag)
        {
            drawRectangle.Drag();
        }
    }
        public void ClickHandler(short slot, ClickType click, short ActionID, bool Shift, short ItemID, byte Count, short Meta)
        {
            if (slot == -999)
            {
                //TODO throw item
                p.OnMouse = Item.Nothing;
                return;
            }

            if (Shift)
            {
                if (slot >= 36)
                {
                    for (int i = 9; i <= 35; i++)
                    {
                        Item item = items[i];
                        if (item.item == items[slot].item)
                        {
                            if (item.item < 255)
                            {
                                if (item.meta != items[slot].meta)
                                {
                                    continue;
                                }
                                else
                                {
                                    byte stacking = isStackable(item.item);
                                    byte available = (byte)(stacking - item.count);
                                    if (available == 0) return;
                                    if (items[slot].count <= available)
                                    {
                                        item.count += items[slot].count;
                                        items[slot] = Item.Nothing;
                                        return;
                                    }
                                    else
                                    {
                                        item.count = stacking;
                                        items[slot].count -= available;
                                    }
                                }
                            }
                            else
                            {
                                byte stacking = isStackable(item.item);
                                byte available = (byte)(stacking - item.count);
                                if (available == 0) return;
                                if (items[slot].count <= available)
                                {
                                    item.count += items[slot].count;
                                    items[slot] = Item.Nothing;
                                    return;
                                }
                                else
                                {
                                    item.count = stacking;
                                    items[slot].count -= available;
                                }
                            }
                        }
                    }
                    for (int i = 9; i <= 35; i++)
                        if (items[i].item == (short)Items.Nothing)
                        {
                            items[i] = items[slot];
                            items[slot] = Item.Nothing;
                        }
                    return;
                }
                if (slot < 36)
                {
                    for (int i = 36; i < 45; i++)
                    {
                        Item item = items[i];
                        if (item.item == items[slot].item)
                        {
                            if (item.item < 255)
                            {
                                if (item.meta != items[slot].meta) continue;
                                else
                                {
                                    byte stacking = isStackable(item.item);
                                    byte available = (byte)(stacking - item.count);
                                    if (available == 0) return;
                                    if (items[slot].count <= available)
                                    {
                                        item.count += items[slot].count;
                                        items[slot] = Item.Nothing;
                                        return;
                                    }
                                    else
                                    {
                                        item.count = stacking;
                                        items[slot].count -= available;
                                    }
                                }
                            }
                            else
                            {
                                byte stacking = isStackable(item.item);
                                byte available = (byte)(stacking - item.count);
                                if (available == 0) return;
                                if (items[slot].count <= available)
                                {
                                    item.count += items[slot].count;
                                    items[slot] = Item.Nothing;
                                    return;
                                }
                                else
                                {
                                    item.count = stacking;
                                    items[slot].count -= available;
                                }
                            }
                        }
                    }
                    for (int i = 36; i < 45; i++)
                        if (items[i].item == (short)Items.Nothing)
                        {
                            items[i] = items[slot];
                            items[slot] = Item.Nothing;
                        }
                    return;
                }
                return;
            }

            if (p.OnMouse != Item.Nothing)
            {
                if (items[slot] != Item.Nothing)
                {
                    #region Crafting Slot Done
                    if (slot == 0)
                    {
                        if (p.OnMouse.item == items[slot].item)
                        {
                            if (p.OnMouse.item < 255)
                            {
                                if (p.OnMouse.meta == items[slot].meta)
                                {
                                    byte stacking = isStackable(p.OnMouse.item);
                                    byte availible = (byte)(stacking - p.OnMouse.count);
                                    if (items[slot].count <= availible)
                                    {
                                        p.OnMouse.count += items[slot].count;
                                    }
                                }
                                else
                                {
                                    Item temp = items[slot];
                                    items[slot] = p.OnMouse;
                                    p.OnMouse = temp;
                                }
                            }
                            else
                            {
                                byte stacking = isStackable(p.OnMouse.item);
                                byte availible = (byte)(stacking - p.OnMouse.count);
                                if (items[slot].count <= availible)
                                {
                                    p.OnMouse.count += items[slot].count;
                                }
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                    #endregion
                    #region Armor Slots Done
                    else if (slot == 5 || slot == 6 || slot == 7 || slot == 8)
                    {
                        if (items[slot].item == p.OnMouse.item) return;
                        switch (slot)
                        {
                            case 5:
                                if (p.OnMouse.item == 298 || p.OnMouse.item == 302 || p.OnMouse.item == 306 || p.OnMouse.item == 310)
                                {
                                    Item temp = items[slot];
                                    items[slot] = p.OnMouse;
                                    p.OnMouse = temp;
                                }
                                break;
                            case 6:
                                if (p.OnMouse.item == 299 || p.OnMouse.item == 303 || p.OnMouse.item == 307 || p.OnMouse.item == 311)
                                {
                                    Item temp = items[slot];
                                    items[slot] = p.OnMouse;
                                    p.OnMouse = temp;
                                }
                                break;
                            case 7:
                                if (p.OnMouse.item == 300 || p.OnMouse.item == 304 || p.OnMouse.item == 308 || p.OnMouse.item == 312)
                                {
                                    Item temp = items[slot];
                                    items[slot] = p.OnMouse;
                                    p.OnMouse = temp;
                                }
                                break;
                            case 8:
                                if (p.OnMouse.item == 301 || p.OnMouse.item == 305 || p.OnMouse.item == 309 || p.OnMouse.item == 313)
                                {
                                    Item temp = items[slot];
                                    items[slot] = p.OnMouse;
                                    p.OnMouse = temp;
                                }
                                break;
                        }
                    }
                    #endregion
                    else
                    {
                        if (click == ClickType.RightClick)
                        {
                            if (p.OnMouse.item == items[slot].item)
                            {
                                if (p.OnMouse.item < 255)
                                {
                                    if (p.OnMouse.meta == items[slot].meta)
                                    {
                                        byte stacking = isStackable(p.OnMouse.item);
                                        if (items[slot].count < stacking)
                                        {
                                            items[slot].count += 1;
                                            if (p.OnMouse.count == 1)
                                            {
                                                p.OnMouse = Item.Nothing;
                                            }
                                            else
                                            {
                                                p.OnMouse.count -= 1;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Item temp = items[slot];
                                        items[slot] = p.OnMouse;
                                        p.OnMouse = temp;
                                    }
                                }
                                else
                                {
                                    byte stacking = isStackable(p.OnMouse.item);
                                    if (items[slot].count < stacking)
                                    {
                                        items[slot].count += 1;
                                        if (p.OnMouse.count == 1)
                                        {
                                            p.OnMouse = Item.Nothing;
                                        }
                                        else
                                        {
                                            p.OnMouse.count -= 1;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (p.OnMouse.item == items[slot].item)
                            {
                                if (p.OnMouse.item < 255)
                                {
                                    if (p.OnMouse.meta == items[slot].meta)
                                    {
                                        byte stacking = isStackable(p.OnMouse.item);
                                        byte available = (byte)(stacking - items[slot].count);
                                        if (available == 0) return;
                                        if (p.OnMouse.count <= available)
                                        {
                                            items[slot].count += p.OnMouse.count;
                                            p.OnMouse = Item.Nothing;
                                        }
                                        else
                                        {
                                            items[slot].count = stacking;
                                            p.OnMouse.count -= available;
                                        }
                                    }
                                    else
                                    {
                                        Item temp = items[slot];
                                        items[slot] = p.OnMouse;
                                        p.OnMouse = temp;
                                    }
                                }
                                else
                                {
                                    byte stacking = isStackable(p.OnMouse.item);
                                    byte available = (byte)(stacking - items[slot].count);
                                    if (available == 0) return;
                                    if (p.OnMouse.count <= available)
                                    {
                                        items[slot].count += p.OnMouse.count;
                                        p.OnMouse = Item.Nothing;
                                    }
                                    else
                                    {
                                        items[slot].count = stacking;
                                        p.OnMouse.count -= available;
                                    }
                                }
                            }
                            else
                            {
                                Item temp = items[slot];
                                items[slot] = p.OnMouse;
                                p.OnMouse = temp;
                            }
                        }
                    }
                }
                #region Empty Slot Done
                else
                {
                    if (slot == 0) return; //Crafting output slot
                    #region Armor slots Done
                    if (slot == 5 || slot == 6 || slot == 7 || slot == 8)
                    {
                        switch (slot)
                        {
                            case 5:
                                if (p.OnMouse.item == 298 || p.OnMouse.item == 302 || p.OnMouse.item == 306 || p.OnMouse.item == 310)
                                {
                                    items[slot] = p.OnMouse;
                                    p.OnMouse = Item.Nothing;
                                }
                                break;
                            case 6:
                                if (p.OnMouse.item == 299 || p.OnMouse.item == 303 || p.OnMouse.item == 307 || p.OnMouse.item == 311)
                                {
                                    items[slot] = p.OnMouse;
                                    p.OnMouse = Item.Nothing;
                                }
                                break;
                            case 7:
                                if (p.OnMouse.item == 300 || p.OnMouse.item == 304 || p.OnMouse.item == 308 || p.OnMouse.item == 312)
                                {
                                    items[slot] = p.OnMouse;
                                    p.OnMouse = Item.Nothing;
                                }
                                break;
                            case 8:
                                if (p.OnMouse.item == 301 || p.OnMouse.item == 305 || p.OnMouse.item == 309 || p.OnMouse.item == 313)
                                {
                                    items[slot] = p.OnMouse;
                                    p.OnMouse = Item.Nothing;
                                }
                                break;
                        }
                    }
                    #endregion
                    else
                    {
                        if (click == ClickType.RightClick)
                        {
                            if (p.OnMouse.count == 1)
                            {
                                items[slot] = p.OnMouse;
                                p.OnMouse = Item.Nothing;
                            }
                            else
                            {
                                p.OnMouse.count -= 1;
                                items[slot] = new Item(p.OnMouse.item, 1, p.OnMouse.meta, p.level);
                            }
                        }
                        else
                        {
                            items[slot] = p.OnMouse;
                            p.OnMouse = Item.Nothing;
                        }
                    }
                }
                #endregion
            }
            #region Empty Mouse done
            else //Player has NOTHING on the mouse
            {
                if (items[slot] != Item.Nothing)
                {
                    if (click == ClickType.RightClick)
                    {
                        p.OnMouse = Right_Click(slot);
                    }
                    else //Player left-clicked
                    {
                        p.OnMouse = items[slot];
                        Remove(slot);
                    }
                }
                else
                {
                    return;
                }
            }
            #endregion
        }
        public bool Click(ClickType clickType, int relativeX, int relativeY)
        {
            var whereToClick = AutomationElement;
            var whereTheHandle = whereToClick;

            if (whereToClick.Current.NativeWindowHandle == 0)
            {
                whereTheHandle = GetAncestorWithHandle(whereToClick);

                if (whereTheHandle.Current.NativeWindowHandle == 0)
                    throw new InvalidOperationException("The handle of this control equals to zero");
            }

            int x;
            int y;

            // These x and y are window-related coordinates
            if (relativeX != 0 && relativeY != 0)
            {
                x = relativeX + (int)whereToClick.Current.BoundingRectangle.X;
                y = relativeY + (int)whereToClick.Current.BoundingRectangle.Y;
            }
            else
            {
                // These x and y are for the SetCursorPos call. They are screen coordinates.

                x = (int)whereToClick.Current.BoundingRectangle.X + ((int)whereToClick.Current.BoundingRectangle.Width / 2);
                y = (int)whereToClick.Current.BoundingRectangle.Y + ((int)whereToClick.Current.BoundingRectangle.Height / 2);
            }

            // PostMessage's (click) second parameter
            uint uDown;
            uint uUp;

            // These relative coordinates for SendMessage/PostMessage
            relativeX = x - (int)whereTheHandle.Current.BoundingRectangle.X;
            relativeY = y - (int)whereTheHandle.Current.BoundingRectangle.Y;

            // PostMessage's (click) third and fourth parameters (the third will be re-assigned later)
            IntPtr wParamDown;
            IntPtr wParamUp;

            var lParam = new IntPtr(
                (new IntPtr(relativeX).ToInt32() & 0xFFFF) +
                ((new IntPtr(relativeY).ToInt32() & 0xFFFF) << 16)
            );

            // PostMessage's (activate) third parameter
            uint ulAct;
            uint uhAct;

            uint mask = 0;
            if (clickType.HasFlag(ClickType.Control))
                mask |= NativeMethods.MK_CONTROL;
            if (clickType.HasFlag(ClickType.Shift))
                mask |= NativeMethods.MK_SHIFT;

            bool doubleClick = clickType.HasFlag(ClickType.DoubleClick);
            var button = clickType & ClickType.ButtonMask;

            switch (button)
            {
                case ClickType.Right:
                    if (!doubleClick)
                    {
                        uhAct = uDown = NativeMethods.WM_RBUTTONDOWN;
                        uUp = NativeMethods.WM_RBUTTONUP;
                        wParamDown = new IntPtr(NativeMethods.MK_RBUTTON | mask);
                        wParamUp = new IntPtr(mask);
                        ulAct = NativeMethods.MK_RBUTTON;
                    }
                    else
                    {
                        uhAct = uDown = NativeMethods.WM_RBUTTONDBLCLK;
                        uUp = NativeMethods.WM_RBUTTONUP;
                        wParamDown = new IntPtr(NativeMethods.MK_RBUTTON | mask);
                        wParamUp = new IntPtr(mask);
                        ulAct = NativeMethods.MK_RBUTTON;
                    }
                    break;

                case ClickType.Middle:
                    if (!doubleClick)
                    {
                        uhAct = uDown = NativeMethods.WM_MBUTTONDOWN;
                        uUp = NativeMethods.WM_MBUTTONUP;
                        wParamDown = new IntPtr(NativeMethods.MK_MBUTTON | mask);
                        wParamUp = new IntPtr(mask);
                        ulAct = NativeMethods.MK_MBUTTON;
                    }
                    else
                    {
                        uhAct = uDown = NativeMethods.WM_MBUTTONDBLCLK;
                        uUp = NativeMethods.WM_MBUTTONUP;
                        wParamDown = new IntPtr(NativeMethods.MK_MBUTTON | mask);
                        wParamUp = new IntPtr(mask);
                        ulAct = NativeMethods.MK_MBUTTON;
                    }
                    break;

                default:
                    if (doubleClick)
                    {
                        uhAct = uDown = NativeMethods.WM_LBUTTONDBLCLK;
                        uUp = NativeMethods.WM_LBUTTONUP;
                        wParamDown = new IntPtr(NativeMethods.MK_LBUTTON | mask);
                        wParamUp = new IntPtr(mask);
                        ulAct = NativeMethods.MK_LBUTTON;
                    }
                    else
                    {
                        uhAct = uDown = NativeMethods.WM_LBUTTONDOWN;
                        uUp = NativeMethods.WM_LBUTTONUP;
                        wParamDown = new IntPtr(NativeMethods.MK_LBUTTON | mask);
                        wParamUp = new IntPtr(mask);
                        ulAct = NativeMethods.MK_LBUTTON;
                    }
                    break;
            }

            var handle = new IntPtr(whereTheHandle.Current.NativeWindowHandle);

            try
            {
                whereTheHandle.SetFocus();
            }
            catch
            {
            }

            NativeMethods.SetCursorPos(x, y);

            Thread.Sleep(0 /* Preferences.OnClickDelay */);

            // Trying to heal context menu clicks
            var mainWindow = Process.GetProcessById(whereTheHandle.Current.ProcessId).MainWindowHandle;

            if (mainWindow != IntPtr.Zero)
            {
                var lParam2 = new IntPtr(
                    (new IntPtr(ulAct).ToInt32() & 0xFFFF) +
                    ((new IntPtr(uhAct).ToInt32() & 0xFFFF) << 16)
                );

                NativeMethods.PostMessage1(
                    handle,
                    NativeMethods.WM_MOUSEACTIVATE,
                    mainWindow,
                    lParam2
                );
            }

            if (clickType.HasFlag(ClickType.Control))
                NativeMethods.keybd_event(NativeMethods.VK_LCONTROL, 0x45, NativeMethods.KEYEVENTF_EXTENDEDKEY, 0);
            if (clickType.HasFlag(ClickType.Shift))
                NativeMethods.keybd_event(NativeMethods.VK_LSHIFT, 0x45, NativeMethods.KEYEVENTF_EXTENDEDKEY, 0);

            bool postDownSuccess = NativeMethods.PostMessage1(handle, uDown, wParamDown, lParam);

            if (button == ClickType.Right || doubleClick)
                NativeMethods.PostMessage1(handle, NativeMethods.WM_MOUSEMOVE, wParamDown, lParam);

            bool postUpSuccess = NativeMethods.PostMessage1(handle, uUp, wParamUp, lParam);

            if (clickType.HasFlag(ClickType.Control))
                NativeMethods.keybd_event(NativeMethods.VK_LCONTROL, 0x45, NativeMethods.KEYEVENTF_EXTENDEDKEY | NativeMethods.KEYEVENTF_KEYUP, 0);
            if (clickType.HasFlag(ClickType.Shift))
                NativeMethods.keybd_event(NativeMethods.VK_LSHIFT, 0x45, NativeMethods.KEYEVENTF_EXTENDEDKEY | NativeMethods.KEYEVENTF_KEYUP, 0);

            return postDownSuccess && postUpSuccess;
        }
 public bool Click(ClickType clickType)
 {
     return Click(clickType, 5, 5);
 }
 public bool DoubleClick(ClickType clickType)
 {
     return Click(clickType | ClickType.DoubleClick);
 }
        public void HandleClick(short slot, ClickType click, short ActionID, bool Shift)
        {
            if (slot == -999)
            {
                //TODO throw item
                p.OnMouse = Item.Nothing;
                return;
            }
            if (slot < 0 || slot > 44) return;
            Item item, clickItem = items[slot];

            if (slot == 0)
            {
                // TODO: Crafting output handler.
                return;
            }

            if (Shift)
            {
                bool useEmptySlot = false;
                if (slot >= 36 || slot <= 8)
                {
                    for (int i = 9; i < 36; i++)
                    {
                        item = items[i];
                        if (useEmptySlot)
                        {
                            if (item.id == -1)
                            {
                                items[i] = clickItem;
                                items[slot] = Item.Nothing;
                                break;
                            }
                        }
                        else if (item.id == clickItem.id && item.meta == clickItem.meta)
                        {
                            byte stack = isStackable(item.id);
                            byte avail = (byte)(stack - item.count);
                            if (avail < 1) continue;

                            if (clickItem.count <= avail)
                            {
                                item.count += clickItem.count;
                                items[slot] = Item.Nothing;
                                break;
                            }
                            else
                            {
                                item.count = stack;
                                clickItem.count -= avail;
                            }
                        }
                        if (i == 35 && !useEmptySlot) { useEmptySlot = true; i = 8; }
                    }
                }
                else
                {
                    for (int i = 36; i < 45; i++)
                    {
                        item = items[i];
                        if (useEmptySlot)
                        {
                            if (item.id == -1)
                            {
                                items[i] = clickItem;
                                items[slot] = Item.Nothing;
                                break;
                            }
                        }
                        else if (item.id == clickItem.id && item.meta == clickItem.meta)
                        {
                            byte stack = isStackable(item.id);
                            byte avail = (byte)(stack - item.count);
                            if (avail < 1) continue;

                            if (clickItem.count <= avail)
                            {
                                item.count += clickItem.count;
                                items[slot] = Item.Nothing;
                                break;
                            }
                            else
                            {
                                item.count = stack;
                                clickItem.count -= avail;
                            }
                        }
                        if (i == 44 && !useEmptySlot) { useEmptySlot = true; i = 35; }
                    }
                }
            }
            else
            {
                if (p.OnMouse.id == -1)
                {
                    if (clickItem.id != -1)
                    {
                        if (click == ClickType.RightClick && clickItem.count > 1)
                        {
                            p.OnMouse = new Item(clickItem);
                            p.OnMouse.count = (byte)Math.Ceiling((float)p.OnMouse.count / 2F);
                            clickItem.count /= 2;
                        }
                        else
                        {
                            items[slot] = Item.Nothing;
                            p.OnMouse = clickItem;
                        }
                    }
                }
                else
                {
                    if (clickItem.id != -1)
                    {
                        if (p.OnMouse.id == clickItem.id && p.OnMouse.meta == clickItem.meta)
                        {
                            if (slot < 5 || slot > 8)
                            {
                                byte stack = isStackable(clickItem.id);
                                if (click == ClickType.RightClick && p.OnMouse.count > 1)
                                {
                                    if (clickItem.count < stack)
                                    {
                                        p.OnMouse.count--;
                                        clickItem.count++;
                                    }
                                }
                                else
                                {
                                    if (clickItem.count < stack)
                                    {
                                        byte avail = (byte)(stack - clickItem.count);
                                        if (p.OnMouse.count <= avail)
                                        {
                                            clickItem.count += p.OnMouse.count;
                                            p.OnMouse = Item.Nothing;
                                        }
                                        else
                                        {
                                            clickItem.count = stack;
                                            p.OnMouse.count -= avail;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (slot >= 5 && slot <= 8)
                            {
                                if (ArmorSlotCheck(slot, p.OnMouse.id))
                                {
                                    items[slot] = p.OnMouse;
                                    p.OnMouse = clickItem;
                                }
                            }
                            else
                            {
                                items[slot] = p.OnMouse;
                                p.OnMouse = clickItem;
                            }
                        }
                    }
                    else
                    {
                        if (slot >= 5 && slot <= 8)
                        {
                            if (ArmorSlotCheck(slot, p.OnMouse.id))
                            {
                                items[slot] = new Item(p.OnMouse);
                                items[slot].count = 1;
                                if (p.OnMouse.count > 1) p.OnMouse.count--;
                                else p.OnMouse = Item.Nothing;
                            }
                        }
                        else
                        {
                            if (click == ClickType.RightClick && p.OnMouse.count > 1)
                            {
                                items[slot] = new Item(p.OnMouse);
                                items[slot].count = 1;
                                p.OnMouse.count--;
                            }
                            else
                            {
                                items[slot] = p.OnMouse;
                                p.OnMouse = Item.Nothing;
                            }
                        }
                    }
                }
            }

            //p.SendWindowItems(0, items);
            //p.SendItem(255, -1, p.OnMouse);
        }
        private void button5_Click(object sender, EventArgs e)
        {
            flowLayoutPanel1.Controls.Clear();
            pictureBox1.Cursor = Cursors.Default;
            flowLayoutPanel1.Visible = true;

            Button uploadButton = new Button() { Size = new Size(166, 33), Location = new Point(3, 3), Text = "Upload image" };
            Button dragButton = new Button() { Size = new Size(80, 33), Location = new Point(3, 3), Text = "Drag image" };
            Button resizeButton = new Button() { Size = new Size(80, 33), Location = new Point(3, 3), Text = "Resize image" };
            Button upButton = new Button() { Size = new Size(80, 33), Location = new Point(3, 3), Text = "Up image" };
            Button downButton = new Button() { Size = new Size(80, 33), Location = new Point(3, 3), Text = "Down image" };
            Button delImgButton = new Button() { Size = new Size(166, 33), Location = new Point(3, 3), Text = "Delete image" };
            Button setImgButton = new Button() { Size = new Size(166, 33), Location = new Point(3, 3), Text = "Set image" };

            flowLayoutPanel1.Controls.Add(uploadButton);
            flowLayoutPanel1.Controls.Add(dragButton);
            flowLayoutPanel1.Controls.Add(resizeButton);
            flowLayoutPanel1.Controls.Add(setImgButton);
            flowLayoutPanel1.Controls.Add(upButton);
            flowLayoutPanel1.Controls.Add(downButton);
            flowLayoutPanel1.Controls.Add(delImgButton);

            ImagesFromListUpdate();

            upButton.Click += (s, a) =>
            {
                if (selected_img != listImages.Count - 1)
                {
                    ImageCustom elementTemp = listImages[selected_img];
                    listImages[selected_img] = listImages[selected_img + 1];
                    listImages[selected_img + 1] = elementTemp;
                    selected_img = selected_img + 1;
                    RefreshGrapfic();
                }
            };

            downButton.Click += (s, a) =>
            {
                if (selected_img != 0)
                {
                    ImageCustom elementTemp = listImages[selected_img];
                    listImages[selected_img] = listImages[selected_img - 1];
                    listImages[selected_img - 1] = elementTemp;
                    selected_img = selected_img - 1;
                    RefreshGrapfic();
                }
            };

            delImgButton.Click += (s, a) =>
            {
                if(listImages.Count>0)
                {
                for (int i = 0; i < flowLayoutPanel1.Controls.Count;i++ )
                {
                    Button tempButton = (Button)flowLayoutPanel1.Controls[i];
                    if (tempButton.Tag != null)
                    {
                        if (tempButton.Tag.ToString() == selected_img.ToString())
                        {
                            flowLayoutPanel1.Controls.RemoveAt(i);
                            if (listImages.Count - 1 == selected_img)
                            {
                                if (selected_img > 0)
                                {
                                    selected_img = selected_img - 1;
                                }
                            }
                            break;
                        }
                    }
                }
                listImages.RemoveAt(selected_img);
                if (selected_img==0 && listImages.Count==0)
                    {
                        tempPicImg.Visible = false;
                    }
                RefreshGrapfic();
                }
            };

            resizeButton.Click += (s, a) =>
            {
                CurTypeClick = ClickType.Resize;
                uploadButton.Enabled = false;
                dragButton.Enabled = false;
                resizeButton.Enabled = false;
                delImgButton.Enabled = false;
                upButton.Enabled = false;
                downButton.Enabled = false;
            };

            dragButton.Click += (s, a) =>
            {
                CurTypeClick = ClickType.Drag;
                uploadButton.Enabled = false;
                dragButton.Enabled = false;
                resizeButton.Enabled = false;
                delImgButton.Enabled = false;
                upButton.Enabled = false;
                downButton.Enabled = false;
            };

            setImgButton.Click += (s, a) =>
            {
                CurTypeClick = ClickType.Empty;
                uploadButton.Enabled = true;
                dragButton.Enabled = true;
                resizeButton.Enabled = true;
                delImgButton.Enabled = true;
                upButton.Enabled = true;
                downButton.Enabled = true;

                AddImageUsePicBox();
            };

            AddImageUsePicBox();

            uploadButton.Click += (s, a) =>
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp; *.png)|*.jpg; *.jpeg; *.gif; *.bmp; *.png";

                if (open.ShowDialog() == DialogResult.OK)
                {
                    if (tempPicImg.Visible == false)
                    {
                        tempPicImg.Visible = true;
                    }
                    BindListImages(open.FileName);
                    Button button = new Button { Height = 50, BackgroundImage = new Bitmap(open.FileName), Tag = listImages.Count - 1, Visible = true, BackgroundImageLayout = ImageLayout.Stretch };

                    button.Click += ClickBtn;

                    flowLayoutPanel1.Controls.Add(button);

                    selected_img = listImages.Count - 1;
                    AddImageUsePicBox();
                }
            };
        }
        private void TryHide(ClickType click)
        {
            bool? hide;
            switch (click)
            {
                case ClickType.Click:
                    hide = Settings.Default.ClickHide;
                    break;
                case ClickType.MidClick:
                    hide = Settings.Default.MidClickHide;
                    break;
                case ClickType.RightClick:
                    hide = Settings.Default.RightClickHide;
                    break;
                default:
                    throw new Exception();
            }

            bool? rev = HideRevert();
            if (rev.HasValue && hide.HasValue)
            {
                if ((hide.Value && !rev.Value) | (!hide.Value && rev.Value))
                {
                    mainWindow.Visibility = System.Windows.Visibility.Hidden;
                }
            }
            else
            {
                if (hide.Value)
                {
                    mainWindow.Visibility = System.Windows.Visibility.Hidden;
                }
            }
        }
Exemple #41
0
		/// <summary>
		/// Raycast the click (touch) on the screen.
		/// </summary>
		/// <param name="clickPosition">The position of the click (touch).</param>
		/// <param name="clickType">The type of the click(touch).</param>
	private void RayCast (ClickType clickType){
		foreach (RaycastHit hit in hits) {
			tempCollider3D = hit.collider;

			if (tempCollider3D != null) {
				//Debug.Log(tempCollider3D.tag + " : " + tempCollider3D.gameObject.name);
				///When a ray hit a grid cell
				if (tempCollider3D.tag == "GridCell") {
					currentGridCell = tempCollider3D.GetComponent<GridCell>();
					//Debug.Log("clicktype ? " + clickType);
					if (clickType == ClickType.Began) {
						previousGridCell = currentGridCell;
						GridCellClickBegan ();
					} else if (clickType == ClickType.Moved) {
						GridCellClickMoved();
						if (EnoughWiresOfType ()) {
							GridCell previousCell = previousRayCell.GetComponent<GridCell> ();
							GridCell currentCell = hit.transform.GetComponent<GridCell> ();
							if (previousCell.OneOfAdjacents (currentCell.index) && currentCell.isEmpty) {
								drawDraggingElement = true;
							}
						}
					}
				}
			}
		}
	}
Exemple #42
0
        public void HandleClick(Player p, short slot, ClickType click, short ActionID, bool Shift)
        {
            if (slot == -999)
            {
                p.inventory.HandleClick(slot, click, ActionID, Shift);
                return;
            }
            if (slot < 0 || slot > InventorySize + 35) return;
            if (Type == WindowType.Workbench || Type == WindowType.Furnace)
            {
                if (slot == 0)
                {
                    // TODO: Crafting/smelting output handler.
                    return;
                }
            }

            if (Shift)
            {
                if (slot >= InventorySize)
                {
                    if (Type == WindowType.Workbench || Type == WindowType.Furnace || Type == WindowType.EnchantmentTable || Type == WindowType.BrewingStand)
                    {
                        p.inventory.HandleClick((short)((slot - InventorySize) + 9), click, ActionID, Shift);
                        return;
                    }
                }

                Item item;
                bool useEmptySlot = false;
                if (slot < InventorySize)
                {
                    Item clickItem = items[slot];
                    if (clickItem.id != -1)
                    {
                        for (int i = 44; i >= 36; i--)
                        {
                            item = p.inventory.items[i];
                            if (useEmptySlot)
                            {
                                if (item.id == -1)
                                {
                                    p.inventory.items[i] = clickItem;
                                    items[slot] = Item.Nothing;
                                    break;
                                }
                            }
                            else if (item.id == clickItem.id && item.meta == clickItem.meta)
                            {
                                byte stack = Inventory.isStackable(item.id);
                                byte avail = (byte)(stack - item.count);
                                if (avail < 1) continue;

                                if (clickItem.count <= avail)
                                {
                                    item.count += clickItem.count;
                                    items[slot] = Item.Nothing;
                                    break;
                                }
                                else
                                {
                                    item.count = stack;
                                    clickItem.count -= avail;
                                }
                            }
                            if (i == 36 && !useEmptySlot) { useEmptySlot = true; i = 45; }
                        }
                        if (items[slot].id != -1)
                        {
                            useEmptySlot = false;
                            for (int i = 35; i >= 9; i--)
                            {
                                item = p.inventory.items[i];
                                if (useEmptySlot)
                                {
                                    if (item.id == -1)
                                    {
                                        p.inventory.items[i] = clickItem;
                                        items[slot] = Item.Nothing;
                                        break;
                                    }
                                }
                                else if (item.id == clickItem.id && item.meta == clickItem.meta)
                                {
                                    byte stack = Inventory.isStackable(item.id);
                                    byte avail = (byte)(stack - item.count);
                                    if (avail < 1) continue;

                                    if (clickItem.count <= avail)
                                    {
                                        item.count += clickItem.count;
                                        items[slot] = Item.Nothing;
                                        break;
                                    }
                                    else
                                    {
                                        item.count = stack;
                                        clickItem.count -= avail;
                                    }
                                }
                                if (i == 9 && !useEmptySlot) { useEmptySlot = true; i = 36; }
                            }
                        }
                    }
                }
                else
                {
                    slot = (short)((slot - InventorySize) + 9);
                    Item clickItem = p.inventory.items[slot];
                    if (clickItem.id != -1)
                    {
                        for (int i = 0; i < InventorySize; i++)
                        {
                            item = items[i];
                            if (useEmptySlot)
                            {
                                if (item.id == -1)
                                {
                                    items[i] = clickItem;
                                    p.inventory.items[slot] = Item.Nothing;
                                    break;
                                }
                            }
                            else if (item.id == clickItem.id && item.meta == clickItem.meta)
                            {
                                byte stack = Inventory.isStackable(item.id);
                                byte avail = (byte)(stack - item.count);
                                if (avail < 1) continue;

                                if (clickItem.count <= avail)
                                {
                                    item.count += clickItem.count;
                                    p.inventory.items[slot] = Item.Nothing;
                                    break;
                                }
                                else
                                {
                                    item.count = stack;
                                    clickItem.count -= avail;
                                }
                            }
                            if (i == InventorySize - 1 && !useEmptySlot) { useEmptySlot = true; i = -1; }
                        }
                    }
                }
            }
            else
            {
                if (slot >= InventorySize)
                {
                    p.inventory.HandleClick((short)((slot - InventorySize) + 9), click, ActionID, Shift);
                    return;
                }

                Item clickItem = items[slot];
                if (p.OnMouse.id == -1)
                {
                    if (clickItem.id != -1)
                    {
                        if (click == ClickType.RightClick && clickItem.count > 1)
                        {
                            p.OnMouse = new Item(clickItem);
                            p.OnMouse.count = (byte)Math.Ceiling((float)p.OnMouse.count / 2F);
                            clickItem.count /= 2;
                        }
                        else
                        {
                            items[slot] = Item.Nothing;
                            p.OnMouse = clickItem;
                        }
                    }
                }
                else
                {
                    if (clickItem.id != -1)
                    {
                        if (p.OnMouse.id == clickItem.id && p.OnMouse.meta == clickItem.meta)
                        {
                            byte stack = Inventory.isStackable(clickItem.id);
                            if (click == ClickType.RightClick && p.OnMouse.count > 1)
                            {
                                if (clickItem.count < stack)
                                {
                                    p.OnMouse.count--;
                                    clickItem.count++;
                                }
                            }
                            else
                            {
                                if (clickItem.count < stack)
                                {
                                    byte avail = (byte)(stack - clickItem.count);
                                    if (p.OnMouse.count <= avail)
                                    {
                                        clickItem.count += p.OnMouse.count;
                                        p.OnMouse = Item.Nothing;
                                    }
                                    else
                                    {
                                        clickItem.count = stack;
                                        p.OnMouse.count -= avail;
                                    }
                                }
                            }
                        }
                        else
                        {
                            items[slot] = p.OnMouse;
                            p.OnMouse = clickItem;
                        }
                    }
                    else
                    {
                        if (click == ClickType.RightClick && p.OnMouse.count > 1)
                        {
                            items[slot] = new Item(p.OnMouse);
                            items[slot].count = 1;
                            p.OnMouse.count--;
                        }
                        else
                        {
                            items[slot] = p.OnMouse;
                            p.OnMouse = Item.Nothing;
                        }
                    }
                }
            }

            if (container != null) container.UpdateContents(p);
            List<Item> items2 = new List<Item>(items); items2.AddRange((Item[])p.inventory.items.TruncateStart(9));
            p.SendWindowItems(id, items2.ToArray());
            p.SendItem(255, -1, p.OnMouse);
        }
Exemple #43
0
        /// <summary>
        ///     Shows the click.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="type">The type.</param>
        private static void ShowClick(Vector3 position, ClickType type)
        {
            if (!Enabled)
            {
                return;
            }

            Hud.ShowClick(type, position);
        }
        private void button5_Click(object sender, EventArgs e)
        {
            flowLayoutPanel1.Controls.Clear();
            pictureBox1.Cursor = Cursors.Default;
            flowLayoutPanel1.Visible = true;

            Button uploadButton = new Button() { Size = new Size(166, 33), Location = new Point(3, 3), Text = "Upload image" };
            Button dragButton = new Button() { Size = new Size(80, 33), Location = new Point(3, 3), Text = "Drag image" };
            Button resizeButton = new Button() { Size = new Size(80, 33), Location = new Point(3, 3), Text = "Resize image" };
            Button setImgButton = new Button() { Size = new Size(166, 33), Location = new Point(3, 3), Text = "Set image" };

            flowLayoutPanel1.Controls.Add(uploadButton);
            flowLayoutPanel1.Controls.Add(dragButton);
            flowLayoutPanel1.Controls.Add(resizeButton);
            flowLayoutPanel1.Controls.Add(setImgButton);

            ImagesFromListUpdate();

            resizeButton.Click += (s, a) =>
            {
                CurTypeClick = ClickType.Resize;
                uploadButton.Enabled = false;
                dragButton.Enabled = false;
                resizeButton.Enabled = false;

            };

            dragButton.Click += (s, a) =>
            {
                CurTypeClick = ClickType.Drag;
                uploadButton.Enabled = false;
                dragButton.Enabled = false;
                resizeButton.Enabled = false;

            };

            setImgButton.Click += (s, a) =>
            {
                CurTypeClick = ClickType.Empty;
                uploadButton.Enabled = true;
                dragButton.Enabled = true;
                resizeButton.Enabled = true;

            };

            AddImageUsePicBox();

            uploadButton.Click += (s, a) =>
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp; *.png)|*.jpg; *.jpeg; *.gif; *.bmp; *.png";

                if (open.ShowDialog() == DialogResult.OK)
                {
                    BindListImages(open.FileName);
                    Button button = new Button { Height = 50, BackgroundImage = new Bitmap(open.FileName), Tag = listImages.Count - 1, Visible = true, BackgroundImageLayout = ImageLayout.Stretch };

                    button.Click += ClickBtn;

                    flowLayoutPanel1.Controls.Add(button);
                }
            };
        }
		public static void Put(IHeatmapHandler component, Vector2 localPoint, ClickType clickType) {

			// Normalize coords - make it ready to save
			var fullScreen = new Vector2(Screen.width, Screen.height);
			var current = localPoint;
			var screenNormalized = new Vector2(current.x / fullScreen.x, current.y / fullScreen.y);

			var localNormalizedPoint = screenNormalized;

			var tag = LayoutTag.None;
			WindowBase screen = null;
			if (component != null) {

				// Find component position
				var rectTransform = (component as WindowComponent).transform as RectTransform;
				if (rectTransform != null) {

					var offset = Vector2.zero;
					/*var scrolls = (component as WindowComponent).GetComponentsInParent<ScrollRect>();
					if (scrolls != null && scrolls.Length > 0) {

						var scroll = scrolls[0];
						var scrollRect = (scroll.transform as RectTransform).rect;

						offset = new Vector2(scrollRect.width * scroll.normalizedPosition.x, scrollRect.height * (1f - scroll.normalizedPosition.y));

					}*/

					var elementRect = rectTransform.rect;
					elementRect.x += offset.x;
					elementRect.y += offset.y;

					// Clamp localPoint to element rect

					localNormalizedPoint = new Vector2(localPoint.x / elementRect.width, localPoint.y / elementRect.height);

					//Debug.Log(elementRect, component as ButtonComponent);

				}

				screen = component.GetWindow();

				var comp = component as WindowComponent;
				if (comp != null) {

					var layout = comp.GetLayoutRoot() as WindowLayoutElement;
					if (layout != null) {

						tag = layout.tag;

					}

				}

			} else {

				screen = WindowSystem.GetCurrentWindow();

			}

			// Send point to server
			HeatmapSystem.Send(tag, screen, component as WindowComponent, localNormalizedPoint);

		}
 void n_ItemClicked(ListBoxItem item, ClickType clickType)
 {
     TryHide( clickType);
 }
Exemple #47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MouseClick"/> struct.
 /// </summary>
 /// <param name="clickType">
 /// The click type.
 /// </param>
 /// <param name="clickPosition">
 /// The click position.
 /// </param>
 internal MouseClick(ClickType clickType, DisplayPosition clickPosition)
 {
     this.clickType = clickType;
     this.clickPosition = clickPosition;
 }
Exemple #48
0
        public void HandleClick(Player p, short slot, ClickType click, short ActionID, bool Shift, Item clicked)
        {
            if (slot == -999)
            {
                p.inventory.HandleClick(slot, click, ActionID, Shift);
                return;
            }
            if (slot < 0 || slot > InventorySize + 35) return;

            if (Shift)
            {
                if (slot >= InventorySize)
                {
                    if (Type == WindowType.Workbench || Type == WindowType.Furnace || Type == WindowType.EnchantmentTable || Type == WindowType.BrewingStand)
                    {
                        p.inventory.HandleClick((short)((slot - InventorySize) + 9), click, ActionID, Shift);
                        return;
                    }
                }

                Item item;
                bool useEmptySlot = false;
                if (slot < InventorySize)
                {
                    Item clickItem = items[slot];
                    if (clickItem.id != -1)
                    {
                        for (int i = 44; i >= 36; i--)
                        {
                            item = p.inventory.items[i];
                            if (useEmptySlot)
                            {
                                if (item.id == -1)
                                {
                                    p.inventory.items[i] = clickItem;
                                    items[slot] = Item.Nothing;
                                    break;
                                }
                            }
                            else if (item.id == clickItem.id && item.meta == clickItem.meta)
                            {
                                byte stack = Inventory.isStackable(item.id);
                                byte avail = (byte)(stack - item.count);
                                if (avail < 1) continue;

                                if (clickItem.count <= avail)
                                {
                                    item.count += clickItem.count;
                                    items[slot] = Item.Nothing;
                                    break;
                                }
                                else
                                {
                                    item.count = stack;
                                    clickItem.count -= avail;
                                }
                            }
                            if (i == 36 && !useEmptySlot) { useEmptySlot = true; i = 45; }
                        }
                        if (items[slot].id != -1)
                        {
                            useEmptySlot = false;
                            for (int i = 35; i >= 9; i--)
                            {
                                item = p.inventory.items[i];
                                if (useEmptySlot)
                                {
                                    if (item.id == -1)
                                    {
                                        p.inventory.items[i] = clickItem;
                                        items[slot] = Item.Nothing;
                                        break;
                                    }
                                }
                                else if (item.id == clickItem.id && item.meta == clickItem.meta)
                                {
                                    byte stack = Inventory.isStackable(item.id);
                                    byte avail = (byte)(stack - item.count);
                                    if (avail < 1) continue;

                                    if (clickItem.count <= avail)
                                    {
                                        item.count += clickItem.count;
                                        items[slot] = Item.Nothing;
                                        break;
                                    }
                                    else
                                    {
                                        item.count = stack;
                                        clickItem.count -= avail;
                                    }
                                }
                                if (i == 9 && !useEmptySlot) { useEmptySlot = true; i = 36; }
                            }
                        }
                    }
                }
                else
                {
                    slot = (short)((slot - InventorySize) + 9);
                    Item clickItem = p.inventory.items[slot];
                    if (clickItem.id != -1)
                    {
                        for (int i = 0; i < InventorySize; i++)
                        {
                            item = items[i];
                            if (useEmptySlot)
                            {
                                if (item.id == -1)
                                {
                                    items[i] = clickItem;
                                    p.inventory.items[slot] = Item.Nothing;
                                    break;
                                }
                            }
                            else if (item.id == clickItem.id && item.meta == clickItem.meta)
                            {
                                byte stack = Inventory.isStackable(item.id);
                                byte avail = (byte)(stack - item.count);
                                if (avail < 1) continue;

                                if (clickItem.count <= avail)
                                {
                                    item.count += clickItem.count;
                                    p.inventory.items[slot] = Item.Nothing;
                                    break;
                                }
                                else
                                {
                                    item.count = stack;
                                    clickItem.count -= avail;
                                }
                            }
                            if (i == InventorySize - 1 && !useEmptySlot) { useEmptySlot = true; i = -1; }
                        }
                    }
                }
            }
            else
            {
                if (slot >= InventorySize)
                {
                    p.inventory.HandleClick((short)((slot - InventorySize) + 9), click, ActionID, Shift);
                    return;
                }

                Item clickItem = items[slot];
                if (p.OnMouse.id == -1)
                {
                    if (clickItem.id != -1)
                    {
                        if (click == ClickType.RightClick && clickItem.count > 1)
                        {
                            p.OnMouse = new Item(clickItem);
                            p.OnMouse.count = (byte)Math.Ceiling((float)p.OnMouse.count / 2F);
                            clickItem.count /= 2;
                        }
                        else
                        {
                            items[slot] = Item.Nothing;
                            p.OnMouse = clickItem;
                        }
                    }
                }
                else
                {
                    if (clickItem.id != -1)
                    {
                        if (p.OnMouse.id == clickItem.id && p.OnMouse.meta == clickItem.meta)
                        {
                            byte stack = Inventory.isStackable(clickItem.id);
                            if (click == ClickType.RightClick && p.OnMouse.count > 1)
                            {
                                if (clickItem.count < stack)
                                {
                                    p.OnMouse.count--;
                                    clickItem.count++;
                                }
                            }
                            else
                            {
                                if (clickItem.count < stack)
                                {
                                    byte avail = (byte)(stack - clickItem.count);
                                    if (p.OnMouse.count <= avail)
                                    {
                                        clickItem.count += p.OnMouse.count;
                                        p.OnMouse = Item.Nothing;
                                    }
                                    else
                                    {
                                        clickItem.count = stack;
                                        p.OnMouse.count -= avail;
                                    }
                                }
                            }
                        }
                        else
                        {
                            items[slot] = p.OnMouse;
                            p.OnMouse = clickItem;
                        }
                    }
                    else
                    {
                        if (click == ClickType.RightClick && p.OnMouse.count > 1)
                        {
                            items[slot] = new Item(p.OnMouse);
                            items[slot].count = 1;
                            p.OnMouse.count--;
                        }
                        else
                        {
                            items[slot] = p.OnMouse;
                            p.OnMouse = Item.Nothing;
                        }
                    }
                }
            }
            Item result = CraftingManager.getResult(p);
            if (result.id != -1)
            {
                Logger.Log(((Items)result.id).ToString());
                if (slot == 0)
                {
                    if (p.OnMouse == Item.Nothing)
                    {
                        p.OnMouse = result;
                        result = Item.Nothing;
                    }
                    else if (p.OnMouse.id == result.id)
                    {
                        p.OnMouse.count += result.count;
                        result = Item.Nothing;
                    }
                    if (click == ClickType.LeftClick)
                    {
                        if (items[0] != Item.Nothing)
                        {
                            for (int i = 1; i < items.Count(); i++)
                            {
                                Item itm = items[i];
                                if (itm == Item.Nothing)
                                    continue;
                                itm.count -= 1;
                                if (itm.count <= 0)
                                    items[i] = Item.Nothing;

                            }
                        }
                    }
                    else if (click == ClickType.RightClick)
                    {
                        if (p.OnMouse != Item.Nothing)
                        {

                        }
                    }

                }

            }
            items[0] = result;
            if (Item.isEqual(clicked, items[slot]))
            {
                p.SendTransaction(id, ActionID, true);
                CraftingManager.UpdateCrafting(this);
            }
            else
            {
                p.SendTransaction(id, ActionID, false);

                //if (container != null) container.UpdateContents(p);
                List<Item> items2 = new List<Item>(items); items2.AddRange((Item[])p.inventory.items.TruncateStart(9));
                for (int i = 0; i <= 9; i++) p.SendItem(id, (short)i, items[i]);

            }
            p.SendItem(255,255, p.OnMouse); //225 = -1 in big endian
        }