Example #1
0
        /// <summary>
        /// Update
        /// </summary>
        protected void Update(object sender, EventArgs e)
        {
            // Color of text
            _textTint             = MColor.Mix(Color.FromArgb(_tintAlpha, _tint), _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());
            FakeTextBox.ForeColor = _textTint;

            // Alpha
            if (FakeTextBox.Focused)
            {
                if (_tintAlpha < 255)
                {
                    _tintAlpha += 15;
                }
            }
            else
            {
                if (_tintAlpha > 0)
                {
                    _tintAlpha -= 15;
                }
            }

            // Redraw
            Invalidate();
        }
Example #2
0
        public override MUserData prepareForDraw(MDagPath objPath, MDagPath cameraPath, MFrameContext frameContext, MUserData oldData)
        {
            // This function is called by maya internal, .Net SDK has transfered MUserData to the derived one
            // Users don't need do the MUserData.getData(oldData) by themselves
            FootPrintData data = oldData as FootPrintData;

            if (data == null)
            {
                // Retrieve data cache (create if does not exist)
                data           = new FootPrintData(false);
                data.OwnerShip = false;
            }

            // compute data and cache it
            data.fMultiplier = getMultiplier(objPath);
            MColor color = MGeometryUtilities.wireframeColor(objPath);

            data.fColor[0]           = color.r;
            data.fColor[1]           = color.g;
            data.fColor[2]           = color.b;
            data.fCustomBoxDraw      = mCustomBoxDraw;
            data.fCurrentBoundingBox = mCurrentBoundingBox;
            // Get the draw override information
            data.fDrawOV = objPath.drawOverrideInfo;

            return(data);
        }
Example #3
0
 private void ColorComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     //Console.WriteLine("aa");
     try
     {
         if (this.SelectedIndex == this.Items.Count - 1 && !IsCustomerSet)
         {
             if (this.colDlg)
             {
                 ColorDialog cDlg = new ColorDialog();
                 cDlg.FullOpen = true;
                 cDlg.ShowDialog();
                 otherCol        = cDlg.Color;
                 resultCol.Color = cDlg.Color;
                 resultCol.Name  = cDlg.Color.Name;
             }
             else
             {
                 this.colDlg = true;
                 this.Refresh();
             }
         }
         else
         {
             resultCol = (MColor)this.Items[this.SelectedIndex];
         }
     }
     catch
     {
         //MessageBox.Show("ERRR");
     }
 }
Example #4
0
        public MColor Get(int id)
        {
            MColor color = new MColor();

            color = auctionContext.MColors.Where(a => a.iColorID == id).FirstOrDefault();
            return(color);
        }
Example #5
0
    /**
     * Create a message indicating which team has picked up the flag.
     */
    public void AddFlagPickupMessage(PunTeams.Team pickupTeam)
    {
        string teamStr = "";
        MColor color   = MColor.neutralTeam;

        switch (pickupTeam)
        {
        case PunTeams.Team.red:
            teamStr = "Red";
            color   = MColor.redTeam;
            break;

        case PunTeams.Team.blue:
            teamStr = "Blue";
            color   = MColor.blueTeam;
            break;

        case PunTeams.Team.none:
            teamStr = "Neutral";
            color   = MColor.neutralTeam;
            break;

        default:
            Debug.Assert(false, "Panic: Invalid team value");
            break;
        }

        string message = string.Format(">>> {0} team has the flag", teamStr);

        GetComponent <PhotonView>().RPC("AddTextMessage_RPC",
                                        PhotonTargets.AllBuffered, message, color);
    }
Example #6
0
    /* Compare, compares to given colors. If colors are not equal
     * the color closest to white is larger color.
     *
     *  @param a, the color to be compared to
     *  @param b. the color to compare
     *
     *  @return 0: a == b
     *  @return 1: a > b
     *  @return -1: a < b
     */
    public static int Compare(MColor a, MColor b)
    {
        if (a is null && b is null)
        {
            return(0);
        }

        //A non null color is greater than a null color
        if (b is null)
        {
            return(1);
        }

        //A null color is not greater than non null color
        if (a is null)
        {
            return(-1);
        }

        if (a.Name == b.Name && a.HexColor == b.HexColor)
        {
            return(0);
        }

        Color ca = a.GetColor();
        Color cb = b.GetColor();

        float total = 0;

        total += ca.r - cb.r;
        total += ca.g - cb.g;
        total += ca.b - cb.b;

        return(total > 0 ? 1 : (total == 0 ? 0 : -1));
    }
    public ModelTexture(DataSnapshot textureData)
    {
        if (textureData == null)
        {
            return;
        }
        if (!textureData.HasChildren)
        {
            return;
        }

        Name  = textureData.Key;
        Color = new MColor(textureData.Key);

        if (!Color.isValid)
        {
            return;
        }

        foreach (DataSnapshot child in textureData.Children)
        {
            if (!child.HasChildren)
            {
                if (child.Key == "glb")
                {
                    SetGLB((string)child.Value);
                }
                else if (child.Key == "thumbnail")
                {
                    Thumbnail = new Thumbnail((string)child.Value);
                }
            }
        }
    }
Example #8
0
    public MPlayer(int index, bool isHuman, string name, MColor color)
    {
        this.index = index;
        this.isHuman = isHuman;
        this.name = name;
        this.color = color;

        framesTillBeast = maxFramesTillBeast;

        stats = new MPlayerStat[4];

        stats[0] = statSpeed = new MPlayerStat(0,"speed",0,30);
        stats[1] = statAttack = new MPlayerStat(1,"attack",0,30);
        stats[2] = statDefence = new MPlayerStat(2,"defence",0,30);
        stats[3] = statHealth = new MPlayerStat(3,"health",0,30);

        currentStatTotal = 0;
        statTotal = 0;

        foreach(MPlayerStat stat in stats)
        {
            stat.player = this;
            statTotal += stat.max;
            stat.SignalChange += HandleStatChange;
        }

        isDirty = true;
    }
