Example #1
0
        public void VSM_GoToState()
        {
            var myControl1 = new MyControl1();

            var prop1Default = (double)InnerControl.Property1Property.GetMetadata(myControl1.InnerControl.GetType()).DefaultValue;
            var prop2Default = (double)InnerControl.Property2Property.GetMetadata(myControl1.InnerControl.GetType()).DefaultValue;
            var prop3Default = (double)InnerControl.Property3Property.GetMetadata(myControl1.InnerControl.GetType()).DefaultValue;
            var prop4Default = (double)InnerControl.Property4Property.GetMetadata(myControl1.InnerControl.GetType()).DefaultValue;

            myControl1.InnerControl.Property1.Should().Be(prop1Default);
            myControl1.InnerControl.Property2.Should().Be(prop2Default);
            myControl1.InnerControl.Property3.Should().Be(prop3Default);
            myControl1.InnerControl.Property4.Should().Be(prop4Default);

            // 1 - Move from no current state to a state
            myControl1.GoToState1().Should().BeTrue();

            myControl1.InnerControl.Property1.Should().Be(42d);
            myControl1.InnerControl.Property2.Should().Be(prop2Default);
            myControl1.InnerControl.Property3.Should().Be(prop3Default);
            myControl1.InnerControl.Property4.Should().Be(prop4Default);

            // 2 - Move from a state to a state in the same group
            myControl1.GoToState2().Should().BeTrue();

            myControl1.InnerControl.Property1.Should().Be(prop1Default);
            myControl1.InnerControl.Property2.Should().Be(84d);
            myControl1.InnerControl.Property3.Should().Be(prop3Default);
            myControl1.InnerControl.Property4.Should().Be(prop4Default);

            // 3 - Move from a group to another
            myControl1.GoToState4().Should().BeTrue();

            myControl1.InnerControl.Property1.Should().Be(prop1Default);
            myControl1.InnerControl.Property2.Should().Be(84d);
            myControl1.InnerControl.Property3.Should().Be(prop3Default);
            myControl1.InnerControl.Property4.Should().Be(336d);

            // 4 - Move to a state that does not exist

            VisualStateManager.GoToState(myControl1, "some_state_that_does_not_exist", false).Should().BeFalse();

            myControl1.InnerControl.Property1.Should().Be(prop1Default);
            myControl1.InnerControl.Property2.Should().Be(84d);
            myControl1.InnerControl.Property3.Should().Be(prop3Default);
            myControl1.InnerControl.Property4.Should().Be(336d);
        }
Example #2
0
        private void Init(object sender, RoutedEventArgs e)
        {
            app      = System.Windows.Application.Current;
            myWindow = (Window)app.MainWindow;
            myWindow.SizeToContent = SizeToContent.WidthAndHeight;
            wfh.TabIndex           = 10;
            initFontSize           = wfh.FontSize;
            initFontWeight         = wfh.FontWeight;
            initFontFamily         = wfh.FontFamily;
            initFontStyle          = wfh.FontStyle;
            initBackBrush          = (SolidColorBrush)wfh.Background;
            initForeBrush          = (SolidColorBrush)wfh.Foreground;
            MyControl1 mc = (MyControl1)wfh.Child;

            mc.OnButtonClick += Pane1_OnButtonClick;
            UIIsReady         = true;
        }
Example #3
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.myControl1 = new EventBrokerPattern.MyControl1();
            this.myControl2 = new EventBrokerPattern.MyControl2();
            this.myControl3 = new EventBrokerPattern.MyControl3();
            this.SuspendLayout();
            // 
            // myControl1
            // 
            this.myControl1.Location = new System.Drawing.Point(12, 12);
            this.myControl1.Name = "myControl1";
            this.myControl1.Size = new System.Drawing.Size(152, 86);
            this.myControl1.TabIndex = 0;
            // 
            // myControl2
            // 
            this.myControl2.Location = new System.Drawing.Point(184, 58);
            this.myControl2.Name = "myControl2";
            this.myControl2.Size = new System.Drawing.Size(131, 28);
            this.myControl2.TabIndex = 1;
            // 
            // myControl3
            // 
            this.myControl3.Location = new System.Drawing.Point(184, 24);
            this.myControl3.Name = "myControl3";
            this.myControl3.Size = new System.Drawing.Size(131, 28);
            this.myControl3.TabIndex = 2;
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(327, 110);
            this.Controls.Add(this.myControl1);
            this.Controls.Add(this.myControl2);
            this.Controls.Add(this.myControl3);
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout(false);

        }