예제 #1
0
        private void LIST_items_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (((CheckedListBox)sender).SelectedItem == null)
            {
                NUM_X.Value = NUM_Y.Value = 0;
            }
            else
            {
                //string item = ((CheckedListBox)sender).SelectedItem.ToString();
                OSDItem sel = OSDItemList.Avaliable[LIST_items.SelectedIndex];//(OSDItem)Array.IndexOf(OSDItemList.Names, item);


                //foreach (var alt in OSDItemList.Alternates)
                //    if (sel == alt.Value)
                //    {
                //        sel = alt.Key;
                //        break;
                //    }

                fromOSD          = false;
                osd.SelectedItem = sel;
                fromOSD          = true;

                Point p = osd.GetItemPosition(sel);
                NUM_X.Value = p.X;
                NUM_Y.Value = p.Y;
                osd.Draw();
            }
        }
예제 #2
0
        private Rectangle ToScreenRectangle(OSDItem item)
        {
            var size = new Size(ItemCaptions.GetCaption(item, out int xOffset).Length *charSizePix.Width, charSizePix.Height);
            var loc  = ToScreenPoint(item, xOffset);

            return(new Rectangle(loc, size));
        }
예제 #3
0
        /// <summary>
        /// Adds or updates an OSD item.
        /// </summary>
        /// <param name="text">Item text</param>
        /// <param name="pos_x">Item X position</param>
        /// <param name="pos_y">Item Y position</param>
        /// <param name="color">Text color</param>
        /// <param name="identifier">Unique identifier, set to be able to update the item without recreating it</param>
        /// <param name="timer">Duration in frames, -1 for permanent, don't set to keep the previous value when updating an existing item</param>
        public void UpdateOSDItem(string text, int pos_x, int pos_y, RawColorBGRA color, string identifier = "", int timer = 0)
        {
            foreach (OSDItem osd in OSDItems)
            {
                if (osd.id != "" && osd.id == identifier)
                {
                    osd.text = text;
                    if (timer != 0)
                    {
                        osd.timer = timer;
                    }
                    osd.pos_x = pos_x - 8;
                    osd.pos_y = pos_y;
                    osd.color = color;
                    return;
                }
            }
            OSDItem newosd = new OSDItem();

            newosd.text  = text;
            newosd.id    = identifier;
            newosd.timer = timer;
            newosd.pos_x = pos_x - 8;
            newosd.pos_y = pos_y;
            newosd.color = color;
            OSDItems.Add(newosd);
        }
예제 #4
0
        public static string GetCaption(OSDItem item, out int xOffset)
        {
            var caption = DoGetCaption(item, out xOffset);

            caption = digitPointRegex.Replace(caption, DigitPointEvaluator);

            return(caption);
        }
예제 #5
0
        public ItemControlBase(ScreenControl screenControl, OSDItem item)
        {
            this.screenControl = screenControl ?? throw new ArgumentNullException(nameof(screenControl));
            this.item          = item ?? throw new ArgumentNullException(nameof(item));

            item.Enabled.Updated += EnabledUpdated;

            Load     += ItemControlLoad;
            Disposed += ItemControlDisposed;
        }
예제 #6
0
        private void LIST_items_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            // if (((CheckedListBox)sender).SelectedItem != null && ((CheckedListBox)sender).SelectedItem.ToString() == "Horizon")
            int idx = -1;

            if (((CheckedListBox)sender).SelectedItem != null)
            {
                OSDItem item = OSDItemList.Avaliable[LIST_items.SelectedIndex];//(OSDItem)Array.IndexOf(OSDItemList.Names, ((CheckedListBox)sender).SelectedItem);

                if (e.NewValue == CheckState.Checked)
                {
                    foreach (var conflict in OSDItemList.Conflits)
                    {
                        if (item == conflict.Key && (idx = Array.IndexOf(OSDItemList.Avaliable, conflict.Value)) >= 0)
                        {
                            LIST_items.SetItemChecked(idx, false);
                            osd.SetItemEnabled(conflict.Value, false);
                        }
                        else if (item == conflict.Value && (idx = Array.IndexOf(OSDItemList.Avaliable, conflict.Key)) >= 0)
                        {
                            LIST_items.SetItemChecked(idx, false);
                            osd.SetItemEnabled(conflict.Key, false);
                        }
                    }
                }

                /*
                 *              foreach (var alt in OSDItemList.Alternates)
                 *              {
                 *                  if (item == alt.Key && e.NewValue == CheckState.Checked && (idx = Array.IndexOf(OSDItemList.Avaliable, alt.Value)) >= 0)
                 *                  {
                 *                      LIST_items.SetItemChecked(idx, false);
                 *                      osd.SetItemEnabled(alt.Value, false);
                 *                      break;
                 *                  }
                 *                  else if (item == alt.Value)
                 *                  {
                 *                      if (e.NewValue == CheckState.Checked
                 *                          //&& OSDItemList.Names[(int)alt.Key] != null
                 *                          && (idx = Array.IndexOf(OSDItemList.Avaliable, alt.Key)) >= 0)
                 *                          LIST_items.SetItemChecked(idx, false);
                 *                      osd.SetItemEnabled(alt.Key, e.NewValue == CheckState.Checked);
                 *                      break;
                 *                  }
                 *              }
                 */
                osd.SetItemEnabled(item, e.NewValue == CheckState.Checked);
            }

            // add a delay to this so it runs after the control value has been defined.
            if (this.IsHandleCreated)
            {
                this.BeginInvoke((MethodInvoker) delegate { /*osdDraw();*/ osd.Draw(); });
            }
        }
