void OnRefresh()
        {
            WindowProvider.RefreshDesktopSize();

            #region Video Source
            var lastVideoSourceName = VideoViewModel.SelectedVideoSource?.Name;

            VideoViewModel.RefreshVideoSources();

            var matchingVideoSource = VideoViewModel.AvailableVideoSources.FirstOrDefault(M => M.Name == lastVideoSourceName);

            if (matchingVideoSource != null)
            {
                VideoViewModel.SelectedVideoSource = matchingVideoSource;
            }
            #endregion

            #region Video Codec
            var lastVideoCodecName = VideoViewModel.SelectedVideoWriter?.ToString();

            VideoViewModel.RefreshCodecs();

            var matchingVideoCodec = VideoViewModel.AvailableVideoWriters.FirstOrDefault(M => M.ToString() == lastVideoCodecName);

            if (matchingVideoCodec != null)
            {
                VideoViewModel.SelectedVideoWriter = matchingVideoCodec;
            }
            #endregion

            #region Audio
            var lastMicNames = AudioSource.AvailableRecordingSources
                               .Where(M => M.Active)
                               .Select(M => M.Name)
                               .ToArray();

            var lastSpeakerNames = AudioSource.AvailableLoopbackSources
                                   .Where(M => M.Active)
                                   .Select(M => M.Name)
                                   .ToArray();

            AudioSource.Refresh();

            foreach (var source in AudioSource.AvailableRecordingSources)
            {
                source.Active = lastMicNames.Contains(source.Name);
            }

            foreach (var source in AudioSource.AvailableLoopbackSources)
            {
                source.Active = lastSpeakerNames.Contains(source.Name);
            }
            #endregion

            #region Webcam
            var lastWebcamName = WebCamProvider.SelectedCam?.Name;

            WebCamProvider.Refresh();

            var matchingWebcam = WebCamProvider.AvailableCams.FirstOrDefault(M => M.Name == lastWebcamName);

            if (matchingWebcam != null)
            {
                WebCamProvider.SelectedCam = matchingWebcam;
            }
            #endregion

            Status.LocalizationKey = nameof(LanguageManager.Refreshed);
        }
Beispiel #2
0
        /// <summary>
        /// The initState.
        /// </summary>
        public override void initState()
        {
            mMDObjects = new List <MMDObject>();
            panelItems = new List <PanelItem>();
            base.initState();

            #region Subscription

            // Objects event
            var mmm = MMMServices.Instance;

            var observeCountChanged   = mmm.ObservedMMDObjects.ObserveCountChanged(true).Select(x => true);
            var observeEveryChanged   = mmm.ObservedMMDObjects.ObserveEveryValueChanged(x => x).Select(x => true);
            var specifiedCountChanged = mmm.SpecifiedMmdObjects.ObserveCountChanged(true).Select(x => true);
            var specifiedChanged      = mmm.SpecifiedMmdObjects.ObserveEveryValueChanged(x => x).Select(x => true);

            countChanged = observeCountChanged.Merge(observeEveryChanged, specifiedCountChanged, specifiedChanged)
                           .Subscribe(_ =>
            {
                Debug.Log("countChanged");
                using (WindowProvider.of(GameObject.Find("Panel")).getScope())
                {
                    var observed  = mmm.ObservedMMDObjects.ToList();
                    var specified = mmm.SpecifiedMmdObjects.ToList();
                    setState(() =>
                    {
                        mMDObjects.Clear();
                        mMDObjects.AddRange(observed);
                        mMDObjects.AddRange(specified);

                        // Set expansion panel items
                        panelItems.Clear();
                        panelItems.AddRange(BuildExpansionDictionary().Select(x => new PanelItem()
                        {
                            IsExpanded = true, Title = x.Key, Cards = x.Value
                        }));
                    });
                }
            }
                                      , onError: e => Debug.Log(e.Message));

            // Sort event
            MMMFlutterApp.SortTypeProperty
            .DistinctUntilChanged()
            .Subscribe(x => setState(() => SortType = x), onError: e => Debug.Log(e.Message));

            // Search pattern changed event
            MMMFlutterApp.SearchPattern
            .Throttle(TimeSpan.FromMilliseconds(100))
            .DistinctUntilChanged()
            .Subscribe(x =>
            {
                using (WindowProvider.of(GameObject.Find("Panel")).getScope())
                {
                    setState(() => SearchPattern = x);
                }
            });

            #endregion

            #region Show tips

            Task.Run(() =>
            {
                Task.Delay(TimeSpan.FromSeconds(3));
                Unity.UIWidgets.material.DialogUtils.showDialog(
                    context: context,
                    barrierDismissible: true,
                    builder: (c) => new AlertDialog(
                        title: new Text(alertTitle),
                        content: new Text(alertContent),
                        actions: new List <Widget>
                {
                    new RaisedButton(child: new Text("Close", style: new TextStyle(color: Colors.white)),
                                     onPressed: () => Navigator.of(c).pop())
                }
                        ));
            });

            #endregion
        }
        public override Widget build(BuildContext context)
        {
            Widget iconWidgetChildren;

            if (m_Joining)
            {
                iconWidgetChildren = new Loading(size: 24);
            }
            else
            {
                iconWidgetChildren = new Icon(
                    IconFont.IconFontChevronRight,
                    size: 24,
                    color: new Color(0xff959595)
                    );
            }
            return(new GestureDetector(
                       onTap: () =>
            {
                if (widget.channels.ContainsKey(widget.channel.id))
                {
                    var rootState = HomePage.of(context);
                    rootState.Select(widget.channel.id);
                }
                else
                {
                    setState(() => m_Joining = true);
                    var requestUrl = string.IsNullOrEmpty(widget.channel.groupId) ?
                                     $"/api/connectapp/v1/channels/{widget.channel.id}/join" :
                                     $"/api/connectapp/v1/groups/{widget.channel.groupId}/join";

                    Post <JoinChannelResponse>(
                        requestUrl,
                        "{}"
                        ).Then(response =>
                    {
                        using (WindowProvider.of(context).getScope())
                        {
                            var state = HomePage.of(context);
                            var responseChannel = response.channel;
                            state.AddChannel(responseChannel);
                            state.Select(responseChannel.id);
                            state.Ack(responseChannel.id);
                            setState(() => m_Joining = false);
                        }
                    });
                }
            },
                       child: new Container(
                           height: 72,
                           alignment: Alignment.centerLeft,
                           decoration: NormalDecoration,
                           child: new Row(
                               crossAxisAlignment: CrossAxisAlignment.center,
                               children: new List <Widget>
            {
                new Container(
                    margin: ThumbnailMargin,
                    child: CreateLobbyIcon(
                        widget.channel.thumbnail,
                        size: 48,
                        radius: 4
                        )
                    ),
                new Expanded(
                    child: new Container(
                        height: 48,
                        child: new Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: new List <Widget>
                {
                    new Container(
                        margin: ChannelNameMargin,
                        height: 24,
                        alignment: Alignment.centerLeft,
                        child: new Text(
                            widget.channel.name,
                            style: NormalChannelNameStyle,
                            overflow: TextOverflow.ellipsis
                            )
                        ),
                    new Container(
                        height: 22,
                        margin: LastMessageMargin,
                        child: new Text(
                            $"{widget.channel.memberCount}成员",
                            style: NormalLastMessageStyle,
                            overflow: TextOverflow.ellipsis
                            )
                        )
                }
                            )
                        )
                    ),
                new Container(
                    margin: LastMessageTimestampMargin,
                    child: iconWidgetChildren
                    ),
            }
                               )
                           )
                       ));
        }
