Пример #1
0
		public LibraryDataView()
		{
			currentLibraryProvider = new LibraryProviderSelector();
			currentLibraryProvider.DataReloaded += LibraryDataReloaded;

			if (libraryDataViewInstance != null)
			{
				throw new Exception("There should only ever be one of these, Lars.");
			}
			libraryDataViewInstance = this;

			// set the display attributes
			{
				this.AnchorAll();
				this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
				this.ScrollArea.Padding = new BorderDouble(3, 3, 5, 3);
			}

			ScrollArea.HAnchor = HAnchor.ParentLeftRight;

			AutoScroll = true;
			topToBottomItemList = new FlowLayoutWidget(FlowDirection.TopToBottom);
			topToBottomItemList.HAnchor = HAnchor.ParentLeftRight;
			AddChild(topToBottomItemList);

			AddAllItems();
		}
		public LibraryRowItemPart(LibraryProvider libraryProvider, int itemIndex, LibraryDataView libraryDataView, GuiWidget thumbnailWidget)
			: base(libraryDataView, thumbnailWidget)
		{
			thumbnailWidth = thumbnailWidget.Width;
			var widget = thumbnailWidget as IClickable;
			if (widget != null)
			{
				widget.Click += onViewPartClick;
			}

			this.ItemName = libraryProvider.GetPrintItemName(itemIndex);
			if(this.ItemName == LibraryRowItem.LoadingPlaceholderToken)
			{
				this.ItemName = "Retrieving Contents...".Localize();
				this.IsViewHelperItem = true;
				this.EnableSlideInActions = false;
			}

			this.libraryProvider = libraryProvider;
			this.ItemIndex = itemIndex;

			CreateGuiElements();

			AddLoadingProgressBar();

            libraryProvider.RegisterForProgress(itemIndex, ReportProgressRatio);
		}
		public LibraryProviderQueue(PrintItemCollection baseLibraryCollection, LibraryProvider parentLibraryProvider)
			: base(parentLibraryProvider)
		{
			this.baseLibraryCollection = baseLibraryCollection;

			QueueData.Instance.ItemAdded.RegisterEvent((sender, e) => OnDataReloaded(null), ref unregisterEvent);
		}
		public LibraryProviderFileSystem(
			string rootPath, string name, 
			LibraryProvider parentLibraryProvider, 
			Action<LibraryProvider> setCurrentLibraryProvider,
			bool useIncrementedNameDuringTypeChange = false)
			: base(parentLibraryProvider, setCurrentLibraryProvider)
		{
			this.Name = name;
			this.rootPath = rootPath;

			// Indicates if the new AMF file should use the original file name incremented until no name collision occurs
			this.useIncrementedNameDuringTypeChange = useIncrementedNameDuringTypeChange;

			if (OsInformation.OperatingSystem == OSType.Windows)
			{
				directoryWatcher = new FileSystemWatcher();
				directoryWatcher.Path = rootPath;

				directoryWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
					   | NotifyFilters.FileName | NotifyFilters.DirectoryName;
				directoryWatcher.Changed += DiretoryContentsChanged;
				directoryWatcher.Created += DiretoryContentsChanged;
				directoryWatcher.Deleted += DiretoryContentsChanged;
				directoryWatcher.Renamed += DiretoryContentsChanged;

				// Begin watching.
				directoryWatcher.EnableRaisingEvents = true;
			}

			GetFilesAndCollectionsInCurrentDirectory();
		}
		public LibraryDataView()
		{
			// let the application controler know about this window so it can use it to switch library providers if it needs to.
			ApplicationController.Instance.CurrentLibraryDataView = this;

			currentLibraryProvider = new LibraryProviderSelector(SetCurrentLibraryProvider, false);
			currentLibraryProvider.DataReloaded += LibraryDataReloaded;

			if (libraryDataViewInstance != null)
			{
#if !__ANDROID__ // this is really just for debugging
				throw new Exception("There should only ever be one of these, Lars.");
#endif
			}
			libraryDataViewInstance = this;

			// set the display attributes
			{
				this.AnchorAll();
				this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
				this.ScrollArea.Padding = new BorderDouble(3);
			}

			ScrollArea.HAnchor = HAnchor.ParentLeftRight;

			AutoScroll = true;
			topToBottomItemList = new FlowLayoutWidget(FlowDirection.TopToBottom);
			topToBottomItemList.HAnchor = HAnchor.ParentLeftRight;
			AddChild(topToBottomItemList);

			AddAllItems();
		}
		public LibraryProviderSQLite(PrintItemCollection baseLibraryCollection, Action<LibraryProvider> setCurrentLibraryProvider, LibraryProvider parentLibraryProvider, string visibleName)
			: base(parentLibraryProvider, setCurrentLibraryProvider)
		{
			this.Name = visibleName;

			if (baseLibraryCollection == null)
			{
				baseLibraryCollection = GetRootLibraryCollection().Result;
			}

			this.baseLibraryCollection = baseLibraryCollection;
			LoadLibraryItems();

			sqliteDatabaseWatcher.Path = Path.GetDirectoryName(ApplicationDataStorage.Instance.DatastorePath);

			sqliteDatabaseWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
				   | NotifyFilters.FileName | NotifyFilters.DirectoryName;
			sqliteDatabaseWatcher.Changed += DatabaseFileChange;
			sqliteDatabaseWatcher.Created += DatabaseFileChange;
			sqliteDatabaseWatcher.Deleted += DatabaseFileChange;
			sqliteDatabaseWatcher.Renamed += DatabaseFileChange;

			// Begin watching.
			sqliteDatabaseWatcher.EnableRaisingEvents = true;
		}
		public LibraryRowItemCollection(PrintItemCollection collection, LibraryDataView libraryDataView, LibraryProvider parentProvider, GuiWidget thumbnailWidget)
			: base(libraryDataView, thumbnailWidget)
		{
			this.parentProvider = parentProvider;
			this.printItemCollection = collection;
			CreateGuiElements();
		}
		public virtual LibraryProvider CreateLibraryProvider(LibraryProvider parentLibraryProvider, Action<LibraryProvider> setCurrentLibraryProvider)
		{
			return new LibraryProviderFileSystem(
				rootPath, 
				Description, 
				parentLibraryProvider, 
				setCurrentLibraryProvider, 
				this.useIncrementedNameDuringTypeChange);
		}
		public LibraryProviderSQLite(PrintItemCollection baseLibraryCollection, LibraryProvider parentLibraryProvider)
			: base(parentLibraryProvider)
		{
			if (baseLibraryCollection == null)
			{
				baseLibraryCollection = GetRootLibraryCollection2(this);
			}

			this.baseLibraryCollection = baseLibraryCollection;
			LoadLibraryItems();
		}
		public LibraryRowItemCollection(PrintItemCollection collection, LibraryProvider currentProvider, int collectionIndex, LibraryDataView libraryDataView, LibraryProvider parentProvider, GuiWidget thumbnailWidget)
			: base(libraryDataView, thumbnailWidget)
		{
			this.currentProvider = currentProvider;
			this.CollectionIndex = collectionIndex;
			this.parentProvider = parentProvider;
			this.printItemCollection = collection;
			this.ItemName = printItemCollection.Name;

			CreateGuiElements();
		}
		public LibrarySelectorRowItem(PrintItemCollection collection, int collectionIndex, LibrarySelectorWidget libraryDataView, LibraryProvider parentProvider, GuiWidget thumbnailWidget)
		{
			this.thumbnailWidget = thumbnailWidget;
			this.libraryDataView = libraryDataView;

			this.CollectionIndex = collectionIndex;
			this.parentProvider = parentProvider;
			this.printItemCollection = collection;
			this.ItemName = printItemCollection.Name;

			CreateGuiElements();
		}
		public LibraryProviderSQLite(PrintItemCollection baseLibraryCollection, LibraryProvider parentLibraryProvider, string visibleName)
			: base(parentLibraryProvider)
		{
			this.visibleName = visibleName;

			if (baseLibraryCollection == null)
			{
				baseLibraryCollection = GetRootLibraryCollection2(this);
			}

			this.baseLibraryCollection = baseLibraryCollection;
			LoadLibraryItems();
		}
