Ejemplo n.º 1
0
		public InactiveLink(LibraryFileLink link)
		{
			Link = link;
			Name = link.Name;
			FolderName = link.Folder.Name;
			Path = link.FullPath;
			IsDead = link.IsDead;
			IsExpired = link.ExpirationSettings.IsExpired;
		}
		public FormEditLinkSettingsEmbedded(BaseLibraryLink sourceLink, LibraryFolderLink parentFolderLink)
		{
			_parentFolderLink = parentFolderLink;
			_sourceLink = (LibraryFileLink)sourceLink;
			InitializeComponent();
			if ((CreateGraphics()).DpiX > 96)
			{
				xtraTabControl.AppearancePage.HeaderActive.Font = new Font(xtraTabControl.AppearancePage.HeaderActive.Font.FontFamily, xtraTabControl.AppearancePage.HeaderActive.Font.Size - 2, xtraTabControl.AppearancePage.HeaderActive.Font.Style);
				xtraTabControl.AppearancePage.Header.Font = new Font(xtraTabControl.AppearancePage.Header.Font.FontFamily, xtraTabControl.AppearancePage.Header.Font.Size - 2, xtraTabControl.AppearancePage.Header.Font.Style);
				xtraTabControl.AppearancePage.HeaderDisabled.Font = new Font(xtraTabControl.AppearancePage.HeaderDisabled.Font.FontFamily, xtraTabControl.AppearancePage.HeaderDisabled.Font.Size - 2, xtraTabControl.AppearancePage.HeaderDisabled.Font.Style);
				xtraTabControl.AppearancePage.HeaderHotTracked.Font = new Font(xtraTabControl.AppearancePage.HeaderHotTracked.Font.FontFamily, xtraTabControl.AppearancePage.HeaderHotTracked.Font.Size - 2, xtraTabControl.AppearancePage.HeaderHotTracked.Font.Style);
			}
		}
Ejemplo n.º 3
0
		public static void OpenCopyOfFile(LibraryFileLink fileLink)
		{
			try
			{
				var newFile = Path.Combine(MainController.Instance.Settings.OpenFilePath, @"Copy of " + Path.GetFileName(fileLink.FullPath));
				File.Copy(fileLink.FullPath, newFile, true);
				Utils.OpenFile(newFile);
			}
			catch
			{
				MainController.Instance.PopupMessages.ShowWarning(string.Format("Could not create copy of {0} in a temp folder.", Path.GetFileName(fileLink.FullPath)));
			}
		}
		public void ApplyUniverslaLinkSettings(IList<LibraryFileLink> targetLinks, LibraryFileLink templateLink = null)
		{
			foreach (var template in SettingsTemplates)
			{
				if (templateLink == null)
					templateLink = ParentFolder.AllLinks
						.FirstOrDefault(link => link.Type == template.FileType &&
						targetLinks.All(tl => tl != link));

				if (templateLink == null) continue;

				foreach (var targetLink in targetLinks)
					ApplyUniversalLinkSettings(template.SettingsType, targetLink, templateLink);
			}
		}
		public void ProcessUniverslaLinkSettings(
			LinkSettingsType settingsType,
			LibraryFileLink templateLink,
			bool useUniversalSettings)
		{
			if (!useUniversalSettings)
			{
				SettingsTemplates.RemoveAll(st => st.SettingsType == settingsType && st.FileType == templateLink.Type);
				return;
			}

			if (!SettingsTemplates.Any(st => st.SettingsType == settingsType && st.FileType == templateLink.Type))
				SettingsTemplates.Add(LinkFileSettingsTemplate.Create(settingsType, templateLink.Type));

			foreach (var targetLink in ParentFolder.AllLinks.Where(l => l.Type == templateLink.Type && l != templateLink).ToList())
				ApplyUniversalLinkSettings(settingsType, targetLink, templateLink);
		}
		private void ApplyUniversalLinkSettings(
			LinkSettingsType settingsType,
			LibraryFileLink targetLink,
			LibraryFileLink templateLink)
		{
			switch (settingsType)
			{
				case LinkSettingsType.Tags:
					targetLink.Tags = null;
					targetLink.TagsEncoded = templateLink.Tags.Serialize();
					break;
				case LinkSettingsType.Security:
					targetLink.Security = null;
					targetLink.SettingsEncoded = templateLink.Security.Serialize();
					break;
				default:
					targetLink.Settings = null;
					targetLink.SettingsEncoded = templateLink.Settings.Serialize();
					break;
			}
			targetLink.MarkAsModified();
		}
Ejemplo n.º 7
0
		public static void EmailLink(LibraryFileLink fileLink)
		{
			EmailFile(fileLink.FullPath);
		}
