Ejemplo n.º 1
0
        public SiteCompare(Window owner, User user, SiteExplorerNodeViewModel dest, List<SiteExplorerNodeViewModel> otherSites)
        {
            this.Owner = owner;
            this.User = user;
            InitializeComponent();
            Destination = dest;
            _compareModel = new ObservableCollection<SiteExplorerNodeViewModel>(otherSites.ConvertAll((vm) => {
                vm.IsSelected = true;
                return vm;
            }));
            txtMergeInto.Text = dest.Name;
            lstRemove.ItemsSource = _compareModel;

            grpDiff.DataContextChanged += new DependencyPropertyChangedEventHandler(grpDiff_DataContextChanged);

            if (_compareModel.Count > 0) {
                lstRemove.SelectedItem = _compareModel[0];
            }
        }
Ejemplo n.º 2
0
		void LoadCitiesBase() {
			var path = AppDomain.CurrentDomain.BaseDirectory;
			var root = Path.GetPathRoot(path);

			bool fileExists = false;
			if (File.Exists(Path.Combine(path, JsonFileName))) {
				fileExists = true;
			}
			else {
				while (path != "" && path != root) {
					path = Directory.GetParent(path).ToString();
					if (File.Exists(Path.Combine(path, JsonFileName))) {
						fileExists = true;
						break;
					}
				}
			}
			if (fileExists) {
				var resultList = new List<string>();
				using (var reader = new StreamReader(Path.Combine(path, JsonFileName))) {
					string line = "";
					JavaScriptSerializer js = new JavaScriptSerializer();
					while (( line = reader.ReadLine() ) != null) {
						var dict = js.Deserialize<Dictionary<string, string>>(line);
						if (dict.ContainsKey("city")) {
							resultList.Add(dict["city"]);
						}
					}
				}
				resultList = resultList.ConvertAll(x => x.ToLower());
				_locations = resultList.OrderBy(x => x).ToArray();
			}
			else {
				MessageBox.Show(JsonFileName + " not found");
			}
		}
        private void DisplaySearchResultItems(string title, List<SearchResultItem> result)
        {
            if (result != null && result.Count > 0)
            {
                if (result[0] is VideoInfo)
                {
                    SelectedCategory = new Category() { Name = title };
                    List<VideoInfo> videoList = result.ConvertAll(i => i as VideoInfo);
					listViewMain.ItemsSource = ViewModels.VideoList.GetVideosView(this, videoList, SelectedSite.HasNextPage);
					SelectAndFocusItem();
					ImageDownloader.GetImages<VideoInfo>(videoList);
                }
                else
                {
                    SelectedCategory = new Category()
                    {
                        Name = title,
                        HasSubCategories = true,
                        SubCategoriesDiscovered = true,
                    };
                    SelectedCategory.SubCategories = result.ConvertAll(i => { (i as Category).ParentCategory = SelectedCategory; return i as Category; });
					listViewMain.ItemsSource = ViewModels.CategoryList.GetCategoriesView(this, SelectedCategory.SubCategories);
                    SelectAndFocusItem();
					ImageDownloader.GetImages<Category>(SelectedCategory.SubCategories);
                }
            }
        }
