internal RibbonDropDown(
     RibbonItem parentItem,
     IEnumerable<RibbonItem> items,
     Controls.Ribbon.Ribbon ownerRibbon)
     : this(parentItem, items, ownerRibbon, RibbonElementSizeMode.DropDown)
 {
 }
        internal RibbonDropDown(
            RibbonItem parentItem, 
            IEnumerable<RibbonItem> items, 
            Controls.Ribbon.Ribbon ownerRibbon,
            RibbonElementSizeMode measuringSize)
            : this()
        {
            _items = items;
            _ownerRibbon = ownerRibbon;
            SizingGripHeight = 12;
            _parentItem = parentItem;
            _sensor = new RibbonSensor(this, OwnerRibbon, items);
            MeasuringSize = measuringSize;

            if (Items != null)
                foreach (RibbonItem item in Items)
                {
                    item.SetSizeMode(RibbonElementSizeMode.DropDown);
                    item.SetCanvas(this);
                }

            UpdateSize();
            UpdateItemsBounds();
        }
 private void RedrawItem(RibbonItem item)
 {
     RedrawItem(item, Rectangle.Empty);
 }
예제 #4
0
        private void flexDesigner_CreateField(object sender, C1.Win.FlexReport.CreateFieldEventArgs e)
        {
            // NOTE: currently add field buttons are used as the keys for inserting fields,
            // i.e. button.Tag/Action are not used. Might want to change that.

            RibbonItem btn      = e.CreateFieldInfo as RibbonItem;
            FieldBase  newField = null;
            string     fldName  = GetUniqueFieldName();

            Action <FieldBase> setFieldBaseProps = (field_) =>
            {
                field_.Name   = fldName;
                field_.Left   = e.FieldBounds.Left;
                field_.Top    = e.FieldBounds.Top;
                field_.Width  = e.FieldBounds.Width;
                field_.Height = e.FieldBounds.Height;
            };

            // Select field type, create field:
            if (btn == rbtnFieldDataField)
            {
                TextField textField = new TextField();
                setFieldBaseProps(textField);
                e.SubSection.Fields.Add(textField);
                newField       = textField;
                textField.Text = _createInfo != null ? ("=" + _createInfo) : string.Empty;
            }
            else if (btn == rbtnFieldCalculated)
            {
                TextField calcField = new TextField();
                setFieldBaseProps(calcField);
                e.SubSection.Fields.Add(calcField);
                CommonFields.SetupField(_flexDesigner.Report, calcField, _createInfo);
                newField = calcField;
            }
            else if (btn == rbtnFieldParagraph)
            {
                ParagraphField paraField = new ParagraphField();
                setFieldBaseProps(paraField);
                e.SubSection.Fields.Add(paraField);
                newField = paraField;
                paraField.Content.Add(_createInfo != null ? ("=" + _createInfo) : string.Empty);
            }
            else if (btn == rbtnFieldRtf)
            {
                RtfField rtfField = new RtfField();
                setFieldBaseProps(rtfField);
                e.SubSection.Fields.Add(rtfField);
                newField      = rtfField;
                rtfField.Text = _createInfo != null ? ("=" + _createInfo) : string.Empty;
            }
            else if (btn == rbtnFieldCheckBox)
            {
                CheckBoxField cbField = new CheckBoxField();
                setFieldBaseProps(cbField);
                e.SubSection.Fields.Add(cbField);
                if (_createInfo != null)
                {
                    cbField.Value = "=" + _createInfo;
                    cbField.Text  = _createInfo;
                }
                newField = cbField;
            }
            else if (btn == rbtnFieldChart)
            {
                ChartField chartField = new ChartField();
                setFieldBaseProps(chartField);
                e.SubSection.Fields.Add(chartField);
                newField = chartField;
            }
#if MAP
            else if (btn == rbtnFieldMap)
            {
                var mapField = new MapField();
                setFieldBaseProps(mapField);
                e.SubSection.Fields.Add(mapField);
                mapField.InitLayout();
                newField = mapField;
            }
#endif
            else if (btn == rbtnFieldBarCode)
            {
                BarCodeField barcodeField = new BarCodeField();
                setFieldBaseProps(barcodeField);
                e.SubSection.Fields.Add(barcodeField);
                barcodeField.Text = _createInfo != null ? ("=" + _createInfo) : "BARCODE";
                // barcodeField.BarCode = C1.Win.C1Document.BarCodeEnum.Code39x; // this was set as default in C1Report designer
                newField = barcodeField;
            }
            else if (btn == rbtnFieldPicture)
            {
                ImageField imageField = new ImageField();
                setFieldBaseProps(imageField);
                e.SubSection.Fields.Add(imageField);
                imageField.Picture = _createInfo;
                newField           = imageField;
            }
            else if (btn == rbtnFieldShape)
            {
                ShapeField shapeField = new ShapeField();
                setFieldBaseProps(shapeField);
                e.SubSection.Fields.Add(shapeField);
                newField = shapeField;
            }
            else if (btn == rbtnFieldSubReport)
            {
                SubreportField subreportField = new SubreportField();
                setFieldBaseProps(subreportField);
                e.SubSection.Fields.Add(subreportField);
                foreach (ReportItem ri in _reportList.Items)
                {
                    if (ri.ToString() == _createInfo && ri.Report != _flexDesigner.Report)
                    {
                        subreportField.Subreport = ri.Report;
                        break;
                    }
                }
                newField = subreportField;
            }
            else if (btn == rbtnFieldLegacy)
            {
                Field legacyField = new Field();
                setFieldBaseProps(legacyField);
                e.SubSection.Fields.Add(legacyField);
                newField = legacyField;
            }
            else if (btn == rbtnFieldFlexChart)
            {
                FlexChartField flexChartField = new FlexChartField();
                setFieldBaseProps(flexChartField);
                flexChartField.Series.Add(new C1.Win.FlexReport.FlexChart.Series()
                {
                    Name        = "DefaultSeries",
                    Label       = "Count",
                    YExpression = "Count()"
                });
                e.SubSection.Fields.Add(flexChartField);
                newField = flexChartField;
            }
            else if (btn.Tag is Field) // custom field
            {
                Field customField = (Field)btn.Tag;
                setFieldBaseProps(customField);
                e.SubSection.Fields.Add(customField);
                newField = customField;
            }
            // else if (btn == rbtnFieldPageBreak) ....
            else
            {
                System.Diagnostics.Debug.Assert(false, "unknown field insert op");
            }

            // select the new field, zap creator
            _flexDesigner.UpdateFromReport();
            _flexDesigner.SelectField(newField, true, true);
            _flexDesigner.CreateFieldInfo = null;
            UpdateCreateFieldButtons(rbtnFieldArrow);
            UpdateUI(false);

            // update report list icons
            if (btn == rbtnFieldSubReport)
            {
                _reportList.UpdateIcons();
            }
        }
