Пример #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Draw the tab's text.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void DrawText(IDeviceContext g)
        {
            const TextFormatFlags kFlags = TextFormatFlags.VerticalCenter |
                                           TextFormatFlags.HorizontalCenter | TextFormatFlags.WordEllipsis |
                                           TextFormatFlags.SingleLine | TextFormatFlags.NoPadding |
                                           TextFormatFlags.HidePrefix | TextFormatFlags.PreserveGraphicsClipping;

            var clrText = (_selected ? Color.Black :
                           ColorHelper.CalculateColor(SystemColors.ControlText,
                                                      SystemColors.Control, 145));

            var rc = ClientRectangle;

            // Account for the image if there is one.
            if (TabImage != null)
            {
                rc.X     += (5 + TabImage.Width);
                rc.Width -= (5 + TabImage.Width);
            }

            // When the tab is selected, then bump the text down a couple of pixels.
            if (_selected)
            {
                rc.Y      += 2;
                rc.Height -= 2;
            }

            TextRenderer.DrawText(g, Text, Font, rc, clrText, kFlags);
        }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        private void ConnectIndentedRowToPrevious(int indentLevel, DataGridViewCellPaintingEventArgs e)
        {
            var selected = ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected);
            var clrFore  = (selected ? e.CellStyle.SelectionForeColor : e.CellStyle.ForeColor);
            var rc       = e.CellBounds;

            if (e.ColumnIndex > 0)
            {
                rc.Width = _grid.Columns[0].Width;
            }

            // Draw a dotted, right-angle line linking the row to the one above.
            using (var pen = new Pen(ColorHelper.CalculateColor(Color.White, clrFore, 130)))
            {
                var dx = rc.X + (rc.Width / 2);
                var dy = rc.Y + (rc.Height / 2) + 1;

                pen.DashStyle = DashStyle.Dot;
                e.Graphics.DrawLines(pen, new[]
                {
                    new Point(dx, rc.Y + 1),
                    new Point(dx, dy),
                    new Point(rc.Right, dy)
                });

                // If the following row is also indented one level in, then draw the connector so it spans
                // the height of the cell, rather than stop where the horizontal line starts.
                if (e.RowIndex + 1 < _grid.RowCount && _files.ElementAt(e.RowIndex + 1).DisplayIndentLevel == indentLevel)
                {
                    e.Graphics.DrawLine(pen, dx, rc.Y + 1, dx, rc.Y + rc.Height - 1);
                }
            }
        }
Пример #3
0
        /// ------------------------------------------------------------------------------------
        public SessionsVw()
        {
            InitializeComponent();
            UpdateSessionFileInfo(null);


            gridFiles.AlternatingRowsDefaultCellStyle.BackColor =
                ColorHelper.CalculateColor(Color.Black, gridFiles.DefaultCellStyle.BackColor, 10);

            gridFiles.Dock = DockStyle.Fill;

            lblNoSessionsMsg.BackColor = lpSessions.ListView.BackColor;

            _fileInfoNotes.Width  = pnlFileInfoNotes.ClientSize.Width - _fileInfoNotes.Left - 1;
            _fileInfoNotes.Height = pnlFileInfoNotes.ClientSize.Height - _fileInfoNotes.Top - 1;

            tblDescription.Paint                    += SpongeColors.PaintDataEntryBackground;
            splitFileTab.Panel2.Paint               += SpongeColors.PaintDataEntryBorder;
            splitFileTab.Panel2.BackColor            = SpongeColors.DataEntryPanelBegin;
            _infoPanel.LabeledTextBoxBackgroundColor = SpongeColors.DataEntryPanelBegin;
            _fileInfoNotes.BackColor                 = SpongeColors.DataEntryPanelBegin;

            if (Sponge.DiscourseTypes != null)
            {
                _unknownEventType = LocalizationManager.LocalizeString("SessionsVw.UnknownEventType",
                                                                       "<Unknown>", "Unknown event type displayed in the event type drop-down list.",
                                                                       "Views", LocalizationCategory.Other, LocalizationPriority.High);

                _eventType.Items.AddRange(Sponge.DiscourseTypes.ToArray());
                _eventType.Items.Add(_unknownEventType);
            }

            btnNewFromFiles.Parent.Controls.Remove(btnNewFromFiles);
            lpSessions.InsertButton(1, btnNewFromFiles);
        }
