コード例 #1
0
        /// <summary>
        ///  Sinks or unsinks selection and component change events from the
        ///  provided service provider.  We need to raise global selection change
        ///  notifications.  A global selection change should be raised whenever
        ///  the selection of the active designer changes, whenever a component
        ///  is added or removed from the active designer, or whenever the
        ///  active designer itself changes.
        /// </summary>
        private void SinkChangeEvents(IServiceProvider provider, bool sink)
        {
            ISelectionService       ss   = provider.GetService(typeof(ISelectionService)) as ISelectionService;
            IComponentChangeService cs   = provider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
            IDesignerHost           host = provider.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (sink)
            {
                if (ss is not null)
                {
                    ss.SelectionChanged += new EventHandler(OnSelectionChanged);
                }

                if (cs is not null)
                {
                    ComponentEventHandler ce = new ComponentEventHandler(OnComponentAddedRemoved);
                    cs.ComponentAdded   += ce;
                    cs.ComponentRemoved += ce;
                    cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
                }

                if (host is not null)
                {
                    host.TransactionOpened += new EventHandler(OnTransactionOpened);
                    host.TransactionClosed += new DesignerTransactionCloseEventHandler(OnTransactionClosed);
                    host.LoadComplete      += new EventHandler(OnLoadComplete);
                    if (host.InTransaction)
                    {
                        OnTransactionOpened(host, EventArgs.Empty);
                    }
                }
            }
            else
            {
                if (ss is not null)
                {
                    ss.SelectionChanged -= new EventHandler(OnSelectionChanged);
                }

                if (cs is not null)
                {
                    ComponentEventHandler ce = new ComponentEventHandler(OnComponentAddedRemoved);
                    cs.ComponentAdded   -= ce;
                    cs.ComponentRemoved -= ce;
                    cs.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged);
                }

                if (host is not null)
                {
                    host.TransactionOpened -= new EventHandler(OnTransactionOpened);
                    host.TransactionClosed -= new DesignerTransactionCloseEventHandler(OnTransactionClosed);
                    host.LoadComplete      -= new EventHandler(OnLoadComplete);
                    if (host.InTransaction)
                    {
                        OnTransactionClosed(host, new DesignerTransactionCloseEventArgs(false, true));
                    }
                }
            }
        }
コード例 #2
0
 public void SubscribeLocalEvent <TComp, TEvent>(
     ComponentEventHandler <TComp, TEvent> handler,
     Type[]?before = null, Type[]?after = null)
     where TComp : IComponent
     where TEvent : EntityEventArgs
 {
     System.SubscribeLocalEvent(handler, before, after);
 }
コード例 #3
0
        protected void SubscribeLocalEvent <TComp, TEvent>(ComponentEventHandler <TComp, TEvent> handler)
            where TComp : IComponent
            where TEvent : EntityEventArgs
        {
            EntityManager.EventBus.SubscribeLocalEvent(handler);

            _subscriptions ??= new();
            _subscriptions.Add(new SubLocal <TComp, TEvent>());
        }
コード例 #4
0
ファイル: Location.cs プロジェクト: qmhoang/SKR
        public void OnMapChanged(EventArgs <Level> e)
        {
            ComponentEventHandler <EventArgs <Level> > handler = MapChanged;

            if (handler != null)
            {
                handler(this, e);
            }
        }
コード例 #5
0
ファイル: Location.cs プロジェクト: qmhoang/SKR
        public void OnPositionChanged(PositionChangedEvent e)
        {
            ComponentEventHandler <PositionChangedEvent> handler = PositionChanged;

            if (handler != null)
            {
                handler(this, e);
            }
        }
コード例 #6
0
        /// <inheritdoc />
        public void SubscribeLocalEvent <TComp, TEvent>(ComponentEventHandler <TComp, TEvent> handler)
            where TComp : IComponent
            where TEvent : EntityEventArgs
        {
            void EventHandler(EntityUid uid, IComponent comp, EntityEventArgs args)
            => handler(uid, (TComp)comp, (TEvent)args);

            _eventTables.Subscribe(typeof(TComp), typeof(TEvent), EventHandler);
        }
コード例 #7
0
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// componenteventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this ComponentEventHandler componenteventhandler, Object sender, ComponentEventArgs e, AsyncCallback callback)
        {
            if (componenteventhandler == null)
            {
                throw new ArgumentNullException("componenteventhandler");
            }

            return(componenteventhandler.BeginInvoke(sender, e, callback, null));
        }
