public static void Drag(AnimatedGameObject animatedGameObject, BaseTrack track, TrackEvent trackEvent, int framesDif, int minFrame, int maxFrame)
        {
            if (Mathf.Abs(framesDif) > 0)
            {
                var newStartFrame = trackEvent.StartFrame + framesDif;
                var newEndFrame   = trackEvent.EndFrame + framesDif;

                if (trackEvent.IsDragged)
                {
                    var eventLenth = trackEvent.Length;
                    trackEvent.StartFrame = Mathf.Clamp(newStartFrame, minFrame, maxFrame - eventLenth);
                    trackEvent.EndFrame   = Mathf.Clamp(newEndFrame, trackEvent.StartFrame + eventLenth, maxFrame);
                }

                if (OnEventDragged != null)
                {
                    OnEventDragged(new EventSelectionHolder()
                    {
                        AnimatedGameObject = animatedGameObject,
                        Event = trackEvent,
                        Track = track
                    });
                }
            }
        }
        public static void DrawTrackSection(AnimatedGameObject animatedGameObject, BaseTrack track, Rect trackRect, TimeLineParameters parameters)
        {
            EditorGUILayout.LabelField(track.TrackName);
            DrawTrackMenu(animatedGameObject, track);
            var eventsRect = new Rect(185f, 0, trackRect.width - 205f, RowHeight);

            GUILayout.BeginArea(eventsRect);
            var events       = track.Events.Where(evt => evt.StartFrame <parameters.MaxFrame && evt.EndFrame> parameters.MinFrame).OrderBy(evt => evt.StartFrame).ToList();
            var lastEndFrame = parameters.MinFrame;

            for (int i = 0; i < events.Count; i++)
            {
                var trackEvent = events[i];
                if (trackEvent.StartFrame > lastEndFrame)
                {
                    DrawEmptyEvent(animatedGameObject, track, eventsRect, lastEndFrame, trackEvent.StartFrame, parameters);
                }

                var minFrame = i == 0 ? parameters.MinFrame : events[i - 1].EndFrame;
                var maxFrame = i == events.Count - 1 ? parameters.MaxFrame : events[i + 1].StartFrame;
                DrawTrackEvent(animatedGameObject, track, trackEvent, eventsRect, parameters, minFrame, maxFrame, i);
                lastEndFrame = trackEvent.EndFrame;
                if (i == events.Count - 1 && trackEvent.EndFrame < parameters.MaxFrame)
                {
                    DrawEmptyEvent(animatedGameObject, track, eventsRect, lastEndFrame, parameters.MaxFrame, parameters);
                }
            }
            GUILayout.EndArea();
            Handles.color = Color.black;
            Handles.DrawLine(new Vector3(0, trackRect.height - 1f), new Vector3(trackRect.width, trackRect.height - 1f));
        }
Ejemplo n.º 3
0
        public LoadEater(LoadEaterInfo info, BaseTrack conv) : base(info, conv)
        {
            loadEaterInfo = info;// as LoadEaterInfo;

            EaterCube             = new Experior.Core.Parts.Cube(Color.LightGray, 0.651f, 0.351f, 0.451f);
            EaterCube.Selectable  = true;
            EaterCube.OnSelected += EaterCube_OnSelected;

            StopCube             = new Core.Parts.Cube(Color.Red, 0.35f, 0.35f, 0.35f);
            StopCube.Selectable  = true;
            StopCube.OnSelected += EaterCube_OnSelected;



            Add((RigidPart)EaterCube);
            Add((RigidPart)StopCube);

            EaterCube.LocalPosition = new Vector3(0, 0.15f, 0);
            StopCube.LocalPosition  = new Vector3(0, 0.17f, 0);
            conv.TransportSection.Route.InsertActionPoint(EaterActionPoint);

            EaterActionPoint.Distance = info.distance;
            EaterActionPoint.OnEnter += EaterActionPoint_OnEnter;
            EaterActionPoint.Visible  = false;
        }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        curTime -= Time.deltaTime;
        if (bShoot == true)
        {
            if (curTime <= 0 && lineBullet == null)
            {
                BaseBullent obj = GameManager.instance.CreateBullet(bulletType);
                obj.transform.position = this.transform.position;
                obj.direct             = direct;
                obj.Owner = Owner;
                BaseTrack track = obj.GetComponent <BaseTrack>();
                if (track != null)
                {
                    obj.GetComponent <BaseTrack>().rotation = transform.eulerAngles.z;
                }
                curTime = 1 / rate;

                if (obj.IsLine == true)
                {
                    lineBullet = obj;
                    lineBullet.transform.SetParent(this.transform);
                    lineBullet.transform.localPosition = Vector3.zero;
                }
            }
        }
    }
