Esempio n. 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MRadioButton()
        {
            InitializeComponent();

            // Scaling
            DIP.GetGraphics(this);

            // Default variables
            _controlTimer          = new Timer();
            _controlTimer.Enabled  = true;
            _controlTimer.Interval = 1;
            _controlTimer.Tick    += new EventHandler(Update);
            _controlTimer.Start();
            _state         = false;
            _tintAlpha     = 0;
            _radius        = 0;
            _hoverAlpha    = 0;
            _hover         = false;
            _usedTheme     = null;
            DoubleBuffered = true;
            AutoSize       = false;
            Height         = DIP.Set(20);
            Font           = new Font("Segoe UI", 7);
            Size           = new Size(130, 36);

            // Pass graphics to DIP class
            DIP.GetGraphics(this);

            // Redraw
            Invalidate();
        }
Esempio n. 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MCheckBox()
        {
            InitializeComponent();

            // Default variables
            _controlTimer          = new Timer();
            _controlTimer.Enabled  = true;
            _controlTimer.Interval = 1;
            _controlTimer.Tick    += new EventHandler(Update);
            _controlTimer.Start();
            _state         = false;
            _a             = 0;
            _frame         = 0;
            _hover         = false;
            _hoverAlpha    = 0;
            DoubleBuffered = true;
            AutoSize       = false;
            DIP.GetGraphics(this);
            Height = DIP.Set(15);
            Font   = new Font("Segoe UI", 7);
            Size   = new Size(130, 36);

            // Redraw
            Invalidate();
        }
Esempio n. 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 public MItem()
 {
     // Default item height
     // Uses device independent pixels to provide best scaling
     // experience
     Height = DIP.Set(50);
 }
Esempio n. 4
0
        /// <summary>
        /// Draw item
        /// </summary>
        protected override void OnDrawItem(Graphics g, Rectangle bounds)
        {
            // Base call
            base.OnDrawItem(g, bounds);

            // Default height
            Height = DIP.Set(70);

            // String format
            // Converts alignment types
            StringFormat format = new StringFormat();
            int          lNum   = (int)Math.Log((double)TextAlign, 2);

            format.LineAlignment = (StringAlignment)(lNum / 4);
            format.Alignment     = (StringAlignment)(lNum % 4);

            // Creates color of secondary text
            Color color = (Owner.Component.SourceTheme.DARK_BASED) ? ColorExtensions.AddRGB(-120, Owner.Component.SourceTheme.COMPONENT_FOREGROUND.Normal) : ColorExtensions.AddRGB(100, Owner.Component.SourceTheme.COMPONENT_FOREGROUND.Normal);

            // Draws secondary text
            using (SolidBrush brush = new SolidBrush(color))
                g.DrawString(SecondaryText, new Font("Segoe UI", 8), brush, new Rectangle(Bounds.X + 10, Bounds.Y + 12, Bounds.Width - 20, Bounds.Height), format);

            // Draws primary text
            using (SolidBrush brush = new SolidBrush(Selected ? Owner.Accent : Owner.Component.SourceTheme.COMPONENT_FOREGROUND.Normal.ToColor()))
                g.DrawString(PrimaryText, new Font("Segoe UI", 9), brush, new Rectangle(Bounds.X + 10, Bounds.Y - 12, Bounds.Width - 20, Bounds.Height), format);
        }
