public void ChangingSortComparisonCausesResortingOfCollection()
        {
            var             originalCollection = new ObservableCollection <ItemMetadata>();
            ViewsCollection viewsCollection    = new ViewsCollection(originalCollection, (i) => true);

            var view1 = new MockSortableView1();
            var view2 = new MockSortableView2();
            var view3 = new MockSortableView3();

            originalCollection.Add(new ItemMetadata(view2));
            originalCollection.Add(new ItemMetadata(view3));
            originalCollection.Add(new ItemMetadata(view1));

            // ensure items are in original order
            Assert.AreSame(view2, viewsCollection.ElementAt(0));
            Assert.AreSame(view3, viewsCollection.ElementAt(1));
            Assert.AreSame(view1, viewsCollection.ElementAt(2));

            // change sort comparison
            viewsCollection.SortComparison = Region.DefaultSortComparison;

            // ensure items are properly sorted
            Assert.AreSame(view1, viewsCollection.ElementAt(0));
            Assert.AreSame(view2, viewsCollection.ElementAt(1));
            Assert.AreSame(view3, viewsCollection.ElementAt(2));
        }
        public void RaisesCollectionChangedWithAddAndRemoveWhenFilteredCollectionChanges()
        {
            var originalCollection                 = new ObservableCollection <ItemMetadata>();
            IViewsCollection viewsCollection       = new ViewsCollection(originalCollection, x => x.IsActive);
            bool             addedToCollection     = false;
            bool             removedFromCollection = false;

            viewsCollection.CollectionChanged += (s, e) =>
            {
                if (e.Action == NotifyCollectionChangedAction.Add)
                {
                    addedToCollection = true;
                }
                else if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    removedFromCollection = true;
                }
            };
            var filteredInObject = new ItemMetadata(new object())
            {
                IsActive = true
            };

            originalCollection.Add(filteredInObject);

            Assert.IsTrue(addedToCollection);
            Assert.IsFalse(removedFromCollection);

            originalCollection.Remove(filteredInObject);

            Assert.IsTrue(removedFromCollection);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 생성자
        /// </summary>
        public FlowMtListViewModel()
        {
            LoadedCommand = new DelegateCommand <object>(OnLoaded);
            SearchCommand = new DelegateCommand <object>(SearchAction);
            ResetCommand  = new DelegateCommand <object>(ResetAction);

            ExcelCmd = new DelegateCommand <object>(ExcelDownAction);

            // 시설물 지도상 위치찾아가기
            cellPosCmd = new DelegateCommand <object>(async delegate(object obj) {
                DataRowView row = obj as DataRowView;
                string FTR_IDN  = row["FTR_IDN"].ToString();
                string FTR_CDE  = row["FTR_CDE"].ToString();
                //MessageBox.Show("지도상 위치찾아가기..FTR_IDN - " + FTR_IDN + ", FTR_CDE - " + FTR_CDE);

                IRegionManager regionManager = FmsUtil.__regionManager;
                ViewsCollection views        = regionManager.Regions["ContentRegion"].ActiveViews as ViewsCollection;

                //MapMainViewMocel 인스턴스불러오기
                foreach (var v in views)
                {
                    //MapMainView mapMainView = v as MapMainView;
                    //MapMainViewModel vm = mapMainView.DataContext as MapMainViewModel;
                    //Find 메소드수행
                    //await vm.findFtrAsync(FTR_CDE, FTR_IDN);

                    MapArcObjView mapMainView = v as MapArcObjView;
                    MapArcObjViewModel vm     = mapMainView.DataContext as MapArcObjViewModel;
                    //Find 메소드수행
                    vm.findFtr(FTR_CDE, FTR_IDN);

                    break;
                }
            });


            // 조회데이터 초기화
            this.PagedCollection = new ObservableCollection <DataTable>();
            // 프로퍼티변경이벤트 처리핸들러 등록
            PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                switch (e.PropertyName)
                {
                case "PageIndex":
                    if (PageIndex < 0)     //초기이벤트는 걸른다
                    {
                        this.pageIndex = 0;
                    }
                    else
                    {
                        SearchAction(PageIndex);
                    }
                    break;

                default:
                    break;
                }
            };
        }
 public RibbonRegion(Ribbon groupBox)
 {
     _ribbon = groupBox;
     _ribbonItemsMetaData = new ObservableCollection <ItemMetadata>();
     _views         = new ViewsCollection(_ribbonItemsMetaData, x => true);
     _activeViews   = new ViewsCollection(_ribbonItemsMetaData, x => x.IsActive == true);
     SortComparison = Region.DefaultSortComparison;
     Behaviors      = new RegionBehaviorCollection(this);
 }
        public void AddingToOriginalCollectionFiresAddCollectionChangeEvent()
        {
            var originalCollection           = new ObservableCollection <ItemMetadata>();
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true);

            var eventTracker = new CollectionChangedTracker(viewsCollection);

            originalCollection.Add(new ItemMetadata(new object()));

            Assert.IsTrue(eventTracker.ActionsFired.Contains(NotifyCollectionChangedAction.Add));
        }