Beispiel #4
0
        public override Widget build(BuildContext context)
        {
            var screenSize   = MediaQuery.of(context).size;
            var screenWidth  = screenSize.width;
            var screenHeight = screenSize.height;

            var headerChildren = new List <Widget>
            {
                new Expanded(
                    child: new Text(
                        $"{channel?.name ?? string.Empty}",
                        style: new TextStyle(
                            fontSize: 16,
                            fontWeight: FontWeight.w500,
                            color: new Color(0xff212121),
                            fontFamily: "PingFang"
                            )
                        )
                    ),
            };

            headerChildren.Add(
                new GestureDetector(
                    onTap: () =>
            {
                if (screenWidth < 750)
                {
                    m_AnimationController.reverse();
                }
                else
                {
                    HomePage.of(this.context).HideChannelInfo();
                }
            },
                    child: new Icon(
                        IconFont.IconFontClose,
                        color: new Color(0xff979a9e),
                        size: 28
                        )
                    )
                );

            var children = new List <Widget> {
            };

            if (channel == null)
            {
                children.Add(
                    new Loading(size: 56)
                    );
            }
            else
            {
                children.Add(
                    CreateLobbyIcon(
                        channel.thumbnail,
                        size: 184,
                        radius: 4
                        )
                    );
                children.Add(
                    new Container(
                        margin: EdgeInsets.only(top: 32),
                        child: new Text(
                            channel.name,
                            style: new TextStyle(
                                color: new Color(0xff000000),
                                fontSize: 24,
                                fontWeight: FontWeight.bold
                                )
                            )
                        )
                    );
                children.Add(
                    new Container(
                        margin: EdgeInsets.only(top: 8),
                        child: new Text(
                            $"{channel.memberCount}成员",
                            style: new TextStyle(
                                color: new Color(0xff797979),
                                fontSize: 14
                                )
                            )
                        )
                    );
                var topic = channel.topic;
                if (!channel.groupId.IsNullOrEmpty() && group != null)
                {
                    topic = group.description;
                }

                children.Add(
                    new Container(
                        margin: EdgeInsets.only(top: 32),
                        child: new Text(
                            topic,
                            style: new TextStyle(
                                color: new Color(0xff000000),
                                fontSize: 14
                                )
                            )
                        )
                    );
                var buttonChildren = new List <Widget>();
                if (m_Joining)
                {
                    buttonChildren.Add(
                        new Text(
                            "加入群聊",
                            style: new TextStyle(
                                color: new Color(0x00000000),
                                fontSize: 18,
                                fontFamily: "PingFang"
                                )
                            )
                        );
                    buttonChildren.Add(
                        new Loading(
                            size: 24
                            )
                        );
                }
                else
                {
                    buttonChildren.Add(
                        new Text(
                            "加入群聊",
                            style: new TextStyle(
                                fontSize: 18,
                                color: new Color(0xff2196f3),
                                fontFamily: "PingFang"
                                )
                            )
                        );
                }

                children.Add(
                    new GestureDetector(
                        onTap: () =>
                {
                    if (m_Joining)
                    {
                        return;
                    }
                    setState(() => m_Joining = true);
                    var requestUrl           = string.IsNullOrEmpty(channel.groupId)
                                ? $"/api/connectapp/v1/channels/{channel.id}/join"
                                : $"/api/connectapp/v1/groups/{channel.groupId}/join";
                    Utils.Post <JoinChannelResponse>(
                        requestUrl,
                        "{}"
                        ).Then(response =>
                    {
                        using (WindowProvider.of(context).getScope())
                        {
                            if (mounted)
                            {
                                var state           = HomePage.of(context);
                                var responseChannel = response.channel;
                                state.AddChannel(responseChannel);
                                state.Select(responseChannel.id);
                                state.Ack(responseChannel.id);
                                setState(() => m_Joining = false);
                            }
                        }
                    });
                },
                        child: new Container(
                            height: 56,
                            width: 234,
                            margin: EdgeInsets.only(top: 48),
                            decoration: new BoxDecoration(
                                color: new Color(0xffffffff),
                                borderRadius: BorderRadius.circular(6),
                                border: Border.all(
                                    color: new Color(0xff2196f3)
                                    )
                                ),
                            alignment: Alignment.center,
                            child: new Stack(
                                alignment: Alignment.center,
                                children: buttonChildren
                                )
                            )
                        )
                    );
            }

            Widget all = new Container(
                color: new Color(0xffffffff),
                child: new Scroller(
                    child: new SingleChildScrollView(
                        child: new Column(
                            children: new List <Widget>
            {
                new Container(
                    height: 64,
                    decoration: new BoxDecoration(
                        border: new Border(
                            bottom: new BorderSide(
                                color: new Color(0xffd8d8d8)
                                )
                            )
                        ),
                    padding: EdgeInsets.symmetric(horizontal: 24),
                    alignment: Alignment.center,
                    child: new Row(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: headerChildren
                        )
                    ),
                new Container(
                    constraints: new BoxConstraints(
                        minHeight: screenHeight - 64
                        ),
                    width: screenWidth < 750 ? (float?)null : 450,
                    margin: EdgeInsets.symmetric(horizontal: 24),
                    alignment: Alignment.center,
                    child: new Column(
                        children: children
                        )
                    ),
            }
                            )
                        )
                    )
                );

            var stacked = new List <Widget> {
                all
            };

            all = new Stack(
                children: stacked
                );

            if (screenWidth < 750)
            {
                all = Transform.translate(
                    offset: new Offset(0, (1 - m_AnimationController.value) * screenHeight),
                    child: all
                    );
            }

            return(all);
        }
