Inheritance: ViewModelBase
示例#1
0
 public void MakeApp(PrjTreeItemVM aAppVM)
 {
     App.MainViewModel.ErrorLog.Clear();
     var slnCompiler = new SolutionCompiler();
     App.MainViewModel.ErrorCount = 0;
     slnCompiler.CodeFileError += (a, b) =>
     {
         var item = new ErrorInfoVM();
         var spIndex = b.Log.IndexOf(": ");
         if (spIndex == -1)
         {
             item.Log = b.Log;
         }
         else
         {
             var front = b.Log.Substring(0, spIndex);
             var line = front.Substring(front.LastIndexOf(':') + 1, front.Length - front.LastIndexOf(':') - 1);
             var back = b.Log.Substring(spIndex + 1, b.Log.Length - spIndex - 1);
             item.Entity = b.Entity;
             item.Log = back;
             item.Line = line;
         }
         App.MainViewModel.ErrorLog.Add(item);
         App.MainViewModel.ErrorCount++;
     };
     App.MainViewModel.IsCompiling = true;
     slnCompiler.Start(
         new ErlangEditor.Core.Entity.ApplicationEntity[] { aAppVM.Entity as ErlangEditor.Core.Entity.ApplicationEntity },
         App.MainViewModel.ExportLog, null,
         (x) =>
         {
             App.MainViewModel.AutoCompleteCache.ScanAllBin(ErlangEditor.Core.SolutionUtil.Solution);
             Dispatcher.Invoke(new Action(() =>
             {
                 App.MainViewModel.IsCompiling = false;
             }));
         });
 }
示例#2
0
 public void MakeTreeLoop(ViewModel.PrjTreeItemVM aParentVM, object aNode)
 {
     var node = new ViewModel.PrjTreeItemVM(aNode);
     if (aNode is ErlangEditor.Core.Entity.SolutionEntity)
     {
         var sln = aNode as ErlangEditor.Core.Entity.SolutionEntity;
         node.DisplayText = sln.Name;
         node.Children = new System.Collections.ObjectModel.ObservableCollection<ViewModel.PrjTreeItemVM>();
     }
     if (aNode is ErlangEditor.Core.Entity.ApplicationEntity)
     {
         var app = aNode as ErlangEditor.Core.Entity.ApplicationEntity;
         node.DisplayText = app.Name;
         node.Children = new System.Collections.ObjectModel.ObservableCollection<ViewModel.PrjTreeItemVM>();
     }
     if (aNode is ErlangEditor.Core.Entity.FolderEntity)
     {
         var fld = aNode as ErlangEditor.Core.Entity.FolderEntity;
         node.DisplayText = fld.Name;
         node.Children = new System.Collections.ObjectModel.ObservableCollection<ViewModel.PrjTreeItemVM>();
     }
     if (aNode is ErlangEditor.Core.Entity.FileEntity)
     {
         var fle = aNode as ErlangEditor.Core.Entity.FileEntity;
         node.DisplayText = fle.DisplayName;
     }
     node.Entity = aNode;
     if (aParentVM == null)
     {
         App.MainViewModel.TreeRoot = new System.Collections.ObjectModel.ObservableCollection<ViewModel.PrjTreeItemVM>();
         App.MainViewModel.TreeRoot.Add(node);
     }
     else if (aNode is ErlangEditor.Core.Entity.FolderEntity && new string[]{"ebin","doc","priv"}.Any(x=> (aNode as ErlangEditor.Core.Entity.FolderEntity).Name == x))
     {
         return;
     }
     else
     {
         aParentVM.Children.Add(node);
     }
     if (aNode is ErlangEditor.Core.Entity.SolutionEntity)
     {
         var sln = aNode as ErlangEditor.Core.Entity.SolutionEntity;
         foreach (var i in sln.Apps)
         {
             MakeTreeLoop(node, i);
         }
     }
     if (aNode is ErlangEditor.Core.Entity.ApplicationEntity)
     {
         var app = aNode as ErlangEditor.Core.Entity.ApplicationEntity;
         foreach (var i in app.Folders)
         {
             MakeTreeLoop(node, i);
         }
         foreach (var i in app.Files)
         {
             MakeTreeLoop(node, i);
         }
     }
     if (aNode is ErlangEditor.Core.Entity.FolderEntity)
     {
         var fld = aNode as ErlangEditor.Core.Entity.FolderEntity;
         foreach (var i in fld.Files)
         {
             MakeTreeLoop(node, i);
         }
     }
     if (!(aNode is ErlangEditor.Core.Entity.FileEntity))
     {
         var comparer = new Tools.Reverser<ViewModel.PrjTreeItemVM>(new ViewModel.PrjTreeItemVM().GetType(), "DisplayText", Tools.ReverserInfo.Direction.ASC);
         var lst = node.Children.ToList();
         lst.Sort(comparer);
         node.Children.Clear();
         foreach (var i in lst)
             node.Children.Add(i);
     }
 }