protected void Page_Init(object sender, EventArgs e)
    {
        TestUserControl uc = (TestUserControl)Page.LoadControl("~/UserControls/TestUserControl.ascx");

        Panel1.Controls.Add(uc);
        uc.Fill();
    }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();

            _abnormalModel = new AbnormalViewModel();
            _abnormalModel.PopulateModel();
            AbnormalAttackWindow = new AbnormalAttackUserControl(_abnormalModel);

            var sbModel = new SimpleBindViewModel();

            sbModel.PopulateModel();
            LsbAttackWindow = new LsbAttackUserControl(sbModel);

            var testModel = new TestViewModel();

            testModel.PopulateModel();
            TestWindow = new TestUserControl(testModel);

            var vpnModel = new VpnViewModel();

            vpnModel.PopulateModel();
            VpnWindow = new VpnUserControl(vpnModel);

            var samrModel = new SamrViewModel();

            samrModel.PopulateModel();
            SamrWindow = new SamrUserControl(samrModel);

            DataContext = this;
        }
        public void IsHitTestVisibleActivatesFrameworkElement()
        {
            var uc = new TestUserControl();

            uc.IsHitTestVisible = false;
            var activation = new ActivationForViewFetcher();

            var obs       = activation.GetActivationForView(uc);
            var activated = obs.CreateCollection(scheduler: ImmediateScheduler.Instance);

            RoutedEventArgs loaded = new RoutedEventArgs();

            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            // IsHitTestVisible still false
            new bool[0].AssertAreEqual(activated);

            uc.IsHitTestVisible = true;

            // IsHitTestVisible true
            new[] { true }.AssertAreEqual(activated);

            RoutedEventArgs unloaded = new RoutedEventArgs();

            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false }.AssertAreEqual(activated);
        }
Example #4
0
        public void IsHitTestVisibleActivatesFrameworkElement()
        {
            var uc = new TestUserControl();

            uc.IsHitTestVisible = false;
            var activation = new ActivationForViewFetcher();

            var obs = activation.GetActivationForView(uc);

            obs.ToObservableChangeSet(scheduler: ImmediateScheduler.Instance).Bind(out var activated).Subscribe();

            var loaded = new RoutedEventArgs();

            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            // Loaded has happened.
            new[] { true }.AssertAreEqual(activated);

            uc.IsHitTestVisible = true;

            // IsHitTestVisible true, we don't want the event to repeat unnecessarily.
            new[] { true }.AssertAreEqual(activated);

            var unloaded = new RoutedEventArgs();

            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            // We had both a loaded/hit test visible change/unloaded happen.
            new[] { true, false }.AssertAreEqual(activated);
        }
Example #5
0
        public void IsHitTestVisibleActivatesFrameworkElement()
        {
            var uc = new TestUserControl();

            uc.IsHitTestVisible = false;
            var activation = new ActivationForViewFetcher();

            var obs = activation.GetActivationForView(uc);

            obs.ToObservableChangeSet(scheduler: ImmediateScheduler.Instance).Bind(out var activated).Subscribe();

            var loaded = new RoutedEventArgs();

            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            // IsHitTestVisible still false
            new bool[0].AssertAreEqual(activated);

            uc.IsHitTestVisible = true;

            // IsHitTestVisible true
            new[] { true }.AssertAreEqual(activated);

            var unloaded = new RoutedEventArgs();

            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false }.AssertAreEqual(activated);
        }
Example #6
0
        public void FrameworkElementIsActivatedAndDeactivated()
        {
            var uc         = new TestUserControl();
            var activation = new ActivationForViewFetcher();

            var obs = activation.GetActivationForView(uc);

            obs.ToObservableChangeSet(scheduler: ImmediateScheduler.Instance).Bind(out var activated).Subscribe();

            var loaded = new RoutedEventArgs();

            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            new[] { true }.AssertAreEqual(activated);

            var unloaded = new RoutedEventArgs();

            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false }.AssertAreEqual(activated);
        }
        public void FrameworkElementIsActivatedAndDeactivatedWithHitTest()
        {
            var uc         = new TestUserControl();
            var activation = new ActivationForViewFetcher();

            var obs       = activation.GetActivationForView(uc);
            var activated = obs.CreateCollection(scheduler: ImmediateScheduler.Instance);

            RoutedEventArgs loaded = new RoutedEventArgs();

            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            new[] { true }.AssertAreEqual(activated);

            // this should deactivate it
            uc.IsHitTestVisible = false;

            new[] { true, false }.AssertAreEqual(activated);

            // this should activate it
            uc.IsHitTestVisible = true;

            new[] { true, false, true }.AssertAreEqual(activated);

            RoutedEventArgs unloaded = new RoutedEventArgs();

            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false, true, false }.AssertAreEqual(activated);
        }
        public void IsHitTestVisibleActivatesFrameworkElement()
        {
            var uc = new TestUserControl();
            uc.IsHitTestVisible = false;
            var activation = new ActivationForViewFetcher();

            var obs = activation.GetActivationForView(uc);
            var activated = obs.CreateCollection();

            RoutedEventArgs loaded = new RoutedEventArgs();
            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            // IsHitTestVisible still false
            new bool[0].AssertAreEqual(activated);

            uc.IsHitTestVisible = true;

            // IsHitTestVisible true
            new[] { true }.AssertAreEqual(activated);

            RoutedEventArgs unloaded = new RoutedEventArgs();
            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false }.AssertAreEqual(activated);
        }