Пример #4
0
        /// ------------------------------------------------------------------------------------
        protected virtual void HandleBackgroundPanelPaint(object sender, PaintEventArgs e)
        {
            var clr1 = m_panel.BackColor;
            var clr2 = ColorHelper.CalculateColor(Color.White, Color.DarkGray, 150);
            var rc   = m_panel.ClientRectangle;

            using (LinearGradientBrush br = new LinearGradientBrush(rc, clr1, clr2, 45))
                e.Graphics.FillRectangle(br, rc);

            const int dypLineThickness = 2;
            int       nTopOfGrayLine   = lblCopyright.Bottom +
                                         (lblMessage.Top - lblCopyright.Bottom) / 2 -
                                         dypLineThickness;

            int x1 = 16;
            int x2 = m_panel.ClientSize.Width - (x1 + 1);

            using (Pen pen = new Pen(Color.FromArgb(128, 128, 128)))
            {
                e.Graphics.DrawLine(pen, x1, nTopOfGrayLine, x2, nTopOfGrayLine);
                e.Graphics.DrawLine(pen, x1, nTopOfGrayLine + 1, x2, nTopOfGrayLine + 1);
                pen.Color = Color.FromArgb(192, 192, 192);
                e.Graphics.DrawLine(pen, x1, nTopOfGrayLine + 2, x2, nTopOfGrayLine + 2);
                e.Graphics.DrawLine(pen, x1, nTopOfGrayLine + 3, x2, nTopOfGrayLine + 3);
            }
        }
Пример #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Draw a nice gradient background for the selected row.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void grid_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            e.Handled = true;
            DataGridViewPaintParts paintParts = DataGridViewPaintParts.All;

            paintParts &= ~DataGridViewPaintParts.Focus;

            if (grid.Rows[e.RowIndex].Selected)
            {
                // Draw default everything but focus rectangle and background.
                paintParts &= ~DataGridViewPaintParts.Background;

                Color clr1 = ColorHelper.CalculateColor(Color.White,
                                                        SystemColors.GradientActiveCaption, 250);

                Color clr2 = ColorHelper.CalculateColor(Color.White,
                                                        SystemColors.GradientActiveCaption, 150);

                using (LinearGradientBrush br =
                           new LinearGradientBrush(e.CellBounds, clr1, clr2, 90f))
                {
                    e.Graphics.FillRectangle(br, e.CellBounds);
                }
            }

            e.Paint(e.ClipBounds, paintParts);
        }
Пример #6
0
        /// ------------------------------------------------------------------------------------
        private void HandleOuterTableLayoutPaint(object sender, PaintEventArgs e)
        {
            var rc = _tableLayout.ClientRectangle;

            rc.Height = _panelScrolling.Top - 1;

            var clr1 = ColorHelper.CalculateColor(SystemColors.ActiveCaption, SystemColors.ActiveCaption, 0);
            var clr2 = ColorHelper.CalculateColor(Color.White, SystemColors.ActiveCaption, 70);

            using (var br = new LinearGradientBrush(rc, clr1, clr2, 0f))
            {
                e.Graphics.FillRectangle(br, rc);
                rc.Y      = _panelScrolling.Bottom;
                rc.Height = _tableLayout.ClientRectangle.Bottom - rc.Y;
                e.Graphics.FillRectangle(br, rc);
            }

            using (var pen = new Pen(clr1))
            {
                var pt1 = new Point(0, _panelScrolling.Top - 1);
                var pt2 = new Point(rc.Right, _panelScrolling.Top - 1);
                e.Graphics.DrawLine(pen, pt1, pt2);

                pt1 = new Point(0, _panelScrolling.Bottom);
                pt2 = new Point(rc.Right, _panelScrolling.Bottom);
                e.Graphics.DrawLine(pen, pt1, pt2);
            }
        }
Пример #7
0
        /// ------------------------------------------------------------------------------------
        public void DrawPlaybackProgressBar(Graphics g, Rectangle rc, Color baseBackColor)
        {
            lock (_mediaFileQueue)
            {
                if (_mediaFileQueue.Count == 0 || !PlaybackInProgress)
                {
                    return;
                }

                var playbackPosition = PlayerViewModel.CurrentPosition;
                if (playbackPosition.Equals(0f))
                {
                    return;
                }

                var start = _mediaFileQueue[0].Start;
                var end   = _mediaFileQueue[0].End;

                var length       = Math.Round(end - start, 1, MidpointRounding.AwayFromZero);
                var pixelsPerSec = rc.Width / length;
                rc.Width = (int)Math.Ceiling(pixelsPerSec * (playbackPosition - start));
            }

            if (rc.Width <= 0)
            {
                return;
            }

            rc.Height -= 6;
            rc.Y      += 3;
            using (var br = new SolidBrush(ColorHelper.CalculateColor(Color.White, baseBackColor, 110)))
                g.FillRectangle(br, rc);
        }
