예제 #1
0
        private void dataListView_Load()
        {
            // Clear on refresh
            dataListView.Clear();
            dataListView.Items.Clear();
            // Add Columns
            dataListView.Columns.Add("Program Name");
            dataListView.Columns.Add("Program Path");

            XmlDocument doc = new XmlDocument();

            doc.Load("pathDir.xml");
            XmlNodeList list = doc.SelectNodes("/pathDir/path");

            // Loop over XML doc
            foreach (XmlNode node in list)
            {
                string programName = node.Attributes[0].Value;
                string programPath = node.Attributes[1].Value;

                // Make and add row to listview
                string[] row = { programName, programPath };
                // Console.WriteLine(row);
                var item = new ListViewItem(row);
                dataListView.Items.Add(item);

                // Console.WriteLine("Name - " + programName + " -- " + programPath);
            }
            AlexaCompCore.Clog("Data List Reloaded");
            // Reset column width
            foreach (ColumnHeader column in dataListView.Columns)
            {
                column.Width = -1;
            }
        }
예제 #2
0
        private void StartLoading(Stopwatch timer)
        {
            UpdateProgress("Reading Config File");
            AlexaComp.ReadConfig();

            UpdateProgress("Creating Port Map", 400);
            AlexaCompSERVER.ForwardPort();

            UpdateProgress("Scanning for RGB Devices");
            AlexaComp.LightingControlThread.Start();

            UpdateProgress("Assigning Sensors");
            HardwareController.InitSensors();

            UpdateProgress("Getting Installed Programs");
            ProgramInventory.ScanDir();

            UpdateProgress("Starting Server");
            AlexaCompCore.ServerThread.Start();

            UpdateProgress("Starting Server Loop");
            AlexaCompCore.ServerLoopThread.Start();

            UpdateProgress("Starting AlexaComp", 400);
            CloseSplashScreen();

            AlexaComp.AppWindowThread.Start();
            timer.Stop();
            AlexaCompCore.Clog(String.Format("Application Window started in {0} ms.", timer.ElapsedMilliseconds));
        }
예제 #3
0
 public static void StartAppWindow()
 {
     Application.Run(new AlexaCompGUI());
     AlexaCompCore.Clog("StartAppWinodw Thread Started");
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     AlexaCompCore.Clog("StartAppWindow Task Completed");
 }
예제 #4
0
 private void UpdateProgress(string message, int wait = 300)
 {
     try {
         AlexaCompCore.Clog(message);
         progressLabel.Invoke(new MethodInvoker(delegate { progressLabel.Text = message; }));
     } catch (InvalidOperationException) {
     }
     // Thread.Sleep(wait);
 }
예제 #5
0
 /*
  * Handler for minimize button click.
  */
 protected override void OnResize(EventArgs e)
 {
     base.OnResize(e);
     if (this.WindowState == FormWindowState.Minimized)
     {
         AlexaCompCore.Clog("Minimized to system tray");
         Hide();
         notifyIcon.Visible = true;
         this.ShowInTaskbar = false;
     }
 }
예제 #6
0
        /*
         * Handler for X button click.
         */
        protected override void OnFormClosing(FormClosingEventArgs e = null)
        {
            if (e != null)
            {
                base.OnFormClosing(e);
            }
            AlexaCompCore.Clog("CLOSING PROGRAM");
            AlexaCompCore.stopProgramFlag = true;
            AlexaCompSERVER.StopServer();
            AlexaCompSERVER.DelPortMap();

            Environment.Exit(1);
        }
예제 #7
0
        private void addToListButton_Click_1(object sender, EventArgs e)
        {
            string programName = programNameTextBox.Text;
            string programPath = programPathTextBox.Text;

            if (string.IsNullOrEmpty(programName) && string.IsNullOrEmpty(programPath))   // If both are empty.
            {
                errorLabel.Visible = true;
                errorLabel.Text    = "Please specify a program name and path.";
            }
            else if (string.IsNullOrEmpty(programPath))   // If only path is empty.
            {
                errorLabel.Visible = true;
                errorLabel.Text    = "Please specify a program path.";
            }
            else if (string.IsNullOrEmpty(programName))   // If only name is empty.
            {
                errorLabel.Visible = true;
                errorLabel.Text    = "Please specify a program name.";
            }
            else   // If both name and path are filled.
            {
                XmlDocument doc = new XmlDocument();
                doc.Load("pathDir.xml");

                programNameTextBox.Clear();
                programPathTextBox.Clear();

                programName = programName.Replace(" ", string.Empty).ToUpper(); // Format string

                string log = "{Name: " + programName + ", Path: " + programPath + "}";
                AlexaCompCore.Clog("Add Program - " + log);

                XmlDocumentFragment frag = doc.CreateDocumentFragment();
                frag.InnerXml = "<path programName=\"" + programName +
                                "\" programPath=\"" + programPath + "\"/>";

                AlexaCompCore.Clog("Add new program - " + frag.InnerXml);
                doc.DocumentElement.AppendChild(frag);
                doc.Save(AlexaCompCore.pathToDebug + "\\pathDir.xml");
                doc.Save(AlexaCompCore.pathToProject + "\\pathDir.xml");
                AlexaCompCore.Clog("pathDir appended");

                dataListView_Load(); // Reset program list

                errorLabel.Visible = false;
                errorLabel.Text    = "";
            }
        }
예제 #8
0
 /*
  * Opens the AlexaComp log file.
  */
 private void openLogFileButton_Click(object sender, EventArgs e)
 {
     AlexaCompCore.Clog("OpenLogFileButtonClicked");
     System.Diagnostics.Process.Start(AlexaComp.pathToDebug + "\\AlexaCompLOG.log");
 }