Inheritance: System.MarshalByRefObject, IComponent, IDisposable
Ejemplo n.º 1
0
 /// <summary>
 /// This gets the UICommand instance (possibly null) for the specified control.
 /// <param name="control"></param>
 public UICommand GetUICommand(Component control)
 {
     // Return null if there is no entry for the control in the dictionary.
     UICommand ret = null;
     _dict.TryGetValue(control, out ret);
     return ret;
 }
Ejemplo n.º 2
0
        public static void ClearEvent(Component component)
        {
            if (component == null)
            {
                return;
            }

            BindingFlags flag = BindingFlags.NonPublic | BindingFlags.Instance;
            EventHandlerList evList = typeof(Component).GetField("events", flag).GetValue(component) as EventHandlerList;
            if (evList == null)
            {
                return;
            }

            object evEntryData = evList.GetType().GetField("head", flag).GetValue(evList);
            if (evEntryData == null)
            {
                return;
            }
            do
            {
                object key = evEntryData.GetType().GetField("key", flag).GetValue(evEntryData);
                if (key == null)
                {
                    break;
                }
                evList[key] = null;
                evEntryData = evEntryData.GetType().GetField("next", flag).GetValue(evEntryData);

            }
            while (evEntryData != null);
        }
 public CommandBindingBase Create(Component component, ICommand command, Func<object> commandParameterCallback)
 {
     if (component == null) { throw new ArgumentNullException("component"); }
     if (command == null) { throw new ArgumentNullException("command"); }
     if (commandParameterCallback == null) { throw new ArgumentNullException("commandParameterCallback"); }
     return CreateCore(component, command, commandParameterCallback);
 }
Ejemplo n.º 4
0
 internal void InternalAddTarget(Component extendee)
 {
     targets.Add(extendee);
     refreshState(extendee);
     AddHandler(extendee);
     OnAddingTarget(extendee);
 }
 public void SetStatusInformation(Component selectedComponent, Point location)
 {
     if (selectedComponent != null)
     {
         Rectangle empty = Rectangle.Empty;
         Control control = selectedComponent as Control;
         if (control != null)
         {
             empty = control.Bounds;
         }
         else
         {
             PropertyDescriptor descriptor = TypeDescriptor.GetProperties(selectedComponent)["Bounds"];
             if ((descriptor != null) && typeof(Rectangle).IsAssignableFrom(descriptor.PropertyType))
             {
                 empty = (Rectangle) descriptor.GetValue(selectedComponent);
             }
         }
         if (location != Point.Empty)
         {
             empty.X = location.X;
             empty.Y = location.Y;
         }
         if (this.StatusRectCommand != null)
         {
             this.StatusRectCommand.Invoke(empty);
         }
     }
 }
Ejemplo n.º 6
0
 public Action GetAction(Component cmp)
 {
     if (ActionDictionary.ContainsKey(cmp))
         return ActionDictionary[cmp];
     else
         return null;
 }
 public void RemoveCommandBinding(Component component)
 {
     if (component == null) { throw new ArgumentNullException("component"); }
     CommandBindingBase binding = bindings.FirstOrDefault(b => b.Component == component);
     if (binding == null) { throw new ArgumentException("The binding to remove wasn't found."); }
     bindings.Remove(binding);
 }
 protected override void ApplyResources(Component component, string componentName, CultureInfo culture)
 {
     foreach (PropertyDescriptor descriptor in this.GetLocalizableStringProperties(component.GetType()))
     {
         string str = this.GetString(string.Format("{0}.{1}", componentName, descriptor.Name), culture);
         if (str != null)
         {
             descriptor.SetValue(component, str);
         }
     }
     ComboBox box = component as ComboBox;
     if ((box != null) && (box.DataSource == null))
     {
         string item = this.GetString(string.Format("{0}.Items", box.Name), culture);
         if (item != null)
         {
             int selectedIndex = box.SelectedIndex;
             box.BeginUpdate();
             box.Items.Clear();
             int num2 = 1;
             while (item != null)
             {
                 box.Items.Add(item);
                 item = this.GetString(string.Format("{0}.Items{1}", box.Name, num2++), culture);
             }
             if (selectedIndex < box.Items.Count)
             {
                 box.SelectedIndex = selectedIndex;
             }
             box.EndUpdate();
         }
     }
 }