Example #9
0
        public void StoresAndLoadsModelUsingModelPersistenceMedium()
        {
            TestUserControl tuc = new TestUserControl();

            tuc.ModelPersistenceMedium = new DictionaryModelPersistenceMedium();
            tuc.SaveModelToPersistenceMedium(this);
            Assert.AreEqual(this, tuc.LoadModelFromPersistenceMedium());
        }
Example #10
0
        public void SetResultSelectsCorrectResult()
        {
            TestUserControl uc        = new TestUserControl();
            Result          theResult = A.Fake <Result>();

            uc.Results.Add("theResult", theResult);
            uc.SetResult("theResult");
        }
Example #11
0
        public Form1()
        {
            InitializeComponent();
            TestUserControl control = new TestUserControl(1);

            control.Location = new Point(491, 65);
            this.Controls.Add(control);
            //testUserControl1.TestUserControl();
            //DesignerForm();
        }
        public void Get_Affinity_For_View_Should_Return_Non_Zero_For_Visual_Elements()
        {
            var userControl = new TestUserControl();
            var activationForViewFetcher = new AvaloniaActivationForViewFetcher();

            var forUserControl    = activationForViewFetcher.GetAffinityForView(userControl.GetType());
            var forNonUserControl = activationForViewFetcher.GetAffinityForView(typeof(object));

            Assert.NotEqual(0, forUserControl);
            Assert.Equal(0, forNonUserControl);
        }
Example #13
0
        public void StoresAndRetrievesModelItem()
        {
            TestSessionModelPersistenceMedium pm = new TestSessionModelPersistenceMedium();
            Control tuc = new TestUserControl("TucID");

            pm.SaveToMedium(tuc, this);
            // ensure key was generated by GetKey() and Item was added to storage
            Assert.AreEqual(this, pm.SessionItems["TucID"]);

            // ensure key was generated by GetKey() and Item is retrieved from storage
            Assert.AreEqual(this, pm.LoadFromMedium(tuc));
        }
Example #14
0
        public void ValidateSetsDefaultVariables()
        {
            TestPage        page = new TestPage(HttpContext.Current);
            TestUserControl c1   = new TestUserControl();

            page.Controls.Add(c1);

            ConditionValidator v1 = new ConditionValidator("#page == #this.Page", null);
            ConditionValidator v2 = new ConditionValidator("#usercontrol == #this", null);

            Assert.IsTrue(c1.Validate(c1, v1, v2));
        }
Example #15
0
        public MainViewModel()
        {
            TestUserControlChange = new TestUserControl();
            _Student     = new Student();
            CopyFullName = new RelayCommand1(OnCopyFullName);

            Name     = _Student.Name;
            LastName = _Student.LastName;
            //TestUserControlChange.Text3 = student.ToString();

            //Name = "Gal";
            //LastName = "Hadour";
        }
Example #16
0
        public void SetResultBubblesUpHierarchyUntilFirstMatch()
        {
            TestUserControl c1  = new TestUserControl();
            Control         c11 = new Control();

            c1.Controls.Add(c11);
            TestUserControl c111      = new TestUserControl(c11);
            Result          theResult = A.Fake <Result>();

            c1.Results.Add("theResult", theResult);
            c111.SetResult("theResult");

            // context is the control, that contains matching Result
            A.CallTo(() => theResult.Navigate(c1)).MustHaveHappened();
        }
