Beispiel #1
0
        /// 생성자
        public ShpMngViewModel()
        {
            ItemsSelect = new ObservableCollection <FileDtl>();
            ItemsFile   = new ObservableCollection <FileInfo>();



            // 초기로딩처리
            LoadedCommand = new RelayCommand <object>(delegate(object obj) {
                if (obj == null)
                {
                    return;
                }
                //그리드뷰인스턴스
                shpMngView = obj as ShpMngView;


                // 초기조회
                InitModel();
            });


            //shp파일 임포트
            ImportCmd = new RelayCommand <object>(delegate(object obj) {
                //필수체크
                if (!BizUtil.ValidReq(shpMngView))
                {
                    return;
                }

                OpenFileDialog openFileDialog   = new OpenFileDialog();
                openFileDialog.Multiselect      = true;
                openFileDialog.Filter           = "Shape files |*.shp;*.shx;*.dbf;*.prj";
                openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                if (openFileDialog.ShowDialog() == true)
                {
                    FileInfo[] files = openFileDialog.FileNames.Select(f => new FileInfo(f)).ToArray(); //파일인포

                    int cnt = 0;                                                                        //전체파일수
                    int chk = 0;                                                                        //shp,dat파일수
                    foreach (FileInfo fi in files)
                    {
                        try
                        {
                            //파일객체
                            ItemsFile.Add(fi);
                            if (fi.Extension.Contains("shp") || fi.Extension.Contains("shx") || fi.Extension.Contains("dbf") || fi.Extension.Contains("prj"))
                            {
                                chk++;
                            }
                            cnt++;
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }
                    }

                    if (chk < 4)
                    {
                        MessageBox.Show("shp, shx, dbf, prj 파일 4개를 선택해야합니다.");
                        return;
                    }
                    if (cnt > 4)
                    {
                        MessageBox.Show("한번에 한종류의 shp파일만 업로드할수 있습니다.");
                        return;
                    }



                    //파일업로드시작
                    upload_thread = new Thread(new ThreadStart(UploadFileListFX));
                    upload_thread.Start();
                }
            });



            //기존파일 다운로드버튼 이벤트
            DownloadCmd = new RelayCommand <object>(delegate(object obj)
            {
                FileDtl dtl      = obj as FileDtl;
                string file_name = dtl.DWN_NAM;

                try
                {
                    source_file_path = BizUtil.GetDataFolder("shape", file_name);
                }
                catch (Exception)
                {
                    Messages.ShowErrMsgBox("다운로드할 수 없습니다.");
                    return;
                }


                //파일다운로드
                saveFileDialog       = new System.Windows.Forms.SaveFileDialog();
                saveFileDialog.Title = "저장경로를 지정하세요.";
                //초기 파일명 지정
                saveFileDialog.FileName        = file_name;
                saveFileDialog.OverwritePrompt = true;
                saveFileDialog.Filter          = "All files (*.*)|*.*";

                if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    target_file_path = saveFileDialog.FileName;
                    download_thread  = new Thread(new ThreadStart(DownloadFX));
                    download_thread.Start();
                }
            });
        }
Beispiel #2
0
        public MapArcObjViewModel()
        {
            loadedCmd = new RelayCommand <object>(delegate(object obj)
            {
                //뷰객체를 파라미터로 전달받기
                mapArcObjView = obj as UserControl;

                mapHost     = mapArcObjView.FindName("mapHost") as WindowsFormsHost;
                toolbarHost = mapArcObjView.FindName("toolbarHost") as WindowsFormsHost;
                treeLayer   = mapArcObjView.FindName("treeLayer") as TreeView;

                mapControl     = mapHost.Child as AxMapControl;
                toolbarControl = toolbarHost.Child as AxToolbarControl;


                //0.맵 초기화
                initMap();

                //1.레이어초기화
                CmmObj.initLayers();

                //2.UniqueRenderer 초기화
                CmmObj.InitUniqueValueRendererObj();

                //3.행정구역경계표시
                ShowShapeLayer("BML_GADM_AS", true);


                //맵마우스클릭 이벤트설정
                mapControl.OnMouseUp += OnMouseClick;
            });


            //레이어 ON/OFF
            chkCmd = new RelayCommand <object>(delegate(object obj)
            {
                Button doc = obj as Button;

                CheckBox chkbox = doc.Template.FindName("chkLayer", doc) as CheckBox;
                bool chk        = (bool)chkbox.IsChecked;


                //ShowShapeLayer( doc.Tag.ToString(), chk);
                ShowShapeLayer(doc.Tag.ToString(), chk);


                //선택된 레이어저장
                try
                {
                    if (chk)
                    {
                        _selectedLayerNms.Add(doc.Tag.ToString());
                        _selectedLayerNm = doc.Tag.ToString();
                    }
                    else
                    {
                        _selectedLayerNms.Remove(doc.Tag.ToString());
                        _selectedLayerNm = _selectedLayerNms.LastOrDefault();
                    }
                }
                catch (Exception) { }
            });


            //GIS초기화
            resetCmd = new RelayCommand <object>(async delegate(object obj) {
                string stat = await resetAction(obj);
            });

            //SHP파일관리창
            importCmd = new RelayCommand <object>(async delegate(object obj) {
                ShpMngView view = new ShpMngView();
                if (view.ShowDialog() is bool)
                {
                    //재조회
                    string stat = await resetAction(null);
                }
            });
        }