コード例 #1
0
        protected virtual void OnGuidCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var tb = e.OriginalSource as TextBox;

            if (tb != null)
            {
                if (NewGuidCommand.Equals(e.Command))
                {
                    tb.Text = Guid.NewGuid().ToString(NormalizeGuidParameter(e.Parameter));
                    return;
                }

                if (EmptyGuidCommand.Equals(e.Command))
                {
                    tb.Text = Guid.Empty.ToString(NormalizeGuidParameter(e.Parameter));
                    return;
                }

                if (IncrementGuidCommand.Equals(e.Command))
                {
                    Guid   g     = ConversionService.ChangeType(tb.Text.Trim(), Guid.Empty);
                    byte[] bytes = g.ToByteArray();
                    bytes[15]++;
                    tb.Text = new Guid(bytes).ToString(NormalizeGuidParameter(e.Parameter));
                    return;
                }
            }
        }