Beispiel #5
0
        public void Run(Assembly startingAssembly, string[] args)
        {
            this.AssertThisIsTheOnlyRunningContext();

            // create a new application context
            _appContext = new PluginApplicationContext();

            // save the command line args
            _commandLineArgs = args;

            if (CarbonConfig.SingleInstance)
            {
                // create a new instance manager, don't dispose of it just yet as we'll need to have our ui plugin
                // grab it and listen for events until the plugin context is destroyed...
                _instanceManager = new InstanceManager(CarbonConfig.SingleInstancePort, CarbonConfig.SingleInstanceMutexName);

                // check to see if this one is the only instance running
                if (!_instanceManager.IsOnlyInstance)
                {
                    // if not, forward our command line, and then instruct the
                    _instanceManager.SendCommandLineToPreviousInstance(PluginContext.Current.CommandLineArgs);
                    return;
                }
            }

            // load the Carbon core sub-system providers
            _windowProviders        = CarbonConfig.GetWindowProviders();
            _configurationProviders = CarbonConfig.GetConfigurationProviders();
            //_encryptionProviders = CarbonConfig.GetEncryptionProviders();
            _pluginProviders = CarbonConfig.GetPluginProviders();

            // show the splash _splashWindow if the config specifies
            if (CarbonConfig.ShowSplashWindow)
            {
                /*
                 * Not-Threaded
                 * */
                using (WindowProvider splashWindowProvider = this.GetSplashWindowProvider())
                {
                    _splashWindow = splashWindowProvider.CreateWindow(null);
                }

                _splashWindow.Show();
                _splashWindow.Refresh();
                _progressViewer = _splashWindow as IProgressViewer;
            }

            ProgressViewer.SetExtendedDescription(_progressViewer, "Initializing Carbon Framework System Providers.");

            // start configuration providers
            ConfigurationProvidersManager.InstructConfigurationProvidersToLoad(_progressViewer, _configurationProviders);

            // use the plugin manager to load the plugin types that the plugin providers want loaded
            using (TypeCollection pluginTypes = PluginManager.LoadPluginTypes(_progressViewer, _pluginProviders))
            {
                // use the plugin manager to create descriptors for all of the plugins
                using (_pluginDescriptors = PluginManager.CreatePluginDescriptors(_progressViewer, pluginTypes))
                {
                    // validate the plugin dependencies
                    PluginManager.ValidatePluginDependencies(_progressViewer, _pluginDescriptors);

                    // sort plugins to have the least dependent plugins first
                    // NOTE: Always sort first because the dependencies are taken into account during instance construction!
                    _pluginDescriptors = PluginManager.Sort(_pluginDescriptors, true);

                    // create the plugins
                    PluginManager.CreatePluginInstances(_progressViewer, _pluginDescriptors);

                    // start plugins
                    PluginManager.StartPlugins(_progressViewer, _pluginDescriptors);

                    // if we are supposed to run a message loop, do it now
                    if (CarbonConfig.RunApplicationContext)
                    {
                        this.OnEnteringMainMessageLoop(new PluginContextEventArgs(this));

                        // run the plugin context's main message loop
                        Application.Run(this.ApplicationContext);

                        this.OnExitingMainMessageLoop(new PluginContextEventArgs(this));
                    }

                    // sort plugins to have the most dependent plugins first
                    _pluginDescriptors = PluginManager.Sort(_pluginDescriptors, false);

                    // stop plugins
                    PluginManager.StopPlugins(null, _pluginDescriptors);
                }
            }

            // stop configuration providers
            // start configuration providers
            ConfigurationProvidersManager.InstructConfigurationProvidersToSave(_configurationProviders);
        }
