2013-01-21 3 views
1

도킹 관리자로 Avalon Dock 2.0을 사용하는 WPF 응용 프로그램이 있습니다. Avalon Dock이 실행중인 새로운 열린 탭의 표준 배치에 관한 문제에 직면하고 있습니다.Avalondock 새 탭 배치 및 순서

모든 탭이 탭 표시 줄에 들어가면 새 탭이 탭 표시 줄의 가장 오른쪽에 추가됩니다. 새 탭이 막대에 맞지 않으면 맨 왼쪽에 새 탭이 추가되어 맨 오른쪽 탭이 사라집니다.

저는 Visual Studio 표준 동작을 알고 있지만 제 응용 프로그램에서는 그 의미가 있습니다. 즉, 항상 새 탭을 가장 왼쪽 또는 가장 오른쪽에 추가해야합니다. 스위치가 사용자에게 매우 혼란 스럽습니다.

Avalon Dock에서 항상 맨 왼쪽 또는 오른쪽 위치에 새 탭을 추가 할 수있는 방법이 있습니까?

+0

비슷한 문제가 아무도 없습니까 : 여기

코드인가? :( –

답변

2

나는 그것을 알아 냈다. 현재 탭을 첫 번째 위치로 재배치하지 못하도록 DocumentPaneTabPanel에서 ArrangeOverride (Size finalSize) 메서드의 코드를 변경했습니다.

이제 패널에 맞지 않는 현재 왼쪽의 탭을 숨 깁니다. 가장 왼쪽의 탭을 먼저 숨 깁니다. 현재 탭의 오른쪽에있는 탭이 숨겨져 있습니다. 가장 오른쪽의 탭이 먼저 숨겨집니다. 오버플로가 있으면 현재 탭이 항상 패널의 가장 오른쪽에 있습니다. 이것은 조금 더러운 순간이지만 더 나은 방법으로 이것을 구현하는 것이 그렇게 어렵지는 않을 것이라고 생각합니다.

protected override Size ArrangeOverride(Size finalSize) 
    { 
     double offset = 0.0; 
     var children = Children.Cast<UIElement>().Where(ch => ch.Visibility != System.Windows.Visibility.Collapsed).ToList(); 
     if (children.Count > 0) 
     { 
      //find currently selected tab 
      int i = 0; 
      for (i = 0; i < children.Count(); i++) 
      { 
       TabItem doc = (TabItem)children[i]; 
       var layoutContent = doc.Content as LayoutContent; 
       if (layoutContent.IsSelected) 
        break; 
      } 

      //calculate how many tabs left from the currently selected would fit in the panel 
      int cur_ind = i; 
      TabItem current_item = (TabItem)children[cur_ind]; 
      List<TabItem> t_to_display = new List<TabItem>(); 
      while (cur_ind >= 0 && offset + current_item.DesiredSize.Width <= finalSize.Width) 
      { 
       current_item = (TabItem)children[cur_ind]; 
       current_item.Visibility = System.Windows.Visibility.Visible; 
       offset += current_item.DesiredSize.Width + current_item.Margin.Left + current_item.Margin.Right; 
       t_to_display.Add(current_item); 
       --cur_ind; 
      } 

      //arrange the fitting tabs on the left 
      double cur_offset = offset; 
      foreach (TabItem t in t_to_display) 
      { 
       cur_offset -= t.DesiredSize.Width + t.Margin.Left + t.Margin.Right; 
       t.Arrange(new Rect(cur_offset, 0.0, t.DesiredSize.Width, finalSize.Height)); 
      } 

      //arrange the tabs on the right 
      cur_ind = i + 1; 
      while (cur_ind < children.Count && offset + current_item.DesiredSize.Width <= finalSize.Width) 
      { 
       current_item = (TabItem)children[cur_ind]; 
       current_item.Visibility = System.Windows.Visibility.Visible; 
       current_item.Arrange(new Rect(offset, 0.0, current_item.DesiredSize.Width, finalSize.Height)); 
       offset += current_item.DesiredSize.Width + current_item.Margin.Left + current_item.Margin.Right; 
       cur_ind++; 
      } 

      while(cur_ind < children.Count) 
      { 
       current_item = (TabItem)children[cur_ind]; 
       current_item.Visibility = System.Windows.Visibility.Hidden; 
       cur_ind++; 
      } 
     } 

     return finalSize; 

    }