Пример #13
0
		public LibraryDataView()
		{
			// let the application controler know about this window so it can use it to switch library providers if it needs to.
			ApplicationController.Instance.CurrentLibraryDataView = this;

			currentLibraryProvider = new LibraryProviderSelector(SetCurrentLibraryProvider);
			currentLibraryProvider.DataReloaded += LibraryDataReloaded;

			if (libraryDataViewInstance != null)
			{
				throw new Exception("There should only ever be one of these, Lars.");
			}
			libraryDataViewInstance = this;

			// set the display attributes
			{
				this.AnchorAll();
				this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
				this.ScrollArea.Padding = new BorderDouble(3, 3, 5, 3);
			}

			ScrollArea.HAnchor = HAnchor.ParentLeftRight;

			AutoScroll = true;
			topToBottomItemList = new FlowLayoutWidget(FlowDirection.TopToBottom);
			topToBottomItemList.HAnchor = HAnchor.ParentLeftRight;
			AddChild(topToBottomItemList);

			AddAllItems();

			providerMessageWidget = new TextWidget("")
			{
				PointSize = 8,
				HAnchor = HAnchor.ParentRight,
				VAnchor = VAnchor.ParentBottom,
				TextColor = ActiveTheme.Instance.SecondaryTextColor,
				Margin = new BorderDouble(6),
				AutoExpandBoundsToText = true,
			};

			providerMessageContainer = new GuiWidget()
			{
				VAnchor = VAnchor.FitToChildren,
				HAnchor = HAnchor.ParentLeftRight,
				BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.SecondaryBackgroundColor, 220),
				Visible = false,
			};

			providerMessageContainer.AddChild(providerMessageWidget);
			this.AddChildToBackground(providerMessageContainer, -1);
		}
		public FolderBreadCrumbWidget(Action<LibraryProvider> SwitchToLibraryProvider, LibraryProvider currentLibraryProvider)
		{
			this.Name = "FolderBreadCrumbWidget";
			this.SwitchToLibraryProvider = SwitchToLibraryProvider;
			UiThread.RunOnIdle(() => SetBreadCrumbs(null, currentLibraryProvider));

			navigationButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
			navigationButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
			navigationButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
			navigationButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
			navigationButtonFactory.disabledFillColor = navigationButtonFactory.normalFillColor;
			navigationButtonFactory.Margin = new BorderDouble(10, 0);
			navigationButtonFactory.borderWidth = 0;
		}
		public LibraryProviderSQLite(PrintItemCollection baseLibraryCollection, Action<LibraryProvider> setCurrentLibraryProvider, LibraryProvider parentLibraryProvider, string visibleName)
			: base(parentLibraryProvider)
		{
			this.setCurrentLibraryProvider = setCurrentLibraryProvider;
			this.Name = visibleName;

			if (baseLibraryCollection == null)
			{
				baseLibraryCollection = GetRootLibraryCollection().Result;
			}

			this.baseLibraryCollection = baseLibraryCollection;
			LoadLibraryItems();
		}
		public LibraryProviderSQLite(PrintItemCollection baseLibraryCollection, Action<LibraryProvider> setCurrentLibraryProvider, LibraryProvider parentLibraryProvider, string visibleName)
			: base(parentLibraryProvider, setCurrentLibraryProvider)
		{
			this.Name = visibleName;

			if (baseLibraryCollection == null)
			{
				baseLibraryCollection = GetRootLibraryCollection().Result;
			}

			this.baseLibraryCollection = baseLibraryCollection;
			LoadLibraryItems();

			ItemAdded.RegisterEvent(DatabaseFileChange, ref unregisterEvents);
		}
		public LibraryProviderSQLite(PrintItemCollection callerSuppliedCollection, Action<LibraryProvider> setCurrentLibraryProvider, LibraryProvider parentLibraryProvider, string visibleName)
			: base(parentLibraryProvider, setCurrentLibraryProvider)
		{
			this.Name = visibleName;

			// Lock ensures that SQLite providers initialized near the same time from different threads (which has been observed during debug)
			// will run in a serial fashion and only one instance will construct and assign to .baseLibraryCollection
			lock (initializingLock) 
			{
				// Use null coalescing operator to assign either the caller supplied collection or if null, the root library collection
				this.baseLibraryCollection = callerSuppliedCollection ?? GetRootLibraryCollection();
			}

			LoadLibraryItems();

			ItemAdded.RegisterEvent(DatabaseFileChange, ref unregisterEvents);
		}
