internal static void OpenResourcePluginControl(PluginControlBase plugin, ResourceOperateInfo opInfo, ResourceInfo resInfo, Dictionary<string, string> parameter) { if (plugin != null) { plugin.ResourceInfo = resInfo; plugin.ResourceService = Services.ResourceService; plugin.OperateInfo = opInfo; plugin.Parameter = parameter; ZLSoft.BusinessHome.Plugin.SmartForms.SmartForm sf = plugin as ZLSoft.BusinessHome.Plugin.SmartForms.SmartForm; if (sf != null) { //sf.RunTimeInfo.ShowToolBarOnSeperatedForm = true; try { Type t = typeof(ZLSoft.BusinessHome.Plugin.SmartForms.SmartFormRunTimeInfo); PropertyInfo pi = t.GetProperty("ShowToolBarOnSeperatedForm"); if (pi != null) { pi.SetValue(sf.RunTimeInfo, true, null); } } catch { } try { Type t = sf.GetType(); FieldInfo fi = t.GetField("ribbonControl1", BindingFlags.NonPublic | BindingFlags.Instance); if (fi != null) { DevExpress.XtraBars.Ribbon.RibbonControl rc = fi.GetValue(sf) as DevExpress.XtraBars.Ribbon.RibbonControl; if (rc != null) rc.Visible = true; } } catch { } } Form form = CreatePluginForm(plugin.OperateInfo, plugin, "", parameter); form.Show(Program.MainForm); } }
/// <summary> /// ���������� /// </summary> static DevExpress.XtraEditors.XtraForm CreatePluginForm(ResourceOperateInfo opInfo, PluginControlBase pluginControlBase, string pluginName, Dictionary<string, string> parameter) { PluginFormBase form = new PluginFormBase(); KeyValuePair<string, string> info = new KeyValuePair<string, string>(pluginControlBase.HostResourceID, opInfo.ID); form.Tag = info; form.ClientSize = pluginControlBase.Size; form.Controls.Add(pluginControlBase); form.StartPosition = FormStartPosition.CenterScreen; //���ݴ����λ�ã�ע�⣺��������[Dock]����֮ǰ if (pluginControlBase.Location != Point.Empty && !(pluginControlBase.Location.X == 0 && pluginControlBase.Location.Y == 0)) { form.Location = new Point(pluginControlBase.Location.X, pluginControlBase.Location.Y); form.StartPosition = FormStartPosition.Manual; } pluginControlBase.Dock = DockStyle.Fill; try { form.ImeMode = ImeMode.OnHalf; } catch (Exception ex) { ClientLogger.Error("���ô����IMEģʽΪ[ImeMode.OnHalf]ʱ�����" + ex.Message + Environment.NewLine + "������.net FrameWork��2.0sp2���ϰ汾��"); } if (parameter.ContainsKey("TopMost") && !string.IsNullOrEmpty(parameter["TopMost"])) form.TopMost = parameter["TopMost"].ToUpper() == "TRUE"; if (parameter.ContainsKey(AppConst.SmartForm_InputParamKey_WindowsState_Text) && !string.IsNullOrEmpty(parameter[AppConst.SmartForm_InputParamKey_WindowsState_Text])) { SmartFormWindowsState ws = EnumHelper.GetEnumValueByName<SmartFormWindowsState>(parameter[AppConst.SmartForm_InputParamKey_WindowsState_Text]); if (ws == SmartFormWindowsState.ȫ����ʾ) form.WindowState = FormWindowState.Maximized; else if (ws == SmartFormWindowsState.��С����ʾ) form.WindowState = FormWindowState.Minimized; } if (parameter.ContainsKey(AppConst.SmartForm_InputParamKey_FormBorderStyle_Text) && !string.IsNullOrEmpty(parameter[AppConst.SmartForm_InputParamKey_FormBorderStyle_Text])) { SmartFormBorderStyle ws = EnumHelper.GetEnumValueByName<SmartFormBorderStyle>(parameter[AppConst.SmartForm_InputParamKey_FormBorderStyle_Text]); if (ws == SmartFormBorderStyle.�ɵ�����С) form.FormBorderStyle = FormBorderStyle.Sizable; else if (ws == SmartFormBorderStyle.�̶���С) form.FormBorderStyle = FormBorderStyle.FixedSingle; else if (ws == SmartFormBorderStyle.�ޱ߿�) form.FormBorderStyle = FormBorderStyle.None; } string startPosition = string.Empty; if (parameter.ContainsKey(AppConst.SmartForm_InputParamKey_StartPosition_Text) && !string.IsNullOrEmpty(parameter[AppConst.SmartForm_InputParamKey_StartPosition_Text])) { startPosition = parameter[AppConst.SmartForm_InputParamKey_StartPosition_Text].ToString(); if (startPosition == SmartFormStartPosition.��Ļ����.ToString()) { form.StartPosition = FormStartPosition.CenterScreen; } else if (startPosition == SmartFormStartPosition.���������.ToString()) { form.StartPosition = FormStartPosition.CenterParent; } else { form.StartPosition = FormStartPosition.Manual; string strTopLocation = parameter[AppConst.SmartForm_InputParamKey_StartPosition_Text].ToString(); if (!string.IsNullOrEmpty(strTopLocation)) { string[] temps = strTopLocation.Split(','); if (temps.Length > 0) { try { int x = Convert.ToInt32(temps[0]); int y = Convert.ToInt32(temps[1]); int h = Convert.ToInt32(temps[2]); //�ؼ��߶� Point topLocation = new Point(x, y); topLocation.Offset(1, 1); Point bottomLocation = new Point(topLocation.X, topLocation.Y + h); Point location = DevExpress.Utils.ControlUtils.CalcLocation(bottomLocation, topLocation, form.Size); form.Location = location; } catch (Exception ex) { //ClientLogger.Error("ͨ���������ô���[" + pluginName + "]ʱ���õij�ʼλ��ʱ���ַ���[" + DesktopLocation + "]��ת������Чֵ��", ex); } } } } } if (parameter.ContainsKey(AppConst.SmartForm_InputParamKey_ScreenIndex_Text) && !string.IsNullOrEmpty(parameter[AppConst.SmartForm_InputParamKey_ScreenIndex_Text])) { int screenIndex = Convert.ToInt32(parameter[AppConst.SmartForm_InputParamKey_ScreenIndex_Text]); if (screenIndex > 0 && Screen.AllScreens.Length > 1 && screenIndex < Screen.AllScreens.Length) { form.DesktopLocation = Screen.AllScreens[screenIndex].Bounds.Location; form.StartPosition = FormStartPosition.Manual; if (startPosition == SmartFormStartPosition.��Ļ����.ToString() || string.IsNullOrEmpty(startPosition)) { int emptyWidth = Screen.AllScreens[screenIndex].Bounds.Width - form.ClientSize.Width; int emptyHeight = Screen.AllScreens[screenIndex].Bounds.Height - form.ClientSize.Height; form.Location = new Point(form.DesktopLocation.X + (emptyWidth / 2), form.DesktopLocation.Y + (emptyHeight / 2)); } } } if (pluginName == "") { form.Text = pluginControlBase.ResourceInfo.DisplayName; } else { form.Text = pluginName; } form.FormClosing += new FormClosingEventHandler(pluginForm_FormClosing); form.FormClosed += new FormClosedEventHandler(pluginForm_FormClosed); return form; }
internal static void OpenResourcePlugin(string pluginClass, ResourceOperateInfo opInfo, ResourceInfo resInfo, Dictionary<string, string> parameter) { object objPlugin = Helper.CreatePlugin(pluginClass); if (objPlugin == null) return; if (objPlugin is PluginControlBase) { OpenResourcePluginControl(objPlugin as PluginControlBase, opInfo, resInfo, parameter); } else if (objPlugin is PluginFormBase) { PluginFormBase frm = objPlugin as PluginFormBase; frm.ResourceInfo = resInfo; frm.ResourceService = Services.ResourceService; frm.OperateInfo = opInfo; frm.Parameter = parameter; frm.Show(Program.MainForm); } }