コード例 #8
0
        public ComponentEventHandler EditResponsor(GameObject context, ComponentEventHandler responsor, Action callback)
        {
            if (responsor == null)
            {
                return(new ComponentEventHandler());
            }
            EditorUtilities.Verticle(() =>
            {
                if (GUILayout.Button($"{responsor.ComponentName}/{responsor.MethodName}", "TextField"))
                {
                    EditorUtilities.PopupMenu(context.GetComponents <Component>()
                                              .Select(component => new PopupMenuItem()
                    {
                        Name     = component.GetType().Name,
                        Children = component.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public)
                                   .Where(m => !m.IsSpecialName)
                                   .Select(method => new PopupMenuItem(method.Name))
                                   .ToArray()
                    }).ToArray(), $"{responsor.ComponentName}/{responsor.MethodName}", (selected) =>
                    {
                        responsor.ComponentName = selected.Split('/')[0];
                        responsor.MethodName    = selected.Split('/')[1];
                        callback();
                    });
                }
            });

            /*
             * EditorGUILayout.BeginHorizontal();
             * var components = context.GetComponents<Component>()
             *  .Select(cpn => cpn.GetType().Name)
             *  .ToList();
             * var idx = EditorGUILayout.Popup(components.IndexOf(responsor.ComponentName), components.ToArray());
             * if (idx < 0)
             *  responsor.ComponentName = "";
             * else
             *  responsor.ComponentName = components[idx];
             * var component = context.GetComponent(responsor.ComponentName);
             * if (component == null)
             * {
             *  EditorGUILayout.Popup(-1, new string[] { });
             *  goto End;
             * }
             * var methods = component.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public)
             *  .Where(m => !m.IsSpecialName)
             *  .Select(m => m.Name)
             *  .ToList();
             * idx = EditorGUILayout.Popup(methods.IndexOf(responsor.MethodName), methods.ToArray());
             * if (idx < 0)
             *  responsor.MethodName = "";
             * else
             *  responsor.MethodName = methods[idx];
             * End:
             * EditorGUILayout.EndHorizontal();*/
            return(responsor);
        }
コード例 #9
0
        private void SinkChangeEvents(IServiceProvider provider, bool sink)
        {
            ISelectionService       service  = provider.GetService(typeof(ISelectionService)) as ISelectionService;
            IComponentChangeService service2 = provider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
            IDesignerHost           sender   = provider.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (sink)
            {
                if (service != null)
                {
                    service.SelectionChanged += new EventHandler(this.OnSelectionChanged);
                }
                if (service2 != null)
                {
                    ComponentEventHandler handler = new ComponentEventHandler(this.OnComponentAddedRemoved);
                    service2.ComponentAdded   += handler;
                    service2.ComponentRemoved += handler;
                    service2.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
                }
                if (sender != null)
                {
                    sender.TransactionOpened += new EventHandler(this.OnTransactionOpened);
                    sender.TransactionClosed += new DesignerTransactionCloseEventHandler(this.OnTransactionClosed);
                    sender.LoadComplete      += new EventHandler(this.OnLoadComplete);
                    if (sender.InTransaction)
                    {
                        this.OnTransactionOpened(sender, EventArgs.Empty);
                    }
                }
            }
            else
            {
                if (service != null)
                {
                    service.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
                }
                if (service2 != null)
                {
                    ComponentEventHandler handler2 = new ComponentEventHandler(this.OnComponentAddedRemoved);
                    service2.ComponentAdded   -= handler2;
                    service2.ComponentRemoved -= handler2;
                    service2.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
                }
                if (sender != null)
                {
                    sender.TransactionOpened -= new EventHandler(this.OnTransactionOpened);
                    sender.TransactionClosed -= new DesignerTransactionCloseEventHandler(this.OnTransactionClosed);
                    sender.LoadComplete      -= new EventHandler(this.OnLoadComplete);
                    if (sender.InTransaction)
                    {
                        this.OnTransactionClosed(sender, new DesignerTransactionCloseEventArgs(false, true));
                    }
                }
            }
        }
コード例 #10
0
        protected void SubscribeLocalEvent <TComp, TEvent>(
            ComponentEventHandler <TComp, TEvent> handler,
            Type[]?before = null, Type[]?after = null)
            where TComp : IComponent
            where TEvent : notnull
        {
            EntityManager.EventBus.SubscribeLocalEvent(handler, GetType(), before, after);

            _subscriptions ??= new();
            _subscriptions.Add(new SubLocal <TComp, TEvent>());
        }
