Beispiel #1
0
        /// <summary>
        /// check if the
        /// </summary>
        /// <param name="controlItemsList"></param>
        /// <returns></returns>
        private bool IsControlItemsListValid(string fileName, List <ControlItem> controlItemsList)
        {
            if (controlItemsList != null)
            {
                // loop on all components
                foreach (var keyValue in runtimeHostSurface.ComponentsDictionary) // key - component, value - ComponentWrapper
                {
                    Control             control             = (Control)keyValue.Key;
                    ControlDesignerInfo controlDesignerInfo = ((ControlDesignerInfo)control.Tag);
                    if (fileName.Equals(controlDesignerInfo.FileName))
                    {
                        int isn = controlDesignerInfo.Isn;
                        // try and get the info for this component from the file info
                        ControlItem controlItem = controlItemsList.Find(x => x.Isn == isn);
                        if (controlItem != null && controlItem.Properties != null)
                        {
                            if (!controlDesignerInfo.ControlType.ToString().Equals(controlItem.ControlType))
                            {
                                return(false);
                            }
                        }
                    }
                }
            }


            return(true);
        }
Beispiel #2
0
        //Return true if the base.OnBeforeDeath should be executed and false if not.
        public static bool UncontrolDeath(Mobile from)
        {
            if (from.AccessLevel < accessLevel)
            {
                return(true);
            }

            ControlItem controlItem = GetControlItem(from);

            if (controlItem != null)
            {
                //Backup NPC
                Mobile NPC = (Mobile)controlItem.NPC;

                //Release GM
                controlItem.Delete();
                from.Hits = from.HitsMax;
                from.Stam = from.StamMax;
                from.Mana = from.StamMax;

                //Kill NPC as normal
                NPC.Kill();

                return(false);                //GM stirbt nicht ;)
            }

            return(true);
        }
Beispiel #3
0
        public static void EndControl(ControlItem controlItem, bool stats, bool skills, bool items)
        {
            Mobile       from      = controlItem.Owner;
            PlayerMobile oldPlayer = controlItem.Player;
            Mobile       oldNPC    = controlItem.NPC;

            if (from == null)
            {
                return;
            }

            from.SendMessage("You are in your original Body");

            if (oldNPC != null && !oldNPC.Deleted)
            {
                CopyProps(from, oldNPC, stats, skills);
                MoveEquip(from, oldNPC, items);
            }
            else
            {
                from.SendMessage("The original NPC was deleted. Maybe because a manual respawn");

                oldNPC.Delete();
            }

            if (oldPlayer != null && !oldPlayer.Deleted)
            {
                CopyProps(oldPlayer, from, true, true);
                MoveEquip(oldPlayer, from, true);

                oldPlayer.Delete();
            }
        }
Beispiel #4
0
        public void RefreshTargetBranches()
        {
            this.TargetBranches.Clear();

            var sourceBranch = this.SourceBranch;

            var mergeRelationships = Enumerable.Empty <ItemIdentifier>();

            if (!string.IsNullOrWhiteSpace(sourceBranch))
            {
                using (var tfsWrapper = CreateTfsWrapper())
                {
                    var vcs = tfsWrapper.VersionControlServer;
                    if (vcs.ServerItemExistsSafe(sourceBranch, ItemType.Any))
                    {
                        mergeRelationships = vcs.QueryMergeRelationships(sourceBranch);
                    }
                }
            }

            var targetBranches = mergeRelationships
                                 .Select(item => ControlItem.Create(item, item.Item))
                                 .ToArray();

            this.TargetBranches.ReplaceContents(targetBranches);

            this.TargetBranchesView.Refresh();
            this.TargetBranchesView.MoveCurrentToFirst();
        }
