/// <summary> /// Opens the project /// </summary> private void OpenProject(object parameters) { try { string path = ((object[])parameters)[0].ToStr(); if (File.Exists(path)) { Window currentWindow = (Window)((object[])parameters)[1]; Project project = Project.Load(path); currentWindow.Hide(); new ProjectWindow(new ProjectViewModel(project)).Show(); currentWindow.Close(); } else { if (MessageBox.Show(Resources.IntroductionWindow_ProjectDoesNotExistMessage_Text, Resources.IntroductionWindow_ProjectDoesNotExistMessage_Caption, MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { RecentProject.Delete(path); Messenger.Instance.Send(MessageType.RecentProjectDeleted); } } } catch (Exception ex) { LogHelper.Logger.Error(ex, "Unable to open project"); FormsHelper.ShowUnexpectedError(); } }
public void RemoveRecentProject(RecentProject recentProject) { var recentProjects = LoadRecentProjects(); recentProjects.Projects.RemoveAll(p => string.Equals(p.Path, recentProject.Path, StringComparison.OrdinalIgnoreCase)); SaveRecentProjects(recentProjects); }
/// <summary> /// Initializes a new instance of the <see cref="RecentProjectViewModel" /> class. /// </summary> /// <param name="recentProject">Recent project</param> public RecentProjectViewModel(RecentProject recentProject) { Name = recentProject.Name; Path = recentProject.Path.TruncateString(200); OpenProjectCommand = new NotifyCommand(OpenProject); }
public void Rebuild() { Project currentProject = GetCurrentProject(); int count = 0; comboBox.Items.Clear(); comboBox.SelectedIndex = -1; // recent string is something like MyProject?C:\Code\MyProject.fdp;OtherProject?etc... foreach (string recentProjectString in Settings.RecentProjects.Split(';')) { if (recentProjectString.IndexOf("?") > -1) // reality check { RecentProject recentProject = new RecentProject(recentProjectString); if (File.Exists(recentProject.Path) && (count++ < Settings.MaxRecentProjects)) { comboBox.Items.Add(recentProject); if (currentProject != null && recentProject.Path == currentProject.ProjectPath) { comboBox.SelectedItem = recentProject; } } } } if (comboBox.Items.Count > 0) { comboBox.Items.Add(new RecentProject("(clear list)?")); } base.IsEnabled = (comboBox.Items.Count > 0); }
public static void AddToRecents(string name, string path) { List <RecentProject> recents = new List <RecentProject>(); if (File.Exists(App.EXECUTABLE_DIRECTORY + "\\" + App.RECENT_PROJECTS_FILE)) { recents.AddRange(GetRecentProjects()); } if (!recents.Any(recent => recent.Path == path)) { RecentProject newRecentProject = new RecentProject(); newRecentProject.Name = name; newRecentProject.Path = path; recents.Add(newRecentProject); try { File.WriteAllText(App.EXECUTABLE_DIRECTORY + "\\" + App.RECENT_PROJECTS_FILE, JsonConvert.SerializeObject(recents)); } catch (Exception ex) { ErrorAlert.Show("Could not save recent projects:\n" + ex.Message); } } }
public static string FormatRecentProject(RecentProject prj) { if (prj == null) { return("erreur"); } return(FormatRecentProject(prj.Name, prj.LastChange)); }
private void ProjectDataService_ProjectLoaded(RecentProject p, EventArgs e) { ProjectFiles.Clear(); foreach (BaseMd fileMd in projectDataService.ProjectFiles) { // Scan for a tag that describes the type. // TODO: create the proper model classes to assign them in here. //File.OpenRead(filePath); ProjectFiles.Add(fileMd); } }
private void OnMouseDown(object sender, MouseButtonEventArgs e) { FrameworkElement element = sender as FrameworkElement; StartPageViewModel vm = this.DataContext as StartPageViewModel; RecentProject project = vm.CreateProject(element.Name); if (project != null) { project.Open(); } }
private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e) { TextBlock textBlock = sender as TextBlock; StartPageViewModel vm = DataContext as StartPageViewModel; RecentProject project = vm.CreateProject(textBlock.Text); if (project != null) { project.Open(); } }
private void LoadRecentProjects() { List <RecentProject> recentProjects = RecentProjects.GetRecentProjects(); if (recentProjects.Count > 0) { lbsRecentProjects.ItemsSource = recentProjects; } else { btnOpenRecentProject.IsEnabled = false; RecentProject empty = new RecentProject(); empty.Name = "No recent projects found"; empty.Path = string.Empty; lbsRecentProjects.Items.Add(empty); } }
private void btnOpenRecentProject_Click(object sender, RoutedEventArgs e) { if (lbsRecentProjects.SelectedItem != null) { RecentProject recentProject = (RecentProject)lbsRecentProjects.SelectedItem; if (File.Exists(recentProject.Path)) { LoadProject(recentProject.Path); } else { List <RecentProject> projects = RecentProjects.GetRecentProjects(); projects.Remove(recentProject); RecentProjects.WriteRecentProjects(projects); ErrorAlert.Show("Project doesn't exist"); LoadRecentProjects(); } } }
public void AddRecentProject(RecentProject project) { if (_recentProjects == null) { _recentProjects = new List <RecentProject>(); } if (_recentProjects.Contains(project)) { _recentProjects.Remove(project); } _recentProjects.Insert(0, project); if (_recentProjects.Count > 5) { _recentProjects.RemoveAt(5); } }
void TabControl_OnTabClicked(object TabData, Point Location, MouseButtons Buttons) { if (Buttons == System.Windows.Forms.MouseButtons.Right) { Activate(); int InsertIdx = 0; while (TabMenu_RecentProjects.DropDownItems[InsertIdx] != TabMenu_Recent_Separator) { TabMenu_RecentProjects.DropDownItems.RemoveAt(InsertIdx); } TabMenu_TabIdx = -1; for (int Idx = 0; Idx < TabControl.GetTabCount(); Idx++) { if (TabControl.GetTabData(Idx) == TabData) { TabMenu_TabIdx = Idx; break; } } foreach (UserSelectedProjectSettings RecentProject in Settings.RecentProjects) { ToolStripMenuItem Item = new ToolStripMenuItem(RecentProject.ToString(), null, new EventHandler((o, e) => TryOpenProject(RecentProject, TabMenu_TabIdx))); TabMenu_RecentProjects.DropDownItems.Insert(InsertIdx, Item); InsertIdx++; } TabMenu_RecentProjects.Visible = (Settings.RecentProjects.Count > 0); TabMenu_TabNames_Stream.Checked = Settings.TabLabels == TabLabels.Stream; TabMenu_TabNames_WorkspaceName.Checked = Settings.TabLabels == TabLabels.WorkspaceName; TabMenu_TabNames_WorkspaceRoot.Checked = Settings.TabLabels == TabLabels.WorkspaceRoot; TabMenu_TabNames_ProjectFile.Checked = Settings.TabLabels == TabLabels.ProjectFile; TabMenu.Show(TabControl, Location); TabControl.LockHover(); } }
public ActionResult BlogGuncelle(RecentProject recentProject) { var blog2 = c.RecentProjectss.Find(recentProject.Id); blog2.Aciklama = recentProject.Aciklama; blog2.Aciklama2 = recentProject.Aciklama2; blog2.Aciklama3 = recentProject.Aciklama3; blog2.Aciklama4 = recentProject.Aciklama4; blog2.Aciklama5 = recentProject.Aciklama5; blog2.Baslik = recentProject.Baslik; blog2.RecentProjectsImage = recentProject.RecentProjectsImage; blog2.RecentProjectsImage2 = recentProject.RecentProjectsImage2; blog2.RecentProjectsImage3 = recentProject.RecentProjectsImage3; blog2.RecentProjectsImage4 = recentProject.RecentProjectsImage4; blog2.RecentProjectsImage5 = recentProject.RecentProjectsImage5; blog2.Tarih = recentProject.Tarih; blog2.Kaynaklar = recentProject.Kaynaklar; blog2.Kaynaklar2 = recentProject.Kaynaklar2; blog2.Kaynaklar3 = recentProject.Kaynaklar3; c.SaveChanges(); return(RedirectToAction("Index")); }
void comboBox_SelectedIndexChanged(object sender, EventArgs e) { Project currentProject = GetCurrentProject(); if (comboBox.SelectedItem != null) { if ((comboBox.SelectedItem as RecentProject).Name == "(clear list)") { Settings.RecentProjects = ""; Rebuild(); if (currentProject != null) { Add(currentProject); } return; } RecentProject recent = comboBox.SelectedItem as RecentProject; if (currentProject != null && recent.Path == currentProject.ProjectPath) { return; // already loaded } // common enough to warrant a special check if (!File.Exists(recent.Path)) { ErrorHandler.ShowInfo("The project '" + recent.Name + "' could not be located. It will be removed from the list."); Rebuild(); return; } if (OpenProject != null) { OpenProject(recent.Path); } } }
private static ToolStripItem CreateDropDownItem(RecentProject arg) { return(new ToolStripMenuItem($"({arg.Path})")); }
public ActionResult YeniBlog(RecentProject recentProject) { c.RecentProjectss.Add(recentProject); c.SaveChanges(); return(RedirectToAction("Index")); }
private void ProjectDataService_ProjectLoaded(RecentProject p, EventArgs e) { }
private void ShellOnSolutionChanged(object sender, SolutionChangedEventArgs e) { if (e.NewValue != null) { var newProject = new RecentProject { Name = e.NewValue.Name, Path = e.NewValue.CurrentDirectory }; if (RecentProjectsCollection.RecentProjects == null) { RecentProjectsCollection.RecentProjects = new List<RecentProject>(); } if (RecentProjectsCollection.RecentProjects.Contains(newProject)) { RecentProjectsCollection.RecentProjects.Remove(newProject); } RecentProjectsCollection.RecentProjects.Insert(0, newProject); RecentProjectsCollection.Save(); LoadRecentProjects(); } }
public bool LoadProject(string projectPath) { if (Directory.Exists(projectPath)) { if (Repository.IsValid(projectPath)) { var repo = new Repository(projectPath); // Store new repo in to the recent projects table. RecentProject project = databaseService.WriteInDb(() => { RecentProject foundProject; using (var db = new LiteDatabase(App.DbPath)) { var col = db.GetCollection <RecentProject>(); var res = Path.GetFileNameWithoutExtension(projectPath); foundProject = col.FindOne(f => f.Location == projectPath && f.Name == res); foundProject = new RecentProject() { Id = foundProject?.Id ?? 0, Date = DateTime.Now, Name = res, Location = projectPath }; // Need to test Upsert a lot more. col.Upsert(foundProject); //if (find == null) //{ // col.Insert(new RecentProject() { Date = DateTime.Now, Name = res, Location = folderDialog.FileName }); //} //else //{ // find.Date = DateTime.Now; // col.Update(find); //} } return(foundProject); }, nameof(RecentProject)); ProjectPath = projectPath; // Read all relevant md files var mdFilePaths = Directory.GetFiles(projectPath, "*.md", SearchOption.TopDirectoryOnly); var resTeam = from mdFile in mdFilePaths where mdFile.ToLower().EndsWith("team.md") select new Team() { LastUpdate = File.GetLastWriteTime(mdFile), FileName = Path.GetFileName(mdFile), FullFileName = mdFile }; var resReadMe = from mdFile in mdFilePaths where mdFile.ToLower().EndsWith(".md") select new ReadMe() { Text = CreateMarkup(mdFile), LastUpdate = File.GetLastWriteTime(mdFile), FileName = Path.GetFileName(mdFile), FullFileName = mdFile }; //var resOther = from mdFile in mdFilePaths // where mdFile.ToLower().EndsWith(".md") //&& !resReadMe.Contains<BaseMd>(mdFile) // select new BaseMd() { Text = File.ReadAllText(Path.Combine(projectPath, mdFile)) }; var castedProjectFiles = ProjectFiles as List <BaseMd>; castedProjectFiles.Clear(); castedProjectFiles.AddRange(resTeam); // NOTE: reworked it to show every kind of MD file other than 'Team' as 'ReadMe' due to time constraints. - 22 Jan 18 foreach (var item in resReadMe) { castedProjectFiles.Remove(item); } castedProjectFiles.AddRange(resReadMe); // castedProjectFiles.AddRange(resOther); ProjectLoaded?.Invoke(project, new EventArgs()); return(true); } else { statusNotificationService.SendMessage(new Notification() { Kind = NotificationKind.Warning, Message = "The directory is not a valid git repo.", Title = "Invalid Repo", Time = DateTime.Now }); return(false); } } else { statusNotificationService.SendMessage(new Notification() { Kind = NotificationKind.Warning, Message = "The remembered directory does not exist (anymore).", Title = "Not Found", Time = DateTime.Now }); return(false); } }