Exemple #1
0
        public AboutPage()
        {
            InitializeComponent();

            AboutNebula.Text = string.Format(NebulaClient.GetLocString("AboutNebula"),
                                             Assembly.GetExecutingAssembly().GetName().Version);
        }
Exemple #2
0
 private void OnPlaylistElementMouseDown(object sender, MouseButtonEventArgs e)
 {
     if (sender is Grid grid && grid.DataContext is IPlaylist playlist)
     {
         NebulaClient.Navigate(typeof(PlaylistPage), playlist, new DrillInNavigationTransitionInfo());
     }
 }
Exemple #3
0
        private void SetSession(SharedSessionInfo sessionInfo, UserInfo[] users = null)
        {
            if (!NebulaClient.Network.IsConnected || sessionInfo == SharedSessionInfo.Empty)
            {
                IsSessionActive = false;
                return;
            }

            Id                = sessionInfo.Id;
            Name              = sessionInfo.Name;
            MaxUsers          = sessionInfo.MaximumUsers;
            PasswordProtected = sessionInfo.PasswordProtected;
            Users.Clear();
            Messages.Clear();
            if (users != null && users.Length > 0)
            {
                foreach (UserInfo user in users)
                {
                    Users.Add(user);
                }
            }

            IsSessionActive = true;
            NebulaClient.Navigate(typeof(SharedSessionPage), null, new DrillInNavigationTransitionInfo());
        }
Exemple #4
0
        private void OnClientContextMenuOpen(object sender, ContextMenuEventArgs e)
        {
            NebulaClient hClient = m_hClientList.SelectedItem as NebulaClient;

            object first  = m_hClientContextMenu.Items[0];
            object second = m_hClientContextMenu.Items[1];
            object third  = m_hClientContextMenu.Items[2];
            object fourth = m_hClientContextMenu.Items[3];

            m_hClientContextMenu.Items.Clear();

            m_hClientContextMenu.Items.Add(first);
            m_hClientContextMenu.Items.Add(second);
            m_hClientContextMenu.Items.Add(third);
            m_hClientContextMenu.Items.Add(fourth);


            foreach (var item in hClient.Modules)
            {
                MenuItem hMenuItem = new MenuItem();
                hMenuItem.Header = item.Name;

                m_hClientContextMenu.Items.Add(hMenuItem);

                foreach (var method in item.Methods)
                {
                    MenuItem hMethodItem = new MenuItem();
                    hMethodItem.Header = method.MethodName;
                    hMethodItem.Tag    = item;
                    hMethodItem.Click += HMenuItem_Click1;

                    hMenuItem.Items.Add(hMethodItem);
                }
            }
        }
Exemple #5
0
        public void HandleControl(FrameworkElement element, PropertyInfo propertyInfo, DataCategory dataCategory, DataProperty dataProperty,
                                  ref DependencyProperty dependencyProperty)
        {
            FrameworkElement bindableElement = element is IDataControlsContainer container?container.GetBindableElement() : element;

            bindableElement.Tag = dataProperty.Tag;
            if (!string.IsNullOrWhiteSpace(dataProperty.ToolTipKey))
            {
                bindableElement.ToolTip = NebulaClient.GetLocString(dataProperty.ToolTipKey);
            }
            if (bindableElement is Control control)
            {
                ControlHelper.SetHeader(control, NebulaClient.GetLocString(dataProperty.HeaderKey));
                ControlHelper.SetPlaceholderText(control, NebulaClient.GetLocString(dataProperty.PlaceholderKey));
                ControlHelper.SetDescription(control, NebulaClient.GetLocString(dataProperty.DescriptionKey));
            }

            if (string.IsNullOrWhiteSpace(dataProperty.DependencyProperty))
            {
                return;
            }

            dependencyProperty =
                bindableElement.GetType().GetField(dataProperty.DependencyProperty, FieldBindingFlags)?.GetValue(bindableElement) as DependencyProperty;
        }
