Example #1
0
        public static void setEnableControl(Controls.RibbonForm objForm, object Container, bool enable = false)
        {
            try
            {
                var stack = new Stack <Control>();
                stack.Push((Control)Container);

                while (stack.Count > 0)
                {
                    var next = stack.Pop();
                    if (next.GetType() == typeof(Spectrum.Controls.TextBox) ||
                        next.GetType() == typeof(Spectrum.Controls.ComboBox) ||
                        next.GetType() == typeof(System.Windows.Forms.CheckBox) ||
                        next.GetType() == typeof(System.Windows.Forms.RadioButton) ||
                        next.GetType() == typeof(Spectrum.Controls.Button))
                    {
                        next.Enabled = enable;
                    }
                    foreach (Control child in next.Controls)
                    {
                        stack.Push(child);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objForm"></param>
        public static void SetCultureFromResource(Controls.RibbonForm objForm)
        {
            try
            {
                var stack = new Stack <Control>();
                objForm.Text = SpectrumResources.GetString(objForm.Name);

                foreach (Control ctrl in objForm.Controls)
                {
                    try
                    {
                        stack.Push(ctrl);

                        if (ctrl.GetType() == typeof(Spectrum.Controls.Label) ||
                            ctrl.GetType() == typeof(Spectrum.Controls.Button))
                        {
                            ctrl.Text = SpectrumResources.GetString(string.Format("{0}.{1}", objForm.Name, ctrl.Name));
                        }
                        else if (ctrl.GetType() == typeof(Spectrum.Controls.FlexGrid))
                        {
                            C1FlexGrid grid = (C1FlexGrid)ctrl;
                            for (int rowIndex = 0; rowIndex < grid.Cols.Count; rowIndex++)
                            {
                                grid.Cols[rowIndex].Caption = SpectrumResources.GetString(string.Format("{0}.{1}.{2}", objForm.Name, ctrl.Name, grid.Cols[rowIndex].Name));
                            }
                        }
                    }
                    catch { }
                }

                while (stack.Count > 0)
                {
                    try
                    {
                        var next = stack.Pop();

                        foreach (Control childControl in next.Controls)
                        {
                            stack.Push(childControl);

                            if (childControl.GetType() == typeof(Spectrum.Controls.Label) ||
                                childControl.GetType() == typeof(Spectrum.Controls.Button))
                            {
                                if (childControl.Name != "LabelText")
                                {
                                    childControl.Text = SpectrumResources.GetString(string.Format("{0}.{1}", objForm.Name, childControl.Name));
                                }
                            }
                            else if (childControl.GetType() == typeof(Spectrum.Controls.LabelMandatory))
                            {
                                ((Spectrum.Controls.LabelMandatory)(childControl)).NormalLabelText = SpectrumResources.GetString(string.Format("{0}.{1}", objForm.Name, childControl.Name));
                            }
                            else if (childControl.GetType() == typeof(Spectrum.Controls.FlexGrid))
                            {
                                C1FlexGrid grid = (C1FlexGrid)childControl;
                                for (int rowIndex = 0; rowIndex < grid.Cols.Count; rowIndex++)
                                {
                                    grid.Cols[rowIndex].Caption = SpectrumResources.GetString(string.Format("{0}.{1}.{2}", objForm.Name, childControl.Name, grid.Cols[rowIndex].Name));
                                }
                            }
                        }
                    }
                    catch { }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #3
0
        public static void WriteResourceFile(Controls.RibbonForm objForm)
        {
            try
            {
                string       filePath = Path.Combine(Application.StartupPath, string.Format("{0}.txt", objForm.Name));
                StreamWriter sWriter  = File.CreateText(filePath);

                var stack = new Stack <Control>();

                sWriter.WriteLine(objForm.Name + "=" + objForm.Text);

                foreach (Control ctrl in objForm.Controls)
                {
                    try
                    {
                        stack.Push(ctrl);

                        if (ctrl.GetType() == typeof(Spectrum.Controls.Label) ||
                            ctrl.GetType() == typeof(Spectrum.Controls.Button))
                        {
                            sWriter.WriteLine(string.Format("{0}.{1}={2}", objForm.Name, ctrl.Name, ctrl.Text));
                        }
                        else if (ctrl.GetType() == typeof(Spectrum.Controls.FlexGrid))
                        {
                            C1FlexGrid grid = (C1FlexGrid)ctrl;
                            for (int rowIndex = 0; rowIndex < grid.Cols.Count; rowIndex++)
                            {
                                sWriter.WriteLine(string.Format("{0}.{1}.{2}={3}", objForm.Name, ctrl.Name, grid.Cols[rowIndex].Name, grid.Cols[rowIndex].Caption));
                            }
                        }
                    }
                    catch { }
                }

                while (stack.Count > 0)
                {
                    try
                    {
                        var next = stack.Pop();

                        foreach (Control childControl in next.Controls)
                        {
                            stack.Push(childControl);

                            if (childControl.GetType() == typeof(Spectrum.Controls.Label) ||
                                childControl.GetType() == typeof(Spectrum.Controls.Button))
                            {
                                sWriter.WriteLine(string.Format("{0}.{1}={2}", objForm.Name, childControl.Name, childControl.Text));
                            }

                            else if (childControl.GetType() == typeof(Spectrum.Controls.LabelMandatory))
                            {
                                sWriter.WriteLine(string.Format("{0}.{1}={2}", objForm.Name, childControl.Name, ((LabelMandatory)(childControl)).NormalLabelText));
                            }
                            else if (childControl.GetType() == typeof(Spectrum.Controls.FlexGrid))
                            {
                                C1FlexGrid grid = (C1FlexGrid)childControl;
                                for (int rowIndex = 0; rowIndex < grid.Cols.Count; rowIndex++)
                                {
                                    sWriter.WriteLine(string.Format("{0}.{1}.{2}={3}", objForm.Name, childControl.Name, grid.Cols[rowIndex].Name, grid.Cols[rowIndex].Caption));
                                }
                            }
                        }
                    }
                    catch { }
                }

                sWriter.Flush();
                sWriter.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public void ShowChildForm(Controls.RibbonForm ChildForm, bool isdoctoparent = false)
        {
            gmdiclientheight = ChildForm.Height;
            gmdiclientwidth = ChildForm.Width;

            try
            {
                // Make it a child of this MDI form before showing it.
                foreach (Form frmS in MdiChildren)
                {
                    if (ChildForm.Name == frmS.Name)
                    {
                        return;
                    }
                }

                ChildForm.MdiParent = this;
                childFormNumber += 1;
                ChildForm.Text = ChildForm.Text;

                //lblTitle.Text = fnMakeTitle(, ChildForm.Text)

                if (isdoctoparent == true)
                {
                    ChildForm.Dock = DockStyle.Fill;
                    ChildForm.MainMenuStrip = MenuStrip;

                    //Rakesh-21.08.2013:Issue-7606-->Disappears title text
                    ChildForm.MaximizeBox = false;
                }
                else
                {
                    ChildForm.StartPosition = FormStartPosition.CenterScreen;
                }

                ChildForm.StartPosition = FormStartPosition.CenterScreen;
                if (ChildForm.Name != "frmNLogin")
                {
                    //Close all child forms of the parent.
                    foreach (Form vChildForm in this.MdiChildren)
                    {
                        if (ChildForm.Name != vChildForm.Name)
                        {
                            vChildForm.Close();
                            ChildForm.Dispose();
                        }
                    }
                }
                else
                {
                    ChildForm.StartPosition = FormStartPosition.CenterScreen;
                    this.MenuStrip.Show();
                }

                ChildForm.Select();
                try
                {
                    ChildForm.Show();
                }
                catch (Exception ex)
                {
                    ChildForm.Close();
                    ChildForm.Dispose();
                }

            }
            catch (Exception ex)
            {
                ChildForm.Close();
                ChildForm.Dispose();
            }
        }