Brother Label Printer c# program with visual studio 2012 for windows8 - windows-8

I want to make a simple program which prints sth (Just wnt it to write sth )
I ve added Interop.bpac.dll (Found it from samples bin folder)
I ve wrote this code
private void buttonTry_Tapped_1(object sender, TappedRoutedEventArgs e)
{
bpac.DocumentClass doc = new DocumentClass();
if(doc.Open("templateFile.lbx"))
{
doc.GetObject("field1").Text = "Hello";
doc.GetObject("field2").Text = "World";
doc.StartPrint("", PrintOptionConstants.bpoDefault);
doc.PrintOut(1, PrintOptionConstants.bpoDefault);
doc.EndPrint();
doc.Close();
}
}
And it gives an error "Interop type 'bpac.DocumentClass' can not be embedded.Use the applicable interface instead." For now Im trying to print QL700 I ll try some other thermal receipt printers later
And also I couldnt get the templateFile.lbx whats that and where does the program search this file?
Thanks :)

Change Embed Interop Types to False

Related

(C++ / CLI) Set contents of textbox to content of a .txt

I am looking to set the contents of a textbox to that of a .txt file,
however I cannot get it to work. I have a button which would "refresh" the
content of the textbox to that of the .txt file, here is the code I am using:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
std::ifstream dat1("DataStore.txt");
String^ textHolder;
if (dat1.is_open())
{
while ( getline(dat1, line) )
{
textHolder += line.c_str;
}
textBox1->Text = textHolder;
dat1.close();
}
else textBox1->Text = "Unable to open file";
}
I get these 2 errors when compiling the program:
error C3867: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str': function call missing argument list; use '&std::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str' to create a pointer to member
error C2297: '+=' : illegal, right operand has type 'const char *(__thiscall std::basic_string<char,std::char_traits<char>,std::allocator<char>>::* )(void) throw() const'
How do I make this work?
NOTE: I am trying to display the whole .txt file's contents in the textbox
If you are going to use C++/CLI you may as well take advantage of .net. You can use the File class to read the file for you:
System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
textBox1->Text = System::IO::File::ReadAllText("DataStore.txt");
}
You'll need to hope that the process working directory contains that file. In a GUI app you are better served by specifying full paths to files, since the working directory is typically ill-defined.
If you are trying to learn C++, then perhaps a .net C++/CLI WinForms application is not the place to start.
You forgot to end method c_str, change it to c_str()

C++ will change it last input

I don't know if anyone had the same problem.
I use Microsoft visual C++ 2010 I am new to it but I know a lot of Java program but for me trying to go from one program to another is confusing.
Anyway I will make a basic program "Hello World" and run it it works fine but when I go and try to type something else or add something to the text it remains the same code when I run it. It does not happen all the time but it will do it a lot and it seam like it is becoming more common.
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
label1 -> Text = "hello world";
}
This is what I put.
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
label1 -> Text = "This is a test";
}
when I run the first code it works, but when I change to the code and put in the 2nd code it will remain the first code when I run it, but I change what the code say so it should change as well but it does not.
There is a setting that controls whether Visual Studio forces a build before you run, likely you set it to false.
Here is a similar question
Tools + Options, Projects and Solutions, Build and Run. "On Run, when projects are out of date" = Always build.

Unable to play sound in Windows 8