예제 #7
0
        public void Draw(OSDItem item, Graphics graphics)
        {
            var   caption = ItemCaptions.GetCaption(item, out int xOffset);
            Point loc     = ToScreenPoint(item, xOffset);

            foreach (var c in caption)
            {
                graphics.DrawImage(font[c], loc.X, loc.Y, charSizePix.Width, charSizePix.Height);
                loc.X += charSizePix.Width;
            }
        }
예제 #8
0
        public CommonItemControl(ScreenControl screenControl, OSDItem item)
            : base(screenControl, item)
        {
            InitializeComponent();

            label.Text = item.Name;

            checkBox.CheckedChanged += CheckBoxChanged;

            label.MouseClick += (s, e) => DoSelect();
            this.MouseClick  += (s, e) => DoSelect();
        }
예제 #9
0
        public void DrawSelection(OSDItem item, Graphics graphics)
        {
            if (item == null)
            {
                return;
            }

            var rect = ToScreenRectangle(item);

            rect.Inflate(5, 5);

            graphics.DrawRectangle(Pens.Yellow, rect);
        }
예제 #10
0
파일: OSD.cs 프로젝트: trttomita/hazys-osd
 public void SetItemEnabled(OSDItem item, bool enabled)
 {
     if (item != OSDItem.NULL)
     {
         if (enabled)
         {
             setting.enable |= (1U << (int)item);
         }
         else
         {
             setting.enable &= ~(1U << (int)item);
         }
         mod = true;
     }
 }
예제 #11
0
        private void NUM_ValueChanged(object sender, EventArgs e)
        {
            try
            {
                //OSDItem info = (OSDItem)Array.IndexOf(OSDItemList.Names, LIST_items.SelectedItem.ToString());
                OSDItem item = OSDItemList.Avaliable[LIST_items.SelectedIndex];

                /*foreach (var alt in OSDItemList.Alternates)
                 *  if (item == alt.Value)
                 *  {
                 *      item = alt.Key;
                 *      break;
                 *  }
                 */
                osd.SetItemPosition(item, new Point((int)NUM_X.Value, (int)NUM_Y.Value));
                osd.Draw();
            }
            catch { return; }
        }
예제 #12
0
파일: OSD.cs 프로젝트: trttomita/hazys-osd
        public void SetItemPosition(OSDItem info, Point pos)
        {
            int x = Setting.coord[(int)info, 0], y = Setting.coord[(int)info, 1];

            if (pos.X != x || pos.Y != y)
            {
                Setting.coord[(int)info, 0] = (byte)pos.X;
                Setting.coord[(int)info, 1] = (byte)pos.Y;

                Array.Clear(itemInPos, 0, itemInPos.Length);
                mod = true;
                if (ItemPositionChanged != null)
                {
                    ItemPositionChanged(this, new EventArgs());
                }
            }


            //if (Setting.IsEnabled(info))
            //    Draw();
        }
예제 #13
0
파일: OSD.cs 프로젝트: trttomita/hazys-osd
 public Point GetItemPosition(OSDItem info)
 {
     return(new Point(Setting.coord[(int)info, 0], Setting.coord[(int)info, 1]));
 }
예제 #14
0
파일: OSD.cs 프로젝트: trttomita/hazys-osd
 public void SetItemEnabled(OSDItem item, bool enabled)
 {
     if (item != OSDItem.NULL)
     {
         if (enabled)
             setting.enable |= (1U << (int)item);
         else
             setting.enable &= ~(1U << (int)item);
         mod = true;
     }
 }
예제 #15
0
파일: OSD.cs 프로젝트: trttomita/hazys-osd
        public void SetItemPosition(OSDItem info, Point pos)
        {
            int x = Setting.coord[(int)info, 0], y = Setting.coord[(int)info, 1];

            if (pos.X != x || pos.Y != y)
            {
                Setting.coord[(int)info, 0] = (byte)pos.X;
                Setting.coord[(int)info, 1] = (byte)pos.Y;

                Array.Clear(itemInPos, 0, itemInPos.Length);
                mod = true;
                if (ItemPositionChanged != null)
                    ItemPositionChanged(this, new EventArgs());
            }


            //if (Setting.IsEnabled(info))
            //    Draw();
        }
