C# PictureBox.Image Parameter is Invalid - c#

I have this issue, I'm assinging an Image in a PictureBox and I added each PictureBox in a list, then I removed each picture box and create a new one and it's working fine the first 50 or 70 times , but then I have an error Message that said "Parameter is invalid" when I'm assign the same image from Resource.Properties.
stop_disabled.Image = Properties.Resources.stop_disabled; //Parameter is invalid
stop_disabled.SizeMode = stop.SizeMode = PictureBoxSizeMode.Zoom;
stop_disabled.Dock = stop.Dock = DockStyle.Fill;
stop_disabled.Location = stop.Location = new System.Drawing.Point(5, 177);
stop_disabled.Margin = stop.Margin = new System.Windows.Forms.Padding(5);
stopButtonList.Add(stop_disabled);

Related

Print function Using DGVPrinter class

I am using DGVPrinter class for printing my windows form data. after gridview unable to print any text
DGVPrinter printer = new DGVPrinter();
Bitmap bitmap1 = new Bitmap(#"D:\Aur.jpg");
DGVPrinter.ImbeddedImage img1 = new DGVPrinter.ImbeddedImage();
img1.theImage = bitmap1; img1.ImageX = 3; img1.ImageY = 3;
img1.ImageAlignment = DGVPrinter.Alignment.Right;
img1.ImageLocation = DGVPrinter.Location.Header;
printer.ImbeddedImageList.Add(img1);
printer.SubTitle = getprocess_setvalupar();
printer.SubTitleAlignment = StringAlignment.Far;
printer.SubTitleFormatFlags = StringFormatFlags.DirectionRightToLeft;
printer.PageNumbers = true;
printer.PageNumberInHeader = true;
printer.PorportionalColumns = true;
printer.HeaderCellAlignment = StringAlignment.Center;
printer.Footer = GetSignatureFooter("XXXXX Ltd");
printer.FooterSpacing = 15;
printer.PrintDataGridView(dataGridView1);
I am unable to print some text after gridview. If i tried to call function after printer.PrintDataGridView(dataGridView1);text not displaying
I am able to print subtitle before gridview in page. but unable after gridview.

ASPxTabControl created dynamically does not receive input events

I have a ASP page with a ASPxTabControl created dynamically (in C#/code behind). The first tab is selected.
But for some reason if I click the 2nd tab, it does not get selected. Any idea's why this could be the case?
Here is my C# code:
Label question1 = new Label();
question1.Text = "Vraag 1";
question1.Font.Bold = true;
placeHolderVrResults.Controls.Add(question1);
ASPxTabControl tabQuestion1 = new ASPxTabControl();
tabQuestion1.TabStyle.BackColor = Color.White;
tabQuestion1.Paddings.PaddingLeft = 0;
tabQuestion1.Paddings.PaddingRight = 0;
tabQuestion1.Enabled = true;
tabQuestion1.EnableClientSideAPI = true;
Tab tab1 = new Tab();
tab1.Text = "1";
tab1.ActiveTabStyle.BackColor = Color.FromArgb(0, 26, 171, 178);
Tab tab2 = new Tab();
tab2.Text = "2";
tab2.ActiveTabStyle.BackColor = Color.FromArgb(0, 26, 171, 178);
tabQuestion1.Tabs.Add(tab1);
tabQuestion1.Tabs.Add(tab2);
placeHolderVrResults.Controls.Add(tabQuestion1);
If I use ASPxTabControl in the .aspx page, then it just works.
So I must be missing some property of ASPxTabControl which needs to be set such that it can receive input/mouse events?
BR, Rene
Your code looks fine, and this works perfectly for me DevExpress Version=16.1.6.0
ASPxTabControl tab = new ASPxTabControl();
tab.Tabs.Add(new Tab("hi"));
tab.Tabs.Add(new Tab("2"));
this.PanelContent3.Controls.Add(tab);
But each project is different, so always you can open a ticket in DX support, they are very nice and will help you for sure.

How to add a map marker to map? Windows Phone

I have passed a GeoCoordinate variable to the page of my map class, but when I try to draw a marker to the map I get an error stating that GeoCoordinate is a 'type' but is used as a 'variable' It also gives me syntax error for the ; at PositionOrigin = new Point(0.5, 0.5);
and the closing ;.
I understand from this that my syntax must be incorrect for adding a map marker due to getting this error. My question is how do I correct this method to draw the marker?
Am I drawing the marker the correct way or is there a different solution?
This is the onNaviagatedTo method of the map page where I pass the coordinates and try to add a marker:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (NavigationContext.QueryString.ContainsKey("GeoLat") && NavigationContext.QueryString.ContainsKey("GeoLong"))
{
var latitude = Convert.ToDouble(NavigationContext.QueryString["GeoLat"]);
var longtitude = Convert.ToDouble(NavigationContext.QueryString["GeoLong"]);
var MyGeoPosition = new GeoCoordinate(latitude, longtitude);
var overlay = new MapOverlay
{
PositionOrigin = new Point(0.5, 0.5); //syntax error
GeoCoordinate = MyGeoPosition; //error thrown here
Content = new TextBlock{Text = "My car"};
var ml = new MapLayer { overlay };
MyMap.Layers.Add(ml);
}; //syntax error
}
Looks to me like you're missing an equal sign.
MapOverlay overlay = new MapOverlay()
{
PositionOrigin = new Point(0.5, 0.5),
GeoCoordinate = MyGeoPosition,
Content = new TextBlock{Text = "My car"},
};
MapLayer ml = new MapLayer { overlay };
MyMap.Layers.Add(ml);
Or, you could just do this with PushPins:
PushPin myPin = new Pushpin();
myPin.Location = MyGeoPosition;
myPin.Content = "My car";
MyMap.Children.Add(myPin);

Trying to add overlays to map error

I just cleared layers off my mapping program and when I try to add a new layer I receive this error message.
newSystem.ArgumentException was unhandled by user code
HResult=-2147024809
Message=Value does not fall within the expected range.
Source=System.Windows
InnerException:
If anyone knows why this is I would very much appreciate your assistance
private void loadZoomLevel12Pics()
{
map1.Layers.Clear();
MapLayer pinLayer = new MapLayer();
// Create a new empty Pushpin
// Beny Sur- Mer War Cemetary
MapOverlay pinOverlay = new MapOverlay();
// Add the location of the Pushpin using latitude and longitude.
pinOverlay.GeoCoordinate = new GeoCoordinate(49.33783000, -0.45215600);
//Image pinOverlayImage = new Image();
pinOverlayImage.Source = new BitmapImage(new Uri("images/Hedgehog.png", UriKind.Relative));
pinOverlay.Content = pinOverlayImage;
pinOverlay.PositionOrigin = new Point(0.0, 0.0);
pinOverlayImage.Opacity = 0.8;
pinOverlayImage.Height = 8;
pinOverlayImage.Width = 8;
pinOverlayImage.Tap += pinOverlayImage_Tap;
pinLayer.Add(pinOverlay);
map1.Layers.Add(pinLayer);
Then these pictures are cleared and a new zoom level is loaded
private void loadZoomLevel13Pics()
{
map1.Layers.Clear();
MapLayer pinLayer = new MapLayer();
// Create a new empty Pushpin
// Beny Sur- Mer War Cemetary
MapOverlay pinOverlay = new MapOverlay();
// Add the location of the Pushpin using latitude and longitude.
pinOverlay.GeoCoordinate = new GeoCoordinate(49.33783000, -0.45215600);
//Image pinOverlayImage = new Image();
pinOverlayImage.Source = new BitmapImage(new Uri("images/Hedgehog.png", UriKind.Relative));
pinOverlay.Content = pinOverlayImage;
pinOverlay.PositionOrigin = new Point(0.0, 0.0);
pinOverlayImage.Opacity = 0.8;
pinOverlayImage.Height = 30;
pinOverlayImage.Width = 30;
pinOverlayImage.Tap += pinOverlayImage_Tap;
pinLayer.Add(pinOverlay);
map1.Layers.Add(pinLayer); // THIS IS THE LINE CAUSING THE PROBLEM
All of the images are declared globally because they are used in other functions/methods inside the program.
It seems like its trying to add the same layer that was previously added and is having difficulty doing so, but all of the layers are cleared on the first line of the method.
I had this same issue using a global polygon instead of an image. The issue is that even though you are calling map1.Layers.Clear() this does not get done immediately after it is called therefore you need to create a new image. In general, this can be fixed by not using global/instance variables for the overlay.Content...just declare it each time and assign it to the Content.

How to retrieve the name of a Panorama-Item at runtime?

I am programmatically adding items to my Panorama Control called PanoramaCC.
//function to create the panorama items in our view
private void showPanorama(string panoramaName)
{
//create the panorama item and define it
PanoramaItem genItem = new PanoramaItem();
genItem.Height = 265;
genItem.Width = 440;
genItem.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(PanoramaItem_Tap);
genItem.Name = panoramaName;
//create the stackpanel for the panoramaitem
StackPanel genStack = new StackPanel();
genStack.Orientation = System.Windows.Controls.Orientation.Horizontal;
//margin to be done
genStack.Margin = new Thickness(0, -20, 0, 20);
//load the image
Image genImg = new Image();
genImg.Height = 220;
genImg.Width = 400;
genImg.Stretch = System.Windows.Media.Stretch.Fill;
genImg.Margin = new Thickness(20, 5, 20, 5);
string path = "Assets/AppGraphics/CreditCards/" + panoramaName.ToString() + "Front.png";
Uri uriR = new Uri(path, UriKind.Relative);
BitmapImage imgSource = new BitmapImage(uriR);
genImg.Source = imgSource;
//add image into stackpanel
genStack.Children.Add(genImg);
//add stackpanel to the panoramaitem
genItem.Content = genStack;
//add the panoramaitem to the panoramaview
this.PanoramaCC.Items.Add(genItem);
}
The issue I have is that during runtime I want to retrieve the name of the panoramaItem I am currently looking at and do something with it. I've managed to retrieve the name through the tap event for navigation purposes, string name = ((PanoramaItem)sender).Name; but this is a diffrent scenario. I want to retrieve the name and then delete the item with the corresponding name. Pressing a button should delete the currently selected panoramaItem, is what I'm trying to achieve.
You can get the current PanoramaItem by using the SelectedItem property. You don't need to get the name to delete it.
PanoramaItem currentItem = myPanorama.SelectedItem as PanoramaItem;
if(currentItem != null)
{
//if you want the name for other reasons
string name = currentItem.Name;
//Items returns an ItemsCollection object
myPanorama.Items.Remove(currentItem);
}

Categories

Resources