Exemple #6
0
        private async void OnCheckForUpdateClick(object sender, RoutedEventArgs e)
        {
            CheckForUpdateButton.IsEnabled = false;
            await NebulaClient.CheckForUpdate(false);

            CheckForUpdateButton.IsEnabled = true;
        }
        public ReplModuleWindow(NebulaClient hClient, Guid vModule)
        {
            m_hClient = hClient;
            m_vId     = vModule;
            m_hSb     = new StringBuilder();

            InitializeComponent();
        }
Exemple #8
0
 private void OnReceiveSessionUserMessagePacket(SharedSessionUserMessagePacket packet, NebulaNetClient net)
 {
     if (!IsSessionActive)
     {
         return;
     }
     NebulaClient.BeginInvoke(() => AddMessage(new SharedSessionMessage(FindUserById(packet.User.Id), packet.Message)));
 }
Exemple #9
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     Medias              = NebulaClient.MediaPlayer.MediaQueue.GetPages();
     Medias.PageChanged += OnPageChanged;
     Username.Text       = NebulaClient.GetLocString("HomeWelcome", NebulaClient.Settings.UserProfile.Username);
     TitlesDuration.Text = Medias.Collection.Count > 0 ? $"{NebulaClient.GetLocString("PlaylistTitles", Medias.Collection.Count)}" : "";
     PagesCount.Text     = Medias.TotalPages != 0 ? $"{Medias.CurrentPage + 1}/{Medias.TotalPages}" : "1/1";
 }
Exemple #10
0
        private void HMenuItem_Click1(object sender, RoutedEventArgs e)
        {
            NebulaClient     hClient     = m_hClientList.SelectedItem as NebulaClient;
            MenuItem         item        = sender as MenuItem;
            NebulaModuleInfo hModuleInfo = item.Tag as NebulaModuleInfo;

            m_hOutputWindow = new ReplModuleWindow(hClient, hModuleInfo.Guid);
            m_hOutputWindow.Show();
        }
Exemple #11
0
 public void HandleControl(FrameworkElement element, PropertyInfo propertyInfo, DataCategory dataCategory, DataProperty dataProperty,
                           ref DependencyProperty dependencyProperty)
 {
     dependencyProperty = ToggleButton.IsCheckedProperty;
     if (element is CheckBox checkBox)
     {
         checkBox.Content = NebulaClient.GetLocString(dataProperty.HeaderKey);
     }
 }
Exemple #12
0
 public void Leave()
 {
     if (!IsSessionActive)
     {
         return;
     }
     NebulaClient.Network.SendPacket(new SharedSessionLeavePacket());
     IsSessionActive = false;
     NebulaClient.Navigate(typeof(SharedSessionsPage));
 }
Exemple #13
0
        public async void Search(string query)
        {
            NebulaClient.Session.AddBrowserSearch(SearchBox.Text);
            Medias.Clear();
            IAsyncEnumerable <IMediaInfo> medias = NebulaClient.Search(query);

            await foreach (IMediaInfo mediaInfo in medias)
            {
                Medias.Add(mediaInfo);
            }
        }
Exemple #14
0
 private void OnReceiveSharedSessions(SharedSessionsPollResponse response, NebulaNetClient net)
 {
     NebulaClient.Invoke(() =>
     {
         ListView.Items.Clear();
         foreach (SharedSessionInfo sessionInfo in response.Sessions)
         {
             ListView.Items.Add(sessionInfo);
         }
     });
 }
Exemple #15
0
        private async void OnMediaItemAuthorMouseUp(object sender, MouseButtonEventArgs e)
        {
            if (!(sender is TextBlock clicked) || !(clicked.DataContext is IMediaInfo mediaInfo))
            {
                return;
            }
            IArtistInfo artistInfo = await mediaInfo.GetArtistInfo();

            UnknownPlaylist playlist = await UnknownPlaylist.FromArtist(artistInfo, false);

            NebulaClient.Navigate(typeof(PlaylistPage), playlist, new DrillInNavigationTransitionInfo());
        }
