private void Button_Click(object sender, RoutedEventArgs e)
        {
            string p = DialogHelpers.OpenLoksimFile(FilePath, FileDialogFilters, null);

            if (!string.IsNullOrEmpty(p))
            {
                FilePath = L3dFilePath.CreateRelativeToFile(p, FilePath != null ? FilePath.ParentFile : null);
            }
        }
        private static void OnTbTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            string          newTxt = e.NewValue as string;
            FilePathControl ctrl   = (FilePathControl)d;

            if (ctrl.FilePath == null || ctrl.FilePath.PathRelativeToParentFile != newTxt)
            {
                ctrl.FilePath = L3dFilePath.CreateRelativeToFile(newTxt, ctrl.FilePath != null ? ctrl.FilePath.ParentFile : null);
            }
        }
        void tbPath_TextChanged(object sender, RoutedEventArgs e)
        {
            string newTxt = tbPath.Text;

            if (_curPath == null || _curPath.PathRelativeToParentFile != newTxt)
            {
                _curPath = L3dFilePath.CreateRelativeToFile(newTxt, _curPath != null ? _curPath.ParentFile : null);
                if (newTxt != "\\")
                {
                    ValidateCurrentPath();
                }
            }
        }
Esempio n. 4
0
 public static Weather ReadFromXml(XElement xmlEl, IUndoManager undoManager, L3dFilePath ownerPath = null)
 {
     if (xmlEl != null && xmlEl.Name == FileDescriptions.FILE_SKY_EL_WEATHER)
     {
         XElement props = xmlEl.Element(FileDescriptions.FILE_SKY_EL_WEATHER_PROPS);
         if (props != null)
         {
             Weather w = new Weather(undoManager);
             w._propability = props.Attribute(FileDescriptions.FILE_SKY_AT_WEATHER_PROBABILITY).Read <int>(1);
             w._weatherFile = L3dFilePath.CreateRelativeToFile(props.Attribute(FileDescriptions.FILE_SKY_AT_WEATHER_FILE).Read <string>(), ownerPath);
             return(w);
         }
     }
     return(null);
 }
