Пример #1
0
        private void Init(LoginType type)
        {
            HelpTopicId = "logon";
            if (BaseSettings.UseDefaultLogin)
            {
                txtOrganization.Text = BaseSettings.DefaultOrganization;
                txtUserName.Text     = BaseSettings.DefaultUser;
                txtPassword.Text     = BaseSettings.DefaultPassword;
            }
            else
            {
                txtOrganization.Text = Config.GetSetting("Organization");
            }

            ControlsLastLanguage = new Dictionary <Control, string> {
                { txtUserName, "en" }, { txtPassword, "en" }
            };

            Application.Idle                         += UpdateLangIndicators;
            ActiveControl                             = txtUserName;
            m_LoginType                               = type;
            m_ConnectionCredentials                   = new ConnectionCredentials();
            m_ArchiveConnectionCredentials            = new ConnectionCredentials(null, "Archive");
            m_ConnectionCredentials.CredentialChange += CredentialChanged;
            m_Manager = new EidssSecurityManager();
            m_Manager.LogOut();
            m_SupportedLanguages.Clear();
            foreach (var key in Localizer.SupportedLanguages.Keys)
            {
                m_SupportedLanguages.Add(key);
            }
            KeyDown += LoginForm_KeyDown;
            RtlHelper.SetRTL(this, true);
        }
Пример #2
0
 private void Init()
 {
     FormIcon.Properties.ShowMenu     = false;
     FormIcon.Properties.AllowFocused = false;
     RtlHelper.SetRTL(FormIcon);
     RtlHelper.SetRTL(FormIDLabel);
     RtlHelper.SetRTL(CaptionLabel);
 }
Пример #3
0
 protected override void InitLayout()
 {
     base.InitLayout();
     if (!SkipDefaultRtlInitialization)
     {
         RtlHelper.SetRTL(this);
     }
 }
Пример #4
0
        /// <summary>
        /// Вычисляем положение кнопок на панели
        /// </summary>
        protected override void RecalculateActionsPositions()
        {
            if (m_Buttons == null)
            {
                return;
            }
            //размещение слева направо, сверху вниз, согласно порядковым номерам кнопок
            var       top       = (Height - m_ButtonHeight) / 2;
            const int margin    = 5;
            var       leftEdge  = 0;
            var       rightEdge = Width;

            //формируем единую коллекцию для всех элементов, участвующих в рендеринге действий

            var actionControls = new List <Control>();

            actionControls.AddRange(m_Buttons);

            for (var i = actionControls.Count - 1; i >= 0; i--)
            {
                var actionControl = actionControls[i];
                var action        = (ActionMetaItem)actionControl.Tag;
                if (action == null)
                {
                    actionControl.Location = new Point(leftEdge + margin, top);
                    leftEdge += actionControl.Width + margin;
                }
                else if (action.Alignment.Equals(ActionsAlignment.Left))
                {
                    actionControl.Location = new Point(leftEdge + margin, top);
                    leftEdge += actionControl.Width + margin;
                }
                else if (action.Alignment.Equals(ActionsAlignment.Right))
                {
                    actionControl.Location = new Point(rightEdge - margin - actionControl.Width, top);
                    rightEdge -= actionControl.Width + margin;
                }
                RtlHelper.SetRTL(actionControl);
            }
        }