Esempio n. 5
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
            g.FillRectangle(new SolidBrush(owner.Tint), new Rectangle(new Point(Bounds.X + 10, Bounds.Y + (Bounds.Height / 2) - 16), new Size(32, 32)));
            StringFormat sfAvatar = new StringFormat();

            sfAvatar.LineAlignment = StringAlignment.Center;
            sfAvatar.Alignment     = StringAlignment.Center;
            g.DrawString(PrimaryText[0].ToString(), new Font("Segoe UI Light", 12), new SolidBrush(Color.White), new Rectangle(new Point(Bounds.X + 10, Bounds.Y + (Bounds.Height / 2) - 16), new Size(32, 32)), sfAvatar);

            // 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 + 48, Bounds.Y + 1, Bounds.Width + 50, Bounds.Height), sfPrimary);
        }
        public static Rectangle GetViewPosition(this global::Android.Views.View view)
        {
            int[] viewLocation = { 0, 0 };
            view?.GetLocationInWindow(viewLocation);
            //var scale = P42.Utils.ReflectionExtensions.GetPropertyValue()
            //var scale = Display.Scale;
            //int left = view.Left;
            //int top = view.Top;
            int width  = view.Width;
            int height = view.Height;

            return(DIP.ToRectangle(viewLocation[0], viewLocation[1], width, height));
        }
        public static Rectangle GetViewGroupPosition(this ViewGroup viewGroup)
        {
            //int left = viewGroup.Left;
            //int top = viewGroup.Top;
            int[] viewLocation = { 0, 0 };
            viewGroup?.GetLocationInWindow(viewLocation);

            int width  = viewGroup.Width;
            int height = viewGroup.Height;

            //return DIP.ToRectangle((double)left, (double)top, (double)width, (double)height);
            return(DIP.ToRectangle(viewLocation[0], viewLocation[1], width, height));
        }
Esempio n. 9
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));
        }
Esempio n. 10
0
        /// <summary>
        /// Constructor
        /// </summary>
        public TwoLineItem(string primaryText, string secondaryText, ContentAlignment textAlign = ContentAlignment.MiddleLeft)
        {
            // Primary text
            PrimaryText = primaryText;

            // Secondary text
            SecondaryText = secondaryText;

            // Alignment
            TextAlign = textAlign;

            // Default height
            Height = DIP.Set(70);
        }
        public static Point[] GetTouches(MotionEvent.PointerCoords[] coords, Android.Views.View view, int[] startLocation)
        {
            //System.Diagnostics.Debug.WriteLine("c0=["+current.GetX()+","+current.GetY()+"]");

            int[] viewLocation = { 0, 0 };
            view?.GetLocationInWindow(viewLocation);

            int pointerCount = coords.Length;
            var array        = new Point[pointerCount];

            for (int i = 0; i < pointerCount; i++)
            {
                array[i] = DIP.ToPoint((double)(coords[i].X + viewLocation[0] - startLocation[0]), (double)(coords[i].Y + viewLocation[1] - startLocation[1]));
                //System.Diagnostics.Debug.WriteLine ("i=["+i+"] pc=["+pointerCoords.X+", "+pointerCoords.Y+"] a=["+array[i]+"]");
            }

            return(array);
        }
        /// <summary>
        /// Display frames
        /// </summary>
        /// <param name="frameDepth16">gray16</param>
        /// <param name="frameMapDepthToColor">rgb32</param>
        void DisplayFrames(byte[] frameColo32, ushort[] frameDepth16, byte[] frameMapDepthToColor)
        {
            //--------------------------------------------
            // Display the depth frame
            //--------------------------------------------

            DIP.BufferClone(frameDepth16, buffDepth16Mul);
            DIP.BufferMultiplyRange(buffDepth16Mul, 20);

            // Update the bitmap
            Util.UpdateOutBitmap(this.bitmapOutDepth, buffDepth16Mul);

            //--------------------------------------------
            // Display the colored depth frame
            //--------------------------------------------

            // Update the bitmap
            Util.UpdateOutBitmap(this.bitmapOutColorFrame, 4, frameColo32);
            Util.UpdateOutBitmap(this.bitmapOutMapDepthToColor, 4, frameMapDepthToColor);
        }
