Example #1
0
        private void InsertToolStripItem(System.Type t)
        {
            IDesignerHost       host        = (IDesignerHost)this.serviceProvider.GetService(typeof(IDesignerHost));
            ToolStrip           parentTool  = this.ParentTool;
            int                 index       = parentTool.Items.IndexOf(this.currentItem);
            IDesigner           designer    = null;
            DesignerTransaction transaction = host.CreateTransaction(System.Design.SR.GetString("ToolStripAddingItem"));

            try
            {
                ToolStripDesigner._autoAddNewItems = false;
                IComponent component = host.CreateComponent(t);
                designer = host.GetDesigner(component);
                if (designer is ComponentDesigner)
                {
                    ((ComponentDesigner)designer).InitializeNewComponent(null);
                }
                if (((component is ToolStripButton) || (component is ToolStripSplitButton)) || (component is ToolStripDropDownButton))
                {
                    Image image = null;
                    try
                    {
                        image = new Bitmap(typeof(ToolStripButton), "blank.bmp");
                    }
                    catch (Exception exception)
                    {
                        if (System.Windows.Forms.ClientUtils.IsCriticalException(exception))
                        {
                            throw;
                        }
                    }
                    PropertyDescriptor descriptor = TypeDescriptor.GetProperties(component)["Image"];
                    if ((descriptor != null) && (image != null))
                    {
                        descriptor.SetValue(component, image);
                    }
                    PropertyDescriptor descriptor2 = TypeDescriptor.GetProperties(component)["DisplayStyle"];
                    if (descriptor2 != null)
                    {
                        descriptor2.SetValue(component, ToolStripItemDisplayStyle.Image);
                    }
                    PropertyDescriptor descriptor3 = TypeDescriptor.GetProperties(component)["ImageTransparentColor"];
                    if (descriptor3 != null)
                    {
                        descriptor3.SetValue(component, Color.Magenta);
                    }
                }
                parentTool.Items.Insert(index, (ToolStripItem)component);
                ISelectionService service = (ISelectionService)this.serviceProvider.GetService(typeof(ISelectionService));
                if (service != null)
                {
                    service.SetSelectedComponents(new object[] { component }, SelectionTypes.Replace);
                }
            }
            catch (Exception exception2)
            {
                if (transaction != null)
                {
                    transaction.Cancel();
                    transaction = null;
                }
                if (System.Windows.Forms.ClientUtils.IsCriticalException(exception2))
                {
                    throw;
                }
            }
            finally
            {
                if (transaction != null)
                {
                    transaction.Commit();
                    transaction = null;
                }
                ToolStripDesigner._autoAddNewItems = true;
                ToolStripDropDown down = parentTool as ToolStripDropDown;
                if ((down != null) && down.Visible)
                {
                    ToolStripDropDownItem ownerItem = down.OwnerItem as ToolStripDropDownItem;
                    if (ownerItem != null)
                    {
                        ToolStripMenuItemDesigner designer2 = host.GetDesigner(ownerItem) as ToolStripMenuItemDesigner;
                        if (designer2 != null)
                        {
                            designer2.ResetGlyphs(ownerItem);
                        }
                    }
                }
            }
        }
Example #2
0
 protected override void Menu_AppendPromptOne(ToolStripDropDown menu)
 {
 }
Example #3
0
 private static void ShowContextMenuBelow(ToolStripDropDown c, Control n) => c.Show(n.PointToScreen(new Point(0, n.Height)));
 /// <summary>
 /// Adds the additional items to the context menu of the component.
 /// </summary>
 /// <param name="menu"> The context menu of the component. </param>
 protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu)
 {
     Menu_AppendSeparator(menu);
     Menu_AppendItem(menu, "Documentation", MenuItemClickComponentDoc, Properties.Resources.WikiPage_MenuItem_Icon);
 }
Example #5
0
 protected override void Menu_AppendDestroyPersistent(ToolStripDropDown menu) =>
 Menu_AppendItem(menu, "Clear selection", Menu_DestroyPersistentData, PersistentDataCount > 0);
