Beispiel #1
0
        public Switch_ViewModel(IEventAggregator eventAggregator, SwitchAppearanceViewModel Appearance,
                                SwitchBehaviorViewModel Behavior,
                                LayoutPropertyViewModel Layout)
        {
            this.Layout     = Layout;
            this.Behavior   = Behavior;
            this.Appearance = Appearance;

            this.Appearance.Behavior = Behavior;

            this.eventAggregator = eventAggregator;

#if DEBUG
            System.Diagnostics.Debug.WriteLine($"entree {this} {Layout.NameUC}");
            var types = new System.Type[] { typeof(LayoutPropertyViewModel), Appearance.GetType(), Behavior.GetType() };
            DataContractSerializer dcs = new DataContractSerializer(GetType(), types);
            string buffer;
            using (var memStream = new MemoryStream())
            {
                dcs.WriteObject(memStream, this);
                buffer = Encoding.ASCII.GetString(memStream.GetBuffer()).TrimEnd('\0');
            }
            XmlDocument docxml = new XmlDocument();
            docxml.LoadXml(buffer);
            using (XmlTextWriter writer = new XmlTextWriter($@"j:\{this}.xml", null))
            {
                writer.Formatting = Formatting.Indented;
                docxml.Save(writer);
            }
#endif
        }
        public HSwitch_ViewModel(IEventAggregator eventAggregator, params object[] settings)
        {
            Layout     = new LayoutPropertyViewModel(eventAggregator, settings);
            Behavior   = new SwitchBehaviorViewModel(eventAggregator, settings);
            Appearance = new SwitchAppearanceViewModel(eventAggregator, Behavior, settings);

            NameUC = (string)settings[2];

            ////ScaleX = (double)settings[10];
            //ScaleX = 1;

            this.eventAggregator = eventAggregator;
            this.eventAggregator.Subscribe(this);
        }