static void OnPrefixChange(DependencyObject sender, DependencyPropertyChangedEventArgs e) { FileSelectionControl me = sender as FileSelectionControl; if (me != null) { if (!me.IsUpdating) { me.IsUpdating = true; if (!string.IsNullOrEmpty(me.Prefix) && string.IsNullOrEmpty(me.FullName) && !string.IsNullOrEmpty(me.FileDisplay)) { me.FullName = Path.Combine(me.Prefix, me.FileDisplay); } me.ProcessValidation(); me.IsUpdating = false; } } }
static void OnFileDisplayChange(DependencyObject sender, DependencyPropertyChangedEventArgs e) { FileSelectionControl me = sender as FileSelectionControl; if (me != null) { if (!me.IsUpdating && !string.IsNullOrEmpty(me.Prefix) && !string.IsNullOrEmpty(me.FileDisplay)) { string wrkFileDisplay = me.FileDisplay.Replace('/', '\\'); if (wrkFileDisplay.EndsWith("*", StringComparison.OrdinalIgnoreCase)) { me.FullName = null; } else if (wrkFileDisplay.Contains(":")) { me.FullName = wrkFileDisplay; } else if (wrkFileDisplay.StartsWith("\\", StringComparison.OrdinalIgnoreCase)) { me.FullName = Path.Combine(me.Prefix, wrkFileDisplay.Substring(1)); } else { me.IsUpdating = true; me.FullName = Path.Combine(me.Prefix, wrkFileDisplay); me.IsUpdating = false; } me.ProcessValidation(); } me.RaiseEvent(new RoutedEventArgs(FileChangedEvent, me.FileDisplay)); } }
static void OnFullnameChange(DependencyObject sender, DependencyPropertyChangedEventArgs e) { FileSelectionControl me = sender as FileSelectionControl; if (me != null) { if (!me.IsUpdating && !string.IsNullOrEmpty(me.Prefix) && !string.IsNullOrEmpty(me.FullName)) { me.IsUpdating = true; string wrkFile = me.FullName; if (!me.FullName.StartsWith(me.Prefix, StringComparison.OrdinalIgnoreCase)) { //First, is it in the Stock folder. if not, is it in the Active artemis copy? // if it is in active artemis copy, then tag "DependsOn". All this must be done elsewhere. RoutedEventArgs e1 = new RoutedEventArgs(InvalidFilePathEvent, wrkFile); me.RaiseEvent(e1); if (!e1.Handled) //if handled, then user canceled operation, so restoring to old value required. { //if e.Handled == true, then all is done, do nothing more. // if not handled, then e.Source should have the new path with the Prefix match. wrkFile = e1.Source as string; if (!wrkFile.StartsWith(me.Prefix, StringComparison.OrdinalIgnoreCase)) // still have problem, but may be okay. { me.FullName = e.OldValue as string; } } else { me.FullName = e.OldValue as string; } } //possibility that FullName not within Prefix. What should FileDisplay be in that case? if (me.FullName.StartsWith(me.Prefix, StringComparison.OrdinalIgnoreCase)) { string str = me.FullName.Substring(me.Prefix.Length + 1); me.FileDisplay = str.Replace('\\', '/'); } else { //Need a way to pass alternate Prefix in event of using dependent mod. if (!string.IsNullOrEmpty(me.AlternatePrefix)) { if (me.FullName.StartsWith(me.AlternatePrefix, StringComparison.OrdinalIgnoreCase)) { me.FileDisplay = me.FullName.Substring(me.AlternatePrefix.Length + 1).Replace('\\', '/'); } else { me.FileDisplay = me.FullName.Replace('\\', '/'); } } else { me.FileDisplay = me.FullName.Replace('\\', '/'); } } me.ProcessValidation(); me.IsUpdating = false; } } }