/// <summary> /// Shows/Hides the Attribute Table /// </summary> /// <param name="visibility">Visibility to be set on the Attribute Table</param> public static void SetTableVisibility(Visibility visibility) { ContentControl container = MapApplication.Current.FindObjectInLayout(ControlNames.FEATUREDATAGRIDTABLECONTAINER) as ContentControl; if (container == null) { return; } if (container.Visibility != visibility) { Storyboard storyBoard = VisualStateManagerHelper.FindStoryboard(container, null, (visibility == Visibility.Visible) ? ControlNames.VISUAL_STATE_SHOW_CONTENTCONTROL : ControlNames.VISUAL_STATE_HIDE_CONTENTCONTROL, true); if (storyBoard != null) { //if animation was defined storyBoard.Begin(); } else { //otherwise simply show/hide using visibility container.Visibility = (container.Visibility == Visibility.Visible) ? Visibility.Collapsed : Visibility.Visible; } } }
public override void Execute(object parameter) { System.Windows.Controls.ContentControl container = MapApplication.Current.FindObjectInLayout(ControlNames.FEATUREDATAGRIDTABLECONTAINER) as ContentControl; if (container == null) { return; } Storyboard showStoryBoard; Storyboard hideStoryBoard; hideStoryBoard = VisualStateManagerHelper.FindStoryboard(container, null, ControlNames.VISUAL_STATE_HIDE_CONTENTCONTROL, true); showStoryBoard = VisualStateManagerHelper.FindStoryboard(container, null, ControlNames.VISUAL_STATE_SHOW_CONTENTCONTROL, true); if (showStoryBoard != null && hideStoryBoard != null) //if animation is defined { if (container.Visibility == Visibility.Collapsed && hideStoryBoard.GetCurrentState() != ClockState.Active) { showStoryBoard.Begin(); } else if (hideStoryBoard.GetCurrentState() == ClockState.Active) { // Account for the possibility that the hiding storyboard could be running hideStoryBoard.Stop(); showStoryBoard.Begin(); } else if (container.Visibility == Visibility.Visible && showStoryBoard.GetCurrentState() != ClockState.Active) { hideStoryBoard.Begin(); } else if (showStoryBoard.GetCurrentState() == ClockState.Active) { // Account for the possibility that the showing storyboard could be running showStoryBoard.Stop(); hideStoryBoard.Begin(); } } else { //otherwise simply show/hide using visibility container.Visibility = (container.Visibility == Visibility.Visible) ? Visibility.Collapsed : Visibility.Visible; } }
public override void Execute(object parameter) { if (tabControlAsControl == null) { tabControlAsControl = MapApplication.Current.FindObjectInLayout(_tabControlName) as Control; } // // Case one - the content control is hosted within a Tab Control (OOTB layouts) // if (tabControlAsControl is TabControl) { TabItem tab = null; TabControl tabControl = tabControlAsControl as TabControl; if (tabIndex == -1) { for (int i = 0; i < tabControl.Items.Count; i++) { tab = tabControl.Items[i] as TabItem; if (tab.Name == _tabName) { tabIndex = i; break; } } } if (tabIndex == -1) { throw new Exception(string.Format( ESRI.ArcGIS.Mapping.Controls.Resources.Strings.NotFoundInLayout, _tabName)); } tab = tabControl.Items[tabIndex] as TabItem; Storyboard visualStateStoryboard = null; Storyboard resourceStoryboard = null; bool show = false; bool useGoToState = false; if (tabControl.SelectedIndex != tabIndex || tabControlAsControl.Visibility == Visibility.Collapsed) { if (VisualStateManagerHelper.StateWellDefined(tabControl, ControlNames.VISUAL_STATE_SHOW_CONTENTCONTROL, true)) { useGoToState = true; } else { visualStateStoryboard = VisualStateManagerHelper.FindStoryboard(tabControl, null, ControlNames.VISUAL_STATE_SHOW_CONTENTCONTROL, true); } resourceStoryboard = findStoryboardIncludedInResources(ControlNames.VISUAL_STATE_SHOW_CONTENTCONTROL); show = true; } else { if (VisualStateManagerHelper.StateWellDefined(tabControl, ControlNames.VISUAL_STATE_HIDE_CONTENTCONTROL, true)) { useGoToState = true; } else { visualStateStoryboard = VisualStateManagerHelper.FindStoryboard(tabControl, null, ControlNames.VISUAL_STATE_HIDE_CONTENTCONTROL, true); } resourceStoryboard = findStoryboardIncludedInResources(ControlNames.VISUAL_STATE_HIDE_CONTENTCONTROL); } // // Hosted in tab: Case one - storyboard for showing/hiding the tab control has been specified // if (visualStateStoryboard != null || resourceStoryboard != null || useGoToState) { if (show) { tabControl.SelectedIndex = tabIndex; tab.Visibility = Visibility.Visible; } //for (int i = storyBoard.Children.Count - 1; i >= 0; i--)//set the target properties if missing //{ // var timeLine = storyBoard.Children[i]; // var timeLineTargetXName = Storyboard.GetTargetName(timeLine); // if (string.IsNullOrEmpty(timeLineTargetXName)) // { // Storyboard.SetTarget(timeLine, tabControl); // } //} //if (_currentlyExecutingAnimation != null) // _currentlyExecutingAnimation.Stop(); //_currentlyExecutingAnimation = visualStateStoryboard; if (useGoToState) { string showHideString = show ? ControlNames.VISUAL_STATE_SHOW_CONTENTCONTROL : ControlNames.VISUAL_STATE_HIDE_CONTENTCONTROL; string state = string.Format("{0}_{1}", tabControl.Name, showHideString); VisualStateHelper.GoToState(tabControl, true, state); } if (visualStateStoryboard != null) { visualStateStoryboard.Begin(); //if animation was defined } if (resourceStoryboard != null) { resourceStoryboard.Begin(); } } // // Hosted in tab: Case two - No animation for showing/hiding the tab control was specified, so simply show/hide via visibility // else { if (show) { tabControl.SelectedIndex = tabIndex; tab.Visibility = Visibility.Visible; tabControlAsControl.Visibility = Visibility.Visible; } else { tabControlAsControl.Visibility = Visibility.Collapsed; } } } // // Case two - the content control is hosted an accordion // else if (tabControlAsControl is Accordion) { AccordionItem tab = null; Accordion accordion = tabControlAsControl as Accordion; int index = -1; for (int i = 0; i < accordion.Items.Count; i++) { tab = accordion.Items[i] as AccordionItem; if (tab.Name == _tabName) { index = i; break; } } if (index == -1) { throw new Exception(string.Format( ESRI.ArcGIS.Mapping.Controls.Resources.Strings.NotFoundInLayout, _tabName)); } bool show = (accordion.SelectedIndex != index || accordion.Visibility == Visibility.Collapsed); accordion.SelectedIndex = index; if (show) { AccordionItem accItem = accordion.Items[index] as AccordionItem; accItem.Visibility = Visibility.Visible; tabControlAsControl.Visibility = Visibility.Visible; } else { tabControlAsControl.Visibility = Visibility.Collapsed; } } }
public override void Execute(object parameter) { if (container == null) { container = MapApplication.Current.FindObjectInLayout(_contentControlName) as ContentControl; if (container == null) { return; } } if (tabControlAsControl == null) { tabControlAsControl = MapApplication.Current.FindObjectInLayout(_tabControlName) as Control; } // // Case one - the content control is hosted within a Tab Control (OOTB layouts) // if (tabControlAsControl is TabControl) { TabItem tab = null; TabControl tabControl = tabControlAsControl as TabControl; if (tabIndex == -1) { for (int i = 0; i < tabControl.Items.Count; i++) { tab = tabControl.Items[i] as TabItem; if (tab.Name == _tabName) { tabIndex = i; break; } } } tab = tabControl.Items[tabIndex] as TabItem; Storyboard storyBoard; bool show = false; if (tabControl.SelectedIndex != tabIndex || tabControlAsControl.Visibility == Visibility.Collapsed) { storyBoard = VisualStateManagerHelper.FindStoryboard(tabControl, null, ControlNames.VISUAL_STATE_SHOW_CONTENTCONTROL, true); show = true; } else { storyBoard = VisualStateManagerHelper.FindStoryboard(tabControl, null, ControlNames.VISUAL_STATE_HIDE_CONTENTCONTROL, true); } // // Hosted in tab: Case one - storyboard for showing/hiding the tab control has been specified // if (storyBoard != null) { if (show) { tabControl.SelectedIndex = tabIndex; tab.Visibility = Visibility.Visible; } //for (int i = storyBoard.Children.Count - 1; i >= 0; i--)//set the target properties if missing //{ // var timeLine = storyBoard.Children[i]; // var timeLineTargetXName = Storyboard.GetTargetName(timeLine); // if (string.IsNullOrEmpty(timeLineTargetXName)) // { // Storyboard.SetTarget(timeLine, tabControl); // } //} //if (_currentlyExecutingAnimation != null) // _currentlyExecutingAnimation.Stop(); _currentlyExecutingAnimation = storyBoard; storyBoard.Begin(); //if animation was defined } // // Hosted in tab: Case two - No animation for showing/hiding the tab control was specified, so simply show/hide via visibility // else { if (show) { tabControl.SelectedIndex = tabIndex; tabControlAsControl.Visibility = Visibility.Visible; } else { tabControlAsControl.Visibility = Visibility.Collapsed; } } } // // Case two - the content control is hosted an accordion // else if (tabControlAsControl is Accordion) { AccordionItem tab = null; int index = -1; Accordion accordion = tabControlAsControl as Accordion; for (int i = 0; i < accordion.Items.Count; i++) { tab = accordion.Items[i] as AccordionItem; if (tab.Name == _tabName) { index = i; break; } } bool show = (accordion.SelectedIndex != index || accordion.Visibility == Visibility.Collapsed); accordion.SelectedIndex = index; if (show) { AccordionItem accItem = accordion.Items[index] as AccordionItem; accItem.Visibility = Visibility.Visible; tabControlAsControl.Visibility = Visibility.Visible; } else { tabControlAsControl.Visibility = Visibility.Collapsed; } } // // Case three - the content control is hosted elsewhere (Custom Layout) // else { Storyboard storyBoard; if (container.Visibility == Visibility.Visible) { storyBoard = VisualStateManagerHelper.FindStoryboard(container, null, ControlNames.VISUAL_STATE_HIDE_CONTENTCONTROL, true); } else { storyBoard = VisualStateManagerHelper.FindStoryboard(container, null, ControlNames.VISUAL_STATE_SHOW_CONTENTCONTROL, true); } // // Hosted elsewhere: Case one - storyboard for showing/hiding the tab control has been specified // if (storyBoard != null) { if (_currentlyExecutingAnimation != null) { _currentlyExecutingAnimation.Stop(); } _currentlyExecutingAnimation = storyBoard; storyBoard.Begin(); //if animation was defined } // // Hosted elsewhere: Case two - No animation for showing/hiding the tab control was specified, so simply show/hide via visibility // else { container.Visibility = (container.Visibility == Visibility.Visible) ? Visibility.Collapsed : Visibility.Visible; } if (container.Visibility == Visibility.Visible) { SidePanelHelper.EnsureSidePanelVisibility(); } } }