Esempio n. 1
0
        public async ValueTask <ChannelTemplate <T>?> ExecuteAsync(ChannelTemplate <T> template, IServiceProvider serviceProvider,
                                                                   CancellationToken ct)
        {
            Validate <Validator> .It(this);

            var factory = serviceProvider.GetRequiredService <IChannelTemplateFactory <T> >();

            if (template.Languages.ContainsKey(Language))
            {
                throw new DomainObjectConflictException(Language);
            }

            var newLanguages = new Dictionary <string, T>(template.Languages)
            {
                [Language] = await factory.CreateInitialAsync(template.Kind, ct)
            };

            var newTemplate = template with
            {
                Languages = newLanguages.ToReadonlyDictionary()
            };

            return(newTemplate);
        }
    }
Esempio n. 2
0
        private void RankListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ChannelTemplate template = RankListBox.SelectedItem as ChannelTemplate;

            if (template != null)
            {
                VideoViewModel videoData = new VideoViewModel
                {
                    width     = 150,
                    hight     = 130,
                    name      = template.name,
                    jumpType  = template.jumpType,
                    subjectId = template.subjectId,
                    picUrl    = template.picUrl,
                    playUrl   = template.playUrl,
                    tag       = template.tag,
                    desc      = template.desc,
                    videoId   = template.videoId,
                    hotDegree = template.hotDegree,
                    webUrl    = template.webUrl,
                    rank      = template.rank
                };
                OperationImageTap(videoData);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 创建多个ImagesView的Grid
        /// </summary>
        /// <param name="list">数据列表List<ChannelTemplate></param>
        /// <param name="gridImageHeight">每个imageView的高度</param>
        /// <param name="lineCount">每行显示多少个imageView</param>
        private void CreateNorLandscapeImages(List <ChannelTemplate> list, double gridImageHeight, int lineCount)
        {
            Grid myGrid = new Grid();

            myGrid.Height = gridImageHeight * Math.Ceiling((double)list.Count / lineCount);
            myGrid.HorizontalAlignment = HorizontalAlignment.Center;
            myGrid.ShowGridLines       = false;
            // Define the Columns
            for (int i = 0; i < lineCount; i++)
            {
                ColumnDefinition colDef = new ColumnDefinition();
                myGrid.ColumnDefinitions.Add(colDef);
            }
            for (int i = 0; i < Math.Ceiling((double)list.Count / lineCount); i++)
            {
                RowDefinition rowDef = new RowDefinition();
                myGrid.RowDefinitions.Add(rowDef);
            }


            for (int i = 0; i < list.Count; i++)
            {
                ChannelTemplate template   = list[i];
                double          imageWidth = (double)(PopupManager.screenWidth - 20 - 5 * lineCount) / lineCount;
                Grid            imageGrid  = CreateImageView(imageWidth, template, gridImageHeight - 10);
                imageGrid.Margin = new Thickness(5, 5, 5, 5);
                Grid.SetColumn(imageGrid, i % lineCount);
                Grid.SetRow(imageGrid, i / lineCount);
                myGrid.Children.Add(imageGrid);
            }
            stackPanel.Children.Add(myGrid);
        }
Esempio n. 4
0
 //this recordchange handler only is run during inital game sync phase
 void HandleDidChangeRecordSync(string arg1, ChannelTemplate arg2, IDictionary arg3, string[] arg4)
 {
     Debug.Log("HH is syncing");
     if (arg2.receiver_id == clientID)                                //if this message applies to us (the receiver_id is us)
     {
         if ((int)sessionSyncPosition > (int)sessionStatuses.running) //when game is running, we can stop setup
         {
             Debug.Log("done with sync");
             channelCollection.DidChangeRecord -= HandleDidChangeRecordSync;                 //remove this handler
         }
         else if (arg2.payload == sessionSyncPosition.ToString())                            //if the channel broadcasts what we are expecting
         {
             StartCoroutine(callReportToTabletopClient(clientSyncPosition.ToString()));
             clientSyncPosition++;
             sessionSyncPosition++;
         }
         else
         {
             Debug.LogError("Uh oh! Sync routine error, expecting: " + sessionSyncPosition.ToString() + ", recieved: " + arg2.payload + " on client step: " + clientSyncPosition.ToString());
         }
     }
     else                    //message not directed to us
     {
         Debug.LogError("this message is not directed at us, senderID: " + arg2.sender_id + ", receiverID: '" + arg2.receiver_id + "', our clientID: '" + clientID + "'");
     }
 }
Esempio n. 5
0
        private Grid CreateRankImageView(double width, ChannelTemplate template, double height)
        {
            VideoViewModel videoData = new VideoViewModel
            {
                name      = template.name,
                jumpType  = template.jumpType,
                subjectId = template.subjectId,
                picUrl    = template.picUrl,
                playUrl   = template.playUrl,
                tag       = template.tag,
                desc      = template.desc,
                videoId   = template.videoId,
                hotDegree = template.hotDegree,
                webUrl    = template.webUrl,
                rank      = template.rank
            };

            if (string.IsNullOrEmpty(rankXaml))
            {
                using (Stream stream = Application.GetResourceStream(new Uri("/MangGuoTv;component/Views/RankImageView.xaml", UriKind.Relative)).Stream)
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        rankXaml = reader.ReadToEnd();
                    }
                }
            }
            Grid imageGrid = (Grid)XamlReader.Load(rankXaml);

            imageGrid.Width       = width;
            imageGrid.Height      = height;
            imageGrid.DataContext = videoData;
            imageGrid.Tap        += new EventHandler <System.Windows.Input.GestureEventArgs>(GridImage_Tap);
            return(imageGrid);
        }