Example #9
0
        /// <summary>
        /// Draw item
        /// </summary>
        public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds)
        {
            // DIP
            DIP.GetGraphics(g);

            // Basic varibles
            Height   = DIP.Set(70);
            Bounds   = itemBounds;
            Graphics = g;

            // Handles control's source theme
            // Check if control has set own theme
            if (owner.UsedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = owner.UsedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)owner.FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Background
            g.FillRectangle(new SolidBrush(_sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()), Bounds);

            // Item have focus || mouse hover
            if (Bounds.Contains(owner.MousePosition))
            {
                // Partially transparent tint layer
                g.FillRectangle(new SolidBrush(Color.FromArgb(25, owner.Tint)), Bounds);
            }

            // Draw primary text
            StringFormat sfPrimary = new StringFormat();

            sfPrimary.LineAlignment = StringAlignment.Center;
            g.DrawString(PrimaryText, new Font("Segoe UI", 9), new SolidBrush((Bounds.Contains(owner.MousePosition) ? owner.Tint : _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor())), new Rectangle(Bounds.X + 10, Bounds.Y + 5, Bounds.Width, Bounds.Height / 2 + 1), sfPrimary);

            // Draw secondary text
            StringFormat sfSecondary = new StringFormat();

            sfSecondary.LineAlignment = StringAlignment.Center;
            Color textColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());

            g.DrawString(SecondaryText, new Font("Segoe UI", 8), new SolidBrush(textColor), new Rectangle(Bounds.X + 10, Bounds.Y + Bounds.Height / 2 - 9, Bounds.Width, Bounds.Height / 2 + 5), sfSecondary);
        }
        /// <summary>
        /// Draw
        /// </summary>
        public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds)
        {
            // DIP
            DIP.GetGraphics(g);

            // Basic varibles
            Height   = DIP.Set(50);
            Bounds   = itemBounds;
            Graphics = g;

            // Handles control's source theme
            // Check if control has set own theme
            if (owner.UsedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = owner.UsedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)owner.FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Background
            g.FillRectangle(new SolidBrush(_sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()), Bounds);

            // Item have focus || mouse hover
            if (Bounds.Contains(owner.MousePosition))
            {
                // Partially transparent tint layer
                g.FillRectangle(new SolidBrush(Color.FromArgb(25, owner.Tint)), Bounds);
            }

            // Avatar
            Rectangle           avatar = new Rectangle(new Point(Bounds.X + 10, Bounds.Y + (Bounds.Height / 2) - 8), new Size(15, 15));
            LinearGradientBrush lgb    = new LinearGradientBrush(avatar, Color, MColor.AddRGB(55, Color), LinearGradientMode.ForwardDiagonal);

            g.FillRectangle(lgb, avatar);
            g.DrawRectangle(new Pen(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor(), 1), avatar);

            // Draw primary text
            StringFormat sfPrimary = new StringFormat();

            sfPrimary.LineAlignment = StringAlignment.Center;
            g.DrawString(PrimaryText, new Font("Segoe UI", 9), new SolidBrush(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(Bounds.X + 32, Bounds.Y + 1, Bounds.Width + 50, Bounds.Height), sfPrimary);
        }
Example #11
0
        /// <summary>
        /// Draw method
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control don't have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Graphics
            Graphics g = e.Graphics;

            // Clear control
            g.Clear(Parent.BackColor);

            // Regular raised button
            Color fill = MColor.Mix(Color.FromArgb(_hoverAlpha, _sourceTheme.CONTROL_FILL.Hover.ToColor()), _sourceTheme.CONTROL_FILL.Normal.ToColor());
            Color text = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor();

            // Disabled
            if (!Enabled)
            {
                fill = _sourceTheme.CONTROL_FILL.Disabled.ToColor();
                text = _sourceTheme.CONTROL_FOREGROUND.Disabled.ToColor();
            }

            // Fill control
            g.FillRectangle(new SolidBrush(fill), ClientRectangle);

            // Click effect
            DrawClick(e);

            // Draw text
            StringFormat sf = new StringFormat();

            sf.LineAlignment = StringAlignment.Center;
            g.DrawString(Text, new Font("Segoe UI", 9), new SolidBrush(text), new Rectangle(ClientRectangle.X + 10, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height), sf);
        }
Example #12
0
        private MColor ParserAddColors(Color color)
        {
            MColor mColors = new MColor();

            if (color != null)
            {
                mColors.iColorID     = color.iColorID;
                mColors.strColorName = color.strColorName ?? " ";
            }
            return(mColors);
        }
Example #13
0
    void AddTextMessage_RPC(string m, MColor mC)
    {
        //When the max text messages have been recieved, remove the oldest one to make room
        while (textMessages.Count >= maxTextMessages)
        {
            textMessages.RemoveAt(0);
        }
        Color   color = GetColor(mC);
        Message msg   = new Message(m, color);

        textMessages.Add(msg);
    }
Example #14
0
        public static Color MsgColor(MColor type)
        {
            switch (type)
            {
            case MColor.Blue:
                return(Color.FromArgb(29, 161, 242));

            case MColor.Grey:
                return(Color.FromArgb(230, 236, 240));
            }

            return(Color.White);
        }
Example #15
0
        public Dizering(Color[] Colors, PictureBox inpPB, int n)
        {
            int N2 = n * n;

            N        = n;
            buf      = new Color[N2];
            inpColor = (Color[])Colors.Clone();
            double size = Factorial(inpColor.Length - 1 + (n * n)) / (Factorial(inpColor.Length - 1) * Factorial(n * n));

            DesColor = new MColor((int)size * N2);
            FComb(0, 0);
            PB = inpPB;
        }
Example #16
0
        public override void addUIDrawables(MDagPath objPath, MUIDrawManager drawManager, MFrameContext frameContext, MUserData data)
        {
            // Draw a text "Foot"
            MPoint pos       = new MPoint(0.0, 0.0, 0.0);          // Position of the text
            MColor textColor = new MColor(0.1f, 0.8f, 0.8f, 1.0f); // Text color

            drawManager.beginDrawable();

            drawManager.setColor(textColor);
            drawManager.setFontSize((uint)MUIDrawManager.FontSize.kSmallFontSize);
            drawManager.text(pos, "Footprint", MUIDrawManager.TextAlignment.kCenter);

            drawManager.endDrawable();
        }