예제 #5
0
        private void LoadThumbnails()
        {
            RemoveThumbnails();

            int step = picBoxClone.Width;
            int space = 5;
            int i = 0;
            int count = 0;

            for( int k = firstIndex; k < thumbNails.Count; k++)
            {
                Image t = thumbNails[k];

                RibbonItem newPicBox = new RibbonItem();
                newPicBox.Width = picBoxClone.Width;
                newPicBox.Height = picBoxClone.Height;
                newPicBox.BackColor = picBoxClone.BackColor;
                newPicBox.Image = t;

                this.mainRibbonGroup.Controls.Add(newPicBox);
                newPicBox.Location = new Point(30 + i, 4);
                newPicBox.MouseEnter += new EventHandler(newPicBox_MouseEnter);
                newPicBox.MouseLeave += new EventHandler(newPicBox_MouseLeave);
                this.toolTip1.SetToolTip(newPicBox, (string)files[k]);
                newPicBox.Click += new EventHandler(newPicBox_Click);
                
                newPicBox.Cursor = Cursors.Hand;
                newPicBox.Tag = k;

                i += (step + space);
                count++;

                int temp = (count + 1) * ( step + space ) + 60;
                if (temp > this.mainRibbonGroup.Width)
                {
                    lastIndex = count + firstIndex;
                    break;                     
                }
            }
        }
예제 #6
0
파일: App.cs 프로젝트: samuto/Lyrebird
 public void Enable()
 {
     RibbonButton rbutton = serverButton as RibbonButton;
     if (!rbutton.Enabled)
     {
         if (serverActive)
         {
             BitmapSource bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_On.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
             if (rbutton != null)
             {
                 rbutton.LargeImage = bms;
                 rbutton.ItemText = "Lyrebird\nServer On";
                 rbutton.ToolTip = "The Lyrebird Server currently on and will accept requests for data and can create objects.  Push button to toggle the server off.";
                 rbutton.Enabled = true;
                 serverButton = rbutton;
             }
             StartServer();
         }
         else
         {
             BitmapSource bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_On.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
             if (rbutton != null)
             {
                 rbutton.LargeImage = bms;
                 rbutton.ItemText = "Lyrebird\nServer Off";
                 rbutton.ToolTip = "The Lyrebird Server is currently off and will not accept requests for data or create objects.  Push button to toggle the server on.";
                 rbutton.Enabled = true;
                 serverButton = rbutton;
             }
             StopServer();
         }
     }
     Toggle();
     Toggle();
 }
예제 #7
0
파일: App.cs 프로젝트: samuto/Lyrebird
 public void Toggle()
 {
     if (serverActive)
     {
         serverActive = false;
         RibbonButton button = serverButton as RibbonButton;
         BitmapSource bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Off.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
         if (button != null)
         {
             button.LargeImage = bms;
             button.ItemText = "Lyrebird\nServer Off";
             button.ToolTip = "The Lyrebird Server is currently off and will not accept requests for data or create objects.  Push button to toggle the server on.";
             serverButton = button;
         }
         StopServer();
         //ServiceOff();
     }
     else
     {
         serverActive = true;
         RibbonButton rbutton = serverButton as RibbonButton;
         BitmapSource bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_On.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
         if (rbutton != null)
         {
             rbutton.LargeImage = bms;
             rbutton.ItemText = "Lyrebird\nServer On";
             rbutton.ToolTip = "The Lyrebird Server currently on and will accept requests for data and can create objects.  Push button to toggle the server off.";
             serverButton = rbutton;
         }
         StartServer();
         //ServiceOn();
     }
     //Properties.Settings.Default.serverActive = serverActive;
     //Properties.Settings.Default.Save();
 }
 /// <summary>
 /// Sets the value of the <see cref="OwnerItem"/> property
 /// </summary>
 /// <param name="item"></param>
 internal virtual void SetOwnerItem(RibbonItem item)
 {
     _ownerItem = item;
 }
        /// <summary>
        /// Selects the specified item as the currently selected sub-item
        /// </summary>
        /// <param name="item"></param>
        private void SetSelectedSubItem(RibbonItem item)
        {
            if (item == _lastSelectedSubItem) return;

            if (_lastSelectedSubItem != null)
            {
                _lastSelectedSubItem.SetSelected(false);
                RedrawItem(_lastSelectedSubItem, GetContentBounds(_lastSelectedSubItemParent));
            }

            if (item != null)
            {
                item.SetSelected(true);
                RedrawItem(item, GetContentBounds(_lastSelectedSubItemParent));
            }

            _lastSelectedSubItem = item;
        }
예제 #10
0
        private void LoadPresetImages( string dir)
        {
            try
            {
                for (int i = 0; i < presetGallery.Controls.Count; i++)
                {
                    Control x = presetGallery.Controls[i];
                    presetGallery.Controls.RemoveAt(i);
                    i--;
                    x.Dispose();
                }

                string[] files = Directory.GetFiles(dir, "*.pre");

                foreach (string file in files)
                {
                    RibbonItem preset = new RibbonItem();
                    preset.Click += new EventHandler(preset_Click);
                    try
                    {
                        preset.Image = ReadPreset(file);
                    }
                    catch { }
                    preset.IsPressed = false;
                    preset.Tag = file;
                    preset.Cursor = Cursors.Hand;
                    toolTip1.SetToolTip(preset, Path.GetFileNameWithoutExtension(file));
                    presetGallery.Controls.Add(preset);
                }
            }
            catch { }
        }