Пример #18
0
		public LibraryRowItemPart(LibraryProvider libraryProvider, int itemIndex, LibraryDataView libraryDataView, GuiWidget thumbnailWidget)
			: base(libraryDataView, thumbnailWidget)
		{
			thumbnailWidth = thumbnailWidget.Width;
			var widget = thumbnailWidget as IClickable;
			if (widget != null)
			{
				widget.Click += onViewPartClick;
			}

			this.ItemName = libraryProvider.GetPrintItemName(itemIndex);
			this.libraryProvider = libraryProvider;
			this.ItemIndex = itemIndex;

			CreateGuiElements();

			AddLoadingProgressBar();
		}
		public LibraryProviderFileSystem(string rootPath, string name, LibraryProvider parentLibraryProvider)
			: base(parentLibraryProvider)
		{
			this.Name = name;
			this.rootPath = rootPath;

			directoryWatcher.Path = rootPath;

			directoryWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
				   | NotifyFilters.FileName | NotifyFilters.DirectoryName;
			directoryWatcher.Changed += DiretoryContentsChanged;
			directoryWatcher.Created += DiretoryContentsChanged;
			directoryWatcher.Deleted += DiretoryContentsChanged;
			directoryWatcher.Renamed += DiretoryContentsChanged;

			// Begin watching.
			directoryWatcher.EnableRaisingEvents = true;

			GetFilesAndCollectionsInCurrentDirectory();
		}
		public LibraryRowItemCollection(PrintItemCollection collection, LibraryProvider currentProvider, int collectionIndex, LibraryDataView libraryDataView, LibraryProvider parentProvider, GuiWidget thumbnailWidget, string openButtonText)
			: base(libraryDataView, thumbnailWidget)
		{
			this.openButtonText = openButtonText;
			this.currentProvider = currentProvider;
			this.CollectionIndex = collectionIndex;
			this.parentProvider = parentProvider;
			this.printItemCollection = collection;
			this.ItemName = printItemCollection.Name;

			this.Name = this.ItemName + " Row Item Collection";

			if (collection.Key == LibraryRowItem.LoadingPlaceholderToken)
			{
				this.EnableSlideInActions = false;
				this.IsViewHelperItem = true;
			}

			CreateGuiElements();
		}
		public LibrarySelectorWidget(bool includeQueueLibraryProvider)
		{
			currentLibraryProvider = new LibraryProviderSelector(SetCurrentLibraryProvider, includeQueueLibraryProvider);
			currentLibraryProvider.DataReloaded += LibraryDataReloaded;

			// set the display attributes
			{
				this.AnchorAll();
				this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
				this.ScrollArea.Padding = new BorderDouble(3);
			}

			ScrollArea.HAnchor = HAnchor.ParentLeftRight;

			AutoScroll = true;
			topToBottomItemList = new FlowLayoutWidget(FlowDirection.TopToBottom);
			topToBottomItemList.HAnchor = HAnchor.ParentLeftRight;
			AddChild(topToBottomItemList);

			AddAllItems();
		}
		public virtual LibraryProvider CreateLibraryProvider(LibraryProvider parentLibraryProvider, Action<LibraryProvider> setCurrentLibraryProvider)
		{
			throw new NotImplementedException();
		}