Esempio n. 6
0
        public async ValueTask <ChannelTemplate <T>?> ExecuteAsync(ChannelTemplate <T> template, IServiceProvider serviceProvider,
                                                                   CancellationToken ct)
        {
            var newTemplate = template;

            if (Kind != null && !string.Equals(Kind, template.Name, StringComparison.Ordinal))
            {
                newTemplate = newTemplate with
                {
                    Kind = Kind.Trim()
                };
            }

            if (Language != null)
            {
                var factory = serviceProvider.GetRequiredService <IChannelTemplateFactory <T> >();

                newTemplate = newTemplate with
                {
                    Languages = new Dictionary <string, T>(template.Languages)
                    {
                        [Language] = await factory.CreateInitialAsync(newTemplate.Kind, ct)
                    }.ToReadonlyDictionary()
                };
            }

            return(newTemplate);
        }
    }
}
Esempio n. 7
0
 //Record change handler for initial game sync
 void HandleDidChangeRecordSync(string arg1, ChannelTemplate arg2, IDictionary arg3, string[] arg4)
 {
     if (arg2.receiver_id == clientID)               //if this message applies to us (the receiverID is us)
     {
         clientSyncPosition = (clientStatuses)System.Enum.Parse(typeof(clientStatuses), arg2.payload);
         Debug.Log("client Sync position is: " + clientSyncPosition.ToString());
         sessionSyncPosition = (sessionStatuses)(int)(clientSyncPosition + 1);
         Debug.Log("session Sync position is: " + sessionSyncPosition.ToString());
         if ((int)sessionSyncPosition > (int)sessionStatuses.running)                        //last stage of sync is 'running'
         //don't broadcast anything to the client, they are running
         {
             playersSynced++;
             Debug.Log("One more client is fully synced!" + sessionSyncPosition + ", total: " + playersSynced);
             if (numberOfPlayers != playersSynced)
             {
                 Debug.Log("number of players != playersSynced! numplayers: " + numberOfPlayers + ", playersSynced: " + playersSynced);
             }
         }
         else
         {
             Debug.Log("recieved message for sync: " + arg2.payload + "; on state: " + sessionSyncPosition);
             StartCoroutine(callUpdateSessionStatus(sessionSyncPosition.ToString()));
         }
     }
     else
     {
         Debug.Log("this message is not directed at us, senderID: " + arg2.sender_id + ", receiverID: '" + arg2.receiver_id + "', our clientID: '" + clientID + "'");
     }
 }