Beispiel #6
0
        static void _handleMethodCall(string method, List <JSONNode> args)
        {
            if (GlobalContext.context != null)
            {
                using (WindowProvider.of(GlobalContext.context).getScope()) {
                    switch (method)
                    {
                    case "OnOpenNotification": {
                        //点击应用通知栏
                        var node    = args[0];
                        var dict    = JSON.Parse(node);
                        var type    = dict["type"];
                        var subType = dict["subtype"];
                        var id      = dict["id"];
                        AnalyticsManager.AnalyticsWakeApp("OnOpenNotification", id, type, subType);
                        AnalyticsManager.ClickNotification(type, subType, id);
                        pushPage(type, subType, id, true);
                    }
                    break;

                    case "OnReceiveNotification": {
                        //接收到推送
                        EventBus.publish(EventBusConstant.refreshNotifications, new List <object>());
                    }
                    break;

                    case "OnReceiveMessage": {
                        //接收到应用内消息
                    }
                    break;

                    case "OnOpenUrl": {
                        if (args.isEmpty())
                        {
                            return;
                        }

                        AnalyticsManager.AnalyticsWakeApp("OnOpenUrl", args.first());
                        openUrl(args.first());
                    }
                    break;

                    case "OnOpenUniversalLinks": {
                        if (args.isEmpty())
                        {
                            return;
                        }

                        AnalyticsManager.AnalyticsWakeApp("OnOpenUniversalLinks", args.first());
                        openUniversalLink(args.first());
                    }
                    break;

                    case "CompletedCallback": {
                        var node   = args[0];
                        var dict   = JSON.Parse(node);
                        var isPush = (bool)dict["push"];
                        if (isPush)
                        {
                            StoreProvider.store.dispatcher.dispatch(new MainNavigatorReplaceToAction {
                                    routeName = MainNavigatorRoutes.Main
                                });
                        }
                        else
                        {
                            if (SplashManager.isExistSplash())
                            {
                                StoreProvider.store.dispatcher.dispatch(new MainNavigatorPushReplaceSplashAction());
                            }
                            else
                            {
                                StoreProvider.store.dispatcher.dispatch(new MainNavigatorPushReplaceMainAction());
                            }
                        }
                    }
                    break;
                    }
                }
            }
        }
Beispiel #7
0
 private void _menuItemBackups_Click(object sender, RoutedEventArgs e)
 {
     WindowProvider.Show(new BackupDialog(), _menuItemBackups, this);
 }
Beispiel #8
0
 private void _menuItemAbout_Click(object sender, RoutedEventArgs e)
 {
     WindowProvider.ShowWindow(new AboutDialog(Configuration.PublicVersion, Configuration.RealVersion, Configuration.Author, SdeAppConfiguration.ProgramName, "sdeAboutBackground.jpg"), this);
 }
Beispiel #9
0
 private void _menuItemAbout_Click(object sender, RoutedEventArgs e)
 {
     WindowProvider.ShowWindow(new AboutDialog(MapcacheConfiguration.PublicVersion, MapcacheConfiguration.RealVersion, MapcacheConfiguration.Author, MapcacheConfiguration.ProgramName), this);
 }
Beispiel #10
0
        void StartRecording()
        {
            var SelectedAudioSourceId   = AudioSettings.SelectedAudioSourceId;
            var SelectedVideoSourceKind = VideoSettings.SelectedVideoSourceKind;
            var SelectedVideoSource     = VideoSettings.SelectedVideoSource;
            var Encoder = VideoSettings.Encoder;

            _duration = OtherSettings.CaptureDuration;
            _delay    = OtherSettings.StartDelay;

            if (_duration != 0 && (_delay * 1000 > _duration))
            {
                Status.Content = "Delay cannot be greater than Duration";
                SystemSounds.Asterisk.Play();
                return;
            }

            if (OtherSettings.MinimizeOnStart)
            {
                WindowState = WindowState.Minimized;
            }

            VideoSettings.Instance.VideoSourceKindBox.IsEnabled = false;
            VideoSettings.Instance.VideoSourceBox.IsEnabled     = SelectedVideoSourceKind == VideoSourceKind.Window;

            // UI Buttons
            RecordButton.ToolTip  = "Stop";
            RecordButton.IconData = (RectangleGeometry)FindResource("StopIcon");

            ReadyToRecord = false;

            int temp;

            var Extension = SelectedVideoSourceKind == VideoSourceKind.NoVideo
                ? (AudioSettings.EncodeAudio && int.TryParse(SelectedAudioSourceId, out temp) ? ".mp3" : ".wav")
                : (Encoder.Name == "Gif" ? ".gif" : ".avi");

            lastFileName = Path.Combine(OutPath.Text, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + Extension);

            Status.Content = _delay > 0 ? $"Recording from t={_delay}ms..." : "Recording...";

            DTimer.Stop();
            _seconds            = _minutes = 0;
            TimeManager.Content = "00:00";

            DTimer.Start();

            var AudioBitRate = App.IsLamePresent ? Mp3EncoderLame.SupportedBitRates[AudioSettings.AudioQuality] : 0;

            IAudioProvider AudioSource = null;
            var            wf          = new WaveFormat(44100, 16, AudioSettings.Stereo ? 2 : 1);

            if (SelectedAudioSourceId != "-1")
            {
                int i;
                if (int.TryParse(SelectedAudioSourceId, out i))
                {
                    AudioSource = new WaveIn(i, VideoSettings.FrameRate, wf);
                }
                else
                {
                    AudioSource = new WasapiLoopbackCapture(WasapiAudioDevice.Get(SelectedAudioSourceId));
                    wf          = AudioSource.WaveFormat;
                }
            }

            #region ImageProvider
            IImageProvider ImgProvider = null;

            Func <System.Windows.Media.Color, System.Drawing.Color> ConvertColor = C => System.Drawing.Color.FromArgb(C.A, C.R, C.G, C.B);

            var mouseKeyHook = new MouseKeyHook(OtherSettings.CaptureClicks,
                                                OtherSettings.CaptureKeystrokes);

            switch (SelectedVideoSourceKind)
            {
            case VideoSourceKind.Window:
                var Src = SelectedVideoSource as WindowVSLI;

                if (Src.Handle == RegionSelector.Instance.Handle &&
                    OtherSettings.StaticRegionCapture)
                {
                    ImgProvider = new StaticRegionProvider(RegionSelector.Instance,
                                                           cursor,
                                                           mouseKeyHook);
                    VideoSettings.Instance.VideoSourceBox.IsEnabled = false;
                }
                else
                {
                    ImgProvider = new WindowProvider(() => (VideoSettings.SelectedVideoSource as WindowVSLI).Handle,
                                                     ConvertColor(VideoSettings.BackgroundColor),
                                                     cursor,
                                                     mouseKeyHook);
                }
                break;

            case VideoSourceKind.Screen:
                ImgProvider = new ScreenProvider((SelectedVideoSource as ScreenVSLI).Screen,
                                                 cursor,
                                                 mouseKeyHook);
                break;
            }
            #endregion

            #region VideoEncoder
            IVideoFileWriter VideoEncoder = null;

            if (Encoder.Name == "Gif")
            {
                if (GifSettings.UnconstrainedGif)
                {
                    Recorder = new UnconstrainedFrameRateGifRecorder(
                        new GifWriter(lastFileName,
                                      Repeat: GifSettings.GifRepeat ? GifSettings.GifRepeatCount : -1),
                        ImgProvider);
                }

                else
                {
                    VideoEncoder = new GifWriter(lastFileName, 1000 / VideoSettings.FrameRate,
                                                 GifSettings.GifRepeat ? GifSettings.GifRepeatCount : -1);
                }
            }

            else if (SelectedVideoSourceKind != VideoSourceKind.NoVideo)
            {
                VideoEncoder = new AviWriter(lastFileName,
                                             ImgProvider,
                                             Encoder,
                                             VideoSettings.VideoQuality,
                                             VideoSettings.FrameRate,
                                             AudioSource,
                                             AudioBitRate == 0 ? null
                                                                : new Mp3EncoderLame(wf.Channels, wf.SampleRate, AudioBitRate));
            }
            #endregion

            if (Recorder == null)
            {
                if (SelectedVideoSourceKind == VideoSourceKind.NoVideo)
                {
                    Recorder = AudioSettings.EncodeAudio ? new AudioRecorder(AudioSource, new EncodedAudioFileWriter(lastFileName, new Mp3EncoderLame(wf.Channels, wf.SampleRate, AudioBitRate)))
                                                         : new AudioRecorder(AudioSource, new WaveFileWriter(lastFileName, wf));
                }

                else
                {
                    Recorder = new Recorder(VideoEncoder, ImgProvider, AudioSource);
                }
            }

            Recorder.RecordingStopped += E => Dispatcher.Invoke(() =>
            {
                OnStopped();

                if (E != null)
                {
                    Status.Content = "Error";
                    MessageBox.Show(E.ToString());
                }
            });

            Recorder.Start(_delay);

            Recent.Add(lastFileName,
                       VideoEncoder == null ? RecentItemType.Audio : RecentItemType.Video);
        }
