コード例 #1
0
        private async void HandleExecuteCmdMessage(Message message)
        {
            if (message.Payload == null)
            {
                return;
            }

            if (message.Payload is List <object> list)
            {
                double volume = 0;
                if ((double)list[3] == 50.0)
                {
                    volume = RoamingSettingsHelper.GetSetting <double>("volume", 50.0);
                }
                else
                {
                    volume = (double)list[3];
                }

                await Load(await SharedLogic.CreateMediafile(list[0] as StorageFile), (bool)list[2], (double)list[1], volume);
            }
            else
            {
                GetType().GetTypeInfo().GetDeclaredMethod(message.Payload as string)?.Invoke(this, new object[] { });
            }

            message.HandledStatus = MessageHandledStatus.HandledCompleted;
        }
コード例 #2
0
        public static async Task RenameFolder(this StorageLibraryChange item, IEnumerable <Mediafile> Library, LibraryService LibraryService)
        {
            int successCount = 0;
            List <Mediafile> ChangedMediafiles = new List <Mediafile>();

            //if it's a folder, get all elements in that folder and change their directory
            foreach (var mediaFile in await LibraryService.Query(item.PreviousPath.ToUpperInvariant()))
            {
                var libraryMediafile = Library.First(t => t.Path == mediaFile.Path);

                //change the folder path.
                //NOTE: this also works for subfolders
                mediaFile.FolderPath = mediaFile.FolderPath.Replace(item.PreviousPath, item.Path);
                mediaFile.Path       = mediaFile.Path.Replace(item.PreviousPath, item.Path);

                //verify that the new path exists before updating.
                if (SharedLogic.VerifyFileExists(mediaFile.Path, 200))
                {
                    successCount++;

                    //add to the list so we can update in bulk (it's faster that way.)
                    ChangedMediafiles.Add(mediaFile);

                    libraryMediafile.Path = mediaFile.Path;
                }
            }
            if (successCount > 0)
            {
                //update in bulk.
                LibraryService.UpdateMediafiles <Mediafile>(ChangedMediafiles);

                await SharedLogic.NotificationManager.ShowMessageAsync(string.Format("{0} Mediafiles Updated. Folder Path: {1}", successCount, item.Path), 5);
            }
        }
コード例 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            Button logClickButton = FindViewById <Button>(Resource.Id.logClickButton);

            logClickButton.Click += (s, e) => {
                ++clicksCount;
                logClickButton.Text = string.Format("{0} clicks logged", clicksCount);

                var dict = new Dictionary <string, string> {
                    { "click", clicksCount.ToString() }
                };
                YandexMetrica.Implementation.ReportEvent("Click from Android", dict);

                SharedLogic.LogClick(clicksCount);
            };

            Button logErrorButton = FindViewById <Button>(Resource.Id.logErrorButton);

            logErrorButton.Click += (s, e) => {
                ++errorsCount;
                logErrorButton.Text = string.Format("{0} errors logged", errorsCount);
                SharedLogic.LogError(errorsCount);
            };
        }
コード例 #4
0
        public override void OnCreate()
        {
            base.OnCreate();

            // Init Android AppMetrica directly
            YandexMetricaAndroid.YandexMetricaImplementation.Activate(this, SharedLogic.AppMetricaConfig(), this);
        }
コード例 #5
0
        public static async Task RemoveFolder(this StorageLibraryChange change, ThreadSafeObservableCollection <Mediafile> Library, LibraryService LibraryService)
        {
            int successCount = 0;
            List <Mediafile> RemovedMediafiles = new List <Mediafile>();

            //iterate all the files in the library that were in
            //the deleted folder.
            foreach (var mediaFile in await LibraryService.Query(string.IsNullOrEmpty(change.PreviousPath) ? change.Path.ToUpperInvariant() : change.PreviousPath.ToUpperInvariant()))
            {
                //verify that the file was deleted because it can be a false call.
                //we do not want to delete a file that exists.
                if (!SharedLogic.VerifyFileExists(mediaFile.Path, 200))
                {
                    RemovedMediafiles.Add(mediaFile);
                    successCount++;
                }
            }
            if (successCount > 0)
            {
                Library.RemoveRange(RemovedMediafiles);
                await LibraryService.RemoveMediafiles(RemovedMediafiles);

                await SharedLogic.NotificationManager.ShowMessageAsync(string.Format("{0} Mediafiles Removed. Folder Path: {1}", successCount, change.Path), 5);
            }
        }
