Пример #1
0
 private void OnSharedDataChanged(object sender, WritableSharedDataChangedEventArgs e)
 {
     if (this.Changed != null)
     {
         this.Changed(this, e);
     }
 }
Пример #2
0
 internal void OnNodeSharedDataChanged(object sender, WritableSharedDataChangedEventArgs e)
 {
     if (!this._initialized)
     {
         throw new Exception(Microsoft.ManagementConsole.Internal.Utility.LoadResourceString(Microsoft.ManagementConsole.Internal.Strings.NodeSyncManagerNotInitialized));
     }
     ScopeNode node = sender as ScopeNode;
     if (node == null)
     {
         throw new ArgumentException(Microsoft.ManagementConsole.Internal.Utility.LoadResourceString(Microsoft.ManagementConsole.Internal.Strings.NodeSyncManagerOnNodeSharedDataChangedScopeNodeExpected), "sender");
     }
     WritableSharedDataItem sharedDataItem = e.SharedDataItem;
     if (sharedDataItem == null)
     {
         throw new Exception(Microsoft.ManagementConsole.Internal.Utility.LoadResourceString(Microsoft.ManagementConsole.Internal.Strings.NodeSyncManagerOnNodeSharedDataChangedWritableSharedDataItemExpected));
     }
     bool flag = false;
     UpdateScopeNodeCommand command = new UpdateScopeNodeCommand();
     command.NodeData = (ScopeNodeData) node.Data;
     ActionsPaneRootData data = new ActionsPaneRootData();
     data.Write(node.ActionsPaneItems.Data);
     command.Actions = data;
     data = new ActionsPaneRootData();
     data.Write(node.ActionsPaneHelpItems.Data);
     command.HelpActions = data;
     switch (e.ChangeType)
     {
         case WritableSharedDataChangeType.Add:
         case WritableSharedDataChangeType.Modify:
         {
             DataFormatConfiguration configuration = new DataFormatConfiguration();
             configuration.ClipboardFormatId = sharedDataItem.ClipboardFormatId;
             configuration.RequiresQuery = sharedDataItem.RequiresCallback;
             SharedDataObjectUpdate update = new SharedDataObjectUpdate();
             if (!sharedDataItem.RequiresCallback)
             {
                 ClipboardData data2 = new ClipboardData();
                 data2.ClipboardFormatId = sharedDataItem.ClipboardFormatId;
                 data2.SetValue(sharedDataItem.GetData());
                 ClipboardData[] updatedData = new ClipboardData[] { data2 };
                 update.SetUpdatedData(updatedData);
             }
             command.UpdatedSharedData = update;
             if (e.ChangeType == WritableSharedDataChangeType.Add)
             {
                 DataFormatConfiguration[] addedFormats = new DataFormatConfiguration[] { configuration };
                 command.UpdatedSharedData.SetAddedFormats(addedFormats);
             }
             else
             {
                 DataFormatConfiguration[] changedFormats = new DataFormatConfiguration[] { configuration };
                 command.UpdatedSharedData.SetChangedFormats(changedFormats);
             }
             flag = true;
             break;
         }
         case WritableSharedDataChangeType.Remove:
             command.UpdatedSharedData.SetRemovedClipboardFormatIds(new string[] { sharedDataItem.ClipboardFormatId });
             flag = true;
             break;
     }
     if (flag)
     {
         this._snapInPlatform.ProcessCommand(command);
     }
 }
Пример #3
0
        private void OnSharedDataChanged(object source, WritableSharedDataChangedEventArgs e)
        {
            if (this._view.Shutdown)
            {
                TraceSources.ExecutiveSource.TraceEvent(TraceEventType.Warning, 12, "Ignoring published data changes since view has been shutdown.");
            }
            else
            {
                WritableSharedDataItem[] itemArray = new WritableSharedDataItem[0];
                WritableSharedDataItem[] addedItems = itemArray;
                WritableSharedDataItem[] modifiedItems = itemArray;
                WritableSharedDataItem[] removedItems = itemArray;
                switch (e.ChangeType)
                {
                    case WritableSharedDataChangeType.Add:
                        addedItems = new WritableSharedDataItem[] { e.SharedDataItem };
                        break;

                    case WritableSharedDataChangeType.Remove:
                        removedItems = new WritableSharedDataItem[] { e.SharedDataItem };
                        break;

                    case WritableSharedDataChangeType.Modify:
                        modifiedItems = new WritableSharedDataItem[] { e.SharedDataItem };
                        break;
                }
                if (this._view.Initialized)
                {
                    this._view.OnSharedDataChanged(addedItems, modifiedItems, removedItems);
                }
            }
        }