Ejemplo n.º 6
0
        public void RaisesCollectionChangedWhenFilteredCollectionChanges()
        {
            var originalCollection             = new ObservableCollection <IView>();
            IViewsCollection viewsCollection   = new ViewsCollection(originalCollection);
            bool             collectionChanged = false;

            viewsCollection.CollectionChanged += (s, e) => collectionChanged = true;

            originalCollection.Add(new MockView());

            Assert.IsTrue(collectionChanged);
        }
        public void CanWrapCollectionCollection()
        {
            var originalCollection           = new ObservableCollection <ItemMetadata>();
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, x => true);

            Assert.AreEqual(0, viewsCollection.Count());

            var item = new object();

            originalCollection.Add(new ItemMetadata(item));
            Assert.AreEqual(1, viewsCollection.Count());
            Assert.AreSame(item, viewsCollection.First());
        }
Ejemplo n.º 8
0
        public void CanWrapCollectionCollection()
        {
            var originalCollection           = new ObservableCollection <IView>();
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection);

            Assert.AreEqual(0, viewsCollection.Count());

            var item = new MockView();

            originalCollection.Add(item);
            Assert.AreEqual(1, viewsCollection.Count());
            Assert.AreSame(item, viewsCollection.First());
        }
        public void OnAddNotifyCollectionChangedThenIndexProvided()
        {
            var originalCollection           = new ObservableCollection <ItemMetadata>();
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true);

            var eventTracker = new CollectionChangedTracker(viewsCollection);

            originalCollection.Add(new ItemMetadata("a"));

            var addEvent = eventTracker.NotifyEvents.Single(e => e.Action == NotifyCollectionChangedAction.Add);

            Assert.AreEqual(0, addEvent.NewStartingIndex);
        }
Ejemplo n.º 10
0
        public void CanWrapCollectionCollection()
        {
            var originalCollection           = new ObservableCollection <ItemMetadata>();
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, x => true);

            Assert.Empty(viewsCollection);

            var item = new ContentView();

            originalCollection.Add(new ItemMetadata(item));
            Assert.Single(viewsCollection);
            Assert.Same(item, viewsCollection.First());
        }
Ejemplo n.º 11
0
        public void EnumeratesWrappedItems()
        {
            var originalCollection = new ObservableCollection <ItemMetadata>()
            {
                new ItemMetadata(new object()),
                new ItemMetadata(new object())
            };
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, x => true);

            Assert.AreEqual(2, viewsCollection.Count());

            Assert.AreSame(originalCollection[0].Item, viewsCollection.ElementAt(0));
            Assert.AreSame(originalCollection[1].Item, viewsCollection.ElementAt(1));
        }
Ejemplo n.º 12
0
        public void CollectionChangedPassesWrappedItemInArgumentsWhenRemoving()
        {
            var originalCollection           = new ObservableCollection <ItemMetadata>();
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, x => true);
            IList            newItemsPassed  = null;

            viewsCollection.CollectionChanged += (s, e) => { newItemsPassed = e.NewItems; };
            var filteredInObject = new ItemMetadata(new object());

            originalCollection.Add(filteredInObject);

            Assert.IsNotNull(newItemsPassed);
            Assert.AreEqual(1, newItemsPassed.Count);
            Assert.AreSame(filteredInObject.Item, newItemsPassed[0]);
        }
