Why Cocos Creator engine file is not called on the browser? - cocos2d-js

Non-Latin characters are not truncated properly so I modified the fragmentText() function to truncate on white space. file is in:
"C:\CocosCreator\resources\engine\cocos2d\core\label\CCTextUtils.js"
fragmentText: function (stringToken, allWidth, maxWidth, measureText) {
return "function called";
}
The problem is that I see the changes in Cocos Creator editor and the text is truncated as I want, but I see no effect on the browser as the function is never called.
Why the function is not called when I build?
P.S: I use Cocos Creator 1.10 but also have 2.1.1 installed in C:\CocosCreator_2.1.1

I guess you forget to recompile the engine.
Check the step 1.3 on the website and try again.
1.3 Change and Build

Related

wxFileDialog filename textbox appears as clipped

I display an Open File dialog using the following code:
wxFileDialog fileDialog(
this,
wxEmptyString,
"E:\\Testfiles",
"SOME_TEST_FILE_WITH_LONG_NAME.txt",
"TXT files (*.txt)|*.txt",
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR);
if (fileDialog.ShowModal() == wxID_OK)
{
// do something with the file
}
Notice that I set the default filename to a long string (about 10 or more characters).
When the file dialog is displayed, the filename looks clipped.
But on inspection, it's not really clipped.
More like the starting point of the text is placed too much to the left.
When you place the cursor on the textbox, and scroll to the left, you get the complete filename.
Also, when you switch to a different window then return to the file dialog, it corrects itself and displays the complete filename.
This isn't really affecting the functionality of the file dialog.
This is more of an aesthetic issue.
But if there's a reason for this behavior or if there's a solution, I would like to know.
Thanks!
I'm using:
wxWidgets 3.1.0
Windows 10 Home 64-bit
UPDATE (2017/03/20):
I opened a ticket at wxTrac for this bug.
You can check it here:
http://trac.wxwidgets.org/ticket/17824.
This looks like a bug in wxWidgets, please try to reproduce it in the dialogs sample by making minimal changes to the wxFileDialog call which is already present there and open a ticket on wxTrac with the patch allowing to see the problem, so that someone could debug it.
As a temporary workaround (while an official resolution from wxWidgets is not yet available), calling CenterOnParent() after constructing the file dialog properly "scrolls" the filename so that it won't appear as "clipped".
wxFileDialog fileDialog(
this,
wxEmptyString,
"E:\\Testfiles",
"SOME_TEST_FILE_WITH_LONG_NAME.txt",
"TXT files (*.txt)|*.txt",
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR);
// fixes the clipped filename
fileDialog.CenterOnParent();
if (fileDialog.ShowModal() == wxID_OK)
{
// do something with the file
}

Printing from a Xamarin.Forms app