Beispiel #5
0
        public static LoginMenuModel GenerateAWP(LoginMenuModel loginMenu)
        {
            ControlItem txtUserName             = CreateControlTextBox("UserName", "UserName", "Tên tài khoản", MenuControlType.TextBox, "", true);
            ControlItem txtPassword             = CreateControlTextBox("PasswordJson", "PasswordJson", "Mật khẩu", MenuControlType.TextBox, "", true);
            ControlItem btnLoginAccountWithPass = CreateControlButton(
                "loginAccountWithPass()",
                MenuControlType.Button,
                "btnLoginAccountWithPass",
                "Đăng nhập",
                "fas fa-sign-in-alt",
                "btn btn-info");

            #region Login Group Item
            GroupItem loginGroupItem = new GroupItem()
            {
                Css           = "",
                LoginModeCode = (int)LoginModeEnum.AccountWithPass,
                CssClass      = "btn-group-vertical login-box",
            };
            List <ControlItem> ControlItems = new List <ControlItem>()
            {
                txtUserName,
                txtPassword,
                btnLoginAccountWithPass
            };
            #endregion
            loginMenu.GroupItems.Add(loginGroupItem);
            return(loginMenu);
        }
Beispiel #6
0
        private static void StartControl(Mobile from, Mobile target, bool stats, bool skills, bool items)
        {
            from.SendMessage("Du verlässt deine Gestallt und übernimmst {0}, {1}", target.Name, target.Title);
            //"You leave your Body an control {0}, {1}"

            //Clone Player
            PlayerMobile playerClone = (PlayerMobile)DupeMobile(from);

            //Create ControlItem
            ControlItem controlItem = new ControlItem(from, playerClone, target, stats, skills, items);

            from.Backpack.DropItem(controlItem);

            //Props target -> player
            CopyProps(from, target, stats, skills);

            //Backup Equip
            MoveEquip(from, playerClone, items);
            //Equip from target to player
            MoveEquip(target, from, items);



            target.Internalize();
            playerClone.Internalize();
        }
        /// <summary>
        /// 根据控件生成Insert的Commond对象,返回新增语句的主键
        /// </summary>
        /// <param name="FormControl">需要组成SQL语句的控件</param>
        /// <param name="Table">表名</param>
        /// <param name="TableId">更新的ID</param>
        /// <param name="db">需要生成Commond的DBHelper</param>
        /// <returns>更新数据的键值</returns>
        public static void GetInsertCommond(Control FormControl, string Table, string TableId, DBClass.DBHelper db)
        {
            string        KeyValue    = string.Empty;
            StringBuilder FieldString = new StringBuilder();
            StringBuilder ValueString = new StringBuilder();

            foreach (Control ControlItem in FormControl.Controls)
            {
                if (ControlItem.GetType() == typeof(TextBox) || ControlItem.GetType() == typeof(RichTextBox))
                {
                    if (!string.IsNullOrEmpty(ControlItem.Text))
                    {
                        if (ControlItem.Name == TableId)
                        {
                            KeyValue = ControlItem.Text;
                        }
                        FieldString.AppendFormat("{0},", ControlItem.Name);
                        ValueString.AppendFormat("@{0},", ControlItem.Name);
                        db.AddInParameter(string.Format("@{0}", ControlItem.Name), DbType.AnsiString, ControlItem.Text);
                    }
                }
            }
            string SQLString = String.Format("Insert into {0} ({1}) values ({2})",
                                             Table,
                                             FieldString.ToString(0, FieldString.Length - 1),
                                             ValueString.ToString(0, ValueString.Length - 1));

            db.SetSqlStringCommond(SQLString);
        }
        public void SetIdocItems(bool keepSelection, IEnumerable <RepositoryItem> items)
        {
            #region Argument Check

            if (items == null)
            {
                throw new ArgumentNullException("items");
            }

            #endregion

            var oldSelectedItem = keepSelection ? this.IdocItemsView.CurrentItem : null;

            _idocItems.Clear();
            _idocItems.AddRange(items.Select(obj => ControlItem.Create(obj, obj.Folder)));

            this.IdocItemsView.Refresh();

            if (oldSelectedItem != null)
            {
                this.IdocItemsView.MoveCurrentTo(oldSelectedItem);
            }

            RaisePropertyChanged(obj => obj.IdocItemsView);
        }
