Esempio n. 1
0
 // internal void Save(Editor txtBox)
 // {
 //     if (txtBox.Filename == null)
 //     {
 //         txtBox.SaveAs();
 //     }
 //     IsDirty = false;
 // }
 // protected void TextChanged(object sender)
 // {
 //     TextBox = (sender as Editor);
 //     if (TextBox != null)
 //     {
 //         FileLanguage.RawText = TextBox.Text;
 //     }
 //     RaisePropertyChanged("Title");
 // }
 public override void Load(string filepath)
 {
     FilePath = filepath;
     Instance = this;
     TextBox.FileLanguage = FileLanguage;
     TextBox.Filename = filepath;
     TextBox.SetHighlighting();
     if (File.Exists(filepath))
     {
         TextBox.Text = File.ReadAllText(filepath);
     }
     RaisePropertyChanged("Title");
 }
Esempio n. 2
0
 public override DocumentViewModel GetFile(string filePath)
 {
     var extension = Path.GetExtension(filePath);
     if (extension != null)
     {
         if (extension == ".prg" || extension == ".mod")
         {
             var result = new DocumentViewModel(filePath);
             return result;
         }
     }
     return null;
 }
Esempio n. 3
0
 public void AddNewFile()
 {
     var file = new DocumentViewModel(null);
     Files.Add(file);
     ActiveEditor = file;
 }
        private static IEditorDocument GetKukaViewModel(string filepath)
        {
            var fileInfo = new FileInfo(filepath);
            var name = Path.GetFileNameWithoutExtension(fileInfo.Name);
            Debug.Assert(name != null, "file != null");
            Debug.Assert(fileInfo.DirectoryName != null, "dir != null");
            name = Path.Combine(fileInfo.DirectoryName, name);
            var src = new FileInfo(name + ".src");
            var dat = new FileInfo(name + ".dat");

            IEditorDocument result;
            if (src.Exists && dat.Exists)
            {
                result = new KukaViewModel(src.FullName, new KUKA(src.FullName));
            }
            else
            {
                result = new DocumentViewModel(filepath, new KUKA(filepath));
            }
            return result;
        }
        public static IEditorDocument GetViewModel(string filepath)
        {
            IEditorDocument result;
            if (!string.IsNullOrEmpty(filepath))
            {
                var extension = Path.GetExtension(filepath);
                var text = extension.ToLower();
                switch (text)
                {
                    case ".as":
                    case ".pg":
                        result = new DocumentViewModel(filepath, new Kawasaki(filepath));
                        return result;

                    case ".src":
                    case ".dat":
                        result = GetKukaViewModel(filepath);
                        return result;

                    case ".rt":
                    case ".sub":
                    case ".kfd":
                        result = new DocumentViewModel(filepath, new KUKA(filepath));
                        return result;

                    case ".mod":
                    case ".prg":
                        result = new DocumentViewModel(filepath, new ABB(filepath));
                        return result;

                    case ".bas":
                        result = new DocumentViewModel(filepath, new VBA(filepath));
                        return result;

                    case ".ls":
                        result = new DocumentViewModel(filepath, new Fanuc(filepath));
                        return result;
                }
                result = new DocumentViewModel(filepath, new LanguageBase(filepath));
            }
            else
            {
                result = new DocumentViewModel(null, new LanguageBase(filepath));
            }
            return result;
        }