protected override void OnLeaveState()
        {
            // Unregister events
            DualityEditorApp.SelectionChanged      -= this.DualityEditorApp_SelectionChanged;
            DualityEditorApp.ObjectPropertyChanged -= this.DualityEditorApp_ObjectPropertyChanged;

            this.View.SuspendLayout();
            toolstrip.SuspendLayout();

            toolstrip.Items.Clear();
            this.View.Controls.Remove(toolstrip);
            toolstrip.Dispose();

            toolstrip.ResumeLayout(true);
            this.View.ResumeLayout(true);

            base.OnLeaveState();
            this.View.SetToolbarCamSettingsEnabled(true);
            this.CameraObj.Active = true;

            if (selectedBody != null)
            {
                selectedBody.IsSelected = false;
                selectedBody            = null;
            }
        }
예제 #2
0
        //Region Window Control Utilities use static methods

        /// <summary>
        /// Remove all toolbar
        /// </summary>
        /// <param name="frm"></param>
        /// <remarks>
        /// Author		:	PhatLT G3
        /// Created day	:	04/10/2011
        /// </remarks>
        public static void RemoveAllToolBar(Form frm)
        {
            ToolBar tb = null;

            foreach (Control ctrl in frm.Controls)
            {
                tb = ctrl as ToolBar;
                if (tb != null)
                {
                    frm.Controls.Remove(tb);
                    tb.Dispose();
                }
            }

            ToolStrip tbStr = null;

            foreach (Control ctrl in frm.Controls)
            {
                tbStr = ctrl as ToolStrip;
                if (tbStr != null)
                {
                    frm.Controls.Remove(tbStr);
                    tbStr.Dispose();
                }
            }
        }
예제 #3
0
 private static void DisposeToolStrip(ToolStrip menuStrip)
 {
     if (menuStrip is null)
     {
         return;
     }
     menuStrip.Items.Clear();
     menuStrip.Dispose();
 }
예제 #4
0
        UserControl m_lastfrm          = null;                   //Interfaz actual

        /// <summary>LoadPage
        /// </summary>
        /// <param name="frm"></param>
        private void LoadPage(UserControl frm)
        {
            UserControl tmpC = m_lastfrm;

            m_lastfrm = frm;

            this.scMain.Panel1.Controls.Clear();
            m_lastfrm.Parent = this.scMain.Panel1;
            m_lastfrm.Dock   = DockStyle.Fill;
            m_lastfrm.Show();

            if (tmpC != null)
            {
                try
                {
                    try
                    {
                        #region Dispose by reflect
                        FieldInfo[] fieldInfoArray = tmpC.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

                        foreach (FieldInfo fi in fieldInfoArray)
                        {
                            if (fi.FieldType == typeof(Control))
                            {
                                Control ctrl = (Control)fi.GetValue(tmpC);
                                DisposeUC(ctrl);
                            }
                            else if (fi.FieldType == typeof(ToolStrip)) //RedGate it, find it to GC
                            {
                                ToolStrip toolStrip = (ToolStrip)fi.GetValue(tmpC);
                                toolStrip.Dispose();
                            }
                        }
                        #endregion
                    }
                    catch
                    { }
                    tmpC.Parent = null;
                    tmpC.Dispose();
                }
                catch
                { }
                tmpC = null;
            }

            if (DateTime.Now > m_lastCollect.AddMinutes(1))
            {
                m_lastCollect = DateTime.Now;
                try
                {
                    GC.Collect();
                }
                catch
                { }
            }
        }
예제 #5
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         fList.Dispose();
         fBtnLinkJump.Dispose();
         fBtnMoveUp.Dispose();
         fBtnMoveDown.Dispose();
         fBtnDelete.Dispose();
         fBtnEdit.Dispose();
         fBtnAdd.Dispose();
         fToolBar.Dispose();
     }
     base.Dispose(disposing);
 }
예제 #6
0
        public void MethodDipose()
        {
            ToolStrip     ts     = new ToolStrip();
            ToolStripItem item_a = ts.Items.Add("A");
            ToolStripItem item_b = ts.Items.Add("B");
            ToolStripItem item_c = ts.Items.Add("C");

            Assert.AreEqual(3, ts.Items.Count, "A1");

            ts.Dispose();

            Assert.AreEqual(0, ts.Items.Count, "A2");
            Assert.IsTrue(item_a.IsDisposed, "A3");
            Assert.IsTrue(item_b.IsDisposed, "A4");
            Assert.IsTrue(item_c.IsDisposed, "A5");
        }