Esempio n. 8
0
        public ValueTask <ChannelTemplate <T>?> ExecuteAsync(ChannelTemplate <T> template, IServiceProvider serviceProvider,
                                                             CancellationToken ct)
        {
            Validate <Validator> .It(this);

            if (!template.Languages.ContainsKey(Language))
            {
                return(default);
Esempio n. 9
0
        public async Task CreateAsync(ChannelTemplate channelTemplate, bool saveChanges = false)
        {
            await Context.AddAsync(channelTemplate);

            if (saveChanges)
            {
                await Context.SaveChangesAsync();
            }
        }
Esempio n. 10
0
        //private void Image_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        //{
        //    ChannelTemplate template = (sender as Image).DataContext as ChannelTemplate;
        //    OperationImageTap(template);

        //}
        private void OperationImageTap(ChannelTemplate template)
        {
            long memory      = DeviceStatus.ApplicationCurrentMemoryUsage / (1024 * 1024);
            long memoryLimit = DeviceStatus.ApplicationMemoryUsageLimit / (1024 * 1024);
            long memoryMax   = DeviceStatus.ApplicationPeakMemoryUsage / (1024 * 1024);

            System.Diagnostics.Debug.WriteLine("当前内存使用情况:" + memory.ToString() + " MB 当前最大内存使用情况: " + memoryMax.ToString() + "MB  当前可分配最大内存: " + memoryLimit.ToString() + "  MB");
            switch (template.jumpType)
            {
            case "videoPlayer":
                App.PlayerModel.VideoId     = template.videoId;
                App.PlayerModel.currentType = ViewModels.PlayerViewModel.PlayType.VideoType;
                CallbackManager.currentPage.NavigationService.Navigate(new Uri(CommonData.PlayerPageName, UriKind.Relative));
                break;

            case "subjectPage":
                MoreSubject.subjectId     = template.subjectId;
                MoreSubject.speicalName   = template.name;
                MoreSubject.isMoreChannel = false;
                CallbackManager.currentPage.NavigationService.Navigate(new Uri(CommonData.SpecialPageName, UriKind.Relative));
                break;

            case "videoLibrary":
                if (channel != null)
                {
                    MoreChannelInfo.typeId = channel.libId;
                    MoreChannelInfo.name   = channel.channelName;
                    CallbackManager.currentPage.NavigationService.Navigate(new Uri(CommonData.MoreChannelPageName, UriKind.Relative));
                }
                break;

            case "webView":
                WebBrowserTask task = new WebBrowserTask();
                task.Uri = new Uri(template.webUrl, UriKind.Absolute);
                try
                {
                    task.Show();
                }
                catch (Exception e)
                {
                }
                break;

            case "livePlayer":
            //LivePlayer.liveUrl = template.playUrl;
            //CallbackManager.currentPage.NavigationService.Navigate(new Uri(CommonData.LivePlayerPage, UriKind.Relative));
            // break;
            case "concertLivePlayer":
                App.ShowToast("抱歉,暂时不支持直播功能");
                break;

            default:
                System.Diagnostics.Debug.WriteLine("该播放类型暂时未实现" + template.jumpType);
                App.ShowToast("该播放类型暂时未实现" + template.jumpType);
                break;
            }
        }
Esempio n. 11
0
        private void MoreChannelSubject(object sender, System.Windows.Input.GestureEventArgs e)
        {
            ChannelTemplate template = (sender as TextBlock).DataContext as ChannelTemplate;

            MoreSubject.subjectId     = template.subjectId;
            MoreSubject.speicalName   = template.name;
            MoreSubject.isMoreChannel = false;
            CallbackManager.currentPage.NavigationService.Navigate(new Uri(CommonData.SpecialPageName, UriKind.Relative));
        }
Esempio n. 12
0
        private Grid CreateImageView(double width, ChannelTemplate template, double height)
        {
            Grid imgGrid = new Grid();

            imgGrid.Width  = width;
            imgGrid.Height = height;
            Grid imgContnt = new Grid();

            imgContnt.Width  = width;
            imgContnt.Height = height - 50;
            Image videoImage = new Image();

            videoImage.Width  = width;
            videoImage.Height = height - 50;
            BitmapImage videoImageSource = new BitmapImage(new Uri(template.picUrl, UriKind.RelativeOrAbsolute));

            //videoImageSource.DecodePixelWidth = videoImageSource.PixelWidth / 2;
            //videoImageSource.DecodePixelHeight = videoImageSource.PixelHeight / 2;
            videoImage.Source              = videoImageSource;
            videoImage.VerticalAlignment   = VerticalAlignment.Top;
            videoImage.HorizontalAlignment = HorizontalAlignment.Center;
            imgContnt.Children.Add(videoImage);
            if (!string.IsNullOrEmpty(template.tag))
            {
                Border tagBorder = new Border();
                tagBorder.Background          = new SolidColorBrush(Color.FromArgb(255, 106, 95, 87));
                tagBorder.Opacity             = 0.7;
                tagBorder.VerticalAlignment   = VerticalAlignment.Bottom;
                tagBorder.HorizontalAlignment = HorizontalAlignment.Right;
                tagBorder.Margin = new Thickness(0, 0, 10, 30);
                TextBlock tagText = new TextBlock();
                tagText.Text    = template.tag;
                tagBorder.Child = tagText;
                imgContnt.Children.Add(tagBorder);
            }
            imgGrid.Children.Add(imgContnt);
            StackPanel descPanel = new StackPanel();

            descPanel.VerticalAlignment = VerticalAlignment.Bottom;
            TextBlock nameText = new TextBlock();

            nameText.Text         = template.name;
            nameText.TextWrapping = TextWrapping.Wrap;
            descPanel.Children.Add(nameText);
            TextBlock descText = new TextBlock();

            descText.Text         = template.desc;
            descText.FontSize     = 15;
            descText.Foreground   = new SolidColorBrush(Color.FromArgb(255, 106, 95, 87));
            descText.TextWrapping = TextWrapping.Wrap;
            descPanel.Children.Add(descText);
            imgGrid.Children.Add(descPanel);
            imgGrid.DataContext = template;
            imgGrid.Tap        += new EventHandler <System.Windows.Input.GestureEventArgs>(GridImage_Tap);
            return(imgGrid);
        }
Esempio n. 13
0
        public async Task UpsertAsync(ChannelTemplate <T> template, string?oldEtag = null,
                                      CancellationToken ct = default)
        {
            using (Telemetry.Activities.StartActivity("MongoDbChannelTemplateRepository/UpsertAsync"))
            {
                var document = MongoDbChannelTemplate <T> .FromChannelTemplate(template);

                await UpsertDocumentAsync(document.DocId, document, oldEtag, ct);
            }
        }
Esempio n. 14
0
        public static MongoDbChannelTemplate <T> FromChannelTemplate(ChannelTemplate <T> template)
        {
            var docId = CreateId(template.AppId, template.Id);

            var result = new MongoDbChannelTemplate <T>
            {
                DocId = docId,
                Doc   = template,
                Etag  = GenerateEtag()
            };

            return(result);
        }
Esempio n. 15
0
        private Grid CreateImageView(double width, ChannelTemplate template, double height)
        {
            VideoViewModel videoData = new VideoViewModel
            {
                name      = template.name,
                jumpType  = template.jumpType,
                subjectId = template.subjectId,
                picUrl    = template.picUrl,
                playUrl   = template.playUrl,
                tag       = template.tag,
                desc      = template.desc,
                videoId   = template.videoId,
                hotDegree = template.hotDegree,
                webUrl    = template.webUrl,
                rank      = template.rank
            };

            if (string.IsNullOrEmpty(xaml))
            {
                using (Stream stream = Application.GetResourceStream(new Uri("/MangGuoTv;component/Views/ImageView.xaml", UriKind.Relative)).Stream)
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        xaml = reader.ReadToEnd();
                    }
                }
            }

            Grid imageGrid = (Grid)XamlReader.Load(xaml);

            imageGrid.Width       = width;
            imageGrid.Height      = height;
            imageGrid.DataContext = videoData;
            imageGrid.Tap        += new EventHandler <System.Windows.Input.GestureEventArgs>(GridImage_Tap);
            return(imageGrid);
            //Grid imgGrid = new Grid();
            //imgGrid.Width = width;
            //imgGrid.Height = height;
            //Image videoImage = new Image();
            //BitmapImage videoImageSource = new BitmapImage(new Uri(template.picUrl, UriKind.RelativeOrAbsolute));
            //videoImageSource.DecodePixelHeight = ((int)height - 50);
            //videoImageSource.DecodePixelWidth = ((int)width)/2;
            //videoImage.Source = videoImageSource;
            //videoImage.VerticalAlignment = VerticalAlignment.Top;
            //videoImage.HorizontalAlignment = HorizontalAlignment.Center;
            //imgGrid.Children.Add(videoImage);
            //imgGrid.DataContext = template;
            //imgGrid.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(GridImage_Tap);
            //return imgGrid;
        }