Example #17
0
        public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds)
        {
            // DIP
            DIP.GetGraphics(g);

            // Basic varibles
            Height   = DIP.Set(30);
            Bounds   = itemBounds;
            Graphics = g;

            // Handles control's source theme
            // Check if control has set own theme
            if (owner.UsedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = owner.UsedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)owner.FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Background
            g.FillRectangle(new SolidBrush((_sourceTheme.DARK_BASED) ? MColor.AddRGB(5, _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()) : MColor.AddRGB(-5, _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor())), Bounds);

            // Draw primary text
            Color        color     = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor();
            StringFormat sfPrimary = new StringFormat();

            sfPrimary.LineAlignment = StringAlignment.Center;
            g.DrawString(PrimaryText, new Font("Segoe UI Semibold", 8), new SolidBrush(color), new Rectangle(Bounds.X + 10, Bounds.Y + 5, Bounds.Width, Bounds.Height / 2 + 5), sfPrimary);

            // Draw divider lines
            Color lineColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-150, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(150, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());

            g.DrawLine(new Pen(lineColor), new Point(Bounds.X, Bounds.Y), new Point(Bounds.X + Bounds.Width, Bounds.Y));
            g.DrawLine(new Pen(lineColor), new Point(Bounds.X, Bounds.Y + Bounds.Height - 1), new Point(Bounds.X + Bounds.Width, Bounds.Y + Bounds.Height - 1));
        }
Example #18
0
        /// <summary>
        /// SidePanel on paint method
        /// </summary>
        private void OnPaint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.Clear(tintColor);

            // Variables
            Point mouse             = PointToClient(Cursor.Position);
            int   distanceToCenterX = (sidePanel.Width / 2) - mouse.X;
            int   distanceToCenterY = (sidePanel.Height / 2) - mouse.Y;
            int   incX    = (distanceToCenterX / 50);
            int   incY    = (distanceToCenterY / 30);
            int   bWidth  = 350;
            int   bHeight = 300;
            int   bX      = (sidePanel.Width / 2) - (bWidth / 2);
            int   bY      = (sidePanel.Height / 2) - (bHeight / 2);

            // Draw ears
            DrawCircle(g, Brushes.White, new Point(bX + 30 + incX, bY + 65 + incY), 50 - (distanceToCenterX / 120));
            DrawCircle(g, Brushes.White, new Point(bX + bWidth - 30 + incX, bY + 65 + incY), 50 + (distanceToCenterX / 120));

            // Draw head
            g.FillEllipse(Brushes.White, new Rectangle(bX, bY, bWidth, bHeight));
            g.FillRectangle(Brushes.White, new Rectangle(bX, bY + (bHeight / 2), bWidth, (this.Height / 2)));

            // Draw eyes
            DrawCircle(g, new SolidBrush(new Hex("#383838").ToColor()), new Point(bX + bWidth / 2 - 25 - incX, bY + 60 - incY), 8 - (distanceToCenterX / 650));
            DrawCircle(g, new SolidBrush(new Hex("#383838").ToColor()), new Point(bX + bWidth / 2 + 25 - incX, bY + 60 - incY), 8 + (distanceToCenterX / 650));

            // Draw muzzle
            SolidBrush brush = new SolidBrush(MColor.Lighten(210, tintColor, Color.White));

            DrawCircle(g, brush, new Point(bX + bWidth / 2 - (distanceToCenterX / 20), bY + 150 - incY), 65);
            g.FillRectangle(brush, new Rectangle(bX + bWidth / 2 - 65 - (distanceToCenterX / 20), bY + 150 - incY, 130, 50));
            DrawCircle(g, brush, new Point(bX + bWidth / 2 - (distanceToCenterX / 20), bY + 50 + 150 - incY), 65);

            // Draw mouth
            Pen pen = new Pen(new Hex("#383838").ToColor(), 4);

            g.DrawLine(pen, new Point(bX + bWidth / 2 - 10 - (distanceToCenterX / 15), bY + 225 - (distanceToCenterY / 15)), new Point(bX + bWidth / 2 + 10 - (distanceToCenterX / 15), bY + 225 - (distanceToCenterY / 15)));

            // Draw nose
            DrawCircle(g, new SolidBrush(new Hex("#383838").ToColor()), new Point(bX + bWidth / 2 - (distanceToCenterX / 15), bY + 150 - (distanceToCenterY / 15)), 45);
            DrawCircle(g, Brushes.White, new Point(bX + bWidth / 2 - (distanceToCenterX / 15) - 20, bY + 150 - (distanceToCenterY / 15) - 20), 10);

            // Draw slogan
            g.TextRenderingHint = TextRenderingHint.AntiAlias;
            g.DrawString("Bear strong protection!", new Font("Segoe UI Light", 48, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, new Point(bX - 80, 50));
        }
Example #19
0
        /// <summary>
        /// Draw label
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control dont have it's own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Normal and alternate color
            Color standardTextColor  = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor();
            Color alternateTextColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());
            Color tintTextColor      = _tint;

            // Set foreground color
            switch (_type)
            {
            case LabelType.Standard:
                ForeColor = standardTextColor;
                break;

            case LabelType.Alternate:
                ForeColor = alternateTextColor;
                break;

            case LabelType.Tint:
                ForeColor = tintTextColor;
                break;
            }
        }
Example #20
0
    Color GetColor(MColor color)
    {
        switch (color)
        {
        case MColor.spawn:
            return(Color.black);

        case MColor.redTeam:
            return(Color.red);

        case MColor.blueTeam:
            return(Color.blue);

        case MColor.neutralTeam:
            return(Color.gray);
        }

        return(Color.white);
    }
Example #21
0
    void creatNewLightMap(ObjLightMapData mapdata, Texture2D tex)
    {
        int lightWidth = tex.width;
        int lightHeigh = tex.height;
        int startX     = (int)(Mathf.Abs(mapdata.offsetX) * lightWidth);
        int startY     = (int)(Mathf.Abs(mapdata.offsetY) * lightHeigh);
        int scaleX     = (int)(mapdata.tilingX * lightWidth);
        int scaleY     = (int)(mapdata.tilingY * lightHeigh);

        for (int i = startX; i < startX + scaleX; i++)
        {
            for (int j = startY; j < startY + scaleY; j++)
            {
                int    index = (i - startX) * scaleY + (j - startY);
                MColor mc    = mapdata.color[index];
                tex.SetPixel(i, j, new Color(mc.r, mc.g, mc.b));
            }
        }
        tex.Apply();
    }
