Remove Bing Maps Pushpins with separate button - wpf

currently I can display pushpins onto my Bing Maps but I would simply like to remove them when another button is pressed, in this case I would be calling it BTNReset. This is just to make the maps a little more tidy when it becomes clustered so the user can remove all uneccessary pushpins.
Private Sub Berwickshire() Handles BTNCounty.Click
If TXTCounty.Text = "Berwickshire" Then
Dim CountyLocation(20) As Microsoft.Maps.MapControl.WPF.Location
CountyLocation(0) = New Microsoft.Maps.MapControl.WPF.Location(55.705617, -2.4676497)
CountyLocation(1) = New Microsoft.Maps.MapControl.WPF.Location(55.780619, -2.3413039)
CountyLocation(2) = New Microsoft.Maps.MapControl.WPF.Location(55.720304, -2.2638738)
CountyLocation(3) = New Microsoft.Maps.MapControl.WPF.Location(55.746443, -2.2271899)
CountyLocation(4) = New Microsoft.Maps.MapControl.WPF.Location(55.808939, -2.4924539)
CountyLocation(5) = New Microsoft.Maps.MapControl.WPF.Location(55.882232, -2.3064212)
CountyLocation(6) = New Microsoft.Maps.MapControl.WPF.Location(55.852663, -2.3889276)
CountyLocation(7) = New Microsoft.Maps.MapControl.WPF.Location(55.802325, -2.2096172)
CountyLocation(8) = New Microsoft.Maps.MapControl.WPF.Location(55.651853, -2.252035)
CountyLocation(9) = New Microsoft.Maps.MapControl.WPF.Location(55.690431, -2.3361588)
CountyLocation(10) = New Microsoft.Maps.MapControl.WPF.Location(55.645024, -2.3311619)
CountyLocation(11) = New Microsoft.Maps.MapControl.WPF.Location(55.932739, -2.3614317)
CountyLocation(12) = New Microsoft.Maps.MapControl.WPF.Location(55.870455, -2.0969097)
CountyLocation(13) = New Microsoft.Maps.MapControl.WPF.Location(55.852035, -2.1896638)
CountyLocation(14) = New Microsoft.Maps.MapControl.WPF.Location(55.887334, -2.1601164)
CountyLocation(15) = New Microsoft.Maps.MapControl.WPF.Location(55.841716, -2.1222754)
CountyLocation(16) = New Microsoft.Maps.MapControl.WPF.Location(55.771675, -2.803132)
CountyLocation(17) = New Microsoft.Maps.MapControl.WPF.Location(55.719837, -2.750872)
CountyLocation(18) = New Microsoft.Maps.MapControl.WPF.Location(55.680163, -2.5615687)
CountyLocation(19) = New Microsoft.Maps.MapControl.WPF.Location(55.741492, -2.5838242)
CountyLocation(20) = New Microsoft.Maps.MapControl.WPF.Location(55.637369, -2.6798897)
Dim names = New String() {
"Greenlaw",
"Duns",
"Swinton",
"Whitsome",
"Longformacus",
"Grantshouse",
"Abbey St Bathans",
"Chirnside",
"Coldstream",
"Leitholm",
"Birgham",
"Cockburnspath",
"Eyemouth",
"Reston",
"Coldingham",
"Ayton",
"Oxton",
"Lauder",
"Gordon",
"Westruther",
"Earlston"}
For index = 0 To CountyLocation.Length - 1
Dim Pin = New Microsoft.Maps.MapControl.WPF.Pushpin()
Dim CoordinateTip = New System.Windows.Controls.ToolTip()
CoordinateTip.Content = names(index)
Pin.Location = CountyLocation(index)
Pin.ToolTip = CoordinateTip
BingMap.Children.Add(Pin)
Next
End If
End Sub

You can do BingMap.Children.Clear() to remove all data on the map.

Related

Xamarin Forms and Calendar in c#

I use to Xamarin Calendar my project of C#.
https://github.com/lilcodelab/Xamarin.Plugin.Calendar
I want to mark several undefined dates, because I want to download them from a text file
Example file:
5/5/2020|Name
As you can see in the Binding events part, the event is bind with Events collection, you could create several event object like:
MyEvent event1=new MyEvent(name,description);
MyEvent event2=new MyEvent(name,description);
and add them into the list:
events.add(event1);
events.add(event2);
In the end I solved it this way
enter code here
String path = #"actividades.txt";
var filePath = Path.Combine(DEFAULTPATH, path);
string texto1;
System.IO.StreamReader sr = new System.IO.StreamReader(filePath);
Events = new EventCollection();
while (!sr.EndOfStream)
{
texto1 = sr.ReadLine();
string[] words = texto1.Split('|');
DateTime fecha = DateTime.Parse(words[0]);
d = fecha.Day;
m = fecha.Month;
y = fecha.Year;
if (words.Length > 2)
Events.Add(new DateTime(y, m, d), new List<Evento> { new Evento { Nombre = words[2], Tipo = words[1], colorF = words[3] } });
}

