예제 #1
0
        private AuraText ActivateText(string id, AuraText a)
        {
            AuraText existing = GetText(id);

            if (existing != null)
            {
                ActivateGeneric(existing, a);
                existing.TextExpression = a.TextExpression;
                existing.Text           = a.EvaluateStringExpression(existing.ctx, existing.TextExpression);
                return(existing);
            }
            else
            {
                ActivateGeneric(a, null);
                a.Text        = a.EvaluateStringExpression(a.ctx, a.TextExpression);
                textitems[id] = a;
                return(a);
            }
        }
예제 #2
0
        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;
            }
        }