Example #1
0
        private void OnToggleValueChanged(EditorType editorType, bool value)
        {
            GameObject emptyEditor = m_editors[(int)EditorType.Empty];

            if (emptyEditor)
            {
                emptyEditor.gameObject.SetActive(!value);
            }

            GameObject editor = m_editors[(int)editorType];

            if (editor)
            {
                editor.SetActive(value);
                if (value)
                {
                    m_editor.Tools.Custom = editorType;
                }
            }

            if (Projector != null)
            {
                if (!value || (editorType == EditorType.Empty || editorType == EditorType.Settings || editorType == EditorType.Selection_Handles))
                {
                    Projector.gameObject.SetActive(false);
                }
                else
                {
                    Projector.gameObject.SetActive(true);
                }
            }
        }
 public void SelectedEditorType(EditorType type, ref bool _switch)
 {
     editorType     = type;
     IsTree         = false;
     IsStateMachine = false;
     _switch        = true;
 }
Example #3
0
        // 创建绑定列

        /*
         * <f:Label runat = "server" ID ="lblId" Label="ID" Hidden="false" />
         * <f:TextBox runat = "server" ID="tbxYear"            Label="年度(YYYY)" Required="true" ShowRedStar="true" />
         * <f:NumberBox runat = "server" ID="tbxCityGDP"         Label=" 全市生产总值        " DecimalPrecision="2" />
         */
        public static FineUI.Field CreateEditor(string dataField, string title, EditorType editor, bool required = false, int precision = 2)
        {
            switch (editor)
            {
            case EditorType.Label:            return(new FineUI.Label()
                {
                    ID = dataField, Label = title, Hidden = false
                });

            case EditorType.TextBox:          return(new FineUI.TextBox()
                {
                    ID = dataField, Label = title, Required = required, ShowRedStar = required
                });

            case EditorType.TextArea:         return(new FineUI.TextArea()
                {
                    ID = dataField, Label = title, Required = required, ShowRedStar = required, Height = 200
                });

            case EditorType.HtmlEditor:       return(new FineUI.HtmlEditor()
                {
                    ID = dataField, Label = title, ShowRedStar = required, Height = 400
                });

            case EditorType.MarkdownEditor:   return(new FineUI.TextArea()
                {
                    ID = dataField, Label = title, Required = required, ShowRedStar = required, Height = 400
                });

            case EditorType.NumberBox:        return(new FineUI.NumberBox()
                {
                    ID = dataField, Label = title, Required = required, ShowRedStar = required, DecimalPrecision = precision
                });

            case EditorType.DatePicker:       return(new FineUI.DatePicker()
                {
                    ID = dataField, Label = title, Required = required, ShowRedStar = required, SelectedDate = DateTime.Today
                });

            case EditorType.TimePicker:       return(new FineUI.TimePicker()
                {
                    ID = dataField, Label = title, Required = required, ShowRedStar = required, SelectedDate = DateTime.Now
                });

            case EditorType.DateTimePicker:   return(new FineUI.DatePicker()
                {
                    ID = dataField, Label = title, Required = required, ShowRedStar = required, SelectedDate = DateTime.Now
                });

            case EditorType.Image:            return(new FineUI.Image()
                {
                    ID = dataField, Label = title, ShowRedStar = required
                });

            default:                          return(new FineUI.TextBox()
                {
                    ID = dataField, Label = title, Required = required, ShowRedStar = required
                });
            }
        }