Пример #8
0
        /// ------------------------------------------------------------------------------------
        public TextAnnotationEditorGrid(Font transcriptionFont, Font translationFont)
        {
            Anchor      = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
            Margin      = new Padding(0);
            VirtualMode = true;
            ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            AutoSizeRowsMode            = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
            AllowUserToResizeRows       = false;
            RowHeadersVisible           = false;
            EditMode                            = DataGridViewEditMode.EditOnEnter;
            ClipboardCopyMode                   = DataGridViewClipboardCopyMode.Disable;
            FullRowFocusRectangleColor          = DefaultCellStyle.SelectionBackColor;
            DefaultCellStyle.SelectionForeColor = DefaultCellStyle.ForeColor;
            DefaultCellStyle.SelectionBackColor =
                ColorHelper.CalculateColor(Color.White, DefaultCellStyle.SelectionBackColor, 140);

            RowTemplate.Height        = 25;
            RowTemplate.MinimumHeight = 24;

            PlayerViewModel = new MediaPlayerViewModel();

            PlayerViewModel.SetVolume(100);
            PlayerViewModel.SetSpeed(Settings.Default.AnnotationEditorPlaybackSpeedIndex);

            SetColumnFonts(transcriptionFont, translationFont);
        }
Пример #9
0
        /// ------------------------------------------------------------------------------------
        public ElementGrid()
        {
            CellBorderStyle   = DataGridViewCellBorderStyle.None;
            VirtualMode       = true;
            RowHeadersVisible = false;
            BorderStyle       = BorderStyle.None;
            StandardTab       = true;
            Font = Program.DialogFont;
            // Underlying code still allows for deleting multiple elements, but JohnH said not
            // to allow it.
            MultiSelect = false;
            PaintFullRowFocusRectangle         = true;
            ExtendFullRowSelectRectangleToEdge = true;
            ColumnHeadersHeightSizeMode        = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;

            var clr = ColorHelper.CalculateColor(Color.White,
                                                 DefaultCellStyle.SelectionBackColor, 140);

            FullRowFocusRectangleColor          = DefaultCellStyle.SelectionBackColor;
            DefaultCellStyle.SelectionBackColor = clr;
            DefaultCellStyle.SelectionForeColor = DefaultCellStyle.ForeColor;

            _locExtender = new L10NSharpExtender();
            _locExtender.LocalizationManagerId = "SayMore";
            _locExtender.SetLocalizingId(this, "ElementGrid");
        }
Пример #10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Draw the line down the panel and give the panel a gradient background.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle rc = ClientRectangle;

            Color clrLeft =
                ColorHelper.CalculateColor(SystemColors.Control, Color.White, 100);

            Color clrRight =
                ColorHelper.CalculateColor(SystemColors.ControlDark, Color.White, 75);

            using (LinearGradientBrush br = new LinearGradientBrush(rc, clrLeft, clrRight, 0f))
                e.Graphics.FillRectangle(br, rc);

            if (!m_sliderOpen)
            {
                if (SlideFromLeft)
                {
                    e.Graphics.DrawLine(SystemPens.ControlDark, rc.Right - 4, 0, rc.Right - 4, rc.Bottom);
                }
                else
                {
                    e.Graphics.DrawLine(SystemPens.ControlDark, 3, 0, 3, rc.Bottom);
                }
            }
        }
