コード例 #1
0
            public KeyControl(KeyRebindTab parent, BoundKeyFunction function)
            {
                Function = function;
                var name = new Label
                {
                    Text = Loc.GetString(
                        $"ui-options-function-{CaseConversion.PascalToKebab(function.FunctionName)}"),
                    HorizontalExpand    = true,
                    HorizontalAlignment = HAlignment.Left
                };

                BindButton1 = new BindButton(parent, this, StyleBase.ButtonOpenRight);
                BindButton2 = new BindButton(parent, this, StyleBase.ButtonOpenLeft);
                ResetButton = new Button {
                    Text = Loc.GetString("ui-options-bind-reset"), StyleClasses = { StyleBase.ButtonCaution }
                };

                var hBox = new BoxContainer
                {
                    Orientation = LayoutOrientation.Horizontal,
                    Children    =
                    {
                        new Control {
                            MinSize = (5, 0)
                        },
コード例 #2
0
        public static void RemoveDuplicates(ref char[] arr, ref int arrLen)
        {
            bool unique = true;

            do
            {
                unique = true;
                for (int i = 0; i < arrLen - 1; i++)
                {
                    for (int j = i + 1; j < arrLen; j++)
                    {
                        if (CaseConversion.ToLowerCase(arr[i]) == CaseConversion.ToLowerCase(arr[j]) && (arr[i] != ' ' && arr[i] != '\n' && arr[i] != '\t'))
                        {
                            unique = false;
                            if (j < arrLen - 1)
                            {
                                for (int k = j + 1; k < arrLen; k++)
                                {
                                    arr[k - 1] = arr[k];
                                }
                            }
                            arrLen--;
                        }
                    }
                }
            } while (!unique);
        }
コード例 #3
0
        public void Assignment1()
        {
            Console.WriteLine("Assignment 1: Camel case and title case");
            CaseConversion caseObj = new CaseConversion();

            caseObj.UnitTestCases();
        }
コード例 #4
0
 private void Reset()
 {
     GUI.FocusControl(null);
     caseConversion = CaseConversion.None;
     oldValue       = ""; newValue = "";
     prefix         = ""; suffix = "";
 }
コード例 #5
0
 private void ResetConfigs()
 {
     GUI.FocusControl(null);
     caseConversion = CaseConversion.None;
     oldValue       = ""; newValue = "";
     prefix         = ""; suffix = "";
     GetObjects();
 }
コード例 #6
0
        public override async Task <(bool Changed, SongData song)> Execute(SongData song)
        {
            if (CaseConversion.CaseConvert(ref song))
            {
                return(true, song);
            }

            return(false, song);
        }
コード例 #7
0
ファイル: EZRenamer.cs プロジェクト: zjytra/EZUnity
 private void DrawConfig()
 {
     caseConversion = (CaseConversion)EditorGUILayout.EnumPopup("Case Conversion", caseConversion);
     {
         EditorGUILayout.BeginHorizontal();
         oldValue = EditorGUILayout.TextField("Replace", oldValue);
         newValue = EditorGUILayout.TextField("To", newValue);
         EditorGUILayout.EndHorizontal();
     }
     {
         EditorGUILayout.BeginHorizontal();
         prefix = EditorGUILayout.TextField("Prefix", prefix);
         suffix = EditorGUILayout.TextField("Suffix", suffix);
         EditorGUILayout.EndHorizontal();
     }
 }
コード例 #8
0
 private void DrawConfig()
 {
     selectionMode  = (SelectionMode)EditorGUILayout.EnumPopup("Selection Mode", selectionMode);
     caseConversion = (CaseConversion)EditorGUILayout.EnumPopup("Case Conversion", caseConversion);
     {
         EditorGUILayout.BeginHorizontal();
         oldValue = EditorGUILayout.TextField("Old Value", oldValue);
         newValue = EditorGUILayout.TextField("New Value", newValue);
         EditorGUILayout.EndHorizontal();
     }
     {
         EditorGUILayout.BeginHorizontal();
         prefix = EditorGUILayout.TextField("Prefix", prefix);
         suffix = EditorGUILayout.TextField("Suffix", suffix);
         EditorGUILayout.EndHorizontal();
     }
 }
コード例 #9
0
 private void DrawConfig()
 {
     caseConversion = (CaseConversion)EditorGUILayout.EnumPopup("Case Conversion", caseConversion);
     useRegex       = EditorGUILayout.Toggle("Use Regex", useRegex);
     {
         EditorGUILayout.BeginHorizontal();
         oldValue = EditorGUILayout.TextField("Replace", oldValue);
         newValue = EditorGUILayout.TextField("To", newValue);
         EditorGUILayout.EndHorizontal();
     }
     {
         EditorGUILayout.BeginHorizontal();
         prefix = EditorGUILayout.TextField("Prefix", prefix);
         suffix = EditorGUILayout.TextField("Suffix", suffix);
         EditorGUILayout.EndHorizontal();
     }
     showLog = EditorGUILayout.ToggleLeft("Show Log", showLog);
 }
コード例 #10
0
 public string PascalToKebab(string input)
 {
     return(CaseConversion.PascalToKebab(input));
 }
コード例 #11
0
        /// <summary>
        ///   Does the actual save of the Song
        /// </summary>
        /// <param name = "song"></param>
        /// <returns></returns>
        private bool SaveTrack(ref SongData song)
        {
            log.Trace(">>>");
            try
            {
                if (song.Changed)
                {
                    Util.StatusCurrentFile($"Saving file {song.FullFileName}");
                    log.Debug($"Save: Saving song: {song.FullFileName}");

                    // The track to be saved, may be currently playing. If this is the case stop playback to free the file
                    //if (track.FullFileName == TracksGrid.MainForm.Player.CurrentSongPlaying)
                    //{
                    //  Log.Debug("Save: Song is played in Player. Stop playback to free the file");
                    //  TracksGrid.MainForm.Player.Stop();
                    //}

                    if (options.MainSettings.CopyArtist && song.AlbumArtist == "")
                    {
                        song.AlbumArtist = song.Artist;
                    }

                    if (options.MainSettings.UseCaseConversion)
                    {
                        CaseConversion.CaseConvert(ref song);
                    }

                    var originalFileName = song.FullFileName; // Need the original filename for database update, in case a rename happens

                    // Save the file
                    var errorMessage = "";
                    if (Song.SaveFile(song, ref errorMessage))
                    {
                        if (RenameFile(song, out var newFileName))
                        {
                            // Read the Song with the new Information
                            song = Song.Create(newFileName);
                        }

                        // Check, if we need to create a folder.jpg
                        var fileName = Path.Combine(Path.GetDirectoryName(song.FullFileName), "folder.jpg");
                        if (!File.Exists(fileName) &&
                            options.MainSettings.CreateFolderThumb)
                        {
                            if (song.Pictures.Count > 0)
                            {
                                int indexFrontCover = song.Pictures
                                                      .Select((pic, i) => new { Pic = pic, Position = i }).First(m => m.Pic.Type == PictureType.FrontCover)
                                                      .Position;
                                if (indexFrontCover < 0)
                                {
                                    indexFrontCover = 0;
                                }

                                Util.SavePicture(song.Pictures[indexFrontCover], fileName);
                                var miscfileevt = new GenericEvent
                                {
                                    Action = "miscfileschanged"
                                };
                                EventSystem.Publish(miscfileevt);
                            }
                        }

                        // TODO: Update the Music Database
                        //ServiceScope.Get<IMusicDatabase>().UpdateTrack(track, originalFileName);

                        song.Status  = 0;
                        song.Changed = false;
                    }
                    else
                    {
                        song.Status    = 2;
                        song.StatusMsg = errorMessage;
                    }
                }
            }
            catch (Exception ex)
            {
                song.Status    = 2;
                song.StatusMsg = ex.Message;
                log.Error($"Save: Error Saving data for song {song.FileName}: {ex.Message} {ex.StackTrace}");
                return(false);
            }
            log.Trace("<<<");
            return(true);
        }