I'm using Gmap.net great tools for enable mapping in my .net 4 desktop application.
I'm adding polygons on form load event. But I can not set tooltip text for polygons.
any idea?
The only way to do it that I found is add a marker on the same overlay, and trigger its IsVisible property when the polygon is entered:
var gm = new GMapControl();
GMapOverlay polyOverlay = new GMapOverlay("polygons");
List<PointLatLng> points = new List<PointLatLng>();
points.Add(new PointLatLng(53.0, 10.0));
points.Add(new PointLatLng(53.0, 11.0));
points.Add(new PointLatLng(54.0, 11.0));
points.Add(new PointLatLng(54.0, 10.0));
var polygon = new GMapPolygon(points, "mypolygon");
polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red));
polygon.Stroke = new Pen(Color.Red, 1);
polygon.IsHitTestVisible = true;
Controls.Add(gm);
gm.Overlays.Add(polyOverlay);
polyOverlay.Polygons.Add(polygon);
polyOverlay.Markers.Add(new GMarkerCross(new PointLatLng(53.5, 10.5)) { ToolTipText = "Test me", IsVisible = false, ToolTipMode = MarkerTooltipMode.Always });
gm.OnPolygonEnter += (poly) => polyOverlay.Markers.First().IsVisible = true;
gm.OnPolygonLeave += (poly) => polyOverlay.Markers.First().IsVisible = false;
Instead of GMarkerCross you could use a GMarkerGoogle with an empty Bitmap. Note: GMarkerGoogleType.none results in a System.ArgumentNullException when the mouse enters the polygon.
There is another way to add a ToolTip to a Polygon: Add a label to the form, and hide it in the Load event. Define your Polygon with a name in the usual way, and make sure to set IsHitTestVisible. Add handlers for the OnPolygonEnter and OnPolygonLeave.
Dim points As New List(Of PointLatLng)()
points.Add(New PointLatLng(48.866383, 2.323575))
points.Add(New PointLatLng(48.863868, 2.321554))
points.Add(New PointLatLng(48.861017, 2.33003))
points.Add(New PointLatLng(48.863727, 2.331918))
Dim polygon As New GMapPolygon(points, "Jardin des Tuileries")
polygon.Fill = New SolidBrush(Color.FromArgb(30, Color.Red))
polygon.Stroke = New Pen(Color.Red, 1)
polygon.IsHitTestVisible = True
ovlPolygons.Polygons.Add(polygon)
Private Sub myMap_OnPolygonEnter(item As GMapPolygon) Handles myMap.OnPolygonEnter
Label1.BringToFront()
Label1.Show()
Label1.Text = item.Name
Label1.Location = New Point(MousePosition.X - Me.Left, MousePosition.Y - Me.Top)
End Sub
Private Sub myMap_OnPolygonLeave(item As GMapPolygon) Handles myMap.OnPolygonLeave
Label1.Hide()
End Sub
Related
I created a set of controls in code behind, but I'm stuck on how to render it in xaml.
private List<object> _controlList;
var _radio1 = new RadioButton();
var _radio2 = new RadioButton();
var _textbox1 = new TextBox();
_radio1.Content = "Radio 1";
_radio1.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(RadioButton));
_radio2.Content = "Radio 2";
_radio2.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(RadioButton));
_textbox1.Text = "Textbox 2";
_textbox1.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(TextBox));
_controlList.Add(_radio1);
_controlList.Add(_radio2);
_controlList.Add(_textbox1);
Because I can't access the stacklayout in my xaml due to it is nested stacklayout, that's why I can't use something like stacklayout.children.add(). So instead I create a list of object and hoping to just bind it in a collectionview and automatically render it.
Hope you can help me.
Edit: Motion Detection I believe this may answer my question...
I want to not only detect motion, but read where the motion occurred in the frame. Nothing in MotionDetector seems to have anything about its location. I thought maybe I could run it through MotionDetector then extract the biggest blob, but that doesn't seem to work either. It only picks up one blob.
Video clip is a vehicle coming down a ramp. mainPBX is the original frame, main2PBX is the altered frame (with the biggest blob overlayed). My thought is to read when the blob goes from smaller to bigger (and vice versa), to determine entering or leaving.
Private Sub Processor()
Dim bc As New BlobCounter With {
.MinWidth = 5,
.MinHeight = 5,
.ObjectsOrder = ObjectsOrder.Size
}
Dim detector As New MotionDetector(New SimpleBackgroundModelingDetector, New MotionAreaHighlighting)
Using reader As New AForge.Video.FFMPEG.VideoFileReader()
reader.Open("C:\Videos\MyVideo.mp4")
For i As Integer = 0 To reader.FrameCount - 1
Dim frame = reader.ReadVideoFrame()
Dim frame2 As Bitmap = frame.Clone()
Dim frame3 As Bitmap = frame.Clone()
detector.ProcessFrame(frame2)
bc.ProcessImage(frame2)
Dim blobs = bc.GetObjectsInformation()
If blobs.Length > 0 Then
bc.ExtractBlobsImage(frame3, blobs(0), True)
PBX_Image(main2PBX, frame3.Clone())
End If
PBX_Image(mainPBX, frame.Clone())
Threading.Thread.Sleep(25)
frame.Dispose()
frame2.Dispose()
frame3.Dispose()
Next
End Using
End Sub
This is in no way finished, but I can actually interact with the blobs.
Private Sub Processor()
Dim Rectangles As New List(Of Rectangle)
Dim detector As New SimpleBackgroundModelingDetector With {
.SuppressNoise = True,
.DifferenceThreshold = 10,
.FramesPerBackgroundUpdate = 10,
.KeepObjectsEdges = True
}
Dim processor As New AForge.Vision.Motion.BlobCountingObjectsProcessing With {
.MinObjectsWidth = 40,
.MinObjectsHeight = 40,
.HighlightColor = Color.Red
}
Dim motionDetector As New MotionDetector(detector, processor)
Using reader As New AForge.Video.FFMPEG.VideoFileReader()
reader.Open("C:\Videos\MyVideo.mp4")
For i As Integer = 0 To reader.FrameCount - 1
Dim frame = reader.ReadVideoFrame()
motionDetector.ProcessFrame(frame)
Dim t As BlobCountingObjectsProcessing = motionDetector.MotionProcessingAlgorithm
Dim r As Rectangle = Rectangle.Empty
If t.ObjectRectangles.Length > 0 Then
If t.ObjectRectangles.Length > 2 Then
r = t.ObjectRectangles.Aggregate(Function(r1, r2) If((r1.Width * r1.Height) > (r2.Width * r2.Height), r1, r2))
Else
r = t.ObjectRectangles.First()
End If
End If
If r.IsEmpty = False Then Rectangles.Add(r)
PBX_Image(mainPBX, frame.Clone())
Threading.Thread.Sleep(25)
frame.Dispose()
Next
End Using
End Sub
I have code in c# windows app creating a line in a 2D sketch. And then I created a 3D sketch. Eventually I want to add a helical curve around this line from the 3D sketch. Can anyone help me please to solve this issue? Thanks in advance.
public void MyMethod(Inventor.Application ThisApplication)
{
PartDocument oSheetMetalDoc = (PartDocument)m_oInventorApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, m_oInventorApp.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject, SystemOfMeasureEnum.kMetricSystemOfMeasure, DraftingStandardEnum.kDefault_DraftingStandard, "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"), true);
// Set a reference to the component definition.
SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oSheetMetalDoc.ComponentDefinition;
// Set a reference to the sheet
// metal features collection.
SheetMetalFeatures oSheetMetalFeatures = (SheetMetalFeatures)oCompDef.Features;
// Create a new sketch on the X-Y work plane.
PlanarSketch oSketch = default(PlanarSketch);
oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes[3]);
TransientGeometry oTransGeom = (TransientGeometry)ThisApplication.TransientGeometry;
// Draw a 4cm x 3cm rectangle with the
// corner at (0,0)
SketchLine line = (SketchLine)oSketch.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(0, 0), oTransGeom.CreatePoint2d(0, 500)); // 2. ihtimal
// skecth line turn to centerline
line.Centerline = true;
ThisApplication.ActiveView.GoHome();
// Create a 3D sketch.
Sketch3D sketch3 = (Sketch3D)oCompDef.Sketches3D.Add();
SketchEntity3D selectObj = m_oInventorApp.CommandManager.Pick(SelectionFilterEnum.kSketch3DCurveFilter, "Select 3d sketch entity");
if (selectObj == null)
{
}
// HelicalConstraint3D . want to add helical curve around the line above
}
This is iLogic/VB.net code for creating helix curve based on selected SketchLine.
Part document must be active, and at least one SketchLine must be visible for selection.
Sub Main()
Dim oSketchLine As SketchLine = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchCurveLinearFilter,
"Select line")
CreateHelicalCurve(oSketchLine)
End Sub
Private Sub CreateHelicalCurve(oSketchLine As SketchLine)
Dim partDef As PartComponentDefinition = oSketchLine.Parent.Parent
Dim sketch3D As Sketch3D = partDef.Sketches3D.Add()
Dim axisStartPoint As Point = oSketchLine.StartSketchPoint.Geometry3d
Dim axisEndPoint As Point = oSketchLine.EndSketchPoint.Geometry3d
Dim curveStartPoint As Point = axisStartPoint.Copy()
curveStartPoint.TranslateBy(ThisApplication.TransientGeometry.CreateVector(0, 0, 1))
Dim diameter As Double = 5 ' [cm]
Dim pitch As Double = 1 ' [cm]
Dim revolution As Object = Nothing ' Optional argument
Dim height As Double = 5 ' [cm]
Dim helicalCurveDefinition As HelicalCurveConstantShapeDefinition = sketch3D.HelicalCurves.
CreateConstantShapeDefinition(
HelicalShapeDefinitionTypeEnum.kPitchAndHeightShapeType,
axisStartPoint,
axisEndPoint,
curveStartPoint,
diameter,
pitch,
revolution,
height
)
sketch3D.HelicalCurves.Add(helicalCurveDefinition)
End Sub
i want to generate a word document
as an input i have this string "open packaging conventions" and each word will have a different style
the result should be open packaging conventions
WordprocessingDocument document = WordprocessingDocument.Create(
#"C:\test PFE.docx",
WordprocessingDocumentType.Document
);
MainDocumentPart mainDocumentPart = document.AddMainDocumentPart();
mainDocumentPart.Document = new Document();
mainDocumentPart.Document.AddNamespaceDeclaration("ve", "http://schemas.openxmlformats.org/markup-compatibility/2006");
mainDocumentPart.Document.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
mainDocumentPart.Document.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
mainDocumentPart.Document.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
mainDocumentPart.Document.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
mainDocumentPart.Document.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
mainDocumentPart.Document.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
mainDocumentPart.Document.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
mainDocumentPart.Document.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
Body documentBody = new Body();
mainDocumentPart.Document.Append(documentBody);
StyleDefinitionsPart styleDefinitionsPart =
mainDocumentPart.AddNewPart<StyleDefinitionsPart>();
FileStream stylesTemplate =
new FileStream("styles.xml", FileMode.Open, FileAccess.Read);
styleDefinitionsPart.FeedData(stylesTemplate);
styleDefinitionsPart.Styles.Save();
#region Titre du document
Paragraph titleParagraphe = new Paragraph() { RsidParagraphAddition = "00AF4948", RsidParagraphProperties = "00625634", RsidRunAdditionDefault = "00625634" }; ;
Run run = new Run();
RunProperties rpr = new RunProperties();
RunStyle rstylr = new RunStyle { Val = "style1" };
run.Append(rpr);
Text t = new Text("open");
run.Append(t);
titleParagraphe.Append(run);
run = new Run();
rpr = new RunProperties();
rstylr = new RunStyle { Val = "style2" };
run.Append(rpr);
t = new Text("packaging")
{
Space = new DocumentFormat.OpenXml.EnumValue<DocumentFormat.OpenXml.SpaceProcessingModeValues> { InnerText = "preserve" }
};
run.Append(t);
titleParagraphe.Append(run);
run = new Run();
rpr = new RunProperties();
rstylr = new RunStyle { Val = "style1" };
run.Append(rpr);
t = new Text("conventions")
{
Space = new DocumentFormat.OpenXml.EnumValue<DocumentFormat.OpenXml.SpaceProcessingModeValues> { InnerText = "preserve" }
};
run.Append(t);
titleParagraphe.Append(run);
documentBody.Append(titleParagraphe);
document.MainDocumentPart.Document.Save();
document.Dispose();
and the result is open*packaging*conventions without space between words
can some one help me please?!
You're on good way by handling the Space property, but you need to do it like this:
t = new Text()
{
Text = "your text with spaces ",
Space = SpaceProcessingModeValues.Preserve
};
Here is another way to set the attribute Space that can be used to specify SpaceProcessingMode.
t = new Text("This is some text");
t.Space = SpaceProcessingModeValues.Preserve;
The default of the attribute is SpaceProcessingModeValues.Default.
From API Documentation:
<w:r>
<w:t> significant whitespace </w:t>
</w:r>
Although there are three spaces on each side of the text content in the run, that whitespace has not been specifically marked as significant, therefore it is subject to the space preservation rules currently specified in that run's scope. end example]
The possible values for this attribute are defined by ยง2.10 of the XML 1.0 specification.
I am new to the MVC Framework. Im working on a dashboard project in the MVC framework. The project consists of a bunch of charting control in a user controls contained in a master page. I did a test on a charting control on a aspx page..and it works...but when I moved the code to a ascx (usercontrol) the chart doesnt render. Any ideas?!?!?!...I'm stuck. Thanks in advance
Jeff
Code that is in in the .aspx
<%
System.Web.UI.DataVisualization.Charting.Chart Chart1 = new System.Web.UI.DataVisualization.Charting.Chart();
Chart1.Width = 450;
Chart1.Height = 296;
Chart1.RenderType = RenderType.ImageTag;
Chart1.ImageLocation = "..\\..\\TempImages\\ChartPic_#SEQ(200,30)";
Chart1.Palette = ChartColorPalette.BrightPastel;
Title t = new Title("Program Pipeline", Docking.Top, new System.Drawing.Font("Trebuchet MS", 14, System.Drawing.FontStyle.Bold), System.Drawing.Color.FromArgb(26, 59, 105));
Chart1.Titles.Add(t);
Chart1.ChartAreas.Add("Prog 1");
// create a couple of series
Chart1.Series.Add("Backlog");
Chart1.Series.Add("Constructed");
Chart1.Series.Add("Billed");
Chart1.Series.Add("BudgetUsed");
Chart1.Series.Add("Total");
Chart1.Series["Backlog"].ChartType = SeriesChartType.StackedBar100;
Chart1.Series["Constructed"].ChartType = SeriesChartType.StackedBar100;
Chart1.Series["Billed"].ChartType = SeriesChartType.StackedBar100;
Chart1.Series["Total"].ChartType = SeriesChartType.StackedBar100;
Chart1.Series["BudgetUsed"].ChartType = SeriesChartType.StackedBar100;
Chart1.Series["Backlog"]["DrawingStyle"] = "Cylinder";
Chart1.Series["Constructed"]["DrawingStyle"] = "Cylinder";
Chart1.Series["Billed"]["DrawingStyle"] = "Cylinder";
Chart1.Series["BudgetUsed"]["DrawingStyle"] = "Cylinder";
Chart1.Series["Total"]["DrawingStyle"] = "Cylinder";
// Bar Size
Chart1.Series["Backlog"]["PointWidth"] = "0.6";
Chart1.Series["Constructed"]["PointWidth"] = "0.6";
Chart1.Series["Billed"]["PointWidth"] = "0.6";
Chart1.Series["BudgetUsed"]["PointWidth"] = "0.6";
Chart1.Series["Total"]["PointWidth"] = "0.6";
int _total = 0;
int _newTotalAmt = 100 - _total;
foreach (MvcApplication1.Models.Amount obj in Model.GetTotalAmt("plm1"))
{
_total += obj.TotalAmount;
Chart1.Series[obj.PLMType].Points.AddY(obj.TotalAmount);
}
Chart1.Series["BudgetUsed"].Points.AddY(0);
Chart1.Series["Total"].Points.AddY(_newTotalAmt);
_total = 0;
_newTotalAmt = 100 - _total;
foreach (MvcApplication1.Models.Amount obj in Model.GetTotalAmtForPLM2("plm2"))
{
_total += obj.TotalAmount;
Chart1.Series[obj.PLMType].Points.AddY(obj.TotalAmount);
}
Chart1.Series["BudgetUsed"].Points.AddY(0);
Chart1.Series["Total"].Points.AddY(_newTotalAmt);
_total = 0;
_newTotalAmt = 100 - _total;
foreach (MvcApplication1.Models.Amount obj in Model.GetTotalAmt("plm3"))
{
_total += obj.TotalAmount;
Chart1.Series[obj.PLMType].Points.AddY(obj.TotalAmount);
}
Chart1.Series["BudgetUsed"].Points.AddY(0);
Chart1.Series["Total"].Points.AddY(_newTotalAmt);
// MvcApplication1.Models.TotalPOAmount oTotal = Model.GetOverAllBudget();
// add points to series 3
Chart1.Series["Billed"].Points.AddY(0);
Chart1.Series["Constructed"].Points.AddY(0);
Chart1.Series["Backlog"].Points.AddY(0);
Chart1.Series["BudgetUsed"].Points.AddY(39);
Chart1.Series["Total"].Points.AddY(100);
Chart1.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
Chart1.BorderColor = System.Drawing.Color.FromArgb(26, 59, 105);
Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
Chart1.BorderWidth = 2;
Chart1.Legends.Add("Legend");
// show legend based on check box value
// Chart1.Legends["Legend1"].Enabled = ShowLegend.Checked;
// Render chart control
Chart1.Page = this;
HtmlTextWriter writer = new HtmlTextWriter(Page.Response.Output);
Chart1.RenderControl(writer);
//IList<SelectListItem> list = new List<SelectListItem>();
//SelectListItem sli = new SelectListItem();
//sli.Text = "test1";
//sli.Value = "1";
//list.Add(sli);
//ViewData["Test"] = list;
%>
I've had exactly the same issue. My problem was to do with the paths to the image file. The chart control was getting it wrong when placed on a usercontrol. If I changed the chart to use Imagestoragemode of HttpHandler then it worked as intended.
unfortunatly this stopped me being able to unit test my views. In the end I put the chart control on an aspx page & then used jQuery to load it when needed. (Luckily my dashboard page used javascript to load the contents of the portlets)
I've just been trying to get round what seems to be the same problem. When I moved the code (similar to yours above) to a UserControl the System.Web.UI.DataVisualization namespace wasn't recognised and I received the error:
The type or namespace name
'DataVisualization' does not exist in
the namespace 'System.Web.UI' (are you
missing an assembly reference?)
The namespace only seemed to be recognised when the Chart code lay within an asp control (in the aspx page it was within an <asp:Content> control). So I put the Chart code within an <asp:Panel> control and it worked.