Example #1
0
        private static string BuildMethod(EventDescription eventDescription, string methodName, string indentation, int tabSize) {
            StringBuilder text = new StringBuilder();
            text.AppendLine(indentation);
            text.Append(indentation);
            text.Append("def ");
            text.Append(methodName);
            text.Append('(');
            text.Append("self");
            foreach (var param in eventDescription.Parameters) {
                text.Append(", ");
                text.Append(param.Name);
            }
            text.AppendLine("):");
            if (tabSize < 0) {
                text.Append(indentation);
                text.Append("\tpass");
            } else {
                text.Append(indentation);
                text.Append(' ', tabSize);
                text.Append("pass");
            }
            text.AppendLine();

            return text.ToString();
        }
        public override bool CreateMethod(EventDescription eventDescription, string methodName, string initialStatements)
        {
            // build the new method handler
            var view = _pythonFileNode.GetTextView();
            var textBuffer = _pythonFileNode.GetTextBuffer();
            var classDef = GetClassForEvents();
            if (classDef != null) {
                int end = classDef.Body.EndIndex;

                using (var edit = textBuffer.CreateEdit()) {
                    var text = BuildMethod(
                        eventDescription,
                        methodName,
                        new string(' ', classDef.Body.Start.Column - 1),
                        view.Options.IsConvertTabsToSpacesEnabled() ?
                            view.Options.GetIndentSize() :
                            -1);

                    edit.Insert(end, text);
                    edit.Apply();
                    return true;
                }
            }

            return false;
        }
        public Event MapIt(Event a, EventDescription p)
        {
            // Terminating call.  Since we can return null from this function
            // we need to be ready for PetaPoco to callback later with null
            // parameters
            if (a == null)
                return current;

            // Is this the same author as the current one we're processing
            if (current != null && current.Id == a.Id)
            {
                // Yes, just add this post to the current author's collection of posts
                current.descriptions.Add(p);

                // Return null to indicate we're not done with this author yet
                return null;
            }

            // This is a different author to the current one, or this is the 
            // first time through and we don't have an author yet

            // Save the current author
            var prev = current;

            // Setup the new current author
            current = a;
            current.descriptions = new List<EventDescription>();
            current.descriptions.Add(p);

            // Return the now populated previous author (or null if first time through)
            return prev;
        }
        public override string CreateUniqueMethodName(string objectName, EventDescription eventDescription)
        {
            string originalMethodName = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", objectName, eventDescription.Name);
            string methodName = originalMethodName;

            List<CodeTypeMember> methods = GetHandlersFromActiveFile(string.Format(CultureInfo.InvariantCulture, "{0}_{1}", objectName, eventDescription.Name));

            while (methods.Count > 0)
            {
                //Try to append a _# at the end until we find an unused method name
                Match match = Regex.Match(methodName, @"_\d+$");

                if (!match.Success)
                {
                    methodName = originalMethodName + "_1";
                }
                else
                {
                    int nextValue = Int32.Parse(match.Value.Substring(1)) + 1;
                    methodName = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", originalMethodName, nextValue);
                }

                methods = GetHandlersFromActiveFile(methodName);
            }
            return methodName;
        }
        public override bool AddEventHandler(EventDescription eventDescription, string objectName, string methodName)
        {
            //FixMe: VladD2: Какая-то питоновская чушь! Надо разобраться и переписать.
            const string Init = "__init__";

            //This is not the most optimal solution for WPF since we will call FindLogicalNode for each event handler,
            //but it simplifies the code generation for now.

            CodeDomDocDataAdapter adapter = GetDocDataAdapterForNemerleFile();
            CodeMemberMethod      method  = null;

            //Find the __init__ method
            foreach (CodeTypeMember ctMember in adapter.TypeDeclaration.Members)
            {
                if (ctMember is CodeConstructor)
                {
                    if (ctMember.Name == Init)
                    {
                        method = ctMember as CodeMemberMethod;
                        break;
                    }
                }
            }

            if (method == null)
            {
                method = new CodeConstructor();
                method.Name = Init;
            }

            //Create a code statement which looks like: LogicalTreeHelper.FindLogicalNode(self.Root, "button1").Click += self.button1_Click
            var logicalTreeHelper        = new CodeTypeReferenceExpression  ("LogicalTreeHelper");
            var findLogicalNodeMethod    = new CodeMethodReferenceExpression(logicalTreeHelper, "FindLogicalNode");
            var selfWindow               = new CodeFieldReferenceExpression (new CodeThisReferenceExpression(), "Root");
            var findLogicalNodeInvoke    = new CodeMethodInvokeExpression   (findLogicalNodeMethod, selfWindow, new CodeSnippetExpression("\'" + objectName + "\'"));
            var createDelegateExpression = new CodeDelegateCreateExpression (new CodeTypeReference("System.EventHandler"), new CodeThisReferenceExpression(), methodName);
            var attachEvent              = new CodeAttachEventStatement     (findLogicalNodeInvoke, eventDescription.Name, createDelegateExpression);

            method.Statements.Add(attachEvent);
            adapter.Generate();

            return true;
        }
        public override bool CreateMethod(EventDescription eventDescription, string methodName, string initialStatements)
        {
            CodeMemberMethod method = new CodeMemberMethod();

            method.Name = methodName;

            foreach (EventParameter param in eventDescription.Parameters)
            {
                method.Parameters.Add(new CodeParameterDeclarationExpression(param.TypeName, param.Name));
            }

            //Finally, add the new method to the class

            CodeDomDocDataAdapter adapter = GetDocDataAdapterForXSharpFile();

            adapter.TypeDeclaration.Members.Add(method);
            adapter.Generate();

            return true;
        }
