GUI/SoundGraphDisplay.cs
branchMiniDisplay
changeset 444 9b09e2ee0968
parent 443 8c139748f179
child 445 fe4c711fd7f8
     1.1 --- a/GUI/SoundGraphDisplay.cs	Thu Apr 18 19:51:05 2013 +0200
     1.2 +++ b/GUI/SoundGraphDisplay.cs	Thu Apr 18 23:25:10 2013 +0200
     1.3 @@ -53,19 +53,15 @@
     1.4              Process[] processes = Process.GetProcessesByName("SoundGraphAccess");
     1.5              if (!(processes.Length > 0))
     1.6              {
     1.7 -
     1.8 -                //Process client = UserAccountControl.CreateProcessAsStandardUser(@"D:\Dev\SoundGraphAccess\Debug\SoundGraphAccess.exe","");
     1.9 -                    /*
    1.10 -                Process client = new Process();
    1.11 -                client.StartInfo.FileName = @"D:\Dev\SoundGraphAccess\Debug\SoundGraphAccess.exe";
    1.12 -                client.StartInfo.WorkingDirectory = @"D:\Dev\SoundGraphAccess";
    1.13 -                client.Start();*/
    1.14 +                //Try to launch the sound graph process from the same folder as this executable
    1.15 +                string exeName=System.IO.Path.GetDirectoryName(Application.ExecutablePath);
    1.16 +                exeName += @"\SoundGraphAccess.exe";
    1.17 +                Process client = UserAccountControl.CreateProcessAsStandardUser(exeName,"");
    1.18              }
    1.19  
    1.20              //Start our SoundGraph server
    1.21              iServer = new SoundGraph.Server(@"\\.\pipe\sga-inbound", @"\\.\pipe\sga-outbound");
    1.22              iServer.Start();
    1.23 -            //iServer.SendMessage("init:");
    1.24          }
    1.25  
    1.26          private void HardwareRemoved(IHardware hardware)
    1.27 @@ -127,17 +123,25 @@
    1.28                  count++;
    1.29                  sensor.Update();
    1.30  
    1.31 +                if (aDisplayTime && count == 1)
    1.32 +                {
    1.33 +                    //First slot is take by time display
    1.34 +                    count++;
    1.35 +                    packedFirstLine = time + " ";
    1.36 +                }
    1.37 +
    1.38                  if (aPacked)
    1.39                  {
    1.40 +                    //Build strings for packed mode
    1.41                      string packedText = "";
    1.42                      packedText = sensor.iFirstLine.Substring(0, 3) + ":" + sensor.iSecondLine;
    1.43                      if (count == 1)
    1.44                      {
    1.45 -                        packedFirstLine = packedText;
    1.46 +                        packedFirstLine = packedText + " "; //Minimum one space to separate sensors on the same line
    1.47                      }
    1.48                      else if (count == 2)
    1.49                      {
    1.50 -                        //Add enough spaces
    1.51 +                        //Add enough spaces to align to right hand side
    1.52                          while (packedFirstLine.Length + packedText.Length < KMaxCharacterPerLine)
    1.53                          {
    1.54                              packedFirstLine += " ";
    1.55 @@ -146,19 +150,17 @@
    1.56                      }
    1.57                      else if (count == 3)
    1.58                      {
    1.59 -                        packedSecondLine = packedText;
    1.60 +                        packedSecondLine = packedText + " "; //Minimum one space to separate sensors on the same line
    1.61                      }
    1.62                      else if (count == 4)
    1.63                      {
    1.64 -                        //Add enough spaces
    1.65 +                        //Add enough spaces to align to right hand side
    1.66                          while (packedSecondLine.Length + packedText.Length < KMaxCharacterPerLine)
    1.67                          {
    1.68                              packedSecondLine += " ";
    1.69                          }
    1.70                          packedSecondLine += packedText;
    1.71                      }
    1.72 -
    1.73 -
    1.74                  }
    1.75                  //SetText(sensor.iFirstLine, sensor.iSecondLine);
    1.76              }
    1.77 @@ -183,17 +185,11 @@
    1.78                          }
    1.79                      }
    1.80  
    1.81 -                    if (aDisplayTime)
    1.82 -                    {
    1.83 -                        SetText(time, (iNextSensorToDisplay == 1 && packedSecondLine.Length > 0 ? packedSecondLine : packedFirstLine));
    1.84 -                    }
    1.85 -                    else
    1.86 -                    {
    1.87 -                        //Display packed sensors on our FrontView display
    1.88 -                        SetText(packedFirstLine, packedSecondLine);
    1.89 -                    }
    1.90 +                    //TODO: Do something like that to cycle lines if ever we want to
    1.91 +                    //SetText(time, (iNextSensorToDisplay == 1 && packedSecondLine.Length > 0 ? packedSecondLine : packedFirstLine));
    1.92  
    1.93 -
    1.94 +                    //Display packed sensors on our FrontView display
    1.95 +                    SetText(packedFirstLine, packedSecondLine);
    1.96                  }
    1.97                  else
    1.98                  {
    1.99 @@ -248,6 +244,11 @@
   1.100                  //UpdateMainIconVisibilty();
   1.101                  settings.SetValue(new Identifier(sensor.Identifier, "FrontView").ToString(), true);
   1.102                  iNextSensorToDisplay = 0;
   1.103 +                if (list.Count == 1)
   1.104 +                {
   1.105 +                    //Just added first sensor in FrontView, unable FrontView plug-in mode
   1.106 +                    Init();
   1.107 +                }
   1.108              }
   1.109  
   1.110          }
   1.111 @@ -256,6 +257,12 @@
   1.112          {
   1.113              Remove(sensor, true);
   1.114              iNextSensorToDisplay = 0;
   1.115 +            if (list.Count == 0)
   1.116 +            {
   1.117 +                //No sensor to display in FrontView, just disable FrontView plug-in mode
   1.118 +                Uninit();
   1.119 +            }
   1.120 +
   1.121          }
   1.122  
   1.123          private void Remove(ISensor sensor, bool deleteConfig)