Пример #1
0
        private void ActivateText(string id, ScarboroughText si)
        {
            ScarboroughText existing = GetText(id);

            if (existing != null)
            {
                existing.Ordinal           = GetNextOrdinal();
                existing.Left              = si.EvaluateNumericExpression(si.ctx, si.InitXExpression);
                existing.Top               = si.EvaluateNumericExpression(si.ctx, si.InitYExpression);
                existing.Width             = si.EvaluateNumericExpression(si.ctx, si.InitWExpression);
                existing.Height            = si.EvaluateNumericExpression(si.ctx, si.InitHExpression);
                existing.Opacity           = si.EvaluateNumericExpression(si.ctx, si.InitOExpression);
                existing.UpdateXExpression = si.UpdateXExpression;
                existing.UpdateYExpression = si.UpdateYExpression;
                existing.UpdateWExpression = si.UpdateWExpression;
                existing.UpdateHExpression = si.UpdateHExpression;
                existing.UpdateOExpression = si.UpdateOExpression;
                existing.TTLExpression     = si.TTLExpression;
                existing.TextAlignment     = si.TextAlignment;
                existing.UseOutline        = si.UseOutline;
                existing.TextColor         = si.TextColor;
                existing.OutlineColor      = si.OutlineColor;
                existing.BackgroundColor   = si.BackgroundColor;
                existing.FontName          = si.FontName;
                existing.FontSize          = si.FontSize;
                existing.FontStyle         = si.FontStyle;
                existing.Text              = si.EvaluateStringExpression(si.ctx, si.TextExpression);
                existing.TextExpression    = si.TextExpression;
                existing.ctx               = si.ctx;
                existing.NeedFont          = true;
            }
            else
            {
                si.Ordinal    = GetNextOrdinal();
                si.plug       = plug;
                si.Left       = si.EvaluateNumericExpression(si.ctx, si.InitXExpression);
                si.Top        = si.EvaluateNumericExpression(si.ctx, si.InitYExpression);
                si.Width      = si.EvaluateNumericExpression(si.ctx, si.InitWExpression);
                si.Height     = si.EvaluateNumericExpression(si.ctx, si.InitHExpression);
                si.Opacity    = si.EvaluateNumericExpression(si.ctx, si.InitOExpression);
                si.Text       = si.EvaluateStringExpression(si.ctx, si.TextExpression);
                si.NeedFont   = true;
                textitems[id] = si;
            }
        }
Пример #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);
        }
Пример #3
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;
            }
        }
Пример #4
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;
            }
        }