Example #22
0
        public bool SaveEdit(MColor color)
        {
            bool status = false;

            if (color.iColorID > 0)
            {
                //Edit Existing Record
                var colr = auctionContext.MColors.Where(a => a.iColorID == color.iColorID).FirstOrDefault();
                if (colr != null)
                {
                    colr.strColorName = color.strColorName;
                }
            }
            else
            {
                //Save
                auctionContext.MColors.Add(color);
            }
            auctionContext.SaveChanges();
            status = true;
            return(status);
        }
        private void ColorComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            //Console.WriteLine("aa");
            try
            {
                if (this.SelectedIndex == this.Items.Count - 1 && !IsCustomerSet)
                {
                    if (this.colDlg)
                    {
                        ColorDialog cDlg = new ColorDialog();
                        cDlg.FullOpen = true;
                        cDlg.ShowDialog();
                        otherCol = cDlg.Color;
                        resultCol.Color = cDlg.Color;
                        resultCol.Name = cDlg.Color.Name;
                    }
                    else
                    {
                        this.colDlg = true;
                        this.Refresh();
                    }
                }
                else resultCol = (MColor)this.Items[this.SelectedIndex];

            }
            catch
            {
                //MessageBox.Show("ERRR");
            }
        }
Example #24
0
        /// <summary>
        /// Paint
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Graphics
            Graphics g = e.Graphics;

            // Clear control
            g.Clear(Parent.BackColor);

            // Scaling
            DIP.GetGraphics(this);

            // Fill color, text and border
            Color fill       = new Color();
            Color border     = new Color();
            Color foreground = new Color();

            if (Enabled)
            {
                // Enabled
                fill       = MColor.Mix(Color.FromArgb(_hoverAlpha, _sourceTheme.CONTROL_BACKGROUND.Hover.ToColor()), _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor());
                border     = _sourceTheme.CONTROL_BORDER.Normal.ToColor();
                foreground = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor();
            }
            else
            {
                // Disabled
                fill       = _sourceTheme.CONTROL_BACKGROUND.Disabled.ToColor();
                border     = _sourceTheme.CONTROL_BORDER.Disabled.ToColor();
                foreground = _sourceTheme.CONTROL_FOREGROUND.Disabled.ToColor();
            }

            // Draw unchecked checkbox
            int height = 19;

            g.FillRectangle(new SolidBrush(fill), new Rectangle(0, Height / 2 - height / 2, height, height));
            g.DrawRectangle(new Pen(border), new Rectangle(0, Height / 2 - height / 2, height, height));

            // Draws cover
            GraphicsPath square = Draw.GetSquarePath(new Point(10, Height / 2 - height / 2 + 10), _a);

            g.FillPath(new SolidBrush(Enabled ? _tint : _sourceTheme.CONTROL_FILL.Disabled.ToColor()), square);

            int b = Height / 2 - height / 2;

            _checkmark = new Point[]
            {
                new Point(4, b + 9),
                new Point(5, b + 10),
                new Point(6, b + 11),
                new Point(7, b + 12),
                new Point(8, b + 13),
                new Point(9, b + 12),
                new Point(10, b + 11),
                new Point(11, b + 10),
                new Point(12, b + 9),
                new Point(13, b + 8),
                new Point(14, b + 7),
                new Point(15, b + 6),
            };

            // Draws checkmark
            if (_a == 10 && _state == true)
            {
                DrawCheckmarkIn(e);
            }

            if (_a == 10 && _state == false)
            {
                DrawCheckmarkOut(e);
            }

            // Draw text
            g.DrawString(this.Text, this.Font, new SolidBrush(foreground), new Point(25, b));
        }
Example #25
0
        private void labelMainLightDiffuseColor_Click(object sender, EventArgs e)
        {
            MMap map = mEditHelper.Map;
            if (map == null)
                return;

            ColorPickForm colorPicker = new ColorPickForm();

            MLight mainLight = map.MainLight;
            MColor oldColor = mainLight.DiffuseColor;
            int iR = (int)(oldColor.R * 255.0);
            int iG = (int)(oldColor.G * 255.0);
            int iB = (int)(oldColor.B * 255.0);
            colorPicker.ColorPicked = Color.FromArgb(iR, iG, iB);
            colorPicker.OnColorChanged += UIMainLightDiffuseColorNotify;

            if (colorPicker.ShowDialog() == DialogResult.OK)
            {
                float fR = colorPicker.ColorPicked.R / 255.0f;
                float fG = colorPicker.ColorPicked.G / 255.0f;
                float fB = colorPicker.ColorPicked.B / 255.0f;

                MColor mColor = new MColor(fR, fG, fB);
                mainLight.DiffuseColor = mColor;                                ///< 更新主灯光漫反射颜色
                labelMainLightDiffuseColor.BackColor = colorPicker.ColorPicked; ///< 更新UI颜色
            }
            else
            {
                mainLight.DiffuseColor = oldColor;                                  ///< 恢复主灯光漫反射颜色
                labelMainLightDiffuseColor.BackColor = Color.FromArgb(iR, iG, iB);  ///< 恢复UI颜色
            }
        }
Example #26
0
        /// <summary>
        /// Draw click effect
        /// </summary>
        /// <param name="e"></param>
        private void DrawClick(PaintEventArgs e)
        {
            // Control's graphics object
            Graphics g = e.Graphics;

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // ClickEffect
            if (_clickEffect != ClickEffect.None)
            {
                // Color of ClickEffect
                Color color;
                Color fill = (_fullColored) ? _tint : _sourceTheme.CONTROL_FILL.Normal.ToColor();

                if (_sourceTheme.DARK_BASED == true)
                {
                    // Dark based themes
                    color = Color.FromArgb(_alpha, MColor.AddRGB(150, fill));
                }
                else
                {
                    // Light based themes
                    color = Color.FromArgb(_alpha, MColor.AddRGB(-150, fill));
                }

                // Draws ClickEffect
                // Set up antialiasing
                g.SmoothingMode = SmoothingMode.AntiAlias;

                // Ink
                if (_clickEffect == ClickEffect.Ink)
                {
                    // Ink's brush and grapics path
                    SolidBrush   brush = new SolidBrush(color);
                    GraphicsPath ink   = Draw.GetEllipsePath(_mouse, (int)_radius);

                    // Draws ink ClickEffect
                    g.FillPath(brush, ink);
                }

                // Square
                if (_clickEffect == ClickEffect.Square || _clickEffect == ClickEffect.SquareRotate)
                {
                    // Square's brush and grapics path
                    SolidBrush   brush  = new SolidBrush(color);
                    GraphicsPath square = Draw.GetSquarePath(_mouse, (int)_radius);

                    // Rotates square
                    if (_clickEffect == ClickEffect.SquareRotate)
                    {
                        Matrix matrix = new Matrix();
                        matrix.RotateAt(_rotation, _mouse);
                        square.Transform(matrix);
                    }

                    // Draws square ClickEffect
                    g.FillPath(brush, square);
                }

                // Remove antialiasing
                g.SmoothingMode = SmoothingMode.Default;
            }
        }