Example #4
0
        public EditorAttribute(EditorType type, string items = null)
        {
            this.EditorType = type;

            if (!string.IsNullOrEmpty(items))
            {
                items = items.Trim();
                if (items.StartsWith('{') && items.EndsWith('}'))
                {
                    this.Items = new Dictionary <string, object>();

                    var pairs = items.Substring(1, items.Length - 2)
                                .Split(',', StringSplitOptions.RemoveEmptyEntries);
                    foreach (var pair in pairs)
                    {
                        var kv = pair.Trim();
                        if (kv.StartsWith('{') && kv.EndsWith('}'))
                        {
                            var kvs = kv.Substring(1, kv.Length - 2)
                                      .Split(':', StringSplitOptions.RemoveEmptyEntries);
                            if (kvs.Length == 2)
                            {
                                string key   = kvs[0].Trim();
                                string value = kvs[1].Trim();
                                this.Items.Add(key, value);
                            }
                            else
                            {
                                throw new ArgumentException();
                            }
                        }
                        else
                        {
                            throw new ArgumentException();
                        }
                    }
                    if (this.Items.Count > 0)
                    {
                        //尝试对全是数值的values进行转换
                        if (this.Items.Values.All(v => decimal.TryParse(v.ToString(), out _)))
                        {
                            for (int i = 0; i < this.Items.Count; i++)
                            {
                                var key = this.Items.Keys.ElementAt(i);
                                decimal.TryParse(this.Items[key].ToString(), out var value);
                                this.Items[key] = value;
                            }
                        }
                    }
                    else
                    {
                        this.Items = null;
                    }
                }
                else
                {
                    throw new ArgumentException();
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DataEditorAttribute"/> class.
        /// </summary>
        /// <param name="alias">The unique identifier of the editor.</param>
        /// <param name="type">The type of the editor.</param>
        /// <param name="name">The friendly name of the editor.</param>
        /// <param name="view">The view to use to render the editor.</param>
        /// <remarks>
        /// <para>Set <paramref name="view"/> to <see cref="NullView"/> to explicitely set the view to null.</para>
        /// <para>Otherwise, <paramref name="view"/> cannot be null nor empty.</para>
        /// </remarks>
        public DataEditorAttribute(string alias, EditorType type, string name, string view)
        {
            if ((type & ~(EditorType.PropertyValue | EditorType.MacroParameter)) > 0)
            {
                throw new ArgumentOutOfRangeException(nameof(type), $"Not a valid {typeof(EditorType)} value.");
            }
            Type = type;

            if (string.IsNullOrWhiteSpace(alias))
            {
                throw new ArgumentNullOrEmptyException(nameof(alias));
            }
            Alias = alias;

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullOrEmptyException(nameof(name));
            }
            Name = name;

            if (string.IsNullOrWhiteSpace(view))
            {
                throw new ArgumentNullOrEmptyException(nameof(view));
            }
            View = view == NullView ? null : view;
        }
Example #6
0
        public static ForumEditor CreateEditorFromType(EditorType etValue)
        {
            switch (etValue)
            {
            case EditorType.Text: return(new TextEditor());

            case EditorType.BBCode: return(new BBCodeEditor());

            case EditorType.FCKv2: return(new FCKEditorV2());

            case EditorType.FreeTextBox: return(new FreeTextBoxEditor());

            case EditorType.FCKv1: return(new FCKEditorV1());

            case EditorType.BasicBBCode: return(new BasicBBCodeEditor());

            case EditorType.FreeTextBoxv3: return(new FreeTextBoxEditorv3());

            case EditorType.TinyMCE: return(new TinyMCEEditor());

            case EditorType.RadEditor: return(new RadEditor());
            }

            return(null);
        }
        public InteractionLayer(ISceneContext sceneContext, ThemeConfig theme, EditorType editorType = EditorType.Part)
        {
            this.sceneContext = sceneContext;
            this.EditorMode   = editorType;
            this.theme        = theme;

            scene = sceneContext.Scene;

            gCodeMeshColor = new Color(theme.PrimaryAccentColor, 35);

            BuildVolumeColor = new ColorF(.2, .8, .3, .2).ToColor();

            floorDrawable = new FloorDrawable(editorType, sceneContext, this.BuildVolumeColor, theme);

            if (ViewOnlyTexture == null)
            {
                // TODO: What is the ViewOnlyTexture???
                UiThread.RunOnIdle(() =>
                {
                    ViewOnlyTexture = new ImageBuffer(32, 32, 32);
                    var graphics2D  = ViewOnlyTexture.NewGraphics2D();
                    graphics2D.Clear(Color.White);
                    graphics2D.FillRectangle(0, 0, ViewOnlyTexture.Width / 2, ViewOnlyTexture.Height, Color.LightGray);
                    // request the texture so we can set it to repeat
                    var plugin = ImageGlPlugin.GetImageGlPlugin(ViewOnlyTexture, true, true, false);
                });
            }

            iavMappings.Add(typeof(ImageObject3D), new List <InteractionVolume> {
                new MoveInZControl(this)
            });

            // Register listeners
            sceneContext.Scene.SelectionChanged += this.Scene_SelectionChanged;
        }
        public WorldEditor(SegmentManager parent)
        {
            ParentSegmentManager = parent;

            _blockMasks = new List <BlockMask>();
            _blockMasks.Add(BlockHelper.BlockMasks.Debug);
            _blockMasks.Add(BlockHelper.BlockMasks.Soil);

            _topRampMasks = new List <BlockMask>();
            _topRampMasks.Add(BlockHelper.RampBlockMasks.Top.Debug);
            _topRampMasks.Add(BlockHelper.RampBlockMasks.Top.Soil);

            _bottomRampMasks = new List <BlockMask>();
            _bottomRampMasks.Add(BlockHelper.RampBlockMasks.Bottom.Debug);
            _bottomRampMasks.Add(BlockHelper.RampBlockMasks.Bottom.Soil);

            _index = 0;

            _selectedType = EditorType.Blocks;

            _keyboardCursor = new SegmentLocation(Vector3.Zero);

            _RampBlockDirection = RampBlockDirection.North;

            _activeBlockMask = BlockHelper.BlockMasks.Soil;

            _previewData = new BlockVertexData();
        }
Example #9
0
        public IPropertyEditorConfig AddPropertyEditor(string alias, string name, EditorType editorType)
        {
            var editor = new PropertyEditorConfig(alias, name, GetEditorByEditorType(editorType));

            _editors.Add(editor);
            return(editor);
        }
Example #10
0
    /// <inheritdoc />
    protected override IDataEditor Create(Type objectType, string path, JObject jobject)
    {
        // in PackageManifest, property editors are IConfiguredDataEditor[] whereas
        // parameter editors are IDataEditor[] - both will end up here because we handle
        // IDataEditor and IConfiguredDataEditor implements it, but we can check the
        // type to figure out what to create
        EditorType type = EditorType.PropertyValue;

        var isPropertyEditor = path.StartsWith("propertyEditors[");

        if (isPropertyEditor)
        {
            // property editor
            jobject["isPropertyEditor"] = JToken.FromObject(true);
            if (jobject["isParameterEditor"] is JToken jToken && jToken.Value <bool>())
            {
                type |= EditorType.MacroParameter;
            }
        }
        else
        {
            // parameter editor
            type = EditorType.MacroParameter;
        }

        return(new DataEditor(_dataValueEditorFactory, type));
    }
 public EyeDropperColorPickerPropertyEditor(
     IDataValueEditorFactory dataValueEditorFactory,
     IIOHelper ioHelper,
     EditorType type = EditorType.PropertyValue)
     : this(dataValueEditorFactory, ioHelper, StaticServiceProvider.Instance.GetRequiredService <IEditorConfigurationParser>(), type)
 {
 }
Example #12
0
        public static bool Inspect_so <T>(Editor editor) where T : ScriptableObject
        {
            _editor = editor;

            editorType = EditorType.ScriptableObject;

            var o  = (T)editor.target;
            var so = editor.serializedObject;

            pegi.inspectedTarget = editor.target;

            var pgi = o as IPEGI;

            if (pgi != null)
            {
                start(so);

                var changed = !pegi.PopUpService.ShowingPopup() && pgi.Inspect();
                end(o);
                return(changed);
            }

            editor.DrawDefaultInspector();

            return(false);
        }
Example #13
0
        /// <summary>
        /// Get a parameter's value at application area
        /// </summary>
        /// <param name="controlName">
        /// Specified Parameter
        /// </param>
        /// <param name="editorType">
        /// Type of editor
        /// </param>
        /// <param name="cachedContainer">
        /// Container for cached GUI-control paths
        /// </param>
        /// <returns>
        /// String: parameter value
        /// </returns>
        private string GetParameterValue(string controlName, EditorType editorType, Container cachedContainer)
        {
            // Enumerations.EditorType editorType = GetEditorType(controlName);
            switch (editorType)
            {
            case EditorType.ComboBox:
            {
                return(this.GetComboBoxValue(controlName, cachedContainer));
            }

            case EditorType.EditField:
            {
                return(this.GetEditFieldValue(controlName, cachedContainer));
            }

            case EditorType.EditFieldReadOnly:
            {
                return(this.GetComboBoxValue(controlName, cachedContainer));
            }

            case EditorType.CheckBox:
            {
                return(this.GetCheckBoxValue(controlName, cachedContainer));
            }

            default:
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Extension of switch()case necessary.");
                return(null);
            }
            }
        }
Example #14
0
        public void SetEditor(EditorType type)
        {
            ControlPanel.Controls.Clear();
            Control editor = null;

            switch (type)
            {
            case EditorType.Int:
                editor = new NumericEditor();
                ((NumericUpDown)editor.Controls[0]).DecimalPlaces = 0;
                break;

            case EditorType.Decimal:
                editor = new NumericEditor();
                ((NumericUpDown)editor.Controls[0]).DecimalPlaces = 2;
                break;

            case EditorType.Date:
                editor = new DateValueEditor();
                break;

            case EditorType.Text:
            default:
                editor = new TextValueEditor();
                break;
            }
            editor.Dock = DockStyle.Fill;
            ControlPanel.Controls.Add(editor /*new TextValueEditor() { Dock = DockStyle.Fill }*/);
            this.ResumeLayout();
        }
Example #15
0
        /// <summary>
        /// Set parameter's value
        /// </summary>
        /// <param name="parameterName">
        /// Parameter to change
        /// </param>
        /// <param name="inputValue">
        /// Input value
        /// </param>
        /// <param name="confirm">
        /// Determines whether to confirm the changed value.
        /// </param>
        /// <returns>
        /// <br>True: If call worked fine</br>
        ///     <br>False: If an error occurred</br>
        /// </returns>
        public bool SetParameterValue(string parameterName, string inputValue, bool confirm)
        {
            try
            {
                Container cachedContainer;
                Host.Local.TryFindSingle(ApplicationPaths.StrApplAreaDtmDisplayArea, DefaultValues.iTimeoutDefault, out cachedContainer);
                string     controlName = this.GetControlname(parameterName, cachedContainer);
                EditorType editor      = this.GetEditorType(controlName, cachedContainer);

                switch (editor)
                {
                case EditorType.ComboBox:
                {
                    return(this.SetComboBoxValue(controlName, inputValue, cachedContainer, confirm));
                }

                case EditorType.EditField:
                {
                    return(this.SetEditFieldValue(controlName, inputValue, cachedContainer, confirm));
                }

                default:
                {
                    Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Extension of switch()case necessary.");
                    return(false);
                }
                }
            }
            catch (Exception exception)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(false);
            }
        }