예제 #16
0
 public bool Contains(OSDItem item, Point point)
 {
     return(ToScreenRectangle(item).Contains(point));
 }
예제 #17
0
        private static string DoGetCaption(OSDItem item, out int xOffset)
        {
            xOffset = 0;

            switch (item.Name)
            {
            case "ALTITUDE":
                xOffset = -2;
                return($"11{Symbols.SYM_ALT_M}");

            case "BAT_VOLT":
                return($"{(char)(Symbols.SYM_BATT_FULL + 1)}11.8{Symbols.SYM_VOLT}");

            case "RSSI":
                return($"{Symbols.SYM_RSSI}93");

            case "CURRENT":
                xOffset = 0;
                return($"8.3{Symbols.SYM_AMP}");

            case "FLTMODE":
                return("STAB" + Symbols.SYM_DISARMED);

            case "SATS":
                return($"{Symbols.SYM_SAT_L}{Symbols.SYM_SAT_R}13");

            case "BATUSED":
                xOffset = -1;
                return($"125{Symbols.SYM_MAH}");

            case "HORIZON":
                xOffset = 4;
                var h = (char)(Symbols.SYM_AH_H_START + 4);
                return($"{h}{h}{h}{Symbols.SYM_AH_CENTER_LINE_LEFT}{Symbols.SYM_AH_CENTER}{Symbols.SYM_AH_CENTER_LINE_RIGHT}{h}{h}{h}");

            case "COMPASS":
                xOffset = 4;
                return(string.Concat(Symbols.SYM_HEADING_N, Symbols.SYM_HEADING_LINE, Symbols.SYM_HEADING_DIVIDED_LINE, Symbols.SYM_HEADING_LINE,
                                     Symbols.SYM_HEADING_E, Symbols.SYM_HEADING_LINE, Symbols.SYM_HEADING_DIVIDED_LINE, Symbols.SYM_HEADING_LINE,
                                     Symbols.SYM_HEADING_S));

            case "GPSLONG":
                return($"{Symbols.SYM_GPS_LONG}  30.5003901");

            case "GPSLAT":
                return($"{Symbols.SYM_GPS_LAT}  50.3534305");

            case "HOME":
                return($"{Symbols.SYM_HOME}{Symbols.SYM_ARROW_START} 101{Symbols.SYM_M}");

            case "GSPEED":
                return($"{Symbols.SYM_GSPD}{Symbols.SYM_ARROW_START} 17{Symbols.SYM_KMH}");

            case "PITCH":
                return($"{Symbols.SYM_PTCHDWN} 10{Symbols.SYM_DEGR}");

            case "ROLL":
                return($"{Symbols.SYM_ROLLL}  3{Symbols.SYM_DEGR}");

            case "VSPEED":
                return($"{Symbols.SYM_UP} 0{Symbols.SYM_MS}");

            case "THROTTLE":
                xOffset = -2;
                return($"0{Symbols.SYM_PCNT}");

            case "HEADING":
                xOffset = -1;
                return($"32{Symbols.SYM_DEGR}");


            default:
                return(item.Name);
            }
        }
예제 #18
0
 public bool IsEnabled(OSDItem info)
 {
     return((enable & (1U << (int)info)) != 0);
 }
예제 #19
0
 static UInt32 _BV(OSDItem bi)
 {
     return(1U << (int)bi);
     //_BV(Pit_BIT) | _BV(Rol_BIT) | _BV(BatA_BIT) | _BV(GPSats_BIT) | _BV(GPL_BIT) | _BV(GPS_BIT),
 }
예제 #20
0
 static UInt32 _BV(OSDItem bi)
 {
     return 1U << (int)bi;
     //_BV(Pit_BIT) | _BV(Rol_BIT) | _BV(BatA_BIT) | _BV(GPSats_BIT) | _BV(GPL_BIT) | _BV(GPS_BIT),
 }
예제 #21
0
파일: OSD.cs 프로젝트: trttomita/hazys-osd
 public Point GetItemPosition(OSDItem info)
 {
     return new Point(Setting.coord[(int)info, 0], Setting.coord[(int)info, 1]);
 }
예제 #22
0
 public bool IsEnabled(OSDItem info)
 {
     return (enable & (1U << (int)info)) != 0;
 }
예제 #23
0
 public Point ToScreenPoint(OSDItem item, int xOffset)
 {
     return(new Point(((int)item.X.Value - xOffset) * charSizePix.Width, (int)item.Y.Value * charSizePix.Height));
 }