private void AddContourCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var contour = Contour.AlignInUnitRectangle(ContourInput.Contour);

            if (contour != null)
            {
                Contours.Add(new ContourInformation(contour));
            }
        }
        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);
                    }
                }
            }
        }
Exemple #3
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));
                    }
                }
            }
        }