示例#1
0
        private void trvKategoriler_MouseUp(object sender, MouseEventArgs e)
        {
            TreeNode selected  = trvKategoriler.GetNodeAt(e.X, e.Y);
            object   tagObject = selected.Tag; // KategoriContainer, Kategori, TheSifre..

            IBase obj = (IBase)tagObject;

            txtOzet.Text = obj.GetDataString();

            string[] keywords = new string[5]
            {
                "Adı :", "Açıklama :", "Başlık :", "Kullanıcı Adı :", "Şifre :"
            };

            foreach (string word in keywords)
            {
                int start = 0;

                do
                {
                    // Kelimeyi arar, bulamazsa -1 döner.
                    start = txtOzet.Find(word, start, RichTextBoxFinds.MatchCase);

                    if (start > -1)
                    {
                        // bulunan kelimeyi seçer.
                        txtOzet.Select(start, word.Length);
                        // kelimeyi bold yapar.
                        txtOzet.SelectionFont = new Font(txtOzet.SelectionFont, FontStyle.Bold);

                        // aramaya başlama index i değiştirilir.
                        start += word.Length;
                    }
                } while (start > -1);
            }

            //if(tagObject is KategoriContainer)
            //{
            //    KategoriContainer obj = (KategoriContainer)tagObject;
            //    txtOzet.Text = obj.Title;
            //}

            //if (tagObject is Kategori)
            //{
            //    Kategori obj = (Kategori)tagObject;
            //    txtOzet.Text = obj.Name + "\n" + obj.Description;
            //}

            //if (tagObject is TheSifre)
            //{
            //    TheSifre obj = (TheSifre)tagObject;
            //    txtOzet.Text = obj.Title + "\n" + obj.Username + "\n" + obj.Password + "\n" + obj.Description;
            //}
        }