예제 #7
0
        /// <summary>
        /// Remove item from the standard toolbar or ribbon control
        /// </summary>
        /// <param name="key">
        /// The string itemName to remove from the standard toolbar or ribbon control
        /// </param>
        /// <remarks>
        /// </remarks>
        public override void Remove(string key)
        {
            var item = this.GetItem(key);

            if (item != null)
            {
                ToolStrip toolStrip = item.Owner;
                item.Dispose();
                if (toolStrip.Items.Count == 0)
                {
                    _Strips.Remove(toolStrip);
                    toolStrip.Dispose();
                }
            }
            base.Remove(key);
        }
예제 #8
0
        public void RemovingAnItemFromDisposedStripDoesNotThrow()
        {
            ToolStrip          strip1    = new ToolStrip();
            ToolStripSeparator separator = new ToolStripSeparator();

            strip1.Items.Add(separator);

            ToolStripButton button = new ToolStripButton("Foo");
            ToolStripItemOwnerCollectionUIAdapter adapterDependingOnSeparator = new ToolStripItemOwnerCollectionUIAdapter(separator);

            adapterDependingOnSeparator.Add(button);

            strip1.Dispose();

            adapterDependingOnSeparator.Remove(button);
        }
        public void BehaviorFindToolStrip()
        {
            // Default stuff
            Assert.AreEqual(null, ToolStripManager.FindToolStrip(string.Empty), "A1");
            Assert.AreEqual(null, ToolStripManager.FindToolStrip("MyStrip"), "A2");

            ToolStrip ts = new ToolStrip();

            ts.Name = "MyStrip";

            // Basic operation
            Assert.AreSame(ts, ToolStripManager.FindToolStrip("MyStrip"), "A3");

            // Dispose removes them
            ts.Dispose();
            Assert.AreEqual(null, ToolStripManager.FindToolStrip("MyStrip"), "A4");

            ts      = new ToolStrip();
            ts.Name = "MyStrip1";
            MenuStrip ms = new MenuStrip();

            ms.Name = "MyStrip2";

            // Basic operation
            Assert.AreSame(ts, ToolStripManager.FindToolStrip("MyStrip1"), "A5");
            Assert.AreSame(ms, ToolStripManager.FindToolStrip("MyStrip2"), "A6");

            // Find unnamed strip
            StatusStrip ss = new StatusStrip();

            Assert.AreEqual(ss, ToolStripManager.FindToolStrip(string.Empty), "A7");

            // Always return first unnamed strip
            ContextMenuStrip cms = new ContextMenuStrip();

            Assert.AreEqual(ss, ToolStripManager.FindToolStrip(string.Empty), "A8");

            // Remove first unnamed strip, returns second one
            ss.Dispose();
            Assert.AreEqual(cms, ToolStripManager.FindToolStrip(string.Empty), "A9");

            // ContextMenuStrips are included
            cms.Name = "Context";
            Assert.AreEqual(cms, ToolStripManager.FindToolStrip("Context"), "A10");
        }
예제 #10
0
        public void DeleteWave()
        {
            if (wavePanels.Count > 0)
            {
                int removalIndex = wavePanels.Count - 1;

                ToolStrip bottomTS = wavePanels[removalIndex];

                wavePanels.RemoveAt(removalIndex);

                bottomTS.Dispose();

                wManager.RemoveBottomWave();

                selectedWave = null;

                if (wavePanels.Count == 0)
                {
                    Font oldFont = selectedWaveLabel.Font;
                    Font newFont = new Font(oldFont, (FontStyle)0);

                    selectedWaveLabel.Font = newFont;

                    selectedWaveLabel.Text = "(wave list is empty)";

                    waveNumTop.Value    = 0;
                    waveNumLeft.Value   = 0;
                    waveNumRight.Value  = 0;
                    waveNumBottom.Value = 0;

                    waveNumTop.Enabled            = false;
                    waveNumLeft.Enabled           = false;
                    waveNumRight.Enabled          = false;
                    waveNumBottom.Enabled         = false;
                    saveToolStripMenuItem.Enabled = false;
                }
                else
                {
                    int selectionIndex = removalIndex - 1;

                    SelectWavePanel(selectionIndex);
                }
            }
        }
        public void RemoveControlOnDisposedToolStripTest()
        {
            var hyperToolTipProvider = new HyperToolTipProvider();

            var id = "id";
            var toolStripButton1 = new ToolStripButton();
            var toolStrip1       = new ToolStrip();

            toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripButton1 });

            hyperToolTipProvider.SetHyperToolTipId(toolStripButton1, id);

            Assert.AreEqual(id, hyperToolTipProvider.GetHyperToolTipId(toolStripButton1));
            toolStrip1.Dispose();
            Assert.AreEqual(
                string.Empty,
                hyperToolTipProvider.GetHyperToolTipId(toolStripButton1),
                "control is not deregistered automatically");
        }
