Exemplo n.º 1
0
 private void InitThisForm(FormMessage someMessage)
 {
     formMessage = someMessage;
     Presenter = new EnslaverFrontEnd.Presenters.LoginFormPresenter(this);
     InitializeComponent();
     TryRaiseEvent(Init, EventArgs.Empty);
 }
Exemplo n.º 2
0
 public BaseForm(FormMessage constructorParameter)
 {
     if (constructorParameter != null)
     {
         this.SenderGuid = constructorParameter.SenderGuid;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Фабрика для создания форм
 /// </summary>
 /// <param name="formType"></param>
 /// <param name="formMessage">Сообщение для инициализации формы</param>
 /// <returns></returns>
 public virtual BaseForm CreateForm(long formTypeID, FormMessage formMessage)
 {
     if (DicTypeIDToForm.ContainsKey(formTypeID))
     {
         return (BaseForm)Activator.CreateInstance(DicTypeIDToForm[formTypeID], (this));
     }
     throw new Exception("Form not found");
 }
Exemplo n.º 4
0
 public AdminForm(FormFactory currentFormFactory, FormMessage someMessage)
     : base(currentFormFactory)
 {
     InitForm(someMessage);
 }
Exemplo n.º 5
0
        public void InitForm(FormMessage someMessage)
        {
            //Initialize the capture device
            grabber = new Capture();
            grabber.QueryFrame();

            formMessage = someMessage;
            InitializeComponent();
            Presenter = new EnslaverFrontEnd.Presenters.AdminFormPresenter(this);
            TryRaiseEvent(Init, EventArgs.Empty);
            //Load haarcascades for face detection
            face = new HaarCascade("haarcascade_frontalface_default.xml");
            eye = new HaarCascade("haarcascade_eye.xml");
            mouth = new HaarCascade("mouth.xml");
            smile = new HaarCascade("haarcascade_smile.xml");

            try
            {
                //Load of previus trainned faces and labels for each image
                string Labelsinfo = File.ReadAllText(Application.StartupPath + "/TrainedFaces/TrainedLabels.txt");
                string[] Labels = Labelsinfo.Split('%');
                NumLabels = Convert.ToInt16(Labels[0]);
                ContTrain = NumLabels;
                string LoadFaces;

                for (int tf = 1; tf < NumLabels + 1; tf++)
                {
                    LoadFaces = "face" + tf + ".bmp";
                    trainingImages.Add(new Image<Gray, byte>(Application.StartupPath + "/TrainedFaces/" + LoadFaces));
                    labels.Add(Labels[tf]);
                }

            }
            catch (Exception e)
            {
                //MessageBox.Show(e.ToString());
                MessageBox.Show("Nothing in binary database, please add at least a face(Simply train the prototype with the Add Face Button).", "Triained faces load", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            //Initialize the FrameGraber event
            Application.Idle += new EventHandler(FrameGrabber);
        }
Exemplo n.º 6
0
 public MainForm(FormFactory currentFormFactory, FormMessage formMessage)
 {
     InitThisForm();
 }
Exemplo n.º 7
0
 public BaseForm ShowSingletoneForm(BaseForm sender, long formTypeID, FormMessage formMessage)
 {
     var existForms = FindFormsByType(formTypeID);
     if (existForms.Count > 0)
     {
         SendMessageToForm(sender, existForms[0].Guid, formMessage);
         existForms[0].Focus();
         return existForms[0];
     }
     else
     {
         return ShowForm(sender, formTypeID, formMessage);
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Создание и показ новой формы, старая не удаляется
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="formTypeID"></param>
 /// <param name="formMessage"></param>
 /// <returns></returns>
 public virtual BaseForm ShowForm(BaseForm sender, long formTypeID, FormMessage formMessage)
 {
     BaseForm CurrentForm = null;
     CurrentForm = CreateForm(formTypeID, formMessage);
     if (sender != null) CurrentForm.SenderGuid = sender.Guid;
     DicOfForms[CurrentForm.Guid] = CurrentForm;
     MainApplicationContext.MainForm.Invoke(new MethodInvoker(() =>
     {
         CurrentForm.Show();
     }));
     return CurrentForm;
 }
Exemplo n.º 9
0
 /// <summary>
 /// отправка сообщения форме
 /// </summary>
 /// <param name="sender">посылатель сообщения</param>
 /// <param name="guidOfForm">получатель сообщения</param>
 /// <param name="formMessage">сообщение</param>
 /// <returns></returns>
 public virtual int SendMessageToForm(BaseForm sender, Guid guidOfForm, FormMessage formMessage)
 {
     if (IsContainForm(guidOfForm))
     {
         return DicOfForms[guidOfForm].ReceiveMessage(formMessage);
     }
     else
     {
         return -1;
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Переход на форму с удалением той, что создала запрос
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="formTypeID"></param>
 /// <param name="formMessage"></param>
 /// <returns></returns>
 public virtual BaseForm MoveToForm(BaseForm sender, long formTypeID, FormMessage formMessage)
 {
     BaseForm CurrentForm = null;
     CurrentForm = CreateForm(formTypeID, formMessage);
     MainApplicationContext.MainForm = CurrentForm;
     if (sender != null)
         CurrentForm.SenderGuid = sender.Guid;
     DicOfForms[CurrentForm.Guid] = CurrentForm;
     if (sender != null)
     {
         DicOfForms.Remove(sender.Guid);
         sender.Close();
     }
     CurrentForm.Show();
     return CurrentForm;
 }
Exemplo n.º 11
0
 /*
 /// <summary>
 /// Переход на форму с удалением той, что создала запрос
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="formTypeID"></param>
 /// <param name="formMessage"></param>
 /// <returns></returns>
 public virtual BaseForm MoveToForm(Guid guid, long formTypeID)
 {
     BaseForm CurrentForm = null;
     CurrentForm = CreateForm(formTypeID, null);
     MainApplicationContext.MainForm = CurrentForm;
         CurrentForm.SenderGuid = guid;
     DicOfForms[CurrentForm.Guid] = CurrentForm;
     if (sender != null)
     {
         DicOfForms.Remove(guid);
         sender.Close();
     }
     CurrentForm.Show();
     return CurrentForm;
 }*/
 /// <summary>
 /// Создание невидимой формы
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="formTypeID"></param>
 /// <param name="formMessage"></param>
 /// <returns></returns>
 public virtual BaseForm CreateGhostForm(BaseForm sender, long formTypeID, FormMessage formMessage)
 {
     BaseForm CurrentForm = null;
     CurrentForm = CreateForm(formTypeID, formMessage);
     if (sender != null) CurrentForm.SenderGuid = sender.Guid;
     DicOfForms[CurrentForm.Guid] = CurrentForm;
     CurrentForm.Visible = false;
     return CurrentForm;
 }
Exemplo n.º 12
0
 public override BaseForm CreateForm(long formTypeID, FormMessage formMessage)
 {
     var type = GetTypeByID(formTypeID);
     var result = (BaseForm)Activator.CreateInstance(type, this, formMessage);
     result.TypeID = formTypeID;
     return result;
 }
Exemplo n.º 13
0
 public LoginForm(FormFactory currentFormFactory, FormMessage formMessage)
     : base(currentFormFactory)
 {
     InitThisForm(formMessage);
 }
Exemplo n.º 14
0
 public virtual int ReceiveMessage(FormMessage constructorParameter)
 {
     return -1;
 }
Exemplo n.º 15
0
 public AlertForm(FormFactory currentFormFactory, FormMessage someMessage)
     : base(currentFormFactory)
 {
     InitThisForm(someMessage);
 }