public class EntityA
{
    public EntityA()
    {
        EntityB.OnCallbackAction1 += OnCallbackListener1;
    }

    private void OnCallbackListener1(float data)
    {
        Debug.Log("OnCallbackListener1" + data.ToString());
    }
}

public class EntityB
{
    public static Action<float> OnCallbackAction1 = null;

    private void ActionHappned()
    {
        float data = 0.0f;
        OnCallbackAction1?.Invoke(data);
    }
}

'Programming > C#' 카테고리의 다른 글

현재시간(C#)  (0) 2023.09.05
Winform - // form 위에 form 설정  (0) 2022.07.13
기초 C#  (0) 2022.07.13
WPF에서 실행파일이 있는 경로  (0) 2022.07.13
WPF 중복 실행 방지  (0) 2021.12.02

// 현재시간
string sNow;
sNow = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff");

'Programming > C#' 카테고리의 다른 글

Action 사용하기  (0) 2023.09.27
Winform - // form 위에 form 설정  (0) 2022.07.13
기초 C#  (0) 2022.07.13
WPF에서 실행파일이 있는 경로  (0) 2022.07.13
WPF 중복 실행 방지  (0) 2021.12.02

namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        Form2 child1 = new Form2();
        Form3 child2 = new Form3();

        private void Form1_Load(object sender, EventArgs e)
        {
            child1.TopLevel = false;
            child2.TopLevel = false;

            this.Controls.Add(child1);
            this.Controls.Add(child2);

            child1.Parent = this.panel1;
            child2.Parent = this.panel1;

            child1.Text = child2.Text = "";
            child1.ControlBox = child2.ControlBox = false;

 

            child1.FormEvent += EventMethod;
            child2.FormEvent += EventMethod;
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            child2.Hide();
            child1.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            child1.Hide();
            child2.Show();
        }

        public void EventMethod(string str)
        {
            textBox1.Text = str.ToString();
        }
    }
}
////////////////////////////////////////////

public partial class Form2 : Form
{
        public delegate void SendDataHandler1(string message);
        public event SendDataHandler1 FormEvent;

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == string.Empty)
            {
                MessageBox.Show("text input !!");
                return;
            }
            this.FormEvent(textBox1.Text);
        }
}

'Programming > C#' 카테고리의 다른 글

Action 사용하기  (0) 2023.09.27
현재시간(C#)  (0) 2023.09.05
기초 C#  (0) 2022.07.13
WPF에서 실행파일이 있는 경로  (0) 2022.07.13
WPF 중복 실행 방지  (0) 2021.12.02

// convert
string str = "3";
int number = Convert.ToInt32(str);
int number1 = Int32.Parse(str);
int number2= int.Parse(str);

 

// array
string[,] array2D = new string[3, 5];

string[,,] Cubes;

int[][] a = new int[3][];
a[0] = new int[10];
a[1] = new int[5];
a[2] = new int[20];

 

 

// writeln

Console.WriteLine(@"c:\temp");
Console.WriteLine($"Sum of {t2.Count} elements is {t2.Sum}.");

 

 

'Programming > C#' 카테고리의 다른 글

Action 사용하기  (0) 2023.09.27
현재시간(C#)  (0) 2023.09.05
Winform - // form 위에 form 설정  (0) 2022.07.13
WPF에서 실행파일이 있는 경로  (0) 2022.07.13
WPF 중복 실행 방지  (0) 2021.12.02

WPF에서는  

AppDomain.CurrentDomain.BaseDirectory;

또는

string appStartPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);

'Programming > C#' 카테고리의 다른 글

Action 사용하기  (0) 2023.09.27
현재시간(C#)  (0) 2023.09.05
Winform - // form 위에 form 설정  (0) 2022.07.13
기초 C#  (0) 2022.07.13
WPF 중복 실행 방지  (0) 2021.12.02

App.xaml.cs

using System.Threading;

namespace AppName
{
    public partial class App : Application
    {
        Mutex mutex;

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            string mutexName = "exe";
            bool createNew;

            mutex = new Mutex(true, mutexName, out createNew);

            if (!createNew)
            {
                Shutdown();
            }
        }

        public App()
        {
           this.InitializeComponent();
        }
    }
}

'Programming > C#' 카테고리의 다른 글

Action 사용하기  (0) 2023.09.27
현재시간(C#)  (0) 2023.09.05
Winform - // form 위에 form 설정  (0) 2022.07.13
기초 C#  (0) 2022.07.13
WPF에서 실행파일이 있는 경로  (0) 2022.07.13

+ Recent posts