Exemplo n.º 1
0
		public bool ShowConnectedPictures(Guid TypeOfMaterial)
		    {
		    if (SelectedOrt == null)
			    return false;
		    ConnectedMaterialHandlerModell MaterialModell = new ConnectedMaterialHandlerModell();
			Window PictureWindow = new Window();
			PictureWindow.Content = new ConnectedMaterialHandlerControl();
		    (PictureWindow.Content as ConnectedMaterialHandlerControl)
					.ConnectedMaterialHandlerModellInstance = MaterialModell;
			MaterialModell.TypeOfMaterial = TypeOfMaterial;
		    MaterialModell.WordUpOrteHandlerModelInstance = this;
		    PictureWindow.Title = "BildDaten für den Ort \"" + SelectedOrt.Bezeichnung + "\"";
			PictureWindow.SizeToContent = SizeToContent.WidthAndHeight;
			MaterialModell.FillSpecialPictureSelectionList();
			MaterialModell.SelectedKoordinatenSource = SelectedOrt;
			MaterialModell.SelectedMaterialJPGTyp
				= Data.DbServer3.Blob.MaterialJPGTypen.Find(MaterialienTypen.OrtsBild);
			PictureWindow.ShowDialog();

		    return true;
		    }
		private void RemoveFromList_OnClick(object sender, RoutedEventArgs e)
			{
			MaterialJPGForeignKeyConnector SelectedEntry = (MaterialJPGForeignKeyConnector)((MenuItem)sender).DataContext;
			e.Handled = true;
			ConnectedMaterialHandlerModell MaterialHandlerModell = new ConnectedMaterialHandlerModell();
			if (!MaterialHandlerModell.RemoveConnectedEntry(SelectedEntry))
				{
				MessageBox.Show("Es trat ein Fehler auf");
				return;
				}
			}
		//private void AddToListClicked_OnClick(object sender, RoutedEventArgs e)
		//	{
		//	Popup contextMenu = ((MenuItem) sender).GetVisualParent(new Func<Popup, bool>(popup => true), true);
		//	MaterialJPGForeignKeyConnector selectedEntry = (MaterialJPGForeignKeyConnector) contextMenu.DataContext;
		//	Guid typOfListToAddTo = ((MaterialJPGForeignKeyConnectorenTyp)((MenuItem)sender).DataContext).Id;
		//	e.Handled = true;
		//	ConnectedMaterialHandlerModell materialHandlerModell = new ConnectedMaterialHandlerModell();
		//	materialHandlerModell.TypeOfMaterial = typOfListToAddTo;
		//	materialHandlerModell.ProjekteModellInstance
		//		= ConnectedMaterialHandlerModellInstance.ProjekteModellInstance;
		//	materialHandlerModell.WordUpOrteHandlerModelInstance
		//		= ConnectedMaterialHandlerModellInstance.WordUpOrteHandlerModelInstance;
		//	materialHandlerModell.JPGIdToImport = (Guid)selectedEntry.JPGId;
		//	if (!materialHandlerModell.ImportJPGIdAsDefinedTypOfMaterial(selectedEntry))
		//		{
		//		MessageBox.Show("Es trat ein Fehler auf");
		//		return;
		//		}
		//	}

		private void MenuForAddToTypListSelection_OnHandler(object sender, RoutedEventArgs e)
			{
			Popup contextMenu = ((MenuItem)sender).GetVisualParent(new Func<Popup, bool>(popup => true), true);
			Guid typOfListToAddTo = ((MaterialJPGForeignKeyConnectorenTyp)((MenuItem)sender).DataContext).Id;
			Guid JPGId = Guid.Empty;
			if (contextMenu.DataContext is MaterialJPGForeignKeyConnector)
				{
				MaterialJPGForeignKeyConnector selectedEntry = (MaterialJPGForeignKeyConnector)contextMenu.DataContext;
				JPGId = (Guid)selectedEntry.JPGId;
				}
			if (contextMenu.DataContext is MaterialJPG)
				{
				MaterialJPG selectedEntry = (MaterialJPG)contextMenu.DataContext;
				JPGId = (Guid)selectedEntry.Id;
				}
			e.Handled = true;
			ConnectedMaterialHandlerModell materialHandlerModell = new ConnectedMaterialHandlerModell();
			materialHandlerModell.TypeOfMaterial = typOfListToAddTo;
			materialHandlerModell.ProjekteModellInstance
				= ConnectedMaterialHandlerModellInstance.ProjekteModellInstance;
			materialHandlerModell.WordUpOrteHandlerModelInstance
				= ConnectedMaterialHandlerModellInstance.WordUpOrteHandlerModelInstance;
			materialHandlerModell.JPGIdToImport = JPGId;
			if (!materialHandlerModell.ImportJPGIdAsDefinedTypOfMaterial
				(Data.DbServer3.Blob.MaterialienJPG.FindOrLoad(JPGId).Description))
				{
				MessageBox.Show("Es trat ein Fehler auf");
				return;
				}

			}
		private void ConnectedMaterialHandlerModellInstanceChanged(ConnectedMaterialHandlerModell OldValue,
			ConnectedMaterialHandlerModell NewValue)
			{
			}
		private void TargetButton_OnDrop(object sender, DragEventArgs e)
			{
			Button source = sender as Button;
			Ort targetOrt= source.DataContext as Ort;
			if (targetOrt != WordUpOrteHandlerModelInstance.SelectedOrt)
				{
				MessageBox.Show("Der ZielOrt für die DragDrop Operation muß selektiert sein");
				return;
				}
			if (targetOrt != WordUpOrteHandlerModelInstance.SelectedOrt)
				return;
			if (!ConnectedMaterialHandlerModell.IsValidPictureDropSource(e))
				return;
			ConnectedMaterialHandlerModell MaterialHandlerModell = new ConnectedMaterialHandlerModell();
			MaterialJPGForeignKeyConnectorenTyp TargetForeignTyp = Data.DbServer3.Blob.MaterialJPGForeignKeyConnectorenTypen
				.Find_MaterialJPGTypViaName((String) source.Tag);
			MaterialJPGTyp TargetMaterialTyp = Data.DbServer3.Blob.MaterialJPGTypen.Find(MaterialienTypen.OrtsBild);
            MaterialHandlerModell.WordUpOrteHandlerModelInstance = WordUpOrteHandlerModelInstance;
			if (MaterialHandlerModell.ImportData(ConnectedMaterialHandlerModell.GetPictureFileDropSource(e),
				targetOrt, TargetMaterialTyp, true, targetOrt.Id, TargetForeignTyp) == null)
				{
				MessageBox.Show("Es trat ein Fehler auf");
				return;
				}
			}
		public List<PictureContainerList>  LoadSelectablePicturesAccordingToPictureSelectionSettings
			(ConnectedMaterialHandlerModell materialModell)
			{
			List<PictureContainerList> result = null;
			switch (UsedPictureSelection)
				{
				case PictureSelection.PPTWorkingPictures:
					if (ActuallProject != null)
						result = PictureContainerList.PrepareData
							(Data.DbServer3.Blob.DataContext, ActuallProject);
					break;
				case PictureSelection.ActuallProject:
					if (ActuallProject != null)
						result = PictureContainerList.PrepareData
							(Data.DbServer3.Blob.DataContext, ActuallProject, ActuallOrt,
								 false, false, true);
					break;
				case PictureSelection.ActuallOrt:
						if (ActuallOrt != null)
							result = PictureContainerList.PrepareData
								(Data.DbServer3.Blob.DataContext, ActuallProject, ActuallOrt,
									 true, false, true);
					break;
				case PictureSelection.AllFromEqualyTypedProject:
					result = new List<PictureContainerList>();


                    break;
				case PictureSelection.OrtNearbyActualOrt:
				case PictureSelection.OrtNearlyNearbyActualOrt:
					result = PictureContainerList.PrepareData(Data.DbServer3.Blob.DataContext,
						(double)ActuallOrt.WLaenge, (double)ActuallOrt.WBreite, DistanceToCenterOfRegionOfInterests);
					break;
				case PictureSelection.RecentlyAddedFew:
				case PictureSelection.RecentlyAddedMore:
					result = PictureContainerList.PrepareData(Data.DbServer3.Blob.DataContext,
						StartIndex, NumberOfRecentlyAddedPictures);
                    break;
				case PictureSelection.StartToEndIndex:
					result = new List<PictureContainerList>();
					break;
				}
			return result;
			}
		public static void FillSpecialPictureSelectionList
			(ConnectedMaterialHandlerModell MaterialModell,
				List<SpecialPictureSelection> ActuallList)
			{
			if (MaterialModell.ProjekteModellInstance != null)
				{
				ActuallList.Add(new SpecialPictureSelection(MaterialModell, PictureSelection.PPTWorkingPictures)
					{
					ActuallProject = MaterialModell.ProjekteModellInstance.SelectedProjekt
					});
				ActuallList.Add(new SpecialPictureSelection(MaterialModell, PictureSelection.ActuallProject)
					{
					ActuallProject = MaterialModell.ProjekteModellInstance.SelectedProjekt
					});
				ActuallList.Add(new SpecialPictureSelection(MaterialModell, PictureSelection.ActuallOrt)
					{
					ActuallOrt = MaterialModell.ProjekteModellInstance.SelectedProjekt.Ort
					});
				ActuallList.Add(new SpecialPictureSelection(MaterialModell, PictureSelection.AllFromEqualyTypedProject)
					{
					ActuallTyp = MaterialModell.ProjekteModellInstance.SelectedProjekt.Typ
					});
				ActuallList.Add(new SpecialPictureSelection(MaterialModell, PictureSelection.OrtNearbyActualOrt)
					{
					ActuallOrt = MaterialModell.ProjekteModellInstance.SelectedProjekt.Ort,
					DistanceToCenterOfRegionOfInterests = 50
					});
				ActuallList.Add(new SpecialPictureSelection(MaterialModell, PictureSelection.OrtNearlyNearbyActualOrt)
					{
					ActuallOrt = MaterialModell.ProjekteModellInstance.SelectedProjekt.Ort,
					DistanceToCenterOfRegionOfInterests = 500
					});
				}
			else
				{
				if (MaterialModell.WordUpOrteHandlerModelInstance != null)
					{
					ActuallList.Add(new SpecialPictureSelection(MaterialModell, PictureSelection.ActuallOrt)
						{
						ActuallOrt = MaterialModell.WordUpOrteHandlerModelInstance.SelectedOrt
						});
					ActuallList.Add(new SpecialPictureSelection(MaterialModell, PictureSelection.OrtNearbyActualOrt)
						{
						ActuallOrt = MaterialModell.WordUpOrteHandlerModelInstance.SelectedOrt,
						DistanceToCenterOfRegionOfInterests = 50
						});
					ActuallList.Add(new SpecialPictureSelection(MaterialModell, PictureSelection.OrtNearlyNearbyActualOrt)
						{
						ActuallOrt = MaterialModell.WordUpOrteHandlerModelInstance.SelectedOrt,
						DistanceToCenterOfRegionOfInterests = 500
						});
					}
				}
			ActuallList.Add(new SpecialPictureSelection(MaterialModell, PictureSelection.RecentlyAddedFew)
				{
				NumberOfRecentlyAddedPictures = 50
				});
			ActuallList.Add(new SpecialPictureSelection(MaterialModell, PictureSelection.RecentlyAddedMore)
				{
				NumberOfRecentlyAddedPictures = 300
				});
			int stepCounter = 100;
			int runningCounter = 0;
			while (runningCounter < Data.DbServer3.Blob.MaterialienJPG.Find_NumberOfExistingEntries())
				{
				ActuallList.Add(new SpecialPictureSelection(MaterialModell, PictureSelection.StartToEndIndex)
					{
					StartIndex = runningCounter,
					NumberOfEntries = stepCounter
					});
				runningCounter += stepCounter;
				}
			}
		public SpecialPictureSelection(ConnectedMaterialHandlerModell materialModell,
			PictureSelection pictureSelection)
			{
			MaterialModell = materialModell;
			UsedPictureSelection = pictureSelection;
			}