Example #16
0
        /// <summary>
        /// Get a parameter's internal type
        /// </summary>
        /// <param name="editorType">
        /// Type of editor
        /// </param>
        /// <returns>
        /// Enumeration.ParameterType: parameter type
        /// </returns>
        private ParameterType GetParameterType(EditorType editorType)
        {
            switch (editorType)
            {
            case EditorType.ComboBox:
            {
                return(ParameterType.Enumeration);
            }

            case EditorType.EditField:
            {
                return(ParameterType.Text);
            }

            case EditorType.EditFieldReadOnly:
            {
                return(ParameterType.Text);
            }

            case EditorType.CheckBox:
            {
                return(ParameterType.BitEnumeration);
            }

            default:
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Extension of switch()case necessary.");
                return(ParameterType.Unknown);
            }
            }
        }
Example #17
0
        public static List <object> GetSearchCaseByType(EditorType editorType)
        {
            switch (editorType)
            {
            case EditorType.Text:
                return(new List <object> {
                    new { Name = "=", Value = "=" }, new { Name = "<>", Value = "<>" }, new { Name = ">", Value = ">=" }, new { Name = "<", Value = "<=" }, new { Name = "Like", Value = "Like" }
                });                                                                                                                                                                                                            //{"=", "<>", ">", "<", "Like"};

            case EditorType.Lookup:
                return(new List <object> {
                    new { Name = "=", Value = "=" }, new { Name = "<>", Value = "<>" }
                });

            case EditorType.Date:
            case EditorType.Datetime:
            case EditorType.Numeric:
                return(new List <object>  {
                    new { Name = "=", Value = "=" }, new { Name = "<>", Value = "<>" }, new { Name = ">", Value = ">=" }, new { Name = "<", Value = "<=" }
                });

            default:
                return(null);
            }
        }
        private void RefreshScriptableTileCache(EditorType type = EditorType.All)
        {
            tileMap.scriptableTileCache.Clear();
            List <ScriptableTile> toRemove = new List <ScriptableTile> ();

            for (int i = 0; i < tileMap.scriptableTileCache.Count; i++)
            {
                if (tileMap.scriptableTileCache [i] == null)
                {
                    toRemove.Add(tileMap.scriptableTileCache [i]);
                }
            }
            AssetDatabase.Refresh();
            tileMap.scriptableTileCache = tileMap.scriptableTileCache.Except(toRemove).ToList();
            string [] guids = AssetDatabase.FindAssets(string.Format("t:{0}", typeof(ScriptableTile)));
            for (int i = 0; i < guids.Length; i++)
            {
                string         assetPath = AssetDatabase.GUIDToAssetPath(guids [i]);
                ScriptableTile asset     = AssetDatabase.LoadAssetAtPath <ScriptableTile> (assetPath);
                if (asset != null && !tileMap.scriptableTileCache.Contains(asset))
                {
                    if (asset is DungeonTileBase && (((DungeonTileBase)asset).editorType == type || type == EditorType.All))
                    {
                        tileMap.scriptableTileCache.Add(asset);
                    }
                }
            }
        }
        public EditEmployee(EditorType editorType)
        {
            InitializeComponent();

            this.editorType = editorType;
            PrepareUI();
        }
Example #20
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        string[] captions = { "地形编辑", "材质编辑", "场景物体编辑" };
        editorTagType = (EditorTagType)GUILayout.Toolbar((int)editorTagType, captions);
        switch (editorTagType)
        {
        case EditorTagType.TerrainEditor:
            DrawTerrainEditorGUI(captions[0]);
            break;

        case EditorTagType.MaterialEditor:
            editorType = EditorType.MaterialEditor;
            DrawMaterialEditorGUI(captions[1]);
            break;

        case EditorTagType.SceneObjEditor:
            editorType = EditorType.SceneObjEditor;
            DrawSceneObjEditorGUI(captions[2]);
            break;
        }

        DrawTerrainMgrUI();
        DrawOperationMgrUI();
    }
        public EditEmployee()
        {
            InitializeComponent();
            editorType = EditorType.Add;

            PrepareUI();
        }
Example #22
0
        public void InitView(String configurationPath, String moduleCode, EditorType selectedType, Boolean allowAnonymous)
        {
            if (!allowAnonymous && UserContext.isAnonymous)
            {
                View.CurrentType = EditorType.none;
            }
            else
            {
                EditorConfiguration config = ServiceEditor.GetConfiguration(configurationPath);
                if (config == null || (config.DefaultEditor == null && !config.Settings.Any()))
                {
                    View.CurrentType = EditorType.none;
                }
                else
                {
                    ModuleEditorSettings mSettings = (config.ModuleSettings == null) ? null : config.ModuleSettings.Where(m => m.ModuleCode == moduleCode).FirstOrDefault();

                    EditorType loadType = (mSettings != null) ?
                                          mSettings.EditorType
                                        :
                                          ((config.Settings.Any() && config.Settings.Where(s => s.EditorType == selectedType).Any())
                                        ? selectedType : ((config.DefaultEditor != null) ? config.DefaultEditor.EditorType:  EditorType.none));
                    View.CurrentType = loadType;
                    EditorSettings    rSettings    = (config.Settings.Any() ? config.Settings.Where(s => s.EditorType == loadType).FirstOrDefault(): null);
                    EditorInitializer eInitializer = GetInitializer(loadType, config, (rSettings != null) ? rSettings: config.DefaultEditor, mSettings);

                    View.LoadEditor(loadType, eInitializer);
                    View.isInitialized = true;
                }
            }
        }
