public string GetUrl(MarkerContext ctx) { // A MarkerContext object contains state describing a text editor instance of a link definition. // GetUrl is called when Flags include PluginFlags.OverrideUrl, allowing you to specify a // state-dependent URL to open when the user double-clicks the associated link text. // ctx is null when GetUrl has been called from the Source Links page of the Visual Assist Options // dialog; in such cases, return text relevant to the user or simply return String.Empty (for // read-only display in the link definition). // When ctx is not null, you are responsible for returning either a valid URL or null/string.Empty. // Source Links will not modify the returned URL; it will only validate and execute it. Debug.WriteLine("Source Links calling GetUrl(MarkerContext)"); if (ctx == null) { // When the MarkerContext is null, GetUrl has been called from the Source Links page // of the Visual Assist Options dialog to get text to display in the URL field of the // link definition. return(_url); } else { // Url to be executed, based on text editor value matched by the link definition. // This example implementation also calls GetUrl directly from GetTooltip, passing // the MarkerContext that it received. return(_url.Replace("$(Value)", ctx.ValueText)); } }
public ExampleContextMenuItem(MarkerContext ctx, string text) { _ctx = ctx; // Header text might be dependent upon state in ctx MarkerContext Header = text; Command = this; // Icon = new Image { Source = YourImage }; }
public void Execute(MarkerContext ctx) { // A MarkerContext object contains state describing a text editor instance of a link definition. // Execute will not get called in this example because Flags in this implementation don't include // PluginFlags.OverrideExecute. // If you include PluginFlags.OverrideExecute in Flags, Execute is called when the user double-clicks the // link instance described by the MarkerContext. You are responsible for executing the action related to // the link. // It is possible that any member of ctx may be null, string.Empty or 0. Debug.WriteLine("Source Links calling Execute(MarkerContext)"); }
private void AddUserPlace(MarkerContext context) { PointLatLng pointLatLng = GetCoordinates(context.City, context.Street, context.StreetNumber); Image image = new Image(); image.Source = new BitmapImage(new Uri(context.MyImageSource)); var byteimage = ImageToByte(image.Source as BitmapImage); Marker newmarker = new Marker() { Name = context.Name, City = context.City, Street = context.Street, Number = context.StreetNumber, Contacts = context.Contacts.ToArray(), Description = context.Description, Lat = pointLatLng.Lat, Lng = pointLatLng.Lng, MarkerType = context.Type, Picture = byteimage, UserName = LoginName }; bll.AddNewPlace(newmarker); }
public MarkerController(MarkerContext context) { _context = context; if (_context.Markers.Count() == 0) { // Create a new TodoItem if collection is empty, // which means you can't delete all TodoItems. _context.Markers.Add(new Marker { PollutionDate = new DateTime(), AddressName = "", Latitude = 0m, Longitude = 0m, NO2Mean = 0f, NO2MaxValue = 0, NO2MaxHour = 0, NO2AQI = 0, O3Mean = 0f, O3MaxValue = 0, O3MaxHour = 0, O3AQI = 0, SO2Mean = 0f, SO2MaxValue = 0, SO2MaxHour = 0, SO2AQI = 0, COMean = 0f, COMaxValue = 0, COMaxHour = 0, COAQI = 0 }); _context.SaveChanges(); } }
public void ContextExecute(MarkerContext ctx) { // If you include PluginFlags.OverrideContextExecute in Flags, ContextExecute is called when // the user right-clicks on a link marker. Debug.WriteLine("Source Links calling ContextExecute()"); try { _contextMenu = new ExampleContextMenu(ctx) { IsOpen = true }; } catch (System.Exception /*ex*/) { System.Diagnostics.Debug.Assert(false, "ContextExecute threw an exception"); } }
internal ExampleContextMenu(MarkerContext ctx) { // Wire up theming of ContextMenu and MenuItem via Visual Assist VaWPFTheming.dll Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("pack://application:,,,/VaWPFTheming;component/ThemedControls.xaml", UriKind.Absolute) }); Style = TryFindResource(typeof(ContextMenu)) as Style; // if menu is executed using keyboard, use marker's bounding rectangle to position the menu if (ctx != null && (bool)ctx.GetNamedProperty(MarkerContext.NamedProperties.IsMouseEvent) == false) { // get the bounding rectangle of the marker, it is returned as double[4] { left, top, right, bottom } double[] markerBounds = ctx.GetNamedProperty(MarkerContext.NamedProperties.MarkerBoundsScreen) as double[]; if (markerBounds != null && markerBounds.Length == 4) { // apply rectangle as a PlacementRectangle PlacementRectangle = new Rect(new Point(markerBounds[0], markerBounds[1]), new Point(markerBounds[2], markerBounds[3])); Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom; } } // add context menu command items Items.Add(new ExampleContextMenuItem(ctx, "Command _1") { Style = TryFindResource(typeof(MenuItem)) as Style }); Items.Add(new ExampleContextMenuItem(ctx, "Command _2") { Style = TryFindResource(typeof(MenuItem)) as Style }); Items.Add(new Separator()); Items.Add(new ExampleContextMenuItem(ctx, "Command _3") { Style = TryFindResource(typeof(MenuItem)) as Style }); }
public string GetTooltip(MarkerContext ctx) { // A MarkerContext object contains state describing a text editor instance of a link definition. // GetTooltip gets called when the mouse cursor hovers over plugin-associated link text. // It is possible that any member of ctx may be null, string.Empty or 0. // The returned string can be either plane text or XAML. // XAML text must be valid in the context of the VASourceLinks.dll assembly, thus all // resources must be defined in a way which the XAML parser may resolve. // Return null or String.Empty if you don't need to provide tooltip text from your plugin. Debug.WriteLine("Source Links calling GetTooltip(MarkerContext)"); // We can determine the link definition behavior from the MarkerContext. // When Exe != null, then behavior is set to ShellExecute. // When Url != null, then behavior is set to open URL in Browser. // The Url, Exe and ExeArgs members of the MarkerContext contain information // from the link definition; if your plugin overrides URL or Execute, the values // may be irrelevant. // Note: In this example, GetUrl is always called because Flags include // OverrideUrl; user can't select ShellExecute behavior with the default // implementation of the example plugin. string actionText = string.Empty; string actionLabel = string.Empty; if (Flags.HasFlag(PluginFlags.OverrideExecute)) { actionLabel = "Execute:"; actionText = "Overridden by plugin"; } else if (Flags.HasFlag(PluginFlags.OverrideUrl)) { actionLabel = "Open URL:"; actionText = GetUrl(ctx); } else { if (ctx.Url != null) // Open URL in Browser { actionLabel = "Open URL:"; actionText = ctx.Url; } else if (ctx.Exe != null) // ShellExecute { actionLabel = "ShellExecute:"; actionText = ctx.Exe; if (!string.IsNullOrEmpty(ctx.ExeArgs)) { actionText += " " + ctx.ExeArgs; } } } // The return string can be either plain text or valid XAML. // This example demonstrates how to turn simple markup into valid XAML. // The returned XAML defines a TextBlock. string tooltip = string.Format( // We can use formatted markup text for FlowDocument. // See: https://msdn.microsoft.com/en-us/library/aa970909(v=vs.110).aspx and // https://docs.microsoft.com/en-us/dotnet/articles/framework/wpf/advanced/flow-document-overview "<Bold>File name:</Bold> {0}<LineBreak/>" + "<Bold>Project file name:</Bold> {1}<LineBreak/>" + "<Bold>Solution file name:</Bold> {2}<LineBreak/>" + "<Bold>Line:</Bold> {3}<LineBreak/>" + "<Bold>Column:</Bold> {4}<LineBreak/>" + "<Bold>Line text:</Bold> {5}<LineBreak/>" + "<Bold>Marker text:</Bold> {6}<LineBreak/>" + // Or we can use some HTML inline tags: H1-H6, B, STRONG, I, EM, U, DEL, INS, S, BR // Those tags are replaced with appropriate XAML tags by calling PluginUtils.WrapMarkupInXAML. // HTML attributes are not supported. "<b>Keyword text:</b> {7}<br/>" + "<b>Value text:</b> {8}<br/>" + "<b>" + actionLabel + "</b> {9}", // Images are supported: // "<Image Source=\"path\\to\\image.jpg\"/>" // Use PluginUtils.EncodeXML in places where text could contain special XML characters. PluginUtils.EncodeXML(System.IO.Path.GetFileName(ctx.FileName)), // 0 PluginUtils.EncodeXML(System.IO.Path.GetFileName(ctx.ProjectName)), // 1 PluginUtils.EncodeXML(System.IO.Path.GetFileName(ctx.SolutionName)), // 2 ctx.Line, // 3 ctx.Column, // 4 PluginUtils.EncodeXML(ctx.LineText), // 5 PluginUtils.EncodeXML(ctx.MarkerText), // 6 PluginUtils.EncodeXML(ctx.KeywordText), // 7 PluginUtils.EncodeXML(ctx.ValueText), // 8 PluginUtils.EncodeXML(actionText)); // 9 // PluginUtils.WrapMarkupInXAML replaces selected HTML formatting tags // with appropriate XAML tags (<b> becomes <Bold> and <br> becomes // <LineBreak>) and wraps the result into a TextBlock. // Note: Because WrapMarkupInXAML wraps your input into a TextBlock, it // can contain ONLY tags derived from Inline. If your tooltip must contain // Block, then don't use this method; format the whole XAML directly, // including required namespaces. return(PluginUtils.WrapMarkupInXAML(tooltip)); }
public MarkersController() : base() { markersContext = new MarkerContext(); }