Exemple #1
0
        protected override void Init(InitArgs <string> args)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title      = Options.Message;
            ofd.Filter     = Options.Filter;
            ofd.DefaultExt = "scf";
            string filename = "";
            string path     = "";

            if (File.Exists(Options.FileName))
            {
                filename = Path.GetFileName(Options.FileName);
                path     = Path.GetDirectoryName(Options.FileName);
            }
            if (!string.IsNullOrEmpty(filename))
            {
                ofd.FileName = filename;
            }
            if (!string.IsNullOrEmpty(path))
            {
                ofd.InitialDirectory = path;
            }

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                args.Value = ofd.FileName;
            }
            else
            {
                args.InputValid = false;
            }

            args.ContinueAsync = false;
        }
Exemple #2
0
 protected override void Init(InitArgs <Point2D> args)
 {
     if (Options.HasBasePoint)
     {
         Jigged = new Line(Options.BasePoint, Options.BasePoint);
     }
 }
 protected override void Init(InitArgs <SelectionSet> args)
 {
     // Immediately return existing picked-selection if any
     if (Options.UsePickedSelection && Editor.PickedSelection.Count != 0)
     {
         SelectionSet ss = new SelectionSet();
         foreach (Drawable item in Editor.PickedSelection)
         {
             if (Options.AllowedClasses.Count == 0 || Options.AllowedClasses.Contains(item.GetType()))
             {
                 ss.Add(item);
             }
         }
         Editor.PickedSelection.Clear();
         args.Value         = ss;
         args.ContinueAsync = false;
     }
     else
     {
         getFirstPoint = false;
     }
 }
Exemple #4
0
        public static async Task <InputResult <TValue> > Run <TGetter>(Editor editor, TOptions options) where TGetter : EditorGetter <TOptions, TValue>
        {
            using (var getter = Activator.CreateInstance <TGetter>())
            {
                getter.Editor = editor;

                getter.Completion = new TaskCompletionSource <InputResult <TValue> >();

                getter.Editor.InputMode = true;
                getter.Editor.DoPrompt("");

                getter.Options = options;

                var initArgs = new InitArgs <TValue>();
                getter.Init(initArgs);
                if (!initArgs.ContinueAsync)
                {
                    if (initArgs.InputValid)
                    {
                        getter.Completion.SetResult(InputResult <TValue> .AcceptResult(initArgs.Value, AcceptReason.Init));
                    }
                    else
                    {
                        getter.Completion.SetResult(InputResult <TValue> .CancelResult(CancelReason.Init));
                    }
                }

                if (initArgs.ContinueAsync)
                {
                    getter.Editor.CursorMove  += getter.Editor_CursorMove;
                    getter.Editor.CursorClick += getter.Editor_CursorClick;
                    getter.Editor.KeyDown     += getter.Editor_KeyDown;
                    getter.Editor.KeyPress    += getter.Editor_KeyPress;
                }

                getter.SetCursorText("");
                return(await getter.Completion.Task);
            }
        }
Exemple #5
0
        protected override void Init(InitArgs <string> args)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Title      = Options.Message;
            sfd.Filter     = Options.Filter;
            sfd.DefaultExt = "scf";
            string filename = "";
            string path     = "";

            try
            {
                filename = Path.GetFileName(Options.FileName);
                path     = Path.GetDirectoryName(Options.FileName);
            }
            catch
            {
                ;
            }
            if (!string.IsNullOrEmpty(filename))
            {
                sfd.FileName = filename;
            }
            if (!string.IsNullOrEmpty(path))
            {
                sfd.InitialDirectory = path;
            }

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                args.Value = sfd.FileName;
            }
            else
            {
                args.InputValid = false;
            }

            args.ContinueAsync = false;
        }
Exemple #6
0
 protected override void Init(InitArgs <float> args)
 {
     Jigged = new Line(Options.BasePoint, Options.BasePoint);
 }
Exemple #7
0
 protected override void Init(InitArgs <CPSelectionSet> args)
 {
     Editor.PickedSelection.Clear();
     getFirstPoint = false;
 }
Exemple #8
0
 protected override void Init(InitArgs <Point2D> args)
 {
     Jigged = new Polygon(Options.BasePoint, Options.BasePoint, Options.BasePoint, Options.BasePoint);
 }
Exemple #9
0
 protected virtual void Init(InitArgs <TValue> args)
 {
 }