예제 #11
0
        private void SavePreset()
        {
            SaveFileDialog saveDialog = new SaveFileDialog();
            saveDialog.AddExtension = true;
            saveDialog.DefaultExt = ".pre";
            saveDialog.Filter = "NuGenImageWorks Presets | *.pre";

            DialogResult res = saveDialog.ShowDialog();

            if (res != DialogResult.OK)
                return;

            Application.DoEvents();

            BinaryWriter wr = null;

            try
            {
                wr = new BinaryWriter(File.Open(saveDialog.FileName, FileMode.OpenOrCreate, FileAccess.Write));
            }
            catch { return; }

            wr.Write("Version." + Application.ProductVersion + Environment.NewLine);

            wr.Write(ribbonTrackAtm1.Value);
            wr.Write(ribbonTrackAtm2.Value);
            wr.Write(ribbonTrackAtm3.Value);
            wr.Write(ribbonTrackAtm4.Value);
            wr.Write(ribbonTrackAtm5.Value);
            wr.Write(ribbonTrackAtm6.Value);
            wr.Write(ribbonTrackAtm7.Value);
            wr.Write(ribbonTrackAtm8.Value);
            wr.Write(ribbonTrackAtm9.Value);
            wr.Write(ribbonTrackAtm10.Value);
            wr.Write(ribbonTrackAtm11.Value);
            wr.Write(ribbonTrackAtm12.Value);
            wr.Write(ribbonTrackAtm13.Value);
            wr.Write(ribbonTrackAtm14.Value);
            wr.Write(ribbonTrackAtm15.Value);
            wr.Write(ribbonTrackAtm16.Value);
            wr.Write(ribbonTrackAtm17.Value);
            wr.Write(ribbonTrackAtm18.Value);



            wr.Write(ribbonTrackEnhance1.Value);
            wr.Write(ribbonTrackEnhance2.Value);
            wr.Write(ribbonTrackEnhance3.Value);
            wr.Write(ribbonTrackEnhance4.Value);
            wr.Write(ribbonTrackEnhance5.Value);
            wr.Write(ribbonTrackEnhance6.Value);



            wr.Write(ribbonTrackFilm1.Value);
            wr.Write(ribbonTrackFilm2.Value);
            wr.Write(ribbonTrackFilm3.Value);
            wr.Write(ribbonTrackFilm4.Value);



            wr.Write(ribbonTrackGain1.Value);
            wr.Write(ribbonTrackGain2.Value);
            wr.Write(ribbonTrackGain3.Value);
            wr.Write(ribbonTrackGain4.Value);
            wr.Write(ribbonTrackGain5.Value);
            wr.Write(ribbonTrackGain6.Value);
            wr.Write(ribbonTrackGain7.Value);
            wr.Write(ribbonTrackGain8.Value);
            wr.Write(ribbonTrackGain9.Value);
            wr.Write(ribbonTrackGain10.Value);
            wr.Write(ribbonTrackGain11.Value);
            wr.Write(ribbonTrackGain12.Value);
            wr.Write(ribbonTrackGain13.Value);
            wr.Write(ribbonTrackGain14.Value);
            wr.Write(ribbonTrackGain15.Value);
            wr.Write(ribbonTrackGain16.Value);
            wr.Write(ribbonTrackGain17.Value);
            wr.Write(ribbonTrackGain18.Value);



            wr.Write(ribbonTrackGamma1.Value);
            wr.Write(ribbonTrackGamma2.Value);
            wr.Write(ribbonTrackGamma3.Value);
            wr.Write(ribbonTrackGamma4.Value);
            wr.Write(ribbonTrackGamma5.Value);
            wr.Write(ribbonTrackGamma6.Value);
            wr.Write(ribbonTrackGamma7.Value);
            wr.Write(ribbonTrackGamma8.Value);
            wr.Write(ribbonTrackGamma9.Value);
            wr.Write(ribbonTrackGamma10.Value);
            wr.Write(ribbonTrackGamma11.Value);
            wr.Write(ribbonTrackGamma12.Value);
            wr.Write(ribbonTrackGamma13.Value);
            wr.Write(ribbonTrackGamma14.Value);
            wr.Write(ribbonTrackGamma15.Value);
            wr.Write(ribbonTrackGamma16.Value);
            wr.Write(ribbonTrackGamma17.Value);
            wr.Write(ribbonTrackGamma18.Value);



            wr.Write(ribbonTrackLens1.Value);
            wr.Write(ribbonTrackLens2.Value);
            wr.Write(ribbonTrackLens3.Value);
            wr.Write(ribbonTrackLens4.Value);
            wr.Write(ribbonTrackLens5.Value);
            wr.Write(ribbonTrackLens6.Value);
            wr.Write(ribbonTrackLens7.Value);
            wr.Write(ribbonTrackLens8.Value);
            wr.Write(ribbonTrackLens9.Value);
            wr.Write(ribbonTrackLens10.Value);
            wr.Write(ribbonTrackLens11.Value);
            wr.Write(ribbonTrackLens12.Value);
            wr.Write(ribbonTrackLens13.Value);
            wr.Write(ribbonTrackLens14.Value);
            wr.Write(ribbonTrackLens15.Value);
            wr.Write(ribbonTrackLens16.Value);
            wr.Write(ribbonTrackLens17.Value);
            wr.Write(ribbonTrackLens18.Value);
            wr.Write(ribbonTrackLens19.Value);
            wr.Write(ribbonTrackLens20.Value);



            wr.Write(ribbonTrackOffset1.Value);
            wr.Write(ribbonTrackOffset2.Value);
            wr.Write(ribbonTrackOffset3.Value);
            wr.Write(ribbonTrackOffset4.Value);
            wr.Write(ribbonTrackOffset5.Value);
            wr.Write(ribbonTrackOffset6.Value);
            wr.Write(ribbonTrackOffset7.Value);
            wr.Write(ribbonTrackOffset8.Value);
            wr.Write(ribbonTrackOffset9.Value);

            // Save Enhance Simple Settings
            wr.Write(ribbonTrackEnhanceN1.Value);
            wr.Write(ribbonTrackEnhanceN2.Value);
            wr.Write(ribbonTrackEnhanceN3.Value);
            wr.Write(ribbonTrackEnhanceN4.Value);
            wr.Write(ribbonTrackEnhanceN5.Value);


            // Save Operations
            wr.Write((int)Effects2.RotateForUndo);
            wr.Write((int)Effects2.FlipForUndo);

            // Croping data
            wr.Write(cropData.X);
            wr.Write(cropData.Y);
            wr.Write(cropData.Width);
            wr.Write(cropData.Height);

            // Drop shadow and grayscale
            wr.Write(Effects2.dropshadow);
            wr.Write(Effects2.grayscale);

            // BoxFilter
            wr.Write(Effects2.BoxFilter.Angle);
            wr.Write(Effects2.BoxFilter.BoxDepth);
            wr.Write(Effects2.BoxFilter.BoxEndColor.ToArgb());
            wr.Write(Effects2.BoxFilter.BoxStartColor.ToArgb());
            wr.Write(Effects2.BoxFilter.DrawImageOnSides);

            // Rounded
            wr.Write(Effects2.rounded);

            // WaterMark
            if (waterMarkText != null && waterMarkText.Length != 0)
            {
                wr.Write(waterMarkText.Length);
                wr.Write(waterMarkText);
            }
            else
            {
                wr.Write(0);
            }

            wr.Write((int)textAlign);
            MemoryStream ms = null;

            wr.Write(waterMarkFont.FontFamily.Name.Length);
            wr.Write(waterMarkFont.FontFamily.Name);
            wr.Write(waterMarkFont.Size);
            wr.Write((int)waterMarkFont.Style);

            if (waterMarkImage != null)
            {
                ms = new MemoryStream();
                Bitmap t = (Bitmap)waterMarkImage;
                t.Save(ms, ImageFormat.Png);
                /// Put in the lengh of the image
                wr.Write(ms.Length);
                // put in the actual image
                wr.Write(ms.ToArray());
            }
            else
            {
                /// Put in the zero to indicate null image
                wr.Write((long)0);
            }

            wr.Write((int)imageAlign);

            // Version > 1.4
            // Fisheye
            wr.Write(Effects2.curvature);

            wr.Write(Effects2.FloorReflectionFilter.AlphaEnd);
            wr.Write(Effects2.FloorReflectionFilter.AlphaStart);
            wr.Write((int)Effects2.FloorReflectionFilter.DockPosition);
            wr.Write(Effects2.FloorReflectionFilter.Offset);
            // End Version > 1.4

            if (Program.Destination.Image != null)
            {
                try
                {
                    ms = new MemoryStream();
                    Bitmap t = (Bitmap)Program.Destination.Image.GetThumbnailImage(50, 50, null, IntPtr.Zero);
                    t.Save(ms, ImageFormat.Png);
                    wr.Write(ms.ToArray());
                }
                catch { }
            }

            wr.Flush();
            wr.Close();


            RibbonItem preset = new RibbonItem();
            preset.Click += new EventHandler(preset_Click);
            try
            {
                preset.Image = ReadPreset(saveDialog.FileName);
            }
            catch { }
            preset.IsPressed = false;
            preset.Tag = saveDialog.FileName;
            preset.Cursor = Cursors.Hand;
            toolTip1.SetToolTip(preset, Path.GetFileNameWithoutExtension(saveDialog.FileName));
            presetGallery.Controls.Add(preset);
        }