Example #6
0
 protected override void Menu_AppendExtractParameter(ToolStripDropDown menu)
 {
 }
        protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown iMenu)
        {
            ToolStripMenuItem item = GH_DocumentObject.Menu_AppendGenericMenuItem(iMenu, "New Random Configuration...", new EventHandler(this.Menu_NewRandomConfigClicked), null, null, true, false);

            item.Font = new Font(item.Font, FontStyle.Bold);
        }
Example #8
0
 protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu)
 {
     Menu_AppendItem(menu, "Source...", (object sender, EventArgs e) => OpenCsxSourceDialog());
     Menu_AppendItem(menu, "Debug...", (object sender, EventArgs e) => OpenCsxEditor());
 }
        protected override void Menu_AppendPromptOne(ToolStripDropDown menu)
        {
            if (SourceCount != 0)
            {
                return;
            }

            var elementTypesBox = new ListBox();

            elementTypesBox.BorderStyle           = BorderStyle.FixedSingle;
            elementTypesBox.Width                 = (int)(300 * GH_GraphicsUtil.UiScale);
            elementTypesBox.Height                = (int)(100 * GH_GraphicsUtil.UiScale);
            elementTypesBox.SelectedIndexChanged += ElementTypesBox_SelectedIndexChanged;
            elementTypesBox.Sorted                = true;

            var familiesBox = new ComboBox();

            familiesBox.DropDownStyle  = ComboBoxStyle.DropDownList;
            familiesBox.DropDownHeight = familiesBox.ItemHeight * 15;
            familiesBox.SetCueBanner("Family filter…");
            familiesBox.Width = (int)(300 * GH_GraphicsUtil.UiScale);

            var categoriesBox = new ComboBox();

            categoriesBox.DropDownStyle  = ComboBoxStyle.DropDownList;
            categoriesBox.DropDownHeight = categoriesBox.ItemHeight * 15;
            categoriesBox.SetCueBanner("Category filter…");
            categoriesBox.Width = (int)(300 * GH_GraphicsUtil.UiScale);

            familiesBox.Tag = Tuple.Create(elementTypesBox, categoriesBox);
            familiesBox.SelectedIndexChanged += FamiliesBox_SelectedIndexChanged;
            categoriesBox.Tag = Tuple.Create(elementTypesBox, familiesBox);
            categoriesBox.SelectedIndexChanged += CategoriesBox_SelectedIndexChanged;

            var categoriesTypeBox = new ComboBox();

            categoriesTypeBox.DropDownStyle         = ComboBoxStyle.DropDownList;
            categoriesTypeBox.Width                 = (int)(300 * GH_GraphicsUtil.UiScale);
            categoriesTypeBox.Tag                   = categoriesBox;
            categoriesTypeBox.SelectedIndexChanged += CategoryType_SelectedIndexChanged;
            categoriesTypeBox.Items.Add("All Categories");
            categoriesTypeBox.Items.Add("Model");
            categoriesTypeBox.Items.Add("Annotation");
            categoriesTypeBox.Items.Add("Tags");
            categoriesTypeBox.Items.Add("Internal");
            categoriesTypeBox.Items.Add("Analytical");

            if (Current is Types.ElementType current)
            {
                if (current.Category.Value.IsTagCategory)
                {
                    categoriesTypeBox.SelectedIndex = 3;
                }
                else
                {
                    categoriesTypeBox.SelectedIndex = (int)current.Category.Value.CategoryType;
                }

                var categoryIndex   = 0;
                var currentCategory = current.Category;
                foreach (var category in categoriesBox.Items.Cast <Types.Category>())
                {
                    if (currentCategory.Equals(category))
                    {
                        categoriesBox.SelectedIndex = categoryIndex;
                        break;
                    }
                    categoryIndex++;
                }

                var familyIndex = 0;
                foreach (var familyName in familiesBox.Items.Cast <string>())
                {
                    if (current.FamilyName == familyName)
                    {
                        familiesBox.SelectedIndex = familyIndex;
                        break;
                    }
                    familyIndex++;
                }
            }
            else
            {
                categoriesTypeBox.SelectedIndex = 0;
            }

            Menu_AppendCustomItem(menu, categoriesTypeBox);
            Menu_AppendCustomItem(menu, categoriesBox);
            Menu_AppendCustomItem(menu, familiesBox);
            Menu_AppendCustomItem(menu, elementTypesBox);
        }