Пример #23
0
 public LibraryProviderHistory(PrintItemCollection baseLibraryCollection, LibraryProvider parentLibraryProvider)
     : base(parentLibraryProvider)
 {
     //PrintHistoryData.Instance.ItemAdded.RegisterEvent((sender, e) => OnDataReloaded(null), ref unregisterEvent);
     this.Name = "Print History";
 }
        public override PrintItemCollection GetCollectionItem(int collectionIndex)
        {
            LibraryProvider provider = libraryCreators[collectionIndex].CreateLibraryProvider(this, setCurrentLibraryProvider);

            return(new PrintItemCollection(provider.Name, provider.ProviderKey));
        }
		private void LibraryProviderChanged(LibraryProvider previousLibraryProvider, LibraryProvider currentLibraryProvider)
		{
			if (currentLibraryProvider.IsProtected())
			{
				addToLibraryButton.Enabled = false;
				createFolderButton.Enabled = false;
				DoLeaveEditMode();
			}
			else
			{
				addToLibraryButton.Enabled = true;
				createFolderButton.Enabled = true;
			}

			if (previousLibraryProvider != null)
			{
				previousLibraryProvider.KeywordFilter = "";
				previousLibraryProvider.DataReloaded -= UpdateStatus;
			}

			searchInput.Text = currentLibraryProvider.KeywordFilter;
			breadCrumbWidget.SetBreadCrumbs(null, this.libraryDataView.CurrentLibraryProvider);

			currentLibraryProvider.DataReloaded += UpdateStatus;

			UpdateStatus(null, null);
		}
		public LibraryDataViewEventArgs(LibraryProvider libraryProvider)
		{
			this.LibraryProvider = libraryProvider;
		}
        public LibraryProviderSQLite(PrintItemCollection baseLibraryCollection, Action <LibraryProvider> setCurrentLibraryProvider, LibraryProvider parentLibraryProvider, string visibleName)
            : base(parentLibraryProvider)
        {
            this.setCurrentLibraryProvider = setCurrentLibraryProvider;
            this.Name = visibleName;

            if (baseLibraryCollection == null)
            {
                baseLibraryCollection = GetRootLibraryCollection().Result;
            }

            this.baseLibraryCollection = baseLibraryCollection;
            LoadLibraryItems();
        }
