示例#1
0
        private void OnOpenDb(object sender, EventArgs e)
        {
            bool ret = OpenDbDlg();

            if (ret)
            {
                //Close editor
                m_edtPanel.clear();
                m_rsc.Panel2Collapsed = true;
                m_rsc.Panel2.Hide();

                //update config
                var cnf = ConfigMng.getInstance();
                cnf.m_content.closeCnn();
                cnf.m_cnnInfo.cnnStr = m_cnnStr;
                cnf.m_content.initCnn(m_cnnStr);
                renderTree();

                //reset current title
                m_curTitle = "";

                //update form title
                UpdateFormName();
            }
        }
示例#2
0
    void Start()
    {
        ConfigMng configMng = GlobalMng.GlobalSingleton <ConfigMng>();

        configMng.Init();
        configMng.AllConfigLoadEnd += OnConfigLoaded;
    }
示例#3
0
        private void OpenFindWnd()
        {
            var dlg = new Form();

            dlg.Name = "Find";
            dlg.Icon = new Icon(@"..\..\..\Search.ico");
            var cfg = ConfigMng.getInstance();

            dlg.Font = new Font(cfg.m_fontFamily, cfg.m_fontSize);
            var srchPanel = new SearchPanel(cfg.m_cnnInfo.cnnStr);

            dlg.Controls.Add(srchPanel.m_tblLayout);
            srchPanel.OnSelectTitle += (s, e) =>
            {
                var title = m_titles.Find((x) => { return(x.ID == e); });
                DisplayTitle2(title);
            };

            dlg.AcceptButton = srchPanel.m_acceptBtn;

            if (cfg.m_srchWndSize.Width > 0)
            {
                dlg.Location = cfg.m_srchWndPos;
                dlg.Size     = cfg.m_srchWndSize;
            }
            dlg.FormClosed += (s, e) =>
            {
                cfg.m_srchWndPos  = dlg.Location;
                cfg.m_srchWndSize = (dlg.WindowState == FormWindowState.Normal) ? dlg.Size : dlg.RestoreBounds.Size;
            };
            dlg.Show();
        }
示例#4
0
        private void VM_GUI_Load(object sender, EventArgs e)
        {
            ///////Ini State///
            mnViewer.ForeColor = Color.WhiteSmoke;
            oOriColor          = btnLauch.BackColor;
            sOriText           = btnLauch.Text;
            fStopLaodingLauch();
            fUpdateRtState();
            /////////////////////


            Rectangle screenRectangle = this.RectangleToScreen(this.ClientRectangle);

            nTtitleHeight = screenRectangle.Top - this.Top;
            nTtitleHeight = 0;
            // fOut(null, "nTitleHeight: " + nTtitleHeight);


            oConfig = new ConfigMng();
            oConfig.LoadConfig(this);
            if (ConfigMng.bLoadFailed)
            {
                ConfigMng.oConfig.vStartSize = Size;
                ConfigMng.oConfig.vStartPos  = Location;
            }

            if (ConfigMng.oConfig.bMaximize)
            {
                WindowState = FormWindowState.Maximized;
                fMaximizedState();
            }

            fLoadRecent();
            bCreated = true;
        }
示例#5
0
        string GenHtmlTxt(string jsTxt)
        {
            string path    = ConfigMng.findTmpl("templ.html");
            var    txt     = File.ReadAllText(path);
            var    htmlTxt = txt.Replace("var jsTxt = null", "var jsTxt = " + jsTxt);

            return(htmlTxt);
        }
示例#6
0
        private string genHtmlTxt(string jsTxt)
        {
#if use_chromium
            var path = ConfigMng.findTmpl("search.html");
#elif use_gecko
            var path = ConfigMng.findTmpl("search_gecko.html");
#endif
            var txt     = File.ReadAllText(path);
            var htmlTxt = txt.Replace("var jsTxt = null", "var jsTxt = " + jsTxt);
            return(htmlTxt);
        }
