public AddChangeParametersViewModel(ChangeDelegate changeDelegate, Parameters param, string testName)
 {
     _isAdd               = false;
     this._param          = param;
     this.TestName        = testName;
     this._changeDelegate = changeDelegate;
 }
Ejemplo n.º 2
0
 internal static void TryBind <OutT, InT>(ref ChangeDelegate <OutT> result, ChangeDelegate <InT> body)
 {
     if (typeof(OutT) == typeof(InT))
     {
         result = (ChangeDelegate <OutT>)(object) body;
     }
 }
Ejemplo n.º 3
0
        public ChangeDelegateKey addChangeListener(ChangeDelegate changeDelegate)
        {
            ChangeDelegateKey changeDelegateKey = new ChangeDelegateKey(changeDelegate);

            _changeListeners.Add(changeDelegateKey);
            return(changeDelegateKey);
        }
Ejemplo n.º 4
0
        public void watchChangeCycle(ChangeDelegate changeDelegate, Action onNoChange)
        {
            var hasChanges = false;

            foreach (string fileName in getFileList())
            {
                try
                {
                    // check if we have any changes
                    // Two lines by intention. Please do not unite into one line as in that case the order of
                    // the operands would be meaningful and in wrong order would cause pollChangesTo to not be called!!!!
                    var changedThisFile = pollChangesToWithLimit(fileName, changeDelegate, linesPerBatch);
                    hasChanges = changedThisFile || hasChanges;
                }
                catch (Exception e)
                {
                    Log.Error(e, "Unexpected exception occured during reading the log lines of file: {0}! Exception: ", fileName);
                }
            }

            // Run the on-no-change delegate if nothing has changed
            if (!hasChanges)
            {
                onNoChange();
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Raises event 'ChangeDelegate'
 /// </summary>
 protected virtual void OnChangeDelegate()
 {
     if (ChangeDelegate != null)
     {
         ChangeDelegate.Invoke(this, System.EventArgs.Empty);
     }
 }
Ejemplo n.º 6
0
 public AddChangeTestViewModel(ChangeDelegate changeDelegate, Tests test)
 {
     _isAdd               = false;
     this._test           = test;
     _parametres          = new ObservableCollection <Parameters>(test.Parameters);
     this._changeDelegate = changeDelegate;
 }
Ejemplo n.º 7
0
 public static void IfChangedThen(DrawDelegate ifChanged, ChangeDelegate then)
 {
     if (ChangeCheck(ifChanged) && then != null)
     {
         then();
     }
 }
Ejemplo n.º 8
0
        public KinectCamera()
        {
            InitializeComponent();

            mKinectTick = new ChangeDelegate(Nui_Tick);
            Disposed += new EventHandler(KinectPanel_Disposed);
            HandleCreated += new EventHandler(KinectPanel_HandleCreated);
        }
Ejemplo n.º 9
0
        public KinectCamera()
        {
            InitializeComponent();

            mKinectTick    = new ChangeDelegate(Nui_Tick);
            Disposed      += new EventHandler(KinectPanel_Disposed);
            HandleCreated += new EventHandler(KinectPanel_HandleCreated);
        }
Ejemplo n.º 10
0
        public void Init(ChangeDelegate thisDelegate)
        {
            this.thisDelegate = thisDelegate;
            this.PageSize     = int.Parse(comboBox1.SelectedItem.ToString());
            this.Enabled      = true;
            ObjectCollection list = comboBox1.Items;

            switchButtonStatus();
        }
Ejemplo n.º 11
0
        void HeavyWorkDoing()
        {
            var countdown = 5;

            while(countdown >= 0)
            {
                //Oops ! Potentielles Problem mit Multithreading...
                //MyLabel.Content = "Noch " + countdown + " Sekunden";

                //Daher brauchen wir einen Delegate
                ChangeDelegate del = new ChangeDelegate(ChangeCountdown);
                MyLabel.Dispatcher.Invoke(del, countdown);

                Thread.Sleep(1000);
                countdown--;
            }
        }
Ejemplo n.º 12
0
        public SimpleKinectCursor()
        {
            GlobalConditions.Init();

            mTickListener    = new ChangeDelegate(Nui_Tick);
            mSmoothingFactor = Scalar.Create(mConfig.CursorSmoothing);

            /*
             * mHandR = test ? Vector.Create("HandR", 0f, 0f, 0f) : Nui.smooth(Nui.joint(Nui.Hand_Right), mSmoothingFactor);
             * mHandL = test ? Vector.Create("HandL", 0f, 0f, 0f) : Nui.smooth(Nui.joint(Nui.Hand_Left), HAND_SMOOTHING_FRAMES);
             * mAnchor = test ? Vector.Create("Anchor", 0f, 0f, 0f) : Nui.smooth(Nui.joint(Nui.Hip_Centre), ANCHOR_SMOOTHING_FRAMES);
             */
            mHandR  = Nui.smooth(Nui.joint(Nui.Hand_Right), mSmoothingFactor);
            mHandL  = Nui.smooth(Nui.joint(Nui.Hand_Left), mSmoothingFactor);
            mAnchor = Nui.smooth(Nui.joint(Nui.Hip_Centre), ANCHOR_SMOOTHING_FRAMES);

            mLeftShift = Scalar.Create("Left Shift", .0f);
            mUpShift   = Scalar.Create("Up Shift", .0f);

            mWidth  = Scalar.Create("Width", .5f);
            mHeight = Scalar.Create("Height", .5f);
            //mWidth = headShoulderDiff * mWidthScale;
            //mHeight = headShoulderDiff * mHeightScale;

            mTopLeftX = Nui.x(mAnchor) - (mWidth * mLeftShift);
            mTopLeftY = Nui.y(mAnchor) + (mHeight * mUpShift);

            mRawXRight = Nui.x(mHandR) - mTopLeftX;
            mRawYRight = Nui.y(mHandR) - mTopLeftY;
            Condition xActiveRight = C.And(mRawXRight >= 0f, mRawXRight <= mWidth);
            Condition yActiveRight = C.And(mRawYRight >= 0f, mRawYRight <= mHeight);

            mConstrainedXRight      = Nui.constrain(mRawXRight, .01f, mWidth, .10f, false);
            mConstrainedYRight      = Nui.constrain(mRawYRight, .01f, mHeight, .10f, false);
            mOnScreenConditionRight = C.And(xActiveRight, yActiveRight);

            mLeftHandShift = Scalar.Create("LeftHandShift", .5f);
            mRawXLeft      = (Nui.x(mHandL) + mLeftHandShift) - mTopLeftX;
            mRawYLeft      = Nui.y(mHandL) - mTopLeftY;
            Condition xActiveLeft = C.And(mRawXLeft >= 0f, mRawXLeft <= mWidth);
            Condition yActiveLeft = C.And(mRawYLeft >= 0f, mRawYLeft <= mHeight);

            mConstrainedXLeft      = Nui.constrain(mRawXLeft, .01f, mWidth, .10f, false);
            mConstrainedYLeft      = Nui.constrain(mRawYLeft, .01f, mHeight, .10f, false);
            mOnScreenConditionLeft = C.And(xActiveLeft, yActiveLeft);
        }
Ejemplo n.º 13
0
        void HeavyWorkDoing()
        {
            var countdown = 5;

            while (countdown >= 0)
            {
                //Oops ! Potentielles Problem mit Multithreading...
                //MyLabel.Content = "Noch " + countdown + " Sekunden";

                //Daher brauchen wir einen Delegate
                ChangeDelegate del = new ChangeDelegate(ChangeCountdown);
                MyLabel.Dispatcher.Invoke(del, countdown);

                Thread.Sleep(1000);
                countdown--;
            }
        }
Ejemplo n.º 14
0
        static PrefixIncrement()
        {
            OperatorFactory.TryBind(ref Invoke, (ref byte val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref sbyte val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref short val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref ushort val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref int val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref uint val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref long val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref ulong val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref float val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref double val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref char val) => ++ val);

            Invoke = Invoke ?? ((ref T value) =>
            {
                value = Increment <T, T> .Invoke(value);
                return(value);
            });
        }
        static PostfixDecrement()
        {
            OperatorFactory.TryBind(ref Invoke, (ref byte val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref sbyte val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref short val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref ushort val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref int val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref uint val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref long val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref ulong val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref float val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref double val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref char val) => val--);

            Invoke = Invoke ?? ((ref T value) =>
            {
                var old = value;
                value = Decrement <T, T> .Invoke(value);
                return(old);
            });
        }
Ejemplo n.º 16
0
 public AddChangeParametr(ChangeDelegate changeDelegate, Parameters parameters, string testName)
 {
     InitializeComponent();
     DataContext = new AddChangeParametersViewModel(changeDelegate, parameters, testName);
 }
Ejemplo n.º 17
0
 public void RegisterDelegate(ChangeDelegate dlgt)
 {
     m_ChangeDelegate = dlgt;
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Read a specific file, and insert the new lines to the database.
        ///
        /// </summary>
        /// <param name="fullPath"></param>
        bool pollChangesToWithLimit(string fullPath, ChangeDelegate changeDelegate, int limitOfLines)
        {
            using (var fs = new FileStream(fullPath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite))
                using (var sr = new StreamReader(fs))
                {
                    // re-open the file when getting the signature so the stream readers offset
                    // wont change because of it.
                    // When re-using the streamreader here, all files that we list are always
                    // marked as changed.
                    var signature = getFileSignature(fullPath);

                    // if the signature is null here, we signal that we did not do any inserts
                    if (signature == null)
                    {
                        return(false);
                    }

                    // use the signature
                    var offsetInFile = stateOfFiles.ContainsKey(signature) ? stateOfFiles[signature] : 0;
                    sr.BaseStream.Seek(offsetInFile, SeekOrigin.Begin);

                    // Have we read the file to the end?
                    bool isFileOver = false;
                    // were there any changes to the file?
                    bool hadChanges = false;

                    int partCount = 0;

                    while (!isFileOver)
                    {
                        var lines = new List <string>();

                        // 1, if we read null, the file is over
                        // 2, if we read not null, add it to the liens
                        //    if the lines are over the limit, then return them and say that we may have more


                        while (true)
                        {
                            string line = sr.ReadLine();
                            // if the line is null, the file is over
                            if (line == null)
                            {
                                isFileOver = true;
                                break;
                            }

                            // If its not null, we can add it
                            lines.Add(line);

                            // if we are over the line limit, break it up
                            if (lines.Count >= limitOfLines)
                            {
                                break;
                            }
                        }

                        // Callback if we have changes
                        if (lines.Count > 0)
                        {
                            changeDelegate(fullPath, lines.ToArray(), partCount++);
                            // mark that we have done our duty
                            hadChanges = true;
                        }
                    }


                    // Update the offset for this file
                    stateOfFiles[signature] = fs.Position;

                    // signal that we did not do any inserts
                    return(hadChanges);
                }
        }
Ejemplo n.º 19
0
 public void watchChangeCycle(ChangeDelegate changeDelegate)
 {
     watchChangeCycle(changeDelegate, () => { });
 }
Ejemplo n.º 20
0
 void OnGridItemChange(int row, int column, int imageIndex)
 {
     int[] a = new int[3];
     a[0] = row;
     a[1] = column;
     a[2] = imageIndex;
     if (InvokeRequired)
     {
         ChangeDelegate d = new ChangeDelegate(this.UpdateOnGridItemChange);
         Invoke(d, a);
         return;
     }
     this.UpdateOnGridItemChange(a);
 }
Ejemplo n.º 21
0
 public ChangeDelegateKey(ChangeDelegate changeDelegate)
 {
     this.changeDelegate = changeDelegate;
 }
Ejemplo n.º 22
0
 public AddChangeTest(ChangeDelegate changeDelegate, Tests tests)
 {
     InitializeComponent();
     DataContext = new AddChangeTestViewModel(changeDelegate, tests);
 }
Ejemplo n.º 23
0
 public MadList(ChangeDelegate onAdd, ChangeDelegate onRemove) : this()
 {
     OnAdd    += onAdd;
     OnRemove += onRemove;
 }
        public SimpleKinectCursor()
        {
            GlobalConditions.Init();

            mTickListener = new ChangeDelegate(Nui_Tick);
            mSmoothingFactor = Scalar.Create(mConfig.CursorSmoothing);
            /*
            mHandR = test ? Vector.Create("HandR", 0f, 0f, 0f) : Nui.smooth(Nui.joint(Nui.Hand_Right), mSmoothingFactor);
            mHandL = test ? Vector.Create("HandL", 0f, 0f, 0f) : Nui.smooth(Nui.joint(Nui.Hand_Left), HAND_SMOOTHING_FRAMES);
            mAnchor = test ? Vector.Create("Anchor", 0f, 0f, 0f) : Nui.smooth(Nui.joint(Nui.Hip_Centre), ANCHOR_SMOOTHING_FRAMES);
            */
            mHandR = Nui.smooth(Nui.joint(Nui.Hand_Right), mSmoothingFactor);
            mHandL = Nui.smooth(Nui.joint(Nui.Hand_Left), mSmoothingFactor);
            mAnchor = Nui.smooth(Nui.joint(Nui.Hip_Centre), ANCHOR_SMOOTHING_FRAMES);

            mLeftShift = Scalar.Create("Left Shift", .0f);
            mUpShift = Scalar.Create("Up Shift", .0f);

            mWidth = Scalar.Create("Width", .5f);
            mHeight = Scalar.Create("Height", .5f);
            //mWidth = headShoulderDiff * mWidthScale;
            //mHeight = headShoulderDiff * mHeightScale;

            mTopLeftX = Nui.x(mAnchor) - (mWidth * mLeftShift);
            mTopLeftY = Nui.y(mAnchor) + (mHeight * mUpShift);

            mRawXRight = Nui.x(mHandR) - mTopLeftX;
            mRawYRight = Nui.y(mHandR) - mTopLeftY;
            Condition xActiveRight = C.And(mRawXRight >= 0f, mRawXRight <= mWidth);
            Condition yActiveRight = C.And(mRawYRight >= 0f, mRawYRight <= mHeight);
            mConstrainedXRight = Nui.constrain(mRawXRight, .01f, mWidth, .10f, false);
            mConstrainedYRight = Nui.constrain(mRawYRight, .01f, mHeight, .10f, false);
            mOnScreenConditionRight = C.And(xActiveRight, yActiveRight);

            mLeftHandShift = Scalar.Create("LeftHandShift", .5f);
            mRawXLeft = (Nui.x(mHandL) + mLeftHandShift) - mTopLeftX;
            mRawYLeft = Nui.y(mHandL) - mTopLeftY;
            Condition xActiveLeft = C.And(mRawXLeft >= 0f, mRawXLeft <= mWidth);
            Condition yActiveLeft = C.And(mRawYLeft >= 0f, mRawYLeft <= mHeight);
            mConstrainedXLeft = Nui.constrain(mRawXLeft, .01f, mWidth, .10f, false);
            mConstrainedYLeft = Nui.constrain(mRawYLeft, .01f, mHeight, .10f, false);
            mOnScreenConditionLeft = C.And(xActiveLeft, yActiveLeft);
        }