예제 #1
0
        public ImportWindow(USBDrive drive) : base(WindowType.Toplevel)
        {
            Drive = drive;
            store = new TreeStore(typeof(AudioFile));

            Build();
            CreateNodeView();
            CreateCompletionEntry();
        }
예제 #2
0
        public static BindingList <USBDrive> GetUSBDrives()
        {
            var drives = new BindingList <USBDrive>();


            try
            {
                foreach (
                    ManagementObject drive in
                    new ManagementObjectSearcher("select * from Win32_DiskDrive where InterfaceType='USB'").Get()
                    .AsParallel())
                {
                    try
                    {
                        int Disk      = Convert.ToInt16(drive.GetPropertyValue("Index"));
                        var Partition = -1;

                        var DriveLetter = "None";
                        var Label       = string.Empty;
                        var FileSystem  = string.Empty;
                        var Status      = drive.GetPropertyValue("Status").ToString();
                        var Model       = drive.GetPropertyValue("Model").ToString();

                        var driveSize = drive.GetPropertyValue("Size");

                        if (driveSize == null)
                        {
                            continue;
                        }

                        var  DriveSize      = long.Parse(driveSize.ToString());
                        var  Bootable       = false;
                        long free           = 0;
                        long size           = 0;
                        var  record         = IOCtl.SendIoCtlDiskGetDriveLayoutEx(Disk);
                        var  partitionCount = 0;
                        if (Convert.ToInt32(drive.GetPropertyValue("Partitions")) > 0)
                        {
                            foreach (ManagementObject partition in drive.GetRelated("Win32_DiskPartition"))
                            {
                                partitionCount++;
                                Partition = Convert.ToInt16(partition.GetPropertyValue("Index")) + 1;
                                Bootable  = Convert.ToBoolean(partition.GetPropertyValue("Bootable").ToString());

                                var LargerThan32GB = false;

                                foreach (ManagementObject logical in partition.GetRelated("Win32_LogicalDisk"))
                                {
                                    DriveLetter = logical.GetPropertyValue("Name").ToString();
                                    try
                                    {
                                        Label = logical.GetPropertyValue("VolumeName").ToString();
                                    }
                                    catch
                                    {
                                    }

                                    try
                                    {
                                        FileSystem = logical.GetPropertyValue("FileSystem").ToString();
                                        free       = long.Parse(logical.GetPropertyValue("FreeSpace").ToString());
                                        size       = long.Parse(logical.GetPropertyValue("Size").ToString());
                                    }
                                    catch
                                    {
                                        FileSystem = "RAW";
                                        size       = long.Parse(drive.GetPropertyValue("Size").ToString());
                                    }
                                }
                            }
                        }
                        else
                        {
                            size  = long.Parse(drive.GetPropertyValue("Size").ToString());
                            Label = "None";
                        }


                        if (partitionCount > 1)
                        {
                            record = BootRecord.Hybrid;
                        }
                        var newUSB = new USBDrive(Model, DriveLetter, Disk, Partition, Label, FileSystem, DriveSize,
                                                  size, free, Bootable, Status, record);
                        drives.Add(newUSB);
                    }
                    catch
                    {
                    }
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message, "Error");
                //cMain.UpdateToolStripLabel(lblStatus, "Error scanning for USB drives ...");
                //cMain.ErrorBox("Win Toolkit encountered an error whilst scanning for USB devices.", "USB Scan Error", Ex.Message);
                //cMain.WriteLog(this, "Error scanning for USB", Ex.Message, lblStatus.Text);
            }

            return(drives);
        }