Пример #11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// We don't want a typical looking button. Therefore, draw it ourselves.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		void m_button_Paint(object sender, PaintEventArgs e)
		{
			DrawButtonBackground(e.Graphics);

			// Draw the item's glyph.
			DrawExpandCollapseGlyph(e.Graphics);

			Rectangle rc = m_button.ClientRectangle;

			// Draw the item's text.
			TextFormatFlags flags = TextFormatFlags.VerticalCenter |
				TextFormatFlags.EndEllipsis;

			rc.Inflate(-2, 0);
			rc.Width -= m_glyphButtonWidth;
			TextRenderer.DrawText(e.Graphics, m_button.Text, Font,
				rc, SystemColors.WindowText, flags);

			rc = m_button.ClientRectangle;

			// Draw a line separating the button area from what collapses and expands below it.
			Color clr1 = ColorHelper.CalculateColor(Color.White, SystemColors.MenuHighlight, 90);
			Point pt1 = new Point(rc.X + 1, rc.Bottom - 3);
			Point pt2 = new Point(rc.Right, rc.Bottom - 3);
			using (LinearGradientBrush br = new LinearGradientBrush(pt1, pt2,
				clr1, SystemColors.Window))
			{
				e.Graphics.DrawLine(new Pen(br, 1), pt1, pt2);
			}

			rc.Inflate(-1, -1);
			if (m_button.Focused)
				ControlPaint.DrawFocusRectangle(e.Graphics, rc);
		}
Пример #12
0
        /// ------------------------------------------------------------------------------------
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            var clr1 = Color.White;
            var clr2 = ColorHelper.CalculateColor(Color.White, SystemColors.GradientActiveCaption, 100);

            using (var br = new LinearGradientBrush(ClientRectangle, clr1, clr2, 45f))
                e.Graphics.FillRectangle(br, ClientRectangle);
        }
Пример #13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Rectangle rc = ClientRectangle;

            if (m_insertMode || Capture)
            {
                PaintingHelper.DrawHotBackground(e.Graphics, rc, PaintState.Hot);
                if (m_labels.Count > 0 && m_insertMode)
                {
                    DrawInsertionMarker(e.Graphics);
                }
            }
            else
            {
                m_insertPoint = new Point(0, rc.Bottom - 3);

                if (m_labels.Count > 0)
                {
                    e.Graphics.FillRectangle(SystemBrushes.Control, rc);
                }
                else
                {
                    // At this point, we know the panel is empty and the mouse isn't over it.
                    // Therefore, fill in the background so the user can see there is something
                    // here. Otherwise the panel would be invisible.
                    Color clr1 = SystemColors.ControlDark;
                    Color clr2 = ColorHelper.CalculateColor(Color.White, clr1, 30);
                    using (LinearGradientBrush br = new LinearGradientBrush(rc, Color.White, clr2, 60))
                        e.Graphics.FillRectangle(br, rc);

                    // Draw a border around the label.
                    ControlPaint.DrawBorder(e.Graphics, rc, SystemColors.ButtonShadow,
                                            ButtonBorderStyle.Solid);
                }
            }

            // Put the word "Empty" (or localized equivalent) in the panel when
            // it doesn't yet contain a search pattern.
            if (m_labels.Count == 0)
            {
                using (Font fnt = new Font(FontHelper.UIFont.Name, 8, GraphicsUnit.Point))
                    using (StringFormat sf = STUtils.GetStringFormat(true))
                    {
                        e.Graphics.DrawString(Properties.Resources.kstidEmptySearchPatternText, fnt,
                                              SystemBrushes.ControlText, rc, sf);
                    }

                if (!m_insertMode && m_tooltip.GetToolTip(this) != m_emptyPatternTooltip)
                {
                    m_tooltip.SetToolTip(this, m_emptyPatternTooltip);
                }
            }
        }
Пример #14
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of the CharContextCtrl.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public CharContextCtrl()
        {
            InitializeComponent();
            gridContext.AutoGenerateColumns = false;
            colRef.MinimumWidth             = 2;
            colRef.Width = colRef.MinimumWidth;

            gridContext.GridColor = ColorHelper.CalculateColor(SystemColors.WindowText,
                                                               SystemColors.Window, 35);
            m_sInitialScanMsgLabel = lblScanMsg.Text;
        }
Пример #15
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="FwBasicGrid"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public FwBasicGrid()
        {
            m_selCellBackColor =
                ColorHelper.CalculateColor(SystemColors.Window, SystemColors.Highlight, 200);

            m_selRowBackColor =
                ColorHelper.CalculateColor(SystemColors.Window, SystemColors.Highlight, 150);

            m_selCellForeColor = SystemColors.WindowText;
            m_selRowForeColor  = SystemColors.WindowText;

            DefaultCellStyle.SelectionForeColor = m_selRowForeColor;
            DefaultCellStyle.SelectionBackColor = m_selRowBackColor;
        }