Пример #5
0
        /// <summary>
        /// Вычисляем положение кнопок на панели
        /// </summary>
        protected override void RecalculateActionsPositions()
        {
            if (m_UpdateLayout)
            {
                return;
            }
            if (m_Buttons == null || m_Buttons.Count == 0 || Parent == null)
            {
                return;
            }
            var findForm = FindForm();

            if (findForm != null && findForm.WindowState == FormWindowState.Minimized)
            {
                return;
            }
            m_UpdateLayout = true;
            SuspendLayout();
            //размещение слева направо, сверху вниз, согласно порядковым номерам кнопок
            const int margin    = 4;
            var       top       = margin;// (Height - m_ButtonHeight) / 2;
            var       leftEdge  = 0;
            var       rightEdge = Width;
            var       hDelta    = Parent.Height - Height;
            //формируем единую коллекцию для всех элементов, участвующих в рендеринге действий

            var actionControls = new List <Control>();

            //в расчётах присутствуют только видимые кнопки
            actionControls.AddRange(m_Buttons);
            //foreach (var group in m_ActionGroups)
            //    actionControls.Add(group.Value.Button);
            m_ButtonHeight = m_Buttons[0].Height;
            for (var i = actionControls.Count - 1; i >= 0; i--)
            {
                var actionControl = actionControls[i];
                var action        = actionControl.Tag as ActionMetaItem;
                if (action != null && action.Alignment.Equals(ActionsAlignment.Left))
                {
                    actionControl.Location = new Point(leftEdge + margin, top);
                    leftEdge += actionControl.Width + margin;
                    RtlHelper.SetRTL(actionControl);
                }
            }
            for (var i = actionControls.Count - 1; i >= 0; i--)
            {
                var actionControl = actionControls[i];
                var action        = actionControl.Tag as ActionMetaItem;
                if (action == null || action.Alignment.Equals(ActionsAlignment.Right))
                {
                    rightEdge -= actionControl.Width + margin;
                    if (rightEdge < leftEdge + margin)
                    {
                        rightEdge = Width - actionControl.Width - margin;
                        top      += m_ButtonHeight + margin;
                        if (Parent.Height != (top + m_ButtonHeight + margin + hDelta))
                        {
                            Parent.Height = top + m_ButtonHeight + margin + hDelta;
                            Height        = Parent.Height;
                        }
                    }

                    actionControl.Location = new Point(rightEdge, top);
                    RtlHelper.SetRTL(actionControl);
                }
            }
            if (Parent.Height != (top + m_ButtonHeight + margin + hDelta))
            {
                Parent.Height = top + m_ButtonHeight + margin + hDelta;
                Height        = Parent.Height;
            }
            ResumeLayout();
            m_UpdateLayout = false;
        }