Example #17
0
        public void SetResultSelectsCorrectResult()
        {
            MockRepository  mocks     = new MockRepository();
            TestUserControl uc        = new TestUserControl();
            Result          theResult = (Result)mocks.CreateMock(typeof(Result));

            using (mocks.Ordered())
            {
                theResult.Navigate(uc);
            }
            mocks.ReplayAll();

            uc.Results.Add("theResult", theResult);
            uc.SetResult("theResult");
            mocks.VerifyAll();
        }
Example #18
0
        public void SetResultBubblesUpHierarchyUntilFirstMatch()
        {
            MockRepository  mocks     = new MockRepository();
            TestUserControl c1        = new TestUserControl();
            Control         c11       = new Control(); c1.Controls.Add(c11);
            TestUserControl c111      = new TestUserControl(c11);
            Result          theResult = (Result)mocks.CreateMock(typeof(Result));

            using (mocks.Ordered())
            {
                // context is the control, that contains matching Result
                theResult.Navigate(c1);
            }
            mocks.ReplayAll();

            c1.Results.Add("theResult", theResult);
            c111.SetResult("theResult");
            mocks.VerifyAll();
        }
Example #19
0
        public void IsHitTestVisibleDeactivatesFrameworkElement()
        {
            var uc         = new TestUserControl();
            var activation = new ActivationForViewFetcher();

            var obs       = activation.GetActivationForView(uc);
            var activated = obs.CreateCollection();

            RoutedEventArgs loaded = new RoutedEventArgs();

            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            new[] { true }.AssertAreEqual(activated);

            uc.IsHitTestVisible = false;

            new[] { true, false }.AssertAreEqual(activated);
        }
        public void FrameworkElementIsActivatedAndDeactivated()
        {
            var uc = new TestUserControl();
            var activation = new ActivationForViewFetcher();

            var obs = activation.GetActivationForView(uc);
            var activated = obs.CreateCollection();

            RoutedEventArgs loaded = new RoutedEventArgs();
            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            new[] { true }.AssertAreEqual(activated);

            RoutedEventArgs unloaded = new RoutedEventArgs();
            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false }.AssertAreEqual(activated);
        }
        public void Visual_Element_Is_Activated_And_Deactivated()
        {
            var userControl = new TestUserControl();
            var activationForViewFetcher = new AvaloniaActivationForViewFetcher();

            activationForViewFetcher
            .GetActivationForView(userControl)
            .ToObservableChangeSet(scheduler: ImmediateScheduler.Instance)
            .Bind(out var activated)
            .Subscribe();

            var fakeRenderedDecorator = new TestRoot();

            fakeRenderedDecorator.Child = userControl;
            Assert.True(activated[0]);
            Assert.Equal(1, activated.Count);

            fakeRenderedDecorator.Child = null;
            Assert.True(activated[0]);
            Assert.False(activated[1]);
            Assert.Equal(2, activated.Count);
        }
        public void NoNullModelPersistenceMediumAllowed()
        {
            TestUserControl tuc = new TestUserControl();

            tuc.ModelPersistenceMedium = null;
        }