Пример #16
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of the CharContextCtrl.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public CharContextCtrl()
        {
            InitializeComponent();
            m_openFileDialog            = new OpenFileDialogAdapter();
            m_openFileDialog.DefaultExt = "lds";
            m_openFileDialog.Title      = FwCoreDlgs.kstidLanguageFileBrowser;

            gridContext.AutoGenerateColumns = false;
            colRef.MinimumWidth             = 2;
            colRef.Width = colRef.MinimumWidth;

            gridContext.GridColor = ColorHelper.CalculateColor(SystemColors.WindowText,
                                                               SystemColors.Window, 35);
            m_sInitialScanMsgLabel = lblScanMsg.Text;
        }
Пример #17
0
        /// ------------------------------------------------------------------------------------
        protected override void OnRowPrePaint(DataGridViewRowPrePaintEventArgs e)
        {
            var i = e.RowIndex;

            if (i < 0)
            {
                return;
            }
            var enabled   = ((CurrentRow != null && CurrentRow.Index == i) || !GetIgnoreStateForRow(i));
            var backColor = enabled ? BackgroundColor : ColorHelper.CalculateColor(GridColor, BackgroundColor, 128);

            Rows[i].DefaultCellStyle.BackColor = backColor;
            Rows[i].DefaultCellStyle.ForeColor = enabled ? ForeColor : ColorHelper.CalculateColor(ForeColor, backColor, 128);
            base.OnRowPrePaint(e);
        }
Пример #18
0
        /// ------------------------------------------------------------------------------------
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (DrawWithGradientBackground)
            {
                var clr1 = Color.White;
                var clr2 = ColorHelper.CalculateColor(Color.White, SystemColors.GradientActiveCaption, 100);
                var rc   = ClientRectangle;
                rc.Inflate(-1, -1);

                using (var br = new LinearGradientBrush(rc, clr1, clr2, 45f))
                    e.Graphics.FillRectangle(br, rc);
            }
        }
Пример #19
0
        /// ------------------------------------------------------------------------------------
        public ComponentFileGrid()
        {
            ShowContextMenu = true;

            Logger.WriteEvent("ComponentFileGrid constructor");

            InitializeComponent();
            Font = Program.DialogFont;
            _toolStripActions.Renderer = new SIL.Windows.Forms.NoToolStripBorderRenderer();

            try
            {
                // Setting AllowDrop when tests are running throws an exception and
                // I'm not quite sure why, even after using reflector to look at the
                // code behind setting the property. Nonetheless, I've seen this before
                // so I'm just going to ignore any exception thrown when enabling drag
                // and drop. The worst that could happen by ignorning an exception
                // when the user runs the program (which should never happen), is that
                // they won't have the drag/drop feature.
                _grid.AllowDrop = true;
            }
            catch { }

            _grid.DragEnter         += HandleFileGridDragEnter;
            _grid.DragDrop          += HandleFileGridDragDrop;
            _grid.CellMouseClick    += HandleFileGridCellMouseClick;
            _grid.CellValueNeeded   += HandleFileGridCellValueNeeded;
            _grid.CellDoubleClick   += HandleFileGridCellDoubleClick;
            _grid.CurrentRowChanged += HandleFileGridCurrentRowChanged;
            _grid.Paint             += HandleFileGridPaint;
            _grid.CellPainting      += HandleFileGridCellPainting;
            _grid.ClientSizeChanged += HandleFileGridClientSizeChanged;
            _grid.Font = Program.DialogFont;

            _grid.IsOkToChangeRows = (() => (IsOKToSelectDifferentFile == null || IsOKToSelectDifferentFile()));

            var clr = ColorHelper.CalculateColor(Color.White,
                                                 _grid.DefaultCellStyle.SelectionBackColor, 140);

            _grid.PaintFullRowFocusRectangle          = true;
            _grid.FullRowFocusRectangleColor          = _grid.DefaultCellStyle.SelectionBackColor;
            _grid.DefaultCellStyle.SelectionBackColor = clr;
            _grid.DefaultCellStyle.SelectionForeColor = _grid.DefaultCellStyle.ForeColor;

            _menuDeleteFile.Click += ((s, e) => DeleteFile());

            LocalizeItemDlg <TMXDocument> .StringsLocalized += HandleStringsLocalized;
        }
