private void CalculateOptWidth()
 {
     double restWidth     = DrawingMethods.GetTextWidth(symbol, TypeFaces.GetMusicFont());
     double dotWidth      = DrawingMethods.GetTextWidth(MusicSymbols.Dot, TypeFaces.GetMusicFont());
     double leftFreeSpace = restWidth * 0.1;
     double dotSpaces     = dotWidth * 0.5;
 }
        private void Draw(bool measure)
        {
            staffLines = ViewModel.ViewModelLocator.Instance.Main.CurrentPageLayout.AvaliableIndexLinePositions;
            DrawingVisualHost rest = new DrawingVisualHost();

            Brush  color     = ViewModel.ViewModelLocator.Instance.Main.CurrentLayout.LayoutStyle.Colors[int.Parse(noteItem.Voice)];
            double positionY = 0.0;

            if (measure)
            {
                measureRest = true;
                GetSymbol();
                positionY = SetPosition(CalculateRestPositionY());
                rest.AddCharacterGlyph(new Point(0, positionY), symbol, color: color);
            }
            else
            {
                GetSymbol();
                positionY = SetPosition(CalculateRestPositionY());
                rest.AddCharacterGlyph(new Point(0, positionY), symbol, color: color);
            }
            if (dotCount != 0)
            {
                double shiftUp = (int)restType >= 6 ? SetPosition(1) :
                                 restType == NoteTypeValueMusicXML.Item32nd ? SetPosition(3) :
                                 restType == NoteTypeValueMusicXML.Item64th ? SetPosition(5) : SetPosition(5);
                Point dotPosition = new Point(DrawingMethods.GetTextWidth(symbol, TypeFaces.GetMusicFont()) + 4.0.TenthsToWPFUnit(), positionY - shiftUp);
                rest.AddCharacterGlyph(dotPosition, MusicSymbols.Dot, color: color);
            }
            ItemCanvas.Children.Add(rest);
        }
Ejemplo n.º 3
0
        public void Update()
        {
            _drawCanvas.Children.Clear();

            ResizeCanvas();

            if (_drawCanvas.ActualWidth > 0)
            {
                _width = _drawCanvas.ActualWidth;
            }
            if (_drawCanvas.ActualHeight > 0)
            {
                _height = _drawCanvas.ActualHeight;
            }

            _xRange = _xEnd - _xStart;
            _yRange = _yEnd - _yStart;

            CalculatePixelIntervals();
            CalculateOrigin();

            _startOffSetX = _xStart % _incrementX;
            _startOffSetY = _yStart % _incrementY;

            GridLightLines();
            Axes();
            Labels();

            _chunks.Add(_penlineChunk);
            _chunks.Add(_templineChunk);
            _chunks.Add(_dataLineChunk);
            _chunks.Add(DrawingMethods.Border(_width, _height, 2, Brushes.Black));
            RenderChunks();
        }
Ejemplo n.º 4
0
 private void Draw()
 {
     visualWidth = 0;
     if (staff != null)
     {
         double separator = 1.5.TenthsToWPFUnit();
         double tempWidth = 0;
         drawingVisualHost.ClearVisuals();
         if (keyAccidentals.Length == 1 && keyAccidentals[0] == AccidentalValueMusicXML.none)
         {
             //skip drawing...
             return;
         }
         for (int i = 0; i < keyAccidentals.Length; i++)
         {
             var symbol = keyAccidentals[i] == AccidentalValueMusicXML.flat ? MusicSymbols.Flat :
                          keyAccidentals[i] == AccidentalValueMusicXML.sharp ? MusicSymbols.Sharp : MusicSymbols.Natural;
             tempWidth = DrawingMethods.GetTextWidth(symbol, Helpers.TypeFaces.GetMusicFont()) + 1;
             drawingVisualHost.AddCharacterGlyph(new System.Windows.Point(separator, staff.GetYStaffSpace(keyStaffSpaceIndex[i])), symbol);
             separator += tempWidth;
         }
         visualWidth = separator;
     }
     else
     {
         Console.WriteLine("Staff not set!");
     }
 }
Ejemplo n.º 5
0
        protected override void Update()
        {
            var staffLineCoords  = ViewModel.ViewModelLocator.Instance.Main.CurrentPageLayout.AvaliableIndexLinePositions;
            DrawingVisualHost cl = new DrawingVisualHost();

            if (fifts == 0)
            {
                itemWidth = 0;
            }
            else
            {
                int symbolsCount = Math.Abs(fifts);
                if (symbolsCount > 7)
                {
                    symbolsCount = 0;
                }
                Point  currentPosition   = new Point();
                double symbolWidth       = DrawingMethods.GetTextWidth(keySymbol, TypeFaces.GetMusicFont());
                double keySignatureWidth = symbolsCount * symbolWidth;
                for (int i = 0; i < symbolsCount; i++)
                {
                    currentPosition = new Point(i * symbolWidth, staffLineCoords[8 - keyIndexes[i]]);
                    cl.AddCharacterGlyph(currentPosition, keySymbol);
                }
                itemWidth = keySignatureWidth;
            }
            ItemCanvas.Children.Add(cl);
        }
Ejemplo n.º 6
0
        private void InternalRendererHeader(ref Graphics g, ref Rectangle rect, bool bHot, ref DrawListViewColumnHeaderEventArgs e)
        {
            //set colors
            Color gradStartColor;
            Color gradEndColor;
            Color gradMiddleColor;
            Color borderColor = _palette.ColorTable.ToolStripBorder;

            if (e.State == ListViewItemStates.Selected)
            {
                gradStartColor  = Color.White;// _palette.ColorTable.ButtonSelectedGradientBegin;
                gradMiddleColor = _palette.ColorTable.ButtonCheckedGradientEnd;
                gradEndColor    = _palette.ColorTable.ButtonCheckedGradientBegin;
            }
            else
            {
                if (bHot)
                {
                    gradStartColor  = Color.White;// _palette.ColorTable.ButtonSelectedGradientBegin;
                    gradMiddleColor = _palette.ColorTable.ButtonSelectedGradientEnd;
                    gradEndColor    = _palette.ColorTable.ButtonSelectedGradientBegin;
                }
                else
                {
                    gradStartColor  = Color.White;//_palette.ColorTable.ToolStripGradientBegin;
                    gradMiddleColor = _palette.ColorTable.ToolStripGradientEnd;
                    gradEndColor    = _palette.ColorTable.ToolStripGradientBegin;
                }
            }
            //Fill Gradient
            using (LinearGradientBrush brush = new LinearGradientBrush(rect, gradStartColor, gradMiddleColor, LinearGradientMode.Vertical))
            {
                if (!_enableHeaderGlow)
                {
                    g.FillRectangle(brush, rect);
                }
                else
                {
                    DrawingMethods.DrawListViewHeader(g, rect, gradStartColor, gradMiddleColor, 90F);
                }
            }

            //DrawBorder
            g.DrawRectangle(new Pen(borderColor), rect);

            //Draw light lines
            //oriz
            g.DrawLine(new Pen(Color.White), new Point(rect.X + 1, rect.Y + 1), new Point(rect.X + rect.Width - 1, rect.Y + 1));
            //vert
            g.DrawLine(new Pen(Color.White), new Point(rect.X + 1, rect.Y + 1), new Point(rect.X + 1, rect.Y + rect.Height - 1));

            if (e.ColumnIndex == this.Columns.Count - 1)
            {
                g.DrawLine(new Pen(borderColor), new Point(rect.X + rect.Width - 1, rect.Y), new Point(rect.X + rect.Width - 1, rect.Y + rect.Height + 0));
            }
        }
        private void CalculateMinWidth()
        {
            double restWidth     = DrawingMethods.GetTextWidth(symbol, TypeFaces.GetMusicFont());
            double dotWidth      = DrawingMethods.GetTextWidth(MusicSymbols.Dot, TypeFaces.GetMusicFont());
            double leftFreeSpace = restWidth * 0.05;
            double dotSpaces     = dotWidth * 0.25;

            itemWidthMin = leftFreeSpace + restWidth + (dotWidth + dotSpaces) * dotCount;
            itemWidth    = itemWidthMin;
        }