예제 #3
0
        private List <string> fuelSystemAcc;                         //A list of all the Accessories that are not considered fuel-related

        public Form1()
        {
            this_year = DateTime.Today.Year.ToString();

            #region List Initialization

            //Initialize and fill up our pNameList variable
            pNameList = new List <string>()
            {
                "Magneto",
                "Wastegate",
                "Turbo",
                "Prop Governor",
                "Starter Adapter",
                "Controller",
                "Fuel Pump",
                "Manifold Valve",
                "Control Valve",
                "Flow Divider",
                "Fuel Servo",
                "Relief Valve",
                "Carburetor",
                "Pressure Regulator"
            };



            //Initialize and fill up our processList variable
            processList = new List <string>()
            {
                "O/H",
                "500 Hour",
                "IRAN",
                "Repair",
                "Test"
            };


            //Initialize and fill up our fuelSystemAcc variable
            fuelSystemAcc = new List <string>()
            {
                "Fuel Pump",
                "Manifold Valve",
                "Control Valve",
                "Fuel Servo",
                "Relief Valve",
                "Carburetor",
                "Pressure Regulator"
            };

            #endregion

            usbStick       = USBDrive.GetSticks("WOUSB" + this_year);
            excel_app      = new Excel.Application();
            basefilepath   = usbStick.ToArray()[0].Name + @"\Users\mike\Desktop";
            customerDBfile = basefilepath + @"\Customer Information.xlsx";
            excelWOPath    = basefilepath + @"\Work Order " + this_year + ".xlsx";

            MessageBox.Show(usbStick.ToString() + "\n" + basefilepath);

            //Set up our lists
            _accList   = new List <Accessory>();                //This list will be used both for editing a Work Order as well as creating a new Work Order
            _curWOList = new List <WorkOrderFile>();            //This list will contain data from Work Orders <year>

            //Set up our AddCustomer panel
            _addPanel                    = new AddCustomer();
            addCustPanel                 = _addPanel.Add_Customer_Panel;
            _addPanel.excel_app          = excel_app;
            addCustPanel.VisibleChanged += new EventHandler(AddCustVisChange);

            //Set up our EditCustomer panel
            _editPanel                    = new EditCustomer();
            editCustPanel                 = _editPanel.Edit_Customer_Panel;
            _editPanel.excel_app          = excel_app;
            editCustPanel.VisibleChanged += new EventHandler(EditCustVisChange);

            //Set up our EditWorkOrders panel
            _editWOPanel                = new EditWorkOrder();
            editWOPanel                 = _editWOPanel.Edit_Work_Order_Panel;
            _editWOPanel.excel_app      = excel_app;
            _editWOPanel._curWOList     = _curWOList;
            _editWOPanel._accList       = _accList;
            _editWOPanel.pNameList      = pNameList;
            _editWOPanel.processList    = processList;
            _editWOPanel.fuelSystemAcc  = fuelSystemAcc;
            _editWOPanel.basefilepath   = basefilepath;
            _editWOPanel.excelWOPath    = excelWOPath;
            _editWOPanel.This_Year      = this_year;
            editWOPanel.VisibleChanged += new EventHandler(EditWOVisCHange);

            //Set up our CreateWorkOrders panel
            _cWorkOrder               = new CreateWorkOrder(excel_app, basefilepath);
            cWOPanel                  = _cWorkOrder.Create_Work_Order_Panel;
            _cWorkOrder.excel_app     = excel_app;
            _cWorkOrder._curWOList    = _curWOList;
            _cWorkOrder._accList      = _accList;
            _cWorkOrder.pNameList     = pNameList;
            _cWorkOrder.processList   = processList;
            _cWorkOrder.basefilepath  = basefilepath;
            _cWorkOrder.fuelSystemAcc = fuelSystemAcc;
            _cWorkOrder.excelWOPath   = excelWOPath;
            _cWorkOrder.This_Year     = this_year;
            cWOPanel.VisibleChanged  += new EventHandler(CreateWOVisChange);

            mainPanel = CreatePanel();

            mainPanel.Controls.Add(new Label()
            {
                Location = new Point(70, 20),
                AutoSize = true,
                Font     = new Font("Verdana", 16.0f, FontStyle.Bold),
                Text     = "This Year:"
            });

            mainPanel.Controls.Add(new Label()
            {
                Size     = new Size(465, 38),
                Font     = new Font("Verdana", 24.0f, FontStyle.Bold),
                Location = new Point(168, 54),
                Text     = "What do you need to do?"
            });                                                                                                     //Add our main label to our mainPanel control
            TextBox year_box = new TextBox()
            {
                Size     = new Size(183, 20),
                Location = new Point(264, 25),
                Name     = "ThisYearBox",
                Text     = this_year
            };
            year_box.KeyUp += (sender2, e2) => YearBoxTextChanged(sender2, e2, year_box.Text);

            addCust          = MainPanelButton("Add Customer", new Point(51, 132));      //Adds our Add Customer button
            addCust.Click   += new EventHandler(Add_Customer);
            editCust         = MainPanelButton("Edit Customer", new Point(335, 132));    //Adds our Edit Customer button
            editCust.Click  += new EventHandler(Edit_Customer);
            editWO           = MainPanelButton("Edit Work Order", new Point(615, 132));  //Adds our Edit Work Order button
            editWO.Click    += new EventHandler(Edit_Work_Order);
            cWOButton        = MainPanelButton("Create Work Order", new Point(51, 225)); //Adds our Create Work Order button
            cWOButton.Click += new EventHandler(Create_Work_Order);

            _goBackButton = new Button()
            {
                Location = new Point(632, 494),
                Size     = new Size(173, 46),
                Text     = "Back to Main Menu"
            };
            _goBackButton.Click += new EventHandler(ReturnToMainMenu);

            _exitAppButton = new Button()
            {
                Location = new Point(438, 494),
                Size     = new Size(173, 46),
                Text     = "Exit Application"
            };
            _exitAppButton.Click += new EventHandler(ExitApplicationButton);

            this.Controls.Add(_goBackButton);
            this.Controls.Add(_exitAppButton);

            mainPanel.Controls.Add(year_box);
            mainPanel.Controls.Add(addCust);
            mainPanel.Controls.Add(editCust);
            mainPanel.Controls.Add(editWO);
            mainPanel.Controls.Add(cWOButton);


            this.Controls.Add(mainPanel);
            this.FormClosing += Form1_Closing;
            InitializeComponent();
        }