コード例 #1
0
        private void rbnDDBtnSearch_MenuItemClick(object sender, PureComponents.ActionSet.RibbonUI.RibbonMenuItemEventArgs e)
        {
            try
            {
                if (e.MenuItem.Text == "Search by Example")
                {
                    this.Cursor = Cursors.WaitCursor;
                    if ((picExample.ImageLocation == null) || (picExample.ImageLocation == ""))
                    {
                        throw new Exception("Please open an example image to find similar images !");
                    }
                    picLstResults.Items.Clear();
                    search srch = new search();
                    //long ll = DateTime.Now.Ticks;
                    List <string[]> res = srch.SearchByExample(picExample.ImageLocation, DBC,
                                                               double.Parse(rbnTxtMaxArea.Text), double.Parse(rbnTxtMinArea.Text));
                    if (res == null)
                    {
                        throw new Exception("An error occured !\nThe database is empty or there are no matches !");
                    }
                    for (int i = 0; i < res.Count; i++)
                    {
                        string name = res[i][0];

                        string imgpath = SC.SettingsList[0].Trim('\\') + "\\" + res[i][1] + "\\" + res[i][0];

                        Bitmap bmp = new Bitmap(imgpath);
                        PureComponents.EntrySet.Lists.PictureListItem pItem =
                            new PureComponents.EntrySet.Lists.PictureListItem(name + res[i][2],
                                                                              bmp, true, null);
                        pItem.Tag   = imgpath;
                        pItem.Value = res[i][3];
                        picLstResults.Items.Add(pItem);
                    }
                    rbnMain.StatusBar.Text =
                        rbnMain.StatusBar.Text.Remove(rbnMain.StatusBar.Text.IndexOf("."));
                    rbnMain.StatusBar.Text = rbnMain.StatusBar.Text + ". Number of results is " + res.Count;
                    //ll = DateTime.Now.Ticks - ll;
                    //ll = ll / 1000;
                    //ll = ll / 3600;
                    //MessageBox.Show(ll.ToString());
                    this.Cursor = Cursors.Default;
                }
                else
                {
                    MessageBox.Show("Search by semantic is not activated !");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Searching Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Cursor = Cursors.Default;
            }
        }
コード例 #2
0
        private void viewAllImages()
        {
            try
            {
                DBC.CommandText = "SELECT * FROM IMAGE";
                DataSet ds = DBC.ExecuteQuery();
                DataSet sds;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    string fname = ds.Tables[0].Rows[i].ItemArray[1].ToString();
                    string imgID = ds.Tables[0].Rows[i].ItemArray[0].ToString();

                    double sid = Math.Floor((double.Parse(imgID) / 100));

                    DBC.CommandText = "SELECT FolderPath FROM Series WHERE SID = " + sid.ToString() + " ;";
                    sds             = DBC.ExecuteQuery();
                    if (sds.Tables[0].Rows.Count < 1)
                    {
                        return;
                    }

                    string imgFld = sds.Tables[0].Rows[0].ItemArray[0].ToString();

                    imgFld = (imgFld.EndsWith("\\")) ? imgFld : imgFld + "\\";
                    imgFld = (imgFld.StartsWith("\\")) ? imgFld : "\\" + imgFld;

                    string imgpath = this.SC.SettingsList[0].TrimEnd('\\') + imgFld + fname;
                    Bitmap bmp     = new Bitmap(imgpath);
                    PureComponents.EntrySet.Lists.PictureListItem pItem =
                        new PureComponents.EntrySet.Lists.PictureListItem(fname,
                                                                          bmp, true, null);
                    pItem.Tag = imgpath;
                    imageRecord imgRecord = new imageRecord(imgID, null, fname, null);
                    pItem.Value = imgRecord;
                    picLstResults.Items.Add(pItem);
                }
                rbnMain.StatusBar.Text = "Database is connected.";
                rbnMain.StatusBar.Text = rbnMain.StatusBar.Text + " - - - - You have "
                                         + picLstResults.Items.Count + " images in the database";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error viewing all images", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }