public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value )
        {
            if( context != null && provider != null )
            {
                editorService = (IWindowsFormsEditorService)provider.GetService( typeof( IWindowsFormsEditorService ) );
                if( editorService != null )
                {
                    // Create a new trackbar and set it up.
                    TrackBar trackBar = new TrackBar();
                    trackBar.ValueChanged += new EventHandler( this.ValueChanged );
                    trackBar.MouseLeave += new EventHandler( this.MouseLeave );
                    trackBar.Minimum = 0;
                    trackBar.Maximum = 100;
                    trackBar.TickStyle = TickStyle.None;

                    // Get the low/high values.
                    PropertyDescriptor prop = context.PropertyDescriptor;
                    RangeAttribute ra = prop.Attributes[typeof( RangeAttribute )] as RangeAttribute;
                    valueLow = ra.Low;
                    valueHigh = ra.High;

                    // Set the corresponding trackbar value.
                    double percent = ( System.Convert.ToDouble( value ) - valueLow ) / ( valueHigh - valueLow );
                    trackBar.Value = (int)( 100 * percent );

                    // Show the control.
                    editorService.DropDownControl( trackBar );

                    // Here is the output value.
                    value = valueLow + ( (double)trackBar.Value / 100 ) * ( valueHigh - valueLow );
                }
            }

            return value;
        }
        /// <summary>
        /// Displays a list of available values for the specified component than sets the value.
        /// </summary>
        /// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
        /// <param name="provider">A service provider object through which editing services may be obtained.</param>
        /// <param name="value">An instance of the value being edited.</param>
        /// <returns>The new value of the object. If the value of the object hasn't changed, this method should return the same object it was passed.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                // This service is in charge of popping our ListBox.
                _service = ((IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)));

                if (_service != null && value is DropDownListProperty)
                {
                    var property = (DropDownListProperty) value;

                    var list = new ListBox();
                    list.Click += ListBox_Click;

                    foreach (string item in property.Values)
                    {
                        list.Items.Add(item);
                    }

                    // Drop the list control.
                    _service.DropDownControl(list);

                    if (list.SelectedItem != null && list.SelectedIndices.Count == 1)
                    {
                        property.SelectedItem = list.SelectedItem.ToString();
                        value =  property;
                    }
                }
            }

            return value;
        }
Exemple #3
1
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            if (context != null && provider != null)
            {
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    lb = new ListBox();
                    lb.Items.AddRange(new object[] {
                        "Sunday",
                        "Monday",
                        "Tuesday",
                        "Wednesday",
                        "Thursday",
                        "Friday",
                        "Saturday"});
                    lb.SelectedIndexChanged += new System.EventHandler(lb_SelectedIndexChanged);
                    edSvc.DropDownControl(lb);
                }
                return text;

            }

            return base.EditValue(context, provider, value);
        }
Exemple #4
0
        public FontPropertyEditor(FontItem  font,
            IWindowsFormsEditorService editorServiceParam )
        {
            editorService = editorServiceParam;
            InitializeComponent();

            this.View = System.Windows.Forms.View.Tile;

            //Default Font
            ListViewItem itemDefault = new ListViewItem();
            itemDefault.Tag = new FontItem("DEFAULT",font.projectParent);
            itemDefault.Text = "Default Font";
            this.Items.Add(itemDefault);

            // Add three font files to the private collection.
            for (int i = 0; i < font.projectParent.AvailableFont.Count; i++)
            {
                ListViewItem item = new ListViewItem();
                item.Tag = font.projectParent.AvailableFont[i];
                item.Font = new Font(font.projectParent.AvailableFont[i].NameForIphone, 14);
                item.Text = font.projectParent.AvailableFont[i].NameForIphone;
                this.Items.Add(item);

            }

            //this.Invalidate();
        }
        /// <summary>
        /// ʹ��GetEditStyle������ָʾ�ı༭����ʽ�༭ָ�������ֵ
        /// </summary>
        /// <param name="context">�����ڻ�ȡ������������Ϣ�� ITypeDescriptorContext</param>
        /// <param name="provider">IServiceProvider��ͨ�������ܻ�ñ༭����</param>
        /// <param name="value">���ڱ༭��ֵ��ʵ��</param>
        /// <returns>�µĶ���ֵ������ö����ֵ��δ���ģ�����Ӧ�����봫�ݸ����Ķ�����ͬ�Ķ���</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)       //�༭����Ķ���Ϊ��
            {
                editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            }

            if (editorService != null)      //�༭�������Ͳ�Ϊ��
            {
                if (this.listBox == null)
                {
                    this.listBox = new ListBox();
                    this.listBox.Dock = DockStyle.Fill;
                    this.listBox.MouseClick += new MouseEventHandler(listBox_MouseClick);
                }
                this.listBox.Items.Clear();
                foreach (string str in CassViewGenerator.chooseString.Split(','))
                {
                    this.listBox.Items.Add(str);
                }
                this.listBox.SelectedItem = value;
                editorService.DropDownControl(this.listBox);
            }
            if (this.listBox.SelectedItem != null)
            {
                return this.listBox.SelectedItem.ToString();
            }
            else
            {
                return null;
            }
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null)
                {
                    if (_mappingPropertyEditorForm == null)
                    {
                        _mappingPropertyEditorForm = new MappingPropertyEditorForm();
                    }

                    _mappingPropertyEditorForm.Start(editorService, value);
                    editorService.ShowDialog(_mappingPropertyEditorForm);

                    if (_mappingPropertyEditorForm.DialogResult == DialogResult.OK)
                    {
                        MappingProperty mappingProperty = new MappingProperty();
                        mappingProperty.MappingInfoCollection = _mappingPropertyEditorForm.MappingInfoCollection;
                        value = mappingProperty;
                    }
                    else
                    {
                        value = null;
                    }
                }
            }

            return value;
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
              if (editorService == null)
            return value;

              FmodEventShape Shape = context.Instance as FmodEventShape;
              System.Diagnostics.Debug.Assert(Shape != null, "EventGroupSelectionEditor only valid for FmodEventShapes!");

              // Create a TreeView and populate it
              treeView = new TreeView();
              treeView.ImageList = EditorManager.GUI.ShapeTreeImages.ImageList;
              treeView.Bounds = new Rectangle(0, 0, 400, 500);
              treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView_NodeMouseClick);
              FmodManaged.ManagedModule.GetEventGroupTree(Shape.EventProject, treeView);
              treeView.ExpandAll();

              // Show our listbox as a DropDownControl.
              // This methods returns, when the DropDownControl is closed.
              editorService.DropDownControl(treeView);

              TreeNode selectedNode = treeView.SelectedNode;
              if (selectedNode != null)
              {
            string fullPath = selectedNode.FullPath;
            return fullPath.Replace("\\", "/");
              }
              else
            return Shape.EventGroup;
        }
        /// <summary>
        ///   Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"/> method.
        /// </summary>
        /// 
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that can be used to gain additional context information.</param>
        /// <param name="provider">An <see cref="T:System.IServiceProvider"/> that this editor can use to obtain services.</param>
        /// <param name="value">The object to edit.</param>
        /// 
        /// <returns>
        ///   The new value of the object. If the value of the object has not changed, this should return the same object it was passed.
        /// </returns>
        /// 
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                this.editorService = (IWindowsFormsEditorService)provider
                    .GetService(typeof(IWindowsFormsEditorService));

                this.CollectionType = context.PropertyDescriptor.ComponentType;
                this.CollectionItemType = detectCollectionType();

                if (editorService != null)
                {
                    NumericCollectionEditorForm form = new NumericCollectionEditorForm(this, value);

                    context.OnComponentChanging();

                    if (editorService.ShowDialog(form) == DialogResult.OK)
                    {
                        context.OnComponentChanged();
                    }
                }
            }

            return value;
        }
 public BookmarkScreen(IWindowsFormsEditorService wfes, PlaylistItem plItem) : this()
 {
     _wfes = wfes;
     _showFilePath = false;
     _canAddToCurrent = false;
     this.PlaylistItem = plItem;
 }
Exemple #10
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            wfes = (IWindowsFormsEditorService) provider.GetService(typeof (IWindowsFormsEditorService));
            if ((wfes == null) || (context == null))
                return null;

            ImageList imageList = GetImageList(context.Instance);
            if ((imageList == null) || (imageList.Images.Count == 0))
                return -1;

            m_imagePanel = new ImageListPanel();

            m_imagePanel.BackgroundColor = Color.FromArgb(241, 241, 241);
            m_imagePanel.BackgroundOverColor = Color.FromArgb(102, 154, 204);
            m_imagePanel.HLinesColor = Color.FromArgb(182, 189, 210);
            m_imagePanel.VLinesColor = Color.FromArgb(182, 189, 210);
            m_imagePanel.BorderColor = Color.FromArgb(0, 0, 0);
            m_imagePanel.EnableDragDrop = true;
            m_imagePanel.Init(imageList, 12, 12, 6, (int) value);

            // add listner for event
            m_imagePanel.ItemClick += OnItemClicked;

            // set m_selectedIndex to -1 in case the dropdown is closed without selection
            m_selectedIndex = -1;
            // show the popup as a drop-down
            wfes.DropDownControl(m_imagePanel);

            // return the selection (or the original value if none selected)
            return (m_selectedIndex != -1) ? m_selectedIndex : (int) value;
        }
Exemple #11
0
        public RangeValueDropDown(float value, float minimum, float maximum,
            IWindowsFormsEditorService editorService, ITypeDescriptorContext context)
        {
            InitializeComponent();

            _EditorService = editorService;
            _Context = context;

            if (value < minimum)
            {
                if ((minimum * 1000 > Int16.MinValue) && (minimum * 1000 < Int16.MaxValue))
                    minimum = value;
            }

            if (value > maximum)
            {
                if ((maximum * 1000 > Int16.MinValue) && (maximum * 1000 < Int16.MaxValue))
                    maximum = value;
            }

            _TrackBar.Minimum = (int)(minimum * 1000);
            _TrackBar.Maximum = (int)(maximum * 1000);
            _TrackBar.SmallChange = _TrackBar.Maximum / 100;
            _TrackBar.LargeChange = _TrackBar.Maximum / 10;
            _TrackBar.TickFrequency = _TrackBar.LargeChange;

            _TrackBar.Value = (int)(value * 1000);

            _LabelMin.Text = String.Format("{0:f}", minimum);
            _LabelMax.Text = String.Format("{0:f}", maximum);

            Value = value;
        }
Exemple #12
0
        /// <summary>
        /// Called when we want to edit the value of a property.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (edSvc != null)
            {
                UI.Actions.MessageAction messageAction = context.Instance as UI.Actions.MessageAction;
                if (messageAction != null)
                {
                    ListBox listBox = new ListBox();
                    foreach (UI.Message message in messageAction.Scene.Messages)
                    {
                        listBox.Items.Add(message);
                    }

                    listBox.SelectedItem = messageAction.Scene.GetMessage((int)value);
                    listBox.SelectedIndexChanged += ((s, e) => { edSvc.CloseDropDown(); });

                    edSvc.DropDownControl(listBox);

                    return listBox.SelectedItem != null ? (listBox.SelectedItem as UI.Message).ID : -1;
                }
            }

            return value;
        }
 public TextureViewControl(
     TextureInfo texture,
     IWindowsFormsEditorService editorService)
 {
     // This call is required by the designer.
     InitializeComponent();
 }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            }
            if (editorService != null)
            {
                if (value == null)
                {
                    time = DateTime.Now.ToString("HH:mm");
                }

                DateTimePicker picker = new DateTimePicker();
                picker.Format = DateTimePickerFormat.Custom;
                picker.CustomFormat = "HH:mm";
                picker.ShowUpDown = true;

                if (value != null)
                {
                    picker.Value = DateTime.Parse((string)value);
                }

                editorService.DropDownControl(picker);
                value = picker.Value.ToString("HH:mm");
            }
            return value;
        }
        /// <summary>
        /// When editing an image index value, let the user choose an image from
        /// a popup that displays all the images in the associated <see cref="ImageSet"/>
        /// </summary>
        /// <param name="context">designer context</param>
        /// <param name="provider">designer service provider</param>
        /// <param name="value">image index item</param>
        /// <returns>
        /// An image index (selected from the popup) or -1 if the user canceled the
        /// selection
        /// </returns>
        public override object EditValue(ITypeDescriptorContext context,IServiceProvider provider,object value)
        {
            wfes = (IWindowsFormsEditorService)
                provider.GetService(typeof(IWindowsFormsEditorService));

            if((wfes == null) || (context == null))
                return null ;

            // Get the image set
            ImageSet imageSet = GetImageSet(context.Instance) ;

            // anything to show?
            if ((imageSet == null) || (imageSet.Count==0))
                return -1 ;

            // Create an image panel that is close to square
            Size dims = ImagePanel.CalculateBestDimensions(imageSet.Count,ImagePanel.PanelSizeHints.MinimizeBoth) ;
            imagePanel = new ImagePanel((Bitmap) imageSet.Preview,imageSet.Count,dims.Height,dims.Width) ;
            // set the current image index value as the default selection
            imagePanel.DefaultImage = (int) value ;
            // no grid
            imagePanel.GridColor = Color.Empty ;
            // listen for an image to be selected
            imagePanel.ImageSelected += new EventHandler(imagePanel_ImageSelected);

            // show the popup as a drop-down
            wfes.DropDownControl(imagePanel) ;

            // return the selection (or the original value if none selected)
            return (selectedIndex != -1) ? selectedIndex : (int) value ;
        }
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (service != null)
                {
                    ListBox list = new ListBox();
                    list.Click += new EventHandler(list_Click);
                    foreach (Cause c in causeList)
                    {
                        list.Items.Add(c);
                    }

                    service.DropDownControl(list);

                    if (list.SelectedItem != null && list.SelectedIndices.Count == 1)
                    {
                        value = list.SelectedItem;
                    }
                }
            }
            return value;
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null
                && context.Instance != null
                && provider != null)
            {
                edSvc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

                if (edSvc != null)
                {
                    ListBox lb = new ListBox();
                    lb.SelectedIndexChanged += new EventHandler(this.SelectedChanged);
                    MetroColorGeneratorParameters currentParams = (MetroColorGeneratorParameters)value;
                    MetroColorGeneratorParameters[] metroThemes = MetroColorGeneratorParameters.GetAllPredefinedThemes();
                    string selectedTheme = null;
                    foreach (MetroColorGeneratorParameters mt in metroThemes)
                    {
                        lb.Items.Add(mt.ThemeName);
                        if (currentParams.BaseColor == mt.BaseColor && currentParams.CanvasColor == mt.CanvasColor)
                        {
                            lb.SelectedItem = mt.ThemeName;
                            selectedTheme = mt.ThemeName;
                        }
                    }

                    edSvc.DropDownControl(lb);
                    if (lb.SelectedItem != null && selectedTheme != (string)lb.SelectedItem)
                    {
                        return metroThemes[lb.SelectedIndex];
                    }
                }
            }

            return value;
        }
        // begin edit operation
        public void Begin(IWindowsFormsEditorService service, object value, ValueExclusionCheck valueCheck)
        {
            _Service = service;
            lvwItems.Items.Clear();

            Type enumType = value.GetType();
            Array values = Enum.GetValues(enumType);

            // prepare list
            long current = Convert.ToInt64(value);
            for (int i = 0; i < values.Length; i++)
            {
                if ((valueCheck != null) && (!valueCheck((Enum)values.GetValue(i)))) continue;
                long val = Convert.ToInt64(values.GetValue(i));
                bool check = false;
                if (val == 0)
                    check = (current == 0);
                else
                {
                    check = ((current & val) == val);
                    if (check)
                        current &= ~val;
                }

                lvwItems.Items.Add(new EnumValueContainer(enumType, val), check);
            }
            leftOver = current;
            _Value = value;
        }
        /// <summary>
        /// Edits a value based on some user input which is collected from a character control.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _dialogProvider = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            List<int> layerList = new List<int>();
            LayoutLegend legend = context.Instance as LayoutLegend;
            LayoutMap map = null;
            if (legend != null)
                map = legend.Map;
            if (map == null)
                return layerList;

            CheckedListBox lb = new CheckedListBox();
            
            List<int> originalList = value as List<int>;
            if (originalList != null)
            {
                for (int i = map.MapControl.Layers.Count - 1; i >= 0 ; i--)
                    lb.Items.Add(map.MapControl.Layers[i].LegendText, originalList.Contains(i));
            }
            
            _dialogProvider.DropDownControl(lb);

            for (int i = 0; i < lb.Items.Count; i ++)
            {
                if (lb.GetItemChecked(i))
                    layerList.Add(lb.Items.Count - 1 -i);
            }

            return layerList;
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null
                && context.Instance != null
                && provider != null)
            {
                ElementStyle es = value as ElementStyle;

                _EditorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

                if (_EditorService != null)
                {
                    ListBox lb = new ListBox();
                    List<DevComponents.Schedule.TimeZoneInfo> timeZonesList = DevComponents.Schedule.TimeZoneInfo.GetSystemTimeZones();
                    int selectedIndex = -1;
                    for (int i = 0; i < timeZonesList.Count; i++)
                    {
                        DevComponents.Schedule.TimeZoneInfo timeZoneInfo = timeZonesList[i];
                        lb.Items.Add(timeZoneInfo.Id);
                        if (timeZoneInfo.Id.Equals((string)value))
                            selectedIndex = i;
                    }
                    lb.SelectedIndex = selectedIndex;
                    lb.SelectedIndexChanged += new EventHandler(this.SelectedChanged);
                    _EditorService.DropDownControl(lb);
                    return lb.SelectedItem;
                }
            }

            return value;
        }
		public GuidEditorListBox(IWindowsFormsEditorService editorService)
		{
			this.editorService = editorService;
			Items.Add("New Guid");
			Size = new Size(Width, ItemHeight);
			BorderStyle = BorderStyle.None;
		}
Exemple #22
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
     if (edSvc != null && value != null)
     {
         double tmp = 0;
         double.TryParse(value.ToString(), out tmp);
         tmp = tmp * 10;
         using (var dlg = new SlideDialog())
         {
             dlg.FormScale = Convert.ToDouble("0.1");
             dlg.MinValue = 0;
             dlg.MaxValue = 10;
             dlg.CurrentValue = (int)tmp;
             dlg.Text = MultilingualUtility.GetString("Alpha");
             if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 Property.Value = (dlg.CurrentValue * dlg.FormScale).ToString();
                 return Property.Value;
             }
             return value.ToString();
         }
     }
     return Property.DefaultValue;
 }
Exemple #23
0
        /// <summary>
        /// This takes care of the actual value-change of the property.
        /// </summary>
        /// <param name="itdc">Standard ITypeDescriptorContext object.</param>
        /// <param name="isp">Standard IServiceProvider object.</param>
        /// <param name="value">The value as an object.</param>
        /// <returns>The new value as an object.</returns>
        public override object EditValue(ITypeDescriptorContext itdc, IServiceProvider isp, object value)
        {
            if(itdc != null && itdc.Instance != null && isp != null)
            {
                iwfes = (IWindowsFormsEditorService)isp.GetService(typeof(IWindowsFormsEditorService));

                if(iwfes != null)
                {
                    MWCommon.TextDir td = MWCommon.TextDir.Normal;

                    if(value is MWCommon.TextDir)
                    {
                        td = (MWCommon.TextDir)itdc.PropertyDescriptor.GetValue(itdc.Instance);
                        pd = itdc.PropertyDescriptor;
                        oInstance = itdc.Instance;
                    }

                    EditorTextDirUI etdui = new EditorTextDirUI();
                    etdui.IWFES = iwfes;
                    etdui.ITDC = itdc;
                    etdui.TextDir = (MWCommon.TextDir)value;
                    etdui.TextDirChanged += new EditorTextDirUI.TextDirEventHandler(this.ValueChanged);

                    iwfes.DropDownControl(etdui);
                    value = etdui.TextDir;
                }
            }

            return value;
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            // Default behavior
            if ((context == null) ||
                (provider == null) || (context.Instance == null)) {
                return base.EditValue(context, provider, value);
            }

            ModelElement modelElement = (context.Instance as ModelElement);
            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (edSvc != null) {
                FrmFeatureModelDiagramSelector form = new FrmFeatureModelDiagramSelector(modelElement.Store);
                if (edSvc.ShowDialog(form) == DialogResult.OK) {
                    using (Transaction transaction = modelElement.Store.TransactionManager.BeginTransaction("UpdatingFeatureModelFileValue")) {

                        if (modelElement is FeatureShape) {
                            FeatureShape featureShape = modelElement as FeatureShape;
                            (featureShape.ModelElement as Feature).DefinitionFeatureModelFile = form.SelectedFeatureModelFile;
                        } else if (modelElement is FeatureModelDSLDiagram) {
                            FeatureModelDSLDiagram featureModelDslDiagram = modelElement as FeatureModelDSLDiagram;
                            (featureModelDslDiagram.ModelElement as FeatureModel).ParentFeatureModelFile = form.SelectedFeatureModelFile;
                        }

                        transaction.Commit();
                    }
                }
            }

            // Default behavior
            return base.EditValue(context, provider, value);
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
                service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (service != null)
            {
                // This is the code you want to run when the [...] is clicked and after it has been verified.
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.InitialDirectory = SceneManager.GameProject.ProjectPath;

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    string path = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, ofd.FileName);

                    if (File.Exists(SceneManager.GameProject.ProjectPath + "\\" + path))
                        value = path;
                }

                // Return the newly selected color.
               // value =
            }

            return value;
        }
        public override object EditValue(ITypeDescriptorContext ctx, IServiceProvider provider, object value)
        {
            // initialize editor service
            _edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (_edSvc == null)
                return value;

            // size the grid
            _flex.ClientSize = new Size(
                Math.Min(800, _flex.Cols[_flex.Cols.Count - 1].Right),
                Math.Min(250, _flex.Rows[_flex.Rows.Count - 1].Bottom));

            // initialize selection
            int col = _flex.Cols[_keyColumn].Index;
            _flex.Col = col;
            _flex.Row = (value is string)
                ? _flex.FindRow((string)value, _flex.Cols.Fixed, col, false, true, true)
                : -1;

            // show the grid
            _flex.Visible = true;
            _cancel = false;
            _edSvc.DropDownControl(_flex);

            if (_ValueSelected)
            {
                // get return value from selected item on the grid
                if (!_cancel && _flex.Row > -1)
                    value = _flex[_flex.Row, _keyColumn];
            }

            // done
            return value;
        }
        public override object EditValue(ITypeDescriptorContext context,
            IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                edSvc = (IWindowsFormsEditorService) provider.GetService(typeof
                                                                             (IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    var style = (TextStyle) value;
                    using (var tsd = new TextStyleDesignerDialog(style)
                        )
                    {
                        context.OnComponentChanging();
                        if (edSvc.ShowDialog(tsd) == DialogResult.OK)
                        {
                            ValueChanged(this, EventArgs.Empty);
                            context.OnComponentChanged();
                            return style;
                        }
                    }
                }
            }

            return value;
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null
                && context.Instance != null
                && provider != null)
            {
                edSvc = (IWindowsFormsEditorService) provider.GetService(typeof (IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    // Create a CheckedListBox and populate it with all the enum values
                    FontListbox = new ListBox
                                  {DrawMode = DrawMode.OwnerDrawFixed, BorderStyle = BorderStyle.None, Sorted = true};
                    FontListbox.MouseDown += OnMouseDown;
                    FontListbox.DoubleClick += ValueChanged;
                    FontListbox.DrawItem += LB_DrawItem;
                    FontListbox.ItemHeight = 20;
                    FontListbox.Height = 200;
                    FontListbox.Width = 180;

                    ICollection fonts = new FontEnum().EnumFonts();
                    foreach (string font in fonts)
                    {
                        FontListbox.Items.Add(font);
                    }
                    edSvc.DropDownControl(FontListbox);
                    if (FontListbox.SelectedItem != null)
                        return FontListbox.SelectedItem.ToString();
                }
            }

            return value;
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null
                && context.Instance != null
                && provider != null)
            {
                m_EditorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

                if (m_EditorService != null)
                {
                    TextMarkupEditor editor = new TextMarkupEditor();
                    editor.buttonOK.Click += new EventHandler(MarkupEditorButtonClick);
                    editor.buttonCancel.Click += new EventHandler(MarkupEditorButtonClick);
                    
                    if(value!=null)
                        editor.inputText.Text = value.ToString();

                    m_EditorService.DropDownControl(editor);

                    if (editor.DialogResult == DialogResult.OK)
                    {
                        string text = editor.inputText.Text;
                        editor.Dispose();
                        return text;
                    }
                    editor.Dispose();
                }
            }

            return value;
        }
Exemple #30
0
		/// <summary>
		/// This takes care of the actual value-change of the property.
		/// </summary>
		/// <param name="itdc">Standard ITypeDescriptorContext object.</param>
		/// <param name="isp">Standard IServiceProvider object.</param>
		/// <param name="value">The value as an object.</param>
		/// <returns>The new value as an object.</returns>
		public override object EditValue(ITypeDescriptorContext itdc, IServiceProvider isp, object value)
		{
			if(itdc != null && itdc.Instance != null && isp != null) 
			{
				iwfes = (IWindowsFormsEditorService)isp.GetService(typeof(IWindowsFormsEditorService));

				if(iwfes != null)
				{
					HatchStyle hs = HatchStyle.Weave;

					//if(itdc.PropertyDescriptor.GetValue(itdc.Instance) is HatchStyle)
					if(value is HatchStyle)
					{
						hs = (HatchStyle)itdc.PropertyDescriptor.GetValue(itdc.Instance);
						pd = itdc.PropertyDescriptor;
						oInstance = itdc.Instance;
					}

					//EditorHatchStyleUI ehsui = new EditorHatchStyleUI(hs, Color.White, Color.Black); //FIX THIS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
					EditorHatchStyleUI ehsui = new EditorHatchStyleUI(HatchStyle.Trellis, Color.White, Color.Black);
					ehsui.IWFES = iwfes;
					ehsui.ITDC = itdc;
					ehsui.HatchStyle = (HatchStyle)value;
					ehsui.HatchStyleChanged += new EditorHatchStyleUI.MWHatchStyleEventHandler(ValueChanged);

					iwfes.DropDownControl(ehsui);
					value = ehsui.HatchStyle;
				}
			}

			return value;
		}
Exemple #31
0
 protected override Control CreateDropDownControl(ITypeDescriptorContext context, IWindowsFormsEditorService editorService)
 {
     return(new GuidEditorListBox(editorService));
 }
Exemple #32
0
        bool EditEntry(Entry ent, out bool isNewCate, IWindowsFormsEditorService edSvc)
        {
            frmCsfEntryEdit f = new frmCsfEntryEdit(DevStringTable.Instance);

            //f.Text = Program.StringTable["GUI:CSFEdit"];
            f.name      = ent.name;
            f.content   = ent.text;
            f.extraData = ent.extra;

            if (edSvc == null)
            {
                f.ShowDialog(this);
            }
            else
            {
                edSvc.ShowDialog(f);
            }

            while (!f.isCanceled && !CheckEntryName(f.name, 2))
            {
                if (edSvc == null)
                {
                    f.ShowDialog(this);
                }
                else
                {
                    edSvc.ShowDialog(f);
                }
            }

            isNewCate = false;
            if (!f.isCanceled)
            {
                string newCate = GetCategory(f.name);

                // 类别是否相同?
                if (newCate != ent.cate)
                {
                    isNewCate = true;

                    // 从旧类别中去除
                    ent.parent.data.Remove(ent);
                    FlushCategory(ent.parent);

                    ent.cate = newCate;

                    // 新类别是否存在?
                    try
                    {
                        ent.parent = Find(newCate);
                    }
                    catch
                    {
                        Category newCat = new Category();
                        newCat.name = newCate;
                        newCat.data = new List <Entry>();
                        fileData.Add(newCat);

                        ent.parent = newCat;
                    }

                    ent.parent.data.Add(ent);
                }

                ent.name  = f.name;
                ent.extra = f.extraData;
                ent.text  = f.content;

                f.Dispose();
                return(true);
            }

            f.Dispose();
            return(false);
        }
            protected override Control CreateDropDownControl(ITypeDescriptorContext context, IWindowsFormsEditorService editorService)
            {
                FileProjectItem item = context.Instance as FileProjectItem;

                if (item != null && item.Project != null)
                {
                    return(new DropDownEditorListBox(editorService, GetNames(item.Project.AvailableFileItemTypes)));
                }
                else
                {
                    return(new DropDownEditorListBox(editorService, GetNames(ItemType.DefaultFileItems)));
                }
            }
            protected override Control CreateDropDownControl(ITypeDescriptorContext context, IWindowsFormsEditorService editorService)
            {
                FileProjectItem item = context.Instance as FileProjectItem;

                if (item != null)
                {
                    return(new DropDownEditorListBox(editorService, CustomToolsService.GetCompatibleCustomToolNames(item)));
                }
                else
                {
                    return(new DropDownEditorListBox(editorService, CustomToolsService.GetCustomToolNames()));
                }
            }
Exemple #35
0
 public void End()
 {
     edSvc = null;
     Value = null;
 }
Exemple #36
0
 public IDControl(byte val, IWindowsFormsEditorService edSvc)
 {
     Value      = val;
     this.edSvc = edSvc;
     InitializeComponent();
 }
Exemple #37
0
 protected internal virtual DialogResult ShowEditorDialog(IWindowsFormsEditorService edSvc)
 {
     throw new NotImplementedException();
 }
Exemple #38
0
 public BackgroundEditorControl(IWindowsFormsEditorService edSvc)
     : this()
 {
     _edSvc = edSvc;
 }
Exemple #39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DropdownColorBlender"/> class.
 /// </summary>
 /// <param name="editorService">The editor service.</param>
 public DropdownColorBlender(IWindowsFormsEditorService editorService)
 {
     InitializeComponent();
     _editorService = editorService;
 }
 /// <summary>
 ///  Sets the internal IWindowsFormsEditorService to null
 /// </summary>
 public void Stop()
 {
     _edSvc = null;
 }
Exemple #41
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService editorService = null;

            if (provider != null)
            {
                editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            }

            if (editorService == null)
            {
                return(value);
            }

            bool         singleSel = true;
            SP0256Timbre tim       = context.Instance as SP0256Timbre;

            SP0256Timbre[] tims = value as SP0256Timbre[];
            if (tims != null)
            {
                tim       = tims[0];
                singleSel = false;
            }

            SP0256 inst = null;

            try
            {
                //InstrumentManager.ExclusiveLockObject.EnterReadLock();

                inst = InstrumentManager.FindParentInstrument(InstrumentType.SP0256, tim) as SP0256;
            }
            finally
            {
                //InstrumentManager.ExclusiveLockObject.ExitReadLock();
            }

            using (FormAllophonesEditor frm = new FormAllophonesEditor(inst, tim, singleSel))
            {
                frm.Tag           = context;
                frm.Allophones    = (string)value;
                frm.ValueChanged += (s, e) =>
                {
                    try
                    {
                        //InstrumentManager.ExclusiveLockObject.EnterWriteLock();

                        context.PropertyDescriptor.SetValue(context.Instance, frm.Allophones);
                    }
                    finally
                    {
                        //InstrumentManager.ExclusiveLockObject.ExitWriteLock();
                    }
                };

                DialogResult dr = frm.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    value = frm.Allophones;
                }
                else if (value != null)
                {
                    value = ((string)value + " ").Clone();
                }
            }
            return(value);
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (_editorService != null && context.Instance != null)
            {
                // CR modifying to accomodate PropertyBag
                Type   instanceType = null;
                object objinfo      = null;
                TypeHelper.GetChildPropertyContextInstanceObject(context, ref objinfo, ref instanceType);
                var propInfo  = instanceType.GetProperty("LoadParameters");
                var paramColl = (ParameterCollection)propInfo.GetValue(objinfo, null);

                if (instanceType == typeof(ChildProperty))
                {
                    _instance = GeneratorController.Current.MainForm.ProjectPanel.ListObjects.SelectedItem;
                }
                else
                {
                    //_instance = context.Instance;
                    _instance = objinfo;
                }

                var criteriaInfo    = typeof(CslaObjectInfo).GetProperty("CriteriaObjects");
                var criteriaObjects = criteriaInfo.GetValue(_instance, null);

                _lstProperties.Items.Clear();
                _lstProperties.Items.Add(new DictionaryEntry("(None)", new Parameter()));
                foreach (Criteria crit in (CriteriaCollection)criteriaObjects)
                {
                    if (crit.GetOptions.Factory || crit.GetOptions.AddRemove || crit.GetOptions.DataPortal)
                    {
                        foreach (var prop in crit.Properties)
                        {
                            _lstProperties.Items.Add(new DictionaryEntry(crit.Name + "." + prop.Name,
                                                                         new Parameter(crit, prop)));
                        }
                    }
                }
//                _lstProperties.Sorted = true;

                foreach (var param in paramColl)
                {
                    var key = param.Criteria.Name + "." + param.Property.Name;
                    for (var entry = 0; entry < _lstProperties.Items.Count; entry++)
                    {
                        if (key == ((DictionaryEntry)_lstProperties.Items[entry]).Key.ToString())
                        {
                            var val = (Parameter)((DictionaryEntry)_lstProperties.Items[entry]).Value;
                            _lstProperties.SelectedItems.Add(new DictionaryEntry(key, val));
                        }
                    }
                }

                _lstProperties.SelectedIndexChanged += LstPropertiesSelectedIndexChanged;
                _editorService.DropDownControl(_lstProperties);
                _lstProperties.SelectedIndexChanged -= LstPropertiesSelectedIndexChanged;

                if (_lstProperties.SelectedItems.Count > 0)
                {
                    var param = new ParameterCollection();
                    foreach (var item in _lstProperties.SelectedItems)
                    {
                        param.Add((Parameter)((DictionaryEntry)item).Value);
                    }
                    return(param);
                }

                return(new ParameterCollection());
            }

            return(value);
        }
 public MpeTextAreaEditorForm(string textValue, IWindowsFormsEditorService editorService)
 {
     InitializeComponent();
     EditorService = editorService;
     TextValue     = textValue;
 }
Exemple #44
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (_editorService != null && context.Instance != null)
            {
                // CR modifying to accomodate PropertyBag
                Type   instanceType = null;
                object objinfo      = null;
                ContextHelper.GetAssociativeEntityContextInstanceObject(context, ref objinfo, ref instanceType);
                PropertyInfo propInfo;
                var          associativeEntity = (AssociativeEntity)objinfo;
                string       cslaObject;
                if (context.PropertyDescriptor.DisplayName == "Primary Load Parameters" &&
                    associativeEntity.MainObject != null)
                {
                    propInfo = instanceType.GetProperty("MainLoadParameters");
//                    if (associativeEntity.MainLoadingScheme == LoadingScheme.SelfLoad)
//                        cslaObject = associativeEntity.MainCollectionTypeName;
//                    else
                    cslaObject = associativeEntity.MainObject;
                }
                else
                {
                    propInfo = instanceType.GetProperty("SecondaryLoadParameters");
//                    if (associativeEntity.SecondaryLoadingScheme == LoadingScheme.SelfLoad)
//                        cslaObject = associativeEntity.SecondaryCollectionTypeName;
//                    else
                    cslaObject = associativeEntity.SecondaryObject;
                }
                var paramColl = (ParameterCollection)propInfo.GetValue(objinfo, null);
                //var objectColl = GeneratorController.Current.MainForm.ProjectPanel.Objects;
                _instance = GeneratorController.Current.CurrentUnit.CslaObjects.FindByGenericName(cslaObject);

                var criteriaInfo    = typeof(CslaObjectInfo).GetProperty("CriteriaObjects");
                var criteriaObjects = criteriaInfo.GetValue(_instance, null);

                _lstProperties.Items.Clear();
                _lstProperties.Items.Add(new DictionaryEntry("(None)", new Parameter()));
                foreach (var crit in (CriteriaCollection)criteriaObjects)
                {
                    if (crit.GetOptions.Factory || crit.GetOptions.AddRemove || crit.GetOptions.DataPortal)
                    {
                        foreach (var prop in crit.Properties)
                        {
                            _lstProperties.Items.Add(new DictionaryEntry(crit.Name + "." + prop.Name,
                                                                         new Parameter(crit.Name, prop.Name)));
                        }
                    }
                }
                _lstProperties.Sorted = true;

                foreach (var param in paramColl)
                {
                    var key = param.CriteriaName + "." + param.PropertyName;
                    for (var entry = 0; entry < _lstProperties.Items.Count; entry++)
                    {
                        if (key == ((DictionaryEntry)_lstProperties.Items[entry]).Key.ToString())
                        {
                            var val = (Parameter)((DictionaryEntry)_lstProperties.Items[entry]).Value;
                            _lstProperties.SelectedItems.Add(new DictionaryEntry(key, val));
                        }
                    }
                }

                _lstProperties.SelectedIndexChanged += LstPropertiesSelectedIndexChanged;
                _editorService.DropDownControl(_lstProperties);
                _lstProperties.SelectedIndexChanged -= LstPropertiesSelectedIndexChanged;

                if (_lstProperties.SelectedItems.Count > 0)
                {
                    var param = new ParameterCollection();
                    foreach (var item in _lstProperties.SelectedItems)
                    {
                        param.Add((Parameter)((DictionaryEntry)item).Value);
                    }
                    return(param);
                }

                return(new ParameterCollection());
            }

            return(value);
        }
 /// <summary>
 ///  Sets the internal IWindowsFormsEditorService to the given edSvc, and calls SetSelection on the given value
 /// </summary>
 public void Start(IWindowsFormsEditorService edSvc, object value)
 {
     _edSvc    = edSvc;
     clickSeen = false;
     SetSelection(value, Nodes);
 }
