Пример #1
0
        private void btnDockingForm_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string frmName = ((RibbonButton)sender).Tag.ToString();
                object objForm = AllManagerForm[frmName];

                if (objForm != null)
                {
                    DockableContent _ContentForm = (DockableContent)objForm;
                    ((DockableContent)objForm).NVSQuyen_Core = new SecurityLevel(checkfunction(frmName));
                    _ContentForm.IsFistLoad = true;
                    if (_ContentForm.State == DockableContentState.None)
                    {
                        _ContentForm.ShowAsDocument();
                        _ContentForm.Activate();
                    }
                    else
                    {
                        _ContentForm.Show();
                    }
                }
                else
                {
                    NoteBox.Show("Chức năng chưa được khởi tạo, hãy liên lạc với quản trị hệ thống");
                }
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
            }
        }
Пример #2
0
        /// <summary>
        ///   Requests the Panel realizer to add a User control to its display
        /// </summary>
        /// <param name = "control">The user control</param>
        /// <param name = "toolbarName">The title on the toolbar header</param>
        /// <param name = "image">The image icon assoacited with the control</param>
        public void AddSideComponent(UserControl control, string toolbarName, Image image)
        {
            if (control == null)
            {
                return;
            }
            try
            {
                Framework.EventBus.Publish(new PanelEvent(this));

                var shown = false;

                foreach (DockableContent tabEntry in this.SideBarExplorer.Items)
                {
                    if (tabEntry.Content == control)
                    {
                        shown = true;
                        tabEntry.Show(this.dockManager);
                        tabEntry.Activate();
                    }
                }

                if (control.Parent == null && shown == false)
                {
                    var aSideBarcontrol = new DockableContent
                    {
                        Background = Brushes.White, Title = toolbarName, Icon = image.Source, Content = control, ToolTip = toolbarName, HideOnClose = false, IsLocked = false
                    };

                    aSideBarcontrol.Closing += this.ASideBarcontrolClosing;
                    this.SideBarExplorer.Items.Add(aSideBarcontrol);
                    aSideBarcontrol.Show(this.dockManager);
                    aSideBarcontrol.Activate();
                }

                control.Focus();
                control.BringIntoView();
            }
            catch (Exception error)
            {
                Framework.EventBus.Publish(error);
            }
        }
Пример #3
0
        InstallBasTextEditor AddEditor(string InstallBasAction)
        {
            ManagedContent mc = null;

            if (DockMan.ActiveContent == null)
            {
                mc = DockMan.DockableContents.First();
            }
            else
            {
                mc = DockMan.ActiveContent;
            }

            DockablePane cPane = mc.ContainerPane as DockablePane;

            string dc_Name = "editor_" + (VM.Editors.Count + 1).ToString();

            DockableContent dc_prev = null;

            foreach (var item in cPane.Items)
            {
                dc_prev = item as DockableContent;
                if (dc_prev.Name.Equals(dc_Name))
                {
                    break;
                }
                else
                {
                    dc_prev = null;
                }
            }
            if (dc_prev != null)
            {
                dc_Name += "_" + cPane.Items.Count.ToString();
            }


            DockableContent dc = new DockableContent();

            dc.Name  = dc_Name;
            dc.Title = dc_Name;
            cPane.Items.Add(dc);


            InstallBasTextEditor bas = new InstallBasTextEditor();

            bas.VM.SyntaxHighlighting = "VBNET";
            bas.VM.Font            = "Consolas";
            bas.VM.FontSize        = 12;
            bas.VM.CurrentFileName = dc_Name;
            if (!String.IsNullOrEmpty(InstallBasAction))
            {
                if (InstallBasAction.Equals(MainWindowViewModel.TOOLBAR_ADD_BAS_ADD_INSTALL))
                {
                    bas.VM.InstallBas();
                }
                else if (InstallBasAction.Equals(MainWindowViewModel.TOOLBAR_ADD_BAS_ADD_REMOVE))
                {
                    bas.VM.RemoveBas();
                }
            }

            dc.Content = bas;

            dc.Closing += delegate(object sender, CancelEventArgs e)
            {
                this.VM.ActiveEditor.IsActive = false;
                this.VM.Editors.Remove(bas.VM);
            };
            dc.Activate();

            this.VM.Editors.Add(bas.VM);
            bas.VM.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName.Equals("CurrentFileName"))
                {
                    dc.Title = Path.GetFileName(bas.VM.CurrentFileName);
                }
            };
            return(bas);
        }