Example #1
0
 public void OpenFile(L3dFilePath p)
 {
     if (!L3dFilePath.IsNullOrEmpty(p))
     {
         var w = _openAppWindows.FirstOrDefault(m => m._currentViewModel != null && m._currentViewModel.CurrentFile != null &&
                                                L3dFilePath.Equals(m._currentViewModel.CurrentFile.OwnPath, p));
         if (w != null)
         {
             //w.BringIntoView();
             if (w.WindowState == System.Windows.WindowState.Minimized)
             {
                 w.WindowState = System.Windows.WindowState.Normal;
             }
             w.Activate();
         }
         else
         {
             if (_currentViewModel == null)
             {
                 Mouse.OverrideCursor = Cursors.Wait;
                 LoksimFile file = LoadFile(p);
                 SetCtrlAndViewModel(file);
                 Mouse.OverrideCursor = null;
             }
             else
             {
                 new MainWindow(p.AbsolutePath).Show();
             }
         }
         SetRecentFilesMenu();
     }
 }
Example #2
0
 /// <summary>
 /// Liefert Pfad relativ zu angegebener Datei
 /// </summary>
 /// <param name="parentFile">"Eltern-Datei"</param>
 /// <returns>Relativer Pfad zur Datei; Falls diese Datei nicht im gleichen Verzeichnis wie parentFile liegt, wird Pfad relativ zum Loksim-Verzeichnis geliefert</returns>
 public string GetPathRelativeToFile(L3dFilePath parentFile)
 {
     if (!L3dFilePath.IsNullOrEmpty(parentFile))
     {
         string parentDir = parentFile.Directory;
         if (AbsolutePath.StartsWith(parentDir, StringComparison.OrdinalIgnoreCase))
         {
             return(AbsolutePath.Substring(parentDir.Length + 1));
         }
     }
     return(PathRelativeToL3dDir);
 }
Example #3
0
 private void CommandSaveAs_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (_currentViewModel != null)
     {
         _currentViewModel.FileSaveAsCmd.Execute(null);
         if (!L3dFilePath.IsNullOrEmpty(_currentViewModel.CurrentFile.OwnPath))
         {
             Settings.RegistrySettings.Default.AddRecentFile(_currentViewModel.CurrentFile.OwnPath);
             SetRecentFilesMenu();
             this.Title = Loksim3D.WetterEdit.Resources.Strings.AppName + " [" + _currentViewModel.CurrentFile.OwnPath.Filename + "]";
         }
     }
 }
Example #4
0
        private void CommandOpen_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            string str = DialogHelpers.OpenLoksimFile(string.Empty, FileExtensions.AllLoksimFiles, this, MAIN_DLG_OPEN);

            if (!string.IsNullOrEmpty(str))
            {
                L3dFilePath p = new L3dFilePath(str);
                if (!L3dFilePath.IsNullOrEmpty(p))
                {
                    OpenFile(p);
                }
            }
        }
Example #5
0
 private void SetPathRelativeToFile(string relativePath, L3dFilePath parentFile)
 {
     if (string.IsNullOrEmpty(relativePath))
     {
         _absolutePath = string.Empty;
     }
     else if (L3dFilePath.IsNullOrEmpty(parentFile) || relativePath[0] == '\\')
     {
         SetPathRelativeToL3dDir(relativePath);
     }
     else if (Path.IsPathRooted(relativePath))
     {
         _absolutePath = relativePath;
     }
     else
     {
         _absolutePath = Path.Combine(Path.GetDirectoryName(parentFile.AbsolutePath), relativePath);
     }
     ParentFile = parentFile;
 }