Ejemplo n.º 1
0
        internal void FillList()
        {
            this.dpTable1.Rows.Clear();

            if (this.PatronSummaries == null)
            {
                return;
            }


            foreach (PatronSummary summary in this.PatronSummaries)
            {
                DpRow row = new DpRow();
                row.BackColor = SystemColors.Window;
                row.ForeColor = SystemColors.WindowText;

                DpCell cell = new DpCell();
                cell.Text      = summary.Barcode + " " + summary.Name;
                cell.OwnerDraw = true;
                row.Add(cell);

                this.dpTable1.Rows.Add(row);
            }

            // 放最后一行可见
            if (this.dpTable1.Rows.Count > 0)
            {
                this.dpTable1.EnsureVisible(this.dpTable1.Rows[dpTable1.Rows.Count - 1]);
            }
        }
Ejemplo n.º 2
0
        // parameters:
        //      strSpeakStyle   状态/状态+内容
        public string GetSpeakContent(DpRow row, string strSpeakStyle)
        {
            if (this.State == "finish" || this.State == "error")
            {
                string strText = "";
                if (this.Color == "red")
                {
                    strText = "错误: ";
                }
                else if (this.Color == "yellow")
                {
                    strText = "提示: ";
                }
                else
                {
                    return("");
                }
                if (strSpeakStyle == "状态")
                {
                    return(strText);
                }
                // 状态+内容
                return(strText + this.ErrorInfo);
            }

            return("");
        }
Ejemplo n.º 3
0
        static void SetGrayText(DpRow row)
        {
            RowTag tag = new RowTag();

            tag.GrayText  = true;
            row.Tag       = tag;
            row.ForeColor = SystemColors.GrayText;
        }
