private void cmdOK_Click(object sender, EventArgs e)
 {
     if (IfCreateNewAction)
     {
         if (NewAction.OnOK(sender, e))
         {
             this.DialogResult = System.Windows.Forms.DialogResult.OK;
         }
     }
     else
     {
         if (NewTarget.OnOK(sender, e))
         {
             this.DialogResult = System.Windows.Forms.DialogResult.OK;
         }
     }
 }
Esempio n. 2
0
        public UtopiaMessage decodePayload()
        {
            //  Decode the payload
            UtopiaMessage evt = null;

            if ((this.msgID == StimulusEvent.MSGID))
            {
                if ((VERBOSITY > 2))
                {
                    System.Console.WriteLine("Trying to read "
                                             + StimulusEvent.MSGNAME + " message");
                }

                evt = StimulusEvent.deserialize(this.msgbuffer);
            }
            else if ((this.msgID == PredictedTargetProb.MSGID))
            {
                if ((VERBOSITY > 2))
                {
                    System.Console.WriteLine("Trying to read "
                                             + PredictedTargetProb.MSGNAME + " message");
                }

                evt = PredictedTargetProb.deserialize(this.msgbuffer);
            }
            else if ((this.msgID == ModeChange.MSGID))
            {
                if ((VERBOSITY > 2))
                {
                    System.Console.WriteLine("Trying to read " + ModeChange.MSGNAME + " message");
                }

                evt = ModeChange.deserialize(this.msgbuffer);
            }
            else if ((this.msgID == Reset.MSGID))
            {
                if ((VERBOSITY > 2))
                {
                    System.Console.WriteLine("Trying to read " + Reset.MSGNAME + " message");
                }

                evt = Reset.deserialize(this.msgbuffer);
            }
            else if ((this.msgID == NewTarget.MSGID))
            {
                if ((VERBOSITY > 2))
                {
                    System.Console.WriteLine("Trying to read " + NewTarget.MSGNAME + " message");
                }

                evt = NewTarget.deserialize(this.msgbuffer);
            }
            else if ((this.msgID == Heartbeat.MSGID))
            {
                if ((VERBOSITY > 2))
                {
                    System.Console.WriteLine("Trying to read " + Heartbeat.MSGNAME + " message");
                }

                evt = Heartbeat.deserialize(this.msgbuffer);
            }
            else
            {
                throw new ClientException("Unsupported Message type: " + this.msgID);
            }

            if ((VERBOSITY > 1))
            {
                System.Console.WriteLine("Got message: " + evt.ToString());
            }

            return(evt);
        }
Esempio n. 3
0
        private void ProcessLink(ItemLink link)
        {
            var linkedItem = Factory.GetDatabase(link.TargetDatabaseName)
                             .GetItem(link.TargetItemID, link.TargetItemLanguage, link.TargetItemVersion);
            var referer = linkedItem.Database.GetItem(link.SourceItemID, link.SourceItemLanguage,
                                                      link.SourceItemVersion);
            var itemField = referer.Fields[link.SourceFieldID];
            var field     = FieldTypeManager.GetField(itemField);

            if (NewTarget != null)
            {
                if (ShouldProcess(referer.GetProviderPath(),
                                  $"Changing link in field '{itemField.Name}' from '{linkedItem.GetProviderPath()}' to '{NewTarget.GetProviderPath()}' "))
                {
                    referer.Editing.BeginEdit();
                    field.Relink(link, NewTarget);
                    referer.Editing.EndEdit(true, false);
                }
            }
            else
            {
                if (ShouldProcess(referer.GetProviderPath(),
                                  $"Removing link to '{linkedItem.GetProviderPath()}' from field '{itemField.Name}'"))
                {
                    referer.Editing.BeginEdit();
                    field.RemoveLink(link);
                    referer.Editing.EndEdit(true, false);
                }
            }
        }
Esempio n. 4
0
        private static void sendTestMessages(UtopiaClient utopiaClient, int offset)
        {
            //  write some test messages..
            int[] objIDs = new int[10];
            for (int i = 0; (i < objIDs.Length); i++)
            {
                objIDs[i] = i;
            }

            int[] objState = new int[objIDs.Length];
            //  send some test StimulusEvents
            for (int i = 0; (i < 5); i++)
            {
                for (int j = 0; (j < objState.Length); j++)
                {
                    objState[j] = (i + offset);
                }

                StimulusEvent e = new StimulusEvent(utopiaClient.getTimeStamp(), objIDs, objState);
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                try {
                    utopiaClient.sendMessage(e);
                }
                catch (IOException ex) {
                    Console.WriteLine(ex);
                }

                System.Threading.Thread.Sleep(1000);
            }

            {
                //  PREDICTEDTARGETPROB
                PredictedTargetProb e = new PredictedTargetProb(utopiaClient.getTimeStamp(), 1, ((float)(0.99)));
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }

            {
                //  PREDICTEDTARGETDIST
                PredictedTargetDist e = new PredictedTargetDist(utopiaClient.getTimeStamp(), new int[] { 1, 2, 3 }, new float[] { .1f, .2f, .3f });
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }
            {
                //  HEARTBEAT V.2.0
                Heartbeat e = new Heartbeat(utopiaClient.getTimeStamp(), "TestMessage");
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }
            // LOG
            {
                Log e = new Log(utopiaClient.getTimeStamp(), "ClientTest");
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }
            {
                //  MODECHANGE
                ModeChange e = new ModeChange(utopiaClient.getTimeStamp(), "ClientTest");
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }
            {
                //  RESET
                Reset e = new Reset(utopiaClient.getTimeStamp());
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }
            {
                //  NEWTARGET
                NewTarget e = new NewTarget(utopiaClient.getTimeStamp());
                Console.WriteLine("Sending: " + e.ToString() + " -> server");
                utopiaClient.sendMessage(e);
                System.Threading.Thread.Sleep(1000);
            }
        }