Ejemplo n.º 9
0
		public static IRawElementProviderFragment PerformComponentMapping (Component component)
		{
			ScrollBar scb = component as ScrollBar;
			if (scb == null) {
				return null;
			}

			//TODO:
			//   We need to add here a ScrollableControlProvider and then verify
			//   if the internal scrollbar instances are matching this one,
			//   if so, then we return a scrollbar, otherwise we return a pane.
#pragma warning disable 219
			ScrollableControl scrollable;
			//ScrollableControlProvider scrollableProvider;
			if ((scrollable = scb.Parent as ScrollableControl) != null
			    || scb.Parent == null) {
#pragma warning restore 219
			//	scrollableProvider = (ScrollableControlProvider) GetProvider (scrollable);
			//	if (scrollableProvider.ScrollBarExists (scb) == true)
					return new ScrollBarProvider (scb);
			//	else 
			//		provider = new PaneProvider (scb);
			}

			return new PaneProvider (scb);
		}
 private bool CheckAssociatedControl(Component c, Glyph childGlyph, GlyphCollection glyphs)
 {
     bool flag = false;
     ToolStripDropDownItem dropDownItem = c as ToolStripDropDownItem;
     if (dropDownItem != null)
     {
         flag = this.CheckDropDownBounds(dropDownItem, childGlyph, glyphs);
     }
     if (flag)
     {
         return flag;
     }
     Control associatedControl = this.GetAssociatedControl(c);
     if (((associatedControl == null) || (associatedControl == this.toolStripContainer)) || System.Design.UnsafeNativeMethods.IsChild(new HandleRef(this.toolStripContainer, this.toolStripContainer.Handle), new HandleRef(associatedControl, associatedControl.Handle)))
     {
         return flag;
     }
     Rectangle bounds = childGlyph.Bounds;
     Rectangle rect = base.BehaviorService.ControlRectInAdornerWindow(associatedControl);
     if ((c == this.designerHost.RootComponent) || !bounds.IntersectsWith(rect))
     {
         glyphs.Insert(0, childGlyph);
     }
     return true;
 }
        ///<summary>
        /// Return the MenuItem that is assigned to each ToolBarButton
        ///</summary>
        public MenuCommand GetMenuItem( Component pComponent )
        {
            if( m_Dictionary.Contains( pComponent ))
                return (MenuCommand) m_Dictionary[ pComponent ];

            return null;
        }
Ejemplo n.º 12
0
		protected override bool IsComponentVisible (Component component)
		{
			// Ensure that even though the TabPages will have
			// Visible = False when they're not selected, they stay
			// in the A11y hierarchy.  This is to model Vista's
			// behavior.
			return true;
		}
Ejemplo n.º 13
0
 public void AddTo()
 {
     var collection = new DisposableCollection();
     var disposable = new Component();
     disposable.AddTo(collection);
     Assert.AreEqual(1, collection.Count);
     Assert.IsTrue(collection.Contains(disposable));
 }
 protected override CommandBindingBase CreateCore(Component component, ICommand command, Func<object> commandParameterCallback)
 {
     TreeView treeView = component as TreeView;
     if (treeView == null)
     {
         throw new ArgumentException("This factory cannot create a CommandBindingBase for the passed component.");
     }
     return new TreeViewBinding(treeView, command, commandParameterCallback);
 }