Esempio n. 16
0
        public static ChannelTemplateDetailsDto <T> FromDomainObject <TInput>(ChannelTemplate <TInput> source, Func <TInput, T> factory)
        {
            var result = SimpleMapper.Map(source, new ChannelTemplateDetailsDto <T>());

            result.Languages = new Dictionary <string, T>();

            if (source.Languages != null)
            {
                foreach (var(key, value) in source.Languages)
                {
                    result.Languages[key] = factory(value);
                }
            }

            return(result);
        }
Esempio n. 17
0
        public async ValueTask <ChannelTemplate <T>?> ExecuteAsync(ChannelTemplate <T> template, IServiceProvider serviceProvider,
                                                                   CancellationToken ct)
        {
            var newTemplate = template;

            if (Languages != null)
            {
                var languages = new Dictionary <string, T>();

                var factory = serviceProvider.GetRequiredService <IChannelTemplateFactory <T> >();

                foreach (var(key, value) in Languages)
                {
                    languages[key] = await factory.ParseAsync(value, ct);
                }

                newTemplate = newTemplate with
                {
                    Languages = languages.ToReadonlyDictionary()
                };
            }

            if (Is.Changed(Name, template.Name))
            {
                newTemplate = newTemplate with
                {
                    Name = Name.Trim()
                };
            }

            if (Is.Changed(Primary, template.Primary))
            {
                newTemplate = newTemplate with
                {
                    Primary = Primary.Value
                };
            }

            return(newTemplate);
        }
    }
}
Esempio n. 18
0
        private Grid CreateRankImageView(double width, ChannelTemplate template, double height)
        {
            if (string.IsNullOrEmpty(rankXaml))
            {
                using (Stream stream = Application.GetResourceStream(new Uri("/MangGuoTv;component/Views/RankImageView.xaml", UriKind.Relative)).Stream)
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        rankXaml = reader.ReadToEnd();
                    }
                }
            }
            Grid imageGrid = (Grid)XamlReader.Load(rankXaml);

            imageGrid.Width       = width;
            imageGrid.Height      = height;
            imageGrid.DataContext = template;
            imageGrid.Tap        += new EventHandler <System.Windows.Input.GestureEventArgs>(GridImage_Tap);
            return(imageGrid);
        }
