public static string ResolveDataProperty(this CellRenderer aCell) { if (TypeValidator.IsCompatible(aCell.GetType(), typeof(MappedCellRenderer)) == true) { return((aCell as MappedCellRenderer).GetDataProperty()); } if (TypeValidator.IsCompatible(aCell.GetType(), typeof(CellRendererToggle)) == true) { return("active"); } if (TypeValidator.IsCompatible(aCell.GetType(), typeof(CellRendererText)) == true) { return("text"); } if (TypeValidator.IsCompatible(aCell.GetType(), typeof(CellRendererPixbuf)) == true) { return("pixbuf"); } if (TypeValidator.IsCompatible(aCell.GetType(), typeof(CellRendererProgress)) == true) { return("value"); } if (TypeValidator.IsCompatible(aCell.GetType(), typeof(CellRendererSpin)) == true) { return("text"); } if (TypeValidator.IsCompatible(aCell.GetType(), typeof(CellRendererCombo)) == true) { return("text"); } throw new NotImplementedException("CellRenderer of type {0} is not specified in list for data property"); }
public QueryModelDescription(System.Type aModel, QueryModelAttribute aDescription) { if (aModel == null) { throw new NullReferenceException("QueryModelDescription: Model type can't be null"); } if (aDescription == null) { throw new NullReferenceException("QueryModelDescription: Attribute must be specified"); } foreach (ConstructorInfo info in aModel.GetConstructors()) { if (info.GetParameters().Length == 1) { if (TypeValidator.IsCompatible(info.GetParameters()[0].ParameterType, typeof(MappingsImplementor)) == true) { constructor = info; break; } } } if (constructor == null) { throw new NotImplementedException("QueryModelDescription: QueryImplementor needs public .ctor (MappingsImplementor)"); } model = aModel; definition = aDescription; }
/// <summary> /// Set object type which will be cached /// </summary> /// <param name="aObject"> /// Object whos type is reference for cache <see cref="System.Object"/> /// </param> public void SetObject(object aObject) { if (aObject == null) { Clear(); return; } if ((objectReference != null) && (objectReference.Target != null)) { if (TypeValidator.IsCompatible(aObject.GetType(), ObjectType) == true) { if (objectReference.Target != aObject) { objectReference.Target = aObject; } if (Reference == GetReferenceObject(aObject)) { return; } } } modified = true; Clear(); objectReference = new WeakReference(aObject); }
private void _ClearContainer(Gtk.Container aContainer) { List <Widget> widgets = new List <Widget>(); foreach (Widget wdg in AllChildren) { widgets.Add(wdg); } foreach (Widget wdg in widgets) { if (TypeValidator.IsCompatible(wdg.GetType(), typeof(Gtk.Container)) == true) { _ClearContainer(wdg as Gtk.Container); } } foreach (Widget wdg in widgets) { Remove(wdg); if (wdg is IDisconnectable) { (wdg as IDisconnectable).Disconnect(); } wdg.Destroy(); } widgets.Clear(); widgets = null; }
public override CellEditable StartEditing(Gdk.Event evnt, Widget widget, string path, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, CellRendererState flags) { System.Console.WriteLine("CR.StartEditing(Editable={0})", Editable); if (Editable == false) { return(null); } // return base.StartEditing (evnt, widget, path, background_area, cell_area, flags); CellEditableImplementor wdg = (CellEditableImplementor)adapter.Implementor; // (wdg as DateEntry).DoubleBuffered = true; (wdg as DateEntry).CellRendererWindow = widget.GdkWindow; System.Console.WriteLine("TYpe={0}", (wdg as DateEntry).CellRendererWindow.GetType()); // CellEditEntry text = new CellEditEntry(); // text.EditingDone += OnEditDone; // text.Text = source.Name; // text.path = path; if (TypeValidator.IsCompatible(wdg.GetType(), typeof(Gtk.Widget)) == true) { (wdg as Gtk.Widget).Show(); } // view.EditingRow = true; return(adapter); }
/// <summary> /// Handles ButtonPress event /// </summary> /// <param name="evnt"> /// Arguments <see cref="Gdk.EventButton"/> /// </param> /// <returns> /// true if handled, false if not <see cref="System.Boolean"/> /// </returns> protected override bool OnButtonPressEvent(Gdk.EventButton evnt) { if (CanFocus == true) { if (HasFocus == false) { GrabFocus(); return(true); } } if (Editable == false) { return(base.OnButtonPressEvent(evnt)); } IDrawingCell cell = mainbox.CellAtCoordinates(System.Convert.ToInt32(evnt.X), System.Convert.ToInt32(evnt.Y)); if (cell == null) { return(base.OnButtonPressEvent(evnt)); } if (TypeValidator.IsCompatible(cell.GetType(), typeof(TimeText)) == true) { if ((int)(cell as TimeText).Part < 4) { Selected = (cell as TimeText).Part; return(true); } } return(base.OnButtonPressEvent(evnt)); }
protected override int[] GetItemIndex(object aNode, bool aDeepSearch) { if (TypeValidator.IsCompatible(aNode.GetType(), typeof(DevelopmentInformationAttribute)) == true) { int i = (DataSource as DevelopmentDescriptionCollection).IndexOf(aNode); if (i == -1) { return(null); } return(new int[1] { i }); } else if (TypeValidator.IsCompatible(aNode.GetType(), typeof(DevelopmentInformationItem)) == true) { DevelopmentInformationAttribute di = (aNode as DevelopmentInformationItem).Owner; int i = (DataSource as DevelopmentDescriptionCollection).IndexOf(di); if (i == -1) { return(null); } int j = di.IndexOf(aNode as DevelopmentInformationItem); if (j == -1) { return(null); } return(new int[2] { i, j }); } return(null); }
protected override int[] GetItemIndex(object aNode, bool aDeepSearch) { if (TypeValidator.IsCompatible(aNode.GetType(), typeof(TypeDevelopmentInformation)) == true) { int i = (DataSource as AssemblyDevelopmentInformation).IndexOf((aNode as TypeDevelopmentInformation)); if (i == -1) { return(null); } return(new int[1] { i }); } else if (TypeValidator.IsCompatible(aNode.GetType(), typeof(MemberDevelopmentInformation)) == true) { int i = (DataSource as AssemblyDevelopmentInformation).IndexOf((aNode as MemberDevelopmentInformation).GetMemberInfo().DeclaringType); TypeDevelopmentInformation ti = (DataSource as AssemblyDevelopmentInformation).GetInfo(i); if (i == -1) { return(null); } int j = ti.IndexOf(aNode as MemberDevelopmentInformation); if (j == -1) { return(null); } return(new int[2] { i, j }); } return(null); }
public object this [int[] aIdx] { get { if ((aIdx == null) || (aIdx.Length == 0)) { throw new NullReferenceException("Hierarchical index (int[]) can't be null or empty"); } if (IsFiltered == false) { if (TypeValidator.IsCompatible(ParentView.GetType(), typeof(IObservableList)) == true) { return((ParentView as IObservableList)[aIdx]); } else { return(HierarchicalList.Get(ParentView, aIdx)); } } if ((aIdx[0] < 0) || (aIdx[0] >= Count)) { throw new IndexOutOfRangeException(string.Format("Index {0} is out of range", aIdx.PathToString())); } return(HierarchicalList.Get(this, aIdx)); } }
/// <summary> /// Checks if control is Window type /// </summary> /// <param name="aControl"> /// Control to check for <see cref="System.Object"/> /// </param> /// <returns> /// true if control is window, false if not <see cref="System.Boolean"/> /// </returns> public override bool ControlIsWindow(object aControl) { if (aControl == null) { return(false); } return(TypeValidator.IsCompatible(aControl.GetType(), typeof(Gtk.Window))); }
/// <summary> /// IList interface needs /// </summary> /// <param name="aObject"> /// Object to search for <see cref="System.Object"/> /// </param> /// <returns> /// Index of found object, -1 if not found <see cref="System.Int32"/> /// </returns> int IList.IndexOf(object aObject) { if (!TypeValidator.IsCompatible(aObject.GetType(), typeof(T))) { throw new ExceptionWrongGenericType(aObject.GetType(), typeof(T)); } return(items.IndexOf((T)aObject)); }
/// <summary> /// Checks if this model description handles specified type /// </summary> /// <param name="aType"> /// Type <see cref="System.Type"/> /// </param> /// <returns> /// true if type is handled, false if not <see cref="System.Boolean"/> /// </returns> public bool HandlesType(System.Type aType) { if ((Definition.Inherited == true) || (aType.IsInterface == true)) { return(TypeValidator.IsCompatible(Definition.ListType, aType)); } return(aType == Definition.ListType); }
public bool Contains(object value) { if (TypeValidator.IsCompatible(value.GetType(), typeof(DataRow)) == false) { throw new NotSupportedException("DbObservableList Contains: value is of wrong type"); } return(Table.Rows.Contains(value)); }
public void Remove(object value) { if (TypeValidator.IsCompatible(value.GetType(), typeof(DataRow)) == false) { throw new NotSupportedException("DbObservableList Remove: value is of wrong type"); } Table.Rows.Remove(value as DataRow); }
/// <summary> /// Overrides OnCursorChanged to handle changes /// </summary> protected override void OnChanged() // protected override void OnCursorChanged() { base.OnChanged(); if (Model == null) { currentSelection.Target = null; return; } if (currentSelection.Target != null) { if (ListItems == null) { adaptor.DemandInstantPost(); currentSelection.Target = null; return; } } TreeIter iter; // TreePath tp; if (GetActiveIter(out iter) == true) { object o = internalModel.NodeFromIter(iter); // tp = internalModel.GetPath (iter); // if (tp == null) // throw new ExceptionResolvingPathFromTreeIterOnChanged (GetType()); if (ListItems != null) { // IList lst = (IList) ListItems; // object obj = HierarchicalList.Get (lst, tp.Indices); if (TypeValidator.IsCompatible(o.GetType(), internalModel.ListItemType) == true) { currentSelection.Target = o; } else { currentSelection.Target = null; } o = null; // lst = null; } else { currentSelection.Target = null; } } else { currentSelection.Target = null; } adaptor.DemandInstantPost(); }
/// <summary> /// Resolves master list for this view /// </summary> /// <returns> /// Master list <see cref="IList"/> /// </returns> public IList <T> GetMasterList() { IList <T> lst = ParentView; while (TypeValidator.IsCompatible(lst.GetType(), typeof(IObservableListClient)) == true) { lst = (lst as IObservableListClient <T>).ParentView; } return(lst); }
/// <summary> /// Forces recalc of boxed children /// </summary> public void RecalcChildren() { // foreach (IDrawingCell cell in Cells) for (int i = 0; i < Count; i++) // IDrawingCell cell in Cells) { if (TypeValidator.IsCompatible(Cells[i].GetType(), typeof(DrawingCellBox)) == true) { (Cells[i] as DrawingCellBox).DoCalculateCellAreas((Cells[i] as DrawingCellBox).Area); } } }
public IListTreeModel(MappingsImplementor aMasterImplementor) : base(aMasterImplementor) { if (Items != null) { if (TypeValidator.IsCompatible(Items.GetType(), typeof(DbObservableList)) == true) { HasDeletedItems = true; } } }
protected override int GetItemChildCount(object aNode) { if (TypeValidator.IsCompatible(aNode.GetType(), typeof(DevelopmentDescriptionCollection)) == true) { return((aNode as DevelopmentDescriptionCollection).Count); } else if (TypeValidator.IsCompatible(aNode.GetType(), typeof(DevelopmentInformationAttribute)) == true) { return((aNode as DevelopmentInformationAttribute).Count); } return(0); }
/// <summary> /// Returns ParentWindow for the specified control /// </summary> /// <param name="aControl"> /// Control whose parent we need <see cref="System.Object"/> /// </param> /// <returns> /// reference to parent window <see cref="System.Object"/> /// </returns> /// <remarks> /// Returns widget even if it is not Window. If specified use demands /// Window type first thing needed after this is validation with /// ControlIsWindow <see cref="GtkAdaptor.ControlIsWindow"/> /// </remarks> public override object ParentWindow(object aControl) { if ((aControl == null) || (ValidateControlType(aControl) == false)) { return(null); } if (TypeValidator.IsCompatible(aControl.GetType(), typeof(Gtk.Window)) == true) { return(aControl); } return((aControl as Gtk.Widget).Toplevel); }
protected override object GetItemChildAtIndex(object aNode, int aIndex) { if (TypeValidator.IsCompatible(aNode.GetType(), typeof(AssemblyDevelopmentInformation)) == true) { return((aNode as AssemblyDevelopmentInformation).GetInfo(aIndex)); } else if (TypeValidator.IsCompatible(aNode.GetType(), typeof(TypeDevelopmentInformation)) == true) { return((aNode as TypeDevelopmentInformation).GetInfo(aIndex)); } return(null); }
/// <summary> /// Disconnects base control events like gaining or loosing focus etc. /// /// ControlAdaptor subclasses should override this method to connect /// to specific widget set events /// </summary> protected override void DisconnectControlEvents() { if (Control == null) { return; } if (TypeValidator.IsCompatible(Control.GetType(), typeof(Gtk.Widget)) == true) { (Control as Gtk.Widget).LeaveNotifyEvent -= OnLeaveNotifyEvent; (Control as Gtk.Widget).ExposeEvent -= HandleExposeEvent; } }
internal virtual void ResetSize() { sizeHeight = -1; sizeWidth = -1; if (Owner != null) { if (TypeValidator.IsCompatible(Owner.GetType(), typeof(DrawingCell)) == true) { (Owner as DrawingCell).ResetSize(); } } }
/// <summary> /// Checks class if its type is correct for this selector /// </summary> /// <param name="aObject"> /// Object to be checked <see cref="System.Object"/> /// </param> /// <returns> /// AdaptorSelector instance or null if type is not correct <see cref="IAdaptorSelector"/> /// </returns> public IAdaptorSelector CheckType(object aObject) { if (aObject == null) { return(null); } if (TypeValidator.IsCompatible(aObject.GetType(), typeof(Gtk.Object)) == true) { return(this); } return(null); }
protected override bool OnMotionNotifyEvent(Gdk.EventMotion evnt) { if (TypeValidator.IsCompatible(this.GetType(), typeof(IEditable)) == true) { if ((this as IEditable).Editable == false) { return(base.OnMotionNotifyEvent(evnt)); } } MouseOverCell = box.CellAtCoordinates(System.Convert.ToInt32(evnt.X), System.Convert.ToInt32(evnt.Y)); return(base.OnMotionNotifyEvent(evnt)); }
/// <summary> /// Returns list of runtime attributes that conform with specified type /// </summary> /// <param name="aAttrType"> /// Type searched <see cref="System.Type"/> /// </param> /// <returns> /// List of resulting attributes <see cref="IRuntimeAttribute"/> /// </returns> public IRuntimeAttribute[] GetRuntimeAttribute(System.Type aAttrType) { if ((aAttrType == null) || (runtimeAttributes == null)) { return(null); } if (TypeValidator.IsCompatible(aAttrType, typeof(IRuntimeAttribute)) == false) { throw new Exception("Runtime attribute has to be derived from IRuntimeAttribute"); } return(null); }
protected override int GetItemChildCount(object aNode) { if (TypeValidator.IsCompatible(aNode.GetType(), typeof(AssemblyDevelopmentInformation)) == true) { return((aNode as AssemblyDevelopmentInformation).Count); } else if (TypeValidator.IsCompatible(aNode.GetType(), typeof(TypeDevelopmentInformation)) == true) { return((aNode as TypeDevelopmentInformation).Count); } return(0); }
public void Insert(int aIndex, object value) { if (TypeValidator.IsCompatible(value.GetType(), typeof(DataRow)) == false) { throw new NotSupportedException("DbObservableList Insert: value is of wrong type"); } if ((aIndex < 0) || (aIndex >= Count)) { throw new IndexOutOfRangeException(string.Format("DbObservableList Insert: index is {0}", aIndex)); } Table.Rows.InsertAt(value as DataRow, aIndex); }
/// <summary> /// Checks if type of the object is compatible with cached type /// </summary> /// <param name="aObject"> /// Object to compare against cached type <see cref="System.Object"/> /// </param> /// <returns> /// true if compatible, false if not <see cref="System.Boolean"/> /// </returns> public bool IsCompatible(object aObject) { if (aObject == null) { return(false); } if (IsCached == false) { return(false); } return((TypeValidator.IsCompatible(aObject.GetType(), ObjectType) == true) && (Reference == GetReferenceObject(aObject))); }
public int Add(object value) { if (value == null) { return(-1); } if (TypeValidator.IsCompatible(value.GetType(), typeof(DataRow)) == false) { throw new NotSupportedException("DbObservableList Add: value is of wrong type"); } Table.Rows.Add(value as DataRow); return(Count); //should be the index of our new row }