public void UpdateToolBox() { App.MainViewModel.ContextButtonsLeft.Clear(); App.MainViewModel.ContextButtonsLeft.Add(new ViewModel.ToolBoxButtonVM("创建", new BitmapImage(new Uri("/Images/appbar.check.rest.png", UriKind.RelativeOrAbsolute))) { ClickedAction = new Action(() => { var mfa = tbMFA.Text.Trim(); if (string.IsNullOrWhiteSpace(mfa) || vm_ == null) return; try { var fld = App.Entity.FindFolderName(vm_.Entity); var app = App.Entity.FindAppName(vm_.Entity); var content = ErlangEditor.Template.TemplateUtil.Make_application(name_, mfa); var entity = new ErlangEditor.Core.Entity.FileEntity { Name = name_ + ".erl", DisplayName = name_ }; ErlangEditor.Core.FileUtil.AddFile(app, fld, entity, content); ErlangEditor.Core.SolutionUtil.SaveSolution(); vm_.Children.Add(new ViewModel.PrjTreeItemVM(entity)); SortChildren(vm_); App.Navigation.JumpToWithFirstFrame(App.MainViewModel.WorkingPage); } catch (Exception ecp) { App.Navigation.ShowMessageBox(ecp.Message, "创建文件"); } }) }); App.ToolBox.ShowButtomBar(); }
private void ErlClicked(object sender, RoutedEventArgs e) { var name = tbName.Text.Trim(); if (string.IsNullOrEmpty(name) || vm_ == null || vm_.Entity == null) return; try { var fld = App.Entity.FindFolderName(vm_.Entity); var app = App.Entity.FindAppName(vm_.Entity); var entity = new ErlangEditor.Core.Entity.FileEntity { Name = name + ".erl", DisplayName = name }; var content = ErlangEditor.Template.TemplateUtil.MakeErlangCode(name); ErlangEditor.Core.FileUtil.AddFile(app, fld, entity, content); ErlangEditor.Core.SolutionUtil.SaveSolution(); vm_.Children.Add(new ViewModel.PrjTreeItemVM(entity)); SortChildren(vm_); App.Navigation.JumpToWithFirstFrame(App.MainViewModel.WorkingPage); } catch (Exception ecp) { App.Navigation.ShowMessageBox(ecp.Message, "创建文件"); } }
public void UpdateToolBox() { App.MainViewModel.ContextButtonsLeft.Clear(); App.MainViewModel.ContextButtonsLeft.Add(new ViewModel.ToolBoxButtonVM("创建", new BitmapImage(new Uri("/Images/appbar.check.rest.png", UriKind.RelativeOrAbsolute))) { ClickedAction = new Action(() => { var modName = tbModName.Text.Trim(); var rs = (cbRS.SelectedValue as ComboBoxItem).Tag as string; var max = tbMax.Text.Trim(); var within = tbWhitin.Text.Trim(); var id = tbID.Text.Trim(); var startMFA = tbStartupMFA.Text.Trim(); var restart = (cbRestart.SelectedValue as ComboBoxItem).Tag as string; var shutdown = cbiShutdownCountdown.IsSelected ? tbShutdownCountdown.Text.Trim() : (cbShutdown.SelectedValue as ComboBoxItem).Tag as string; var nodeType = (cbType.SelectedValue as ComboBoxItem).Tag as string; var mods = tbMods.Text.Trim(); if (string.IsNullOrWhiteSpace(modName) || vm_ == null) return; try { var fld = App.Entity.FindFolderName(vm_.Entity); var app = App.Entity.FindAppName(vm_.Entity); var content = ErlangEditor.Template.TemplateUtil.Make_supervisor(modName, rs, max, within, id, startMFA, restart, shutdown, nodeType, mods); var entity = new ErlangEditor.Core.Entity.FileEntity { Name = modName + ".erl", DisplayName = modName }; ErlangEditor.Core.FileUtil.AddFile(app, fld, entity, content); ErlangEditor.Core.SolutionUtil.SaveSolution(); vm_.Children.Add(new ViewModel.PrjTreeItemVM(entity)); SortChildren(vm_); App.Navigation.JumpToWithFirstFrame(App.MainViewModel.WorkingPage); } catch (Exception ecp) { App.Navigation.ShowMessageBox(ecp.Message, "创建文件"); } }) }); App.ToolBox.ShowButtomBar(); }
public void UpdateToolBox() { App.MainViewModel.ContextButtonsLeft.Clear(); App.MainViewModel.ContextButtonsLeft.Add(new ViewModel.ToolBoxButtonVM("创建", new BitmapImage(new Uri("/Images/appbar.check.rest.png", UriKind.RelativeOrAbsolute))) { ClickedAction = new Action(() => { var appname = tbAppName.Text.Trim(); var vsn = tbVsn.Text.Trim(); var desc = tbDesc.Text.Trim(); var mods = tbMods.Text.Split(',').Select(i => i.Trim()).Where(i => !string.IsNullOrEmpty(i)).ToArray(); var reg = tbReg.Text.Split(',').Select(i => i.Trim()).Where(i => !string.IsNullOrEmpty(i)).ToArray(); var apps = tbApps.Text.Split(',').Select(i => i.Trim()).Where(i => !string.IsNullOrEmpty(i)).ToArray(); var mod = tbMod.Text.Trim(); var arg = tbArg.Text.Trim(); if (string.IsNullOrWhiteSpace(appname) || vm_ == null) return; try { var fld = App.Entity.FindFolderName(vm_.Entity); var app = App.Entity.FindAppName(vm_.Entity); var content = ErlangEditor.Template.TemplateUtil.MakeAppFile(vsn, appname, desc, mods, reg, apps, mod, arg); var entity = new ErlangEditor.Core.Entity.FileEntity { Name = appname + ".app.src", DisplayName = appname + ".app", IsAppFile = true }; ErlangEditor.Core.FileUtil.AddFile(app, fld, entity, content); ErlangEditor.Core.SolutionUtil.SaveSolution(); vm_.Children.Add(new ViewModel.PrjTreeItemVM(entity)); SortChildren(vm_); App.Navigation.JumpToWithFirstFrame(App.MainViewModel.WorkingPage); } catch (Exception ecp) { App.Navigation.ShowMessageBox(ecp.Message, "创建文件"); } }) }); App.ToolBox.ShowButtomBar(); }
private void ExistsFiles(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Title = "选择现有文件"; fileDialog.Filter = "All Files (*.*)|*.*"; fileDialog.Multiselect = true; if (fileDialog.ShowDialog() == true) { try { var fld = App.Entity.FindFolderName(vm_.Entity); var app = App.Entity.FindAppName(vm_.Entity); foreach (var i in fileDialog.FileNames) { var name = System.IO.Path.GetFileName(i); var displayname = System.IO.Path.GetFileNameWithoutExtension(i); var newpath = System.IO.Path.Combine(ErlangEditor.Core.Helper.EntityTreeUtil.GetPath(vm_.Entity), name); if(i.ToLower() != newpath.ToLower()) System.IO.File.Copy(i, newpath); ErlangEditor.Core.Entity.FileEntity entity = null; if(System.IO.Path.GetExtension(newpath).ToLower() == ".src") entity = new ErlangEditor.Core.Entity.FileEntity { Name = name, DisplayName = displayname , IsAppFile = true }; else entity = new ErlangEditor.Core.Entity.FileEntity { Name = name, DisplayName = displayname }; ErlangEditor.Core.FileUtil.AddFile(app, fld, entity); ErlangEditor.Core.SolutionUtil.SaveSolution(); vm_.Children.Add(new ViewModel.PrjTreeItemVM(entity)); App.Navigation.JumpToWithFirstFrame(App.MainViewModel.WorkingPage); } SortChildren(vm_); } catch (Exception ecp) { App.Navigation.ShowMessageBox(ecp.Message, "选择现有文件"); } //App.ViewModel.LoadSolution(file); } }