Esempio n. 19
0
        /// <summary>
        /// Opens a channel of the given type.
        /// </summary>
        /// <param name="channelTemplate">The channel type to open.</param>
        /// <exception cref="InvalidChannelTypeException">
        ///     Thrown if <paramref name="channelTemplate"/> is <see cref="ChannelTemplate.None"/>.
        /// </exception>
        private void OpenChannel(ChannelTemplate channelTemplate)
        {
            {
                Lokad.Enforce.With <InvalidChannelTypeException>(
                    channelTemplate != ChannelTemplate.None,
                    Resources.Exceptions_Messages_AChannelTypeMustBeDefined);
            }

            if (HasChannelFor(channelTemplate))
            {
                return;
            }

            lock (m_Lock)
            {
                var pair = m_ChannelBuilder(channelTemplate, m_Id);
                m_OpenConnections.Add(channelTemplate, pair);
                pair.Item1.OpenChannel();
            }
        }
Esempio n. 20
0
        public Task <ChannelTemplate <T> > UpsertAsync(string appId, string?id, ICommand <ChannelTemplate <T> > command,
                                                       CancellationToken ct = default)
        {
            Guard.NotNullOrEmpty(appId);
            Guard.NotNull(command);

            if (string.IsNullOrWhiteSpace(id))
            {
                id = Guid.NewGuid().ToString();
            }

            return(Updater.UpdateRetriedAsync(5, async() =>
            {
                var(template, etag) = await repository.GetAsync(appId, id, ct);

                if (template == null)
                {
                    if (!command.CanCreate)
                    {
                        throw new DomainObjectNotFoundException(id);
                    }

                    template = new ChannelTemplate <T>(appId, id, clock.GetCurrentInstant());
                }

                var newTemplate = await command.ExecuteAsync(template, serviceProvider, ct);

                if (newTemplate == null || ReferenceEquals(template, newTemplate))
                {
                    return template;
                }

                newTemplate = newTemplate with
                {
                    LastUpdate = clock.GetCurrentInstant()
                };

                await repository.UpsertAsync(newTemplate, etag, ct);

                return newTemplate;
            }));
Esempio n. 21
0
        private void StartChanneling(MessageTemplate template, NetIncomingMessage message)
        {
            ChannelTemplate ct = Newtonsoft.Json.JsonConvert.DeserializeObject <ChannelTemplate>(template.JsonMessage);

            if (ct.ChannelType.Equals(ChannelType.Ability))
            {
                AbilityHead     ability   = AbilityContainer.GetAbilityByName(ct.ChannelName);
                CharacterPlayer character = MapContainer.FindCharacterByID(message.SenderConnection.RemoteUniqueIdentifier);
                Entity          entity    = Scene.FindEntity(character._name);
                PlayerComponent pc        = entity.GetComponent <PlayerComponent>();
                if (pc != null && !pc.isChanneling)
                {
                    if (ability != null)
                    {
                        entity.AddComponent(new DamageChannelingComponent(pc, ability.ChannelTime, ability));
                    }
                    else
                    {
                        entity.AddComponent(new ChannelingComponent(pc, 4));
                    }
                }
            }
        }
Esempio n. 22
0
        private void GridImage_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            ChannelTemplate template = (sender as Grid).DataContext as ChannelTemplate;

            OperationImageTap(template);
        }
Esempio n. 23
0
 private bool HasChannelFor(ChannelTemplate channelTemplate)
 {
     return(m_OpenConnections.ContainsKey(channelTemplate));
 }
