Draw a line in C# for metro app - microsoft-metro

I am trying to draw a line in a windows 8 app in c#. However, when I try to use
Line myLine = new Line(); it does not work and tells me the namespace does not exist.
Using LineGeometery myLine = new LineGeometery (); does appear to create a new line and I can set the start and end points. However, as I cannot set the stroke, I really do not know if this is the correct approach. In fact, I am unsure on the difference between LineGeometery() and Line().
If anyone could help, that would be very appreciated.
<code>using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;</code>

Please add the following using in your application.
Windows.UI.Xaml.Shapes
Line class resides in the Windows.UI.Xaml.Shapes namespace.
Here's the part of code I used to add a line to a grid named LayoutRoot
Line line = new Line();
line.X1 = 10;
line.X2 = 200;
line.Y1 = 10;
line.Y2 = 200;
line.Stroke = new SolidColorBrush(Colors.Red);
LayoutRoot.Children.Add(line);

Related

MRTKv2 'Interactable' script for dynamically added gameobjects

So I want to be able to use the 'Interactable' script in MRTKv2 for some of my gameobjects. I've had success when attaching the 'Interactable' and 'NearInteractionTouchable' script to the corresponding gameobject, but not when attempting to add the same functionality dynamically in the script.
Since the 'Microsoft.MixedReality.Toolkit.UI' isn't currently defined, I know I can't reference the 'Interactable' script in the script directly, but in using the 'IMixedRealityFocusHandler', 'IMixedRealityPointerHandler', 'IMixedRealityTouchHandler', and 'IMixedRealityInputHandler' interfaces instead I still haven't had success in receiving any input.
The namespaces currently defined by MRTKv2
All of the namespaces in MRTKv2
Event mapping from HL1 to HL2
Any ideas on a step that I'm missing to recreate the functionality of the 'Interactable' script that can be attached to gameobjects dynamically?
Interactable does exist in the MRTK namespace under using Microsoft.MixedReality.Toolkit.UI; perhaps you are missing references to your projects? The following code works for me, using the latest mrtk_development:
using Microsoft.MixedReality.Toolkit.Input;
using Microsoft.MixedReality.Toolkit.UI;
using UnityEngine;
public class AddInteractableTest : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
gameObject.AddComponent<Interactable>();
gameObject.AddComponent<NearInteractionTouchable>();
}
}

Keeping track of text position on pdf using FPDF and GetY

I am trying to keep track of the current Y position on a PDF page created using FPDF so that I can correctly start a new page ensuring tables do not cross a page break. Firstly am I right in using GetY to monitor this and if so what is the correct syntax. I am trying
$currentYposition = GetY();
but it does not seem to work. Any advice?
No idea why this works - but it does:
If you just grab Y after the call, it seems to be the value before the MultiCell.
Grabbing it before and after and taking the difference gives you the height.
$oldY = $this->getY();
$this->MultiCell(150, 4, utf8_decode($description), 0, "L");
$newY = $this->getY();
$multiCellHeight = $newY-$oldY;
This one worked for me.
$y = $pdf->GetY();
I came to this question when programming in python and using the fpdf module. I'll post in case anyone else need this, I could not find this solution in the official documentation but for me following worked:
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
current_y = FPDF.get_y(pdf)

IronPython error, "'TextBox' object has no attribute 'text'" when using a ShowDialog() method created in SharpDevelop

I am trying to call a form designed in SharpDevelop within another IDE. I get the following error message: 'TextBox' object has no attribute 'text'. This happens when I run the script which includes the lines shown below in the other IDE. Is the problem in the script itself or in the Form1 class written in SharpDevelop? How can I resolve this?
import myform
import System
f = myform.Form1()
if f.ShowDialog() == System.Windows.Forms.DialogResult.OK:
dx = f._directionx.text
dy = f._directiony.text
dz = f._directionz.text
nb = f._nbofiterations.text
w = f._width.text
h = f._height.text
Since it appears that you're using IronPython (the System.Windows.Forms gave it away) I'm guessing that your TextBox is a Forms element.
If this is so, you need the .Text property - everything (properties, functions/methods that I know of) in the .NET library starts with an uppercase letter.
change .text to .Text
dx = f._directionx.Text
and so on
C sharp is case sensitive language

ObjectSet library is not being found?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using ModelLayer.PocoModels;
using System.Data.Objects;
namespace ModelLayer
{
public class NorthwindDataContext : ObjectContext
{
private ObjectSet<Category> _categories;
private ObjectSet<Product> _products;
public NorthwindDataContext()
: base("name=NorthwindEntities",
"NorthwindEntities")
{
_categories = CreateObjectSet<Category>();
_products = CreateObjectSet<Product>();
}
}
}
In the above code I get an error as it cant find the ObjectSet class and gives me type or namespace not found error.While in the sample project it works fine it is under using System.Data.Objects.ObjectSet but I dont see that library in my current project? I am using asp.net mvc and .net 4.0. Does anyone have any good ideas ?
Make sure your project has a reference to System.Data.Entity.
You may also need references to System.Runtime.Serialization and System.Security.
Visual Studio adds these for you automatically when you add an EDMX file (ADO.NET Entity Data Model) to your project.

Windows Automation with Matlab

Hello I'm trying to control FastHenry2 via Windows automation with Matlab.
I'm new to that topic. If I understood everything right I have to open it:
ax=actxserver('FastHenry2.Document');
and than run the function I want with the handle?
ax.Run('coils1.inp')
but that doesn't work. Matlab can't find Run and uses run instead, which is some build in Function not related at all with the problem. Also all other Function this UI should support don't work either. For Example FastHenry2.IsRunning or FastHenry2.GetInductance. So I guess I do something wrong with the whole UI handling. FastHenry provides an example script using VBS which I attached bellow and since it works fine FastHenry should be installed right on computer. I'm thankful for every hint I can get.
so long
eactor
The following VBS example works fine
Dim FastHenry2
pathPos = InstrRev(Wscript.ScriptFullName, Wscript.ScriptName)
path = left(Wscript.ScriptFullName, pathPos-1)
Set FastHenry2 = CreateObject("FastHenry2.Document")
couldRun = FastHenry2.Run("""" + path + "coils1.inp""")
Do While FastHenry2.IsRunning = True
Wscript.Sleep 500
Loop
inductance = FastHenry2.GetInductance()
WScript.Echo "Coils1 mutual inductance is " + CStr(inductance(0, 0, 1))
FastHenry2.Quit
Set FastHenry2 = Nothing
You might need to use an alternate syntax. Instead of
FastHenry2.Run('coils1.inp')
try this.
invoke(FastHenry2, 'Run', 'coils2.inp')
I've had to do this for some methods on the Excel.Application ActiveX control. I'm not clear why the first syntax doesn't work in some cases.