| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.WPF;
- using Color = System.Drawing.Color;
- namespace PRSDesktop
- {
- public partial class JobDocumentSetPanel : UserControl, IJobControl, IDataModelSource, IPanel<Job>
- {
- public Guid JobID { get; set; }
- public JobDocumentSetPanel()
- {
- InitializeComponent();
- // Dictionary<String, BitmapImage> images = new Dictionary<string, BitmapImage>()
- // {
- // { "Sample", PRSDesktop.Resources.localfile.AsBitmapImage() },
- // { "Another File", PRSDesktop.Resources.tick.AsBitmapImage() }
- // };
- // preview.ItemsSource = images;
- }
- public string SectionName => "Job Document Set";
- public DataModel DataModel(Selection selection)
- {
- var ids = Documents.Data != null ? Documents.Data.ExtractValues<JobDocumentSet, Guid>(x => x.ID).ToArray() : new Guid[] { };
- return new AutoDataModel<JobDocumentSet>(new Filter<JobDocumentSet>(x => x.ID).InList(ids));
- }
- public event DataModelUpdateEvent OnUpdateDataModel;
-
- public void Setup()
- {
- }
- public void Shutdown()
- {
- }
- public void Refresh()
- {
- Folders.JobID = this.JobID;
- Documents.JobID = this.JobID;
- Folders.Refresh();
- Documents.Refresh();
- }
- public bool IsReady { get; set; }
- public void CreateToolbarButtons(IPanelHost host)
- {
- // Check In
- // Check Out
- // Issue
- }
- public Dictionary<string, object[]> Selected()
- {
- return new Dictionary<string, object[]>();
- }
- public void Heartbeat(TimeSpan time)
- {
-
- }
- private Guid _folderid = Guid.Empty;
-
- private void Folders_OnOnSelectItem(DynamicTreeNode node)
- {
- _folderid = node != null ? node.ID : Guid.Empty;
- Documents.FolderID = _folderid;
- Documents.Refresh();
- }
- private void DynamicSplitPanel_OnOnChanged(object sender, DynamicSplitPanelChangedArgs e)
- {
- if (e.View == DynamicSplitPanelView.Detail)
- Documents.FolderID = Guid.Empty;
- else
- Documents.FolderID = _folderid;
- Documents.Refresh();
- }
- private void Preview_OnSizeChanged(object sender, SizeChangedEventArgs e)
- {
- //throw new NotImplementedException();
- }
- private void Documents_OnMileStoneSelected(JobDocumentSetMileStoneBlock block)
- {
- if (block != null && block.Attachments > 0)
- {
- var id = block.ID;
- var files = new Client<JobDocumentSetMileStoneFile>().Query(
- new Filter<JobDocumentSetMileStoneFile>(x => x.EntityLink.ID).IsEqualTo(block.ID),
- new Columns<JobDocumentSetMileStoneFile>(x => x.ID)
- .Add(x => x.DocumentLink.FileName)
- .Add(x => x.Thumbnail),
- new SortOrder<JobDocumentSetMileStoneFile>(x => x.DocumentLink.FileName)
- );
- preview.ItemsSource = files.Rows
- .Select(r =>
- new Tuple<Guid, String, BitmapImage>(
- r.Get<JobDocumentSetMileStoneFile, Guid>(c => c.ID),
- r.Get<JobDocumentSetMileStoneFile, String>(c => c.DocumentLink.FileName),
- r.Get<JobDocumentSetMileStoneFile,byte[]>(c=>c.Thumbnail) != null
- ? String.IsNullOrWhiteSpace(block.Watermark)
- ? ImageUtils.LoadImage(r.Get<JobDocumentSetMileStoneFile, byte[]>(c => c.Thumbnail))
- : ImageUtils.LoadImage(r.Get<JobDocumentSetMileStoneFile, byte[]>(c => c.Thumbnail))
- .AsBitmap().WatermarkImage(block.Watermark,Color.LightSalmon)
- .AsBitmapImage()
- : ImageUtils.BitmapFromColor(Color.White,256, 192, Color.Transparent)
- .WatermarkImage("No Preview\nAvailable", Color.LightGray).AsBitmapImage()
- )
- ).ToList();
- }
- else
- preview.ItemsSource = new List<Tuple<Guid, String, BitmapImage>>();
-
- }
- }
- }
|