Ejemplo n.º 8
0
        //Draws the pendulum bobs.
        public override void Draw(State state)
        {
            //Sets width and height to canvas height and width propeties depending on
            //if the canvas is initialised.
            var width  = Canvas.ActualWidth > 0 ? Canvas.ActualWidth : Canvas.Width;
            var height = Canvas.ActualHeight > 0 ? Canvas.ActualHeight : Canvas.Height;

            //Calaculate bob position.
            BobPosition.X = Length * Math.Sin(state.Displacement);
            BobPosition.Y = Length * Math.Cos(state.Displacement);

            PivotPosition = new Vec2
            {
                X = width / 2,
                Y = height / 2
            };

            Batches.Add(DrawingMethods.FilledCircle(PivotPosition, 4, Brushes.Black));

            //Calculate bob position relative to the canvas coordinates.
            BobPosCanvas.X = PivotPosition.X + BobPosition.X * PixelsPerMeter;
            BobPosCanvas.Y = PivotPosition.Y + BobPosition.Y * PixelsPerMeter;


            //Create line objects for pendulum arm.
            var arm = new LightLine
            {
                X1 = PivotPosition.X,
                Y1 = PivotPosition.Y,
                X2 = BobPosCanvas.X - BobRadius * Math.Sin(state.Displacement),
                Y2 = BobPosCanvas.Y - BobRadius * Math.Cos(state.Displacement)
            };

            var armLineBatch = new LineBatch {
                LineThickness = 2
            };

            armLineBatch.Add(arm);
            Batches.Add(armLineBatch);

            //Draw origin circles depending on whether interaction is taking place.
            Batches.Add(IsInteracting
                ? DrawingMethods.FilledCircle(BobPosCanvas, (int)BobRadius, Brushes.Red)
                : DrawingMethods.FilledCircle(BobPosCanvas, (int)BobRadius, Brushes.Blue));

            //Render the batches.
            foreach (var batch in Batches)
            {
                batch.Render(Canvas);
                batch.Clear();
            }

            Batches.Clear();
        }
 protected override void Update()
 {
     if (isSymbol)
     {
         itemWidth = DrawingMethods.GetTextWidth(symbol, TypeFaces.GetMusicFont());
         DrawingVisualHost canvas = new DrawingVisualHost();
         canvas.AddCharacterGlyph(new Point(0, staffLine[3]), symbol);
         ItemCanvas.Children.Add(canvas);
     }
     if (!isSymbol || symbolValue == TimeSymbolMusicXML.normal)
     {
         char[]            beatChars      = beatSymbol.ToCharArray();
         double[]          beatCharWidths = beatSymbol.ToCharArray().GetCharsVisualWidth();
         double            beatWidth      = beatCharWidths.Sum();
         DrawingVisualHost canvasBeat     = new DrawingVisualHost();
         double            offset         = 0;
         for (int i = 0; i < beatChars.Length; i++)
         {
             canvasBeat.AddCharacterGlyph(new Point(offset, 0), beatChars[i].ToString());
             offset += beatCharWidths[i];
         }
         //beatTime
         char[]            beatTimeChars      = beatTimeSymbol.ToCharArray();
         double[]          beatTimeCharWidths = beatTimeSymbol.ToCharArray().GetCharsVisualWidth();
         double            beatTimeWidth      = beatTimeCharWidths.Sum();
         DrawingVisualHost canvasBeatTime     = new DrawingVisualHost();
         offset = 0.0;
         for (int i = 0; i < beatTimeChars.Length; i++)
         {
             canvasBeatTime.AddCharacterGlyph(new Point(offset, 0), beatTimeChars[i].ToString());
             offset += beatTimeCharWidths[i];
         }
         //measure legth + align
         itemWidth        = beatWidth > beatTimeWidth ? beatWidth : beatTimeWidth;
         ItemCanvas.Width = itemWidth;
         if (beatWidth > beatTimeWidth)
         {
             Canvas.SetLeft(canvasBeat, 0);
             double shift = (beatWidth - beatTimeWidth) / 2;
             Canvas.SetLeft(canvasBeatTime, shift);
         }
         else
         {
             Canvas.SetLeft(canvasBeatTime, 0);
             double shift = (beatTimeWidth - beatWidth) / 2;
             Canvas.SetLeft(canvasBeat, shift);
         }
         Canvas.SetTop(canvasBeat, staffLine[4]);
         Canvas.SetTop(canvasBeatTime, staffLine[2]);
         ItemCanvas.Children.Add(canvasBeat);
         ItemCanvas.Children.Add(canvasBeatTime);
     }
 }
Ejemplo n.º 10
0
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            base.OnPaintBackground(e);
            Rectangle rect       = new Rectangle(0, 0, this.Width, this.Height);         // e.ClipRectangle;
            Rectangle borderrect = new Rectangle(0, 0, this.Width - 1, this.Height - 1); // e.ClipRectangle;

            // Draw background
            Color gradStartColor;
            Color gradEndColor;

            if (_gradientToogleColors == false)
            {
                gradStartColor = _gradientStartColor;
                gradEndColor   = _gradientEndColor;
            }
            else
            {
                gradStartColor = _gradientEndColor;
                gradEndColor   = _gradientStartColor;
            }

            if (_gradientUseSolid == false)
            {
                if (_gradientUseBlend == false)
                {
                    using (LinearGradientBrush brush = new LinearGradientBrush(rect,
                                                                               gradStartColor,
                                                                               gradEndColor,
                                                                               GradientDirection))
                    {
                        e.Graphics.FillRectangle(brush, rect);
                    }
                }
                else
                {
                    DrawingMethods.DrawGradient(e.Graphics, rect, gradStartColor, gradEndColor, 90F, false, Color.White, 0);
                }
            }
            else
            //Solid Color
            {
                using (Brush brush = new SolidBrush(GradientSolidColour))
                {
                    e.Graphics.FillRectangle(brush, rect);
                }
            }

            if (this._borderWidth > 0)
            {
                e.Graphics.DrawRectangle(new Pen(Color.FromArgb(180, this._borderColor), _borderWidth), borderrect);
            }
        }
