コード例 #1
0
ファイル: OperLogForm.cs プロジェクト: renyh1013/dp2
        string m_strFindOperations = "";    // 曾经用过的查找参数

        void menu_find_Click(object sender, EventArgs e)
        {
#if NO
            OperLogFindDialog dlg = new OperLogFindDialog();
            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.Operations = m_strFindOperations;

            this.MainForm.AppInfo.LinkFormState(dlg, "operlogform_finddialog_formstate");
            dlg.ShowDialog(this);
            this.MainForm.AppInfo.UnlinkFormState(dlg);

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


            m_strFindOperations = dlg.Operations;

            int start_index = 0;
            if (this.listView_records.SelectedIndices.Count > 0)
                start_index = this.listView_records.SelectedIndices[0];

            List<string> operations = StringUtil.FromListString(dlg.Operations);
            ListViewItem found_item = null;
            int i = 0;
            foreach (ListViewItem item in this.listView_records.Items)
            {
                if (i <= start_index)
                {
                    i++;
                    continue;
                }

                string strOperation = ListViewUtil.GetItemText(item, COLUMN_OPERATION);

                foreach (string o in operations)
                {
                    if (strOperation.IndexOf(o) != -1)
                    {
                        found_item = item;
                        goto FOUND;
                    }
                }

                i++;
            }

            MessageBox.Show(this, "操作类型为 '"+dlg.Operations+"' 的日志记录没有找到");
            return;
        FOUND:
            ListViewUtil.ClearSelection(this.listView_records);
            found_item.Selected = true;
            found_item.EnsureVisible();
#endif
            Find("");
        }
コード例 #2
0
ファイル: OperLogForm.cs プロジェクト: renyh1013/dp2
        // parameters:
        //      strStyle    下列之一 continue
        void Find(string strStyle)
        {
            if (StringUtil.IsInList("continue", strStyle) == true
                && string.IsNullOrEmpty(this.m_strFindOperations) == false)
            {
            }
            else
            {
                OperLogFindDialog dlg = new OperLogFindDialog();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.Operations = m_strFindOperations;

                this.MainForm.AppInfo.LinkFormState(dlg, "operlogform_finddialog_formstate");
                dlg.ShowDialog(this);
                this.MainForm.AppInfo.UnlinkFormState(dlg);

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

                m_strFindOperations = dlg.Operations;
            }

            int start_index = 0;
            if (this.listView_records.SelectedIndices.Count > 0)
                start_index = this.listView_records.SelectedIndices[0];

            ListViewItem found_item = null;

            Cursor oldCursor = this.Cursor;
            this.Cursor = Cursors.WaitCursor;

            try
            {

                List<string> operations = StringUtil.FromListString(m_strFindOperations);
                int i = 0;
                foreach (ListViewItem item in this.listView_records.Items)
                {
                    if (i <= start_index)
                    {
                        i++;
                        continue;
                    }

                    string strOperation = ListViewUtil.GetItemText(item, COLUMN_OPERATION);

                    foreach (string o in operations)
                    {
                        if (strOperation.IndexOf(o) != -1)
                        {
                            found_item = item;
                            goto FOUND;
                        }
                    }

                    i++;
                }

            }
            finally
            {
                this.Cursor = oldCursor;
            }

            this.MainForm.StatusBarMessage = "操作类型为 '" + m_strFindOperations + "' 的日志记录没有找到";
            return;
        FOUND:
            ListViewUtil.ClearSelection(this.listView_records);
            found_item.Selected = true;
            found_item.EnsureVisible();
            this.MainForm.StatusBarMessage = "找到";
        }
コード例 #3
0
ファイル: OperLogForm.cs プロジェクト: renyh1013/dp2
        // 筛选
        void menu_filter_Click(object sender, EventArgs e)
        {
            OperLogFindDialog dlg = new OperLogFindDialog();
            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.Text = "筛选";
            dlg.Operations = m_strFindOperations;

            this.MainForm.AppInfo.LinkFormState(dlg, "operlogform_finddialog_formstate");
            dlg.ShowDialog(this);
            this.MainForm.AppInfo.UnlinkFormState(dlg);

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


            m_strFindOperations = dlg.Operations;

            List<string> operations = StringUtil.FromListString(dlg.Operations);
            int nRemoveCount = 0;

            Cursor oldCursor = this.Cursor;
            this.Cursor = Cursors.WaitCursor;

            try
            {
#if NO
                foreach (ListViewItem item in this.listView_records.SelectedItems)
                {
                    string strOperation = ListViewUtil.GetItemText(item, COLUMN_OPERATION);

                    foreach (string o in operations)
                    {
                        if (strOperation.IndexOf(o) == -1)
                        {
                            this.listView_records.Items.Remove(item);
                            nRemoveCount++;
                        }
                    }
                }
#endif
                List<ListViewItem> reserves = new List<ListViewItem>();
                foreach (ListViewItem item in this.listView_records.Items)
                {
                    if (item.Selected == false)
                    {
                        reserves.Add(item);
                        continue;
                    }

                    string strOperation = ListViewUtil.GetItemText(item, COLUMN_OPERATION);

                    foreach (string o in operations)
                    {
                        if (strOperation.IndexOf(o) != -1)
                            reserves.Add(item);
                    }
                }

                nRemoveCount = this.listView_records.Items.Count - reserves.Count;
                this.listView_records.Items.Clear();
                this.listView_records.BeginUpdate();
                foreach (ListViewItem item in reserves)
                {
                    this.listView_records.Items.Add(item);
                }
                this.listView_records.EndUpdate();
            }
            finally
            {
                this.Cursor = oldCursor;
            }
            MessageBox.Show(this, "共移走 '" + nRemoveCount.ToString() + "' 项");
            return;
        }