Exemplo n.º 1
1
 public static Color GetMetroThemeColor(MetroFramework.MetroColorStyle style)
 {
     switch (style)
     {
         case MetroFramework.MetroColorStyle.Black:
             return MetroFramework.MetroColors.Black;
         case MetroFramework.MetroColorStyle.Brown:
             return MetroFramework.MetroColors.Brown;
         case MetroFramework.MetroColorStyle.Green:
             return MetroFramework.MetroColors.Green;
         case MetroFramework.MetroColorStyle.Lime:
             return MetroFramework.MetroColors.Lime;
         case MetroFramework.MetroColorStyle.Magenta:
             return MetroFramework.MetroColors.Magenta;
         case MetroFramework.MetroColorStyle.Orange:
             return MetroFramework.MetroColors.Orange;
         case MetroFramework.MetroColorStyle.Pink:
             return MetroFramework.MetroColors.Pink;
         case MetroFramework.MetroColorStyle.Purple:
             return MetroFramework.MetroColors.Purple;
         case MetroFramework.MetroColorStyle.Red:
             return MetroFramework.MetroColors.Red;
         case MetroFramework.MetroColorStyle.Silver:
             return MetroFramework.MetroColors.Silver;
         case MetroFramework.MetroColorStyle.Teal:
             return MetroFramework.MetroColors.Teal;
         case MetroFramework.MetroColorStyle.White:
             return MetroFramework.MetroColors.White;
         case MetroFramework.MetroColorStyle.Yellow:
             return MetroFramework.MetroColors.Yellow;
         default:
             return MetroFramework.MetroColors.Blue;
     }
 }
Exemplo n.º 2
0
 public ListContact(string jid, MetroFramework.MetroColorStyle style)
 {
     this.Style = style;
     InitializeComponent();
     int vertScrollWidth = SystemInformation.VerticalScrollBarWidth;
     this.Width -= vertScrollWidth;
     this.BackColor = Helper.GetMetroThemeColor(style);
     this.contact = ContactStore.GetContactByJid(jid);
     if (this.contact != null)
     {
         this.lblName.Text = this.contact.FullName;
         string imgpath = ChatWindow.getCacheImagePath(jid);
         if (File.Exists(imgpath))
         {
             try
             {
                 Image i = Image.FromFile(imgpath);
                 Bitmap b = new Bitmap(i, new Size(48, 48));
                 this.pictureBox1.Image = b;
                 i.Dispose();
             }
             catch (Exception e)
             {
                 throw e;
             }
         }
     }
 }
 //an intermediate isPresent check
 public static bool IsPresent(MetroFramework.Controls.MetroTextBox textBox)
 {
     if (textBox.Text == "")
     {                                
         return false;
     }
     return true;
 }
 public static bool IsPositive(MetroFramework.Controls.MetroTextBox textbox, string name)
 {
     if (Convert.ToDecimal(textbox.Text) < 0)
     {
         MessageBox.Show(name + " must be positive");
         return false;
     }
     return true;
 }
 public BufferingForm(Simulation Sim, bool StartFromBeginning, long NumberGenerations, MetroFramework.MetroThemeStyle Theme, MetroFramework.MetroColorStyle ColorStyle)
 {
     InitializeComponent();
     this.Sim = Sim;
     this.StartFromBeginning = StartFromBeginning;
     this.NumberGenerations = NumberGenerations;
     this.BSim = new SimpleBufferedSimulation((int)NumberGenerations);
     this.SetThemeStyle(Theme, ColorStyle);
 }
Exemplo n.º 6
0
 private void m_textBox_CustomPaintForeground(object sender, MetroFramework.Drawing.MetroPaintEventArgs e)
 {
     if (!m_isValidNumber)
     {
         MetroTextBox textBox = sender as MetroTextBox;
         if (textBox != null)
             ControlPaint.DrawBorder(e.Graphics, textBox.DisplayRectangle, Color.Red, ButtonBorderStyle.Solid);
     }
 }
Exemplo n.º 7
0
 public static int checkNullMetrotxt(MetroFramework.Controls.MetroTextBox txt)
 {
     if (txt.Text.Trim() == "")
     {
         MessageBox.Show("กรุณาระบุข้อมูลให้ครบถ้วน");
         txt.Focus();
         return 0;
     }
     return 1;
 }
 public static bool IsPresent(MetroFramework.Controls.MetroTextBox textBox, string name)
 {
     if (textBox.Text == "")
     {
         MessageBox.Show(name + " is a required field.", "Entry Error");
         textBox.Focus();
         return false;
     }
     return true;
 }
