예제 #1
0
        void _biblioRegister_EnsureVisible(object sender, EnsureVisibleEventArgs e)
        {
            //e.Rect.X -= this.label_color.Location.X;
            //e.Rect.Y -= this.label_color.Location.Y;

            (this.Container as EntityRegisterControl).EnsureVisible(this, e.Rect);
        }
예제 #2
0
        // 添加一个新的册对象
        // parameters:
        //      strRecPath  记录路径
        public int NewEntity(string strRecPath,
            byte [] timestamp,
            string strXml,
            bool ScrollIntoView,
            out string strError)
        {
            strError = "";

            if (this.InvokeRequired)
            {
                Delegate_NewEntity d = new Delegate_NewEntity(NewEntity);
                object[] args = new object[5];
                args[0] = strRecPath;
                args[1] = timestamp;
                args[2] = strXml;
                args[3] = ScrollIntoView;
                args[4] = strError;
                int result = (int)this.Invoke(d, args);

                // 取出out参数值
                strError = (string)args[4];
                return result;
            }

            EntityEditControl control = new EntityEditControl();
            control.DisplayMode = "simple_register";
            control.Width = 120;
            control.AutoScroll = false;
            control.AutoSize = true;
            control.Font = this.Font;
            control.BackColor = Color.Transparent;

            // control.ErrorInfo = "测试文字 asdfasdf a asd fa daf a df af asdf asdf adf asdf asdf asf asdf asdf ---- ";

            if (string.IsNullOrEmpty(strXml) == false)
            {
                int nRet = control.SetData(strXml, strRecPath, timestamp, out strError);
                if (nRet == -1)
                    return -1;
            }
            else
            {
                control.Initializing = false;
                // control.Barcode = strItemBarcode;
                if (string.IsNullOrEmpty(control.RefID) == true)
                    control.RefID = Guid.NewGuid().ToString();
            }

            if (timestamp == null)
            {
                control.CreateState = ItemDisplayState.New;
                control.Changed = true;
                this.EntitiesChanged = true;    // 让外界能感知到含有新册事项
            }

            control.PaintContent += new PaintEventHandler(control_PaintContent);
            control.ContentChanged += new DigitalPlatform.ContentChangedEventHandler(control_ContentChanged);
            control.GetValueTable += new DigitalPlatform.GetValueTableEventHandler(control_GetValueTable);
            control.AppendMenu += new ApendMenuEventHandler(control_AppendMenu);

            ClearBlank();

            this.flowLayoutPanel1.Controls.Add(control);

            // this.flowLayoutPanel1.PerformLayout();
            // this.tableLayoutPanel1.PerformLayout();

            this.AdjustFlowLayoutHeight();

            if (ScrollIntoView)
            {
                this.flowLayoutPanel1.ScrollControlIntoView(control);
                if (this.EnsureVisible != null)
                {
                    EnsureVisibleEventArgs e1 = new EnsureVisibleEventArgs();
                    e1.Control = control;
                    e1.Rect = new Rectangle(control.Location, control.Size);
                    e1.Rect.X += this.flowLayoutPanel1.Location.X;
                    e1.Rect.Y += this.flowLayoutPanel1.Location.Y;
                    this.EnsureVisible(this, e1);
                }
            }

            // this.BeginInvoke(new Action<Control>(EnsureVisible), control);

            return 0;
        }