예제 #1
0
파일: FormMain.cs 프로젝트: minskowl/MY
        /// <summary>
        /// Adds the file.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        void IFileTabControl.AddFile(string filePath)
        {
            var dummyDoc = new FileWindow
            {
                Text = Path.GetFileName(filePath)
            };

            dummyDoc.Show(dockPanel);
            try
            {
                dummyDoc.FileName = filePath;
            }
            catch (Exception exception)
            {
                dummyDoc.Close();
                MessageBoxEx.Show(this, "Error open file " + filePath, exception.Message);
            }
        }
예제 #2
0
        private void User_ActiveEvent(int id, string name, int command)
        {
            if (command == ElementCommands.InfoModule)
            {
                Connection.SendMessage(new MessageClass(Connection.ID, id, Commands.GetInfo, 0));
            }

            if (command == ElementCommands.SendModule)
            {
                Random r   = new Random();
                int    gid = -1;
                bool   ok  = true;
                while (ok)
                {
                    ok  = false;
                    gid = r.Next(1, Int32.MaxValue / 2);
                    for (int i = 0; i < Setupers.Count; i++)
                    {
                        if (gid == Setupers[i].ID)
                        {
                            ok = true;
                        }
                    }
                }

                var setup = new SetupWindow(gid, id, name, Connection);
                Setupers.Add(setup);
                setup.Owner       = this;
                setup.CloseEvent += (SetupWindow window) =>
                {
                    Setupers.Remove(window);
                    GC.Collect();
                };
                setup.Show();
            }

            if (command == ElementCommands.VideoModule)
            {
                Random r   = new Random();
                int    gid = -1;
                bool   ok  = true;
                while (ok)
                {
                    ok  = false;
                    gid = r.Next(1, Int32.MaxValue / 2);
                    for (int i = 0; i < VideoWindows.Count; i++)
                    {
                        if (gid == VideoWindows[i].ID)
                        {
                            ok = true;
                        }
                    }
                }

                var video = new VideoWindow(gid, id, name, Connection);
                VideoWindows.Add(video);
                video.CloseEvent += (VideoWindow window) =>
                {
                    VideoWindows.Remove(window);
                    GC.Collect();
                };
                video.Show();
            }

            if (command == ElementCommands.FileModule)
            {
                Random r   = new Random();
                int    gid = -1;
                bool   ok  = true;
                while (ok)
                {
                    ok  = false;
                    gid = r.Next(1, Int32.MaxValue / 2);
                    for (int i = 0; i < VideoWindows.Count; i++)
                    {
                        if (gid == VideoWindows[i].ID)
                        {
                            ok = true;
                        }
                    }
                }

                var fileWindow = new FileWindow(gid, id, name, Connection);
                FileWindows.Add(fileWindow);
                fileWindow.CloseEvent += (FileWindow window) =>
                {
                    FileWindows.Remove(window);
                    GC.Collect();
                };
                fileWindow.Show();
            }
        }