public PagePresenter(TabItem item) { Item = item; Frame frame = (Frame)item.Content; Content = (QueryPage)frame.Content; }
public void SaveAsQuery(QueryPage page, string fileName) { page.FileName = fileName; page.Save(); }
public bool CloseQuery(QueryPage page) { if (page.Modified && ConfirmFileSave) { switch (MessageBox.Show(String.Format("Save {0}?", page.FileName), GetApplicationTitle(), MessageBoxButton.YesNoCancel, MessageBoxImage.Question)) { case MessageBoxResult.Yes: if (!SaveQuery(page)) return false; break; case MessageBoxResult.Cancel: return false; } } page.Close(); return true; }
public bool SaveQuery(QueryPage page) { if (page.FilePath != String.Empty) page.Save(); else { IQueryEngineFacade facade = page.QueryFacade; SaveFileDialog dlg = new SaveFileDialog(); dlg.DefaultExt = facade.DefaultExt; dlg.Filter = String.Format("{0} files|*{1}|Text documents|*.txt|All files|*.*", facade.EngineName, facade.DefaultExt); dlg.FileName = page.ShortFileName; if (dlg.ShowDialog() != true) return false; SaveAsQuery(page, dlg.FileName); } return true; }
public void CloneQuery(TabControl queryTabs, QueryPage page) { QueryPage cloned_page = new QueryPage(page.QueryFacade); cloned_page.FileName = GetNewQueryTitle(queryTabs, page.QueryFacade); cloned_page.textEditor.Text = page.textEditor.Text; AddPage(queryTabs, cloned_page); }
public void OpenQuery(TabControl queryTabs, string fileName) { QueryPage page = null; String ext = Path.GetExtension(fileName); Frame frame = (Frame)queryTabs.SelectedContent; if (frame != null) { page = (QueryPage)frame.Content; if (page.HasContent) page = null; } if (page == null || String.Compare(page.QueryFacade.DefaultExt, ext, true) != 0) { page = new QueryPage(CreateQueryFacade(ext)); AddPage(queryTabs, page); } page.Title = Path.GetFileName(fileName); page.FileName = fileName; page.Load(); }
public void NewQuery(TabControl queryTabs, IQueryEngineFacade facade) { QueryPage page = new QueryPage(facade); page.FileName = GetNewQueryTitle(queryTabs, facade); AddPage(queryTabs, page); }
private void AddPage(TabControl queryTabs, QueryPage page) { Binding binding = new Binding(); binding.Source = page; binding.Path = new PropertyPath("Title"); binding.Mode = BindingMode.OneWay; TabItem tab = new CloseableTabItem(); tab.SetBinding(TabItem.HeaderProperty, binding); tab.IsSelected = true; tab.AddHandler(CloseableTabItem.CloseTabEvent, new RoutedEventHandler(CloseTab)); Frame frame = new Frame(); frame.Content = page; tab.Content = frame; queryTabs.Items.Add(tab); }