예제 #1
0
        // 添加一个新的册对象
        // parameters:
        //      strRecPath  记录路径
        public int NewEntity(string strRecPath,
            byte[] timestamp,
            string strXml,
            bool ScrollIntoView,
            bool bAutoSetFocus,
            out EntityEditControl control,
            out string strError)
        {
            strError = "";
#if NO
            if (this.easyMarcControl1.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.easyMarcControl1.Invoke(d, args);

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

            control = new EntityEditControl();
            control.DisplayMode = "simple_register";
            control.HideSelection = false;
            control.Width = 120;
            control.AutoScroll = false;
            control.AutoSize = true;
            control.Font = this.Owner.Font;
            control.BackColor = Color.Transparent;
            control.Margin = new Padding(8, 8, 8, 8);
            // control.TableMargin = new Padding(100);
            control.TablePadding = new Padding(64,12,24,12);

            // 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;    // 让外界能感知到含有新册事项
            }

            AddEditEvents(control, true);

            // ClearBlank();

            // control.BackColor = ControlPaint.Dark(this.flowLayoutPanel1.BackColor);
            SetControlColor(control);
#if NO
            control.BackColor = this.flowLayoutPanel1.BackColor;
            control.ForeColor = this.flowLayoutPanel1.ForeColor;
#endif
            
            // this.flowLayoutPanel1.Controls.Add(control);
            AddEditControl(control);

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

            // this.AdjustFlowLayoutHeight();

            if (bAutoSetFocus == true)
                control.Focus();    // 这一句让 Edit Control 部分可见,但不是全部可见

            if (ScrollIntoView)
                this.flowLayoutPanel1.ScrollControlIntoView(control);

            return 0;
        }
예제 #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;
        }