Ejemplo n.º 11
0
        private void DrawAccidental(NoteMusicXML note, int index, DrawingVisualHost noteVisualHost)
        {
            AccidentalMusicXML accidental          = note.Accidental;
            string             accidentalSymbol    = GetAccidentalSymbolString(accidental.Value);
            double             size                = 1.0;
            double             totalAccidentalSize = 0.0;
            bool hasBracket     = accidental.BracketSpecified ? accidental.Bracket == YesNoMusicXML.yes: false;
            bool hasParentheses = accidental.ParenthesesSpecified ? accidental.Parentheses == YesNoMusicXML.yes: false;

            if (isSmall)
            {
                size = 0.7;
            }
            if (accidental.SizeSpecified)
            {
                size = accidental.Size == SymbolSizeMusicXML.cue ? 0.7 : accidental.Size == SymbolSizeMusicXML.large ? 1.2 : 1.0;
            }
            if (accidental.CautionarySpecified)
            {
                hasParentheses = accidental.Cautionary == YesNoMusicXML.yes;
                //! missing implementation if yes
            }
            //! accidental.Editiorial skipped...

            double accidentalWidth   = DrawingMethods.GetTextWidth(accidentalSymbol, TypeFaces.GetMusicFont(), isSmall);
            double accidentalMargin  = layoutStyle.NotesStyle.AccidentalToNoteSpace.TenthsToWPFUnit();
            double noteHeadYPosition = pitchedValue[index];

            if (hasBracket)
            {
                totalAccidentalSize += 2 * DrawingMethods.GetTextWidth(MusicSymbols.AccidentalBracketL, TypeFaces.GetMusicFont(), size);
            }
            if (hasParentheses)
            {
                totalAccidentalSize += 2 * DrawingMethods.GetTextWidth(MusicSymbols.AccidentalParenthesesL, TypeFaces.GetMusicFont(), size);
            }
            if (hasBracket || hasParentheses)
            {
                string left = hasBracket ? MusicSymbols.AccidentalBracketL : MusicSymbols.AccidentalParenthesesL;
                noteVisualHost.AddCharacterGlyph(new Point(0 - (totalAccidentalSize + accidentalWidth + accidentalMargin), noteHeadYPosition), left, isSmall, color);
                string rigth = hasBracket ? MusicSymbols.AccidentalBracketR : MusicSymbols.AccidentalParenthesesR;
                noteVisualHost.AddCharacterGlyph(new Point(0 - (totalAccidentalSize / 2 + accidentalWidth + accidentalMargin), noteHeadYPosition), accidentalSymbol, isSmall, color);
                noteVisualHost.AddCharacterGlyph(new Point(0 - (totalAccidentalSize / 2) - accidentalMargin, noteHeadYPosition), rigth, isSmall, color);
                SetLeftMargin(totalAccidentalSize + accidentalWidth + accidentalMargin);
            }
            else
            {
                noteVisualHost.AddCharacterGlyph(new Point(0 - accidentalWidth - accidentalMargin, noteHeadYPosition), accidentalSymbol, isSmall, color);
                SetLeftMargin(accidentalWidth + accidentalMargin);
            }
        }
        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                      System.Windows.Forms.DataGridViewPaintParts paintParts)
        {
            Single progressVal;

            try
            {
                progressVal = Conversions.ToSingle(value);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                progressVal = 0;
            }

            float percentage = (float)(progressVal / 100);
            Brush backBrush  = new SolidBrush(cellStyle.BackColor);
            Brush foreBrush  = new SolidBrush(cellStyle.ForeColor);

            // Call the base Class method to paint the default cell appearance.
            base.Paint(g, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
                       paintParts);

            if (percentage > 0.0)
            {
                if (percentage > 1)
                {
                    percentage = 1;
                }
                // Draw the progress bar and the text
                Rectangle rect = new Rectangle(cellBounds.X + 1, cellBounds.Y + 1, Convert.ToInt32((percentage * cellBounds.Width - 3)), cellBounds.Height - 3);
                DrawingMethods.DrawGradient(g, rect, Color.FromArgb(205, 255, 205), Color.FromArgb(10, 209, 48), 90F, false, Color.White, 0);
                g.DrawRectangle(new Pen(Color.FromArgb(28, 220, 56)), rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
                //g.FillRectangle(New SolidBrush(Color.FromArgb(163, 189, 242)), cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4)
                g.DrawString(progressVal.ToString() + "%", cellStyle.Font, foreBrush, cellBounds.X + 6, cellBounds.Y + 4);
            }
            else
            {
                //draw the text
                if ((this.DataGridView.CurrentCell != null) && this.DataGridView.CurrentCell.RowIndex == rowIndex)
                {
                    g.DrawString(progressVal.ToString() + "%", cellStyle.Font, new SolidBrush(cellStyle.SelectionForeColor), cellBounds.X + 6, cellBounds.Y + 4);
                }
                else
                {
                    g.DrawString(progressVal.ToString() + "%", cellStyle.Font, foreBrush, cellBounds.X + 6, cellBounds.Y + 4);
                }
            }
        }
Ejemplo n.º 13
0
        private void DrawFlag()
        {
            bool              isFlagDownwards = stem.IsDirectionDown();
            string            flagSymbol      = MusicSymbols.GetFlag(noteType, isFlagDownwards);
            Point             stemEnd         = stem.GetStemEnd();
            DrawingVisualHost flagHost        = new DrawingVisualHost();

            flagHost.AddCharacterGlyph(stemEnd, flagSymbol, isSmall, color);
            flagHost.Tag = "flag";
            if (!isFlagDownwards)
            {
                itemRightMargin = DrawingMethods.GetTextWidth(flagSymbol, TypeFaces.GetMusicFont());
            }
            AddFlag(flagHost);
        }
Ejemplo n.º 14
0
        private void XAxisTitleLabel()
        {
            var xAxisTitle = new LightText {
                Text = XAxisTitle
            };

            //If the origin line is too close the edge of the canvas, the labels are drawn on the opposite side of the axis (above).
            if (graphProperties.Origin.Y - DrawingMethods.MeasureString(YAxisTitle, FontSize).Height * 2 > 0)
            {
                xAxisTitle.Position.X = graphProperties.CanvasWidth - DrawingMethods.MeasureString(XAxisTitle, FontSize).Width - offSetX;
                xAxisTitle.Position.Y = graphProperties.Origin.Y - DrawingMethods.MeasureString(XAxisTitle, FontSize).Height * 2;
            }
            else //Else the labels are drawn on the normal side of the axis (below).
            {
                xAxisTitle.Position.X = graphProperties.CanvasWidth - DrawingMethods.MeasureString(XAxisTitle, FontSize).Width - offSetX;
                xAxisTitle.Position.Y = graphProperties.Origin.Y + DrawingMethods.MeasureString(XAxisTitle, FontSize).Height * 2;
            }

            this.Add(xAxisTitle);
        }
Ejemplo n.º 15
0
        private void DrawDots(DrawingVisualHost noteVisualHost, int index)
        {
            double dotPositionY = pitchedValue[index];

            if (pitchedPosition[index] % 2 == 0)
            {
                double sizeFactor = isSmall ? 0.8 : 1.0;
                double shiftUp    = 5.0.TenthsToWPFUnit() * sizeFactor;
                dotPositionY -= shiftUp;
            }
            int    dotCount    = noteItem[index].Dot.Count;
            double noteWidth   = DrawingMethods.GetTextWidth(symbol, TypeFaces.GetMusicFont(), isSmall);
            double dotWidth    = DrawingMethods.GetTextWidth(MusicSymbols.Dot, TypeFaces.GetMusicFont(), isSmall);
            Point  dotPosition = new Point(noteWidth + layoutStyle.NotesStyle.DotStandardOffset.TenthsToWPFUnit(), dotPositionY);

            for (int i = 0; i < dotCount; i++)
            {
                noteVisualHost.AddCharacterGlyph(dotPosition, MusicSymbols.Dot, isSmall, color);
                dotPosition.X += layoutStyle.NotesStyle.DotStandardOffset.TenthsToWPFUnit() + dotWidth;
            }
        }
Ejemplo n.º 16
0
        private void YAxisTitleLabel()
        {
            var yAxisTitle = new LightText {
                Text = YAxisTitle
            };

            //Set position for axis title.

            //If the origin line is too close the edge of the canvas, the labels are drawn on the opposite side of the axis (the right).
            if (graphProperties.Origin.X + DrawingMethods.MeasureString(YAxisTitle, FontSize).Width * 2 < graphProperties.CanvasWidth)
            {
                yAxisTitle.Position.X = graphProperties.Origin.X + 25;
                yAxisTitle.Position.Y = DrawingMethods.MeasureString(YAxisTitle, FontSize).Height * 1.5;
            }
            else //Else the labels are drawn on the normal side of the axis (the left).
            {
                yAxisTitle.Position.X = graphProperties.Origin.X - DrawingMethods.MeasureString(YAxisTitle, FontSize).Width * 2;
                yAxisTitle.Position.Y = DrawingMethods.MeasureString(YAxisTitle, FontSize).Height * 1.5;
            }

            this.Add(yAxisTitle);
        }
Ejemplo n.º 17
0
        public ActionResult Create(Drawing drawing, HttpPostedFileBase LargeImage)
        {
            if (ModelState.IsValid)
            {
                if (LargeImage != null)
                {
                    //saving both small and large images and receiving back their urls.
                    DrawingMethods drawingMethods = new DrawingMethods();
                    drawing.LargeImageUrl = drawingMethods.SaveLargeImage(LargeImage, db.drawingTypes.Single(i => i.DrawingTypeId == drawing.DrawingTypeId).Name);

                    //adding records to database..
                    db.drawings.Add(drawing);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Please Select an image for project.");
                }
            }

            return(View(drawing));
        }
Ejemplo n.º 18
0
        private void InternalRenderer(ref Graphics g, ref Rectangle rect)
        {
            //set colors
            if (_persistentColours == false)
            {
                //init color values
                if (_useStyledColours == true)
                {
                    _gradientStartColour  = Color.FromArgb(255, 246, 215);
                    _gradientEndColour    = Color.FromArgb(255, 213, 77);
                    _gradientMiddleColour = Color.FromArgb(252, 224, 133);
                }
                else
                {
                    _gradientStartColour  = _palette.ColorTable.StatusStripGradientBegin;
                    _gradientEndColour    = _palette.ColorTable.OverflowButtonGradientEnd;
                    _gradientMiddleColour = _palette.ColorTable.StatusStripGradientEnd;
                }
            }


            //draw
            DrawingMethods.DrawGradient(g, rect, _gradientStartColour, _gradientEndColour, 90F, _enableSelectionBorder, _gradientMiddleColour, 1);
        }
Ejemplo n.º 19
0
        //Get the label increment for a given set of intervals to be drawn on the x axis. (i.e. the spacing between each label.)
        private double GetLabelIncrementX(int FontSize)
        {
            var labelincrementX = graphProperties.IncrementX;

            for (double i = 0; i <= graphProperties.XRange; i += graphProperties.IncrementX)
            {
                var labelIncrementFound = false;
                var loopCounter         = 0;
                var labelText           = (graphProperties.XStart - graphProperties.StartOffSetX + i).ToString("0.######");
                while (labelIncrementFound == false)
                {
                    loopCounter++;
                    if (DrawingMethods.MeasureString(labelText, FontSize).Width > graphProperties.XInterval * (2 / 3f) * loopCounter)
                    {
                        labelincrementX = graphProperties.IncrementX * (loopCounter + 1);
                    }
                    else
                    {
                        labelIncrementFound = true;
                    }
                }
            }
            return(labelincrementX);
        }
Ejemplo n.º 20
0
        //Get the label increment for a given set of intervals to be drawn on the y axis. (i.e. the spacing between each label.)
        private double GetLabelIncrementY(int FontSize)
        {
            var labelincrementY = graphProperties.IncrementY;

            for (var i = graphProperties.YRange; i >= -graphProperties.IncrementY; i -= graphProperties.IncrementY)
            {
                var labelIncrementFound = false;
                var loopCounter         = 0;
                var labelText           = (graphProperties.YStart - graphProperties.StartOffSetY + (graphProperties.YRange - i)).ToString("0.######");
                while (labelIncrementFound == false)
                {
                    loopCounter++;
                    if (DrawingMethods.MeasureString(labelText, FontSize).Height > graphProperties.YIncrement * (2 / 3f) * loopCounter)
                    {
                        labelincrementY = graphProperties.IncrementY * (loopCounter + 1);
                    }
                    else
                    {
                        labelIncrementFound = true;
                    }
                }
            }
            return(labelincrementY);
        }
Ejemplo n.º 21
0
        public ActionResult Edit(Drawing drawing, HttpPostedFileBase LargeImage)
        {
            if (ModelState.IsValid)
            {
                DrawingMethods drawingMethods = new DrawingMethods();

                if (LargeImage != null)
                {
                    //deleting old large image file.
                    var oldLargeImageUrlPath = Path.Combine(HttpContext.Server.MapPath(drawing.LargeImageUrl));

                    //saving small image and receiving back their urls.
                    drawing.LargeImageUrl = drawingMethods.SaveLargeImage(LargeImage, drawing.drawingsType.Name);
                    if (System.IO.File.Exists(oldLargeImageUrlPath))
                    {
                        System.IO.File.Delete(oldLargeImageUrlPath);
                    }
                }
                db.Entry(drawing).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(drawing));
        }
 protected override void Update()
 {
     GetSymbol();
     GetLine();
     if (IsVisible)
     {
         double tempLine   = _staffLine;
         string tempSymbol = _symbol;
         if (_isEmpty) // used for proper layout spacing, invisible but taking space; //TODO_LATER more test/refactor
         {
             _itemWidth = DrawingMethods.GetTextWidth(MusicSymbols.GClef, TypeFaces.GetMusicFont(), _isAdditional);
             tempSymbol = "";
             tempLine   = 0.0;
         }
         else
         {
             _itemWidth = DrawingMethods.GetTextWidth(_symbol, TypeFaces.GetMusicFont(), _isAdditional);
         }
         DrawingVisualHost clefVisualsHost = new DrawingVisualHost();
         clefVisualsHost.AddCharacterGlyph(new Point(0, tempLine), tempSymbol, _isAdditional, Color);
         ItemCanvas.Children.Clear();
         ItemCanvas.Children.Add(clefVisualsHost);
     }
 }
Ejemplo n.º 23
0
        internal void DrawTab(Graphics g, TabPage tabPage, int nIndex)
        {
            Rectangle  recBounds   = this.GetTabRect(nIndex);
            RectangleF tabTextArea = (RectangleF)this.GetTabRect(nIndex);

            //debug --> to be fixed
            if (recBounds.Width == 0)
            {
                recBounds.Width = 50;
            }
            if (tabTextArea.Width == 0)
            {
                tabTextArea.Width = 50;
            }
            if (recBounds.Height == 0)
            {
                recBounds.Width = 22;
            }
            if (tabTextArea.Height == 0)
            {
                tabTextArea.Width = 22;
            }


            bool bSelected = (this.SelectedIndex == nIndex);
            bool bHot      = false;

            if (tabPage.Tag != null)
            {
                bHot = (bool)tabPage.Tag;
            }

            //for buttons appearance
            if (this.Appearance != TabAppearance.Normal)
            {
                _cornerLeftWidth  = 0;
                _cornerRightWidth = 0;
                _cornerWidth      = 0;
                this.Alignment    = TabAlignment.Top;
            }

            //Tab Hedaer Status
            DrawingMethods.TabHeaderStatus Status = DrawingMethods.TabHeaderStatus.Normal;
            if (_preserveTabColour)
            {
                Status = DrawingMethods.TabHeaderStatus.NormalPreserve;
            }
            if (bHot)
            {
                Status = DrawingMethods.TabHeaderStatus.Hot;
            }

            //bool bHotselected = false;

            if ((bSelected) && (!bHot))
            {
                Status = DrawingMethods.TabHeaderStatus.Selected;
            }
            else if ((bSelected) && (bHot))
            {
                Status = DrawingMethods.TabHeaderStatus.HotSelected;
                //bHotselected = true;
            }

            //Selected tab has to be highter
            if (!_allowSelectedTabHigh)
            {
                _allowSelectedTabHighSize = 0;
            }
            else
            {
                _allowSelectedTabHighSize = 1;
            }

            //Create tab Header Points (Sqared)
            Point[] pt = DrawingMethods.GetTabSquaredPoints(recBounds, _cornerWidth, Alignment, _cornerLeftWidth, _cornerRightWidth, this.Appearance, Status, _allowSelectedTabHighSize, false);

            //----------------------------
            // fill this tab with background color
            Brush br = new SolidBrush(tabPage.BackColor);

            //Font for header
            Font fnt = Font;

            switch (Status)
            {
            case DrawingMethods.TabHeaderStatus.Selected:
                DrawingMethods.DrawTabHeader(g, pt, recBounds, _tabColourSelectedLight, _tabColourSelectedDark, tabPage.BackColor, 90, Alignment, _useExtendedLayout, Status, false);
                fnt = new Font(Font.FontFamily, Font.SizeInPoints, FontStyle.Bold);
                br  = new SolidBrush(_tabForeColour);
                break;

            case DrawingMethods.TabHeaderStatus.HotSelected:
                DrawingMethods.DrawTabHeader(g, pt, recBounds, _tabColourSelectedLight, DrawingMethods.GetLighterColour(_tabColourSelectedDark), tabPage.BackColor, 90, Alignment, _useExtendedLayout, Status, false);
                fnt = new Font(Font.FontFamily, Font.SizeInPoints, FontStyle.Bold);
                br  = new SolidBrush(_tabHotForeColour);
                break;

            case DrawingMethods.TabHeaderStatus.Hot:
                DrawingMethods.DrawTabHeader(g, pt, recBounds, _tabColourHotLight, _tabColourHotDark, _tabColourHotLight, 90, Alignment, _useExtendedLayout, Status, false);
                br = new SolidBrush(_tabHotForeColour);
                break;

            case DrawingMethods.TabHeaderStatus.Normal:
                DrawingMethods.DrawTabHeader(g, pt, recBounds, _tabColourDefaultLight, _tabColourDefaultDark, _tabColourDefaultLight, 90, Alignment, _useExtendedLayout, Status, false);
                br = new SolidBrush(_tabForeColour);
                break;

            case DrawingMethods.TabHeaderStatus.NormalPreserve:
                DrawingMethods.DrawTabHeader(g, pt, recBounds, DrawingMethods.GetSystemLighterColour(tabPage.BackColor), DrawingMethods.GetDarkerColour(tabPage.BackColor), tabPage.BackColor, 90, Alignment, _useExtendedLayout, Status, true);
                br = new SolidBrush(_tabForeColour);
                break;
            }

            //----------------------------

            //----------------------------
            // draw border
            //g.DrawRectangle(SystemPens.ControlDark, recBounds);
            g.DrawPolygon(new Pen(_borderColour, _borderWidth), pt);
            //----------------------------

            if (((Status == DrawingMethods.TabHeaderStatus.Selected) || (Status == DrawingMethods.TabHeaderStatus.HotSelected)) && (this.Appearance == TabAppearance.Normal))
            {
                //----------------------------
                // clear bottom lines
                Pen pen = new Pen(tabPage.BackColor);

                DrawingMethods.ClearTabSelectedBottomLine(g, recBounds, pen, this.Alignment);

                pen.Dispose();
                //----------------------------
            }
            //----------------------------

            //----------------------------
            // draw tab's icon
            if ((tabPage.ImageIndex >= 0) && (ImageList != null) && (ImageList.Images[tabPage.ImageIndex] != null))
            {
                int nLeftMargin  = 8;
                int nRightMargin = 2;

                Image img = ImageList.Images[tabPage.ImageIndex];

                Rectangle rimage = new Rectangle(recBounds.X + nLeftMargin, recBounds.Y + 1, img.Width, img.Height);

                // adjust rectangles
                float nAdj = (float)(nLeftMargin + img.Width + nRightMargin);

                // adjust rectangles
                if (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom)
                {
                    nAdj = (float)(nLeftMargin + img.Width + nRightMargin);

                    rimage.Y          += (recBounds.Height - img.Height) / 2;
                    tabTextArea.X     += nAdj;
                    tabTextArea.Width -= nAdj;
                }
                else
                {
                    if (_useExtendedLayout == false)
                    {
                        img.RotateFlip(RotateFlipType.Rotate90FlipNone);
                        rimage.X -= 5;
                    }
                    //rimage.X += (recBounds.Width - img.Width) / 2;

                    rimage.Y += 3;

                    nAdj                = (float)(10 + img.Height);
                    tabTextArea.Y      += img.Height;
                    tabTextArea.Height -= img.Height;
                }

                // draw icon
                g.DrawImage(img, rimage);
            }
            //no image
            else
            {
                if (_useExtendedLayout == true)
                {
                    tabTextArea.Y      += 16;
                    tabTextArea.Height -= 16;
                }
            }
            //----------------------------

            //----------------------------
            // draw string
            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;

            //rtl
            if (this.RightToLeft == RightToLeft.Yes)
            {
                stringFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft;
            }

            //Disabled
            if (!this.Enabled)
            {
                br = new SolidBrush(SystemColors.GrayText);
            }

            if (this.Alignment == TabAlignment.Right || this.Alignment == TabAlignment.Left)
            {
                //not ExtendedLayout
                if (_useExtendedLayout == false)
                {
                    stringFormat.FormatFlags = StringFormatFlags.DirectionVertical;
                    tabTextArea.Offset(-3, -5);
                }
                else
                //Extended Layout
                {
                    tabTextArea.Height = tabTextArea.Height + 8;
                    tabTextArea.Offset(4, -12);
                    stringFormat.FormatFlags = StringFormatFlags.NoWrap;
                    stringFormat.Trimming    = StringTrimming.EllipsisCharacter;
                }
            }
            else
            {
                tabTextArea.Offset(-5, 0);
            }

            //use AntiAlias
            if (Utility.IsVista())
            {
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            }
            else
            {
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
            }

            g.DrawString(tabPage.Text, fnt, br, tabTextArea, stringFormat);
            //----------------------------

            br.Dispose();
        }
Ejemplo n.º 24
0
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            try
            {
                //init expanded, collapsed, item values
                string expanded  = ">>";
                string collapsed = "<<";
                string item      = " ";

                Image exp;
                Image col;
                if (_enableVistaSigns == true)
                {
                    exp = ilSigns.Images[2];
                    col = ilSigns.Images[3];
                }
                else
                {
                    exp = ilSigns.Images[0];
                    col = ilSigns.Images[1];
                }


                //node font color
                Brush nodeTextColor  = new SolidBrush(_nodeTextColor); //new SolidBrush(_palette.ColorTable.ToolStripText);
                Brush nodeFocusColor = new SolidBrush(_nodeFocusColor);

                Graphics  g    = e.Graphics;
                Rectangle rect = e.Bounds;

                //ClearType
                try
                {
                    e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message);
                }

                // for background and for expanded, collapsed indicator
                Rectangle bgnrect = e.Bounds;
                bgnrect.Height -= 1;
                bgnrect.Width  -= 1;


                Color gradStartColor = _gradientStartColor;
                Color gradEndColor   = _gradientEndColor;

                //set colors
                if (_persistentColors == false)
                {
                    //init color values
                    if (_useStyledColors == true)
                    {
                        gradStartColor = _gradientStartColorStyled;
                        gradEndColor   = _gradientEndColorStyled;
                    }
                    else
                    {
                        gradStartColor = _gradientStartColor;
                        gradEndColor   = _gradientEndColor;
                    }
                }

                //BackColors



                //TreeNodeStates stat = e.State;
                //Console.Write(stat);

                // Draw the background and node text for a selected node.
                if (((e.State & TreeNodeStates.Selected) != 0) || ((e.State & TreeNodeStates.Focused) != 0) || ((e.State & TreeNodeStates.Checked) != 0))
                {
                    // Draw the background of the selected node. The NodeBounds
                    // method makes the highlight rectangle large enough to
                    // include the text of a node tag, if one is present.

                    using (LinearGradientBrush brush = new LinearGradientBrush(e.Bounds, gradStartColor, gradEndColor, LinearGradientMode.Vertical))
                    {
                        g.FillRectangle(Brushes.White, rect);
                    }

                    if (_flatDesign)
                    {
                        g.FillRectangle(new SolidBrush(_flatDesignColor), rect);
                    }
                    else
                    {
                        DrawingMethods.DrawGradient(g, bgnrect, gradStartColor, gradEndColor, 90F, _enableSelectionBorder, gradEndColor, 1);
                    }
                    //DrawingMethods.DrawBlendGradient(g, rect, gradStartColor, gradEndColor, gradMiddleColor, 90F);

                    // Retrieve the node font. If the node font has not been set,
                    // use the TreeView font.
                    Font nodeFont = e.Node.NodeFont;
                    if (nodeFont == null)
                    {
                        nodeFont = this.Font;
                    }


                    //if root node, less offset
                    if (e.Node.Level != 0)
                    {
                        //others
                        //progress by 19 starting with 41
                        rect.Offset(41 + 19 * (e.Node.Level - 1), 0);
                        bgnrect.Offset(41 + 19 * (e.Node.Level - 1) - 18, 0);

                        //if (e.Node.Level == 1) rect.Offset(41, 0);
                        //if (e.Node.Level == 2) rect.Offset(60, 0);
                        //if (e.Node.Level == 3) rect.Offset(79, 0);
                        //if (e.Node.Level == 4) rect.Offset(98, 0);
                    }
                    else
                    {
                        //root
                        rect.Offset(22, 0);
                        bgnrect.Offset(22 - 18, 0);
                    }


                    //expanded, collapsed, item? --> Draw Indicator
                    if (e.Node.Nodes.Count > 0)
                    {
                        if (e.Node.IsExpanded)              //Expanded
                        {
                            if (_enableVisualSigns == true) //image or string?
                            {
                                g.DrawImage(col, bgnrect.X - 1, bgnrect.Y, 16, 16);
                            }
                            else
                            {
                                g.DrawString(collapsed, nodeFont, nodeTextColor, bgnrect);
                            }
                        }
                        else // Collapsed
                        {
                            if (_enableVisualSigns == true)
                            {
                                g.DrawImage(exp, bgnrect.X - 1, bgnrect.Y, 16, 16);
                            }
                            else
                            {
                                g.DrawString(expanded, nodeFont, nodeTextColor, bgnrect);
                            }
                        }
                    }
                    else //Item
                    {
                        g.DrawString(item, nodeFont, nodeTextColor, bgnrect);
                    }

                    //CheckBox present?
                    if (this.CheckBoxes == true)
                    {
                        //string CheckState = "V";
                        Image Check;
                        if (e.Node.Checked == true)
                        {
                            //CheckState = "V";
                            if (_enableVistaCheckBoxes == true)
                            {
                                Check = ilCheckBoxes.Images[3];
                            }
                            else
                            {
                                Check = ilCheckBoxes.Images[1];
                            }
                        }
                        else
                        {
                            //CheckState = "O";
                            if (_enableVistaCheckBoxes == true)
                            {
                                Check = ilCheckBoxes.Images[2];
                            }
                            else
                            {
                                Check = ilCheckBoxes.Images[0];
                            }
                        }

                        //vista Pixel fix
                        if (Utility.IsVista() == true)
                        {
                            rect.Offset(-2, -1);
                        }

                        //e.Graphics.DrawString(CheckState, this.Font, new SolidBrush(textColor), rect);
                        g.DrawImage(Check, rect.X, rect.Y, 16, 16);
                        rect.Offset(16, 0);

                        //vista Pixel fix
                        if (Utility.IsVista() == true)
                        {
                            rect.Offset(-1, 1);
                        }
                    }

                    //Picture Present?
                    if (this.ImageList != null && e.Node.ImageIndex >= 0 && e.Node.ImageIndex < ImageList.Images.Count)
                    {
                        this.ImageList.Draw(g, rect.X, rect.Y + 0, 16, 16, e.Node.ImageIndex);
                        rect.Offset(19, 0);
                    }
                    else
                    {
                        if (this.ImageList != null)
                        {
                            this.ImageList.Draw(g, rect.X, rect.Y + 0, 16, 16, this.ImageIndex);
                            rect.Offset(19, 0);
                        }
                    }

                    //ofset for aligning the text
                    rect.Offset(0, 1);

                    // Draw the node text.
                    g.DrawString(e.Node.Text, nodeFont, nodeTextColor, rect);
                }


                // Use the default background and node text.
                else
                {
                    e.DrawDefault = true;
                }

                // If a node tag is present, draw its string representation
                // to the right of the label text.
                if (e.Node.Tag != null)
                {
                    e.Graphics.DrawString(e.Node.Tag.ToString(), tagFont,
                                          nodeTextColor, e.Bounds.Right + 2, e.Bounds.Top);
                }

                // If the node has focus, draw the focus rectangle large, making
                // it large enough to include the text of the node tag, if present.
                if ((e.State & TreeNodeStates.Focused) != 0)
                {
                    using (Pen focusPen = new Pen(nodeFocusColor))
                    {
                        focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                        Rectangle focusBounds = NodeBounds(e.Node);
                        focusBounds.Size = new Size(focusBounds.Width - 1,
                                                    focusBounds.Height - 2);
                        //uncomment for focus area
                        if (_drawFocus == true)
                        {
                            e.Graphics.DrawRectangle(focusPen, focusBounds);
                        }
                    }
                }
                nodeTextColor.Dispose();
                nodeFocusColor.Dispose();
            }

            catch
            {
            }
        }