Example #23
0
        public static void SetMainControl(ERMTControl view)
        {
            ERMTUserControl currentUserControl = new ERMTUserControl {
                Name = "new"
            };

            switch (view)
            {
            case ERMTControl.About:
            {
                About about = new About();
                about.ShowDialog();
                break;
            }

            case ERMTControl.EditRegion:
            {
                EditRegion editRegion = new EditRegion();
                currentUserControl = editRegion;
                SetMainControl(editRegion);
                ApplicationPrincipalForm.LoadLeftButtons();
                break;
            }

            case ERMTControl.ElectoralCycle:
            {
                IndexUserControl indexUserControl = new IndexUserControl
                {
                    IndexContentType = IndexContentType.ElectoralCycle
                };
                currentUserControl = indexUserControl;
                SetMainControl(indexUserControl);
                ApplicationPrincipalForm.LoadLeftButtons("electoralcycle");
                indexUserControl.ShowHtml();
                break;
            }

            case ERMTControl.ElectoralCycleModifyPhase:
            {
                ElectoralCycleModifyPhase electoralCycleModifyPhase = new ElectoralCycleModifyPhase();
                currentUserControl = electoralCycleModifyPhase;
                SetMainControl(electoralCycleModifyPhase);
                ApplicationPrincipalForm.LoadLeftButtons();
                break;
            }

            case ERMTControl.FactorModify:
            {
                FactorModify modifyFactor = new FactorModify();
                currentUserControl = modifyFactor;
                SetMainControl(modifyFactor);
                ApplicationPrincipalForm.LoadLeftButtons();
                break;
            }

            case ERMTControl.FactorNew:
            {
                FactorNew newFactor = new FactorNew();
                currentUserControl = newFactor;
                SetMainControl(newFactor);
                ApplicationPrincipalForm.LoadLeftButtons();
                break;
            }

            case ERMTControl.FactorReorder:
            {
                FactorsReorder reorderFactors = new FactorsReorder();
                currentUserControl = reorderFactors;
                SetMainControl(reorderFactors);
                ApplicationPrincipalForm.LoadLeftButtons();
                break;
            }

            case ERMTControl.KnowledgeResources:
            {
                IndexUserControl indexUserControl = new IndexUserControl
                {
                    IndexContentType = IndexContentType.KnowledgeResources
                };
                currentUserControl = indexUserControl;
                SetMainControl(indexUserControl);
                ApplicationPrincipalForm.LoadLeftButtons("KnowledgeResources");
                indexUserControl.ShowHtml();
                break;
            }

            case ERMTControl.Login:
            {
                LoginUserControl loginUserControl = new LoginUserControl();
                currentUserControl = loginUserControl;
                SetMainControl(loginUserControl);
                break;
            }

            case ERMTControl.MarkerTypeCRUD:
            {
                MarkerTypeCRUD markerTypeControl = new MarkerTypeCRUD();
                currentUserControl = markerTypeControl;
                SetMainControl(markerTypeControl);
                ApplicationPrincipalForm.LoadLeftButtons();
                break;
            }

            case ERMTControl.ModelEdit:
            {
                ModelEdit modelEdit = new ModelEdit();
                currentUserControl = modelEdit;
                SetMainControl(modelEdit);
                ApplicationPrincipalForm.LoadLeftButtons();
                break;
            }

            case ERMTControl.ModelNew:
            {
                ModelNew modelNew = new ModelNew();
                currentUserControl = modelNew;
                SetMainControl(modelNew);
                ApplicationPrincipalForm.LoadLeftButtons();
                break;
            }

            case ERMTControl.ModelReorderFactors:
            {
                ModelReorderFactors modelReorderFactors = new ModelReorderFactors();
                currentUserControl = modelReorderFactors;
                SetMainControl(modelReorderFactors);
                ApplicationPrincipalForm.LoadLeftButtons();
                break;
            }

            case ERMTControl.RiskActionRegister:
            {
                RiskAndActionRegister riskActionRegister = new RiskAndActionRegister(true);
                currentUserControl = riskActionRegister;
                SetMainControl(riskActionRegister);
                ApplicationPrincipalForm.LoadLeftButtons("riskandaction");
                break;
            }

            case ERMTControl.RiskMapping:
            {
                //RiskMapping riskMapping = new RiskMapping();
                //currentUserControl = riskMapping;
                //SetMainControl(riskMapping);
                currentUserControl = ControlCache.RiskMappingInstance;
                SetMainControl(ControlCache.RiskMappingInstance);
                ApplicationPrincipalForm.LoadLeftButtons("map");
                break;
            }

            case ERMTControl.Start:
            {
                SetMainControl(ControlCache.StartInstance);
                currentUserControl = ControlCache.StartInstance;
                ApplicationPrincipalForm.LoadLeftButtons("Start");
                break;
            }

            case ERMTControl.TestUserControl:
            {
                TestUserControl testUserControl = new TestUserControl();
                SetMainControl(testUserControl);
                break;
            }

            case ERMTControl.UserModify:
            {
                UserModify userModify = new UserModify();
                currentUserControl = userModify;
                SetMainControl(userModify);
                ApplicationPrincipalForm.LoadLeftButtons();
                break;
            }

            case ERMTControl.UserNew:
            {
                UserNew userNew = new UserNew();
                currentUserControl = userNew;
                SetMainControl(userNew);
                ApplicationPrincipalForm.LoadLeftButtons();
                break;
            }

            case ERMTControl.UserResetPassword:
            {
                UserChangePassword ucp = new UserChangePassword();
                ucp.ShowDialog();

                break;
            }
            }
            if (currentUserControl.Name != "new")
            {
                currentUserControl.ShowTitle();
            }
        }
Example #24
0
        public void NoNullModelPersistenceMediumAllowed()
        {
            TestUserControl tuc = new TestUserControl();

            Assert.Throws <ArgumentNullException>(() => tuc.ModelPersistenceMedium = null);
        }