Пример #1
0
        protected Procedure FileSaveProcedure(string name, string blurb,
                                              string help, string author,
                                              string copyright, string date,
                                              string menu_path,
                                              string image_types)
        {
            var inParams = new ParamDefList(true)
            {
                new ParamDef("run_mode", typeof(Int32),
                             "Interactive, non-interactive"),
                new ParamDef("image", typeof(Image),
                             "Input image"),
                new ParamDef("drawable", typeof(Drawable),
                             "Drawable to save"),
                new ParamDef("filename", typeof(FileName),
                             "The name of the file to save the image in"),
                new ParamDef("raw_filename", typeof(FileName),
                             "The name of the file to save the image in")
            };

            _saveProcedure = new Procedure(name, blurb, help, author, copyright,
                                           date, menu_path, image_types, inParams);

            return(_saveProcedure);
        }
Пример #2
0
        protected Procedure FileLoadProcedure(string name, string blurb,
                                              string help, string author,
                                              string copyright, string date,
                                              string menu_path)
        {
            var inParams = new ParamDefList(true)
            {
                new ParamDef("run_mode", typeof(Int32),
                             "Interactive, non-interactive"),
                new ParamDef("filename", typeof(FileName),
                             "The name of the file to load"),
                new ParamDef("raw_filename", typeof(FileName),
                             "The name entered")
            };

            var outParams = new ParamDefList(true)
            {
                new ParamDef("image", typeof(Image), "Output image")
            };

            _loadProcedure = new Procedure(name, blurb, help, author, copyright,
                                           date, menu_path, null,
                                           inParams, outParams);

            return(_loadProcedure);
        }
Пример #3
0
        virtual protected void Run(string name, ParamDefList inParam,
                                   out ParamDefList outParam)
        {
            RunMode run_mode = (RunMode)inParam[0].Value;

            Console.WriteLine("Run: " + _usesDrawable);
            Console.WriteLine("Drawable: " + inParam[2].Value);

            if (_usesImage)
            {
                _image = (Image)inParam[1].Value;
            }
            if (_usesDrawable)
            {
                _drawable = (Drawable)inParam[2].Value;
            }

            if (run_mode == RunMode.Interactive)
            {
                GetData();
                Dialog = CreateDialog();
                if (Dialog == null)
                {
                    SetData();
                }
                else
                {
                    Dialog.ShowAll();
                    if (DialogRun())
                    {
                        SetData();
                    }
                }
            }
            else if (run_mode == RunMode.Noninteractive)
            {
                if (ValidateParameters(inParam))
                {
                    CallRender();
                }
            }
            else if (run_mode == RunMode.WithLastVals)
            {
                GetData();
                CallRender();
            }

            if (_usesDrawable && _drawable != null)
            {
                _drawable.Detach();
            }

            outParam = new ParamDefList(true);
            outParam.Add(new ParamDef(PDBStatusType.Success, typeof(PDBStatusType)));
        }
Пример #4
0
        void SaveFile(ParamDefList inParam, ParamDefList outParam)
        {
            var    image    = (Image)inParam[1].Value;
            var    drawable = (Drawable)inParam[2].Value;
            string filename = (string)inParam[3].Value;

            if (!Save(image, drawable, filename))
            {
                outParam[0].Value = PDBStatusType.ExecutionError;
            }
        }
Пример #5
0
 virtual protected bool ValidateParameters(ParamDefList inParam)
 {
     foreach (var attribute in new SaveAttributeSet(GetType()))
     {
         string name = attribute.Name;
         if (name != null)
         {
             object value = inParam.GetValue(name);
             if (value != null)
             {
                 attribute.Field.SetValue(this, value);
             }
         }
     }
     return(true);
 }
Пример #6
0
        override protected void Run(string name, ParamDefList inParam,
                                    out ParamDefList outParam)
        {
            outParam = new ParamDefList(true);
            outParam.Add(new ParamDef(PDBStatusType.Success,
                                      typeof(PDBStatusType)));

            if (_loadProcedure != null && _loadProcedure.Name == name)
            {
                LoadFile(inParam, outParam);
            }
            else if (_saveProcedure != null && _saveProcedure.Name == name)
            {
                SaveFile(inParam, outParam);
            }
        }
Пример #7
0
 public Procedure(string name, string blurb, string help,
                  string author, string copyright,
                  string date, string menuPath,
                  string imageTypes,
                  ParamDefList inParams  = null,
                  ParamDefList outParams = null)
 {
     Name        = name;
     _blurb      = blurb;
     _help       = help;
     _author     = author;
     _copyright  = copyright;
     _date       = date;
     _menuPath   = menuPath;
     _imageTypes = imageTypes;
     _inParams   = inParams ?? new ParamDefList();
     _outParams  = outParams ?? new ParamDefList(false);
 }
Пример #8
0
        void LoadFile(ParamDefList inParam, ParamDefList outParam)
        {
            Filename = (string)inParam[1].Value;

            if (File.Exists(Filename))
            {
                Reader = new BinaryReader(File.Open(Filename, FileMode.Open));
                var image = Load();
                if (image == null)
                {
                    outParam[0].Value = PDBStatusType.ExecutionError;
                }
                else
                {
                    outParam.Add(new ParamDef(image, typeof(Image)));
                }
                Reader.Close();
            }
            else
            {
                outParam[0].Value = PDBStatusType.ExecutionError;
            }
        }