Beispiel #9
0
    public void CopyCodeToClipBoard()
    {
        CorrectComponents();

        StringBuilder sb = new StringBuilder(1024);

        sb.Append("#region 控件绑定变量声明,自动生成请勿手改\r\n");

        for (int i = 0, imax = controls.Count; i < imax; i++)
        {
            ControlItem ctrl = controls[i];
            if (ctrl.targets.Length == 0)
            {
                continue;
            }

            if (ctrl.targets.Length == 1)
            {
                sb.AppendFormat("\t\t[ControlBinding]\r\n\t\tprivate {0} {1};\r\n", ctrl.type, ctrl.name);
            }
            else
            {
                sb.AppendFormat("\t\t[ControlBinding]\r\n\t\tprivate {0}[] {1};\r\n", ctrl.type, ctrl.name);
            }
        }
        sb.Append("#endregion\r\n\r\n");

        GUIUtility.systemCopyBuffer = sb.ToString();

        UnityEngine.Object go = PrefabUtility.GetPrefabParent(gameObject);
        PrefabUtility.ReplacePrefab(gameObject, go, ReplacePrefabOptions.Default);
    }
 public ControlItemAccessibleObject(ControlItem controlItem, ErrorWindow window, Control control, ErrorProvider provider)
 {
     _controlItem = controlItem;
     _window      = window;
     _control     = control;
     _provider    = provider;
 }
Beispiel #11
0
        public static LoginMenuModel GenerateAWoutP(LoginMenuModel loginMenu, int?registerAttr, PrepareFormModel prepareFormModel)
        {
            #region Register Group Item
            GroupItem registerGroupItem = new GroupItem()
            {
                Css           = "",
                LoginModeCode = (int)LoginModeEnum.RegisterInformation,
                CssClass      = "btn-group-vertical register-box-general-form",
            };

            List <ControlItem> registerControlItems = new List <ControlItem>();
            // Prepare other fields
            PrepareOtherFields(registerAttr, registerControlItems, prepareFormModel);
            ControlItem btnLoginAccountWithoutPass = CreateControlButton(
                "loginAccountWithoutPass()",
                MenuControlType.Button,
                "btnRegisterAccountWithoutPass",
                "Đồng ý",
                "fas fa-arrow-alt-circle-right",
                "btn btn-info btn-block");

            registerControlItems.Add(btnLoginAccountWithoutPass);
            registerGroupItem.ControlItems = registerControlItems;

            loginMenu.GroupItems.Add(registerGroupItem);
            #endregion
            return(loginMenu);
        }
Beispiel #12
0
        public static void DoControl(Mobile from, object targeted, bool stats, bool skills, bool items)
        {
            Mobile target;

            if (from is PlayerMobile && targeted is Mobile)
            {
                if (targeted is PlayerMobile && ((PlayerMobile)targeted).Player)
                {
                    from.SendMessage("Lets be realistic, you can not control players.");
                    return;
                }

                target = (Mobile)targeted;
                ControlItem controlItem = GetControlItem(from);

                if (controlItem == null)
                {
                    from.SendMessage("Stats: {0} Skills: {1} Items: {2}", stats, skills, items);
                    StartControl(from, target, stats, skills, items);
                }
                else
                {
                    from.SendMessage("Stats: {0} Skills: {1} Items: {2}", controlItem.Stats, controlItem.Skills, controlItem.Items);
                    ChangeControl(target, controlItem, controlItem.Stats, controlItem.Skills, controlItem.Items);
                }
            }
            else if (from is PlayerMobile && targeted is ControlItem)
            {
                ((Item)targeted).Delete();
            }
        }
