예제 #1
0
 private void UpdateUi(string Type, double limit, string btn)
 {
     Dispatcher.FromThread(uiThread).Invoke(new Action(() =>
     {
         c4352m1_window w = measurerWindow as c4352m1_window;
         w?.UpdateView(Type, limit, btn);
     }));
 }
예제 #2
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);
            }
        }
예제 #3
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;
        }