Esempio n. 13
0
    void DrumFormation(float radius)
    {
        int rnd;

        bool[] usedRnd = new bool[8];

        for (int i = 0; i < 8; i++)
        {
            while (true)
            {
                rnd = Random.Range(0, 8);
                if (usedRnd[rnd] == false)
                {
                    usedRnd[rnd] = true;
                    break;
                }
            }

            Animator star = StarPrefabs[i];
            star.gameObject.SetActive(false);

            DIP dip = DrumImagePrefabs[i];
            dip.DrumImage        = dip.GetComponent <Image>();
            dip.DrumImage.sprite = PuzzleComponents[rnd].DrumImageSprite;
            dip.PuzzleComponents = PuzzleComponents[rnd];
            dip.StarAnimator     = star;

            float angle = -i * (2f * Mathf.PI / 8f);
            float x     = Mathf.Cos(angle) * radius;
            float y     = Mathf.Sin(angle) * radius;

            dip.transform.localPosition = new Vector3(x, y, 0);

            x = Mathf.Cos(angle) * radius / 2.15f;
            y = Mathf.Sin(angle) * radius / 2.15f;

            star.transform.localPosition = new Vector3(x, y, 0);
        }
    }
        public static Point[] GetTouches(MotionEvent current, Android.Views.View view, int[] startLocation)
        {
            //System.Diagnostics.Debug.WriteLine("c0=["+current.GetX()+","+current.GetY()+"]");

            int[] viewLocation = { 0, 0 };
            try
            {
                view?.GetLocationInWindow(viewLocation);
            }
            catch (System.Exception) { return(new Point[] { }); }
            var pointerCoords = new MotionEvent.PointerCoords();
            int pointerCount  = current.PointerCount;
            var array         = new Point[pointerCount];

            for (int i = 0; i < pointerCount; i++)
            {
                current.GetPointerCoords(i, pointerCoords);
                array[i] = DIP.ToPoint((double)(pointerCoords.X + viewLocation[0] - startLocation[0]), (double)(pointerCoords.Y + viewLocation[1] - startLocation[1]));
                //System.Diagnostics.Debug.WriteLine ("i=["+i+"] pc=["+pointerCoords.X+", "+pointerCoords.Y+"] a=["+array[i]+"]");
            }

            return(array);
        }
Esempio n. 15
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MRadioButton()
        {
            // Register a new component
            ComponentManager.RegisterComponent(this);

            // Initializes component
            InitializeComponent();

            // Default variables
            _state         = false;
            _tintAlpha     = 0;
            _radius        = 0;
            _hoverAlpha    = 0;
            _hover         = false;
            DoubleBuffered = true;
            AutoSize       = false;
            Height         = DIP.Set(20);
            Font           = new Font("Segoe UI", 7);
            Size           = new Size(130, 21);

            // Redraw
            Invalidate();
        }
Esempio n. 16
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MCheckBox()
        {
            // Register a new component
            ComponentManager.RegisterComponent(this);

            // Initialize
            InitializeComponent();

            // Default variables
            _state         = false;
            _a             = 0;
            _frame         = 0;
            _hover         = false;
            _hoverAlpha    = 0;
            DoubleBuffered = true;
            AutoSize       = false;
            Height         = DIP.Set(15);
            Font           = new Font("Segoe UI", 7);
            Size           = new Size(130, 21);

            // Redraw
            Invalidate();
        }
Esempio n. 17
0
        /// <summary>
        /// Construcotor
        /// </summary>
        public MLabeledTextBox()
        {
            InitializeComponent();
            DIP.GetGraphics(this);

            // Default variables
            _controlTimer          = new Timer();
            _controlTimer.Enabled  = true;
            _controlTimer.Interval = 1;
            _controlTimer.Tick    += new EventHandler(Update);
            _controlTimer.Start();
            _usedTheme            = null;
            _tintAlpha            = 0;
            DoubleBuffered        = true;
            _textBox.TextChanged += new PropertyChangedEventHandler(OnTextChanged);
            PrefixChanged        += OnPrefixChange;
            PostfixChanged       += OnPostfixChanged;
            _textBox.Font         = new Font("Segoe UI", 9);
            Controls.Add(_textBox);
            Height  = _textBox.Height;
            Prefix  = "";
            Postfix = "";
            UpdateLayout();
        }
