Esempio n. 1
0
 private void TabControlMain_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         TabPage         currentTab = tabControlMain.TabPages[tabControlMain.SelectedIndex];
         IToolboxControl control    = currentTab.Tag as IToolboxControl;
         if (null != control)
         {
             bool firstShow = !_toolBoxControlsFirstShowPassed.Any(c => c == control);
             control.Activate(firstShow);
             if (!firstShow)
             {
                 _toolBoxControlsFirstShowPassed.Add(control);
             }
             if (null != _lastSelectedcontrol)
             {
                 _lastSelectedcontrol.Deactivated();
                 _lastSelectedcontrol = null;
             }
         }
     }
     catch (Exception exception)
     {
         ErrorForm.ShowError(this, exception, ErrorCategory.NonCritical, CurrentLanguageID);
     }
 }
Esempio n. 2
0
        public static void TranslateControls(Control control, string ressourceFile, int languageId)
        {
            string ressourceContent = ReadString(ressourceFile);

            string[] splitArray = ressourceContent.Split(new string[] { "[End]" }, StringSplitOptions.RemoveEmptyEntries);
            Dictionary <string, string> translateTable = GetTranslateRessources(splitArray, languageId);

            IToolboxControl toolBoxControl = control as IToolboxControl;

            if ((null != toolBoxControl) && (null != toolBoxControl.Components))
            {
                foreach (System.ComponentModel.IComponent controlComponent in toolBoxControl.Components.Components)
                {
                    ContextMenuStrip menuStrip = controlComponent as ContextMenuStrip;
                    if (null != menuStrip)
                    {
                        string message = "";
                        translateTable.TryGetValue(menuStrip.Name, out message);
                        if (!string.IsNullOrEmpty(message))
                        {
                            menuStrip.Text = message;
                        }

                        foreach (ToolStripItem unkownItem in menuStrip.Items)
                        {
                            ToolStripMenuItem menuItem = unkownItem as ToolStripMenuItem;
                            if (null != menuItem)
                            {
                                message = "";
                                translateTable.TryGetValue(menuItem.Name, out message);
                                if (!string.IsNullOrEmpty(message))
                                {
                                    menuItem.Text = message;
                                }
                                ForEachItems(menuItem, translateTable);
                            }
                        }
                    }
                }
            }

            string caption = "";

            translateTable.TryGetValue("this", out caption);
            if (!string.IsNullOrEmpty(caption))
            {
                control.Text = caption;
            }

            foreach (Control item in control.Controls)
            {
                string message = "";
                translateTable.TryGetValue(item.Name, out message);
                if (!string.IsNullOrEmpty(message))
                {
                    item.Text = message;
                }
                ForEachSubControls(item, translateTable);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="innerInstance">instance to wrap into</param>
 public ControlContainer(IToolboxControl innerInstance)
 {
     InitializeComponent();
     if (null == innerInstance)
         throw new ArgumentNullException("innerInstance");
     InnerInstance = innerInstance;
     panelToolboxControl.Controls.Add(innerInstance as Control);
     (innerInstance as Control).Dock = DockStyle.Fill;
 }
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="innerInstance">instance to wrap into</param>
 public ControlContainer(IToolboxControl innerInstance)
 {
     InitializeComponent();
     if (null == innerInstance)
     {
         throw new ArgumentNullException("innerInstance");
     }
     InnerInstance = innerInstance;
     panelToolboxControl.Controls.Add(innerInstance as Control);
     (innerInstance as Control).Dock = DockStyle.Fill;
 }
Esempio n. 5
0
 public void SwitchTo(string controlName)
 {
     foreach (TabPage item in tabControlMain.TabPages)
     {
         IToolboxControl ctrl = item.Tag as IToolboxControl;
         if (null != ctrl && ctrl.ControlName == controlName)
         {
             tabControlMain.SelectedTab = item;
             return;
         }
     }
 }
Esempio n. 6
0
 private void TabControlMain_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         TabPage         currentTab = tabControlMain.TabPages[tabControlMain.SelectedIndex];
         IToolboxControl control    = currentTab.Tag as IToolboxControl;
         if (null != control)
         {
             control.Activate();
         }
     }
     catch (Exception exception)
     {
         ErrorForm.ShowError(this, exception, ErrorCategory.NonCritical, CurrentLanguageID);
     }
 }
Esempio n. 7
0
        private void TabControlMain_Deselecting(object sender, TabControlCancelEventArgs e)
        {
            try
            {
                IToolboxControl lastControl = null;

                if (null != tabControlMain.SelectedTab)
                {
                    lastControl = tabControlMain.SelectedTab.Tag as IToolboxControl;
                }

                _lastSelectedcontrol = lastControl;
            }
            catch (Exception exception)
            {
                ErrorForm.ShowError(this, exception, ErrorCategory.NonCritical, CurrentLanguageID);
            }
        }
Esempio n. 8
0
        private void LoadRuntimeControl(Type type)
        {
            IToolboxControl  ctrl          = Activator.CreateInstance(type) as IToolboxControl;
            ControlContainer hostContainer = new ControlContainer(ctrl);

            tabControlMain.TabPages.Add(hostContainer.ControlCaption);
            TabPage page = tabControlMain.TabPages[tabControlMain.TabPages.Count - 1];

            page.Margin  = new System.Windows.Forms.Padding(0);
            page.Padding = new System.Windows.Forms.Padding(0);
            page.Controls.Add(hostContainer as Control);
            page.Tag = hostContainer;
            imageListTabMain.Images.Add(hostContainer.Icon);
            page.ImageIndex = imageListTabMain.Images.Count - 1;
            (hostContainer as Control).Dock = DockStyle.Fill;
            _toolboxControls.Add(hostContainer);
            hostContainer.InitializeControl(this);
        }
Esempio n. 9
0
 private void TabControlMain_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         TabPage currentTab = tabControlMain.TabPages[tabControlMain.SelectedIndex];
         IToolboxControl control = currentTab.Tag as IToolboxControl;
         if (null != control)
         {
             bool firstShow = !_toolBoxControlsFirstShowPassed.Any(c => c == control);
             control.Activate(firstShow);
             if (!firstShow)
                 _toolBoxControlsFirstShowPassed.Add(control);
             if (null != _lastSelectedcontrol)
             {
                 _lastSelectedcontrol.Deactivated();
                 _lastSelectedcontrol = null;
             }
         }
     }
     catch (Exception exception)
     {
         ErrorForm.ShowError(this, exception,ErrorCategory.NonCritical, CurrentLanguageID);
     }
 }
Esempio n. 10
0
        private void TabControlMain_Deselecting(object sender, TabControlCancelEventArgs e)
        {
            try
            {
                IToolboxControl lastControl = null;

                if (null != tabControlMain.SelectedTab)
                    lastControl = tabControlMain.SelectedTab.Tag as IToolboxControl;

                _lastSelectedcontrol = lastControl;
            }
            catch (Exception exception)
            {
                ErrorForm.ShowError(this, exception,ErrorCategory.NonCritical, CurrentLanguageID);
            }
        }