Ejemplo n.º 5
0
        public LoadFeeder(LoadFeederInfo info, BaseTrack conv) : base(info, conv)
        {
            loadFeederInfo = info;// as LoadFeederInfo;

            FeederCube             = new Experior.Core.Parts.Cube(Color.LightGray, 0.651f, 0.351f, 0.451f);
            FeederCube.Rigid       = false;
            FeederCube.Selectable  = true;
            FeederCube.OnSelected += EaterCube_OnSelected;

            StartArrow             = new Core.Parts.Arrow(0.35f);
            StartArrow.Color       = Color.Green;
            StartArrow.Selectable  = true;
            StartArrow.OnSelected += EaterCube_OnSelected;

            Add((RigidPart)FeederCube);
            Add((RigidPart)StartArrow);

            FeederCube.LocalPosition = new Vector3(0, 0.15f, 0);
            StartArrow.LocalPosition = new Vector3(0, 0.315f, 0);
            conv.TransportSection.Route.InsertActionPoint(FeederActionPoint);

            FeederActionPoint.Distance = info.distance;
            FeederActionPoint.OnEnter += FeederActionPoint_OnEnter;
            FeederActionPoint.Visible  = false;

            if (loadFeederInfo.feedInterval != 0)
            {
                feedTimer            = new Core.Timer(loadFeederInfo.feedInterval);
                feedTimer.AutoReset  = true;
                feedTimer.OnElapsed += feedTimer_OnElapsed;
            }

            Enabled = loadFeederInfo.enabled;
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Called when the current playing item changes
        /// </summary>
        private async void Instance_OnCurrentTrackChanged(BaseTrack newTrack)
        {
            await DispatcherHelper.ExecuteOnUIThreadAsync(async() =>
            {
                var overlay = App.CurrentFrame.FindName("VideoOverlay") as MediaElement;

                if (overlay != null)
                {
                    if (newTrack.ServiceType == ServiceType.YouTube)
                    {
                        overlay.Source = new Uri(newTrack.VideoStreamUrl);
                        overlay.Play();
                    }
                    else
                    {
                        overlay.Opacity = 0;
                        overlay.Pause();
                        overlay.Source = null;
                    }
                }

                // Set the pin button text
                PinButtonText = TileHelper.IsTilePinned("Track_" + newTrack.TrackId) ? "Unpin" : "Pin";

                // Set the like button text
                LikeButtonText = (await SoundByteService.Current.ExistsAsync(ServiceType.SoundCloud, "/me/favorites/" + newTrack.TrackId)).Response
                    ? "Unlike"
                    : "Like";

                // Reload all the comments
                CommentItems.Source.Track = newTrack;
                CommentItems.RefreshItems();
            });
        }
Ejemplo n.º 7
0
        public CasePhotocell(CasePhotocellInfo info, BaseTrack conv) : base(info, conv)
        {
            photocellInfo = info;
            AssemblyInfo ai = new AssemblyInfo();

            conveyor = conv;

            photocellDisplay = new CasePhotocellDisplay(new PhotocellDisplayInfo {
                width = info.width
            });
            photocellDisplay.ListSolutionExplorer       = false;
            photocellDisplay.OnPhotocellDisplayDeleted += photocellDisplay_OnPhotocellDisplayDeleted;

            Add(photocellDisplay, new Vector3(info.length / 2, 0, 0));
            sensor.OnEnter += sensor_OnEnter;
            sensor.OnLeave += sensor_OnLeave;
            sensor.Color    = Color.Green;
            sensor.Visible  = false;

            conv.TransportSection.Route.InsertActionPoint(sensor);

            //If the photocell is connected to a belt conveyor then we want to pause the timers if the conveyor is not available
            if (conveyor is IBeltControl)
            {
                beltControl = conveyor as IRouteStatus;
                routeStatus = beltControl.GetRouteStatus(conveyor.StartFixPoint);
                routeStatus.OnRouteStatusChanged += routeStatus_OnRouteStatusChanged;
            }

            OnNameChanged += CasePhotocell_OnNameChanged;
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Build a media item and add it to the list
        /// </summary>
        /// <param name="track">Track to build into a media item</param>
        private void BuildMediaItem(BaseTrack track)
        {
            // Create a media binding for later (this is used to
            // load the track streams as we need them).
            var binder = new MediaBinder
            {
                Token = JsonConvert.SerializeObject(track)
            };

            binder.Binding += BindMediaSource;

            // Create the source, bind track metadata and use it to
            // create a playback item
            var source            = MediaSource.CreateFromMediaBinder(binder);
            var mediaPlaybackItem = new MediaPlaybackItem(track.AsMediaSource(source));

            // Apply display properties to this item
            var displayProperties = mediaPlaybackItem.GetDisplayProperties();

            displayProperties.Type = MediaPlaybackType.Music;
            displayProperties.MusicProperties.Title  = track.Title;
            displayProperties.MusicProperties.Artist = track.User.Username;
            displayProperties.Thumbnail = RandomAccessStreamReference.CreateFromUri(new Uri(track.ThumbnailUrl));

            // Apply the properties
            mediaPlaybackItem.ApplyDisplayProperties(displayProperties);

            // Add this item to the list
            _mediaPlaybackList.Items.Add(mediaPlaybackItem);
        }
Ejemplo n.º 9
0
        public async Task StartTrackAsync(BaseTrack trackToPlay = null, TimeSpan?startTime = null)
        {
            MediaPlaybackList.ShuffleEnabled = false;

            MediaPlayer.Pause();

            if (trackToPlay == null)
            {
                MediaPlayer.Play();
                return;
            }

            var keepTrying = 0;

            while (keepTrying < 50)
            {
                try
                {
                    // find the index of the track in the playlist
                    var index = MediaPlaybackList.Items.ToList()
                                .FindIndex(item => item.Source.AsBaseTrack().TrackId ==
                                           trackToPlay.TrackId);

                    if (index == -1)
                    {
                        await Task.Delay(50);

                        keepTrying++;
                        continue;
                    }

                    // Move to the track
                    MediaPlaybackList.MoveTo((uint)index);

                    // Begin playing
                    MediaPlayer.Play();

                    // Set the position if we supply one
                    if (startTime.HasValue)
                    {
                        MediaPlayer.PlaybackSession.Position = startTime.Value;
                    }

                    await App.RoamingService.StopActivityAsync();

                    await App.RoamingService.StartActivityAsync(_playlistSource, trackToPlay, MediaPlaybackList.Items.Select(x => x.Source.AsBaseTrack()), _playlistToken);

                    return;
                }
                catch (Exception)
                {
                    keepTrying++;
                    await Task.Delay(200);
                }
            }

            // Just play the first item
            MediaPlayer.Play();
        }
Ejemplo n.º 10
0
        public ShareDialog(BaseTrack trackItem)
        {
            // Do this before the xaml is loaded, to make sure
            // the object can be binded to.
            Track = trackItem;

            // Load the XAML page
            InitializeComponent();
        }
Ejemplo n.º 11
0
        /// <summary>
        ///     Loads stream items from the souncloud api
        /// </summary>
        /// <param name="count">The amount of items to load</param>
        // ReSharper disable once RedundantAssignment
        public IAsyncOperation <LoadMoreItemsResult> LoadMoreItemsAsync(uint count)
        {
            // Return a task that will get the items
            return(Task.Run(async() =>
            {
                _track = PlaybackService.Instance.CurrentTrack;


                if (_track == null)
                {
                    return new LoadMoreItemsResult {
                        Count = 0
                    }
                }
                ;

                // We are loading
                await DispatcherHelper.ExecuteOnUIThreadAsync(() => { App.IsLoading = true; });

                try
                {
                    var trackComments = await _track.GetCommentsAsync(count, Token);

                    // Get the comment offset
                    Token = string.IsNullOrEmpty(trackComments.Token) ? "eol" : trackComments.Token;

                    // Loop though all the comments on the UI thread
                    await DispatcherHelper.ExecuteOnUIThreadAsync(() => { trackComments.Comments.ForEach(Add); });

                    // Set the count variable
                    count = (uint)trackComments.Comments.Count;
                }
                catch (SoundByteException ex)
                {
                    // Exception, most likely did not add any new items
                    count = 0;

                    // Reset the token
                    Token = "eol";

                    // Exception, display error to the user
                    await DispatcherHelper.ExecuteOnUIThreadAsync(async() =>
                    {
                        await new MessageDialog(ex.ErrorDescription, ex.ErrorTitle).ShowAsync();
                    });
                }

                // We are not loading
                await DispatcherHelper.ExecuteOnUIThreadAsync(() => { App.IsLoading = false; });

                // Return the result
                return new LoadMoreItemsResult {
                    Count = count
                };
            }).AsAsyncOperation());
        }
        public void Init(EditorParameters parameters, EventParameters eventParameters, Sequence selectedSequence = null, AnimatedGameObject animatedGameObject = null, BaseTrack track = null, TrackEvent trackEvent = null)
        {
            _eventParameters    = eventParameters;
            _sequenceName       = selectedSequence == null ? string.Empty : selectedSequence.name;
            _animatedGameObject = animatedGameObject;
            _track      = track;
            _trackEvent = trackEvent;

            _lastEditorParameters = parameters;
        }
Ejemplo n.º 13
0
        public void ApplyParameters(Dictionary <string, object> data)
        {
            data.TryGetValue("t", out var trackId);
            data.TryGetValue("s", out var service);

            Track = new BaseTrack
            {
                ServiceType = (ServiceType)service,
                TrackId     = trackId.ToString()
            };
        }
Ejemplo n.º 14
0
        public ShareDialog(BaseTrack trackItem)
        {
            // Do this before the xaml is loaded, to make sure
            // the object can be binded to.
            Track = trackItem;

            // Load the XAML page
            InitializeComponent();

            LightsSourceHelper.SetIsLightsContainer(RootGrid, true);
        }
Ejemplo n.º 15
0
        public PlaylistDialog(BaseTrack trackItem)
        {
            // Do this before the xaml is loaded, to make sure
            // the object can be binded to.
            Track = trackItem;

            // Load the XAML page
            InitializeComponent();

            // Bind the open event handler
            Opened += LoadContent;
        }
Ejemplo n.º 16
0
    public override void SwitchSwitch()
    {
        if (Content != null)
            return;
        if (!IsUp)
            IsUp = true;
        else
            IsUp = false;

        BaseTrack tempTrack = Inactive;
        Inactive = Previous;
        Previous = tempTrack;
    }
Ejemplo n.º 17
0
    public override void SwitchSwitch()
    {
        if (!IsEmpty())
            return;

        if (!IsUp)
            IsUp = true;
        else
            IsUp = false;

        BaseTrack tempTrack = Inactive;
        Inactive = Next;
        Next = tempTrack;
    }
Ejemplo n.º 18
0
        public Device(DeviceInfo info, BaseTrack conv) : base(info)
        {
            deviceInfo = info;
            conveyor   = conv;

            SectionName       = conv.SectionName;
            OnSectionChanged += Device_OnSectionChanged;

            if (conv is IConstructDevice)
            {
                parent = (IConstructDevice)conv;
                ((IConstructDevice)conv).OnSizeUpdated += Device_OnSizeUpdated;
            }
        }
Ejemplo n.º 19
0
 private async void InstanceOnOnCurrentTrackChanged(BaseTrack newTrack)
 {
     await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
     {
         if (!DeviceHelper.IsDesktop ||
             RootFrame.CurrentSourcePageType == typeof(NowPlayingView))
         {
             HideNowPlayingBar();
         }
         else
         {
             ShowNowPlayingBar();
         }
     });
 }
Ejemplo n.º 20
0
        public void MoveToTrack(BaseTrack track)
        {
            // Find the index of the track in the playlist
            var index = _mediaPlaybackList.Items.ToList()
                        .FindIndex(item => item.Source.AsBaseTrack().TrackId
                                   == track.TrackId);

            if (index == -1)
            {
                return;
            }

            // Move to the track
            _mediaPlaybackList.MoveTo((uint)index);
        }
Ejemplo n.º 21
0
        public async Task StartActivityAsync(ISource <BaseTrack> source, BaseTrack track, IEnumerable <BaseTrack> playlist, string token)
        {
            // We do not support these items
            if (track.ServiceType == ServiceType.ITunesPodcast ||
                track.ServiceType == ServiceType.Local ||
                track.ServiceType == ServiceType.Unknown)
            {
                return;
            }

            var activity = await UpdateActivityAsync(source, track, playlist, token);

            await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
            {
                _currentUserActivitySession = activity.CreateSession();
            });
        }