Ejemplo n.º 8
0
		public static void PrintFile(LibraryFileLink fileLink)
		{
			var printProcess = new Process();
			var newFile = Path.Combine(MainController.Instance.Settings.OpenFilePath, @"Copy of " + Path.GetFileName(fileLink.FullPath));
			File.Copy(fileLink.FullPath, newFile, true);
			if (FileFormatHelper.IsWordFile(fileLink.FullPath))
			{
				try
				{
					printProcess.StartInfo.FileName = "winword.exe";
					printProcess.StartInfo.Arguments = '"' + newFile + '"' + " /mFilePrint";
					printProcess.Start();
				}
				catch { }
			}
			else if (FileFormatHelper.IsExcelFile(fileLink.FullPath))
			{
				if (ExcelHelper.Instance.Connect())
				{
					ExcelHelper.Instance.Print(new FileInfo(newFile));
					ExcelHelper.Instance.Disconnect();
				}
			}
			else if (FileFormatHelper.IsPdfFile(fileLink.FullPath))
			{
				try
				{
					printProcess.StartInfo.FileName = "AcroRd32.exe";
					printProcess.StartInfo.Arguments = " /p " + '"' + newFile + '"';
					printProcess.Start();
				}
				catch
				{
					MainController.Instance.PopupMessages.ShowWarning("AcroRd32.exe has not been found");
				}
			}
		}
Ejemplo n.º 9
0
		public static void SaveLink(string dialogTitle, LibraryFileLink fileLink)
		{
			using (var dialog = new SaveFileDialog())
			{
				dialog.Title = dialogTitle;
				dialog.InitialDirectory = MainController.Instance.Settings.SaveFilePath;
				dialog.FileName = fileLink.Name;
				dialog.OverwritePrompt = true;
				dialog.Filter = fileLink.Extension.Substring(1).ToUpper() + " Files|*" + fileLink.Extension;
				if (dialog.ShowDialog(MainController.Instance.MainForm) == DialogResult.OK)
				{
					var newFile = dialog.FileName;
					File.Copy(fileLink.FullPath, newFile, true);
					if (File.Exists(newFile))
					{
						if (MainController.Instance.PopupMessages.ShowWarningQuestion(
							String.Format("The file has been saved as\n{0}\nDo you want to open it?",
								newFile)
							) == DialogResult.Yes)
							Utils.OpenFile(newFile);
					}
					else
						MainController.Instance.PopupMessages.ShowWarning("File has not been saved successfully.");
				}
			}
		}
		public PowerPointLinkProcessor(LibraryFileLink fileLink)
			: base(fileLink)
		{
			_powerPointLink = (PowerPointLink)fileLink;
		}
		protected PreviewableFileLinkProcessor(LibraryFileLink fileLink)
		{
			_fileLink = fileLink;
		}
		protected DocumentLinkProcessor(LibraryFileLink fileLink) : base(fileLink) { }
		public ExcelLinkProcessor(LibraryFileLink fileLink) : base(fileLink) { }
		public FilePreviewShortcut(LibraryFileLink sourceFileLink)
		{
			SourceFileLink = sourceFileLink;
		}
Ejemplo n.º 15
0
		public void RemoveLink(LibraryFileLink fileLink)
		{
			EmailLinks.Remove(fileLink);
			Save();
			ListChanged?.Invoke(this, EventArgs.Empty);
		}
		public static DialogResult RunEmbedded(LibraryFileLink link, LibraryFolderLink parentLink, LinkSettingsType settingsType)
		{
			var dilogResult = DialogResult.Cancel;
			link.PerformTransaction(link.ParentLibrary.Context,
				linkCopy =>
				{
					using (var editForm = new FormEditLinkSettingsEmbedded(linkCopy, parentLink))
					{
						editForm.InitForm(settingsType);
						dilogResult = editForm.ShowDialog();
						if (dilogResult == DialogResult.OK)
							linkCopy.MarkAsModified();
						return dilogResult == DialogResult.OK;
					}
				},
				copyMethod => MainController.Instance.ProcessManager.Run("Preparing Data...", cancelationToken => copyMethod()),
				(context, original, current) => MainController.Instance.ProcessManager.Run("Saving Changes...",
					cancelationToken =>
					{
						current.BeforeSave();
						original.ApplyValues(current);
					}));
			return dilogResult;
		}
		public WordLinkProcessor(LibraryFileLink fileLink) : base(fileLink) { }
Ejemplo n.º 18
0
		public PdfLinkProcessor(LibraryFileLink fileLink) : base(fileLink) {}