Ejemplo n.º 25
0
        public void GetAllProjects()
        {
            try
            {
                LogMethods.Log.Info("GetAllProjects:Info:" + "Start processing all projects");
                //create service client to call API endpoint
                using (enterprise.SoapClient queryClient = new enterprise.SoapClient("Soap", apiAddr))
                {
                    //create SQL query statement
                    string query = "SELECT Id, Project_Number__c, Name, CloseDate, Type, OwnerId, Owner.CommunityNickname, Bidding_Type__c, Bidding_Source__c, Product_Line__c, Middle_Updated_Flag__c, "
                                   + " Bidding_Due_Date__c, Bidding_Remark__c, Sync__c, Account_Executive__r.CommunityNickname, Project_Coordinator__r.CommunityNickname, "
                                   + " (SELECT Id, Name, Billing_Company_City__c, Billing_Contact_Name__r.Account.Id, Billing_Company_Name__r.Name, Billing_Company_Name__r.Id, Billing_Company_Postal_Code__c, Billing_Company_Province__c, Billing_Company_Street__c, Billing_Contact_Name__r.FirstName, Billing_Contact_Name__r.LastName, Billing_Contact_Name__r.Id, Billing_Contact_Phone__c, Billing_Company_Country__c, Quoting_Company_City__c, Quoting_Company_Name__r.Name, Quoting_Company_Name__r.Id,  Quoting_Contact_Name__r.Account.Id, Quoting_Company_Postal_Code__c, Quoting_Company_Province__c, Quoting_Company_Street__c, Quoting_Contact_Name__r.FirstName, Quoting_Contact_Name__r.LastName, Quoting_Contact_Name__r.Id, Quoting_Contact_Phone__c, Quoting_Company_Country__c,Installing_Company_City__c, Installing_Company_Name__r.Name, Installing_Company_Name__r.Id, Installing_Contact_Name__r.Account.Id, Installing_Company_Postal_Code__c, Installing_Company_Province__c, Installing_Company_Street__c, Installing_Contact_Name__r.FirstName, Installing_Contact_Name__r.LastName, Installing_Contact_Name__r.Id, Installing_Contact_Phone__c, Installing_Company_Country__c, Billing_Account_Intersection__c, Billing_Account_Corner__c, Installing_Account_Intersection__c,Installing_Account_Corner__c,Quoting_Account_Intersection__c,Quoting_Account_Corner__c,Billing_Company_Name__r.Legal_Name__c  FROM Bill_Quote_Ships__r), "
                                   + " (SELECT Id, Number_of_Signs__c, Project_Value_Estimated__c,  Remarks__c, Issue_Date__c, Due_Date__c, LandLord__r.Name, LandLord_Contact__r.Name, LandLord_Phone_Number__c, LandLord__r.BillingStreet, LandLord__r.BillingCity, LandLord__r.BillingState, LandLord__r.BillingPostalCode FROM Sign_Permits__r),"
                                   + " (SELECT Id, Occupation_Start_Time__c, Occupation_End_Time__c, Issue_Date__c, Type_Of_Truck__c, Truck_Weight__c, Foreman_Name__r.Name, Foreman_Phone__c, Remarks__c FROM Hoisting_Permits__r),"
                                   + " (SELECT Id, Stick_Position_Radius__c, Dept_Of_Holes__c, Issue_Date__c, Due_Date__c, Remarks__c FROM StakeOut_Permits__r),"
                                   + " (SELECT Id, Name, First_Site_Contact__c, Second_Site_Contact__c, Budget__c, Provided_By__c,  Remarks__c, Due_Date__c, Rush__c, Requirement__c, Requirement_As_Other__c, Estimated_Shipping_Cost__c, Shipping_Items_Total_Value__c, Work_Order_Number__c  FROM SubContracts__r) "
                                   + " FROM Opportunity "
                                   + " WHERE Sync__c = true and Middle_Updated_Flag__c = 1 ";
                    //+ " WHERE name= '2131 Yonge Street - Exterior and Interior Signage Program'";



                    enterprise.QueryResult result;
                    queryClient.query(
                        header, //sessionheader
                        null,   //queryoptions
                        null,   //mruheader
                        null,   //packageversion
                        query, out result);

                    /* if no any record, return */
                    if (result.size == 0)
                    {
                        return;
                    }

                    //cast query results
                    IEnumerable <enterprise.Opportunity> opportunityList = result.records.Cast <enterprise.Opportunity>();

                    /*
                     * enterprise.Opportunity[] opp = new enterprise.Opportunity[result.size];
                     * int i = 0;
                     * foreach (var opportunity in opportunityList)
                     * {
                     *  enterprise.Opportunity temp = new enterprise.Opportunity();
                     *  temp.Id = opportunity.Id;
                     *  temp.Middle_Updated_Flag__c = 0;
                     *  temp.Middle_Updated_Flag__cSpecified = true;
                     *  opp[i] = temp;
                     *  i++;
                     * }
                     * enterprise.LimitInfo[] l1;
                     * enterprise.SaveResult[] s1;
                     * queryClient.update(header, null, null, null, null, null, null, null, null, null, null, null, null, opp, out l1, out s1);
                     * */

                    int size = result.size;
                    int j    = 1;
                    int k    = 0;
                    while (j <= size)
                    {
                        int limitArray = (size > 150) ? 150 : size;
                        size -= limitArray;

                        enterprise.Opportunity[] opp = new enterprise.Opportunity[limitArray];
                        int i = 0;
                        for (int m = k; m < k + limitArray; m++)
                        {
                            enterprise.Opportunity temp = new enterprise.Opportunity();
                            temp.Id = opportunityList.ElementAt(m).Id;
                            temp.Middle_Updated_Flag__c          = 0;
                            temp.Middle_Updated_Flag__cSpecified = true;
                            opp[i] = temp;
                            i++;
                        }
                        k += limitArray;
                        enterprise.LimitInfo[]  l1;
                        enterprise.SaveResult[] s1;
                        queryClient.update(header, null, null, null, null, null, null, null, null, null, null, null, null, opp, out l1, out s1);
                    }

                    //show results
                    foreach (var opportunity in opportunityList)
                    {
                        /* get project owner */
                        //string un = CommonMethods.GetUserName(opportunity.OwnerId);
                        string     un         = (opportunity.Owner.CommunityNickname == null ? "" : opportunity.Owner.CommunityNickname);
                        FsEmployee fsEmployee = new FsEmployee(un);
                        if (fsEmployee.EmployeeNumber > 0)
                        {
                            LogMethods.Log.Info("GetAllProjects:Info:" + "Processing project name:" + opportunity.Name);
                            int sales_JobMasterListID = CommonMethods.GetMISID(TableName.Sales_JobMasterList, opportunity.Id, opportunity.Id);
                            if (sales_JobMasterListID == 0)
                            {
                                int jobID = CreateNewProject(fsEmployee.EmployeeNumber);

                                /* insert data to MISSalesForceMapping */
                                if (jobID > 0)
                                {
                                    UpdateProject(jobID, opportunity.CloseDate, fsEmployee.EmployeeNumber, opportunity.Name, opportunity.Type, opportunity.Account_Executive__r, opportunity.Product_Line__c, opportunity.Project_Coordinator__r);
                                    /* update jobnumber */
                                    UpdateJobNumber(jobID, opportunity.Project_Number__c);

                                    CommonMethods.InsertToMISSalesForceMapping(TableName.Sales_JobMasterList, opportunity.Id, jobID.ToString(), opportunity.Id);
                                }
                                else
                                {
                                    LogMethods.Log.Error("GetAllProjects:Error:" + "Cannot create a new project!");
                                    continue;
                                }
                                sales_JobMasterListID = jobID;
                            }
                            else
                            {
                                UpdateProject(sales_JobMasterListID, opportunity.CloseDate, fsEmployee.EmployeeNumber, opportunity.Name, opportunity.Type, opportunity.Account_Executive__r, opportunity.Product_Line__c, opportunity.Project_Coordinator__r);
                            }

                            /* for bidding project */
                            if (opportunity.Type == SalesType.Bid)
                            {
                                /* check if the bidding record exists */
                                int biddingID = GetBiddingID(sales_JobMasterListID);
                                if (biddingID > 0)
                                {
                                    //exist
                                    UpdateBiddingProject(biddingID, sales_JobMasterListID, opportunity.Bidding_Type__c, opportunity.Bidding_Source__c, opportunity.Bidding_Due_Date__c, opportunity.Bidding_Remark__c);
                                }
                                else
                                {
                                    InsertBiddingProject(fsEmployee.EmployeeNumber);
                                    UpdateBiddingProject(SqlCommon.GetNewlyInsertedRecordID("Sales_JobMaster_BiddingJob"), Convert.ToInt32(sales_JobMasterListID), opportunity.Bidding_Type__c, opportunity.Bidding_Source__c, opportunity.Bidding_Due_Date__c, opportunity.Bidding_Remark__c);
                                }
                            }

                            /* Bill-Quote-Ship */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing account and contact");
                            CustomerMethods cm = new CustomerMethods(opportunity.Id);
                            cm.GetAllAccounts(opportunity.Id, sales_JobMasterListID, fsEmployee.EmployeeNumber, opportunity.Bill_Quote_Ships__r);

                            /* Estimation */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing estimation");
                            EstimationMethods em = new EstimationMethods(opportunity.Id);
                            int estRevID         = CommonMethods.GetEstRevID(sales_JobMasterListID);
                            em.GetEstimation(opportunity.Id, estRevID, sales_JobMasterListID, fsEmployee.EmployeeNumber);

                            /*Drawing */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing drawing");
                            DrawingMethods dm = new DrawingMethods(opportunity.Id);
                            dm.GetAllDrawings(opportunity.Id, estRevID, sales_JobMasterListID, fsEmployee.EmployeeNumber);

                            /* Quote */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing quote");
                            QuoteMethods qm = new QuoteMethods(opportunity.Id);
                            qm.GetAllQuotes(opportunity.Id, sales_JobMasterListID, estRevID, fsEmployee.EmployeeNumber);

                            /* Sign/Hoisting/Stakeout permit */
                            PermitMethods pm = new PermitMethods(opportunity.Id);
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing sign permit");
                            pm.GetAllSignPermits(opportunity.Id, sales_JobMasterListID, fsEmployee.EmployeeNumber, opportunity.Sign_Permits__r);
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing hoisting permit");
                            pm.GetAllHoistingPermits(opportunity.Id, sales_JobMasterListID, fsEmployee.EmployeeNumber, opportunity.Hoisting_Permits__r);
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing stakeout permit");
                            pm.GetAllStakeOutPermits(opportunity.Id, sales_JobMasterListID, fsEmployee.EmployeeNumber, opportunity.StakeOut_Permits__r);

                            /* WorkOrder */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing work order");
                            WorkOrderMethods wo = new WorkOrderMethods(opportunity.Id);
                            wo.GetAllWorkOrders(opportunity.Id, sales_JobMasterListID, estRevID, fsEmployee.EmployeeNumber);

                            /* Sub-Contract */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing SubContract");
                            SubContractMethods sc = new SubContractMethods(opportunity.Id);
                            sc.GetAllSubContracts(opportunity.Id, sales_JobMasterListID, fsEmployee.EmployeeNumber, opportunity.SubContracts__r);

                            /* Invoice */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing invoice");
                            InvoiceMethods im = new InvoiceMethods(opportunity.Id);
                            im.GetAllInvoices(opportunity.Id, sales_JobMasterListID, estRevID, fsEmployee.EmployeeNumber);

                            LogMethods.Log.Info("GetAllProjects:Info:" + "Done: " + opportunity.Name + "<Project Num:" + opportunity.Project_Number__c + ">");
                        }
                        else
                        {
                            LogMethods.Log.Error("GetAllProjects:Error:" + "User Name: " + un + " does not exist in database");
                        }
                    }
                    LogMethods.Log.Info("GetAllProjects:Info:" + "All projects are done");
                }
            }
            catch (Exception e)
            {
                LogMethods.Log.Error("GetAllProjects:Error:" + e.Message);
            }
        }