I want to play sound from a mp3 file in windows 8 metro-style app. I tried two approaches to do so:
Method1:
This is using the code provided by https://stackoverflow.com/a/10961201/147530. It works.
Method 2:
Here I just new a MediaElement and set its Source property like so:
var x = new MediaElement { Source = new Uri("ms-appx:/Assets/MyMp3File.mp3") };
When I do x.Play() nothing happens however. There are no exceptions thrown.
Question: How can I make method 2 work?
EDIT:
Wanted to update that none of the MediaFailed, MediaOpened, MediaEnded event handlers get called using Method 2.
sound = new MediaElement { Source = new Uri("ms-appx:/Assets/Clook.mp3") };
sound.MediaFailed += sound_MediaFailed;
sound.MediaOpened += sound_MediaOpened;
sound.MediaEnded += sound_MediaEnded;
static void sound_MediaEnded(object sender, RoutedEventArgs e)
{
Debugger.Break();
}
static void sound_MediaOpened(object sender, RoutedEventArgs e)
{
Debugger.Break();
}
static void sound_MediaFailed(object sender, ExceptionRoutedEventArgs e)
{
Debugger.Break();
}
A couple of things to try. Try the following code
var music = new MediaElement()
{
AudioCategory = AudioCategory.ForegroundOnlyMedia,
Source = new Uri(this.BaseUri, "Assets/MyMp3File.mp3")
};
// This is really the only difference, adding it to the visual tree
// LayoutRoot is the root of the visual tree, in the case, a grid in my XAML
LayoutRoot.Children.Add(music);
music.Play();
Adding it to the visual tree may be the key. Put a break point on that to make sure your MediaElement has data in it.
Second (and actually happened to me so, that's why I mention it), I was developing on a Samsung device from //Build that has a docking station. The audio jack on the device and the speakers are disabled when it is in the docking station. You have to plug a headset into the docking station directly or remove it from the docking station to hear any sound.
You have to put the MediaElement in the visualTree before to make it play any media :)
Use x.autoplay = true. With autoplay it will wait until it's loaded.

Newbie trying to creating a Signal Event in MonoDevelop

Newbie here, just trying to create a signal event handler in response to an onclick menu item.
Aint working for me.
I click on the menu item, click signals, to the right of "Activated" where it says "Click to Add Handler", I type in "MyOnClick"
then it shoots me out an error. weird.
Exception has been thrown by the target of an invocation.
I am running this in windows 7 under a vm on macbook pro. Windows is not sharing folders from Macbook Pro so shouldn't be a UNC issue. Pathways seem fine.
Any ideas?
Ben
I have the same issue on mac and windows with current monodevelop versions.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NotImplementedException: The method or operation is not implemented.
It's annoying me so much! Must be some bug.
EDIT: I've solve it!
In source add method like this:
protected virtual void onClick (object sender, EventArgs e)
{
MessageDialog md = new MessageDialog (this, DialogFlags.Modal,
MessageType.Error, ButtonsType.Close, "Some error");
md.Response += delegate(object o, ResponseArgs args) {
if (args.ResponseId == ResponseType.Close)
Console.WriteLine ("Response: Closed");
else
Console.WriteLine ("Other response happened.");
};
md.Run ();
md.Destroy ();
}
Then switch to visual designer and instead double click on signal/method name just type in method name [this case] onClick (no brackets). This time a method is implemented and doesn't cause throwing error.
It work but is not as comfortable as double click.

How to let the user cancel my AutoCAD command

I'm currently developing an AutoCAD 2008 Addin in Visual Basic (.Net 3.0, VisualStudio 2010).
I'm able to define my own command and I want the user to be able to cancel my command by hitting the ESC key.
In AutoCAD 2010 or higher there exists the
HostApplicationServices.Current.UserBreak
method. But not in ACAD 2008.
Does anyone has any suggestions, how the user may be able to cancel my command?
Not sure if this is what your looking for, but I'll throw it out there. In the following example, it prompts the user for input and stores it to the getPointResult. If the user selects "Escape" at this time, the getPointResult.Status will not be PromptStatus.OK, therefor it will not execute the code in the 'if' statement.
Sorry, this is written in C#, but should be easy enough to understand the general idea.
[CommandMethod("test", CommandFlags.Session)]
public void Test()
{
PromptPointOptions getPointOptions = new PromptPointOptions("Select the top-left location for the view: ");
Document currentDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
PromptPointResult getPointResult = currentDocument.Editor.GetPoint(getPointOptions);
if (getPointResult.Status == PromptStatus.OK)
{
//Do work
}
else
{
//what to do if 'ESC' is pressed during GetPoint()
}
}