예제 #12
0
        /// <summary>
        /// Clean up all child objects here, unlink all events and dispose
        /// </summary>
        protected override void DisposeChildObjects()
        {
            base.DisposeChildObjects();

            if (_toolGroup != null)
            {
                _toolGroup.Dispose();
                _toolGroup = null;
            }
            try
            {
                if (_childToolBox != null)
                {
                    _childToolBox.Dispose();
                    _childToolBox = null;
                }
            }
            catch
            { }
            _button  = null;
            _toolBox = null;
        }
예제 #13
0
        public void LoadUserDefinedReports(bool showCustomButtons)
        {
            string locale = Configuration.mForceEnglish ? "en-US" : Thread.CurrentThread.CurrentCulture.Name;

            mUserReports = new GetUserReportList(Configuration.operatorID, Configuration.LoginStaffID,
                                                 locale);
            try
            {
                mUserReports.Send();
            }
            catch (Exception ex)
            {
                MessageForm.Show(this, Resources.errorLoadData + "...Exception: " + ex.Message, Resources.report_center);
                return;
            }

            // FIX: DE6958 Crash when database has no custom reports
            if (mUserReports.ReportTypes.Count > 0)
            // END: DE6958 Crash when database has no custom reports
            {
                // Update the MD5s and file names from the data we already have.
                foreach (KeyValuePair <int, UserReportType> userType in mUserReports.ReportTypes)
                {
                    foreach (KeyValuePair <int, UserReportGroup> userGroups in userType.Value.UserReportGroups)
                    {
                        for (int x = 0; x < userGroups.Value.ReportsArray.Count; x++)
                        {
                            ReportInfo info = (ReportInfo)userGroups.Value.ReportsArray[x];

                            if (ReportsDictionary.ContainsKey(info.ID))
                            {
                                // MD5 Hash
                                if (ReportsDictionary[info.ID].Hash != null)
                                {
                                    info.Hash = new byte[ReportsDictionary[info.ID].Hash.Length];
                                    Array.Copy(ReportsDictionary[info.ID].Hash, info.Hash, info.Hash.Length);
                                }
                                else
                                {
                                    info.Hash = null;
                                }

                                // File Name
                                info.FileName = ReportsDictionary[info.ID].FileName;
                                userGroups.Value.ReportsArray[x] = info;
                            }
                        }
                    }
                }
            }

            if (mUserReports.ReportTypes.Count < 1)
            {
                //clean up if there is old types there
                menuStrip.SuspendLayout();
                SuspendLayout();
                if (userReportMenu != null)
                {
                    int buttons = userReportMenu.Items.Count;
                    for (int iButton = 0; iButton < buttons; iButton++)
                    {
                        userReportMenu.Items[0].Click -= TempToolStripButtonClick;
                        userReportMenu.Items.RemoveAt(0);
                    }
                    Controls.Remove(userReportMenu);
                    userReportMenu.Dispose();
                    userReportMenu = null;
                    GC.Collect();
                }
                //reorder it as backword
                Control[] myControls = new Control[Controls.Count];
                int       iCounter = 0, controlCount = Controls.Count;
                for (int iControl = 0; iControl < controlCount; iControl++)
                {
                    myControls[iCounter++] = Controls[0];
                    Controls.RemoveAt(0);
                }
                //add it back
                for (int iControl = 0; iControl < myControls.Length; iControl++)
                {
                    Controls.Add(myControls[iControl]);
                }


                menuStrip.ResumeLayout(false);
                ResumeLayout(true);
                PerformLayout();
                if (mCenter != null)
                {
                    mCenter.Dock = DockStyle.Fill;
                    mCenter.Refresh();
                }
                Refresh();
            }
            else
            {
                if (showCustomButtons) //RALLY DE 6239
                {
                    InitializeUserReport();
                }
            }
        }