Ejemplo n.º 26
0
        protected void ODrawItem(DrawItemEventArgs e)
        {
            Rectangle rect = e.Bounds;
            Graphics  g    = e.Graphics;

            //DDL fix
            if (e.Index == -1)
            {
                return;
            }

            //ClearType
            try
            {
                e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }

            if (_palette == null)
            {
                EventArgs Ev = new EventArgs();
                ThisGlobalPaletteChanged(this, Ev);
            }

            //set colors
            if (_persistentColors == false)
            {
                //init color values
                if (_useStyledColors == true)
                {
                    _gradientStartColor = Color.FromArgb(255, 246, 215);
                    _gradientEndColor   = Color.FromArgb(255, 213, 77);
                }
                else
                {
                    _gradientStartColor = _palette.ColorTable.StatusStripGradientBegin;
                    _gradientEndColor   = _palette.ColorTable.OverflowButtonGradientEnd;
                }
            }

            //BackColors
            Color gradStartColor = _gradientStartColor;
            Color gradEndColor   = _gradientEndColor;
            Color textColor      = _palette.ColorTable.StatusStripText;

            // Retrieve the item font. If the item font has not been set,
            // use the ComboBox font.
            Font itemFont = e.Font;

            if (itemFont == null)
            {
                itemFont = this.Font;
            }

            // Draw the background of the item.
            e.DrawBackground();

            // Draw each string in the array, using a different size, color,
            // and font for each item.

            string str = (string)this.Items[e.Index];

            if (!Enabled)
            {
                e.Graphics.DrawString(str, itemFont, new SolidBrush(SystemColors.GrayText), e.Bounds);
            }
            else
            {
                e.Graphics.DrawString(str, itemFont, new SolidBrush(this.ForeColor), e.Bounds);
            }

            if ((e.State & DrawItemState.Selected) != 0)
            {
                //DrawingMethods.DrawBlendGradient(e.Graphics, e.Bounds, gradStartColor, gradEndColor, gradMiddleColor, 90F);
                DrawingMethods.DrawGradient(g, e.Bounds, gradStartColor, gradEndColor, 90F, false, Color.White, 0);
                e.Graphics.DrawString(str, itemFont, new SolidBrush(textColor), e.Bounds);
                e.DrawFocusRectangle();
            }

            // Draw the focus rectangle if the mouse hovers over an item.
            e.DrawFocusRectangle();
        }
        protected override void OnPaint(PaintEventArgs pevent)
        {
            Graphics g = pevent.Graphics;

            ButtonRenderer.DrawParentBackground(g, ClientRectangle, this);
            float Angle = 90F;

            if (!isHotTracking)
            {
                paintGradientTop         = gradientTop;
                paintGradientBottom      = gradientBottom;
                paintGradientBorderColor = gradientBorderColor;
                paintForeColor           = ForeColor;
            }
            else
            {
                paintGradientTop         = _hotGradientTop;
                paintGradientBottom      = _hotGradientBottom;
                paintGradientBorderColor = _hotGradientBorderColor;
                paintForeColor           = _hotForeColor;
            }
            if (isPressed)
            {
                paintGradientTop         = _pressedGradientTop;
                paintGradientBottom      = _pressedGradientBottom;
                paintGradientBorderColor = _pressedGradientBorderColor;
                paintForeColor           = _pressedForeColor;
            }


            // Paint the outer rounded rectangle
            g.SmoothingMode = SmoothingMode.AntiAlias;
            using (GraphicsPath outerPath = RoundedRectangle(buttonRect, rectCornerRadius, 0))
            {
                using (LinearGradientBrush outerBrush = new LinearGradientBrush(buttonRect, Color.White, Color.White, LinearGradientMode.Vertical))
                {
                    g.FillPath(outerBrush, outerPath);
                }
                using (Pen outlinePen = new Pen(paintGradientBorderColor, rectOutlineWidth))
                {
                    outlinePen.Alignment = PenAlignment.Inset;
                    g.DrawPath(outlinePen, outerPath);
                }
            }
            // If this is the default button, paint an additional highlight
            if (IsDefault)
            {
                using (GraphicsPath defaultPath = new GraphicsPath())
                {
                    defaultPath.AddPath(RoundedRectangle(buttonRect, rectCornerRadius, 0), false);
                    defaultPath.AddPath(RoundedRectangle(buttonRect, rectCornerRadius, defaultHighlightOffset), false);
                    using (PathGradientBrush defaultBrush = new PathGradientBrush(defaultPath))
                    {
                        defaultBrush.CenterColor    = Color.FromArgb(50, Color.White);
                        defaultBrush.SurroundColors = new Color[] { Color.FromArgb(150, Color.White) };
                        g.FillPath(defaultBrush, defaultPath);
                    }
                }
            }
            // Paint the gel highlight
            using (GraphicsPath innerPath = RoundedRectangle(highlightRect, rectCornerRadius, highlightRectOffset))
            {
                //using (LinearGradientBrush innerBrush = new LinearGradientBrush(highlightRect, Color.FromArgb(highlightAlphaTop, Color.White), Color.FromArgb(highlightAlphaBottom, Color.White), LinearGradientMode.Vertical))
                //{
                g.FillPath(DrawingMethods.GetBrush(ClientRectangle, paintGradientTop, paintGradientBottom, DrawingMethods.PaletteColourStyle.Default, Angle, DrawingMethods.VisualOrientation.Top, false), innerPath);
                //g.FillPath(innerBrush, innerPath);
                //}
            }
            // Paint the text
            //TextRenderer.DrawText(g, Text, Font, buttonRect, paintForeColor, Color.Transparent, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
            OnDrawTextAndImage(g);
        }