コード例 #11
0
        public void SubscribeLocalEvent <TComp, TEvent>(
            ComponentEventHandler <TComp, TEvent> handler,
            Type orderType,
            Type[]?before = null,
            Type[]?after  = null)
            where TComp : IComponent
            where TEvent : EntityEventArgs
        {
            void EventHandler(EntityUid uid, IComponent comp, EntityEventArgs args)
            => handler(uid, (TComp)comp, (TEvent)args);

            var orderData = new OrderingData(orderType, before, after);

            _eventTables.Subscribe(typeof(TComp), typeof(TEvent), EventHandler, orderData);
            HandleOrderRegistration(typeof(TEvent), orderData);
        }
コード例 #12
0
        /// <include file='doc\ReferenceService.uex' path='docs/doc[@for="ReferenceService.ReferenceService"]/*' />
        /// <devdoc>
        ///     Constructs the ReferenceService.
        /// </devdoc>
        public ReferenceService(IDesignerHost host, bool ignoreCase)
        {
            this.host         = host;
            this.ignoreCase   = ignoreCase;
            onComponentAdd    = new ComponentEventHandler(OnComponentAdd);
            onComponentRemove = new ComponentEventHandler(OnComponentRemove);
            onComponentRename = new ComponentRenameEventHandler(OnComponentRename);
            referenceList     = new ArrayList();

            IComponentChangeService changeService = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));

            Debug.Assert(changeService != null, "If we can't get a change service, how are we ever going to update references...");
            if (changeService != null)
            {
                changeService.ComponentAdded   += onComponentAdd;
                changeService.ComponentRemoved += onComponentRemove;
                changeService.ComponentRename  += onComponentRename;
            }
        }
