Beispiel #1
0
        private void GrabContours_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            lock (m_sync)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = "Contours set (*.set)|*.set";

                if (sfd.ShowDialog() == true)
                {
                    var contourInfos = m_lastFindedContours.Select(fullInfo => new ContourInformation(Contour.AlignInUnitRectangle(fullInfo.Contour)));
                    var collection   = new ContourInformationCollection(contourInfos);

                    try
                    {
                        using (Stream stream = sfd.OpenFile())
                        {
                            collection.Save(stream);
                        }
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(string.Format("Error while saving contour collection: {0}", exc.Message));
                    }
                }
            }
        }
Beispiel #2
0
        private void LoadFamiliar_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Contours set (*.set)|*.set";

            if (ofd.ShowDialog() == true)
            {
                try
                {
                    Stream stream = File.OpenRead(ofd.FileName);

                    m_familiar = ContourInformationCollection.Load(stream);

                    m_matcher.FamiliarContours = m_familiar;
                    m_matcher.BringFamiliarContours(m_targetLen);

                    LoadedContourCollectionInfo.Text = string.Format("{0} contour(s) has been successfully loaded", m_familiar.Count);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(string.Format("Error while loading contour collection: {0}", exc.Message));
                }
            }
        }
        private void LoadFamiliarButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Contour collection|*.set";

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                using (Stream stream = File.Open(ofd.FileName, FileMode.Open))
                {
                    var loadedContours = ContourInformationCollection.Load(stream);

                    m_matcher.FamiliarContours = loadedContours;
                    m_matcher.BringFamiliarContours(m_targetContoursLenght);
                }
            }
        }
 private void AddFromCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (m_ofd.ShowDialog() == true)
     {
         using (Stream stream = File.Open(m_ofd.FileName, FileMode.Open))
         {
             try
             {
                 ContourInformationCollection.Load(stream).ForEach(c => Contours.Add(c));
             }
             catch (Exception exc)
             {
                 MessageBox.Show(exc.Message);
             }
         }
     }
 }
        private void SaveButton_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Contour collection|*.set";

            lock (m_findedContours)
            {
                if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    using (Stream stream = sfd.OpenFile())
                    {
                        var findedContourInfos = m_findedContours.Select(finded => new ContourInformation(Contour.AlignInUnitRectangle(finded.Contour)));
                        var findedCollection   = new ContourInformationCollection(findedContourInfos);

                        findedCollection.Save(stream);
                    }
                }
            }
        }