Exemplo n.º 9
0
		public bool ShowConnectedPictures(Guid TypeOfMaterial)
			{
			if (SelectedProjekt == null)
				return false;
			ConnectedMaterialHandlerModell MaterialModell = new ConnectedMaterialHandlerModell();
			Window PictureWindow = new Window();
			PictureWindow.Content = new ConnectedMaterialHandlerControl();
			(PictureWindow.Content as ConnectedMaterialHandlerControl)
					.ConnectedMaterialHandlerModellInstance = MaterialModell;
			MaterialModell.TypeOfMaterial = TypeOfMaterial;
			MaterialModell.ProjekteModellInstance = this;
			PictureWindow.Title = $"BildDaten und OrtsDaten für das Projekt \"{SelectedProjekt.Beschreibung}\"" +
							$", ProjektID = \"{SelectedProjekt.NumericProjektId}\" am Ort \"{SelectedProjekt.Ort.Bezeichnung}\"";
			PictureWindow.SizeToContent = SizeToContent.WidthAndHeight;
			MaterialModell.FillSpecialPictureSelectionList();
			MaterialModell.SelectedKoordinatenSource = SelectedProjekt.Ort;
			MaterialModell.SelectedMaterialJPGTyp
				= Data.DbServer3.Blob.MaterialJPGTypen.Find(MaterialienTypen.ProjektBild);
            PictureWindow.ShowDialog();
			PictureWindow.Close();
            return true;
			}