示例#1
0
        //[TestMethod]
        public void WpfMeasurerViewSimpleTest()
        {
            c4352m1_window win    = null; // = new c4352m1_window();
            Thread         thread = new Thread(new ThreadStart(() =>
            {
                SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
                c4352m1_window window = new c4352m1_window();

                win = window;

                window.Closed += (s, e) => Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);
                //window.MoveSelector(34.4);

                window.Show();
                Dispatcher.Run();
            }));

            thread.Name = "Ui_Wpf_Thread";
            thread.SetApartmentState(ApartmentState.STA);
            thread.IsBackground = true;

            thread.Start();

            Thread.Sleep(1000);

            Dispatcher.FromThread(thread).Invoke(new Action(() =>
            {
                //win?.MoveSelector(64.4);
            }));

            Dispatcher.FromThread(thread).Invoke(new Action(() =>
            {
                win?.MoveArrow(55);
                //win?.SetType("1");
            }));


            //win.MoveSelector(34.4);

            while (true)
            {
                Thread.Sleep(1);
            }
        }
示例#2
0
        public void InitializeBase(string pathToBase)
        {
            logger.Info("");
            mDevicesBase = new MDevicesBase(pathToBase);

            string type = mDevicesBase.GetType(measurerSerial);

            device = new Device(mDevicesBase.GetDevice(measurerSerial), mDevicesBase.GetScalesBySerial(measurerSerial));

            switch (type)
            {
            case "c4352m1":

                uiThread = new Thread(new ThreadStart(() =>
                {
                    SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));

                    c4352m1_window window = new c4352m1_window();
                    measurerWindow        = window;

                    window.Closed += (s, e) => Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);

                    window.Show();
                    //window.Visibility = Visibility.Collapsed;
                    Dispatcher.Run();
                }));

                uiThread.SetApartmentState(ApartmentState.STA);
                uiThread.IsBackground = true;

                uiThread.Start();
                break;

            default:
                break;
            }

            //device.SetMesurerState(measurerState.Limit, measurerState.Type, measurerState.Btn);

            comWorker.ChangedProbePoints  += ComWorker_ChangedProbePoints;
            comWorker.ChangeMeasurerState += ComWorker_ChangeMeasurerState;
        }