Ejemplo n.º 4
0
        public SiteDetails(User user, int siteID, bool readOnly)
            : base(user, "Site:" + siteID)
        {
            InitializeComponent();
            this.SiteID = siteID;

            this.IsReadOnly = readOnly;
            var list = new List<Ellipsoid>(GeoUtils.ELLIPSOIDS);
            cmbDatum.ItemsSource = new ObservableCollection<string>(list.ConvertAll((ellipsoid) => { return ellipsoid.Name; }));

            if (GoogleEarth.IsInstalled()) {
                coordGrid.ColumnDefinitions[7].Width = new GridLength(23);
            } else {
                coordGrid.ColumnDefinitions[7].Width = new GridLength(0);
            }

            // Radio button checked event handlers
            optNearestPlace.Checked += new RoutedEventHandler((s, e) => {
                txtLocality.IsEnabled = false;
                txtDirectionFrom.IsEnabled = true;
                txtDistanceFrom.IsEnabled = true;
                txtFrom.IsEnabled = true;
            });

            optLocality.Checked += new RoutedEventHandler((s, e) => {
                txtLocality.IsEnabled = true;
                txtDirectionFrom.IsEnabled = false;
                txtDistanceFrom.IsEnabled = false;
                txtFrom.IsEnabled = false;
            });

            var service = new MaterialService(User);
            var model = service.GetSite(SiteID);
            _viewModel = new SiteViewModel(model);
            this.DataContext = _viewModel;

            tabSite.AddTabItem("Traits", new TraitControl(User, TraitCategoryType.Site, _viewModel) { IsReadOnly = readOnly });
            tabSite.AddTabItem("Notes", new NotesControl(User, TraitCategoryType.Site, _viewModel) { IsReadOnly = readOnly });
            tabSite.AddTabItem("Multimedia", new MultimediaControl(User, TraitCategoryType.Site, _viewModel) { IsReadOnly = readOnly });
            tabSite.AddTabItem("Ownership", new OwnershipDetails(_viewModel.Model));

            txtPosSource.BindUser(User, PickListType.Phrase, "Source", TraitCategoryType.Site);
            txtPosWho.BindUser(User, "tblSite", "vchrPosWho");
            txtPosOriginal.BindUser(User, PickListType.Phrase, "OriginalDetermination", TraitCategoryType.Site);

            txtElevUnits.BindUser(User, PickListType.Phrase, "Units", TraitCategoryType.Site);
            txtElevSource.BindUser(User, PickListType.Phrase, "Source", TraitCategoryType.Site);

            txtGeoEra.BindUser(User, PickListType.Phrase, "Geological Era", TraitCategoryType.Site);
            txtGeoPlate.BindUser(User, PickListType.Phrase, "Geological Plate", TraitCategoryType.Site);
            txtGeoStage.BindUser(User, PickListType.Phrase, "Geological State", TraitCategoryType.Site);

            txtGeoFormation.BindUser(User, PickListType.Phrase, "Geological Formation", TraitCategoryType.Site);
            txtGeoMember.BindUser(User, PickListType.Phrase, "Geological Member", TraitCategoryType.Site);
            txtGeoBed.BindUser(User, PickListType.Phrase, "Geological Bed", TraitCategoryType.Site);

            this.ctlX1.CoordinateValueChanged += new CoordinateValueChangedHandler((s, v) => { UpdateMiniMap(ctlY1.Value, ctlX1.Value); });
            this.ctlY1.CoordinateValueChanged += new CoordinateValueChangedHandler((s, v) => { UpdateMiniMap(ctlY1.Value, ctlX1.Value); });

            this.ctlX2.Visibility = System.Windows.Visibility.Hidden;
            this.ctlY2.Visibility = System.Windows.Visibility.Hidden;

            txtPoliticalRegion.BindUser(User, LookupType.Region);

            string llmode = Config.GetUser(User, "SiteDetails.LatLongFormat", LatLongMode.DegreesMinutesSeconds.ToString());
            if (!String.IsNullOrEmpty(llmode)) {
                LatLongMode mode = (LatLongMode)Enum.Parse(typeof(LatLongMode), llmode);
                SwitchLatLongFormat(mode);
            }

            optPoint.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); });
            optLine.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); });
            optBoundingBox.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); });

            optCoordsNotSpecified.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); });
            optEastingsNorthings.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); });
            optLatLong.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); });

            optElevDepth.Checked += new RoutedEventHandler(UpdateElevation);
            optElevElevation.Checked += new RoutedEventHandler(UpdateElevation);
            optElevNotSpecified.Checked += new RoutedEventHandler(UpdateElevation);

            if (model.PosY1.HasValue && model.PosX1.HasValue) {
                UpdateMiniMap(model.PosY1.Value, model.PosX1.Value);
            }

            this.PreviewDragOver += new DragEventHandler(site_PreviewDragEnter);
            this.PreviewDragEnter += new DragEventHandler(site_PreviewDragEnter);

            //this.Drop += new DragEventHandler(site_Drop);

            HookLatLongControl(ctlX1);
            HookLatLongControl(ctlY1);
            HookLatLongControl(ctlX2);
            HookLatLongControl(ctlY2);

            this.Loaded += new RoutedEventHandler(SiteDetails_Loaded);
        }
Ejemplo n.º 5
0
        private void ReloadMultimediaPanel(List<MultimediaLink> data)
        {
            JobExecutor.QueueJob(() => {
                _model = new ObservableCollection<MultimediaLinkViewModel>(data.ConvertAll((item) => {
                    MultimediaLinkViewModel viewmodel = null;
                    this.InvokeIfRequired(() => {
                        viewmodel = new MultimediaLinkViewModel(item);
                        viewmodel.DataChanged += new DataChangedHandler((m) => {
                            RegisterUniquePendingChange(new UpdateMultimediaLinkCommand(viewmodel.Model, CategoryType));
                        });
                    });
                    return viewmodel;
                }));
                this.InvokeIfRequired(() => {
                    this.thumbList.ItemsSource = _model;
                });

                foreach (MultimediaLinkViewModel item in _model) {
                    this.BackgroundInvoke(() => {
                        GenerateThumbnail(item, THUMB_SIZE);
                    });
                }
            });
        }