예제 #14
0
        /// <summary>
        /// Constructor using given PropertyGridView and mode flags</summary>
        /// <param name="mode">The flags specifying the PropertyGrid's features and appearance</param>
        /// <param name="propertyGridView">The customized PropertyGridView</param>
        public PropertyGrid(PropertyGridMode mode, PropertyGridView propertyGridView)
        {
            m_propertyGridView                        = propertyGridView;
            m_propertyGridView.BackColor              = SystemColors.Window;
            m_propertyGridView.Dock                   = DockStyle.Fill;
            m_propertyGridView.EditingContextChanged += propertyGrid_EditingContextChanged;
            m_propertyGridView.MouseUp               += propertyGrid_MouseUp;
            m_propertyGridView.DragOver              += propertyGrid_DragOver;
            m_propertyGridView.DragDrop              += propertyGrid_DragDrop;
            m_propertyGridView.MouseHover            += propertyGrid_MouseHover;
            m_propertyGridView.MouseLeave            += propertyGrid_MouseLeave;
            m_propertyGridView.DescriptionSetter      = p =>
            {
                if (p != null)
                {
                    m_descriptionTextBox.SetDescription(p.DisplayName, p.Description);
                }
                else
                {
                    m_descriptionTextBox.ClearDescription();
                }
            };

            m_toolStrip           = new ToolStrip();
            m_toolStrip.GripStyle = ToolStripGripStyle.Hidden;
            m_toolStrip.Dock      = DockStyle.Top;

            if ((mode & PropertyGridMode.PropertySorting) != 0)
            {
                m_propertyOrganization             = new ToolStripDropDownButton(null, s_categoryImage);
                m_propertyOrganization.ToolTipText = "Property Organization".Localize(
                    "Could be rephrased as 'How do you want these properties to be organized?'");
                m_propertyOrganization.ImageTransparentColor = Color.Magenta;
                m_propertyOrganization.DropDownItemClicked  += organization_DropDownItemClicked;

                var item1 = new ToolStripMenuItem("Unsorted".Localize());
                item1.Tag = PropertySorting.None;

                var item2 = new ToolStripMenuItem("Alphabetical".Localize());
                item2.Tag = PropertySorting.Alphabetical;

                var item3 = new ToolStripMenuItem("Categorized".Localize());
                item3.Tag = PropertySorting.Categorized;

                var item4 = new ToolStripMenuItem("Categorized Alphabetical Properties".Localize());
                item4.Tag = PropertySorting.Categorized | PropertySorting.Alphabetical;

                var item5 = new ToolStripMenuItem("Alphabetical Categories".Localize());
                item5.Tag = PropertySorting.Categorized | PropertySorting.CategoryAlphabetical;

                var item6 = new ToolStripMenuItem("Alphabetical Categories And Properties".Localize());
                item6.Tag = PropertySorting.ByCategory;

                m_propertyOrganization.DropDownItems.Add(item1);
                m_propertyOrganization.DropDownItems.Add(item2);
                m_propertyOrganization.DropDownItems.Add(item3);
                m_propertyOrganization.DropDownItems.Add(item4);
                m_propertyOrganization.DropDownItems.Add(item5);
                m_propertyOrganization.DropDownItems.Add(item6);

                m_toolStrip.Items.Add(m_propertyOrganization);
                m_toolStrip.Items.Add(new ToolStripSeparator());
            }

            if ((mode & PropertyGridMode.DisableSearchControls) == 0)
            {
                var dropDownButton = new ToolStripDropDownButton();
                dropDownButton.DisplayStyle          = ToolStripItemDisplayStyle.Image;
                dropDownButton.Image                 = ResourceUtil.GetImage16(Resources.SearchImage);
                dropDownButton.ImageTransparentColor = System.Drawing.Color.Magenta;
                dropDownButton.Name = "PropertyGridSearchButton";
                dropDownButton.Size = new System.Drawing.Size(29, 22);
                dropDownButton.Text = "Search".Localize("'Search' is a verb");

                m_patternTextBox                         = new ToolStripAutoFitTextBox();
                m_patternTextBox.Name                    = "patternTextBox";
                m_patternTextBox.MaximumWidth            = 1080;
                m_patternTextBox.KeyUp                  += patternTextBox_KeyUp;
                m_patternTextBox.TextBox.PreviewKeyDown += patternTextBox_PreviewKeyDown;

                var clearSearchButton = new ToolStripButton();
                clearSearchButton.DisplayStyle       = ToolStripItemDisplayStyle.Image;
                clearSearchButton.Image              = ResourceUtil.GetImage16(Resources.DeleteImage);
                dropDownButton.ImageTransparentColor = System.Drawing.Color.Magenta;
                clearSearchButton.Name   = "PropertyGridClearSearchButton";
                clearSearchButton.Size   = new System.Drawing.Size(29, 22);
                clearSearchButton.Text   = "Clear Search".Localize("'Clear' is a verb");
                clearSearchButton.Click += clearSearchButton_Click;

                m_toolStrip.Items.AddRange(
                    new ToolStripItem[] {
                    dropDownButton,
                    m_patternTextBox,
                    clearSearchButton
                });
            }

            if ((mode & PropertyGridMode.HideResetAllButton) == 0)
            {
                // Reset all button.
                var resetAllButton = new ToolStripButton();
                resetAllButton.DisplayStyle          = ToolStripItemDisplayStyle.Image;
                resetAllButton.Image                 = ResourceUtil.GetImage16(Resources.ResetImage);
                resetAllButton.ImageTransparentColor = System.Drawing.Color.Magenta;
                resetAllButton.Name        = "PropertyGridResetAllButton";
                resetAllButton.Size        = new Size(29, 22);
                resetAllButton.ToolTipText = "Reset all properties".Localize();
                resetAllButton.Click      += (sender, e) =>
                {
                    ITransactionContext transaction = m_propertyGridView.EditingContext.As <ITransactionContext>();
                    transaction.DoTransaction(delegate
                    {
                        ResetAll();
                    },
                                              "Reset All Properties".Localize("'Reset' is a verb and this is the name of a command"));
                };
                m_toolStrip.Items.Add(resetAllButton);
            }

            if ((mode & PropertyGridMode.AllowEditingComposites) != 0)
            {
                m_navigateOut             = new ToolStripButton(null, s_navigateOutImage, navigateOut_Click);
                m_navigateOut.Enabled     = true;
                m_navigateOut.ToolTipText = "Navigate back to parent of selected object".Localize();

                m_toolStrip.Items.Add(m_navigateOut);

                m_propertyGridView.AllowEditingComposites = true;
            }

            SuspendLayout();

            if ((mode & PropertyGridMode.DisplayTooltips) != 0)
            {
                m_propertyGridView.AllowTooltips = true;
            }

            if ((mode & PropertyGridMode.DisplayDescriptions) == 0)
            {
                Controls.Add(m_propertyGridView);
            }
            else
            {
                m_splitContainer.Orientation   = Orientation.Horizontal;
                m_splitContainer.BackColor     = SystemColors.InactiveBorder;
                m_splitContainer.FixedPanel    = FixedPanel.Panel2;
                m_splitContainer.SplitterWidth = 8;
                m_splitContainer.Dock          = DockStyle.Fill;

                m_splitContainer.Panel1.Controls.Add(m_propertyGridView);

                m_descriptionTextBox           = new DescriptionControl(this);
                m_descriptionTextBox.BackColor = SystemColors.Window;
                m_descriptionTextBox.Dock      = DockStyle.Fill;

                m_splitContainer.Panel2.Controls.Add(m_descriptionTextBox);
                Controls.Add(m_splitContainer);

                m_propertyGridView.SelectedPropertyChanged += propertyGrid_SelectedRowChanged;
                m_descriptionTextBox.ClearDescription();
            }

            if (m_toolStrip.Items.Count > 0)
            {
                UpdateToolstripItems();
                Controls.Add(m_toolStrip);
            }
            else
            {
                m_toolStrip.Dispose();
                m_toolStrip = null;
            }

            Name         = "PropertyGrid";
            Font         = m_propertyGridView.Font;
            FontChanged += (sender, e) => m_propertyGridView.Font = Font;
            ResumeLayout(false);
            PerformLayout();
        }