Beispiel #11
0
        public override Widget build(BuildContext context)
        {
            var topic = widget.channel.topic;

            if (!widget.channel.groupId.IsNullOrEmpty())
            {
                topic = widget.groups[widget.channel.groupId].description;
            }

            var buttonChildren = new List <Widget>();

            if (m_Joining)
            {
                buttonChildren.Add(
                    new Text(
                        widget.channels.ContainsKey(widget.channel.id) ? "查看群聊" : "立即加入",
                        style: new TextStyle(
                            color: new Color(0x00000000),
                            fontSize: 14,
                            fontFamily: "PingFang"
                            )
                        )
                    );
                buttonChildren.Add(
                    new Loading(
                        size: 24
                        )
                    );
            }
            else
            {
                buttonChildren.Add(
                    new Text(
                        widget.channels.ContainsKey(widget.channel.id) ? "查看群聊" : "立即加入",
                        style: new TextStyle(
                            color: new Color(0xff2196f3),
                            fontSize: 14,
                            fontFamily: "PingFang"
                            )
                        )
                    );
            }

            return(new Container(
                       decoration: Decoration,
                       height: 280,
                       width: widget.width,
                       margin: EdgeInsets.all(8),
                       padding: EdgeInsets.only(top: 24, left: 16, right: 16, bottom: 16),
                       child: new Column(
                           crossAxisAlignment: CrossAxisAlignment.stretch,
                           children: new List <Widget>
            {
                new Row(
                    children: new List <Widget>
                {
                    CreateLobbyIcon(
                        widget.channel.thumbnail,
                        radius: 4,
                        size: 48
                        ),
                    new Expanded(
                        child: new Container(
                            height: 48,
                            margin: EdgeInsets.only(left: 16),
                            child: new Column(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: new List <Widget>
                    {
                        new Container(
                            height: 24,
                            alignment: Alignment.centerLeft,
                            child: new Text(
                                widget.channel.name,
                                style: NameTextStyle,
                                overflow: TextOverflow.ellipsis
                                )
                            ),
                        new Container(
                            height: 22,
                            alignment: Alignment.centerLeft,
                            child: new Text(
                                $"{widget.channel.memberCount}成员",
                                style: MemberCountTextStyle
                                )
                            )
                    }
                                )
                            )
                        ),
                }
                    ),
                new Expanded(
                    child: new Container(
                        margin: TopicMargin,
                        child: new RichText(
                            text: ParseMessage(topic, null, TopicTextStyle),
                            maxLines: 5,
                            overflow: TextOverflow.ellipsis
                            )
                        )
                    ),
                new GestureDetector(
                    onTap: () =>
                {
                    if (widget.channels.ContainsKey(widget.channel.id))
                    {
                        HomePage.of(context).Select(widget.channel.id);
                    }
                    else
                    {
                        setState(() => m_Joining = true);
                        var requestUrl = string.IsNullOrEmpty(widget.channel.groupId)
                                        ? $"/api/connectapp/v1/channels/{widget.channel.id}/join"
                                        : $"/api/connectapp/v1/groups/{widget.channel.groupId}/join";
                        Post <JoinChannelResponse>(
                            requestUrl,
                            "{}"
                            ).Then(response =>
                        {
                            using (WindowProvider.of(context).getScope())
                            {
                                if (mounted)
                                {
                                    var state = HomePage.of(context);
                                    var responseChannel = response.channel;
                                    state.AddChannel(responseChannel);
                                    state.Select(responseChannel.id);
                                    state.Ack(responseChannel.id);
                                    setState(() => m_Joining = false);
                                }
                            }
                        });
                    }
                },
                    child: new Container(
                        height: 32,
                        decoration: new BoxDecoration(
                            borderRadius: BorderRadius.circular(8),
                            color: new Color(0xffffffff),
                            border: Border.all(
                                color: new Color(0xffd8d8d8)
                                )
                            ),
                        alignment: Alignment.center,
                        child: new Stack(
                            alignment: Alignment.center,
                            children: buttonChildren
                            )
                        )
                    )
            }
                           )
                       ));
        }