Ejemplo n.º 15
0
		protected override bool IsComponentVisible (Component component)
		{
			// Hide the TabPage's children if it's not visible.
			// This is to sweep under the rug the fact that SWF
			// seems to keep a TabPages' children visible even if
			// the TabPage isn't.  This is to model Vista's
			// behavior.
			return Control.Visible;
		}
		/// <summary>
		/// Causes this object to be disposed when the <see cref="Component"/> is disposed.
		/// </summary>
		/// <param name="disposable">
		///		The <see cref="IDisposable"/> object that</param> should be disposed when
		///		the <paramref name="component"/> is disposed.
		/// <param name="component">
		///		When this component is disposed, the <paramref name="disposable"/> object
		///		should be disposed.
		/// </param>
		/// <remarks>
		///		This is useful for ensuring that objects are disposed when a Windows Forms
		///		control is disposed.
		/// </remarks>
		public static void DisposeWith(this IDisposable disposable, Component component)
		{
			if (disposable == null)
			{
				return;
			}
			Verify.ArgumentNotNull(component, "component");
			component.Disposed += (sender, args) => DisposeOf(disposable);
		}
Ejemplo n.º 17
0
 public void Load(Component component)
 {
     var source = (InfoComponent)component;
      Id = source.Id;
      Name = source.Name;
      Authors = source.Authors;
      Website = source.Website;
      Targets = source.Targets;
 }
Ejemplo n.º 18
0
 IModelSynchronizer IModelSynchronizersHolder.GetSynchronizer(Component component) {
     IModelSynchronizer result = null;
     if (component != null) {
         result = OnCustomModelSynchronizer(component);
         if (result == null) {
             ColumnsInfoCache.TryGetValue(component, out result);
         }
     }
     return result;
 }
Ejemplo n.º 19
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        protected CommandBindingBase(Component component, ICommand command,
                                     Func<object> commandParameterCallback)
        {
            Component = component;
            Command = command;
            CommandParameterCallback = commandParameterCallback;

            Component.Disposed += event_Dispose;
            Command.CanExecuteChanged += CanExecuteChanged;
        }
Ejemplo n.º 20
0
        public void OnGenerateIngresDataSet(
			Component component, object sender, EventArgs e)
        {
            IServiceProvider sp = component.Site;
            EnvDTE._DTE dte = (EnvDTE._DTE)sp.GetService(typeof(EnvDTE._DTE));

            Form dlg = new GenDataSetForm(
                component.Site,                   // IServiceProvider
                (DbDataAdapter)component, dte);
            DialogResult result = dlg.ShowDialog();
        }
        protected override CommandBindingBase CreateCore(Component component, ICommand command, Func<object> commandParameterCallback)
        {
            var tabControl = component as TabControl;

            if (tabControl == null)
            {
                throw new ArgumentException("This factory cannot create a CommandBindingBase for the passed component.");
            }

            return new TabChangedBinding(tabControl, command, commandParameterCallback);
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Applies the value resulting from this property onto the given Component instance.
 /// </summary>
 public void ApplyValue(Component Component)
 {
     //Component Component = Entity.Components[ComponentName];
     PropertyInfo Property = Component.GetType().GetProperty(PropertyName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
     if(Property == null)
         throw new KeyNotFoundException("Unable to find a property named '" + PropertyName + "' on Component of type '" + Component.GetType().Name + "'.");
     object Value = Argument.GetValue(Component, Property);
     if(!Property.PropertyType.IsAssignableFrom(Value.GetType()))
         Value = Convert.ChangeType(Value, Property.PropertyType);
     Property.SetValue(Component, Value, null);
 }
Ejemplo n.º 23
0
 public void SetAction(Component cmp, Action act)
 {
     ActionDictionary.Remove(cmp);
     if (act != null)
     {
         ActionDictionary.Add(cmp, act);
         UpdateEnabled(act);
         UpdateText(act);
         AddExecuteTarget(act);
     }
 }
        protected override CommandBindingBase CreateCore(Component component, ICommand command, Func<object> commandParameterCallback)
        {
            var containerControl = component as HotKeyManager;

            if (containerControl == null)
            {
                throw new ArgumentException("This factory cannot create a CommandBindingBase for the passed component.");
            }

            return new KeyPressCommandBinding(containerControl, command, commandParameterCallback);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// 为指定控件的属性赋值。
 /// </summary>
 /// <param name="ctl">控件。</param>
 /// <param name="propertyName">属性名称。</param>
 /// <param name="value">新值。</param>
 /// <returns>指定属性的值。</returns>
 public void SetPropertyValue(System.ComponentModel.Component ctl, string propertyName, object value)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new SetPropertyHandler(this.SetPropertyValue), ctl, propertyName, value);
     }
     else
     {
         ctl.GetType().GetProperty(propertyName).SetValue(ctl, value, null);
     }
 }