Example #23
0
 static public EditorInfo Organisation(EditorType action = EditorType.Editable)
 {
     return(new EditorInfo("Organisation", "Organisation", typeof(string), "Profile")
     {
         ClaimName = "organisation"
     });
 }
Example #24
0
        public bool IsValid(string value)
        {
            if (EditorType.HasFlag(EditorType.Required) && String.IsNullOrWhiteSpace(value))
            {
                return(false);
            }

            if (!String.IsNullOrWhiteSpace(value))
            {
                if (this.EditorType.HasFlag(EditorType.EmailAddress) &&
                    !value.CheckRegex(ValidationExtensions.EmailAddressRegex))
                {
                    return(false);
                }

                if (this.EditorType.HasFlag(EditorType.Phone) &&
                    !value.CheckRegex(ValidationExtensions.PhoneNumberRegex))
                {
                    return(false);
                }

                if (!value.CheckRegex(RegexPattern))
                {
                    return(false);
                }
            }

            return(true);
        }
        public Object3DControlsLayer(ISceneContext sceneContext, ThemeConfig theme, EditorType editorType = EditorType.Part)
        {
            this.sceneContext = sceneContext;
            this.EditorMode   = editorType;

            scene = sceneContext.Scene;

            gCodeMeshColor = new Color(theme.PrimaryAccentColor, 35);

            BuildVolumeColor = new ColorF(.2, .8, .3, .2).ToColor();

            floorDrawable = new FloorDrawable(editorType, sceneContext, this.BuildVolumeColor, theme);

            if (viewOnlyTexture == null)
            {
                // TODO: What is the ViewOnlyTexture???
                UiThread.RunOnIdle(() =>
                {
                    viewOnlyTexture = new ImageBuffer(32, 32, 32);
                    var graphics2D  = viewOnlyTexture.NewGraphics2D();
                    graphics2D.Clear(Color.White);
                    graphics2D.FillRectangle(0, 0, viewOnlyTexture.Width / 2, viewOnlyTexture.Height, Color.LightGray);
                    // request the texture so we can set it to repeat
                    ImageGlPlugin.GetImageGlPlugin(viewOnlyTexture, true, true, false);
                });
            }

            // Register listeners
            sceneContext.Scene.SelectionChanged += this.Scene_SelectionChanged;
            if (sceneContext.Printer != null)
            {
                sceneContext.Printer.Settings.SettingChanged += this.Settings_SettingChanged;
            }
        }
Example #26
0
 private void setEditor(EditorType editorType)
 {
     if (listEditors.TryGetValue(editorType, out m_currentTableIO))
     {
         m_editorType = editorType;
         removeAllTabs();
     }
 }
Example #27
0
 static public EditorInfo PhoneNumber(EditorType action = EditorType.Editable | EditorType.Phone /*| DbPropertyInfoEditorType.Required*/)
 {
     return(new EditorInfo("PhoneNumber", "Phone number", typeof(string), "Profile")
     {
         EditorType = action,
         ClaimName = JwtClaimTypes.PhoneNumber
     });
 }
Example #28
0
 static public EditorInfo BirthDate(EditorType action = EditorType.Editable | EditorType.Date)
 {
     return(new EditorInfo("BirthDay", "Birthday", typeof(DateTime), "Profile")
     {
         EditorType = action,
         ClaimName = JwtClaimTypes.BirthDate,
     });
 }
Example #29
0
 static public EditorInfo ReadOnlyEmail(EditorType action = EditorType.ReadOnly)
 {
     return(new EditorInfo("Email", "Email", typeof(string), "Profile")
     {
         EditorType = action,
         ClaimName = JwtClaimTypes.Email
     });
 }
Example #30
0
 static public EditorInfo FamilyName(EditorType action = EditorType.Editable)
 {
     return(new EditorInfo("FamilyName", "Familyname", typeof(string), "Profile")
     {
         EditorType = action,
         ClaimName = JwtClaimTypes.FamilyName
     });
 }
Example #31
0
 public AshFile(MainWindow own, string f, EditorType etype)
 {
     et = etype;
     pwner = own;
     sourcefile = f;
     InitializeComponent();
     loadFile();
     tbEdit.TextChanged += delegate(object s, EventArgs e) { NeedsSave = true; };
     NeedsSave = false;
 }