예제 #15
0
        /// <summary>
        /// Initialize User Interface
        /// </summary>
        private void InitUI()
        {
            BIServerConnector           callback          = BIServerConnector.SharedInstance;
            Dictionary <string, string> extraInputMethods = new Dictionary <string, string>();
            Dictionary <string, string> outputFilters     = new Dictionary <string, string>();
            Dictionary <string, string> aroundFilters     = new Dictionary <string, string>();
            List <string> modulesSuppressedFromUI         = new List <string>();

            string currentInputMethod   = "";
            bool   useFullWidth         = true;
            bool   useSimplifiedChinese = false;
            bool   useEnglishKeyboard   = false;

            if (callback != null)
            {
                currentInputMethod = callback.stringValueForLoaderConfigKey("PrimaryInputMethod");
                if (currentInputMethod.Length == 0)
                {
                    currentInputMethod = callback.primaryInputMethod();
                }

                useSimplifiedChinese    = callback.isOutputFilterEnabled("ChineseCharacterConvertor-TC2SC");
                useFullWidth            = callback.isFullWidthCharacterMode();
                extraInputMethods       = callback.allInputMethodIdentifiersAndNames();
                outputFilters           = callback.allOutputFilterIdentifiersAndNames();
                aroundFilters           = callback.allAroundFilterIdentifiersAndNames();
                modulesSuppressedFromUI = callback.arrayValueForLoaderConfigKey("ModulesSuppressedFromUI");

                if (callback.isLoaderConfigKeyTrue("EnablesCapsLockAsAlphanumericModeToggle"))
                {
                    this.u_toolStrip.Items.Remove(u_toggleAlphanumericMode);
                }
            }

            // Load extra Input Method modules.

            this.u_toggleInputMethodDropDownMenu.Items.Clear();
            this.u_toggleInputMethodDropDownMenu.Items.AddRange(this.m_defualtInputMethodMenuItems);

            if (modulesSuppressedFromUI.Contains("SmartMandarin"))
            {
                this.u_toggleInputMethodDropDownMenu.Items.Remove(this.u_smartPhoneticToolStripMenuItem);
            }
            if (modulesSuppressedFromUI.Contains("TraditionalMandarins"))
            {
                this.u_toggleInputMethodDropDownMenu.Items.Remove(this.u_traditionalPhoneticToolStripMenuItem);
            }
            if (modulesSuppressedFromUI.Contains("Generic-cj-cin"))
            {
                this.u_toggleInputMethodDropDownMenu.Items.Remove(this.u_cangjieToolStripMenuItem);
            }
            if (modulesSuppressedFromUI.Contains("Generic-simplex-cin"))
            {
                this.u_toggleInputMethodDropDownMenu.Items.Remove(this.u_simplexToolStripMenuItem);
            }

            if (extraInputMethods.Count > 0)
            {
                ToolStrip               tempStrip = new ToolStrip();
                ToolStripItem[]         tempItems = new ToolStripItem[] { };
                ToolStripItemCollection genericInputMethodMenuItems = new ToolStripItemCollection(tempStrip, tempItems);

                foreach (KeyValuePair <string, string> genericInputMethod in extraInputMethods)
                {
                    string moduleID   = genericInputMethod.Key;
                    string moduleName = genericInputMethod.Value;

                    if (modulesSuppressedFromUI.Contains(moduleID))
                    {
                        continue;
                    }

                    System.Windows.Forms.ToolStripMenuItem newItem = new System.Windows.Forms.ToolStripMenuItem();

                    if (moduleID.Equals(currentInputMethod))
                    {
                        newItem.CheckState = CheckState.Checked;
                    }

                    newItem.AutoSize    = true;
                    newItem.Image       = global::BaseIMEUI.Properties.Resources.generic;
                    newItem.Name        = moduleID;
                    newItem.Text        = moduleName;
                    newItem.ToolTipText = moduleName;
                    newItem.TextAlign   = System.Drawing.ContentAlignment.MiddleLeft;
                    newItem.ImageAlign  = System.Drawing.ContentAlignment.MiddleLeft;
                    newItem.Click      += new System.EventHandler(this.SelectInputMethod);
                    genericInputMethodMenuItems.Add(newItem);
                }

                if (u_toggleInputMethodDropDownMenu.Items.Count > 0 && genericInputMethodMenuItems.Count > 0)
                {
                    this.u_toggleInputMethodDropDownMenu.Items.Add(new ToolStripSeparator());
                }
                if (genericInputMethodMenuItems.Count > 0)
                {
                    this.u_toggleInputMethodDropDownMenu.Items.AddRange(genericInputMethodMenuItems);
                }
                tempStrip.Dispose();
            }

            // Avoids that there is no input method in the menu.
            if (this.u_toggleInputMethodDropDownMenu.Items.Count == 0)
            {
                this.u_toggleInputMethodDropDownMenu.Items.Add(this.u_smartPhoneticToolStripMenuItem);
            }

            this.u_configsDropDownMenu.Items.Clear();

            // Loads Around Filters.
            if (aroundFilters.Count > 0)
            {
                foreach (KeyValuePair <string, string> aroundFilter in aroundFilters)
                {
                    string moduleID   = aroundFilter.Key;
                    string moduleName = aroundFilter.Value;

                    // Makes the search and evanuator module always enabled.
                    if (moduleID.Equals("OneKey") || moduleID.Equals("Evaluator"))
                    {
                        if (callback != null && !callback.isAroundFilterEnabled(moduleID))
                        {
                            callback.toggleAroundFilter(moduleID);
                        }
                        continue;
                    }
                    // Leaves the ReverseLookup Modules hidden.
                    if (moduleID.StartsWith("ReverseLookup"))
                    {
                        continue;
                    }

                    System.Windows.Forms.ToolStripMenuItem newItem = new System.Windows.Forms.ToolStripMenuItem();
                    newItem.AutoSize = true;
                    if (callback != null && callback.isAroundFilterEnabled(moduleID) == true)
                    {
                        newItem.Image   = global::BaseIMEUI.Properties.Resources.menuCheck;
                        newItem.Checked = true;
                    }
                    else
                    {
                        newItem.Image   = global::BaseIMEUI.Properties.Resources.menuUncheck;
                        newItem.Checked = false;
                    }
                    newItem.Name        = moduleID;
                    newItem.Text        = moduleName;
                    newItem.ToolTipText = moduleName;
                    newItem.TextAlign   = System.Drawing.ContentAlignment.MiddleLeft;
                    newItem.ImageAlign  = System.Drawing.ContentAlignment.MiddleLeft;
                    newItem.Click      += new System.EventHandler(this.aroundFilterToolStripMenuItem_Click);
                    this.u_configsDropDownMenu.Items.Add(newItem);
                }
                this.u_configsDropDownMenu.Items.Add(new ToolStripSeparator());
            }

            // Load Output Filters.

            if (outputFilters.Count > 0)
            {
                foreach (KeyValuePair <string, string> outputFilter in outputFilters)
                {
                    string ID   = outputFilter.Key;
                    string Name = outputFilter.Value;

                    System.Windows.Forms.ToolStripMenuItem newItem = new System.Windows.Forms.ToolStripMenuItem();
                    newItem.AutoSize = true;
                    if (callback != null && callback.isOutputFilterEnabled(ID) == true)
                    {
                        newItem.Image   = global::BaseIMEUI.Properties.Resources.menuCheck;
                        newItem.Checked = true;
                    }
                    else
                    {
                        newItem.Image   = global::BaseIMEUI.Properties.Resources.menuUncheck;
                        newItem.Checked = false;
                    }
                    newItem.Name        = ID;
                    newItem.Text        = Name;
                    newItem.ToolTipText = Name;
                    newItem.TextAlign   = System.Drawing.ContentAlignment.MiddleLeft;
                    newItem.ImageAlign  = System.Drawing.ContentAlignment.MiddleLeft;
                    newItem.Click      += new System.EventHandler(this.outputFilterToolStripMenuItem_Click);
                    u_configsDropDownMenu.Items.Add(newItem);
                }
                this.u_configsDropDownMenu.Items.Add(new ToolStripSeparator());
            }

            this.u_configsDropDownMenu.Items.AddRange(this.m_defualtConfigItems);

            #region Init the default input method

            ToolStripMenuItem targetItem = null;
            bool found = false;
            foreach (object item in this.u_toggleInputMethodDropDownMenu.Items)
            {
                if (item is ToolStripMenuItem)
                {
                    ToolStripMenuItem currentItem = (ToolStripMenuItem)item;
                    if (currentItem.Name.Equals(currentInputMethod))
                    {
                        found      = true;
                        targetItem = currentItem;
                        break;
                    }
                }
            }

            if (!found)
            {
                targetItem = (ToolStripMenuItem)this.u_toggleInputMethodDropDownMenu.Items[0];
            }

            if (targetItem != null)
            {
                this.u_toggleInputMethod.Image = targetItem.Image;
                this.u_toggleInputMethod.Text  = targetItem.Text;
                if (callback != null)
                {
                    callback.setPrimaryInputMethod(targetItem.Name, false);
                }
                targetItem.CheckState = CheckState.Checked;
            }

            #endregion

            if (useEnglishKeyboard == true)
            {
                this.u_toggleAlphanumericMode.Image = global::BaseIMEUI.Properties.Resources.english;
            }
            else
            {
                this.u_toggleAlphanumericMode.Image = global::BaseIMEUI.Properties.Resources.chinese;
            }

            if (useFullWidth == true)
            {
                this.u_toggleFullWidthCharacterMode.Image = global::BaseIMEUI.Properties.Resources.fullwidth;
            }
            else
            {
                this.u_toggleFullWidthCharacterMode.Image = global::BaseIMEUI.Properties.Resources.halfwidth;
            }

            if (useSimplifiedChinese == true)
            {
                this.u_toggleChineseCharacterConverter.Image = global::BaseIMEUI.Properties.Resources.zh_CN;
            }
            else
            {
                this.u_toggleChineseCharacterConverter.Image = global::BaseIMEUI.Properties.Resources.zh_TW;
            }
        }