How to add attributes for custom claims types for IdP Saml2 response

I converted the IdPInitiatedController example code for my WebForms project. Although I don't get compiler or runtime error, I still cannot seem to get the manually created claims added to the Saml2AuthnResponse object after setting the claims identity. Is there another way to add attributes to the SAML response? The app uses forms authentication; and the credentials are in a SQL database. That's why I don't have Windows Identity.
' SSO CODE BEHIND
...
Dim binding = New Saml2PostBinding With {
.RelayState = String.Format("RPID={0}", Uri.EscapeDataString(serviceProviderRealm))
}
Dim config = New Saml2Configuration With {
.Issuer = "company.stage.app",
.SingleSignOnDestination = New Uri(ConfigurationManager.AppSettings.Get("appValue")),
.SigningCertificate = CertificateUtil.Load(X509Certificates.StoreName.TrustedPeople, X509Certificates.StoreLocation.LocalMachine, X509Certificates.X509FindType.FindByThumbprint, ConfigurationManager.AppSettings.Get("ThatKey")),
.SignatureAlgorithm = Saml2SecurityAlgorithms.RsaSha256Signature
}
Dim samlResponse = New Saml2AuthnResponse(config) With {
.Status = Saml2StatusCodes.Success
}
_ssoService.AddAttributes(samlResponse, currentUser)
binding.Bind(samlResponse) ' NO ATTRIBUTES WERE ADDED
Me.SAMLResponse.Value = binding.XmlDocument.InnerXml
Me.RelayState.Value = binding.RelayState
frmSSO.Action = config.SingleSignOnDestination.AbsoluteUri()
frmSSO.Method = "POST"
Public Sub AddAttributes(ByRef samlResponse As Saml2AuthnResponse, ByVal currentUser As CurrentUser)
Dim acctContact As CoveredInsuredDto = _coveragesService.GetAccountPointOfContact(currentUser.getControlNo())
If Not IsNothing(acctContact) Then
' Adding Attributes as claims
Dim claimIdentity = New ClaimsIdentity(Me.BuildClaims(currentUser, acctContact))
samlResponse.NameId = New IdentityModel.Tokens.Saml2NameIdentifier(acctContact.Name)
samlResponse.ClaimsIdentity = claimIdentity
End If
End Sub
Private Function BuildClaims(ByVal currentUser As CurrentUser, ByVal acctContact As CoveredInsuredDto) As IEnumerable(Of Claim)
Dim claims = New List(Of Claim)
If Not IsNothing(acctContact) Then
claims.Add(New Claim("FIRST_NAME", acctContact.FirstName))
claims.Add(New Claim("LAST_NAME", acctContact.LastName))
End If
Return claims.ToList()
End Function
The problem is that you have forgot the var token = response.CreateSecurityToken(appliesToAddress); line which is actually the line creating the token.
The ASP.NET Core IdP Initiated sample code:
public IActionResult Initiate()
{
var serviceProviderRealm = "https://some-domain.com/some-service-provider";
var binding = new Saml2PostBinding();
binding.RelayState = $"RPID={Uri.EscapeDataString(serviceProviderRealm)}";
var config = new Saml2Configuration();
config.Issuer = "http://some-domain.com/this-application";
config.SingleSignOnDestination = new Uri("https://test-adfs.itfoxtec.com/adfs/ls/");
config.SigningCertificate = CertificateUtil.Load(Startup.AppEnvironment.MapToPhysicalFilePath("itfoxtec.identity.saml2.testwebappcore_Certificate.pfx"), "!QAZ2wsx");
config.SignatureAlgorithm = Saml2SecurityAlgorithms.RsaSha256Signature;
var appliesToAddress = "https://test-adfs.itfoxtec.com/adfs/services/trust";
var response = new Saml2AuthnResponse(config);
response.Status = Saml2StatusCodes.Success;
var claimsIdentity = new ClaimsIdentity(CreateClaims());
response.NameId = new Saml2NameIdentifier(claimsIdentity.Claims.Where(c => c.Type == ClaimTypes.NameIdentifier).Select(c => c.Value).Single(), NameIdentifierFormats.Persistent);
response.ClaimsIdentity = claimsIdentity;
var token = response.CreateSecurityToken(appliesToAddress);
return binding.Bind(response).ToActionResult();
}
private IEnumerable<Claim> CreateClaims()
{
yield return new Claim(ClaimTypes.NameIdentifier, "some-user-identity");
yield return new Claim(ClaimTypes.Email, "some-user#domain.com");
}

Relate a Docusign Envelope to a Salesforce Custom object