Пример #28
0
		private void ClearSearchWidget(LibraryProvider previousLibraryProvider, LibraryProvider currentLibraryProvider)
		{
			previousLibraryProvider.KeywordFilter = "";
			searchInput.Text = "";
		}
		public virtual LibraryProvider CreateLibraryProvider(LibraryProvider parentLibraryProvider, Action<LibraryProvider> setCurrentLibraryProvider)
		{
			return new LibraryProviderHistory(null, parentLibraryProvider, setCurrentLibraryProvider);
		}
Пример #30
0
 public LibraryProviderQueue(PrintItemCollection baseLibraryCollection, Action <LibraryProvider> setCurrentLibraryProvider, LibraryProvider parentLibraryProvider)
     : base(parentLibraryProvider, setCurrentLibraryProvider)
 {
     QueueData.Instance.ItemAdded.RegisterEvent((sender, e) => OnDataReloaded(null), ref unregisterEvent);
     this.Name = "Print Queue";
 }
Пример #31
0
 public virtual LibraryProvider CreateLibraryProvider(LibraryProvider parentLibraryProvider, Action <LibraryProvider> setCurrentLibraryProvider)
 {
     return(new LibraryProviderQueue(null, setCurrentLibraryProvider, parentLibraryProvider));
 }
Пример #32
0
 public virtual LibraryProvider CreateLibraryProvider(LibraryProvider parentLibraryProvider, Action <LibraryProvider> setCurrentLibraryProvider)
 {
     throw new NotImplementedException();
 }