Ejemplo n.º 13
0
        public void RaisesCollectionChangedWhenFilteredCollectionChanges()
        {
            var originalCollection             = new ObservableCollection <ItemMetadata>();
            IViewsCollection viewsCollection   = new ViewsCollection(originalCollection, x => x.IsActive);
            bool             collectionChanged = false;

            viewsCollection.CollectionChanged += (s, e) => collectionChanged = true;

            originalCollection.Add(new ItemMetadata(new object())
            {
                IsActive = true
            });

            Assert.IsTrue(collectionChanged);
        }
Ejemplo n.º 14
0
        private World()
        {
            Settings       = new WorldSettings();
            EventPublisher = new Publisher();

            Map      = Map.CreateMap();
            _miniMap = Map.CreateMiniMap(Map);

            _players  = new Dictionary <string, Player>();
            _tribes   = new Dictionary <string, Tribe>();
            _villages = new WorldVillagesCollection();

            Cache = new AutoCompleteCache();
            Views = new ViewsCollection();

            You = new Player();
        }
Ejemplo n.º 15
0
        private World()
        {
            Settings = new WorldSettings();
            EventPublisher = new Publisher();

            Map = Map.CreateMap();
            _miniMap = Map.CreateMiniMap(Map);

            _players = new Dictionary<string, Player>();
            _tribes = new Dictionary<string, Tribe>();
            _villages = new WorldVillagesCollection();

            Cache = new AutoCompleteCache();
            Views = new ViewsCollection();

            You = new Player();
        }
Ejemplo n.º 16
0
        public void AddingToOriginalCollectionFiresResetNotificationIfSortComparisonSet()
        {
            // Reset is fired to support the need to resort after updating the collection
            var originalCollection = new ObservableCollection <ItemMetadata>();
            var viewsCollection    = new ViewsCollection(originalCollection, (i) => true);

            viewsCollection.SortComparison = (a, b) => { return(0); };

            var eventTracker = new CollectionChangedTracker(viewsCollection);

            originalCollection.Add(new ItemMetadata(new object()));

            Assert.IsTrue(eventTracker.ActionsFired.Contains(NotifyCollectionChangedAction.Add));
            Assert.AreEqual(
                1,
                eventTracker.ActionsFired.Count(a => a == NotifyCollectionChangedAction.Reset));
        }
Ejemplo n.º 17
0
        public void CollectionChangedPassesWrappedItemInArgumentsWhenAdding()
        {
            var originalCollection = new ObservableCollection <ItemMetadata>();
            var filteredInObject   = new ItemMetadata(new ContentView());

            originalCollection.Add(filteredInObject);

            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, x => true);
            IList            oldItemsPassed  = null;

            viewsCollection.CollectionChanged += (s, e) => { oldItemsPassed = e.OldItems; };
            originalCollection.Remove(filteredInObject);

            Assert.NotNull(oldItemsPassed);
            Assert.Equal(1, oldItemsPassed.Count);
            Assert.Same(filteredInObject.Item, oldItemsPassed[0]);
        }
Ejemplo n.º 18
0
        public void DoesNotRaiseCollectionChangedWhenAddingOrRemovingFilteredOutObject()
        {
            var originalCollection             = new ObservableCollection <ItemMetadata>();
            IViewsCollection viewsCollection   = new ViewsCollection(originalCollection, x => x.IsActive);
            bool             collectionChanged = false;

            viewsCollection.CollectionChanged += (s, e) => collectionChanged = true;
            var filteredOutObject = new ItemMetadata(new object())
            {
                IsActive = false
            };

            originalCollection.Add(filteredOutObject);
            originalCollection.Remove(filteredOutObject);

            Assert.IsFalse(collectionChanged);
        }
Ejemplo n.º 19
0
        public void OnRemoveNotifyCollectionChangedThenIndexProvided()
        {
            var originalCollection = new ObservableCollection <ItemMetadata>();

            originalCollection.Add(new ItemMetadata("a"));
            originalCollection.Add(new ItemMetadata("b"));
            originalCollection.Add(new ItemMetadata("c"));
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true);

            var eventTracker = new CollectionChangedTracker(viewsCollection);

            originalCollection.RemoveAt(1);

            var removeEvent = eventTracker.NotifyEvents.Single(e => e.Action == NotifyCollectionChangedAction.Remove);

            Assert.NotNull(removeEvent);
            Assert.Equal(1, removeEvent.OldStartingIndex);
        }
