コード例 #1
0
 private void RotationScannerForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     SetState(ScanningStates.None);
     Turntable.DeviceConnected    -= Turntable_DeviceConnected;
     Turntable.DeviceDisconnected -= Turntable_DeviceDisconnected;
     if (Modeller != null)
     {
         Modeller.Dispose();
         Modeller = null;
     }
     if (Turntable != null)
     {
         Turntable.Dispose();
         Turntable = null;
     }
     SF.SaveSettings();
     SF.Dispose();
     SF = null;
 }
コード例 #2
0
        public RotationScannerForm(KinectScanContext context)
        {
            InitializeComponent();
            Context = context;

            //Modeller
            Modeller = new ExCoreModeller(Context);
            Modeller.CreateDevice(XPanel);
            Modeller.DebugLoad();

            //GUI
            Array ViewModes = Enum.GetValues(typeof(Modeller.Views));

            string[] specialViewModes = Modeller.SpecialViewModes;

            MenuItem MI;

            foreach (Modeller.Views mode in ViewModes)
            {
                if (mode == KinectScan.Modeller.Views.Special && specialViewModes.Length > 0)
                {
                    continue;
                }
                MI            = new MenuItem(mode.ToString());
                MI.RadioCheck = true;
                if (Modeller.ViewMode == mode)
                {
                    MI.Checked     = true;
                    MISelectedView = MI;
                }
                MI.Click += (object sender, EventArgs e) =>
                {
                    if (MISelectedView != null)
                    {
                        MISelectedView.Checked = false;
                    }
                    MISelectedView         = (MenuItem)sender;
                    MISelectedView.Checked = true;
                    Modeller.ViewMode      = (Modeller.Views)MISelectedView.Tag;
                };
                MI.Tag = mode;
                MIView.MenuItems.Add(MI);
            }

            if (specialViewModes.Length > 0)
            {
                int i = 0;
                MIView.MenuItems.Add(new MenuItem("-"));
                foreach (string mode in specialViewModes)
                {
                    MI            = new MenuItem(mode.ToString());
                    MI.RadioCheck = true;
                    MI.Checked    = (Modeller.ViewMode == Modeller.Views.Special && Modeller.SpecialViewMode == i);
                    MI.Click     += (object sender, EventArgs e) =>
                    {
                        if (MISelectedView != null)
                        {
                            MISelectedView.Checked = false;
                        }
                        MISelectedView           = (MenuItem)sender;
                        MISelectedView.Checked   = true;
                        Modeller.ViewMode        = KinectScan.Modeller.Views.Special;
                        Modeller.SpecialViewMode = (int)MISelectedView.Tag;
                    };
                    MI.Tag = i++;
                    MIView.MenuItems.Add(MI);
                }
            }

            MIViewLegs.MenuItems[Modeller.VisualizedLeg].Checked = true;

            XPanel.KeyDown += (object o, KeyEventArgs e) => {
                switch (e.KeyCode)
                {
                case Keys.Space:
                    MIScan_Click(this, null);
                    break;

                case Keys.Tab:
                    TScan.Start();
                    break;
                }
            };

            //Settings
            SF = new TurntableSettingsForm();
            SF.LoadSettings();
            SF.SetModeller(Modeller);

            //Scanning
            ScanUITimer          = new Timer();
            ScanUITimer.Interval = 100;
            ScanUITimer.Tick    += (object sender, EventArgs e) =>
            {
                if (ScanningState == ScanningStates.Scanning)
                {
                    int degrees = (int)Turntable.PositionInDegrees;
                    TSPB.Value = degrees;
                    TSSL.Text  = string.Format(LocalizedResources.ScannerScanning, degrees);
                }
            };
            SetState(ScanningStates.None);
            Context.ScannerCreated += Context_ScannerCreated;
            if (Context.Scanner != null)
            {
                Context_ScannerCreated(this, null);
            }
            Turntable.DeviceConnected    += Turntable_DeviceConnected;
            Turntable.DeviceDisconnected += Turntable_DeviceDisconnected;
            TScan          = new Timer();
            TScan.Interval = 20000;
            TScan.Tick    += (object sender, EventArgs e) => { MIScan_Click(this, null); TScan.Stop(); };
        }