Exemple #16
0
        void OnEnable()
        {
            _gameObjectDirector = new GameObjectDirector(new Dictionary <string, GameObject> {
                { Prefab.name, Prefab }
            });

            _transmissionProtocol = new TcpClientTransmissionProtocol(Ip, Port);
            _transmissionProtocol.Start();

            _nebula = new NebulaClient(new RecorderInputSender(_transmissionProtocol, new RecordedInputSerializer()),
                                       new PacketReciver(_transmissionProtocol, SetupPacketSerializer()), new InputRecorder());
        }
Exemple #17
0
        public PlaylistEditDialog(IPlaylist playlist)
        {
            Playlist          = playlist;
            Title             = NebulaClient.GetLocString("EditPlaylist");
            PrimaryButtonText = NebulaClient.GetLocString("Edit");
            Name        = playlist.Name;
            Description = playlist.Description;
            Author      = playlist.Author;
            string thumbnailUri = playlist.Thumbnail.ToString();

            Thumbnail = thumbnailUri.StartsWith("file") ? playlist.Thumbnail.LocalPath : thumbnailUri;
            Cache.PrepareFor(this);
        }
Exemple #18
0
 public override void OnPeerDisconnected(NetPeer peer, DisconnectInfo disconnectInfo)
 {
     ServerPeer = null;
     NebulaClient.BeginInvoke(() =>
     {
         NebulaClient.Notifications.NotifyOk("", "ServerConnectionLost", "#ff0000");
         Disconnected?.Invoke(this, new DisconnectedFromServerEventArgs(peer, disconnectInfo));
         if (!NebulaClient.SharedSession.IsSessionActive)
         {
             return;
         }
         NebulaClient.SharedSession.Leave();
     });
 }
        private void OnPlayerStateChanged(object sender, StateChangedEventArgs e)
        {
            switch (e.NewState)
            {
            case MediaPlayerState.Paused:
                PlaybackPlay.Icon  = new SymbolIcon(Symbol.Play);
                PlaybackPlay.Label = NebulaClient.GetLocString("Play");
                break;

            case MediaPlayerState.Playing:
                PlaybackPlay.Icon  = new SymbolIcon(Symbol.Pause);
                PlaybackPlay.Label = NebulaClient.GetLocString("Pause");
                break;
            }
        }
 private void OnPlayerMuteChanged(object sender, MuteChangedEventArgs e)
 {
     if (e.IsMuted)
     {
         PlaybackMute.IsChecked = true;
         PlaybackMute.Icon      = new SymbolIcon(Symbol.Mute);
         PlaybackMute.Label     = NebulaClient.GetLocString("Unmute");
     }
     else
     {
         PlaybackMute.IsChecked = false;
         PlaybackMute.Icon      = new SymbolIcon(Symbol.Volume);
         PlaybackMute.Label     = NebulaClient.GetLocString("Mute");
     }
 }
Exemple #21
0
 public void NotifyOk(string badgeKey, string contentKey, string accentColor = "#1751C3", params object[] args)
 {
     NotificationsManager.CreateMessage()
     .Animates(true)
     .AnimationInDuration(0.75)
     .AnimationOutDuration(0.25)
     .Accent(accentColor)
     .Background("#333")
     .HasBadge(string.IsNullOrWhiteSpace(badgeKey)
                             ? NebulaClient.GetLocString("NotificationsBadgeInfo")
                             : NebulaClient.GetLocString(badgeKey))
     .HasMessage(NebulaClient.GetLocString(contentKey, args))
     .Dismiss().WithButton(NebulaClient.GetLocString("ButtonOk"), button => { })
     .Queue();
 }