Ejemplo n.º 4
0
        private void dpTable_items_PaintBack(object sender, PaintBackArgs e)
        {
            if (!(e.Item is DpRow))
            {
                if (e.Item is DpCell)
                {
                    DpCell cell = e.Item as DpCell;

                    if (cell.BackColor != Color.Transparent)
                    {
                        using (Brush brush = new SolidBrush(cell.BackColor))
                        {
                            e.pe.Graphics.FillRectangle(brush, e.Rect);
                        }
                    }
                }
                return;
            }

            DpRow row = e.Item as DpRow;

            bool bGray = IsGray(row);

            if (row.Selected == true)
            {
                if (row.Control.Focused == true)
                {
                    using (Brush brush = new SolidBrush(
                               bGray ? Color.FromArgb(240, 240, 240) : row.Control.HighlightBackColor
                               ))
                    {
                        e.pe.Graphics.FillRectangle(brush, e.Rect);
                    }
                }
                else
                {
                    // textColor = SystemColors.InactiveCaptionText;
                    using (Brush brush = new SolidBrush(
                               bGray ? Color.FromArgb(240, 240, 240) : row.Control.InactiveHighlightBackColor
                               ))
                    {
                        e.pe.Graphics.FillRectangle(brush, e.Rect);
                    }
                }
            }
            else
            {
                if (row.BackColor != Color.Transparent)
                {
                    using (Brush brush = new SolidBrush(
                               row.Control.BackColor
                               ))
                    {
                        e.pe.Graphics.FillRectangle(brush, e.Rect);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void dpTable_items_DoubleClick(object sender, EventArgs e)
        {
            string strError = "";

            if (this.dpTable_items.SelectedRows.Count != 1)
            {
                strError = "请选择一行";
                goto ERROR1;
            }

            // 检查是否为灰色文字
            if (Control.ModifierKeys == Keys.Control)
            {
                // 按下 Control 键的时候灰色事项也可以操作
            }
            else
            {
                DpRow row = this.dpTable_items.SelectedRows[0];
                if (IsGray(row) == true)
                {
                    strError = "当前功能不允许选择此行。";
                    if (this.FunctionType == "borrow")
                    {
                        strError += "只能对尚未借出的、状态为空的册进行借书操作";
                    }

                    if (this.FunctionType == "return" &&
                        string.IsNullOrEmpty(this.VerifyBorrower) == false)
                    {
                        strError += "(验证还书时)只能对在借状态的、并且是特定读者借了的册进行还书操作";
                    }
                    else if (this.FunctionType == "return")
                    {
                        strError += "只能对在借状态的册进行还书操作";
                    }

                    if (this.FunctionType == "renew")
                    {
                        strError += "只能对在借状态的册进行续借操作";
                    }
                    goto ERROR1;
                }
            }

            // 如果正在检索
            if (this.m_nInSearching > 0)
            {
                Progress.DoStop();
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Ejemplo n.º 6
0
        static bool IsGray(DpRow row)
        {
            if (row.Tag == null)
            {
                return(false);
            }
            RowTag tag = row.Tag as RowTag;

            return(tag.GrayText);
        }
Ejemplo n.º 7
0
        public void RefreshPatronCardDisplay(DpRow row)
        {
            if (row.Count < 3)
                return;

            DpCell cell = row[2];
            if (this.Action == "load_reader_info")
                cell.OwnerDraw = true;

            cell.Relayout();
        }
Ejemplo n.º 8
0
        private void dpTable1_PaintRegion(object sender, DigitalPlatform.CommonControl.PaintRegionArgs e)
        {
            if (e.Action == "query")
            {
                e.Height = BAR_HEIGHT + TOP_BLANK;
                DpCell cell = e.Item as DpCell;
                DpRow  row  = cell.Container;

                int index = this.dpTable1.Rows.IndexOf(row);
                if (index == -1)
                {
                    Debug.Assert(false, "");
                    return;
                }

                if (index >= this.PatronSummaries.Count)
                {
                    Debug.Assert(false, "");
                    return;
                }

                PatronSummary summary = this.PatronSummaries[index];
                if (summary != null)
                {
                    cell.Tag = summary;
                }
                return;
            }


            // paint
            {
                DpCell cell = e.Item as DpCell;
                if (cell == null)
                {
                    Debug.Assert(false, "");
                    return;
                }
                PatronSummary summary = cell.Tag as PatronSummary;
                if (summary == null)
                {
                    Debug.Assert(false, "");
                    return;
                }

                ColorSummaryControl.DoPaint(e.pe.Graphics,
                                            e.X,
                                            e.Y + TOP_BLANK,
                                            new Size(e.Width, e.Height - TOP_BLANK),
                                            summary.ColorList);
            }
        }
Ejemplo n.º 9
0
        DpRow AddNewRow(string name, string new_message_count)
        {
            DpRow row = new DpRow();

            row.Add(new DpCell());
            row.Add(new DpCell {
                Text = name
            });
            row.Add(new DpCell {
                Text = new_message_count
            });
            this.dpTable_groups.Rows.Add(row);
            return(row);
        }
Ejemplo n.º 10
0
        void AddTraceItem(DpRow row)
        {
            AmazonBiblioInfo info = row.Tag as AmazonBiblioInfo;

            if (info != null && string.IsNullOrEmpty(info.ImageUrl) == false)
            {
                TraceImage trace = new TraceImage();
                trace.ImageUrl = info.ImageUrl;
                trace.Row      = row;
                lock (_trace_images)
                {
                    _trace_images.Add(trace);
                }
            }
        }
Ejemplo n.º 11
0
 void OpenSelectedRecord()
 {
     if (this.dpTable_items.SelectedRows.Count == 1)
     {
         DpRow row = this.dpTable_items.SelectedRows[0];
         if (string.IsNullOrEmpty(row[0].Text) == true)
         {
             LoadNextBatch();
         }
         else
         {
             button_OK_Click(this, new EventArgs());
         }
     }
 }
Ejemplo n.º 12
0
        public void RefreshPatronCardDisplay(DpRow row)
        {
            if (row.Count < 3)
            {
                return;
            }

            DpCell cell = row[2];

            if (this.Action == "load_reader_info")
            {
                cell.OwnerDraw = true;
            }

            cell.Relayout();
        }
Ejemplo n.º 13
0
        void AddNextCmdLine()
        {
            DpRow row = new DpRow();

            DpCell cell = new DpCell();

            cell.Text = "";
            row.Add(cell);

            cell      = new DpCell();
            cell.Text = "";
            row.Add(cell);

            cell      = new DpCell();
            cell.Text = "共命中 " + _search.HitCount.ToString() + " 条。双击调入下一批命中记录 ...";
            row.Add(cell);

            this.dpTable_items.Rows.Add(row);
        }
Ejemplo n.º 14
0
        // parameters:
        //      strSpeakStyle   状态/状态+内容
        public string GetSpeakContent(DpRow row, string strSpeakStyle)
        {
            if (this.State == "finish" || this.State == "error")
            {
                string strText = "";
                if (this.Color == "red")
                    strText = "错误: ";
                else if (this.Color == "yellow")
                    strText = "提示: ";
                else
                    return "";
                if (strSpeakStyle == "状态")
                    return strText;
                // 状态+内容
                return strText + this.ErrorInfo;
            }

            return "";
        }
Ejemplo n.º 15
0
 private void dpTable_items_SelectionChanged(object sender, EventArgs e)
 {
     if (this.dpTable_items.SelectedRows.Count != 1)
     {
         this.button_OK.Enabled = false;
     }
     else
     {
         // 检查是否为灰色文字
         DpRow row = this.dpTable_items.SelectedRows[0];
         if (IsGray(row) == true)
         {
             this.button_OK.Enabled = false;
         }
         else
         {
             this.button_OK.Enabled = true;
         }
     }
 }
Ejemplo n.º 16
0
        // 打开到 种册窗
        void menuItem_loadToEntityForm_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.dpTable_items.SelectedRows.Count == 0)
            {
                strError = "尚未选定要打开的册事项";
                goto ERROR1;
            }

            DpRow  selected_row   = this.dpTable_items.SelectedRows[0];
            string strItemBarcode = selected_row[COLUMN_ITEMBARCODE].Text;

            if (string.IsNullOrEmpty(strItemBarcode) == true)
            {
                strError = "所选定的册事项不具备册条码号信息";
                goto ERROR1;
            }

            EntityForm form = Program.MainForm.EnsureEntityForm();

            Global.Activate(form);

            if (strItemBarcode.StartsWith("@biblioRecPath:") == true)
            {
                form.LoadRecordOld(strItemBarcode.Substring("@biblioRecPath:".Length), "", true);
            }
            else
            {
                form.LoadItemByBarcode(strItemBarcode, false);
            }

            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Ejemplo n.º 17
0
        // 获得一个 DpRow 行的用于 Copy 的文本
        static string GetRowText(DpRow row)
        {
            StringBuilder text = new StringBuilder(4096);
            int           i    = 0;

            foreach (DpCell cell in row)
            {
                // 跳过第一列
                if (i > 0)
                {
                    if (text.Length > 0)
                    {
                        text.Append("\t");
                    }
                    text.Append(cell.Text);
                }

                i++;
            }

            return(text.ToString());
        }
Ejemplo n.º 18
0
        // TODO: 可否通过一个事件,在事件中让 EntityForm 通过 FloatingMessage 显示报错信息
        // 或者用 WebBrowser 控件显示报错信息
        public void DisplayError(string strError)
        {
            this.ActionTable.Rows.Clear();
            this.ActionTable.MaxTextHeight = 500;

            DpRow item = new DpRow();

            DpCell cell = new DpCell("");

            item.Add(cell);

            // 快捷键
            cell = new DpCell();
            item.Add(cell);

            // 说明
            cell = new DpCell(strError);
            // cell.Font = new Font(this.ActionTable.Font.FontFamily, this.ActionTable.Font.SizeInPoints * 2, FontStyle.Bold, GraphicsUnit.Point);
            item.Add(cell);

            item.Tag = new ScriptAction();
            this.ActionTable.Rows.Add(item);
        }
Ejemplo n.º 19
0
        internal void FillList()
        {
            this.dpTable1.Rows.Clear();

            if (this.PatronSummaries == null)
                return;

            
            foreach(PatronSummary summary in this.PatronSummaries)
            {
                DpRow row = new DpRow();
                row.BackColor = SystemColors.Window;
                row.ForeColor = SystemColors.WindowText;

                DpCell cell = new DpCell();
                cell.Text = summary.Barcode + " " + summary.Name;
                cell.OwnerDraw = true;
                row.Add(cell);

                this.dpTable1.Rows.Add(row);
            }

            // 放最后一行可见
            if (this.dpTable1.Rows.Count > 0)
                this.dpTable1.EnsureVisible(this.dpTable1.Rows[dpTable1.Rows.Count - 1]);

        }
Ejemplo n.º 20
0
        private void button_dpTable_fill_Click(object sender, EventArgs e)
        {
            if (this.dpTable1.Columns.Count == 0)
            {
                for (int i = 0; i < 10; i++)
                {
                    DpColumn cell = new DpColumn();
                    cell.Text = "column " + i.ToString();
                    cell.Width = 100;
                    this.dpTable1.Columns.Add(cell);
                }
            }

            string strImageFileName = Path.Combine(this.MainForm.DataDir, "ajax-loader.gif");
            Image image = Image.FromFile(strImageFileName);

            for (int i = 0; i < 10; i++)
            {
                DpRow line = new DpRow();
                line.ForeColor = System.Drawing.Color.Yellow;
                for (int j = 0; j < 10; j++)
                {
                    DpCell cell = new DpCell();
                    if (j == 0)
                        cell.Image = image;
                    cell.Text = "asdf asd fa sdfa sdf asd fa sdf" + i.ToString() + " " + j.ToString();
                    if (j == 5)
                    {
                        cell.BackColor = System.Drawing.Color.Green;
                        cell.ForeColor = System.Drawing.Color.White;
                        cell.Font = new System.Drawing.Font(this.dpTable1.Font, FontStyle.Bold);

                    }
                        if (i == 2)
                            cell.Alignment = DpTextAlignment.InheritLine;
                    line.Add(cell);
                }

                if (i == 2)
                {
                    line.BackColor = System.Drawing.Color.Red;
                    line.Font = new System.Drawing.Font(this.dpTable1.Font, FontStyle.Italic);
                    line.Alignment = StringAlignment.Center;
                }

                this.dpTable1.Rows.Add(line);
            }

            /*
            {
                DpRow line = new DpRow();
                line.Style = DpRowStyle.Seperator;
                line.BackColor = Color.Blue;
                line.ForeColor = Color.White;
                this.dpTable1.Rows.Add(line);

            }
             * */
        }
Ejemplo n.º 21
0
        // 加入书目行
        void AddBiblioLine(string strBiblioRecPath)
        {
            string strError = "";

            string strVolume = "";
            string strPrice = "";

            GetVolume(strBiblioRecPath,
            out strVolume,
            out strPrice);

            Color colorBack = Color.LightGreen;

            DpRow row = new DpRow();
#if NO
            // 设为灰色行
            SetGrayText(row);
#endif

            // 状态
            DpCell cell = new DpCell();
            cell.BackColor = colorBack;
            cell.Text = "";
            row.Add(cell);

            // 册条码号
            cell = new DpCell();
            cell.BackColor = colorBack;
            cell.Text = "@biblioRecPath:" + strBiblioRecPath;
            row.Add(cell);

            // 在借情况
            cell = new DpCell();
            cell.BackColor = colorBack;
#if NO
            {
                    if (IsGray(row) == true)
                        cell.BackColor = Color.FromArgb(220, 220, 0);
                    else
                        cell.BackColor = Color.FromArgb(180, 180, 0);

                cell.ForeColor = Color.FromArgb(255, 255, 255);
                cell.Alignment = DpTextAlignment.Center;
                cell.Text = "";
            }
#endif
            row.Add(cell);

            // 书目摘要
            string strSummary = "";
            {
                int nRet = this.MainForm.GetBiblioSummary("@bibliorecpath:" + strBiblioRecPath,
                    "",
                    false,
                    out strSummary,
                    out strError);
                if (nRet == -1)
                    strSummary = strError;
            }
            cell = new DpCell();
            cell.BackColor = colorBack;
            cell.Text = strSummary;
            row.Add(cell);

            // 卷册
            cell = new DpCell();
            cell.BackColor = colorBack;
            cell.Text = strVolume;
            row.Add(cell);

            // 地点
            cell = new DpCell();
            cell.BackColor = colorBack;
            cell.Text = "";
            row.Add(cell);

            // 价格
            cell = new DpCell();
            cell.BackColor = colorBack;
            cell.Text = strPrice;
            row.Add(cell);

            // 册记录路径
            cell = new DpCell();
            cell.BackColor = colorBack;
            cell.Text = strBiblioRecPath;
            row.Add(cell);

            this.dpTable_items.Rows.Add(row);
        }
Ejemplo n.º 22
0
        // 将一条书目记录下属的若干册记录装入列表
        // return:
        //      -2  用户中断
        //      -1  出错
        //      >=0 装入的册记录条数
        int LoadBiblioSubItems(string strBiblioRecPath,
            out string strError)
        {
            strError = "";

            Progress.SetMessage("正在装入书目记录 '"+strBiblioRecPath+"' 下属的册记录 ...");

            int nCount = 0;

            long lPerCount = 100; // 每批获得多少个
            long lStart = 0;
            long lResultCount = 0;
            long lCount = -1;
            for (; ; )
            {
                if (Progress.State != 0)
                {
                    strError = "用户中断";
                    return -2;
                }

                EntityInfo[] entities = null;

                long lRet = Channel.GetEntities(
         Progress,
         strBiblioRecPath,
         lStart,
         lCount,
         "",  // bDisplayOtherLibraryItem == true ? "getotherlibraryitem" : "",
         "zh",
         out entities,
         out strError);
                if (lRet == -1)
                    return -1;

                lResultCount = lRet;

                if (lRet == 0)
                    return nCount;

                Debug.Assert(entities != null, "");

                foreach (EntityInfo entity in entities)
                {
                    string strXml = entity.OldRecord;

                    XmlDocument dom = new XmlDocument();
                    {
                        try
                        {
                            if (string.IsNullOrEmpty(strXml) == false)
                                dom.LoadXml(strXml);
                            else
                                dom.LoadXml("<root />");
                        }
                        catch (Exception ex)
                        {
                            strError = "XML 装入 DOM 出错: " + ex.Message;
                            return -1;
                        }
                    }

                    DpRow row = new DpRow();

                    string strState = DomUtil.GetElementText(dom.DocumentElement, "state");
                    string strBorrower = DomUtil.GetElementText(dom.DocumentElement, "borrower");
                    if (this.FunctionType == "borrow")
                    {
                        // 在借的册、或者状态有值的需要显示为灰色
                        if (string.IsNullOrEmpty(strBorrower) == false
                            || string.IsNullOrEmpty(strState) == false)
                            SetGrayText(row);
                    }
                    else if (this.FunctionType == "return")
                    {
                        // 没有在借的册需要显示为灰色
                        if (string.IsNullOrEmpty(strBorrower) == true)
                            SetGrayText(row);
                        if (string.IsNullOrEmpty(this.VerifyBorrower) == false)
                        {
                            // 验证还书时,不是要求的读者所借阅的册,显示为灰色
                            if (strBorrower != this.VerifyBorrower)
                                SetGrayText(row);
                        }
                    }
                    else if (this.FunctionType == "renew")
                    {
                        // 没有在借的册需要显示为灰色
                        if (string.IsNullOrEmpty(strBorrower) == true)
                            SetGrayText(row);
                    }

                    string strBarcode = DomUtil.GetElementText(dom.DocumentElement, "barcode");
                    string strRefID = DomUtil.GetElementText(dom.DocumentElement, "refID");

                    // 状态
                    DpCell cell = new DpCell();
                    cell.Text = strState;
                    row.Add(cell);

                    // 册条码号
                    cell = new DpCell();
                    if (string.IsNullOrEmpty(strBarcode) == false)
                        cell.Text = strBarcode;
                    else
                        cell.Text = "@refID:" + strRefID;
                    row.Add(cell);

                    // 在借情况
                    cell = new DpCell();
                    if (string.IsNullOrEmpty(strBorrower) == false)
                    {
                        string strReaderSummary = this.MainForm.GetReaderSummary(strBorrower, false);
                        bool bError = (string.IsNullOrEmpty(strReaderSummary) == false && strReaderSummary[0] == '!');

                        if (bError == true)
                            cell.BackColor = Color.FromArgb(180, 0, 0);
                        else
                        {
                            if (IsGray(row) == true)
                                cell.BackColor = Color.FromArgb(220, 220, 0);
                            else
                                cell.BackColor = Color.FromArgb(180, 180, 0);
                        }

                        if (bError == false)
                            cell.Font = new System.Drawing.Font(this.dpTable_items.Font.FontFamily.Name, this.dpTable_items.Font.Size * 2, FontStyle.Bold);

                        cell.ForeColor = Color.FromArgb(255, 255, 255);
                        cell.Alignment = DpTextAlignment.Center;
                        cell.Text = strReaderSummary;
                        // TODO: 后面还可加上借阅时间,应还时间
                    }
                    row.Add(cell);

                    // 书目摘要
                    string strSummary = "";
                    if (entity.ErrorCode != ErrorCodeValue.NoError)
                    {
                        strSummary = entity.ErrorInfo;
                    }
                    else
                    {
                        int nRet = this.MainForm.GetBiblioSummary("@bibliorecpath:" + strBiblioRecPath,
                            "",
                            false,
                            out strSummary,
                            out strError);
                        if (nRet == -1)
                            strSummary = strError;
                    }
                    cell = new DpCell();
                    cell.Text = strSummary;
                    row.Add(cell);

                    // 卷册
                    string strVolumn = DomUtil.GetElementText(dom.DocumentElement, "volumn");
                    cell = new DpCell();
                    cell.Text = strVolumn;
                    row.Add(cell);

                    // 地点
                    string strLocation = DomUtil.GetElementText(dom.DocumentElement, "location");
                    cell = new DpCell();
                    cell.Text = strLocation;
                    row.Add(cell);

                    // 价格
                    string strPrice = DomUtil.GetElementText(dom.DocumentElement, "price");
                    cell = new DpCell();
                    cell.Text = strPrice;
                    row.Add(cell);

                    // 册记录路径
                    cell = new DpCell();
                    cell.Text = entity.OldRecPath;
                    row.Add(cell);

                    this.dpTable_items.Rows.Add(row);
                    nCount++;
                }

                lStart += entities.Length;
                if (lStart >= lResultCount)
                    break;

                if (lCount == -1)
                    lCount = lPerCount;

                if (lStart + lCount > lResultCount)
                    lCount = lResultCount - lStart;
            }

            if (lStart > 0)
            {
                DpRow row = new DpRow();
                row.Style = DpRowStyle.Seperator;
                this.dpTable_items.Rows.Add(row);
            }

            return nCount;
        }
Ejemplo n.º 23
0
        // 替换浏览列内容
        public void ChangeBiblioBrowseLine(
            DpRow row,
            string strBrowseText,
            RegisterBiblioInfo info)
        {
            if (this.dpTable_browseLines.InvokeRequired)
            {
                // 事件是在多线程上下文中触发的,需要 Invoke 显示信息
                this.BeginInvoke(new Action<DpRow, string, RegisterBiblioInfo>(ChangeBiblioBrowseLine),
                    row,
                    strBrowseText,
                    info);
                return;
            }

            List<string> columns = StringUtil.SplitList(strBrowseText, '\t');


            // 0: index
            // 1: recpath

            int index = COLUMN_IMAGE + 1;
            foreach (string s in columns)
            {
                if (index >= row.Count)
                    break;
                row[index].Text = s;
                index++;
            }

            row.Tag = info;
            // PrepareCoverImage(row);
        }
Ejemplo n.º 24
0
        // 设置图像文件
        public void AsyncGetImageComplete(DpRow row,
            string strBiblioRecPath,
            string strFileName,
            string strErrorInfo)
        {
            if (this.dpTable_browseLines.InvokeRequired)
            {
                this.Invoke(new Action<DpRow, string, string, string>(AsyncGetImageComplete),
                    row, strBiblioRecPath, strFileName, strErrorInfo);
                return;
            }

            // row[COLUMN_IMAGE].Text = strFileName;

            if (string.IsNullOrEmpty(strErrorInfo) == false)
                row[COLUMN_IMAGE].Text = "!" + strErrorInfo;
            else
                SetImage(row[COLUMN_IMAGE], strFileName);

#if NO
            // 已经选定了书目记录的情况
            if (row == null)
            {
                if (string.IsNullOrEmpty(strErrorInfo) == false)
                {
                    // 如何报错?
                    // row 为空
                    // this.pictureBox1.Image = null;
                    return;
                }

                // 给相关浏览行设定
                row = FindRowByRecPath(this.BiblioRecPath + "@" + this.ServerName);
                if (row != null)
                {
                    RegisterBiblioInfo info = row.Tag as RegisterBiblioInfo;
                    if (info != null)
                        info.CoverImageFileName = strFileName;
                }

                if (strBiblioRecPath == this.BiblioRecPath
                    && this.DisplayMode == "detail")
                {
                    this.ImageFileName = strFileName;
                    this.pictureBox1.LoadAsync(strFileName);
                }
                return;
            }

            {
                RegisterBiblioInfo info = row.Tag as RegisterBiblioInfo;
                if (info != null)
                    info.CoverImageFileName = strFileName;

                if (this.DisplayMode == "select"
                    && this.dpTable_browseLines.SelectedRows.Count == 1
                    && this.dpTable_browseLines.SelectedRows[0] == row)
                    this.pictureBox1.LoadAsync(strFileName);
            }
#endif
        }
Ejemplo n.º 25
0
        public void RefreshState()
        {
            if (this.SetMenu == null)
            {
                return;
            }

            RefreshMenuEventArgs e = new RefreshMenuEventArgs();

            e.Actions = this.Actions;
            e.sender  = this.sender;
            e.e       = this.e;

            this.SetMenu(this, e);

            DpRow first_selected_row = null;
            DpRow last_selected_row  = null;

            for (int i = 0; i < this.ActionTable.Rows.Count; i++)
            {
                DpRow row = this.ActionTable.Rows[i];

                if (row.Style == DpRowStyle.Seperator)
                {
                    continue;
                }

                ScriptAction action = (ScriptAction)row.Tag;
                if (action == null)
                {
                    Debug.Assert(false, "");
                    continue;
                }

                if (this.Actions == null || this.Actions.IndexOf(action) == -1)
                {
                    row.Selected = false;
                    continue;
                }

                if (row.Count == 0)
                {
                    continue;
                }

                Debug.Assert(row.Count >= 4, "");

                // 刷新一行
                row[0].Text = action.Name;
                string strText = "";
                if (action.ShortcutKey != (char)0)
                {
                    strText = new string(action.ShortcutKey, 1);
                    strText = strText.ToUpper();
                }
                row[1].Text = strText;
                row[2].Text = action.Comment;
                row[3].Text = action.ScriptEntry;

                row.Selected = action.Active;

                if (first_selected_row == null &&
                    row.Selected == true)
                {
                    first_selected_row = row;
                }
                if (row.Selected == true)
                {
                    last_selected_row = row;
                }
            }

            if (first_selected_row != null)
            {
                first_selected_row.EnsureVisible();
            }
            if (last_selected_row != null &&
                last_selected_row != first_selected_row)
            {
                last_selected_row.EnsureVisible();
            }
        }
Ejemplo n.º 26
0
        // 设置封面图像
        // 按照这样的次序:1) 如果是 http: 直接设置; 2) 如果有本地文件,直接设置; 3) 从服务器获取,然后异步设置
        void SetCoverImage(string strUrl,
            string strLocalImageFileName,
            string strBiblioRecPath,
            DpRow row)
        {
            if (StringUtil.HasHead(strUrl, "http:") == true)
                this.pictureBox1.LoadAsync(strUrl);
            else
            {
                if (string.IsNullOrEmpty(strLocalImageFileName) == false)
                    this.pictureBox1.LoadAsync(strLocalImageFileName);
                else
                {
                    RegisterBiblioInfo info = null;
                    if (row != null)
                        info = row.Tag as RegisterBiblioInfo;

                    if (info != null && info.CoverImageRquested == true)
                        return;

                    // 通过 dp2library 协议获得图像文件
                    if (this.AsyncGetImage != null)
                    {
                        AsyncGetImageEventArgs e = new AsyncGetImageEventArgs();
                        e.RecPath = strBiblioRecPath;
                        e.ObjectPath = strUrl;
                        e.FileName = "";
                        e.Row = row;
                        this.AsyncGetImage(this, e);
                        // 修改状态,表示已经发出请求
                        if (row != null)
                        {
                            if (info != null)
                                info.CoverImageRquested = true;
                        }
                        else
                        {
                            this.CoverImageRequested = true;
                        }
                    }
                }
            }

        }
Ejemplo n.º 27
0
        // 加入一个浏览行
        public void AddBiblioBrowseLine(
            string strBiblioRecPath,
            string strBrowseText,
            AmazonBiblioInfo info)
        {
            if (this.dpTable_items.InvokeRequired)
            {
                // 事件是在多线程上下文中触发的,需要 Invoke 显示信息
                this.BeginInvoke(new Action <string, string, AmazonBiblioInfo>(AddBiblioBrowseLine),
                                 strBiblioRecPath,
                                 strBrowseText,
                                 info);
                return;
            }

            // 检查已经存在的最后一行是否为命令行
            if (this.dpTable_items.Rows.Count > 0)
            {
                DpRow tail = this.dpTable_items.Rows[this.dpTable_items.Rows.Count - 1];
                if (string.IsNullOrEmpty(tail[0].Text) == true)
                {
                    this.dpTable_items.Rows.RemoveAt(this.dpTable_items.Rows.Count - 1);
                }
            }

            List <string> columns = StringUtil.SplitList(strBrowseText, '\t');
            DpRow         row     = new DpRow();

            row.LineAlignment = StringAlignment.Center;

            DpCell cell = new DpCell();

            cell.Text      = (this.dpTable_items.Rows.Count + 1).ToString();
            cell.Font      = this._idFont;
            cell.ForeColor = SystemColors.GrayText;
            row.Add(cell);

#if NO
            cell      = new DpCell();
            cell.Text = strBiblioRecPath;
            row.Add(cell);
#endif

            cell = new DpCell();
            // cell.Text = info.ImageUrl;
            // cell.Text = "正在加载图片 ...";
            row.Add(cell);

            int i = 0;
            foreach (string s in columns)
            {
                cell      = new DpCell();
                cell.Text = s;
                if (i == 0)
                {
                    cell.Font = this._titleFont;
                }

                row.Add(cell);
                i++;
            }

            row.Tag = info;
            // row[COLUMN_IMAGE].OwnerDraw = true;

            this.dpTable_items.Rows.Add(row);

#if NO
            if (string.IsNullOrEmpty(info.ImageUrl) == false)
            {
                TraceImage trace = new TraceImage();
                trace.ImageUrl = info.ImageUrl;
                trace.Row      = row;
                lock (_trace_images)
                {
                    _trace_images.Add(trace);
                }
            }
#endif
            AddTraceItem(row);
        }
Ejemplo n.º 28
0
        // 准备特定浏览行的封面图像
        void PrepareCoverImage(DpRow row)
        {
            Debug.Assert(row != null, "");

            RegisterBiblioInfo info = row.Tag as RegisterBiblioInfo;
            if (info == null)
                return;

            if (string.IsNullOrEmpty(info.CoverImageFileName) == false)
                return;

            string strMARC = info.OldXml;
            if (string.IsNullOrEmpty(strMARC) == true)
                return;

            string strUrl = ScriptUtil.GetCoverImageUrl(strMARC);
            if (string.IsNullOrEmpty(strUrl) == true)
                return;

            if (StringUtil.HasHead(strUrl, "http:") == true)
                return;

            if (info != null && info.CoverImageRquested == true)
                return;

            // 通过 dp2library 协议获得图像文件
            if (this.AsyncGetImage != null)
            {
                AsyncGetImageEventArgs e = new AsyncGetImageEventArgs();
                e.RecPath = row[1].Text;
                e.ObjectPath = strUrl;
                e.FileName = "";
                e.Row = row;
                this.AsyncGetImage(this, e);
                // 修改状态,表示已经发出请求
                if (row != null)
                {
                    if (info != null)
                        info.CoverImageRquested = true;
                }
                else
                {
                    this.CoverImageRequested = true;
                }
            }
        }
Ejemplo n.º 29
0
        // 设置特定浏览行的封面图像
        void SetCoverImage(DpRow row)
        {
            RegisterBiblioInfo info = row.Tag as RegisterBiblioInfo;
            if (info == null)
                goto CLEAR;

            string strMARC = info.OldXml;
            if (string.IsNullOrEmpty(strMARC) == true)
                goto CLEAR;

            string strUrl = ScriptUtil.GetCoverImageUrl(strMARC);
            if (string.IsNullOrEmpty(strUrl) == true)
                goto CLEAR;

#if NO
            if (StringUtil.HasHead(strUrl, "http:") == true)
                this.pictureBox1.LoadAsync(strUrl);
            else
            {
                if (string.IsNullOrEmpty(info.CoverImageFileName) == false)
                    this.pictureBox1.LoadAsync(info.CoverImageFileName);
                else
                {
                    // 通过 dp2library 协议获得图像文件
                    if (this.AsyncGetImage != null)
                    {
                        string strBiblioRecPath = row[1].Text;
                        AsyncGetImageEventArgs e = new AsyncGetImageEventArgs();
                        e.RecPath = strBiblioRecPath;
                        e.ObjectPath = strUrl;
                        e.FileName = "";
                        e.Row = row;
                        this.AsyncGetImage(this, e);
                    }
                }
            }
#endif
            // 设置封面图像
            // 按照这样的次序:1) 如果是 http: 直接设置; 2) 如果有本地文件,直接设置; 3) 从服务器获取,然后异步设置
            SetCoverImage(strUrl,
                info.CoverImageFileName,
                row[1].Text,
                row);
            return;
        CLEAR:
            this.pictureBox1.Image = null;
        }
Ejemplo n.º 30
0
        public void RefreshDisplay(DpRow row)
        {
            // 初始化列
            if (row.Count == 0)
            {
                // 色条
                DpCell cell = new DpCell();
                row.Add(cell);

                // 状态
                cell            = new DpCell();
                cell.ImageIndex = -1;
                row.Add(cell);

                // 内容
                cell = new DpCell();
                row.Add(cell);
            }

            bool bStateText = false;

            // 状态
            // row[0].Text = this.State;
            DpCell state_cell = row[1];

            if (this.State == "begin")
            {
                if (bStateText == true)
                {
                    state_cell.Text = "请求中";
                }
                state_cell.ImageIndex = IMAGEINDEX_WAITING;
            }
            else if (this.State == "error")
            {
                if (bStateText == true)
                {
                    state_cell.Text = "出错";
                }
                state_cell.ImageIndex = IMAGEINDEX_ERROR;
            }
            else if (this.State == "finish")
            {
                if (bStateText == true)
                {
                    state_cell.Text = "完成";
                }
                state_cell.ImageIndex = IMAGEINDEX_FINISH;
            }
            else
            {
                if (bStateText == true)
                {
                    state_cell.Text = "未处理";
                }
                state_cell.ImageIndex = -1;
            }

            string strText = "";

            // 内容
            if (this.Action == "load_reader_info")
            {
                strText = "装载读者信息 " + this.ReaderBarcode;
            }
            else if (this.Action == "borrow")
            {
                strText = GetOperText("借");
            }
            else if (this.Action == "return")
            {
                strText = GetOperText("还");
            }
            else if (this.Action == "verify_return")
            {
                strText = GetOperText("(验证)还");
            }
            else if (this.Action == "lost")
            {
                strText = GetOperText("丢失");
            }
            else if (this.Action == "verify_lost")
            {
                strText = GetOperText("(验证)丢失");
            }
            else if (this.Action == "renew")
            {
                strText = GetOperText("续借");
            }
            else if (this.Action == "verify_renew")
            {
                strText = GetOperText("(验证)续借");
            }
            else if (this.Action == "inventory")
            {
                strText = GetOperText("盘点");
            }
            else if (this.Action == "read")
            {
                strText = GetOperText("读过");
            }
            else if (this.Action == "boxing")
            {
                strText = GetOperText("配书");
            }

            if (string.IsNullOrEmpty(this.ErrorInfo) == false)
            {
                strText += "\r\n===\r\n" + this.ErrorInfo;
            }

            row[2].Text = strText;

            // 缺省为透明色,即使用 row 的前景背景色 2015/10/18
            ////row.BackColor = SystemColors.Window;
            ////row.ForeColor = SystemColors.WindowText;

            DpCell color_cell = row[0];

            // row.BackColor = System.Drawing.Color.Transparent;
            if (this.Color == "red")
            {
                color_cell.BackColor = System.Drawing.Color.Red;
                // row.ForeColor = System.Drawing.Color.White;
            }
            else if (this.Color == "green")
            {
                color_cell.BackColor = System.Drawing.Color.Green;
                // row.ForeColor = System.Drawing.Color.White;
            }
            else if (this.Color == "yellow")
            {
                row.BackColor        = System.Drawing.Color.Yellow;
                color_cell.BackColor = System.Drawing.Color.Transparent;
                // row.ForeColor = System.Drawing.Color.Black;
            }
            else if (this.Color == "light")
            {
                color_cell.BackColor = System.Drawing.Color.LightGray;
            }
            else if (this.Color == "purple")
            {
                color_cell.BackColor = System.Drawing.Color.Purple;
            }
            else if (this.Color == "black")
            {
                color_cell.BackColor = System.Drawing.Color.Purple;
#if NO
                row.BackColor = System.Drawing.Color.Black;
                row.ForeColor = System.Drawing.Color.LightGray;
#endif
            }
            else
            {
                // color_cell.BackColor = System.Drawing.Color.Transparent;
                color_cell.BackColor = System.Drawing.Color.White;
            }
        }
Ejemplo n.º 31
0
        private void dpTable_items_PaintRegion(object sender, PaintRegionArgs e)
        {
            if (e.Action == "query")
            {
                // 测算图像高度
                DpCell cell = e.Item as DpCell;
                // DpRow row = cell.Container;
                ImageCellInfo cell_info = (ImageCellInfo)cell.Tag;
                // string strFileName = (string)cell.Tag;
                if (cell_info == null || string.IsNullOrEmpty(cell_info.FileName) == true)
                {
                    e.Height = 0;
                }
                else
                {
                    try
                    {
                        using (Stream s = File.Open(cell_info.FileName, FileMode.Open))
                        {
                            using (Image image = Image.FromStream(s))
                            {
                                e.Height = image.Height;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        // throw new Exception("read image error:" + ex.Message);
                        if (cell_info.RetryCount < 5)
                        {
                            cell_info.RetryCount++;
                            DpRow row = cell.Container;
                            AddTraceItem(row);
                        }
                        else
                        {
                            e.Height       = 0;
                            cell.OwnerDraw = false;
                            cell.Text      = "read image error";
                        }
                        return;
                    }

                    if (this.dpTable_items.MaxTextHeight < e.Height)
                    {
                        this.dpTable_items.MaxTextHeight = e.Height;
                    }
                }
                return;
            }

            {
                Debug.Assert(e.Action == "paint", "");

                DpCell cell = e.Item as DpCell;

                ImageCellInfo cell_info = (ImageCellInfo)cell.Tag;
                // string strFileName = (string)cell.Tag;
                if (cell_info != null && string.IsNullOrEmpty(cell_info.FileName) == false)
                {
                    try
                    {
                        using (Stream s = File.Open(cell_info.FileName, FileMode.Open))
                        {
                            using (Image image = Image.FromStream(s))
                            {
                                // 绘制图像
                                e.pe.Graphics.DrawImage(image,
                                                        (float)e.X,
                                                        (float)e.Y);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        // throw new Exception("read image error:" + ex.Message);
                        if (cell_info.RetryCount < 5)
                        {
                            cell_info.RetryCount++;
                            DpRow row = cell.Container;
                            AddTraceItem(row);
                        }
                        else
                        {
                            cell.OwnerDraw = false;
                            cell.Text      = "read image error";
                        }
                    }
                }
                else
                {
                    // 绘制文字“正在加载”
                }
            }
        }
Ejemplo n.º 32
0
        void FillList()
        {
            this.ActionTable.Rows.Clear();
            if (Actions == null)
                return;

            DpRow first_item = null;

            for (int i = 0; i < Actions.Count; i++)
            {
                ScriptAction action = (ScriptAction)Actions[i];

                DpRow item = new DpRow();
                if (action.Name == "-")
                    item.Style = DpRowStyle.Seperator;
                else
                {
                    DpCell cell = new DpCell(action.Name);
                    cell.Font = new Font(this.ActionTable.Font.FontFamily, 10, FontStyle.Bold, GraphicsUnit.Point);
                    item.Add(cell);

                    // 快捷键
                    cell = new DpCell();
                    if (action.ShortcutKey != (char)0)
                    {
                        cell.Text = new string(action.ShortcutKey, 1);
                        cell.Text = cell.Text.ToUpper();
                    }
                    item.Add(cell);

                    // 说明

                    item.Add(new DpCell(action.Comment));


                    // 入口函数
                    cell = new DpCell(action.ScriptEntry);
                    cell.ForeColor = SystemColors.GrayText;
                    cell.Font = new Font(this.ActionTable.Font.FontFamily, 8, GraphicsUnit.Point);
                    item.Add(cell);
                }

                if (action.Active == true)
                {
                    item.Selected = true;

                    // 2009/2/24
                    if (first_item == null)
                        first_item = item;
                }

                this.ActionTable.Rows.Add(item);
            }

            if (first_item != null)
            {
                this.ActionTable.FocusedItem = first_item;
                first_item.EnsureVisible();
            }
        }
Ejemplo n.º 33
0
        public void RefreshDisplay(DpRow row)
        {
            // 初始化列
            if (row.Count == 0)
            {
                // 色条
                DpCell cell = new DpCell();
                row.Add(cell);

                // 状态
                cell = new DpCell();
                cell.ImageIndex = -1;
                row.Add(cell);

                // 内容
                cell = new DpCell();
                row.Add(cell);
            }

            bool bStateText = false;

            // 状态
            // row[0].Text = this.State;
            DpCell state_cell = row[1];
            if (this.State == "begin")
            {
                if (bStateText == true)
                    state_cell.Text = "请求中";
                state_cell.ImageIndex = IMAGEINDEX_WAITING;
            }
            else if (this.State == "error")
            {
                if (bStateText == true)
                    state_cell.Text = "出错";
                state_cell.ImageIndex = IMAGEINDEX_ERROR;
            }
            else if (this.State == "finish")
            {
                if (bStateText == true)
                    state_cell.Text = "完成";
                state_cell.ImageIndex = IMAGEINDEX_FINISH;
            }
            else
            {
                if (bStateText == true)
                    state_cell.Text = "未处理";
                state_cell.ImageIndex = -1;
            }

            string strText = "";
            // 内容
            if (this.Action == "load_reader_info")
                strText = "装载读者信息 " + this.ReaderBarcode;
            else if (this.Action == "borrow")
            {
                strText = GetOperText("借");
            }
            else if (this.Action == "return")
            {
                strText = GetOperText("还");
            }
            else if (this.Action == "verify_return")
            {
                strText = GetOperText("(验证)还");
            }
            else if (this.Action == "lost")
            {
                strText = GetOperText("丢失");
            }
            else if (this.Action == "verify_lost")
            {
                strText = GetOperText("(验证)丢失");
            }
            else if (this.Action == "renew")
            {
                strText = GetOperText("续借");
            }
            else if (this.Action == "verify_renew")
            {
                strText = GetOperText("(验证)续借");
            }
            else if (this.Action == "inventory")
            {
                strText = GetOperText("盘点");
            }

            if (string.IsNullOrEmpty(this.ErrorInfo) == false)
                strText += "\r\n===\r\n" + this.ErrorInfo;

            row[2].Text = strText;

            row.BackColor = SystemColors.Window;
            row.ForeColor = SystemColors.WindowText;

            DpCell color_cell = row[0];
            // row.BackColor = System.Drawing.Color.Transparent;
            if (this.Color == "red")
            {
                color_cell.BackColor = System.Drawing.Color.Red;
                // row.ForeColor = System.Drawing.Color.White;
            }
            else if (this.Color == "green")
            {
                color_cell.BackColor = System.Drawing.Color.Green;
                // row.ForeColor = System.Drawing.Color.White;
            }
            else if (this.Color == "yellow")
            {
                row.BackColor = System.Drawing.Color.Yellow;
                color_cell.BackColor = System.Drawing.Color.Transparent;
                // row.ForeColor = System.Drawing.Color.Black;
            }
            else if (this.Color == "light")
            {
                color_cell.BackColor = System.Drawing.Color.LightGray;
            }
            else if (this.Color == "purple")
            {
                color_cell.BackColor = System.Drawing.Color.Purple;
            }
            else if (this.Color == "black")
            {
                color_cell.BackColor = System.Drawing.Color.Purple;
                row.BackColor = System.Drawing.Color.Black;
                row.ForeColor = System.Drawing.Color.LightGray;
            }
            else
            {
                // color_cell.BackColor = System.Drawing.Color.Transparent;
                color_cell.BackColor = System.Drawing.Color.White;
            }
        }
Ejemplo n.º 34
0
        // 加入书目行
        void AddBiblioLine(string strBiblioRecPath)
        {
            string strError = "";

            string strVolume = "";
            string strPrice  = "";

            GetVolume(strBiblioRecPath,
                      out strVolume,
                      out strPrice);

            Color colorBack = Color.LightGreen;

            DpRow row = new DpRow();

#if NO
            // 设为灰色行
            SetGrayText(row);
#endif

            // 状态
            DpCell cell = new DpCell();
            cell.BackColor = colorBack;
            cell.Text      = "";
            row.Add(cell);

            // 册条码号
            cell           = new DpCell();
            cell.BackColor = colorBack;
            cell.Text      = "@biblioRecPath:" + strBiblioRecPath;
            row.Add(cell);

            // 在借情况
            cell           = new DpCell();
            cell.BackColor = colorBack;
#if NO
            {
                if (IsGray(row) == true)
                {
                    cell.BackColor = Color.FromArgb(220, 220, 0);
                }
                else
                {
                    cell.BackColor = Color.FromArgb(180, 180, 0);
                }

                cell.ForeColor = Color.FromArgb(255, 255, 255);
                cell.Alignment = DpTextAlignment.Center;
                cell.Text      = "";
            }
#endif
            row.Add(cell);

            // 书目摘要
            string strSummary = "";
            {
                int nRet = Program.MainForm.GetBiblioSummary("@bibliorecpath:" + strBiblioRecPath,
                                                             "",
                                                             false,
                                                             out strSummary,
                                                             out strError);
                if (nRet == -1)
                {
                    strSummary = strError;
                }
            }
            cell           = new DpCell();
            cell.BackColor = colorBack;
            cell.Text      = strSummary;
            row.Add(cell);

            // 卷册
            cell           = new DpCell();
            cell.BackColor = colorBack;
            cell.Text      = strVolume;
            row.Add(cell);

            // 地点
            cell           = new DpCell();
            cell.BackColor = colorBack;
            cell.Text      = "";
            row.Add(cell);

            // 价格
            cell           = new DpCell();
            cell.BackColor = colorBack;
            cell.Text      = strPrice;
            row.Add(cell);

            // 册记录路径
            cell           = new DpCell();
            cell.BackColor = colorBack;
            cell.Text      = strBiblioRecPath;
            row.Add(cell);

            this.dpTable_items.Rows.Add(row);
        }
Ejemplo n.º 35
0
 static bool IsGray(DpRow row)
 {
     if (row.Tag == null)
         return false;
     RowTag tag = row.Tag as RowTag;
     return tag.GrayText;
 }
Ejemplo n.º 36
0
        public void DisplayError(string strError)
        {
            this.ActionTable.Rows.Clear();

            DpRow item = new DpRow();
            DpCell cell = new DpCell("");
            item.Add(cell);

            // 快捷键
            cell = new DpCell();
            item.Add(cell);

            // 说明
            cell = new DpCell(strError);
            // cell.Font = new Font(this.ActionTable.Font.FontFamily, this.ActionTable.Font.SizeInPoints * 2, FontStyle.Bold, GraphicsUnit.Point);
            item.Add(cell);

            item.Tag = new ScriptAction();
            this.ActionTable.Rows.Add(item);
        }
Ejemplo n.º 37
0
        void FillList()
        {
            this.ActionTable.Rows.Clear();
            if (Actions == null)
            {
                return;
            }

            DpRow first_item = null;

            for (int i = 0; i < Actions.Count; i++)
            {
                ScriptAction action = (ScriptAction)Actions[i];

                DpRow item = new DpRow();
                if (action.Name == "-")
                {
                    item.Style = DpRowStyle.Seperator;
                }
                else
                {
                    DpCell cell = new DpCell(action.Name);
                    cell.Font = new Font(this.ActionTable.Font.FontFamily, 10, FontStyle.Bold, GraphicsUnit.Point);
                    item.Add(cell);

                    // 快捷键
                    cell = new DpCell();
                    if (action.ShortcutKey != (char)0)
                    {
                        cell.Text = new string(action.ShortcutKey, 1);
                        cell.Text = cell.Text.ToUpper();
                    }
                    item.Add(cell);

                    // 说明

                    item.Add(new DpCell(action.Comment));


                    // 入口函数
                    cell           = new DpCell(action.ScriptEntry);
                    cell.ForeColor = SystemColors.GrayText;
                    cell.Font      = new Font(this.ActionTable.Font.FontFamily, 8, GraphicsUnit.Point);
                    item.Add(cell);
                }

                if (action.Active == true)
                {
                    item.Selected = true;

                    // 2009/2/24
                    if (first_item == null)
                    {
                        first_item = item;
                    }
                }

                this.ActionTable.Rows.Add(item);
            }

            if (first_item != null)
            {
                this.ActionTable.FocusedItem = first_item;
                first_item.EnsureVisible();
            }
        }
Ejemplo n.º 38
0
        // 加入一个浏览行
        public void AddBiblioBrowseLine(
            int nType,
            string strBiblioRecPath,
            string strBrowseText,
            RegisterBiblioInfo info,
            bool bAutoSetFocus)
        {
            if (this.dpTable_browseLines.InvokeRequired)
            {
                // 事件是在多线程上下文中触发的,需要 Invoke 显示信息
                this.BeginInvoke(new Action<int, string, string, RegisterBiblioInfo, bool>(AddBiblioBrowseLine),
                    nType,
                    strBiblioRecPath,
                    strBrowseText,
                    info,
                    bAutoSetFocus);
                return;
            }

            List<string> columns = StringUtil.SplitList(strBrowseText, '\t');
            DpRow row = new DpRow();

            // 序号
            DpCell cell = new DpCell();
            cell.Alignment = DpTextAlignment.Far;
            cell.Font = new Font(this.Font.FontFamily, this.Font.Size * 2);
            cell.Text = (this.dpTable_browseLines.Rows.Count + 1).ToString();
            {
                cell.ImageIndex = nType;
                if (nType == TYPE_ERROR)
                    cell.BackColor = Color.Red;
                else if (nType == TYPE_INFO)
                    cell.BackColor = Color.Yellow;
            }
            row.Add(cell);

            // 记录路径
            cell = new DpCell();
            cell.Text = strBiblioRecPath;
            row.Add(cell);

            // 封面
            cell = new DpCell();
            cell.Text = "";
            row.Add(cell);

            foreach (string s in columns)
            {
                cell = new DpCell();
                cell.Text = s;
                row.Add(cell);
            }

            row.Tag = info;
            this.dpTable_browseLines.Rows.Add(row);

            // 当插入第一行的时候,顺便选中它
            if (this.dpTable_browseLines.Rows.Count == 1)
            {
                if (bAutoSetFocus)
                    this.dpTable_browseLines.Focus();
                row.Selected = true;
                this.dpTable_browseLines.FocusedItem = row;
            }

            PrepareCoverImage(row);
        }
Ejemplo n.º 39
0
        private void button_load_loadFromBarcodeFile_Click(object sender, EventArgs e)
        {
            string strError = "";
            //int nRet = 0;

            bool bClearBefore = true;

            if (Control.ModifierKeys == Keys.Control)
            {
                bClearBefore = false;
            }

            if (bClearBefore == true)
            {
                ClearBefore();
            }

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title = "请指定要打开的条码号文件名";
            // dlg.FileName = this.BarcodeFilePath;
            // dlg.InitialDirectory =
            dlg.Filter           = "条码号文件 (*.txt)|*.txt|All files (*.*)|*.*";
            dlg.RestoreDirectory = true;

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            EnableControls(false);
            // MainForm.ShowProgress(true);

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在将册条码号转换为记录路径 ...");
            stop.BeginLoop();

            try
            {
                Hashtable     barcode_table = new Hashtable();
                int           nDupCount     = 0;
                List <string> lines         = new List <string>();

                using (StreamReader sr = new StreamReader(dlg.FileName))
                {
                    for (; ;)
                    {
                        Application.DoEvents();

                        if (stop != null && stop.State != 0)
                        {
                            strError = "用户中断";
                            goto ERROR1;
                        }

                        string strLine = "";
                        strLine = sr.ReadLine();

                        if (strLine == null)
                        {
                            break;
                        }

                        strLine = strLine.Trim();
                        if (String.IsNullOrEmpty(strLine) == true)
                        {
                            continue;
                        }

                        if (strLine[0] == '#')
                        {
                            continue;   // 注释行
                        }
                        if (barcode_table[strLine] != null)
                        {
                            nDupCount++;
                            continue;
                        }

                        barcode_table[strLine] = true;
                        lines.Add(strLine);
                    }
                }

                if (lines.Count == 0)
                {
                    strError = "条码号文件为空";
                    goto ERROR1;
                }

                stop.SetProgressRange(0, lines.Count);

                ItemBarcodeLoader loader = new ItemBarcodeLoader();
                loader.Channel  = this.Channel;
                loader.Stop     = this.stop;
                loader.Barcodes = lines;

                int i = 0;
                foreach (EntityItem item in loader)
                {
                    Application.DoEvents();

                    if (stop != null && stop.State != 0)
                    {
                        strError = "用户中断";
                        goto ERROR1;
                    }

                    DpRow row = new DpRow();
                    // icon1
                    DpCell cell = new DpCell();
                    row.Add(cell);

                    // icon2
                    cell = new DpCell();
                    row.Add(cell);

                    // barcode
                    cell      = new DpCell();
                    cell.Text = item.Barcode;
                    row.Add(cell);

                    // summary
                    cell = new DpCell();
                    // 如果出错
                    if (string.IsNullOrEmpty(item.ErrorInfo) == false)
                    {
                        cell.Text = item.ErrorInfo;
                    }
                    row.Add(cell);

                    // recpath
                    cell      = new DpCell();
                    cell.Text = item.RecPath;
                    row.Add(cell);

                    this.dpTable1.Rows.Add(row);

                    i++;
                    stop.SetProgressValue(i);
                }


                // BrowseLoader
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
                stop.HideProgress();

                EnableControls(true);
                // MainForm.ShowProgress(false);
            }

            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Ejemplo n.º 40
0
        // public event AsyncGetImageEventHandler AsyncGetImage = null;
        // bool CoverImageRequested = false; // 如果为 true ,表示已经请求了异步获取图像,不要重复请求

        // 准备特定浏览行的封面图像
        // parameters:
        //      bRetry  是否为重试?如果为 true,表示即便 info.CoverImageRquested == true 也要重做
        void PrepareCoverImage(DpRow row, 
            bool bRetry = false)
        {
            Debug.Assert(row != null, "");

            RegisterBiblioInfo info = row.Tag as RegisterBiblioInfo;
            if (info == null)
                return;

            if (string.IsNullOrEmpty(info.CoverImageFileName) == false)
                return;

            if (string.IsNullOrEmpty(info.OldXml) == true)
                return;

            string strUrl = "";
            {
                string strError = "";
                string strMARC = "";
                string strMarcSyntax = "";
                // 将XML格式转换为MARC格式
                // 自动从数据记录中获得MARC语法
                int nRet = MarcUtil.Xml2Marc(info.OldXml,
                    true,
                    null,
                    out strMarcSyntax,
                    out strMARC,
                    out strError);
                if (nRet == -1)
                {
                    Debug.Assert(false, "");
                    return;
                }

                if (string.IsNullOrEmpty(strMARC) == true)
                    return;

                strUrl = ScriptUtil.GetCoverImageUrl(strMARC);
                if (string.IsNullOrEmpty(strUrl) == true)
                    return;
            }

#if NO
            if (StringUtil.HasHead(strUrl, "http:") == true)
                return;
#endif

            if (info != null
                && bRetry == false
                && info.CoverImageRquested == true)
                return;

            // 通过 dp2library 协议获得图像文件
            // if (this.AsyncGetImage != null)
            {
                AsyncGetImageEventArgs e = new AsyncGetImageEventArgs();
                e.RecPath = row[1].Text;
                e.ObjectPath = strUrl;
                e.FileName = "";
                e.Row = row;
                this.AsyncGetImageFile(this, e);
                // 修改状态,表示已经发出请求
                if (row != null && info != null)
                {
                    info.CoverImageRquested = true;
                }
            }
        }
Ejemplo n.º 41
0
        // 加入一个浏览行
        public void AddBiblioBrowseLine(
            int nType,
            string strBiblioRecPath,
            string strBrowseText,
            RegisterBiblioInfo info)
        {
            if (this.dpTable_browseLines.InvokeRequired)
            {
                // 事件是在多线程上下文中触发的,需要 Invoke 显示信息
                this.BeginInvoke(new Action<int, string, string, RegisterBiblioInfo>(AddBiblioBrowseLine),
                    nType,
                    strBiblioRecPath,
                    strBrowseText,
                    info);
                return;
            }

            List<string> columns = StringUtil.SplitList(strBrowseText, '\t');
            DpRow row = new DpRow();

            DpCell cell = new DpCell();
            cell.Text = (this.dpTable_browseLines.Rows.Count + 1).ToString();
            {
                cell.ImageIndex = nType;
                if (nType == TYPE_ERROR)
                    cell.BackColor = Color.Red;
                else if (nType == TYPE_INFO)
                    cell.BackColor = Color.Yellow;
            }
            row.Add(cell);

            cell = new DpCell();
            cell.Text = strBiblioRecPath;
            row.Add(cell);

            foreach (string s in columns)
            {
                cell = new DpCell();
                cell.Text = s;
                row.Add(cell);
            }

            row.Tag = info;
            this.dpTable_browseLines.Rows.Add(row);

            PrepareCoverImage(row);
        }
Ejemplo n.º 42
0
        // 将控件加入到tablelayoutpanel中
        internal void AddToTable(DpTable table, int nInsertPos)
        {
            DpRow row = new DpRow();

            DpCell cell = new DpCell();
            cell.InnerControl = this.label_color;
            row.Add(cell);

            cell = new DpCell();
            cell.InnerControl = this.textBox_catalogNo;
            row.Add(cell);

            cell = new DpCell();
            cell.InnerControl = this.comboBox_seller;
            row.Add(cell);

            cell = new DpCell();
            cell.InnerControl = this.comboBox_source;
            row.Add(cell);

            cell = new DpCell();
            cell.InnerControl = this.dateRange_range;
            row.Add(cell);

            cell = new DpCell();
            cell.InnerControl = this.comboBox_issueCount;
            row.Add(cell);

            cell = new DpCell();
            cell.InnerControl = this.comboBox_copy;
            row.Add(cell);

            cell = new DpCell();
            cell.InnerControl = this.textBox_price;
            row.Add(cell);

            cell = new DpCell();
            cell.InnerControl = this.location;
            row.Add(cell);

            cell = new DpCell();
            cell.InnerControl = this.comboBox_class;
            row.Add(cell);

            cell = new DpCell();
            cell.InnerControl = this.label_sellerAddress;
            row.Add(cell);

            cell = new DpCell();
            cell.InnerControl = this.label_other;
            row.Add(cell);

            if (nInsertPos >= table.Rows.Count)
                table.Rows.Add(row);
            else
                table.Rows.Insert(nInsertPos, row);

            AddEvents();
        }
Ejemplo n.º 43
0
 void AddTraceItem(DpRow row)
 {
     AmazonBiblioInfo info = row.Tag as AmazonBiblioInfo;
     if (info != null && string.IsNullOrEmpty(info.ImageUrl) == false)
     {
         TraceImage trace = new TraceImage();
         trace.ImageUrl = info.ImageUrl;
         trace.Row = row;
         lock (_trace_images)
         {
             _trace_images.Add(trace);
         }
     }
 }
Ejemplo n.º 44
0
        // 准备 dpTable Rows 事项。但不急于填充
        static int PrepareRows(RelationControl control,
            List<ResultItem> items,
            out List<DpRow> rows,
            out string strError)
        {
            strError = "";
            rows = new List<DpRow>();

            ControlInfo info = (ControlInfo)control.Tag;

            // List<ResultItem> items = info.ResultItems;
            if (items == null || items.Count == 0)
                return 0;

            string strControlKey = control.SourceText;

            foreach (ResultItem item in items)
            {
                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(item.Xml);
                }
                catch (Exception ex)
                {
                    strError = "XML 装入 DOM 时出错: " + ex.Message;
                    return -1;
                }

                XmlElement node = dom.DocumentElement.SelectSingleNode("key") as XmlElement;

                string strKey = node.GetAttribute("name");
                // string strKeyCaption = DomUtil.GetCaption(this.Lang, node);

                if (info.Relation.DbName.StartsWith("DDC") == true)
                    strKey = strKey.Replace("/", "");

                XmlNodeList nodes = dom.DocumentElement.SelectNodes("rel");
                foreach (XmlElement rel_node in nodes)
                {
                    string strRel = rel_node.GetAttribute("name");
                    // string strRelCaption = DomUtil.GetCaption(this.Lang, rel_node);
                    string strWeight = rel_node.GetAttribute("weight");

                    DpRow row = new DpRow();
                    // key
                    {
                        DpCell cell = new DpCell();
                        cell.Text = strKey;
                        cell.OwnerDraw = true;
                        row.Add(cell);
                    }
                    // rel
                    {
                        DpCell cell = new DpCell();
                        cell.Text = strRel;
                        row.Add(cell);
                    }
                    // weight
                    {
                        DpCell cell = new DpCell();
                        cell.Text = strWeight;
                        row.Add(cell);
                    }
                    // level
                    {
                        DpCell cell = new DpCell();
                        int nLevel = GetLevel(strControlKey, strKey);
                        Debug.Assert(nLevel <= strControlKey.Length && nLevel <= strKey.Length, "");
                        cell.Text = nLevel.ToString();
                        row.Add(cell);
                    }

                    rows.Add(row);
                }
            }

            rows.Sort(CompareEntrys);

            // 如果 control 还没有初始化过 hitcounts,则初始化一次
            if (control.HitCounts.Count == 0)
                control.HitCounts = BuildHitCountList(rows, strControlKey);

#if NO
            // 选定特定行
            if (info.SelectedLines != null && info.SelectedLines.Count > 0)
            {
                foreach (string line in info.SelectedLines)
                {
                    SelectRowByKey(line);
                }
            }
#endif
            return 0;
        }
Ejemplo n.º 45
0
 static void SetGrayText(DpRow row)
 {
     RowTag tag = new RowTag();
     tag.GrayText = true;
     row.Tag = tag;
     row.ForeColor = SystemColors.GrayText;
 }
Ejemplo n.º 46
0
        private void dpTable_items_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            ContextMenuStrip contextMenu = new ContextMenuStrip();

            ToolStripMenuItem menuItem = null;
            //ToolStripMenuItem subMenuItem = null;
            ToolStripSeparator menuSepItem = null;

            DpRow selected_row = null;

            if (this.dpTable_items.SelectedRows.Count > 0)
            {
                selected_row = this.dpTable_items.SelectedRows[0];
            }

            //
            menuItem = new ToolStripMenuItem("打开到 册窗(&I)");
            if (this.dpTable_items.SelectedRows.Count > 0)
            {
                menuItem.Enabled = true;
            }
            else
            {
                menuItem.Enabled = false;
            }
            menuItem.Click += new EventHandler(menuItem_loadToItemInfoForm_Click);
            contextMenu.Items.Add(menuItem);

            //
            menuItem = new ToolStripMenuItem("打开到 种册窗(&E)");
            if (this.dpTable_items.SelectedRows.Count > 0)
            {
                menuItem.Enabled = true;
            }
            else
            {
                menuItem.Enabled = false;
            }
            menuItem.Click += new EventHandler(menuItem_loadToEntityForm_Click);
            contextMenu.Items.Add(menuItem);

            // ---
            menuSepItem = new ToolStripSeparator();
            contextMenu.Items.Add(menuSepItem);

            //
            menuItem = new ToolStripMenuItem("复制 [" + this.dpTable_items.SelectedRows.Count.ToString() + "] (&D)");
            if (this.dpTable_items.SelectedRows.Count > 0)
            {
                menuItem.Enabled = true;
            }
            else
            {
                menuItem.Enabled = false;
            }
            menuItem.Click += new EventHandler(menuItem_copy_Click);
            contextMenu.Items.Add(menuItem);

            contextMenu.Show(this.dpTable_items, e.Location);
        }
Ejemplo n.º 47
0
        void AddNextCmdLine()
        {
            DpRow row = new DpRow();

            DpCell cell = new DpCell();
            cell.Text = "";
            row.Add(cell);

            cell = new DpCell();
            cell.Text = "";
            row.Add(cell);

            cell = new DpCell();
            cell.Text = "共命中 "+_search.HitCount.ToString()+" 条。双击调入下一批命中记录 ...";
            row.Add(cell);

            this.dpTable_items.Rows.Add(row);
        }
Ejemplo n.º 48
0
        // 加入一个浏览行
        public void AddBiblioBrowseLine(
            string strBiblioRecPath,
            string strBrowseText,
            AmazonBiblioInfo info)
        {
            if (this.dpTable_items.InvokeRequired)
            {
                // 事件是在多线程上下文中触发的,需要 Invoke 显示信息
                this.BeginInvoke(new Action<string, string, AmazonBiblioInfo>(AddBiblioBrowseLine),
                    strBiblioRecPath,
                    strBrowseText,
                    info);
                return;
            }

            // 检查已经存在的最后一行是否为命令行
            if (this.dpTable_items.Rows.Count > 0)
            {
                DpRow tail = this.dpTable_items.Rows[this.dpTable_items.Rows.Count - 1];
                if (string.IsNullOrEmpty(tail[0].Text) == true)
                    this.dpTable_items.Rows.RemoveAt(this.dpTable_items.Rows.Count - 1);
            }

            List<string> columns = StringUtil.SplitList(strBrowseText, '\t');
            DpRow row = new DpRow();
            row.LineAlignment = StringAlignment.Center;

            DpCell cell = new DpCell();
            cell.Text = (this.dpTable_items.Rows.Count + 1).ToString();
            cell.Font = this._idFont;
            cell.ForeColor = SystemColors.GrayText;
            row.Add(cell);

#if NO
            cell = new DpCell();
            cell.Text = strBiblioRecPath;
            row.Add(cell);
#endif

            cell = new DpCell();
            // cell.Text = info.ImageUrl;
            // cell.Text = "正在加载图片 ...";
            row.Add(cell);

            int i = 0;
            foreach (string s in columns)
            {
                cell = new DpCell();
                cell.Text = s;
                if (i == 0)
                    cell.Font = this._titleFont;

                row.Add(cell);
                i++;
            }

            row.Tag = info;
            // row[COLUMN_IMAGE].OwnerDraw = true;

            this.dpTable_items.Rows.Add(row);

#if NO
            if (string.IsNullOrEmpty(info.ImageUrl) == false)
            {
                TraceImage trace = new TraceImage();
                trace.ImageUrl = info.ImageUrl;
                trace.Row = row;
                lock (_trace_images)
                {
                    _trace_images.Add(trace);
                }
            }
#endif
            AddTraceItem(row);
        }
Ejemplo n.º 49
0
        // 加入一个浏览行
        public void AddBiblioBrowseLine(string strText,
            int nType)
        {
            if (this.dpTable_browseLines.InvokeRequired)
            {
                // 事件是在多线程上下文中触发的,需要 Invoke 显示信息
                this.BeginInvoke(new Action<string, int>(AddBiblioBrowseLine),
                    strText,
                    nType);
                return;
            }

            DpRow row = new DpRow();

            DpCell cell = new DpCell();
            cell.Text = (this.dpTable_browseLines.Rows.Count + 1).ToString();

            {
                cell.ImageIndex = nType;
                if (nType == TYPE_ERROR)
                    cell.BackColor = Color.Red;
                else if (nType == TYPE_INFO)
                    cell.BackColor = Color.Yellow;
            }
            row.Add(cell);

            cell = new DpCell();
            cell.Text = strText;
            row.Add(cell);

            row.Tag = null;
            this.dpTable_browseLines.Rows.Add(row);
        }
Ejemplo n.º 50
0
        // 将一条书目记录下属的若干册记录装入列表
        // return:
        //      -2  用户中断
        //      -1  出错
        //      >=0 装入的册记录条数
        int LoadBiblioSubItems(
            LibraryChannel channel,
            string strBiblioRecPath,
            out string strError)
        {
            strError = "";

            Progress.SetMessage("正在装入书目记录 '" + strBiblioRecPath + "' 下属的册记录 ...");

            if (this.FunctionType == "read")
            {
                AddBiblioLine(strBiblioRecPath);
            }

            int nCount = 0;

            long lPerCount    = 100; // 每批获得多少个
            long lStart       = 0;
            long lResultCount = 0;
            long lCount       = -1;

            for (; ;)
            {
                if (Progress.State != 0)
                {
                    strError = "用户中断";
                    return(-2);
                }

                EntityInfo[] entities = null;

                long lRet = channel.GetEntities(
                    Progress,
                    strBiblioRecPath,
                    lStart,
                    lCount,
                    "", // bDisplayOtherLibraryItem == true ? "getotherlibraryitem" : "",
                    "zh",
                    out entities,
                    out strError);
                if (lRet == -1)
                {
                    return(-1);
                }

                lResultCount = lRet;

                if (lRet == 0)
                {
                    return(nCount);
                }

                Debug.Assert(entities != null, "");

                foreach (EntityInfo entity in entities)
                {
                    string strXml = entity.OldRecord;

                    XmlDocument dom = new XmlDocument();
                    {
                        try
                        {
                            if (string.IsNullOrEmpty(strXml) == false)
                            {
                                dom.LoadXml(strXml);
                            }
                            else
                            {
                                dom.LoadXml("<root />");
                            }
                        }
                        catch (Exception ex)
                        {
                            strError = "XML 装入 DOM 出错: " + ex.Message;
                            return(-1);
                        }
                    }

                    DpRow row = new DpRow();

                    string strState    = DomUtil.GetElementText(dom.DocumentElement, "state");
                    string strBorrower = DomUtil.GetElementText(dom.DocumentElement, "borrower");
                    if (this.FunctionType == "borrow")
                    {
                        // 在借的册、或者状态有值的需要显示为灰色
                        if (string.IsNullOrEmpty(strBorrower) == false ||
                            string.IsNullOrEmpty(strState) == false)
                        {
                            SetGrayText(row);
                        }
                    }
                    else if (this.FunctionType == "return")
                    {
                        // 没有在借的册需要显示为灰色
                        if (string.IsNullOrEmpty(strBorrower) == true)
                        {
                            SetGrayText(row);
                        }
                        if (string.IsNullOrEmpty(this.VerifyBorrower) == false)
                        {
                            // 验证还书时,不是要求的读者所借阅的册,显示为灰色
                            if (strBorrower != this.VerifyBorrower)
                            {
                                SetGrayText(row);
                            }
                        }
                    }
                    else if (this.FunctionType == "renew")
                    {
                        // 没有在借的册需要显示为灰色
                        if (string.IsNullOrEmpty(strBorrower) == true)
                        {
                            SetGrayText(row);
                        }
                    }

                    string strBarcode = DomUtil.GetElementText(dom.DocumentElement, "barcode");
                    string strRefID   = DomUtil.GetElementText(dom.DocumentElement, "refID");

                    // 状态
                    DpCell cell = new DpCell();
                    cell.Text = strState;
                    row.Add(cell);

                    // 册条码号
                    cell = new DpCell();
                    if (string.IsNullOrEmpty(strBarcode) == false)
                    {
                        cell.Text = strBarcode;
                    }
                    else
                    {
                        cell.Text = "@refID:" + strRefID;
                    }
                    row.Add(cell);

                    // 在借情况
                    cell = new DpCell();
                    if (string.IsNullOrEmpty(strBorrower) == false)
                    {
                        string strReaderSummary = Program.MainForm.GetReaderSummary(strBorrower, false);
                        bool   bError           = (string.IsNullOrEmpty(strReaderSummary) == false && strReaderSummary[0] == '!');

                        if (bError == true)
                        {
                            cell.BackColor = Color.FromArgb(180, 0, 0);
                        }
                        else
                        {
                            if (IsGray(row) == true)
                            {
                                cell.BackColor = Color.FromArgb(220, 220, 0);
                            }
                            else
                            {
                                cell.BackColor = Color.FromArgb(180, 180, 0);
                            }
                        }

                        if (bError == false)
                        {
                            cell.Font = new System.Drawing.Font(this.dpTable_items.Font.FontFamily.Name, this.dpTable_items.Font.Size * 2, FontStyle.Bold);
                        }

                        cell.ForeColor = Color.FromArgb(255, 255, 255);
                        cell.Alignment = DpTextAlignment.Center;
                        cell.Text      = strReaderSummary;
                        // TODO: 后面还可加上借阅时间,应还时间
                    }
                    row.Add(cell);

                    // 书目摘要
                    string strSummary = "";
                    if (entity.ErrorCode != ErrorCodeValue.NoError)
                    {
                        strSummary = entity.ErrorInfo;
                    }
                    else
                    {
                        int nRet = Program.MainForm.GetBiblioSummary("@bibliorecpath:" + strBiblioRecPath,
                                                                     "",
                                                                     false,
                                                                     out strSummary,
                                                                     out strError);
                        if (nRet == -1)
                        {
                            strSummary = strError;
                        }
                    }
                    cell      = new DpCell();
                    cell.Text = strSummary;
                    row.Add(cell);

                    // 卷册
                    string strVolume = DomUtil.GetElementText(dom.DocumentElement, "volume");
                    cell      = new DpCell();
                    cell.Text = strVolume;
                    row.Add(cell);

                    // 地点
                    string strLocation = DomUtil.GetElementText(dom.DocumentElement, "location");
                    cell      = new DpCell();
                    cell.Text = strLocation;
                    row.Add(cell);

                    // 价格
                    string strPrice = DomUtil.GetElementText(dom.DocumentElement, "price");
                    cell      = new DpCell();
                    cell.Text = strPrice;
                    row.Add(cell);

                    // 册记录路径
                    cell      = new DpCell();
                    cell.Text = entity.OldRecPath;
                    row.Add(cell);

                    this.dpTable_items.Rows.Add(row);
                    nCount++;
                }

                lStart += entities.Length;
                if (lStart >= lResultCount)
                {
                    break;
                }

                if (lCount == -1)
                {
                    lCount = lPerCount;
                }

                if (lStart + lCount > lResultCount)
                {
                    lCount = lResultCount - lStart;
                }
            }

            // 分割行
            if (lStart > 0)
            {
                DpRow row = new DpRow();
                row.Style = DpRowStyle.Seperator;
                this.dpTable_items.Rows.Add(row);
            }

            return(nCount);
        }
Ejemplo n.º 51
0
        // 设置图像文件
        public void AsyncGetImageComplete(DpRow row,
            string strBiblioRecPath,
            string strFileName,
            string strErrorInfo)
        {
            if (this.dpTable_browseLines.InvokeRequired)
            {
                this.Invoke(new Action<DpRow, string, string, string>(AsyncGetImageComplete),
                    row, strBiblioRecPath, strFileName, strErrorInfo);
                return;
            }

            // row[COLUMN_IMAGE].Text = strFileName;

            if (string.IsNullOrEmpty(strErrorInfo) == false)
                row[COLUMN_IMAGE].Text = "!" + strErrorInfo;
            else
                SetImage(row[COLUMN_IMAGE], strFileName);
        }
Ejemplo n.º 52
0
        void _displayTask(string strAction, ChargingTask task)
        {
            if (strAction == "add")
            {
                DpRow line = new DpRow();
                line.Style = DpRowStyle.HorzGrid;
                line.BackColor = this.TaskBackColor;    // SystemColors.Window;
                line.ForeColor = this.TaskForeColor;
                task.RefreshDisplay(line);

                line.Tag = task;
                this.dpTable_tasks.Rows.Add(line);
                if (this._bScrollBarTouched == false)
                {
                    // TODO: 应该分为两种情况  希望看到最末事项的,和看中间的。信号是触动卷滚条到底部;拖动卷滚条到中部
                    this.dpTable_tasks.FocusedItem = line;
                    line.EnsureVisible();
                }
            }
            else if (strAction == "remove")
            {
                DpRow line = FindTaskLine(task);
                if (line != null)
                    this.dpTable_tasks.Rows.Remove(line);
                else
                {
                    // Debug.Assert(false, "");
                }
            }
            else if (strAction == "refresh"
                || strAction == "refresh_and_visible")
            {
                DpRow line = FindTaskLine(task);
                if (line != null)
                {
                    // 刷新显示
                    task.RefreshDisplay(line);

                    if (this.StateSpeak != "[不朗读]")
                    {
                        string strContent = task.GetSpeakContent(line, this.StateSpeak);
                        if (string.IsNullOrEmpty(strContent) == false)
                            this.MainForm.Speak(strContent);
                    }

                    if (task.Action == "load_reader_info" && string.IsNullOrEmpty(task.ReaderXml) == false)
                        task.RefreshPatronCardDisplay(line);

                    if (this._bScrollBarTouched == false)
                    {
                        // 如果刷新的对象是 Focus 对象,则确保显示在视野范围内
                        // TODO: 当发现中途人触动了控件时,这个功能要禁用,以免对人的操作发生干扰
                        if (this.dpTable_tasks.FocusedItem == line)
                            line.EnsureVisible();
                        else
                        {
                            if (strAction == "refresh_and_visible")
                                line.EnsureVisible();
                        }
                    }

                }

            }

            // 刷新读者摘要窗口
            if (this._patronSummaryForm != null
                && this._patronSummaryForm.Visible
                && strAction == "add")
                this._patronSummaryForm.OnTaskStateChanged(strAction, task);
        }
Ejemplo n.º 53
0
        // 获得一个 DpRow 行的用于 Copy 的文本
        static string GetRowText(DpRow row)
        {
            StringBuilder text = new StringBuilder(4096);
            int i = 0;
            foreach (DpCell cell in row)
            {
                // 跳过第一列
                if (i > 0)
                {
                    if (text.Length > 0)
                        text.Append("\t");
                    text.Append(cell.Text);
                }

                i++;
            }

            return text.ToString();
        }
Ejemplo n.º 54
0
        private void button_load_loadFromBarcodeFile_Click(object sender, EventArgs e)
        {
            string strError = "";
            int nRet = 0;

            bool bClearBefore = true;
            if (Control.ModifierKeys == Keys.Control)
                bClearBefore = false;

            if (bClearBefore == true)
                ClearBefore();

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title = "请指定要打开的条码号文件名";
            // dlg.FileName = this.BarcodeFilePath;
            // dlg.InitialDirectory = 
            dlg.Filter = "条码号文件 (*.txt)|*.txt|All files (*.*)|*.*";
            dlg.RestoreDirectory = true;

            if (dlg.ShowDialog() != DialogResult.OK)
                return;

            EnableControls(false);
            // MainForm.ShowProgress(true);

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在将册条码号转换为记录路径 ...");
            stop.BeginLoop();

            try
            {
                Hashtable barcode_table = new Hashtable();
                int nDupCount = 0;
                List<string> lines = new List<string>();

                using (StreamReader sr = new StreamReader(dlg.FileName))
                {
                    for (; ; )
                    {
                        Application.DoEvents();

                        if (stop != null && stop.State != 0)
                        {
                            strError = "用户中断";
                            goto ERROR1;
                        }

                        string strLine = "";
                        strLine = sr.ReadLine();

                        if (strLine == null)
                            break;

                        strLine = strLine.Trim();
                        if (String.IsNullOrEmpty(strLine) == true)
                            continue;

                        if (strLine[0] == '#')
                            continue;   // 注释行

                        if (barcode_table[strLine] != null)
                        {
                            nDupCount++;
                            continue;
                        }

                        barcode_table[strLine] = true;
                        lines.Add(strLine);
                    }
                }

                if (lines.Count == 0)
                {
                    strError = "条码号文件为空";
                    goto ERROR1;
                }

                stop.SetProgressRange(0, lines.Count);

                ItemBarcodeLoader loader = new ItemBarcodeLoader();
                loader.Channel = this.Channel;
                loader.Stop = this.stop;
                loader.Barcodes = lines;

                int i = 0;
                foreach (EntityItem item in loader)
                {
                    Application.DoEvents();

                    if (stop != null && stop.State != 0)
                    {
                        strError = "用户中断";
                        goto ERROR1;
                    }

                    DpRow row = new DpRow();
                    // icon1
                    DpCell cell = new DpCell();
                    row.Add(cell);

                    // icon2
                    cell = new DpCell();
                    row.Add(cell);

                    // barcode
                    cell = new DpCell();
                    cell.Text = item.Barcode;
                    row.Add(cell);

                    // summary
                    cell = new DpCell();
                    // 如果出错
                    if (string.IsNullOrEmpty(item.ErrorInfo) == false)
                        cell.Text = item.ErrorInfo;
                    row.Add(cell);

                    // recpath
                    cell = new DpCell();
                    cell.Text = item.RecPath;
                    row.Add(cell);

                    this.dpTable1.Rows.Add(row);

                    i++;
                    stop.SetProgressValue(i);
                }


                // BrowseLoader
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
                stop.HideProgress();

                EnableControls(true);
                // MainForm.ShowProgress(false);
            }

            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
Ejemplo n.º 55
0
 static string BuildRowLine(DpRow row)
 {
     StringBuilder text = new StringBuilder();
     text.Append("source_key 源=[" + row[RelationDialog.COLUMN_KEY].Text + "] ");
     text.Append("target_key 目标=[" + row[RelationDialog.COLUMN_REL].Text + "] ");
     text.Append("weight权值 =[" + row[RelationDialog.COLUMN_WEIGHT].Text + "] ");
     text.Append("level级别 =[" + row[RelationDialog.COLUMN_LEVEL].Text + "] ");
     return text.ToString();
 }