Ejemplo n.º 1
0
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("On", "");

            lChecker.addItemName(lItem);
            mOnItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Value");
            lChecker.addItemName(lItem);
            mValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            SignalString = lReader.getAttribute <String>("Signal");
            Bias         = lReader.getAttribute <Double>("Bias", mBias);
            Amplitude    = lReader.getAttribute <Double>("Amplitude", mAmplitude);
            PeriodMS     = lReader.getAttribute <UInt32>("PeriodMS", mPeriodMS);
            TurnMS       = lReader.getAttribute <UInt32>("TurnMS", mTurnMS);
            StartMS      = lReader.getAttribute <UInt32>("StartMS", mStartMS);

            try
            {
                mValue = (double)mItemBrowser.readItemValue(mValueItemHandle);
            }
            catch
            {
                if (mSignal > 0)
                {
                    mPeriodStartMS = MiscUtils.TimerMS - mStartMS;
                    mCurrentMS     = mStartMS;
                    mFSM.executeStateAction();
                }
            }
        }
        private void                updateForm()
        {
            if (mPBoxBmp != null)
            {
                pictureBox.Image = null;
                mPBoxBmp.Dispose();
                mPBoxBmp = null;
            }

            if (mBmp != null)
            {
                var lWidth = mBmp.Width;
                if (mWidthItemHandle != -1)
                {
                    try
                    {
                        lWidth = (int)mBrowser.readItemValue(mWidthItemHandle);
                    }
                    catch {}

                    if (lWidth > ImageMove.Move.MaxWidth)
                    {
                        lWidth = ImageMove.Move.MaxWidth;
                    }
                }

                var lHeight = mBmp.Height;
                if (mHeightItemHandle != -1)
                {
                    try
                    {
                        lHeight = (int)mBrowser.readItemValue(mHeightItemHandle);
                    }
                    catch {}

                    if (lHeight > ImageMove.Move.MaxHeight)
                    {
                        lHeight = ImageMove.Move.MaxHeight;
                    }
                }

                var lLabel = "";
                if (mLabelItemHandle != -1)
                {
                    try
                    {
                        lLabel = StringUtils.ObjectToString(mBrowser.readItemValue(mLabelItemHandle));
                    }
                    catch {}
                }

                var mPBoxBmp = new Bitmap(lWidth, lHeight);
                mPBoxBmp.SetResolution(mBmp.HorizontalResolution, mBmp.VerticalResolution);

                using (var lGraphics = Graphics.FromImage(mPBoxBmp))
                {
                    lGraphics.Clear(Color.Transparent);
                    lGraphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
                    lGraphics.DrawImage(mBmp, 0, 0, lWidth, lHeight);
                    if (String.IsNullOrWhiteSpace(lLabel) == false)
                    {
                        lGraphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

                        using (var lBrush = new SolidBrush(mLabelColor))
                        {
                            lGraphics.DrawString(lLabel, mLabelFont, lBrush, 0, 0);
                        }
                    }
                }

                pictureBox.Image     = mPBoxBmp;
                labelControl_HW.Text = StringUtils.ObjectToString(lWidth) + ", " + StringUtils.ObjectToString(lHeight);
            }
            else
            {
                labelControl_HW.Text = "0, 0";
            }
        }