Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
        void OwnerForm_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.S)
            {
                DBFormItemBase item = FindItemByDocument(BaseTabbedView.ActiveDocument);
                if (item != null)
                {
                    if (item.View is DBViewInterface)
                    {
                        DBViewInterface view = item.View as DBViewInterface;
                        view.DBInterface.SaveData();
                    }
                }
            }

            if (e.Control && e.KeyCode == Keys.L)
            {
                DBFormItemBase item = FindItemByDocument(BaseTabbedView.ActiveDocument);
                if (item != null)
                {
                    if (item.View is DBViewInterface)
                    {
                        DBViewInterface view = item.View as DBViewInterface;
                        view.DBInterface.LoadData();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Проверка формы на сохранения данных.
        /// </summary>
        void CheckAndActivateItem(DBFormItemBase item)
        {
            AllowSwitchMessage allowViewActiveLast = new AllowSwitchMessage(true, false);
            if (ViewActiveLast is DBViewInterface)
            {
                DBViewInterface view = ViewActiveLast as DBViewInterface;
                if (view.DBInterface != null)
                    allowViewActiveLast = view.DBInterface.GetAllowSwitch();
            }

            if (item.Document != null &&
                item.Document.Form != null)
            {
                if (allowViewActiveLast.IsMessage)
                {
                    item.Document.Form.Visible = false;
                    item.Document.Form.Visible = true;
                }
                else
                    if (!item.Document.Form.Visible)
                        item.Document.Form.Visible = true;
            }

            BaseNavBarControl.SelectedLink = item.BaseNavBarItem.Links[0];
            ItemActive = item;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Удание элемента коллекции.
        /// </summary>
        public void DestroyControl(DBFormItemBase item)
        {
            IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
            DesignerTransaction transaction = host.CreateTransaction("DeleteControl");

            HostComponent.DestroyComponent(host, item.BaseNavBarItem);

            transaction.Commit();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Создание иконки записи.
        /// </summary>
        public void CreateIcon(DBFormItemBase item, ViewMemberInfo info)
        {
            string imageName = GetImageFullName(info.ImageName);
            if (!ImageEx.IsExist(Icons, info.ImageName) && File.Exists(imageName))
            {
                Image image = Image.FromFile(imageName);
                Icons.Images.Add(image, info.ImageName);
            }

            item.ImageIndex = ImageEx.GetImageIndex(Icons, info.ImageName);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Обработчик события на изменение свойств ItemBase.
        /// </summary>
        void Item_PropertyChanged(object sender, EventArgs e)
        {
            DBFormItemBase item = sender as DBFormItemBase;

            if (item != null)
            {
                Caption    = item.Caption;
                ImageIndex = item.ImageIndex;
                ViewType   = item.ViewType;
                //TableType = item.TableType;
            }
        }
Ejemplo n.º 7
0
        protected override object CreateInstance(Type itemType)
        {
            DBFormItemBase dbItem = null;
            DBForm         dbForm = FindDBForm();

            if (dbForm != null)
            {
                dbItem = dbForm.CreateInstance();
            }

            return(dbItem);
        }
Ejemplo n.º 8
0
 void DBFormItem_RightMouseDown(object sender, XPObjectEventArgs e)
 {
     DBFormItemBase item = FindItemByTableType(e.TableType);
     if (item != null)
     {
         CreateItem(item);
         if (item.View is DBViewInterface)
         {
             DBViewInterface view = item.View as DBViewInterface;
             view.FocusRecord(e.Record);
         }
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Автоматическое создание элемента коллекции.
        /// </summary>
        public DBFormItemBase CreateInstance(ViewMemberInfo info = null)
        {
            DBFormItemBase item = null;

            if (info == null)
            {
                item = DBForm.CreateInstance(treeList: treeExist, memberExists: MemberExists);
            }
            else if (MemberExists.FindInfo(info) == null)
            {
                item = DBForm.CreateInstance(info, treeExist, MemberExists);
            }
            return(item);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Удание записи.
        /// </summary>
        public void DestroyInstance(DBFormItemBase item)
        {
            DestroyControl(item);

            if (item.Owner != null)
                item.Owner.Remove(item);
            if (item is IDisposable)
                ((IDisposable)item).Dispose();

            if (item.ImageIndex != -1)
            {
                DeleteUnusedImage(item.ImageIndex);
                Items.CorrectImageIndex();
            }

            item = null;
        }
Ejemplo n.º 11
0
        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);
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Создание всех элементов для данного типа поля таблицы БД.
        /// </summary>
        public void CreateControl(DBFormItemBase item, string name)
        {
            IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
            DesignerTransaction transaction = host.CreateTransaction("AddControl");

            item.DBForm = this;
            item.BaseNavBarItem = (NavBarItem)HostComponent.CreateComponent(host, typeof(NavBarItem), string.Format("{0}NavBarItem", name));
            item.BaseNavBarItem.AppearancePressed.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
            item.BaseNavBarItem.AppearancePressed.ForeColor = System.Drawing.Color.Red;
            item.BaseNavBarItem.AppearancePressed.Options.UseFont = true;
            item.BaseNavBarItem.AppearancePressed.Options.UseForeColor = true;

            BaseNavBarControl.Items.Add(item.BaseNavBarItem);
            BaseNavBarGroup.ItemLinks.Add(new NavBarItemLink(item.BaseNavBarItem));
            BaseNavBarGroup.SelectedLinkIndex = -1;
            item.UpdateAll();

            transaction.Commit();
        }
Ejemplo n.º 13
0
 void tabbedView_DocumentClosing(object sender, DocumentCancelEventArgs e)
 {
     TabbedView tabbedView = sender as TabbedView;
     AllowSwitchMessage allow = new AllowSwitchMessage(true, false);
     if (tabbedView != null)
     {                
         DBFormItemBase item = FindItemByDocument(tabbedView.ActiveDocument);
         if (item != null)
         {
             if (item.View is DBViewInterface)
             {
                 DBViewInterface view = item.View as DBViewInterface;
                 allow = view.DBInterface.GetAllowSwitch();
             }
         }
         if (allow.IsAllow)
             tabbedView.ActiveDocument.Form.Visible = false;
     }
     e.Cancel = true;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Создание записи для уже созданных полей таблицы
        /// </summary>
        public static ViewMemberInfo PrintExistData(TreeList treeList, DBFormItemBase item, ViewMemberInfos infos)
        {
            ViewMemberInfo info = new ViewMemberInfo() 
            { 
                ViewType = item.ViewType, 
                Caption = item.Caption, 
                ImageIndex = item.ImageIndex, 
                ImageName = item.ImageName, 
                Item = item 
            };

            infos.Add(info);

            TreeListNode node = FindNode(treeList, info);
            if (node != null)
            {
                treeList.FocusedNode = node;
                treeList.Selection.Clear();
                treeList.Selection.Add(treeList.FocusedNode);
            }
            return info;
        }
Ejemplo n.º 15
0
 void BaseTabbedView_DocumentDeactivated(object sender, DocumentEventArgs e)
 {
     DBFormItemBase item = FindItemByDocument(e.Document);
     if (item != null)
         ViewActiveLast = item.View;
 }
Ejemplo n.º 16
0
 void BaseTabbedView_DocumentActivated(object sender, DocumentEventArgs e)
 {
     DBFormItemBase item = FindItemByDocument(e.Document);
     if (item != null)
         CheckAndActivateItem(item);
 }
Ejemplo n.º 17
0
 void Items_LinksClicked(object sender, NavBarLinkEventArgs e)
 {
     NavBarItem barItem = sender as NavBarItem;
     DBFormItemBase item = FindItemByBarLink(barItem);
     CreateItem(item);
 }