Ejemplo n.º 6
0
        private ObservableCollection<HierarchicalViewModelBase> BuildExplorerModel(List<SiteExplorerNode> list, bool isFindModel)
        {
            list.Sort((item1, item2) => {
                int compare = item1.ElemType.CompareTo(item2.ElemType);
                if (compare == 0) {
                    return item1.Name.CompareTo(item2.Name);
                }
                return compare;
            });

            var regionsModel = new ObservableCollection<HierarchicalViewModelBase>(list.ConvertAll((model) => {
                var viewModel = new SiteExplorerNodeViewModel(model, isFindModel);

                if (model.NumChildren > 0) {
                    viewModel.Children.Add(new ViewModelPlaceholder("Loading..."));
                    viewModel.LazyLoadChildren += new HierarchicalViewModelAction(viewModel_LazyLoadChildren);
                }
                return viewModel;
            }));
            return regionsModel;
        }
Ejemplo n.º 7
0
        public int? ChooseTemplate(SiteExplorerNodeType templateType)
        {
            var picklist = new PickListWindow(User, "Select Template", () => {
                var service = new MaterialService(User);
                List<SiteExplorerNode> list = new List<SiteExplorerNode>();
                switch (templateType) {
                    case SiteExplorerNodeType.Site:
                        list.AddRange(service.GetSiteTemplates());
                        break;
                    case SiteExplorerNodeType.SiteVisit:
                        list.AddRange(service.GetSiteVisitTemplates());
                        break;
                    case SiteExplorerNodeType.Material:
                        list.AddRange(service.GetMaterialTemplates());
                        break;
                }
                return list.ConvertAll((node) => {
                    return new SiteExplorerNodeViewModel(node);
                });
            }, null);

            if (picklist.ShowDialog().GetValueOrDefault(false)) {
                var selected = picklist.SelectedValue as SiteExplorerNodeViewModel;
                if (selected != null) {
                    return selected.ElemID;
                }
            }

            return null;
        }
        private void bDistribute_Click(object sender, RoutedEventArgs e)
        {
            Decimal sumForDistribution = Convert.ToDecimal(tbsum.Text);
            String stringOfsum = tbSumForDistribution.Text;

            List<String> ListOfSumStr = new List<String>(Regex.Split(stringOfsum, @";"));
            List<Decimal> ListOfSumDec = ListOfSumStr.ConvertAll(new Converter<String, Decimal>(ConvertToDecimal));
            tbkRezult.Text = operations[cbTypeOfDistribution.Text](ListOfSumDec, sumForDistribution);
        }
        /// <summary>
        /// Render the <paramref name="GammaWorldCharacter"/>'s name, class, level and so on.
        /// </summary>
        /// <param name="GammaWorldCharacter">
        /// The <see cref="Character"/> to render. This cannot be null.
        /// </param>
        /// <param name="resourceDictionary">
        /// A <see cref="ResourceDictionary"/> containing styles. This cannot be null.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// No arguments can be null.
        /// </exception>
        private Block RenderAbilities(Character GammaWorldCharacter, ResourceDictionary resourceDictionary)
        {
            if (GammaWorldCharacter == null)
            {
                throw new ArgumentNullException("GammaWorldCharacter");
            }
            if (resourceDictionary == null)
            {
                throw new ArgumentNullException("resourceDictionary");
            }
            DictionaryHelper.Expect<Style>(resourceDictionary, StyleHelper.TraitHeaderRowStyleName);

            List<Score> skills;
            Table table;
            TableRowGroup tableRowGroup;
            TableRow tableRow;
            TableCell leftCell; // Reused
            TableCell middleCell; // Reused
            TableCell rightCell; // Reused
            Paragraph paragraph; // Reused

            table = new Table();
            table.Style = (Style)resourceDictionary[StyleHelper.TraitHeaderRowStyleName];
            table.Columns.Add(new TableColumn());
            table.Columns.Add(new TableColumn());
            table.Columns.Add(new TableColumn());

            tableRowGroup = new TableRowGroup();

            // The skills row
            skills = new List<Score>();
            foreach (ScoreType skill in ScoreTypeHelper.Skills)
            {
                skills.Add(GammaWorldCharacter[skill]);
            }
            skills.Sort((x, y) => x.Name.CompareTo(y.Name));
            paragraph = new Paragraph();
            paragraph.Inlines.Add(new Bold(new Run("Skills ")));
            paragraph.Inlines.Add(new Run(string.Join(", ",
                skills.ConvertAll(x => string.Format("{0} {1}", x.Name, x.ToString(
                    CharacterRendererHelper.GetFormatString(ScoreDisplayType.Modifier, ShowModifiers)))).ToArray())));
            leftCell = new TableCell();
            leftCell.ColumnSpan = 3;
            leftCell.Blocks.Add(paragraph);

            // Contruct the third row
            tableRow = new TableRow();
            tableRow.Cells.Add(leftCell);
            tableRowGroup.Rows.Add(tableRow);

            // TODO: Convert these to loops

            // The first row of ability scores
            paragraph = new Paragraph();
            paragraph.Inlines.Add(new Bold(new Run("Str ")));
            paragraph.Inlines.Add(new Run(string.Format(" {0} ({1})",
                GammaWorldCharacter[ScoreType.Strength].ToString(
                CharacterRendererHelper.GetFormatString(ScoreDisplayType.Score, ShowModifiers)),
                ModifierHelper.FormatModifier(((AbilityScore) GammaWorldCharacter[ScoreType.Strength]).Modifier, false))));
            leftCell = new TableCell();
            leftCell.Blocks.Add(paragraph);

            paragraph = new Paragraph();
            paragraph.Inlines.Add(new Bold(new Run("Dex ")));
            paragraph.Inlines.Add(new Run(string.Format(" {0} ({1})",
                GammaWorldCharacter[ScoreType.Dexterity].ToString(
                CharacterRendererHelper.GetFormatString(ScoreDisplayType.Score, ShowModifiers)),
                ModifierHelper.FormatModifier(((AbilityScore)GammaWorldCharacter[ScoreType.Dexterity]).Modifier, false))));
            middleCell = new TableCell();
            middleCell.Blocks.Add(paragraph);

            paragraph = new Paragraph();
            paragraph.Inlines.Add(new Bold(new Run("Wis ")));
            paragraph.Inlines.Add(new Run(string.Format(" {0} ({1})",
                GammaWorldCharacter[ScoreType.Wisdom].ToString(
                CharacterRendererHelper.GetFormatString(ScoreDisplayType.Score, ShowModifiers)),
                ModifierHelper.FormatModifier(((AbilityScore) GammaWorldCharacter[ScoreType.Wisdom]).Modifier, false))));
            rightCell = new TableCell();
            rightCell.Blocks.Add(paragraph);

            // Contruct the first row of ability scores
            tableRow = new TableRow();
            tableRow.Cells.Add(leftCell);
            tableRow.Cells.Add(middleCell);
            tableRow.Cells.Add(rightCell);
            tableRowGroup.Rows.Add(tableRow);

            // The second row of ability scores
            paragraph = new Paragraph();
            paragraph.Inlines.Add(new Bold(new Run("Con ")));
            paragraph.Inlines.Add(new Run(string.Format(" {0} ({1})",
                GammaWorldCharacter[ScoreType.Constitution].ToString(
                CharacterRendererHelper.GetFormatString(ScoreDisplayType.Score, ShowModifiers)),
                ModifierHelper.FormatModifier(((AbilityScore) GammaWorldCharacter[ScoreType.Constitution]).Modifier, false))));
            leftCell = new TableCell();
            leftCell.Blocks.Add(paragraph);

            paragraph = new Paragraph();
            paragraph.Inlines.Add(new Bold(new Run("Int ")));
            paragraph.Inlines.Add(new Run(string.Format(" {0} ({1})",
                GammaWorldCharacter[ScoreType.Intelligence].ToString(
                CharacterRendererHelper.GetFormatString(ScoreDisplayType.Score, ShowModifiers)),
                ModifierHelper.FormatModifier(((AbilityScore)GammaWorldCharacter[ScoreType.Intelligence]).Modifier, false))));
            middleCell = new TableCell();
            middleCell.Blocks.Add(paragraph);

            paragraph = new Paragraph();
            paragraph.Inlines.Add(new Bold(new Run("Cha ")));
            paragraph.Inlines.Add(new Run(string.Format(" {0} ({1})",
                GammaWorldCharacter[ScoreType.Charisma].ToString(
                CharacterRendererHelper.GetFormatString(ScoreDisplayType.Score, ShowModifiers)),
                ModifierHelper.FormatModifier(((AbilityScore)GammaWorldCharacter[ScoreType.Charisma]).Modifier, false))));
            rightCell = new TableCell();
            rightCell.Blocks.Add(paragraph);

            // Contruct the second row of ability scores
            tableRow = new TableRow();
            tableRow.Cells.Add(leftCell);
            tableRow.Cells.Add(middleCell);
            tableRow.Cells.Add(rightCell);
            tableRowGroup.Rows.Add(tableRow);

            table.RowGroups.Add(tableRowGroup);

            return table;
        }