Esempio n. 18
0
    // Use this for initialization
    void Start()
    {
        cName.text = character._characterName;
        race.text  = character._characterRace.ToString();
        HP.text    = "" + character.GetCurrentHealth() + " / " + character.GetMaxHealth();

        STR = character.GetAbilityScore(AbilityID.Strength);
        DEX = character.GetAbilityScore(AbilityID.Dexterity);
        CON = character.GetAbilityScore(AbilityID.Constitution);
        INT = character.GetAbilityScore(AbilityID.Intelligence);
        WIS = character.GetAbilityScore(AbilityID.Wisdom);
        CHA = character.GetAbilityScore(AbilityID.Charisma);

        ATH  = character.GetSkill(SkillID.Athletics);
        ACR  = character.GetSkill(SkillID.Acrobatics);
        STE  = character.GetSkill(SkillID.Stealth);
        THI  = character.GetSkill(SkillID.Thievery);
        END  = character.GetSkill(SkillID.Endurance);
        ARC  = character.GetSkill(SkillID.Arcana);
        HIS  = character.GetSkill(SkillID.History);
        REL  = character.GetSkill(SkillID.Religion);
        DUN  = character.GetSkill(SkillID.Dungeoneering);
        HEA  = character.GetSkill(SkillID.Heal);
        INS  = character.GetSkill(SkillID.Insight);
        NAT  = character.GetSkill(SkillID.Nature);
        PER  = character.GetSkill(SkillID.Perception);
        BLU  = character.GetSkill(SkillID.Bluff);
        DIP  = character.GetSkill(SkillID.Diplomacy);
        INTI = character.GetSkill(SkillID.Intimidate);
        STRE = character.GetSkill(SkillID.Streetwise);

        tSTR.text = STR + "  +" + character.GetModifier(AbilityID.Strength);
        tDEX.text = DEX + "  +" + character.GetModifier(AbilityID.Dexterity);
        tCON.text = CON + "  +" + character.GetModifier(AbilityID.Constitution);
        tINT.text = INT + "  +" + character.GetModifier(AbilityID.Intelligence);
        tWIS.text = WIS + "  +" + character.GetModifier(AbilityID.Wisdom);
        tCHA.text = CHA + "  +" + character.GetModifier(AbilityID.Charisma);

        tAC.text = character.GetDefence(DefenceID.ArmorClass).ToString();
        tFO.text = character.GetDefence(DefenceID.Fortitude).ToString();
        tRE.text = character.GetDefence(DefenceID.Reflex).ToString();
        tWI.text = character.GetDefence(DefenceID.Will).ToString();

        tATH.text  = ATH.ToString();
        tACR.text  = ACR.ToString();
        tSTE.text  = STE.ToString();
        tTHI.text  = THI.ToString();
        tEND.text  = END.ToString();
        tARC.text  = ARC.ToString();
        tHIS.text  = HIS.ToString();
        tREL.text  = REL.ToString();
        tDUN.text  = DUN.ToString();
        tHEA.text  = HEA.ToString();
        tINS.text  = INS.ToString();
        tNAT.text  = NAT.ToString();
        tPER.text  = PER.ToString();
        tBLU.text  = BLU.ToString();
        tDIP.text  = DIP.ToString();
        tINTI.text = INTI.ToString();
        tSTRE.text = STRE.ToString();
    }
Esempio n. 19
0
        /// <summary>
        /// Draw
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base call
            base.OnPaint(e);

            // 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       = Component.SourceTheme.COMPONENT_BACKGROUND.Normal.ToColor();
                border     = Component.SourceTheme.COMPONENT_BORDER.Normal.ToColor();
                foreground = Component.SourceTheme.COMPONENT_FOREGROUND.Normal.ToColor();
                hover      = Component.SourceTheme.COMPONENT_FILL.Hover.ToColor();
            }
            else
            {
                // Disabled
                fill       = Component.SourceTheme.COMPONENT_BACKGROUND.Disabled.ToColor();
                border     = Component.SourceTheme.COMPONENT_BORDER.Disabled.ToColor();
                foreground = Component.SourceTheme.COMPONENT_FOREGROUND.Disabled.ToColor();
                hover      = Component.SourceTheme.COMPONENT_FILL.Disabled.ToColor();
            }

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

            // Anti-aliasing
            g.SmoothingMode = SmoothingMode.AntiAlias;

            // Draw border
            if (!_state)
            {
                using (Pen pen = new Pen(!Checked ? Component.SourceTheme.COMPONENT_BORDER.Normal.ToColor() : Component.Accent, 1))
                    g.DrawPath(pen, Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), DIP.Set(10)));
            }

            // Draw mouse hover effect
            using (SolidBrush brush = new SolidBrush(Color.FromArgb(_hoverAlpha, hover)))
                g.FillPath(brush, Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), DIP.Set(3)));

            // Animation - inner circle
            using (SolidBrush brush = new SolidBrush(Enabled ? Component.Accent : Component.SourceTheme.COMPONENT_FILL.Disabled.ToColor()))
                g.FillPath(brush, Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), Convert.ToInt32(_radius)));

            // Animation - border tint
            using (Pen pen = new Pen(ColorExtensions.Mix(Color.FromArgb(_tintAlpha, Enabled ? Component.Accent : Component.SourceTheme.COMPONENT_BORDER.Disabled.ToColor()), border)))
                g.DrawEllipse(pen, new Rectangle(0, 0, DIP.Set(20), DIP.Set(20)));

            // Anti-aliasing
            g.SmoothingMode = SmoothingMode.Default;

            // Draw text
            using (SolidBrush brush = new SolidBrush(foreground))
                g.DrawString(Text, Font, brush, new Point(25 + DIP.Set(8), 2));
        }