Example #32
0
 void loadFile()
 {
     bool eSave = false;
     pwner.SetStatus(string.Empty);
     img.Source = null;
     txtEditor.Visibility = Visibility.Collapsed;
     binEditor.Visibility = Visibility.Collapsed;
     imgPane.Visibility = Visibility.Collapsed;
     disasm.Visibility = Visibility.Collapsed;
     compi.Visibility = Visibility.Collapsed;
     iledit.Visibility = Visibility.Collapsed;
     resedit.Visibility = Visibility.Collapsed;
     nd = null;
     List<string> viewAsText = new List<string>() { "xaml", "xml" };
     List<string> viewAsImage = new List<string>() { "png", "bmp", "jpg", "ico" };
     long fl = new System.IO.FileInfo(sourcefile).Length;
     pwner.SetStatus(sourcefile, true);
     string stat = string.Format("{0:0} {1}", (fl > 1024 ? (fl / 1024) : fl), (fl > 1024 ? "Kb" : "bytes"));
     if (et == EditorType.Default)
     {
         string e = Path.GetExtension(sourcefile).Substring(1);
         if (viewAsText.Contains(e)) et = EditorType.Text;
         else if (viewAsImage.Contains(e)) et = EditorType.Image;
         else if (e == "dll") et = EditorType.Assembly;
         else et = EditorType.Binary;
     }
     switch (et)
     {
         case EditorType.Text:
             eSave = true;
             try
             {
                 tbEdit.Text = System.IO.File.ReadAllText(sourcefile, Encoding.UTF8);
             }
             catch (Exception e) { MessageBox.Show(e.Message); }
             txtEditor.Visibility = Visibility.Visible;
             break;
         case EditorType.Compiler:
             eSave = true;
             compilerCode.Text = System.IO.File.ReadAllText(sourcefile, Encoding.UTF8);
             compi.Visibility = Visibility.Visible;
             break;
         case EditorType.Image:
             BitmapImage bi = StaticBitmap.Read(sourcefile);
             img.Source = bi;
             stat = string.Format("{0:0}x{1:0}px | {2}", bi.Width, bi.Height, stat);
             imgPane.Visibility = Visibility.Visible;
             break;
         case EditorType.Assembly:
             nd = new NetDasm(this);
             nd.LoadAsm(sourcefile);
             disasm.Visibility = Visibility.Visible;
             Disassemble();
             eSave = true;
             break;
         case EditorType.Binary:
             Be.Windows.Forms.HexBox hb = new Be.Windows.Forms.HexBox() { ByteProvider = new Be.Windows.Forms.FileByteProvider(sourcefile), ByteCharConverter = new Be.Windows.Forms.DefaultByteCharConverter(), BytesPerLine = 16, UseFixedBytesPerLine = true, StringViewVisible = true, VScrollBarVisible = true };
             hb.TextChanged += delegate(object sender, EventArgs ev) { NeedsSave = true; };
             binHost.Child = hb;
             binEditor.Visibility = Visibility.Visible;
             break;
         case EditorType.Resource:
             resedit.Visibility = Visibility.Visible;
             break;
     }
     pwner.SetStatus(stat);
     CanSave = eSave;
     pwner.menu_save.IsEnabled = CanSave;
     OnFileLoaded();
 }
Example #33
0
 private void OnEditprTypeChanged(object sender, RoutedEventArgs e)
 {
     if (IsInitialized)
     {
         if (moveCheckBox.IsChecked == true)
         {
             curEditorType = EditorType.MOVE;
             underSideCanvas.Visibility = Visibility.Hidden;
         }
         else if (underSideCheckBox.IsChecked == true)
         {
             curEditorType = EditorType.UNDER_SIDE;
             underSideCanvas.Visibility = Visibility.Visible;
         }
     }
 }
Example #34
0
 public EditorFieldAttribute(EditorType editorType)
 {
     this.Type = editorType;
 }
Example #35
0
        public static ForumEditor CreateEditorFromType(EditorType etValue)
        {
            switch (etValue)
            {
                case EditorType.etText: return new TextEditor();
                case EditorType.etBBCode: return new BBCodeEditor();
                case EditorType.etFCKv2: return new FCKEditorV2();
                case EditorType.etFreeTextBox: return new FreeTextBoxEditor();
                case EditorType.etFCKv1: return new FCKEditorV1();
            }

            return null;
        }
 private void setEditor(EditorType editorType)
 {
     if (listEditors.TryGetValue(editorType, out m_currentTableIO))
     {
         m_editorType = editorType;
         removeAllTabs();
     }
 }
        public void setEditor(object sender, EventArgs e)
        {
            EditorType currentEditorType = m_editorType;
            if (sender.ToString().Equals(menuCategories.Text))
            {
                m_editorType = EditorType.Categories;
            }
            else if (sender.ToString().Equals(menuSubCategories.Text))
            {
                m_editorType = EditorType.SubCategories;
            }
            else if (sender.ToString().Equals(menuManufacturers.Text))
            {
                m_editorType = EditorType.Manufacturers;
            }
            else if (sender.ToString().Equals(menuItems.Text))
            {
                m_editorType = EditorType.Items;
            }
            else if (sender.ToString().Equals(menuFactions.Text))
            {
                m_editorType = EditorType.Factions;
            }
            else if (sender.ToString().Equals(menuMissions.Text))
            {
                m_editorType = EditorType.Missions;
            }
            else
            {
                MessageBox.Show("Internal error within frmMain.cs:setEditor()\rsender: '" + sender.ToString());
            }

            if (!m_editorType.Equals(currentEditorType))
            {
                removeAllTabs();
                setEditor(m_editorType);
                // TODO: Initialize the new editor
            }
        }
