Beispiel #1
0
        private void ExecuteAction(ItemAction ia)
        {
            switch (ia.Action)
            {
            case ItemAction.ActionTypeEnum.Activate:
            {
                if (ia.Item is ScarboroughImage)
                {
                    ActivateImage(ia.Id, (ScarboroughImage)ia.Item);
                }
                else if (ia.Item is ScarboroughText)
                {
                    ActivateText(ia.Id, (ScarboroughText)ia.Item);
                }
            }
            break;

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

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

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

                case ItemAction.ItemTypeEnum.Text:
                {
                    List <ScarboroughText> toRem = new List <ScarboroughText>();
                    foreach (KeyValuePair <string, ScarboroughText> si in textitems)
                    {
                        toRem.Add(si.Value);
                    }
                    textitems.Clear();
                    foreach (ScarboroughText si in toRem)
                    {
                        si.Dispose();
                    }
                }
                break;
                }
            }
            break;
            }
        }
Beispiel #2
0
        private void UpdateText(int numTicks, ref RenderCollection rc)
        {
            List <string>          toRem    = new List <string>();
            List <DeferredMessage> messages = new List <DeferredMessage>();

            toRem.Clear();
            foreach (KeyValuePair <string, ScarboroughText> si in textitems)
            {
                try
                {
                    if (si.Value.Logic(numTicks) == false)
                    {
                        toRem.Add(si.Key);
                    }
                    else
                    {
                        if (si.Value.Opacity > 0)
                        {
                            rc.Add(si.Value);
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (si.Value.ctx != null && si.Value.ctx.trig != null)
                    {
                        messages.Add(new DeferredMessage()
                        {
                            ctx     = si.Value.ctx,
                            plug    = plug,
                            level   = Triggernometry.Plugin.DebugLevelEnum.Error,
                            Message = Triggernometry.I18n.Translate("internal/AuraContainer/updateerror", String.Format("Deactivating aura due to update exception: {0}", ex.Message))
                        }
                                     );
                    }
                    else
                    {
                        messages.Add(new DeferredMessage()
                        {
                            ctx     = null,
                            plug    = plug,
                            level   = Triggernometry.Plugin.DebugLevelEnum.Error,
                            Message = Triggernometry.I18n.Translate("internal/AuraContainer/updateerror", String.Format("Deactivating aura due to update exception: {0}", ex.Message))
                        }
                                     );
                    }
                    toRem.Add(si.Key);
                }
            }
            if (toRem.Count > 0)
            {
                foreach (string si in toRem)
                {
                    ScarboroughText sit = textitems[si];
                    if (sit.ctx != null && sit.ctx.trig != null)
                    {
                        messages.Add(new DeferredMessage()
                        {
                            ctx     = sit.ctx,
                            plug    = plug,
                            level   = Triggernometry.Plugin.DebugLevelEnum.Verbose,
                            Message = Triggernometry.I18n.Translate("internal/AuraContainer/closingaura", "Closing aura window")
                        }
                                     );
                    }
                    else
                    {
                        messages.Add(new DeferredMessage()
                        {
                            ctx     = null,
                            plug    = plug,
                            level   = Triggernometry.Plugin.DebugLevelEnum.Verbose,
                            Message = Triggernometry.I18n.Translate("internal/AuraContainer/closingaura", "Closing aura window")
                        }
                                     );
                    }
                    textitems.Remove(si);
                    sit.Dispose();
                }
            }
            ProcessMessages(messages);
        }
Beispiel #3
0
        private void ExecuteAction(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 ScarboroughImage)
                {
                    ActivateImage(ia.Id, (ScarboroughImage)ia.Item);
                }
                else if (ia.Item is ScarboroughText)
                {
                    ActivateText(ia.Id, (ScarboroughText)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)
                    {
                        ScarboroughImage si = null;
                        si = imageitems[rem];
                        imageitems.Remove(rem);
                        if (si != null)
                        {
                            si.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)
                    {
                        ScarboroughText si = null;
                        si = textitems[rem];
                        textitems.Remove(rem);
                        if (si != null)
                        {
                            si.Dispose();
                        }
                    }
                }
                break;
                }
            }
            break;

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

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

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

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