Exemple #1
0
        void AddPartToQueue(object state)
        {
            PartToAddToQueue partToAddToQueue = (PartToAddToQueue)state;
            PrintQueueItem   queueItem        = new PrintQueueItem(partToAddToQueue.Name, partToAddToQueue.FileLocation);

            PrintQueueControl.Instance.AddChild(queueItem, partToAddToQueue.insertAfterIndex);
        }
Exemple #2
0
        void RemoveIndexAfterEvent(object state)
        {
            RemoveIndexArgs removeArgs = state as RemoveIndexArgs;

            if (removeArgs != null & removeArgs.index >= 0 && removeArgs.index < Count)
            {
                int currentIndex = removeArgs.index;

                //If the item to be removed is the active print item, set the active print item to null.
                GuiWidget      itemHolder = topToBottomItemList.Children[currentIndex];
                PrintQueueItem child      = (PrintQueueItem)itemHolder.Children[0];
                if (child.isActivePrint)
                {
                    if (PrinterCommunication.Instance.PrinterIsPrinting)
                    {
                        return;
                    }
                    PrinterCommunication.Instance.ActivePrintItem = null;
                }
                RemoveChild(currentIndex);
                SelectedIndex = System.Math.Min(SelectedIndex, Count - 1);

                SaveDefaultQueue();
            }
        }
Exemple #3
0
 public void MoveSelectedToBottom()
 {
     if (SelectedIndex >= 0 && SelectedIndex < Count)
     {
         int            currentIndex    = SelectedIndex;
         PrintQueueItem replacementItem = new PrintQueueItem(PrintQueueControl.Instance.SelectedPart.Name, PrintQueueControl.Instance.SelectedPart.FileLocation);
         this.RemoveChild(SelectedIndex);
         this.AddChild(replacementItem);
         this.SelectedIndex = currentIndex;
     }
 }
Exemple #4
0
        public PrintQueueItem GetPrintQueueItem(int index)
        {
            if (index >= 0 && index < topToBottomItemList.Children.Count)
            {
                GuiWidget      itemHolder = topToBottomItemList.Children[index];
                PrintQueueItem child      = (PrintQueueItem)itemHolder.Children[0];

                return(child);
            }

            return(null);
        }
Exemple #5
0
        public int GetIndex(PrintItemWrapper printItem)
        {
            for (int i = 0; i < topToBottomItemList.Children.Count; i++)
            {
                PrintQueueItem queueItem = GetPrintQueueItem(i);
                if (queueItem != null && queueItem.PrintItemWrapper == printItem)
                {
                    return(i);
                }
            }

            return(-1);
        }
Exemple #6
0
        public string[] GetItemNames()
        {
            List <string> itemNames = new List <string>();;

            for (int i = 0; i < topToBottomItemList.Children.Count; i++)
            {
                PrintQueueItem queueItem = GetPrintQueueItem(i);
                if (queueItem != null)
                {
                    itemNames.Add(queueItem.PrintItemWrapper.Name);
                }
            }

            return(itemNames.ToArray());
        }
Exemple #7
0
        public override void OnDragDrop(FileDropEventArgs fileDropEventArgs)
        {
            foreach (string droppedFileName in fileDropEventArgs.DroppedFiles)
            {
                string extension = Path.GetExtension(droppedFileName).ToUpper();
                if (extension == ".STL" || extension == ".GCODE")
                {
                    PrintQueueItem queueItem = new PrintQueueItem(System.IO.Path.GetFileNameWithoutExtension(droppedFileName), System.IO.Path.GetFullPath(droppedFileName));
                    PrintQueueControl.Instance.AddChild(queueItem);
                }
                PrintQueueControl.Instance.EnsureSelection();
                PrintQueueControl.Instance.Invalidate();
            }
            PrintQueueControl.Instance.SaveDefaultQueue();

            base.OnDragDrop(fileDropEventArgs);
        }
Exemple #8
0
        public ExportQueueItemWindow(PrintQueue.PrintQueueItem printQueueItem)
            : base(400, 250)
        {
            if (Path.GetExtension(printQueueItem.PrintItemWrapper.FileLocation).ToUpper() == ".GCODE")
            {
                partIsGCode = true;
            }

            string McExportFileTitleBeg  = new LocalizedString("MatterControl").Translated;
            string McExportFileTitleEnd  = new LocalizedString("Export File").Translated;
            string McExportFileTitleFull = string.Format("{0}: {1}", McExportFileTitleBeg, McExportFileTitleEnd);

            this.Title           = McExportFileTitleFull;
            this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            // TODO: Complete member initialization
            this.printQueueItem = printQueueItem;

            doLayout();
            ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(reloadAfterPrinterProfileChanged, ref unregisterEvents);
        }
        public ExportQueueItemWindow(PrintQueue.PrintQueueItem printQueueItem)
            : base(400, 250)
        {
            if (Path.GetExtension(printQueueItem.PrintItemWrapper.FileLocation).ToUpper() == ".GCODE")
            {
                partIsGCode = true;
            }

			string McExportFileTitleBeg = new LocalizedString("MatterControl").Translated;
			string McExportFileTitleEnd = new LocalizedString("Export File").Translated;
			string McExportFileTitleFull = string.Format("{0}: {1}", McExportFileTitleBeg, McExportFileTitleEnd); 

			this.Title = McExportFileTitleFull;
            this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            
            // TODO: Complete member initialization
            this.printQueueItem = printQueueItem;

            doLayout();
            ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(reloadAfterPrinterProfileChanged, ref unregisterEvents);
        }
