private async void OnExportWplClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                var fileName = await FieldEditor.ShowAsync($"{Playlist.Title}.wpl",
                                                           CommonSharedStrings.ChooseFileName,
                                                           CommonSharedStrings.ValidFilenameRequired,
                                                           @"^(?!((con|prn|aux)((\.[^\\/:*?<>|" + "\"" + @"]{1,3}$)|$))|[\s\.])[^\\/:*?<>|" + "\"" + @"]{1,254}$");

                if (fileName == null)
                {
                    return;
                }
                var picker = new FolderPicker();
                picker.SuggestedStartLocation = PickerLocationId.MusicLibrary;
                picker.ViewMode = PickerViewMode.List;
                picker.FileTypeFilter.Add(".wpl");
                var folder = await picker.PickSingleFolderAsync();

                if (folder == null)
                {
                    return;
                }
                await PlaylistManager.Instance.ExportAsync(Playlist, folder, fileName);

                MessagePrompt(CommonSharedStrings.PlaylistSaved);
            }
            catch (Exception ex)
            {
                MessagePrompt(ex.Message, CommonSharedStrings.FailedToSavePlaylist);
            }
        }
Exemple #2
0
 public void CancelAndClose()
 {
     Helper.LoadJsonFile(this, filePath);
     dataEditor = new FieldEditor(this);
     edit       = false;
     OnClose();
 }
Exemple #3
0
 private static void Load()
 {
     FieldEditor.RegisterEditor(typeof(JourneyPath), (a, l) => new PathEditor(a));
     FieldEditor.RegisterEditor(typeof(Location.MapPoint), (a, l) => new MapPointEditor(a, l));
     Story.Load();
     DataObjectEditor.SafeNamer = new EmigreSafeNamer();
 }
        public void CanExecuteBadContext()
        {
            Sitecore.Shell.Framework.Commands.CommandContext context = new Sitecore.Shell.Framework.Commands.CommandContext();
            var fieldEditor = new FieldEditor();
            var canExecute  = fieldEditor.CanExecute(context);

            Assert.IsFalse(canExecute);
        }
Exemple #5
0
 void OnEnable()
 {
     if (data.applyOnEnable)
     {
         Apply();
     }
     _editor = new FieldEditor(data);
 }
 public Client()
 {
     InitializeComponent();
     editor = new FieldEditor(playerFeld);
     client = new ClientPlayer();
     waitingConnectionThread = new Thread(new ThreadStart(WaitConnection));
     game = new GameLogic(client, playerFeld, oponentField, startButton);
     InitActions();
     FormClosing += CloseConnection;
 }
Exemple #7
0
        /// <summary>
        /// Instantiates the in.
        /// </summary>
        /// <param name="container">The container.</param>
        public override void InstantiateIn(Control container)
        {
            Assert.ArgumentNotNull(container, "container");

            FieldEditor fieldEditor = container.BindingContainer as FieldEditor;

            if (fieldEditor != null)
            {
                this.Order = (Order)fieldEditor.DataItem;
            }

            base.InstantiateIn(container);
        }
        private void AddRow(Accessor accessor, TableLayoutPanel tableLayout)
        {
            if (accessor.GetTags().Any(x => x.flag == FieldTags.Inline))
            {
                AddInlineRow(accessor, tableLayout);
                return;
            }

            FieldEditor editor = FieldEditor.CreateEditor(accessor, this);

            if (editor == null)
            {
                return;
            }

            tableLayout.RowCount++;
            Label label = new Label();

            label.AutoSize = true;
            label.Text     = GetHumanReadableField(accessor.GetName());
            FieldTag comment = accessor.GetTags().Where(tag => tag.flag == FieldTags.Comment).FirstOrDefault();

            if (comment != null)
            {
                ToolTip tooltip = new ToolTip();
                tooltip.SetToolTip(label, comment.arg);
            }
            tableLayout.Controls.Add(label, 0, tableLayout.RowCount - 1);

            Control content = editor.GetControl();

            content.Enabled = !editor.accessor.GetTags().Any((tag) => tag.flag == FieldTags.Readonly);
            tableLayout.Controls.Add(content, 1, tableLayout.RowCount - 1);
            int fieldIndex = editors.Count;

            editors.Add(editor);
            editor.OnEdited += (sender, args) =>
            {
                if (OnObjectEdited != null)
                {
                    EditorIndex    index  = Index;
                    FieldEditState state0 = new FieldEditState(args.valueBefore, editor.LastSelectedIndex);
                    FieldEditState state1 = new FieldEditState(args.valueAfter, editor.SelectedIndex);
                    OnObjectEdited(sender, new FieldEditAction(state0, state1, index.RemoveNext(), fieldIndex, editor.EditsCanCombine));
                }
            };
        }