Example #10
0
 public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
 {
     base.AppendAdditionalMenuItems(menu);
     this.Menu_AppendConnect(menu, Menu_Connect);
 }
Example #11
0
 protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu)
 {
     Utility.SetMenuList(this, menu, "", () => StartPointType, o => StartPointType = o);
 }
Example #12
0
 protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu)
 {
     Menu_AppendItem(menu, "Match outputs", Menu_AutoCreateOutputs_Clicked);
     Menu_AppendItem(menu, "Lock Outputs", Menu_LockOutputs_Clicked, true, StructureLocked);
     base.AppendAdditionalComponentMenuItems(menu);
 }
        public static void Menu_AppendConnect(this IGH_Param param, ToolStripDropDown menu, EventHandler eventHandler)
        {
            if ((param.Kind == GH_ParamKind.floating || param.Kind == GH_ParamKind.output) && param.Recipients.Count == 0)
            {
                var components = new List <IGH_Component>();
                var paramType  = param.Type;

                foreach (var proxy in Instances.ComponentServer.ObjectProxies.Where(x => !x.Obsolete && x.Kind == GH_ObjectType.CompiledObject && x.Exposure != GH_Exposure.hidden && x.Exposure < GH_Exposure.tertiary))
                {
                    if (typeof(IGH_Component).IsAssignableFrom(proxy.Type))
                    {
                        try
                        {
                            if (proxy.CreateInstance() is IGH_Component compoennt)
                            {
                                foreach (var input in compoennt.Params.Input)
                                {
                                    if (input.Type == typeof(IGH_Goo) || input.Type == typeof(IGH_GeometricGoo))
                                    {
                                        continue;
                                    }

                                    if (input.GetType() == param.GetType() || input.Type.IsAssignableFrom(paramType))
                                    {
                                        components.Add(compoennt);
                                        break;
                                    }
                                }
                            }
                        }
                        catch { }
                    }
                }

                var connect = GH_DocumentObject.Menu_AppendItem(menu, "Connect") as ToolStripMenuItem;

                var panedComponentId = new Guid("{59E0B89A-E487-49f8-BAB8-B5BAB16BE14C}");
                var panel            = GH_DocumentObject.Menu_AppendItem(connect.DropDown, "Panel", eventHandler, Instances.ComponentServer.EmitObjectIcon(panedComponentId));
                panel.Tag = panedComponentId;

                var valueSetComponentId = new Guid("{AFB12752-3ACB-4ACF-8102-16982A69CDAE}");
                var picker = GH_DocumentObject.Menu_AppendItem(connect.DropDown, "Value Set Picker", eventHandler, Instances.ComponentServer.EmitObjectIcon(valueSetComponentId));
                picker.Tag = valueSetComponentId;

                if (components.Count > 0)
                {
                    GH_DocumentObject.Menu_AppendSeparator(connect.DropDown);
                    var maxComponents = CentralSettings.CanvasMaxSearchResults;
                    maxComponents = Math.Min(maxComponents, 30);
                    maxComponents = Math.Max(maxComponents, 3);

                    int count = 0;
                    foreach (var componentGroup in components.GroupBy(x => x.Exposure).OrderBy(x => x.Key))
                    {
                        foreach (var component in componentGroup.OrderBy(x => x.Category).OrderBy(x => x.SubCategory).OrderBy(x => x.Name))
                        {
                            var item = GH_DocumentObject.Menu_AppendItem(connect.DropDown, component.Name, eventHandler, component.Icon_24x24);
                            item.Tag = component.ComponentGuid;

                            if (count >= maxComponents)
                            {
                                break;
                            }
                        }

                        if (count >= maxComponents)
                        {
                            break;
                        }
                    }
                }
            }
        }
 protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu)
 {
     GH_DocumentObject.Menu_AppendItem(menu, $"Lock All JSwan {Type.ToString()} Components", LockAllJSwan_Clicked, true, false);
     base.AppendAdditionalComponentMenuItems(menu);
 }
