예제 #1
0
        private void ActivateImage(string id, ScarboroughImage si)
        {
            ScarboroughImage existing = GetImage(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.Display           = si.Display;
                existing.ctx               = si.ctx;
                si.ImageFilename           = si.EvaluateStringExpression(si.ctx, si.ImageExpression);
                if (existing.ImageFilename != si.ImageFilename)
                {
                    existing.ImageFilename = si.ImageFilename;
                    existing.NeedImage     = true;
                }
            }
            else
            {
                si.Ordinal       = GetNextOrdinal();
                si.NeedImage     = true;
                si.plug          = plug;
                si.ImageFilename = si.EvaluateStringExpression(si.ctx, si.ImageExpression);
                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);
                imageitems[id]   = si;
            }
        }
예제 #2
0
        private void UpdateImages(int numTicks, ref RenderCollection rc)
        {
            List <string>          toRem    = new List <string>();
            List <DeferredMessage> messages = new List <DeferredMessage>();

            toRem.Clear();
            foreach (KeyValuePair <string, ScarboroughImage> si in imageitems)
            {
                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)
                {
                    ScarboroughImage sit = imageitems[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")
                        }
                                     );
                    }
                    imageitems.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;
            }
        }