Exemple #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int classId = QueryHelper.GetInteger("objectid", 0);

        dci = DataClassInfoProvider.GetDataClassInfo(classId);
        // Set edited object
        EditedObject             = dci;
        CurrentMaster.BodyClass += " FieldEditorBody";

        btnGenerateGuid = new HeaderAction
        {
            Tooltip       = GetString("customtable.GenerateGUID"),
            Text          = GetString("customtable.GenerateGUIDField"),
            Visible       = false,
            CommandName   = "createguid",
            OnClientClick = "return confirm(" + ScriptHelper.GetLocalizedString("customtable.generateguidconfirmation") + ");"
        };
        FieldEditor.HeaderActions.AddAction(btnGenerateGuid);
        FieldEditor.HeaderActions.ActionPerformed += (s, ea) => { if (ea.CommandName == "createguid")
                                                                  {
                                                                      CreateGUID();
                                                                  }
        };

        // Class exists
        if (dci != null)
        {
            className = dci.ClassName;
            if (dci.ClassIsCoupledClass)
            {
                FieldEditor.Visible                  = true;
                FieldEditor.ClassName                = className;
                FieldEditor.Mode                     = FieldEditorModeEnum.CustomTable;
                FieldEditor.OnFieldNameChanged      += FieldEditor_OnFieldNameChanged;
                FieldEditor.OnAfterDefinitionUpdate += FieldEditor_OnAfterDefinitionUpdate;
            }
            else
            {
                FieldEditor.ShowError(GetString("customtable.ErrorNoFields"));
            }
        }

        ScriptHelper.HideVerticalTabs(this);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        int classId = QueryHelper.GetInteger("customtableid", 0);

        dci = DataClassInfoProvider.GetDataClass(classId);
        // Set edited object
        EditedObject             = dci;
        CurrentMaster.BodyClass += " FieldEditorBody";

        btnGenerateGuid = new HeaderAction()
        {
            Tooltip     = GetString("customtable.GenerateGUID"),
            Text        = GetString("customtable.GenerateGUIDField"),
            ImageUrl    = GetImageUrl("/Design/Controls/UniGrid/Actions/Rebuild.png"),
            Visible     = false,
            CommandName = "createguid",
        };
        FieldEditor.HeaderActions.AddAction(btnGenerateGuid);
        FieldEditor.HeaderActions.ActionPerformed += (s, ea) => { if (ea.CommandName == "createguid")
                                                                  {
                                                                      CreateGUID();
                                                                  }
        };

        // Class exists
        if (dci != null)
        {
            className = dci.ClassName;
            if (dci.ClassIsCoupledClass)
            {
                FieldEditor.Visible             = true;
                FieldEditor.ClassName           = className;
                FieldEditor.Mode                = FieldEditorModeEnum.CustomTable;
                FieldEditor.OnFieldNameChanged += FieldEditor_OnFieldNameChanged;
            }
            else
            {
                FieldEditor.ShowError(GetString("customtable.ErrorNoFields"));
            }
        }
    }
        private async void OnNewPlaylistClicked(object sender, RoutedEventArgs e)
        {
            var name = await FieldEditor.ShowAsync(
                CommonSharedStrings.PlaylistDefaultname,
                CommonSharedStrings.NewPlaylistString,
                CommonSharedStrings.NewNameEmptyPrompt,
                "[^ ]");

            if (name == null)
            {
                return;
            }
            try
            {
                await PlaylistManager.Instance.CreateBlankPlaylistAsync(name);
            }
            catch (ArgumentException ex)
            {
                var dialog = new MessageDialog(ex.Message, CommonSharedStrings.InternalErrorTitle);
                await dialog.ShowAsync();
            }
        }
        private async void OnMenuRenameClicked(object sender, RoutedEventArgs e)
        {
            var playlist = (sender as FrameworkElement).DataContext as Playlist;
            var newName  = await FieldEditor.ShowAsync(
                playlist.Title,
                CommonSharedStrings.RenameString,
                CommonSharedStrings.NewNameEmptyPrompt,
                "[^ ]");

            if (newName == null)
            {
                return;
            }
            try
            {
                await PlaylistManager.Instance.RenameAsync(playlist.Title, newName);
            }
            catch (ArgumentException ex)
            {
                var dialog = new MessageDialog(ex.Message, CommonSharedStrings.InternalErrorTitle);
                await dialog.ShowAsync();
            }
        }
