示例#1
0
   //==========================================================================

   /// <summary>
   /// Switches the mode, layout, sorter and filter of a TreeView defined by 
   /// the given preset.
   /// </summary>
   /// <param name="start">If true, the new TreeMode will be started.</param>
   public TreeMode SwitchPreset(TreeView tree, OutlinerPreset preset, Boolean start)
   {
      Throw.IfNull(tree, "tree");
      Throw.IfNull(preset, "preset");

      TreeMode oldMode = this.GetActiveTreeMode(tree);
      if (oldMode != null)
      {
         oldMode.Stop();
         this.UnRegisterTreeMode(oldMode);
      }

      this.currentPresets.Remove(tree);
      this.currentPresets.Add(tree, preset);

      tree.TreeNodeLayout = preset.TreeNodeLayout;
      tree.NodeSorter = preset.Sorter;
      tree.Settings.DragDropMouseButton = Configuration.TreeView.DragDropMouseButton;
      tree.Settings.DoubleClickAction = Configuration.TreeView.DoubleClickAction;
      tree.Settings.ScrollToSelection = Configuration.TreeView.ScrollToSelection;
      tree.Settings.AutoExpandSelectionParents = Configuration.TreeView.AutoExpandSelectionParents;
      tree.Settings.CollapseAutoExpandedParents = Configuration.TreeView.CollapseAutoExpandedParents;

      TreeMode newMode = preset.CreateTreeMode(tree);

      this.RegisterTreeMode(tree, newMode);

      newMode.AddPermanentFilter(this.CommonNameFilter);

      if (start)
         newMode.Start();

      return newMode;
   }
 public PresetPropertiesEditor(OutlinerPreset preset) : this()
 {
    this.preset = preset;
 }