Esempio n. 1
0
 private bool Declutter(GaugeSet set, int id)
 {
     foreach (int other in set)
     {
         if (!set.IsGaugeEnabled(other))
         {
             continue;
         }
         if (id != other)
         {
             Pair <int, int> position = set.GetWindowPosition(id);
             Pair <int, int> cmp      = set.GetWindowPosition(other);
             if (Math.Abs(position.first - cmp.first) < MIN_GAUGE_DISTANCE && Math.Abs(position.second - cmp.second) < MIN_GAUGE_DISTANCE)
             {
                 int x = position.first + MIN_GAUGE_DISTANCE;
                 int y = position.second + MIN_GAUGE_DISTANCE;
                 if (x >= Screen.width - NanoGauges.configuration.verticalGaugeWidth)
                 {
                     x = 0;
                 }
                 if (y >= Screen.height - NanoGauges.configuration.verticalGaugeHeight)
                 {
                     y = 0;
                 }
                 Pair <int, int> newPosition = new Pair <int, int>(x, y);
                 set.SetWindowPosition(id, newPosition);
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 2
0
 public void copyPositionsFrom(GaugeSet source)
 {
     foreach (int key in source.windowPositions.Keys)
     {
         SetWindowPosition(key, source.GetWindowPosition(key));
     }
 }
Esempio n. 3
0
            public void Layout(GaugeSet set)
            {
                Log.Info("layout " + GetType() + ", set " + set);
                //
                // move all gauges to 0/0 to find gauges that are unaffected by layout
                foreach (AbstractGauge g in gauges)
                {
                    int id = g.GetWindowId();
                    set.SetWindowPosition(id, Constants.ORIGIN);
                }
                //
                DoLayout(set);
                //
                EnableGauges(set);

                Reset();
                foreach (AbstractGauge g in gauges)
                {
                    int id = g.GetWindowId();
                    if (set.GetWindowPosition(id).Equals(Constants.ORIGIN))
                    {
                        AddToSpare(set, id);
                    }
                }

                Log.Detail("layout done for " + set);
            }
Esempio n. 4
0
            public void CopySelectorPositionFrom(GaugeSet.ID id)
            {
                GaugeSet        source   = GaugeSetPool.instance.GetGaugeSet(id);
                Pair <int, int> position = source.GetWindowPosition(Constants.WINDOW_ID_GAUGE_SETS);

                foreach (GaugeSet set in GaugeSetPool.instance)
                {
                    set.SetWindowPosition(Constants.WINDOW_ID_GAUGE_SETS, position);
                }
            }
Esempio n. 5
0
 private void WriteWindowPositions(BinaryWriter writer, GaugeSet set)
 {
     Log.Info("storing window positions");
     writer.Write((Int16)set.Count());
     Log.Detail("writing " + set.Count() + " window positions");
     foreach (int id in set.Keys())
     {
         Pair <int, int> position = set.GetWindowPosition(id);
         writer.Write((Int32)id);
         writer.Write((Int16)position.first);
         writer.Write((Int16)position.second);
         Log.Trace("window position for window id " + id + " written: " + position.first + "/" + position.second);
     }
 }
Esempio n. 6
0
 public void Declutter(GaugeSet set)
 {
     Log.Info("declutter " + set);
     foreach (int id in set)
     {
         if (!set.IsGaugeEnabled(id))
         {
             continue;
         }
         while (Declutter(set, id))
         {
             Log.Info("decluttering gauge id " + id + " to " + set.GetWindowPosition(id) + " in set " + set);
         }
     }
 }
Esempio n. 7
0
 private void WriteWindowPositions(BinaryWriter writer, GaugeSet set)
 {
     Log.Info("storing window positions");
     writer.Write((Int16)set.Count());
     Log.Detail("writing " + set.Count() + " window positions");
     foreach (int id in set.Keys())
     {
         // never write the aligment gauge
         if (id == Constants.WINDOW_ID_GAUGE_ALIGNMENT)
         {
             continue;
         }
         //
         Pair <int, int> position = set.GetWindowPosition(id);
         writer.Write((Int32)id);
         writer.Write((Int16)position.first);
         writer.Write((Int16)position.second);
         Log.Trace("window position for window id " + id + " written: " + position.first + "/" + position.second);
     }
 }
Esempio n. 8
0
            // BROKEN
            public void copyArrangementFrom(GaugeSet source)
            {
                int[] sourceSortedByPosition = new int[source.gaugeIds.Count];
                int   sourceCnt = 0;

                foreach (int id in source.gaugeIds)
                {
                    if (gaugesEnabled[id])
                    {
                        sourceSortedByPosition[sourceCnt] = id;
                        sourceCnt++;
                    }
                }
                int[] thisSortedByPosition = new int[source.gaugeIds.Count];
                int   thisCnt = 0;

                foreach (int id in gaugeIds)
                {
                    if (gaugesEnabled[id])
                    {
                        thisSortedByPosition[thisCnt] = id;
                        thisCnt++;
                    }
                }

                Array.Sort(sourceSortedByPosition,
                           delegate(int left, int right)
                {
                    if (right == 0)
                    {
                        return(-1);
                    }
                    if (left == 0)
                    {
                        return(1);
                    }
                    Pair <int, int> posLeft  = source.GetWindowPosition(left);
                    Pair <int, int> posRight = source.GetWindowPosition(right);
                    int xLeft  = posLeft.first;
                    int yLeft  = posLeft.second;
                    int xRight = posLeft.first;
                    int yRight = posLeft.second;
                    //

                    if (yLeft.In(yRight, yRight + NanoGauges.configuration.verticalGaugeHeight) ||
                        yRight.In(yLeft, yLeft + NanoGauges.configuration.verticalGaugeHeight))
                    {
                        return(xLeft.CompareTo(xRight));
                    }
                    return(yLeft.CompareTo(yRight));
                }
                           );

                Array.Sort(thisSortedByPosition,
                           delegate(int left, int right)
                {
                    if (right == 0)
                    {
                        return(-1);
                    }
                    if (left == 0)
                    {
                        return(1);
                    }
                    Pair <int, int> posLeft  = GetWindowPosition(left);
                    Pair <int, int> posRight = GetWindowPosition(right);
                    int xLeft  = posLeft.first;
                    int yLeft  = posLeft.second;
                    int xRight = posLeft.first;
                    int yRight = posLeft.second;
                    //

                    if (yLeft.In(yRight, yRight + NanoGauges.configuration.verticalGaugeHeight) ||
                        yRight.In(yLeft, yLeft + NanoGauges.configuration.verticalGaugeHeight))
                    {
                        return(xLeft.CompareTo(xRight));
                    }
                    return(yLeft.CompareTo(yRight));
                }
                           );

                for (int i = 0; i < sourceCnt && i < thisCnt; i++)
                {
                    SetWindowPosition(thisSortedByPosition[i], source.GetWindowPosition(sourceSortedByPosition[i]));
                }
            }
Esempio n. 9
0
 public Pair <int, int> GetWindowPosition(AbstractWindow window)
 {
     return(currentGaugeSet.GetWindowPosition(window.GetWindowId()));
 }