public override void InitializeNewComponent(IDictionary defaultValues) { IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if (HostComponent.FindSimilarClass(host, typeof(DBConnection), dbConnection)) { XtraMessageBox.Show("Объект типа DBClass уже содержится на форме", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); dbConnection.DestroyItself(); } else { object form = defaultValues["Parent"]; if (form != null && (TypeEx.IsSubclassOf(form.GetType(), typeof(Form)) || form.GetType() == typeof(Form))) { base.InitializeNewComponent(defaultValues); dbConnection.OwnerForm = form as Form; } else { XtraMessageBox.Show("Данный объект не типа Form.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); dbConnection.DestroyItself(); } } }
/// <summary> /// Создание элемента коллекции. /// </summary> public DBFormItemBase CreateInstance(ViewMemberInfo info = null, TreeList treeList = null, ViewMemberInfos memberExists = null) { DBFormItemBase item = null; string name = "BaseView"; if (info != null) { name = info.ViewTypeName; if (TypeEx.IsSubclassOf(info.ViewType, typeof(DBViewInterface))) item = CreateComponent(typeof(DBFormItemView), name) as DBFormItemBase; else item = CreateComponent(typeof(DBFormItemBase), name) as DBFormItemBase; info.IsUsed = true; item.ViewType = info.ViewType; item.Caption = info.Caption; if (item.Caption == "") item.Caption = name; item.ImageName = info.ImageName; } else item = CreateComponent(typeof(DBFormItemBase), name) as DBFormItemBase; Items.Add(item); CreateControl(item, name); if (info != null) CreateIcon(item, info); if (treeList != null && memberExists != null) PrintExistData(treeList, item, memberExists); return item; }
/// <summary> /// Получение значений с объекта-источника. /// </summary> public virtual void GetData <Type>(Type source) { if (TypeEx.IsSubclassOf(typeof(Type), typeof(XPObjectEx))) { Oid = (source as XPObjectEx).Oid; } }
/// <summary> /// Принадлежит ли тип к XPObject. /// </summary> public static bool isXPBaseObject(Type type) { if (TypeEx.IsSubclassOf(type, typeof(XPBaseObject)) || type == typeof(XPBaseObject)) { return(true); } else { return(false); } }
/// <summary> /// Сохранение данных в БД определенной сессии. /// </summary> public static void SaveTable <Type>(Session targetSession) { if (TypeEx.IsSubclassOf(typeof(Type), typeof(XPObjectEx))) { XPCollection <Type> stores = new XPCollection <Type>(); foreach (Type store in stores) { XPObjectEx newItem = Activator.CreateInstance(typeof(Type), targetSession) as XPObjectEx; newItem.GetData <Type>(store); newItem.Save(); } } }
void CreateItem(DBFormItemBase item) { if (item != null && item.ViewType != null && TypeEx.IsSubclassOf(item.ViewType, typeof(DBViewBase))) { if (item.Document == null) { SplashScreenManager.ShowForm(null, typeof(WaitFormEx), true, true, false); SplashScreenManager.Default.SetWaitFormDescription(string.Format("Загружается форма \"{0}\"", item.Caption)); CheckAndActivateItem(item); item.View = Activator.CreateInstance(item.ViewType) as DBViewBase; if (item.View is DBViewInterface) ((DBViewInterface)item.View).RightMouseDown += DBFormItem_RightMouseDown; item.Document = BaseTabbedView.AddDocument(item.View); if (item.Document != null) { item.Document.Caption = item.Caption; item.Document.ImageIndex = item.ImageIndex; } if (!item.IsDocumentActivated) item.IsDocumentActivated = true; item.View.InvokeFormUpdate(this, null); SplashScreenManager.CloseForm(false); } else { SplashScreenManager.ShowForm(null, typeof(WaitFormEx), true, true, false); SplashScreenManager.Default.SetWaitFormDescription(string.Format("Обновляется форма \"{0}\"", item.Caption)); CheckAndActivateItem(item); BaseTabbedView.Controller.Activate(item.Document); item.View.InvokeFormUpdate(this, null); SplashScreenManager.CloseForm(false); } } }
public static List <Type> GetDerivedTypes(Type baseType, Assembly assembly) { // Get all types from the given assembly Type[] types = assembly.GetTypes(); List <Type> derivedTypes = new List <Type>(); for (int i = 0, count = types.Length; i < count; i++) { Type type = types[i]; if (TypeEx.IsSubclassOf(type, baseType)) { // The current type is derived from the base type, // so add it to the list derivedTypes.Add(type); } } return(derivedTypes); }
public override void InitializeNewComponent(IDictionary defaultValues) { object form = defaultValues["Parent"]; if (form != null && (TypeEx.IsSubclassOf(form.GetType(), typeof(Form)) || form.GetType() == typeof(Form))) { base.InitializeNewComponent(defaultValues); DBForm.InitializeVisibleComponents((Form)form); DBForm.OwnerForm = form as Form; } else { XtraMessageBox.Show("Данный объект не типа Form.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); DBForm.DestroyItself(); } }
public static void Transfer <TypeReal>(XPCollection xpCollection, Collection <TypeReal> collectionReal) { if (TypeEx.IsSubclassOf(typeof(TypeReal), typeof(LinkXPObject))) { Collection <XPObject> collection = new Collection <XPObject>(); foreach (XPObject server in xpCollection) { collection.Add(server); } foreach (TypeReal serverReal in collectionReal) { LinkXPObject link = serverReal as LinkXPObject; XPObject server = link.FindXPOject(collection) as XPObject; if (server != null) { collection.Remove(server); } } } }