Ejemplo n.º 22
0
        private async void AddMusicFilesAsync(IEnumerable <IStorageItem> files, Random random)
        {
            if (files == null)
            {
                return;
            }

            foreach (var item in files)
            {
                var file = item as StorageFile;

                if (file == null)
                {
                    continue;
                }

                if (!supportedMediaTypes.Contains(file.FileType))
                {
                    continue;
                }

                var properties = await file.Properties.GetMusicPropertiesAsync();

                var track = new BaseTrack
                {
                    ServiceType    = ServiceType.Local,
                    AudioStreamUrl = file.Path,
                    Title          = GetNullString(properties.Title, file.DisplayName),
                    User           = new BaseUser
                    {
                        ServiceType = ServiceType.Local,
                        Username    = GetNullString(properties.Artist, "Unknown Artist")
                    },
                    Genre    = string.Join(',', properties.Genre),
                    Duration = properties.Duration,
                    TrackId  = random.Next(0, 999999999).ToString()
                };

                track.CustomProperties.Add("File", file);

                tracks.Add(track);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        ///     Get the image for the track
        /// </summary>
        /// <param name="track">The track to get an image for</param>
        /// <returns>A url to the image</returns>
        private static string GetTrackImage(BaseTrack track)
        {
            // If there is no uri, return the users image
            if (string.IsNullOrEmpty(track.ArtworkUrl))
            {
                return(GetUserImage(track.User));
            }

            // Check if this image supports high resolution
            if (track.ArtworkUrl.Contains("large"))
            {
                return(SettingsService.Instance.IsHighQualityArtwork
                    ? track.ArtworkUrl.Replace("large", "t500x500")
                    : track.ArtworkUrl.Replace("large", "t300x300"));
            }

            // This image does not support high resoultion
            return(track.ArtworkUrl);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Move to the specified base track.
        /// </summary>
        /// <param name="track"></param>
        public void MoveTo([CanBeNull] BaseTrack track)
        {
            if (track == null)
            {
                return;
            }

            // find the index of the track in the playlist
            var index = MediaPlaybackList.Items.ToList()
                        .FindIndex(item => item.Source.AsBaseTrack().TrackId ==
                                   track.TrackId);

            if (index == -1)
            {
                return;
            }

            // Move to the track
            MediaPlaybackList.MoveTo((uint)index);
        }
Ejemplo n.º 25
0
        public ViewTrack(BaseTrack baseTrack)
        {
            Name = baseTrack.Name;

            Id = baseTrack.Id;

            APIEndpointHRefForDetails = baseTrack.APIEndpointHRefForDetails;

            IsExplicit = baseTrack.IsExplicit;

            if (baseTrack.ExternalUrls.ContainsKey("spotify"))
            {
                ExternalUrl = baseTrack.ExternalUrls["spotify"];
            }

            if (!String.IsNullOrWhiteSpace(baseTrack.PreviewURL))
            {
                PreviewURL = baseTrack.PreviewURL;
            }
        }
        private static void DrawTrackMenu(AnimatedGameObject animatedGameObject, BaseTrack track)
        {
            var rect = new Rect(0, 0, 185f, RowHeight);

            if (EditorHelper.GetMouseDownRect(rect, 1))
            {
                var         mousePos  = Event.current.mousePosition;
                GenericMenu toolsMenu = new GenericMenu();
                toolsMenu.AddItem(new GUIContent("Remove Track"), false, OnRemoveTrack, new RemoveTrackHolder()
                {
                    Track = track, AnimatedGameObject = animatedGameObject
                });
                var animationTrack = track as AnimationTrack;
                if (animationTrack != null)
                {
                    toolsMenu.AddItem(new GUIContent("Generate State Machine"), false, OnGenerateTrack, animationTrack);
                }
                toolsMenu.DropDown(new Rect(mousePos.x, mousePos.y, 0, 0));
                GUIUtility.ExitGUI();
            }
        }
        private async void Instance_OnCurrentTrackChanged(BaseTrack newTrack)
        {
            await DispatcherHelper.ExecuteOnUIThreadAsync(async() =>
            {
                // Show a pane that says to start playing music
                if (newTrack == null)
                {
                    PlaybackGrid.Visibility      = Visibility.Collapsed;
                    StartPlaybackGrid.Visibility = Visibility.Visible;

                    return;
                }
                else
                {
                    PlaybackGrid.Visibility      = Visibility.Visible;
                    StartPlaybackGrid.Visibility = Visibility.Collapsed;
                }

                await SetupMediaElementAsync(newTrack);
            });
        }
        private static void DrawEmptyEvent(AnimatedGameObject animatedGameObject, BaseTrack track, Rect eventsRect, int startFrame, int endFrame, TimeLineParameters parameters)
        {
            var frameLength = parameters.MaxFrame - parameters.MinFrame;
            var x_dif       = eventsRect.width / frameLength;

            var startFr = startFrame - parameters.MinFrame;
            var start   = Mathf.Clamp(startFr, 0, frameLength);
            var end     = Mathf.Clamp(endFrame - startFr - parameters.MinFrame, 0, frameLength);
            var rect    = new Rect(start * x_dif, 0, end * x_dif, RowHeight);

            if (EditorHelper.GetMouseDownRect(rect, 1))
            {
                var         mousePos  = Event.current.mousePosition;
                GenericMenu toolsMenu = new GenericMenu();
                toolsMenu.AddItem(new GUIContent("Add new event"), false, OnAddEvent, new AddEventHolder()
                {
                    StartFrame = startFrame, EndFrame = endFrame, Track = track, AnimatedGameObject = animatedGameObject
                });
                toolsMenu.DropDown(new Rect(mousePos.x, mousePos.y, 0, 0));
                GUIUtility.ExitGUI();
            }
        }
Ejemplo n.º 29
0
        public async Task <UserActivity> UpdateActivityAsync(ISource source, BaseTrack track, IEnumerable <BaseSoundByteItem> playlist, string token, TimeSpan?timeSpan, bool isShuffled)
        {
            // Don't enable if windows timeline support is disabled
            if (!SettingsService.Instance.WindowsTimelineEnabled)
            {
                return(null);
            }

            // We do not support these items
            if (track.ServiceType == ServiceTypes.ITunesPodcast ||
                track.ServiceType == ServiceTypes.Local ||
                track.ServiceType == ServiceTypes.Unknown)
            {
                return(null);
            }

            var activity = await _channel.GetOrCreateUserActivityAsync("playback-" + SettingsService.Instance.SessionId);

            activity.FallbackUri = new Uri("https://soundbytemedia.com/pages/remote-subsystem");

            var continueText = @"Continue listening to " + track.Title.Replace('"', ' ') + " and " + playlist.Count() + " other songs.";

            activity.VisualElements.DisplayText = track.Title.Replace('"', ' ');
            activity.VisualElements.Description = continueText;

            var json = @"{""$schema"":""http://adaptivecards.io/schemas/adaptive-card.json"",""type"":""AdaptiveCard"",""backgroundImage"":""" + track.ArtworkUrl + @""",""version"": ""1.0"",""body"":[{""type"":""Container"",""items"":[{""type"":""TextBlock"",""text"":""" + track.Title.Replace('"', ' ') + @""",""weight"":""bolder"",""size"":""large"",""wrap"":true,""maxLines"":3},{""type"":""TextBlock"",""text"":""" + continueText + @""",""size"":""default"",""wrap"":true,""maxLines"":3}]}]}";

            activity.VisualElements.Content = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(json);

            // Set the activation url using shorthand protocol
            var protoUri = ProtocolHelper.EncodeTrackProtocolItem(new ProtocolHelper.TrackProtocolItem(source, new BaseSoundByteItem(track), playlist, token, timeSpan, isShuffled), true) + "&session=" + SettingsService.Instance.SessionId;

            activity.ActivationUri = new Uri(protoUri);

            await activity.SaveAsync();

            return(activity);
        }
Ejemplo n.º 30
0
        public PalletPhotocell(PalletPhotocellInfo info, BaseTrack conv) : base(info, conv)
        {
            PhotocellInfo = info;
            AssemblyInfo ai = new AssemblyInfo();

            conveyor = conv;

            photocellDisplay = new PalletPhotocellDisplay(new PhotocellDisplayInfo {
                width = info.width
            });
            photocellDisplay.ListSolutionExplorer       = false;
            photocellDisplay.OnPhotocellDisplayDeleted += photocellDisplay_OnPhotocellDisplayDeleted;

            Add(photocellDisplay, new Vector3(info.length / 2, 0, 0));
            sensor.OnEnter += sensor_OnEnter;
            sensor.OnLeave += sensor_OnLeave;
            sensor.Color    = Color.Green;
            sensor.Visible  = false;

            conv.TransportSection.Route.InsertActionPoint(sensor);

            OnNameChanged += PalletPhotocell_OnNameChanged;
        }
Ejemplo n.º 31
0
        public string EncodeActivityParameters(ISource <BaseTrack> source, BaseTrack track,
                                               IEnumerable <BaseTrack> playlist, string token)
        {
            // Conver to raw objects
            var currentTrack  = $"c={(int)track.ServiceType}-{track.TrackId}";
            var sourceName    = $"&s={source.GetType().Name}";
            var sourceDetails = $"&d={string.Join(',', source.GetParameters().Select(x => $"{x.Key}-{x.Value}"))}";
            var playlistToken = $"&t={token}";
            var tracks        = $"&p={string.Join(',', playlist.Select(x => $"{(int)x.ServiceType}-{x.TrackId}"))}";

            // If we don't have a token, we do not need to send the tracks
            // unless this is a dummy source. This is because our source can
            // load the first set of items.
            if (string.IsNullOrEmpty(token) && source.GetType() != typeof(DummyTrackSource))
            {
                tracks = "";
            }

            // Format into url
            var data = $"{currentTrack}{sourceName}{sourceDetails}{playlistToken}{tracks}";

            return(Uri.EscapeDataString(StringHelpers.CompressString(data)));
        }
Ejemplo n.º 32
0
        public DematicCommunicationPoint(DematicCommunicationPointInfo info, BaseTrack conv) : base(info, conv)
        {
            commPointInfo = info as DematicCommunicationPointInfo;

            commCylinder             = new Cylinder(Color.DarkOrange, 0.15f, 0.08f, 20);
            commCylinder.Pitch       = (float)Math.PI / 2;
            commCylinder.Selectable  = true;
            commCylinder.Color       = LoadColour;
            commCylinder.OnSelected += commPoint_OnSelected;
            Add((RigidPart)commCylinder);

            Font font = new Font("Helvetica", 1f, FontStyle.Bold, GraphicsUnit.Pixel);

            nameLabel       = new Text3D(Color.FromArgb(60, 60, 60), 0.2f, 0.05f, font);
            nameLabel.Text  = "  " + Name;
            nameLabel.Pitch = (float)Math.PI / 2;
            nameLabel.Roll  = Trigonometry.Angle2Rad(90);
            Add((RigidPart)nameLabel);
            nameLabel.LocalPosition = commCylinder.LocalPosition + new Vector3(0.065f, 0.05f, 0);
            nameLabel.OnSelected   += commPoint_OnSelected;

            apCommPoint.Distance = info.distance;
            apCommPoint.Edge     = ActionPoint.Edges.Leading;
            apCommPoint.OnEnter += new ActionPoint.EnterEvent(apCommPoint_OnEnter);
            apCommPoint.Visible  = false;
            apCommPoint.Name     = commPointInfo.name;

            conv.TransportSection.Route.InsertActionPoint(apCommPoint);
            ShowLabel  = info.showLabel;
            LabelAngle = info.labelAngle;

            ControllerProperties = StandardCase.SetMHEControl(commPointInfo, this);
            if (Controller == null)
            {
                ControllerName = "No Controller"; //This will set the default value of controller dropdown box
            }
        }
Ejemplo n.º 33
0
 private void connectTracks(BaseTrack x, BaseTrack y)
 {
     x.Next = y;
         y.Previous = x;
 }
Ejemplo n.º 34
0
    public void initializeBoard()
    {
        char[][] boardArray = new char[8][];

            boardArray[0] = "#########D##".ToCharArray();
            boardArray[1] = "           #".ToCharArray();
            boardArray[2] = "W### ##### #".ToCharArray();
            boardArray[3] = "   C#I   C##".ToCharArray();
            boardArray[4] = "W### ## ##  ".ToCharArray();
            boardArray[5] = "      C#I   ".ToCharArray();
            boardArray[6] = "W###### ####".ToCharArray();
            boardArray[7] = "LLLLLLLL####".ToCharArray();
            board.FirstRow = new LinkedList<LinkedList<BaseTrack>>();
            for (int i = 0; i < boardArray.Length; i++)
            {
                board.FirstRow.AddLast(new LinkedList<BaseTrack>());

                for (int j = 0; j < boardArray[i].Length; j++)
                {
                    BaseTrack track = null;
                    switch(boardArray[i][j]) {
                        case '#':
                            track = new BaseTrack();
                            break;
                        case 'D':
                            track = new Dock(board);
                            break;
                        case ' ':
                            track = new EmptyVoid();
                            break;
                        case 'W':
                            track = new Warehouse();
                            break;
                        case 'C':
                            track = new ConvergingSwitch();
                            break;
                        case 'I':
                            track = new DivergingSwitch();
                            break;
                        case 'L':
                            track = new SafeTrack();
                            break;
                    }

                    board.FirstRow.Last.Value.AddLast(track);
                }
            }

            connectTracks(getAtPosition(2,0), getAtPosition(2,1));
            connectTracks(getAtPosition(2,1), getAtPosition(2,2));
            connectTracks(getAtPosition(2,2), getAtPosition(2,3));
            connectTracks(getAtPosition(3,3), getAtPosition(3,4));
            connectTracks(getAtPosition(3,4), getAtPosition(3,5));
            connectTracks(getAtPosition(3,5), getAtPosition(2,5));
            connectTracks(getAtPosition(2,5), getAtPosition(2,6));
            connectTracks(getAtPosition(2,6), getAtPosition(2,7));
            connectTracks(getAtPosition(2,7), getAtPosition(2,8));
            connectTracks(getAtPosition(2,8), getAtPosition(2,9));
            connectTracks(getAtPosition(2,9), getAtPosition(3,9));
            connectTracks(getAtPosition(3,9), getAtPosition(3,10));
            connectTracks(getAtPosition(3,10), getAtPosition(3,11));
            connectTracks(getAtPosition(3,11), getAtPosition(2,11));
            connectTracks(getAtPosition(2,11), getAtPosition(1,11));
            connectTracks(getAtPosition(1,11), getAtPosition(0,11));
            connectTracks(getAtPosition(0,11), getAtPosition(0,10));
            connectTracks(getAtPosition(0,10), getAtPosition(0,9));
            connectTracks(getAtPosition(0,9), getAtPosition(0,8));
            connectTracks(getAtPosition(0,8), getAtPosition(0,7));
            connectTracks(getAtPosition(0,7), getAtPosition(0,6));
            connectTracks(getAtPosition(0,6), getAtPosition(0,5));
            connectTracks(getAtPosition(0,5), getAtPosition(0,4));
            connectTracks(getAtPosition(0,4), getAtPosition(0,3));
            connectTracks(getAtPosition(0,3), getAtPosition(0,2));
            connectTracks(getAtPosition(0,2), getAtPosition(0,1));
            connectTracks(getAtPosition(0,1), getAtPosition(0,0));

            connectTracks(getAtPosition(4,0), getAtPosition(4,1));
            connectTracks(getAtPosition(4,1), getAtPosition(4,2));
            connectTracks(getAtPosition(4,2), getAtPosition(4,3));
            connectTracks(getAtPosition(4,3), getAtPosition(3,3));

            connectTracks(getAtPosition(4,5), getAtPosition(4,6));
            connectTracks(getAtPosition(4,8), getAtPosition(4,9));

            connectTracks(getAtPosition(6,0), getAtPosition(6,1));
            connectTracks(getAtPosition(6,1), getAtPosition(6,2));
            connectTracks(getAtPosition(6,2), getAtPosition(6,3));
            connectTracks(getAtPosition(6,3), getAtPosition(6,4));
            connectTracks(getAtPosition(6,4), getAtPosition(6,5));
            connectTracks(getAtPosition(6,5), getAtPosition(6,6));
            connectTracks(getAtPosition(6,6), getAtPosition(5,6));

            connectTracks(getAtPosition(5,6), getAtPosition(5,7));
            connectTracks(getAtPosition(5,7), getAtPosition(5,8));
            connectTracks(getAtPosition(5,8), getAtPosition(6,8));

            connectTracks(getAtPosition(6,8), getAtPosition(6,9));
            connectTracks(getAtPosition(6,9), getAtPosition(6,10));
            connectTracks(getAtPosition(6,10), getAtPosition(6,11));

            connectTracks(getAtPosition(6,11), getAtPosition(7,11));
            connectTracks(getAtPosition(7,11), getAtPosition(7,10));
            connectTracks(getAtPosition(7,10), getAtPosition(7,9));
            connectTracks(getAtPosition(7,9), getAtPosition(7,8));
            connectTracks(getAtPosition(7,8), getAtPosition(7,7));
            connectTracks(getAtPosition(7,7), getAtPosition(7,6));
            connectTracks(getAtPosition(7,6), getAtPosition(7,5));
            connectTracks(getAtPosition(7,5), getAtPosition(7,4));
            connectTracks(getAtPosition(7,4), getAtPosition(7,3));
            connectTracks(getAtPosition(7,3), getAtPosition(7,2));
            connectTracks(getAtPosition(7,2), getAtPosition(7,1));
            connectTracks(getAtPosition(7,1), getAtPosition(7,0));

            //Inactives
            getAtPosition(2,3).Next = getAtPosition(3,3); //2,3 is inactive
            getAtPosition(4,6).Next = getAtPosition(5,6); //4,6 is inactive
            getAtPosition(4,9).Next = getAtPosition(3,9); //4,9 is inactive
            getAtPosition(4,8).Previous = getAtPosition(5,8); //4,8 is inactive
            getAtPosition(4,5).Previous = getAtPosition(3,5); //4,5 is inactive

            ConvergingSwitch cSwitch = (ConvergingSwitch)getAtPosition(3,3);
            cSwitch.IsUp = false;
            cSwitch.Inactive = getAtPosition(2,3);
            board.Switches[0] = cSwitch;

            cSwitch = (ConvergingSwitch)getAtPosition(3, 9);
            cSwitch.Inactive = getAtPosition(4, 9);
            board.Switches[4] = cSwitch;

            cSwitch = (ConvergingSwitch)getAtPosition(5, 6);
            cSwitch.IsUp = false;
            cSwitch.Inactive = getAtPosition(4, 6);
            board.Switches[2] = cSwitch;

            DivergingSwitch dSwitch = (DivergingSwitch)getAtPosition(3, 5);
            dSwitch.Inactive = getAtPosition(4, 5);
            board.Switches[1] = dSwitch;

            dSwitch = (DivergingSwitch)getAtPosition(5, 8);
            dSwitch.IsUp = false;
            dSwitch.Inactive = getAtPosition(4, 8);
            board.Switches[3] = dSwitch;

            board.Warehouses[0] = (Warehouse)getAtPosition(2,0);
            board.Warehouses[1] = (Warehouse)getAtPosition(4, 0);
            board.Warehouses[2] = (Warehouse)getAtPosition(6, 0);
    }