コード例 #1
0
        public void OnLoad()
        {
            var types = typeof(PreviewViewModel).Assembly.GetTypes();

            Items = types
                    .Where(t => t.IsPublic && !t.IsAbstract && !t.IsInterface && PreviewItem.Match(t))
                    .Select(x => new PreviewItem(x)).ToArray();
            Messenger.Default.Register <StringId>(this, OnStringId);
        }
コード例 #2
0
        void OnStringId(StringId id)
        {
            Type localizerType = (id ?? StringId.None).LocalizerType;

            SelectedItem = Items.FirstOrDefault(x => PreviewItem.Match(x.Type, localizerType));
            if (SelectedItem != null && SelectedItem.IsTargetCreated)
            {
                if (!object.ReferenceEquals(StringId.None, id) && id.Value != null)
                {
                    var dispatcher = this.GetService <IDispatcherService>();
                    dispatcher.BeginInvoke(() =>
                    {
                        SelectedItem.Target.Show(id.Value);
                    });
                }
            }
        }