Beispiel #12
0
        public override Widget build(BuildContext context)
        {
            if (!m_Focusing || m_Cursor == -1 || !m_Mentioning)
            {
                return(new Container());
            }

            var children = new List <Widget> {
            };

            if (beginIndex != -1 && beginIndex == endIndex - 1)
            {
                var selectedChannelId = widget.selectedChannelIdGetter();
                var widgets           = widget.members[selectedChannelId]
                                        .Where(member => member.user.id != Window.currentUserId)
                                        .Take(10)
                                        .Select(member => widget.users[member.user.id])
                                        .Select((user, idx) => new MentionUser(user,
                                                                               onMentionUserSelectedFactory(user),
                                                                               idx == selectedIndex));
                children.AddRange(
                    widgets
                    );
                candidateCount = widgets.Count();
                if (widget.members[widget.selectedChannelIdGetter()].Any(member =>
                                                                         member.user.id == Window.currentUserId && member.role == "admin"))
                {
                    children.Add(
                        new MentionEveryone(
                            onTap: () =>
                    {
                        Sender.currentState?.AddMentionEveryone(m_Query, beginIndex, endIndex);
                        SchedulerBinding.instance.addPostFrameCallback(value =>
                        {
                            using (WindowProvider.of(context).getScope())
                            {
                                StopMention();
                            }
                        });
                    }
                            )
                        );
                }
            }
            else
            {
                var widgets = m_SearchResults
                              .Select(uid => widget.users[uid])
                              .Select((user, idx) => new MentionUser(
                                          user,
                                          onMentionUserSelectedFactory(user),
                                          idx == selectedIndex));
                children.AddRange(
                    widgets
                    );
                candidateCount = widgets.Count();
            }

            if (children.Count == 0)
            {
                return(new Container());
            }

            var left = MediaQuery.of(context).size.width < 750 ? 25 : 400;

            return(new Positioned(
                       bottom: 96,
                       left: left,
                       child: new Container(
                           padding: EdgeInsets.symmetric(vertical: 6),
                           width: 280,
                           decoration: new BoxDecoration(
                               borderRadius: BorderRadius.all(3),
                               color: new Color(0xffffffff),
                               boxShadow: new List <BoxShadow>
            {
                new BoxShadow(
                    blurRadius: 16,
                    color: new Color(0x33000000)
                    )
            }
                               ),
                           child: new Column(
                               children: children
                               )
                           )
                       ));
        }
Beispiel #13
0
        private void DetectMention()
        {
            if (!m_Focusing || m_Query.IsNullOrEmpty() || m_Cursor == -1)
            {
                beginIndex   = -1;
                endIndex     = -1;
                m_Mentioning = false;
                return;
            }

            var currText   = m_Query.Substring(0, m_Cursor);
            var query      = "";
            var mentioning = false;

            for (var pos = m_Cursor - 1; pos >= 0; pos--)
            {
                if (currText[pos] != '@')
                {
                    continue;
                }
                beginIndex = pos;
                endIndex   = m_Cursor;
                query      = ((pos + 1) >= currText.Length) ? "" : m_Query.Substring(pos + 1, m_Cursor - pos - 1);
                mentioning = true;
                break;
            }

            var channelId = widget.selectedChannelIdGetter();

            m_SearchResults.Clear();
            var i = 0;

            if (widget.members.ContainsKey(channelId))
            {
                foreach (var member in widget.members[channelId])
                {
                    if (member.user.fullName.ToLower().Contains(query.ToLower()) &&
                        member.user.id != Window.currentUserId)
                    {
                        m_SearchResults.Add(member.user.id);
                        ++i;
                        if (i > 9)
                        {
                            break;
                        }
                    }
                }
            }

            if (!widget.hasMoreMembers.ContainsKey(channelId))
            {
                widget.hasMoreMembers[channelId] = true;
            }
            if (m_SearchResults.Count < 10 && widget.hasMoreMembers[channelId])
            {
                var offset = widget.members[channelId].Count;
                Utils.Get <GetMembersResponse>(
                    $"/api/connectapp/channels/{channelId}/members?offset={offset}"
                    ).Then(response =>
                {
                    response.list.ForEach(member =>
                    {
                        if (widget.members[channelId].All(m => m.user.id != member.user.id))
                        {
                            widget.members[channelId].Add(member);
                        }

                        widget.users.putIfAbsent(member.user.id, () => member.user);
                    });

                    widget.hasMoreMembers[channelId] = response.total > widget.members[channelId].Count;
                    if (mounted)
                    {
                        using (WindowProvider.of(context).getScope())
                        {
                            DetectMention();
                            setState();
                        }
                    }
                });
            }

            selectedIndex = -1;
            m_Mentioning  = mentioning;
        }
 private void _buttonSettings_Click(object sender, RoutedEventArgs e)
 {
     WindowProvider.Show(new PreviewSettingsDialog(() => OnFrameChanged(SelectedFrame), c => _viewer._primary.Background = new SolidColorBrush(c)), _buttonSettings, WpfUtilities.FindDirectParentControl <Window>(this));
 }