Exemplo n.º 9
0
        public ListChat(WappMessage msg, MetroFramework.MetroColorStyle style)
        {
            InitializeComponent();
            this.Style = style;
            this.metroTile1.Style = style;
            this.metroTile1.BackColor = Helper.GetMetroThemeColor(style);
            if (msg.from_me)
            {
                this.Padding = new Padding(50, this.Padding.Top, 4, this.Padding.Bottom);
            }
            if (!String.IsNullOrEmpty(msg.author))
            {
                Contact c = ContactStore.GetContactByJid(msg.author);
                if (c != null)
                {
                    msg.author = c.FullName;
                }
                msg.data = String.Format("{0}\r\n{1}", msg.author, msg.data);
            }
            if (msg.type == "image")
            {
                if (!string.IsNullOrEmpty(msg.preview))
                {
                    MemoryStream ms = new MemoryStream(Convert.FromBase64String(msg.preview));
                    Image i = Image.FromStream(ms);
                    this.Height += i.Height;
                    this.Controls.Remove(this.metroTile1);
                    PictureBox pb = new PictureBox();
                    pb.Width = i.Width;
                    pb.Height = i.Height;
                    pb.Image = i;
                    this.Controls.Add(pb);
                }
                
            }
            else
            {
                Font f = MetroFonts.Tile(this.metroTile1.TileTextFontSize, this.metroTile1.TileTextFontWeight);
                int lineHeight = Int32.Parse(Math.Round((decimal)this.metroTile1.CreateGraphics().MeasureString("X", f).Height).ToString());
                SizeF sf = new SizeF();
                sf = this.metroTile1.CreateGraphics().MeasureString(msg.data, f, this.metroTile1.Width);
                this.metroTile1.Text = msg.data;
                int newHeight = (int)Math.Round(decimal.Parse(sf.Height.ToString()));
                int lines = newHeight / f.Height;
                //lines--;

                if (lines > 0)
                {
                    this.Height = (lines * this.Height);
                }
            }
        }
Exemplo n.º 10
0
 public static bool IsWithinRange(MetroFramework.Controls.MetroTextBox textBox, string name,
     decimal min, decimal max)
 {
     decimal number = Convert.ToDecimal(textBox.Text);
     if (number < min || number > max)
     {
         MessageBox.Show(name + " must be between " + min
             + " and " + max + ".", "Entry Error");
         textBox.Focus();
         return false;
     }
     return true;
 }
Exemplo n.º 11
0
 public static bool IsDecimal(MetroFramework.Controls.MetroTextBox textBox, string name)
 {
     decimal number = 0m;
     if (Decimal.TryParse(textBox.Text, out number))
     {
         return true;
     }
     else
     {
         MessageBox.Show(name + " must be a decimal value.", "Entry Error");
         textBox.Focus();
         return false;
     }
 }
Exemplo n.º 12
0
 public static bool IsInt32(MetroFramework.Controls.MetroTextBox textBox, string name)
 {
     int number = 0;
     if (Int32.TryParse(textBox.Text, out number))
     {
         return true;
     }
     else
     {
         MessageBox.Show(name + " must be an integer.", "Entry Error");
         textBox.Focus();
         return false;
     }
 }
 private void SetThemeStyle(MetroFramework.MetroThemeStyle Theme, MetroFramework.MetroColorStyle ColorStyle)
 {
     System.Drawing.Color BC = MetroFramework.Drawing.MetroPaint.BackColor.Form(Theme);
     System.Drawing.Color FC = MetroFramework.Drawing.MetroPaint.ForeColor.Title(Theme);
     this.Theme = Theme;
     this.Style = ColorStyle;
     Tabs.Theme = Theme;
     Tabs.Style = ColorStyle;
     Tab_Basic.Theme = Theme;
     Tab_Basic.Style = ColorStyle;
     Tab_Advanced.Theme = Theme;
     Tab_Advanced.Style = ColorStyle;
     L1.Theme = Theme;
     L2.Theme = Theme;
     Basic_NumberGenerations.ForeColor = FC;
     Basic_NumberGenerations.BackColor = BC;
     Basic_StartFromCurrentGeneration.Theme = Theme;
     Basic_StartFromCurrentGeneration.Style = ColorStyle;
     StartButton.Theme = Theme;
     StartButton.Style = ColorStyle;
     CancelButton.Theme = Theme;
     CancelButton.Style = ColorStyle;
 }