Exemple #13
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        // Class exists
        if (dci != null)
        {
            if (dci.ClassIsCoupledClass)
            {
                // GUID column is not present
                if ((FormInfo != null) && (FormInfo.GetFormField("ItemGUID") == null))
                {
                    btnGenerateGuid.Visible = true;
                    FieldEditor.ShowInformation(GetString("customtable.GUIDColumMissing"));
                }
            }

            if (!RequestHelper.IsPostBack() && QueryHelper.GetBoolean("gen", false))
            {
                FieldEditor.ShowInformation(GetString("customtable.GUIDFieldGenerated"));
            }
        }
    }
Exemple #14
0
    /// <summary>
    /// Adds GUID field to form definition.
    /// </summary>
    private void CreateGUID()
    {
        bool success;

        try
        {
            if (FormInfo == null)
            {
                return;
            }

            // Create GUID field
            FormFieldInfo ffiGuid = new FormFieldInfo();

            // Fill FormInfo object
            ffiGuid.Name = "ItemGUID";
            ffiGuid.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "GUID");
            ffiGuid.DataType = FieldDataType.Guid;
            ffiGuid.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
            ffiGuid.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, String.Empty);
            ffiGuid.PrimaryKey = false;
            ffiGuid.System     = true;
            ffiGuid.Visible    = false;
            ffiGuid.Size       = 0;
            ffiGuid.AllowEmpty = false;

            FormInfo.AddFormItem(ffiGuid);

            // Update definition
            dci.ClassFormDefinition = FormInfo.GetXmlDefinition();

            using (CMSActionContext context = new CMSActionContext())
            {
                // Disable logging into event log
                context.LogEvents = false;

                DataClassInfoProvider.SetDataClassInfo(dci);
            }

            // Clear the default queries
            QueryInfoProvider.ClearDefaultQueries(dci, true);

            // Clear the object type hashtable
            AbstractProviderDictionary.ReloadDictionaries(className, true);

            // Clear the classes hashtable
            AbstractProviderDictionary.ReloadDictionaries("cms.class", true);

            // Clear class strucures
            ClassStructureInfo.Remove(className, true);

            // Ensure GUIDs for all items
            using (CMSActionContext ctx = new CMSActionContext())
            {
                ctx.UpdateSystemFields = false;
                ctx.LogSynchronization = false;
                DataSet dsItems = CustomTableItemProvider.GetItems(className);
                if (!DataHelper.DataSourceIsEmpty(dsItems))
                {
                    foreach (DataRow dr in dsItems.Tables[0].Rows)
                    {
                        CustomTableItem item = CustomTableItem.New(className, dr);
                        item.ItemGUID = Guid.NewGuid();
                        item.Update();
                    }
                }
            }

            // Log event
            UserInfo currentUser = MembershipContext.AuthenticatedUser;

            var logData = new EventLogData(EventTypeEnum.Information, "Custom table", "GENERATEGUID")
            {
                EventDescription = String.Format(ResHelper.GetAPIString("customtable.GUIDGenerated", "Field 'ItemGUID' for custom table '{0}' was created and GUID values were generated."), dci.ClassName),
                UserID           = currentUser.UserID,
                UserName         = currentUser.UserName,
            };

            Service.Resolve <IEventLogService>().LogEvent(logData);

            success = true;
        }
        catch (Exception ex)
        {
            success = false;

            FieldEditor.ShowError(GetString("customtable.ErrorGUID"));

            // Log event
            Service.Resolve <IEventLogService>().LogException("Custom table", "GENERATEGUID", ex);
        }

        if (success)
        {
            URLHelper.Redirect(URLHelper.AddParameterToUrl(RequestContext.CurrentURL, "gen", "1"));
        }
    }