Ejemplo n.º 28
0
        //Add Axes and increment lines to the main line batch.
        private void Axes()
        {
            //X-Axis
            for (var i = -graphProperties.StartOffSetX; i <= graphProperties.XRange + graphProperties.IncrementX; i += graphProperties.IncrementX)
            {
                if (!(i / graphProperties.IncrementX * graphProperties.XInterval >= 0) || !(i / graphProperties.IncrementX * graphProperties.XInterval <= graphProperties.CanvasWidth))
                {
                    continue;
                }
                //Setup fo increment lines on the axis.
                var incrementLightLine = new LightLine
                {
                    X1 = i / graphProperties.IncrementX * graphProperties.XInterval,
                    Y1 = graphProperties.Origin.Y + 4,
                    X2 = i / graphProperties.IncrementX * graphProperties.XInterval,
                    Y2 = graphProperties.Origin.Y - 4
                };

                this.Add(incrementLightLine);
            }


            var axesLightLine = new LightLine
            {
                X1 = 0,
                Y1 = graphProperties.Origin.Y,
                X2 = graphProperties.CanvasWidth,
                Y2 = graphProperties.Origin.Y
            };

            this.Add(axesLightLine);


            //Y-Axis

            for (var i = graphProperties.YRange + graphProperties.StartOffSetY; i >= -graphProperties.IncrementY; i -= graphProperties.IncrementY)
            {
                if (!(i / graphProperties.IncrementY * graphProperties.YIncrement >= 0) || !(i / graphProperties.IncrementY * graphProperties.YIncrement <= graphProperties.CanvasHeight))
                {
                    continue;
                }
                //Setup fo increment lines on the axis.
                var incrementLightLine = new LightLine
                {
                    X1 = graphProperties.Origin.X + 4,
                    Y1 = i / graphProperties.IncrementY * graphProperties.YIncrement,
                    X2 = graphProperties.Origin.X - 4,
                    Y2 = i / graphProperties.IncrementY * graphProperties.YIncrement
                };

                this.Add(incrementLightLine);
            }
            var axesLightLineY = new LightLine
            {
                X1 = graphProperties.Origin.X,
                Y1 = 0,
                X2 = graphProperties.Origin.X,
                Y2 = graphProperties.CanvasHeight
            };

            this.Add(axesLightLineY);



            //If the origin is present to be drawn on the canvas a ellipse will be drawn to mark its location.
            if (graphProperties.XStart <= 0 && graphProperties.XEnd >= 0 && graphProperties.YStart <= 0 && graphProperties.YEnd >= 0)
            {
                //Add origin circle to main batch list.
                this.Add(DrawingMethods.Circle(graphProperties.Origin, 10).Content());
            }
        }
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            base.OnPaintBackground(e);

            int tmpShadowOffSet      = Math.Min(Math.Min(_shadowOffSet, this.Width - 2), this.Height - 2);
            int tmpSoundCornerRadius = Math.Min(Math.Min(_roundCornerRadius, this.Width - 2), this.Height - 2);

            if (this.Width > 1 && this.Height > 1)
            {
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                Rectangle rect = new Rectangle(0, 0, this.Width - tmpShadowOffSet - 1,
                                               this.Height - tmpShadowOffSet - 1);

                Rectangle rectShadow = new Rectangle(tmpShadowOffSet, tmpShadowOffSet,
                                                     this.Width - tmpShadowOffSet - 1, this.Height - tmpShadowOffSet - 1);

                GraphicsPath graphPathShadow = GetRoundPath(rectShadow, tmpSoundCornerRadius);
                GraphicsPath graphPath       = GetRoundPath(rect, tmpSoundCornerRadius);

                if (tmpSoundCornerRadius > 0)
                {
                    using (PathGradientBrush gBrush = new PathGradientBrush(graphPathShadow))
                    {
                        gBrush.WrapMode = WrapMode.Clamp;
                        ColorBlend colorBlend = new ColorBlend(3);
                        colorBlend.Colors = new Color[] { Color.Transparent,
                                                          Color.FromArgb(180, Color.DimGray),
                                                          Color.FromArgb(180, Color.DimGray) };

                        colorBlend.Positions = new float[] { 0f, .1f, 1f };

                        gBrush.InterpolationColors = colorBlend;
                        e.Graphics.FillPath(gBrush, graphPathShadow);
                    }
                }

                // Draw backgroup
                Color gradStartColor;
                Color gradEndColor;
                if (_gradientToogleColors == false)
                {
                    gradStartColor = _gradientStartColor;
                    gradEndColor   = _gradientEndColor;
                }
                else
                {
                    gradStartColor = _gradientEndColor;
                    gradEndColor   = _gradientStartColor;
                }


                if (_gradientUseBlend == false)
                {
                    using (LinearGradientBrush brush = new LinearGradientBrush(rect,
                                                                               gradStartColor,
                                                                               gradEndColor,
                                                                               GradientDirection))
                    {
                        e.Graphics.FillPath(brush, graphPath);
                    }
                }
                else
                {
                    DrawingMethods.DrawGradient(e.Graphics, rect, gradStartColor, gradEndColor, 90F, false, Color.White, 0);
                }

                if (this._borderWidth > 0)
                {
                    e.Graphics.DrawPath(new Pen(Color.FromArgb(180, this._borderColor), _borderWidth), graphPath);
                }
                // Draw Image
                if (_image != null)
                {
                    e.Graphics.DrawImageUnscaled(_image, _imageLocation);
                }
            }
        }