Ejemplo n.º 26
0
 public void Construct_from_component()
 {
     Dispose();
     using (var component = new Component())
     {
         DisplaySettings = new DisplaySettings(component);
         Assert.AreEqual(component.GetType().FullName, DisplaySettings.Name);
         Assert.IsFalse(DisplaySettings.IsDisposed);
     }
     Assert.IsTrue(DisplaySettings.IsDisposed);
 }
 public SynchronizerBase()
 {
     try
      {
     _Timer = new Timer();
     _Component = new Component();
      }
      catch (Exception ex)
      {
     throw ex;
      }
 }
 private void SwitchControl(Component obj)
 {
     if (obj != null)
     {
         if (propertyGrid.SelectedObject != obj)
         {
             Text = obj.ToString();
             propertyGrid.SelectedObject = obj;
             propertyGrid.PropertySort = PropertySort.Alphabetical;
         }
     }
 }
Ejemplo n.º 29
0
        public ConsoleMonitor()
        {
            handle = GetStdHandle(STD_OUTPUT_HANDLE);
            if (handle == IntPtr.Zero)
                throw new InvalidOperationException("A console handle is not available.");

            component = new Component();

            string output = "The ConsoleMonitor class constructor.\n";
            uint written = 0;
            WriteConsole(handle, output, (uint)output.Length, out written, IntPtr.Zero);
        }
        /// <summary>
        /// バインディングを作成します。
        /// </summary>
        public CommandBindingBase Create(Component component, ICommand command,
                                         Func<object> commandParameterCallback)
        {
            var target = component as ButtonBase;
            if (target == null)
            {
                throw new ArgumentException(
                    "This factory cannot create a CommandBindingBase for the passed component.");
            }

            return new ButtonCommandBinding(target, command, commandParameterCallback);
        }
        public EventSuppressor(Component source)
        {
            if (source == null)
                throw new ArgumentNullException("control", "An instance of a control must be provided.");

            _source = source;
            _sourceType = _source.GetType();
            _sourceEventsInfo = _sourceType.GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic);
            _sourceEventHandlerList = (EventHandlerList)_sourceEventsInfo.GetValue(_source, null);
            _eventHandlerListType = _sourceEventHandlerList.GetType();
            _headFI = _eventHandlerListType.GetField("head", BindingFlags.Instance | BindingFlags.NonPublic);
        }
Ejemplo n.º 32
0
        private void listBox_Components_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_SelectionChangeFlag)
            {
                return;
            }

            _SelectionChangeFlag = true;
            try
            {
                _ActiveComponent = UIDesigner_Component.FindComponent(_host, _components, listBox_Components.Text);
            }
            finally
            {
                _SelectionChangeFlag = false;
            }
        }
Ejemplo n.º 33
0
 private void SetPropertyThreadSafe(System.ComponentModel.Component what, object setto, string property)
 {
     if (this.InvokeRequired)
     {
         SetPropertyThreadSafeCallback sptscb = new SetPropertyThreadSafeCallback(SetPropertyThreadSafe);
         try
         {
             this.Invoke(sptscb, new object[] { what, setto, property });
         }
         catch (Exception)
         {
             // FFFFF!
         }
         return;
     }
     what.GetType().GetProperty(property).SetValue(what, setto, null);
     //what.Text = setto;
 }
 internal EventHandlerList(Component parent)
 {
     this.parent = parent;
 }
 internal SampleSelectionItem(SampleSelectionService selectionMgr, System.ComponentModel.Component component)
 {
     this.component    = component;
     this.selectionMgr = selectionMgr;
 }
Ejemplo n.º 36
0
 public TreeNodeRootProvider(System.ComponentModel.Component component) :
     base(component)
 {
     nodeProviders =
         new Dictionary <SWF.TreeNode, TreeNodeProvider> ();
 }