Example #15
0
        protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu)
        {
            ToolStripMenuItem mm = Menu_AppendItem(menu, "Make default file", item1_Clicked);

            mm.ToolTipText = "Lets you dave a flex parameter file the default values to your drive, so you can just make changes to the default values.";
        }
Example #16
0
 protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu)
 {
     Menu_AppendItem(menu, "Use Clamp", (_, __) => UseClamp = !UseClamp, true, UseClamp);
 }
Example #17
0
        protected override void Menu_AppendPromptOne(ToolStripDropDown menu)
        {
            if (SourceCount != 0)
            {
                return;
            }

            var listBox = new ListBox();

            listBox.BorderStyle           = BorderStyle.FixedSingle;
            listBox.Width                 = (int)(200 * GH_GraphicsUtil.UiScale);
            listBox.Height                = (int)(100 * GH_GraphicsUtil.UiScale);
            listBox.SelectedIndexChanged += ListBox_SelectedIndexChanged;
            listBox.Sorted                = true;

            var viewTypeBox = new ComboBox();

            viewTypeBox.DropDownStyle         = ComboBoxStyle.DropDownList;
            viewTypeBox.Width                 = (int)(200 * GH_GraphicsUtil.UiScale);
            viewTypeBox.Tag                   = listBox;
            viewTypeBox.SelectedIndexChanged += ViewTypeBox_SelectedIndexChanged;
            viewTypeBox.SetCueBanner("View type filter…");

            using (var collector = new DB.FilteredElementCollector(Revit.ActiveUIDocument.Document))
            {
                listBox.Items.Clear();

                var views = collector.
                            OfClass(typeof(DB.View)).
                            Cast <DB.View>().
                            Where(x => !x.IsTemplate).
                            GroupBy(x => x.Document.GetElement <DB.ViewFamilyType>(x.GetTypeId())?.ViewFamily ?? DB.ViewFamily.Invalid);

                viewTypeBox.DisplayMember = "Text";
                foreach (var view in views)
                {
                    if (view.Key != DB.ViewFamily.Invalid)
                    {
                        viewTypeBox.Items.Add(new Types.ViewFamily(view.Key));
                    }
                }

                if (Current?.APIView is DB.View current)
                {
                    var familyIndex = 0;
                    foreach (var viewFamily in viewTypeBox.Items.Cast <Types.ViewFamily>())
                    {
                        var type = current.Document.GetElement <DB.ViewFamilyType>(current.GetTypeId());
                        if (type.ViewFamily == viewFamily.Value)
                        {
                            viewTypeBox.SelectedIndex = familyIndex;
                            break;
                        }
                        familyIndex++;
                    }
                }
                else
                {
                    RefreshViewsList(listBox, DB.ViewFamily.Invalid);
                }
            }

            Menu_AppendCustomItem(menu, viewTypeBox);
            Menu_AppendCustomItem(menu, listBox);
        }
Example #18
0
 protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu)
 {
     GH_DocumentObject.Menu_AppendItem(menu, "ShowGraphOnThis", Menu_OutPutClicked, enabled: true, GetValue("ShowGraphOnThis", @default: true)).ToolTipText      = "When checked, it will show the graph on this component.";
     GH_DocumentObject.Menu_AppendItem(menu, "ShowGraphOnSlider", Menu_OutPutClicked2, enabled: true, GetValue("ShowGraphOnSlider", @default: true)).ToolTipText = "When checked, it will show the graph on slider component.";
     GH_DocumentObject.Menu_AppendItem(menu, "ClearRamData", Menu_OutPutClicked3, enabled: true, GetValue("ClearRamData", @default: false)).ToolTipText          = "When checked, it will show the graph on slider component.";
 }
