예제 #1
0
        public static string ToDescription <T>(object item, Action <T, StringBuilder> details)
        {
            var sb = new StringBuilder();

            sb.AppendLine(TypeConverterBase.ToString(item));

            if (item is T typedItem)
            {
                details(typedItem, sb);
            }

            return(sb.ToString());
        }
예제 #2
0
        private static void UpdateDropDownWidth(ComboBox control)
        {
            if (control.Items.Count == 0)
            {
                return;
            }

            var font          = control.Font;
            var g             = control.CreateGraphics();
            var isDroppedDown = control.DroppedDown;

            var vertScrollBarWidth = control.Items.Count > control.MaxDropDownItems
                ? SystemInformation.VerticalScrollBarWidth
                : 0;

            var width = (int)control.Items
                        .Cast <object>()
                        .Select(i => g.MeasureString(TypeConverterBase.ToString(i), font).Width + vertScrollBarWidth)
                        .Max();

            control.DropDownWidth = Math.Max(control.Width, width);
            control.DroppedDown   = isDroppedDown;
        }
예제 #3
0
 private void lbPositions_DoubleClick(object sender, EventArgs e)
 {
     if (lbPositions.SelectedItem is IPosition position && _positionsProcessor.CanExitPosition(position))
     {
         if (MessageBox.Show($"Are you sure you'd like to exit position:{Environment.NewLine}{TypeConverterBase.ToString(position)}", "Exit position", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             _positionsProcessor.ExitPosition(position, _ordersProcessor);
         }
     }
 }