Exemple #15
0
    /// <summary>
    /// Adds GUID field to form definition.
    /// </summary>
    private void CreateGUID()
    {
        try
        {
            // Create GUID field
            FormFieldInfo ffiGuid = new FormFieldInfo();

            // Fill FormInfo object
            ffiGuid.Name = "ItemGUID";
            ffiGuid.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "GUID");
            ffiGuid.DataType = FieldDataType.Guid;
            ffiGuid.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
            ffiGuid.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, String.Empty);
            ffiGuid.FieldType = FormFieldControlTypeEnum.CustomUserControl;
            ffiGuid.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
            ffiGuid.PrimaryKey = false;
            ffiGuid.System     = true;
            ffiGuid.Visible    = false;
            ffiGuid.Size       = 0;
            ffiGuid.AllowEmpty = false;

            FormInfo.AddFormItem(ffiGuid);

            // Update table structure - columns could be added
            bool old = TableManager.UpdateSystemFields;
            TableManager.UpdateSystemFields = true;
            string schema = FormInfo.GetXmlDefinition();

            TableManager tm = new TableManager(null);
            tm.UpdateTableByDefinition(dci.ClassTableName, schema);

            TableManager.UpdateSystemFields = old;

            // Update xml schema and form definition
            dci.ClassFormDefinition = schema;
            dci.ClassXmlSchema      = tm.GetXmlSchema(dci.ClassTableName);

            dci.Generalized.LogEvents = false;

            // Save the data
            DataClassInfoProvider.SetDataClassInfo(dci);

            dci.Generalized.LogEvents = true;

            // Clear the default queries
            QueryInfoProvider.ClearDefaultQueries(dci, true, false);

            // Clear the object type hashtable
            ProviderStringDictionary.ReloadDictionaries(className, true);

            // Clear the classes hashtable
            ProviderStringDictionary.ReloadDictionaries("cms.class", true);

            // Clear class strucures
            ClassStructureInfo.Remove(className, true);

            // Ensure GUIDs for all items
            using (CMSActionContext ctx = new CMSActionContext())
            {
                ctx.UpdateSystemFields = false;
                ctx.LogSynchronization = false;
                DataSet dsItems = CustomTableItemProvider.GetItems(className);
                if (!DataHelper.DataSourceIsEmpty(dsItems))
                {
                    foreach (DataRow dr in dsItems.Tables[0].Rows)
                    {
                        CustomTableItem item = CustomTableItem.New(className, dr);
                        item.ItemGUID = Guid.NewGuid();
                        item.Update();
                    }
                }
            }

            // Log event
            UserInfo currentUser = MembershipContext.AuthenticatedUser;
            EventLogProvider.LogEvent(EventType.INFORMATION, "Custom table", "GENERATEGUID", string.Format(ResHelper.GetAPIString("customtable.GUIDGenerated", "Field 'ItemGUID' for custom table '{0}' was created and GUID values were generated."), dci.ClassName), null, currentUser.UserID, currentUser.UserName);

            URLHelper.Redirect(URLHelper.AddParameterToUrl(RequestContext.CurrentURL, "gen", "1"));
        }
        catch (Exception ex)
        {
            FieldEditor.ShowError(GetString("customtable.ErrorGUID") + ex.Message);

            // Log event
            EventLogProvider.LogException("Custom table", "GENERATEGUID", ex);
        }
    }
Exemple #16
0
 void OnEnable()
 {
     _frames = new LinkedList <Frame> ();
     _editor = new FieldEditor(data);
 }
Exemple #17
0
 void Start()
 {
     _serverField = new FieldEditor(serverData);
     _clientField = new FieldEditor(clientData);
 }
		public override void Init(BXCustomField field)
		{
			this.field = field;
			maxSize = field.Settings.GetInt("MaxSize");
			IEnumerable<string> ae = field.Settings.Get<IEnumerable<string>>("AllowedExtensions");
			allowedExtensions = ae != null ? new List<string>(ae) : new List<string>();
			for (int i = 0; i < allowedExtensions.Count; i++)
				allowedExtensions[i] = allowedExtensions[i].Trim().ToLowerInvariant();
			textboxSize = field.Settings.GetInt("TextBoxSize");
			editor = field.Multiple ? (FieldEditor)new MultipleFieldEditor(this) : (FieldEditor)new SingleFieldEditor(this);
		}
 void OnEnable()
 {
     _attachedCamera = GetComponent <Camera> ();
     _editor         = new FieldEditor(data);
 }