Ejemplo n.º 30
0
        private void Draw()
        {
            isSmall = noteVisualType == NoteChoiceTypeMusicXML.cue || noteVisualType == NoteChoiceTypeMusicXML.grace;
            DrawingVisualHost noteVisualHost = new DrawingVisualHost();
            int index = 0;

            for (int i = 0; i < noteItem.Count; i++)
            {
                double noteHeadOffset = 0;
                if (i > 0)
                {
                    int maxPitch = pitchedPosition.Values.Max();
                    int stemDir  = maxPitch < 5 ?  -1 : 1;
                    if (Math.Abs(pitchedPosition[index - 1] - pitchedPosition[index]) == 1)
                    {
                        noteHeadOffset = DrawingHelpers.DrawingMethods.GetTextWidth(symbol, TypeFaces.GetMusicFont()) * stemDir;
                    }
                }
                if (noteItem[i].Voice == null)
                {
                    Log.LoggIt.Log($"Missing note voice element, setting to default", Log.LogType.Warning);
                    noteItem[i].Voice = "1"; //! voice set to "1" if null- bugfix
                }
                color = ViewModel.ViewModelLocator.Instance.Main.CurrentLayout.LayoutStyle.Colors[int.Parse(noteItem[i].Voice)];
                noteVisualHost.AddCharacterGlyph(new Point(noteHeadOffset, pitchedValue[index]), symbol, isSmall, color);
                if (noteItem[i].Accidental != null)
                {
                    DrawAccidental(noteItem[i], noteItem.IndexOf(noteItem[i]), noteVisualHost);
                }
                if (hasDots)
                {
                    DrawDots(noteVisualHost, index);
                }
                index++;
            }

            /*foreach (var note in noteItem)
             * {
             *  if (note.Voice == null)
             *  {
             *      Log.LoggIt.Log($"Missing note voice element, setting to default", Log.LogType.Warning);
             *      note.Voice = "1"; //! voice set to "1" if null- bugfix
             *  }
             *  color = ViewModel.ViewModelLocator.Instance.Main.CurrentLayout.LayoutStyle.Colors[int.Parse(note.Voice)];
             *  noteVisualHost.AddCharacterGlyph(new Point(0, pitchedValue[index]), symbol, isSmall, color);
             *  if (note.Accidental != null)
             *  {
             *      DrawAccidental(note, noteItem.IndexOf(note), noteVisualHost);
             *  }
             *  if (hasDots)
             *  {
             *      DrawDots(noteVisualHost, index);
             *  }
             *  index++;
             * }
             */
            itemWidthMin = DrawingMethods.GetTextWidth(symbol, TypeFaces.GetMusicFont(), isSmall);
            itemWidth    = itemWidthMin;
            CheckForLedgerLines();
            if (needLedgerLines)
            {
                Point position     = new Point();
                int   indexLedgers = 0;
                foreach (var ledgerPosition in ledgerLinesPositions)
                {
                    noteVisualHost.AddLedgerLine(new Point(position.X, ledgerLinesPositions[indexLedgers]), itemWidthMin);
                    indexLedgers++;
                }
            }
            ItemCanvas.Children.Add(noteVisualHost);
        }