Ejemplo n.º 20
0
        public void OnRemoveOfFilterMatchingItemThenViewCollectionRelativeIndexProvided()
        {
            var originalCollection = new ObservableCollection <ItemMetadata>();

            originalCollection.Add(new ItemMetadata("a"));
            originalCollection.Add(new ItemMetadata("b"));
            originalCollection.Add(new ItemMetadata("c"));
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => !"b".Equals(i.Item));

            var eventTracker = new CollectionChangedTracker(viewsCollection);

            originalCollection.RemoveAt(2);

            var removeEvent = eventTracker.NotifyEvents.Single(e => e.Action == NotifyCollectionChangedAction.Remove);

            Assert.IsNotNull(removeEvent);
            Assert.AreEqual(1, removeEvent.OldStartingIndex);
        }
Ejemplo n.º 21
0
        public void CanFilterCollection()
        {
            var originalCollection           = new ObservableCollection <ItemMetadata>();
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, x => x.Name == "Possible");

            originalCollection.Add(new ItemMetadata(new ContentView()));

            Assert.Empty(viewsCollection);

            var item = new ContentView();

            originalCollection.Add(new ItemMetadata(item)
            {
                Name = "Possible"
            });
            Assert.Single(viewsCollection);

            Assert.Same(item, viewsCollection.First());
        }
Ejemplo n.º 22
0
        public void ViewsCollectionSortedAfterAddingItemToOriginalCollection()
        {
            var             originalCollection = new ObservableCollection <ItemMetadata>();
            ViewsCollection viewsCollection    = new ViewsCollection(originalCollection, (i) => true);

            viewsCollection.SortComparison = Region.DefaultSortComparison;

            var view1 = new MockSortableView1();
            var view2 = new MockSortableView2();
            var view3 = new MockSortableView3();

            originalCollection.Add(new ItemMetadata(view2));
            originalCollection.Add(new ItemMetadata(view3));
            originalCollection.Add(new ItemMetadata(view1));

            Assert.AreSame(view1, viewsCollection.ElementAt(0));
            Assert.AreSame(view2, viewsCollection.ElementAt(1));
            Assert.AreSame(view3, viewsCollection.ElementAt(2));
        }
Ejemplo n.º 23
0
        public void CanFilterCollection()
        {
            var originalCollection           = new ObservableCollection <ItemMetadata>();
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, x => x.Name == "Possible");

            originalCollection.Add(new ItemMetadata(new object()));

            Assert.AreEqual(0, viewsCollection.Count());

            var item = new object();

            originalCollection.Add(new ItemMetadata(item)
            {
                Name = "Possible"
            });
            Assert.AreEqual(1, viewsCollection.Count());

            Assert.AreSame(item, viewsCollection.First());
        }
Ejemplo n.º 24
0
        public void ChangingMetadataOnItemAddsOrRemovesItFromTheFilteredCollection()
        {
            var originalCollection                 = new ObservableCollection <ItemMetadata>();
            IViewsCollection viewsCollection       = new ViewsCollection(originalCollection, x => x.IsActive);
            bool             addedToCollection     = false;
            bool             removedFromCollection = false;

            viewsCollection.CollectionChanged += (s, e) =>
            {
                if (e.Action == NotifyCollectionChangedAction.Add)
                {
                    addedToCollection = true;
                }
                else if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    removedFromCollection = true;
                }
            };

            originalCollection.Add(new ItemMetadata(new object())
            {
                IsActive = true
            });
            Assert.IsTrue(addedToCollection);
            Assert.IsFalse(removedFromCollection);
            addedToCollection = false;

            originalCollection[0].IsActive = false;

            Assert.AreEqual(0, viewsCollection.Count());
            Assert.IsTrue(removedFromCollection);
            Assert.IsFalse(addedToCollection);
            Assert.AreEqual(0, viewsCollection.Count());
            addedToCollection     = false;
            removedFromCollection = false;

            originalCollection[0].IsActive = true;

            Assert.AreEqual(1, viewsCollection.Count());
            Assert.IsTrue(addedToCollection);
            Assert.IsFalse(removedFromCollection);
        }