コード例 #13
0
		/// <summary>
		/// Called by the framework when the designer is being initialized with the designed control
		/// </summary>
		/// <param name="component"></param>
		public override void Initialize(IComponent component)
		{
			base.Initialize(component);

			if (Control is TreeView)
			{
				try
				{
					m_oSelectionService = (ISelectionService) GetService(typeof (ISelectionService));
				}
				catch
				{
				}
				try
				{
					m_oSelectionService.SelectionChanged += new EventHandler(this.OnSelectionServiceChanged);
				}
				catch
				{
				}
				try
				{
					m_oDesignerHost = (IDesignerHost) GetService(typeof (IDesignerHost));
				}
				catch
				{
				}
				try
				{
					m_oMenuService = (IMenuCommandService) GetService(typeof (IMenuCommandService));
				}
				catch
				{
				}
				try
				{
					m_oDesignerSerializationService = (IDesignerSerializationService) GetService(typeof (IDesignerSerializationService));
				}
				catch
				{
				}
				try
				{
					m_oToolboxService = (IToolboxService) GetService(typeof (IToolboxService));
				}
				catch
				{
				}
				try
				{
					m_oUIService = (IUIService) GetService(typeof (IUIService));
				}
				catch
				{
				}
				try
				{
					m_oComponentChangeService = (IComponentChangeService) GetService(typeof (IComponentChangeService));
				}
				catch
				{
				}

				m_oTreeView = (TreeView) Control;
				m_oTreeView.m_bFocus = true;
				m_oTreeView.ClearAllSelection();
				m_oTreeView.DesignerHost = m_oDesignerHost;
				m_oTreeView.IsDesignMode = true;

				if (m_bFirstTime == true)
				{
					OnComponentCreated(m_oTreeView);
					m_bFirstTime = false;
				}

				try
				{
					m_oComponentAddedHandler = new ComponentEventHandler(this.OnComponentAdded);
				}
				catch
				{
				}
				try
				{
					m_oComponentRemovingHandler = new ComponentEventHandler(this.OnComponentRemoving);
				}
				catch
				{
				}
				try
				{
					m_oComponentChangeService.ComponentAdded += m_oComponentAddedHandler;
				}
				catch
				{
				}
				try
				{
					m_oComponentChangeService.ComponentRemoving += m_oComponentRemovingHandler;
				}
				catch
				{
				}
				try
				{
					m_oNodeParentChanged = new EventHandler(this.OnNodeParentChanged);
				}
				catch
				{
				}

				try
				{
					m_oOldCmdCopy = m_oMenuService.FindCommand(StandardCommands.Copy);
				}
				catch
				{
				}
				try
				{
					m_oOldCmdPaste = m_oMenuService.FindCommand(StandardCommands.Paste);
				}
				catch
				{
				}
				try
				{
					m_oOldCmdCut = m_oMenuService.FindCommand(StandardCommands.Cut);
				}
				catch
				{
				}
				try
				{
					m_oOldBringFront = m_oMenuService.FindCommand(StandardCommands.BringToFront);
				}
				catch
				{
				}
				try
				{
					m_oOldSendBack = m_oMenuService.FindCommand(StandardCommands.SendToBack);
				}
				catch
				{
				}
				try
				{
					m_oOldAlignGrid = m_oMenuService.FindCommand(StandardCommands.AlignToGrid);
				}
				catch
				{
				}
				try
				{
					m_oOldLockControls = m_oMenuService.FindCommand(StandardCommands.LockControls);
				}
				catch
				{
				}
				try
				{
					m_oOldDelete = m_oMenuService.FindCommand(StandardCommands.Delete);
				}
				catch
				{
				}

				try
				{
					m_oNewCmdCopy = new MenuCommand(new EventHandler(this.OnMenuCopy), StandardCommands.Copy);
				}
				catch
				{
				}
				try
				{
					m_oNewCmdPaste = new MenuCommand(new EventHandler(this.OnMenuPaste), StandardCommands.Paste);
				}
				catch
				{
				}

				if (TreeViewDesigner.MenuAdded == false)
				{
					try
					{
						m_oMenuService.RemoveCommand(m_oOldCmdCopy);
					}
					catch
					{
					}
					try
					{
						m_oMenuService.RemoveCommand(m_oOldCmdPaste);
					}
					catch
					{
					}
					try
					{
						m_oMenuService.AddCommand(m_oNewCmdCopy);
					}
					catch
					{
					}
					try
					{
						m_oMenuService.AddCommand(m_oNewCmdPaste);
					}
					catch
					{
					}

					TreeViewDesigner.MenuAdded = true;
				}

				m_oTreeView.Invalidate();

				#region action menus

				#region node menu

				m_oActionMenuNode = new ActionMenuNative();
				m_oActionMenuNode.Width = 170;
				m_oActionMenuNode.Title = "Node Action Menu";

				ActionMenuGroup oMenuGroup = m_oActionMenuNode.AddMenuGroup("Editing");
				oMenuGroup.Expanded = true;
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Add Node");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Delete Node");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Add Panel");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Clear Content");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Delete TreeView");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Copy");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Paste");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Properties");
				oMenuGroup = m_oActionMenuNode.AddMenuGroup("Arranging");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Expand");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Collapse");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Top");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Bottom");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Up");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Down");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Left");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Right");
				oMenuGroup = m_oActionMenuNode.AddMenuGroup("Color Schemes");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Default");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Forest");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Gold");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Ocean");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Rose");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Silver");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Sky");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Sunset");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Wood");

				m_oActionMenuNode.ItemClick += new ActionMenuNative.ItemClickEventHandler(this.OnActionMenuNodeItemClicked);

				#endregion			

				#region TreeView menu

				m_oActionMenuTreeView = new ActionMenuNative();
				m_oActionMenuTreeView.Width = 170;
				m_oActionMenuTreeView.Title = "TreeView Action Menu";

				oMenuGroup = m_oActionMenuTreeView.AddMenuGroup("Editing");
				oMenuGroup.Expanded = true;
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Add Node");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Color Scheme Picker...");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Clear Content");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Delete TreeView");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Copy");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Paste");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Properties");
				oMenuGroup = m_oActionMenuTreeView.AddMenuGroup("Arranging");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Expand All");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Collapse All");
				oMenuGroup = m_oActionMenuTreeView.AddMenuGroup("Layout");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Bring to Front");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Send to Back");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Align to Grid");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Lock Controls");

				m_oActionMenuTreeView.ItemClick += new ActionMenuNative.ItemClickEventHandler(this.OnActionMenuTreeViewItemClicked);

				#endregion

				#endregion

				// enable the drag drop operations
				m_oTreeView.AllowDrop = true;
				this.EnableDragDrop(true);

				m_oTreeView.CollapseAll();
				m_oSelector.SelectionService = m_oSelectionService;
				m_oSelector.TreeView = m_oTreeView;
			}
		}
コード例 #14
0
ファイル: ChoiceGroup.cs プロジェクト: curiosity-ai/tesserae
 public Choice OnSelected(ComponentEventHandler <Choice> onSelected)
 {
     SelectedItem += onSelected;
     return(this);
 }