Esempio n. 24
0
        /// <summary>
        /// Gets the connection information for the channel of a given type created by the current application.
        /// </summary>
        /// <param name="protocolVersion">The version of the protocol for which the connection information is required.</param>
        /// <param name="channelTemplate">The type of channel for which the connection information is required.</param>
        /// <returns>
        /// A tuple containing the <see cref="EndpointId"/>, the <see cref="Uri"/> of the message channel and the
        /// <see cref="Uri"/> of the data channel; returns <see langword="null" /> if no channel of the given type exists.
        /// </returns>
        public Tuple <EndpointId, Uri, Uri> LocalConnectionFor(Version protocolVersion, ChannelTemplate channelTemplate)
        {
            Tuple <EndpointId, Uri, Uri> result = null;

            if (m_OpenConnections.ContainsKey(channelTemplate))
            {
                var connection = m_OpenConnections[channelTemplate].Item1.LocalConnectionPointForVersion(protocolVersion);
                if (connection == null)
                {
                    return(null);
                }

                result = new Tuple <EndpointId, Uri, Uri>(m_Id, connection.MessageAddress, connection.DataAddress);
            }

            return(result);
        }
Esempio n. 25
0
        private Tuple <IProtocolChannel, IDirectIncomingMessages> ChannelInformationForType(ChannelTemplate connection)
        {
            Tuple <IProtocolChannel, IDirectIncomingMessages> channel = null;

            lock (m_Lock)
            {
                if (m_OpenConnections.ContainsKey(connection))
                {
                    channel = m_OpenConnections[connection];
                }

                return(channel);
            }
        }
 //this recordchange handler only is run during inital game sync phase
 void HandleDidChangeRecordSync(string arg1, ChannelTemplate arg2, IDictionary arg3, string[] arg4)
 {
     Debug.Log ("HH is syncing");
     if (arg2.receiver_id == clientID) {	//if this message applies to us (the receiver_id is us)
         if ((int)sessionSyncPosition > (int)sessionStatuses.running) {	//when game is running, we can stop setup
             Debug.Log ("done with sync");
             channelCollection.DidChangeRecord -= HandleDidChangeRecordSync;	//remove this handler
         } else if (arg2.payload == sessionSyncPosition.ToString ()) {		//if the channel broadcasts what we are expecting
             StartCoroutine (callReportToTabletopClient (clientSyncPosition.ToString ()));
             clientSyncPosition++;
             sessionSyncPosition++;
         } else {
             Debug.LogError ("Uh oh! Sync routine error, expecting: " + sessionSyncPosition.ToString () + ", recieved: " + arg2.payload + " on client step: " + clientSyncPosition.ToString ());
         }
     } else {	//message not directed to us
         Debug.LogError ("this message is not directed at us, senderID: " + arg2.sender_id + ", receiverID: '" + arg2.receiver_id + "', our clientID: '" + clientID + "'");
     }
 }
 /// <summary>
 /// Returns the URI of the local entry channel for the given channel template.
 /// </summary>
 /// <param name="template">The channel template for which the entry channel should be provided.</param>
 /// <returns>The URI of the local entry channel.</returns>
 public Uri EntryChannel(ChannelTemplate template)
 {
     return(m_EntryChannel(template));
 }
 //Record change handler for initial game sync
 void HandleDidChangeRecordSync(string arg1, ChannelTemplate arg2, IDictionary arg3, string[] arg4)
 {
     if (arg2.receiver_id == clientID) {	//if this message applies to us (the receiverID is us)
         clientSyncPosition = (clientStatuses) System.Enum.Parse (typeof(clientStatuses), arg2.payload);
         Debug.Log ("client Sync position is: " + clientSyncPosition.ToString());
         sessionSyncPosition = (sessionStatuses)(int)(clientSyncPosition + 1);
         Debug.Log ("session Sync position is: " + sessionSyncPosition.ToString());
         if ((int)sessionSyncPosition > (int)sessionStatuses.running) {		//last stage of sync is 'running'
             //don't broadcast anything to the client, they are running
             playersSynced++;
             Debug.Log ("One more client is fully synced!" + sessionSyncPosition + ", total: " + playersSynced);
             if (numberOfPlayers != playersSynced) {
                 Debug.Log ("number of players != playersSynced! numplayers: " + numberOfPlayers + ", playersSynced: " + playersSynced);
             }
         } else {
             Debug.LogError ("recieved message for sync: " + arg2.payload + "; on state: " + sessionSyncPosition);
             StartCoroutine (callUpdateSessionStatus (sessionSyncPosition.ToString ()));
         }
     } else {
         Debug.LogError ("this message is not directed at us, senderID: " + arg2.sender_id + ", receiverID: '" + arg2.receiver_id + "', our clientID: '" + clientID + "'");
     }
 }
