Пример #1
0
        MatchingParameters Form2;//Remember to dispose this when finish creating model

        //This function initializes the matching parameter form
        private void MatchingInitialize()
        {
            if (HGraphics.allObj.ContainsKey("colored_region")) //check if region is empty
            {
                EndRegionSelect -= MatchingInitialize;          // once MatchingInitialize() is executed, unsubscribe from the event EndRegionSelect
                if (Form2 == null)
                {
                    Form2 = new MatchingParameters();
                }
                else
                {
                    DisposeMatchingForm();
                    Form2 = new MatchingParameters();
                }
                try
                {
                    Form2.Show();
                }
                catch
                {
                    Form2 = new MatchingParameters();
                    Form2.Show();
                }

                HGraphics.allObj["green_matchingRegion"] = CalculateShapeModel(30);
                HGraphics.display();
                Form2.contrastBar.Scroll   += InteractiveContrastSelection;
                Form2.CentroidRadio.Checked = true;//Use centroid as model center


                CalculateModelCenter(HGraphics.allObj["green_matchingRegion"], Form2);

                //Subscriptions **remember to unsubscribe**
                hWindowControl.HMouseDown          += ManualCenterSelection;
                Form2.hWindowControl1.HMouseDown   += ManualCenterSelection;
                Form2.CentroidRadio.CheckedChanged += AutoCenterSelection;
                Form2.CreateModel.Click            += CreateModelOK;
                Form2.Cancel.Click += CreateModelCancel;
            }
        }
Пример #2
0
 /*findModelToolStripMenuItem_Click creates a MatchingParameters form and let user change matching parameters and
  * find model*/
 private void findModelToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (openShapeModel.ShowDialog() == DialogResult.OK)
         {
             HGraphics.keepOnly(new string[] { "pic" });
             HGraphics.display();
             if (Form2 != null)
             {
                 DisposeMatchingForm();
             }
             Form2 = new MatchingParameters(MatchingParameters.deserialize(openShapeModel.FileName));
             Form2.Show();
             Form2.FindButton.Click += findModelClick;
         }
     }
     catch (Exception ex)
     {
         Log(ex.ToString() + "\n");
     }
 }