Ejemplo n.º 25
0
        public void RemovingFromFilteredCollectionDoesNotThrow()
        {
            var originalCollection = new ObservableCollection <ItemMetadata>();

            originalCollection.Add(new ItemMetadata("a"));
            originalCollection.Add(new ItemMetadata("b"));
            originalCollection.Add(new ItemMetadata("c"));
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true);

            CollectionViewSource cvs = new CollectionViewSource {
                Source = viewsCollection
            };

            var view = cvs.View;

            try
            {
                originalCollection.RemoveAt(1);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Ejemplo n.º 26
0
        public MapLayerViewModel()
        {
            loadedCmd = new RelayCommand <object>(delegate(object obj)
            {
                //뷰객체를 파라미터로 전달받기
                System.Windows.Controls.Grid divGrid = obj as System.Windows.Controls.Grid;

                this.mapView     = divGrid.FindName("mapView") as MapView;
                this.divLayer    = divGrid.FindName("divLayer") as Popup;
                this.ClearButton = divGrid.FindName("ClearButton") as Button;

                txtFTR_CDE = divGrid.FindName("txtFTR_CDE") as TextBox;
                txtFTR_IDN = divGrid.FindName("txtFTR_IDN") as TextBox;

                //지도초기화
                InitMap();


                //시설물레이어DIV 초기화작업
                InitDivLayer();

                InitUniqueValueRenderer();//렌더러초기생성작업


                //비트맵초기화(시설물상세DIV 아이콘)
                BitImg = new BitmapImage();
            });


            //레이어 ON/OFF
            chkCmd = new RelayCommand <object>(delegate(object obj)
            {
                Button doc = obj as Button;
                //IEnumerable<CheckBox> collection = doc.Children.OfType<CheckBox>();
                //CheckBox chkbox = collection.First();

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

                //ShowLocalServerLayer(mapView, doc.Tag.ToString(), chk);
                ShowShapeLayer(mapView, 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) { }
            });

            //팝업레이어 토글처리
            toggleCmd = new RelayCommand <object>(delegate(object obj)
            {
                StackPanel spLayer = divLayer.FindName("spLayer") as StackPanel;
                System.Windows.Controls.Grid gridTitle = divLayer.FindName("gridTitle") as System.Windows.Controls.Grid;

                spLayer.Visibility = spLayer.Visibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;

                if (spLayer.Visibility == Visibility.Collapsed)
                {
                    divLayer.Height = gridTitle.Height;
                }
                else
                {
                    divLayer.Height = gridTitle.Height + spLayer.Height;
                }
            });

            //팝업레이어 토글처리
            closeCmd = new RelayCommand <object>(delegate(object obj)
            {
                Popup divLayerInfo = obj as Popup;

                divLayerInfo.IsOpen = false;
            });


            // 레이어스타일 Renderer 초기화 - shape방식에서만 사용함
            //InitUniqueValueRenderer();

            //GIS초기화
            resetCmd = new RelayCommand <object>(delegate(object obj)
            {
                //0.맵초기화
                InitMap();

                //1.로컬서버 재기동
                //Initialize_LocalServer();

                //2.레이어 클리어
                mapView.Map.OperationalLayers.Clear();


                //3.열여있는 시설물정보창 닫기
                popFct.IsOpen = false;

                TreeView treeLayer = obj as TreeView;

                //레이어div 체크해제
                foreach (CheckBox cb in FmsUtil.FindVisualChildren <CheckBox>(treeLayer))
                {
                    cb.IsChecked = false;
                }
                //선택된레이어 해제
                _selectedLayerNms.Clear();
                _selectedLayerNm = "";
            });

            //시설물팝업에서 시설물메뉴화면 호출작업
            CallPageCmd = new RelayCommand <object>(delegate(object obj) {
                FctDtl fctDtl = obj as FctDtl;

                IRegionManager regionManager = FmsUtil.__regionManager;
                ViewsCollection views        = regionManager.Regions["ContentRegion"].ActiveViews as ViewsCollection;

                foreach (var v in views)
                {
                    MapLayerView mapMainView = v as MapLayerView;
                    //MainWinViewModel vm = ((System.Windows.Controls.Grid)((ContentControl)mapMainView.Parent).Parent).DataContext as MainWinViewModel;
                    break;
                }
            });

            //파일찾기버튼 이벤트
            ChgImgCmd = new RelayCommand <object>(delegate(object obj)
            {
                // 전달된 파라미터
                if (obj == null)
                {
                    Messages.ShowErrMsgBox("시설물코드가 존재하지 않습니다.");
                    return;
                }
                string _FTR_CDE = obj as string;

                // UniqueValueRenderer 자원해제
                //uniqueValueRenderer = new UniqueValueRenderer();
                //layers[_selectedLayerNm].ResetRenderer();

                // 파일탐색기 열기
                OpenFileDialog openFileDialog   = new OpenFileDialog();
                openFileDialog.Multiselect      = false;
                openFileDialog.Filter           = "All files (*.*)|*.*";
                openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                if (openFileDialog.ShowDialog() == true)
                {
                    //아이콘 파일경로
                    string icon_foler = Path.Combine(BizUtil.GetDataFolder(), "style_img");


                    FileInfo[] files = openFileDialog.FileNames.Select(f => new FileInfo(f)).ToArray();  //파일인포
                    foreach (FileInfo fi in files)
                    {
                        try
                        {
                            //해당이미지파일을 FTR_CDE ex)SA117 이름의파일로 복사
                            fi.CopyTo(Path.Combine(icon_foler, _FTR_CDE), true);
                        }
                        catch (Exception ex)
                        {
                            Messages.ShowErrMsgBox(ex.Message);
                        }
                        finally
                        {
                            //1.렌더러 재구성
                            InitUniqueValueRenderer();

                            //2.레이어의 렌더러 재세팅
                            foreach (string sel in _selectedLayerNms)
                            {
                                layers[sel].Renderer = uniqueValueRenderer.Clone();
                                layers[sel].RetryLoadAsync();
                            }

                            //3.팝업이미지소스 업데이트
                            BitImg = new BitmapImage(new Uri(Path.Combine(Path.Combine(BizUtil.GetDataFolder(), "style_img"), _FTR_CDE))).Clone();
                        }
                    }
                }
            });



            btnCmd = new RelayCommand <object>(async delegate(object obj)
            {
                Button btn = obj as Button;
                switch (btn.Content.ToString())
                {
                case "시설물편집":
                    //시설물편집팝업호출



                    break;


                default:
                    break;
                }
            });


            //도형클리어처리
            clearCmd = new RelayCommand <object>(delegate(object obj)
            {
                // Remove all graphics from the graphics overlay
                _sketchOverlay.Graphics.Clear();

                // Disable buttons that require graphics
                ClearButton.IsEnabled = false;
            });
            completeCmd = new RelayCommand <object>(async delegate(object obj)
            {
                mapView.SketchEditor.Stop();
                //추가된 도형 저장처리

                _selectedFeature.Geometry = _geometry;
                // Apply the edit to the feature table.
                await _selectedFeature.FeatureTable.UpdateFeatureAsync(_selectedFeature);
                _selectedFeature.Refresh();
                MessageBox.Show("Added feature ", "Success!");
            });

            //시설물찾기
            //findCmd = new RelayCommand<object>(FindAction);
        }
Ejemplo n.º 27
0
        public MapMainViewModel()
        {
            //string licenseKey = "runtimelite,1000,rud1244207246,none,9TJC7XLS1MJPF5KHT033"; //그린텍
            //string licenseKey = "runtimelite,1000,rud9177830334,none,A3E60RFLTFM5NERL1040"; //kyun0828 free

            //ArcGISRuntimeEnvironment.SetLicense(licenseKey);


            loadedCmd = new RelayCommand <object>(delegate(object obj)
            {
                //뷰객체를 파라미터로 전달받기
                System.Windows.Controls.Grid divGrid = obj as System.Windows.Controls.Grid;

                this.mapView     = divGrid.FindName("mapView") as MapView;
                this.divLayer    = divGrid.FindName("divLayer") as Popup;
                this.ClearButton = divGrid.FindName("ClearButton") as Button;


                //지도초기화
                InitMap();


                //시설물레이어DIV 초기화작업
                InitDivLayer();

                CmmRun.InitUniqueValueRenderer();//렌더러초기생성작업


                //비트맵초기화(시설물상세DIV 아이콘)
                BitImg = new BitmapImage();

                //ShowShapeLayer(mapView, "BML_GADM_AS", true);
            });


            //레이어 ON/OFF
            chkCmd = new RelayCommand <object>(delegate(object obj)
            {
                Button doc = obj as Button;
                //IEnumerable<CheckBox> collection = doc.Children.OfType<CheckBox>();
                //CheckBox chkbox = collection.First();

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

                ShowLocalServerLayer(mapView, doc.Tag.ToString(), chk);
                //ShowShapeLayer(mapView, 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) { }
            });

            //팝업레이어 토글처리
            toggleCmd = new RelayCommand <object>(delegate(object obj)
            {
                StackPanel spLayer = divLayer.FindName("spLayer") as StackPanel;
                System.Windows.Controls.Grid gridTitle = divLayer.FindName("gridTitle") as System.Windows.Controls.Grid;

                spLayer.Visibility = spLayer.Visibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;

                if (spLayer.Visibility == Visibility.Collapsed)
                {
                    divLayer.Height = gridTitle.Height;
                }
                else
                {
                    divLayer.Height = gridTitle.Height + spLayer.Height;
                }
            });



            // 레이어스타일 Renderer 초기화 - shape방식에서만 사용함
            //InitUniqueValueRenderer();

            levelCmd = new RelayCommand <object>(delegate(object obj)
            {
                MessageBox.Show("MapScale - " + mapView.MapScale);
            });

            //GIS초기화
            resetCmd = new RelayCommand <object>(delegate(object obj)
            {
                //0.맵초기화
                InitMap();

                //1.로컬서버 재기동
                //Initialize_LocalServer();

                //2.레이어 클리어
                mapView.Map.OperationalLayers.Clear();


                //3.열여있는 시설물정보창 닫기
                popFct.IsOpen = false;

                TreeView treeLayer = obj as TreeView;

                //레이어div 체크해제
                foreach (CheckBox cb in FmsUtil.FindVisualChildren <CheckBox>(treeLayer))
                {
                    cb.IsChecked = false;
                }

                //선택된레이어 해제
                _selectedFeature = null;
                try
                {
                    CmmRun.layers[_selectedLayerNm].ClearSelection();
                }
                catch (Exception) { }
                _selectedLayerNms.Clear();
                _selectedLayerNm = "";


                // 행정구역 표시
                ShowLocalServerLayer(mapView, "BML_GADM_AS", true);
                //ShowShapeLayer(mapView, "BML_GADM_AS", true);
            });

            //시설물팝업에서 시설물메뉴화면 호출작업
            CallPageCmd = new RelayCommand <object>(delegate(object obj) {
                FctDtl fctDtl = obj as FctDtl;

                IRegionManager regionManager = FmsUtil.__regionManager;
                ViewsCollection views        = regionManager.Regions["ContentRegion"].ActiveViews as ViewsCollection;

                foreach (var v in views)
                {
                    MapArcObjView mapMainView = v as MapArcObjView;
                    //MainWinViewModel vm = ((System.Windows.Controls.Grid)((ContentControl)mapMainView.Parent).Parent).DataContext as MainWinViewModel;
                    break;
                }
            });

            //시설물편집창
            EditCmd = new RelayCommand <object>(delegate(object obj)
            {
                EditWinView view = new EditWinView();
                if (view.ShowDialog() is bool)
                {
                    //재조회
                }
            });



            //도형클리어처리
            clearCmd = new RelayCommand <object>(delegate(object obj)
            {
                // Remove all graphics from the graphics overlay
                _sketchOverlay.Graphics.Clear();

                // Disable buttons that require graphics
                ClearButton.IsEnabled = false;
            });
            completeCmd = new RelayCommand <object>(async delegate(object obj)
            {
                mapView.SketchEditor.Stop();
                //추가된 도형 저장처리

                //_selectedFeature.Geometry = _geometry;
                // Apply the edit to the feature table.
                await _selectedFeature.FeatureTable.UpdateFeatureAsync(_selectedFeature);
                _selectedFeature.Refresh();
                MessageBox.Show("Added feature ", "Success!");
            });
        }