예제 #16
0
 public void Dispose()
 {
     view.Items.Clear();
     view.Dispose();
 }
예제 #17
0
        /// <summary>
        /// Constructor</summary>
        /// <param name="mode">Flags specifiying the GridControl's features and appearance</param>
        /// <param name="gridView">The GridView to be used. Can be sub-classed to customize its behavior.</param>
        public GridControl(PropertyGridMode mode, GridView gridView)
        {
            m_gridView                          = gridView;
            m_gridView.BackColor                = SystemColors.Window;
            m_gridView.Dock                     = DockStyle.Fill;
            m_gridView.EditingContextChanged   += gridView_BindingChanged;
            m_gridView.MouseUp                 += gridView_MouseUp;
            m_gridView.DragOver                += gridView_DragOver;
            m_gridView.DragDrop                += gridView_DragDrop;
            m_gridView.MouseHover              += gridView_MouseHover;
            m_gridView.MouseLeave              += gridView_MouseLeave;
            m_gridView.SelectedPropertyChanged += gridView_SelectedPropertyChanged;

            m_toolStrip           = new ToolStrip();
            m_toolStrip.GripStyle = ToolStripGripStyle.Hidden;
            m_toolStrip.Dock      = DockStyle.Top;

            if ((mode & PropertyGridMode.PropertySorting) != 0)
            {
                m_propertyOrganization             = new ToolStripDropDownButton(null, s_categoryImage);
                m_propertyOrganization.ToolTipText = "Property Organization".Localize(
                    "Could be rephrased as 'How do you want these properties to be organized?'");
                //m_propertyOrganization.ImageTransparentColor = Color.Magenta;
                m_propertyOrganization.DropDownItemClicked += organization_DropDownItemClicked;

                ToolStripMenuItem item1 = new ToolStripMenuItem("Unsorted".Localize());
                item1.Tag = PropertySorting.None;

                ToolStripMenuItem item2 = new ToolStripMenuItem("Alphabetical".Localize());
                item2.Tag = PropertySorting.Alphabetical;

                ToolStripMenuItem item3 = new ToolStripMenuItem("Categorized".Localize());
                item3.Tag = PropertySorting.Categorized;

                ToolStripMenuItem item4 = new ToolStripMenuItem("Categorized Alphabetical Properties".Localize());
                item4.Tag = PropertySorting.Categorized | PropertySorting.Alphabetical;

                ToolStripMenuItem item5 = new ToolStripMenuItem("Alphabetical Categories".Localize());
                item5.Tag = PropertySorting.Categorized | PropertySorting.CategoryAlphabetical;

                ToolStripMenuItem item6 = new ToolStripMenuItem("Alphabetical Categories And Properties".Localize());
                item6.Tag = PropertySorting.ByCategory;

                m_propertyOrganization.DropDownItems.Add(item1);
                m_propertyOrganization.DropDownItems.Add(item2);
                m_propertyOrganization.DropDownItems.Add(item3);
                m_propertyOrganization.DropDownItems.Add(item4);
                m_propertyOrganization.DropDownItems.Add(item5);
                m_propertyOrganization.DropDownItems.Add(item6);

                m_toolStrip.Items.Add(m_propertyOrganization);
                m_toolStrip.Items.Add(new ToolStripSeparator());
            }

            if ((mode & PropertyGridMode.ShowHideProperties) != 0)
            {
                m_propertyShowHideButton             = new ToolStripButton(null, s_showHidePropertiesImage);
                m_propertyShowHideButton.ToolTipText = "Property Show / Hide".Localize();
                m_propertyShowHideButton.Click      += propertyShowHide_Click;
                m_toolStrip.Items.Add(m_propertyShowHideButton);
                m_toolStrip.Items.Add(new ToolStripSeparator());
            }

            if ((mode & PropertyGridMode.DisableDragDropColumnHeaders) != 0)
            {
                m_gridView.DragDropColumnsEnabed = false;
            }

            m_descriptionLabel              = new ToolStripAutoFitLabel();
            m_descriptionLabel.TextAlign    = ContentAlignment.TopLeft;
            m_descriptionLabel.MaximumWidth = 5000;
            m_toolStrip.Items.Add(m_descriptionLabel);

            SuspendLayout();

            Controls.Add(m_gridView);

            if (m_toolStrip.Items.Count > 0)
            {
                UpdateToolstripItems();
                Controls.Add(m_toolStrip);
            }
            else
            {
                m_toolStrip.Dispose();
                m_toolStrip = null;
            }
            Font = new Font("Segoe UI", 9.0f);

            ResumeLayout(false);
            PerformLayout();
        }