コード例 #6
0
        private List <SubscriberDetail> GenerateSubscribersList(IEnumerable <Entity> contacts, string primaryEmail, MetadataHelper mdh)
        {
            trace.Trace("Generating Subscriber List");
            var subscribers = new List <SubscriberDetail>();

            foreach (Entity contact in contacts)
            {
                // remove the primary email field, it's sent as a separate param and we don't want duplicate fields
                var email = contact[primaryEmail].ToString();
                var name  = contact["fullname"].ToString();

                // check to make sure this contact isn't duplicated within the filter for the config
                if (!config.SyncDuplicateEmails && SharedLogic.CheckEmailIsDuplicate(orgService, config, primaryEmail, email))
                {
                    continue;
                }

                var fields = SharedLogic.ContactAttributesToSubscriberFields(orgService, trace, contact, contact.Attributes.Keys);
                fields = SharedLogic.PrettifySchemaNames(mdh, fields);

                subscribers.Add(new SubscriberDetail {
                    EmailAddress = email,
                    Name         = name,
                    CustomFields = fields
                });
            }

            return(subscribers);
        }
コード例 #7
0
        public static async Task <(string artistArtPath, Color dominantColor)> CacheArtistArt(string url, Artist artist)
        {
            var artistArtPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, @"ArtistArts\" + (artist.Name).ToLower().ToSha1() + ".jpg");

            if (!File.Exists(artistArtPath))
            {
                var artistArt = await ApplicationData.Current.LocalFolder.CreateFileAsync(@"ArtistArts\" + (artist.Name).ToLower().ToSha1() + ".jpg", CreationCollisionOption.FailIfExists);

                HttpClient client = new HttpClient();                                          // Create HttpClient
                byte[]     buffer = await client.GetByteArrayAsync(url).ConfigureAwait(false); // Download file

                using (FileStream stream = new FileStream(artistArt.Path, FileMode.Open, FileAccess.Write, FileShare.None, 51200, FileOptions.WriteThrough))
                {
                    await stream.WriteAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
                }
                var color = await SharedLogic.GetDominantColor(artistArt).ConfigureAwait(false);

                return(artistArt.Path, color);
            }
            else
            {
                var color = await SharedLogic.GetDominantColor(await StorageFile.GetFileFromPathAsync(artistArtPath)).ConfigureAwait(false);

                return(artistArtPath, color);
            }
        }
コード例 #8
0
        public static async void LoadSettings(bool onlyVol = false, bool play = false)
        {
            var volume = RoamingSettingsHelper.GetSetting <double>(VolKey, 50.0);

            if (!onlyVol)
            {
                _path = RoamingSettingsHelper.GetSetting <string>(PathKey, "");
                string folders = RoamingSettingsHelper.GetSetting <string>(FoldersKey, "");
                folders.Split('|').ToList().ForEach(async str =>
                {
                    if (!string.IsNullOrEmpty(str))
                    {
                        var folder = await StorageFolder.GetFolderFromPathAsync(str);
                        SharedLogic.SettingsVm.LibraryFoldersCollection.Add(folder);
                    }
                });
                // SettingsVM.LibraryFoldersCollection.ToList().ForEach(new Action<StorageFolder>((StorageFolder folder) => { folderPaths += folder.Path + "|"; }));
                if (_path != "" && SharedLogic.VerifyFileExists(_path, 300))
                {
                    double position = RoamingSettingsHelper.GetSetting <double>(PosKey, 0);
                    SharedLogic.Player.PlayerState = PlayerState.Paused;
                    try
                    {
                        Messenger.Instance.NotifyColleagues(MessageTypes.MsgExecuteCmd,
                                                            new List <object> {
                            await StorageFile.GetFileFromPathAsync(_path), position, play, volume
                        });
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        BLogger.Logger.Error("Access denied while trying to play file on startup.", ex);
                    }
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Adds storage files into library.
        /// </summary>
        /// <param name="files">List containing StorageFile(s).</param>
        /// <returns></returns>
        public async static Task AddStorageFilesToLibraryAsync(IEnumerable <StorageFile> files)
        {
            foreach (var file in files)
            {
                Mediafile mp3file = null;
                int       index   = -1;
                if (file != null)
                {
                    if (TracksCollection.Elements.Any(t => t.Path == file.Path))
                    {
                        index = TracksCollection.Elements.IndexOf(TracksCollection.Elements.First(t => t.Path == file.Path));
                        RemoveMediafile(TracksCollection.Elements.First(t => t.Path == file.Path));
                    }
                    //this methods notifies the Player that one song is loaded. We use both 'count' and 'i' variable here to report current progress.
                    await NotificationManager.ShowMessageAsync(" Song(s) Loaded");

                    await Task.Run(async() =>
                    {
                        //here we load into 'mp3file' variable our processed Song. This is a long process, loading all the properties and the album art.
                        mp3file = await SharedLogic.CreateMediafile(file, false); //the core of the whole method.
                        await SaveSingleFileAlbumArtAsync(mp3file, file).ConfigureAwait(false);
                    });

                    AddMediafile(mp3file, index);
                }
            }
        }
コード例 #10
0
ファイル: ThemeManager.cs プロジェクト: JTechMe/MBoard-UWP
        public static async void SetThemeColor(string albumartPath)
        {
            try
            {
                await SharedLogic.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
                {
                    if (App.Current.RequestedTheme == ApplicationTheme.Light && SharedLogic.SettingsVM.ChangeAccentByAlbumArt)
                    {
                        Color color;
                        if (!string.IsNullOrEmpty(albumartPath))
                        {
                            color = await SharedLogic.GetDominantColor(await StorageFile.GetFileFromPathAsync(albumartPath));
                        }
                        else
                        {
                            color = GetAccentColor();
                        }

                        var oldColor = GetThemeResource <SolidColorBrush>("SystemControlBackgroundAccentBrush").Color;
                        ChangeTitleBarColor(color);
                        GetThemeResource <SolidColorBrush>("SystemControlBackgroundAccentBrush").AnimateBrush(oldColor, color, "(SolidColorBrush.Color)");
                        foreach (var brushKey in brushKeys)
                        {
                            if (Application.Current.Resources.ContainsKey(brushKey))
                            {
                                ((SolidColorBrush)App.Current.Resources[brushKey]).Color = color;
                            }
                        }
                        //ThemeChanged.Invoke(null, new Events.ThemeChangedEventArgs(oldColor, color));
                    }
                });
            }
            catch { }
        }
コード例 #11
0
ファイル: SkillListForm.cs プロジェクト: cool8868/Soccer-King
        void Delete()
        {
            var selRow = SelectdRow();

            if (null == selRow)
            {
                SharedLogic.ShowMessage("请选择要删除的行");
                return;
            }
            var selXml = SharedLogic.GetSkillXml(this._rootXml, selRow[SkillItemData.COLSkillCode].ToString());

            if (null == selXml)
            {
                SharedLogic.ShowMessage("未找到要删除的节点");
                return;
            }
            string skillCode = selRow[SkillItemData.COLSkillCode].ToString();

            if (MessageBox.Show("确定要删除技能[" + skillCode + "]吗?", "系统信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }
            this._bindData.Rows.Remove(selRow);
            this._bindData.AcceptChanges();
            selXml.Remove();
        }
コード例 #12
0
        private async void Open(object para)
        {
            FileOpenPicker openPicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.MusicLibrary
            };

            openPicker.FileTypeFilter.Add(".mp3");
            openPicker.FileTypeFilter.Add(".wav");
            openPicker.FileTypeFilter.Add(".ogg");
            openPicker.FileTypeFilter.Add(".flac");
            openPicker.FileTypeFilter.Add(".m4a");
            openPicker.FileTypeFilter.Add(".aif");
            openPicker.FileTypeFilter.Add(".wma");
            StorageFile file = await openPicker.PickSingleFileAsync();

            if (file != null)
            {
                var mp3File = await SharedLogic.CreateMediafile(file, true);

                if (Player.PlayerState == PlayerState.Paused || Player.PlayerState == PlayerState.Stopped)
                {
                    await Load(mp3File);
                }
                else
                {
                    await Load(mp3File, true);
                }
            }
        }
コード例 #13
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Init iOS AppMetrica directly
            YandexMetricaIOS.YandexMetricaImplementation.Activate(SharedLogic.AppMetricaConfig());

            LogClickButton.AccessibilityIdentifier = "logClickButton";
            LogClickButton.TouchUpInside          += delegate {
                ++clicksCount;
                var title = string.Format("{0} clicks logged", clicksCount);
                LogClickButton.SetTitle(title, UIControlState.Normal);

                var dict = new Dictionary <string, string> {
                    { "click", clicksCount.ToString() }
                };
                YandexMetrica.Implementation.ReportEvent("Click from iOS", dict);

                SharedLogic.LogClick(clicksCount);
            };

            LogErrorButton.AccessibilityIdentifier = "logErrorButton";
            LogErrorButton.TouchUpInside          += delegate {
                ++errorsCount;
                var title = string.Format("{0} errors logged", errorsCount);
                LogErrorButton.SetTitle(title, UIControlState.Normal);

                SharedLogic.LogError(errorsCount);
            };
        }
コード例 #14
0
ファイル: SkillListForm.cs プロジェクト: cool8868/Soccer-King
        void _diagOpenFile_FileOk(object sender, CancelEventArgs e)
        {
            this.SelecedFile = this._diagOpenFile.FileName;
            var xd = XDocument.Load(this._openFilePath);

            this._rootXml = SharedLogic.WrapLoadXml(xd.Root);
            SharedLogic.FillBindSkillTable(this._bindData, this._rootXml);
        }
コード例 #15
0
        public async Task <IEnumerable <Mediafile> > LoadPlaylist(StorageFile file)
        {
            using (var streamReader = new StreamReader(await file.OpenStreamForReadAsync()))
            {
                List <Mediafile> playlistSongs = new List <Mediafile>();
                string           line;
                int  index       = 0;
                int  failedFiles = 0;
                bool ext         = false;
                while ((line = streamReader.ReadLine()) != null)
                {
                    if (line.ToLower() == "#extm3u") //m3u header
                    {
                        ext = true;
                    }
                    else if (ext && line.ToLower().StartsWith("#extinf:")) //extinfo of each song
                    {
                        continue;
                    }
                    else if (line.StartsWith("#") || line == "") //pass blank lines
                    {
                        continue;
                    }
                    else
                    {
                        await Task.Run(async() =>
                        {
                            try
                            {
                                index++;
                                FileInfo info = new FileInfo(file.Path);  //get playlist file info to get directory path
                                string path   = line;
                                if (!File.Exists(line) && line[1] != ':') // if file doesn't exist then perhaps the path is relative
                                {
                                    path = info.DirectoryName + line;     //add directory path to song path.
                                }

                                var accessFile = await StorageFile.GetFileFromPathAsync(path);
                                var token      = StorageApplicationPermissions.FutureAccessList.Add(accessFile);

                                Mediafile mp3File = await SharedLogic.CreateMediafile(accessFile); //prepare Mediafile

                                await SettingsViewModel.SaveSingleFileAlbumArtAsync(mp3File, accessFile);
                                playlistSongs.Add(mp3File);
                                StorageApplicationPermissions.FutureAccessList.Remove(token);
                            }
                            catch
                            {
                                failedFiles++;
                            }
                        });
                    }
                }
                return(playlistSongs);
            }
        }
コード例 #16
0
        /// <summary>
        /// Asynchronously saves all the album arts in the library.
        /// </summary>
        /// <param name="Data">ID3 tag of the song to get album art data from.</param>
        public static async Task <bool> SaveAlbumArtsAsync(StorageFile file, Mediafile mediafile)
        {
            var albumArt = AlbumArtFileExists(mediafile);

            if (!albumArt.NotExists)
            {
                return(false);
            }

            try
            {
                using (StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(ThumbnailMode.MusicView, 512, ThumbnailOptions.ReturnOnlyIfCached))
                {
                    if (thumbnail == null && SharedLogic.VerifyFileExists(file.Path, 150))
                    {
                        using (TagLib.File tagFile = TagLib.File.Create(new SimpleFileAbstraction(file), TagLib.ReadStyle.Average))
                        {
                            if (tagFile.Tag.Pictures.Length >= 1)
                            {
                                var image = await ApplicationData.Current.LocalFolder.CreateFileAsync(@"AlbumArts\" + albumArt.FileName + ".jpg", CreationCollisionOption.FailIfExists);

                                using (FileStream stream = new FileStream(image.Path, FileMode.Open, FileAccess.Write, FileShare.None, 51200, FileOptions.WriteThrough))
                                {
                                    await stream.WriteAsync(tagFile.Tag.Pictures[0].Data.Data, 0, tagFile.Tag.Pictures[0].Data.Data.Length);
                                }
                                return(true);
                            }
                        }
                    }
                    else
                    {
                        var albumart = await ApplicationData.Current.LocalFolder.CreateFileAsync(@"AlbumArts\" + albumArt.FileName + ".jpg", CreationCollisionOption.FailIfExists);

                        IBuffer buf;
                        Windows.Storage.Streams.Buffer inputBuffer = new Windows.Storage.Streams.Buffer((uint)thumbnail.Size / 2);
                        using (IRandomAccessStream albumstream = await albumart.OpenAsync(FileAccessMode.ReadWrite))
                        {
                            while ((buf = await thumbnail.ReadAsync(inputBuffer, inputBuffer.Capacity, InputStreamOptions.ReadAhead)).Length > 0)
                            {
                                await albumstream.WriteAsync(buf);
                            }

                            return(true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //await SharedLogic.NotificationManager.ShowMessageAsync(ex.Message + "||" + file.Path);
            }

            return(false);
        }
コード例 #17
0
        public override System.Xml.Linq.XElement GetValue()
        {
            var xe = base.GetValue();

            if (null != xe)
            {
                xe.SetAttributeValue(SharedData.KEYMemo, SharedLogic.GetSkillMemo(xe));
                xe.SetAttributeValue(SharedData.KEYClipId, SharedLogic.GetClipId(xe));
                xe.SetAttributeValue(SharedData.KEYModelId, SharedLogic.GetModelId(xe));
            }
            return(xe);
        }
コード例 #18
0
ファイル: SkillListForm.cs プロジェクト: cool8868/Soccer-King
 void menuCheck_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(this._openFilePath))
     {
         SharedLogic.ShowMessage("请先打开需要验证的文件");
         return;
     }
     if (CheckRules.CheckFile(this._openFilePath))
     {
         SharedLogic.ShowMessage("文件格式正确有效");
     }
 }
コード例 #19
0
        private QueryExpression GetBulkSyncFilter(CampaignMonitorConfiguration config, BulkSyncData syncData, string primaryEmail)
        {
            // retrieve contacts based on the filter, grabbing the columns specified either
            // in the fields to sync (on config entity) or fields specified in the bulkdata sync fields
            QueryExpression viewFilter;

            if (config.SyncViewId != null && config.SyncViewId != Guid.Empty)
            {
                viewFilter = SharedLogic.GetConfigFilterQuery(orgService, config.SyncViewId);
            }
            else
            {
                // if no view filter, sync all active contacts
                viewFilter = new QueryExpression("contact");
                viewFilter.Criteria.AddCondition(
                    new ConditionExpression("statecode", ConditionOperator.Equal, 0));
            }

            viewFilter.ColumnSet.Columns.Clear();
            foreach (var link in viewFilter.LinkEntities)
            {
                link.Columns.Columns.Clear();
            }

            if (syncData.UpdatedFields != null && syncData.UpdatedFields.Length > 0)
            {
                viewFilter.ColumnSet.Columns.AddRange(syncData.UpdatedFields);
            }
            else
            {
                viewFilter.ColumnSet.Columns.AddRange(config.SyncFields);
            }

            // add required fields for syncing if they are not a part of the filter
            if (!viewFilter.ColumnSet.Columns.Contains(primaryEmail))
            {
                viewFilter.ColumnSet.Columns.Add(primaryEmail);
            }

            if (!viewFilter.ColumnSet.Columns.Contains("fullname"))
            {
                viewFilter.ColumnSet.Columns.Add("fullname");
            }

            viewFilter.AddOrder("modifiedon", OrderType.Ascending);
            viewFilter.PageInfo.Count = BATCH_AMOUNT;
            viewFilter.PageInfo.ReturnTotalRecordCount = true;

            return(viewFilter);
        }
コード例 #20
0
        private void SendSubscriberToList(string listId, string emailField, List <SubscriberCustomField> fields)
        {
            // send subscriber to campaign monitor list using CM API
            var name  = fields.Where(f => f.Key == "fullname").FirstOrDefault();
            var email = fields.Where(f => f.Key == emailField).FirstOrDefault();

            MetadataHelper mdh = new MetadataHelper(orgService, tracer);

            fields = SharedLogic.PrettifySchemaNames(mdh, fields);

            Subscriber subscriber = new Subscriber(authDetails, listId);

            subscriber.Add(email?.Value, name?.Value, fields, false, false);
        }
コード例 #21
0
        FlatCtrl GetFlatCtrl(string classKey)
        {
            FlatCtrl flatCtrl = null;

            if (dicFlatCtrl.TryGetValue(classKey, out flatCtrl) && null != flatCtrl)
            {
                return(flatCtrl);
            }
            flatCtrl = SharedLogic.GetFlatControl(classKey);
            if (null != flatCtrl)
            {
                flatCtrl.Dock         = DockStyle.Top;
                dicFlatCtrl[classKey] = flatCtrl;
            }
            return(flatCtrl);
        }
コード例 #22
0
        public void SendMessage(Entity target)
        {
            var emailField = target["campmon_email"].ToString();
            List <SubscriberCustomField> contactData = JsonConvert.DeserializeObject <List <SubscriberCustomField> >(target["campmon_data"].ToString());

            // If campmon_syncduplicates = 'false', do a retrieve multiple for any contact
            //      that matches the email address found in the sync email of the contact.
            // if yes : set campmon_error on message to "Duplicate email"
            if (!campaignMonitorConfig.SyncDuplicateEmails)
            {
                var contactEmail = contactData.Where(x => x.Key == emailField).FirstOrDefault();
                if (contactEmail == null)
                {
                    tracer.Trace("The email field to sync was not found within the data for this message.");
                    target["campmon_error"] = "The email field to sync was not found within the data for this message.";
                    orgService.Update(target);
                    return;
                }

                bool emailIsDuplicate = SharedLogic.CheckEmailIsDuplicate(orgService, campaignMonitorConfig, emailField, contactEmail.Value.ToString());
                if (emailIsDuplicate)
                {
                    tracer.Trace("Duplicate email");
                    target["campmon_error"] = "Duplicate email";
                    orgService.Update(target);
                    return;
                }
            }

            try
            {
                SendSubscriberToList(campaignMonitorConfig.ListId, emailField, contactData);
            }
            catch (Exception ex)
            {
                target["campmon_error"] = ex.Message;
                orgService.Update(target);
                return;
            }

            tracer.Trace("User successfully sent to CM.");

            // deactivate msg if successful create/update
            target["statuscode"] = new OptionSetValue(2);
            target["statecode"]  = new OptionSetValue(1);
            orgService.Update(target);
        }
コード例 #23
0
 public static async Task RemoveItem(this StorageLibraryChange change, IEnumerable <Mediafile> Library, LibraryService LibraryService)
 {
     if (change.IsOfType(StorageItemTypes.File))
     {
         if (IsItemInLibrary(change, Library, out Mediafile movedItem))
         {
             if (await SharedLogic.RemoveMediafile(movedItem))
             {
                 await SharedLogic.NotificationManager.ShowMessageAsync(string.Format("Mediafile Removed. File Path: {0}", movedItem.Path), 5);
             }
         }
     }
     else
     {
         await RemoveFolder(change, (ThreadSafeObservableCollection <Mediafile>) Library, LibraryService);
     }
 }
コード例 #24
0
ファイル: ThemeManager.cs プロジェクト: jmbits/BreadPlayer
        public static async void SetThemeColor(string albumartPath)
        {
            await BreadDispatcher.InvokeAsync(async() =>
            {
                if (SharedLogic.SettingsVm.ChangeAccentByAlbumArt == false)
                {
                    ChangeColor(GetAccentColor());
                    return;
                }
                if (RoamingSettingsHelper.GetSetting <string>("SelectedTheme", "Light") == "Light" && SharedLogic.SettingsVm.ChangeAccentByAlbumArt)
                {
                    try
                    {
                        Color color;
                        if (!string.IsNullOrEmpty(albumartPath) && albumartPath != "default")
                        {
                            color = await SharedLogic.GetDominantColor(await StorageFile.GetFileFromPathAsync(albumartPath));
                        }
                        else if (albumartPath == "default" && SharedLogic.Player.CurrentlyPlayingFile != null)
                        {
                            color = await SharedLogic.GetDominantColor(await StorageFile.GetFileFromPathAsync(SharedLogic.Player.CurrentlyPlayingFile.AttachedPicture));
                        }
                        else
                        {
                            color = GetAccentColor();
                        }

                        ChangeColor(color);
                    }
                    catch (Exception ex)
                    {
                        BLogger.Logger.Error("Failed to update accent.", ex);
                        await SharedLogic.NotificationManager.ShowMessageAsync(ex.Message);
                    }
                    //ThemeChanged?.Invoke(null, new Events.ThemeChangedEventArgs(oldColor, color));
                }
                else
                {
                    ChangeColor(GetAccentColor());
                }
            });
        }
コード例 #25
0
        public static async Task AddNewItem(this StorageLibraryChange change)
        {
            if (change.IsOfType(StorageItemTypes.File))
            {
                if (await change.GetStorageItemAsync() == null)
                {
                    return;
                }
                if (IsItemPotentialMediafile(await change.GetStorageItemAsync()))
                {
                    var newFile = await SharedLogic.CreateMediafile((StorageFile)await change.GetStorageItemAsync());

                    newFile.FolderPath = Path.GetDirectoryName(newFile.Path);
                    if (SharedLogic.AddMediafile(newFile))
                    {
                        await SharedLogic.NotificationManager.ShowMessageAsync(string.Format("Mediafile Added. File Path: {0}", newFile.Path), 5);
                    }
                }
            }
        }
コード例 #26
0
        public static async Task UpdateChangedItem(this StorageLibraryChange change, IEnumerable <Mediafile> Library, LibraryService LibraryService)
        {
            if (change.IsOfType(StorageItemTypes.File))
            {
                if (IsItemInLibrary(change, Library, out Mediafile createdItem))
                {
                    var id = createdItem.Id;
                    createdItem = await SharedLogic.CreateMediafile((StorageFile)await change.GetStorageItemAsync());

                    createdItem.Id = id;
                    if (await LibraryService.UpdateMediafile(createdItem))
                    {
                        await SharedLogic.NotificationManager.ShowMessageAsync(string.Format("Mediafile Updated. File Path: {0}", createdItem.Path), 5);
                    }
                }
                else
                {
                    await AddNewItem(change);
                }
            }
        }
コード例 #27
0
ファイル: SkillEditForm.cs プロジェクト: cool8868/Soccer-King
 public void Init(OperationState opState, string editCode, XElement rootXml, DataTable bindData)
 {
     this.OpState   = opState;
     this._editCode = editCode;
     this._rootXml  = rootXml;
     this._bindData = bindData;
     this.ucSkill.InitData();
     if (string.IsNullOrEmpty(this._editCode))
     {
         this._editXml = new XElement(SharedLogic.KEYSkill);
         return;
     }
     this._editXml = SharedLogic.GetSkillXml(this._rootXml, this._editCode);
     this.ucSkill.SetValue(this._editXml);
     if (opState == OperationState.CopyNew)
     {
         this._editXml = new XElement(SharedLogic.KEYSkill);
         this.ucSkill.txtSkillCode.Text = "";
         this.ucSkill.txtSkillCode.Focus();
     }
 }
コード例 #28
0
 public static async void SetThemeColor(string albumartPath)
 {
     await SharedLogic.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
     {
         if (SharedLogic.SettingsVM.ChangeAccentByAlbumArt == false)
         {
             ChangeColor(GetAccentColor());
             return;
         }
         if (App.Current.RequestedTheme == ApplicationTheme.Light && SharedLogic.SettingsVM.ChangeAccentByAlbumArt)
         {
             try
             {
                 Color color;
                 if (!string.IsNullOrEmpty(albumartPath) && albumartPath != "default")
                 {
                     color = await SharedLogic.GetDominantColor(await StorageFile.GetFileFromPathAsync(albumartPath));
                 }
                 else if (albumartPath == "default" && SharedLogic.Player.CurrentlyPlayingFile != null)
                 {
                     color = await SharedLogic.GetDominantColor(await StorageFile.GetFileFromPathAsync(SharedLogic.Player.CurrentlyPlayingFile.AttachedPicture));
                 }
                 else
                 {
                     color = GetAccentColor();
                 }
                 ChangeColor(color);
             }
             catch (Exception ex)
             {
                 BLogger.Logger.Error("Failed to update accent.", ex);
                 await Core.SharedLogic.NotificationManager.ShowMessageAsync(ex.Message);
             }
             //ThemeChanged.Invoke(null, new Events.ThemeChangedEventArgs(oldColor, color));
         }
     });
 }
コード例 #29
0
ファイル: SkillListForm.cs プロジェクト: cool8868/Soccer-King
        void Edit(OperationState opState)
        {
            string skillCode = string.Empty;

            if (opState == OperationState.Edit || opState == OperationState.CopyNew)
            {
                var selRow = SelectdRow();
                if (null == selRow)
                {
                    SharedLogic.ShowMessage("请选择要编辑的行");
                    return;
                }
                skillCode = selRow[SkillItemData.COLSkillCode].ToString();
            }
            this._bindData.TableName = string.Empty;
            var editForm = new SkillEditForm();

            editForm.Init(opState, skillCode, this._rootXml, this._bindData);
            editForm.ShowDialog();
            string newCode = this._bindData.TableName;

            if (string.IsNullOrEmpty(newCode))
            {
                return;
            }
            foreach (DataGridViewRow gridRow in this.gridList.Rows)
            {
                var bindRow = ((DataRowView)gridRow.DataBoundItem).Row;
                if (string.Compare(bindRow[SkillItemData.COLSkillCode].ToString(), newCode, true) == 0)
                {
                    gridRow.Selected     = true;
                    gridList.CurrentCell = gridRow.Cells[0];
                    return;
                }
            }
            this._bindData.DefaultView.RowFilter = "";
        }
コード例 #30
0
ファイル: SkillListForm.cs プロジェクト: cool8868/Soccer-King
 void Save(bool newFlag)
 {
     if (string.IsNullOrEmpty(this._openFilePath) || newFlag)
     {
         if (this._diagSaveFile.ShowDialog() != DialogResult.OK)
         {
             return;
         }
     }
     try
     {
         this._bindData.DefaultView.RowFilter = "";
         var nXml = SharedLogic.WrapSaveXml(this._rootXml);
         nXml.Save(this._openFilePath);
         var    clientXml = SharedLogic.GenClientXml(nXml);
         string fileName  = this._openFilePath.Substring(this._openFilePath.LastIndexOf('\\') + 1);
         clientXml.Save(this._openFilePath.Replace(fileName, "SkillClient.xml"));
         SharedLogic.ShowMessage("保存成功");
     }
     catch (Exception ex)
     {
         SharedLogic.ShowMessage("保存文件失败:" + ex.Message + "\n" + ex.StackTrace);
     }
 }