//============================================================ // <T>加载所有目录。</T> //============================================================ public virtual void LoadFolderAll() { // 加载所有子目录 foreach (string path in RDirectory.ListDirectories(_directory)) { // 跳过SVN目录 if (path.IndexOf(".svn") != -1) { continue; } // 加载子目录 OnLoadFolder(path); } if (_folders != null) { _folders.Sort(); } // 加载配置 if (RFile.Exists(ConfigFileName)) { FXmlDocument xdoc = new FXmlDocument(); try { xdoc.LoadFile(ConfigFileName); } catch (Exception e) { throw new FFatalException(e, "Open config file error. (file_name={0})", ConfigFileName); } LoadConfig(xdoc.Root); } }
//============================================================ // <T>设计对齐处理。</T> // // @param alignCd 对齐方式 // @param step 间隔 //============================================================ public void DesignAlign(int alignCd, int step) { // 检查变量 if (!HasFocusControl()) { return; } if (!HasSelectControl()) { return; } // 获得焦点对象 int left = _focusControl.Location.X; int right = _focusControl.Location.X + _focusControl.Size.Width; int hmiddle = (left + right) / 2; int top = _focusControl.Location.Y; int bottom = _focusControl.Location.Y + _focusControl.Size.Height; int vmiddle = (top + bottom) / 2; // 控件集合处理 int count = Count; FObjects <FUiControl> controls = new FObjects <FUiControl>(); controls.Assign(this); if (alignCd == EUiDesignAlign.HorizontalAvg) { if (count > 3) { controls.Sort(new FUiControlLocationComparer(EUiControlLocation.X, true)); int firstX = controls.First.CenterX; int lastX = controls.Last.CenterX; int stepX = (lastX - firstX) / (count - 1); for (int n = 0; n < count; n++) { FUiControl control = controls.Get(n); control.CenterX = firstX + stepX * n; } } } else if (alignCd == EUiDesignAlign.HorizontalAvgSize) { if (count > 3) { controls.Sort(new FUiControlLocationComparer(EUiControlLocation.X, true)); int x = controls.First.Location.X; for (int n = 0; n < count; n++) { FUiControl control = controls.Get(n); control.Location.X = x; x += control.Size.Width + step; } } } else if (alignCd == EUiDesignAlign.VerticalAvg) { if (count > 3) { controls.Sort(new FUiControlLocationComparer(EUiControlLocation.Y, true)); int firstY = controls.First.CenterY; int lastY = controls.Last.CenterY; int stepY = (lastY - firstY) / (count - 1); for (int n = 0; n < count; n++) { FUiControl control = controls.Get(n); control.CenterY = firstY + stepY * n; } } } else if (alignCd == EUiDesignAlign.VerticalAvgSize) { if (count > 3) { controls.Sort(new FUiControlLocationComparer(EUiControlLocation.Y, true)); int y = controls.First.Location.Y; for (int n = 0; n < count; n++) { FUiControl control = controls.Get(n); control.Location.Y = y; y += control.Size.Height + step; } } } else { // 处理其他情况 foreach (FUiControl control in this) { // 检查控件 if (control == _focusControl) { continue; } // 对齐处理 switch (alignCd) { case EUiDesignAlign.Center: control.Location.X = hmiddle - (control.Size.Width >> 1); control.Location.Y = vmiddle - (control.Size.Height >> 1); break; case EUiDesignAlign.Left: control.Location.X = left; break; case EUiDesignAlign.HorizontalMiddle: control.Location.X = hmiddle - (control.Size.Width >> 1); break; case EUiDesignAlign.Right: control.Location.X = right - control.Size.Width; break; case EUiDesignAlign.Top: control.Location.Y = top; break; case EUiDesignAlign.VerticalMiddle: control.Location.Y = vmiddle - (control.Size.Height >> 1); break; case EUiDesignAlign.Bottom: control.Location.Y = bottom - control.Size.Height; break; } } } }