Example #27
0
        /// <summary>
        /// Draw method
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control don't have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Graphics
            Graphics g = e.Graphics;

            // Clear control
            g.Clear(Parent.BackColor);

            // Draw raised button
            if (_buttonType == ButtonType.Raised)
            {
                // Fill color
                Color fill = new Color();

                // Button is filled with his Tint color
                if (_fullColored)
                {
                    if (Enabled)
                    {
                        fill = MColor.AddRGB((_sourceTheme.DARK_BASED) ? +(_hoverAlpha / 15) : -(_hoverAlpha / 15), _tint);
                    }
                    else
                    {
                        fill = _sourceTheme.CONTROL_FILL.Disabled.ToColor();
                    }

                    g.FillRectangle(new SolidBrush(fill), ClientRectangle);
                }
                else
                {
                    // Regular raised button
                    fill = MColor.Mix(Color.FromArgb(_hoverAlpha, _sourceTheme.CONTROL_FILL.Hover.ToColor()), _sourceTheme.CONTROL_FILL.Normal.ToColor());

                    // Disabled
                    if (!Enabled)
                    {
                        fill = _sourceTheme.CONTROL_FILL.Disabled.ToColor();
                    }

                    g.FillRectangle(new SolidBrush(fill), ClientRectangle);
                }

                // Click effect
                DrawClick(e);

                // Focus rectangle
                if (Focused || _tintAlpha > 0)
                {
                    Rectangle rc             = new Rectangle(Location.X, Location.Y, Width, Height);
                    Color     frameColor     = MColor.Mix(Color.FromArgb(_tintAlpha, Enabled ? _tint : fill), fill);
                    Pen       framePen       = new Pen(frameColor);
                    Rectangle frameRectangle = new Rectangle(0, 0, rc.Width - 1, rc.Height - 1);
                    g.DrawRectangle(framePen, frameRectangle);
                }

                // Text
                DrawText(e);
            }

            if (_buttonType == ButtonType.Outline)
            {
                // Fill color
                Color fill   = new Color();
                Color border = new Color();

                // Button is filled with his Tint color
                if (_fullColored)
                {
                    // Fullcolored outlined button
                    fill   = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(220, _tint, Parent.BackColor)), Parent.BackColor);
                    border = (Enabled) ? _tint : _sourceTheme.CONTROL_FILL.Disabled.ToColor();

                    // Disabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }

                    Rectangle r = ClientRectangle;
                    g.FillRectangle(new SolidBrush(fill), r);
                    g.DrawRectangle(new Pen(border), new Rectangle(r.X, r.Y, r.Width - 1, r.Height - 1));
                }
                else
                {
                    // Fullcolored outlined button
                    fill   = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(220, _sourceTheme.CONTROL_BORDER.Normal.ToColor(), Parent.BackColor)), Parent.BackColor);
                    border = (Enabled) ? _sourceTheme.CONTROL_FILL.Normal.ToColor() : _sourceTheme.CONTROL_FILL.Disabled.ToColor();

                    // Disabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }

                    Rectangle r = ClientRectangle;
                    g.FillRectangle(new SolidBrush(fill), r);
                    g.DrawRectangle(new Pen(border), new Rectangle(r.X, r.Y, r.Width - 1, r.Height - 1));
                }

                // Click effect
                DrawClick(e);

                // Text
                DrawText(e);
            }

            if (_buttonType == ButtonType.Flat)
            {
                // Fill color
                Color fill = new Color();

                // Button is filled with his Tint color
                if (_fullColored)
                {
                    // Fullcolored outlined button
                    fill = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(220, _tint, Parent.BackColor)), Parent.BackColor);

                    // Disabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }

                    Rectangle r = ClientRectangle;
                    g.FillRectangle(new SolidBrush(fill), r);
                }
                else
                {
                    // Fullcolored outlined button
                    fill = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(160, _sourceTheme.CONTROL_BORDER.Normal.ToColor(), Parent.BackColor)), Parent.BackColor);

                    // Disabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }

                    Rectangle r = ClientRectangle;
                    g.FillRectangle(new SolidBrush(fill), r);
                }

                // Click effect
                DrawClick(e);

                // Text
                DrawText(e);
            }
        }
Example #28
0
        private void UIAssistantLightAmbientColorNotify(object sender, EventArgs e)
        {
            MMap map = mEditHelper.Map;
            if (map == null)
                return;

            ColorPickForm colorPicker = (ColorPickForm)sender;

            float fR = colorPicker.ColorPicked.R / 255.0f;
            float fG = colorPicker.ColorPicked.G / 255.0f;
            float fB = colorPicker.ColorPicked.B / 255.0f;

            MColor pickedColor = new MColor(fR, fG, fB);
            MLight assistantLight = map.AssistantLight;
            assistantLight.AmbientColor = pickedColor;
        }
Example #29
0
        private void UIMainLightDiffuseColorNotify(object sender, EventArgs e)
        {
            MMap map = mEditHelper.Map;
            if (map == null)
                return;

            ColorPickForm colorPicker = (ColorPickForm)sender;

            float fR = colorPicker.ColorPicked.R / 255.0f;
            float fG = colorPicker.ColorPicked.G / 255.0f;
            float fB = colorPicker.ColorPicked.B / 255.0f;

            MColor pickedColor = new MColor(fR, fG, fB);
            MLight mainLight = map.MainLight;
            mainLight.DiffuseColor = pickedColor;
        }