Esempio n. 20
0
        /// <summary>
        /// Draw method
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);
            Graphics g = e.Graphics;

            DIP.GetGraphics(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)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Draw item background
            Color fill = (Owner.MenuItem == this) ? _sourceTheme.WINDOW_CAPTIONBAR.Normal.ToColor() : MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(230, _tint, _sourceTheme.WINDOW_CAPTIONBAR.Normal.ToColor())), _sourceTheme.WINDOW_CAPTIONBAR.Normal.ToColor());

            g.FillRectangle(new SolidBrush(fill), new Rectangle(0, 0, Width, Height));

            if (FullColored)
            {
                g.FillRectangle(new SolidBrush(MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.AddRGB((_sourceTheme.DARK_BASED) ? +(_hoverAlpha / 15) : -(_hoverAlpha / 15), _tint)), _tint)), new Rectangle(0, 0, Owner.MenuItem.Height, Owner.MenuItem.Height));
            }

            // Click effect
            DrawClick(e);

            // Icon mode
            if (_icon != null && !_fullColored)
            {
                if (_sourceTheme.DARK_BASED)
                {
                    _icon.DarkBased = true;
                }
                else
                {
                    _icon.DarkBased = false;
                }
            }

            // Draw Icon
            if (_icon != null)
            {
                g.InterpolationMode = InterpolationMode.NearestNeighbor;

                if (Owner.SelectedItem == this)
                {
                    Image img = MColor.SetImageColor(_icon.Icon, _tint);
                    g.DrawImage(MColor.SetImageOpacity(img, 1f), 16, 16, 32, 32);
                }
                else
                {
                    g.DrawImage(MColor.SetImageOpacity(_icon.Icon, 1f), 16, 16, 32, 32);
                }
            }
            else
            {
                // Icon rect
                g.DrawRectangle(new Pen(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(20, 20, 20, 20));
            }

            // Draw text
            SolidBrush brush = (Owner.SelectedItem == this) ? new SolidBrush(_tint) : (_fullColored) ? new SolidBrush(ForeColor) : new SolidBrush(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());

            g.DrawString(Text, Font, brush, new Rectangle(65, (Height / 2) - (Font.Height / 2), Width, Height));
        }