Beispiel #13
0
        private void ColumnGUI(Rect cellRect, ControlItem item, int column, ref RowGUIArgs args)
        {
            CenterRectUsingSingleLineHeight(ref cellRect);

            switch (column)
            {
            case (int)ColumnId.Name:
                args.rowRect = cellRect;
                base.RowGUI(args);
                break;

            case (int)ColumnId.DisplayName:
                GUI.Label(cellRect, item.control.displayName);
                break;

            case (int)ColumnId.Layout:
                GUI.Label(cellRect, item.layout);
                break;

            case (int)ColumnId.Format:
                GUI.Label(cellRect, item.format);
                break;

            case (int)ColumnId.Offset:
                GUI.Label(cellRect, item.offset);
                break;

            case (int)ColumnId.Bit:
                GUI.Label(cellRect, item.bit);
                break;

            case (int)ColumnId.Size:
                GUI.Label(cellRect, item.sizeInBits);
                break;

            case (int)ColumnId.Type:
                GUI.Label(cellRect, item.type);
                break;

            case (int)ColumnId.Value:
                if (item.value != null)
                {
                    GUI.Label(cellRect, item.value);
                }
                else if (item.values != null && item.values[0] != null)
                {
                    GUI.Label(cellRect, item.values[0]);
                }
                break;

            default:
                var valueIndex = column - (int)ColumnId.Value;
                if (item.values != null && item.values[valueIndex] != null)
                {
                    GUI.Label(cellRect, item.values[valueIndex]);
                }
                break;
            }
        }
Beispiel #14
0
        public void AssociateCommand(
            ICommand command,
            Func <object[]> paramsMaker,
            params object[] controls)
        {
            //_paramMakers.Add(command, paramsMaker);
            RegisterCommand(command);

            foreach (var oneControl in controls)
            {
                IGenericUiElement uiElement;
                if (oneControl is TextBox)
                {
                    uiElement = new TextField((TextBox)oneControl);
                }
                else if (oneControl is Control)
                {
                    uiElement = new ControlItem((Control)oneControl);
                }
                else if (oneControl is ToolStripItem)
                {
                    uiElement = new MenuItem((ToolStripItem)oneControl);
                }
                else
                {
                    throw new InvalidOperationException("Unsupported item was passed.");
                }
                uiElement.Activated += (sender, args) =>
                {
                    try
                    {
                        command.InitiateExecution(paramsMaker());
                        if (_onCommandExecuted != null)
                        {
                            _onCommandExecuted();
                        }
                        UpdateControlsAvailability();
                    }
                    catch (Exception ex)
                    {
                        if (_onCommandFailed != null)
                        {
                            _onCommandFailed(ex);
                        }
                        else
                        {
                            throw;
                        }
                    }
                };
                _allCommands.Add(command,
                                 new ElementParamMakerPair
                {
                    Element    = uiElement,
                    ParamMaker = paramsMaker
                });
            }
        }
 public static Binding CreateControlItemBinding(Controllable control, ControlItem item, IValueConverter convertor = null)
 {
     return(new Binding(item.Id)
     {
         Source = control,
         Mode = item.Access.HasFlag(ControlItem.PropAccess.Write) ? BindingMode.TwoWay : BindingMode.OneWay,
         Converter = convertor
     });
 }
    private void AddControl(int idx)
    {
        ControlItem item = new ControlItem();

        _controls.Insert(idx + 1, item);

        ControlItemDrawer drawer = new ControlItemDrawer(this, item);

        _drawers.Insert(idx + 1, drawer);
    }
        public void SetSelectedIdocItem(RepositoryItem item)
        {
            if (item == null)
            {
                this.IdocItemsView.MoveCurrentTo(null);
                return;
            }

            var selectedItem = ControlItem.Create(item);

            this.IdocItemsView.MoveCurrentTo(selectedItem);
        }
