Example #1
0
        private async void Launch_Media(object sender, RoutedEventArgs e)
        {
            MediaMessageType type = rbtnNone.IsChecked.Value ? MediaMessageType.None : rbtnVideo.IsChecked.Value ? MediaMessageType.Video : MediaMessageType.Voice;

            switch (type)
            {
            case MediaMessageType.Video:
                if (_video_file != null)
                {
                    await Launcher.LaunchFileAsync(_video_file);
                }
                else
                {
                    await Launcher.LaunchFileAsync(await StorageFile.GetFileFromApplicationUriAsync(_evnt.MediaMessageUri));
                }
                break;

            case MediaMessageType.Voice:
                if (_voice_file != null)
                {
                    await Launcher.LaunchFileAsync(_voice_file);
                }
                else
                {
                    await Launcher.LaunchFileAsync(await StorageFile.GetFileFromApplicationUriAsync(_evnt.MediaMessageUri));
                }
                break;
            }
        }
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            string           param = parameter as string;
            MediaMessageType type  = (MediaMessageType)value;

            switch (type)
            {
            case MediaMessageType.None:
                if (param == "vis")
                {
                    return(Visibility.Collapsed);
                }
                else
                {
                    return("");
                }

            case MediaMessageType.Video:
                if (param == "vis")
                {
                    return(Visibility.Visible);
                }
                else
                {
                    return(App.Eng ? "Video" : "Видео");
                }

            case MediaMessageType.Voice:
                if (param == "vis")
                {
                    return(Visibility.Visible);
                }
                else
                {
                    return(App.Eng ? "Audio" : "Аудио");
                }

            default:
                return(null);
            }
        }
Example #3
0
        private async Task Save()
        {
            Event newEvnt = new Event(_evnt.Guid);

            newEvnt.Name = nameBox.Text;
            string name = newEvnt.Guid.ToString();

            if (clndPicker.Date.Value.Date == _evnt.Date.Date)
            {
                newEvnt.Date = _evnt.Date;
            }
            else
            {
                newEvnt.Date = clndPicker.Date.Value.Date + DateTimeOffset.Now.TimeOfDay;
            }

            if (_icon_file == null)
            {
                if (_evnt.IconPath.AbsoluteUri.StartsWith("ms-appx"))
                {
                    newEvnt.IconPath = _evnt.IconPath;
                }
                else
                {
                    _icon_file = await(await StorageFile.GetFileFromApplicationUriAsync(_evnt.IconPath)).CopyAsync(ApplicationData.Current.TemporaryFolder);
                }
            }
            newEvnt.Message = txtBox.Text;
            MediaMessageType type = rbtnNone.IsChecked.Value ? MediaMessageType.None : rbtnVideo.IsChecked.Value ? MediaMessageType.Video : MediaMessageType.Voice;

            newEvnt.MediaMessageType = type;
            if (type == MediaMessageType.Video)
            {
                if (_video_file == null)
                {
                    _video_file = await(await StorageFile.GetFileFromApplicationUriAsync(_evnt.MediaMessageUri)).CopyAsync(ApplicationData.Current.TemporaryFolder);
                }
            }
            else if (type == MediaMessageType.Voice)
            {
                if (_voice_file == null)
                {
                    _voice_file = await(await StorageFile.GetFileFromApplicationUriAsync(_evnt.MediaMessageUri)).CopyAsync(ApplicationData.Current.TemporaryFolder);
                }
            }

            Task task = App.Storage.RemoveAsync(_evnt);

            if (notiftgl.IsOn)
            {
                if (alarmOffset == null)
                {
                    alarmOffset = clndPicker.Date.Value.Date + timePicker.Time;
                }
                var xml = App.FormNotification(newEvnt.Name, notiftgl.IsOn ? newEvnt.Message : "", newEvnt.IconPath.AbsoluteUri, newEvnt.Guid.ToString());
                ScheduledToastNotification notification = new ScheduledToastNotification(xml, alarmOffset.Value);
                ToastNotificationManager.CreateToastNotifier().AddToSchedule(notification);
                newEvnt.Alarm = alarmOffset.Value;
            }
            await task;

            _evnt = newEvnt;

            if (ink.InkPresenter.StrokeContainer.GetStrokes().Count > 0)
            {
                _strokes.Clear();
                foreach (var stroke in ink.InkPresenter.StrokeContainer.GetStrokes())
                {
                    _strokes.Add(stroke.Clone());
                }
                _evnt.HasStroke = true;
                StorageFile file = await(await ApplicationData.Current.LocalFolder.
                                         CreateFolderAsync("Inks", CreationCollisionOption.OpenIfExists)).CreateFileAsync(newEvnt.Guid.ToString() + ".gif", CreationCollisionOption.ReplaceExisting);
                using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    using (IOutputStream outStream = stream.GetOutputStreamAt(0))
                    {
                        await ink.InkPresenter.StrokeContainer.SaveAsync(outStream);

                        await outStream.FlushAsync();
                    }
                }
            }
            else
            {
                _strokes.Clear();
            }

            if (_icon_file != null)
            {
                _evnt.IconPath = await StoreFile("Icons", _icon_file);

                if (_delete)
                {
                    _delete = false;
                    await _icon_file.DeleteAsync(StorageDeleteOption.PermanentDelete);
                }
                _icon_file = null;
            }

            if (_video_file != null)
            {
                _evnt.MediaMessageUri = await StoreFile("Videos", _video_file);

                await _video_file.DeleteAsync();

                _video_file = null;
            }
            if (_voice_file != null)
            {
                _evnt.MediaMessageUri = await StoreFile("Audios", _voice_file);

                await _voice_file.DeleteAsync();

                _voice_file = null;
            }
            _evnt.Keep = !delChkBox.IsChecked.Value;
            task       = _evnt.SaveToFileAsync();
            App.Storage.AddEvent(_evnt);
            Uncheck(true);
            await task;

            App.State.MenuSelected = _evnt.IsPast ? MenuSelection.Past : MenuSelection.Scheduled;
            App.State.Year         = _evnt.Date.Year;
            App.State.Month        = _evnt.Date.Month;
            App.State.ActivePage   = PageActive.Events;
            App.MenuRefresh();
        }