Example #30
0
 public void setColor(MColor color)
 {
     mColor = color;
 }
Example #31
0
        /// <summary>
        /// Extract geometry (position, normal, UVs...) for a specific vertex
        /// </summary>
        /// <param name="mFnMesh"></param>
        /// <param name="polygonId">The polygon (face) to examine</param>
        /// <param name="vertexIndexGlobal">The object-relative (mesh-relative/global) vertex index</param>
        /// <param name="vertexIndexLocal">The face-relative (local) vertex id to examine</param>
        /// <param name="uvSetNames"></param>
        /// <param name="isUVExportSuccess"></param>
        /// <returns></returns>
        private GlobalVertex ExtractVertex(MFnMesh mFnMesh, int polygonId, int vertexIndexGlobal, int vertexIndexLocal, MStringArray uvSetNames, ref bool[] isUVExportSuccess, ref bool isTangentExportSuccess)
        {
            MPoint point = new MPoint();

            mFnMesh.getPoint(vertexIndexGlobal, point);

            MVector normal = new MVector();

            mFnMesh.getFaceVertexNormal(polygonId, vertexIndexGlobal, normal);

            // Switch coordinate system at object level
            point.z  *= -1;
            normal.z *= -1;

            var vertex = new GlobalVertex
            {
                BaseIndex = vertexIndexGlobal,
                Position  = point.toArray(),
                Normal    = normal.toArray()
            };

            // Tangent
            if (isTangentExportSuccess)
            {
                try
                {
                    MVector tangent = new MVector();
                    mFnMesh.getFaceVertexTangent(polygonId, vertexIndexGlobal, tangent);

                    // Switch coordinate system at object level
                    tangent.z *= -1;

                    int  tangentId            = mFnMesh.getTangentId(polygonId, vertexIndexGlobal);
                    bool isRightHandedTangent = mFnMesh.isRightHandedTangent(tangentId);

                    // Invert W to switch to left handed system
                    vertex.Tangent = new float[] { (float)tangent.x, (float)tangent.y, (float)tangent.z, isRightHandedTangent ? -1 : 1 };
                }
                catch
                {
                    // Exception raised when mesh don't have tangents
                    isTangentExportSuccess = false;
                }
            }

            // Color
            int    colorIndex;
            string colorSetName;

            float[] defaultColor = new float[] { 1, 1, 1, 0 };
            MColor  color        = new MColor();

            mFnMesh.getCurrentColorSetName(out colorSetName);

            if (mFnMesh.numColors(colorSetName) > 0)
            {
                //Get the color index
                mFnMesh.getColorIndex(polygonId, vertexIndexLocal, out colorIndex);

                //if a color is set
                if (colorIndex != -1)
                {
                    mFnMesh.getColor(colorIndex, color);
                    vertex.Color = color.toArray();
                }
                //else set the default color
                else
                {
                    vertex.Color = defaultColor;
                }
            }

            // UV
            int indexUVSet = 0;

            if (uvSetNames.Count > indexUVSet && isUVExportSuccess[indexUVSet])
            {
                try
                {
                    float u = 0, v = 0;
                    mFnMesh.getPolygonUV(polygonId, vertexIndexLocal, ref u, ref v, uvSetNames[indexUVSet]);
                    vertex.UV = new float[] { u, v };
                }
                catch
                {
                    // An exception is raised when a vertex isn't mapped to an UV coordinate
                    isUVExportSuccess[indexUVSet] = false;
                }
            }
            indexUVSet = 1;
            if (uvSetNames.Count > indexUVSet && isUVExportSuccess[indexUVSet])
            {
                try
                {
                    float u = 0, v = 0;
                    mFnMesh.getPolygonUV(polygonId, vertexIndexLocal, ref u, ref v, uvSetNames[indexUVSet]);
                    vertex.UV2 = new float[] { u, v };
                }
                catch
                {
                    // An exception is raised when a vertex isn't mapped to an UV coordinate
                    isUVExportSuccess[indexUVSet] = false;
                }
            }

            // skin
            if (mFnSkinCluster != null)
            {
                // Filter null weights
                Dictionary <int, double> weightByInfluenceIndex = new Dictionary <int, double>(); // contains the influence indices with weight > 0

                // Export Weights and BonesIndices for the vertex
                // Get the weight values of all the influences for this vertex
                allMayaInfluenceWeights = new MDoubleArray();
                MGlobal.executeCommand($"skinPercent -query -value {mFnSkinCluster.name} {mFnTransform.name}.vtx[{vertexIndexGlobal}]",
                                       allMayaInfluenceWeights);
                allMayaInfluenceWeights.get(out double[] allInfluenceWeights);

                for (int influenceIndex = 0; influenceIndex < allInfluenceWeights.Length; influenceIndex++)
                {
                    double weight = allInfluenceWeights[influenceIndex];

                    if (weight > 0)
                    {
                        try
                        {
                            // add indice and weight in the local lists
                            weightByInfluenceIndex.Add(indexByNodeName[allMayaInfluenceNames[influenceIndex]], weight);
                        }
                        catch (Exception e)
                        {
                            RaiseError(e.Message, 2);
                            RaiseError(e.StackTrace, 3);
                        }
                    }
                }

                // normalize weights => Sum weights == 1
                Normalize(ref weightByInfluenceIndex);

                // decreasing sort
                OrderByDescending(ref weightByInfluenceIndex);

                int   bonesCount = indexByNodeName.Count; // number total of bones/influences for the mesh
                float weight0    = 0;
                float weight1    = 0;
                float weight2    = 0;
                float weight3    = 0;
                int   bone0      = bonesCount;
                int   bone1      = bonesCount;
                int   bone2      = bonesCount;
                int   bone3      = bonesCount;
                int   nbBones    = weightByInfluenceIndex.Count; // number of bones/influences for this vertex

                if (nbBones == 0)
                {
                    weight0 = 1.0f;
                    bone0   = bonesCount;
                }

                if (nbBones > 0)
                {
                    bone0   = weightByInfluenceIndex.ElementAt(0).Key;
                    weight0 = (float)weightByInfluenceIndex.ElementAt(0).Value;

                    if (nbBones > 1)
                    {
                        bone1   = weightByInfluenceIndex.ElementAt(1).Key;
                        weight1 = (float)weightByInfluenceIndex.ElementAt(1).Value;

                        if (nbBones > 2)
                        {
                            bone2   = weightByInfluenceIndex.ElementAt(2).Key;
                            weight2 = (float)weightByInfluenceIndex.ElementAt(2).Value;

                            if (nbBones > 3)
                            {
                                bone3   = weightByInfluenceIndex.ElementAt(3).Key;
                                weight3 = (float)weightByInfluenceIndex.ElementAt(3).Value;
                            }
                        }
                    }
                }

                float[] weights = { weight0, weight1, weight2, weight3 };
                vertex.Weights      = weights;
                vertex.BonesIndices = (bone3 << 24) | (bone2 << 16) | (bone1 << 8) | bone0;

                if (nbBones > 4)
                {
                    bone0   = weightByInfluenceIndex.ElementAt(4).Key;
                    weight0 = (float)weightByInfluenceIndex.ElementAt(4).Value;
                    weight1 = 0;
                    weight2 = 0;
                    weight3 = 0;

                    if (nbBones > 5)
                    {
                        bone1   = weightByInfluenceIndex.ElementAt(5).Key;
                        weight1 = (float)weightByInfluenceIndex.ElementAt(4).Value;

                        if (nbBones > 6)
                        {
                            bone2   = weightByInfluenceIndex.ElementAt(6).Key;
                            weight2 = (float)weightByInfluenceIndex.ElementAt(4).Value;

                            if (nbBones > 7)
                            {
                                bone3   = weightByInfluenceIndex.ElementAt(7).Key;
                                weight3 = (float)weightByInfluenceIndex.ElementAt(7).Value;
                            }
                        }
                    }

                    float[] weightsExtra = { weight0, weight1, weight2, weight3 };
                    vertex.WeightsExtra      = weightsExtra;
                    vertex.BonesIndicesExtra = (bone3 << 24) | (bone2 << 16) | (bone1 << 8) | bone0;
                }
            }
            return(vertex);
        }
 public ColorComboBox(MColor[] colors)
 {
     InitializeComponent();
     mColors = colors;
 }
