private void radMenuItem13_Click(object sender, EventArgs e) { var np = new NewItemDialog(); if (np.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var f = new Core.ProjectSystem.File(); f.Name = np.Filename; f.Src = np.Filename; f.ID = np.Type; Workspace.SelectedProject.Files.Add(f); explorerTreeView.Nodes.Clear(); explorerTreeView.Nodes.Add(SolutionExplorer.Build(Workspace.Solution, solutionContextMenu, projectContextMenu, fileContextMenu)); Workspace.Solution.Save(Workspace.SolutionPath); var fi = new FileInfo(Workspace.SolutionPath).Directory.FullName + "\\" + f.Name; System.IO.File.WriteAllBytes(fi, np.Template.Raw); np.Plugin.Events.Fire("OnCreateItem", f, np.Template.Raw); var doc = new DocumentWindow(f.Name); doc.Controls.Add(ViewSelector.Select(np.Template, System.IO.File.ReadAllBytes(fi), f, np.Template.AutoCompletionProvider as IntellisenseProvider).GetView()); AddDocument(doc); } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { var uiapp = commandData.Application; var uidoc = uiapp.ActiveUIDocument; var doc = uidoc.Document; var acview = doc.ActiveView; var collecor = new FilteredElementCollector(doc); var planviews = collecor.OfClass(typeof(ViewPlan)).Where(m => !(m as ViewPlan).IsTemplate).OrderBy(m => m.Name); ViewSelector selector = new ViewSelector(); selector.sourceView.ItemsSource = planviews; selector.sourceView.DisplayMemberPath = "Name"; selector.sourceView.SelectedIndex = 0; selector.targetViewList.ItemsSource = planviews; selector.targetViewList.DisplayMemberPath = "Name"; selector.ShowDialog(); var sourceview = selector.sourceView.SelectionBoxItem as View; var targetviews = selector.targetViewList.SelectedItems.Cast <ViewPlan>(); Transaction ts = new Transaction(doc, "复制裁剪"); ts.Start(); var boundingbox = sourceview.CropBox; //MessageBox.Show(boundingbox.Max.ToString() + Environment.NewLine+ // boundingbox.Min.ToString()); foreach (var targetview in targetviews) { var boundingbox1 = new BoundingBoxXYZ(); boundingbox1.Transform = targetview.CropBox.Transform; boundingbox1.Max = boundingbox.Max; boundingbox1.Min = boundingbox.Min; targetview.CropBox = boundingbox1; var para_crop = targetview.get_Parameter(BuiltInParameter.VIEWER_CROP_REGION); var para_crop_visible = targetview.get_Parameter(BuiltInParameter.VIEWER_CROP_REGION_VISIBLE); para_crop.Set(1); para_crop_visible.Set(1); } ts.Commit(); selector.Close(); } catch (Exception e) { return(Result.Cancelled); } return(Result.Succeeded); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (SlingServletResourceTypes != null) { hashCode = hashCode * 59 + SlingServletResourceTypes.GetHashCode(); } if (SlingServletMethods != null) { hashCode = hashCode * 59 + SlingServletMethods.GetHashCode(); } if (SlingServletSelectors != null) { hashCode = hashCode * 59 + SlingServletSelectors.GetHashCode(); } if (DownloadConfig != null) { hashCode = hashCode * 59 + DownloadConfig.GetHashCode(); } if (ViewSelector != null) { hashCode = hashCode * 59 + ViewSelector.GetHashCode(); } if (SendEmail != null) { hashCode = hashCode * 59 + SendEmail.GetHashCode(); } return(hashCode); } }
protected void Page_Load(object sender, EventArgs e) { var skinnable = Master as BaseMasterPage; if (skinnable != null) { skinnable.Skin = new CustomerFocusSkin(ViewSelector.CurrentViewIs(MasterPageFile)); } var pageUrl = ValidatePageUrlFromQueryString(); if (pageUrl == null) { return; } this._problem.Page = _cms.ReadMetadataForPage(pageUrl); ReadWebAuthorsForPage(pageUrl); if (this._problem.WebAuthors.Count == 0) { this.reportForm.Visible = false; this.noWebAuthor.Visible = true; return; } DisplayWebAuthors(); DisplayLinkToPage(); DisplayProblemTypes(); }
void BeforeShow(object viewModel, Type viewType) { ViewModel = viewModel; if (viewType != null) { ViewSelector.Add(ViewModel, viewType); } }
private static View CreateMenu(Menu menu, ViewSelector viewSelector) { View view = menu.CreateView(); viewSelector.GetListView().AppendItem(StringListViewItem.Create(Variant.Create(view.Handle), menu.Name, 216, 0)); viewSelector.AppendView(view); return(view); }
protected void Page_Load(object sender, EventArgs e) { var skinnable = Master as BaseMasterPage; if (skinnable != null) { skinnable.Skin = new CustomerFocusSkin(ViewSelector.CurrentViewIs(MasterPageFile)); } }
protected override void UninitializeCore() { if (ViewModel != null) { ViewSelector.Remove(ViewModel); } ViewModel = null; base.UninitializeCore(); }
void IStrategy.Inject(object viewModel, Type viewType) { if (viewModel == null || ViewModels.Contains(viewModel)) { return; } ViewSelector.Add(viewModel, viewType); ViewModels.Add(viewModel); OnInjected(viewModel); }
void IStrategy.Remove(object viewModel) { if (viewModel == null || !ViewModels.Contains(viewModel)) { return; } ViewSelector.Remove(viewModel); ViewModels.Remove(viewModel); OnRemoved(viewModel); }
private void ShowGotoLineDialog() { EdiViewModel f = this.ActiveDocument as EdiViewModel; if (f != null) { Window dlg = null; Edi.View.Dialogs.GotoLine.GotoLineViewModel dlgVM = null; try { int iCurrLine = Workspace.GetCurrentEditorLine(f); dlgVM = new Edi.View.Dialogs.GotoLine.GotoLineViewModel(1, f.Document.LineCount, iCurrLine); dlg = ViewSelector.GetDialogView((object)dlgVM); // It is important to either: // 1> Use the InitDialogInputData methode here or // 2> Reset the WindowCloseResult=null property // because otherwise ShowDialog will not work twice // (Symptom: The dialog is closed immeditialy by the attached behaviour) dlgVM.InitDialogInputData(); dlg.DataContext = dlgVM; dlg.Closing += dlgVM.OpenCloseView.OnClosing; dlg.Owner = Application.Current.MainWindow; // Make sure that dialog window appears in front of main window dlg.ShowDialog(); // Copy input if user OK'ed it. This could also be done by a method, equality operator, or copy constructor if (((Edi.View.Dialogs.GotoLine.GotoLineViewModel)dlg.DataContext).OpenCloseView.WindowCloseResult == true) { DocumentLine line = f.Document.GetLineByNumber(dlgVM.LineNumber); f.TxtControl.SelectText(line.Offset, 0); // Select text with length 0 and scroll to where f.TxtControl.ScrollToLine(dlgVM.LineNumber); // we are supposed to be at } } catch (Exception exc) { Edi.Msg.Box.Show(exc, "An unexpected error occured.", MsgBoxButtons.OK, MsgBoxImage.Error); } finally { if (dlg != null) { dlg.Closing -= dlgVM.OpenCloseView.OnClosing; dlg.Close(); } } } }
public MainView(MainViewModel vm, ViewSelector navigation) { InitializeComponent(); DataContext = vm; this.navigation = navigation; var eventAggregator = ServiceLocator.Current.GetInstance <IEventAggregator>(); eventAggregator.GetEvent <NavigationMessageEvent>().Subscribe(OnNavigation); }
protected void Page_Load(object sender, EventArgs e) { var skinnable = Master as BaseMasterPage; if (skinnable != null) { skinnable.Skin = new CustomerFocusSkin(ViewSelector.CurrentViewIs(MasterPageFile)); } ValidateFilters(); ConvertPostToGetRequest(); RepopulateSearchForm(); DisplayProblemReports(); }
private void explorerTreeView_NodeMouseDoubleClick(object sender, RadTreeViewEventArgs e) { var p = e.Node.Tag as PropertiesView; var f = e.Node.Tag as Core.ProjectSystem.File; if (p != null) { var v = new PropertiesView(); var doc = new DocumentWindow(e.Node.Text); doc.Controls.Add(v.GetView()); AddDocument(doc); } if (f != null) { ItemTemplate np = null; Plugin nn = null; foreach (var item in Workspace.PluginManager.Plugins) { foreach (var it in item.ItemTemplates) { if (it.ID == f.ID) { np = it; nn = item; } } } byte[] raw = null; if (Workspace.SelectedProject != null) { raw = System.IO.File.ReadAllBytes(new FileInfo(Workspace.SolutionPath).Directory.FullName + "\\" + f.Src); } else { raw = System.IO.File.ReadAllBytes(f.Src); } nn?.Events.Fire("OnCreateItem", np, f, raw); var doc = new DocumentWindow(f.Name); doc.Controls.Add(ViewSelector.Select(np, raw, f, np?.AutoCompletionProvider as IntellisenseProvider, doc).GetView()); AddDocument(doc); } }
protected (Type componentType, string propertyName) GetModelViewComponentInfo(object model) { (Type componentType, string propertyName)viewComponentInfo = ViewSelector.GetModelViewComponentInfo(model); if (viewComponentInfo == (null, null)) { viewComponentInfo = DefaultViewSelector.GetModelViewComponentInfo(model); } if (viewComponentInfo == (null, null)) { viewComponentInfo = new(typeof(ComponentNotRegistered), "Model"); } return(viewComponentInfo); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, System.EventArgs e) { var skinnable = Master as BaseMasterPage; if (skinnable != null) { skinnable.Skin = new CustomerFocusSkin(ViewSelector.CurrentViewIs(MasterPageFile)); css.Attributes["class"] = skinnable.Skin.TextContentClass; } // Return the correct HTTP status code new Web.HttpStatus().BadRequest(); // Set the page title Page.Title = "Bad request"; }
private void Show404(Uri requestedUrl) { // Return the correct HTTP status code new Web.HttpStatus().NotFound(); // Set the page title Page.Title = "Page not found"; var skinnable = Master as BaseMasterPage; if (skinnable != null) { skinnable.Skin = new CustomerFocusSkin(ViewSelector.CurrentViewIs(MasterPageFile)); css.Attributes["class"] = skinnable.Skin.TextContentClass; } var nonce = Guid.NewGuid().ToString().Replace("-", String.Empty); new ContentSecurityPolicyHeaders(Response.Headers).AppendPolicy($"script-src 'nonce-{nonce}'").UpdateHeaders(); // Configure the tracking script and track the 404 with Google Analytics script.TagName = "script"; script.Attributes.Add("nonce", nonce); if (requestedUrl != null) { script.Attributes.Add("data-request", Server.HtmlEncode(Regex.Replace(requestedUrl.PathAndQuery, @"[^A-Za-z0-9/\-_\.\?=:#+%]", String.Empty))); } var normalisedReferrer = String.Empty; try { if (Request.UrlReferrer != null) { normalisedReferrer = Request.UrlReferrer.ToString().Replace("'", "\'"); } } catch (UriFormatException) { // Catch this error and simply ignore the referrer if it is an invalid URI, which can happen in a hacking scenario. // For example, if the request contains an invalid referring URL such as http://google.com', when you access the // Request.UrlReferrer property .NET creates a Uri instance which throws this exception. } script.Attributes.Add("data-referrer", Server.HtmlEncode(Regex.Replace(normalisedReferrer, @"[^A-Za-z0-9/\-_\.\?=:#+%]", String.Empty))); }
protected void Page_Load(object sender, EventArgs e) { var skinnable = Master as BaseMasterPage; if (skinnable != null) { skinnable.Skin = new CustomerFocusSkin(ViewSelector.CurrentViewIs(MasterPageFile)); } if (!IsPostBack && !String.IsNullOrEmpty(Request.QueryString["redirect"])) { // Get the redirect id from the querystring int editRedirectId; try { editRedirectId = Int32.Parse(Request.QueryString["redirect"], CultureInfo.InvariantCulture); // Read it from the db and populate the form using (var reader = SqlHelper.ExecuteReader(ConfigurationManager.ConnectionStrings["RedirectsWriter"].ConnectionString, CommandType.StoredProcedure, "usp_Redirect_Select", new SqlParameter("@redirectId", editRedirectId))) { while (reader.Read()) { this.redirectId.Value = editRedirectId.ToString(CultureInfo.InvariantCulture); this.pattern.Text = "/" + reader["Pattern"].ToString(); this.destination.Text = reader["Destination"].ToString(); SelectRedirectType(reader["Type"].ToString()); this.comment.Text = reader["Comment"].ToString(); } } this.Title = Properties.Resources.EditRedirect; this.h1.Text = Properties.Resources.EditRedirect; } catch (OverflowException) { } catch (FormatException) { } } else if (!IsPostBack && !String.IsNullOrEmpty(Request.QueryString["type"])) { SelectRedirectType(Request.QueryString["type"]); } }
/// <summary> /// Returns true if ComDayCqDamCoreImplServletResourceCollectionServletProperties instances are equal /// </summary> /// <param name="other">Instance of ComDayCqDamCoreImplServletResourceCollectionServletProperties to be compared</param> /// <returns>Boolean</returns> public bool Equals(ComDayCqDamCoreImplServletResourceCollectionServletProperties other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( SlingServletResourceTypes == other.SlingServletResourceTypes || SlingServletResourceTypes != null && SlingServletResourceTypes.Equals(other.SlingServletResourceTypes) ) && ( SlingServletMethods == other.SlingServletMethods || SlingServletMethods != null && SlingServletMethods.Equals(other.SlingServletMethods) ) && ( SlingServletSelectors == other.SlingServletSelectors || SlingServletSelectors != null && SlingServletSelectors.Equals(other.SlingServletSelectors) ) && ( DownloadConfig == other.DownloadConfig || DownloadConfig != null && DownloadConfig.Equals(other.DownloadConfig) ) && ( ViewSelector == other.ViewSelector || ViewSelector != null && ViewSelector.Equals(other.ViewSelector) ) && ( SendEmail == other.SendEmail || SendEmail != null && SendEmail.Equals(other.SendEmail) )); }
protected void Page_Load(object sender, EventArgs e) { var skinnable = Master as BaseMasterPage; if (skinnable != null) { skinnable.Skin = new CustomerFocusSkin(ViewSelector.CurrentViewIs(MasterPageFile)); } var sort = "pattern"; if (Request.QueryString["sort"] == "destination") { sort = "destination"; } if (Request.QueryString["sort"] == "date") { sort = "date"; } sortLinks.Controls.Add(new LiteralControl((sort == "destination" || sort == "date") ? "<li><a href=\"moved.aspx\">Moved from</a></li>" : "<li>Moved from</li>")); sortLinks.Controls.Add(new LiteralControl((sort == "destination") ? "<li>Moved to</li>" : "<li><a href=\"moved.aspx?sort=destination\">Moved to</a></li>")); sortLinks.Controls.Add(new LiteralControl((sort == "date") ? "<li>Most recent first</li>" : "<li><a href=\"moved.aspx?sort=date\">Most recent first</a></li>")); var editConfig = XElement.Load(Server.MapPath(@".\edit\web.config")); var allowed = editConfig.Descendants("authorization").Descendants("allow").Attributes("roles").Select(attr => attr.Value).ToList(); var permissions = new LogonIdentityGroupMembershipChecker(); editTable.Visible = (allowed.Count > 0 && permissions.UserIsInGroup(allowed)); add.Visible = editTable.Visible; viewTable.Visible = !editTable.Visible; var table = editTable.Visible ? editTable : viewTable; using (var reader = SqlHelper.ExecuteReader(ConfigurationManager.ConnectionStrings["RedirectsReader"].ConnectionString, "usp_Redirect_SelectByType", new SqlParameter("@type", 2), new SqlParameter("@sort", sort))) { table.DataSource = reader; table.DataBind(); } }
/// <summary> /// Handles the PreInit event of the page. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void page_PreInit(object sender, EventArgs e) { //... and change the master page. var page = sender as Page; // If there's no master page at the moment, this page would probably fail if we assigned a master page as it'll // have controls other than <asp:Content /> on it. So just drop out here in that case. if (String.IsNullOrEmpty(page.MasterPageFile)) { return; } var preferredMasterPage = ViewSelector.SelectView(page.Request.QueryString, page.Request.UserAgent, ViewEngine.WebForms, page.Request.Cookies); // If the master page has been set, change it. // Otherwise if no default was in config, just leave it using the one it would've used anyway. if (!String.IsNullOrEmpty(preferredMasterPage)) { page.MasterPageFile = preferredMasterPage; } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, System.EventArgs e) { var skinnable = Master as BaseMasterPage; if (skinnable != null) { skinnable.Skin = new CustomerFocusSkin(ViewSelector.CurrentViewIs(MasterPageFile)); css.Attributes["class"] = skinnable.Skin.TextContentClass; } // change status Response.Status = "500 Internal Server Error"; // introduce random delay, so defend against anyone trying to detect errors based on the time taken // Code from http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx byte[] delay = new byte[1]; using (RandomNumberGenerator prng = new RNGCryptoServiceProvider()) { prng.GetBytes(delay); Thread.Sleep((int)delay[0]); } }
private static unsafe void OnOptionPanelActivated(IntPtr pOptionPanelModule, bool unk) { IntPtr pOptionWindow = OptionPanelModule_c.GetOptionWindow(pOptionPanelModule + 0xB8); if (pOptionWindow == IntPtr.Zero) { return; } IntPtr pViewSelector = *(IntPtr *)(pOptionWindow + 0x78); if (pViewSelector == IntPtr.Zero) { return; } ViewSelector viewSelector = ViewSelector.FromPointer(pViewSelector, false); foreach (Menu menu in _menus) { CreateMenu(menu, viewSelector); } }
protected void Page_Load(object sender, EventArgs e) { var skinnable = Master as BaseMasterPage; if (skinnable != null) { skinnable.Skin = new CustomerFocusSkin(ViewSelector.CurrentViewIs(MasterPageFile)); } var reportId = GetReportIdFromQueryString(); if (reportId == -1) { return; } _problem = _repo.ReadProblemReport(reportId); this.subject.InnerText = _problem.SubjectLine(); this.reportDate.InnerText = _problem.ReportDate.ToBritishDateWithDay(); this.messageHtml.Text = _problem.MessageHtml; DisplayWebAuthors(); }
/// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override void CreateChildControls() { // Ensure controls are visible by default this.Visible = true; // Look for various reasons why controls may need to be hidden // Hide based on master page if (Desktop != null && Desktop.Value != ViewSelector.CurrentViewIs(Page.MasterPageFile, EsccWebsiteView.Desktop)) { HideContents(); return; } if (Plain != null && Plain.Value != ViewSelector.CurrentViewIs(Page.MasterPageFile, EsccWebsiteView.Plain)) { HideContents(); return; } if (FullScreen != null && FullScreen.Value != ViewSelector.CurrentViewIs(Page.MasterPageFile, EsccWebsiteView.FullScreen)) { HideContents(); return; } // Hide based on user var libraryContext = new LibraryCatalogueContext(HttpContext.Current.Request.UserAgent); if (LibraryCatalogue != null && LibraryCatalogue.Value != libraryContext.RequestIsFromLibraryCatalogueMachine()) { HideContents(); return; } if (!String.IsNullOrEmpty(Groups)) { var settings = new ActiveDirectorySettingsFromConfiguration(); var permissions = new LogonIdentityGroupMembershipChecker(settings.DefaultDomain, new SessionPermissionsResultCache()); if (!permissions.UserIsInGroup(Groups.SplitAndTrim(';'))) { HideContents(); return; } } // Hide based on location if (!String.IsNullOrEmpty(this.UrlMatch) && !Regex.IsMatch(HttpContext.Current.Request.Url.ToString(), this.UrlMatch, RegexOptions.IgnoreCase)) { HideContents(); return; } var context = new HostingEnvironmentContext(); if (Public != null && Public.Value != context.IsPublicUrl) { HideContents(); return; } // Hide based on date if (this.After.HasValue && DateTime.Now.ToUkDateTime() <= this.After) { HideContents(); return; } if (this.Before.HasValue && DateTime.Now.ToUkDateTime() >= this.Before) { HideContents(); return; } }
private void ShowFindReplaceDialog(bool ShowFind = true) { EdiViewModel f = this.ActiveDocument as EdiViewModel; if (f != null) { Window dlg = null; try { if (this.FindReplaceVM == null) { this.FindReplaceVM = new Edi.View.Dialogs.FindReplace.FindReplaceViewModel(); } this.FindReplaceVM.FindNext = this.FindNext; // determine whether Find or Find/Replace is to be executed this.FindReplaceVM.ShowAsFind = ShowFind; if (f.TxtControl != null) // Search by default for currently selected text (if any) { string textToFind; f.TxtControl.GetSelectedText(out textToFind); if (textToFind.Length > 0) { this.FindReplaceVM.TextToFind = textToFind; } } this.FindReplaceVM.CurrentEditor = f; dlg = ViewSelector.GetDialogView((object)this.FindReplaceVM); // It is important to either: // 1> Use the InitDialogInputData methode here or // 2> Reset the WindowCloseResult=null property // because otherwise ShowDialog will not work twice // (Symptom: The dialog is closed immeditialy by the attached behaviour) this.FindReplaceVM.InitDialogInputData(); dlg.DataContext = this.FindReplaceVM; dlg.Closing += this.FindReplaceVM.OpenCloseView.OnClosing; dlg.Owner = Application.Current.MainWindow; // Make sure that dialog window appears in front of main window dlg.ShowDialog(); } catch (Exception exc) { Edi.Msg.Box.Show(exc, "An unexpected error occured.", MsgBoxButtons.OK, MsgBoxImage.Error); } finally { if (dlg != null) { dlg.Closing -= this.FindReplaceVM.OpenCloseView.OnClosing; dlg.Close(); } } } }
public Form1() { InitializeComponent(); startpageDocument.Controls.Add(new StartPage(openMenuItem_Click, newProjectMenuItem_Click) { Dock = System.Windows.Forms.DockStyle.Fill }); NotificationService.Init(radDesktopAlert1); ThemeResolutionService.ApplicationThemeName = "VisualStudio2012Dark"; Workspace.Settings.Load(); if (!Workspace.Settings.Get <bool>("BetaAccepted")) { new BetaKeyDialog(this).ShowDialog(); Hide(); } Workspace.Output = new Core.Contracts.Debug(outputTextBox); Workspace.PluginManager.Load(Environment.CurrentDirectory + "\\Plugins"); foreach (var item in Workspace.PluginManager.Plugins) { foreach (var win in item.Windows) { var tw = new ToolWindow(win.Value.Title); var ctrl = win.Value.View.Build(); ctrl.Dock = System.Windows.Forms.DockStyle.Fill; tw.Controls.Add(ctrl); dock.AddDocument(tw); } } // add here loading from startup // file, project, solution var args = Environment.GetCommandLineArgs(); if (args.Length > 0) { string file = null; #if DEBUG if (args.Length > 1) { file = args[1]; } #else file = args[0]; #endif if (file != null) { switch (Path.GetExtension(file)) { case ".sln": Workspace.Solution = Solution.Load(file); Workspace.SolutionPath = file; startpageDocument.Hide(); solutionExplorerWindow.Show(); newProjectMenuItem.Enabled = true; newFileMenuItem.Enabled = true; explorerTreeView.Nodes.Clear(); explorerTreeView.Nodes.Add(SolutionExplorer.Build(Workspace.Solution, solutionContextMenu, projectContextMenu, fileContextMenu)); break; case "proj": var p = Project.Load(file); explorerTreeView.Nodes.Clear(); explorerTreeView.Nodes.Add(SolutionExplorer.Build(p, projectContextMenu, fileContextMenu)); break; default: var f = new Core.ProjectSystem.File(); var shortF = Path.GetFileName(file); f.Name = shortF; f.Src = file; f.ID = Utils.GetTemplateID(shortF); explorerTreeView.Nodes.Clear(); explorerTreeView.Nodes.Add(SolutionExplorer.Build(f, fileContextMenu)); ItemTemplate np = null; Plugin npp = null; foreach (var item in Workspace.PluginManager.Plugins) { foreach (var it in item.ItemTemplates) { if (it.ID == f.ID) { np = it; npp = item; } } } var raw = System.IO.File.ReadAllBytes(file); npp.Events.Fire("OnCreateItem", np, f, raw); var doc = new DocumentWindow(f.Name); doc.Controls.Add(ViewSelector.Select(np, raw, f, np.AutoCompletionProvider as IntellisenseProvider, doc).GetView()); AddDocument(doc); startpageDocument.Hide(); break; } } } RefreshLanguage(); addItemContextItem.Click += radMenuItem13_Click; }
protected void Page_Load(object sender, EventArgs e) { var skinnable = Master as BaseMasterPage; if (skinnable != null) { skinnable.Skin = new CustomerFocusSkin(ViewSelector.CurrentViewIs(MasterPageFile)); } // Use standard parameter instead of the old tQ if (String.IsNullOrEmpty(Request.QueryString["q"]) && !String.IsNullOrEmpty(Request.QueryString["tq"])) { var query = HttpUtility.ParseQueryString(Request.QueryString.ToString()); query.Remove("tq"); query.Add("q", Request.QueryString["tq"]); var revisedUrl = new Uri(Request.Url.Scheme + "://" + Request.Url.Authority + Request.Url.AbsolutePath + "?" + query); new HttpStatus().MovedPermanently(revisedUrl); } // If there's a search query if (!String.IsNullOrEmpty(Request.QueryString["q"])) { // Redisplay search term if (!String.IsNullOrEmpty(Request.QueryString["refine"])) { this.Title = "Search results for '" + HttpUtility.HtmlEncode(Request.QueryString["refine"]) + "' within '" + HttpUtility.HtmlEncode(Request.QueryString["q"]) + "'"; } else { this.Title = "Search results for '" + HttpUtility.HtmlEncode(Request.QueryString["q"]) + "'"; } this.heading.InnerHtml = this.Title; this.catalogueSearch.InnerHtml = string.Format("<a href=\"https://e-library.eastsussex.gov.uk/cgi-bin/spydus.exe/ENQ/OPAC/BIBENQ?ENTRY_NAME=BS&ENTRY={0}&ENTRY_TYPE=K&NRECS=20&SORTS=HBT.SOVR&SEARCH_FORM=%2Fcgi-bin%2Fspydus.exe%2FMSGTRN%2FOPAC%2FBSEARCH&CF=GEN&ISGLB=0\"> Search the library catalogue for '{1}' </a>", HttpUtility.HtmlEncode(Request.QueryString["q"]), HttpUtility.HtmlEncode(Request.QueryString["q"])); // Search Google with standard options var service = new GoogleSiteSearch(ConfigurationManager.AppSettings["GoogleSearchEngineId"]); var cacheHours = new TimeSpan(Int32.Parse(ConfigurationManager.AppSettings["CacheHours"], CultureInfo.CurrentCulture), 0, 0); service.CacheStrategy = new FileCacheStrategy(Server.MapPath(ConfigurationManager.AppSettings["CacheFilePath"]), cacheHours); var query = new GoogleQuery(Request.QueryString["q"]); if (!String.IsNullOrEmpty(Request.QueryString["refine"])) { query.QueryWithinResultsTerms = Request.QueryString["refine"]; } query.PageSize = this.paging.PageSize; query.Page = this.paging.CurrentPage; try { var response = service.Search(query); // Display results this.paging.TotalResults = response.TotalResults; this.noResults.Visible = (this.paging.TotalResults == 0 && response.ResultsAvailable); this.resultsUnavailable.Visible = (this.paging.TotalResults == 0 && !response.ResultsAvailable); if (this.noResults.Visible == false) { this.searchLibrary.InnerHtml = string.Format("<a href=\"https://e-library.eastsussex.gov.uk/cgi-bin/spydus.exe/ENQ/OPAC/BIBENQ?ENTRY_NAME=BS&ENTRY={0}&ENTRY_TYPE=K&NRECS=20&SORTS=HBT.SOVR&SEARCH_FORM=%2Fcgi-bin%2Fspydus.exe%2FMSGTRN%2FOPAC%2FBSEARCH&CF=GEN&ISGLB=0\"> Search the library catalogue for '{1}' </a>", HttpUtility.HtmlEncode(Request.QueryString["q"]), HttpUtility.HtmlEncode(Request.QueryString["q"])); } var searchResults = response.Results(); this.results.DataSource = searchResults; this.results.DataBind(); // Display spelling suggestions if (response.SpellingSuggestions().Count > 0) { this.spelling.Visible = true; foreach (string suggestion in response.SpellingSuggestions()) { if (this.suggestions.Controls.Count > 0) { this.suggestions.Controls.Add(new LiteralControl(" or ")); } using (var spellingLink = new HtmlAnchor()) { spellingLink.InnerText = suggestion; spellingLink.HRef = Request.Url.LocalPath + "?q=" + HttpUtility.UrlEncode(suggestion); this.suggestions.Controls.Add(spellingLink); } } } } catch (XmlException ex) { // This catches where Google has a 500 error and sends back malformed XML, <GSP VER="3.2"> <ERROR>500</ERROR>. // Exception is "Unexpected end of file has occurred. The following elements are not closed: GSP. Line 3, position 19." this.noResults.Visible = true; new HttpStatus().BadGateway(); ex.ToExceptionless().Submit(); } } else { this.noResults.Visible = true; new HttpStatus().BadRequest(); } #if (!DEBUG) new HttpCacheHeaders().CacheUntil(Response.Cache, DateTime.Now.AddDays(1)); #endif }