Beispiel #18
0
        private static void ChangeControl(Mobile target, ControlItem controlItem, bool stats, bool skills, bool items)
        {
            Mobile       from      = controlItem.Owner;
            PlayerMobile oldPlayer = controlItem.Player;
            Mobile       oldNPC    = controlItem.NPC;

            if (oldNPC != null)
            {
                //NPC Wiederherstellen
                if (!oldNPC.Deleted)
                {
                    //Props immer übernehmen bei der Rückverwandlung?
                    //ja, weil sich hits etc ändern
                    //Props from -> oldNPC
                    CopyProps(oldNPC, from, stats, skills);
                    //nicht nur zurück holen
                    //if ( oldNPC.Map == Map.Internal )
                    //	oldNPC.MoveToWorld(from.Location, from.Map);

                    //Equip: from -> oldNPC
                    MoveEquip(from, oldNPC, items);
                }
                else
                {
                    from.SendMessage("Der originale NPC wurde gelöscht und wird nicht wiederhergestellt. Grund könnte ein manueller Respawn gewesen sein");
                    oldNPC.Delete();
                }
            }

            //Neuen Mobile übernehmen oder Control abbrechen
            if (target != oldPlayer && target != null && !target.Deleted)               //Neues Mobile übernehmen
            {
                from.SendMessage("Du übernimmst {0}, {1}", target.Name, target.Title);
                //"You Control  {0}, {1}"

                //Update ControlItem
                controlItem.NPC    = target;
                controlItem.Stats  = stats;
                controlItem.Skills = skills;
                controlItem.Items  = items;

                //Props: target -> player
                CopyProps(from, target, stats, skills);
                //Equip: target -> player
                MoveEquip(target, from, items);

                target.Internalize();
            }
            else if (target == oldPlayer && !target.Deleted)
            {
                controlItem.Delete();
            }
        }