コード例 #15
0
        public static void BuildSSISPackage(out Microsoft.SqlServer.Dts.Runtime.Package package, out IDTSComponentMetaData100 multipleHash, out CManagedComponentWrapper multipleHashInstance, out String lineageString, out MainPipe dataFlowTask, out Microsoft.SqlServer.Dts.Runtime.Application app)
        {
            package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            dataFlowTask = thMainPipe.InnerObject as MainPipe;
            ComponentEventHandler events = new ComponentEventHandler();

            dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);

            // Create a flat file source
            ConnectionManager flatFileConnectionManager = package.Connections.Add("FLATFILE");

            flatFileConnectionManager.Properties["Format"].SetValue(flatFileConnectionManager, "Delimited");
            flatFileConnectionManager.Properties["Name"].SetValue(flatFileConnectionManager, "Flat File Connection");
            flatFileConnectionManager.Properties["ConnectionString"].SetValue(flatFileConnectionManager, @".\TextDataToBeHashed.txt");
            flatFileConnectionManager.Properties["ColumnNamesInFirstDataRow"].SetValue(flatFileConnectionManager, false);
            flatFileConnectionManager.Properties["HeaderRowDelimiter"].SetValue(flatFileConnectionManager, "\r\n");
            flatFileConnectionManager.Properties["TextQualifier"].SetValue(flatFileConnectionManager, "\"");
            flatFileConnectionManager.Properties["DataRowsToSkip"].SetValue(flatFileConnectionManager, 0);
            flatFileConnectionManager.Properties["Unicode"].SetValue(flatFileConnectionManager, false);
            flatFileConnectionManager.Properties["CodePage"].SetValue(flatFileConnectionManager, 1252);

            // Create the columns in the flat file
            IDTSConnectionManagerFlatFile100       flatFileConnection = flatFileConnectionManager.InnerObject as IDTSConnectionManagerFlatFile100;
            IDTSConnectionManagerFlatFileColumn100 StringDataColumn   = flatFileConnection.Columns.Add();

            StringDataColumn.ColumnDelimiter     = ",";
            StringDataColumn.ColumnType          = "Delimited";
            StringDataColumn.DataType            = DataType.DT_STR;
            StringDataColumn.DataPrecision       = 0;
            StringDataColumn.DataScale           = 0;
            StringDataColumn.MaximumWidth        = 255;
            ((IDTSName100)StringDataColumn).Name = "StringData";
            IDTSConnectionManagerFlatFileColumn100 MoreStringColumn = flatFileConnection.Columns.Add();

            MoreStringColumn.ColumnDelimiter     = ",";
            MoreStringColumn.ColumnType          = "Delimited";
            MoreStringColumn.DataType            = DataType.DT_STR;
            MoreStringColumn.DataPrecision       = 0;
            MoreStringColumn.DataScale           = 0;
            MoreStringColumn.MaximumWidth        = 255;
            ((IDTSName100)MoreStringColumn).Name = "MoreString";
            IDTSConnectionManagerFlatFileColumn100 DateColumn = flatFileConnection.Columns.Add();

            DateColumn.ColumnDelimiter     = ",";
            DateColumn.ColumnType          = "Delimited";
            DateColumn.DataType            = DataType.DT_DATE;
            DateColumn.DataPrecision       = 0;
            DateColumn.DataScale           = 0;
            DateColumn.MaximumWidth        = 0;
            ((IDTSName100)DateColumn).Name = "DateColumn";
            IDTSConnectionManagerFlatFileColumn100 IntegerColumn = flatFileConnection.Columns.Add();

            IntegerColumn.ColumnDelimiter     = ",";
            IntegerColumn.ColumnType          = "Delimited";
            IntegerColumn.DataType            = DataType.DT_I4;
            IntegerColumn.DataPrecision       = 0;
            IntegerColumn.DataScale           = 0;
            IntegerColumn.MaximumWidth        = 0;
            ((IDTSName100)IntegerColumn).Name = "IntegerColumn";
            IDTSConnectionManagerFlatFileColumn100 NumericColumn = flatFileConnection.Columns.Add();

            NumericColumn.ColumnDelimiter     = "\r\n";
            NumericColumn.ColumnType          = "Delimited";
            NumericColumn.DataType            = DataType.DT_NUMERIC;
            NumericColumn.DataPrecision       = 15;
            NumericColumn.DataScale           = 2;
            NumericColumn.MaximumWidth        = 0;
            ((IDTSName100)NumericColumn).Name = "NumericColumn";

            app = new Microsoft.SqlServer.Dts.Runtime.Application();

            IDTSComponentMetaData100 flatFileSource = dataFlowTask.ComponentMetaDataCollection.New();

            flatFileSource.ComponentClassID = app.PipelineComponentInfos["Flat File Source"].CreationName;
            // Get the design time instance of the Flat File Source Component
            var flatFileSourceInstance = flatFileSource.Instantiate();

            flatFileSourceInstance.ProvideComponentProperties();

            flatFileSource.RuntimeConnectionCollection[0].ConnectionManager   = DtsConvert.GetExtendedInterface(flatFileConnectionManager);
            flatFileSource.RuntimeConnectionCollection[0].ConnectionManagerID = flatFileConnectionManager.ID;

            // Reinitialize the metadata.
            flatFileSourceInstance.AcquireConnections(null);
            flatFileSourceInstance.ReinitializeMetaData();
            flatFileSourceInstance.ReleaseConnections();
            flatFileSource.CustomPropertyCollection["RetainNulls"].Value = true;



            //[MD5BinaryOutput] varbinary(16), [MD5HexOutput] varchar(34), [MD5BaseOutput] varchar(24))";
            multipleHash = dataFlowTask.ComponentMetaDataCollection.New();
            multipleHash.ComponentClassID = typeof(Martin.SQLServer.Dts.MultipleHash).AssemblyQualifiedName;
            multipleHashInstance          = multipleHash.Instantiate();

            multipleHashInstance.ProvideComponentProperties();
            multipleHash.Name = "Multiple Hash Test";
            multipleHashInstance.ReinitializeMetaData();

            // Create the path from source to destination.
            StaticTestUtilities.CreatePath(dataFlowTask, flatFileSource.OutputCollection[0], multipleHash, multipleHashInstance);

            // Select the input columns.
            IDTSInput100        multipleHashInput  = multipleHash.InputCollection[0];
            IDTSVirtualInput100 multipleHashvInput = multipleHashInput.GetVirtualInput();

            foreach (IDTSVirtualInputColumn100 vColumn in multipleHashvInput.VirtualInputColumnCollection)
            {
                multipleHashInstance.SetUsageType(multipleHashInput.ID, multipleHashvInput, vColumn.LineageID, DTSUsageType.UT_READONLY);
            }

            // Add the output columns
            // Generate the Lineage String
            lineageString = String.Empty;
            foreach (IDTSInputColumn100 inputColumn in multipleHashInput.InputColumnCollection)
            {
                if (lineageString == String.Empty)
                {
                    lineageString = String.Format("#{0}", inputColumn.LineageID);
                }
                else
                {
                    lineageString = String.Format("{0},#{1}", lineageString, inputColumn.LineageID);
                }
            }
        }
