11-15-2012, 11:34 PM
(Сообщение последний раз редактировалось: 11-16-2012, 12:15 AM praetorianec.)
Все же от код шарпа:
От код С++
std:
tring
error: namespace "std" не содержит члена "string"
Код:
using System;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
namespace Teragame.logger
{
public class Log
{
static bool cf = false;
public static void warning(string text)
{
(Application.OpenForms[0] as MainInterface).LogBox.Invoke((MethodInvoker)(delegate()
{
if ((Application.OpenForms[0] as MainInterface).LogBox.Text.Length > 0)
{
(Application.OpenForms[0] as MainInterface).LogBox.AppendText(Environment.NewLine);
}
(Application.OpenForms[0] as MainInterface).LogBox.AppendText(text);
(Application.OpenForms[0] as MainInterface).LogBox.Select((Application.OpenForms[0] as MainInterface).LogBox.Text.Length - text.Length, text.Length);
(Application.OpenForms[0] as MainInterface).LogBox.SelectionColor = Color.Yellow;
}));
if (cf) tw.WriteLine(text);
}
public static void error(string text)
{
(Application.OpenForms[0] as MainInterface).LogBox.Invoke((MethodInvoker)(delegate() {
if ((Application.OpenForms[0] as MainInterface).LogBox.Text.Length > 0)
{
(Application.OpenForms[0] as MainInterface).LogBox.AppendText(Environment.NewLine);
}
(Application.OpenForms[0] as MainInterface).LogBox.AppendText(text);
(Application.OpenForms[0] as MainInterface).LogBox.Select((Application.OpenForms[0] as MainInterface).LogBox.Text.Length - text.Length, text.Length);
(Application.OpenForms[0] as MainInterface).LogBox.SelectionColor = Color.Red;
}));
if (cf) tw.WriteLine(text);
}
public static void info(string text)
{
(Application.OpenForms[0] as MainInterface).LogBox.Invoke((MethodInvoker)(delegate()
{
if ((Application.OpenForms[0] as MainInterface).LogBox.Text.Length > 0)
{
(Application.OpenForms[0] as MainInterface).LogBox.AppendText(Environment.NewLine);
}
(Application.OpenForms[0] as MainInterface).LogBox.AppendText(text);
}));
if (cf) tw.WriteLine(text);
}
public static void extra_info(string text)
{
(Application.OpenForms[0] as MainInterface).LogBox.Invoke((MethodInvoker)(delegate()
{
if ((Application.OpenForms[0] as MainInterface).LogBox.Text.Length > 0)
{
(Application.OpenForms[0] as MainInterface).LogBox.AppendText(Environment.NewLine);
}
(Application.OpenForms[0] as MainInterface).LogBox.AppendText(text);
(Application.OpenForms[0] as MainInterface).LogBox.Select((Application.OpenForms[0] as MainInterface).LogBox.Text.Length - text.Length, text.Length);
(Application.OpenForms[0] as MainInterface).LogBox.SelectionColor = Color.Lime;
}));
if (cf) tw.WriteLine(text);
}
static string name;
static TextWriter tw;
public static void form()
{
if (!cf)
return;
name = @"log\" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".log";
tw = File.CreateText(name);
extra_info("Log file created " + name);
}
}
}
От код С++
Код:
#pragma once
using namespace System;
using namespace System::IO;
using namespace System::Windows::Forms;
using namespace System::Drawing;
namespace Teragame
{
namespace logger
{
class Log
{
private:
static bool cf;
public:
static void warning (std::string text)
{
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Invoke((MethodInvoker)(delegate()
{
if ((dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Text.Length > 0)
{
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->AppendText("\r\n");
}
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->AppendText(text);
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Select((dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Text.Length - text.length(), text.length());
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->SelectionColor = Color::Yellow;
}
));
if (cf)
tw->WriteLine(text);
}
static void error(std::string text)
{
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Invoke((MethodInvoker)(delegate()
{
if ((dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Text.Length > 0)
{
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->AppendText("\r\n");
}
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->AppendText(text);
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Select((dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Text.Length - text.length(), text.length());
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->SelectionColor = Color::Red;
}
));
if (cf)
tw->WriteLine(text);
}
static void info(std::string text)
{
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Invoke((MethodInvoker)(delegate()
{
if ((dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Text.Length > 0)
{
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->AppendText("\r\n");
}
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->AppendText(text);
}
));
if (cf)
tw->WriteLine(text);
}
static void extra_info(std::string text)
{
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Invoke((MethodInvoker)(delegate()
{
if ((dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Text.Length > 0)
{
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->AppendText("\r\n");
}
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->AppendText(text);
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Select((dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->Text.Length - text.length(), text.length());
(dynamic_cast<MainInterface*>(Application::OpenForms[0]))->LogBox->SelectionColor = Color::Lime;
}
));
if (cf)
tw->WriteLine(text);
}
private:
static std::string name;
static TextWriter *tw;
public:
static void form()
{
if (!cf)
return;
name = "log\\" + DateTime::Now.ToString("yyyy-MM-dd HH-mm-ss") + ".log";
tw = File::CreateText(name);
extra_info("Log file created " + name);
}
};
}
}
std:

error: namespace "std" не содержит члена "string"