Exemple #46
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                var v = (string)value;

                Store            = ResolveStore(context.Instance);
                this.Referential = ReferentialResolver.Instance.GetReferential(Store);
                if (this.Referential == null)
                {
                    throw new Exception("referential can't be loded");
                }

                TreeView control = new TreeView();

                var io = List();
                if (io == null)
                {
                    return(value);
                }

                control.Nodes.AddRange(io.ToArray());

                //control.DataSource = io;
                //control.DisplayMember = this.DisplayMember;
                //control.ValueMember = this.ValueMember;

                if (!String.IsNullOrEmpty((string)value))
                {
                    foreach (object item in io)
                    {
                        if (Evaluate(item, v))
                        {
                            //control.SelectedItem = item;
                            break;
                        }
                    }
                }

                Close          = () => edSvc.CloseDropDown();
                control.Click += control_Click;
                edSvc.DropDownControl(control);
                control.Click -= control_Click;



                value = string.Empty;

                try
                {
                    value = GetValue(control.SelectedNode);
                }
                catch (Exception)
                {
                }
            }

            return(value);
        }
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                editorSvc = provider == null ? null :
                            (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (context != null && context.Instance != null && editorSvc != null)
                {
                    // создание и заполнение выпадающего списка
                    listBox   = new ListBox();
                    textBrush = new SolidBrush(listBox.ForeColor);

                    listBox.BorderStyle    = BorderStyle.None;
                    listBox.ItemHeight     = 16;
                    listBox.IntegralHeight = false;
                    listBox.DrawMode       = DrawMode.OwnerDrawFixed;
                    listBox.Items.AddRange(colorArr);

                    Type instanceType = context.Instance.GetType();
                    if (instanceType == typeof(SchemeView.Scheme) && context.PropertyDescriptor.Name != "ForeColor" ||
                        instanceType == typeof(SchemeView.StaticText) ||
                        instanceType == typeof(SchemeView.StaticPicture))
                    {
                        listBox.Items.RemoveAt(0); // запрет цвета, который определяется статусом входного канала
                    }
                    int n = listBox.Items.Count <= ItemCount ? listBox.Items.Count : ItemCount;
                    listBox.Height = n * listBox.ItemHeight;

                    listBox.DrawItem += listBox_DrawItem;
                    listBox.Click    += listBox_Click;
                    listBox.KeyDown  += listBox_KeyDown;

                    // выбор элемента в выпадающем списке
                    string selColor = value is string?((string)value).Trim().ToLower() : "";

                    if (selColor != "")
                    {
                        int cnt = listBox.Items.Count;
                        for (int i = 0; i < cnt; i++)
                        {
                            object item = listBox.Items[i];
                            if (item is string)
                            {
                                if (selColor == ((string)item).ToLower())
                                {
                                    listBox.SelectedIndex = i;
                                    break;
                                }
                            }
                            else if (item is Color)
                            {
                                if (selColor == ((Color)item).Name.ToLower())
                                {
                                    listBox.SelectedIndex = i;
                                    break;
                                }
                            }
                        }
                    }

                    // отображение выпадающего списка
                    editorSvc.DropDownControl(listBox);

                    // установка выбранного значения
                    object selItem = listBox.SelectedItem;
                    if (selItem is string)
                    {
                        value = selItem;
                    }
                    else if (selItem is Color)
                    {
                        value = ((Color)selItem).Name;
                    }
                }

                return(value);
            }
 public EditablePatternControl(IWindowsFormsEditorService editorService)
 {
     this.editorService = editorService;
     this.InitializeComponent();
     this.txEdit.Focus();
 }
Exemple #49
0
 public void End()
 {
     _editorService = null;
     Value          = null;
 }
Exemple #50
0
        /// <summary>
        /// Overrides the method used to provide basic behaviour for selecting editor.
        /// Shows our custom control for editing the value.
        /// </summary>
        /// <param name="context">The context of the editing control</param>
        /// <param name="provider">A valid service provider</param>
        /// <param name="value">The current value of the object to edit</param>
        /// <returns>The new value of the object</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null &&
                context.Instance != null &&
                provider != null)
            {
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    // Create a CheckedListBox and populate it with all the enum values
                    clb              = new CheckedListBox();
                    clb.BorderStyle  = BorderStyle.FixedSingle;
                    clb.CheckOnClick = true;
                    clb.MouseDown   += new MouseEventHandler(this.OnMouseDown);
                    clb.MouseMove   += new MouseEventHandler(this.OnMouseMoved);

                    tooltipControl            = new ToolTip();
                    tooltipControl.ShowAlways = true;

                    foreach (string name in Enum.GetNames(context.PropertyDescriptor.PropertyType))
                    {
                        // Get the enum value
                        object enumVal = Enum.Parse(context.PropertyDescriptor.PropertyType, name);
                        // Get the int value
                        int intVal = (int)Convert.ChangeType(enumVal, typeof(int));

                        // Get the description attribute for this field
                        System.Reflection.FieldInfo fi    = context.PropertyDescriptor.PropertyType.GetField(name);
                        DescriptionAttribute[]      attrs = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);

                        // Store the the description
                        string tooltip = attrs.Length > 0 ? attrs[0].Description : string.Empty;

                        // Get the int value of the current enum value (the one being edited)
                        int intEdited = (int)Convert.ChangeType(value, typeof(int));

                        // Creates a clbItem that stores the name, the int value and the tooltip
                        clbItem item = new clbItem(enumVal.ToString(), intVal, tooltip);

                        // Get the checkstate from the value being edited
                        //bool checkedItem = (intEdited & intVal) > 0;
                        bool checkedItem = (intEdited & intVal) == intVal;

                        // Add the item with the right check state
                        clb.Items.Add(item, checkedItem);
                    }

                    // Show our CheckedListbox as a DropDownControl.
                    // This methods returns only when the dropdowncontrol is closed
                    edSvc.DropDownControl(clb);

                    // Get the sum of all checked flags
                    int result = 0;
                    foreach (clbItem obj in clb.CheckedItems)
                    {
                        //result += obj.Value;
                        result |= obj.Value;
                    }

                    // return the right enum value corresponding to the result
                    return(Enum.ToObject(context.PropertyDescriptor.PropertyType, result));
                }
            }

            return(value);
        }
Exemple #51
0
        public void SetData(ITypeDescriptorContext context, IWindowsFormsEditorService editorService, object value)
        {
            m_editorService = editorService;

            m_PropertyType = context.PropertyDescriptor.PropertyType;
            if (m_PropertyType.IsEnum)
            {
                m_EnumDataType = Enum.GetUnderlyingType(m_PropertyType);
                m_bFlag        = (m_PropertyType.GetCustomAttributes(typeof(FlagsAttribute), false).Length > 0);
            }
            else if (context.PropertyDescriptor is CustomPropertyDescriptor && (((CustomPropertyDescriptor)context.PropertyDescriptor).PropertyFlags & PropertyFlags.IsFlag) != 0)
            {
                m_EnumDataType = typeof(Int32);
                m_bFlag        = true;
            }

            m_Value = value;

            listViewEnum.Items.Clear( );
            listViewEnum.CheckBoxes = m_bFlag;

            if (!(context.PropertyDescriptor is CustomPropertyDescriptor))
            {
                throw new Exception("PropertyDescriptorManager has not been installed on this instance.");
            }

            CustomPropertyDescriptor cpd = context.PropertyDescriptor as CustomPropertyDescriptor;

            // create list view items for the visible Enum items
            foreach (StandardValueAttribute sva in cpd.StatandardValues)
            {
                if (sva.Visible)
                {
                    ListViewItem lvi = new ListViewItem( );
                    lvi.Text      = sva.DisplayName;
                    lvi.ForeColor = (sva.Enabled == true ? lvi.ForeColor : Color.FromKnownColor(KnownColor.GrayText));
                    lvi.Tag       = new TagItem(sva);
                    listViewEnum.Items.Add(lvi);
                }
            }

            UpdateCheckState( );

            // make initial selection
            if (m_bFlag)
            {
                // select the first checked one
                foreach (ListViewItem lvi in listViewEnum.CheckedItems)
                {
                    lvi.Selected = true;
                    lvi.EnsureVisible( );
                    break;
                }
            }
            else
            {
                foreach (ListViewItem lvi in listViewEnum.Items)
                {
                    TagItem ti = lvi.Tag as TagItem;
                    if (ti.Item.Value.Equals(m_Value))
                    {
                        lvi.Selected = true;
                        lvi.EnsureVisible( );
                        break;
                    }
                }
            }
        }
 public RecessEditorControl(IWindowsFormsEditorService editorService)
 {
     InitializeComponent();
     this.editorService = editorService;
 }