Example #38
0
 /// <summary>
 ///   <para>Activate the specified editor</para>
 /// </summary>
 public void setEditor(EditorType editorType, Boolean activate)
 {
     if (listEditors.TryGetValue(editorType, out m_currentEditor))
     {
         m_editorType = editorType;
         TableIO.State state = m_currentEditor.getTableIO(tabBase).getState();
         m_currentEditor.ensureState(state);
         if (activate)
         {
             String currentId = m_currentEditor.activate();
             flnSearch.Text = currentId == null ? "" : currentId;
         }
     }
     else
     {
         // TODO: User feedback
         MessageBox.Show("Unable to activate the editor " + editorType.ToString());
     }
 }
Example #39
0
        private ThreadViewModel GenerateThreadViewModel(int forumID, EditorType editorType, int? postID = null)
        {
            if (editorType == EditorType.Edit && !postID.HasValue)
                throw new InvalidOperationException("postID is required to generate an edit ThreadViewModel");

            Forum forum = _forumServices.GetForum(forumID);

            var permittedThreadTypes = _permissionServices.GetAllowedThreadTypes(forumID, _currentUser.UserID).ToList();
            var model = new ThreadViewModel()
            {
                EditorType = editorType,
                Forum = forum,
                ForumID = forum.ForumID,
                ThreadEditor = new ThreadEditorViewModel()
                {
                    AllowThreadImages = SiteConfig.AllowThreadImage.ToBool(),
                    PermittedThreadTypes = permittedThreadTypes,
                    ThreadImages = _threadServices.GetThreadImages(),
                },
                CanUploadAttachments = _permissionServices.CanCreateAttachment(forumID, _currentUser.UserID),
                CanCreatePoll = _permissionServices.CanCreatePoll(forumID, _currentUser.UserID)
            };

            if (editorType == EditorType.Edit)
            {
                var post = _postServices.GetPost(postID.Value);
                var thread = post.Thread;
                model.ThreadEditor.ThreadType = thread.Type;
                model.ThreadEditor.Image = thread.Image;
                model.ThreadEditor.ThreadID = post.ThreadID;
                model.ThreadEditor.Title = thread.Title;
                model.PostEditor = GeneratePostEditorViewModel(thread.ThreadID, EditorType.Edit, post);

                if (post.Thread.Poll != null)
                {
                    Poll poll = post.Thread.Poll;
                    IEnumerable<PollOption> options = poll.PollOptions;
                    bool hasVotes = options.Any(item => item.PollVotes.Count > 0);
                    model.PollEditor = new PollEditorViewModel()
                    {
                        HasVotes = hasVotes,
                        Options = poll.PollOptionsAsString(),
                        Text = poll.Question,
                        PollID = poll.PollID
                    };
                }
            }

            if (TempData.ContainsKey("Preview_Text"))
            {
                string previewText = (string)TempData["Preview_Text"];
                model.PreviewText = _parseServices.ParseBBCodeText(previewText);
                model.Preview = true;
                model.PreviewTitle = (string)TempData["Preview_Title"];
            }

            return model;
        }
Example #40
0
        private PostEditorViewModel GeneratePostEditorViewModel(int threadID, EditorType editorType, Post post = null)
        {
            if (editorType == EditorType.Edit && post == null)
                throw new InvalidOperationException("postID is required to generate an edit PostViewModel");

            var model = new PostEditorViewModel();

            if (editorType == EditorType.Edit)
            {
                model.Message = post.Text;
                model.ShowSignature = post.UseSignature;
                model.PostID = post.PostID;
                model.SubscribeToThread = _threadServices.IsSubscribed(threadID, _currentUser.UserID);
                model.Attachments = _fileServices.GetPostAttachments(post.PostID);
            }

            return model;
        }
Example #41
0
		public static ForumEditor CreateEditorFromType( EditorType etValue )
		{
			switch ( etValue )
			{
				case EditorType.Text: return new TextEditor();
				case EditorType.BBCode: return new BBCodeEditor();
				case EditorType.FCKv2: return new FCKEditorV2();
				case EditorType.FreeTextBox: return new FreeTextBoxEditor();
				case EditorType.FCKv1: return new FCKEditorV1();
				case EditorType.BasicBBCode: return new BasicBBCodeEditor();
				case EditorType.FreeTextBoxv3: return new FreeTextBoxEditorv3();
				case EditorType.TinyMCE: return new TinyMCEEditor();
				case EditorType.RadEditor: return new RadEditor();
			}

			return null;
		}