Esempio n. 21
0
        /// <summary>
        /// Draw
        /// </summary>
        public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds)
        {
            // DIP
            DIP.GetGraphics(g);

            // Basic variables
            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 don't 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(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(Bounds.X + 21, Bounds.Y + 6, 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 + 21, Bounds.Y + Bounds.Height / 2 - 6, Bounds.Width, Bounds.Height / 2 + 5), sfSecondary);

            Color bad    = new Hex("#F56C6C").ToColor();
            Color medium = new Hex("#E6A23C").ToColor();
            Color good   = new Hex("#67C23A").ToColor();

            string strength  = "";
            Color  infoColor = Color.Beige;

            if (_passwordHash.Length >= 10)
            {
                infoColor = good;
                strength  = "Strong";
            }
            else if (_passwordHash.Length >= 6)
            {
                infoColor = medium;
                strength  = "Good";
            }
            else
            {
                infoColor = bad;
                strength  = "Weak";
            }

            // Draw password hash
            StringFormat sfPassword = new StringFormat();

            sfPassword.LineAlignment = StringAlignment.Center;
            sfPassword.Alignment     = StringAlignment.Far;

            Font  passwordFont  = new Font("Segoe UI", 9);
            SizeF size          = g.MeasureString(strength, passwordFont);
            Color passwordColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());

            g.DrawString(strength, passwordFont, new SolidBrush(infoColor), new Rectangle(Bounds.X, Bounds.Y, Convert.ToInt32(Bounds.Width - 20), Bounds.Height), sfPassword);
            // new Rectangle(Bounds.X + Bounds.Width - Convert.ToInt32(size.Width) - 21, Bounds.Y + Bounds.Height / 2 - Convert.ToInt32(size.Height/2), Bounds.Width, Bounds.Height / 2 - Convert.ToInt32(size.Height / 2))
        }
Esempio n. 22
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));
        }
Esempio n. 23
0
        /// <summary>
        /// Draw item method
        /// </summary>
        protected virtual void OnDrawItem(Graphics g, Rectangle bounds)
        {
            if (Owner == null)
            {
                return;
            }

            // If item is not in the view-port
            if (!ItemInView(this))
            {
                // Go back
                return;
            }

            // Is item divider?
            if (Divider)
            {
                // Draws background
                using (SolidBrush brush = new SolidBrush(Owner.Component.SourceTheme.COMPONENT_BACKGROUND.Normal))
                    g.FillRectangle(brush, Bounds);

                // End
                return;
            }

            // Updates item's height property
            // Uses device independent pixels to provide best scaling
            // experience
            Height = DIP.Set(50);

            // Update bounds property
            Bounds = bounds;

            // Set clip region. Clip graphics canvas to the dimensions of
            // list item.
            g.Clip = new Region(bounds);

            // Draws background
            using (SolidBrush brush = new SolidBrush(Owner.Component.SourceTheme.COMPONENT_BACKGROUND.Normal))
                g.FillRectangle(brush, Bounds);

            // If touch-controls are disabled
            if (!M.TouchEnabled)
            {
                // Shortcut variable for normal control background color
                Color bg = Owner.Component.SourceTheme.COMPONENT_BACKGROUND.Normal;

                // Draws partially transparent accent layer as background
                using (SolidBrush brush = new SolidBrush(ColorExtensions.Mix(Color.FromArgb(_hoverAlpha, Owner.Accent), bg)))
                    g.FillRectangle(brush, Bounds);

                // Turn on anti-aliasing
                g.SmoothingMode = SmoothingMode.AntiAlias;

                // Reveal effect ellipse
                GraphicsPath ellipse = Draw.GetEllipsePath(_mousePosition, 150);

                // Path gradient brush
                PathGradientBrush pgb = new PathGradientBrush(ellipse);
                pgb.CenterPoint    = _mousePosition;
                pgb.CenterColor    = Color.FromArgb(55, Owner.Accent);
                pgb.SurroundColors = new Color[] { ColorExtensions.Mix(Color.FromArgb(_hoverAlpha, Owner.Accent), bg) };

                // Draw reveal effect if mouse is hovering over an item
                if (Hover)
                {
                    g.FillPath(pgb, ellipse);
                }

                // Turn off anti-aliasing
                g.SmoothingMode = SmoothingMode.Default;

                // Draws partially transparent accent layer as overlay
                // to hide rest of reveal ellipse
                using (SolidBrush brush = new SolidBrush(ColorExtensions.Mix(Color.FromArgb(_hoverAlpha, Owner.Accent), bg)))
                    g.FillRectangle(brush, new Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width - 4, Bounds.Height - 4));
            }

            // Draws click effect
            DrawClick(g);
        }
Esempio n. 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));
        }
