public virtual void ShouldFireCompletedEventOnceWithinTransition() { TransitioningContentControl tcc = DefaultTransitioningContentControlToTest; int count = 0; tcc.TransitionCompleted += (sender, e) => count++; bool tccIsLoaded = false; tcc.Loaded += delegate { tccIsLoaded = true; }; // Add the element to the test surface and wait until it's loaded EnqueueCallback(() => TestPanel.Children.Add(tcc)); EnqueueConditional(() => tccIsLoaded); EnqueueCallback(() => tcc.Content = "different content"); EnqueueCallback(() => Assert.AreEqual(0, count)); EnqueueCallback(() => tcc.Content = "different content2"); EnqueueCallback(() => tcc.Content = "different content3"); EnqueueCallback(() => tcc.Content = "different content4"); EnqueueDelay(500); // template has 300 ms transitions EnqueueCallback(() => Assert.AreEqual(1, count, "Should fire completed event.")); EnqueueTestComplete(); }
protected void ConfigureChildWindow(RCPChildWindow window, IWindowControl windowContent, bool isModal) { // Place the content within a transitioning content control for a transition when the window is opened var content = new TransitioningContentControl() { FocusVisualStyle = null, IsTabStop = false, Transition = Data.UI_EnableAnimations ? TransitionType.Left : TransitionType.Normal, UseLayoutRounding = true, Content = windowContent.UIContent, RestartTransitionOnContentChange = true }; // For some reason the transition doesn't start automatically here, so we manually reload it on load (might be because the Loaded event fires twice, probably once before it gets shown) void Content_Loaded(object s, RoutedEventArgs e) => content.ReloadTransition(); void Content_Unloaded(object s, RoutedEventArgs e) { // Make sure to unsubscribe to the events content.Unloaded -= Content_Unloaded; content.Loaded -= Content_Loaded; } content.Loaded += Content_Loaded; content.Unloaded += Content_Unloaded; // Set window properties window.Content = content; window.IsModal = isModal; window.CanMaximize = windowContent.IsResizable; }
public void Transitioning_Control_Should_Derive_Template_From_Content_Control() { var target = new TransitioningContentControl(); var stylable = (IStyledElement)target; Assert.Equal(typeof(ContentControl), stylable.StyleKey); }
public virtual void ShouldNotSetIsTransitioningProperty() { TransitioningContentControl tcc = new TransitioningContentControl(); TestAsync( tcc, () => Assert.IsTrue(DependencyProperty.UnsetValue == tcc.ReadLocalValue(TransitioningContentControl.IsTransitioningProperty))); }
private void TransitioningContentControl_TransitionCompleted(object sender, RoutedEventArgs e) { //// Set the root visual to use the transitioning control. TransitioningContentControl transitionControl = (TransitioningContentControl)sender; //transitionControl.Transition = "RightTransition"; TransitionControl = transitionControl; }
private void btnBack_Click(object sender, RoutedEventArgs e) { HomeNavigation home = Core.ViewLocator.Instance.Get <HomeNavigation>(); TransitioningContentControl selector = Core.ViewLocator.Instance.Get <TransitioningContentControl>("TransitionContentHome"); selector.Transition = TransitionType.Right; selector.Content = home.Templates["Home"]; selector.Transition = TransitionType.Left; }
public virtual void ShouldThrowExceptionOnInvalidTransitionName() { // the control will cache the invalid Transition until such time // that the template is applied, so that it can be validated. TransitioningContentControl tcc = DefaultTransitioningContentControlToTest; TestAsync( tcc, () => tcc.Transition = "non exisiting transition"); }
void settings_ConfigurationLoaded(object sender, EventArgs e) { this.Dispatcher.Invoke((Action)(() => { HomeNavigation home = ViewLocator.Instance.Get <HomeNavigation>(); TransitioningContentControl selector = ViewLocator.Instance.Get <TransitioningContentControl>("TransitionContentHome"); selector.Transition = TransitionType.Right; selector.Content = home.Templates["Settings"]; selector.Content = home.Templates["Home"]; selector.Transition = TransitionType.Left; })); }
public virtual void ShouldBeAbleToSetValidTransitionNames() { TransitioningContentControl tcc = DefaultTransitioningContentControlToTest; TestAsync( tcc, () => Assert.AreEqual("DefaultTransition", tcc.Transition), () => tcc.Transition = "UpTransition", () => Assert.AreEqual("UpTransition", tcc.Transition), () => tcc.Transition = "DownTransition", () => Assert.AreEqual("DownTransition", tcc.Transition)); }
public Controller(MainWindow mainWindow, Grid MainGrid, ref MyLabel[,] CellsArray, Label timeLabel) { this.mainWindow = mainWindow; this.MainGrid = MainGrid; this.CellsArray = CellsArray; this.timeLabel = timeLabel; timer = new MyTimer(timeLabel); contentControl = new TransitioningContentControl() { Transition = TransitionType.Left, RestartTransitionOnContentChange = true }; mainMenu = new MyMainMenu(NewGameBtn_Click, ResumeBtn_Click, OpenBtn_Click); menu = new MyMenu(ResumeBtn_Click, SaveBtn_Click, MainMenuBtn_Click); finishBanner = new FinishBanner(MainGrid, timer); ShowGrid(mainMenu.grid); }
public void Transitioning_Control_Template_Should_Be_Instantiated() { var target = new TransitioningContentControl { PageTransition = null, Template = GetTemplate(), Content = "Foo" }; target.ApplyTemplate(); ((ContentPresenter)target.Presenter).UpdateChild(); var child = ((IVisual)target).VisualChildren.Single(); Assert.IsType <Border>(child); child = child.VisualChildren.Single(); Assert.IsType <ContentPresenter>(child); child = child.VisualChildren.Single(); Assert.IsType <TextBlock>(child); }
private static void ReloadSelectionChanged(TabControl sender, SelectionChangedEventArgs e) { if (e.OriginalSource != sender) { return; } ContentControl metroContentControl = ReloadBehavior.GetMetroContentControl((TabControl)sender); MetroContentControl metroContentControl1 = metroContentControl as MetroContentControl; if (metroContentControl1 != null) { metroContentControl1.Reload(); } TransitioningContentControl transitioningContentControl = metroContentControl as TransitioningContentControl; if (transitioningContentControl != null) { transitioningContentControl.ReloadTransition(); } }
public virtual void ShouldWorkWithVisuals() { List <Rectangle> rectangles = new List <Rectangle> { new Rectangle { Height = 30, Width = 30, Fill = new SolidColorBrush(Colors.Red) }, new Rectangle { Height = 30, Width = 30, Fill = new SolidColorBrush(Colors.Green) }, new Rectangle { Height = 30, Width = 30, Fill = new SolidColorBrush(Colors.Blue) }, }; TransitioningContentControl tcc = new TransitioningContentControl(); bool tccIsLoaded = false; tcc.Loaded += delegate { tccIsLoaded = true; }; int count = 0; tcc.TransitionCompleted += (sender, e) => count++; EnqueueCallback(() => TestPanel.Children.Add(tcc)); EnqueueConditional(() => tccIsLoaded); EnqueueCallback(() => tcc.Content = rectangles[0]); EnqueueConditional(() => count == 1); EnqueueCallback(() => tcc.Content = rectangles[1]); EnqueueConditional(() => count == 2); EnqueueCallback(() => tcc.Content = rectangles[2]); EnqueueConditional(() => count == 3); EnqueueTestComplete(); }
private void InitLeftMenu(List <T_SYS_ENTITYMENU> menulist) { #region 备份的代码 ////StackPanel menuTemp = new StackPanel(); ////menuTemp.Margin = new Thickness(0, 1, 0, 1); ////leftMenu.MenuRoot.Children.Add(menuTemp); //HyperlinkButton btnTest = new HyperlinkButton(); //btnTest.Height = 22; //btnTest.FontSize = 13.333; //btnTest.FontWeight = FontWeights.Bold; //btnTest.Content = " 动态菜单"; //btnTest.Style = new Style(typeof(HyperlinkButton)); ////Link3.NavigateUri=null; ////btnTest.NavigateUri = new Uri("/SMT.HRM.UI;component/Views/Home.xaml", System.UriKind.Relative); //("//Home.xaml"); ////btnTest.TargetName = "contenxtPanle"; //btnTest.Click += new RoutedEventHandler(delegate{ // ContentFrame.Navigate(new Uri("/Home", UriKind.Relative));}); ////menuTemp.Children.Add(btnTest); ////btnTest.Style = new Style(); #endregion if (MainLeftMenu.Items != null) { MainLeftMenu.Items.Clear(); } //生成分组 // 1s 冉龙军 //var groupItems = from m in menulist // where m.T_SYS_ENTITYMENU2 == null // orderby m.ORDERNUMBER // select m; var groupItems = from m in menulist where m.T_SYS_ENTITYMENU2Reference.EntityKey == null orderby m.ORDERNUMBER select m; // 1e foreach (var item in groupItems) { AccordionItem group = new AccordionItem(); group.Header = item; group.Style = this.Resources["TreeMenuGroupStyle"] as Style; group.BorderThickness = new Thickness(0); group.FontSize = 14.0; if (UIHelper._CurrentStyleCode_2 == 1) { group.Foreground = Application.Current.Resources["TextBBlue1"] as SolidColorBrush; } group.VerticalContentAlignment = VerticalAlignment.Stretch; group.HorizontalContentAlignment = HorizontalAlignment.Stretch; group.VerticalAlignment = VerticalAlignment.Stretch; group.HorizontalAlignment = HorizontalAlignment.Stretch; //生成菜单明细 //var menuItems = from m in menulist // where m.T_SYS_ENTITYMENU2 == item // orderby m.ORDERNUMBER // select m; var menuItems = from m in menulist where m.T_SYS_ENTITYMENU2Reference.EntityKey != null && m.T_SYS_ENTITYMENU2Reference.EntityKey.EntityKeyValues[0].Value.ToString() == item.ENTITYMENUID orderby m.ORDERNUMBER select m; TransitioningContentControl ctrl = new TransitioningContentControl(); StackPanel pnl = new StackPanel(); pnl.VerticalAlignment = VerticalAlignment.Stretch; pnl.HorizontalAlignment = HorizontalAlignment.Stretch; pnl.Margin = new Thickness(0, 0, 0, 0); TreeView tree = new TreeView(); tree.Style = (Style)Application.Current.Resources["TreeViewStyle"]; tree.BorderThickness = new Thickness(0); tree.Margin = new Thickness(0); tree.HorizontalAlignment = HorizontalAlignment.Stretch; tree.Width = MainLeftMenu.ActualWidth; foreach (var menu in menuItems) { TreeViewItem treeItem = CreateTreeItem(menu); AddSubMenu(menulist, treeItem, menu); tree.Items.Add(treeItem); #region 原始方法生成 //StackPanel itempanel = new StackPanel(); //itempanel.Height = 24; //itempanel.Orientation = Orientation.Horizontal; //Image img = new Image(); //img.Width = 16; //img.Height = 16; //img.HorizontalAlignment = HorizontalAlignment.Left; //if (!string.IsNullOrEmpty(menu.URLADDRESS)) // img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(menu.MENUICONPATH, UriKind.Relative)); //img.Margin = new Thickness(6, 1, 0, 0); //itempanel.Children.Add(img); //HyperlinkButton link = new HyperlinkButton(); //link.Content = menu.MENUNAME; //if (!string.IsNullOrEmpty(menu.URLADDRESS)) // link.NavigateUri = new Uri(menu.URLADDRESS, UriKind.Relative); //link.Margin = new Thickness(6, 6, 0, 0); //itempanel.Children.Add(link); //pnl.Children.Add(itempanel); #endregion } ctrl.Content = tree; //ctrl.Content = pnl; group.Content = ctrl; MainLeftMenu.Items.Add(group); } }
public static void navigate(string newPage, object windowParams = null, object pageParams = null) { try { string newWindowName = pages[newPage].WindowName; bool isDialog = windows[newWindowName].IsDialog; if (activeWindow != newWindowName) { Window tmpWindow = (Window)Activator.CreateInstance(windows[newWindowName].WindowClass); if (!isDialog) { Application.Current.MainWindow = tmpWindow; } if (openedWindows.Count > 0 && !isDialog) { ((Window)openedWindows.Pop()).Close(); } openedWindows.Push(tmpWindow); } Window newPageWindow = (Window)openedWindows.Peek(); TransitioningContentControl transitionContent = newPageWindow.FindName(windows[newWindowName].TransitionContentName) as TransitioningContentControl; if (windowParams != null) { ISwitchParams newPageWindowParams = newPageWindow as ISwitchParams; if (newPageWindowParams != null) { newPageWindowParams.onLoad(windowParams); } else { throw new NotImplementedException("ISwitchParams not implemented"); } } if (pageParams != null) { ISwitchParams newPageParams = pages[newPage].Page as ISwitchParams; if (newPageParams != null) { newPageParams.onLoad(windowParams); } else { throw new NotImplementedException("ISwitchParams not implemented"); } } if (transitionContent != null) { transitionContent.Transition = pages[newPage].TransitionType; transitionContent.DataContext = pages[newPage].Page.DataContext; transitionContent.Content = pages[newPage].Page.Content; activePage = newPage; } else { newPageWindow.Content = pages[newPage].Page.Content; newPageWindow.DataContext = pages[newPage].Page.DataContext; activePage = newPage; } if (activeWindow != newWindowName) { activeWindow = newWindowName; if (isDialog) { newPageWindow.ShowDialog(); //blocking openedWindows.Pop(); activeWindow = "HeaderWindow"; } else { newPageWindow.Show(); } } } catch (Exception e) { Console.WriteLine(e.Message); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); presenter = GetTemplateChild(PART_Presenter) as TransitioningContentControl; backButton = GetTemplateChild(PART_BackButton) as Button; forwardButton = GetTemplateChild(PART_ForwardButton) as Button; bannerGrid = GetTemplateChild(PART_BannerGrid) as Grid; bannerLabel = GetTemplateChild(PART_BannerLabel) as Label; }
void Current_Activated(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e) { DisplaySplash = false; DataContextManager.HandleActivated(); TransitionControl = new TransitioningContentControl(); }
private void initLeftMenu(List <T_SYS_ENTITYMENU> menulist) { #region 源代码备份 StackPanel menuTemp = new StackPanel(); menuTemp.Margin = new Thickness(0, 1, 0, 1); //leftMenu.MenuRoot.Children.Add(menuTemp); HyperlinkButton btnTest = new HyperlinkButton(); btnTest.Height = 22; btnTest.FontSize = 13.333; btnTest.FontWeight = FontWeights.Bold; btnTest.Content = " 动态菜单"; btnTest.Style = new Style(typeof(HyperlinkButton)); //Link3.NavigateUri=null; //btnTest.NavigateUri = new Uri("/SMT.SaaS.OA.UI;component/Views/Home.xaml", System.UriKind.Relative); //("//Home.xaml"); //btnTest.TargetName = "contenxtPanle"; btnTest.Click += new RoutedEventHandler(delegate { ContentFrame.Navigate(new Uri("/TravelapplicationPage", UriKind.Relative)); }); menuTemp.Children.Add(btnTest); //btnTest.Style = new Style(); #endregion if (toolkitacc.Items != null) { toolkitacc.Items.Clear(); } //生成分组 var groupItems = from m in menulist where m.T_SYS_ENTITYMENU2Reference.EntityKey == null orderby m.ORDERNUMBER select m; foreach (var item in groupItems) { AccordionItem group = new AccordionItem(); group.Header = item.MENUNAME; group.BorderThickness = new Thickness(0); group.Style = this.Resources["TreeMenuGroupStyle"] as Style; group.VerticalContentAlignment = VerticalAlignment.Stretch; group.HorizontalContentAlignment = HorizontalAlignment.Stretch; group.VerticalAlignment = VerticalAlignment.Stretch; group.HorizontalAlignment = HorizontalAlignment.Stretch; //生成菜单明细 var menuItems = from m in menulist where m.T_SYS_ENTITYMENU2Reference.EntityKey != null && m.T_SYS_ENTITYMENU2Reference.EntityKey.EntityKeyValues[0].Value.ToString() == item.ENTITYMENUID orderby m.ORDERNUMBER select m; TransitioningContentControl ctrl = new TransitioningContentControl(); StackPanel pnl = new StackPanel(); pnl.VerticalAlignment = VerticalAlignment.Stretch; pnl.HorizontalAlignment = HorizontalAlignment.Stretch; pnl.Margin = new Thickness(0, 6, 0, 0); TreeView tree = new TreeView(); tree.Style = Application.Current.Resources["TreeViewStyle"] as Style; tree.BorderThickness = new Thickness(0); tree.HorizontalAlignment = HorizontalAlignment.Stretch; tree.Width = toolkitacc.ActualWidth; foreach (var menu in menuItems) { TreeViewItem treeItem = CreateTreeItem(menu); treeItem.HeaderTemplate = this.Resources["TreeMenuItemStyle"] as DataTemplate; treeItem.Style = Application.Current.Resources["TreeViewItemStyle"] as Style; AddSubMenu(menulist, treeItem, menu); tree.Items.Add(treeItem); } ctrl.Content = tree; group.Content = ctrl; toolkitacc.Items.Add(group); } }
public virtual void ShouldWorkWithVisuals() { List<Rectangle> rectangles = new List<Rectangle> { new Rectangle { Height = 30, Width = 30, Fill = new SolidColorBrush(Colors.Red) }, new Rectangle { Height = 30, Width = 30, Fill = new SolidColorBrush(Colors.Green) }, new Rectangle { Height = 30, Width = 30, Fill = new SolidColorBrush(Colors.Blue) }, }; TransitioningContentControl tcc = new TransitioningContentControl(); bool tccIsLoaded = false; tcc.Loaded += delegate { tccIsLoaded = true; }; int count = 0; tcc.TransitionCompleted += (sender, e) => count++; EnqueueCallback(() => TestPanel.Children.Add(tcc)); EnqueueConditional(() => tccIsLoaded); EnqueueCallback(() => tcc.Content = rectangles[0]); EnqueueConditional(() => count == 1); EnqueueCallback(() => tcc.Content = rectangles[1]); EnqueueConditional(() => count == 2); EnqueueCallback(() => tcc.Content = rectangles[2]); EnqueueConditional(() => count == 3); EnqueueTestComplete(); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); showBannerStoryboard = ((Storyboard)this.Template.Resources["ShowBannerStoryboard"]).Clone(); hideBannerStoryboard = ((Storyboard)this.Template.Resources["HideBannerStoryboard"]).Clone(); showControlStoryboard = ((Storyboard)this.Template.Resources["ShowControlStoryboard"]).Clone(); hideControlStoryboard = ((Storyboard)this.Template.Resources["HideControlStoryboard"]).Clone(); presenter = GetTemplateChild(PART_Presenter) as TransitioningContentControl; backButton = GetTemplateChild(PART_BackButton) as Button; forwardButton = GetTemplateChild(PART_ForwardButton) as Button; upButton = GetTemplateChild(PART_UpButton) as Button; downButton = GetTemplateChild(PART_DownButton) as Button; bannerGrid = GetTemplateChild(PART_BannerGrid) as Grid; bannerLabel = GetTemplateChild(PART_BannerLabel) as Label; bannerLabel.Opacity = IsBannerEnabled ? 1.0 : 0.0; }
private void initLeftMenu(List <V_UserMenuPermission> menulist) { #region 源代码备份 //StackPanel menuTemp = new StackPanel(); //menuTemp.Margin = new Thickness(0, 1, 0, 1); //leftMenu.MenuRoot.Children.Add(menuTemp); //HyperlinkButton btnTest = new HyperlinkButton(); //btnTest.Height = 22; //btnTest.FontSize = 13.333; //btnTest.FontWeight = FontWeights.Bold; //btnTest.Content = " 动态菜单"; //btnTest.Style = new Style(typeof(HyperlinkButton)); //Link3.NavigateUri=null; //btnTest.NavigateUri = new Uri("/SMT.SaaS.OA.UI;component/Views/Home.xaml", System.UriKind.Relative); //("//Home.xaml"); //btnTest.TargetName = "contenxtPanle"; //btnTest.Click += new RoutedEventHandler(delegate //{ // ContentFrame.Navigate(new Uri("/Home", UriKind.Relative)); //}); //menuTemp.Children.Add(btnTest); //btnTest.Style = new Style(); #endregion if (toolkitacc.Items != null) { toolkitacc.Items.Clear(); } //生成分组 var groupItems = from m in menulist where string.IsNullOrEmpty(m.EntityMenuFatherID) orderby m.ORDERNUMBER select m; foreach (var item in groupItems) { AccordionItem group = new AccordionItem(); group.Header = item; group.Style = this.Resources["TreeMenuGroupStyle"] as Style; group.BorderThickness = new Thickness(0); group.FontSize = 14.0; if (UIHelper._CurrentStyleCode_2 == 1) { group.Foreground = Application.Current.Resources["TextBBlue1"] as SolidColorBrush; } group.VerticalContentAlignment = VerticalAlignment.Stretch; group.HorizontalContentAlignment = HorizontalAlignment.Stretch; group.VerticalAlignment = VerticalAlignment.Stretch; group.HorizontalAlignment = HorizontalAlignment.Stretch; //生成菜单明细 var menuItems = from m in menulist where m.EntityMenuFatherID != null && m.EntityMenuFatherID == item.ENTITYMENUID orderby m.ORDERNUMBER select m; TransitioningContentControl ctrl = new TransitioningContentControl(); StackPanel pnl = new StackPanel(); pnl.VerticalAlignment = VerticalAlignment.Stretch; pnl.HorizontalAlignment = HorizontalAlignment.Stretch; pnl.Margin = new Thickness(0, 0, 0, 0); TreeView tree = new TreeView(); tree.Style = (Style)Application.Current.Resources["TreeViewStyle"]; tree.BorderThickness = new Thickness(0); tree.HorizontalAlignment = HorizontalAlignment.Stretch; tree.Width = toolkitacc.ActualWidth; tree.Margin = new Thickness(0); foreach (var menu in menuItems) { TreeViewItem treeItem = CreateTreeItem(menu); AddSubMenu(menulist, treeItem, menu); tree.Items.Add(treeItem); } ctrl.Content = tree; group.Content = ctrl; toolkitacc.Items.Add(group); } }