Exemple #22
0
        private void OnContextMenuAddModule(object sender, RoutedEventArgs e)
        {
            NebulaClient hClient = m_hClientList.SelectedItem as NebulaClient;

            Microsoft.Win32.OpenFileDialog hDlg = new Microsoft.Win32.OpenFileDialog();
            hDlg.FileName   = "Nebula Module";
            hDlg.DefaultExt = ".dll";
            hDlg.Filter     = "Assembly Files (.dll)|*.dll";

            if (hDlg.ShowDialog() == true)
            {
                byte[] hData = File.ReadAllBytes(hDlg.FileName);

                NebulaModuleInfo[] hModules = hClient.Callback.AddModule(hData);
            }
        }
Exemple #23
0
 private void OnReceiveSharedSessionUserJoin(SharedSessionUserJoinedPacket response, NebulaNetClient net)
 {
     if (!IsSessionActive)
     {
         return;
     }
     NebulaClient.BeginInvoke(() =>
     {
         if (IsUserPresent(response.User))
         {
             return;
         }
         Users.Add(response.User);
         AddMessage(new SharedSessionMessage(FindUserById(response.User.Id), NebulaClient.GetLocString("SharedSessionMessageUserJoined"), "#10b513"));
     });
 }
Exemple #24
0
 public override void OnPeerConnected(NetPeer peer)
 {
     ServerPeer = peer;
     SendPacket(new UserInfoPacket
     {
         UserInfo = new UserInfo
         {
             Id        = -1,
             Username  = NebulaClient.Settings.UserProfile.Username,
             AvatarUrl = NebulaClient.Settings.UserProfile.Avatar,
         }
     });
     if (Connected != null)
     {
         NebulaClient.Invoke(() => Connected.Invoke(this, new ConnectedToServerEventArgs(peer)));
     }
 }
Exemple #25
0
 private void OnReceiveSharedSessionUserLeft(SharedSessionUserLeftPacket response, NebulaNetClient net)
 {
     if (!IsSessionActive)
     {
         return;
     }
     NebulaClient.BeginInvoke(() =>
     {
         UserInfo listUser = FindUserById(response.User.Id);
         if (listUser == UserInfo.Empty)
         {
             return;
         }
         Users.Remove(listUser);
         AddMessage(new SharedSessionMessage(listUser, NebulaClient.GetLocString("SharedSessionMessageUserLeft"), "#fc0000"));
     });
 }
        private void OnMediaChanged(object sender, MediaChangedEventArgs e)
        {
            IMediaProvider mediaProvider = e.NewMedia.GetMediaProvider();

            MediaThumbnail.Source    = new BitmapImage(new Uri(e.NewMedia.ThumbnailUrl));
            MediaTitle.Text          = e.NewMedia.Title;
            MediaAuthor.Text         = e.NewMedia.Author;
            MediaProvider.Text       = mediaProvider.Name;
            MediaProvider.Foreground = new SolidColorBrush((Color)(ColorConverter.ConvertFromString(mediaProvider.NameColorEx) ?? Colors.Gray));
            PlaybackPosition.Minimum = 0;
            PlaybackPosition.Maximum = e.NewMedia.Duration.TotalSeconds;
            PlaybackRemaining.Text   = e.NewMedia.Duration.ToString();
            PlaybackVolume.Value     = NebulaClient.MediaPlayer.Volume;
            PlaybackPlay.Icon        = new SymbolIcon(Symbol.Pause);
            PlaybackPlay.Label       = NebulaClient.GetLocString("Pause");
            UpdateMediaInfoWidth();
        }
