Ejemplo n.º 1
0
 private void OnOpenTitle(string s)
 {
     OnSelectTitle?.Invoke(m_wb, Convert.ToUInt64(s));
 }
Ejemplo n.º 2
0
        public SearchPanel(string cnnStr, bool bldSrchDb = false)
        {
            this.cnnStr = cnnStr;

            m_tblLayout      = new TableLayoutPanel();
            m_tblLayout.Dock = DockStyle.Fill;

            var edt = new TextBox();

            edt.Anchor = AnchorStyles.Left | AnchorStyles.Right;

            var btn = new Button();

            btn.Text     = "Search";
            btn.AutoSize = true;
            btn.Anchor   = AnchorStyles.Right;
            if (!bldSrchDb)
            {
                btn.Click += (s, e) =>
                {
                    OnSearch(edt.Text);
                };
            }
            else
            {
                btn.Click += (s, e) =>
                {
                    BuildSearchDb();
                };
            }
            m_acceptBtn = btn;

#if use_chromium
            var lst = new CefSharp.WinForms.ChromiumWebBrowser("");
            lst.Dock = DockStyle.Fill;
            JsHandler jsHandler = new JsHandler();
            jsHandler.OnTitleSelected += (s, e) =>
            {
                Debug.WriteLine("OnSelectTitle {0}", e);
                OnSelectTitle?.Invoke(s, Convert.ToUInt64(e));
            };
            lst.JavascriptObjectRepository.Register("jsHandler", jsHandler, true);
            m_wb = lst;
#elif use_gecko
            var lst = new Gecko.GeckoWebBrowser();
            lst.Dock = DockStyle.Fill;
            m_wb     = lst;
#else
            var lst = new ListView();
            lst.View                  = View.Details;
            lst.FullRowSelect         = true;
            lst.GridLines             = true;
            lst.Dock                  = DockStyle.Fill;
            lst.ItemSelectionChanged += (s, e) =>
            {
                //UInt64 titleId = 0;
                foreach (ListViewItem li in lst.SelectedItems)
                {
                    //UInt64.TryParse(li.SubItems[1].Text, out titleId);
                    //OnSelectTitle(titleId);
                    OnSelectTitle?.Invoke(s, Convert.ToUInt64(li.SubItems[1].Tag));
                    break;
                }
            };
            m_lstV = lst;
#endif

            //var sts = new StatusBar
            //{
            //    Dock = DockStyle.Bottom,
            //    ShowPanels = false
            //};
            //m_sts = sts;

            //m_trck = new TrackBar();
            //m_trck.Maximum = 1000;
            //m_trck.Minimum = 500;
            //m_trck.Height = 30;
            //var flow = new FlowLayoutPanel();
            //flow.Dock = DockStyle.Fill;
            //flow.FlowDirection = FlowDirection.RightToLeft;
            //flow.Height = 30;
            //m_sts.Height = 50;
            //m_sts.Width = 300;
            //flow.Controls.Add(m_trck);
            //flow.Controls.Add(m_sts);

            int iRow = 0;
            m_tblLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
            m_tblLayout.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
            m_tblLayout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            //m_tblLayout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            m_tblLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
            m_tblLayout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            m_tblLayout.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
            m_tblLayout.Controls.Add(edt, 0, iRow);
            m_tblLayout.Controls.Add(btn, 1, iRow++);
            m_tblLayout.Controls.Add(lst, 0, iRow++);
            m_tblLayout.SetColumnSpan(lst, 2);
            //m_tblLayout.Controls.Add(sts, 0, iRow);
            //m_tblLayout.Controls.Add(m_trck, 1, iRow);
            m_tblLayout.CellBorderStyle = TableLayoutPanelCellBorderStyle.None;

            var statusStrip1 = new StatusStrip();
            statusStrip1.LayoutStyle = ToolStripLayoutStyle.Table;
            var toolStripStatusLabel1 = new ToolStripStatusLabel();
            toolStripStatusLabel1.Anchor    = AnchorStyles.Right;
            toolStripStatusLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            var ToolStripTraceBarItem = new ToolStripTraceBarItem();
            ToolStripTraceBarItem.Anchor = AnchorStyles.Left;
            statusStrip1.Items.Add(ToolStripTraceBarItem);
            statusStrip1.Items.Add(toolStripStatusLabel1);
            m_tblLayout.Controls.Add(statusStrip1);
            m_tblLayout.SetColumnSpan(statusStrip1, 2);
            m_trck         = (TrackBar)ToolStripTraceBarItem.Control;
            m_sts          = toolStripStatusLabel1;
            m_trck.Maximum = 1000;
            m_trck.Minimum = 500;
            var cfg = ConfigMng.getInstance();
            m_trck.Value               = cfg.m_srchMaxD;
            m_trck.ValueChanged       += M_trck_ValueChanged;
            toolStripStatusLabel1.Text = "status";
        }