Exemplo n.º 14
0
 public contextcolors(MetroFramework.MetroThemeStyle Theme, MetroColorStyle Style)
 {
     _theme = Theme;
     _style = Style;
 }
Exemplo n.º 15
0
 public MetroCTXRenderer(MetroFramework.MetroThemeStyle Theme, MetroColorStyle Style) : base(new contextcolors(Theme, Style)) { }
 /// <summary>
 /// Creates a new buffer simulation form with a particular simulation to buffer
 /// </summary>
 /// <param name="SimulationToBuffer">The simulation to buffer</param>
 public BufferSimulation(Simulation SimulationToBuffer, MetroFramework.MetroThemeStyle Theme, MetroFramework.MetroColorStyle ColorStyle)
 {
     InitializeComponent();
     this.Sim = SimulationToBuffer;
     SetThemeStyle(Theme, ColorStyle);
 }
 private void SetThemeStyle(MetroFramework.MetroThemeStyle Theme, MetroFramework.MetroColorStyle ColorStyle)
 {
     System.Drawing.Color BC = MetroFramework.Drawing.MetroPaint.BackColor.Form(Theme);
     System.Drawing.Color FC = MetroFramework.Drawing.MetroPaint.ForeColor.Title(Theme);
     this.Theme = Theme;
     this.Style = ColorStyle;
     this.StatusLabel.Theme = Theme;
     this.StatusLabel.Style = ColorStyle;
     this.PB.Theme = Theme;
     this.PB.Style = ColorStyle;
 }
Exemplo n.º 18
0
 private void SetUpPanel(MetroFramework.Controls.MetroUserControl panel)
 {
     this.Controls.Add(panel);
     panel.Dock = DockStyle.Fill;
 }
Exemplo n.º 19
0
        /// <summary>
        /// Anima una forma dada con un desplazamiento lineal marcado por un vector, segun sea el estado marcado para cerrar o abrir. Se utiliza un control de tiempo para marcar
        /// la velocidad de la animación.
        /// </summary>
        /// <param name="vectorx">Marca la posicion inicial de la forma</param>
        /// <param name="estado">Indica si el formulario entra (true) o sale (false) de pantalla.</param>
        /// <param name="formulario">Formulario que se desea animar.</param>
        /// <param name="TimerControl">Controlador de tiempo de animación.</param>
        /// <returns></returns>
        public static int slide(int vectorx, bool estado,MetroFramework.Forms.MetroForm formulario,Timer TimerControl )
        {
            if (estado == true)
            {
                vectorx = vectorx - 80;

                if (vectorx <= 350)
                {
                    TimerControl.Stop();

                }
                 formulario.Location = new Point(vectorx, 150);
                 return vectorx;
            }
            else
            {
                vectorx = vectorx + 80;

                if (vectorx >= 1350)
                {
                    TimerControl.Stop();
                    formulario.Close();
                    return vectorx;

                }
                formulario.Location = new Point(vectorx, 150);
                return vectorx;
            }
        }
 private void m_keyTextBox_CustomPaintForeground(object sender, MetroFramework.Drawing.MetroPaintEventArgs e)
 {
     if (!m_isKeyValidNumber)
         ControlPaint.DrawBorder(e.Graphics, m_keyTextBox.DisplayRectangle, Color.Red, ButtonBorderStyle.Solid);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Ajusta o diretório no componente informado para o diretório base 
 /// respeitando o último nome de diretório informado
 /// </summary>
 /// <param name="textBox">Componente do tipo TextBox que será modificado</param>
 /// <param name="baseDir">diretório base para substituir no componente</param>
 private void SetNewDir(MetroFramework.Controls.MetroTextBox textBox, string baseDir, string subfolder)
 {
     string[] dirs = textBox.Text.Split(new char[] { '\\' });
     if (dirs.Length > 0 && !String.IsNullOrEmpty(textBox.Text))
     {
         string dir = dirs[dirs.Length - 1];
         textBox.Text = String.Format("{0}\\{1}", baseDir, dir);
     }
     else
         textBox.Text = String.Format("{0}\\{1}", baseDir, subfolder);
     __oldvalues[textBox] = textBox.Text;
 }
Exemplo n.º 22
0
        private void metroTabControl2_CustomPaint(object sender, MetroFramework.Drawing.MetroPaintEventArgs e)
        {
            MetroFramework.Controls.MetroTabPage tab = (MetroFramework.Controls.MetroTabPage)((MetroFramework.Controls.MetroTabControl)sender).Controls[0];
            Point location = new Point();
            location.X = tab.Location.X - 1;
            location.Y = tab.Location.Y - 29;

            Size size = new Size();
            size.Width = tab.Size.Width + 1;
            size.Height = tab.Size.Height + 30;

            e.Graphics.DrawRectangle(new Pen(Color.FromArgb(255, 226, 227, 231), 1), new Rectangle(location, size));
        }
Exemplo n.º 23
0
 public static void LoadTheme(MetroFramework.Components.MetroStyleManager MetroStyleManager)
 {
     Friends.globalThemeManager.Add(MetroStyleManager);
     MetroStyleManager.Theme = Friends.globalStyleManager.Theme;
     MetroStyleManager.Style = Friends.globalStyleManager.Style;
 }
 public MenuColorPallet(MetroFramework.MetroThemeStyle Theme, MetroFramework.MetroColorStyle Style)
 {
     this.Theme = Theme;
     this.Style = Style;
 }
Exemplo n.º 25
0
        private void txt_quant_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
            {
                e.Handled = true;
            }
            var validKeys = new [] {Keys.Back, Keys.D1};
            e.Handled = !validKeys.Contains((Keys)e.KeyChar);           

        }
