//called when data for any output pin is requested
 public void Evaluate(int SpreadMax)
 {
     if (FAH[0])
     {
         if (FFilter[0])
         {
             if (!FOutput.Contains(FInput[0]))
             {
                 FOutput.Insert(0, FInput[0]);
             }
         }
         else
         {
             FOutput.Insert(0, FInput[0]);
         }
     }
     if (FCT[0])
     {
         FOutput.RemoveAt(FOutput.SliceCount - 1);
     }
     if (FReset[0])
     {
         FOutput.SliceCount = 0;
     }
     //FLogger.Log(LogType.Debug, "Logging to Renderer (TTY)");
 }
Esempio n. 2
0
        protected override void Initialize(IObservable <EventPattern <WMEventArgs> > windowMessages, IObservable <bool> disabled)
        {
            var keyNotifications = windowMessages
                                   .Select <EventPattern <WMEventArgs>, KeyNotification>(e =>
            {
                var a = e.EventArgs;
                switch (a.Message)
                {
                case WM.KEYDOWN:
                case WM.SYSKEYDOWN:
                    return(new KeyDownNotification((Keys)a.WParam, this));

                case WM.CHAR:
                case WM.SYSCHAR:
                    return(new KeyPressNotification((char)a.WParam, this));

                case WM.KEYUP:
                case WM.SYSKEYUP:
                    return(new KeyUpNotification((Keys)a.WParam, this));
                }
                return(null);
            }
                                                                                         )
                                   .OfType <KeyNotification>();
            var keyboard = new Keyboard(keyNotifications);

            FKeyboardOut[0] = keyboard;

            // Subscribe to the keyboard so we can write the legacy keyboard string output
            FKeyboardSubscription = keyboard.KeyNotifications
                                    .OfType <KeyCodeNotification>()
                                    .Subscribe(keyNotification =>
            {
                var keyCode = keyNotification.KeyCode;
                var keyName = LegacyKeyboardHelper.VirtualKeycodeToString(keyCode);
                switch (keyNotification.Kind)
                {
                case KeyNotificationKind.KeyDown:
                    if (!FLegacyKeyStringOut.Contains(keyName))
                    {
                        FLegacyKeyStringOut.Add(keyName);
                    }
                    break;

                case KeyNotificationKind.KeyUp:
                    FLegacyKeyStringOut.Remove(keyName);
                    break;

                default:
                    break;
                }
            }
                                               );

            // Create a keyboard split node for us and connect our keyboard out to its keyboard in
            var nodeInfo = FIOFactory.NodeInfos.First(n => n.Name == "KeyboardState" && n.Category == "System" && n.Version == "Split Legacy");

            FKeyboardSplitNode = FIOFactory.CreatePlugin(nodeInfo, c => c.IOAttribute.Name == "Keyboard", c => FKeyboardOut);
        }
        public bool Filter(RigidBody body)
        {
            if (IdList == null)
            {
                return(false);
            }

            BodyCustomData data = (BodyCustomData)body.UserObject;

            return(IdList.Contains(data.Id));
        }
Esempio n. 4
0
// ReSharper restore MemberCanBePrivate.Global
// ReSharper restore UnassignedField.Global

        public void Evaluate(int SpreadMax)
        {
            if (!ControlIn.IsChanged)
            {
                return;
            }

            ControlOut.SliceCount = 0;
            BinSizeOut.SliceCount = ControlIn.SliceCount;

            for (var i = 0; i < ControlIn.SliceCount; i++)
            {
                BinSizeOut[i] = ControlIn[i].SliceCount;

                ControlIn[i].ToList().ForEach(control =>
                {
                    if (!ControlOut.Contains(control))
                    {
                        ControlOut.Add(control);
                    }
                });
            }
        }
Esempio n. 5
0
        public void Evaluate(int spreadMax)
        {
            var gestureDevice = FInput[0] ?? GestureDevice.Empty;

            if (gestureDevice != FGestureDevice)
            {
                Unsubscribe();
                FGestureDevice = gestureDevice;
                Subscribe();
            }

            var notifications = FEnumerator.MoveNext()
                ? FEnumerator.Current
                : FEmptyList;

            var gestures = notifications.Where(g => (g.Kind == FGestureFilterKind) ||
                                               ((g.Kind == GestureNotificationKind.GestureEnd) && (IdOut.Contains(g.Id))))
                           .ToList();

            UseGestures(gestures);

            PositionOut.SliceCount = gestures.Count;
            IdOut.SliceCount       = gestures.Count;
            DeviceIDOut.SliceCount = gestures.Count;
            for (int i = 0; i < gestures.Count; i++)
            {
                var position           = new Vector2D(gestures[i].Position.X, gestures[i].Position.Y);
                var clientArea         = new Vector2D(gestures[i].ClientArea.Width, gestures[i].ClientArea.Height);
                var normalizedPosition = VMath.Map(position, Vector2D.Zero, clientArea, new Vector2D(-1, 1), new Vector2D(1, -1), TMapMode.Float);
                PositionOut[i] = normalizedPosition;
                IdOut[i]       = gestures[i].Id;
                DeviceIDOut[i] = gestures[i].GestureDeviceID;
            }
        }
