Interaction logic for Trigger.xaml
Наследование: System.Windows.Controls.UserControl
Пример #1
0
        Controls.Trigger CreateTrigger(Trigger t, Value v, Event e)
        {
            var result = new Controls.Trigger();

            result.ParentPage    = this;
            result.ParentEvent   = e;
            result.ParentValue   = v;
            result.ParentTrigger = t;

            result.SettingChanged += Trigger_SettingChanged;
            result.RemoveClicked  += Trigger_RemoveClicked;

            foreach (CollectedItem item in CollectedItems)
            {
                result.DataItems.Add(item.Id);
            }

            result.LinkType = t.linkType;

            //result.link_COMBO.Text = t.link;
            result.SelectedLink = t.link;

            //result.SelectedLink = t.link;
            result.modifier_COMBO.SelectedItem = t.modifier;

            result.value_COMBO.SelectedItem = t.value;
            result.Value = t.value;

            return(result);
        }
Пример #2
0
        private void MultiTrigger_AddTriggerClicked(Controls.MultiTrigger sender)
        {
            if (sender.ParentMultiTrigger != null && sender.ParentValue != null && sender.ParentEvent != null)
            {
                if (sender.ParentEvent.values.Contains(sender.ParentValue))
                {
                    Controls.Event e = events.Find(x => x.ParentEvent == sender.ParentEvent);
                    if (e != null)
                    {
                        int index = e.Values.ToList().FindIndex(x => x.ParentValue == sender.ParentValue);
                        if (index >= 0)
                        {
                            Controls.Value v = e.Values[index];
                            if (v != null)
                            {
                                var t = new Trigger();
                                Controls.Trigger tr = CreateTrigger(t, sender.ParentValue, sender.ParentEvent);

                                sender.ParentMultiTrigger.triggers.Add(t);

                                tr.modifier_COMBO.SelectedItem = "Equal To";
                                sender.Triggers.Add(tr);
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
        private void Value_AddMultiTriggerClicked(Controls.Value val)
        {
            if (val.ParentValue != null && val.ParentEvent != null)
            {
                if (val.ParentEvent.values.Contains(val.ParentValue))
                {
                    Controls.Event e = events.Find(x => x.ParentEvent == val.ParentEvent);
                    if (e != null)
                    {
                        int index = e.Values.ToList().FindIndex(x => x.ParentValue == val.ParentValue);
                        if (index >= 0)
                        {
                            Controls.Value v = e.Values[index];
                            if (v != null)
                            {
                                var multitrigger = new MultiTrigger();
                                val.ParentValue.triggers.Add(multitrigger);

                                Controls.MultiTrigger uiMultiTrigger = CreateMultiTrigger(multitrigger, val.ParentValue, val.ParentEvent);

                                var trigger = new Trigger();
                                multitrigger.triggers.Add(trigger);

                                Controls.Trigger uiTrigger = CreateTrigger(trigger, uiMultiTrigger.ParentValue, uiMultiTrigger.ParentEvent);
                                uiTrigger.modifier_COMBO.SelectedItem = "Equal To";
                                uiMultiTrigger.Triggers.Add(uiTrigger);

                                val.Triggers.Add(uiMultiTrigger);
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        void Value_AddTriggerClicked(Controls.Value val)
        {
            if (val.ParentValue != null && val.ParentEvent != null)
            {
                if (val.ParentEvent.values.Contains(val.ParentValue))
                {
                    Controls.Event e = events.Find(x => x.ParentEvent == val.ParentEvent);
                    if (e != null)
                    {
                        int index = e.Values.ToList().FindIndex(x => x.ParentValue == val.ParentValue);
                        if (index >= 0)
                        {
                            Controls.Value v = e.Values[index];
                            if (v != null)
                            {
                                var t = new Trigger();
                                val.ParentValue.triggers.Add(t);

                                Controls.Trigger tr = CreateTrigger(t, val.ParentValue, val.ParentEvent);
                                tr.modifier_COMBO.SelectedItem = "Equal To";
                                val.Triggers.Add(tr);
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
        Controls.Value CreateValue(Value v, Event e)
        {
            Controls.Value result = new Controls.Value();

            result.ParentEvent = e;
            result.ParentValue = v;

            result.SettingChanged         += result_SettingChanged;
            result.RemoveClicked          += Value_RemoveClicked;
            result.AddTriggerClicked      += Value_AddTriggerClicked;
            result.AddMultiTriggerClicked += Value_AddMultiTriggerClicked;

            if (v.result != null)
            {
                result.ValueName = v.result.value.Replace('_', ' ');
            }

            foreach (Trigger t in v.triggers.OfType <Trigger>())
            {
                Controls.Trigger tr = CreateTrigger(t, v, e);
                result.Triggers.Add(tr);
            }

            foreach (MultiTrigger t in v.triggers.OfType <MultiTrigger>())
            {
                Controls.MultiTrigger tr = CreateMultiTrigger(t, v, e);
                result.Triggers.Add(tr);
            }

            return(result);
        }
Пример #6
0
        void Event_AddValueClicked(Controls.Event e)
        {
            if (e.ParentEvent != null)
            {
                var value = new Value();

                e.ParentEvent.values.Add(value);

                var uiValue = CreateValue(value, e.ParentEvent);

                var t = new Trigger();
                uiValue.ParentValue.triggers.Add(t);

                Controls.Trigger tr = CreateTrigger(t, uiValue.ParentValue, uiValue.ParentEvent);
                tr.modifier_COMBO.SelectedItem = "Equal To";
                uiValue.Triggers.Add(tr);

                e.Values.Add(uiValue);
            }

            ChangeSetting(null, null, null);
        }
Пример #7
0
        void Trigger_RemoveClicked(Controls.Trigger t)
        {
            if (t.ParentTrigger != null && t.ParentValue != null && t.ParentEvent != null)
            {
                t.ParentValue.triggers.Remove(t.ParentTrigger);

                if (t.ParentEvent.values.Contains(t.ParentValue))
                {
                    Controls.Event e = events.Find(x => x.ParentEvent == t.ParentEvent);
                    if (e != null)
                    {
                        Controls.Value v = e.Values.ToList().Find(x => x.ParentValue == t.ParentValue);
                        if (v != null)
                        {
                            if (v.Triggers.Contains(t))
                            {
                                v.Triggers.Remove(t);
                            }
                        }
                    }
                }
            }
        }
Пример #8
0
        Controls.Trigger CreateTrigger(Trigger t, Value v, Event e)
        {
            var result = new Controls.Trigger();

            result.ParentPage = this;
            result.ParentEvent = e;
            result.ParentValue = v;
            result.ParentTrigger = t;

            result.SettingChanged += Trigger_SettingChanged;
            result.RemoveClicked += Trigger_RemoveClicked;

            foreach (CollectedItem item in CollectedItems)
            {
                result.DataItems.Add(item.Id);
            }

            result.LinkType = t.linkType;

            //result.link_COMBO.Text = t.link;
            result.SelectedLink = t.link;

            //result.SelectedLink = t.link;
            result.modifier_COMBO.SelectedItem = t.modifier;

            result.value_COMBO.SelectedItem = t.value;
            result.Value = t.value;

            return result;
        }