Exemplo n.º 26
0
        public static void LoadTheme(MetroFramework.Forms.MetroForm Form, System.Windows.Forms.Control.ControlCollection Controls, MetroFramework.Controls.MetroUserControl MetroUserControl = null)
        {
            foreach (var form in System.Windows.Forms.Application.OpenForms)
            {
                if (form is MetroForm && !form.Equals(Form))
                {
                    try
                    {
                        var metroForm = (MetroForm)form;
                        metroForm.Theme = metroForm.StyleManager.Theme = Friends.GlobalStyleManager.Theme;
                        metroForm.Style = metroForm.StyleManager.Style = Friends.GlobalStyleManager.Style;
                        metroForm.Refresh();
                    }
                    catch
                    {

                    }
                }
            }
            if (Controls != null)
            {
                foreach (System.Windows.Forms.Control control in Controls)
                {
                    try
                    {
                        if (control.GetType().GetProperties().Any(x => x.Name == "StyleManager") || (control.GetType().GetProperties().Any(x => x.Name == "Theme") && control.GetType().GetProperties().Any(x => x.Name == "Style")))
                        {
                            control.GetType().GetProperty("Theme").SetValue(control, Friends.GlobalStyleManager.Theme, null);
                            control.GetType().GetProperty("Style").SetValue(control, Friends.GlobalStyleManager.Style, null);
                            var styleManager = control.GetType().GetProperty("StyleManager").GetValue(control, null) as MetroFramework.Components.MetroStyleManager;
                            styleManager = Friends.GlobalStyleManager;
                            styleManager.Style = Friends.GlobalStyleManager.Style;
                            styleManager.Theme = Friends.GlobalStyleManager.Theme;
                            control.Refresh();
                        }
                        LoadTheme(null, control.Controls);
                    }
                    catch
                    {

                    }
                }
            }
            if (Form != null)
            {
                Form.Theme = Form.StyleManager.Theme = Friends.GlobalStyleManager.Theme;
                Form.Style = Form.StyleManager.Style = Friends.GlobalStyleManager.Style;
                Form.Refresh();
            }
            if (MetroUserControl != null)
            {
                MetroUserControl.Theme = MetroUserControl.StyleManager.Theme = Friends.GlobalStyleManager.Theme;
                MetroUserControl.Style = MetroUserControl.StyleManager.Style = Friends.GlobalStyleManager.Style;
                MetroUserControl.Refresh();
            }
        }
Exemplo n.º 27
0
 public static string checkzeroM(MetroFramework.Controls.MetroTextBox txt)
 {
     if (txt.Text.Trim() == "")
     {
         return "0";
     }
     return txt.Text;
 }