I'm all new to Xamarin and I'm currently working on a sample or a "prove of concept" app using Xamarin.Forms.
I'm supposed to perform a print task from this app though I'm not at this point sure what to print yet (the screen, content of a label, a file etc.).
Either way, what is the easiest way to print from a Xamarin.Forms app?
(current target is primarily Android 4.4+).
I hope this isn't too complicated :)
EDIT:
Ok let me just update this post as the original text might be a bit ambitious/vague.
I have a Xamarin.Forms project (+ an Android part) and I have some HTML available in the XF part of the project that I need to get into a WebView and print it.
From what I understand, the thing with the WebView has to be done on the Android part of the project due to the fact that this is where the printing will be handled.
I was hoping this could be done from code since I don't really need to display the WebView, just print it's content.
The Android part of the project has only the MainActivity and no layouts or XAML files.
I don't know where to add the WebView or how to access it (other than DependecyService seems to be a buzz word here) so I'm kinda stuck here.
I'm thinking that this task should be rather trivial to someone with a little more Xamarin experience than me.
Every platform XF supports has it's own mechanism for printing. XF does not provide any abstractions for printing in a cross-platform manner. You will need to write printing logic for each layer and expose it to XF using DependencyService (or some other DI engine).
Here is a good example, of course, using dependency service:
https://codemilltech.com/xamarin-forms-e-z-print/
I so wanted to do this but it was too hard. Finally built it into Forms9Patch - a MIT licensed open source project.
Verifying that Printing is available
Before printing, you should verify that printing is available on your device. To do so, call:
if (Forms9Patch.PrintService.CanPrint)
{
// do the printing here
}
Print the contents of a Xamarin.Forms.WebView
using Forms9Patch;
...
var myWebView = new Xamarin.Forms.WebView
myWebView.Source = new HtmlWebViewSource
{
Html = "some HTML text here"
};
...
myWebView.Print("my_print_job_name");
Note that your WebView does not have to be attached to a Layout. This allows you to Print without having to display the WebView in your app’s UI.
Printing an HTML string
using Forms9Patch;
...
var myHtmlString = #"
<!DOCTYPE html>
<html>
<body>
<h1>Convert to PNG</h1>
<p>This html will be converted to a PNG, PDF, or print.</p>
</body>
</html>
";
...
myHtmlString.Print("my_print_job_name");
PLEASE NOTE: iOS sometimes places the page breaks in weird places. I have a StackOverflow Bounty on why this happens and how to fix it.
Using EmbeddedResource as a source for a Xamarin.Forms.WebView
This is sort of an experimental feature I’ve built that I’ve found it useful. As such the documentation is sparse. It allow you to put HTML content in a folder in your app’s EmbeddedResources folder and then use it as a source for a WebView. A much nicer solution than using platform specific approach provided by Xamarin. It also supports putting all of the HTML content into a zip file. Please take a look at the source code to see how it works.
You can handle the printing of lists/ invoices .. with the xfinium pdf component from xamarin componentstore. With that you create your _pdffile and then call the following method which starts the adobereader from where you can select a printer (in my case google cloudprint)
public void printPdfToCloud(string _pdffile)
{
try
{
var saveto = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(), "YourApp/"+_pdffile);
string file_path = saveto;
if (System.IO.File.Exists(file_path))
{
Android.Net.Uri pdfFile = Android.Net.Uri.FromFile(new Java.IO.File(file_path));
Intent pdfIntent = new Intent(Intent.ActionView);
pdfIntent.SetPackage("com.adobe.reader");
pdfIntent.SetDataAndType(pdfFile, "application/pdf");
pdfIntent.SetFlags(ActivityFlags.NoHistory);
StartActivity(pdfIntent);
}else
{
// give a note that the file does not exist
}
}
catch (Exception E)
{
// Do some Error dialog
}
}

OpenCV 245 first building errors