Пример #33
0
        public LibraryProviderSQLite(PrintItemCollection callerSuppliedCollection, Action <LibraryProvider> setCurrentLibraryProvider, LibraryProvider parentLibraryProvider, string visibleName)
            : base(parentLibraryProvider, setCurrentLibraryProvider)
        {
            this.Name = visibleName;

            // Lock ensures that SQLite providers initialized near the same time from different threads (which has been observed during debug)
            // will run in a serial fashion and only one instance will construct and assign to .baseLibraryCollection
            lock (initializingLock)
            {
                // Use null coalescing operator to assign either the caller supplied collection or if null, the root library collection
                this.baseLibraryCollection = callerSuppliedCollection ?? GetRootLibraryCollection();
            }

            LoadLibraryItems();

            ItemAdded.RegisterEvent(DatabaseFileChange, ref unregisterEvents);
        }
 public virtual LibraryProvider CreateLibraryProvider(LibraryProvider parentLibraryProvider, Action <LibraryProvider> setCurrentLibraryProvider)
 {
     return(new LibraryProviderSQLite(null, setCurrentLibraryProvider, parentLibraryProvider, "Local Library"));
 }
		public virtual LibraryProvider CreateLibraryProvider(LibraryProvider parentLibraryProvider)
		{
			return new LibraryProviderQueue(null, parentLibraryProvider);
		}
Пример #36
0
        public override PrintItemCollection GetCollectionItem(int collectionIndex)
        {
            LibraryProvider provider = libraryProviders[collectionIndex];

            return(new PrintItemCollection(provider.Name, provider.ProviderKey));
        }
Пример #37
0
 public LibraryProvider(LibraryProvider parentLibraryProvider, Action <LibraryProvider> setCurrentLibraryProvider)
 {
     this.SetCurrentLibraryProvider = setCurrentLibraryProvider;
     this.parentLibraryProvider     = parentLibraryProvider;
 }
Пример #38
0
		public void SetCurrentLibraryProvider(LibraryProvider libraryProvider)
		{
			this.CurrentLibraryProvider = libraryProvider;
		}
		public LibraryProviderHistory(PrintItemCollection baseLibraryCollection, LibraryProvider parentLibraryProvider, Action<LibraryProvider> setCurrentLibraryProvider)
			: base(parentLibraryProvider, setCurrentLibraryProvider)
		{
			//PrintHistoryData.Instance.ItemAdded.RegisterEvent((sender, e) => OnDataReloaded(null), ref unregisterEvent);
			this.Name = "Print History";
		}
Пример #40
0
		protected GuiWidget GetThumbnailWidget(LibraryProvider parentProvider, PrintItemCollection printItemCollection, ImageBuffer imageBuffer)
		{
			Vector2 expectedSize = new Vector2((int)(50 * TextWidget.GlobalPointSizeScaleRatio), (int)(50 * TextWidget.GlobalPointSizeScaleRatio));
			if (imageBuffer.Width != expectedSize.x)
			{
				ImageBuffer scaledImageBuffer = new ImageBuffer((int)expectedSize.x, (int)expectedSize.y, 32, new BlenderBGRA());
				scaledImageBuffer.NewGraphics2D().Render(imageBuffer, 0, 0, scaledImageBuffer.Width, scaledImageBuffer.Height);
				imageBuffer = scaledImageBuffer;
			}

			ImageWidget folderThumbnail = new ImageWidget(imageBuffer);
			folderThumbnail.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;

			Button clickThumbnail = new Button(0, 0, folderThumbnail);
			clickThumbnail.Cursor = Cursors.Hand;

			clickThumbnail.Click += (sender, e) =>
			{
				if (parentProvider == null)
				{
					this.CurrentLibraryProvider = this.CurrentLibraryProvider.GetProviderForCollection(printItemCollection);
				}
				else
				{
					this.CurrentLibraryProvider = parentProvider;
				}
			};

			return clickThumbnail;
		}
 public virtual LibraryProvider CreateLibraryProvider(LibraryProvider parentLibraryProvider, Action <LibraryProvider> setCurrentLibraryProvider)
 {
     return(new LibraryProviderFileSystem(rootPath, Description, parentLibraryProvider, setCurrentLibraryProvider));
 }
Пример #42
0
 public LibraryProvider(LibraryProvider parentLibraryProvider)
 {
     this.parentLibraryProvider = parentLibraryProvider;
 }