Esempio n. 29
0
        //TODO: Change to customizable keybindings later
        private Keys[] KeyboardChange()
        {
            KeyboardState newState         = Input.CurrentKeyboardState;
            KeyboardState OldKeyboardState = Input.PreviousKeyboardState;
            List <Keys>   keys             = new List <Keys>();

            if (AbiliyCoolDown > 1)
            {
                foreach (var KeyBind in KeyBindContainer.KeyBinds)
                {
                    if (newState.IsKeyDown(KeyBind.BindedKey) && OldKeyboardState.IsKeyUp(KeyBind.BindedKey) && KeyBind.BindedAbilitityID != -1 && Scene.GetSceneComponent <ChannelBarComponent>() == null)
                    {
                        AbilityHead     ability = KeyBind.GetAbility();
                        MessageTemplate template;
                        ChannelTemplate ct = new ChannelTemplate(KeyBind.GetAbility().AbilityName, ChannelType.Ability);
                        if ((Scene as MainScene).UICanvas.Stage.FindAllElementsOfType <TargetWindow>() != null)
                        {
                            if (ability.ChannelTime > 0 && targeting)
                            {
                                template = new MessageTemplate(ct.ToJson(), MessageType.StartChanneling);
                                ChannelBarComponent channelBarComponent = new ChannelBarComponent(ability.ChannelTime, ability, Scene.FindEntitiesWithTag(2).ElementAt(0).GetComponent <PlayerComponent>().GetTarget(), Entity.Position);

                                Scene.AddSceneComponent(channelBarComponent);
                            }
                            else
                            {
                                template = new MessageTemplate(ct.ToJson(), MessageType.DamageTarget);
                            }
                            MessageManager.AddToQueue(template);
                            AbiliyCoolDown = 0;
                        }
                    }
                }
            }

            //Generated inventory
            if (newState.IsKeyDown(Keys.I) && OldKeyboardState.IsKeyUp(Keys.I))
            {
                if (!InventoryWindow.RemoveInventory(Scene))
                {
                    UIManager.GenerateInventoryWindow(skin, Scene, new Vector2(-1, -1), -1, -1);
                }
            }

            if (newState.IsKeyDown(Keys.C) && OldKeyboardState.IsKeyUp(Keys.C))
            {
                if (!CharacterWindow.RemoveCharacterWindow(Scene))
                {
                    UIManager.GenerateCharacterWindow(skin, Scene, new Vector2(-1, -1), -1, -1);
                }
            }

            if (newState.IsKeyDown(Keys.D1) && !OldKeyboardState.IsKeyDown(Keys.D1))
            {
            }
            if (newState.IsKeyDown(Keys.S) && !OldKeyboardState.IsKeyDown(Keys.S))
            {
                direction = Direction.Down;

                IsMoving = true;
            }
            if (newState.IsKeyDown(Keys.W) && !OldKeyboardState.IsKeyDown(Keys.W))
            {
                direction = Direction.Up;

                IsMoving = true;
            }
            if (newState.IsKeyDown(Keys.A) && !OldKeyboardState.IsKeyDown(Keys.A))
            {
                direction = Direction.Left;
                IsMoving  = true;
            }
            if (newState.IsKeyDown(Keys.D) && !OldKeyboardState.IsKeyDown(Keys.D))
            {
                direction = Direction.Right;
                IsMoving  = true;
            }
            if (newState.IsKeyDown(Keys.T) && !OldKeyboardState.IsKeyDown(Keys.T))
            {
                keys.Add(Keys.T);
            }
            if (IsMoving)
            {
                Scene.RemoveSceneComponent <ChannelBarComponent>();
            }

            return(keys.ToArray());
        }