Esempio n. 25
0
        /// <summary>
        /// Updates prefix, postfix and textBox positions
        /// </summary>
        private void UpdateLayout()
        {
            try
            {
                // Size of postfix and prefix in pixels
                _prefixSize  = TextRenderer.MeasureText(_prefix, this.Font);
                _postfixSize = TextRenderer.MeasureText(_postfix, this.Font);

                // Prefix
                // Prefix is not empty string
                if (_prefix != "")
                {
                    // Prefix area rectangle
                    _prefixRectangle        = new Rectangle(new Point(0, 0), new Size(DIP.ToInt(10) + _prefixSize.Width, this.Height));
                    _textBox.DrawLeftBorder = false;
                }
                else
                {
                    // Empty area
                    _prefixRectangle        = new Rectangle(new Point(0, 0), new Size(0, 0));
                    _textBox.DrawLeftBorder = true;
                }

                // Adjust textBox size
                _textBox.Size     = new Size(this.Width - _prefixRectangle.Width - _postfixRectangle.Width, this.Height);
                _textBox.Location = new Point(_prefixRectangle.X + _prefixRectangle.Width, 0);

                // Postfix
                // Postfix is not empty string
                if (_postfix != "")
                {
                    // Postfix area rectangle
                    _postfixRectangle        = new Rectangle(new Point(_prefixRectangle.X + _prefixRectangle.Width + _textBox.Width, 0), new Size(DIP.ToInt(10) + _postfixSize.Width, this.Height));
                    _textBox.DrawRightBorder = false;
                }
                else
                {
                    // Empty area
                    _postfixRectangle        = new Rectangle(new Point(0, 0), new Size(0, 0));
                    _textBox.DrawRightBorder = true;
                }

                // Adjust textBox size
                _textBox.Size     = new Size(this.Width - _prefixRectangle.Width - _postfixRectangle.Width, this.Height);
                _textBox.Location = new Point(_prefixRectangle.X + _prefixRectangle.Width, 0);

                // Redraw
                Invalidate();
            }
            catch
            {
            }
        }
Esempio n. 26
0
        static void Main(string[] args)
        {
            Console.WriteLine("Loading sample data...");
            _bScan = SAM.Core.DataProcessing.SamBScanLoader.LoadFloat(dataPath, NUMBER_RECORDS, RECORD_LENGTH);
            Console.WriteLine("Done!");

            //var aScan = new float[RECORD_LENGTH];
            //for (int i = 0; i <= RECORD_LENGTH; i++)
            //    aScan[i] = _bScan[0, i];

            Action <Action> measure = (body) =>
            {
                var startTime = DateTime.Now;
                body();
                Console.WriteLine("Time Elapsed: {0} ", (DateTime.Now - startTime).Milliseconds);
            };

            //var random = new Random();
            //var aScan = new double[100000];
            //for (int i = 0; i < 100000; i++)
            //{
            //    double rand = ((double)random.Next(2000)) / 2000;
            //    rand = rand * 2 + -1;
            //    aScan[i] = rand;
            //}

            //measure(() => DIP.FHT(aScan, FourierTransform.Direction.Forward));

            var random = new Random();
            var aScan  = new double[500];

            for (int j = 0; j < 500; j++)
            {
                double rand = ((double)random.Next(2000)) / 2000;
                rand     = rand * 2 + -1;
                aScan[j] = rand;
            }

            measure(() =>
            {
                for (int i = 0; i < 2000; i++)
                {
                    //var aScan = new double[RECORD_LENGTH];
                    //for (int j = 0; j < RECORD_LENGTH; j++)
                    //    aScan[j] = _bScan[0, j];


                    DIP.FHT(aScan, FourierTransform.Direction.Forward);
                }
            });

            //var tasks = new Task[NUMBER_RECORDS];
            //for (int i = 0; i < NUMBER_RECORDS; i++)
            //{
            //    var aScan = new double[RECORD_LENGTH];
            //    for (int j = 0; j < RECORD_LENGTH; j++)
            //        aScan[j] = _bScan[0, j];
            //    tasks[i] = Task.Factory.StartNew(() => DIP.FHT(aScan, FourierTransform.Direction.Forward));
            //}

            //measure(() => Task.WaitAll(tasks));
            Console.ReadKey();
        }