示例#1
0
        public void UIThreadMethod()
        {
            InitializeComponent();

            PosCommon so = wr.Target as PosCommon;

            if (so != null)
            {
                this.Text = so.DeviceName;

                // create status bar panels
                sbpState             = new StatusBarPanel();
                sbpState.BorderStyle = StatusBarPanelBorderStyle.Sunken;
                sbpState.AutoSize    = StatusBarPanelAutoSize.Spring;
                statusBar1.Panels.Add(sbpState);

                piDataCount = so.GetType().GetProperty("DataCount");
                if (piDataCount != null)
                {
                    sbpDataCount             = new StatusBarPanel();
                    sbpDataCount.BorderStyle = StatusBarPanelBorderStyle.Sunken;
                    sbpDataCount.AutoSize    = StatusBarPanelAutoSize.Spring;
                    statusBar1.Panels.Add(sbpDataCount);
                }

                piDataEventEnabled = so.GetType().GetProperty("DataEventEnabled");
                if (piDataEventEnabled != null)
                {
                    sbpDataEventsEnabled             = new StatusBarPanel();
                    sbpDataEventsEnabled.BorderStyle = StatusBarPanelBorderStyle.Sunken;
                    sbpDataEventsEnabled.AutoSize    = StatusBarPanelAutoSize.Spring;
                    statusBar1.Panels.Add(sbpDataEventsEnabled);
                }
            }

            so = null;
            Application.Run(this);
        }
示例#2
0
 private void SetDataEventEnabledPosCommon(ref PosCommon posCommon, bool isEnabled)
 {
     try
     {
         PropertyInfo dataEventEnabled = posCommon.GetType().GetProperty("DataEventEnabled");
         if (dataEventEnabled != null)
         {
             dataEventEnabled.SetValue(posCommon, isEnabled, null);
         }
     }
     catch (Exception ex)
     {
         sMessengeError = ex.Message;
     }
 }
示例#3
0
        private void HookUpEvents(PosCommon pc, bool attach)
        {
            EventInfo dataEvent = pc.GetType().GetEvent("DataEvent");

            if (dataEvent != null)
            {
                if (attach)
                {
                    dataEvent.AddEventHandler(pc, new DataEventHandler(co_OnDataEvent));
                }
                else
                {
                    dataEvent.RemoveEventHandler(pc, new DataEventHandler(co_OnDataEvent));
                }
            }
        }
示例#4
0
        void HookUpEvents(PosCommon pc, bool attach)
        {
            if (pc == null)
                return;

            if (attach)
            {
                pc.StatusUpdateEvent += new StatusUpdateEventHandler(co_OnStatusUpdateEvent);
                pc.DirectIOEvent += new DirectIOEventHandler(co_OnDirectIOEvent);
            }
            else
            {
                pc.StatusUpdateEvent -= new StatusUpdateEventHandler(co_OnStatusUpdateEvent);
                pc.DirectIOEvent -= new DirectIOEventHandler(co_OnDirectIOEvent);
            }

            EventInfo dataEvent = pc.GetType().GetEvent("DataEvent");
            if (dataEvent != null)
            {
                if (attach)
                    dataEvent.AddEventHandler(pc, new DataEventHandler(co_OnDataEvent));
                else
                    dataEvent.RemoveEventHandler(pc, new DataEventHandler(co_OnDataEvent));
            }

            EventInfo errorEvent = pc.GetType().GetEvent("ErrorEvent");
            if (errorEvent != null)
            {
                if (attach)
                    errorEvent.AddEventHandler(pc, new DeviceErrorEventHandler(co_OnErrorEvent));
                else
                    errorEvent.RemoveEventHandler(pc, new DeviceErrorEventHandler(co_OnErrorEvent));
            }

            EventInfo outputCompleteEvent = pc.GetType().GetEvent("OutputCompleteEvent");
            if (outputCompleteEvent != null)
            {
                if (attach)
                    outputCompleteEvent.AddEventHandler(pc, new OutputCompleteEventHandler(co_OnOutputCompleteEvent));
                else
                    outputCompleteEvent.RemoveEventHandler(pc, new OutputCompleteEventHandler(co_OnOutputCompleteEvent));
            }
        }
示例#5
0
        void SetCheckState(PosCommon pc, CheckBox cb, string propertyName)
        {
            cb.Tag = cb; // Mark the tag so that we event handler is disabled
            try
            {
                if (pc == null)
                {
                    cb.Enabled = cb.Checked = false;
                }
                else
                {
                    PropertyInfo pi = pc.GetType().GetProperty(propertyName);
                    if (pi != null)
                    {
                        cb.Enabled = true;

                        if (pc.State != ControlState.Closed)
                        {
                            try
                            {
                                if (propertyName == "PowerNotify")
                                    cb.Checked = ((PowerNotification)pi.GetValue(pc, null)) == PowerNotification.Enabled;
                                else
                                    cb.Checked = (bool)pi.GetValue(pc, null);
                            }
                            catch (Exception)
                            {
                                cb.Checked = false;
                            }
                        }
                        else
                            cb.Checked = false;

                    }
                    else
                        cb.Enabled = cb.Checked = false;
                }
            }
            finally
            {
                cb.Tag = null;
            }
        }
示例#6
0
 bool ImplementsProperty(PosCommon pc, string PropertyName)
 {
     if (pc != null)
         return (pc.GetType().GetProperty(PropertyName) != null);
     return false;
 }
示例#7
0
 bool ImplementsMethod(PosCommon pc, string methodName)
 {
     if (pc != null)
         return (pc.GetType().GetMethod(methodName) != null);
     return false;
 }