Example #33
0
        // @}
        // @{
        //*********************************************************************
        // 消息响应/UI回调函数
        //*********************************************************************
        private void labelTerrainAmbientColor_Click(object sender, EventArgs e)
        {
            ColorPickForm colorPicker = new ColorPickForm();

            MColor oldColor = mEditTerrainHelper.GetAmbientMaterial();
            int iR = (int)(oldColor.R * 255.0);
            int iG = (int)(oldColor.G * 255.0);
            int iB = (int)(oldColor.B * 255.0);
            colorPicker.ColorPicked = Color.FromArgb(iR, iG, iB);
            colorPicker.OnColorChanged += UITerrainAmbientColorNotify;

            if (colorPicker.ShowDialog() == DialogResult.OK)
            {
                float fR = colorPicker.ColorPicked.R / 255.0f;
                float fG = colorPicker.ColorPicked.G / 255.0f;
                float fB = colorPicker.ColorPicked.B / 255.0f;

                MColor mColor = new MColor(fR, fG, fB);
                mEditTerrainHelper.SetAmbientMaterial(mColor);                  ///< 更新材质颜色
                labelTerrainAmbientColor.BackColor = colorPicker.ColorPicked;   ///< 更新UI颜色
            }
            else
            {
                mEditTerrainHelper.SetAmbientMaterial(oldColor);                    ///< 恢复材质颜色
                labelTerrainAmbientColor.BackColor = Color.FromArgb(iR, iG, iB);    ///< 恢复UI颜色
            }
        }
Example #34
0
        private void UITerrainSpecularColorNotify(object sender, EventArgs e)
        {
            ColorPickForm colorPicker = (ColorPickForm)sender;

            float fR = colorPicker.ColorPicked.R / 255.0f;
            float fG = colorPicker.ColorPicked.G / 255.0f;
            float fB = colorPicker.ColorPicked.B / 255.0f;

            MColor mColor = new MColor(fR, fG, fB);
            mEditTerrainHelper.SetSpecularMaterial(mColor);
        }
Example #35
0
        public override void addUIDrawables(MDagPath objPath, MUIDrawManager drawManager, MFrameContext frameContext, MUserData data)
        {
            // Draw a text "Foot"
            MPoint pos = new MPoint( 0.0, 0.0, 0.0 ); // Position of the text
            MColor textColor = new MColor( 0.1f, 0.8f, 0.8f, 1.0f ); // Text color

            drawManager.beginDrawable();

            drawManager.setColor( textColor );
            drawManager.setFontSize( (uint)MUIDrawManager.FontSize.kSmallFontSize );
            drawManager.text( pos,  "Footprint", MUIDrawManager.TextAlignment.kCenter );

            drawManager.endDrawable();
        }
Example #36
0
        /// <summary>
        /// Draw
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);
            Graphics  g  = e.Graphics;
            Rectangle rc = ClientRectangle;

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Clear control
            g.Clear(Parent.BackColor);

            // Fill color
            Color fill = Enabled ? _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor() : _sourceTheme.CONTROL_BACKGROUND.Disabled.ToColor();

            // TextBox background color
            FakeTextBox.BackColor = fill;

            // Control outline colors
            Color      backgroundColor = fill;
            SolidBrush backroundBrush  = new SolidBrush(backgroundColor);

            g.FillRectangle(backroundBrush, rc);

            // Draw control outline
            Color frameColor = MColor.Mix(Color.FromArgb(_tintAlpha, Enabled ? _tint : _sourceTheme.CONTROL_BORDER.Disabled.ToColor()), Enabled ? _sourceTheme.CONTROL_BORDER.Normal.ToColor() : _sourceTheme.CONTROL_BORDER.Disabled.ToColor());
            Pen   framePen   = new Pen(frameColor);

            // Top border
            if (DrawTopBorder)
            {
                g.DrawLine(framePen, new Point(0, 0), new Point(Width, 0));
            }

            // Bottom border
            g.DrawLine(framePen, new Point(0, Height - 1), new Point(Width, Height - 1));

            // Left border
            if (DrawLeftBorder)
            {
                g.DrawLine(framePen, new Point(0, 0), new Point(0, Height - 1));
            }

            // Right border
            if (DrawRightBorder)
            {
                g.DrawLine(framePen, new Point(Width - 1, 0), new Point(Width - 1, Height - 1));
            }
        }
