public void Canonicalize()
 {
     Microsoft.Windows.Design.Interaction.Selection selection = this.featureManager.Context.Items.GetValue <Microsoft.Windows.Design.Interaction.Selection>();
     if (selection == null || !Enumerable.Any <ISceneNodeModelItem>(Enumerable.OfType <ISceneNodeModelItem>((IEnumerable)selection.SelectedObjects), (Func <ISceneNodeModelItem, bool>)(item => item.SceneNode.DocumentNode.Marker == null)))
     {
         return;
     }
     this.UpdateSelection();
 }
 private void SetSelection(Microsoft.Windows.Design.Interaction.Selection selection)
 {
     if (this.settingSelection)
     {
         return;
     }
     try
     {
         this.settingSelection = true;
         this.featureManager.Context.Items.SetValue((ContextItem)selection);
     }
     finally
     {
         this.settingSelection = false;
     }
 }
 private void OnUserSelectionChanged(Microsoft.Windows.Design.Interaction.Selection selection)
 {
     if (this.settingSelection)
     {
         return;
     }
     try
     {
         this.settingSelection = true;
         using (SceneEditTransaction editTransaction = this.viewModel.CreateEditTransaction(StringTable.UndoUnitSetSelection))
         {
             List <SceneElement> list             = new List <SceneElement>();
             SceneElement        primarySelection = (SceneElement)null;
             foreach (ModelItem modelItem in selection.SelectedObjects)
             {
                 ISceneNodeModelItem sceneNodeModelItem = modelItem as ISceneNodeModelItem;
                 if (sceneNodeModelItem != null)
                 {
                     SceneElement sceneElement = sceneNodeModelItem.SceneNode as SceneElement;
                     if (sceneElement != null)
                     {
                         list.Add(sceneElement);
                         if (modelItem == selection.PrimarySelection)
                         {
                             primarySelection = sceneElement;
                         }
                     }
                 }
             }
             if (list.Count == 0)
             {
                 this.viewModel.ElementSelectionSet.Clear();
             }
             else
             {
                 this.viewModel.ElementSelectionSet.SetSelection((ICollection <SceneElement>)list, primarySelection);
             }
             editTransaction.Commit();
         }
     }
     finally
     {
         this.settingSelection = false;
     }
 }