예제 #12
0
파일: App.cs 프로젝트: spearfish/Lyrebird
        public Result OnStartup(UIControlledApplication application)
        {
            address = new Uri(addr + application.ControlledApplication.VersionNumber);
            uicApp  = application;


            _app         = this;
            serverActive = Properties.Settings.Default.defaultServerOn;
            // Create the button
            try
            {
                BitmapSource   bms;
                PushButtonData lyrebirdButton;
                //StartServer();
                if (disableButton)
                {
                    bms            = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_On.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                    lyrebirdButton = new PushButtonData("Lyrebird Server", "Lyrebird Server\nDisabled", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.ServerToggle")
                    {
                        LargeImage = bms,
                        ToolTip    = "The Lyrebird Server is currently disabled in this session of Revit.  This is most likely because you have more than one session of Revit and the server can only run in one.",
                    };
                    Properties.Settings.Default.enableServer = false;
                    Properties.Settings.Default.Save();
                }
                else
                {
                    if (serverActive)
                    {
                        bms            = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_On.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                        lyrebirdButton = new PushButtonData("Lyrebird Server", "Lyrebird\nServer On", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.ServerToggle")
                        {
                            LargeImage = bms,
                            ToolTip    = "The Lyrebird Server currently on and will accept requests for data and can create objects.  Push button to toggle the server off.",
                        };
                        StartServer();
                        //ServiceOn();
                    }
                    else
                    {
                        bms            = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Off.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                        lyrebirdButton = new PushButtonData("Lyrebird Server", "Lyrebird\nServer Off", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.ServerToggle")
                        {
                            LargeImage = bms,
                            ToolTip    = "The Lyrebird Server is currently off and will not accept requests for data or create objects.  Push button to toggle the server on.",
                        };
                    }
                    Properties.Settings.Default.enableServer = true;
                    Properties.Settings.Default.Save();
                }

                // Settings button
                BitmapSource   setBMS             = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Settings.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData settingsButtonData = new PushButtonData("Lyrebird Settings", "Lyrebird Settings", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.SettingsCmd")
                {
                    LargeImage = setBMS,
                    ToolTip    = "Lyrebird Server settings.",
                };

                // Selection button
                BitmapSource   selBMS = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Select.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData selectionButtonData = new PushButtonData("Select Run", "Select Run", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.SelectRunElementsCmd")
                {
                    LargeImage = selBMS,
                    ToolTip    = "Select elements created from Lyrebird",
                };

                // Selection button
                BitmapSource   delBMS           = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_RemoveData.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData removeButtonData = new PushButtonData("Remove Data", "Remove Data", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.RemoveDataCmd")
                {
                    LargeImage = delBMS,
                    ToolTip    = "Remove Lyrebird data from selected elements",
                };

                // Create the tab if necessary
                const string tabName = "LMN";
                Autodesk.Windows.RibbonControl ribbon = Autodesk.Windows.ComponentManager.Ribbon;
                Autodesk.Windows.RibbonTab     tab    = null;
                foreach (Autodesk.Windows.RibbonTab t in ribbon.Tabs)
                {
                    if (t.Id == tabName)
                    {
                        tab = t;
                    }
                }
                if (tab == null)
                {
                    application.CreateRibbonTab(tabName);
                }

                bool found = false;
                List <RibbonPanel> panels = application.GetRibbonPanels(tabName);
                RibbonPanel        panel  = null;
                foreach (RibbonPanel rp in panels)
                {
                    if (rp.Name == "Utilities")
                    {
                        panel = rp;
                        found = true;
                    }
                }

                SplitButtonData sbd = new SplitButtonData("Lyrebird", "Lyrebird");

                if (!found)
                {
                    // Create the panel
                    RibbonPanel utilitiesPanel = application.CreateRibbonPanel(tabName, "Utilities");

                    // Split button
                    SplitButton sb = utilitiesPanel.AddItem(sbd) as SplitButton;
                    serverButton = sb.AddPushButton(lyrebirdButton) as PushButton;
                    PushButton settingsButton = sb.AddPushButton(settingsButtonData) as PushButton;
                    PushButton selButton      = sb.AddPushButton(selectionButtonData) as PushButton;
                    PushButton removeButton   = sb.AddPushButton(removeButtonData) as PushButton;
                    sb.IsSynchronizedWithCurrentItem = false;
                }
                else
                {
                    SplitButton sb = panel.AddItem(sbd) as SplitButton;
                    serverButton = sb.AddPushButton(lyrebirdButton) as PushButton;
                    PushButton settingsButton = sb.AddPushButton(settingsButtonData) as PushButton;
                    PushButton selButton      = sb.AddPushButton(selectionButtonData) as PushButton;
                    PushButton removeButton   = sb.AddPushButton(removeButtonData) as PushButton;
                    sb.IsSynchronizedWithCurrentItem = false;
                }

                if (disableButton)
                {
                    serverButton.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                TaskDialog.Show("Error", ex.ToString());
            }

            return(Result.Succeeded);
        }
예제 #13
0
 public virtual void DoPostProcessing(RibbonItem ribbonItem)
 {
 }
예제 #14
0
        /// <summary>
        ///     Handles the MouseDown on the control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Control_MouseDown(object sender, MouseEventArgs e)
        {
            if (IsSupsended || Disposed)
            {
                return;
            }

            HitTest(e.Location);
            _lastMouseDown = HittedItem;

            #region Tab Scrolls

            if (HittedTab != null)
            {
                if (HittedTabScrollLeft)
                {
                    HittedTab.SetScrollLeftPressed(true);
                    Control.Invalidate(HittedTab.ScrollLeftBounds);
                }

                if (HittedTabScrollRight)
                {
                    HittedTab.SetScrollRightPressed(true);
                    Control.Invalidate(HittedTab.ScrollRightBounds);
                }
            }

            #endregion

            #region Panel

            if (HittedPanel != null)
            {
                HittedPanel.SetPressed(true);
                HittedPanel.OnMouseDown(e);
                Control.Invalidate(HittedPanel.Bounds);
            }

            #endregion

            #region Item

            if (HittedItem != null)
            {
                HittedItem.SetPressed(true);
                HittedItem.OnMouseDown(e);
                Control.Invalidate(HittedItem.Bounds);
            }

            #endregion

            #region SubItem

            if (HittedSubItem != null)
            {
                HittedSubItem.SetPressed(true);
                HittedSubItem.OnMouseDown(e);
                Control.Invalidate(Rectangle.Intersect(HittedItem.Bounds, HittedSubItem.Bounds));
            }

            #endregion
        }
        /// <summary>
        /// Redraws the specified item, intersected by the specified rectangle
        /// </summary>
        /// <param name="item"></param>
        /// <param name="clipIntersect"></param>
        private void RedrawItem(RibbonItem item, Rectangle clipIntersect)
        {
            Rectangle clip = Rectangle.FromLTRB(
                item.Bounds.Left,
                item.Bounds.Top,
                item.Bounds.Right + 1,
                item.Bounds.Bottom + 1);

            clip = clipIntersect.IsEmpty ? (item.Bounds) : (Rectangle.Intersect(item.Bounds, clipIntersect));

            Control.Invalidate(clip);
        }
        /// <summary>
        /// Selects the specified item as the currently selected item
        /// </summary>
        /// <param name="item"></param>
        private void SetSelectedItem(RibbonItem item)
        {
            if (item == _lastSelectedItem) return;

            if (_lastSelectedItem != null)
            {
                _lastSelectedItem.SetSelected(false);
                RedrawItem(_lastSelectedItem);
            }

            if (item != null)
            {
                item.SetSelected(true);
                RedrawItem(item);
            }

            _lastSelectedItem = item;
        }
        internal void HandleDesignerItemRemoved(RibbonItem item)
        {
            if (MenuItems.Contains(item))
            {
                MenuItems.Remove(item);
            }
            else if (RecentItems.Contains(item))
            {
                RecentItems.Remove(item);
            }
            else if (OptionItems.Contains(item))
            {
                OptionItems.Remove(item);
            }

            OnRegionsChanged();
        }
예제 #18
0
 /// <summary>
 /// Sets the value of the OwnerList property
 /// </summary>
 internal virtual void SetOwnerGroup(RibbonItemGroup ownerGroup)
 {
     _ownerItem = ownerGroup;
 }
 /// <summary>
 /// Selects the specified item on the designer
 /// </summary>
 /// <param name="item"></param>
 internal void SelectOnDesigner(RibbonItem item)
 {
     if (RibbonDesigner.Current != null)
     {
         RibbonDesigner.Current.SelectedElement = item;
         UpdateDesignerSelectedBounds();
         Invalidate();
     }
 }
예제 #20
0
        private void Stream(ArrayList data, RibbonItem ribbonItem)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(RibbonItem)));

             data.Add(new Snoop.Data.Bool("Enabled", ribbonItem.Enabled));
             data.Add(new Snoop.Data.String("Item text", ribbonItem.ItemText));
             data.Add(new Snoop.Data.String("Item type", ribbonItem.ItemType.ToString()));
             data.Add(new Snoop.Data.String("Tool tip", ribbonItem.ToolTip));

             PulldownButton pullDownBtn = ribbonItem as PulldownButton;
             if (pullDownBtn != null)
             {
            Stream(data, pullDownBtn);
            return;
             }

             PushButton pushBtn = ribbonItem as PushButton;
             if (pushBtn != null)
             {
            Stream(data, pushBtn);
            return;
             }

             //RibbonMenuItem ribMenuItem = ribbonItem as RibbonMenuItem;
             //if (ribMenuItem != null) {
             //    Stream(data, ribMenuItem);
             //    return;
             //}
        }
        /// <summary>
        /// Senses the movement of the mouse
        /// </summary>
        /// <param name="e"></param>
        public void SenseMouseMove(MouseEventArgs e)
        {
            if (Disposed)
                throw new ObjectDisposedException(GetType().Name);

            RibbonPanel hittedPanel = null;
            RibbonItem hittedItem = null;
            RibbonItem hittedSubItem = null;

            if (!SenseOnlyItems)
            {
                if (MouseMoveTabScroll(e.X, e.Y)) return;

                ///Check for the selected panel
                if (Tab.TabContentBounds.Contains(e.X, e.Y) || PanelLimit != null)
                {
                    foreach (RibbonPanel panel in GetPanelsToSense())
                    {
                        if (panel.Bounds.Contains(e.X, e.Y))
                        {
                            SetSelectedPanel(panel, e.X, e.Y);
                            if (panel.PopUp != null)
                            {
                                hittedPanel = panel;
                            }
                            hittedPanel = panel;
                            break;
                        }
                    }
                }

                if (hittedPanel != null)
                    hittedPanel.OnMouseMove(e);

                ///If no panel, unselect last panel
                if (hittedPanel == null && _lastSelectedPanel != null)
                {
                    SetSelectedPanel(null, e.X, e.Y);
                    SetSelectedItem(null);
                    SetSelectedSubItem(null);
                }
            }

            ///Check for the selected item
            if ((hittedPanel != null && (hittedPanel.SizeMode != RibbonElementSizeMode.Overflow || hittedPanel.PopUp != null))
                || SenseOnlyItems)
            {
                IEnumerable<RibbonItem> items = SenseOnlyItems ? ItemsToSense : hittedPanel.Items;

                foreach (RibbonItem item in items)
                {
                    if (item.Bounds.Contains(e.X, e.Y))
                    {
                        if (item != _lastSelectedSubItemParent) SetSelectedSubItem(null);
                        SetSelectedItem(item);
                        hittedItem = item;
                        break;
                    }
                }
            }

            ///Check for sub-items on the item
            ///(This should be recursive, but it's not necessary so far)
            if (hittedItem != null && hittedItem is IContainsSelectableRibbonItems)
            {
                foreach (RibbonItem item in (hittedItem as IContainsSelectableRibbonItems).GetItems())
                {
                    if (item.Bounds.Contains(e.X, e.Y))
                    {
                        _lastSelectedSubItemParent = hittedItem;
                        SetSelectedSubItem(item);
                        hittedSubItem = item;
                        break;
                    }
                }
            }

            ///if no hitted item, unselect last item
            if (hittedItem == null && _lastSelectedItem != null)
            {
                SetSelectedItem(null);
                SetSelectedSubItem(null);
            }

            if (hittedPanel != null)
            {
                hittedPanel.OnMouseMove(e);
            }

            if (hittedItem != null)
                hittedItem.OnMouseMove(e);

            ///If no hitted sub-item, unselect last item
            if ((hittedSubItem == null && _lastSelectedSubItem != null))
            {
                SetSelectedSubItem(null);
            }

            if(hittedSubItem != null)
                hittedSubItem.OnMouseMove(e);
        }
예제 #22
0
파일: App.cs 프로젝트: samuto/Lyrebird
 public void Disable()
 {
     RibbonButton rbutton = serverButton as RibbonButton;
     if (rbutton.Enabled)
     {
         BitmapSource bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_On.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
         rbutton.LargeImage = bms;
         rbutton.ItemText = "Lyrebird Server\nDisabled";
         rbutton.ToolTip = "The Lyrebird Server is currently disabled in this session of Revit.  This is most likely because you have more than one session of Revit and the server can only run in one.";
         rbutton.Enabled = false;
         serverButton = rbutton;
         StopServer();
     }
 }
        /// <summary>
        /// Senses the mouse button up
        /// </summary>
        /// <param name="e"></param>
        public void SenseMouseUp(MouseEventArgs e)
        {
            if (Disposed)
                throw new ObjectDisposedException(GetType().Name);

            RibbonPanel mouseUpPanel = null;
            RibbonItem mouseUpItem = null;
            RibbonPanel hittedPanel = null;
            RibbonItem hittedItem = null;

            if (!SenseOnlyItems)
            {
                if (MouseUpTabScroll(e.X, e.Y)) return;

                ///Check for the selected panel
                if (Tab.TabContentBounds.Contains(e.X, e.Y) || PanelLimit != null)
                {
                    foreach (RibbonPanel panel in GetPanelsToSense())
                    {
                        if (panel.Bounds.Contains(e.X, e.Y))
                        {
                            hittedPanel = panel;
                            if (PanelLimit == null || PanelLimit == hittedPanel)
                            {
                                mouseUpPanel = panel;
                                panel.OnMouseUp(e);
                            }
                            break;
                        }
                    }
                }

                if (mouseUpPanel != null && mouseUpPanel == _mouseDownPanel)
                {
                    _mouseDownPanel = null;
                    mouseUpPanel.OnClick(EventArgs.Empty);
                }

                if (hittedPanel != null)
                {
                    hittedPanel.OnMouseUp(e);
                }
            }

            ///Check for the selected item
            if (hittedPanel != null || SenseOnlyItems)
            {
                IEnumerable<RibbonItem> items = SenseOnlyItems ? ItemsToSense : hittedPanel.Items;

                foreach (RibbonItem item in items)
                {
                    if (item.Bounds.Contains(e.X, e.Y))
                    {
                        item.OnMouseUp(e);
                        hittedItem = item;
                        mouseUpItem = item;
                        RedrawItem(item);
                        break;
                    }
                }
            }

            ///Check for sub-items on the item
            ///(This should be recursive, but it's not necessary so far)
            if (hittedItem != null && hittedItem is IContainsSelectableRibbonItems)
            {
                foreach (RibbonItem item in (hittedItem as IContainsSelectableRibbonItems).GetItems())
                {
                    if (item.Bounds.Contains(e.X, e.Y))
                    {
                        item.OnMouseUp(e);
                        mouseUpItem = item;
                        RedrawItem(item, GetContentBounds(hittedItem));
                        break;
                    }
                }
            }

            if (mouseUpItem == _mouseDownItem && mouseUpItem != null)
            {
                _mouseDownItem = null;
                mouseUpItem.OnClick(EventArgs.Empty);
            }
        }
예제 #24
0
파일: App.cs 프로젝트: samuto/Lyrebird
        public Result OnStartup(UIControlledApplication application)
        {
            address = new Uri(addr + application.ControlledApplication.VersionNumber);
            uicApp = application;


            _app = this;
            serverActive = Properties.Settings.Default.defaultServerOn;
            // Create the button
            try
            {
                BitmapSource bms;
                PushButtonData lyrebirdButton;
                //StartServer();
                if (disableButton)
                {
                    bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_On.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                    lyrebirdButton = new PushButtonData("Lyrebird Server", "Lyrebird Server\nDisabled", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.ServerToggle")
                    {
                        LargeImage = bms,
                        ToolTip = "The Lyrebird Server is currently disabled in this session of Revit.  This is most likely because you have more than one session of Revit and the server can only run in one.",
                    };
                    Properties.Settings.Default.enableServer = false;
                    Properties.Settings.Default.Save();
                }
                else
                {
                    if (serverActive)
                    {
                        bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_On.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                        lyrebirdButton = new PushButtonData("Lyrebird Server", "Lyrebird\nServer On", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.ServerToggle")
                        {
                            LargeImage = bms,
                            ToolTip = "The Lyrebird Server currently on and will accept requests for data and can create objects.  Push button to toggle the server off.",
                        };
                        StartServer();
                        //ServiceOn();
                    }
                    else
                    {
                        bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Off.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                        lyrebirdButton = new PushButtonData("Lyrebird Server", "Lyrebird\nServer Off", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.ServerToggle")
                        {
                            LargeImage = bms,
                            ToolTip = "The Lyrebird Server is currently off and will not accept requests for data or create objects.  Push button to toggle the server on.",
                        };
                    }
                    Properties.Settings.Default.enableServer = true;
                    Properties.Settings.Default.Save();
                }

                // Settings button
                BitmapSource setBMS = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Settings.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData settingsButtonData = new PushButtonData("Lyrebird Settings", "Lyrebird Settings", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.SettingsCmd")
                {
                    LargeImage = setBMS,
                    ToolTip = "Lyrebird Server settings.",
                };

                // Selection button
                BitmapSource selBMS = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Select.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData selectionButtonData = new PushButtonData("Select Run", "Select Run", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.SelectRunElementsCmd")
                {
                    LargeImage = selBMS,
                    ToolTip = "Select elements created from Lyrebird",
                };

                // Selection button
                BitmapSource delBMS = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_RemoveData.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData removeButtonData = new PushButtonData("Remove Data", "Remove Data", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.RemoveDataCmd")
                {
                    LargeImage = delBMS,
                    ToolTip = "Remove Lyrebird data from selected elements",
                };

                // Create the tab if necessary
                const string tabName = "LMN";
                Autodesk.Windows.RibbonControl ribbon = Autodesk.Windows.ComponentManager.Ribbon;
                Autodesk.Windows.RibbonTab tab = null;
                foreach (Autodesk.Windows.RibbonTab t in ribbon.Tabs)
                {
                    if (t.Id == tabName)
                    {
                        tab = t;
                    }
                }
                if (tab == null)
                {
                    application.CreateRibbonTab(tabName);
                }

                bool found = false;
                List<RibbonPanel> panels = application.GetRibbonPanels(tabName);
                RibbonPanel panel = null;
                foreach (RibbonPanel rp in panels)
                {
                    if (rp.Name == "Utilities")
                    {
                        panel = rp;
                        found = true;
                    }
                }

                SplitButtonData sbd = new SplitButtonData("Lyrebird", "Lyrebird");

                if (!found)
                {
                    // Create the panel
                    RibbonPanel utilitiesPanel = application.CreateRibbonPanel(tabName, "Utilities");

                    // Split button
                    SplitButton sb = utilitiesPanel.AddItem(sbd) as SplitButton;
                    serverButton = sb.AddPushButton(lyrebirdButton) as PushButton;
                    PushButton settingsButton = sb.AddPushButton(settingsButtonData) as PushButton;
                    PushButton selButton = sb.AddPushButton(selectionButtonData) as PushButton;
                    PushButton removeButton = sb.AddPushButton(removeButtonData) as PushButton;
                    sb.IsSynchronizedWithCurrentItem = false;
                }
                else
                {
                    SplitButton sb = panel.AddItem(sbd) as SplitButton;
                    serverButton = sb.AddPushButton(lyrebirdButton) as PushButton;
                    PushButton settingsButton = sb.AddPushButton(settingsButtonData) as PushButton;
                    PushButton selButton = sb.AddPushButton(selectionButtonData) as PushButton;
                    PushButton removeButton = sb.AddPushButton(removeButtonData) as PushButton;
                    sb.IsSynchronizedWithCurrentItem = false;
                }

                if (disableButton)
                {
                    serverButton.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                TaskDialog.Show("Error", ex.ToString());
            }

            return Result.Succeeded;
        }
        /// <summary>
        /// Tries to extract from IContainsRibbonItems.GetContentBounds()
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private Rectangle GetContentBounds(RibbonItem item)
        {
            IContainsSelectableRibbonItems cont = item as IContainsSelectableRibbonItems;

            if (cont == null)
            {
                return Rectangle.Empty;
            }

            return cont.GetContentBounds();
        }
예제 #26
0
        void newPicBox_Click(object sender, EventArgs e)
        {
            try
            {

                RibbonItem source = (RibbonItem)sender;
                int fileNum = (int)source.Tag;
                string fileName = (string)files[fileNum];

                string fileSize = Utility.GetFileSize(fileName);

                FileStream fs = File.Open(fileName, FileMode.Open, FileAccess.Read);
                Program.Photo = new Bitmap(fs);
                fs.Close();

                string[] fn = fileName.Split('\\');
                Program.Title.Text = "File: " + fn[fn.Length - 1] + " Resolution: " + Program.Photo.Width.ToString() + " x " + Program.Photo.Height.ToString() + " Size: " + fileSize;
                Program.FileName = fileName;

                ((MainForm)this.Parent.Parent).Open();

                Program.Source.Size = Program.Destination.Size;

                Program.Optimize2();

                Program.Destination.Image = (Bitmap)Program.Source.Image.Clone();

                if (lastSelected != null)
                {
                    lastSelected.IsPressed = false;
                }

                lastSelected = source;
                lastSelected.IsPressed = true;
            }
            catch (Exception) {}
        }
예제 #27
0
        private void DoCreateField(RibbonItem item)
        {
            if (item == rbtnFieldChart)
            {
                _flexDesigner.CreateFieldInfo = item;
                _createInfo = null;
            }
            else if (item == rbtnFieldFlexChart)
            {
                _flexDesigner.CreateFieldInfo = item;
                _createInfo = null;
            }
#if MAP
            else if (item == rbtnFieldMap)
            {
                _flexDesigner.CreateFieldInfo = item;
                _createInfo = null;
            }
#endif
            else if (item == rbtnFieldDataField || item == rbtnFieldRtf || item == rbtnFieldCheckBox || item == rbtnFieldBarCode ||
                     item == rbtnFieldShape || item == rbtnFieldLegacy || item == rbtnFieldParagraph || item == rbtnFieldLegacy)
            {
                _flexDesigner.CreateFieldInfo = item;
                _createInfo = null;
            }
            else if (item == rbtnFieldCalculated)
            {
                ValueHolder valueHolder = new ValueHolder()
                {
                    Value = string.Empty
                };
                var    contextName = EditorScriptContextBase.MakeContextName(_flexDesigner.Report.DataSourceName, ScriptEditorContextKind.ReportScript);
                object result;
                if (EditScriptInternal(_flexDesigner.Report, contextName, null, valueHolder, "Value", Strings.MainForm.NewCalcFieldExprName, true, out result))
                {
                    _createInfo = valueHolder.Value;
                    if (!string.IsNullOrEmpty(_createInfo))
                    {
                        _flexDesigner.CreateFieldInfo = item;
                    }
                }
                else
                {
                    _flexDesigner.CreateFieldInfo = null;
                    item = rbtnFieldArrow; // to reset Pressed
                }
            }
            else if (item == rbtnFieldPicture)
            {
                using (OpenFileDialog dlg = new OpenFileDialog())
                {
                    dlg.DereferenceLinks = true;
                    dlg.Filter           = Strings.MainForm.OpenImageFilter;
                    dlg.FileName         = "*.bmp;*.dib;*.ico;*.cur;*.gif;*.jpg;*.wmf;*.emf;*.png";
                    dlg.FilterIndex      = 0;
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        _createInfo = dlg.FileName;
                        _flexDesigner.CreateFieldInfo = rbtnFieldPicture;
                    }
                    else
                    {
                        _flexDesigner.CreateFieldInfo = null;
                        item = rbtnFieldArrow; // to reset Pressed
                    }
                }
            }
            else if (item.Parent is RibbonDropDownBase)
            {
                _flexDesigner.CreateFieldInfo = item.Parent;
                _createInfo = ((RibbonButton)item).Text;
            }
            else if (item.Tag is Field)
            {
                _flexDesigner.CreateFieldInfo = item;
            }

            // NO else here on purpose:
            if (item == rbtnFieldArrow)
            {
                _flexDesigner.CancelMouseOperation();
                _flexDesigner.CreateFieldInfo = null;
                _createInfo = null;
            }
            // We keep the button that caused the action pressed for the duration of adding the field
            // (i.e. while mouse cursor is a cross), while un-pressing all other items:
            UpdateCreateFieldButtons(item);
            //
            if (item != rbtnFieldArrow)
            {
                _flexDesigner.DoCreateFieldWithMouse(_flexDesigner.CreateFieldInfo);
            }
        }