public virtual DesignElement GetDesignTypeForComponent(Component component) { var de = DesignElement.None; var ctl = component as Control; if (ctl != null) { if (ctl.GetType().DeclaringType != null && ctl.GetType().DeclaringType != GetType()) { return(de); } if (TranslationToolHelperWinClient.IsSelectableControl(ctl)) { if (ctl is XtraTabControl) { de = de | DesignElement.Moving; } else { de = de | DesignElement.Sizing | DesignElement.Moving; } } if (TranslationToolHelperWinClient.IsEditableControl(ctl)) { de = de | DesignElement.Caption; } } else if (component is GridColumn || component is GridBand || component is TreeListColumn || component is NavBarGroup || component is LayoutControlItem) { de = de | DesignElement.Caption; } return(de); }
public override void ApplyResources(string cultureCode) { ResourcesList.Clear(); foreach (Control ctl in Controls) { var action = ctl.Tag as ActionMetaItem; if (action != null) { string s = action.CaptionId(BusinessObject, Permissions); var resValue = CommonResourcesCache.Get(CommonResource.BvMessages.ToString(), cultureCode, s, GetViewNameForSplittedResources()); var propName = TranslationToolHelper.GetPropertyName(ctl.Name, TranslationToolHelper.TextPropName); if (resValue == null && Messages != null) { resValue = CommonResourcesCache.Get(Messages.GetType().Name, cultureCode, s, GetViewNameForSplittedResources()); } if (resValue != null) { ResourcesList.Add(propName, resValue); ctl.Text = resValue.Value.ToString(); if (!EditableControlsList.ContainsKey(propName)) { EditableControlsList.Add(propName, ctl); } } } else if (BasePanel != null && !(ctl is TranslationButton)) { TranslationToolHelperWinClient.ApplyResources(ctl, BasePanel as ITranslationView, cultureCode); } } }
public void RefreshPropertiesGrid(ControlDesigner sourceControl) { SourceControl = sourceControl; var control = SourceControl.RealControl; Model = new ControlModel { X = control.Location.X, Y = control.Location.Y, Width = control.Size.Width, Height = control.Size.Height, CanCaptionChange = TranslationToolHelperWinClient.IsEditableControl(control) }; if (Model.CanCaptionChange) { Model.OldCaption = Model.Caption = TranslationToolHelperWinClient.GetComponentText(control); } else { rowCaption.Visible = false; } if (SourceControl.MovingEnabled) { Model.OldLocation = control.Location; } else { categoryLocation.Visible = false; } if (SourceControl.SizingEnabled) { Model.OldSize = control.Size; } else { categorySize.Visible = false; } //we create a list with all menu items if (control is PopUpButton) { var pb = (PopUpButton)control; foreach (BarButtonItemLink action in pb.PopupActions.ItemLinks) { Model.MenuItems.Add(action.Item.Caption); } categoryMenuItems.Visible = true; } else { categoryMenuItems.Visible = false; } propGrid.SelectedObject = Model; }
private void RestoreControlState(UndoControlState state) { var elem = state.Element; var ctl = elem as Control; if (ctl != null && (state.Operation & UndoOperation.Position) != 0) { ctl.SuspendLayout(); ctl.SetBounds(state.Bounds.X, state.Bounds.Y, state.Bounds.Width, state.Bounds.Height); ctl.ResumeLayout(); } if ((state.Operation & UndoOperation.Text) != 0) { TranslationToolHelperWinClient.SetComponentText(elem, state.Caption); } if (ctl != null && (state.Operation & UndoOperation.Visibility) != 0) { ctl.Visible = state.Visible; } if (state.RelatedChanges != null && state.RelatedChanges.Length > 0) { foreach (var change in state.RelatedChanges) { RestoreControlState(change); } } }
public override bool SaveChanges(Dictionary <object, DesignElement> changes, string cultureCode) { try { var captionChange = changes.First(c => c.Key == this.CaptionLabel); if (!captionChange.Equals(null)) { ParentBasePanel.Caption = CaptionLabel.Text; var tmpChanges = new Dictionary <object, DesignElement> { { ParentBasePanel, DesignElement.Caption } }; TranslationToolHelperWinClient.SaveViewChanges(ParentBasePanel as ITranslationView, tmpChanges, cultureCode); changes.Remove(captionChange.Key); } ((ITranslationView)panelMain.Controls[0]).SaveChanges(changes, cultureCode); ((ITranslationView)panelBottom.Controls[0]).SaveChanges(changes, cultureCode); return(true); } catch (Exception ex) { Dbg.Debug("error during translation saving", ex); return(false); } }
/// <summary> /// Проставляет нужное текстовое свойство в зависимости от типа контрола /// </summary> /// <param name="control"></param> /// <param name="caption"></param> /// <param name="editedObject"> </param> public static void SetControlText(Control control, string caption, object editedObject = null) { var proxy = control as ControlDesignerProxy; if (proxy != null) { SetControlText(proxy.HostControl, caption, editedObject); return; } TranslationToolHelperWinClient.SetComponentText(editedObject ?? control, caption); }
public override bool SaveChanges(Dictionary <object, DesignElement> changes, string cultureCode) { bool res = TranslationToolHelperWinClient.SaveViewChanges(this, CommonResource.BvMessages.ToString(), changes, cultureCode, false); if (res && Messages != null) { res = TranslationToolHelperWinClient.SaveViewChanges(this, Messages.GetType().Name, changes, cultureCode, false); } //if (res && BasePanel!=null) // res = TranslationToolHelperWinClient.SaveViewChanges(BasePanel as ITranslationView, BasePanel.GetType().Name, changes, cultureCode, false); return(res); }
private void OnThisSizeChanged(object sender, EventArgs e) { if (m_HostControl != null) { if (m_HostControl is PopupContainerEdit && TranslationToolHelperWinClient.IsLookupControl(m_HostControl.Parent)) { m_HostControl.Parent.Size = Size; } else { m_HostControl.Size = Size; } } }
public virtual string GetResourceNameForComponent(Component component, DesignElement designType) { if ((designType & DesignElement.Caption) != 0 && ExclusionsList.ContainsKey(component)) { return(ExclusionsList[component].Resource.ToString()); } var propName = GetKeyForComponent(component, designType); Type declaringType = TranslationToolHelperWinClient.GetControlViewDeclaringType(component, propName); if (declaringType != null) { return(declaringType.Name); } return(GetType().Name); }
private static Control GetRealControl(Control ctl) { var proxy = ctl as ControlDesignerProxy; if (proxy != null) { if (TranslationToolHelperWinClient.IsLookupControl(proxy.HostControl) && ReflectionHelper.HasProperty(proxy.HostControl, "PopupEdit", BindingFlags.NonPublic | BindingFlags.Instance)) { var c = ReflectionHelper.GetProperty(proxy.HostControl, "PopupEdit", BindingFlags.NonPublic | BindingFlags.Instance); if (c != null) { return((Control)c); } } return(proxy.HostControl); } return(ctl); }
public override bool SaveChanges(Dictionary <object, DesignElement> changes, string cultureCode) { try { var captionChange = changes.FirstOrDefault(c => c.Key == ngSearchPanel); if (!captionChange.Equals(null)) { TranslationToolHelperWinClient.SaveViewChanges(this, changes, cultureCode); } ((ITranslationView)panelMain.Controls[0]).SaveChanges(changes, cultureCode); ((ITranslationView)panelBottom.Controls[0]).SaveChanges(changes, cultureCode); return(base.SaveChanges(changes, cultureCode)); } catch (Exception ex) { Dbg.Debug("error during translation saving", ex); return(false); } }
public virtual bool SaveChanges(Dictionary <object, DesignElement> changes, string cultureCode) { return(TranslationToolHelperWinClient.SaveViewChanges(this, changes, cultureCode)); }
public virtual void ApplyResources(string cultureCode) { TranslationToolHelperWinClient.ApplyViewResources(this, cultureCode); }
public virtual string GetKeyForComponent(Component component, DesignElement designType) { return(TranslationToolHelperWinClient.GetPropertyNameForComponent(component, designType)); }
public override bool SaveChanges(Dictionary <object, DesignElement> changes, string cultureCode) { bool res = TranslationToolHelperWinClient.SaveViewChanges(this, CommonResource.EidssFields.ToString(), changes, cultureCode, false); return(res); }
private void AddTranslateBarItem(BarItemLinkCollection collection, BarManager manager) { var bi = new BarButtonItem(manager, "Translate"); m_TranslateButtons.Add(bi); bi.ItemClick += TranslationBarItem_Click; bi.Tag = collection; foreach (BarItemLink il in collection) { var action = il.Item.Tag as MenuAction; if (action != null) { if (string.IsNullOrEmpty(il.Item.Name)) { il.Item.Name = GetUniqueMenuName(); } m_View.ExclusionsList.Add(il.Item, new ExclusionItem() { Resource = CommonResource.EidssMenu, Disabled = false, Keys = new[] { action.ResourceKey }, Source = ExclusionSource.MenuAction }); var propName = TranslationToolHelperWinClient.GetPropertyNameForComponent(il.Item, DesignElement.Caption); string englishCaption; if (action.ItemsStorage != null) { englishCaption = action.ItemsStorage.GetString(action.ResourceKey, null, Localizer.lngEn); } else { englishCaption = il.Caption; } if (m_View.ResourcesList.ContainsKey(propName)) { m_View.ResourcesList[propName].EnglishText = englishCaption; m_View.ResourcesList[propName].ResourceName = CommonResource.EidssMenu.ToString(); m_View.ResourcesList[propName].SourceKey = action.ResourceKey; m_View.ResourcesList[propName].Value = il.Caption; } else { m_View.ResourcesList.Add(propName, new ResourceValue() { EnglishText = englishCaption, ResourceName = CommonResource.EidssMenu.ToString(), SourceKey = action.ResourceKey, Value = il.Caption }); } } var bsi = il.Item as BarSubItem; if (bsi == null) { il.Item.Enabled = false; continue; } AddTranslateBarItem(bsi.ItemLinks, manager); } collection.Add(bi); }