Example #7
0
        public override bool CreateMethod(EventDescription eventDescription, string methodName, string initialStatements) {
            // build the new method handler
            var view = _pythonFileNode.GetTextView();
            var textBuffer = _pythonFileNode.GetTextBuffer();
            PythonAst ast;
            var classDef = GetClassForEvents(out ast);
            if (classDef != null) {
                int end = classDef.Body.EndIndex;
                
                // insert after the newline at the end of the last statement of the class def
                if (textBuffer.CurrentSnapshot[end] == '\r') {
                    if (end + 1 < textBuffer.CurrentSnapshot.Length &&
                        textBuffer.CurrentSnapshot[end + 1] == '\n') {
                        end += 2;
                    } else {
                        end++;
                    }
                } else if (textBuffer.CurrentSnapshot[end] == '\n') {
                    end++;
                }

                using (var edit = textBuffer.CreateEdit()) {
                    var text = BuildMethod(
                        eventDescription,
                        methodName,
                        new string(' ', classDef.Body.GetStart(ast).Column - 1),
                        view.Options.IsConvertTabsToSpacesEnabled() ?
                            view.Options.GetIndentSize() :
                            -1);

                    edit.Insert(end, text);
                    edit.Apply();
                    return true;
                }
            }


            return false;
        }
        public override async Task <IExecutionResult> ExecuteAsync(
            IExecutionContext executionContext,
            CancellationToken cancellationToken)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException(nameof(executionContext));
            }

            EventDescription @event = CreateEvent(executionContext);

            IEventStream eventStream = await SubscribeAsync(
                executionContext.Services, @event);

            return(new SubscriptionResult(
                       eventStream,
                       message => executionContext.Clone(
                           new Dictionary <string, object> {
                { typeof(IEventMessage).FullName, message }
            },
                           cancellationToken),
                       ExecuteSubscriptionQueryAsync));
        }
Example #9
0
 private void OnEnable()
 {
     TreeWindSfxManager.Add(this);
     if (FMOD_StudioSystem.instance)
     {
         EventDescription eventDescription = FMOD_StudioSystem.instance.GetEventDescription(this.EventPath, true);
         if (eventDescription != null)
         {
             if (this.WindParameterIndex == -1)
             {
                 this.WindParameterIndex = FMODCommon.FindParameterIndex(eventDescription, "wind");
             }
             if (this.SizeParameterIndex == -1)
             {
                 this.SizeParameterIndex = FMODCommon.FindParameterIndex(eventDescription, "size");
             }
             if (this.TimeParameterIndex == -1)
             {
                 this.TimeParameterIndex = FMODCommon.FindParameterIndex(eventDescription, "time");
             }
         }
     }
 }