Example #42
0
 private void reEntries_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     ComboBoxItem cbi = ((sender as ComboBox).SelectedItem as ComboBoxItem);
     if (cbi != null)
     {
         EditorType et = EditorType.Binary;
         switch (Path.GetExtension(cbi.Content as string))
         {
             case ".jpg":
             case ".jpeg":
             case ".png":
                 et = EditorType.Image;
                 break;
             case ".xaml":
                 et = EditorType.Text;
                 break;
         }
         AshFile af = new AshFile(this.pwner, cbi.Tag as string, et);
         reContent.Child = af;
     }
     reSaveAs.IsEnabled = (cbi != null);
 }
Example #43
0
 public EditorField(EditorType editorType)
 {
     this.Type = editorType;
 }
Example #44
0
        private PostViewModel GeneratePostViewModel(int forumID, int threadID, EditorType editorType, int? quotePostID = null, int? postID = null)
        {
            var postEditor = GeneratePostEditorViewModel(threadID, EditorType.Create);

            if (editorType == EditorType.Create)
            {
                if (quotePostID.HasValue)
                {
                    Post quotePost = _postServices.GetPost(quotePostID.Value);
                    string quoteText = string.Format("[quote={0}]{1}[/quote]{2}", quotePost.User.Username, quotePost.Text, Environment.NewLine);
                    postEditor.Message = quoteText + postEditor.Message;
                }
            }
            else
            {
                Post post = _postServices.GetPost(postID.Value);
                postEditor.Message = post.Text;
                postEditor.PostID = post.PostID;
            }

            var model = new PostViewModel()
            {
                EditorType = editorType,
                PostEditor = postEditor,
                ThreadID = threadID,
                CanUploadAttachments = _permissionServices.CanCreateAttachment(forumID, _currentUser.UserID),
                Thread = _threadServices.GetThread(threadID)
            };

            if (TempData.ContainsKey("Preview_Text"))
            {
                string text = (string)TempData["Preview_Text"];
                model.PreviewText = _parseServices.ParseBBCodeText(text);
                model.Preview = true;
            }

            return model;
        }
Example #45
0
 public ConfigEditorAttribute(EditorType editorType)
 {
     Editor = editorType;
 }
Example #46
0
 public IEditor getEditor(EditorType editorType)
 {
     IEditor editor;
     if (!listEditors.TryGetValue(editorType, out editor))
     {
         editor = null;
     }
     return editor;
 }
Example #47
0
 public ConfigEditorAttribute(EditorType editorType, Type sourceListType)
 {
     Editor = editorType;
     SourceListType = sourceListType;
 }
Example #48
0
		/// <summary>
		/// Creates a new designer attribute.
		/// </summary>
		/// <param name="displayName">The name shown on the node and in the property editor for the property.</param>
		/// <param name="description">The description shown in the property editor for the property.</param>
		/// <param name="category">The category shown in the property editor for the property.</param>
		/// <param name="displayMode">Defines how the property is visualised in the editor.</param>
		/// <param name="displayOrder">Defines the order the properties will be sorted in when shown in the property grid. Lower come first.</param>
		/// <param name="flags">Defines the designer flags stored for the property.</param>
		/// <param name="editorTypes">The type of the editor used in the property grid.</param>
		protected DesignerProperty(string displayName, string description, string category, DisplayMode displayMode, int displayOrder, DesignerFlags flags, EditorType[] editorTypes)
		{
			_displayName= displayName;
			_description= description;
			_category= category;
			_displayMode= displayMode;
			_displayOrder= displayOrder;
			_flags= flags;
			_editorTypes= editorTypes;
		}
Example #49
0
        internal FieldSet(PropertyInfo p, ComponentSet ownerObjSet)
        {
            this.Name = p.Name;
            this.Property = p;
            this.Type = p.PropertyType;
            this.ParentSet = ownerObjSet;

            EditorAttribute disAtt = ComponentSet.GetEditorAttribute(p);

            if (disAtt != null)
            {
                this.DisplayName = disAtt.DisplayName;
                this.MaxLength = disAtt.MaxLength;
                this.EditorType = disAtt.EditorType;
                this.EditorArgs = disAtt.EditorArgs;
                this.CheckValues = disAtt.CheckValues;
                this.ValidationType = disAtt.ValidationType;
                this.ValidationExpression = disAtt.ValidationExpression;
                this.Sequence = disAtt.Sequence;

                this.CheckValuesProvider = this.GetCheckValuesProvider(disAtt);

                this.Ignore = disAtt.Ignore;
                //
            }

            if (String.IsNullOrEmpty(this.DisplayName))
                this.DisplayName = this.Name;
        }
Example #50
0
 public ConfigEditorAttribute(EditorType editorType, string openFileFilter)
 {
     Editor = editorType;
     OpenFileFilter = openFileFilter;
 }