Exemple #10
0
        void LoadFileOnIdle(object state)
        {
            OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true);

            openParams.ActionButtonLabel = "Add to Queue";
            openParams.Title             = "MatterControl: Select A File";

            FileDialog.OpenFileDialog(ref openParams);
            if (openParams.FileNames != null)
            {
                foreach (string loadedFileName in openParams.FileNames)
                {
                    PrintQueueItem queueItem = new PrintQueueItem(System.IO.Path.GetFileNameWithoutExtension(loadedFileName), System.IO.Path.GetFullPath(loadedFileName));
                    PrintQueueControl.Instance.AddChild(queueItem);
                }
                if (PrintQueueControl.Instance.Count > 0)
                {
                    PrintQueueControl.Instance.SelectedIndex = PrintQueueControl.Instance.Count - 1;
                }
                //PrintQueueControl.Instance.EnsureSelection();
                PrintQueueControl.Instance.Invalidate();
            }
            PrintQueueControl.Instance.SaveDefaultQueue();
        }
        void LoadFileOnIdle(object state)
        {
            OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true);
			openParams.ActionButtonLabel = "Add to Queue";
			openParams.Title = "MatterControl: Select A File";

            FileDialog.OpenFileDialog(ref openParams);
            if (openParams.FileNames != null)
            {
                foreach (string loadedFileName in openParams.FileNames)
                {
					PrintQueueItem queueItem = new PrintQueueItem(System.IO.Path.GetFileNameWithoutExtension(loadedFileName), System.IO.Path.GetFullPath(loadedFileName));
					PrintQueueControl.Instance.AddChild(queueItem);
                }
                if (PrintQueueControl.Instance.Count > 0)
                {
                    PrintQueueControl.Instance.SelectedIndex = PrintQueueControl.Instance.Count - 1;
                }
                //PrintQueueControl.Instance.EnsureSelection();
                PrintQueueControl.Instance.Invalidate();
            }
            PrintQueueControl.Instance.SaveDefaultQueue();
        }
        public override void OnDragDrop(FileDropEventArgs fileDropEventArgs)
        {
            foreach (string droppedFileName in fileDropEventArgs.DroppedFiles)
            {
                string extension = Path.GetExtension(droppedFileName).ToUpper();
                if (extension == ".STL" || extension == ".GCODE")
                {
                    PrintQueueItem queueItem = new PrintQueueItem(System.IO.Path.GetFileNameWithoutExtension(droppedFileName), System.IO.Path.GetFullPath(droppedFileName));
                    PrintQueueControl.Instance.AddChild(queueItem);
                }
                PrintQueueControl.Instance.EnsureSelection();
                PrintQueueControl.Instance.Invalidate();
            }
            PrintQueueControl.Instance.SaveDefaultQueue();

            base.OnDragDrop(fileDropEventArgs);
        }
 void AddPartToQueue(object state)
 {
     PartToAddToQueue partToAddToQueue = (PartToAddToQueue)state;
     PrintQueueItem queueItem = new PrintQueueItem(partToAddToQueue.Name, partToAddToQueue.FileLocation);
     PrintQueueControl.Instance.AddChild(queueItem, partToAddToQueue.insertAfterIndex);
 }
        public PrintLibraryListItem(PrintItemWrapper printItem)
        {
            this.printItem = printItem;
            linkButtonFactory.fontSize = 10;
            linkButtonFactory.textColor = RGBA_Bytes.White;

            WidgetTextColor = RGBA_Bytes.Black;
            WidgetBackgroundColor = RGBA_Bytes.White;

            TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

            SetDisplayAttributes();

            FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
            mainContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
            {
                GuiWidget selectionCheckBoxContainer = new GuiWidget();
                selectionCheckBoxContainer.VAnchor = VAnchor.Max_FitToChildren_ParentHeight;
                selectionCheckBoxContainer.HAnchor = Agg.UI.HAnchor.FitToChildren;
                selectionCheckBoxContainer.Margin = new BorderDouble(left: 6);
                selectionCheckBox = new CheckBox("");
                selectionCheckBox.VAnchor = VAnchor.ParentCenter;
                selectionCheckBox.HAnchor = HAnchor.ParentCenter;
                selectionCheckBoxContainer.AddChild(selectionCheckBox);
                
                FlowLayoutWidget leftColumn = new FlowLayoutWidget(FlowDirection.TopToBottom);
                leftColumn.VAnchor |= VAnchor.ParentTop;


                FlowLayoutWidget middleColumn = new FlowLayoutWidget(FlowDirection.TopToBottom);
                middleColumn.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                middleColumn.VAnchor = Agg.UI.VAnchor.ParentBottomTop;
                middleColumn.Padding = new BorderDouble(0,6);
                middleColumn.Margin = new BorderDouble(10,0);
                {
                    string labelName = textInfo.ToTitleCase(printItem.Name);
                    labelName = labelName.Replace('_', ' ');
                    partLabel = new TextWidget(labelName, pointSize: 12);
                    partLabel.TextColor = WidgetTextColor;
                    partLabel.MinimumSize = new Vector2(1, 16);
                    middleColumn.AddChild(partLabel);
                }

                FlowLayoutWidget rightColumn = new FlowLayoutWidget(FlowDirection.TopToBottom);
                rightColumn.VAnchor = Agg.UI.VAnchor.ParentBottomTop;                

                buttonContainer = new FlowLayoutWidget();
                buttonContainer.Margin = new BorderDouble(0,6);
                buttonContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; 
                {
					addToQueueLink = linkButtonFactory.Generate(new LocalizedString("Add to Queue").Translated);
                    addToQueueLink.Margin = new BorderDouble(left: 0, right: 10);
                    addToQueueLink.VAnchor = VAnchor.ParentCenter;

                    addToQueueLink.Click += (sender, e) =>
                    {
                        PrintQueueItem queueItem = new PrintQueueItem(this.printItem.Name, this.printItem.FileLocation);
                        PrintQueueControl.Instance.AddChild(queueItem);
                    };

					viewLink = linkButtonFactory.Generate(new LocalizedString("View").Translated);
                    viewLink.Margin = new BorderDouble(left: 0, right:10);
                    viewLink.VAnchor = VAnchor.ParentCenter;                    

					exportLink = linkButtonFactory.Generate(new LocalizedString("Export").Translated);
                    exportLink.Margin = new BorderDouble(left: 0, right: 10);
                    exportLink.VAnchor = VAnchor.ParentCenter;

                    exportLink.Click += (sender, e) =>
                    {
						OpenExportWindow();
                    };

					removeLink = linkButtonFactory.Generate(new LocalizedString("Remove").Translated);
                    removeLink.Margin = new BorderDouble(left: 10, right: 10);
                    removeLink.VAnchor = VAnchor.ParentCenter;

                    buttonContainer.AddChild(addToQueueLink);
                    buttonContainer.AddChild(viewLink);
                    buttonContainer.AddChild(exportLink);
                    buttonContainer.AddChild(removeLink);
                }
                middleColumn.AddChild(buttonContainer);
                //rightColumn.AddChild(buttonContainer);

                mainContainer.AddChild(selectionCheckBoxContainer);
                {
                    PartThumbnailWidget thumbnailWidget = new PartThumbnailWidget(printItem, "part_icon_transparent_40x40.png", "building_thumbnail_40x40.png", new Vector2(50, 50));                    
                    mainContainer.AddChild(thumbnailWidget);
                }
                mainContainer.AddChild(leftColumn);
                mainContainer.AddChild(middleColumn);                
                mainContainer.AddChild(rightColumn);
            }
            this.AddChild(mainContainer);
            AddHandlers();
        }
        void AddButtonOnIdle(object state)
        {
            OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file|*.stl", multiSelect: true);

            FileDialog.OpenFileDialog(ref openParams);
            if (openParams.FileNames != null)
            {
                foreach (string loadedFileName in openParams.FileNames)
                {
                    PrintQueueItem queueItem = new PrintQueueItem(System.IO.Path.GetFileNameWithoutExtension(loadedFileName), System.IO.Path.GetFullPath(loadedFileName));
                    PrintQueueControl.Instance.AddChild(queueItem);
                }
                
                PrintQueueControl.Instance.EnsureSelection();
                PrintQueueControl.Instance.Invalidate();
            }
            PrintQueueControl.Instance.SaveDefaultQueue();
        }
 public void MoveSelectedToBottom()
 {
     if (SelectedIndex >= 0 && SelectedIndex < Count)
     {
         int currentIndex = SelectedIndex;
         PrintQueueItem replacementItem = new PrintQueueItem(PrintQueueControl.Instance.SelectedPart.Name, PrintQueueControl.Instance.SelectedPart.FileLocation);
         this.RemoveChild(SelectedIndex);
         this.AddChild(replacementItem);
         this.SelectedIndex = currentIndex;
     }
 }