I have a Template created in DS which contains custom tags which are mapped to Salesforce fields. The template works well when used via the JS button example code provided by DS and the fields appear as expected.
I am now trying to automate the process using the Docusign SOAPAPI. When creating the envelope the custom fields aren't populated; even the signer fields.
Below is my code:-
DocusignAPI.ArrayOfRecipient1 recipients = new DocusignAPI.ArrayOfRecipient1();
recipients.Recipient = new list<DocusignAPI.Recipient>();
DocusignAPI.Recipient recipient = new DocusignAPI.Recipient();
recipient.Email = signer_email;
recipient.UserName = signer_name;
recipient.ID = 1;
recipient.Type_x = 'Signer';
recipient.RoutingOrder = 1;
recipients.Recipient.add(recipient);
DocusignAPI.ArrayOfTemplateReference templateReferences = new DocusignAPI.ArrayOfTemplateReference();
templateReferences.TemplateReference = new list<DocusignAPI.TemplateReference>();
DocusignAPI.TemplateReference templateReference = new DocusignAPI.TemplateReference();
TemplateReference.Template = '6bc2930f-6d46-4804-a9fc-69d1cf3ebe09';
templateReference.TemplateLocation = 'Server';
templateReferences.TemplateReference.add(templateReference);
DocusignAPI.EnvelopeInformation ei = new DocusignAPI.EnvelopeInformation();
ei.AccountId = account_id;
ei.Subject = 'Lorem Ipsum';
ei.EmailBlurb = 'More text...';
// Create an envelope and fill it in
DocusignAPI.CustomField field = new DocusignAPI.CustomField ();
field.Name = 'DSFSSourceObjectId';
field.Value = 'a1qW0000000vMCj';
field.Show = 'false';
field.CustomFieldType = 'Text';
DocusignAPI.ArrayOfCustomField arrayOfCustomFields = new DocusignAPI.ArrayOfCustomField();
arrayOfCustomFields.CustomField = new list<DocusignAPI.CustomField>();
arrayOfCustomFields.CustomField.add(field);
ei.CustomFields = arrayOfCustomFields;
try {
DocusignAPI.EnvelopeStatus result = api_sender.CreateEnvelopeFromTemplates(templateReferences, recipients, ei, true);
envelope_id = result.EnvelopeID;
System.debug('Returned successfully, envelope_id = ' + envelope_id );
} catch ( CalloutException e) {
System.debug('Exception - ' + e );
error_code = 'Problem: ' + e;
error_message = error_code;
}
All customtags are related to my custom object with id defined in the CustomField above.
Any help gratefully appreciated.
Turns out I need to add in the object API name to the Id. Solution is:-
DocusignAPI.CustomField field = new DocusignAPI.CustomField ();
field.Name = 'DSFSSourceObjectId';
field.Value = 'a1qW0000000vMCj~Property__c';
field.Show = 'false';
field.CustomFieldType = 'Text';

ListView not scrolling when items added pro-grammatically

I have a listView which I add a number of buttons to in a for loop. However the listView isn't scrollable even if I set it to be scrollable. I'm not sure why this is happening. I'm simply adding a button every time I enter the for loop however once there is too many buttons to view on the listview no scroll bar appears. My code is as follows.
ListViewTemplates.HeaderStyle = ColumnHeaderStyle.None
For i As Integer = 1 To level3Cat.Count
counter = i Mod 2
If counter = 0 Then
Dim picture As Button = New Button()
picture.Location = New System.Drawing.Point(165, topForNextControl)
picture.Size = New System.Drawing.Size(90, layoutTemplateHeight)
picture.TabStop = False
picture.BackgroundImageLayout = BackgroundImageLayout.Stretch
picture.BackgroundImage = My.Resources.XButton
ListViewTemplates.Controls.Add(picture)
topForNextControl += layoutTemplateHeight + HeighScaleFactor
Else
Dim picture As Button = New Button()
picture.Location = New System.Drawing.Point(35, topForNextControl)
picture.Size = New System.Drawing.Size(90, layoutTemplateHeight)
picture.TabStop = False
picture.BackgroundImageLayout = BackgroundImageLayout.Stretch
picture.BackgroundImage = My.Resources.XButton
ListViewTemplates.Controls.Add(picture)
End If
ListViewTemplates.Scrollable = True
ListViewTemplates.View = View.Details
counter += 1
Next

ArcGIS Runtime for wpf - PointDataSource mapTip

I have GraphicsLayer in my application and I use PointDataSource like itemsSource:
trackEntryPointDataSource = new PointDataSource();
trackEntryPointDataSource.DataSpatialReference =
new SpatialReference((int)CommonEpsgCodes.JTSKEN);
trackEntryPointDataSource.XCoordinateBinding =
new System.Windows.Data.Binding("XJTSK");
trackEntryPointDataSource.YCoordinateBinding =
new System.Windows.Data.Binding("YJTSK");
SimpleRenderer srd = new SimpleRenderer();
srd.Symbol = new SimpleMarkerSymbol()
{
Color = new SolidColorBrush(Colors.Yellow)
};
EntriesLyr.GraphicsSource = trackEntryPointDataSource;
EntriesLyr.Renderer = srd;
Have someone any idea how to add MapTips to graphics symbols?
GraphicsLayer class has a MapTip property.
A detailed example if found here

Resources