private void InitThisForm(FormMessage someMessage) { formMessage = someMessage; Presenter = new EnslaverFrontEnd.Presenters.LoginFormPresenter(this); InitializeComponent(); TryRaiseEvent(Init, EventArgs.Empty); }
public BaseForm(FormMessage constructorParameter) { if (constructorParameter != null) { this.SenderGuid = constructorParameter.SenderGuid; } }
/// <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"); }
public AdminForm(FormFactory currentFormFactory, FormMessage someMessage) : base(currentFormFactory) { InitForm(someMessage); }
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); }
public MainForm(FormFactory currentFormFactory, FormMessage formMessage) { InitThisForm(); }
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); } }
/// <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; }
/// <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; } }
/// <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; }
/* /// <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; }
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; }
public LoginForm(FormFactory currentFormFactory, FormMessage formMessage) : base(currentFormFactory) { InitThisForm(formMessage); }
public virtual int ReceiveMessage(FormMessage constructorParameter) { return -1; }
public AlertForm(FormFactory currentFormFactory, FormMessage someMessage) : base(currentFormFactory) { InitThisForm(someMessage); }