Esempio n. 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics         g    = e.Graphics;
            ExtendedGraphics eg   = new ExtendedGraphics(g);
            Rectangle        rect = e.ClipRectangle;

            Pen pen = new Pen(frameColor, framePenWidth);

            //
            // Context
            //
            if (contextID != null)
            {
                int ctxSquareX = Width - framePenWidth - 2 - ctxSquareWidth;
                int ctxSquareY = framePenWidth + 2;

                Color c1, c2;
                colorPool.GetColorsForId(contextID, out c1, out c2);

                eg.DrawRoundRectangle(new Pen(c2, framePenWidth),
                                      ctxSquareX, ctxSquareY,
                                      ctxSquareWidth, ctxSquareWidth, 2);

                g.FillRectangle(new SolidBrush(c1),
                                ctxSquareX + framePenWidth, ctxSquareY + framePenWidth,
                                ctxSquareWidth - framePenWidth,
                                ctxSquareWidth - framePenWidth);
            }

            //
            // Draw a round outer frame
            //
            eg.DrawRoundRectangle(pen, 0, 0, Width - framePenWidth, Height - framePenWidth, 4.0f);
        }
Esempio n. 2
0
        /// <summary>
        /// To Set the smart Part Height
        /// </summary>
        /// <param name="recordCount">Record Count</param>
        private void SetSmartPartHeight(int recordCount)
        {
            if (recordCount > 5)
            {
                if (recordCount > 10)
                {
                    recordCount = 10;
                }

                int increment = ((recordCount - 5) * 21);
                this.AuditTrailDataPanel.Height  = 164 + increment;
                this.AuditTrailDataGrid.Height   = 165 + increment;
                this.AuditTrailPictureBox.Height = this.AuditTrailDataPanel.Height;
                this.AuditTrailPictureBox.Image  = ExtendedGraphics.GenerateVerticalImage(this.AuditTrailPictureBox.Height, this.AuditTrailPictureBox.Width, this.sectionIndicatorText, this.redColor, this.greenColor, this.blueColor);
                this.Height = this.AuditTrailPictureBox.Height;
                ////To Assgin Empty Row at End of the Row
                this.AuditTrailDataGrid.DisplayLayout.EmptyRowSettings.ShowEmptyRows = false;
                this.AuditTrailDataGrid.DisplayLayout.EmptyRowSettings.Style         = EmptyRowStyle.AlignWithDataRows;
            }
            else
            {
                this.AuditTrailDataPanel.Height  = 164;
                this.AuditTrailDataGrid.Height   = 164 + 1;
                this.AuditTrailPictureBox.Height = this.AuditTrailDataPanel.Height;
                this.AuditTrailPictureBox.Image  = ExtendedGraphics.GenerateVerticalImage(this.AuditTrailPictureBox.Height, this.AuditTrailPictureBox.Width, this.sectionIndicatorText, this.redColor, this.greenColor, this.blueColor);
                this.Height = this.AuditTrailPictureBox.Height;

                ////To Assgin Empty Row at End of the Row
                this.AuditTrailDataGrid.DisplayLayout.EmptyRowSettings.ShowEmptyRows = true;
                this.AuditTrailDataGrid.DisplayLayout.EmptyRowSettings.Style         = EmptyRowStyle.AlignWithDataRows;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Handles the Load event of the F15004 control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 private void F15004_Load(object sender, EventArgs e)
 {
     try
     {
         this.FlagSliceForm = true;
         this.AgencyId      = this.keyId;
         this.CustomizeDisbursementHistoryGridView();
         this.PopulateAgencyMgmtDetails(this.AgencyId);
         ////this.AgencyNameTextBox.ReadOnly = true;
         this.TabPictureBox.Image                 = ExtendedGraphics.GenerateVerticalImage(this.TabPictureBox.Height, this.TabPictureBox.Width, "Tab", 28, 81, 128);
         this.ContactAPictureBox.Image            = ExtendedGraphics.GenerateVerticalImage(this.ContactAPictureBox.Height, this.ContactAPictureBox.Width, "Contact A", 174, 150, 94);
         this.ContactBPictureBox.Image            = ExtendedGraphics.GenerateVerticalImage(this.ContactBPictureBox.Height, this.ContactBPictureBox.Width, "Contact B", 174, 150, 94);
         this.DisbursementHistoryPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.DisbursementHistoryPictureBox.Height, this.DisbursementHistoryPictureBox.Width, "Disbursements", 0, 51, 0);
         this.AgencyNameTextBox.Focus();
         ////this.SubFundsListPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.SubFundsListPictureBox.Height, this.SubFundsListPictureBox.Width, "SubFund", 28, 81, 128);
         ////this.DisbursementHistoryPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.DisbursementHistoryPictureBox.Height, this.DisbursementHistoryPictureBox.Width, "Disbursement History", 174, 150, 94);
         ////this.PopulateSubFundDetais();
     }
     catch (SoapException ex)
     {
         ExceptionManager.ManageException(ex, ExceptionManager.ActionType.CloseCurrentForm, this.ParentForm);
     }
     catch (Exception exc)
     {
         ExceptionManager.ManageException(exc, ExceptionManager.ActionType.CloseCurrentForm, this.ParentForm);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Sets the height of the smart part.
        /// </summary>
        /// <param name="recordCount">The record count.</param>
        private void SetSmartPartHeight(int recordCount)
        {
            if (recordCount > 7)
            {
                if (recordCount > 7)
                {
                    recordCount = 7;
                }

                int increment = ((recordCount - 3) * 22);
                this.AssociatedGridView.Height          = 88 + increment;
                this.AssociatePanel.Height              = this.AssociatedGridView.Height;
                this.AssociateReceiptVscrollBar.Height  = 88 + increment - 2;
                this.AssociatePaymentsPictureBox.Height = 88 + increment;
                this.AssociatePaymentsPictureBox.Image  = ExtendedGraphics.GenerateVerticalImage(this.AssociatePaymentsPictureBox.Height, this.AssociatePaymentsPictureBox.Width, this.sectionIndicatorTabText, this.redColor, this.greenColor, this.blueColor);
                this.AssociatedGridView.NumRowsVisible  = recordCount;
                this.Height = this.AssociatePaymentsPictureBox.Height;
            }

            else
            {
                this.AssociatedGridView.Height          = 178;
                this.AssociatePanel.Height              = this.AssociatedGridView.Height - 1;
                this.AssociateReceiptVscrollBar.Height  = this.AssociatedGridView.Height - 1;
                this.AssociatePaymentsPictureBox.Height = this.AssociatedGridView.Height - 1;
                this.AssociatedGridView.NumRowsVisible  = 7;
                this.Height = this.AssociatedGridView.Height;
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:F2550"/> class.
 /// </summary>
 public F9080()
 {
     InitializeComponent();
     this.ParcelPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.formPanel.Height - 4, this.ParcelPictureBox.Width, "Roll Year Management", 28, 81, 128);
     //this.FormClose += new EventHandler<DataEventArgs<string>>(F9080_FormClose);
     // this.ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing);
 }
Esempio n. 6
0
        /// <summary>
        /// Sets the height of the smart part.
        /// </summary>
        /// <param name="recordCount">The record count.</param>
        private void SetSmartPartHeight(int recordCount)
        {
            if (recordCount > 4)
            {
                if (recordCount > 8)
                {
                    recordCount = 8;
                }

                int increment = ((recordCount - 4) * 22);
                this.InspectionDetailsGridView.Height = 111 + increment;
                this.GridPanel.Height = this.InspectionDetailsGridView.Height;
                this.InspectionDetailsGridVscrollBar.Height    = 111 + increment - 4;
                this.DistrictInfoSecIndicatorPictureBox.Height = 153 + increment;
                this.panel2.Top = CommentPanel.Height + this.GridPanel.Height - 4;
                this.panel4.Top = this.panel2.Top;
                this.InspectionDetailsGridView.NumRowsVisible = recordCount;
                this.Height = this.DistrictInfoSecIndicatorPictureBox.Height;
                this.DistrictInfoSecIndicatorPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(153, this.DistrictInfoSecIndicatorPictureBox.Width, this.sectionIndicatorTabText, this.redColor, this.greenColor, this.blueColor);
            }
            else
            {
                this.InspectionDetailsGridView.Height = 111;
                this.GridPanel.Height = this.InspectionDetailsGridView.Height;
                this.InspectionDetailsGridVscrollBar.Height = this.InspectionDetailsGridView.Height - 4;
                this.panel2.Top = CommentPanel.Height + this.GridPanel.Height - 4;
                this.panel4.Top = this.panel2.Top;
                this.DistrictInfoSecIndicatorPictureBox.Height = 153;
                this.InspectionDetailsGridView.NumRowsVisible  = 4;
                this.Height = 153;
                this.DistrictInfoSecIndicatorPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(153, this.DistrictInfoSecIndicatorPictureBox.Width, this.sectionIndicatorTabText, this.redColor, this.greenColor, this.blueColor);
            }
        }
Esempio n. 7
0
        public void OnD9030_F9030_LoadSliceDetails(object sender, DataEventArgs <SliceReloadActiveRecord> eventArgs)
        {
            try
            {
                if (this.masterFormNo == eventArgs.Data.MasterFormNo)
                {
                    this.ReceiptOwnersDataGridView.Refresh();
                    this.keyId         = eventArgs.Data.SelectedKeyId;
                    this.FlagSliceForm = true;
                    this.CustomizeReceiptOwnersGrid();
                    this.rowCount = this.form15103ReceiptOwnersData.ListReceiptOwners.Rows.Count;
                    if (this.rowCount > 0)
                    {
                        this.ReceiptOwnersDataGridView.DataSource = this.form15103ReceiptOwnersData.ListReceiptOwners.DefaultView;
                    }
                    else
                    {
                        this.form15103ReceiptOwnersData.ListReceiptOwners.Clear();
                        this.ReceiptOwnersDataGridView.DataSource = this.form15103ReceiptOwnersData.ListReceiptOwners.DefaultView;
                    }

                    this.ReceiptOwnersDataGridView.Refresh();
                    this.SetSmartPartHeight(this.rowCount);
                    this.ReceiptOwnerspicturebox.Image = ExtendedGraphics.GenerateVerticalImage(this.ReceiptOwnerspicturebox.Height, this.ReceiptOwnerspicturebox.Width, this.sectionIndicatorTabText, this.redColor, this.greenColor, this.blueColor);
                    this.Height = this.ReceiptOwnerspicturebox.Height;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.ManageException(ex, ExceptionManager.ActionType.CloseCurrentForm, this.ParentForm);
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:F8042"/> class.
 /// </summary>
 /// <param name="masterform">The master Form No</param>
 /// <param name="formNo">The Form No</param>
 /// <param name="keyID">KeyID</param>
 /// <param name="red">Picturebox color</param>
 /// <param name="green">pictureboxcolor</param>
 /// <param name="blue">picturebox color</param>
 /// <param name="tabText">tabText</param>
 /// <param name="permissionEdit">permissionEdit</param>
 public F15016(int masterform, int formNo, int keyID, int red, int green, int blue, string tabText, bool permissionEdit)
 {
     this.InitializeComponent();
     this.masterFormNo     = masterform;
     this.keyID            = keyID;
     this.PictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.PictureBox.Height, this.PictureBox.Width, tabText, red, green, blue);
 }
Esempio n. 9
0
        public void Draw(Graphics g, SwitchBase sw, DrawableBase parent, RenderingEngine e)
        {
            const float offset = 10;
            const float radius = 4;
            var         r      = sw.SelectionBounds;

            StringFormat format = new StringFormat();

            var textBounds = g.MeasureString(this.Title, FontTitle, r.Size, format);

            r = new RectangleF(r.X, r.Y - offset - textBounds.Height, r.Width, textBounds.Height);

            ExtendedGraphics extendedGraphics = new ExtendedGraphics(g, e);

            var brush = GetMainBrush(r);

            extendedGraphics.FillRoundRectangle(brush, r.X, r.Y, r.Width, r.Height, radius);
            extendedGraphics.DrawRoundRectangle(Pen, r.X, r.Y, r.Width, r.Height, radius);

            r = new RectangleF(r.X + 4, r.Y, r.Width, r.Height);

            var r1 = new RectangleF(r.X + 0.5f, r.Y + 0.5f, r.Width, r.Height);
            var r2 = new RectangleF(r.X, r.Y, r.Width, r.Height);

            g.DrawString(Title, FontTitle, Brushes.Black, r1, format);
            g.DrawString(Title, FontTitle, Brushes.White, r2, format);
        }
Esempio n. 10
0
        /// <summary>
        /// Sets the height of the smart part.
        /// </summary>
        /// <param name="recordCount">The record count.</param>
        private void SetSmartPartHeight(int recordCount)
        {
            if (recordCount > 3)
            {
                if (recordCount > 6)
                {
                    recordCount = 6;
                }

                int increment = ((recordCount - 3) * 22);
                this.SitusManagementGrid.Height         = 89 + increment;
                this.SitusGridpanel.Height              = this.SitusManagementGrid.Height;
                this.SitusGridVerticalScroll.Height     = 89 + increment;
                this.SitusManagementMainPanel.Height    = 151 + increment;
                this.SitusManagementPictureBox.Height   = 151 + increment;
                this.SitusManagementPictureBox.Image    = ExtendedGraphics.GenerateVerticalImage(this.SitusManagementPictureBox.Height, this.SitusManagementPictureBox.Width, this.sectionIndicatorText, this.redColor, this.greenColor, this.blueColor);
                this.SitusManagementGrid.NumRowsVisible = recordCount;
                this.Height = this.SitusManagementPictureBox.Height;
            }
            else
            {
                this.SitusManagementGrid.Height         = 89;
                this.SitusGridpanel.Height              = this.SitusManagementGrid.Height;
                this.SitusGridVerticalScroll.Height     = this.SitusManagementGrid.Height; //// -1;
                this.SitusManagementMainPanel.Height    = 151;
                this.SitusManagementPictureBox.Height   = 151;
                this.SitusManagementGrid.NumRowsVisible = 3;
                this.Height = 151;
            }

            this.TitlePanel.Top       = this.SitusGridpanel.Bottom - 1;
            this.SitusButtonPanel.Top = this.TitlePanel.Bottom - 1;
        }
Esempio n. 11
0
        public virtual void DrawBody(Graphics g, RenderingEngine e, DrawableBase parent)
        {
            ExtendedGraphics extendedGraphics = new ExtendedGraphics(g, e);

            var r = Rectangle;

            Brush brush;

            if (IsSelected)
            {
                brush = GetMainSelectionBrush(r, e);
            }
            else if (DebugMode)
            {
                brush = GetDebugBrush(r, e);
            }
            else if (DebugDataMode)
            {
                brush = GetDebugDataBrush(r, e);
            }
            else
            {
                brush = GetMainBrush(r, e);
            }

            const float radius = 3;

            extendedGraphics.FillRoundRectangle(brush, r.X, r.Y, r.Width, r.Height, radius);
            extendedGraphics.DrawRoundRectangle(Pen, r.X, r.Y, r.Width, r.Height, radius);
        }
Esempio n. 12
0
        public virtual void DrawGlyph(Graphics g, RenderingEngine e, DrawableBase parent)
        {
            var r = DescriptionBounds;

            if (r.Height > 0)
            {
                //r.Height -= compactOffset2

                ExtendedGraphics extendedGraphics = new ExtendedGraphics(g, e);

                float radius = 2;

                var brush = new SolidBrush(Color.FromArgb(40, 0, 0, 0));
                extendedGraphics.FillRoundRectangle(brush, r.X, r.Y + 1, r.Width, r.Height - 1, radius);

                var img = GlyphImage;
                if (DrawGlyphImage && img != null)
                {
                    float ratio     = r.Height / img.Height;
                    var   imageRect = r;

                    imageRect.Width  = img.Width * ratio;
                    imageRect.Height = img.Height * ratio;

                    imageRect.X = r.X + r.Width * 0.5f - imageRect.Width * 0.5f;
                    imageRect.Y = r.Y + r.Height * 0.5f - imageRect.Height * 0.5f;
                    g.DrawImage(img, imageRect);
                }
            }
        }
Esempio n. 13
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;

            if (navBitmap == null)
            {
                g.FillRectangle(new SolidBrush(Color.White), e.ClipRectangle);
            }
            else
            {
                g.DrawImage(navBitmap, 0, 0);
            }

            // Find the current viewport
            int x = StaticUtils.GetScrollPos(timeline.Handle, StaticUtils.SB_HORZ);
            int y = StaticUtils.GetScrollPos(timeline.Handle, StaticUtils.SB_VERT);

            if (x >= 0 && y >= 0)
            {
                float ratioX, ratioY;
                GetRatios(out ratioX, out ratioY);

                int w = timeline.ClientRectangle.Width;
                int h = timeline.ClientRectangle.Height;

                Pen pen = new Pen(ForeColor);

                // Scale it down to our miniature
                x = (int)((float)x * ratioX);
                y = (int)((float)y * ratioY);

                w = (int)((float)w * ratioX);
                if (w >= ClientRectangle.Width)
                {
                    w = ClientRectangle.Width - (int)pen.Width;
                }

                h = (int)((float)h * ratioY);
                if (h >= ClientRectangle.Height)
                {
                    h = ClientRectangle.Height - (int)pen.Width;
                }

                if (w < 1)
                {
                    w = 1;
                }
                if (h < 1)
                {
                    h = 1;
                }

                ExtendedGraphics eg = new ExtendedGraphics(g);
                eg.FillRoundRectangle(new SolidBrush(Color.FromArgb(127, 0x9B, 0x57, 0x9F)),
                                      x, y, w, h, 3);
                eg.DrawRoundRectangle(pen, x, y, w, h, 3);
            }
        }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:F8042"/> class.
 /// </summary>
 /// <param name="masterform">The masterform.</param>
 /// <param name="formNo">The form no.</param>
 /// <param name="keyID">The key ID.</param>
 /// <param name="red">The red.</param>
 /// <param name="green">The green.</param>
 /// <param name="blue">The blue.</param>
 /// <param name="tabText">The tab text.</param>
 /// <param name="permissionEdit">if set to <c>true</c> [permission edit].</param>
 public F8046(int masterform, int formNo, int keyID, int red, int green, int blue, string tabText, bool permissionEdit)
 {
     this.InitializeComponent();
     this.masterFormNo = masterform;
     this.keyID        = keyID;
     this.MaterialsFooterPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(37, 42, string.Empty, red, green, blue);
 }
Esempio n. 15
0
        private void DueDateGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                for (int i = 0; i < this.DueDateGridView.Rows.Count; i++)
                {
                    TerraScanTextAndImageCell FirstDueCell = (TerraScanTextAndImageCell)this.DueDateGridView[this.DueDatePostDetailsTable.FirstDueColumn.ColumnName, i];
                    FirstDueCell.ImagexLocation = 99;
                    FirstDueCell.ImageyLocation = 2;

                    TerraScanTextAndImageCell secondDueCell = (TerraScanTextAndImageCell)this.DueDateGridView[this.DueDatePostDetailsTable.SecondDueColumn.ColumnName, i];

                    secondDueCell.ImagexLocation = 99;
                    secondDueCell.ImageyLocation = 2;
                    if (e.RowIndex == i)
                    {
                        FirstDueCell.Image  = Properties.Resources.calendarImage;
                        secondDueCell.Image = Properties.Resources.calendarImage;
                    }
                    else
                    {
                        if (e.RowIndex >= 0)
                        {
                            FirstDueCell.Image  = ExtendedGraphics.GenerateImage(1, 1, Convert.ToInt32(this.DueDateGridView[this.DueDateGridView.Columns["FirstDue"].Index, e.RowIndex].InheritedStyle.BackColor.R), Convert.ToInt32(this.DueDateGridView[0, e.RowIndex].InheritedStyle.BackColor.G), Convert.ToInt32(this.DueDateGridView[0, e.RowIndex].InheritedStyle.BackColor.B));
                            secondDueCell.Image = ExtendedGraphics.GenerateImage(1, 1, Convert.ToInt32(this.DueDateGridView[this.DueDateGridView.Columns["SecondDue"].Index, e.RowIndex].InheritedStyle.BackColor.R), Convert.ToInt32(this.DueDateGridView[0, e.RowIndex].InheritedStyle.BackColor.G), Convert.ToInt32(this.DueDateGridView[0, e.RowIndex].InheritedStyle.BackColor.B));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.ManageException(ex, ExceptionManager.ActionType.CloseCurrentForm, this.ParentForm);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Sets the height of the form slice.
        /// </summary>
        /// <param name="rowCount">The row count.</param>
        private void SetFormSliceHeight(int rowCount)
        {
            if (rowCount > 5)
            {
                int setCurrentHeight = (rowCount - 5) * 21;
                this.EntireDepreciationTablePanel.Height = 155 + setCurrentHeight;

                this.DeprTablePictureBox.Height = this.EntireDepreciationTablePanel.Height;
                this.Height = this.DeprTablePictureBox.Height;
                this.DepreciationControlDataGrid.Height = 1000; //// 126 + setCurrentHeight;

                this.DeprTablePictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.DeprTablePictureBox.Height, this.DeprTablePictureBox.Width, this.sectionIndicatorText, this.redColor, this.greenColor, this.blueColor);
            }
            else
            {
                //// modified the code to implement the CO:5733
                rowCount = 5;
                int setCurrentHeight = rowCount * 21;
                this.EntireDepreciationTablePanel.Height = 49 + setCurrentHeight;
                this.DeprTablePictureBox.Height          = this.EntireDepreciationTablePanel.Height;
                this.Height = this.DeprTablePictureBox.Height;
                this.DepreciationControlDataGrid.Height = 1000; //// 126 + setCurrentHeight;
                this.DeprTablePictureBox.Image          = ExtendedGraphics.GenerateVerticalImage(this.DeprTablePictureBox.Height, this.DeprTablePictureBox.Width, this.sectionIndicatorText, this.redColor, this.greenColor, this.blueColor);
            }

            //// Added this method and removed the below code as its same.
            this.FormSliceResize();
            this.DepreciationControlDataGrid.DisplayLayout.EmptyRowSettings.ShowEmptyRows = true;
        }
Esempio n. 17
0
        /// <summary>
        /// Sets the height of the smart part.
        /// </summary>
        /// <param name="recordCount">The record count.</param>
        private void SetSmartPartHeight(int recordCount)
        {
            if (recordCount > 3)
            {
                if (recordCount > 6)
                {
                    recordCount = 6;
                }

                int increment = ((recordCount - 3) * 22);
                this.ReceiptOwnersDataGridView.Height         = 88 + increment;
                this.ReceiptOwnerspanel.Height                = this.ReceiptOwnersDataGridView.Height;
                this.ReceiptOwnersVscrollBar.Height           = 88 + increment - 2;
                this.ReceiptOwnerspicturebox.Height           = 88 + increment;
                this.ReceiptOwnerspicturebox.Image            = ExtendedGraphics.GenerateVerticalImage(this.ReceiptOwnerspicturebox.Height, this.ReceiptOwnerspicturebox.Width, this.sectionIndicatorTabText, this.redColor, this.greenColor, this.blueColor);
                this.ReceiptOwnersDataGridView.NumRowsVisible = recordCount;
                this.Height = this.ReceiptOwnerspicturebox.Height;
            }
            else
            {
                this.ReceiptOwnersDataGridView.Height         = 88;
                this.ReceiptOwnerspanel.Height                = this.ReceiptOwnersDataGridView.Height;
                this.ReceiptOwnersVscrollBar.Height           = this.ReceiptOwnersDataGridView.Height - 1;
                this.ReceiptOwnerspicturebox.Height           = 88;
                this.ReceiptOwnersDataGridView.NumRowsVisible = 3;
                this.Height = 88;
            }
            ////this.ReceiptOwnersDataGridView.DataSource = this.form15103ReceiptOwnersData.ListReceiptOwners;
        }
Esempio n. 18
0
 /// <summary>
 /// Handles the Load event of the F35001 control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 private void F35001_Load(object sender, EventArgs e)
 {
     try
     {
         this.keyField      = "ValueSliceID";
         this.formNo        = 35001;
         this.FlagSliceForm = true;
         this.ValueSliceHeaderPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.ValueSliceHeaderPictureBox.Height, this.ValueSliceHeaderPictureBox.Width, "", 28, 81, 128);
         this.InitWillValueCombo();
         this.InitWillRollCombo();
         this.comboInitialized = true;
         this.PopulateValueSliceHeaderDetails();
         this.willValue = Convert.ToBoolean(this.WillValueCombo.SelectedValue);
         this.form35001Controll.WorkItem.RootWorkItem.State["WillValue"] = this.willValue;
         if (this.ParentForm != null)
         {
             this.ParentForm.ActiveControl = this.DescriptionTextBox;
             this.DescriptionTextBox.Focus();
         }
     }
     catch (SoapException ex)
     {
         ExceptionManager.ManageException(ex, ExceptionManager.ActionType.CloseCurrentForm, this.ParentForm);
     }
     catch (Exception exc)
     {
         ExceptionManager.ManageException(exc, ExceptionManager.ActionType.CloseCurrentForm, this.ParentForm);
     }
 }
Esempio n. 19
0
        /// <summary>
        /// Draw DataSeries visual (Path) for Polar
        /// </summary>
        /// <param name="series"></param>
        /// <param name="pointCollection"></param>
        /// <param name="polarCanvas"></param>
        private static void DrawDataSeriesPath(DataSeries series, List <DataPoint> pointCollection, Canvas polarCanvas)
        {
            if (series.InternalDataPoints.Count > 0)
            {
                Path path = new Path()
                {
                    Tag = new ElementData()
                    {
                        Element = series, VisualElementName = "PolarVisual"
                    }
                };

                path.Stroke           = (Boolean)series.LightingEnabled ? Graphics.GetLightingEnabledBrush(series.Color, "Linear", null) : series.Color;
                path.StrokeDashArray  = ExtendedGraphics.GetDashArray(series.LineStyle);
                path.StrokeThickness  = (Double)series.LineThickness;
                path.StrokeMiterLimit = 1;
                path.Opacity          = series.Opacity;

                path.Data = GetPathGeometry(pointCollection);

                series.Faces.Parts.Add(path);

                polarCanvas.Children.Add(path);
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Apply PlotAreaBevel
        /// </summary>
        internal void ApplyBevel(Double plankDepth, Double plankThickness)
        {
            if (_bevelCanvas != null)
            {
                BevelGrid.Children.Remove(_bevelCanvas);
                _bevelCanvas = null;
            }

            if (Bevel)
            {
                Chart chart = Chart as Chart;

                _bevelCanvas = ExtendedGraphics.Get2DRectangleBevel(this, BorderElement.Width - InternalBorderThickness.Left - InternalBorderThickness.Right// - plankDepth
                , BorderElement.Height - InternalBorderThickness.Top - InternalBorderThickness.Bottom //+ ((chart.PlotDetails.ChartOrientation == ChartOrientationType.Horizontal || chart.PlotDetails.ChartOrientation == ChartOrientationType.NoAxis) ? 0 : (-plankDepth - plankThickness))
                , Charts.Chart.BEVEL_DEPTH, Charts.Chart.BEVEL_DEPTH
                , Graphics.GetBevelTopBrush(BorderElement.Background)
                , Graphics.GetBevelSideBrush(0, BorderElement.Background)
                , Graphics.GetBevelSideBrush(180, BorderElement.Background)
                , Graphics.GetBevelSideBrush(90, BorderElement.Background));

                _bevelCanvas.SetValue(Canvas.LeftProperty, InternalBorderThickness.Left);
                _bevelCanvas.SetValue(Canvas.TopProperty, InternalBorderThickness.Top);

                _bevelCanvas.IsHitTestVisible = false;

                BevelGrid.Children.Add(_bevelCanvas);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Populates the inspection details.
        /// </summary>
        private void PopulateInspectionDetails()
        {
            // Issue Fix Code : Starts Here
            int keyIdvalid = this.form8056Control.WorkItem.F8056_CheckEventId(this.masterFormNo, this.keyId);

            if (keyIdvalid == 1)
            {
                this.DisableControls(true);
                this.DisableHeaderControls(true);

                this.inspectionDetailsDataSet = this.form8056Control.WorkItem.F8056_ListInspectionDetails(this.keyId);

                (this.InspectionDetailsGridView.Columns["Component"] as DataGridViewComboBoxColumn).DataSource    = this.componentTypeDataTable;
                (this.InspectionDetailsGridView.Columns["Component"] as DataGridViewComboBoxColumn).DisplayMember = this.componentTypeDataTable.DescriptionColumn.ColumnName;   ////"Description";
                (this.InspectionDetailsGridView.Columns["Component"] as DataGridViewComboBoxColumn).ValueMember   = this.componentTypeDataTable.ComponentIDColumn.ColumnName;   ////"ComponentID";

                (this.InspectionDetailsGridView.Columns["Condition"] as DataGridViewComboBoxColumn).DataSource    = this.conditionTypeDataTable;
                (this.InspectionDetailsGridView.Columns["Condition"] as DataGridViewComboBoxColumn).DisplayMember = this.conditionTypeDataTable.DescriptionColumn.ColumnName;   ////"Description";
                (this.InspectionDetailsGridView.Columns["Condition"] as DataGridViewComboBoxColumn).ValueMember   = this.conditionTypeDataTable.ConditionIDColumn.ColumnName;   ////"ConditionID";

                (this.InspectionDetailsGridView.Columns["Action"] as DataGridViewComboBoxColumn).DataSource    = this.actionTypeDataTable;
                (this.InspectionDetailsGridView.Columns["Action"] as DataGridViewComboBoxColumn).DisplayMember = this.actionTypeDataTable.DescriptionColumn.ColumnName; ////"Description";
                (this.InspectionDetailsGridView.Columns["Action"] as DataGridViewComboBoxColumn).ValueMember   = this.actionTypeDataTable.ActionIDColumn.ColumnName;    ////"ActionID";

                this.SetSmartPartHeight(this.inspectionDetailsDataSet.ListInspectionDetails.Rows.Count);

                if (this.inspectionDetailsDataSet.ListInspectionDetails.Rows.Count > 8)
                {
                    this.InspectionDetailsGridVscrollBar.Visible = false;
                }
                else
                {
                    this.InspectionDetailsGridVscrollBar.Visible = true;
                }

                this.InspectionDetailsGridView.DataSource = this.inspectionDetailsDataSet.ListInspectionDetails;
                SliceResize sliceResize;
                sliceResize.MasterFormNo    = this.masterFormNo;
                sliceResize.SliceFormName   = Utility.GetFormNameSpace(this.Name);
                sliceResize.SliceFormHeight = this.DistrictInfoSecIndicatorPictureBox.Height;
                if (!this.flagFormLoad)
                {
                    this.OnFormSlice_Resize(new DataEventArgs <SliceResize>(sliceResize));
                    this.DistrictInfoSecIndicatorPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.DistrictInfoSecIndicatorPictureBox.Height, this.DistrictInfoSecIndicatorPictureBox.Width, this.sectionIndicatorTabText, this.redColor, this.greenColor, this.blueColor);
                }

                if (this.InspectionDetailsGridView.OriginalRowCount == 0)
                {
                    this.InspectionDetailsGridView.CurrentCell = null;
                }
            }
            else
            {
                this.DisableControls(false);
                this.DisableHeaderControls(false);
            }

            // Issue Fix Code : Ends Here
        }
Esempio n. 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:F8102"/> class.
 /// </summary>
 /// <param name="masterform">The masterform.</param>
 /// <param name="formNo">The form no.</param>
 /// <param name="keyID">The key ID.</param>
 /// <param name="red">The red.</param>
 /// <param name="green">The green.</param>
 /// <param name="blue">The blue.</param>
 /// <param name="tabText">The tab text.</param>
 /// <param name="permissionEdit">if set to <c>true</c> [permission edit].</param>
 public F8106(int masterform, int formNo, int keyID, int red, int green, int blue, string tabText, bool permissionEdit)
 {
     this.InitializeComponent();
     this.formMasterPermissionEdit = permissionEdit;
     this.masterFormNo             = masterform;
     this.keyID = keyID;
     this.StoppageEventPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(StoppageEventPictureBox.Width, StoppageEventPictureBox.Height, string.Empty, red, green, blue);
 }
Esempio n. 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:F8052"/> class.
 /// </summary>
 /// <param name="masterform">The masterform.</param>
 /// <param name="formNo">The form no.</param>
 /// <param name="keyID">The key ID.</param>
 /// <param name="red">The red.</param>
 /// <param name="green">The green.</param>
 /// <param name="blue">The blue.</param>
 /// <param name="tabText">The tab text.</param>
 /// <param name="permissionEdit">if set to <c>true</c> [permission edit].</param>
 public F8902(int masterform, int formNo, int keyID, int red, int green, int blue, string tabText, bool permissionEdit)
 {
     this.InitializeComponent();
     this.workId                    = keyID;
     this.masterFormNo              = masterform;
     this.formMasterPermissionEdit  = permissionEdit;
     this.WorkOrderPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(39, 42, tabText, red, green, blue);
 }
Esempio n. 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="F25055"/> class.
 /// </summary>
 /// <param name="masterForm">The masterform.</param>
 /// <param name="formNo">The form no.</param>
 /// <param name="keyId">The key ID.</param>
 /// <param name="red">The red color.</param>
 /// <param name="green">The green color.</param>
 /// <param name="blue">The blue color.</param>
 /// <param name="tabText">The tab text.</param>
 /// <param name="permissionEdit">if set to <c>true</c> [permission edit].</param>
 public F25055(int masterForm, int formNo, int keyId, int red, int green, int blue, string tabText, bool permissionEdit)
 {
     InitializeComponent();
     this.masterFormNo = masterForm;
     this.Tag          = formNo;
     this.scheduleId   = keyId;
     this.PropertyHeaderPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.PropertyHeaderPictureBox.Height, this.PropertyHeaderPictureBox.Width, tabText, red, green, blue);
 }
Esempio n. 25
0
 /// <summary>
 /// Initializes a new instance of the F9008 class.
 /// </summary>
 public F9008()
 {
     this.InitializeComponent();
     ////this.formMasterPermissionEdit = permissionEdit ;
     ////this.masterFormNo = masterform ;
     this.ReportDetailspicturebox.Image = ExtendedGraphics.GenerateVerticalImage(this.ReportDetailspicturebox.Height, this.ReportDetailspicturebox.Width, "Report Printer Assignments", 28, 81, 128);
     this.form9008ReportDetailsData     = new F9008ReportDetailsData();
 }
Esempio n. 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:F8104"/> class.
 /// </summary>
 /// <param name="masterform">The masterform.</param>
 /// <param name="formNo">The form no.</param>
 /// <param name="keyID">The key ID.</param>
 /// <param name="red">The red.</param>
 /// <param name="green">The green.</param>
 /// <param name="blue">The blue.</param>
 /// <param name="tabText">The tab text.</param>
 /// <param name="permissionEdit">if set to <c>true</c> [permission edit].</param>
 public F8104(int masterform, int formNo, int keyID, int red, int green, int blue, string tabText, bool permissionEdit)
 {
     this.InitializeComponent();
     this.formMasterPermissionEdit = permissionEdit;
     this.masterFormNo             = masterform;
     this.keyId = keyID;
     this.DistrictInfoSecIndicatorPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.DistrictInfoSecIndicatorPictureBox.Height, this.DistrictInfoSecIndicatorPictureBox.Width, tabText, red, green, blue);
 }
Esempio n. 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:F84721"/> class.
 /// </summary>
 /// <param name="masterform">The masterform.</param>
 /// <param name="formNo">The form no.</param>
 /// <param name="keyID">The key ID.</param>
 /// <param name="red">The red.</param>
 /// <param name="green">The green.</param>
 /// <param name="blue">The blue.</param>
 /// <param name="tabText">The tab text.</param>
 /// <param name="permissionEdit">if set to <c>true</c> [permission edit].</param>
 public F29530(int masterform, int formNo, int keyID, int red, int green, int blue, string tabText, bool permissionEdit)
 {
     this.InitializeComponent();
     this.masterFormNo = masterform;
     this.Tag          = formNo;
     this.eventId      = keyID;
     this.AssociationEventGridpictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.AssociationEventGridpictureBox.Height, this.AssociationEventGridpictureBox.Width, string.Empty, 28, 81, 128);
 }
Esempio n. 28
0
        /// <summary>
        /// Loads the situs management grid.
        /// </summary>
        private void LoadSitusManagementGrid()
        {
            this.listSitusManagementDataTable.Clear();
            this.situsManagementData          = this.form25003Control.WorkItem.F25003_ListSitusMangement(this.parcelId, this.invalidsiusId);
            this.listSitusManagementDataTable = this.situsManagementData.ListSitusManagement;
            if (this.situsManagementData.ListParcelValidID.Rows.Count > 0)
            {
                int.TryParse(this.situsManagementData.ListParcelValidID.Rows[0][this.situsManagementData.ListParcelValidID.KeyIDColumn.ColumnName].ToString(), out this.validKeyId);
            }
            else
            {
                this.validKeyId = 0;
            }

            this.listSitusManagementDataTableRowCount = this.listSitusManagementDataTable.Rows.Count;

            if (this.listSitusManagementDataTableRowCount > 0)
            {
                this.SetSmartPartHeight(this.listSitusManagementDataTableRowCount);

                this.SitusManagementGrid.DataSource       = this.listSitusManagementDataTable.DefaultView;
                this.SitusManagementGrid.Rows[0].Selected = true;
                this.SitusManagementGrid.Enabled          = true;
                ////TerraScanCommon.SetDataGridViewPosition(this.SitusManagementGrid, 0);
                this.SitusGridpanel.Enabled    = true;
                this.TitlePanel.Enabled        = true;
                this.ModifyDeletePanel.Enabled = true;
            }
            else
            {
                this.ClearSitusManagementGrid();
                this.SitusGridpanel.Enabled    = false;
                this.TitlePanel.Enabled        = true;
                this.ModifyDeletePanel.Enabled = false;
            }

            if (this.listSitusManagementDataTableRowCount > this.SitusManagementGrid.NumRowsVisible)
            {
                this.SitusGridVerticalScroll.Visible = false;
            }
            else
            {
                this.SitusGridVerticalScroll.Visible = true;
            }

            SliceResize sliceResize;

            sliceResize.MasterFormNo    = this.masterFormNo;
            sliceResize.SliceFormName   = Utility.GetFormNameSpace(this.Name);
            sliceResize.SliceFormHeight = this.SitusManagementPictureBox.Height;
            this.OnFormSlice_Resize(new DataEventArgs <SliceResize>(sliceResize));

            if (!this.flagLoadOnProcess)
            {
                this.SitusManagementPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.SitusManagementPictureBox.Height, this.SitusManagementPictureBox.Width, this.sectionIndicatorText, this.redColor, this.greenColor, this.blueColor);
            }
        }
Esempio n. 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:F1220"/> class.
 /// </summary>
 public F1220()
 {
     InitializeComponent();
     this.registerId = -1;
     this.clid       = -1;
     this.cltypeId   = -1;
     this.AccountRegisterHeaderPictureBox.Image = ExtendedGraphics.GenerateVerticalImage(this.AccountRegisterHeaderPictureBox.Height, this.AccountRegisterHeaderPictureBox.Width, "", 0, 51, 0);
     this.PaymentGridPictureBox.Image           = ExtendedGraphics.GenerateVerticalImage(this.PaymentGridPictureBox.Height, this.PaymentGridPictureBox.Width, "Account Transactions", 28, 81, 128);
 }
Esempio n. 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:F29610"/> class.
 /// </summary>
 /// <param name="masterform">The masterform.</param>
 /// <param name="formNo">The form no.</param>
 /// <param name="keyID">The key ID.</param>
 /// <param name="red">The red.</param>
 /// <param name="green">The green.</param>
 /// <param name="blue">The blue.</param>
 /// <param name="tabText">The tab text.</param>
 /// <param name="permissionEdit">if set to <c>true</c> [permission edit].</param>
 public F29610(int masterform, int formNo, int keyID, int red, int green, int blue, string tabText, bool permissionEdit)
 {
     this.InitializeComponent();
     this.masterFormNo             = masterform;
     this.Tag                      = formNo;
     this.eventId                  = keyID;
     this.formMasterPermissionEdit = permissionEdit;
     this.HoHpictureBox.Image      = ExtendedGraphics.GenerateVerticalImage(this.HoHpictureBox.Height, this.HoHpictureBox.Width, tabText, red, green, blue);
 }
Esempio n. 31
0
        /// <summary>
        /// Get a spectrum of the signal specified at the input
        /// </summary>
        /// <param name="mag">array of magnitude values as decibel</param>
        /// <param name="freq">array of frequency values as herz</param>
        /// <param name="imageSize">Size of image</param>
        /// <param name="minFrequency">minimum frequency to show</param>
        /// <param name="maxFrequency">maximum frequency to show</param>
        /// <param name="foundMaxDecibel">if specified output max decibel text</param>
        /// <param name="foundMaxFrequency">if specified output max frequency text</param>
        /// <returns>Spectral image of the signal</returns>
        /// <remarks>This code is based on the code by Gerald T. Beauregard
        /// which was released under the MIT License. (Copyright (c) 2010 Gerald T. Beauregard)
        /// The code were ported to C# and heavily modifified by Per Ivar Nerseth, 2012
        /// </remarks>
        public static Bitmap GetSpectrumImage(ref float[] mag, ref float[] freq,
		                                      Size imageSize,
		                                      float minFrequency = 0, float maxFrequency = 20000,
		                                      float foundMaxDecibel = -1, float foundMaxFrequency = -1)
        {
            // Basic constants
            int TOTAL_HEIGHT = imageSize.Height;    // Height of graph
            int TOTAL_WIDTH = imageSize.Width;      // Width of graph

            float MIN_FREQ = minFrequency;  	// Minimum frequency (Hz) on horizontal axis.
            float MAX_FREQ = maxFrequency;		// Maximum frequency (Hz) on horizontal axis.
            float FREQ_STEP = 2000;				// Interval between ticks (Hz) on horizontal axis.
            float MAX_DB = -0.0f;				// Maximum dB magnitude on vertical axis.
            float MIN_DB = -100.0f; //-60       // Minimum dB magnitude on vertical axis.
            float DB_STEP = 20;                	// Interval between ticks (dB) on vertical axis.

            int TOP = 5;                     	// Top of graph
            int LEFT = 5;                    	// Left edge of graph
            int HEIGHT = imageSize.Height-2*TOP;	// Height of graph
            int WIDTH = imageSize.Width-2*LEFT;     // Width of graph
            string LABEL_X = "Frequency (Hz)"; 	// Label for X axis
            string LABEL_Y = "dB";             	// Label for Y axis
            bool drawLabels = false;
            bool drawRoundedRectangles = true;

            // if the max frequency gets lower than ... lower the frequency step
            if (MAX_FREQ < 20000) {
                FREQ_STEP = (float) MathUtils.GetNicerNumber(MAX_FREQ / 10);
            }

            // Colors
            Color lineColor = ColorTranslator.FromHtml("#C7834C");
            Color middleLineColor = ColorTranslator.FromHtml("#EFAB74");
            Color textColor = ColorTranslator.FromHtml("#A9652E");
            Color sampleColor = ColorTranslator.FromHtml("#4C2F1A");
            Color fillOuterColor = ColorTranslator.FromHtml("#FFFFFF");
            Color fillColor = ColorTranslator.FromHtml("#F9C998");

            // Derived constants
            int BOTTOM = TOTAL_HEIGHT-TOP;                   		// Bottom of graph
            float DBTOPIXEL = (float) HEIGHT/(MAX_DB-MIN_DB);    	// Pixels/tick
            float FREQTOPIXEL = (float) WIDTH/(MAX_FREQ-MIN_FREQ);	// Pixels/Hz

            try {
                Bitmap png = new Bitmap( TOTAL_WIDTH, TOTAL_HEIGHT, PixelFormat.Format32bppArgb );
                Graphics g = Graphics.FromImage(png);
                ExtendedGraphics eg = new ExtendedGraphics(g);

                int numPoints = mag.Length;
                if ( mag.Length != freq.Length )
                    System.Diagnostics.Debug.WriteLine( "mag.length != freq.length" );

                Pen linePen = new Pen(lineColor, 0.5f);
                Pen middleLinePen = new Pen(middleLineColor, 0.5f);
                Pen textPen = new Pen(textColor, 1);
                Pen samplePen = new Pen(sampleColor, 1);

                // Draw a rectangular box marking the boundaries of the graph
                // Create outer rectangle.
                Rectangle rectOuter = new Rectangle(0, 0, TOTAL_WIDTH, TOTAL_HEIGHT);
                Brush fillBrushOuter = new SolidBrush(fillOuterColor);
                g.FillRectangle(fillBrushOuter, rectOuter);

                // Create rectangle.
                Rectangle rect = new Rectangle(LEFT, TOP, WIDTH, HEIGHT);
                Brush fillBrush = new SolidBrush(fillColor);
                if (drawRoundedRectangles) {
                    eg.FillRoundRectangle(fillBrush, rect.X, rect.Y, rect.Width, rect.Height, 10);
                    eg.DrawRoundRectangle(linePen, rect.X, rect.Y, rect.Width, rect.Height, 10);
                } else {
                    g.FillRectangle(fillBrush, rect);
                    g.DrawRectangle(linePen, rect);
                }

                // Label for horizontal axis
                Font drawLabelFont = new Font("Arial", 8);
                SolidBrush drawLabelBrush = new SolidBrush(textPen.Color);
                if (drawLabels) {
                    SizeF drawLabelTextSize = g.MeasureString(LABEL_X, drawLabelFont);
                    g.DrawString(LABEL_X, drawLabelFont, drawLabelBrush, (TOTAL_WIDTH/2) - (drawLabelTextSize.Width/2), TOTAL_HEIGHT - drawLabelFont.GetHeight(g) -3);
                }

                float y = 0;
                float yMiddle = 0;
                float x = 0;
                float xMiddle = 0;
                for ( float dBTick = MIN_DB; dBTick <= MAX_DB; dBTick += DB_STEP )
                {
                    // draw horozontal main line
                    y = BOTTOM - DBTOPIXEL*(dBTick-MIN_DB);
                    if (y < BOTTOM && y > TOP+1) {
                        g.DrawLine(linePen, LEFT, y, LEFT+WIDTH, y);
                    }

                    // draw horozontal middle line (between the main lines)
                    yMiddle = y-(DBTOPIXEL*DB_STEP)/2;
                    if (yMiddle > 0) {
                        g.DrawLine(middleLinePen, LEFT, yMiddle, LEFT+WIDTH, yMiddle);
                    }

                    if ( dBTick != MAX_DB )
                    {
                        // Numbers on the tick marks
                        Font drawFont = new Font("Arial", 8);
                        SolidBrush drawBrush = new SolidBrush(textPen.Color);
                        g.DrawString("" + dBTick + " dB", drawFont, drawBrush, LEFT+5, y - drawFont.GetHeight(g) -2);
                    }
                }

                if (drawLabels) {
                    // Label for vertical axis
                    g.DrawString(LABEL_Y, drawLabelFont, drawLabelBrush, 1, TOP + HEIGHT/2 - drawLabelFont.GetHeight(g)/2);
                }

                // Tick marks on the horizontal axis
                for ( float f = MIN_FREQ; f <= MAX_FREQ; f += FREQ_STEP )
                {
                    // draw vertical main line
                    x = LEFT + FREQTOPIXEL*(f-MIN_FREQ);
                    if (x > LEFT  && x < WIDTH) {
                        g.DrawLine(linePen, x, BOTTOM, x, TOP);
                    }

                    // draw vertical middle line (between the main lines)
                    xMiddle = x + FREQTOPIXEL*FREQ_STEP/2;
                    if (xMiddle < TOTAL_WIDTH) {
                        g.DrawLine(middleLinePen, xMiddle, BOTTOM, xMiddle, TOP);
                    }

                    if ( f != MIN_FREQ && f != MAX_FREQ )
                    {
                        // Numbers on the tick marks
                        Font drawFont = new Font("Arial", 8);
                        SolidBrush drawBrush = new SolidBrush(textPen.Color);
                        g.DrawString("" + f + " Hz", drawFont, drawBrush, x, TOP +2);
                    }
                }

                if (foundMaxDecibel != -1 && foundMaxFrequency != -1) {
                    int note = 0;
                    int cents = 0;
                    MidiUtils.PitchToMidiNote(foundMaxFrequency, out note, out cents);
                    string noteName = MidiUtils.GetNoteName(note, false, true);

                    //string foundMax = String.Format("Max found: {0}dB @ {1} hz", foundMaxDecibel, foundMaxFrequency);
                    string foundMax = String.Format("Max found: {0}dB @ {1} hz ({2} - Note: {3} {4:+#;-#;0} cents)", foundMaxDecibel, foundMaxFrequency, noteName, note, cents);

                    SizeF foundMaxLabelTextSize = g.MeasureString(foundMax, drawLabelFont);
                    g.DrawString(foundMax, drawLabelFont, drawLabelBrush, TOTAL_WIDTH - foundMaxLabelTextSize.Width - 10, TOTAL_HEIGHT - drawLabelFont.GetHeight(g) - 10);
                }

                // The line in the graph
                int i = 0;

                // Ignore points that are too far to the left
                for ( i = 0; i < numPoints && freq[i] < MIN_FREQ; i++ )
                {
                }

                // For all remaining points within range of x-axis
                float oldX = 0;
                float oldY = TOP;
                bool firstPoint = true;
                for ( ; i < numPoints && freq[i] <= MAX_FREQ; i++ )
                {
                    // Compute horizontal position
                    x = LEFT + FREQTOPIXEL*(freq[i]-MIN_FREQ);

                    // Compute vertical position of point
                    // and clip at top/bottom.
                    y = BOTTOM - DBTOPIXEL*(mag[i]-MIN_DB);

                    if ( y < TOP )
                        y = TOP;
                    else if ( y > BOTTOM )
                        y = BOTTOM;

                    // If it's the first point
                    if ( firstPoint )
                    {
                        // Move to the point
                        oldX = x;
                        oldY = y;
                        firstPoint = false;
                    }
                    else
                    {
                        // Otherwise, draw line from the previous point
                        g.DrawLine(samplePen, oldX, oldY, x, y);
                        oldX = x;
                        oldY = y;
                    }
                }

                return png;
            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex);
                return null;
            }
        }
Esempio n. 32
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;

            if (navBitmap == null)
            {
                g.FillRectangle(new SolidBrush(Color.White), e.ClipRectangle);
            }
            else
            {
                g.DrawImage(navBitmap, 0, 0);
            }

            // Find the current viewport
            int x = StaticUtils.GetScrollPos(timeline.Handle, StaticUtils.SB_HORZ);
            int y = StaticUtils.GetScrollPos(timeline.Handle, StaticUtils.SB_VERT);

            if (x >= 0 && y >= 0)
            {
                float ratioX, ratioY;
                GetRatios(out ratioX, out ratioY);

                int w = timeline.ClientRectangle.Width;
                int h = timeline.ClientRectangle.Height;

                Pen pen = new Pen(ForeColor);

                // Scale it down to our miniature
                x = (int) ((float)x * ratioX);
                y = (int) ((float)y * ratioY);

                w = (int) ((float)w * ratioX);
                if (w >= ClientRectangle.Width)
                    w = ClientRectangle.Width - (int) pen.Width;

                h = (int) ((float)h * ratioY);
                if (h >= ClientRectangle.Height)
                    h = ClientRectangle.Height - (int) pen.Width;

                ExtendedGraphics eg = new ExtendedGraphics(g);
                eg.FillRoundRectangle(new SolidBrush(Color.FromArgb(127, 0x9B, 0x57, 0x9F)),
                                      x, y, w, h, 3);
                eg.DrawRoundRectangle(pen, x, y, w, h, 3);
            }
        }
Esempio n. 33
0
        /// <summary>
        /// Draw a waveform using start and end zoom sample position
        /// </summary>
        /// <param name="audioData">The audio data (mono)</param>
        /// <param name="imageSize">Size of the image</param>
        /// <param name="amplitude">Amplitude (1 is default)</param>
        /// <param name="startZoomSamplePosition">First Sample to Zoom in on</param>
        /// <param name="endZoomSamplePosition">Last Sample to Zoom in on</param>
        /// <param name="sampleRate">Samplerate of the audio data (to calculate time)</param>
        /// <param name="drawRaw">Whether to draw only the raw image (no margins)</param>
        /// <seealso cref="https://github.com/aalin/canvas_waveform"></seealso>
        /// <seealso cref="http://www.hisschemoller.com/2010/mp3-wave-display/"></seealso>
        /// <seealso cref="http://www.marinbezhanov.com/web-development/14/actionscript-3-sound-extract-demystified-or-how-to-draw-a-waveform-in-flash/"></seealso>
        /// <seealso cref="http://stackoverflow.com/questions/1215326/open-source-c-sharp-code-to-present-wave-form"></seealso>
        /// <returns>A bitmap of the waveform</returns>
        public static Bitmap DrawWaveform(float[] audioData, Size imageSize, int amplitude, int startZoomSamplePosition, int endZoomSamplePosition, double sampleRate, bool drawRaw=false)
        {
            // Basic constants
            int TOTAL_HEIGHT = imageSize.Height;    // Height of graph
            int TOTAL_WIDTH = imageSize.Width;      // Width of graph

            int TOP = 5;                     		// Top of graph
            int LEFT = 5;                    		// Left edge of graph
            if (drawRaw) {
                TOP = 0;                     		// Top of graph
                LEFT = 0;                    		// Left edge of graph
            }
            int HEIGHT = imageSize.Height-2*TOP;	// Height of graph
            int WIDTH = imageSize.Width-2*LEFT;     // Width of graph

            // limit amplitude
            if (amplitude > 5000) {
                amplitude = 5000;
            }
            float MIN_AMPLITUDE = -1.0f / amplitude;
            float MAX_AMPLITUDE = 1.0f / amplitude;
            float AMPLITUDE_STEP = MAX_AMPLITUDE / 5;

            string LABEL_X = "Time"; 					// Label for X axis
            string LABEL_Y = "Amplitude";             	// Label for Y axis

            bool drawLabels = false;
            bool drawRoundedRectangles = true;
            bool displayInformationBox = true;
            bool displayTime = true;
            bool useAverages = false; // averages draws a "filled" waveform

            if (drawRaw) {
                drawLabels = false;
                drawRoundedRectangles = false;
                displayInformationBox = false;
                displayTime = false;
            }

            // Colors
            Color lineColor = ColorTranslator.FromHtml("#C7834C");
            Color middleLineColor = ColorTranslator.FromHtml("#EFAB74");
            Color textColor = ColorTranslator.FromHtml("#A9652E");
            Color sampleColor = ColorTranslator.FromHtml("#4C2F1A");
            Color fillOuterColor = ColorTranslator.FromHtml("#FFFFFF");
            Color fillColor = ColorTranslator.FromHtml("#F9C998");
            Color textInfoBoxColor = ColorTranslator.FromHtml("#4C2F1A");
            Color textInfoBoxBgColor = ColorTranslator.FromHtml("#F7DECA");

            // Derived constants
            int CENTER = TOTAL_HEIGHT / 2;
            int RIGHT = WIDTH;
            int BOTTOM = TOTAL_HEIGHT-TOP;                   		// Bottom of graph

            int totalNumberOfSamples = 0;
            float[] data = null;
            float samplesPerPixel = 0;
            if (audioData != null && audioData.Length > 0) {

                totalNumberOfSamples = audioData.Length;

                // make sure the zoom start and zoom end is correct
                if (startZoomSamplePosition < 0)
                    startZoomSamplePosition = 0;
                if (endZoomSamplePosition > audioData.Length || endZoomSamplePosition < 0)
                    endZoomSamplePosition = audioData.Length;

                if (endZoomSamplePosition != 0) {
                    data = new float[endZoomSamplePosition-startZoomSamplePosition];
                    Array.Copy(audioData, startZoomSamplePosition, data, 0, endZoomSamplePosition-startZoomSamplePosition);
                    samplesPerPixel = (float) (endZoomSamplePosition - startZoomSamplePosition) / (float) WIDTH;
                } else {
                    data = audioData;
                    samplesPerPixel = (float) totalNumberOfSamples / (float) WIDTH;
                }
            }

            double totalDurationMs = totalNumberOfSamples / sampleRate * 1000;

            float MAX_TIME = (float) (endZoomSamplePosition / sampleRate * 1000);
            float MIN_TIME = 0.0f;
            if (startZoomSamplePosition > 0) {
                MIN_TIME = (float) (startZoomSamplePosition / sampleRate * 1000);
            }

            float TIME_STEP = (float) MathUtils.GetNicerNumber((MAX_TIME-MIN_TIME) / 10);
            float AMPLITUDETOPIXEL = (float) HEIGHT/(MAX_AMPLITUDE-MIN_AMPLITUDE); 	// Pixels/tick
            float TIMETOPIXEL = (float) WIDTH/(MAX_TIME-MIN_TIME); 					// Pixels/second

            // Set up for drawing
            Bitmap png = new Bitmap( TOTAL_WIDTH, TOTAL_HEIGHT, PixelFormat.Format32bppArgb );
            Graphics g = Graphics.FromImage(png);
            ExtendedGraphics eg = new ExtendedGraphics(g);

            Pen linePen = new Pen(lineColor, 0.5f);
            Pen middleLinePen = new Pen(middleLineColor, 0.5f);
            Pen textPen = new Pen(textColor, 1.0f);
            Pen samplePen = new Pen(sampleColor, 1.0f);
            Pen infoBoxPen = new Pen(textInfoBoxColor, 1.0f);

            // Draw a rectangular box marking the boundaries of the graph
            // Create outer rectangle.
            Rectangle rectOuter = new Rectangle(0, 0, TOTAL_WIDTH, TOTAL_HEIGHT);
            Brush fillBrushOuter = new SolidBrush(fillOuterColor);
            g.FillRectangle(fillBrushOuter, rectOuter);

            // Create rectangle.
            Rectangle rect = new Rectangle(LEFT, TOP, WIDTH, HEIGHT);
            Brush fillBrush = new SolidBrush(fillColor);
            if (drawRoundedRectangles) {
                eg.FillRoundRectangle(fillBrush, rect.X, rect.Y, rect.Width, rect.Height, 10);
                eg.DrawRoundRectangle(linePen, rect.X, rect.Y, rect.Width, rect.Height, 10);
            } else {
                g.FillRectangle(fillBrush, rect);
                g.DrawRectangle(linePen, rect);
            }

            // Label for horizontal axis
            Font drawLabelFont = new Font("Arial", 8);
            SolidBrush drawLabelBrush = new SolidBrush(textPen.Color);
            if (drawLabels) {
                SizeF drawLabelTextSize = g.MeasureString(LABEL_X, drawLabelFont);
                g.DrawString(LABEL_X, drawLabelFont, drawLabelBrush, (TOTAL_WIDTH/2) - (drawLabelTextSize.Width/2), TOTAL_HEIGHT - drawLabelFont.GetHeight(g) -3);
            }

            float y = 0;
            float yMiddle = 0;
            float x = 0;
            float xMiddle = 0;
            for ( float amplitudeTick = MIN_AMPLITUDE; amplitudeTick <= MAX_AMPLITUDE; amplitudeTick += AMPLITUDE_STEP )
            {
                // draw horozontal main line
                y = BOTTOM - AMPLITUDETOPIXEL*(amplitudeTick-MIN_AMPLITUDE);
                if (y < BOTTOM && y > TOP+1) {
                    g.DrawLine(linePen, LEFT, y, LEFT+WIDTH, y);
                }

                // draw horozontal middle line (between the main lines)
                yMiddle = y-(AMPLITUDETOPIXEL*AMPLITUDE_STEP)/2;
                if (yMiddle > 0) {
                    g.DrawLine(middleLinePen, LEFT, yMiddle, LEFT+WIDTH, yMiddle);
                }

                if ( amplitudeTick != MAX_AMPLITUDE )
                {
                    // Numbers on the tick marks
                    Font drawFont = new Font("Arial", 8);
                    SolidBrush drawBrush = new SolidBrush(textPen.Color);
                    //g.DrawString("" + amplitudeTick, drawFont, drawBrush, LEFT+5, y - drawFont.GetHeight(g) -2);
                    g.DrawString(amplitudeTick.ToString("0.000000"), drawFont, drawBrush, LEFT+5, y - drawFont.GetHeight(g) -2);
                }
            }

            if (drawLabels) {
                // Label for vertical axis
                g.DrawString(LABEL_Y, drawLabelFont, drawLabelBrush, 1, TOP + HEIGHT/2 - drawLabelFont.GetHeight(g)/2);
            }

            // Tick marks on the horizontal axis
            for ( float timeTick = MIN_TIME; timeTick <= MAX_TIME; timeTick += TIME_STEP )
            {
                // draw vertical main line
                x = LEFT + TIMETOPIXEL*(timeTick-MIN_TIME);
                if (x > LEFT  && x < WIDTH) {
                    g.DrawLine(linePen, x, BOTTOM, x, TOP);
                }

                // draw vertical middle line (between the main lines)
                xMiddle = x + TIMETOPIXEL*TIME_STEP/2;
                if (xMiddle < TOTAL_WIDTH) {
                    g.DrawLine(middleLinePen, xMiddle, BOTTOM, xMiddle, TOP);
                }

                if ( timeTick != MIN_TIME && timeTick != MAX_TIME )
                {
                    // Numbers on the tick marks
                    Font drawFont = new Font("Arial", 8);
                    SolidBrush drawBrush = new SolidBrush(textPen.Color);
                    TimeSpan time = TimeSpan.FromMilliseconds(timeTick);
                    //g.DrawString("" + timeTick + " ms", drawFont, drawBrush, x, TOP +2);
                    g.DrawString(time.ToString(@"hh\:mm\:ss\.FFFFFFF"), drawFont, drawBrush, x, TOP +2);
                }
            }

            if (displayTime) {
                string displayTimeString = String.Format("Duration: {0} samples @ {1:0.0000} ms", totalNumberOfSamples, totalDurationMs);
                SizeF displayTimeStringTextSize = g.MeasureString(displayTimeString, drawLabelFont);
                g.DrawString(displayTimeString, drawLabelFont, drawLabelBrush, TOTAL_WIDTH - displayTimeStringTextSize.Width - 10, TOTAL_HEIGHT - drawLabelFont.GetHeight(g) - 10);
            }

            // draw middle line
            g.DrawLine(middleLinePen, LEFT, CENTER, WIDTH, CENTER);

            // Draw waveform
            if (data != null && data.Length > 0) {
                if (samplesPerPixel >= 1) {
                    // the number of samples are greater than the available drawing space (i.e. greater than the number of pixles in the X-Axis)

                    float xPrev = 0;
                    float yPrev = 0;
                    float yAxis = 0;

                    int yMax = 0;
                    int yMin = 0;
                    int yMaxPrev = 0;
                    int yMinPrev = 0;
                    bool firstPoint = true;
                    for (int xAxis = 0; xAxis < WIDTH; xAxis++)
                    {
                        // determine start and end points within WAV (for this single pixel on the X axis)
                        int start 	= (int)((float)(xAxis) 		* samplesPerPixel);
                        int end 	= (int)((float)(xAxis + 1) 	* samplesPerPixel);

                        // reset the min and max values
                        yMax = 0;
                        yMin = 0;
                        if (useAverages) {
                            // determine the average min and max values within this specific range
                            float posAvg = 0, negAvg = 0;
                            MathUtils.Averages(data, start, end, out posAvg, out negAvg);

                            yMax = TOP + HEIGHT - (int)((posAvg * amplitude + 1) * 0.5 * HEIGHT);
                            yMin = TOP + HEIGHT - (int)((negAvg * amplitude + 1) * 0.5 * HEIGHT);

                            g.DrawLine(samplePen, xAxis + LEFT, yMin, xAxis + LEFT, yMax);
                        } else {
                            // determine the min and max values within this specific range
                            float min = float.MaxValue;
                            float max = float.MinValue;
                            for (int i = start; i <= end; i++)
                            {
                                if (i < data.Length) {
                                    float val = data[i];
                                    min = val < min ? val : min;
                                    max = val > max ? val : max;
                                }
                            }

                            yMax = TOP + HEIGHT - (int)((max * amplitude + 1) * 0.5 * HEIGHT);
                            yMin = TOP + HEIGHT - (int)((min * amplitude + 1) * 0.5 * HEIGHT);

                            // limit within the drawing space
                            if (yMax < 0) yMax = 0;
                            if (yMin > HEIGHT) yMin = HEIGHT;

                            // make sure that we always draw something
                            if (yMin == yMax) {
                                yMin += 1;
                            }
                            yAxis = yMax;

                            // draw waveform
                            // If it's the first point
                            if ( firstPoint )
                            {
                                // Move to the point
                                xPrev = xAxis;
                                yPrev = yAxis;

                                yMaxPrev = yMax;
                                yMinPrev = yMin;

                                firstPoint = false;
                            }
                            else
                            {
                                if (TIMETOPIXEL > 10) {
                                    // For smaller resolution, Draw line from the previous point
                                    g.DrawLine(samplePen, xPrev + LEFT, yPrev, xAxis + LEFT, yAxis);

                                    // Try to smooth the lines by using the previous max value
                                    //g.DrawLine(samplePen, xPrev + LEFT, yMaxPrev, xAxis + LEFT, yMin);
                                } else {
                                    // use yMax and yMin
                                    // original from example: http://stackoverflow.com/questions/1215326/open-source-c-sharp-code-to-present-wave-form
                                    // basically don't care about previous x or y, but draw vertical lines
                                    // from y min to y max value
                                    g.DrawLine(samplePen, xAxis + LEFT, yMin, xAxis + LEFT, yMax);
                                }

                                // store values to next iteration
                                xPrev = xAxis;
                                yPrev = yAxis;

                                yMaxPrev = yMax;
                                yMinPrev = yMin;
                            }
                        }
                    }
                } else {
                    // the number of samples are less than the available drawing space
                    // (i.e. less than the number of pixles in the X-Axis)
                    int samples = data.Length;
                    if (samples > 1) {
                        // at least two samples
                        float mult_x = (float) WIDTH / (endZoomSamplePosition-startZoomSamplePosition - 1);

                        List<Point> ps = new List<Point>();
                        for (int i = 0; i < data.Length; i++)
                        {
                            x = (i * mult_x) + LEFT;
                            y = TOP + HEIGHT - (int)((data[i] * amplitude + 1) * 0.5 * HEIGHT);
                            Point p = new Point((int)x, (int)y);
                            ps.Add(p);
                        }

                        if (ps.Count > 0)
                        {
                            g.DrawLines(samplePen, ps.ToArray());
                        }
                    } else {
                        // we have only one sample, draw a flat line
                        g.DrawLine(linePen, 0, 0.5f * HEIGHT, WIDTH, 0.5f * HEIGHT);
                    }
                }
            }

            // draw right upper box
            if (displayInformationBox) {
                Font drawInfoBoxFont = new Font("Arial", 8);
                SolidBrush drawInfoBoxBrush = new SolidBrush(infoBoxPen.Color);

                string infoBoxLine1Text = String.Format("SampleToPixel Orig: {0:0.000} => New: {1:0.000}", (float) totalNumberOfSamples / WIDTH, samplesPerPixel);
                string infoBoxLine2Text = String.Format("Time (Min->Max): {0} -> {1}", MIN_TIME, MAX_TIME);
                string infoBoxLine3Text = String.Format("Timestep: {0}, TimeToPixel: {1}", TIME_STEP, TIMETOPIXEL);

                // get box width
                int infoBoxMargin = 5;
                List<float> textLineSizes = new List<float>();
                textLineSizes.Add(g.MeasureString(infoBoxLine1Text, drawInfoBoxFont).Width + infoBoxMargin*2);
                textLineSizes.Add(g.MeasureString(infoBoxLine2Text, drawInfoBoxFont).Width + infoBoxMargin*2);
                textLineSizes.Add(g.MeasureString(infoBoxLine3Text, drawInfoBoxFont).Width + infoBoxMargin*2);
                textLineSizes.Add(150.0f); // info box minimum width

                float infoBoxLineTextWidth = 0.0f;
                float minWidth = 0.0f;
                MathUtils.ComputeMinAndMax(textLineSizes.ToArray(), out minWidth, out infoBoxLineTextWidth);

                int infoBoxWidth = (int) infoBoxLineTextWidth;

                float infoBoxLineTextHeight = drawInfoBoxFont.GetHeight(g);
                int infoBoxHeight = (int) (infoBoxMargin + (infoBoxLineTextHeight + infoBoxMargin)*4);

                Rectangle rectInfoBox = new Rectangle(WIDTH - infoBoxWidth - 20, 30, infoBoxWidth, infoBoxHeight);
                Brush fillBrushInfoBox = new SolidBrush(textInfoBoxBgColor);
                g.FillRectangle(fillBrushInfoBox, rectInfoBox);
                g.DrawRectangle(linePen, rectInfoBox);

                g.DrawString(infoBoxLine1Text, drawInfoBoxFont, drawInfoBoxBrush, WIDTH - infoBoxWidth - 20 + infoBoxMargin, 30 + infoBoxMargin);
                g.DrawString(infoBoxLine2Text, drawInfoBoxFont, drawInfoBoxBrush, WIDTH - infoBoxWidth - 20 + infoBoxMargin, 30 + infoBoxMargin + (infoBoxLineTextHeight + infoBoxMargin));
                g.DrawString(infoBoxLine3Text, drawInfoBoxFont, drawInfoBoxBrush, WIDTH - infoBoxWidth - 20 + infoBoxMargin, 30 + infoBoxMargin + (infoBoxLineTextHeight + infoBoxMargin)*2);
            }

            return png;
        }
Esempio n. 34
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            ExtendedGraphics eg = new ExtendedGraphics(g);
            Rectangle rect = e.ClipRectangle;

            Pen pen = new Pen(frameColor, framePenWidth);

            //
            // Context
            //
            if (contextID != null)
            {
                int ctxSquareX = Width - framePenWidth - 2 - ctxSquareWidth;
                int ctxSquareY = framePenWidth + 2;

                Color c1, c2;
                colorPool.GetColorsForId(contextID, out c1, out c2);

                eg.DrawRoundRectangle(new Pen(c2, framePenWidth),
                    ctxSquareX, ctxSquareY,
                    ctxSquareWidth, ctxSquareWidth, 2);

                g.FillRectangle(new SolidBrush(c1),
                    ctxSquareX + framePenWidth, ctxSquareY + framePenWidth,
                    ctxSquareWidth - framePenWidth,
                    ctxSquareWidth - framePenWidth);
            }

            //
            // Draw a round outer frame
            //
            eg.DrawRoundRectangle(pen, 0, 0, Width - framePenWidth, Height - framePenWidth, 4.0f);
        }
Esempio n. 35
0
        public void Draw(Graphics g, float width, float height, bool isCopy)
        {
            ExtendedGraphics eg = new ExtendedGraphics(g);
            thinPen = new Pen(Color.Black, 1);

            //			float Sx = width / 84.0f;
            //			float Sy = height / 84.0f;
            float S = width / 84.0f;

            //  HFONT font  = CreateFont(int(2.5*S),0     ,0,0, FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH | FF_ROMAN,"");
            //  HFONT specf = CreateFont(int(2.2*S),0     ,0,0, FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH | FF_ROMAN,"");
            //  HFONT bfont = CreateFont(int(2.5*S),0     ,0,0, FW_BOLD,  FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH | FF_ROMAN,"");
            //  HFONT lfont = CreateFont(int(2*S)  ,0     ,0,0, FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH | FF_ROMAN,"");
            //  HFONT hfont = CreateFont(int(4*S)  ,0     ,0,0, FW_BOLD,  FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH | FF_SWISS,"");
            Font font  = new Font(FontFamily.GenericSerif,    2.5f * 2.5f * S, FontStyle.Regular, GraphicsUnit.Document);
            Font specF = new Font(FontFamily.GenericSerif,    2.5f * 2.2f * S, FontStyle.Regular, GraphicsUnit.Document);
            Font bfont = new Font(FontFamily.GenericSerif,    2.5f * 2.5f * S, FontStyle.Bold,    GraphicsUnit.Document);
            Font lfont = new Font(FontFamily.GenericSerif,    2.5f * 2f   * S, FontStyle.Regular, GraphicsUnit.Document);
            Font hFont = new Font(FontFamily.GenericSansSerif,2.5f * 4f   * S, FontStyle.Bold,    GraphicsUnit.Document);

            TextLeft(g,hFont, 1*S,1*S,"Båt & Inredningssnickerier");

            float doubleliney = 18*S;
            eg.DrawDoubleLine(80*S, 83*S, doubleliney, S, thinPen);

            string whatText = isCopy ? " FAKTURAKOPIA " : " FAKTURA ";
            SizeF whatSize = g.MeasureString(whatText, hFont);
            g.DrawString(whatText, hFont, Brushes.Black, new PointF(80*S-whatSize.Width, doubleliney+0.5f*S-0.5f*whatSize.Height));
            eg.DrawDoubleLine(S, 80*S-whatSize.Width, doubleliney, S, thinPen);

            g.DrawString("Svante Höglund", font, Brushes.Black, new PointF(1*S,5*S));
            g.DrawString("Kalkstadsgatan 6", font, Brushes.Black, new PointF(1*S,8*S));
            g.DrawString("386 93 Färjestaden", font, Brushes.Black, new PointF(1*S,11*S));
            g.DrawString("070-544 10 98", font, Brushes.Black, new PointF(1*S,14*S));

            int recty=(int)(21*S);
            RectangleF rr1 = new RectangleF(1*S,  recty, 46*S, 9*S);
            RectangleF rr2 = new RectangleF(48*S, recty, 35*S, 9*S);
            eg.DrawRoundRectangle(thinPen, rr1, 1*S);
            eg.DrawRoundRectangle(thinPen, rr2, 1*S);

            float l1=recty+1*S, l2=recty+3.5f*S, l3=recty+6*S;
            TextLeft(g, lfont, 2*S,  l1, "Namn:");
            TextLeft(g, lfont, 2*S,  l2, "Adress:");
            TextLeft(g, lfont, 2*S,  l3, "Postadress:");
            TextLeft(g, lfont, 49*S, l1, "Datum:");
            TextLeft(g, lfont, 49*S, l2, "Fakturanr:");
            TextLeft(g, lfont, 49*S, l3, "Er ref:");
            TextUL(g, font, 11*S, l1, 35*S, 2.5f*S, namn);
            TextUL(g, font, 11*S, l2, 35*S, 2.5f*S, address);
            TextUL(g, font, 11*S, l3, 35*S, 2.5f*S, postnr + " " + postort);
            TextUL(g, font, 57*S, l1, 25*S, 2.5f*S, datum);
            TextUL(g, font, 57*S, l2, 25*S, 2.5f*S, fakturanr);
            TextUL(g, font, 57*S, l3, 25*S, 2.5f*S, referens);

            float specy = 34*S;
            float speclinespacing = 3.3f*S;
            float summay = 88*S;
            float summayend = summay+12*S;

            MoveTo(    1*S, specy-0.5f*S);
            LineTo(g, 83*S, specy-0.5f*S);
            LineTo(g, 83*S, summayend);
            LineTo(g,  1*S, summayend);
            LineTo(g,  1*S, specy-0.5f*S);
            MoveTo(    1*S, specy+speclinespacing-2);
            LineTo(g, 83*S, specy+speclinespacing-2);
            MoveTo(   70*S, specy-0.5f*S);
            LineTo(g, 70*S, summayend);
            MoveTo(   57*S, specy-0.5f*S);
            LineTo(g, 57*S, summayend);
            MoveTo(   44*S, specy-0.5f*S);
            LineTo(g, 44*S, summayend);

            TextLeft(g, bfont,  2*S,  specy, "Specifikation");
            TextRight(g, bfont, 56*S, specy, "Antal");
            TextRight(g, bfont, 69*S, specy, "À pris");
            TextRight(g, bfont, 82*S, specy, "Belopp");
            for(int i=0; i<15; i++) {
                float y=specy+speclinespacing*(i+1);
                InvoiceSpec spec = specs[i];
                TextLeft (g, specF,  2*S, y, spec.beskrivning);
                TextRight(g, specF, 56*S, y, spec.antal);
                TextRight(g, specF, 69*S, y, spec.styckpris);
                TextRight(g, specF, 82*S, y, spec.belopp);
            }

            TextLeft(g,  bfont,  2*S,  summay+0*S, "Avrundning");
            TextRight(g, bfont, 82*S, summay+0*S, Spec.Currency(Avrundning()));
            TextLeft(g,  bfont,  2*S,  summay+3*S, "Summa");
            TextRight(g, bfont, 82*S, summay+3*S, Spec.Currency(Summa()));
            TextLeft(g,  bfont,  2*S,  summay+6*S, "Moms");
            TextRight(g, bfont, 82*S, summay+6*S, Spec.Currency(Moms()));
            TextLeft(g,  bfont,  2*S,  summay+9*S, "Att betala");
            TextRight(g, bfont, 82*S, summay+9*S, Spec.Currency(AttBetala()));

            float legaly = 105*S;
            string legal1 = "F-skattesedel finns.  Momsreg.nr. 490531-0134";
            string legal2 = "Betalningsvillkor: " + antaldgr + " dagar netto, dröjsmålsränta 2%/mån.";
            string pg = "Bankgiro 5718-2305";

            TextLeft (g, lfont,  1*S, legaly, legal1);
            TextRight(g, lfont, 83*S, legaly, legal2);
            eg.DrawDoubleLine(S, 83*S, legaly+3*S, S, thinPen);
            TextLeft(g, font,  1*S, legaly+5*S, pg);
        }
Esempio n. 36
0
        private Bitmap GetHeadingBitmap()
        {
            int w = headingColsRect.X + (sessions.Count * (colWidth + colSpacing));
            int h = headingColsRect.Y + headingColsRect.Height + 3; // FIXME

            Bitmap bitmap = new Bitmap(w, h);

            Graphics g = Graphics.FromImage(bitmap);
            ExtendedGraphics eg = new ExtendedGraphics(g);

            Brush fgBrush = new SolidBrush(Color.White);
            Font headerFont = new Font("Tahoma", 10, FontStyle.Bold);

            int x = headingColsRect.X;

            Pen selectedPen = new Pen(Color.Black, 3);

            foreach (VisualSession stream in sessions)
            {
                string str = stream.Name;

                Brush bgBrush = new SolidBrush(colorPool.GetColorForId(Convert.ToString(str.GetHashCode())));

                eg.FillRoundRectangle(bgBrush, x, headingColsRect.Y, colWidth, headingColsRect.Height, 2.0f);

                if (selectedSessions.ContainsKey(stream))
                {
                    eg.DrawRoundRectangle(selectedPen, x, headingColsRect.Y, colWidth, headingColsRect.Height, 2.0f);
                }

                SizeF fs = g.MeasureString(str, headerFont);

                g.DrawString(str, headerFont, fgBrush,
                    x + (colWidth / 2) - (fs.Width / 2),
                    headingColsRect.Y + ((headingColsRect.Height / 2) - (fs.Height / 2)));

                x += colWidth + colSpacing;
            }

            return bitmap;
        }
Esempio n. 37
0
            /// <summary>
            /// Draws the background.
            /// </summary>
            /// <param name="graphics">The graphics object we render to.</param>
            /// <param name="nvd">The view data of this node in the current view.</param>
            /// <param name="renderDepth">The depth which is still rendered.</param>
            /// <param name="padding">The padding between the nodes.</param>
            public void DrawBackground(Graphics graphics, NodeViewData nvd, int renderDepth, SizeF padding)
            {
                SizeF size = nvd.GetTotalSize(padding.Width, renderDepth);

                if (_backgroundColor != CommentColor.NoColor)
                {
                    float commentPadding = Math.Min(padding.Height, padding.Width) * 0.75f;

                    ExtendedGraphics extended = new ExtendedGraphics(graphics);
                    extended.FillRoundRectangle(_backgroundBrush, nvd.LayoutRectangle.X - commentPadding * 0.5f, nvd.LayoutRectangle.Y - commentPadding * 0.5f, size.Width + commentPadding, size.Height + commentPadding, 0.05f);
                }
            }