Пример #20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="FwBasicGrid"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public FwBasicGrid()
        {
            m_selCellBackColor =
                ColorHelper.CalculateColor(SystemColors.Window, SystemColors.Highlight, 200);

            m_selRowBackColor =
                ColorHelper.CalculateColor(SystemColors.Window, SystemColors.Highlight, 150);

            m_selCellForeColor = SystemColors.WindowText;
            m_selRowForeColor  = SystemColors.WindowText;

            DefaultCellStyle.SelectionForeColor = m_selRowForeColor;
            DefaultCellStyle.SelectionBackColor = m_selRowBackColor;

            //BorderStyle = (Application.VisualStyleState == VisualStyleState.NoneEnabled ?
            //    BorderStyle.Fixed3D : BorderStyle.FixedSingle);
        }
Пример #21
0
        /// ------------------------------------------------------------------------------------
        public FieldsValuesGrid(FieldsValuesGridViewModel model, string name)
        {
            Name = name;

            // ReSharper disable once UseObjectOrCollectionInitializer
            _locExtender = new L10NSharpExtender();
            _locExtender.LocalizationManagerId = "SayMore";
            _locExtender.SetLocalizingId(this, "FieldsAndValuesGrid");

            VirtualMode       = true;
            Font              = Program.DialogFont;
            _factoryFieldFont = new Font(Font, FontStyle.Bold);

            AllowUserToDeleteRows = true;
            MultiSelect           = false;
            Margin            = new Padding(0, Margin.Top, 0, Margin.Bottom);
            RowHeadersVisible = false;
            DefaultCellStyle.SelectionForeColor = DefaultCellStyle.ForeColor;

            _focusedSelectionBackColor = ColorHelper.CalculateColor(Color.White,
                                                                    DefaultCellStyle.SelectionBackColor, 140);

            SetSelectionColors(false);

            _model = model;

            AddColumns();

            RowCount = _model.RowData.Count;

            // setting AllowUserToAddRows=True will add a blank line
            AllowUserToAddRows = _model.AllowUserToAddRows;

            AutoResizeRows();

            _model.ComponentFileChanged = HandleComponentFileChanged;

            if (!string.IsNullOrEmpty(_model.GridSettingsName) &&
                Settings.Default[_model.GridSettingsName] != null)
            {
                ((GridSettings)Settings.Default[_model.GridSettingsName]).InitializeGrid(this);
            }
        }