Example #37
0
        /// <summary>
        /// Update
        /// </summary>
        protected void Update(object sender, EventArgs e)
        {
            // Animation
            _t += 0.05;
            if (_t > 1)
            {
                _t = 1;
            }

            // Opening and closing
            if (_opened)
            {
                // Opening
                Height = _header.Height + Animation.CosinusMotion(_t, _dropdownLength);
            }
            else
            {
                // Closing
                Height = _dropdownLength + _header.Height + 2 - Animation.CosinusMotion(_t, _dropdownLength);
            }

            // Hover effect
            if (_hover)
            {
                if (_hoverAlpha < 255)
                {
                    _hoverAlpha += 15;
                }
            }
            else
            {
                if (_hoverAlpha > 0)
                {
                    _hoverAlpha -= 15;
                }
            }

            // Alpha
            if (Focused || _listBox.Focused || _header.Focused || _search.Focused || _search.FakeTextBox.Focused)
            {
                if (_tintAlpha < 255)
                {
                    _tintAlpha += 15;
                }
            }
            else
            {
                if (_tintAlpha > 0)
                {
                    _tintAlpha -= 15;
                }
            }

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Border color
            Color fill       = MColor.Mix(Color.FromArgb(_hoverAlpha, _sourceTheme.CONTROL_FILL.Hover.ToColor()), _sourceTheme.CONTROL_FILL.Normal.ToColor());
            Color frameColor = MColor.Mix(Color.FromArgb(_tintAlpha, _tint), fill);

            BackColor = frameColor;
        }
Example #38
0
 public static string MToString(MColor color)
 {
     return(string.Format("({0},{1},{2},{3})", color.r, color.g, color.b, color.a));
 }
Example #39
0
        public static Label[] AddMessage(String text, DateTime date, Control parent, MColor color, bool attach = false)
        {
            int y_plus = 5;

            if (parent.Controls.Count > 1)
            {
                Control prev = parent.Controls[parent.Controls.Count - 1];
                y_plus += prev.Location.Y + prev.Height;
            }
            else if (parent.Controls.Count > 0)
            {
                y_plus += parent.Controls[0].Height;
            }
            else if (parent.Controls.Count == 0)
            {
                y_plus = 15;
            }

            if (text.Length > 10000)
            {
                text = text.Substring(0, 10000);
            }

            int max_width = (int)((parent.ClientSize.Width - 25) / 2);
            int min_width = (int)(max_width / 4);

            if (max_width < 0)
            {
                max_width = 0;
            }
            if (min_width < 0)
            {
                min_width = 0;
            }

            Label label = new Label();

            label.Text        = text;
            label.Font        = new Font("Segoe UI", 12);
            label.MaximumSize = new Size(max_width, 2048);
            label.MinimumSize = new Size(min_width, 15);
            label.AutoSize    = true;


            label.BackColor = Graphing.MsgColor(color);

            Label label2 = new Label();

            label2.AutoSize = true;

            label2.Font = new Font("Segoe UI", 8);
            label2.Text = date.ToShortTimeString();


            int x    = 10;
            int x_sm = 15;

            if (color == MColor.Blue)
            {
                label.ForeColor = Color.White;
                x    = parent.Width - 30 - label.PreferredWidth;
                x_sm = parent.Width - 35 - label2.PreferredWidth;
            }



            label.Location  = new Point(x, y_plus);
            label2.Location = new Point(x_sm, label.Location.Y + 5 + label.PreferredHeight);

            if (attach)
            {
                parent.Controls.AddRange(new [] { label, label2 });
            }

            return(new Label[] { label, label2 });
        }
Example #40
0
        /// <summary>
        /// Draw
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);

            // Scaling
            DIP.GetGraphics(this);

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control don't have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Graphics
            Graphics g = e.Graphics;

            // Clear control
            g.Clear(Parent.BackColor);

            // Fill color, text and border
            Color fill       = new Color();
            Color border     = new Color();
            Color hover      = new Color();
            Color foreground = new Color();

            if (Enabled)
            {
                // Enabled
                fill       = _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor();
                border     = _sourceTheme.CONTROL_BORDER.Normal.ToColor();
                foreground = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor();
                hover      = _sourceTheme.CONTROL_FILL.Hover.ToColor();
            }
            else
            {
                // Disabled
                fill       = _sourceTheme.CONTROL_BACKGROUND.Disabled.ToColor();
                border     = _sourceTheme.CONTROL_BORDER.Disabled.ToColor();
                foreground = _sourceTheme.CONTROL_FOREGROUND.Disabled.ToColor();
                hover      = _sourceTheme.CONTROL_FILL.Disabled.ToColor();
            }

            // Draw background
            g.FillPath(new SolidBrush(fill), Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), DIP.Set((10))));

            // Antialiasing
            g.SmoothingMode = SmoothingMode.AntiAlias;

            // Draw border
            if (!_state)
            {
                g.DrawPath(new Pen(!Checked ? _sourceTheme.CONTROL_BORDER.Normal.ToColor() : _tint, 1), Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), DIP.Set(10)));
            }

            // Mouse hover
            g.FillPath(new SolidBrush(Color.FromArgb(_hoverAlpha, hover)), Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), DIP.Set(3)));

            // Animation - inner circle
            g.FillPath(new SolidBrush(Enabled ? _tint : _sourceTheme.CONTROL_FILL.Disabled.ToColor()), Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), Convert.ToInt32(_radius)));

            // Animation - border tint
            g.DrawEllipse(new Pen(MColor.Mix(Color.FromArgb(_tintAlpha, Enabled ? _tint : _sourceTheme.CONTROL_BORDER.Disabled.ToColor()), border)), new Rectangle(0, 0, DIP.Set(20), DIP.Set(20)));

            // Antialiasing
            g.SmoothingMode = SmoothingMode.Default;

            // Draw text
            g.DrawString(this.Text, this.Font, new SolidBrush(foreground), new Point(25 + DIP.Set(8), 2));
        }