Example #10
0
        /// <see cref="IEventRepository.SaveDescriptionSchema" />
        public bool SaveDescriptionSchema(int id, PageBlock pageBlock, UserPageCategory cat, int eventId)
        {
            cat = SaveUserPageCategory(cat);
            var page = SavePage(pageBlock.Page);

            if (page == null)
            {
                return(false);
            }
            pageBlock.IdPage = page.Id;
            var pageblock = SavePageBlock(pageBlock);

            if (pageblock == null)
            {
                return(false);
            }
            var desc = db.EventDescriptions.FirstOrDefault(o => o.Id == id);

            if (desc == null)
            {
                desc = new EventDescription {
                    IdType = 1, IdEvent = eventId
                };
                db.Entry(desc).State = EntityState.Added;
            }
            desc.IdBlock            = pageblock.Id;
            desc.IdUserPageCategory = cat?.Id;
            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
        public static List <EnumDefinition> GetEventDefinitionsForType(Type type, int startvalue = 0)
        {
            List <EnumDefinition> result = new List <EnumDefinition>();
            List <EventInfo>      events = type.GetEvents().ToList();
            int index = startvalue;

            foreach (var @event in events)
            {
                if (@event != null)
                {
                    Type args = null;
                    if (@event.EventHandlerType.IsGenericType)
                    {
                        args = @event.EventHandlerType
                               .GetGenericArguments()[0];
                    }
                    else
                    {
                        args = @event.EventHandlerType.GetMethod("Invoke")
                               .GetParameters()[1].ParameterType;
                    }
                    var description = new EventDescription(
                        new Type[] { @event.DeclaringType },
                        @event.Name, @event.EventHandlerType,
                        args,
                        "Enum for the " + @event.Name + " Event.");
                    var definition = new EnumDefinition(
                        @event.Name,
                        index,
                        description);
                    result.Add(definition);
                    index++;
                }
            }
            ;
            return(result);
        }
Example #12
0
        private void OpenFrame(object source, FocusFrameEventArgs args)
        {
            Data.Frame frame = args.Frame;

            if (frame is EventFrame)
            {
                EventThreadViewControl.Highlight(frame as EventFrame, null);
            }

            if (frame is EventFrame)
            {
                EventFrame eventFrame = frame as EventFrame;
                FrameGroup group      = eventFrame.Group;

                if (eventFrame.RootEntry != null)
                {
                    EventDescription desc = eventFrame.RootEntry.Description;

                    FunctionSummaryVM.Load(group, desc);
                    FunctionInstanceVM.Load(group, desc);

                    FunctionSamplingVM.Load(group, desc);
                    SysCallsSamplingVM.Load(group, desc);

                    FrameInfoControl.SetFrame(frame, null);
                }
            }

            if (frame != null && frame.Group != null)
            {
                if (!ReferenceEquals(SummaryVM.Summary, frame.Group.Summary))
                {
                    SummaryVM.Summary     = frame.Group.Summary;
                    SummaryVM.CaptureName = _captureName;
                }
            }
        }
        public override string CreateUniqueMethodName(string objectName, EventDescription eventDescription)
        {
            string originalMethodName = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", objectName, eventDescription.Name);
            string methodName         = originalMethodName;

            List <CodeTypeMember> methods = GetHandlersFromActivePyFile(string.Format(CultureInfo.InvariantCulture, "{0}_{1}", objectName, eventDescription.Name));

            while (methods.Count > 0)
            {
                //Try to append a _# at the end until we find an unused method name
                Match match = Regex.Match(methodName, @"_\d+$");
                if (!match.Success)
                {
                    methodName = originalMethodName + "_1";
                }
                else
                {
                    int nextValue = Int32.Parse(match.Value.Substring(1)) + 1;
                    methodName = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", originalMethodName, nextValue);
                }
                methods = GetHandlersFromActivePyFile(methodName);
            }
            return(methodName);
        }
Example #14
0
        public override bool CreateMethod(EventDescription eventDescription, string methodName, string initialStatements) {
            // build the new method handler
            var insertPoint = _callback.GetInsertionPoint(null);

            if (insertPoint != null) {
                var view = _callback.TextView;
                var textBuffer = _callback.Buffer;
                using (var edit = textBuffer.CreateEdit()) {
                    var text = BuildMethod(
                        eventDescription,
                        methodName,
                        new string(' ', insertPoint.Indentation),
                        view.Options.IsConvertTabsToSpacesEnabled() ?
                            view.Options.GetIndentSize() :
                            -1);

                    edit.Insert(insertPoint.Location, text);
                    edit.Apply();
                    return true;
                }
            }

            return false;
        }
Example #15
0
    // Creates and starts and instance of the sound. Remember to Stop the sound later. Otherwise it will create a memory leak from not being cleared. Use PlayOneShot if the sound aren't looping. Object with no rigidbody can be set to null

    public static EventInstance Play(string eventName, Transform position, Rigidbody rb)
    {
        EventDescription description = RuntimeManager.GetEventDescription(eventName);

        description.createInstance(out EventInstance instance);

        //EventInstance instance = RuntimeManager.CreateInstance(eventName);

        if (string.IsNullOrEmpty(eventName))
        {
            return(instance);
        }

        description.is3D(out bool is3D);

        if (is3D)
        {
            instance.set3DAttributes(RuntimeUtils.To3DAttributes(position, rb));
            RuntimeManager.AttachInstanceToGameObject(instance, position, rb);
        }

        instance.start();
        return(instance);
    }
Example #16
0
        public static EventDescription GetEventDescription(string path)
        {
            EventDescription desc = null;

            if (path == null || Audio.cachedEventDescriptions.TryGetValue(path, out desc))
            {
                return(desc);
            }

            RESULT status;

            if (cachedModEvents.TryGetValue(path, out desc))
            {
                status = RESULT.OK;
            }
            else
            {
                status = system.getEvent(path, out desc);
            }

            if (status == RESULT.OK)
            {
                desc.loadSampleData();
                Audio.cachedEventDescriptions.Add(path, desc);
            }
            else if (status == RESULT.ERR_EVENT_NOTFOUND)
            {
                Logger.Log("Audio", $"Event not found: {path}");
            }
            else
            {
                throw new Exception("FMOD getEvent failed: " + status);
            }

            return(desc);
        }
Example #17
0
    public bool ShouldBeCulled(string path, Vector3 position)
    {
        EventDescription eventDescription = this.GetEventDescription(path);

        if (eventDescription == null)
        {
            return(true);
        }
        bool flag = false;

        FMOD_StudioSystem.ERRCHECK(eventDescription.is3D(out flag));
        if (flag)
        {
            float num = 0f;
            FMOD_StudioSystem.ERRCHECK(eventDescription.getMaximumDistance(out num));
            num += 20f;
            FMOD.Studio.ATTRIBUTES_3D aTTRIBUTES_3D;
            FMOD_StudioSystem.ERRCHECK(this.System.getListenerAttributes(0, out aTTRIBUTES_3D));
            float sqrMagnitude = (position - aTTRIBUTES_3D.position.toUnityVector()).sqrMagnitude;
            float num2         = num * num;
            return(sqrMagnitude > num2);
        }
        return(false);
    }
Example #18
0
        public Task SubscribeOneConsumer_SendMessage_ConsumerReceivesMessage()
        {
            return(TestHelper.TryTest(async() =>
            {
                // arrange
                var cts = new CancellationTokenSource(30000);
                var eventDescription = new EventDescription(
                    Guid.NewGuid().ToString());

                // act
                IEventStream consumer = await _registry.SubscribeAsync(eventDescription);
                var outgoing = new EventMessage(eventDescription, "bar");
                await _sender.SendAsync(outgoing);

                // assert
                IEventMessage incoming = null;
                await foreach (IEventMessage item in consumer.WithCancellation(cts.Token))
                {
                    incoming = item;
                    break;
                }
                Assert.Equal(outgoing.Payload, incoming.Payload);
            }));
        }
        private async Task <IExecutionResult> ExecuteInternalAsync(
            IExecutionContext executionContext,
            CancellationToken cancellationToken)
        {
            EventDescription eventDescription = CreateEvent(executionContext);

            IEventStream eventStream = await SubscribeAsync(
                executionContext.Services,
                eventDescription)
                                       .ConfigureAwait(false);

            return(new SubscriptionResult(
                       eventStream,
                       msg =>
            {
                IExecutionContext cloned = executionContext.Clone();

                cloned.ContextData[typeof(IEventMessage).FullName] = msg;

                return cloned;
            },
                       ExecuteSubscriptionQueryAsync,
                       executionContext.ServiceScope));
        }
Example #20
0
 public override void ValidateMethodName(EventDescription eventDescription, string methodName)
 {
     return;
 }
Example #21
0
 public override bool AddEventHandler(EventDescription eventDescription, string objectName, string methodName)
 {
     // we return false here which causes the event handler to always be wired up via XAML instead of via code.
     return(false);
 }
Example #22
0
 /// <summary>
 /// Set button's onClick function to the passed in function.
 /// Also gets external component references (such as the eventDescription)
 /// </summary>
 /// <param name="smd"> Delegate function only takes in a monster as a parameter </param>
 /// <remark>
 /// When a monster is instantiated, it does not contain the logic or info that the combatManager
 /// uses to determine if its being attacked.false By passing it an onClick from the combatManager,
 /// its functionality can be simplified.
 /// </remark>
 public void AddSMDListener(SelectMonsterDelegate smd)
 {
     b.onClick.AddListener(() => smd(displayedMonster));
     eventDescription = EventManager.instance.eventDescription;
 }
Example #23
0
 public override bool RemoveEventHandler(EventDescription eventDescription, string objectName, string methodName)
 {
     throw new NotImplementedException();
 }
 public override bool IsExistingMethodName(EventDescription eventDescription, string methodName)
 {
     return(_callback.FindMethods(null, null).Contains(methodName));
 }
 private RecipientTrackingEvent(string domain, SmtpAddress recipientAddress, string recipientDisplayName, DeliveryStatus status, EventType eventType, EventDescription eventDescription, string[] rawEventData, string serverFqdn, DateTime date, long internalMessageId, string uniquePathId, bool hiddenRecipient, bool?bccRecipient, string rootAddress, bool parseEventData, TrackingExtendedProperties trackingExtendedProperties)
 {
     this.domain               = domain;
     this.recipientAddress     = recipientAddress;
     this.recipientDisplayName = recipientDisplayName;
     this.status               = status;
     this.eventType            = eventType;
     this.eventDescription     = eventDescription;
     this.server               = serverFqdn;
     this.date = date;
     this.internalMessageId  = internalMessageId;
     this.uniquePathId       = uniquePathId;
     this.hiddenRecipient    = hiddenRecipient;
     this.bccRecipient       = bccRecipient;
     this.rootAddress        = rootAddress;
     this.extendedProperties = trackingExtendedProperties;
     if (parseEventData)
     {
         VersionConverter.ConvertRawEventData(rawEventData, this);
         return;
     }
     this.eventData = rawEventData;
 }
Example #26
0
 public override bool IsExistingMethodName(EventDescription eventDescription, string methodName) {
     return FindMethod(methodName) != null;
 }
Example #27
0
        void DrawHistoryEntry(HistoryEntry he, int rowpos, int rowheight, Point3D tpos, Color textcolour, Color backcolour)
        {
            List <string> coldata       = new List <string>();              // First we accumulate the strings
            List <int>    tooltipattach = new List <int>();

            if (Config(Configuration.showTime))
            {
                coldata.Add((EDDiscoveryForm.EDDConfig.DisplayUTC ? he.EventTimeUTC : he.EventTimeLocal).ToString("HH:mm.ss"));
            }

            if (Config(Configuration.showIcon))
            {
                coldata.Add("`!!ICON!!");                // dummy place holder..
            }
            he.journalEntry.FillInformation(out string EventDescription, out string EventDetailedInfo);

            if (Config(Configuration.showDescription))
            {
                tooltipattach.Add(coldata.Count);
                coldata.Add(he.EventSummary.Replace("\r\n", " "));
            }

            if (Config(Configuration.showInformation))
            {
                tooltipattach.Add(coldata.Count);
                coldata.Add(EventDescription.Replace("\r\n", " "));
            }

            if (layoutorder == 0 && Config(Configuration.showNotes))
            {
                coldata.Add((he.snc != null) ? he.snc.Note.Replace("\r\n", " ") : "");
            }

            bool showdistance = !Config(Configuration.showDistancesOnFSDJumpsOnly) || he.IsFSDJump;

            if (layoutorder == 2 && Config(Configuration.showDistancePerStar))
            {
                coldata.Add(showdistance ? DistToStar(he, tpos) : "");
            }

            if (Config(Configuration.showXYZ))
            {
                coldata.Add((he.System.HasCoordinate && showdistance) ? he.System.X.ToString("0.00") : "");
                coldata.Add((he.System.HasCoordinate && showdistance) ? he.System.Y.ToString("0.00") : "");
                coldata.Add((he.System.HasCoordinate && showdistance) ? he.System.Z.ToString("0.00") : "");
            }

            if (layoutorder > 0 && Config(Configuration.showNotes))
            {
                coldata.Add((he.snc != null) ? he.snc.Note.Replace("\r\n", " ") : "");
            }

            if (layoutorder < 2 && Config(Configuration.showDistancePerStar))
            {
                coldata.Add(showdistance ? DistToStar(he, tpos) : "");
            }

            int colnum = 0;

            if (Config(Configuration.showEDSMButton))
            {
                Color backtext = (backcolour.IsFullyTransparent()) ? Color.Black : backcolour;
                ExtendedControls.PictureBoxHotspot.ImageElement edsm = pictureBox.AddTextFixedSizeC(new Point(scanpostextoffset.X + columnpos[colnum++], rowpos), new Size(45, 14),
                                                                                                    "EDSM", displayfont, backtext, textcolour, 0.5F, true, he, "View system on EDSM");
                edsm.Translate(0, (rowheight - edsm.img.Height) / 2);          // align to centre of rowh..
                edsm.SetAlternateImage(BaseUtils.BitMapHelpers.DrawTextIntoFixedSizeBitmapC("EDSM", edsm.img.Size, displayfont, backtext, textcolour.Multiply(1.2F), 0.5F, true), edsm.pos, true);
            }

            string tooltip = he.EventSummary + Environment.NewLine + EventDescription + Environment.NewLine + EventDetailedInfo;

            for (int i = 0; i < coldata.Count; i++)             // then we draw them, allowing them to overfill columns if required
            {
                int nextfull = i + 1;
                for (; nextfull < coldata.Count && Config(Configuration.showExpandOverColumns) && coldata[nextfull].Length == 0; nextfull++)
                {
                }

                if (coldata[i].Equals("`!!ICON!!"))              // marker for ICON..
                {
                    Image img = he.GetIcon;
                    ExtendedControls.PictureBoxHotspot.ImageElement e = pictureBox.AddImage(new Rectangle(scanpostextoffset.X + columnpos[colnum + i], rowpos, img.Width, img.Height), img, null, null, false);
                    e.Translate(0, (rowheight - e.img.Height) / 2);          // align to centre of rowh..
                }
                else
                {
                    AddColText(colnum + i, colnum + nextfull, rowpos, rowheight, coldata[i], textcolour, backcolour, tooltipattach.Contains(i) ? tooltip : null);
                }
            }
        }
Example #28
0
        public override IEnumerable<string> GetCompatibleMethods(EventDescription eventDescription) {
            var classDef = GetClassForEvents();
            SuiteStatement suite = classDef.Body as SuiteStatement;

            if (suite != null) {
                int requiredParamCount = eventDescription.Parameters.Count() + 1;
                foreach (var methodCandidate in suite.Statements) {
                    FunctionDefinition funcDef = methodCandidate as FunctionDefinition;
                    if (funcDef != null) {
                        // Given that event handlers can be given any arbitrary 
                        // name, it is important to not rely on the default naming 
                        // to detect compatible methods.  Instead we look at the 
                        // event parameters. We don't have param types in Python, 
                        // so really the only thing that can be done is look at 
                        // the method parameter count, which should be one more than
                        // the event parameter count (to account for the self param).
                        if (funcDef.Parameters.Count == requiredParamCount) {
                            yield return funcDef.Name;
                        }
                    }
                }
            }
        }
Example #29
0
 public override IEnumerable<string> GetMethodHandlers(EventDescription eventDescription, string objectName) {
     return new string[0];
 }
Example #30
0
 public override string CreateUniqueMethodName(string objectName, EventDescription eventDescription) {
     var name = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}_{1}", objectName, eventDescription.Name);
     int count = 0;
     while (IsExistingMethodName(eventDescription, name)) {
         name = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}_{1}{2}", objectName, eventDescription.Name, ++count);
     }
     return name;
 }
 public override void AppendStatements(EventDescription eventDescription, string methodName, string statements, int relativePosition)
 {
     throw new NotImplementedException();
 }
        public override bool RemoveEventHandler(EventDescription eventDescription, string objectName, string methodName)
        {
            var method = FindMethod(methodName);

            if (method != null && method.IsFound)
            {
                var view       = _callback.TextView;
                var textBuffer = _callback.Buffer;

                // appending a method adds 2 extra newlines, we want to remove those if those are still
                // present so that adding a handler and then removing it leaves the buffer unchanged.

                using (var edit = textBuffer.CreateEdit()) {
                    int start = method.Start - 1;

                    // eat the newline we insert before the method
                    while (start >= 0)
                    {
                        var curChar = edit.Snapshot[start];
                        if (!Char.IsWhiteSpace(curChar))
                        {
                            break;
                        }
                        else if (curChar == ' ' || curChar == '\t')
                        {
                            start--;
                            continue;
                        }
                        else if (curChar == '\n')
                        {
                            if (start != 0)
                            {
                                if (edit.Snapshot[start - 1] == '\r')
                                {
                                    start--;
                                }
                            }
                            start--;
                            break;
                        }
                        else if (curChar == '\r')
                        {
                            start--;
                            break;
                        }

                        start--;
                    }


                    // eat the newline we insert at the end of the method
                    int end = method.End;
                    while (end < edit.Snapshot.Length)
                    {
                        if (edit.Snapshot[end] == '\n')
                        {
                            end++;
                            break;
                        }
                        else if (edit.Snapshot[end] == '\r')
                        {
                            if (end < edit.Snapshot.Length - 1 && edit.Snapshot[end + 1] == '\n')
                            {
                                end += 2;
                            }
                            else
                            {
                                end++;
                            }
                            break;
                        }
                        else if (edit.Snapshot[end] == ' ' || edit.Snapshot[end] == '\t')
                        {
                            end++;
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    }

                    // delete the method and the extra whitespace that we just calculated.
                    edit.Delete(Span.FromBounds(start + 1, end));
                    edit.Apply();
                }

                return(true);
            }
            return(false);
        }
 public override IEnumerable <string> GetCompatibleMethods(EventDescription eventDescription)
 {
     return(_callback.FindMethods(null, eventDescription.Parameters.Count() + 1));
 }
            public RESULT getEvent(GUID guid, LOADING_MODE mode, out EventDescription _event)
            {
                RESULT result   = RESULT.OK;
                IntPtr eventraw = new IntPtr();
                _event = null;

                try
                {
                result = FMOD_Studio_System_GetEvent(rawPtr, ref guid, mode, out eventraw);
                }
                catch
                {
                result = RESULT.ERR_INVALID_PARAM;
                }
                if (result != RESULT.OK)
                {
                return result;
                }

                _event = new EventDescription();
                _event.setRaw(eventraw);

                return result;
            }
 private void OnDestroy()
 {
     if (FMOD_StudioEventEmitter.isShuttingDown)
     {
         return;
     }
     UnityUtil.Log("Destroy called");
     if (this.IsEventInstanceValid())
     {
         if (this.getPlaybackState() != PLAYBACK_STATE.STOPPED)
         {
             UnityUtil.Log("Release evt: '" + this.path + "'");
             this.ERRCHECK(this.evt.stop(STOP_MODE.IMMEDIATE));
         }
         this.ERRCHECK(this.evt.release());
         this.evt = null;
         this.timeParameter = null;
         this.windParameter = null;
     }
     this.preStartAction = null;
     this.eventDescription = null;
 }
 internal void ConvertRecipientTrackingEvent(DeliveryStatus status, EventType eventType, EventDescription eventDescription)
 {
     this.status           = status;
     this.eventType        = eventType;
     this.eventDescription = eventDescription;
 }
Example #37
0
        public override bool RemoveEventHandler(EventDescription eventDescription, string objectName, string methodName) {
            var method = FindMethod(methodName);
            if (method != null) {
                var view = _pythonFileNode.GetTextView();
                var textBuffer = _pythonFileNode.GetTextBuffer();

                // appending a method adds 2 extra newlines, we want to remove those if those are still
                // present so that adding a handler and then removing it leaves the buffer unchanged.

                using (var edit = textBuffer.CreateEdit()) {
                    int start = method.StartIndex - 1;

                    // eat the newline we insert before the method
                    while (start >= 0) {
                        var curChar = edit.Snapshot[start];
                        if (!Char.IsWhiteSpace(curChar)) {
                            break;
                        } else if (curChar == ' ' || curChar == '\t') {
                            start--;
                            continue;
                        } else if (curChar == '\n') {
                            if (start != 0) {
                                if (edit.Snapshot[start - 1] == '\r') {
                                    start--;
                                }
                            }
                            start--;
                            break;
                        } else if (curChar == '\r') {
                            start--;
                            break;
                        }

                        start--;
                    }

                    
                    // eat the newline we insert at the end of the method
                    int end = method.EndIndex;                    
                    while (end < edit.Snapshot.Length) {
                        if (edit.Snapshot[end] == '\n') {
                            end++;
                            break;
                        } else if (edit.Snapshot[end] == '\r') {
                            if (end < edit.Snapshot.Length - 1 && edit.Snapshot[end + 1] == '\n') {
                                end += 2;
                            } else {
                                end++;
                            }
                            break;
                        } else if (edit.Snapshot[end] == ' ' || edit.Snapshot[end] == '\t') {
                            end++;
                            continue;
                        } else {
                            break;
                        }
                    }

                    // delete the method and the extra whitespace that we just calculated.
                    edit.Delete(Span.FromBounds(start + 1, end));
                    edit.Apply();
                }

                return true;
            }
            return false;
        }
 public override IEnumerable <string> GetMethodHandlers(EventDescription eventDescription, string objectName)
 {
     return(new string[0]);
 }
Example #39
0
    void OnGUI()
    {
        boundactive = false;
        GUI.depth   = -5000;
        if (editing == this)
        {
            if (Vector3.Dot(Camera.main.transform.forward, (transform.position - Camera.main.transform.position).normalized) > 0.1f)
            {
                GUI.skin = gskin;
                Vector3 screenPoint = Camera.main.WorldToScreenPoint(transform.position);
                screenPoint.x -= 30f;
                screenPoint.y -= 25f;

                int height = 120;
                if (audioSrc.audioInst != null)
                {
                    int slidercnt = 0;
                    audioSrc.audioInst.getParameterCount(out slidercnt);
                    height = 304 + 25 * slidercnt;
                }

                GUI.BeginGroup(new Rect(screenPoint.x, Screen.height - screenPoint.y, 300, height));
                GUI.Box(new Rect(0, 0, 300, height), "");
                GUILayout.BeginHorizontal();
                GUILayout.Space(5);
                GUILayout.BeginVertical();
                GUILayout.Space(8);
                {
                    GUILayout.Label("Load Event");
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(13);
                        inputPath = GUILayout.TextField(inputPath, GUILayout.Width(200));
                        if (GUILayout.Button("Load", GUILayout.Width(50)))
                        {
                            audioSrc.path = inputPath;
                        }
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.Space(15);
                    GUILayout.Label("Audio Settings");
                    if (audioSrc.audioInst != null)
                    {
                        EventDescription desc = null;
                        audioSrc.audioInst.getDescription(out desc);
                        if (desc != null && desc.isValid())
                        {
                            bool is3D = false;
                            desc.is3D(out is3D);
                            bool isOneshot = false;
                            desc.isOneshot(out isOneshot);
                            float mindist = 0, maxdist = 0;
                            if (is3D)
                            {
                                desc.getMinimumDistance(out mindist);
                                desc.getMaximumDistance(out maxdist);
                                boundactive = true;
                                bound.transform.localScale = Vector3.one * audioSrc.maxDistance * 2f;
                            }
                            string is3Dstr = is3D ? "3D Sound" : "2D Sound";
                            string diststr = is3D ? ("Distance Area ( " + mindist.ToString("0.##") + "m ~ " + maxdist.ToString("0.##") + "m )") : ("");

                            if (listener != null)
                            {
                                LabelField("Distance", listenDist.ToString("#,##0.00") + " m");
                            }
                            else
                            {
                                LabelField("Distance", "-");
                            }

                            LabelField(is3Dstr, diststr);

                            audioSrc.minDistance = FloatField("Min Dist", audioSrc.minDistance);
                            audioSrc.maxDistance = FloatField("Max Dist", audioSrc.maxDistance);

                            LabelField("Is Oneshot", isOneshot.ToString());

                            audioSrc.volume = Slider("Volume", audioSrc.volume, 0f, 1f);
                            audioSrc.pitch  = Slider("Pitch", audioSrc.pitch, 0f, 4f);

                            int pcnt = 0;
                            audioSrc.audioInst.getParameterCount(out pcnt);

                            for (int i = 0; i < pcnt; ++i)
                            {
                                ParameterInstance pinst = null;
                                audioSrc.audioInst.getParameterByIndex(i, out pinst);
                                PARAMETER_DESCRIPTION pdesc = new PARAMETER_DESCRIPTION();
                                pinst.getDescription(out pdesc);
                                float val = 0f, _val = 0f;
                                pinst.getValue(out val);
                                _val = Slider(pdesc.name, val, pdesc.minimum, pdesc.maximum);
                                if (_val != val)
                                {
                                    pinst.setValue(_val);
                                }
                            }

                            GUILayout.Space(8);
                            GUILayout.BeginHorizontal();
                            {
                                GUILayout.Space(17);
                                if (GUILayout.Button("Play", GUILayout.Width(80)))
                                {
                                    audioSrc.Play();
                                }
                                GUILayout.Space(4);
                                if (GUILayout.Button("Stop", GUILayout.Width(80)))
                                {
                                    audioSrc.Stop();
                                }
                                GUILayout.Space(4);
                                if (GUILayout.Button("Unload", GUILayout.Width(80)))
                                {
                                    audioSrc.path = "";
                                }
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                    else
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space(13);
                            GUILayout.Label("No Event Loaded");
                        }
                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
                GUI.EndGroup();
            }
            else
            {
                if (audioSrc.is3D)
                {
                    boundactive = true;
                    bound.transform.localScale = Vector3.one * audioSrc.maxDistance * 2f;
                }
            }
        }
    }
Example #40
0
        public override bool ShowMethod(EventDescription eventDescription, string methodName) {
            var method = FindMethod(methodName);
            if (method != null) {
                var view = _pythonFileNode.GetTextView();
                view.Caret.MoveTo(new VisualStudio.Text.SnapshotPoint(view.TextSnapshot, method.StartIndex));
                view.Caret.EnsureVisible();
                return true;
            }

            return false;
        }
 public RecipientTrackingEvent(string domain, SmtpAddress recipientAddress, string recipientDisplayName, DeliveryStatus status, EventType eventType, EventDescription eventDescription, string[] eventData, string serverFqdn, DateTime date, long internalMessageId, string uniquePathId, bool hiddenRecipient, bool?bccRecipient, string rootAddress, string arbitrationMailboxAddress, string initMessageId) : this(domain, recipientAddress, recipientDisplayName, status, eventType, eventDescription, eventData, serverFqdn, date, internalMessageId, uniquePathId, hiddenRecipient, bccRecipient, rootAddress, false, new TrackingExtendedProperties(false, false, null, false, string.Empty, arbitrationMailboxAddress, initMessageId, false))
 {
 }
Example #42
0
 public override bool AddEventHandler(EventDescription eventDescription, string objectName, string methodName) {
     // we return false here which causes the event handler to always be wired up via XAML instead of via code.
     return false;
 }
Example #43
0
        private void InstantiateAudioObject(Transform follow = null, List <AudioObjectParameter> parameters = null)
        {
            if (destructionInProgress || !initializationSuccesfull)
            {
                return;
            }

            if (singleton && instantiations.Count > 0)
            {
                return;
            }

            int index = 0;

            if (eventReferences.Count > 1)
            {
                index = SelectRandomIndex();
            }

            EventInstance eventInstance;

            eventInstance = RuntimeManager.CreateInstance(eventReferences[index]);

            if (!eventInstance.isValid())
            {
                Debug.LogError("Creating an event instance failed for Audio Object '" + gameObject.name + "'.");
                return;
            }

            if (parameters != null)
            {
                for (int i = 0; i < parameters.Count; i++)
                {
                    AudioObjectParameter parameter = parameters[i];

                    FMOD.RESULT result = eventInstance.setParameterByName(parameter.name, parameter.value);

                    if (result != FMOD.RESULT.OK)
                    {
                        Debug.LogWarning("Setting a value for local parameter '" + parameter.name +
                                         "' failed for '" + gameObject.name + "'. Fmod error: " + result);
                    }
                }
            }

            EventDescription eventDescription = RuntimeManager.GetEventDescription(eventReferences[index]);

            bool is3D;

            eventDescription.is3D(out is3D);

            Transform transformToFollow = null;

            if (is3D)
            {
                // Transform follow priority:
                // 1. Transform optionally provided with the event instantiation
                // 2. Transform optionally provided in the inspector
                // 3. The Transform of this Audio Object.

                if (follow != null)
                {
                    transformToFollow = follow;
                }
                else if (followTransform)
                {
                    transformToFollow = followTransform;
                }
                else
                {
                    transformToFollow = gameObject.transform;
                }

                // If the followed game object has a rigibody, retrieve it and pass it to FMOD RuntimeManager for velocity updates.
                Rigidbody rb = transformToFollow.gameObject.GetComponent <Rigidbody>();

                RuntimeManager.AttachInstanceToGameObject(eventInstance, transformToFollow, rb);
            }

            if (spatialAudioRoomAware && SpatialAudioManager.Instance != null)
            {
                if (is3D)
                {
                    if (_usesResonanceAudioSource)
                    {
                        var delayedRegistree = new DelayedSpatialAudioRegistree();
                        delayedRegistree.transformToFollow = transformToFollow;
                        delayedRegistree.eventInstance     = eventInstance;
                        delayedSpatialAudioRegistrees.Add(delayedRegistree);

                        GCHandle registreeHandle = GCHandle.Alloc(delayedRegistree, GCHandleType.Pinned);
                        eventInstance.setUserData(GCHandle.ToIntPtr(registreeHandle));
                        eventInstance.setCallback(instanceCreatedCallback, EVENT_CALLBACK_TYPE.CREATED | EVENT_CALLBACK_TYPE.DESTROYED);
                        return;
                    }
                    else
                    {
                        float maxDistance;
                        eventDescription.getMaximumDistance(out maxDistance);
                        SpatialAudioManager.Instance.RegisterRoomAwareInstance(eventInstance, transformToFollow, maxDistance, initialRoom, false);
                    }
                }
            }

            instantiations.Add(eventInstance);
            eventInstance.start();
        }
 public override void AppendStatements(EventDescription eventDescription, string methodName, string statements, int relativePosition)
 {
     throw new NotImplementedException();
 }
Example #45
0
        public override bool IsExistingMethodName(EventDescription eventDescription, string methodName)
        {
            List <CodeTypeMember> elements = GetHandlersFromActiveFile(methodName);

            return(elements.Count != 0);
        }
        public override IEnumerable<string> GetMethodHandlers(EventDescription eventDescription, string objectName)
        {
            List<string> methodHandlers = new List<string>();

            foreach (CodeTypeMember member in GetCodeDomForPyFile().Members)
            {
                if (member is CodeConstructor)
                {
                    CodeConstructor constructor = (CodeConstructor)member;
                    foreach (CodeStatement statement in constructor.Statements)
                    {
                        if (statement is CodeAttachEventStatement)
                        {
                            CodeAttachEventStatement codeAttach = (CodeAttachEventStatement)statement;
                            if (codeAttach.Event.EventName != eventDescription.Name)
                            {
                                //This is a code attach, but not for the event that the designer is looking for.
                                //Go to the next one.
                                continue;
                            }
                            if (codeAttach.Event.TargetObject is CodeMethodInvokeExpression)
                            {
                                CodeMethodInvokeExpression findLogNode = (CodeMethodInvokeExpression)codeAttach.Event.TargetObject;
                                if (findLogNode.Parameters.Count >= 2)
                                {
                                    if (findLogNode.Parameters[1] is CodePrimitiveExpression)
                                    {
                                        string targetObjectName = ((CodePrimitiveExpression)findLogNode.Parameters[1]).Value.ToString().Trim('"');
                                        if(targetObjectName.Equals(objectName, StringComparison.Ordinal))
                                        {
                                            if (codeAttach.Listener is CodeDelegateCreateExpression)
                                            {
                                                methodHandlers.Add(((CodeDelegateCreateExpression)codeAttach.Listener).MethodName);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return methodHandlers;
        }
Example #47
0
 public override bool RemoveMethod(EventDescription eventDescription, string methodName)
 {
     throw new NotImplementedException();
 }
 public override bool RemoveEventHandler(EventDescription eventDescription, string objectName, string methodName)
 {
     throw new NotImplementedException();
 }
Example #49
0
 public override void AppendStatements(EventDescription eventDescription, string methodName, string statements, int relativePosition)
 {
     //??
 }
        public override bool ShowMethod(EventDescription eventDescription, string methodName)
        {
            CodeDomDocDataAdapter adapter = GetDocDataAdapterForPyFile();
            List<CodeTypeMember> methodsToShow = GetHandlersFromActivePyFile(methodName);
            if (methodsToShow == null || methodsToShow.Count < 1)
                return false;

            Point point = new Point();
            if (methodsToShow[0] != null)
            {
                //We can't navigate to every method, so just take the first one in the list.
                object pt = methodsToShow[0].UserData[typeof(Point)];
                if (pt != null)
                {
                    point = (Point)pt;
                }
            }
            //Get IVsTextManager to navigate to the code
            IVsTextManager mgr = Package.GetGlobalService(typeof(VsTextManagerClass)) as IVsTextManager;
            Guid logViewCode = VSConstants.LOGVIEWID_Code;
            return ErrorHandler.Succeeded(mgr.NavigateToLineAndColumn(adapter.DocData.Buffer, ref logViewCode, point.Y - 1, point.X, point.Y - 1, point.X));
        }
Example #51
0
 protected virtual void Update(FrameGroup group, EventDescription desc)
 {
 }
Example #52
0
            public RESULT getEvent(string path, out EventDescription _event)
            {
                _event = null;

                IntPtr eventraw = new IntPtr();
                RESULT result = FMOD_Studio_System_GetEvent(rawPtr, Encoding.UTF8.GetBytes(path + Char.MinValue), out eventraw);
                if (result != RESULT.OK)
                {
                return result;
                }

                _event = new EventDescription(eventraw);
                return result;
            }
 public override IEnumerable<string> GetCompatibleMethods(EventDescription eventDescription)
 {
     throw new NotImplementedException();
 }
		///     Shows the body of the user code with the given method
		///     name. This returns true if it was possible to show
		///     the code, or false if not. We are never showing code
		///     since we do not generate handler methods.
		protected bool ShowCode(object component, EventDescriptor e, string methodName)
        {
            EventDescription ev = new EventDescription(methodName, e);
            VisualPascalABC.CodeFileDocumentControl cfdc = VisualPascalABC.VisualPABCSingleton.MainForm._currentCodeFileDocument;
            cfdc.GenerateDesignerCode(ev);
            if (ev.editor != null)
            {
                cfdc.DesignerAndCodeTabs.SelectedTab = cfdc.TextPage;
                VisualPascalABC.VisualPABCSingleton.MainForm.VisualEnvironmentCompiler.ExecuteSourceLocationAction(
                    new PascalABCCompiler.SourceLocation(cfdc.FileName, ev.line_num, ev.column_num, ev.line_num, ev.column_num),
                    VisualPascalABCPlugins.SourceLocationAction.GotoBeg);
            }
            return false;
        }
 public override bool IsExistingMethodName(EventDescription eventDescription, string methodName)
 {
     List<CodeTypeMember> elements = GetHandlersFromActivePyFile(methodName);
     return elements.Count != 0;
 }
Example #56
0
            public RESULT getDescription(out EventDescription description)
            {
                description = null;

                IntPtr newPtr;
                RESULT result = FMOD_Studio_EventInstance_GetDescription(rawPtr, out newPtr);
                if (result != RESULT.OK)
                {
                return result;
                }
                description = new EventDescription(newPtr);
                return result;
            }
 public override bool RemoveMethod(EventDescription eventDescription, string methodName)
 {
     throw new NotImplementedException();
 }
Example #58
0
            public RESULT getEventList(out EventDescription[] array)
            {
                array = null;

                RESULT result;
                int capacity;
                result = FMOD_Studio_Bank_GetEventCount(rawPtr, out capacity);
                if (result != RESULT.OK)
                {
                return result;
                }
                if (capacity == 0)
                {
                array = new EventDescription[0];
                return result;
                }

                IntPtr[] rawArray = new IntPtr[capacity];
                int actualCount;
                result = FMOD_Studio_Bank_GetEventList(rawPtr, rawArray, capacity, out actualCount);
                if (result != RESULT.OK)
                {
                return result;
                }
                if (actualCount > capacity) // More items added since we queried just now?
                {
                actualCount = capacity;
                }
                array = new EventDescription[actualCount];
                for (int i=0; i<actualCount; ++i)
                {
                array[i] = new EventDescription(rawArray[i]);
                }
                return RESULT.OK;
            }
 public override void ValidateMethodName(EventDescription eventDescription, string methodName)
 {
     return;
 }
Example #60
0
            public RESULT getEvent(GUID guid, LOADING_MODE mode, out EventDescription _event)
            {
                _event = null;

                IntPtr eventraw = new IntPtr();
                RESULT result = FMOD_Studio_System_GetEvent(rawPtr, ref guid, mode, out eventraw);
                if (result != RESULT.OK)
                {
                return result;
                }

                _event = new EventDescription(eventraw);
                return result;
            }