Beispiel #15
0
 private void BrowseButton_Click(object sender, RoutedEventArgs e)
 {
     WindowProvider.OpenImgFileDialog(ProductImage);
 }
Beispiel #16
0
        private void _comboBoxEncoding_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            object oldSelected = null;
            bool   cancel      = false;

            if (e.RemovedItems.Count > 0)
            {
                oldSelected = e.RemovedItems[0];
            }

            switch (_comboBoxEncoding.SelectedIndex)
            {
            case 0:
                if (!SetEncoding(1252))
                {
                    cancel = true;
                }
                break;

            case 1:
                if (!SetEncoding(949))
                {
                    cancel = true;
                }
                break;

            case 2:
                InputDialog dialog = WindowProvider.ShowWindow <InputDialog>(new InputDialog("Using an unsupported encoding may cause unexpected results, make a copy of your GRF file before saving!\nEnter the codepage number for the encoding :",
                                                                                             "Encoding", _comboBoxEncoding.Items[2].ToString().IndexOf(' ') > 0 ? _comboBoxEncoding.Items[2].ToString().Substring(0, _comboBoxEncoding.Items[2].ToString().IndexOf(' ')) : EncodingService.DisplayEncoding.CodePage.ToString(CultureInfo.InvariantCulture)), this);

                bool pageExists;

                if (dialog.Result == MessageBoxResult.OK)
                {
                    pageExists = EncodingService.EncodingExists(dialog.Input);

                    if (pageExists)
                    {
                        _comboBoxEncoding.SelectionChanged -= _comboBoxEncoding_SelectionChanged;
                        _comboBoxEncoding.Items[2]          = dialog.Input + "...";
                        _comboBoxEncoding.SelectedIndex     = 2;
                        _comboBoxEncoding.SelectionChanged += _comboBoxEncoding_SelectionChanged;
                        if (!SetEncoding(Int32.Parse(dialog.Input)))
                        {
                            cancel = true;
                        }
                    }
                    else
                    {
                        cancel = true;
                    }
                }
                else
                {
                    cancel = true;
                }

                break;

            default:
                if (!SetEncoding(1252))
                {
                    cancel = true;
                }
                break;
            }

            if (cancel)
            {
                _comboBoxEncoding.SelectionChanged -= _comboBoxEncoding_SelectionChanged;

                if (oldSelected != null)
                {
                    _comboBoxEncoding.SelectedItem = oldSelected;
                }

                _comboBoxEncoding.SelectionChanged += _comboBoxEncoding_SelectionChanged;
            }
            else
            {
                _delayedReloadDatabase = true;
            }
        }
Beispiel #17
0
        private void _comboBoxResEncoding_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            object oldSelected = null;
            bool   cancel      = false;

            if (e == null)
            {
                oldSelected = _comboBoxResEncoding.SelectedIndex;
            }
            else if (e.RemovedItems.Count > 0)
            {
                oldSelected = e.RemovedItems[0];
            }

            try {
                switch (_comboBoxResEncoding.SelectedIndex)
                {
                case 4:
                    if (sender == null)
                    {
                        break;
                    }

                    InputDialog dialog = WindowProvider.ShowWindow <InputDialog>(
                        new InputDialog(
                            "Using an unsupported encoding may cause unexpected results.\n" +
                            "Enter the codepage number for the encoding :",
                            "Encoding", SdeAppConfiguration.EncodingResCodePage.ToString(CultureInfo.InvariantCulture)), this);

                    if (dialog.DialogResult == true)
                    {
                        bool pageExists = EncodingService.EncodingExists(dialog.Input);

                        if (!pageExists)
                        {
                            cancel = true;
                        }
                        else
                        {
                            SdeAppConfiguration.EncodingResCodePage = Int32.Parse(dialog.Input);
                        }
                    }
                    else
                    {
                        cancel = true;
                    }
                    break;

                case 0:
                    SdeAppConfiguration.EncodingResCodePage = SdeAppConfiguration.EncodingCodepageClient;
                    break;

                case 1:
                    SdeAppConfiguration.EncodingResCodePage = SdeAppConfiguration.EncodingServer.CodePage;
                    break;

                case 2:
                    SdeAppConfiguration.EncodingResCodePage = 1252;
                    break;

                case 3:
                    SdeAppConfiguration.EncodingResCodePage = 949;
                    break;

                case -1:
                    return;
                }
            }
            catch {
                cancel = true;
            }

            if (cancel)
            {
                _comboBoxResEncoding.SelectionChanged -= _comboBoxResEncoding_SelectionChanged;

                if (oldSelected != null)
                {
                    _comboBoxResEncoding.SelectedItem = oldSelected;
                }

                _comboBoxResEncoding.SelectionChanged += _comboBoxResEncoding_SelectionChanged;
            }

            if (_comboBoxResEncoding.SelectedIndex > -1 && !cancel)
            {
                SdeAppConfiguration.EncodingResIndex = _comboBoxResEncoding.SelectedIndex;
            }
        }