I downloaded the sources of opencv-2.4.5 and I followed the tutorial (on the opencv site for windows) about the installing my own libraries everything. Ok. I created the opencv.sln file with cmake then I opened it with visual studio 2010 professional and I click the build solution but just 9 succeeded. Most of the 200 failed and most of the errors about tbbd.lib not found and opencv_core245d.lib not found with LNK1104 error. I'm trying to solve it for how many days. I've tried to show the ways of files... Anyone can help please? This is about my dissertation. (Build with No Common Language Support)
Collapse
I spent a good 15 hours or so to get the homework finished using OpenCV. 14.5 of those hours were spent just getting it setup properly. I ran through about 7 tutorial videos, several set up guides, and read hundreds of posts containing resolutions to the same erros I was getting.So I understand that simply installing OpenCV is not a trivial task and there are several steps to do this. So here is a straightforward tutorial for setting it up if you want to use openCV.
It is important to understand how things work as far as linking goes. There are three types of files, your headers that you include, the .dlls that contain the functions, and the libraries that contain instructions for how to call the functions in the .dlls. So here, rather than add just the .dlls as dependencies in the input linker, we are going to add the lib files. We will then create a System Environment variable that will tell the machine where to look for the .dll files when their corresponding library files are referenced. We will be creating a Property Sheet so that when we create a new project, we can simply add the settings to our project by clicking "Add Existing Property Sheet" instead of adding a new one. This way, we never have to go through this again.
FOLLOW THESE STEPS EXACTLY AND MAKE SURE VISUAL STUDIO IS CLOSED BEFORE CONTINUING
NOTE: When text is given in quotes with instructions to copy said text, do not include the quotes.
First of all, the easy part - download OpenCV 2.4.5 from their website. http://opencv.org/ and click OpenCV for Windows. It will download OpenCV 2.4.5.exe.
Install OpenCV
When the download finishes, double click OpenCV-2.4.5.exe to run it.
When asked where to extract the files, type ino the text box: "C:\"
C:\opencv should have been created upon completion. Navigate there to make sure.
Setup Environment Variables
WINDOWS 8 USERS:
- Right click the bottom left corner of your screen when the start icon pops up.
- Click "Command Prompt (Admin)"
- Type "SETX -m OPENCV_DIR C:\opencv\build" and press enter to set the opencv build directory as a System Environment Variable. Wait for the console to give you confirmation that it is set.
- Right click the bottom left corner of your screen when the "Start" icon pops up. Click System -> Advanced System Settings -> Environment Variables
- In the "System Variables" list box, under the "Variable" collumn, find "Path".
- Highlight the "Path" row and click edit.
- Click in the "Variable Value" text box and hit the "end" key on your keyboard to scroll to the end of the line and add a semicolon.
- Type the following: "C:\opencv\build\x86\vc10\bin;C:\opencv\build\x86\vc10" and click "OK". This will add the openCV bin directory to the system path.
WINDOWS 7 USERS:
Follow the same steps. The only difference is how you get to the command prompt and the system settings. Google how to set up an environment variable on Windows 7 if needed.
Setup Visial Studio
NOTE: I highly recommend VS2012 Professional because of advanced syntax highlighting that makes life so much easier when programming C++. This version can be downloaded and installed for free from DreamSpark. Just make and account with your student ID. However, the steps for VS2010 and VS2012 are the same.
Open Visual Studio
Click "New Project" and under "C++" select "Win32 Console Application".
When the window opens click "Next", check "Empty Project", and click "Finish". It is very important that you start with an EMPTY PROJECT without a precompiled header.
Locate the "Property Manager." By default, it should be a tab that is sometimes hard to miss. Alternatively it can be accessed by clicking from the toolbar "View" -> "Property Manager".
Right Click "Debug | Win32" and select "Add New Project Property Sheet". Name it "OpenCVProps" and click "Add".
Right Click your new property sheet and select "Properties".
From the left column, go to "C/C++" -> "General" and in the listbox on the right, select "Additional Include Directories" and click "Edit".
Add the following THREE directories:
"$(OPENCV_DIR)\include"
"$(OPENCV_DIR)\include\opencv"
"$(OPENCV_DIR)\include\opencv2"
From the left column, go to "Linker" -> "General" and in the listbox on the right, select "Additional Library Directories" and click "Edit".
Add the following directory:
"$(OPENCV_DIR)\x86\vc10\lib"
From the left column, go to "Linker" -> "Input" and in the listbox on the right, select "Additional Dependenies" and click "Edit".
Add the following .lib files to the depedencies. You may do this by copying and pasting these into that edit box. I have purposely not included a bulletpoint to make it easy for you to copy paste these.
opencv_core245d.lib
opencv_imgproc245d.lib
opencv_highgui245d.lib
opencv_ml245d.lib
opencv_video245d.lib
opencv_features2d245d.lib
opencv_calib3d245d.lib
opencv_objdetect245d.lib
opencv_contrib245d.lib
opencv_legacy245d.lib
opencv_flann245d.lib
NOTE: If building for release, these steps are the same. However, when copying and pasting these files, remove the 'd' from the end of each of them. The 'd' denotes that it is a release library and links to a release .dll.
Congrats! The difficult part is almost done! Click "OK" to close the Window.
Creating and Building a Test Project
Head over to our Solution Explorer. This can be focused from the toolbar via "View" -> "Solution Explorer"
Right click "Source Files" and select "Add" -> "New Item".
Select "C++ File (.cpp)" and name the file "main.cpp". Click "Add".
Copy and paste the following program and press "F7" on your keyboard and watch the bottom left corner of your screen to see if you get a "Build Succeeded" message. If so, only one step left before you compile and run! If not, please retrace your steps, or comment below and maybe I can help.
#include &ltopencv\cv.h&gt
#include &ltopencv\highgui.h&gt
int main(int argc, char* argv)
{ // openCV .image object
cv::Mat inputImage;
//Create a Window
cv::namedWindow("window",1);
// Initialize our image.
inputImage = cv::imread("Lenna.png");
// Always check to make sure that image has data.
if(inputImage.empty())
{
std::cout &lt&lt "Image Failed to Load.";
return -1;
}
else
{
// All is well, display me.
cv::imshow("window",inputImage);
// Wait for user to press a key to exit.
cvWaitKey(0);
}
return 0;
}
If the build succeeded, then all that is left is to add the image to your folder. The placement is very important. I have copied the directoy that I have placed mine in. Follow the same directory pattern.
"C:\Users\Josh\Documents\Visual Studio 2012\Projects\ConsoleApplication3\ConsoleApplication3\Lenna.png"
Now hit "Ctrl + F5" To build, compile, and run to observe your image in the window!!
*IF YOU HAVE A WEBCAM*
Copy and paste the following code to check if OpenCV is working without being required to add an image. This is useful because if the above code doesn't work, but this code does, then you know you put the image in the wrong folder.
#include
#include
int main(int argc, char* argv)
{ // openCV .image object
cv::Mat image;
//Create a Window
cv::namedWindow("window",1);
// Create the capture object.
cv::VideoCapture device;
// Open your webcam.
device.open(0);
while (1)
{
// Read data from your device and store it to the image frame.
device >> image;
// Always check to make sure that image has data.
if(image.empty())
{
std::cout&lt&lt "Image Failed to Load.";
return -1;
}
else
{
// All is well, display me.
cv::imshow("window",image);
// Wait for user to press a key to exit.
cvWaitKey(33);
}
}
return 0;
}
Happy Coding!! Let me know if something didn't work so I can fix it!
Quick Answer
I have managed to compile OpenCV with TBB support using the tutorial here.
Specs: Visual Studio 2012/ Win 7 (64 bit)/ OpenCV 2.4.5/ CUDA 5
I have downloaded the latest TBB zip and extracted it to C:/src/OpenCV/dep (as suggested in the tutorial linked above).
You have to use the following TBB settings in CMake (adapt depending on your file paths):
TBB_LIB_DIR :: C:/src/OpenCV/dep/tbb41_20130314oss/lib/intel64/vc11
TBB_INCLUDE_DIRS :: C:/src/OpenCV/dep/tbb41_20130314oss/include/
TBB_STDDEF_PATH :: C:/src/OpenCV/dep/tbb41_20130314oss/include/tbb/tbb_stddef.h
WITH_TBB :: checked
BUILD_TBB :: unchecked
More Information
Initially, I also wanted to install OpenCV with CUDA 5 support, but it seems that CUDA 5 is incompatible with VS2012. This is the error I got when compiling
OpenCV:
Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/Debug/cuda_compile_generated_matrix_operations.cu.obj
nvcc : fatal error : nvcc cannot find a supported cl version. Only MSVC 9.0 and MSVC 10.0 are supported
The good news is that you are using VS2010, which can be used with CUDA, as suggested here.
VS2012 can be set up to create projects with CUDA, but there is currently no way (AFAIK) to compile OpenCV with CUDA support for VS2012 (read this for more info).
In conclusion, people that need CUDA support should compile and use OpenCV with VS2010.
Also, when compiling OpenCV, I got the following errors:
error C3859: virtual memory range for PCH exceeded; please recompile with a command line option of '-Zm118' or greater
fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit
I used the instructions here to finally compile OpenCV. I created a Property Sheet which had /Zm130 as an additional option in Common Properties > C/C++ > Command Line and added it
to all of the generated OpenCV projects.
For your reference, I also attach the CMake configuration and CMakeCache.txt file that I've used (CUDA is disabled as I am using VS2012):
CMake configuration: http://pastebin.com/8rJZGZ3T
CMakeCache.txt: http://pastebin.com/A0q8YgJg
Hope this helps and please comment if you need me to elaborate on any step.
I installed again opencv-master, opencv-2.4.5 and opencv-2.4.7 both to my new laptop. OpenCV-2.4.7's imread function returned always null but C-cvImageLoad worked well and opencv-master's cvLoadImage didn't work cvImageLoad or I missed something. But TBB's dir must be .../bin/ia32 not intel64 my OS is 64-bit but VS201x 32-bit this was my error. And I've get stitching and gpu errors and visual studio is telling about the error and this is usually memory allocation limit error and I did same things like your said #dilgenter and now it's working well but just 2.4.5 well and the python_d.lib error can be occur this is not a problem at debug mode I've read about this from a lot of forum sites. I'll try to find why 2.4.7's imread returning null Mat element. But now I'm too busy and this is