Beispiel #19
0
 private int  GetIndex(string name)
 {
     for (int i = 0, imax = controls.Count; i < imax; i++)
     {
         ControlItem item = controls[i];
         if (item.name == name)
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #20
0
            public void Add(ControlItem item)
            {
                _items.Add(item);
                if (!EnsureCreated())
                {
                    return;
                }

                var toolInfo = new ComCtl32.ToolInfoWrapper <ErrorWindow>(this, item.Id, ComCtl32.TTF.SUBCLASS, item.Error);

                toolInfo.SendMessage(_tipWindow, (User32.WM)ComCtl32.TTM.ADDTOOLW);

                Update(timerCaused: false);
            }
Beispiel #21
0
    /// <summary>
    /// 由于自动拖上去的对象永远都是 GameObject,所以我们需要把它修正为正确的对象类型
    /// </summary>
    private bool ReplaceTargetsToUIComponent()
    {
        for (int i = 0, imax = controls.Count; i < imax; i++)
        {
            var  objs = controls[i].targets;
            Type type = null;
            for (int j = 0, jmax = objs.Length; j < jmax; j++)
            {
                if (objs[j] == null)
                {
                    Debug.LogErrorFormat("控件名字 [{0}] 第 {1} 项为空,请修正", controls[i].name, j + 1);
                    return(false);
                }

                GameObject go = objs[j] as GameObject;
                if (go == null)
                {
                    go = (objs[j] as Component).gameObject;
                }

                // 必须拖当前 Prefab 下的控件
                if (!IsInCurrentPrefab((go.transform).transform))
                {
                    Debug.LogErrorFormat("控件名字 [{0}] 第 {1} 项不是当前 Prefab 下的控件,请修正", controls[i].name, j + 1);
                    return(false);
                }

                var correctComponent = FindCorrectComponent(go);
                if (type == null)
                {
                    type = correctComponent.GetType();
                }
                else if (type != correctComponent.GetType())
                {
                    Debug.LogErrorFormat("控件名字 [{0}] 第 {1} 项与第 1 项的类型不同,请修正", controls[i].name, j + 1);
                    return(false);
                }

                objs[j] = correctComponent;
            }

            controls[i] = new ControlItem()
            {
                name = controls[i].name, type = type.Name, targets = objs
            };
        }
        return(true);
    }
        private void RestoreSelectedFolder()
        {
            _wasSelectedFolderRestored = true;

            var selectedFolder = SettingManager.Instance.ParameterPageSelectedFolder;

            if (selectedFolder.IsNullOrEmpty())
            {
                this.IdocItemsView.MoveCurrentTo(null);
                return;
            }

            this.IdocItemsView.MoveCurrentTo(ControlItem.Create(new RepositoryItem {
                Folder = selectedFolder
            }));
        }
Beispiel #23
0
        public static void EndControl(ControlItem controlItem, bool stats, bool skills, bool items)
        {
            Mobile       from      = controlItem.Owner;
            PlayerMobile oldPlayer = controlItem.Player;
            Mobile       oldNPC    = controlItem.NPC;

            if (from == null)
            {
                return;
            }

            from.SendMessage("Du bist wieder in deiner alten Gestallt");
            //"You are in your original Body"

            //NPC wiederherstellen
            if (oldNPC != null && !oldNPC.Deleted)
            {
                //Props immer übernehmen bei der Rückverwandlung?
                //ja, weil sich hits etc ändern
                //Props from -> oldNPC
                CopyProps(oldNPC, from, stats, skills);
                //nicht nur zurück holen:
                //if ( oldNPC.Map == Map.Internal )
                //	oldNPC.MoveToWorld(from.Location, from.Map);


                //Equip from -> oldNPC
                MoveEquip(from, oldNPC, items);
            }
            else
            {
                from.SendMessage("Der originale NPC wurde gelöscht und wird nicht wiederhergestellt. Grund könnte ein manueller Respawn gewesen sein");
                //"The original NPC was deleted. Maybe because a manual respawn"
                oldNPC.Delete();
            }

            if (oldPlayer != null && !oldPlayer.Deleted)
            {
                //Spieler Wiederherstellen (100%)
                //Props: oldPlayer -> player
                CopyProps(from, oldPlayer, true, true);
                //Equip: oldPlayer -> player
                MoveEquip(oldPlayer, from, true);

                oldPlayer.Delete();
            }
        }
Beispiel #24
0
        private static void StartControl(Mobile from, Mobile target, bool stats, bool skills, bool items)
        {
            from.SendMessage("You leave your Body to control {0}, {1}", target.Name, target.Title);

            PlayerMobile playerClone = (PlayerMobile)DupeMobile(from);

            ControlItem controlItem = new ControlItem(from, playerClone, target, stats, skills, items);

            from.Backpack.DropItem(controlItem);

            MoveEquip(from, playerClone, items);

            MoveEquip(target, from, items);
            CopyProps(target, from, stats, skills);

            target.Internalize();
            playerClone.Internalize();
        }
Beispiel #25
0
        public static bool UncontrolDeath(Mobile from)
        {
            if (from.AccessLevel < accessLevel)
            {
                return(true);
            }

            ControlItem controlItem = GetControlItem(from);

            if (controlItem != null)
            {
                controlItem.Delete();
                from.Hits = from.HitsMax;
                return(false);
            }

            return(true);
        }
Beispiel #26
0
        private void DeserializeXMLfile(String fileName)
        {
            // get the file info
            List <ControlItem> controlItemsList = RuntimeDesignerSerializer.DeSerializeFromFile(fileName);

            if (controlItemsList != null && IsControlItemsListValid(fileName, controlItemsList))
            {
                // loop on all components
                foreach (var keyValue in runtimeHostSurface.ComponentsDictionary) // key - component, value - ComponentWrapper
                {
                    Control             control             = (Control)keyValue.Key;
                    ComponentWrapper    cw                  = keyValue.Value;
                    ControlDesignerInfo controlDesignerInfo = ((ControlDesignerInfo)control.Tag);
                    if (fileName.Equals(controlDesignerInfo.FileName))
                    {
                        int isn = controlDesignerInfo.Isn;
                        // try and get the info for this component from the file info
                        ControlItem controlItem = controlItemsList.Find(x => x.Isn == isn);
                        if (controlItem != null && controlItem.Properties != null)
                        {
                            if (!controlDesignerInfo.ControlType.ToString().Equals(controlItem.ControlType))
                            {
                                return;
                            }

                            // set the value for and every each property
                            foreach (var item in controlItem.Properties)
                            {
                                object value = item.GetValue();
                                if (ComponentWrapper.IsCoordinateProperty(item.Key))
                                {
                                    value = ((int)value) + controlDesignerInfo.GetPlacementForProp(item.Key);
                                }
                                cw.PropertiesDescriptors[item.Key].SetValue(keyValue.Key, value);
                                if (item.Key == Constants.WinPropVisible)
                                {
                                    control.Visible = false;
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #27
0
            protected override void ValidateTypedValue(
                ObjectValidatorContext validatorContext,
                MemberConstraintValidationContext memberContext,
                ControlItem <IPlayerInfo> value)
            {
                if (value?.Value is null)
                {
                    AddError(
                        validatorContext,
                        memberContext,
                        $@"The player is not selected ({
                            ((PlayerChoiceControlViewModel)memberContext.Container).PlayerSide}).");

                    return;
                }

                var dataValidationResult = value.Value.CreationData?.Validate();

                if (dataValidationResult is { IsObjectValid : false })
Beispiel #28
0
            private unsafe void OnPaint()
            {
                using var hdc  = new User32.BeginPaintScope(Handle);
                using var save = new Gdi32.SaveDcScope(hdc);

                MirrorDcIfNeeded(hdc);

                for (int i = 0; i < _items.Count; i++)
                {
                    ControlItem item   = _items[i];
                    Rectangle   bounds = item.GetIconBounds(_provider.Region.Size);
                    User32.DrawIconEx(
                        hdc,
                        bounds.X - _windowBounds.X,
                        bounds.Y - _windowBounds.Y,
                        _provider.Region,
                        bounds.Width, bounds.Height);
                }
            }
Beispiel #29
0
            public void Remove(ControlItem item)
            {
                _items.Remove(item);

                if (_tipWindow is not null)
                {
                    var info = new ComCtl32.ToolInfoWrapper <ErrorWindow>(this, item.Id);
                    info.SendMessage(_tipWindow, (User32.WM)ComCtl32.TTM.DELTOOLW);
                }

                if (_items.Count == 0)
                {
                    EnsureDestroyed();
                }
                else
                {
                    Update(timerCaused: false);
                }
            }
Beispiel #30
0
 private void logMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     if (e.ClickedItem.Name == "addAsItem")
     {
         if (logListViews.SelectedItem == null)
         {
             return;
         }
         var logValue = logListViews.SelectedItem.ToString();
         if (logValue.StartsWith("VPX"))
         {
             var(success, triggerString, valueString, _) = VPXProcessor.splitCommandString(logValue.Replace("VPX ", ""));
             if (success)
             {
                 ControlItem newItem = new ControlItem(triggerString, valueString);
                 dataProcessor.AddControlItem(newItem);
             }
         }
     }
 }
Beispiel #31
0
 /// <summary>
 /// Creates a new ShowControls for a single control that will shown fullscreen.
 /// </summary>
 public static ShowControls CreateFullscreen(ControlItem item)
 {
     return CreateFullscreen(new[] { item });
 }
Beispiel #32
0
 /// <include file='doc\ErrorProvider.uex' path='docs/doc[@for="ErrorProvider.EnsureControlItem"]/*' />
 /// <devdoc>
 ///     Helper to make sure we have allocated a control item for this control.
 /// </devdoc>
 /// <internalonly/>
 private ControlItem EnsureControlItem(Control control) {
     if (control == null)
         throw new ArgumentNullException("control");
     ControlItem item = (ControlItem)items[control];
     if (item == null) {
         item = new ControlItem(this, control, (IntPtr)(++itemIdCounter));
         items[control] = item;
     }
     return item;
 }
Beispiel #33
0
            /// <include file='doc\ErrorProvider.uex' path='docs/doc[@for="ErrorProvider.ErrorWindow.Remove"]/*' />
            /// <devdoc>
            ///     This is called when a control no longer needs to display an error icon.
            /// </devdoc>
            public void Remove(ControlItem item) {
                items.Remove(item);

                if (tipWindow != null) {
                    NativeMethods.TOOLINFO_T toolInfo = new NativeMethods.TOOLINFO_T();
                    toolInfo.cbSize = Marshal.SizeOf(toolInfo);
                    toolInfo.hwnd = Handle;
                    toolInfo.uId = item.Id;
                    UnsafeNativeMethods.SendMessage(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.TTM_DELTOOL, 0, toolInfo);
                }

                if (items.Count == 0) {
                    EnsureDestroyed();
                }
                else {
                    Update(false /*timerCaused*/);
                }
            }
Beispiel #34
0
            //
            // METHODS
            //

            /// <include file='doc\ErrorProvider.uex' path='docs/doc[@for="ErrorProvider.ErrorWindow.Add"]/*' />
            /// <devdoc>
            ///     This is called when a control would like to show an error icon.
            /// </devdoc>
            public void Add(ControlItem item) {
                items.Add(item);
                if (!EnsureCreated())
                {
                    return;
                }

                NativeMethods.TOOLINFO_T toolInfo = new NativeMethods.TOOLINFO_T();
                toolInfo.cbSize = Marshal.SizeOf(toolInfo);
                toolInfo.hwnd = Handle;
                toolInfo.uId = item.Id;
                toolInfo.lpszText = item.Error;
                toolInfo.uFlags = NativeMethods.TTF_SUBCLASS;
                UnsafeNativeMethods.SendMessage(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.TTM_ADDTOOL, 0, toolInfo);

                Update(false /*timerCaused*/);
            }
Beispiel #35
0
 /// <summary>
 /// Creates a new ShowControls for a single control that will be docked.
 /// </summary>
 public static ShowControls CreateDocked(ControlItem control)
 {
     return CreateDocked(new[] { control });
 }
Beispiel #36
0
 /// <summary>
 /// Creates a new ShowControls for a multiple controls that will be docked.
 /// </summary>
 public static ShowControls CreateDocked(ControlItem[] controls)
 {
     GameObject prefab = (GameObject)Resources.Load("DefaultShowControls");
     GameObject obj = (GameObject)Instantiate(prefab);
     ShowControls sc = obj.GetComponent<ShowControls>();
     sc.controls = new ArrayList(controls);
     return sc;
 }
Beispiel #37
0
 /// <summary>
 /// Creates a new ShowControls for a multiple controls that will shown fullscreen.
 /// </summary>
 public static ShowControls CreateFullscreen(ControlItem[] controls)
 {
     GameObject prefab = (GameObject)Resources.Load("DefaultShowControls");
     GameObject obj = (GameObject)Instantiate(prefab);
     ShowControls sc = obj.GetComponent<ShowControls>();
     sc.controls = new ArrayList(controls);
     sc.style = ShowControlStyle.FullScreen;
     sc.slideSpeed = -1;
     sc.showDuration = -1;
     sc.pauseOnDisplay = true;
     return sc;
 }
Beispiel #38
0
    private void ShowControl(ControlItem control, int x, int y)
    {
        Rect texRect = new Rect(x, y, texSize, texSize);
        Rect labelRect;

        if (control.custom != null)
        {
            ShowCustom(texRect, control.custom);
            texRect.x += texSize;
        }
        // draw each of the keys
        if (control.keys != null)
        {
            foreach (KeyCode key in control.keys)
            {
                ShowKey(texRect, key);
                texRect.x += texSize;
            }
        }

        // draw the mouse, if necessary
        if (control.button != MouseButton.None || control.direction != MouseDirection.None)
        {
            // if we already showed keys, also show a plus between keys & mouse
            if (control.keys != null)
            {
                Rect plusRect = new Rect(texRect.x, texRect.y + (texSize *.375f), texSize / 4, texSize / 4);
                GUI.DrawTexture(plusRect, plus);
                texRect.x += texSize / 4;
            }
            ShowMouse(texRect, control.direction, control.button);
            texRect.x += texSize;
        }
        // put the text description in the leftover space
        labelRect = new Rect(texRect.x, y, (Screen.width / 2) - (texRect.x - x), verticalSize);
        GUI.Box(labelRect, control.description, gui.box);
    }