Exemplo n.º 1
0
 public void SelectModule(ModuleObject module)
 {
     if( module == null )
     {
         ContentControl.Content = null;
         SelectedModule = null;
     }
     else
     {
         var control = module.ContentControl;
         ContentControl.Content = control;
         control.Width = double.NaN;
         control.Height = double.NaN;
         control.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
         control.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
         SelectedModule = module;
     }
 }
Exemplo n.º 2
0
        private void Module_IsAvailableChanged(ModuleObject module)
        {
            if( module.IsAvailable )
            {
                int insertIndex;
                if( AvailableModulesList.Count == 0 )
                {
                    // Will be the only one in the list
                    insertIndex = 0;
                }
                else
                {
                    int indexInAll = AllModulesList.IndexOf( module );
                    System.Diagnostics.Debug.Assert( indexInAll >= 0, "The specified module is not in the AllModulesList" );

                    // Search for the visible module before
                    for( int i=indexInAll-1; i>=0; --i )
                    {
                        if( AllModulesList[i].IsAvailable )
                        {
                            insertIndex = AvailableModulesList.IndexOf( AllModulesList[i] ) + 1;
                            System.Diagnostics.Debug.Assert( insertIndex >= 0, "The visible module before has not been found in AvailableModulesList" );
                            goto InsertIndexFound;
                        }
                    }

                    // Search for the visible module after
                    for( int i=indexInAll+1; i<AllModulesList.Count; ++i )
                    {
                        if( AllModulesList[i].IsAvailable )
                        {
                            insertIndex = AvailableModulesList.IndexOf( AllModulesList[i] );
                            System.Diagnostics.Debug.Assert( insertIndex >= 0, "The visible module before has not been found in AvailableModulesList" );
                            goto InsertIndexFound;
                        }
                    }

                    throw new ApplicationException( "Could not find the insertIndex in the available module list" );
                }
            InsertIndexFound:
                System.Diagnostics.Debug.Assert( insertIndex >= 0, "Invalid value for insertIndex" );
                AvailableModulesList.Insert( insertIndex, module );
            }
            else  // module is not visible
            {
                AvailableModulesList.Remove( module );
            }
        }