Пример #6
0
        private static Form PrepareFormShowing
            (IApplicationForm appForm, bool isModal, Dictionary <string, object> parameters, int width, int height)
        {
            //DebugTimer.Start(string.Format("{0} before load", form.GetType().Name));
            if (appForm is Form)
            {
                var form = appForm as Form;
                form.KeyDown   += appForm.BaseForm_KeyDown;
                form.Activated += OnFormActivate;
                form.Closing   += OnFormClosing;
                RtlHelper.SetRTL(form);

                return(appForm as Form);
            }

            //Контейнер, содержащий всю смысловую часть формы, который требуется разместить либо в теле главной формы, либо на подложке созданной формы
            var container = GetContainer(appForm);

            var screenSize = Screen.GetWorkingArea(new Point(0, 0));

            if (appForm.Sizable)
            {
                if (width > 0)
                {
                    container.Width = width;
                }
                else if (width < 0 || container.Width > screenSize.Width)
                {
                    container.Width = screenSize.Width;
                }
                if (height > 0)
                {
                    container.Height = height;
                }
                else if (height < 0 || container.Height > screenSize.Height)
                {
                    container.Height = screenSize.Height;
                }
            }

            if (container.MinimumSize.Height != 0 && container.Height < container.MinimumSize.Height)
            {
                container.Height = container.MinimumSize.Height;
            }

            if (container.MinimumSize.Width != 0 && container.Width < container.MinimumSize.Width)
            {
                container.Width = container.MinimumSize.Width;
            }

            //подложка, на которой располагается контейнер formCtl
            var baseFormContainer = new BvForm
            {
                StartPosition = FormStartPosition.CenterScreen,
                ClientSize    = new Size(width > 0 ? width : container.Width, height > 0 ? height : container.Height),
                MinimumSize   = new Size(appForm.MinWidth == 0 ? 0 : appForm.MinWidth,
                                         appForm.MinHeight == 0 ? 0 : appForm.MinHeight)
            };

            if (appForm.Sizable)
            {
                baseFormContainer.FormBorderStyle = FormBorderStyle.Sizable;
            }
            else
            {
                baseFormContainer.FormBorderStyle = FormBorderStyle.FixedDialog;
                baseFormContainer.MaximizeBox     = false;
            }
            //baseFormContainer.ControlBox =false;
            baseFormContainer.Controls.Add(container);

            container.Dock = DockStyle.Fill;

            //}
            //TODO разобраться нужно ли создавать форму baseFormContainer, если нужно положить контейнер внутрь главной формы);
            if (MainForm != null)
            {
                //if (isModal)
                //    baseFormContainer.Owner = m_MainForm;
                baseFormContainer.Icon = MainForm.Icon;
            }

            //Control formContainer = GetFormLayout(form);
            baseFormContainer.ShowInTaskbar = !isModal;
            baseFormContainer.KeyPreview    = true;
            baseFormContainer.MinimizeBox   = !isModal;

            var basePanel = appForm as IBasePanel;

            //if (basePanel != null)
            //{
            //    baseFormContainer.ClientSize = new Size(container.Width, container.Height);
            //    container.Dock = DockStyle.Fill;
            //}

            if (baseFormContainer.Width > screenSize.Width)
            {
                if ((basePanel != null) && !appForm.Sizable)
                {
                    container.Location = new Point(0, 0);
                    container.Dock     = DockStyle.None;
                }
                baseFormContainer.Width = screenSize.Width;
                baseFormContainer.Left  = screenSize.Left;
            }
            if (baseFormContainer.Height > screenSize.Height)
            {
                if (!appForm.Sizable)
                {
                    container.Location = new Point(0, 0);
                    container.Dock     = DockStyle.None;
                }
                baseFormContainer.Height = screenSize.Height;
                baseFormContainer.Top    = screenSize.Top;
            }
            if (!appForm.Sizable)
            {
                baseFormContainer.AutoScroll = true;
            }
            baseFormContainer.KeyDown   += appForm.BaseForm_KeyDown;
            baseFormContainer.Activated += OnFormActivate;
            baseFormContainer.Closing   += OnFormClosing;
            //AddHandler baseFormContainer.KeyDown, AddressOf form.BaseFom_KeyDown
            //if ((form) is BasePanel)
            //{
            container.Parent = baseFormContainer;
            //}
            //DebugTimer.Start(string.Format("{0} set visible", form.GetType().Name));
            container.Visible = true;
            if (parameters != null)
            {
                if (basePanel != null)
                {
                    basePanel.StartUpParameters = parameters;
                }
                else if (ReflectionHelper.HasProperty(appForm, "StartUpParameters"))
                {
                    ReflectionHelper.SetProperty(appForm, "StartUpParameters", parameters);
                }
            }
            //DebugTimer.Stop();
            //form.ParentKey = ParentID;
            //form.StartUpParameters = Params;
            //form.ParentBaseForm = m_CurrentForm;
            //if (form is ISearchable)
            //{
            //    ((ISearchable)form).LoadSearchPanel();
            //    if (Params != null)
            //    {
            //        if (Params.ContainsKey("FromCondition"))
            //        {
            //            form.BusinessObject.ListFromCondition = Params["FromCondition"].ToString();
            //        }
            //        if (Params.ContainsKey("FilterCondition"))
            //        {
            //            form.BusinessObject.ListFilterCondition = Params["FilterCondition"].ToString();
            //        }
            //    }
            //}
            baseFormContainer.WindowState = FormWindowState.Normal; //form.DefaultFormState
            if (baseFormContainer != appForm)
            {
                baseFormContainer.Text = appForm.Caption;
            }
            return(baseFormContainer);
        }