Visual Studio macro to navigate to T4MVC link

I use T4MVC and I'm happy with it and want to keep it - it keeps down run time defects. Unfortunately, it makes it harder to navigate to views and content (a.k.a. Views and Links in T4MVC) though. Even using Resharper, I can't navigate to the referenced item:
T4MVC and Resharper Navigation
Can I get a hand building a macro to do this? Never having built a VS IDE macro before, I don't have a grasp on how to get at some things, like the internal results of the "Go To Definition" process, if that's even possible.
If you aren't familiar with T4MVC, here's generally what the macro might do to help:
Given the token: Links.Content.Scripts.jQuery_js in the file MyView.cshtml, '(F12) Go To Definition'. This behaves properly.
Having arrived at the the related assignment:
public readonly string jQuery_js = "~/Content/Scripts/jQuery.js"; in a file generated by T4MVC (which is very nice, thank you David, but we really don't ever need to see), capture the string assigned and close the file.
Navigate in Solution Explorer to the PhysicalPath represented by the captured string.
This process would also work for views/layouts/master-pages/partials, etc.
If you provide a macro or link to a macro to do this, or have another solution, wonderful. Otherwise, hints on how to do step 3 simply in a VS macro would be especially appreciated and receive upvote from me. I'd post the macro back here as an answer when done.
Thanks!
Here's a Visual Studio macro to help.
What it does
Now you probably use T4MVC references in places like this:
Layout = MVC.Shared.Views.MasterSiteTheme;
ScriptManager.AddResource(Links.Content.Script.jQueryXYZ_js);
<link type="text/css" href="#Links.Content.Style.SiteTheme_css" />
return View(MVC.Account.Views.SignIn);
#Html.Partial(MVC.Common.Views.ContextNavigationTree)
#Html.ActionLink("Sign in / Register", MVC.Account.SignIn())
F12 (Go to Definition) already works for the last bullet (actions), but this hack is intended to cover the other scenarios (resources).
Macro
Imports EnvDTE
Imports System.IO
Public Module NavT4Link
Sub NavigateToLink()
DTE.ExecuteCommand("Edit.GoToDefinition")
Dim navpath As String = Path.GetFileName(DTE.ActiveDocument.FullName)
Dim isContentLink As Boolean = navpath.Equals("T4MVC.cs")
If (isContentLink Or navpath.EndsWith("Controller.generated.cs")) Then
Dim t4doc As TextDocument = DTE.ActiveDocument.Object()
navpath = CurrentLinePathConstant(t4doc)
If isContentLink Then
t4doc.Selection.MoveToPoint(t4doc.Selection.ActivePoint.CodeElement(vsCMElement.vsCMElementClass).StartPoint)
t4doc.Selection.FindText("URLPATH")
navpath = Path.Combine(CurrentLinePathConstant(t4doc), navpath)
End If
If navpath.StartsWith("~") Then
DTE.ActiveDocument.Close(vsSaveChanges.vsSaveChangesPrompt)
Dim proj As Object = DTE.Solution.FindProjectItem(DTE.ActiveDocument.FullName).ContainingProject
navpath = Path.GetDirectoryName(proj.Fullname()) + navpath.TrimStart("~")
DTE.ItemOperations.OpenFile(navpath)
End If
End If
End Sub
Function CurrentLinePathConstant(ByVal t4doc As TextDocument) As String
t4doc.Selection.SelectLine()
Dim sa() As String = t4doc.Selection.Text().Split("""")
If sa.Length > 1 Then Return sa(sa.Length - 2) Else Return ""
End Function
End Module
Installation
In Visual Studio, press "Alt-F8" to open Macro Explorer.
Right-Click "My Macros", select "New Module...", and click "Add".
Replace all the text with the code shown here.
Save and exit the Macro Editor.
Open "Tools : Options".
In the left pane, select "Environment : Keyboard".
In the "Show commands containing" text field enter "T4".
In the "Press shortcut keys:" field press the "F12" key.
Click "Assign" and "OK".
On un-patched VS, this installation process doesn't result in a 'bindable' macro. A workaround was to (CTRL-SHIFT-R-R) to record an empty macro, and paste the code into it without renaming it. If someone knows of a more documentable approach to install a macro in VS, please comment.
Notes/Caveats
It's meant to replace the current F12 functionality, so if it isn't a T4MVC link, it will do the usual, otherwise it continues on to open the resource. It handles the majority of cases, but not T4MVC-generated empty controller methods. Those you get dumped off at the same place you did before.
For Content/Asset/Link resources, navigating to it in Solution Explorer would probably be in order, for image files for example, but I didn't see that functionality in the Visual Studio docs.

ABCPDF Font Printing Layout - Machine Dependent

I am using ABCPDF to print a PDF file to a local printer via EMF file. I've based this very closely on ABC PDF's sample "ABCPDFView" project. My application worked fine on my Windows 7 and Windows XP dev boxes, but when I moved to a Windows 2003 test box, simple embedded fonts (like Times New Roman 12) rendered completely wrong (wrong spot, and short and squat, almost like the DPI's were crazily wrong).
Note that I've hardcoded the DPI to 240 here b/c I'm using a weird mainframe print driver that forces 240x240. I can discount that driver as the culprit as, if I save the EMF file locally during print, it shows the same layout problems. If I render to PNG or TIFF files, this looks just fine on all my servers using this same code (put .png in place of .emf). Finally, if I use the ABCPDFView project to manually add in a random text box to my PDF, that text also renders wrong in the EMF file. (Side note, if I print the PDF using Acrobat, the text renders just fine)
Update: I left out a useful point for anyone else having this problem. I can work around the problem by setting RenderTextAsText to "0" (see code below). This forces ABCPDF to render the text as polygons and makes the problem go away. This isn't a great solution though, as it greatly increases the size of my EMF files, and those polygons don't render nearly as cleanly in my final print document.
Anyone have any thoughts on the causes of this weird font problem?
private void DoPrintPage(object sender, PrintPageEventArgs e)
{
using (Graphics g = e.Graphics)
{
//... omitted code to determine the rect, used straight from ABC PDF sample
mDoc.Rendering.DotsPerInch = 240 ;
mDoc.Rendering.ColorSpace = "RGB";
mDoc.Rendering.BitsPerChannel = 8;
mDoc.SetInfo(0, "RenderTextAsText", "0");//the magic is right here
byte[] theData = mDoc.Rendering.GetData(".emf");
using (MemoryStream theStream = new MemoryStream(theData))
{
using (Metafile theEMF = new Metafile(theStream))
{
g.DrawImage(theEMF, theRect);
}
}
//... omitted code to move to the next page
}
Try upgrading to the new version of abcpdf 8, it has its own rendering engine based on Gecko and so you can bypass issues like this when abcpdf is using the inbuilt server version of IE for rendering.
I was originally RDPing in with 1920x1080 resolution, by switching to 1024x768 res for RDP, the problem went away. My main program runs as a service, and starting this service from an RDP session w/ 1024x768 fixes it.
I have an email out w/ ABC PDF to see if they can explain this and offer a more elegant solution, but for now this works.
Please note that this is ABC PDF 7, I have no idea if this issue applies to other versions.
Update: ABC PDF support confirmed that its possible the service is caching the display resolution from the person that started the process. They confirmed that they've seen some other weird issues with Remote Desktop and encouraged me to use this 1024x768 workaround and/or start the service remotely.

Resources