public MainWindow() { InitializeComponent(); BindingObject = ObjectFactory.GetBindingObject(); DataContext = BindingObject; FormManagerObject = ObjectFactory.GetFormManager(BindingObject); EnableWindowElements(false); }
public void GetSuggestions(IWindowProperties formPropertiesObject) { tagDB.ExecuteSQLQuery(this.GetSQLQuery(formPropertiesObject)); while (tagDB.Read()) { tagDB.IsNewSong = true; Assign.AssignTo(formPropertiesObject, tagDB, formPropertiesObject); } }
private string GetSQLQuery(IWindowProperties currentValues) { string sqlQuery = null; bool isFirstCondition = true; string sqlSELECTQuery = "SELECT Songs.SongTitle, " + "art.ArtistName AS Artist_Name, " + "contArt.ArtistName AS ContArtists_Name, " + "Albums.AlbumName, " + "Songs.Year, " + "Songs.TrackNo, " + "Songs.Genre "; string sqlFROMQuery = "FROM ContributingArtists " + "INNER JOIN Songs ON Songs.ID = ContributingArtists.SongID " + "INNER JOIN Albums ON Albums.ID = Songs.AlbumID " + "INNER JOIN Artists AS art ON art.ID = Songs.ArtistID " + "INNER JOIN Artists AS contArt ON contArt.ID = ContributingArtists.ArtistID "; string sqlWHEREQuery = ""; Action<ObservableCollection<string>, string, bool> generateQuery = (property, columnName, loop) => { if (property.Count > 0) { if (isFirstCondition) sqlWHEREQuery += String.Format("WHERE (UPPER(" + columnName + ") LIKE UPPER('{0}') ", property[0]); else sqlWHEREQuery += String.Format("AND (UPPER(" + columnName + ") LIKE UPPER('{0}') ", property[0]); if (loop) { foreach (string artist in property[0].Split(';')) { sqlWHEREQuery += String.Format("OR UPPER(" + columnName + ") LIKE UPPER('{0}') ", artist); } } sqlWHEREQuery += ")"; isFirstCondition = false; } }; generateQuery(currentValues.Title, "Songs.SongTitle", false); generateQuery(currentValues.Artist, "art.ArtistName", false); generateQuery(currentValues.ContributingArtists, "contArt.ArtistName", true); generateQuery(currentValues.Album, "Albums.AlbumName", false); generateQuery(currentValues.Year, "Songs.Year", false); generateQuery(currentValues.TrackNo, "Songs.TrackNo", false); generateQuery(currentValues.Genre, "Songs.Genre", false); sqlQuery = sqlSELECTQuery + sqlFROMQuery + sqlWHEREQuery; return sqlQuery; }
public InputViewModel(IWpfCalculationExecutor executor, IApplicationArguments arguments, IEventAggregator eventAggregator, InputStringValidator validator, IConversionProperties conversionProperties, IWindowProperties windowProperties, IUnitsAndAbbreviationsSource unitsAndAbbreviationsSource) { mExecutor = executor; mArguments = arguments; mEventAggregator = eventAggregator; mValidator = validator; mConversionProperties = conversionProperties; mWindowProperties = windowProperties; mUnitsAndAbbreviationsSource = unitsAndAbbreviationsSource; mStepExpander = mWindowProperties.AreStepsExpanded; }
public string Rename(string filePath, IWindowProperties formPropertiesObject) { string formmatedFilename = this.GenerateFormattedName(filePath, formPropertiesObject); string newFilePath = System.IO.Path.GetDirectoryName(filePath) + "\\" + formmatedFilename; if (System.IO.File.Exists(filePath)) System.IO.File.Move(filePath, newFilePath); else MessageBox.Show("The file at:" + filePath + " was not found.", "Error!"); return newFilePath; }
public override void ShowScreen <TProp>(IWindowController screen, TProp properties) { IWindowProperties windowProp = properties as IWindowProperties; if (ShouldEnqueue(screen, windowProp)) { EnqueueWindow(screen, properties); } else { DoShow(screen, windowProp); } }
public bool AddToDatabase(IWindowProperties formPropertiesObject) { this.addNewArtistRecord(formPropertiesObject.Artist[0]); this.addNewAlbumRecord(formPropertiesObject.Album[0], formPropertiesObject.Year[0], formPropertiesObject.Genre[0], GetHash(formPropertiesObject.Artist[0])); this.addNewSongRecord(formPropertiesObject.Title[0], GetHash(formPropertiesObject.Artist[0]), formPropertiesObject.Year[0], formPropertiesObject.Genre[0], GetHash(formPropertiesObject.Album[0]), formPropertiesObject.TrackNo[0]); foreach (string artist in formPropertiesObject.ContributingArtists[0].Split(';')) { this.addNewArtistRecord(artist); this.addNewContributingArtists(GetHash(formPropertiesObject.Title[0]), GetHash(artist)); } return true; }
public static void AssignTo(IReadAndWriteable<ObservableCollection<string>> Left, IReadAndWriteable<string> Right, IWindowProperties LockedStatus) { Action<ObservableCollection<string>, string, bool> AddTo = (LHS, RHS, IsLocked) => { if (!IsLocked) if (!LHS.Contains(RHS)) LHS.Add(RHS); }; AddTo(Left.Title, Right.Title, LockedStatus.CheckBoxTitle); AddTo(Left.Artist, Right.Artist, LockedStatus.CheckBoxArtist); AddTo(Left.ContributingArtists, Right.ContributingArtists, LockedStatus.CheckBoxContributingArtists); AddTo(Left.Album, Right.Album, LockedStatus.CheckBoxAlbum); AddTo(Left.Year, Right.Year, LockedStatus.CheckBoxYear); AddTo(Left.TrackNo, Right.TrackNo, LockedStatus.CheckBoxTrackNo); AddTo(Left.Genre, Right.Genre, LockedStatus.CheckBoxGenre); }
public override Task ShowScreen <TProps>(IWindowController screen, TProps properties) { Task result; IWindowProperties windowProperties = properties as WindowProperties; if (ShouldEnqueue(screen, windowProperties)) { EnqueueWindow(screen, windowProperties); result = Task.CompletedTask; } else { result = DoShow(screen, windowProperties); } return(result); }
public ShellViewModel( InputViewModel input, ConversionViewModel conversion, IEventAggregator eventAggregator, ConfigurationWindowViewModel configurationWindow, IWindowManager windowManager, IWindowProperties windowProperties, IConversionProperties conversionProperties) { mConfigurationWindow = configurationWindow; mWindowManager = windowManager; mWindowProperties = windowProperties; mConversionProperties = conversionProperties; Input = input; Conversion = conversion; eventAggregator.Subscribe(this); SetupWindowAttributesFromConfig(); }
private bool ShouldEnqueue(IWindowController controller, IWindowProperties windowProp) { if (CurrentWindow == null && windowQueue.Count == 0) { return(false); } if (windowProp != null && windowProp.SuppressPrefabProperties) { return(windowProp.WindowQueuePriority != WindowPriority.ForceForeground); } if (controller.WindowPriority != WindowPriority.ForceForeground) { return(true); } return(false); }
private bool ShouldEnqueue(IWindowController window, IWindowProperties properties) { bool result = false; if (CurrentWindow == null && windowQueue.Count == 0) { result = false; } else if (properties != null && properties.SupressPrefabProperties) { result = properties.WindowQueuePriority != WindowPriority.ForceForeground; } else if (window.WindowPriority != WindowPriority.ForceForeground) { result = true; } return(result); }
public ConversionViewModel(IEventAggregator eventAggregator, IWindowProperties windowProperties, IConversionProperties conversionProperties) { mEventAggregator = eventAggregator; mWindowProperties = windowProperties; mConversionProperties = conversionProperties; SetListsForView(); AllUnitsAndAbbreviations = new List <List <UnitAbbreviationsAndNames> > { MetricalMasses, MetricalAreas, MetricalLengths, MetricalVolumes, ImperialMasses, ImperialAreas, ImperialLengths, ImperialVolumes }; SetUnitOnStartup(); mToMetric = mConversionProperties.DoUseMetricSystem; mToImperial = !mConversionProperties.DoUseMetricSystem; mUnitExpander = mWindowProperties.AreUnitsExpanded; }
public WindowHistoryEntry(IWindowController screen, IWindowProperties properties) { this.screen = screen; this.properties = properties; }
public static IFormManager GetFormManager(IWindowProperties formPropertiesObject) { return new FormManager(formPropertiesObject); }
public ConfigurationOptionTabViewModel(IWindowProperties windowProperties) { mWindowProperties = windowProperties; DisplayName = "Options"; mFontsize = mWindowProperties.FontSize; }
private string GenerateFormattedName(string filePath, IWindowProperties formPropertiesObject) { Func<ObservableCollection<string>, string> nullCheck = (collection) => { if (!(collection == null)) return collection[0]; else return ""; }; string title = nullCheck(formPropertiesObject.Title); uint track = uint.Parse(formPropertiesObject.TrackNo[0]); string artist = formPropertiesObject.Artist[0]; string fileDirectoryPath = System.IO.Path.GetDirectoryName(filePath); string invalidFilenameChars = @"[\\/:?*""<>|]+"; string formattedFileName = ""; //Generate formatted filename switch (formPropertiesObject.Format) { case 0: //#. Title - Artist format { formattedFileName = (track < 10 ? "0" : "") + track + ". " + title + " - " + artist + System.IO.Path.GetExtension(filePath); break; } case 1: //#. Artist - Title format { formattedFileName = (track < 10 ? "0" : "") + track + ". " + artist + " - " + title + System.IO.Path.GetExtension(filePath); break; } case 2: //Artist - Title format { formattedFileName = artist + " - " + title + System.IO.Path.GetExtension(filePath); break; } case 3: //#. Title format { formattedFileName = (track < 10 ? "0" : "") + track + ". " + title + System.IO.Path.GetExtension(filePath); break; } case 4: //Title - Artist format { formattedFileName = title + " - " + artist + System.IO.Path.GetExtension(filePath); break; } default: break; } if (formattedFileName != "") { if (!Regex.IsMatch(formattedFileName, invalidFilenameChars)) return formattedFileName; else { MessageBoxResult result = default(MessageBoxResult); result = MessageBox.Show("Invalid charachters in potential filename: " + formattedFileName + "\nRemove invalid characters?", "Error!", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { formattedFileName = Regex.Replace(formattedFileName, invalidFilenameChars, ""); return formattedFileName; } else return System.IO.Path.GetFileName(filePath); } } else return System.IO.Path.GetFileName(filePath); }
public bool Write(string filePath, IWindowProperties formPropertiesObject) { IFileTagTools file = ObjectFactory.GetTagLibrary(filePath); Assign.AssignTo(file, formPropertiesObject); file.Save(); return true; }
public string FormChecker(IWindowProperties audioFileTags) { IVerify iVerifyForm = ObjectFactory.GetVerifier(); string userDecision = null; Action<string> checkForNullTags = (tag) => { if (userDecision == null) userDecision = iVerifyForm.nullTagChecker(tag); }; checkForNullTags(audioFileTags.Title[0]); checkForNullTags(audioFileTags.Artist[0]); checkForNullTags(audioFileTags.ContributingArtists[0]); checkForNullTags(audioFileTags.Album[0]); checkForNullTags(audioFileTags.Genre[0]); return userDecision; }
private void DoShow(IWindowController screen, IWindowProperties properties) { DoShow(new WindowHistoryEntry(screen, properties)); }
private void EnqueueWindow(IWindowController window, IWindowProperties properties) { windowQueue.Enqueue(new WindowHistoryEntry(window, properties)); }
public ConfigurationWindowViewModel(ConfigurationViewModel configuration, IWindowProperties windowProperties) { mWindowProperties = windowProperties; ConfigurationTabs = configuration; }
public void Read(string filePath, IWindowProperties formPropertiesObject) { IFileTagTools file = ObjectFactory.GetTagLibrary(filePath); Assign.AssignTo(formPropertiesObject, file, formPropertiesObject); formPropertiesObject.TagArt = file.TagArt; }
private Task DoShow(IWindowController window, IWindowProperties properties) { return(DoShow(new WindowHistoryEntry(window, properties))); }
public ConfigurationThemeTabViewModel(IWindowProperties windowProperties) { mWindowProperties = windowProperties; DisplayName = "Colors, Font and Themes"; }
public FormManager(IWindowProperties formPropertiesObject) { this.formPropertiesObject = formPropertiesObject; Reset(); }