/// <summary>
        /// Call this constructor when restoring a gauge from the DB
        /// </summary>
        /// <param name="row"></param>
        public GaugeItem(ItemRow row)
        {
            this.Row = row;

            this._context    = new UndoRedoContext();
            this.UndoCommand = this._context.GetUndoCommand();
            this.RedoCommand = this._context.GetRedoCommand();

            this.LoadFromRow();
            this.NotifyOfPropertyChangeAll();

            Messenger.Default.Register <Color>(this, "OnForegroundColorChanged", (color) =>
            {
                this.GaugeColor = color;
            });
        }
Пример #2
0
        /// <summary>
        /// This constructor prevents external code from inheriting from this class.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="context"></param>
        internal UndoableActionBase(string name = "", IUndoRedoContext context = null)
        {
            this.Context = context;
            if (this.Context == null)
            {
                this.Context = UndoRedoContext.GetDefaultContext();
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                this.Name = Guid.NewGuid().ToString();
            }
            else
            {
                this.Name = name.Trim();
            }

            this.Context.RegisterAction(this);
        }
        /// <summary>
        /// Call this constructor when building a new gauge from scratch
        /// </summary>
        public GaugeItem(Int64 pageId)
        {
            this._context    = new UndoRedoContext();
            this.UndoCommand = this._context.GetUndoCommand();
            this.RedoCommand = this._context.GetRedoCommand();

            this.Row = App.BuildDBTables.GaugeTable.CreateRow();
            App.BuildDBTables.GaugeTable.AddRow(this.Row);

            this.LoadFromRow();
            this.PageId = pageId;

            Task.Run(async() =>
            {
                await this.BeginCommit();
            }).Wait();

            this.NotifyOfPropertyChangeAll();

            Messenger.Default.Register <Color>(this, "OnForegroundColorChanged", (color) =>
            {
                this.GaugeColor = color;
            });
        }