示例#7
0
        private void MiFont_Click(object sender, EventArgs e)
        {
            FontDialog fontDialog1 = new FontDialog();
            ConfigMng  cfg         = ConfigMng.getInstance();

            fontDialog1.Font = new Font(cfg.m_fontFamily, cfg.m_fontSize);

            if (fontDialog1.ShowDialog() != DialogResult.Cancel)
            {
                cfg.m_fontFamily = fontDialog1.Font.FontFamily.Name;
                cfg.m_fontSize   = fontDialog1.Font.Size;
                string msg = string.Format("Selected font {0} size {1} will be applied after restart application",
                                           fontDialog1.Font.Name, fontDialog1.Font.Size);
                MessageBox.Show(msg, "Font changed!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#8
0
        private void button1_Click(object sender, EventArgs e)
        {
            TitleEdt edt = new TitleEdt(true);

            edt.m_edtPanel.m_title = new MyTitle()
            {
                ID = 5,
            };

            var cnnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=<db>;";

            cnnStr = cnnStr.Replace("<db>", @"D:\tmp\github\utilities\KinhPhat\kinhtang.accdb");
            ConfigMng.getInstance().m_content.initCnn(cnnStr);
            //edt.m_edtPanel.m_cnnStr = cnnStr;
            //edt.m_edtPanel.initCnn();
            edt.m_edtPanel.loadTitle();
            edt.m_edtPanel.updateCmb();
            edt.ShowDialog();
        }
示例#9
0
        private void OnCloseForm(object sender, FormClosedEventArgs e)
        {
            Queue <TreeNodeCollection> q = new Queue <TreeNodeCollection>();

            q.Enqueue(m_tree.Nodes);
            List <string> selected = new List <string>();
            List <string> expanded = new List <string>();

            while (q.Count > 0)
            {
                var nodes = q.Dequeue();
                foreach (TreeNode node in nodes)
                {
                    if (node.Nodes.Count > 0)
                    {
                        q.Enqueue(node.Nodes);
                    }
                    else
                    {
                        //leaf
                        if (node.StateImageIndex == 1)
                        {
                            selected.Add((string)node.Tag);
                        }
                    }

                    if (node.IsExpanded)
                    {
                        expanded.Add((string)node.Tag);
                    }
                }
            }
            var cfg = ConfigMng.getInstance();

            cfg.m_curSts.selectedTitles = selected;
            cfg.m_curSts.expandedNodes  = expanded;
            cfg.m_curSts.readingTitle   = m_curTitle;
            cfg.m_wndPos  = this.Location;
            cfg.m_wndSize = (this.WindowState == FormWindowState.Normal) ? this.Size : this.RestoreBounds.Size;
            cfg.SaveConfig();
        }
示例#10
0
        private void OnLoadForm(object sender, EventArgs e)
        {
            var cfg    = ConfigMng.getInstance();
            var cnnStr = cfg.m_cnnInfo.cnnStr;

            if (cnnStr == null && OpenDbDlg())
            {
                cfg.m_cnnInfo.cnnStr = m_cnnStr;
                cfg.m_content.initCnn(m_cnnStr);
                renderTree();

                //set form title
                UpdateFormName();
            }
            else
            {
                m_cnnStr = cfg.m_cnnInfo.cnnStr;
                cfg.m_content.initCnn(m_cnnStr);
                renderTree();

                //restore state
                //restoreSts();

                //set form title
                UpdateFormName();
            }

            //set font
            this.Font = new Font(cfg.m_fontFamily, cfg.m_fontSize);
            this.MainMenuStrip.Font = new Font(cfg.m_fontFamily, cfg.m_fontSize);

            if (cfg.m_wndSize.Width > 0)
            {
                this.Location = cfg.m_wndPos;
                this.Size     = cfg.m_wndSize;
            }

            m_wb.AddMessageEventListener("addNewMsg", OnaddNewMsg);
            m_wb.AddMessageEventListener("addLikeMsg", OnaddLikeMsg);
            m_wb.AddMessageEventListener("addProgReg", OnaddProgReg);
        }
示例#11
0
        void restoreSts()
        {
            var sts = ConfigMng.getInstance().m_curSts;

            foreach (string path in sts.selectedTitles)
            {
                var node = GetTreeNode(path);
                Check(node, true);
            }
            foreach (string path in sts.expandedNodes)
            {
                var node = GetTreeNode(path);
                node.Expand();
            }

            foreach (var title in m_titles)
            {
                if (title.zPath == sts.readingTitle)
                {
                    DisplayTitle2(title);
                    break;
                }
            }
        }
示例#12
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";
        }
示例#13
0
        private void M_trck_ValueChanged(object sender, EventArgs e)
        {
            var cfg = ConfigMng.getInstance();

            cfg.m_srchMaxD = m_trck.Value;
        }
示例#14
0
        SrchRec[] calcDiff(MyWord[][] arr, int nRow)
        {
            var cfg     = ConfigMng.getInstance();
            int max_res = cfg.m_srchMaxRes;
            int max_d   = cfg.m_srchMaxD;

            var begin = Environment.TickCount;
            var res   = new SrchRec[arr[0].Length];

            for (int i = 0; i < arr[0].Length; i++)
            {
                res[i] = new SrchRec()
                {
                    path = new int[] { i }, d = 0
                };
            }
            for (var row = 1; row < nRow; row++)
            {
                var lst     = arr[row];
                var prevLst = arr[row - 1];
                var tmplRes = new List <int[]>();
                for (var j = 0; j < res.Length; j++)
                {
                    var prevD = res[j].d;
                    var prevI = res[j].path[row - 1];
                    var prevW = prevLst[prevI];
                    for (var k = 0; k < lst.Length; k++)
                    {
                        var curW = lst[k];
                        if (prevW.titleId == curW.titleId)
                        {
                            //var d = wordDiff(res[j].w, lst[k]);
                            var d = Convert.ToInt32(prevW.parId) - Convert.ToInt32(curW.parId);
                            d *= d < 0 ? -100 : 100;
                            d += Math.Abs(prevW.pos - curW.pos) * 10;
                            d += prevD;
                            tmplRes.Add(new int[] { j, k, d });
                        }
                    }
                }

                var h   = new MyHeap <int[]>(tmplRes.ToArray(), (x, y) => x[2] - y[2]);
                var n   = Math.Min(max_res, tmplRes.Count);
                var top = new SrchRec[n];
                for (int i = 0; i < n; i++)
                {
                    var t = h.PopMin();

                    //chk distance
                    if (t[2] > max_d)
                    {
                        Array.Resize(ref top, i);
                        break;
                    }

                    var newRec = new SrchRec()
                    {
                        d = t[2], path = new int[row + 1]
                    };
                    res[t[0]].path.CopyTo(newRec.path, 0);
                    newRec.path[row] = t[1];
                    top[i]           = newRec;
                }
                res = top;
            }
            var elapsed = Environment.TickCount - begin;

            Debug.WriteLine("calc diff {0}", elapsed);
            foreach (var item in res)
            {
                var row = 0;
                item.detail = item.path.Select(v => arr[row++][v]).ToList();
            }
            return(res);
        }
示例#15
0
 private void Start()
 {
     Instance = this;
 }