Esempio n. 30
0
        private void LoadSiftChannelCompleted(IAsyncResult ar)
        {
            string result = HttpHelper.SyncResultTostring(ar);

            if (result != null)
            {
                channelDetailResult channelDetails = null;
                try
                {
                    channelDetails = JsonConvert.DeserializeObject <channelDetailResult>(result);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("LoadChannelCompleted   json 解析错误" + ex.Message);
                }
                if (channelDetails != null && channelDetails.err_code == HttpHelper.rightCode)
                {
                    siftListLoadSucc = true;

                    CallbackManager.currentPage.Dispatcher.BeginInvoke(() =>
                    {
                        SiftLLs.Visibility = System.Windows.Visibility.Visible;
                        List <VideoViewModel> TemplateListData = new List <VideoViewModel>();
                        foreach (ChannelDetail channelDatail in channelDetails.data)
                        {
                            switch (channelDatail.type)
                            {
                            case "normalAvatorText":
                            case "normalLandScape":
                            case "roundAvatorText":
                            case "tvPortrait":
                                for (int i = 0; i < channelDatail.templateData.Count; i = i + 2)
                                {
                                    if (channelDatail.templateData.Count > i + 1)
                                    {
                                        ChannelTemplate template1 = channelDatail.templateData[i];
                                        ChannelTemplate template2 = channelDatail.templateData[i + 1];
                                        VideoViewModel videoData  = new VideoViewModel
                                        {
                                            //stupid func
                                            type       = channelDatail.type,
                                            name       = template1.name,
                                            jumpType   = template1.jumpType,
                                            picUrl     = template1.picUrl,
                                            tag        = template1.tag,
                                            desc       = template1.desc,
                                            videoId    = template1.videoId,
                                            webUrl     = template1.webUrl,
                                            playUrl    = template1.playUrl,
                                            subjectId  = template1.subjectId,
                                            name1      = template2.name,
                                            picUrl1    = template2.picUrl,
                                            tag1       = template2.tag,
                                            desc1      = template2.desc,
                                            videoId1   = template2.videoId,
                                            jumpType1  = template1.jumpType,
                                            webUrl1    = template2.webUrl,
                                            playUrl1   = template2.playUrl,
                                            subjectId1 = template2.subjectId,
                                        };
                                        TemplateListData.Add(videoData);
                                    }
                                    else
                                    {
                                        ChannelTemplate template1 = channelDatail.templateData[i];
                                        VideoViewModel videoData  = new VideoViewModel
                                        {
                                            type      = channelDatail.type,
                                            name      = template1.name,
                                            jumpType  = template1.jumpType,
                                            picUrl    = template1.picUrl,
                                            tag       = template1.tag,
                                            desc      = template1.desc,
                                            videoId   = template1.videoId,
                                            webUrl    = template1.webUrl,
                                            playUrl   = template1.playUrl,
                                            subjectId = template1.subjectId,
                                        };
                                        TemplateListData.Add(videoData);
                                    }
                                }
                                break;

                            default:
                                break;
                            }
                            foreach (ChannelTemplate template in channelDatail.templateData)
                            {
                                switch (channelDatail.type)
                                {
                                case "banner":
                                case "largeLandScapeNodesc":
                                case "largeLandScape":
                                case "normalLandScapeNodesc":
                                case "aceSeason":
                                case "title":
                                case "rankList":
                                case "live":
                                    break;

                                case "normalAvatorText":
                                case "normalLandScape":
                                case "roundAvatorText":
                                case "tvPortrait":
                                case "unknowModType1":
                                case "unknowModType2":
                                    continue;

                                default:
                                    continue;
                                }
                                VideoViewModel videoData = new VideoViewModel
                                {
                                    type = channelDatail.type,
                                    //width = width,
                                    //hight = height,
                                    name      = template.name,
                                    jumpType  = template.jumpType,
                                    subjectId = template.subjectId,
                                    picUrl    = template.picUrl,
                                    playUrl   = template.playUrl,
                                    tag       = template.tag,
                                    desc      = template.desc,
                                    videoId   = template.videoId,
                                    hotDegree = template.hotDegree,
                                    webUrl    = template.webUrl,
                                    rank      = template.rank
                                };
                                TemplateListData.Add(videoData);
                            }
                        }
                        SiftLLs.ItemsSource = TemplateListData;
                    });
                }
            }
            else
            {
                if (CommonData.NetworkStatus != "None")
                {
                    App.ShowToast("获取数据失败,请检查网络或重试");
                }
                CallbackManager.currentPage.Dispatcher.BeginInvoke(() =>
                {
                    siftLoadGrid.Visibility = System.Windows.Visibility.Visible;
                    App.HideLoading();
                    //siftLoadGrid.Tap -= new EventHandler<System.Windows.Input.GestureEventArgs>(ReloadSiftDataTap);
                    //siftLoadGrid.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(ReloadSiftDataTap);
                    SiftLLs.Visibility = System.Windows.Visibility.Collapsed;
                });
            }
        }
Esempio n. 31
0
        public static ChannelTemplateDto FromDomainObject <T>(ChannelTemplate <T> source)
        {
            var result = SimpleMapper.Map(source, new ChannelTemplateDto());

            return(result);
        }