Example #19
0
 public virtual void AppendAdditionalElementMenuItems(ToolStripDropDown menu)
 {
 }
Example #20
0
 protected override void Menu_AppendInternaliseData(ToolStripDropDown menu) =>
 Menu_AppendItem(menu, "Internalise selection", Menu_InternaliseDataClicked, SourceCount > 0);
Example #21
0
        /*
         * protected internal override void Paint(Graphics gr)
         * {
         * if (MouseIsOver && m_Grid.ColumnResizeAllowed &&  m_Grid.m_RepositioningColumn==null)
         *  using(var br =  new LinearGradientBrush(Region, Color.Blue, Color.White, LinearGradientMode.ForwardDiagonal))
         *  {
         *    gr.FillRectangle(br, Region);
         *  }
         * }
         */

        protected internal override void OnMouseClick(MouseEventArgs e)
        {
            // Right click on the right edge of a column - open the column picker
            if (e.Button == MouseButtons.Right)
            {
                if (!m_Grid.Columns.Any() || !m_Grid.ColumnHidingAllowed)
                {
                    return;
                }

                var longestText     = new string('W', m_Grid.Columns.Max(c => c.Title.Length));
                var textSize        = TextRenderer.MeasureText(longestText, m_Grid.Font);
                int preferredHeight = (m_Grid.Columns.Count * textSize.Height) + 7;
                var checkedListBox  = new CheckedListBox()
                {
                    CheckOnClick = true,
                    Height       = (preferredHeight < 350) ? preferredHeight : 350,
                    Width        = Math.Min(textSize.Width, m_Grid.Width),
                };
                checkedListBox.ItemCheck += (sender, ea) =>
                {
                    var column = m_Grid.Columns.FirstOrDefault(c => c.Title.Equals(checkedListBox.Items[ea.Index].ToString()));
                    if (column == null)
                    {
                        return;
                    }
                    if (m_Grid.Columns.Count(c => c.Visible) > 1 || ea.NewValue == CheckState.Checked)
                    {
                        column.Visible = ea.NewValue == CheckState.Checked;
                    }
                    else
                    {
                        ea.NewValue = ea.CurrentValue;
                    }
                };

                foreach (var c in m_Grid.Columns)
                {
                    checkedListBox.Items.Add(c.Title, c.Visible);
                }

                var controlHost = new ToolStripControlHost(checkedListBox)
                {
                    Padding  = Padding.Empty,
                    Margin   = Padding.Empty,
                    AutoSize = false
                };

                // The following permits handling of custom actions such as applying themes
                // to the newly created control:
                m_Grid.Controls.Add(checkedListBox);

                var popup = new ToolStripDropDown()
                {
                    Padding = Padding.Empty
                };
                popup.Items.Add(controlHost);
                popup.Disposed += (sender, args) => m_Grid.Controls.Remove(checkedListBox); // This removes checkedListBox from m_Grid.Controls

                popup.Show(m_Grid.PointToScreen(e.Location));
            }

            base.OnMouseClick(e);
        }
Example #22
0
        protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu)
        {
            ToolStripMenuItem item = Menu_AppendItem(menu, "Massive Refinement", Menu_MassivePreviewClicked, true, MassiveRefinement);

            item.ToolTipText = "CAUTION: When checked, disable the imposed limit of minimum element-size.\nNote that setting a too small element-size might lead to over-refinements which can radically increase the computational time of the meshing process.";
        }
 public ContextMenuStripActionList(ToolStripDropDownDesigner designer) : base(designer.Component)
 {
     _toolStripDropDown = (ToolStripDropDown)designer.Component;
 }
Example #24
0
 public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
 {
     //Menu_AppendItem(menu, "Set the default value", SetDefaultHandler, SourceCount == 0);
     base.AppendAdditionalMenuItems(menu);
 }
        protected override void AppendAdditionalComponentMenuItems(ToolStripDropDown menu)
        {
            Menu_AppendItem(menu, "Try Rotate Boundary", Menu_TryRotateBoundaryClick, true, tryRotateBoundary);

            base.AppendAdditionalComponentMenuItems(menu);
        }
