Trying to play a sound file using c# open source managed operating system (cosmos) project in visual studio - cosmos

using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
using System.Threading;
using System.Media.SoundPlayer;
Since cosmos uses c#, I am trying to use System.Media.SoundPlayer to play a sound file, but visual studio shows a red squiggle under "Media", saying "The type or namespace doesn't exist in the namespace 'System'(are you missing an assembly reference)". How should I resolve this?

If I remember correctly, SoundPlayer is not a namespace, its the class name.
So you can just import the media namespace and use the SoundPlayer like below.
using System.Media;
and in code, use like this:
SoundPlayer player = new SoundPlayer (#"###.mp3");
player.Play();
Hope this helps.

Related

Windows Workflow Foundation - how to add namespace using in custom activity

Is there a way to add a namespace using in a custom activity by the designer instead of writing directly in the xaml?
Pascal

Using Cocostudio UI Editor with cocos2d-x (load json files)

I am working with cocos2d-x 3.1 and try to use the Cocostudio UI Editor.
This helppage http://upyun.cocimg.com/CocoStudio/helpdoc/v1.0.0.0/en/index.html uses a CCUIHelper to load the json file and create a widget. This method was removed in cocos2d-x 3.0. While searching for a solution I found a directory which is called "WidgetReader" located under "editor-support". Sadly I am unable to include it, because the vs 2013 project can't find it. (and I am unsure if that's the right place where I am searching)
Does anyone know how I can use the exportes json-files from ui editor?
Thanks!
You can try this :
#include "cocostudio/Cocostudio.h"
auto widget = cocostudio::GUIReader::getInstance()->widgetFromJsonFile("abc.json");
Anyway,the include path should add "(yourCocosRoot)/cocos/editor-support".
you can use the following code
Node* node = CSLoader::createNode("SampleUIAnimation.json");
this->addChild(node);

automation errors in Flex Builder 3 when importing a swc from Flash CS 5

I am facing a really weird issue while trying to use an "swc" file imported from Flash CS5, that I am trying to use in Flex Builder 3 (by converting symbol to "Flex Component"). The errors are coming in files which are not even remotely related to the "swc" file that i am importing.
Now, I know that the automation stuff has come as a part of FB4, but I don't really have an option to migrate to FB4.
I have tried to change the flex sdk settings in Flash CS5 (steps given below), but that has not helped.
Edit-->Preferences-->Actionscript-->"Actionscript 3.0 Settings"-->"Flex SDK Path" (pointing this to flex3.5 sdk instead of Flex4.0 sdk)
I feel that the issue is most probably a compatibility issue b/w Flex 3 and Flex 4, but have not been able to find a workaround for the same. Any help is greatly appreciated.
Thanks,
Kapil
Here is the trace:
Severity and Description Path Resource Location Creation Time Id
1044: Interface method createAutomationIDPartWithRequiredProperties in namespace mx.automation:IAutomationObject not implemented by class com.sparsha.view.ui:SchematicWindow.
1044: Interface method createAutomationIDPartWithRequiredProperties in namespace mx.automation:IAutomationObject not implemented by class
1044: Interface method get automationEnabled in namespace mx.automation:IAutomationObject not implemented by class com.sparsha.lib.controls:CloseableTabBar.
1044: Interface method get automationEnabled in namespace mx.automation:IAutomationObject not implemented by class
1044: Interface method get automationEnabled in namespace mx.automation:IAutomationObject not implemented by class com.sparsha.lib.layouts:DockedAppLayout.
OK, first, the error: this means that Flash probably generated a class for the symbol you are importing using a certain template, where the template doesn't fit the SDK you are using to compile the project. Specifically, the generated class did not implement the methods listed in the error message. I.e. your framework.swc has a definition of mx.automation:IAutomationObject that has method createAutomationIDPartWithRequiredProperties() (nice name btw), but Flash generated code that reads as
package com.sparsha.view.ui {
import mx.automation:IAutomationObject;
public class SchematicWindow implements IAutomationObject { . . . } }
Since you cannot do anything about Flash not generating the method you need, your only way is to monkeypatch the SDK. I.e. copy the mx/automation/IAutomationObject.as from the SDK sources to the classpath of your project. Remove the conflicting method declaration (this may or may not result in other errors). If it results in further errors, repeat the same procedure for every class that "misbehaves"...
However, monkeypatching will mean that you are no longer able to use framework RSLs, as they will come with the original version. So, I would try to avoid the problem altogether and look for another way of exporting symbols from Flash IDE, for example, by not making them a Flex component. Or, if you really insist on them being a Flex component, then bootstrap the FlexSprite, for example, and assign your Flash symbols the bootstrapped class as the "parent class".
I was also having this problem recently. I would get the errors when I included the flash generated swc in my flex projects lib folder.
I was able to work around the issue by upgrading my flex to the flex 4.5.1.21328A SDK.
Additional Details about my project that might help others:
My swc was generated from Flash Professional CS5.5 and my Flex Project was being used in Flash Builder 4.5.
My swc was published to Flash Player 9 with ActionScript 3.0.
My flex project was using the 3.5.0.12683 SDK.

using namespace

what is the difference between
using System;
and
using namespace System;
is it the same thing?
thanks
Yes, there's a difference. The first one doesn't compile. Maybe you meant this:
#using <System.dll>
using namespace System;
The #using directive allows you to reference an assembly without going through the Framework and References project setting.

How can I set the Root Namespace property correctly in a C++/CLI application?

I have a C++/CLI application in Visual Studio 2008 whose namespace follows the .NET guideline of CompanyName.TechnologyName[.Feature][.Design]. The problem is that there seems to be no way to set a multi-level namespace in the project's Root Namespace property. I have tried both CompanyName.TechnologyName and CompanyName::TechnologyName.
It seems that I cannot have a Form control inside a namespace that is not the root namespace as this causes the resources it uses to not be found, thus to me it seems impossible to follow their guideline and be consistent with my C# applications.
Is there a way to set this property to use multi-leveled namespaces or am I forced to use a root namespace that is simply one-level? Or is there a solution that I am overlooking?
Edit:
Functionality is added in Visual Studio 2010 to allow multi-level root namespaces. Use CompanyName.TechnologyName format NOT CompanyName::TechnologyName. While the latter works for /creating/ forms, if your forms require resources then when compiling, Visual Studio tries to save to CompanyName::TechnologyName.resources which will throw an error.
Not sure I see the resource problem. There is no notion of a "root namespace". You have the follow the C++ rules for namespace declarations, you'll have to nest them one at a time. For example:
namespace Contoso {
namespace Accounting {
namespace PayRoll {
namespace Employees {
// class declarations go here
}}}} // yeah, that sux
And in the .cpp file:
using namespace Contoso::Accounting::PayRoll::Employees;
There's no trouble adding resources when it is declared like this that I could find. But don't add a resource, then change the namespace name. The C++ IDE has no refactoring support whatsoever. Windows Forms development in C++/CLI isn't very popular, this would perhaps be one reason.