// ReSharper restore UnassignedField.Global
// ReSharper restore MemberCanBePrivate.Global

        public void Evaluate(int SpreadMax)
        {
            if (OnClickOut.Contains(true))
            {
                for (var i = 0; i < OnClickOut.SliceCount; i++)
                {
                    OnClickOut[i] = false;
                }
            }

            if (_onClick.ContainsValue(true))
            {
                (from item in _onClick where item.Value select item).ToList().ForEach(item =>
                {
                    OnClickOut[item.Key] = true;
                    _onClick[item.Key]   = false;
                });
            }

            //if (ControlOut.SliceCount == SpreadMax && !TransformIn.IsChanged && !TextIn.IsChanged && !EnabledIn.IsChanged) return;

            if (ControlOut.SliceCount != SpreadMax)
            {
                if (ControlOut.SliceCount > SpreadMax)
                {
                    for (var i = ControlOut.SliceCount; i > SpreadMax; i--)
                    {
                        ControlOut[i].Dispose();
                        _onClick.Remove(i);
                    }
                    ControlOut.SliceCount = SpreadMax;
                    OnClickOut.SliceCount = SpreadMax;
                }
                else
                {
                    var i = ControlOut.SliceCount;
                    for (ControlOut.SliceCount = SpreadMax; i < SpreadMax; i++)
                    {
                        ControlOut[i] = new Button
                        {
                            Text      = TextIn[i],
                            Tag       = i,
                            Font      = FontIn[i],
                            BackColor = BackColorIn[i].Color,
                            ForeColor = ForeColorIn[i].Color,
                            UseVisualStyleBackColor = !OwnStyleIn[i]
                        };
                        ControlOut[i].Click += (sender, args) => _onClick[(int)((Control)sender).Tag] = true;
                    }
                    OnClickOut.SliceCount = SpreadMax;
                }
            }

            for (var i = 0; i < SpreadMax; i++)
            {
                if (ControlOut[i] == null)
                {
                    ControlOut[i] = new Button
                    {
                        Text      = TextIn[i],
                        Tag       = i,
                        Font      = FontIn[i],
                        BackColor = BackColorIn[i].Color,
                        ForeColor = ForeColorIn[i].Color,
                        UseVisualStyleBackColor = !OwnStyleIn[i]
                    };
                    ControlOut[i].Click += (sender, args) => _onClick[(int)((Control)sender).Tag] = true;
                }

                if (TextIn.IsChanged)
                {
                    ControlOut[i].Text = TextIn[i];
                }

                if (EnabledIn.IsChanged)
                {
                    ControlOut[i].Enabled = EnabledIn[i];
                }

                if (FontIn.IsChanged)
                {
                    ControlOut[i].Font = FontIn[i];
                }

                if (OwnStyleIn[i] && BackColorIn.IsChanged)
                {
                    ControlOut[i].BackColor = BackColorIn[i].Color;
                }

                if (ForeColorIn.IsChanged)
                {
                    ControlOut[i].ForeColor = ForeColorIn[i].Color;
                }

                if (OwnStyleIn.IsChanged)
                {
                    ((Button)ControlOut[i]).UseVisualStyleBackColor = !OwnStyleIn[i];
                    ((Button)ControlOut[i]).FlatStyle = OwnStyleIn[i] ? FlatStyle.Flat : FlatStyle.Standard;
                }

                if (TransformIn.IsChanged)
                {
                    Vector3D scale;
                    Vector3D rotation;
                    Vector3D translation;
                    if (TransformIn[i].Decompose(out scale, out rotation, out translation))
                    {
                        //ControlOut[i].Bounds = new Rectangle((int) (translation.x*100.0), (int) (translation.y*100.0),
                        //    (int) (scale.x*75.0), (int) (scale.y*23.0));

                        ControlOut[i].Size = new Size((int)(scale.x * 75.0), (int)(scale.y * 23.0));
                    }
                }
            }
        }