Esempio n. 5
0
 public WeatherTimeRange(IUndoManager undoManager, L3dFilePath parentFile = null) : base(undoManager)
 {
     _sightDistance    = 10000;
     _brightnessFactor = 1.0f;
     _variables        = new UndoAwareObservableCollection <L3dVariable>(undoManager);
     _textures         = new List <TextureEntry>(5);
     for (int i = 0; i < 5; i++)
     {
         TextureEntry en = new TextureEntry();
         en._texture = L3dFilePath.CreateRelativeToFile(string.Empty, parentFile);
         en._tileU   = 1;
         en._tileV   = 1;
         _textures.Add(en);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Lädt Daten in diese Instanz von der angegebenen Datei
 /// </summary>
 /// <param name="path">Dateipfad</param>
 public void LoadFromFile(L3dFilePath path)
 {
     if (!L3dFilePath.IsNullOrEmpty(path))
     {
         XDocument doc   = XDocument.Load(path.AbsolutePath);
         XElement  props = doc.Elements().First().Element(FileDescriptions.FILE_GENERAL_EL_PROPS);
         if (props != null)
         {
             FileAuthor  = props.Attribute(FileDescriptions.FILE_GENERAL_AT_AUTHOR).Read <string>();
             FileInfo    = props.Attribute(FileDescriptions.FILE_GENERAL_AT_INFO).Read <string>();
             FilePicture = L3dFilePath.CreateRelativeToFile(props.Attribute(FileDescriptions.FILE_GENERAL_AT_PICTURE).Read <string>(), path);
             FileDoku    = L3dFilePath.CreateRelativeToFile(props.Attribute(FileDescriptions.FILE_GENERAL_AT_DOKU).Read <string>(), path);
         }
         OwnPath = path;
         LoadFromDoc(doc);
         _lastSavedDoc = GetOutputString(SaveToXmlDocument(GetRootPropsElement(OwnPath), OwnPath));
     }
 }
        void tbPath_Populating(object sender, PopulatingEventArgs e)
        {
            L3dFilePath parentFile = _curPath.ParentFile;
            string      startDir;

            if (L3dFilePath.IsNullOrEmpty(parentFile) || e.Parameter.StartsWith("\\"))
            {
                startDir = L3dFilePath.LoksimDirectory.AbsolutePath;
            }
            else
            {
                startDir = parentFile.Directory;
            }

            startDir = startDir + System.IO.Path.DirectorySeparatorChar + e.Parameter;
            if (!string.IsNullOrEmpty(startDir))
            {
                string dir = System.IO.Path.GetDirectoryName(startDir);
                if (Directory.Exists(dir))
                {
                    string file = System.IO.Path.GetFileName(startDir);
                    var    res  = Directory.EnumerateDirectories(dir, file + "*").Select(p => L3dFilePath.CreateRelativeToFile(p, parentFile).PathRelativeToParentFile);

                    if (_possibleExtensions.Count() == 0)
                    {
                        res = res.Union(Directory.EnumerateFiles(dir, file + "*").Select(p => L3dFilePath.CreateRelativeToFile(p, parentFile).PathRelativeToParentFile));
                    }
                    else
                    {
                        foreach (var ext in _possibleExtensions)
                        {
                            res = res.Union(Directory.EnumerateFiles(dir, file + "*." + ext).Select(p => L3dFilePath.CreateRelativeToFile(p, parentFile).PathRelativeToParentFile));
                        }
                    }

                    tbPath.ItemsSource = res.Take(15);
                }
                else
                {
                    tbPath.ItemsSource = Enumerable.Empty <string>();
                }
            }
        }
Esempio n. 8
0
        public static WeatherTimeRange ReadFromXml(XElement xmlEl, IUndoManager undoManager, L3dFilePath ownerPath = null)
        {
            if (xmlEl != null && xmlEl.Name == FileDescriptions.FILE_WEATHER_EL_TIME_RANGE)
            {
                XElement props = xmlEl.Element(FileDescriptions.FILE_WEATHER_EL_TIME_RANGE_PROPS);
                if (props != null)
                {
                    WeatherTimeRange t = new WeatherTimeRange(undoManager, ownerPath);
                    using (var tk = undoManager.EnterNoUndoSection())
                    {
                        t._begin            = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_BEGIN).ReadTime();
                        t._end              = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_END).ReadTime();
                        t._brightnessFactor = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_BRIGHTNESS_FACTOR).Read <float>(1.0f);
                        t._sightDistance    = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SIGHT_DISTANCE).Read <int>(6000);

                        foreach (L3dVariable v in xmlEl.Elements(FileDescriptions.File_WEATHER_EL_TIME_RANGE_VARIABLE).Select(el =>
                        {
                            return(new L3dVariable(undoManager)
                            {
                                Name = el.Attribute(FileDescriptions.File_WEATHER_AT_TIME_RANGE_VARIABLE_NAME).Read <string>("UnnamedVar"),
                                Value = el.Value
                            });
                        }))
                        {
                            t.Variables.Add(v);
                        }

                        XElement skybox = xmlEl.Element(FileDescriptions.FILE_WEATHER_EL_TIME_RANGE_SKYBOX);
                        if (skybox != null)
                        {
                            props = skybox.Element(FileDescriptions.FILE_WEATHER_EL_TIME_RANGE_SKYBOX_TEXTURES);
                            if (props != null)
                            {
                                t.TextureNorth = L3dFilePath.CreateRelativeToFile(props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTURENORTH).Read <string>(string.Empty), ownerPath);
                                t.TextureEast  = L3dFilePath.CreateRelativeToFile(props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTUREEAST).Read <string>(string.Empty), ownerPath);
                                t.TextureSouth = L3dFilePath.CreateRelativeToFile(props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTURESOUTH).Read <string>(string.Empty), ownerPath);
                                t.TextureWest  = L3dFilePath.CreateRelativeToFile(props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTUREWEST).Read <string>(string.Empty), ownerPath);
                                t.TextureAbove = L3dFilePath.CreateRelativeToFile(props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTUREABOVE).Read <string>(string.Empty), ownerPath);

                                t.TextureNorthTileU = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTURENORTH_TILE_U).Read <float>(0);
                                t.TextureNorthTileV = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTURENORTH_TILE_V).Read <float>(0);
                                t.TextureEastTileU  = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTUREEAST_TILE_U).Read <float>(0);
                                t.TextureEastTileV  = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTUREEAST_TILE_V).Read <float>(0);
                                t.TextureSouthTileU = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTURESOUTH_TILE_U).Read <float>(0);
                                t.TextureSouthTileV = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTURESOUTH_TILE_V).Read <float>(0);
                                t.TextureWestTileU  = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTUREWEST_TILE_U).Read <float>(0);
                                t.TextureWestTileV  = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTUREWEST_TILE_V).Read <float>(0);
                                t.TextureAboveTileU = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTUREABOVE_TILE_U).Read <float>(0);
                                t.TextureAboveTileV = props.Attribute(FileDescriptions.FILE_WEATHER_AT_TIME_RANGE_SKYBOX_TEXTUREABOVE_TILE_V).Read <float>(0);
                            }
                        }

                        XElement xmlPreci = xmlEl.Element(FileDescriptions.FILE_WEATHER_EL_TIME_RANGE_PRECIPITATION);
                        if (xmlPreci != null)
                        {
                            t._snowfall = xmlPreci.Attribute(FileDescriptions.FILE_WEATHER_EL_TIME_RANGE_PRECIPITATION_TYPE).Read <int>(0) == 1;
                        }

                        return(t);
                    }
                }
            }
            return(null);
        }