コード例 #16
0
        public PropertyGrid()  {

            onComponentAdd = new ComponentEventHandler(OnComponentAdd);
            onComponentRemove = new ComponentEventHandler(OnComponentRemove);
            onComponentChanged = new ComponentChangedEventHandler(OnComponentChanged);

            SuspendLayout();
            AutoScaleMode = AutoScaleMode.None;

            if (!isScalingInitialized) {
                if (DpiHelper.IsScalingRequired) {
                    normalButtonSize = DpiHelper.LogicalToDeviceUnits(DEFAULT_NORMAL_BUTTON_SIZE);
                    largeButtonSize = DpiHelper.LogicalToDeviceUnits(DEFAULT_LARGE_BUTTON_SIZE);
                }
                isScalingInitialized = true;
            }
           
            try
            {
                gridView = CreateGridView(null);
                gridView.TabStop = true;
                gridView.MouseMove += new MouseEventHandler(this.OnChildMouseMove);
                gridView.MouseDown += new MouseEventHandler(this.OnChildMouseDown);
                gridView.TabIndex = 2;

                separator1 = CreateSeparatorButton();
                separator2 = CreateSeparatorButton();

                toolStrip = new ToolStrip();
                toolStrip.SuspendLayout();
                toolStrip.ShowItemToolTips = true;
                toolStrip.AccessibleName = SR.GetString(SR.PropertyGridToolbarAccessibleName);
                toolStrip.AccessibleRole = AccessibleRole.ToolBar;
                toolStrip.TabStop = true;
                toolStrip.AllowMerge = false;

                // This caption is for testing.
                toolStrip.Text = "PropertyGridToolBar";

                // LayoutInternal handles positioning, and for perf reasons, we manually size.
                toolStrip.Dock = DockStyle.None;
                toolStrip.AutoSize = false;
                toolStrip.TabIndex = 1;
                toolStrip.ImageScalingSize = normalButtonSize;

                // parity with the old... 
                toolStrip.CanOverflow = false;


                // hide the grip but add in a few more pixels of padding.
                toolStrip.GripStyle = ToolStripGripStyle.Hidden;
                Padding toolStripPadding = toolStrip.Padding;
                toolStripPadding.Left = 2;
                toolStrip.Padding = toolStripPadding;
                SetToolStripRenderer();


                // always add the property tab here
                AddRefTab(DefaultTabType, null, PropertyTabScope.Static, true);

                doccomment = new DocComment(this);
                doccomment.SuspendLayout();
                doccomment.TabStop = false;
                doccomment.Dock = DockStyle.None;
                doccomment.BackColor = SystemColors.Control;
                doccomment.ForeColor = SystemColors.ControlText;
                doccomment.MouseMove += new MouseEventHandler(this.OnChildMouseMove);
                doccomment.MouseDown += new MouseEventHandler(this.OnChildMouseDown);



                hotcommands = new HotCommands(this);
                hotcommands.SuspendLayout();
                hotcommands.TabIndex = 3;
                hotcommands.Dock = DockStyle.None;
                SetHotCommandColors(false);
                hotcommands.Visible = false;
                hotcommands.MouseMove += new MouseEventHandler(this.OnChildMouseMove);
                hotcommands.MouseDown += new MouseEventHandler(this.OnChildMouseDown);
              
                Controls.AddRange(new Control[] { doccomment, hotcommands, gridView, toolStrip });

                SetActiveControlInternal(gridView);
                toolStrip.ResumeLayout(false);  // SetupToolbar should perform the layout
                SetupToolbar();
                this.PropertySort = PropertySort.Categorized | PropertySort.Alphabetical;
                this.Text = "PropertyGrid";
                SetSelectState(0);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            finally {
                if (doccomment != null) {
                    doccomment.ResumeLayout(false);
                }
                if (hotcommands != null) {
                    hotcommands.ResumeLayout(false);
                }
                ResumeLayout(true);
            }
        }
コード例 #17
0
 private void SinkChangeEvents(IServiceProvider provider, bool sink)
 {
     ISelectionService service = provider.GetService(typeof(ISelectionService)) as ISelectionService;
     IComponentChangeService service2 = provider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
     IDesignerHost sender = provider.GetService(typeof(IDesignerHost)) as IDesignerHost;
     if (sink)
     {
         if (service != null)
         {
             service.SelectionChanged += new EventHandler(this.OnSelectionChanged);
         }
         if (service2 != null)
         {
             ComponentEventHandler handler = new ComponentEventHandler(this.OnComponentAddedRemoved);
             service2.ComponentAdded += handler;
             service2.ComponentRemoved += handler;
             service2.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
         }
         if (sender != null)
         {
             sender.TransactionOpened += new EventHandler(this.OnTransactionOpened);
             sender.TransactionClosed += new DesignerTransactionCloseEventHandler(this.OnTransactionClosed);
             sender.LoadComplete += new EventHandler(this.OnLoadComplete);
             if (sender.InTransaction)
             {
                 this.OnTransactionOpened(sender, EventArgs.Empty);
             }
         }
     }
     else
     {
         if (service != null)
         {
             service.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
         }
         if (service2 != null)
         {
             ComponentEventHandler handler2 = new ComponentEventHandler(this.OnComponentAddedRemoved);
             service2.ComponentAdded -= handler2;
             service2.ComponentRemoved -= handler2;
             service2.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
         }
         if (sender != null)
         {
             sender.TransactionOpened -= new EventHandler(this.OnTransactionOpened);
             sender.TransactionClosed -= new DesignerTransactionCloseEventHandler(this.OnTransactionClosed);
             sender.LoadComplete -= new EventHandler(this.OnLoadComplete);
             if (sender.InTransaction)
             {
                 this.OnTransactionClosed(sender, new DesignerTransactionCloseEventArgs(false, true));
             }
         }
     }
 }
コード例 #18
0
 public PropertyGrid()
 {
     this.onComponentAdd = new ComponentEventHandler(this.OnComponentAdd);
     this.onComponentRemove = new ComponentEventHandler(this.OnComponentRemove);
     this.onComponentChanged = new ComponentChangedEventHandler(this.OnComponentChanged);
     base.SuspendLayout();
     base.AutoScaleMode = AutoScaleMode.None;
     try
     {
         this.gridView = this.CreateGridView(null);
         this.gridView.TabStop = true;
         this.gridView.MouseMove += new MouseEventHandler(this.OnChildMouseMove);
         this.gridView.MouseDown += new MouseEventHandler(this.OnChildMouseDown);
         this.gridView.TabIndex = 2;
         this.separator1 = this.CreateSeparatorButton();
         this.separator2 = this.CreateSeparatorButton();
         this.toolStrip = new ToolStrip();
         this.toolStrip.SuspendLayout();
         this.toolStrip.ShowItemToolTips = true;
         this.toolStrip.AccessibleName = System.Windows.Forms.SR.GetString("PropertyGridToolbarAccessibleName");
         this.toolStrip.AccessibleRole = AccessibleRole.ToolBar;
         this.toolStrip.TabStop = true;
         this.toolStrip.AllowMerge = false;
         this.toolStrip.Text = "PropertyGridToolBar";
         this.toolStrip.Dock = DockStyle.None;
         this.toolStrip.AutoSize = false;
         this.toolStrip.TabIndex = 1;
         this.toolStrip.CanOverflow = false;
         this.toolStrip.GripStyle = ToolStripGripStyle.Hidden;
         System.Windows.Forms.Padding padding = this.toolStrip.Padding;
         padding.Left = 2;
         this.toolStrip.Padding = padding;
         this.SetToolStripRenderer();
         this.AddRefTab(this.DefaultTabType, null, PropertyTabScope.Static, true);
         this.doccomment = new DocComment(this);
         this.doccomment.SuspendLayout();
         this.doccomment.TabStop = false;
         this.doccomment.Dock = DockStyle.None;
         this.doccomment.BackColor = SystemColors.Control;
         this.doccomment.ForeColor = SystemColors.ControlText;
         this.doccomment.MouseMove += new MouseEventHandler(this.OnChildMouseMove);
         this.doccomment.MouseDown += new MouseEventHandler(this.OnChildMouseDown);
         this.hotcommands = new HotCommands(this);
         this.hotcommands.SuspendLayout();
         this.hotcommands.TabIndex = 3;
         this.hotcommands.Dock = DockStyle.None;
         this.SetHotCommandColors(false);
         this.hotcommands.Visible = false;
         this.hotcommands.MouseMove += new MouseEventHandler(this.OnChildMouseMove);
         this.hotcommands.MouseDown += new MouseEventHandler(this.OnChildMouseDown);
         this.Controls.AddRange(new Control[] { this.doccomment, this.hotcommands, this.gridView, this.toolStrip });
         base.SetActiveControlInternal(this.gridView);
         this.toolStrip.ResumeLayout(false);
         this.SetupToolbar();
         this.PropertySort = System.Windows.Forms.PropertySort.CategorizedAlphabetical;
         this.Text = "PropertyGrid";
         this.SetSelectState(0);
     }
     catch (Exception)
     {
     }
     finally
     {
         if (this.doccomment != null)
         {
             this.doccomment.ResumeLayout(false);
         }
         if (this.hotcommands != null)
         {
             this.hotcommands.ResumeLayout(false);
         }
         base.ResumeLayout(true);
     }
 }
コード例 #19
0
 public void UnsubscribeLocalEvent <TComp, TEvent>(ComponentEventHandler <TComp, TEvent> handler)
     where TComp : IComponent
     where TEvent : EntityEventArgs
 {
     _eventTables.Unsubscribe(typeof(TComp), typeof(TEvent));
 }
コード例 #20
0
ファイル: ContextMenu.cs プロジェクト: curiosity-ai/tesserae
 private void OnItemClick(ComponentEventHandler <Item, MouseEvent> componentEventHandler)
 {
     ItemClick += componentEventHandler;
 }
コード例 #21
0
 public Picker <TPickerItem> OnItemSelected(ComponentEventHandler <Picker <TPickerItem>, ItemPickedEvent> eventHandler)
 {
     SelectedItem += eventHandler;
     return(this);
 }
コード例 #22
0
 private void OnActiveDesignerChanged(object sender, ActiveDesignerEventArgs e)
 {
     ComponentEventHandler handler = new ComponentEventHandler(this.OnComponentCollectionChanged);
     if (this._activeDesigner != null)
     {
         IComponentChangeService service = (IComponentChangeService) this._activeDesigner.GetService(typeof(IComponentChangeService));
         if (service != null)
         {
             service.ComponentAdded -= handler;
             service.ComponentRemoved -= handler;
         }
     }
     this._activeDesigner = e.NewDesigner;
     if (this._activeDesigner != null)
     {
         IComponentChangeService service2 = (IComponentChangeService) this._activeDesigner.GetService(typeof(IComponentChangeService));
         if (service2 != null)
         {
             service2.ComponentAdded += handler;
             service2.ComponentRemoved += handler;
         }
         IPropertyBrowserClient client = e.NewDesigner.GetService(typeof(DocumentWindow)) as IPropertyBrowserClient;
         if (client != null)
         {
             base.Enabled = client.SupportsPropertyBrowser;
             if (!client.SupportsPropertyBrowser)
             {
                 this._propGrid.SelectedObject = null;
             }
         }
     }
     this.UpdateSelection();
 }
コード例 #23
0
 protected void UnsubscribeLocalEvent <TComp, TEvent>(ComponentEventHandler <TComp, TEvent> handler)
     where TComp : IComponent
     where TEvent : EntityEventArgs
 {
     EntityManager.EventBus.UnsubscribeLocalEvent <TComp, TEvent>();
 }
コード例 #24
0
 public ToggleButton OnChange(ComponentEventHandler <ToggleButton, Event> onChange)
 {
     Changed += onChange;
     return(this);
 }