/** * Returns all repetitions of Contact Identifiers (CTD-7). */ public PI[] getContactIdentifiers() { PI[] ret = null; try { Type[] t = this.getField(7); ret = new PI[t.Length]; for (int i = 0; i < ret.Length; i++) { ret[i] = (PI)t[i]; } } catch (HL7Exception he) { HapiLogFactory.getHapiLog(this.GetType()).error("Unexpected problem obtaining field value. This is a bug.", he); throw new System.Exception("An unexpected error ocurred", he); } catch (System.Exception cce) { HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", cce); throw new System.Exception("An unexpected error ocurred", cce); } return(ret); }
/// <summary> /// Получить время последнего ввода пользователя /// </summary> /// <returns>Время в миллисекундах</returns> private static uint GetLastInputTime() { uint idleTime = 0; PI.LASTINPUTINFO lastInputInfo = new PI.LASTINPUTINFO(); lastInputInfo.cbSize = (uint)Marshal.SizeOf(lastInputInfo); lastInputInfo.dwTime = 0; uint envTicks = (uint)Environment.TickCount; if (PI.GetLastInputInfo(ref lastInputInfo)) { uint lastInputTick = lastInputInfo.dwTime; idleTime = envTicks - lastInputTick; } return((idleTime > 0) ? idleTime : 0); }
public async void CreateNewPIAction() { PI pi; InputDialog inputDialog = new InputDialog("Ingrese el numero de PI:", ""); if (inputDialog.ShowDialog() == true) { pi = new PI(inputDialog.Answer, DateTime.Now); } else { MessageBox.Show("Se requiere de un numero de PI para continuar", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } WaitPlease w = new WaitPlease(); w.Show(); Response r = await WebService.InsertData(pi, "http://localhost/costs_api/controller/pi/pi.php", PI.DataType.NewPI); w.Close(); if (r != null) { int aux = -1; if (int.TryParse(r.message.ToString(), out aux)) { pi.id = aux; App.Current.Properties["IDPI"] = pi; AddPIInfo p = new AddPIInfo(); p.ShowDialog(); } else { MessageBox.Show("Error, " + r.message); } } else { MessageBox.Show("No se pudo establecer comunicacion con el servidor", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void DoTheBlur() { if (!_blurValues.BlurWhenFocusLost || _parentForm.IsDisposed || _parentForm.Disposing ) { // Has blur been turned off ? return; } _visualBlur = new VisualBlur(_blurValues); Rectangle clientRectangle = CommonHelper.RealClientRectangle(_parentForm.Handle); _visualBlur.SetTargetRect(_parentForm.DesktopLocation, clientRectangle); Rectangle targetRect = _visualBlur.TargetRect; _visualBlur.UpdateBlur(_currentFormDisplay); // As UpdateBlur can take a few moments, then it is possible for the app to be closed before getting to the next line if ((_visualBlur == null) || _parentForm.IsDisposed || _parentForm.Disposing ) { return; } PI.SetWindowPos(_visualBlur.Handle, PI.HWND_TOP, //.HWND_TOPMOST, //PI.SetWindowPos(_visualBlur.Handle, _parentForm.Handle, targetRect.X, targetRect.Y, targetRect.Width, targetRect.Height, PI.SWP_.NOACTIVATE | PI.SWP_.NOREDRAW | PI.SWP_.SHOWWINDOW | PI.SWP_.NOCOPYBITS //| PI.SWP_.NOOWNERZORDER ); // Set parent form opacity afterwards to prevent flicker _parentBeforeOpacity ??= _parentForm.Opacity; _parentForm.Opacity = _blurValues.Opacity / 100.0; _detectIsActiveTimer.Enabled = true; }
static void Main(string[] args) { const double PI = Math.PI; var daysType = typeof(Days); Console.WriteLine("PI Type: " + PI.GetType()); Console.WriteLine("Circumference: " + (PI * 3)); Console.WriteLine("\nFirst Name:" + Days.Sat); Console.WriteLine("\n1st Index: " + (int)Days.Sat); string name = Enum.GetName(daysType, 1); Console.WriteLine("\n2nd Index: " + name); bool flag = Enum.IsDefined(daysType, "Mon"); Console.WriteLine("Contains Mon?: " + flag); Console.ReadKey(); }
static FlashWindowExListener() { int processId = PI.GetCurrentThreadId(); // create an instance of the delegate that // won't be garbage collected to avoid: // Managed Debugging Assistant 'CallbackOnCollectedDelegate' :** // 'A callback was made on a garbage collected delegate of type // 'WpfApp1!WpfApp1.MainWindow+NativeMethods+CBTProc::Invoke'. // This may cause application crashes, corruption and data loss. // When passing delegates to unmanaged code, they must be // kept alive by the managed application until it is guaranteed // that they will never be called.' _hookProc = ShellProc; // we are interested in listening to WH_SHELL events, mainly the HSHELL_REDRAW event. _hHook = PI.SetWindowsHookEx(PI.WH_.SHELL, _hookProc, IntPtr.Zero, processId); Application.ApplicationExit += delegate { PI.UnhookWindowsHookEx(_hHook); }; }
public static bool deviceIsShown = false; // Показано ли окно. /// <summary> /// Показать окно в формой /// </summary> public void ShowDlg() { System.Diagnostics.Process oCurrent = System.Diagnostics.Process.GetCurrentProcess(); // Идентификатор команды вызова окна "Основные данные изделия" const int wndWmCommand = 35357; string windowName = "Основные данные изделия"; if (deviceIsShown == true) { StaticHelper.GUIHelper.ShowHiddenWindow(oCurrent, wndDevVisibilePtr, wndWmCommand); return; } StaticHelper.GUIHelper.SearchWindowDescriptor(oCurrent, windowName, wndWmCommand, ref dialogHandle, ref wndDevVisibilePtr); if (wndDevVisibilePtr != IntPtr.Zero) { StaticHelper.GUIHelper.ShowHiddenWindow(oCurrent, wndDevVisibilePtr, wndWmCommand); StaticHelper.GUIHelper.ChangeWindowMainPanels(ref dialogHandle, ref panelPtr); Controls.Clear(); // Переносим на найденное окно свои элементы (SetParent) и // подгоняем их размеры и позицию. PI.SetParent(devicesTreeViewAdv.Handle, dialogHandle); PI.SetParent(toolStrip.Handle, dialogHandle); ChangeUISize(); // Устанавливаем свой хук для найденного окна // (для изменения размеров своих элементов, сохранения // изменений при закрытии и отключения хука). SetUpHook(); deviceIsShown = true; } }
/// <summary> /// 根据实体类生成SqlParameter集合,用于大量参数(返回自增后的主键时使用) /// </summary> /// <param name="mouob">实体类</param> /// <returns>SqlParameter[]</returns> public static SqlParameter[] ParmsByModuleAddId(object mouob) { PropertyInfo[] Fields = mouob.GetType().GetProperties(); SqlParameter[] parms = new SqlParameter[Fields.Length + 1]; int i = 0; foreach (PropertyInfo PI in Fields) { parms[i] = new SqlParameter(); parms[i].ParameterName = "@" + PI.Name; if (PI.PropertyType == typeof(System.Int32)) { parms[i].SqlDbType = SqlDbType.Int; } else if (PI.PropertyType == typeof(System.String)) { parms[i].SqlDbType = SqlDbType.VarChar; } else if (PI.PropertyType == typeof(System.DateTime)) { parms[i].SqlDbType = SqlDbType.DateTime; } else if (PI.PropertyType == typeof(System.Double)) { parms[i].SqlDbType = SqlDbType.Float; } else if (PI.PropertyType == typeof(System.Boolean)) { parms[i].SqlDbType = SqlDbType.Bit; } parms[i].Value = PI.GetValue(mouob, null); i++; } //插入后自增ID parms[i] = new SqlParameter(); parms[i].ParameterName = "@InsertId"; parms[i].SqlDbType = SqlDbType.Int; parms[i].Value = 0; parms[i].Direction = ParameterDirection.Output; return(parms); }
public static bool ContainsFileDropPaths( IntPtr hwnd = default ) { if( ( hwnd != IntPtr.Zero ) && PI.OpenClipboard( hwnd ) ) { try { for( uint i = PI.EnumClipboardFormats( 0 ); i != 0; i = PI.EnumClipboardFormats( i ) ) { if( i == PI.CF_HDROP ) { return true; } } } finally { PI.CloseClipboard(); } } return false; }
public object GetMocks() { Mocker mock = new Mocker(); List <object> list = new List <object>(); var generatedObject = _builder.CreateDynamicClass(PropertyNames, TypesString); Type TP = generatedObject.GetType(); foreach (PropertyInfo PI in TP.GetProperties()) { var businessObjectPropValue = PI.GetValue(generatedObject, null); PI.SetValue(generatedObject, mock.Name.FirstName(), null); //PI.SetValue("FirstName", mock.Name.FirstName()); list.Add(PI.Name); } //var testEmployee = new MockerGeneric<TempEmployee>() // .Condition(o => o.FirstName, m => m.Name.FirstName()) // .Condition(o => o.LastName, m => m.Name.LastName()) // .Condition(o => o.id, m => m.Random.Number(1, 100)); //var user = testEmployee.Mock(1000); return(generatedObject); }
protected override T PerformInsert <T>(T ValueToInsert) //where T:PersistentBase { Type type = ValueToInsert.GetType(); string TableName = type.GetCustomAttribute <PersistentTableName>().TableName; string query = "INSERT INTO [" + TableName + "]("; string values = " OUTPUT INSERTED.ID VALUES("; bool first = true; int i = 1; SqlCommand tmpCommand = new SqlCommand(); foreach (PropertyInfo PI in type.GetProperties()) { if (!PI.PropertyType.IsArray && PI.Name.ToLower() != "id" && !Attribute.IsDefined(PI, typeof(NonPersistent))) { if (!first) { query += ", "; values += ","; } first = false; query += "[" + PI.Name + "]"; values += "@" + i.ToString(); object val = (PI.GetValue(ValueToInsert)); /*if (val is decimal) * tmpCommand.Parameters.AddWithValue("@"+i++.ToString(), ((decimal)val).ToString("#############00.0000000000#####")); * else*/ tmpCommand.Parameters.AddWithValue("@" + i++.ToString(), val ?? DBNull.Value); } } query += ") "; values += ")"; tmpCommand.CommandText = query + values; tmpCommand.Connection = Connection; ValueToInsert.Id = (int)tmpCommand.ExecuteScalar(); return(ValueToInsert); }
/// <summary> Returns all repetitions of Provider Identifiers (PRD-7).</summary> public virtual PI[] getProviderIdentifiers() { PI[] ret = null; try { Type[] t = this.getField(7); ret = new PI[t.Length]; for (int i = 0; i < ret.Length; i++) { ret[i] = (PI)t[i]; } } catch (System.InvalidCastException) { throw new Exception(); } catch (NuGenHL7Exception) { throw new Exception(); } return(ret); }
/// <summary> /// Show the window relative to provided screen rectangle. /// </summary> /// <param name="screenRect">Screen rectangle.</param> public void ShowRelative(Rectangle screenRect) { // Find screen middle points int yMid = screenRect.Y + (screenRect.Height / 2); int xMid = screenRect.X + (screenRect.Width / 2); // Find docking size middle points int yHalf = _dragData.DockWindowSize.Height / 2; int xHalf = _dragData.DockWindowSize.Width / 2; Point location; if (_dragData.ShowLeft && !_dragData.ShowRight && !_dragData.ShowMiddle && !_dragData.ShowTop && !_dragData.ShowBottom) { location = new Point(screenRect.Left + 10, yMid - yHalf); } else if (!_dragData.ShowLeft && _dragData.ShowRight && !_dragData.ShowMiddle && !_dragData.ShowTop && !_dragData.ShowBottom) { location = new Point(screenRect.Right - _dragData.DockWindowSize.Width - 10, yMid - yHalf); } else if (!_dragData.ShowLeft && !_dragData.ShowRight && !_dragData.ShowMiddle && _dragData.ShowTop && !_dragData.ShowBottom) { location = new Point(xMid - xHalf, screenRect.Top + 10); } else if (!_dragData.ShowLeft && !_dragData.ShowRight && !_dragData.ShowMiddle && !_dragData.ShowTop && _dragData.ShowBottom) { location = new Point(xMid - xHalf, screenRect.Bottom - _dragData.DockWindowSize.Height - 10); } else { location = new Point(xMid - xHalf, yMid - yHalf); } // Update the image for display UpdateLayeredWindow(new Rectangle(location, _showRect.Size)); // Show the window without activating it (i.e. do not take focus) PI.ShowWindow(Handle, PI.ShowWindowCommands.SW_SHOWNOACTIVATE); }
private bool compare(Virus a, Virus b) { var virusAprop = typeof(Virus).GetProperties(); foreach (PropertyInfo PI in virusAprop) { //object? is een var die null mag zijn object?valueA = PI.GetValue(a); object?valueB = PI.GetValue(b); if (PI.PropertyType.Name == "double") {// als double afronden valueA = Math.Round((double)PI.GetValue(a), 1); valueB = Math.Round((double)PI.GetValue(b), 1); } if (valueA != valueB) { return(false); } } return(true); }
//установить данные объекта для модификации БД public bool SetDataForModify(ApplicationContext db, RowContainer RC, DataProvider ParentNode) { int nSetVal = 0; RC.ValueCellContainer.ForEach(Cell => { foreach (PropertyInfo PI in GetType().GetProperties()) { //перебор атрибутов (false - без родителей) foreach (ColumnAttribute Column in PI.GetCustomAttributes <ColumnAttribute>(false)) { //поиск по имени атрибута if (Column.headerPropName == Cell.CI.headerPropName) { //установить значение свойства PI.SetValue(this, Cell.value); nSetVal++; } } } }); if (RC.ValueCellContainer.Count != nSetVal) { return(false); } //установить специфические данные для строки таблицы bool bSet = SetSecificDataForModify(db, ParentNode); if (!bSet) { return(false); } return(true); }
public override void OnInteract() { if (!PI.IsFull()) { if (hasRandom) { randomItem = Random.Range(0, item.Count); PI.Add(item[randomItem]); } else { PI.Add(item[0]); } Cleared(); gameObject.SetActive(false); Invoke("reset", ResetTime); } else if (PI.IsFull()) { EM.InventoryFull(); } }
public void SubmittedByCustomerToProgressAllowed_ByCaseOfficer() { //Get The Additional Information Object AdditionalInformation_ProgressAllowed AdditionalInformation = new AdditionalInformation_ProgressAllowed((int)BOPermitInfo.PermitStatusTypes.ProgressAllowed); Assert.IsTrue(Common.IsInRole(_ssoCaseOfficerUserId, Common.RolesList.CaseOfficer), "You need to change your Role in SSO to be a Case Officer"); GetPermitInfo(); PI.PermitStatus = new BO.ReferenceData.BOPermitStatus((int)BOPermitInfo.PermitStatusTypes.SubmittedByCustomer); PI.AssignedTo = new BO.ReferenceData.BOStatusAssignedToGroup((int)Common.AssignedToList.CaseOfficer); PI.Save(_ssoCaseOfficerUserId); Console.WriteLine("Saved PI"); bool Success = BOPermitInfo.ChangeStatus(PI.PermitInfoId, (int)Common.AssignedToList.CaseOfficer, _ssoCaseOfficerUserId, AdditionalInformation); Assert.IsTrue(Success, "Status change Failed"); PI = new uk.gov.defra.Phoenix.BO.Application.BOPermitInfo(5); Assert.IsTrue((PI.AssignedTo.ID == (int)Common.AssignedToList.CaseOfficer && PI.PermitStatus.ID == (int)BOPermitInfo.PermitStatusTypes.ProgressAllowed), "State Has not Changed Correctly"); }
/// <summary> /// Enumerates the properties of an object (of a type it supports). /// </summary> /// <param name="Object">Object</param> /// <returns>Property enumeration as a script element.</returns> public IElement EnumerateProperties(object Object) { List <IElement> Elements = new List <IElement>(); Type T = Object.GetType(); foreach (PropertyInfo PI in T.GetRuntimeProperties()) { if (PI.GetIndexParameters().Length > 0) { continue; } Elements.Add(new StringValue(PI.Name)); Elements.Add(Expression.Encapsulate(PI.GetValue(Object))); } ObjectMatrix M = new ObjectMatrix(Elements.Count / 2, 2, Elements) { ColumnNames = new string[] { "Name", "Value" } }; return(M); }
internal void WndProc(ref Message m) { switch (m.Msg) { case PI.WM_.ACTIVATE: if ((PI.LOWORD(m.WParam) == 0) && // WA_INACTIVE (PI.HIWORD(m.WParam) == 0) ) { if (_blurValues.BlurWhenFocusLost || (Form.ActiveForm != null) ) { DoTheBlur(); } } else { RemoveBlur(); } break; } }
private double CalculateNOfX(double x) { if (x < 0) { return(1 - (CalculateNOfX(-x))); } const double alpha = 0.2316419; const double a1 = 0.31938153; const double a2 = -0.356563782; const double a3 = 1.781477937; const double a4 = -1.821255978; const double a5 = 1.330274429; double k = 1.0 / (1.0 + alpha * x); double nX1 = (Exp(-(x * x / 2))) / Sqrt((2 * Convert.ToDouble(PI.ToString(CultureInfo.InvariantCulture)))); double result = 1 - (nX1 * (a1 * k + a2 * k * k + a3 * k * k * k + a4 * Pow(k, 4.0) + a5 * Pow(k, 5.0))); return(result); }
protected override T PerformUpdate <T>(T ValueToUpdate)// where T : PersistentBase { if (ValueToUpdate.Id <= 0) { return(PerformInsert <T>(ValueToUpdate)); } Type type = ValueToUpdate.GetType(); string TableName = type.GetCustomAttribute <PersistentTableName>().TableName; string query = "UPDATE [" + TableName + "] set"; bool first = true; int i = 1; MySqlCommand tmpCommand = new MySqlCommand(); foreach (PropertyInfo PI in type.GetProperties()) { if (!PI.PropertyType.IsArray && PI.Name.ToLower() != "id") { if (!first) { query += ", "; } first = false; query += "[" + PI.Name + "] = @" + i.ToString(); tmpCommand.Parameters.AddWithValue("@" + i++.ToString(), PI.GetValue(ValueToUpdate)); } } query += " WHERE [" + TableName + "].Id = @" + i.ToString(); tmpCommand.Parameters.AddWithValue("@" + i++.ToString(), ValueToUpdate.Id); tmpCommand.CommandText = query; //tmpCommand.Connection = SqlConnection //Set sql connection here ValueToUpdate.Id = (int)tmpCommand.ExecuteScalar(); return(ValueToUpdate); }
private void OnRibbonMdiChildActivate(object sender, EventArgs e) { // Cast to correct type Form topForm = sender as Form; // Unhook from watching any previous mdi child if (_activeMdiChild != null) { _activeMdiChild.SizeChanged -= OnRibbonMdiChildSizeChanged; } _activeMdiChild = topForm.ActiveMdiChild; // Start watching any new mdi child if (_activeMdiChild != null) { _activeMdiChild.SizeChanged += OnRibbonMdiChildSizeChanged; } // Update the pendant buttons with reference to new child _buttonSpecClose.MdiChild = _activeMdiChild; _buttonSpecRestore.MdiChild = _activeMdiChild; _buttonSpecMin.MdiChild = _activeMdiChild; ButtonSpecManager.RecreateButtons(); PerformNeedPaint(true); // We never want the mdi child window to have a system menu, we provide the // pendant buttons as part of the ribbon and so replace the need for it. PI.SetMenu(new HandleRef(_ribbon, topForm.Handle), NullHandleRef); if (_activeMdiChild != null) { uint windowStyle = PI.GetWindowLong(_activeMdiChild.Handle, PI.GWL_.STYLE); windowStyle |= PI.WS_.SYSMENU; PI.SetWindowLong(_activeMdiChild.Handle, PI.GWL_.STYLE, windowStyle); } }
/// <summary> /// Should a mouse down at the provided point cause an end to popup tracking. /// </summary> /// <param name="m">Original message.</param> /// <param name="pt">Client coordinates point.</param> /// <returns>True to end tracking; otherwise false.</returns> public virtual bool DoesCurrentMouseDownEndAllTracking(Message m, Point pt) { bool endTracking = !ClientRectangle.Contains(pt); // The mouse is not over our client area but the focus is if (endTracking && ContainsFocus) { // Get the window handle of the window under this screen point Point screenPt = PointToScreen(pt); PI.POINT screenPIPt = new PI.POINT { X = screenPt.X, Y = screenPt.Y }; IntPtr hWnd = PI.WindowFromPoint(screenPIPt); // Assuming we got back a valid window handle if (hWnd != IntPtr.Zero) { StringBuilder className = new StringBuilder(256); int length = PI.GetClassName(hWnd, className, className.Capacity); // If we got back a valid name if (length > 0) { // If let the message occur as it is being pressed on a combo box // drop down list and so it will process the message appropriately if (className.ToString() == "ComboLBox") { endTracking = false; } } } } return(endTracking); }
private void UpdateRepoItemGuids(RepositoryItemBase item, List <GuidMapper> guidMappingList) { foreach (FieldInfo PI in item.GetType().GetFields()) { var token = PI.GetCustomAttribute(typeof(IsSerializedForLocalRepositoryAttribute)); if (token == null) { continue; } // we drill down to ObservableList if (typeof(IObservableList).IsAssignableFrom(PI.FieldType)) { IObservableList obj = (IObservableList)PI.GetValue(item); if (obj == null) { return; } List <object> items = ((IObservableList)obj).ListItems; if ((items != null) && (items.Count > 0) && (items[0].GetType().IsSubclassOf(typeof(RepositoryItemBase)))) { foreach (RepositoryItemBase ri in items.Cast <RepositoryItemBase>()) { GuidMapper mapping = new GuidMapper(); mapping.Original = ri.Guid; ri.Guid = Guid.NewGuid(); mapping.newGuid = ri.Guid; guidMappingList.Add(mapping); UpdateRepoItemGuids(ri, guidMappingList); } } } } }
/// <summary> /// Поиск закрепленного представления окна в процессе. /// </summary> /// <param name="currentProcess">Текущий процесс</param> /// <param name="stringBuffer">Буфер</param> /// <param name="windowName">Имя окна</param> /// <param name="dialogHandle">Handle диалога выходной</param> /// <param name="wndVisiblePtr">Найденный дескриптор окна</param> private static void SearchStaticWindow(Process currentProcess, StringBuilder stringBuffer, string windowName, ref IntPtr dialogHandle, ref IntPtr wndVisiblePtr) { List <IntPtr> resW = PI.GetChildWindows(currentProcess.MainWindowHandle); foreach (IntPtr panel in resW) { PI.GetWindowText(panel, stringBuffer, stringBuffer.Capacity); if (stringBuffer.ToString().Contains(windowName) == true) { if (PI.IsWindowVisible(panel) == true) { var resList = PI.GetChildWindows(panel); if (resList.Count > 0) { dialogHandle = resList[0]; wndVisiblePtr = dialogHandle; break; } } } } }
/// <summary> /// Заменить панели заданного окна. /// </summary> /// <param name="dialogHandle">Дескриптор нового диалога</param> /// <param name="panelPtr">Дескриптор старого диалога</param> public static void ChangeWindowMainPanels(ref IntPtr dialogHandle, ref IntPtr panelPtr) { var panelList = PI.GetChildWindows(dialogHandle); if (panelList.Count > 0) { panelPtr = panelList[0]; } if (panelPtr == IntPtr.Zero) { MessageBox.Show("Не удалось скрыть окно!"); return; } // Проверка, скрыт ли элемент управления с редактором. if (PI.IsWindowVisible(dialogHandle) == false) { PI.ShowWindow(dialogHandle, 1); } PI.ShowWindow(panelPtr, 0); }
/// <summary> /// Internals the show. /// </summary> /// <param name="owner">The owner.</param> /// <param name="messageContent">Content of the message.</param> /// <param name="caption">The caption.</param> /// <param name="iconVisibility">The icon visibility.</param> /// <param name="borderType">Type of the border.</param> /// <param name="buttonCount">The button count.</param> /// <param name="buttons">The buttons.</param> /// <param name="options">The options.</param> /// <param name="helpInfo">The help information.</param> /// <param name="defaultButton">The default button.</param> /// <param name="icon">The icon.</param> /// <param name="result">The result.</param> /// <param name="buttonTextCollection">The button text collection.</param> /// <param name="customIcon">The custom icon.</param> /// <returns></returns> /// <exception cref="InvalidOperationException">Cannot show modal dialog when non-interactive</exception> /// <exception cref="ArgumentException"> /// Cannot show message box from a service with an owner specified - options /// or /// Cannot show message box from a service with help specified - options /// </exception> private static KryptonMessageBoxExtendedResult InternalShow(IWin32Window owner, string messageContent, string caption, KryptonMessageBoxExtendedApplicationIconVisibility iconVisibility, KryptonMessageBoxExtendedBorderType borderType, KryptonMessageBoxExtendedBoxButtonCount buttonCount, KryptonMessageBoxExtendedButtons buttons, KryptonMessageBoxExtendedBoxOptions options, HelpInformation helpInfo = null, KryptonMessageBoxExtendedDefaultButton defaultButton = KryptonMessageBoxExtendedDefaultButton.BUTTON1, KryptonMessageBoxExtendedIcon icon = KryptonMessageBoxExtendedIcon.NONE, string[] buttonTextCollection = null, string checkBoxText = null, Image customIcon = null) // KryptonMessageBoxExtendedResult result = KryptonMessageBoxExtendedResult.OK, { // Check if trying to show a message box from a non-interactive process, this is not possible if (!SystemInformation.UserInteractive && ((options & (KryptonMessageBoxExtendedBoxOptions.SERVICENOTIFICATION | KryptonMessageBoxExtendedBoxOptions.DEFAULTDESKTOPONLY)) == 0)) { throw new InvalidOperationException("Cannot show modal dialog when non-interactive"); } // Check if trying to show a message box from a service and the owner has been specified, this is not possible if ((owner != null) && ((options & (KryptonMessageBoxExtendedBoxOptions.SERVICENOTIFICATION | KryptonMessageBoxExtendedBoxOptions.DEFAULTDESKTOPONLY)) != 0)) { throw new ArgumentException(@"Cannot show message box from a service with an owner specified", nameof(options)); } // Check if trying to show a message box from a service and help information is specified, this is not possible if ((helpInfo != null) && ((options & (KryptonMessageBoxExtendedBoxOptions.SERVICENOTIFICATION | KryptonMessageBoxExtendedBoxOptions.DEFAULTDESKTOPONLY)) != 0)) { throw new ArgumentException(@"Cannot show message box from a service with help specified", nameof(options)); } // If help information provided or we are not a service/default desktop application then grab an owner for showing the message box IWin32Window showOwner = null; if ((helpInfo != null) || ((options & (KryptonMessageBoxExtendedBoxOptions.SERVICENOTIFICATION | KryptonMessageBoxExtendedBoxOptions.DEFAULTDESKTOPONLY)) == 0)) { // If do not have an owner passed in then get the active window and use that instead showOwner = owner ?? FromHandle(PI.GetActiveWindow()); } using (ExtendedKryptonMessageboxOld ekmb = new ExtendedKryptonMessageboxOld(showOwner, messageContent, caption, iconVisibility, borderType, buttonCount, buttons, options, helpInfo, defaultButton, icon, buttonTextCollection, checkBoxText, customIcon)) { ekmb.StartPosition = showOwner == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent; return(ekmb.ShowDialogExtended(showOwner)); } }
internal void UpdateObjectFromPayLoad(NewPayLoad PL, Attribute attr) { List <PropertyInfo> list = GetProperties(attr); //TODO: unpack the Payload and update the obj foreach (PropertyInfo PI in list) { object v = PI.GetValue(mObj); if (PI.PropertyType.IsEnum) { string s = PL.GetValueEnum(); object o = Enum.Parse(PI.PropertyType, s); PI.SetValue(mObj, o); } else if (v is IObservableList) { List <NewPayLoad> lst = PL.GetListPayLoad(); foreach (NewPayLoad PL1 in lst) { ObjectReflectionHelper ORH1 = new ObjectReflectionHelper(); ORH1.CreateObjectFromPayLoad(PL1, attr); ((IObservableList)v).Add(ORH1.obj); } } else if (PI.PropertyType.Name == "String") { string s = PL.GetValueString(); PI.SetValue(mObj, s); } else { throw new Exception("Unknown type to handle - " + PI.PropertyType); } } }
public ActionResult Uploaded() { if (TempData["fileName"] != null && TempData["DepartmentID"] != null) { string fileName = (string)TempData["fileName"]; int DepartmentID = (int)TempData["DepartmentID"]; var engine = new FileHelperEngine <PIVM>(); var records = engine.ReadFile(fileName); int LOId; foreach (var rec in records) { LOId = db.LOs.Where(x => x.DepartmentID == DepartmentID && x.LearningOutcome == rec.SO).FirstOrDefault().LOID; var pi = new PI() { LOID = LOId, PILetter = rec.PI, PIDesc = rec.desc, PINo = rec.Number }; db.PIs.Add(pi); db.SaveChanges(); } return(View(records)); } return(View()); }
/// <summary> /// Draw text without a glowing background, for use on a composition element. /// </summary> /// <param name="g">Graphics reference.</param> /// <param name="text">Text to be drawn.</param> /// <param name="font">Font to use for text.</param> /// <param name="bounds">Bounding area for the text.</param> /// <param name="state">State of the source element.</param> /// <param name="color"><see cref="Color"/> of the text.</param> /// <param name="copyBackground">Should existing background be copied into the bitmap.</param> /// <param name="sf">StringFormat of the memento.</param> public static void DrawCompositionText(Graphics g, string text, Font font, Rectangle bounds, PaletteState state, Color color, bool copyBackground, StringFormat sf) { // Get the hDC for the graphics instance and create a memory DC IntPtr gDC = g.GetHdc(); try { IntPtr mDC = PI.CreateCompatibleDC(gDC); PI.BITMAPINFO bmi = new() { biWidth = bounds.Width, biHeight = -bounds.Height, biCompression = 0, biBitCount = 32, biPlanes = 1 }; bmi.biSize = (uint)Marshal.SizeOf(bmi); // Create a device independent bitmap and select into the memory DC IntPtr hDIB = PI.CreateDIBSection(gDC, ref bmi, 0, out _, IntPtr.Zero, 0); PI.SelectObject(mDC, hDIB); if (copyBackground) { // Copy existing background into the bitmap PI.BitBlt(mDC, 0, 0, bounds.Width, bounds.Height, gDC, bounds.X, bounds.Y, 0x00CC0020); } // Select the font for use when drawing IntPtr hFont = font.ToHfont(); PI.SelectObject(mDC, hFont); // Get renderer for the correct state VisualStyleRenderer renderer = new(state == PaletteState.Normal ? VisualStyleElement.Window.Caption.Active : VisualStyleElement.Window.Caption.Inactive); // Create structures needed for theme drawing call PI.RECT textBounds = new() { left = 0, top = 0, right = bounds.Right - bounds.Left, bottom = bounds.Bottom - bounds.Top }; PI.DTTOPTS dttOpts = new() { dwSize = Marshal.SizeOf(typeof(PI.DTTOPTS)), dwFlags = PI.DTT_COMPOSITED | PI.DTT_TEXTCOLOR, crText = ColorTranslator.ToWin32(color) }; // Always draw text centered TextFormatFlags textFormat = TextFormatFlags.SingleLine | TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter; ////Seb | TextFormatFlags.EndEllipsis; // Perform actual drawing //PI.DrawThemeTextEx(renderer.Handle, // mDC, 0, 0, // text, -1, (int)StringFormatToFlags(sf), // ref textBounds, ref dttOpts); PI.DrawThemeTextEx(renderer.Handle, mDC, 0, 0, text, -1, (int)textFormat, ref textBounds, ref dttOpts); // Copy to foreground PI.BitBlt(gDC, bounds.Left, bounds.Top, bounds.Width, bounds.Height, mDC, 0, 0, 0x00CC0020); // Dispose of allocated objects PI.DeleteObject(hFont); PI.DeleteObject(hDIB); PI.DeleteDC(mDC); } catch { // ignored } finally { // Must remember to release the hDC g.ReleaseHdc(gDC); } }
public int CompareTo(PI b) { return first * b.second - second * b.first; }