Beispiel #18
0
        static void _handleMethodCall(string method, List <JSONNode> args)
        {
            if (GlobalContext.context != null)
            {
                using (WindowProvider.of(GlobalContext.context).getScope()) {
                    switch (method)
                    {
                    case "OnOpenNotification": {
                        if (args.isEmpty())
                        {
                            return;
                        }

                        //点击应用通知栏
                        var    node    = args.first();
                        var    dict    = JSON.Parse(node);
                        var    type    = dict["type"];
                        var    subType = dict["subtype"];
                        string id      = dict["id"] ?? "";
                        if (id.isEmpty())
                        {
                            id = dict["channelId"] ?? "";
                        }

                        AnalyticsManager.AnalyticsWakeApp("OnOpenNotification", id, type, subType);
                        AnalyticsManager.ClickNotification(type, subType, id);
                        pushPage(type, subType, id, true);
                        break;
                    }

                    case "OnReceiveNotification": {
                        //接收到推送
                        if (args.isEmpty())
                        {
                            return;
                        }

                        var node = args.first();
                        var dict = JSON.Parse(node);
                        var type = dict["type"] ?? "";
                        if (type != "messenger")
                        {
                            EventBus.publish(EventBusConstant.newNotifications, new List <object>());
                        }

                        var id = dict["id"] ?? "";
                        if (CTemporaryValue.currentPageModelId.isEmpty() ||
                            id != CTemporaryValue.currentPageModelId)
                        {
                            playMessageSound();
                        }

                        break;
                    }

                    case "OnReceiveMessage": {
                        //接收到应用内消息
                        break;
                    }

                    case "OnOpenUrl": {
                        if (args.isEmpty())
                        {
                            return;
                        }

                        AnalyticsManager.AnalyticsWakeApp("OnOpenUrl", args.first());
                        openUrl(args.first());
                        break;
                    }

                    case "OnOpenUniversalLinks": {
                        if (args.isEmpty())
                        {
                            return;
                        }

                        AnalyticsManager.AnalyticsWakeApp("OnOpenUniversalLinks", args.first());
                        openUniversalLink(args.first());
                        break;
                    }

                    case "CompletedCallback": {
                        if (args.isEmpty())
                        {
                            return;
                        }

                        clearIconBadge();
                        var node   = args.first();
                        var dict   = JSON.Parse(node);
                        var isPush = (bool)dict["push"];
                        if (isPush)
                        {
                            StoreProvider.store.dispatcher.dispatch(new MainNavigatorReplaceToAction {
                                    routeName = MainNavigatorRoutes.Main
                                });
                        }
                        else
                        {
                            if (PreferencesManager.initTabIndex() == 0 && SplashManager.isExistSplash())
                            {
                                StoreProvider.store.dispatcher.dispatch(new MainNavigatorPushReplaceSplashAction());
                            }
                            else
                            {
                                StoreProvider.store.dispatcher.dispatch(new MainNavigatorPushReplaceMainAction());
                            }
                        }

                        break;
                    }

                    case "RegisterToken": {
                        if (args.isEmpty())
                        {
                            return;
                        }

                        var node  = args.first();
                        var dict  = JSON.Parse(node);
                        var token = (string)dict["token"];
                        hmsToken = token;
                        registerHmsToken(StoreProvider.store.getState().loginState.isLoggedIn
                                ? StoreProvider.store.getState().loginState.loginInfo.userId
                                : "");
                        break;
                    }

                    case "SaveImageSuccess": {
                        CustomDialogUtils.showToast("保存成功", iconData: Icons.sentiment_satisfied);
                        break;
                    }

                    case "SaveImageError": {
                        CustomDialogUtils.showToast("保存失败,请检查权限", iconData: Icons.sentiment_dissatisfied);
                        break;
                    }
                    }
                }
            }
        }
Beispiel #19
0
        VideoPlayer _videoPlayer(string url)
        {
            var player      = VideoPlayerManager.instance.getPlayer();
            var audioSource = VideoPlayerManager.instance.getAudioSource();

            player.url             = url;
            player.renderMode      = VideoRenderMode.RenderTexture;
            player.source          = VideoSource.Url;
            player.audioOutputMode = VideoAudioOutputMode.AudioSource;
            player.SetTargetAudioSource(0, audioSource);
            player.playOnAwake = false;
            player.IsAudioTrackEnabled(0);
            player.targetTexture        = this._texture;
            player.isLooping            = false;
            player.sendFrameReadyEvents = true;
            player.aspectRatio          = VideoAspectRatio.Stretch;
            player.prepareCompleted    += this.prepareCompleted;
            player.frameReady          += (source, frameIndex) => {
                using (WindowProvider.of(this.widget.context).getScope()) {
                    _pauseAudioSession();
                    Texture.textureFrameAvailable();
                    if (this._relative * source.frameCount < frameIndex || frameIndex == 0)
                    {
                        this._isLoaded = true;
                        if (!this._isHiddenBar && !this._isReadyHiddenBar)
                        {
                            this._isReadyHiddenBar = true;
                            this._hiddenBar();
                        }
                    }

                    this._relative  = (float)frameIndex / source.frameCount;
                    this._isFailure = false;
                    if (this._playState == PlayState.play)
                    {
                        this._player.Play();
                    }

                    if (frameIndex == 0)
                    {
                        Promise.Delayed(TimeSpan.FromMilliseconds(200)).Then(() => { this.setState(() => { }); });
                    }
                    else
                    {
                        this.setState(() => { });
                    }
                }
            };
            player.loopPointReached += _player => {
                using (WindowProvider.of(this.widget.context).getScope()) {
                    this._relative  = 0.0f;
                    this._playState = PlayState.stop;
                    _player.Stop();
                    _player.frame = 0;
                    this.cancelTimer();
                    this._isHiddenBar      = false;
                    this._isReadyHiddenBar = false;
                    this.setState(() => { });
                }
            };
            player.errorReceived += this._errorReceived;
            player.Prepare();
            player.Pause();
            return(player);
        }
Beispiel #20
0
 private void _menuItemCopyAll_Click(object sender, RoutedEventArgs e)
 {
     WindowProvider.Show(new CopyDialog(this), _menuItemCopyAll);
 }