Exemple #53
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            ListBox listBox = new ListBox();

            listBox.DisplayMember   = "Name"; // EnumItem 'Name' property
            listBox.IntegralHeight  = true;
            listBox.SelectionMode   = SelectionMode.One;
            listBox.MouseClick     += OnListBoxMouseClick;
            listBox.KeyDown        += OnListBoxKeyDown;
            listBox.PreviewKeyDown += OnListBoxPreviewKeyDown;

            Type enumType = value.GetType();

            if (!enumType.IsEnum)
            {
                throw new InvalidOperationException();
            }

            var           converter = context.PropertyDescriptor.Converter;
            List <object> vs        = null;

            if (converter != null && converter.GetStandardValuesSupported())
            {
                vs = new List <object>();
                var svs = converter.GetStandardValues();
                foreach (var sv in svs)
                {
                    vs.Add(sv);
                }
            }

            foreach (FieldInfo fi in enumType.GetFields(BindingFlags.Public | BindingFlags.Static))
            {
                EnumItem item = new EnumItem();
                item.Value = fi.GetValue(null);
                if (vs != null && !vs.Contains(item.Value))
                {
                    continue;
                }

                object[] atts = fi.GetCustomAttributes(typeof(DescriptionAttribute), true);
                if (atts != null && atts.Length > 0)
                {
                    item.Name = ((DescriptionAttribute)atts[0]).Description;
                }
                else
                {
                    item.Name = fi.Name;
                }

                int index = listBox.Items.Add(item);

                if (fi.Name == value.ToString())
                {
                    listBox.SetSelected(index, true);
                }
            }

            _cancel = false;
            _editorService.DropDownControl(listBox);
            if (_cancel || listBox.SelectedIndices.Count == 0)
            {
                return(value);
            }

            return(((EnumItem)listBox.SelectedItem).Value);
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (_editorService != null)
            {
                if (context.Instance != null)
                {
                    // CR modifying to accomodate PropertyBag
                    Type   instanceType = null;
                    object objinfo      = null;
                    TypeHelper.GetValuePropertyContextInstanceObject(context, ref objinfo, ref instanceType);
                    var obj = (ValueProperty)objinfo;
                    _lstProperties.Items.Clear();
                    _lstProperties.Items.Add("(None)");
                    if (obj.PrimaryKey == ValueProperty.UserDefinedKeyBehaviour.Default)
                    {
                        // Warehouse.FK_Models_Brands - FK=Models.BrandID - PK = Brands.BrandID
                        // GeneralStore.FK_Products_ProdFamilies
                        //      FK=Products.ProdFamilyId
                        //      PK=ProdFamily.ProdFamilyId
                        //
                        foreach (var constraint in GeneratorController.Catalog.ForeignKeyConstraints)
                        {
                            // get constraints with table match for PK or FK
                            if (obj.DbBindColumn.ObjectName == constraint.PKTable.ObjectName ||
                                obj.DbBindColumn.ObjectName == constraint.ConstraintTable.ObjectName)

                            // get constraints with table match for Constraint FK
                            //if (obj.DbBindColumn.ObjectName == constraint.ConstraintTable.ObjectName)
                            {
                                _lstProperties.Items.Add(constraint.ConstraintName);
                            }
                        }
                        _lstProperties.Sorted = true;

                        if (_lstProperties.Items.Contains(obj.FKConstraint))
                        {
                            _lstProperties.SelectedItem = obj.FKConstraint;
                        }
                        else
                        {
                            _lstProperties.SelectedItem = "(None)";
                        }

                        _editorService.DropDownControl(_lstProperties);
                        if (_lstProperties.SelectedIndex < 0 || _lstProperties.SelectedItem.ToString() == "(None)")
                        {
                            return(string.Empty);
                        }

                        return(_lstProperties.SelectedItem.ToString());
                    }

                    _lstProperties.Items.Add("(Illegal)");
                    _editorService.DropDownControl(_lstProperties);
                    return(string.Empty);
                }
            }

            return(value);
        }
Exemple #55
0
        public override object EditValue(ITypeDescriptorContext context,
                                         IServiceProvider provider,
                                         object value)
        {
            if ((context == null) || (provider == null))
            {
                return(base.EditValue(context, provider, value));
            }

            // Access the Property Browser's UI display service
            IWindowsFormsEditorService editorService =
                (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (editorService == null)
            {
                return(base.EditValue(context, provider, value));
            }

            // Create an instance of the UI editor form
            IReportItem iri = context.Instance as IReportItem;

            if (iri == null)
            {
                return(base.EditValue(context, provider, value));
            }
            PropertyReportItem pri = iri.GetPRI();

            PropertyTable pt = value as PropertyTable;

            if (pt == null)
            {
                return(base.EditValue(context, provider, value));
            }

            //SingleCtlDialog scd = new SingleCtlDialog(pri.DesignCtl, pri.Draw, pri.Nodes, SingleCtlTypeEnum.BorderCtl, pb.Names);
            DesignCtl     dc = pri.DesignCtl;
            DesignXmlDraw dp = dc.DrawCtl;

            if (dp.SelectedCount != 1)
            {
                return(base.EditValue(context, provider, value));
            }
            XmlNode riNode = dp.SelectedList[0];
            XmlNode table  = dp.GetTableFromReportItem(riNode);

            if (table == null)
            {
                return(base.EditValue(context, provider, value));
            }
            XmlNode tc = dp.GetTableColumn(riNode);
            XmlNode tr = dp.GetTableRow(riNode);

            List <XmlNode> ar = new List <XmlNode>();             // need to put this is a list for dialog to handle

            ar.Add(table);
            dc.UndoObject.StartUndoGroup("Table Dialog");
            using (PropertyDialog pd = new PropertyDialog(dp, ar, PropertyTypeEnum.ReportItems, tc, tr))
            {
                // Display the UI editor dialog
                DialogResult dr = editorService.ShowDialog(pd);
                dc.UndoObject.EndUndoGroup(pd.Changed || dr == DialogResult.OK);
                if (pd.Changed || dr == DialogResult.OK)
                {
                    dp.Invalidate();
                    return(new PropertyTable(dp, dc, pt.Nodes));
                }

                return(base.EditValue(context, provider, value));
            }
        }