Exemple #27
0
        private void OnClientContextMenuOpen(object sender, ContextMenuEventArgs e)
        {
            NebulaClient hClient = m_hClientList.SelectedItem as NebulaClient;

            if (hClient == null)
            {
                return;
            }

            //Detach previous event handlers
            foreach (Control hItem in m_hClientContextMenu.Items)
            {
                if (hItem is MenuItem)
                {
                    foreach (MenuItem hServerItem in (hItem as MenuItem).Items)
                    {
                        hServerItem.Click -= ServerMenuItemClick;
                    }
                }
            }

            //Clear the menu
            m_hClientContextMenu.Items.Clear();

            //Fill It Again
            m_hNebulaModuleControlHandles.ForEach(x => m_hClientContextMenu.Items.Add(x));

            foreach (NebulaModuleInfo hModuleInfo in hClient.Modules)
            {
                MenuItem hMenuItem = new MenuItem();
                hMenuItem.Header = hModuleInfo.Name;

                m_hClientContextMenu.Items.Add(hMenuItem);

                foreach (NebulaModuleMethod hMethod in hModuleInfo.Methods)
                {
                    MenuItem hMethodItem = new ServerMenuItem();
                    hMethodItem.Header = hMethod.Name;
                    hMethodItem.Tag    = hModuleInfo;
                    hMethodItem.Click += ServerMenuItemClick;

                    hMenuItem.Items.Add(hMethodItem);
                }
            }
        }
Exemple #28
0
        public override void OnPrimaryClick()
        {
            string oldName = Playlist.Name;

            Playlist.Name        = Name;
            Playlist.Description = Description;
            Playlist.Author      = Author;
            Playlist.Thumbnail   = string.IsNullOrWhiteSpace(Thumbnail) ? null : new Uri(Thumbnail);
            if (oldName != Playlist.Name)
            {
                NebulaClient.Playlists.RenamePlaylist(oldName, Playlist);
            }
            else
            {
                NebulaClient.Playlists.SavePlaylist(Playlist);
            }
            NebulaClient.Navigate(typeof(PlaylistPage), Playlist);
        }
Exemple #29
0
        public static DataContentCache BuildCache(Type type)
        {
            DataContentCache dataContentCache = new DataContentCache(type);
            Type             frameworkType    = typeof(FrameworkElement);

            foreach (PropertyInfo propertyInfo in type.GetProperties(PropertyBindingFlags).OrderBy(p => p.GetCustomAttribute <DataProperty>()?.Order))
            {
                DataProperty dataProperty = propertyInfo.GetCustomAttribute <DataProperty>();
                if (dataProperty == null || !frameworkType.IsAssignableFrom(dataProperty.ControlType))
                {
                    continue;
                }
                ConstructorInfo  ctor = dataProperty.ControlType.GetConstructor(new[] { typeof(object[]) });
                FrameworkElement frameworkElement;
                if (ctor == null)
                {
                    frameworkElement = (FrameworkElement)Activator.CreateInstance(dataProperty.ControlType);
                }
                else
                {
                    frameworkElement = (FrameworkElement)Activator.CreateInstance(dataProperty.ControlType, dataProperty.Params);
                }
                if (frameworkElement == null)
                {
                    continue;
                }
                DataCategory dataCategory = propertyInfo.GetCustomAttribute <DataCategory>();
                if (dataCategory != null)
                {
                    dataContentCache.AddElement(new TextBlock {
                        Text = NebulaClient.GetLocString(dataCategory.Category), FontSize = 24
                    });
                }
                DependencyProperty dependencyProperty = null;
                BaseControlHandler.HandleControl(frameworkElement, propertyInfo, dataCategory, dataProperty, ref dependencyProperty);
                HandleControl(frameworkElement, propertyInfo, dataCategory, dataProperty, ref dependencyProperty);
                dataContentCache.AddElement(frameworkElement, dependencyProperty, propertyInfo);
            }

            return(dataContentCache);
        }
Exemple #30
0
        public override async void OnPrimaryClick()
        {
            if (string.IsNullOrWhiteSpace(Path))
            {
                return;
            }
            IPlaylist playlist;

            if (Path.Contains("http") && Path.Contains("youtube"))
            {
                playlist = await NebulaClient.GetMediaProvider <YoutubeMediaProvider>().GetPlaylist(Path);

                NebulaClient.Playlists.AddPlaylist(playlist);
            }
            else
            {
                playlist = NebulaClient.Playlists.LoadPlaylist(new FileInfo(Path));
                NebulaClient.Playlists.SavePlaylist(playlist);
            }

            await NebulaMessageBox.ShowOk("PlaylistImport", "PlaylistImported", playlist.Name);
        }