Пример #22
0
        /// ------------------------------------------------------------------------------------
        private void DrawBoundarySelectedAtX(Graphics g, int dx, int penSelector = 0)
        {
            if (dx == 0)
            {
                return;
            }

            var pen       = _solidBorderPens[penSelector];
            var baseColor = pen.Color;

            int clientHeight = (Control == null ? 0 : Control.ClientSize.Height);
            var fillColor    = ColorHelper.CalculateColor(Color.White, baseColor, 200);

            int regionHeight = Math.Min(30, clientHeight / 6);
            int arrowHeight  = kBoundaryHotZoneHalfWidth;

            var path = new GraphicsPath();

            path.AddLine(dx - kBoundaryHotZoneHalfWidth, 0, dx - kBoundaryHotZoneHalfWidth, regionHeight - arrowHeight);
            path.AddLine(dx - kBoundaryHotZoneHalfWidth, regionHeight - arrowHeight, dx, regionHeight);
            path.AddLine(dx, regionHeight, dx + kBoundaryHotZoneHalfWidth, regionHeight - arrowHeight);
            path.AddLine(dx + kBoundaryHotZoneHalfWidth, regionHeight - arrowHeight, dx + kBoundaryHotZoneHalfWidth, 0);

            using (var br = new LinearGradientBrush(path.GetBounds(), fillColor, baseColor, 90f))
            {
                g.FillRegion(br, new Region(path));
                g.DrawPath(pen, path);
            }

            path.Reset();

            path.AddLine(dx - kBoundaryHotZoneHalfWidth, clientHeight, dx - kBoundaryHotZoneHalfWidth, (clientHeight - 1) - (regionHeight - arrowHeight));
            path.AddLine(dx - kBoundaryHotZoneHalfWidth, (clientHeight - 1) - (regionHeight - arrowHeight), dx, (clientHeight - 1) - regionHeight);
            path.AddLine(dx, (clientHeight - 1) - regionHeight, dx + kBoundaryHotZoneHalfWidth, (clientHeight - 1) - (regionHeight - arrowHeight));
            path.AddLine(dx + kBoundaryHotZoneHalfWidth, (clientHeight - 1) - (regionHeight - arrowHeight), dx + kBoundaryHotZoneHalfWidth, clientHeight);

            using (var br = new LinearGradientBrush(path.GetBounds(), baseColor, fillColor, 90f))
            {
                g.FillRegion(br, new Region(path));
                g.DrawPath(pen, path);
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Paints the background of the OK and Reset buttons.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private bool HandleButtonDrawBackground(XButton btn, PaintEventArgs e, PaintState state)
        {
            if (state == PaintState.Hot || state == PaintState.HotDown)
            {
                return(false);
            }

            var   rc  = btn.ClientRectangle;
            Color clr = ColorHelper.CalculateColor(Color.White, BackColor, 100);

            using (SolidBrush br = new SolidBrush(clr))
                e.Graphics.FillRectangle(br, rc);

            rc.Width--;
            rc.Height--;
            clr = ColorHelper.CalculateColor(Color.Black, BackColor, 70);
            using (Pen pen = new Pen(clr))
                e.Graphics.DrawRectangle(pen, rc);

            //btn.DrawText(e);
            return(true);
        }
Пример #24
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="OverviewVw"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public OverviewVw(SpongeProject project, StatisticsViewModel statisticsModel)
        {
            InitializeComponent();

            gridGenre.Rows.Add(10);
            gridTasks.Rows.Add(10);

            gridGenre.AlternatingRowsDefaultCellStyle.BackColor =
                ColorHelper.CalculateColor(Color.Black, gridGenre.DefaultCellStyle.BackColor, 10);

            gridTasks.AlternatingRowsDefaultCellStyle.BackColor =
                ColorHelper.CalculateColor(Color.Black, gridTasks.DefaultCellStyle.BackColor, 10);

            var statisticsView = new StatisticsView(statisticsModel);

            this.Controls.Add(statisticsView);

            _viewBtnManger = new ViewButtonManager(tsOverview,
                                                   new Control[] { statisticsView, gridGenre, pnlContributor, gridTasks });

            _viewBtnManger.SetView(tsbStatistics);
        }
Пример #25
0
/// ------------------------------------------------------------------------------------
/// <summary>
/// Fills the specified rectangle with a gradient background consistent with the
/// current system's color scheme.
/// </summary>
/// ------------------------------------------------------------------------------------
        public static void DrawGradientBackground(Graphics g, Rectangle rc, bool makeDark)
        {
            Color clrTop;
            Color clrBottom;

            if (makeDark)
            {
                clrTop = ColorHelper.CalculateColor(Color.White,
                                                    SystemColors.ActiveCaption, 70);

                clrBottom = ColorHelper.CalculateColor(SystemColors.ActiveCaption,
                                                       SystemColors.ActiveCaption, 0);
            }
            else
            {
                clrTop = ColorHelper.CalculateColor(Color.White,
                                                    SystemColors.GradientActiveCaption, 190);

                clrBottom = ColorHelper.CalculateColor(SystemColors.ActiveCaption,
                                                       SystemColors.GradientActiveCaption, 50);
            }

            DrawGradientBackground(g, rc, clrTop, clrBottom);
        }
Пример #26
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Add columns to grid.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void AddColumns()
        {
            // Add the HexIpa field column.
            DataGridViewColumn col = SilGrid.CreateTextBoxColumn(kHexadecimal);

            col.HeaderText = Utils.ConvertLiteralNewLines(Properties.Resources.kstidIpaGridHexIpa);
            col.SortMode   = DataGridViewColumnSortMode.Programmatic;
            col.ReadOnly   = true;
            col.Frozen     = true;
            col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            col.DefaultCellStyle.BackColor = ColorHelper.CalculateColor(Color.Black, SystemColors.Window, 15);
            Grid.Columns.Add(col);

            // Add the IpaChar field column.
            col            = SilGrid.CreateTextBoxColumn(kLiteral);
            col.HeaderText = Utils.ConvertLiteralNewLines(Properties.Resources.kstidIpaGridIpaChar);
            col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            col.DefaultCellStyle.Font      = App.PhoneticFont;
            col.CellTemplate.Style.Font    = App.PhoneticFont;
            col.DefaultCellStyle.BackColor = ColorHelper.CalculateColor(Color.Black, SystemColors.Window, 15);
            col.SortMode = DataGridViewColumnSortMode.Programmatic;
            col.ReadOnly = true;
            col.Frozen   = true;
            Grid.Columns.Add(col);

            // Add the Name field column.
            col            = SilGrid.CreateTextBoxColumn(kName);
            col.HeaderText = Properties.Resources.kstidIpaGridName;
            col.SortMode   = DataGridViewColumnSortMode.Programmatic;
            Grid.Columns.Add(col);

            // Add the Description field column.
            col            = SilGrid.CreateTextBoxColumn(kDescription);
            col.HeaderText = Properties.Resources.kstidIpaGridDesc;
            col.SortMode   = DataGridViewColumnSortMode.Programmatic;
            Grid.Columns.Add(col);

            // Add the CharType drop down list combo box column.
            col = SilGrid.CreateDropDownListComboBoxColumn(
                kType, Enum.GetNames(typeof(IPASymbolType)).Cast <object>());
            col.HeaderText = Properties.Resources.kstidIpaGridCharType;
            col.SortMode   = DataGridViewColumnSortMode.Programmatic;
            Grid.Columns.Add(col);

            // Add the CharSubType drop down list combo box column.
            col = SilGrid.CreateDropDownListComboBoxColumn(
                kSubType, Enum.GetNames(typeof(IPASymbolSubType)).Cast <object>());
            col.HeaderText = Properties.Resources.kstidIpaGridCharSubType;
            col.SortMode   = DataGridViewColumnSortMode.Programmatic;
            Grid.Columns.Add(col);

            // Add the CharIgnoreType drop down list combo box column.
            col = SilGrid.CreateDropDownListComboBoxColumn(
                kIgnoreType, Enum.GetNames(typeof(IPASymbolIgnoreType)).Cast <object>());
            col.HeaderText = Properties.Resources.kstidIpaGridCharIgnoreType;
            col.SortMode   = DataGridViewColumnSortMode.Programmatic;
            Grid.Columns.Add(col);

            // Add the IsBaseChar check box column.
            col            = SilGrid.CreateCheckBoxColumn(kIsBase);
            col.HeaderText = Properties.Resources.kstidIpaGridIsBase;
            col.SortMode   = DataGridViewColumnSortMode.Programmatic;
            col.ValueType  = typeof(bool);
            Grid.Columns.Add(col);

            // Add the Can preceed base character check box column.
            col            = SilGrid.CreateCheckBoxColumn(kCanPrecedeBase);
            col.HeaderText = Utils.ConvertLiteralNewLines(Properties.Resources.kstidIpaGridCanPreceedBase);
            col.SortMode   = DataGridViewColumnSortMode.Programmatic;
            col.ValueType  = typeof(bool);
            Grid.Columns.Add(col);

            // Add the DisplayWDottedCircle check box column.
            col            = SilGrid.CreateCheckBoxColumn(kDisplayWithDottedCircle);
            col.HeaderText = Utils.ConvertLiteralNewLines(Properties.Resources.kstidIpaGridWDotCircle);
            col.SortMode   = DataGridViewColumnSortMode.Programmatic;
            col.ValueType  = typeof(bool);
            Grid.Columns.Add(col);

            //// Add the MOA column.
            //col = SilGrid.CreateTextBoxColumn(kMOA);
            //col.HeaderText = Properties.Resources.kstidIpaGridMOA;
            //col.SortMode = DataGridViewColumnSortMode.Automatic;
            //col.ValueType = typeof(int);
            //if (!m_amTesting)
            //    col.Visible = false;
            //Grid.Columns.Add(col);

            //// Add the POA column.
            //col = SilGrid.CreateTextBoxColumn(kPOA);
            //col.HeaderText = Properties.Resources.kstidIpaGridPOA;
            //col.SortMode = DataGridViewColumnSortMode.Automatic;
            //col.ValueType = typeof(int);
            //if (!m_amTesting)
            //    col.Visible = false;
            //Grid.Columns.Add(col);

            // Add the articulatory Mask field.
            col            = SilGrid.CreateTextBoxColumn(kAFeatures);
            col.HeaderText = Properties.Resources.kstidAfeaturesHdg;
            col.SortMode   = DataGridViewColumnSortMode.Programmatic;
            col.ReadOnly   = true;
            Grid.Columns.Add(col);

            // Add the binary Mask field.
            col            = SilGrid.CreateTextBoxColumn(kBFeatures);
            col.HeaderText = Properties.Resources.kstidBFeaturesHdg;
            col.SortMode   = DataGridViewColumnSortMode.Programmatic;
            col.ReadOnly   = true;
            Grid.Columns.Add(col);
        }