コード例 #1
0
ファイル: Manager.cs プロジェクト: wananhsn/Triggernometry
        private AuraImage ActivateImage(string id, AuraImage a)
        {
            AuraImage existing = GetImage(id);

            if (existing != null)
            {
                ActivateGeneric(existing, a);
                return(existing);
            }
            else
            {
                ActivateGeneric(a, null);
                imageitems[id] = a;
                return(a);
            }
        }
コード例 #2
0
ファイル: Manager.cs プロジェクト: wananhsn/Triggernometry
        internal void ExecuteItemAction(ItemAction ia)
        {
            switch (ia.Action)
            {
            case ItemAction.ActionTypeEnum.RenderingOn:
                RenderingActive = true;
                break;

            case ItemAction.ActionTypeEnum.RenderingOff:
                RenderingActive = false;
                break;

            case ItemAction.ActionTypeEnum.Activate:
            {
                if (ia.Item is AuraImage)
                {
                    ia.Item.Name = ia.Id;
                    ActivateImage(ia.Id, (AuraImage)ia.Item);
                }
                else if (ia.Item is AuraText)
                {
                    ia.Item.Name = ia.Id;
                    ActivateText(ia.Id, (AuraText)ia.Item);
                }
            }
            break;

            case ItemAction.ActionTypeEnum.DeactivateRegex:
            {
                Regex         rex   = new Regex(ia.Id);
                List <string> toRem = new List <string>();
                switch (ia.ItemType)
                {
                case ItemAction.ItemTypeEnum.Image:
                {
                    toRem.AddRange(from sx in imageitems where rex.IsMatch(sx.Key) select sx.Key);
                    foreach (string rem in toRem)
                    {
                        AuraImage a = null;
                        a = imageitems[rem];
                        imageitems.Remove(rem);
                        if (a != null)
                        {
                            a.Dispose();
                        }
                    }
                }
                break;

                case ItemAction.ItemTypeEnum.Text:
                {
                    toRem.AddRange(from sx in textitems where rex.IsMatch(sx.Key) select sx.Key);
                    foreach (string rem in toRem)
                    {
                        AuraText a = null;
                        a = textitems[rem];
                        textitems.Remove(rem);
                        if (a != null)
                        {
                            a.Dispose();
                        }
                    }
                }
                break;
                }
            }
            break;

            case ItemAction.ActionTypeEnum.Deactivate:
            {
                switch (ia.ItemType)
                {
                case ItemAction.ItemTypeEnum.Image:
                {
                    AuraImage a = null;
                    if (imageitems.ContainsKey(ia.Id) == true)
                    {
                        a = imageitems[ia.Id];
                        imageitems.Remove(ia.Id);
                    }
                    if (a != null)
                    {
                        a.Dispose();
                    }
                }
                break;

                case ItemAction.ItemTypeEnum.Text:
                {
                    AuraText a = null;
                    if (textitems.ContainsKey(ia.Id) == true)
                    {
                        a = textitems[ia.Id];
                        textitems.Remove(ia.Id);
                    }
                    if (a != null)
                    {
                        a.Dispose();
                    }
                }
                break;
                }
            }
            break;

            case ItemAction.ActionTypeEnum.DeactivateAll:
            {
                switch (ia.ItemType)
                {
                case ItemAction.ItemTypeEnum.Image:
                {
                    List <AuraImage> toRem = new List <AuraImage>();
                    foreach (KeyValuePair <string, AuraImage> si in imageitems)
                    {
                        toRem.Add(si.Value);
                    }
                    imageitems.Clear();
                    foreach (AuraImage si in toRem)
                    {
                        si.Dispose();
                    }
                }
                break;

                case ItemAction.ItemTypeEnum.Text:
                {
                    List <AuraText> toRem = new List <AuraText>();
                    foreach (KeyValuePair <string, AuraText> si in textitems)
                    {
                        toRem.Add(si.Value);
                    }
                    textitems.Clear();
                    foreach (AuraText si in toRem)
                    {
                        si.Dispose();
                    }
                }
                break;
                }
            }
            break;
            }
        }