コード例 #1
0
        private void selectionService_SelectionChanged(object sender, EventArgs e)
        {
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <ExchangeFormView>(0L, "-->ExchangeFormView.SelectionChanged: {0}", this);
            this.DelayUpdates();
            SelectedObjects    selectedObjects     = new SelectedObjects(this.selectionService.GetSelectedComponents());
            DataObject         selectionDataObject = this.ResultPane.SelectionDataObject;
            WritableSharedData writableSharedData  = new WritableSharedData();
            UnicodeEncoding    unicodeEncoding     = new UnicodeEncoding();

            foreach (string text in selectionDataObject.GetFormats())
            {
                object data = selectionDataObject.GetData(text);
                if (data is string)
                {
                    WritableSharedDataItem writableSharedDataItem = new WritableSharedDataItem(text, false);
                    writableSharedDataItem.SetData(unicodeEncoding.GetBytes(data as string));
                    writableSharedData.Add(writableSharedDataItem);
                    ExTraceGlobals.DataFlowTracer.Information <string, object>(0L, "ExchangeFormView.SelectionChanged: shared data: {0} => {1}", text, data);
                }
                else
                {
                    ExTraceGlobals.DataFlowTracer.Information <string, object>(0L, "ExchangeFormView.SelectionChanged: {0}:{1} is not published to MMC because it is not a string.", text, data);
                }
            }
            if (selectedObjects.Count > 0)
            {
                ExTraceGlobals.DataFlowTracer.Information <int>(0L, "ExchangeFormView.SelectionChanged: selectedComponents.Count:{0}", selectedObjects.Count);
                base.SelectionData.Update(selectedObjects, selectedObjects.Count > 1, ExchangeFormView.emptyGuidArray, writableSharedData);
                base.SelectionData.DisplayName = selectionDataObject.GetText();
                ExTraceGlobals.DataFlowTracer.Information <string>(0L, "ExchangeFormView.SelectionChanged: this.SelectionData.DisplayName:{0}", base.SelectionData.DisplayName);
                base.SelectionData.Description = (selectionDataObject.GetData("Description") as string);
                ExTraceGlobals.DataFlowTracer.Information <string>(0L, "ExchangeFormView.SelectionChanged: this.SelectionData.Description:{0}", base.SelectionData.Description);
                base.SelectionData.HelpTopic = (string.IsNullOrEmpty(this.ResultPane.SelectionHelpTopic) ? base.ScopeNode.HelpTopic : this.ResultPane.SelectionHelpTopic);
                ExTraceGlobals.DataFlowTracer.Information <string>(0L, "ExchangeFormView.SelectionChanged: this.SelectionData.HelpTopic:{0}", base.SelectionData.HelpTopic);
            }
            else
            {
                ExTraceGlobals.DataFlowTracer.Information(0L, "ExchangeFormView.SelectionChanged: clearing selection.");
                base.SelectionData.Clear();
                base.SelectionData.HelpTopic = base.ScopeNode.HelpTopic;
            }
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <ExchangeFormView>(0L, "<--ExchangeFormView.SelectionChanged: {0}", this);
        }