Esempio n. 7
0
        public void DoPublish()
        {
            canceledTask = false;
            bool badId = true;

            badCoord        = true;
            alreadySleeping = false;
            if (FPublishInReplyIds.SliceCount > 1 || (FPublishInReplyIds.SliceCount == 1 && !FPublishInReplyIds[0].IsNullOrEmpty()))
            {
                for (int i = 0; i < FPublishInReplyIds.SliceCount; i++)
                {
                    if (!FPublishInReplyIds[i].IsNullOrEmpty())
                    {
                        try
                        {
                            tweetIdToReply = Convert.ToInt64(FPublishInReplyIds[i]);
                            badId          = false;
                        }
                        catch
                        {
                            FActionStatus[0] = "Tweet Id to reply to not recognised, you bell-end";
                            FLogger.Log(LogType.Debug, "Tweet Id to reply to not recognised, you bell-end");
                            badId = true;
                        }
                        if (!badId)
                        {
                            if (FPublishPicture.SliceCount == 1 && !HasImageExtension(FPublishPicture[0]))
                            {
                                if (FRandom[0])
                                {
                                    var randomo = randi.Next(0, FPublishText.SliceCount);
                                    FLogger.Log(LogType.Debug, "random " + randomo);
                                    if (FPublishCoordinates.SliceCount == 2 && !FPublishCoordinates.Contains(0))
                                    {
                                        Tweet_PublishTweetWithGeoInReplyToAnotherTweet(FPublishText[randomo], tweetIdToReply, FPublishCoordinates[1], FPublishCoordinates[0]);
                                    }
                                    else
                                    {
                                        Tweet_PublishTweetInReplyToAnotherTweet(FPublishText[randomo], tweetIdToReply);
                                    }
                                    FLogger.Log(LogType.Debug, "sleeping or not");
                                    SleepOrNot(FPublishInReplyIds, "Publish", i);
                                    if (!FMachineGun[0] || canceledTask)
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    for (int j = 0; j < FPublishText.SliceCount; j++)
                                    {
                                        if (FPublishCoordinates.SliceCount == 2 && !FPublishCoordinates.Contains(0))
                                        {
                                            Tweet_PublishTweetWithGeoInReplyToAnotherTweet(FPublishText[j], tweetIdToReply, FPublishCoordinates[1], FPublishCoordinates[0]);
                                        }
                                        else
                                        {
                                            Tweet_PublishTweetInReplyToAnotherTweet(FPublishText[j], tweetIdToReply);
                                        }
                                        SleepOrNot(FPublishText, "Publish", j);
                                        if (!FMachineGun[0] || canceledTask)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (FRandom[0])
                                {
                                    var randomo      = randi.Next(0, FPublishText.SliceCount);
                                    var randomPicNum = 0;
                                    if (randomo < FPublishPicture.SliceCount)
                                    {
                                        randomPicNum = randomo;
                                    }
                                    else
                                    {
                                        randomPicNum = randomo % FPublishPicture.SliceCount;
                                    }
                                    if (HasImageExtension(FPublishPicture[randomPicNum]))
                                    {
                                        Tweet_PublishTweetWithImageInReplyToAnotherTweet(FPublishText[randomo], FPublishPicture[randomPicNum], tweetIdToReply);
                                    }
                                    else
                                    {
                                        FActionStatus[0] = "Slice " + randomPicNum + " in your image spread is not a valid image, sending tweeting without image...";
                                        FLogger.Log(LogType.Debug, "Slice " + randomPicNum + " in your image spread is not a valid image, sending tweeting without image...");
                                        if (FPublishCoordinates.SliceCount == 2 && !FPublishCoordinates.Contains(0))
                                        {
                                            Tweet_PublishTweetWithGeoInReplyToAnotherTweet(FPublishText[randomo], tweetIdToReply, FPublishCoordinates[1], FPublishCoordinates[0]);
                                        }
                                        else
                                        {
                                            Tweet_PublishTweetInReplyToAnotherTweet(FPublishText[randomo], tweetIdToReply);
                                        }
                                    }
                                    SleepOrNot(FPublishInReplyIds, "Publish", i);
                                    if (!FMachineGun[0] || canceledTask)
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    for (int j = 0; j < FPublishText.SliceCount; j++)
                                    {
                                        var k = 0;
                                        if (j < FPublishPicture.SliceCount)
                                        {
                                            k = j;
                                        }
                                        else
                                        {
                                            k = j % FPublishPicture.SliceCount;
                                        }
                                        if (HasImageExtension(FPublishPicture[k]))
                                        {
                                            Tweet_PublishTweetWithImageInReplyToAnotherTweet(FPublishText[j], FPublishPicture[k], tweetIdToReply);
                                        }
                                        else
                                        {
                                            FActionStatus[0] = "Slice " + j + " in your image spread is not a valid image, sending tweeting without image...";
                                            FLogger.Log(LogType.Debug, "Slice " + j + " in your image spread is not a valid image, sending tweeting without image...");
                                            if (FPublishCoordinates.SliceCount == 2 && !FPublishCoordinates.Contains(0))
                                            {
                                                Tweet_PublishTweetWithGeoInReplyToAnotherTweet(FPublishText[j], tweetIdToReply, FPublishCoordinates[1], FPublishCoordinates[0]);
                                            }
                                            else
                                            {
                                                Tweet_PublishTweetInReplyToAnotherTweet(FPublishText[j], tweetIdToReply);
                                            }
                                        }
                                        SleepOrNot(FPublishText, "Publish", j);
                                        if (!FMachineGun[0] || canceledTask)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        FActionStatus[0] = "Tweet Id to reply to is null or empty, you twat";
                        FLogger.Log(LogType.Debug, "Tweet Id to reply to is null or empty, you twat");
                    }
                    if (!alreadySleeping)
                    {
                        //csshnage here? to SleepOrNot(FPublishText, "Publish", j);
                        MakeTaskWait("Publish");
                    }
                    if (!FMachineGun[0] || canceledTask)
                    {
                        break;
                    }
                }
            }
            else
            {
                if (FPublishPicture.SliceCount == 1 && !HasImageExtension(FPublishPicture[0]))
                {
                    for (int j = 0; j < FPublishText.SliceCount; j++)
                    {
                        if (FPublishCoordinates.SliceCount == 2 && !FPublishCoordinates.Contains(0))
                        {
                            Tweet_PublishTweetWithGeo(FPublishText[j], FPublishCoordinates[1], FPublishCoordinates[0]);
                        }
                        else
                        {
                            Tweet_PublishTweet(FPublishText[j]);
                        }
                        SleepOrNot(FPublishText, "Publish", j);
                        if (!FMachineGun[0])
                        {
                            break;
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < FPublishText.SliceCount; j++)
                    {
                        var k = 0;
                        if (j < FPublishPicture.SliceCount)
                        {
                            k = j;
                        }
                        else
                        {
                            k = j % FPublishPicture.SliceCount;
                        }
                        if (HasImageExtension(FPublishPicture[k]))
                        {
                            Tweet_PublishTweetWithImage(FPublishText[j], FPublishPicture[k]);
                        }
                        else
                        {
                            FActionStatus[0] = "Slice " + j + " in your image spread is not a valid image, sending tweeting without image...";
                            FLogger.Log(LogType.Debug, "Slice " + j + " in your image spread is not a valid image, sending tweeting without image...");

                            if (FPublishCoordinates.SliceCount == 2 && !FPublishCoordinates.Contains(0))
                            {
                                Tweet_PublishTweetWithGeo(FPublishText[j], FPublishCoordinates[1], FPublishCoordinates[0]);
                            }
                            else
                            {
                                Tweet_PublishTweet(FPublishText[j]);
                            }
                        }
                        SleepOrNot(FPublishText, "Publish", j);
                        if (!FMachineGun[0] || canceledTask)
                        {
                            break;
                        }
                    }
                }
            }
            FAllActionDone[0] = true;
            //FActionStatus[0] = "FINISHED! Whatever you did, you did well. I believe in you mate.";
            FLogger.Log(LogType.Debug, "FINISHED! Whatever you did, you did well. I believe in you mate.");
        }
// ReSharper restore UnassignedField.Global
// ReSharper restore MemberCanBePrivate.Global


        public void Evaluate(int SpreadMax)
        {
            if (OnClickOut.Contains(true))
            {
                for (var i = 0; i < OnClickOut.SliceCount; i++)
                {
                    OnClickOut[i] = false;
                }
            }

            if (_onClick.ContainsValue(true))
            {
                (from item in _onClick where item.Value select item).ToList().ForEach(item =>
                {
                    OnClickOut[item.Key] = true;
                    _onClick[item.Key]   = false;
                });
            }

            //if (ControlOut.SliceCount == SpreadMax && !TransformIn.IsChanged && !EnabledIn.IsChanged) return;

            if (!(from path in PathIn.ToList() where File.Exists(path) select path).Any())
            {
                ControlOut.SliceCount = 0;
                return;
            }

            if (ControlOut.SliceCount != SpreadMax)
            {
                if (ControlOut.SliceCount > SpreadMax)
                {
                    for (var i = ControlOut.SliceCount; i > SpreadMax; i--)
                    {
                        ControlOut[i].Dispose();
                        _onClick.Remove(i);
                    }
                    OnClickOut.SliceCount = SpreadMax;
                    ControlOut.SliceCount = SpreadMax;
                }
                else
                {
                    var i = ControlOut.SliceCount;
                    for (ControlOut.SliceCount = SpreadMax; i < SpreadMax; i++)
                    {
                        if (File.Exists(PathIn[i]))
                        {
                            ControlOut[i] = new PictureBox {
                                Tag = i, Image = new Bitmap(PathIn[i]), SizeMode = PictureBoxSizeMode.Zoom
                            };
                            ControlOut[i].Click += (sender, args) => _onClick[(int)((Control)sender).Tag] = true;
                        }
                        OnClickOut.SliceCount = SpreadMax;
                    }
                }
            }

            for (var i = 0; i < SpreadMax; i++)
            {
                if (ControlOut[i] == null)
                {
                    if (File.Exists(PathIn[i]))
                    {
                        ControlOut[i] = new PictureBox {
                            Tag = i, Image = new Bitmap(PathIn[i]), SizeMode = PictureBoxSizeMode.Zoom
                        };
                        ControlOut[i].Click += (sender, args) => _onClick[(int)((Control)sender).Tag] = true;
                    }
                }

                if (!(ControlOut[i] is PictureBox))
                {
                    continue;
                }

                if (EnabledIn.IsChanged)
                {
                    ControlOut[i].Enabled = EnabledIn[i];
                }

                if (PathIn.IsChanged)
                {
                    if (File.Exists(PathIn[i]))
                    {
                        ((PictureBox)ControlOut[i]).Image = new Bitmap(PathIn[i]);
                    }
                }

                if (TransformIn.IsChanged)
                {
                    Vector3D scale;
                    Vector3D rotation;
                    Vector3D translation;
                    if (TransformIn[i].Decompose(out scale, out rotation, out translation))
                    {
                        ControlOut[i].Bounds = new Rectangle((int)(translation.x * 100.0), (int)(translation.y * 100.0), (int)(scale.x * ((PictureBox)ControlOut[i]).Image.Width), (int)(scale.y * ((PictureBox)ControlOut[i]).Image.Height));
                    }
                }
            }
        }
Esempio n. 9
0
        public void Evaluate(int spreadMax)
        {
            var gestureDevice = FInput[0] ?? GestureDevice.Empty;

            if (gestureDevice != FGestureDevice)
            {
                Unsubscribe();
                FGestureDevice = gestureDevice;
                Subscribe();
            }

            var notifications = FEnumerator.MoveNext()
                ? FEnumerator.Current
                : FEmptyList;

            var gestures = notifications.Where(g => (g.Kind == FGestureFilterKind) ||
                                               ((g.Kind == GestureNotificationKind.GestureEnd) && (IdOut.Contains(g.Id))))
                           .ToList();

            UseGestures(gestures);

            PositionOut.SliceCount = gestures.Count;
            PositionInProjectionSpaceOut.SliceCount      = gestures.Count;
            PositionInNormalizedProjectionOut.SliceCount = gestures.Count;
            PositionPixelOut.SliceCount = gestures.Count;
            IdOut.SliceCount            = gestures.Count;
            DeviceIDOut.SliceCount      = gestures.Count;
            for (int i = 0; i < gestures.Count; i++)
            {
                var      g = gestures[i];
                Vector2D inNormalizedProjection, inProjection;

                SpaceHelpers.MapFromPixels(g.Position, g.Sender, g.ClientArea,
                                           out inNormalizedProjection, out inProjection);

                PositionOut[i] = MouseExtensions.GetLegacyMousePositon(g.Position, g.ClientArea);
                PositionInProjectionSpaceOut[i]      = inProjection;
                PositionInNormalizedProjectionOut[i] = inNormalizedProjection;
                PositionPixelOut[i] = new Vector2D(g.Position.X, g.Position.Y);

                IdOut[i]       = g.Id;
                DeviceIDOut[i] = g.GestureDeviceID;
            }
        }