Example #26
0
 public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
 {
     base.AppendAdditionalMenuItems(menu);
     Menu_AppendSeparator(menu);
     Menu_AppendItem(menu, "Titles", TitleMode, true, HasTitle);
 }
Example #27
0
        public void ToolStripDropDown_Constructor()
        {
            var tsdd = new ToolStripDropDown();

            Assert.NotNull(tsdd);
        }
Example #28
0
 public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
 {
     base.AppendAdditionalMenuItems(menu);
     Menu_AppendItem(menu, "Invert selection", Menu_InvertSelectionClicked, SourceCount > 0);
     Menu_AppendItem(menu, "Select all", Menu_SelectAllClicked, SourceCount > 0);
 }
Example #29
0
 public override void AppendAdditionalElementMenuItems(ToolStripDropDown menu)
 {
     base.AppendAdditionalElementMenuItems(menu);
     Menu_AppendItem(menu, $"Highlight {GH_Convert.ToPlural(TypeName)}", Menu_HighlightElements, !VolatileData.IsEmpty, false);
 }
 // Constructors
 public ToolStripDropDownAccessibleObject(ToolStripDropDown owner)
 {
 }
        private void StopRecording()
        {
            Cursor = Cursors.WaitCursor;

            try
            {
                _capturingThread.Interrupt();
                _capturingThread.Join();
            }
            finally
            {
                Cursor = Cursors.Default;
            }

            _recording = false;

            if (!tsbRecord.Enabled)
            {
                tsbRecordWithCam.ShowDropDownArrow = true;
                tsbRecordWithCam.DropDown          = _dropDownItems;
                tsbRecordWithCam.Image             = Resources.record_cam;
                tsbRecordWithCam.Text = "Record with webcam";
                _dropDownItems        = null;
                tsbRecord.Enabled     = true;
            }
            else
            {
                tsbRecord.ShowDropDownArrow = true;
                tsbRecord.DropDown          = _dropDownItems;
                tsbRecord.Image             = Resources.record;
                tsbRecord.Text           = "Record";
                _dropDownItems           = null;
                tsbRecordWithCam.Enabled = true;
            }

            UnregisterHotKey(Handle, MYKEYID);
            WindowState = FormWindowState.Normal;
            SetForegroundWindow(Handle);

            if (_capturingThreadData.Result != 0)
            {
                statusBar.Items[0].Text = "Recording failed";
                MessageBox.Show("Capturing failed.\n\nError: " + _capturingThreadData.ErrorText);
            }
            else
            {
                SaveFileDialog dlg = new SaveFileDialog();

                if (Program.Cfg.SelectedVideoCodecTab == 0)
                {
                    dlg.DefaultExt = "*.wmv";
                    dlg.Filter     = "WMV files (*.wmv)|*.wmv|All files (*.*)|*.*";
                }
                else
                {
                    dlg.DefaultExt = "*.avi";
                    dlg.Filter     = "AVI files (*.avi)|*.avi|All files (*.*)|*.*";
                }

                dlg.FileName         = "Screencast" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
                dlg.Title            = "Save captured video as";
                dlg.InitialDirectory = Program.Cfg.LastUsedFolder;

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    File.Copy(_capturingThreadData.TempFile, dlg.FileName, true);

                    _lastRecordedFile          = dlg.FileName;
                    statusBar.Items[0].Text    = "Successfully recorded \"" + Path.GetFileName(dlg.FileName) + "\"";
                    tsbPlay.Enabled            = File.Exists(_lastRecordedFile);
                    Program.Cfg.LastUsedFolder = Path.GetDirectoryName(dlg.FileName);

                    // open saved video file in the default media player
                    Process.Start(dlg.FileName);
                }
                else
                {
                    statusBar.Items[0].Text = "Canceled";
                }

                try
                {
                    File.Delete(_capturingThreadData.TempFile);
                }
                catch
                {
                }
            }
        }