예제 #1
0
        public override void RestoreDefaultValues()
        {
            var editors = Editors.OfType <RangeEditorViewModel>();

            foreach (var editor in editors)
            {
                editor.RestoreDefaultValues();
            }
        }
        protected override async Task UpdateCurrentValueAsync()
        {
            if (Event == null)
            {
                return;
            }
            if (Editors.Count == 0)
            {
                SetCurrentMethods(null);
                return;
            }

            using (await AsyncWork.RequestAsyncWork(this)) {
                // Right now we only show events if one item is selected, but there's no technical reason
                // we can't attach the same event to the same handler across multiple objects, so the ground
                // work is done.
                IReadOnlyList <string>[] methodLists = await Task.WhenAll(Editors.OfType <IObjectEventEditor>().Select(ed => ed.GetHandlersAsync(Event)));

                bool disagree = false;
                IReadOnlyList <string> methods = methodLists[0];
                for (int i = 1; i < methodLists.Length; i++)
                {
                    IReadOnlyList <string> methodList = methodLists[i];
                    if (methodList.Count != methods.Count)
                    {
                        disagree = true;
                        break;
                    }

                    for (int x = 0; x < methodList.Count; i++)
                    {
                        if (methodList[x] != methods[x])
                        {
                            disagree = true;
                            break;
                        }
                    }

                    if (disagree)
                    {
                        break;
                    }
                }

                MultipleValues = disagree;
                SetCurrentMethods((!disagree) ? methods : null);
            }
        }
        private async void SetMethodName(string name)
        {
            IObjectEventEditor editor = Editors.OfType <IObjectEventEditor>().First();

            if (this.methodName != null)
            {
                await editor.DetachHandlerAsync(Event, this.methodName);
            }

            if (!String.IsNullOrWhiteSpace(name))
            {
                await editor.AttachHandlerAsync(Event, name);
            }

            await UpdateCurrentValueAsync();
        }