Exemplo n.º 1
0
        public Server()
        {
            InitializeComponent();

            Thread t = new Thread(InitSocket);

            t.IsBackground = true;
            t.Start();

            //메뉴정보 폴더체크
            DirectoryInfo mmf = new DirectoryInfo(Application.StartupPath + @"\MainMenu");

            if (!mmf.Exists)
            {
                mmf.Create();
            }
            DirectoryInfo smf = new DirectoryInfo(Application.StartupPath + @"\SideMenu");

            if (!smf.Exists)
            {
                smf.Create();
            }
            DirectoryInfo bf = new DirectoryInfo(Application.StartupPath + @"\BeverageMenu");

            if (!bf.Exists)
            {
                bf.Create();
            }

            //각 메뉴별 객체 생성
            mainInfo     = new MenuInfo(mainMenu, mainImg);
            sideInfo     = new MenuInfo(sideMenu, sideImg);
            beverageInfo = new MenuInfo(beverageMenu, beverageImg);

            //메뉴파일이 있다면 불러온다
            MenuManage.MenuLoad(mainInfo, Application.StartupPath + "\\MainMenu\\MainMenu.txt");
            MenuManage.MenuLoad(sideInfo, Application.StartupPath + "\\SideMenu\\SideMenu.txt");
            MenuManage.MenuLoad(beverageInfo, Application.StartupPath + "\\BeverageMenu\\BeverageMenu.txt");

            //사진파일을 불러온다
            replaceImg(mainInfo, Application.StartupPath + "\\MainMenu\\");
            replaceImg(sideInfo, Application.StartupPath + "\\SideMenu\\");
            replaceImg(beverageInfo, Application.StartupPath + "\\BeverageMenu\\");
        }
Exemplo n.º 2
0
        //메뉴파일을 불러오는 함수
        public static void MenuLoad(MenuInfo currentmenu, string currentpath)
        {
            ListView listView;

            listView = currentmenu.menu;
            Dictionary <string, string> Msg = new Dictionary <string, string>();                                 // 문자열 키를 인덱스로 사용하는 테이블을 생성하기 위해 선언

            String MessageListFile = currentpath;                                                                // 메세지가 들어 있는 파일을 지정

            if (File.Exists(MessageListFile))                                                                    // 파일 존재 유무, 있으면 처리한다.
            {
                FileStream   MessageFile   = File.Open(MessageListFile, FileMode.OpenOrCreate, FileAccess.Read); // 파일을 열되 없다면 생성하고 권한은 읽기 전용으로 생성
                StreamReader MessageStream = new StreamReader(MessageFile, Encoding.Default);                    // 스트림 생성

                MessageStream.BaseStream.Seek(0, SeekOrigin.Begin);                                              // 파일을 읽어가기 시작한다.

                while (MessageStream.Peek() > -1)
                {
                    String ReadLine   = MessageStream.ReadLine(); // String형 변수에 파일 내의 한 줄을 읽어온다.
                    int    SplitIndex = ReadLine.IndexOf("\t");   // Tab을 구분자로 두고 구분자를 기준으로 잘라내기 위해 인덱스를 얻는다.
                    if (SplitIndex == 0 || SplitIndex == -1 || ReadLine.StartsWith(";"))
                    {
                        continue;
                    }                                                                                      // 맨 첫문자가 구분자이거나 또는 없거나, ; 로 시작하는 경우 스킵
                    Msg[ReadLine.Substring(0, SplitIndex).ToLower()] = ReadLine.Substring(SplitIndex + 1); // 테이블에 구분자 전의 값을 키, 후를 값으로 리스트를 생성한다.
                }

                MessageStream.Close();

                int i = 0;

                foreach (KeyValuePair <string, string> Message in Msg)
                {
                    listView.Items.Add(Message.Key);
                    listView.Items[i].Tag = Message.Value;
                    i++;
                }
            }
            else // 파일이 없으면 찾을 수 없다는 메세지 출력
            {
            }
        }
Exemplo n.º 3
0
        //사진파일 삭제시 파일이름 재정렬 함수
        private void deleteImg(MenuInfo currentMenu, string currentpath)
        {
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();
            string oldName;
            string fileExt;
            string oldFile;
            string nextName;
            string nextFile;

            currentMenu.menuimg.Images.Clear();
            int index = currentMenu.menu.Items.Count;

            for (int i = 0; i < index; i++)
            {
                oldName = i.ToString();

                DirectoryInfo dir   = new DirectoryInfo(currentpath);
                FileInfo[]    files = dir.GetFiles(i + ".*");

                if (files.Length > 0) //파일이 있으면
                {
                    fileExt  = files[0].Extension;
                    oldName += fileExt;
                    oldFile  = Path.Combine(currentpath, oldName);
                    currentMenu.menuimg.Images.Add(Image.FromFile(oldFile));
                }

                else //파일이 없으면
                {
                    nextName = (i + 1).ToString();

                    files = dir.GetFiles((i + 1) + ".*");
                    if (files.Length > 0)
                    {
                        fileExt   = files[0].Extension;
                        nextName += fileExt;
                        oldName  += fileExt;
                    }
                    else
                    {
                        break;
                    }

                    nextFile = Path.Combine(currentpath, nextName);
                    oldFile  = Path.Combine(currentpath, oldName);

                    if (File.Exists(oldFile))  // 파일의 존재 유무 확인 : 파일이 존재하면
                    {
                        break;
                    }
                    else   // 파일의 존재하지 않으면
                    {
                        if (File.Exists(nextFile))
                        {
                            File.Copy(nextFile, oldFile);
                            File.Delete(nextFile);
                            currentMenu.menuimg.Images.Add(Image.FromFile(oldFile));
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }