Dialog for editing picture properties
상속: System.Windows.Forms.Form, IFWDisposable
예제 #1
0
		public void showProperties()
		{
			CheckDisposed();
			CmPicture pic = (CmPicture) this.Object;
			using (PicturePropertiesDialog dlg = new PicturePropertiesDialog(m_cache, pic,
					   FwApp.App, true))
			{
				if (dlg.Initialize())
				{
					if (dlg.ShowDialog() == DialogResult.OK)
					{
						string strLocalPictures = SIL.FieldWorks.Common.RootSites.EditingHelper.DefaultPictureFolder;
						pic.UpdatePicture(dlg.CurrentFile, dlg.Caption, strLocalPictures, pic.Cache.DefaultAnalWs);
						InstallPicture(m_picBox);
						m_lastSize = new Size(0, 0); // forces OnSizeChanged to do something (we need to adjust to new aspect ratio).
						OnSizeChanged(new EventArgs());
					}
				}
			}
		}
예제 #2
0
		/// <summary>
		/// Called by reflection based on menu item InsertPicture.
		/// </summary>
		/// <param name="cmd"></param>
		/// <returns></returns>
		public bool OnInsertPicture(object cmd)
		{
			int flid;
			if (!CanInsertPictureOrMediaFile(cmd, out flid))
				return false; // should not happen, but play safe
			var obj = m_dataEntryForm.CurrentSlice.Object;
			int chvo = obj.Cache.DomainDataByFlid.get_VecSize(obj.Hvo, flid);
			IApp app = (IApp)m_mediator.PropertyTable.GetValue("App");
			using (PicturePropertiesDialog dlg = new PicturePropertiesDialog(obj.Cache, null,
				m_mediator.HelpTopicProvider, app, true))
			{
				if (dlg.Initialize())
				{
					var stylesheet = FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
					dlg.UseMultiStringCaption(obj.Cache, WritingSystemServices.kwsVernAnals, stylesheet);
					if (dlg.ShowDialog() == DialogResult.OK)
					{
						UndoableUnitOfWorkHelper.Do(xWorksStrings.ksUndoInsertPicture, xWorksStrings.ksRedoInsertPicture, obj, () =>
						{
							string strLocalPictures = CmFolderTags.DefaultPictureFolder;
							int hvoPic = obj.Cache.DomainDataByFlid.MakeNewObject(CmPictureTags.kClassId, obj.Hvo, flid, chvo);
							var picture = Cache.ServiceLocator.GetInstance<ICmPictureRepository>().GetObject(hvoPic);
							dlg.GetMultilingualCaptionValues(picture.Caption);
							picture.UpdatePicture(dlg.CurrentFile, null, strLocalPictures, 0);
						});
					}
				}
			}
			return true;
		}
예제 #3
0
		public void showProperties()
		{
			CheckDisposed();
			var pic = (ICmPicture)Object;
			var app = (IApp)m_mediator.PropertyTable.GetValue("App");
			using (var dlg = new PicturePropertiesDialog(m_cache, pic, m_mediator.HelpTopicProvider, app, true))
			{
				if (dlg.Initialize())
				{
					var stylesheet = FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
					dlg.UseMultiStringCaption(m_cache, WritingSystemServices.kwsVernAnals, stylesheet);
					dlg.SetMultilingualCaptionValues(pic.Caption);
					if (dlg.ShowDialog() == DialogResult.OK)
					{
						UndoableUnitOfWorkHelper.Do(DetailControlsStrings.ksUndoUpdatePicture, DetailControlsStrings.ksRedoUpdatePicture, m_obj, () =>
						{
							string strLocalPictures = CmFolderTags.DefaultPictureFolder;
							dlg.GetMultilingualCaptionValues(pic.Caption);
							pic.UpdatePicture(dlg.CurrentFile, null, strLocalPictures, 0);
						});
						InstallPicture(m_picBox);
						m_lastSize = new Size(0, 0); // forces OnSizeChanged to do something (we need to adjust to new aspect ratio).
						OnSizeChanged(new EventArgs());
					}
				}
			}
		}
예제 #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Inserts the picture at the current selection (or updates the picture we are editing)
		/// </summary>
		/// <param name="initialPicture">picture to modify, or null to insert</param>
		/// <param name="dlg">the dialog we ran to get or modify the picture.</param>
		/// ------------------------------------------------------------------------------------
		private void InsertThePicture(ICmPicture initialPicture, PicturePropertiesDialog dlg)
		{
			FwEditingHelper editHelper = ActiveEditingHelper;
			string undo;
			string redo;
			TeResourceHelper.MakeUndoRedoLabels(initialPicture == null ?
				"kstidInsertPicture" : "kstidUpdatePicture", out undo, out redo);
			using (UndoTaskHelper undoTaskHelper = new UndoTaskHelper(m_cache.ActionHandlerAccessor,
					  editHelper.EditedRootBox.Site, undo, redo))
			{
				string strLocalPictures = CmFolderTags.DefaultPictureFolder;

				if (initialPicture != null)
					initialPicture.UpdatePicture(dlg.CurrentFile, dlg.Caption, strLocalPictures, m_cache.DefaultVernWs);
				else
					editHelper.InsertPicture(dlg.CurrentFile, dlg.Caption, strLocalPictures);
				undoTaskHelper.RollBack = false;
			}
		}
예제 #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handles the clicking on the "Picture Properties" context menu.
		/// </summary>
		/// <param name="args"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected bool OnPictureProperties(object args)
		{
			if (ActiveEditingHelper == null || !ActiveEditingHelper.IsPictureSelected)
				return false;

			ICmPicture pic = ActiveEditingHelper.Picture;
			using (PicturePropertiesDialog dlg = new PicturePropertiesDialog(m_cache, pic, m_app, m_app))
			{
				if (dlg.Initialize())
				{
					if (dlg.ShowDialog() == DialogResult.OK)
						InsertThePicture(pic, dlg);
				}
			}

			return true;
		}
예제 #6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Displays the insert picture dialog.
		/// </summary>
		/// <param name="args"></param>
		/// <returns><c>true</c> if we handle this</returns>
		/// ------------------------------------------------------------------------------------
		protected bool OnInsertPictureDialog(object args)
		{
			Debug.Assert(m_cache != null);
			FwEditingHelper editHelper = ActiveEditingHelper;
			if (editHelper == null)
				return false;

			if (editHelper.IsBackTranslation)
			{
				SelectionHelper helper = editHelper.CurrentSelection;
				ICmPictureRepository repo = Cache.ServiceLocator.GetInstance<ICmPictureRepository>();
				SelLevInfo info;
				ISegment segment;
				if (helper.GetLevelInfoForTag(StTxtParaTags.kflidSegments, out info))
					segment = m_cache.ServiceLocator.GetInstance<ISegmentRepository>().GetObject(info.hvo);
				else
				{
					SelLevInfo paraLevInfo;
					helper.GetLevelInfoForTag(StTextTags.kflidParagraphs, out paraLevInfo);
					IStTxtPara para = Cache.ServiceLocator.GetInstance<IStTxtParaRepository>().GetObject(paraLevInfo.hvo);
					segment = para.GetSegmentForOffsetInFreeTranslation(helper.GetIch(SelectionHelper.SelLimitType.Top), helper.Ws);
				}
				ITsString tssVernSegment = segment.BaselineText;
				Guid guidNextPicNotInBt = tssVernSegment.GetAllEmbeddedObjectGuids(FwObjDataTypes.kodtGuidMoveableObjDisp).FirstOrDefault(g =>
					!segment.FreeTranslation.get_String(helper.Ws).GetAllEmbeddedObjectGuids(FwObjDataTypes.kodtGuidMoveableObjDisp).Contains(g));
				if (guidNextPicNotInBt == Guid.Empty)
					return false;
				ICmPicture pict = repo.GetObject(guidNextPicNotInBt);
				string undo;
				string redo;
				TeResourceHelper.MakeUndoRedoLabels("kstidInsertPicture", out undo, out redo);
				using (UndoTaskHelper undoTaskHelper = new UndoTaskHelper(m_cache.ActionHandlerAccessor,
						  editHelper.EditedRootBox.Site, undo, redo))
				{
					editHelper.InsertPicture(pict);
					undoTaskHelper.RollBack = false;
				}
			}
			else
			{
				using (PicturePropertiesDialog dlg = new PicturePropertiesDialog(m_cache, null,
					m_app, m_app))
				{
					// Don't allow inserting an empty picture, so don't check for result of Initialize()
					if (dlg.Initialize())
					{
						if (dlg.ShowDialog() == DialogResult.OK)
							InsertThePicture(null, dlg);
					}
				}
			}
			return true;
		}
예제 #7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Inserts the picture at the current selection (or updates the picture we are editing)
		/// </summary>
		/// <param name="initialPicture">picture to modify, or null to insert</param>
		/// <param name="dlg">the dialog we ran to get or modify the picture.</param>
		/// ------------------------------------------------------------------------------------
		private void InsertThePicture(CmPicture initialPicture, PicturePropertiesDialog dlg)
		{
			FwEditingHelper editHelper = ActiveEditingHelper;
			string undo;
			string redo;
			TeResourceHelper.MakeUndoRedoLabels(initialPicture == null ?
				"kstidInsertPicture" : "kstidUpdatePicture", out undo, out redo);
			using (UndoTaskHelper undoTaskHelper = new UndoTaskHelper(m_cache.MainCacheAccessor,
					  editHelper.EditedRootBox.Site, undo, redo, true))
			{
				string strLocalPictures = EditingHelper.DefaultPictureFolder;

				try
				{
					if (initialPicture != null)
					{
						editHelper.UpdatePicture(initialPicture, dlg.CurrentFile,
							dlg.Caption, strLocalPictures);
					}
					else
					{
						editHelper.InsertPicture(dlg.CurrentFile, dlg.Caption,
							strLocalPictures);
					}
				}
				catch (Exception)
				{
					undoTaskHelper.EndUndoTask = false;
					throw;
				}
			}
		}
예제 #8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Displays the insert picture dialog.
		/// </summary>
		/// <param name="args"></param>
		/// <returns><c>true</c> if we handle this</returns>
		/// ------------------------------------------------------------------------------------
		protected bool OnInsertPictureDialog(object args)
		{
			Debug.Assert(m_cache != null);
			if (ActiveEditingHelper == null)
				return false;

			using (PicturePropertiesDialog dlg = new PicturePropertiesDialog(m_cache, null,
				FwApp.App))
			{
				// Don't allow inserting an empty picture, so don't check for result of Initialize()
				if (dlg.Initialize())
				{
					if (dlg.ShowDialog() == DialogResult.OK)
						InsertThePicture(null, dlg);
				}
			}

			return true;
		}